From 48f5fd9660a58bf2d89387f25cf4b7c8573fb756 Mon Sep 17 00:00:00 2001 From: Ray Essick Date: Wed, 2 May 2018 10:47:09 -0700 Subject: [PATCH] Import xHE-AAC decoder from Ittiam Clean copy of version XHEAAC_V1_36 as delivered 2018/4/13 Sole change is to map cr/lf line termination to unix lf. Added appropriate LICENSE, MODULE_LICENSE_APACHE2, and NOTICE files as part of folding into internal master. Bug: 77287124 Test: CTS audio/media Change-Id: I3c8d124033f967b29d6e384cce5c843ee17a7bb1 --- Android.bp | 293 + LICENSE | 203 + MODULE_LICENSE_APACHE2 | 0 NOTICE | 19 + decoder/armv7/ia_xheaacd_mps_mulshift.s | 46 + .../ia_xheaacd_mps_reoder_mulshift_acc.s | 240 + decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s | 50 + decoder/armv7/ixheaacd_apply_rot.s | 229 + decoder/armv7/ixheaacd_apply_scale_fac.s | 147 + decoder/armv7/ixheaacd_auto_corr.s | 155 + decoder/armv7/ixheaacd_autocorr_st2.s | 403 ++ decoder/armv7/ixheaacd_basic_op.h | 79 + decoder/armv7/ixheaacd_basic_ops16.h | 403 ++ decoder/armv7/ixheaacd_basic_ops32.h | 516 ++ decoder/armv7/ixheaacd_basic_ops40.h | 400 ++ decoder/armv7/ixheaacd_calc_post_twid.s | 109 + decoder/armv7/ixheaacd_calc_pre_twid.s | 107 + decoder/armv7/ixheaacd_calcmaxspectralline.s | 82 + decoder/armv7/ixheaacd_complex_fft_p2.s | 809 +++ decoder/armv7/ixheaacd_complex_ifft_p2.s | 809 +++ decoder/armv7/ixheaacd_conv_ergtoamplitude.s | 132 + .../armv7/ixheaacd_conv_ergtoamplitudelp.s | 148 + decoder/armv7/ixheaacd_cos_sin_mod.s | 472 ++ decoder/armv7/ixheaacd_dct3_32.s | 506 ++ decoder/armv7/ixheaacd_dec_DCT2_64_asm.s | 522 ++ decoder/armv7/ixheaacd_decorr_filter2.s | 1071 ++++ .../ixheaacd_eld_decoder_sbr_pre_twiddle.s | 67 + .../armv7/ixheaacd_enery_calc_per_subband.s | 158 + .../armv7/ixheaacd_esbr_cos_sin_mod_loop1.s | 172 + .../armv7/ixheaacd_esbr_cos_sin_mod_loop2.s | 180 + decoder/armv7/ixheaacd_esbr_fwd_modulation.s | 111 + decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s | 409 ++ decoder/armv7/ixheaacd_esbr_radix4bfly.s | 154 + decoder/armv7/ixheaacd_expsubbandsamples.s | 113 + decoder/armv7/ixheaacd_ffr_divide16.s | 49 + decoder/armv7/ixheaacd_fft32x32_ld.s | 860 +++ decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s | 373 ++ decoder/armv7/ixheaacd_fft_15_ld.s | 516 ++ decoder/armv7/ixheaacd_fft_armv7.c | 89 + .../ixheaacd_function_selector_arm_non_neon.c | 185 + .../armv7/ixheaacd_function_selector_armv7.c | 249 + decoder/armv7/ixheaacd_fwd_modulation.s | 102 + decoder/armv7/ixheaacd_harm_idx_zerotwolp.s | 109 + decoder/armv7/ixheaacd_imdct_using_fft.s | 825 +++ decoder/armv7/ixheaacd_inv_dit_fft_8pt.s | 163 + decoder/armv7/ixheaacd_lap1.s | 113 + .../armv7/ixheaacd_mps_complex_fft_64_asm.s | 694 +++ decoder/armv7/ixheaacd_mps_synt_out_calc.s | 55 + .../ixheaacd_mps_synt_post_fft_twiddle.s | 65 + .../armv7/ixheaacd_mps_synt_post_twiddle.s | 60 + decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s | 60 + decoder/armv7/ixheaacd_no_lap1.s | 110 + decoder/armv7/ixheaacd_overlap_add1.s | 297 + decoder/armv7/ixheaacd_overlap_add2.s | 268 + decoder/armv7/ixheaacd_post_radix_compute2.s | 144 + decoder/armv7/ixheaacd_post_radix_compute4.s | 138 + decoder/armv7/ixheaacd_post_twiddle.s | 545 ++ decoder/armv7/ixheaacd_post_twiddle_overlap.s | 1277 +++++ decoder/armv7/ixheaacd_pre_twiddle_compute.s | 388 ++ decoder/armv7/ixheaacd_qmf_dec.c | 1282 +++++ decoder/armv7/ixheaacd_radix4_bfly.s | 149 + .../armv7/ixheaacd_rescale_subbandsamples.s | 205 + decoder/armv7/ixheaacd_sbr_imdct_using_fft.s | 855 +++ .../armv7/ixheaacd_sbr_qmfanal32_winadds.s | 265 + .../ixheaacd_sbr_qmfanal32_winadds_eld.s | 245 + decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s | 379 ++ decoder/armv7/ixheaacd_shiftrountine.s | 105 + .../ixheaacd_shiftrountine_with_rnd_eld.s | 92 + .../armv7/ixheaacd_shiftrountine_with_round.s | 111 + .../ixheaacd_shiftrountine_with_round_hq.s | 75 + .../ixheaacd_tns_ar_filter_fixed_32x16.s | 272 + decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s | 122 + decoder/armv8/ixheaacd_apply_scale_factors.s | 166 + decoder/armv8/ixheaacd_basic_op.h | 99 + decoder/armv8/ixheaacd_basic_ops16.h | 397 ++ decoder/armv8/ixheaacd_basic_ops32.h | 598 ++ decoder/armv8/ixheaacd_basic_ops40.h | 439 ++ decoder/armv8/ixheaacd_calcmaxspectralline.s | 82 + decoder/armv8/ixheaacd_cos_sin_mod_loop1.s | 231 + decoder/armv8/ixheaacd_cos_sin_mod_loop2.s | 213 + decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s | 555 ++ .../armv8/ixheaacd_function_selector_armv8.c | 248 + decoder/armv8/ixheaacd_imdct_using_fft.s | 819 +++ decoder/armv8/ixheaacd_inv_dit_fft_8pt.s | 174 + decoder/armv8/ixheaacd_no_lap1.s | 123 + decoder/armv8/ixheaacd_overlap_add1.s | 333 ++ decoder/armv8/ixheaacd_overlap_add2.s | 305 + decoder/armv8/ixheaacd_post_twiddle.s | 713 +++ decoder/armv8/ixheaacd_postradixcompute4.s | 148 + decoder/armv8/ixheaacd_pre_twiddle.s | 512 ++ decoder/armv8/ixheaacd_qmf_dec.c | 2415 ++++++++ decoder/armv8/ixheaacd_sbr_imdct_using_fft.s | 777 +++ .../armv8/ixheaacd_sbr_qmf_analysis32_neon.s | 341 ++ decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s | 403 ++ .../armv8/ixheaacd_shiftrountine_with_round.s | 73 + .../ixheaacd_shiftrountine_with_round_eld.s | 79 + decoder/drc_src/impd_apicmd_standards.h | 106 + decoder/drc_src/impd_drc_api.c | 699 +++ decoder/drc_src/impd_drc_api_defs.h | 51 + decoder/drc_src/impd_drc_api_struct_def.h | 130 + decoder/drc_src/impd_drc_bitbuffer.c | 291 + decoder/drc_src/impd_drc_bitbuffer.h | 53 + decoder/drc_src/impd_drc_bitstream_dec_api.h | 63 + decoder/drc_src/impd_drc_common.h | 221 + decoder/drc_src/impd_drc_config_params.h | 42 + decoder/drc_src/impd_drc_dec.c | 378 ++ decoder/drc_src/impd_drc_dec.h | 54 + decoder/drc_src/impd_drc_definitions.h | 38 + decoder/drc_src/impd_drc_dynamic_payload.c | 1527 +++++ decoder/drc_src/impd_drc_eq.c | 1554 +++++ decoder/drc_src/impd_drc_eq.h | 196 + decoder/drc_src/impd_drc_error_codes.h | 59 + .../drc_src/impd_drc_extr_delta_coded_info.c | 113 + .../drc_src/impd_drc_extr_delta_coded_info.h | 88 + decoder/drc_src/impd_drc_fiilter_bank.c | 505 ++ decoder/drc_src/impd_drc_filter_bank.c | 505 ++ decoder/drc_src/impd_drc_filter_bank.h | 165 + decoder/drc_src/impd_drc_gain_dec.c | 752 +++ decoder/drc_src/impd_drc_gain_dec.h | 97 + decoder/drc_src/impd_drc_gain_decoder.c | 498 ++ decoder/drc_src/impd_drc_gain_decoder.h | 107 + decoder/drc_src/impd_drc_hashdefines.h | 30 + decoder/drc_src/impd_drc_host_params.c | 160 + decoder/drc_src/impd_drc_host_params.h | 38 + decoder/drc_src/impd_drc_init.c | 573 ++ decoder/drc_src/impd_drc_interface.h | 132 + decoder/drc_src/impd_drc_interface_decoder.c | 57 + decoder/drc_src/impd_drc_interface_parser.c | 515 ++ decoder/drc_src/impd_drc_loud_eq.c | 191 + decoder/drc_src/impd_drc_loudness_control.c | 987 ++++ decoder/drc_src/impd_drc_loudness_control.h | 107 + decoder/drc_src/impd_drc_main_qmf_process.c | 237 + decoder/drc_src/impd_drc_main_stft_process.c | 232 + decoder/drc_src/impd_drc_main_td_process.c | 312 + .../drc_src/impd_drc_main_td_qmf_process.c | 371 ++ decoder/drc_src/impd_drc_multi_band.h | 72 + decoder/drc_src/impd_drc_multiband.c | 186 + decoder/drc_src/impd_drc_parametric_dec.c | 1031 ++++ decoder/drc_src/impd_drc_parser.h | 109 + decoder/drc_src/impd_drc_parser_interface.h | 56 + decoder/drc_src/impd_drc_peak_limiter.c | 193 + decoder/drc_src/impd_drc_peak_limiter.h | 57 + .../drc_src/impd_drc_peak_limiter_struct.h | 50 + decoder/drc_src/impd_drc_process.c | 557 ++ decoder/drc_src/impd_drc_process_audio.h | 98 + decoder/drc_src/impd_drc_qmf_filter.h | 40 + decoder/drc_src/impd_drc_rom.c | 1291 +++++ decoder/drc_src/impd_drc_rom.h | 156 + .../drc_src/impd_drc_sel_proc_drc_set_sel.h | 184 + decoder/drc_src/impd_drc_selection_process.c | 1101 ++++ decoder/drc_src/impd_drc_selection_process.h | 190 + ...d_drc_selection_process_drcset_selection.c | 1537 +++++ .../drc_src/impd_drc_selection_process_init.c | 336 ++ decoder/drc_src/impd_drc_shape_filter.c | 265 + decoder/drc_src/impd_drc_static_payload.c | 2550 +++++++++ decoder/drc_src/impd_drc_struct.h | 660 +++ decoder/drc_src/impd_drc_tables.c | 120 + decoder/drc_src/impd_drc_tables.h | 42 + .../drc_src/impd_drc_uni_bitstream_dec_api.h | 64 + decoder/drc_src/impd_drc_uni_common.h | 169 + decoder/drc_src/impd_drc_uni_dec.h | 44 + decoder/drc_src/impd_drc_uni_eq.h | 49 + decoder/drc_src/impd_drc_uni_gain_dec.h | 136 + decoder/drc_src/impd_drc_uni_interface.h | 116 + decoder/drc_src/impd_drc_uni_loud_eq.h | 32 + decoder/drc_src/impd_drc_uni_multi_band.h | 72 + decoder/drc_src/impd_drc_uni_parser.h | 107 + decoder/drc_src/impd_drc_uni_process_audio.h | 59 + .../impd_drc_uni_sel_proc_drc_set_sel.h | 145 + decoder/drc_src/impd_drc_uni_sel_proc_init.h | 42 + .../impd_drc_uni_sel_proc_loudness_control.h | 90 + decoder/drc_src/impd_drc_uni_shape_filter.h | 25 + decoder/drc_src/impd_drc_uni_tables.h | 92 + decoder/drc_src/impd_error_handler.h | 94 + decoder/drc_src/impd_error_standards.h | 40 + decoder/drc_src/impd_memory_standards.h | 109 + decoder/drc_src/impd_parametric_drc_dec.h | 198 + decoder/drc_src/impd_type_def.h | 114 + decoder/ixheaacd_Windowing.c | 104 + decoder/ixheaacd_aac_config.h | 60 + decoder/ixheaacd_aac_imdct.c | 2812 +++++++++ decoder/ixheaacd_aac_imdct.h | 132 + decoder/ixheaacd_aac_rom.c | 2265 ++++++++ decoder/ixheaacd_aac_rom.h | 173 + decoder/ixheaacd_aac_tns.c | 452 ++ decoder/ixheaacd_aacdec.h | 88 + decoder/ixheaacd_aacdecoder.c | 886 +++ decoder/ixheaacd_aacpluscheck.c | 164 + decoder/ixheaacd_acelp_bitparse.c | 560 ++ decoder/ixheaacd_acelp_com.h | 68 + decoder/ixheaacd_acelp_decode.c | 597 ++ decoder/ixheaacd_acelp_info.h | 59 + decoder/ixheaacd_acelp_mdct.c | 246 + decoder/ixheaacd_acelp_tools.c | 208 + decoder/ixheaacd_adts.h | 46 + decoder/ixheaacd_adts_crc_check.c | 210 + decoder/ixheaacd_adts_crc_check.h | 31 + decoder/ixheaacd_api.c | 2618 +++++++++ decoder/ixheaacd_api_defs.h | 39 + decoder/ixheaacd_apicmd_standards.h | 84 + decoder/ixheaacd_arith_dec.c | 2122 +++++++ decoder/ixheaacd_arith_dec.h | 35 + decoder/ixheaacd_audioobjtypes.h | 66 + decoder/ixheaacd_avq_dec.c | 294 + decoder/ixheaacd_avq_rom.c | 1227 ++++ decoder/ixheaacd_basic_funcs.c | 191 + decoder/ixheaacd_basic_funcs.h | 56 + decoder/ixheaacd_basic_ops.c | 607 ++ decoder/ixheaacd_basic_ops.h | 137 + decoder/ixheaacd_basic_ops16.h | 331 ++ decoder/ixheaacd_basic_ops32.h | 478 ++ decoder/ixheaacd_basic_ops40.h | 366 ++ decoder/ixheaacd_basic_ops_arr.h | 425 ++ decoder/ixheaacd_bit_extract.h | 89 + decoder/ixheaacd_bitbuffer.c | 281 + decoder/ixheaacd_bitbuffer.h | 136 + decoder/ixheaacd_block.c | 1310 +++++ decoder/ixheaacd_block.h | 189 + decoder/ixheaacd_channel.c | 1153 ++++ decoder/ixheaacd_channel.h | 63 + decoder/ixheaacd_channelinfo.h | 341 ++ decoder/ixheaacd_cnst.h | 120 + decoder/ixheaacd_common_initfuncs.c | 186 + decoder/ixheaacd_common_lpfuncs.c | 368 ++ decoder/ixheaacd_common_rom.c | 351 ++ decoder/ixheaacd_common_rom.h | 47 + decoder/ixheaacd_config.h | 662 +++ decoder/ixheaacd_constants.h | 75 + decoder/ixheaacd_create.c | 697 +++ decoder/ixheaacd_create.h | 49 + decoder/ixheaacd_dec_main.h | 31 + decoder/ixheaacd_decode_main.c | 211 + decoder/ixheaacd_defines.h | 62 + decoder/ixheaacd_definitions.h | 56 + decoder/ixheaacd_drc_data_struct.h | 93 + decoder/ixheaacd_drc_dec.h | 43 + decoder/ixheaacd_drc_freq_dec.c | 1082 ++++ decoder/ixheaacd_dsp_fft32x32s.c | 117 + decoder/ixheaacd_dsp_fft32x32s.h | 29 + decoder/ixheaacd_env_calc.c | 1829 ++++++ decoder/ixheaacd_env_calc.h | 191 + decoder/ixheaacd_env_dec.c | 799 +++ decoder/ixheaacd_env_dec.h | 68 + decoder/ixheaacd_env_extr.c | 1724 ++++++ decoder/ixheaacd_env_extr.h | 185 + decoder/ixheaacd_env_extr_part.h | 107 + decoder/ixheaacd_error_codes.h | 114 + decoder/ixheaacd_error_handler.h | 58 + decoder/ixheaacd_error_standards.h | 29 + decoder/ixheaacd_esbr_envcal.c | 960 ++++ decoder/ixheaacd_esbr_fft.c | 1217 ++++ decoder/ixheaacd_esbr_polyphase.c | 246 + decoder/ixheaacd_esbr_rom.c | 2609 +++++++++ decoder/ixheaacd_esbr_rom.h | 61 + decoder/ixheaacd_ext_ch_ele.c | 911 +++ decoder/ixheaacd_fft.c | 1776 ++++++ decoder/ixheaacd_freq_sca.c | 592 ++ decoder/ixheaacd_freq_sca.h | 32 + decoder/ixheaacd_func_def.h | 98 + decoder/ixheaacd_function_selector.h | 199 + decoder/ixheaacd_fwd_alias_cnx.c | 200 + decoder/ixheaacd_hbe_trans.c | 1580 ++++++ decoder/ixheaacd_hcr.h | 44 + decoder/ixheaacd_headerdecode.c | 1129 ++++ decoder/ixheaacd_headerdecode.h | 71 + decoder/ixheaacd_huff_code_reorder.c | 1872 ++++++ decoder/ixheaacd_huff_tools.c | 110 + decoder/ixheaacd_hufftables.c | 81 + decoder/ixheaacd_hybrid.c | 285 + decoder/ixheaacd_hybrid.h | 45 + decoder/ixheaacd_imdct.c | 549 ++ decoder/ixheaacd_info.h | 109 + decoder/ixheaacd_init_config.c | 559 ++ decoder/ixheaacd_initfuncs.c | 492 ++ decoder/ixheaacd_interface.h | 116 + decoder/ixheaacd_intrinsics.h | 26 + decoder/ixheaacd_latmdemux.c | 313 + decoder/ixheaacd_latmdemux.h | 65 + decoder/ixheaacd_longblock.c | 314 + decoder/ixheaacd_lpc.c | 720 +++ decoder/ixheaacd_lpc_dec.c | 244 + decoder/ixheaacd_lpfuncs.c | 829 +++ decoder/ixheaacd_lpp_tran.c | 1131 ++++ decoder/ixheaacd_lpp_tran.h | 106 + decoder/ixheaacd_lt_predict.c | 523 ++ decoder/ixheaacd_lt_predict.h | 54 + decoder/ixheaacd_main.h | 230 + decoder/ixheaacd_memory_standards.h | 107 + decoder/ixheaacd_mps_dec.c | 1522 +++++ decoder/ixheaacd_mps_dec.h | 390 ++ decoder/ixheaacd_mps_decor.h | 35 + decoder/ixheaacd_mps_decorr.c | 259 + decoder/ixheaacd_mps_huff_tab.h | 95 + decoder/ixheaacd_mps_hybfilter.h | 36 + decoder/ixheaacd_mps_hybrid_filt.c | 293 + decoder/ixheaacd_mps_interface.h | 34 + decoder/ixheaacd_mps_nlc_dec.h | 60 + decoder/ixheaacd_mps_parse.c | 1059 ++++ decoder/ixheaacd_mps_poly_filt.c | 192 + decoder/ixheaacd_mps_polyphase.h | 38 + decoder/ixheaacd_mps_pre_mix.c | 691 +++ decoder/ixheaacd_mps_process.h | 33 + decoder/ixheaacd_mps_rom.c | 5030 +++++++++++++++++ decoder/ixheaacd_mps_smoothing.c | 213 + decoder/ixheaacd_mps_temp_process.c | 241 + decoder/ixheaacd_mps_temp_reshape.c | 194 + decoder/ixheaacd_multichannel.c | 404 ++ decoder/ixheaacd_multichannel.h | 39 + decoder/ixheaacd_pns.h | 52 + decoder/ixheaacd_pns_js_thumb.c | 441 ++ decoder/ixheaacd_pred_vec_block.c | 239 + decoder/ixheaacd_process.c | 419 ++ decoder/ixheaacd_process.h | 29 + decoder/ixheaacd_ps_bitdec.c | 278 + decoder/ixheaacd_ps_bitdec.h | 33 + decoder/ixheaacd_ps_dec.c | 990 ++++ decoder/ixheaacd_ps_dec.h | 182 + decoder/ixheaacd_pulsedata.h | 41 + decoder/ixheaacd_pvc_dec.h | 55 + decoder/ixheaacd_pvc_rom.c | 616 ++ decoder/ixheaacd_pvc_rom.h | 53 + decoder/ixheaacd_qmf_dec.c | 2803 +++++++++ decoder/ixheaacd_qmf_dec.h | 181 + decoder/ixheaacd_qmf_poly.h | 44 + decoder/ixheaacd_rev_vlc.c | 1769 ++++++ decoder/ixheaacd_rom.c | 4295 ++++++++++++++ decoder/ixheaacd_rvlc.h | 20 + decoder/ixheaacd_sbr_common.h | 25 + decoder/ixheaacd_sbr_const.h | 242 + decoder/ixheaacd_sbr_crc.c | 97 + decoder/ixheaacd_sbr_crc.h | 30 + decoder/ixheaacd_sbr_dec.c | 1243 ++++ decoder/ixheaacd_sbr_dec.h | 237 + decoder/ixheaacd_sbr_payload.h | 34 + decoder/ixheaacd_sbr_rom.c | 2428 ++++++++ decoder/ixheaacd_sbr_rom.h | 180 + decoder/ixheaacd_sbr_scale.h | 33 + decoder/ixheaacd_sbrdec_initfuncs.c | 1153 ++++ decoder/ixheaacd_sbrdec_lpfuncs.c | 1248 ++++ decoder/ixheaacd_sbrdecoder.c | 731 +++ decoder/ixheaacd_sbrdecoder.h | 81 + decoder/ixheaacd_sbrdecsettings.h | 85 + decoder/ixheaacd_sbrqmftrans.h | 39 + decoder/ixheaacd_spectrum_dec.c | 447 ++ decoder/ixheaacd_stereo.c | 204 + decoder/ixheaacd_stereo.h | 35 + decoder/ixheaacd_struct.h | 63 + decoder/ixheaacd_struct_def.h | 290 + decoder/ixheaacd_tcx_fwd_alcnx.c | 389 ++ decoder/ixheaacd_tcx_fwd_mdct.c | 254 + decoder/ixheaacd_td_mdct.h | 31 + decoder/ixheaacd_thumb_ps_dec.c | 169 + decoder/ixheaacd_tns.c | 313 + decoder/ixheaacd_tns.h | 81 + decoder/ixheaacd_tns_usac.h | 49 + decoder/ixheaacd_type_def.h | 107 + decoder/ixheaacd_vec_baisc_ops.h | 61 + decoder/ixheaacd_ver_number.h | 26 + decoder/ixheaacd_windows.h | 62 + decoder/x86/ixheaacd_basic_op.h | 28 + decoder/x86/ixheaacd_function_selector_x86.c | 248 + decoder/x86_64/ixheaacd_basic_op.h | 28 + .../ixheaacd_function_selector_x86_64.c | 248 + test/Android.bp | 31 + test/impd_drc_config_params.h | 58 + test/ixheaacd_error.c | 325 ++ test/ixheaacd_fileifc.c | 172 + test/ixheaacd_fileifc.h | 81 + test/ixheaacd_main.c | 2247 ++++++++ test/ixheaacd_main_flush_csd.c | 2477 ++++++++ test/ixheaacd_metadata_read.c | 202 + test/ixheaacd_metadata_read.h | 58 + 372 files changed, 148215 insertions(+) create mode 100644 Android.bp create mode 100644 LICENSE create mode 100644 MODULE_LICENSE_APACHE2 create mode 100644 NOTICE create mode 100644 decoder/armv7/ia_xheaacd_mps_mulshift.s create mode 100644 decoder/armv7/ia_xheaacd_mps_reoder_mulshift_acc.s create mode 100644 decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s create mode 100644 decoder/armv7/ixheaacd_apply_rot.s create mode 100644 decoder/armv7/ixheaacd_apply_scale_fac.s create mode 100644 decoder/armv7/ixheaacd_auto_corr.s create mode 100644 decoder/armv7/ixheaacd_autocorr_st2.s create mode 100644 decoder/armv7/ixheaacd_basic_op.h create mode 100644 decoder/armv7/ixheaacd_basic_ops16.h create mode 100644 decoder/armv7/ixheaacd_basic_ops32.h create mode 100644 decoder/armv7/ixheaacd_basic_ops40.h create mode 100644 decoder/armv7/ixheaacd_calc_post_twid.s create mode 100644 decoder/armv7/ixheaacd_calc_pre_twid.s create mode 100644 decoder/armv7/ixheaacd_calcmaxspectralline.s create mode 100644 decoder/armv7/ixheaacd_complex_fft_p2.s create mode 100644 decoder/armv7/ixheaacd_complex_ifft_p2.s create mode 100644 decoder/armv7/ixheaacd_conv_ergtoamplitude.s create mode 100644 decoder/armv7/ixheaacd_conv_ergtoamplitudelp.s create mode 100644 decoder/armv7/ixheaacd_cos_sin_mod.s create mode 100644 decoder/armv7/ixheaacd_dct3_32.s create mode 100644 decoder/armv7/ixheaacd_dec_DCT2_64_asm.s create mode 100644 decoder/armv7/ixheaacd_decorr_filter2.s create mode 100644 decoder/armv7/ixheaacd_eld_decoder_sbr_pre_twiddle.s create mode 100644 decoder/armv7/ixheaacd_enery_calc_per_subband.s create mode 100644 decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop1.s create mode 100644 decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop2.s create mode 100644 decoder/armv7/ixheaacd_esbr_fwd_modulation.s create mode 100644 decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s create mode 100644 decoder/armv7/ixheaacd_esbr_radix4bfly.s create mode 100644 decoder/armv7/ixheaacd_expsubbandsamples.s create mode 100644 decoder/armv7/ixheaacd_ffr_divide16.s create mode 100644 decoder/armv7/ixheaacd_fft32x32_ld.s create mode 100644 decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s create mode 100644 decoder/armv7/ixheaacd_fft_15_ld.s create mode 100644 decoder/armv7/ixheaacd_fft_armv7.c create mode 100644 decoder/armv7/ixheaacd_function_selector_arm_non_neon.c create mode 100644 decoder/armv7/ixheaacd_function_selector_armv7.c create mode 100644 decoder/armv7/ixheaacd_fwd_modulation.s create mode 100644 decoder/armv7/ixheaacd_harm_idx_zerotwolp.s create mode 100644 decoder/armv7/ixheaacd_imdct_using_fft.s create mode 100644 decoder/armv7/ixheaacd_inv_dit_fft_8pt.s create mode 100644 decoder/armv7/ixheaacd_lap1.s create mode 100644 decoder/armv7/ixheaacd_mps_complex_fft_64_asm.s create mode 100644 decoder/armv7/ixheaacd_mps_synt_out_calc.s create mode 100644 decoder/armv7/ixheaacd_mps_synt_post_fft_twiddle.s create mode 100644 decoder/armv7/ixheaacd_mps_synt_post_twiddle.s create mode 100644 decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s create mode 100644 decoder/armv7/ixheaacd_no_lap1.s create mode 100644 decoder/armv7/ixheaacd_overlap_add1.s create mode 100644 decoder/armv7/ixheaacd_overlap_add2.s create mode 100644 decoder/armv7/ixheaacd_post_radix_compute2.s create mode 100644 decoder/armv7/ixheaacd_post_radix_compute4.s create mode 100644 decoder/armv7/ixheaacd_post_twiddle.s create mode 100644 decoder/armv7/ixheaacd_post_twiddle_overlap.s create mode 100644 decoder/armv7/ixheaacd_pre_twiddle_compute.s create mode 100644 decoder/armv7/ixheaacd_qmf_dec.c create mode 100644 decoder/armv7/ixheaacd_radix4_bfly.s create mode 100644 decoder/armv7/ixheaacd_rescale_subbandsamples.s create mode 100644 decoder/armv7/ixheaacd_sbr_imdct_using_fft.s create mode 100644 decoder/armv7/ixheaacd_sbr_qmfanal32_winadds.s create mode 100644 decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s create mode 100644 decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s create mode 100644 decoder/armv7/ixheaacd_shiftrountine.s create mode 100644 decoder/armv7/ixheaacd_shiftrountine_with_rnd_eld.s create mode 100644 decoder/armv7/ixheaacd_shiftrountine_with_round.s create mode 100644 decoder/armv7/ixheaacd_shiftrountine_with_round_hq.s create mode 100644 decoder/armv7/ixheaacd_tns_ar_filter_fixed_32x16.s create mode 100644 decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s create mode 100644 decoder/armv8/ixheaacd_apply_scale_factors.s create mode 100644 decoder/armv8/ixheaacd_basic_op.h create mode 100644 decoder/armv8/ixheaacd_basic_ops16.h create mode 100644 decoder/armv8/ixheaacd_basic_ops32.h create mode 100644 decoder/armv8/ixheaacd_basic_ops40.h create mode 100644 decoder/armv8/ixheaacd_calcmaxspectralline.s create mode 100644 decoder/armv8/ixheaacd_cos_sin_mod_loop1.s create mode 100644 decoder/armv8/ixheaacd_cos_sin_mod_loop2.s create mode 100644 decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s create mode 100644 decoder/armv8/ixheaacd_function_selector_armv8.c create mode 100644 decoder/armv8/ixheaacd_imdct_using_fft.s create mode 100644 decoder/armv8/ixheaacd_inv_dit_fft_8pt.s create mode 100644 decoder/armv8/ixheaacd_no_lap1.s create mode 100644 decoder/armv8/ixheaacd_overlap_add1.s create mode 100644 decoder/armv8/ixheaacd_overlap_add2.s create mode 100644 decoder/armv8/ixheaacd_post_twiddle.s create mode 100644 decoder/armv8/ixheaacd_postradixcompute4.s create mode 100644 decoder/armv8/ixheaacd_pre_twiddle.s create mode 100644 decoder/armv8/ixheaacd_qmf_dec.c create mode 100644 decoder/armv8/ixheaacd_sbr_imdct_using_fft.s create mode 100644 decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s create mode 100644 decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s create mode 100644 decoder/armv8/ixheaacd_shiftrountine_with_round.s create mode 100644 decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s create mode 100644 decoder/drc_src/impd_apicmd_standards.h create mode 100644 decoder/drc_src/impd_drc_api.c create mode 100644 decoder/drc_src/impd_drc_api_defs.h create mode 100644 decoder/drc_src/impd_drc_api_struct_def.h create mode 100644 decoder/drc_src/impd_drc_bitbuffer.c create mode 100644 decoder/drc_src/impd_drc_bitbuffer.h create mode 100644 decoder/drc_src/impd_drc_bitstream_dec_api.h create mode 100644 decoder/drc_src/impd_drc_common.h create mode 100644 decoder/drc_src/impd_drc_config_params.h create mode 100644 decoder/drc_src/impd_drc_dec.c create mode 100644 decoder/drc_src/impd_drc_dec.h create mode 100644 decoder/drc_src/impd_drc_definitions.h create mode 100644 decoder/drc_src/impd_drc_dynamic_payload.c create mode 100644 decoder/drc_src/impd_drc_eq.c create mode 100644 decoder/drc_src/impd_drc_eq.h create mode 100644 decoder/drc_src/impd_drc_error_codes.h create mode 100644 decoder/drc_src/impd_drc_extr_delta_coded_info.c create mode 100644 decoder/drc_src/impd_drc_extr_delta_coded_info.h create mode 100644 decoder/drc_src/impd_drc_fiilter_bank.c create mode 100644 decoder/drc_src/impd_drc_filter_bank.c create mode 100644 decoder/drc_src/impd_drc_filter_bank.h create mode 100644 decoder/drc_src/impd_drc_gain_dec.c create mode 100644 decoder/drc_src/impd_drc_gain_dec.h create mode 100644 decoder/drc_src/impd_drc_gain_decoder.c create mode 100644 decoder/drc_src/impd_drc_gain_decoder.h create mode 100644 decoder/drc_src/impd_drc_hashdefines.h create mode 100644 decoder/drc_src/impd_drc_host_params.c create mode 100644 decoder/drc_src/impd_drc_host_params.h create mode 100644 decoder/drc_src/impd_drc_init.c create mode 100644 decoder/drc_src/impd_drc_interface.h create mode 100644 decoder/drc_src/impd_drc_interface_decoder.c create mode 100644 decoder/drc_src/impd_drc_interface_parser.c create mode 100644 decoder/drc_src/impd_drc_loud_eq.c create mode 100644 decoder/drc_src/impd_drc_loudness_control.c create mode 100644 decoder/drc_src/impd_drc_loudness_control.h create mode 100644 decoder/drc_src/impd_drc_main_qmf_process.c create mode 100644 decoder/drc_src/impd_drc_main_stft_process.c create mode 100644 decoder/drc_src/impd_drc_main_td_process.c create mode 100644 decoder/drc_src/impd_drc_main_td_qmf_process.c create mode 100644 decoder/drc_src/impd_drc_multi_band.h create mode 100644 decoder/drc_src/impd_drc_multiband.c create mode 100644 decoder/drc_src/impd_drc_parametric_dec.c create mode 100644 decoder/drc_src/impd_drc_parser.h create mode 100644 decoder/drc_src/impd_drc_parser_interface.h create mode 100644 decoder/drc_src/impd_drc_peak_limiter.c create mode 100644 decoder/drc_src/impd_drc_peak_limiter.h create mode 100644 decoder/drc_src/impd_drc_peak_limiter_struct.h create mode 100644 decoder/drc_src/impd_drc_process.c create mode 100644 decoder/drc_src/impd_drc_process_audio.h create mode 100644 decoder/drc_src/impd_drc_qmf_filter.h create mode 100644 decoder/drc_src/impd_drc_rom.c create mode 100644 decoder/drc_src/impd_drc_rom.h create mode 100644 decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h create mode 100644 decoder/drc_src/impd_drc_selection_process.c create mode 100644 decoder/drc_src/impd_drc_selection_process.h create mode 100644 decoder/drc_src/impd_drc_selection_process_drcset_selection.c create mode 100644 decoder/drc_src/impd_drc_selection_process_init.c create mode 100644 decoder/drc_src/impd_drc_shape_filter.c create mode 100644 decoder/drc_src/impd_drc_static_payload.c create mode 100644 decoder/drc_src/impd_drc_struct.h create mode 100644 decoder/drc_src/impd_drc_tables.c create mode 100644 decoder/drc_src/impd_drc_tables.h create mode 100644 decoder/drc_src/impd_drc_uni_bitstream_dec_api.h create mode 100644 decoder/drc_src/impd_drc_uni_common.h create mode 100644 decoder/drc_src/impd_drc_uni_dec.h create mode 100644 decoder/drc_src/impd_drc_uni_eq.h create mode 100644 decoder/drc_src/impd_drc_uni_gain_dec.h create mode 100644 decoder/drc_src/impd_drc_uni_interface.h create mode 100644 decoder/drc_src/impd_drc_uni_loud_eq.h create mode 100644 decoder/drc_src/impd_drc_uni_multi_band.h create mode 100644 decoder/drc_src/impd_drc_uni_parser.h create mode 100644 decoder/drc_src/impd_drc_uni_process_audio.h create mode 100644 decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h create mode 100644 decoder/drc_src/impd_drc_uni_sel_proc_init.h create mode 100644 decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h create mode 100644 decoder/drc_src/impd_drc_uni_shape_filter.h create mode 100644 decoder/drc_src/impd_drc_uni_tables.h create mode 100644 decoder/drc_src/impd_error_handler.h create mode 100644 decoder/drc_src/impd_error_standards.h create mode 100644 decoder/drc_src/impd_memory_standards.h create mode 100644 decoder/drc_src/impd_parametric_drc_dec.h create mode 100644 decoder/drc_src/impd_type_def.h create mode 100644 decoder/ixheaacd_Windowing.c create mode 100644 decoder/ixheaacd_aac_config.h create mode 100644 decoder/ixheaacd_aac_imdct.c create mode 100644 decoder/ixheaacd_aac_imdct.h create mode 100644 decoder/ixheaacd_aac_rom.c create mode 100644 decoder/ixheaacd_aac_rom.h create mode 100644 decoder/ixheaacd_aac_tns.c create mode 100644 decoder/ixheaacd_aacdec.h create mode 100644 decoder/ixheaacd_aacdecoder.c create mode 100644 decoder/ixheaacd_aacpluscheck.c create mode 100644 decoder/ixheaacd_acelp_bitparse.c create mode 100644 decoder/ixheaacd_acelp_com.h create mode 100644 decoder/ixheaacd_acelp_decode.c create mode 100644 decoder/ixheaacd_acelp_info.h create mode 100644 decoder/ixheaacd_acelp_mdct.c create mode 100644 decoder/ixheaacd_acelp_tools.c create mode 100644 decoder/ixheaacd_adts.h create mode 100644 decoder/ixheaacd_adts_crc_check.c create mode 100644 decoder/ixheaacd_adts_crc_check.h create mode 100644 decoder/ixheaacd_api.c create mode 100644 decoder/ixheaacd_api_defs.h create mode 100644 decoder/ixheaacd_apicmd_standards.h create mode 100644 decoder/ixheaacd_arith_dec.c create mode 100644 decoder/ixheaacd_arith_dec.h create mode 100644 decoder/ixheaacd_audioobjtypes.h create mode 100644 decoder/ixheaacd_avq_dec.c create mode 100644 decoder/ixheaacd_avq_rom.c create mode 100644 decoder/ixheaacd_basic_funcs.c create mode 100644 decoder/ixheaacd_basic_funcs.h create mode 100644 decoder/ixheaacd_basic_ops.c create mode 100644 decoder/ixheaacd_basic_ops.h create mode 100644 decoder/ixheaacd_basic_ops16.h create mode 100644 decoder/ixheaacd_basic_ops32.h create mode 100644 decoder/ixheaacd_basic_ops40.h create mode 100644 decoder/ixheaacd_basic_ops_arr.h create mode 100644 decoder/ixheaacd_bit_extract.h create mode 100644 decoder/ixheaacd_bitbuffer.c create mode 100644 decoder/ixheaacd_bitbuffer.h create mode 100644 decoder/ixheaacd_block.c create mode 100644 decoder/ixheaacd_block.h create mode 100644 decoder/ixheaacd_channel.c create mode 100644 decoder/ixheaacd_channel.h create mode 100644 decoder/ixheaacd_channelinfo.h create mode 100644 decoder/ixheaacd_cnst.h create mode 100644 decoder/ixheaacd_common_initfuncs.c create mode 100644 decoder/ixheaacd_common_lpfuncs.c create mode 100644 decoder/ixheaacd_common_rom.c create mode 100644 decoder/ixheaacd_common_rom.h create mode 100644 decoder/ixheaacd_config.h create mode 100644 decoder/ixheaacd_constants.h create mode 100644 decoder/ixheaacd_create.c create mode 100644 decoder/ixheaacd_create.h create mode 100644 decoder/ixheaacd_dec_main.h create mode 100644 decoder/ixheaacd_decode_main.c create mode 100644 decoder/ixheaacd_defines.h create mode 100644 decoder/ixheaacd_definitions.h create mode 100644 decoder/ixheaacd_drc_data_struct.h create mode 100644 decoder/ixheaacd_drc_dec.h create mode 100644 decoder/ixheaacd_drc_freq_dec.c create mode 100644 decoder/ixheaacd_dsp_fft32x32s.c create mode 100644 decoder/ixheaacd_dsp_fft32x32s.h create mode 100644 decoder/ixheaacd_env_calc.c create mode 100644 decoder/ixheaacd_env_calc.h create mode 100644 decoder/ixheaacd_env_dec.c create mode 100644 decoder/ixheaacd_env_dec.h create mode 100644 decoder/ixheaacd_env_extr.c create mode 100644 decoder/ixheaacd_env_extr.h create mode 100644 decoder/ixheaacd_env_extr_part.h create mode 100644 decoder/ixheaacd_error_codes.h create mode 100644 decoder/ixheaacd_error_handler.h create mode 100644 decoder/ixheaacd_error_standards.h create mode 100644 decoder/ixheaacd_esbr_envcal.c create mode 100644 decoder/ixheaacd_esbr_fft.c create mode 100644 decoder/ixheaacd_esbr_polyphase.c create mode 100644 decoder/ixheaacd_esbr_rom.c create mode 100644 decoder/ixheaacd_esbr_rom.h create mode 100644 decoder/ixheaacd_ext_ch_ele.c create mode 100644 decoder/ixheaacd_fft.c create mode 100644 decoder/ixheaacd_freq_sca.c create mode 100644 decoder/ixheaacd_freq_sca.h create mode 100644 decoder/ixheaacd_func_def.h create mode 100644 decoder/ixheaacd_function_selector.h create mode 100644 decoder/ixheaacd_fwd_alias_cnx.c create mode 100644 decoder/ixheaacd_hbe_trans.c create mode 100644 decoder/ixheaacd_hcr.h create mode 100644 decoder/ixheaacd_headerdecode.c create mode 100644 decoder/ixheaacd_headerdecode.h create mode 100644 decoder/ixheaacd_huff_code_reorder.c create mode 100644 decoder/ixheaacd_huff_tools.c create mode 100644 decoder/ixheaacd_hufftables.c create mode 100644 decoder/ixheaacd_hybrid.c create mode 100644 decoder/ixheaacd_hybrid.h create mode 100644 decoder/ixheaacd_imdct.c create mode 100644 decoder/ixheaacd_info.h create mode 100644 decoder/ixheaacd_init_config.c create mode 100644 decoder/ixheaacd_initfuncs.c create mode 100644 decoder/ixheaacd_interface.h create mode 100644 decoder/ixheaacd_intrinsics.h create mode 100644 decoder/ixheaacd_latmdemux.c create mode 100644 decoder/ixheaacd_latmdemux.h create mode 100644 decoder/ixheaacd_longblock.c create mode 100644 decoder/ixheaacd_lpc.c create mode 100644 decoder/ixheaacd_lpc_dec.c create mode 100644 decoder/ixheaacd_lpfuncs.c create mode 100644 decoder/ixheaacd_lpp_tran.c create mode 100644 decoder/ixheaacd_lpp_tran.h create mode 100644 decoder/ixheaacd_lt_predict.c create mode 100644 decoder/ixheaacd_lt_predict.h create mode 100644 decoder/ixheaacd_main.h create mode 100644 decoder/ixheaacd_memory_standards.h create mode 100644 decoder/ixheaacd_mps_dec.c create mode 100644 decoder/ixheaacd_mps_dec.h create mode 100644 decoder/ixheaacd_mps_decor.h create mode 100644 decoder/ixheaacd_mps_decorr.c create mode 100644 decoder/ixheaacd_mps_huff_tab.h create mode 100644 decoder/ixheaacd_mps_hybfilter.h create mode 100644 decoder/ixheaacd_mps_hybrid_filt.c create mode 100644 decoder/ixheaacd_mps_interface.h create mode 100644 decoder/ixheaacd_mps_nlc_dec.h create mode 100644 decoder/ixheaacd_mps_parse.c create mode 100644 decoder/ixheaacd_mps_poly_filt.c create mode 100644 decoder/ixheaacd_mps_polyphase.h create mode 100644 decoder/ixheaacd_mps_pre_mix.c create mode 100644 decoder/ixheaacd_mps_process.h create mode 100644 decoder/ixheaacd_mps_rom.c create mode 100644 decoder/ixheaacd_mps_smoothing.c create mode 100644 decoder/ixheaacd_mps_temp_process.c create mode 100644 decoder/ixheaacd_mps_temp_reshape.c create mode 100644 decoder/ixheaacd_multichannel.c create mode 100644 decoder/ixheaacd_multichannel.h create mode 100644 decoder/ixheaacd_pns.h create mode 100644 decoder/ixheaacd_pns_js_thumb.c create mode 100644 decoder/ixheaacd_pred_vec_block.c create mode 100644 decoder/ixheaacd_process.c create mode 100644 decoder/ixheaacd_process.h create mode 100644 decoder/ixheaacd_ps_bitdec.c create mode 100644 decoder/ixheaacd_ps_bitdec.h create mode 100644 decoder/ixheaacd_ps_dec.c create mode 100644 decoder/ixheaacd_ps_dec.h create mode 100644 decoder/ixheaacd_pulsedata.h create mode 100644 decoder/ixheaacd_pvc_dec.h create mode 100644 decoder/ixheaacd_pvc_rom.c create mode 100644 decoder/ixheaacd_pvc_rom.h create mode 100644 decoder/ixheaacd_qmf_dec.c create mode 100644 decoder/ixheaacd_qmf_dec.h create mode 100644 decoder/ixheaacd_qmf_poly.h create mode 100644 decoder/ixheaacd_rev_vlc.c create mode 100644 decoder/ixheaacd_rom.c create mode 100644 decoder/ixheaacd_rvlc.h create mode 100644 decoder/ixheaacd_sbr_common.h create mode 100644 decoder/ixheaacd_sbr_const.h create mode 100644 decoder/ixheaacd_sbr_crc.c create mode 100644 decoder/ixheaacd_sbr_crc.h create mode 100644 decoder/ixheaacd_sbr_dec.c create mode 100644 decoder/ixheaacd_sbr_dec.h create mode 100644 decoder/ixheaacd_sbr_payload.h create mode 100644 decoder/ixheaacd_sbr_rom.c create mode 100644 decoder/ixheaacd_sbr_rom.h create mode 100644 decoder/ixheaacd_sbr_scale.h create mode 100644 decoder/ixheaacd_sbrdec_initfuncs.c create mode 100644 decoder/ixheaacd_sbrdec_lpfuncs.c create mode 100644 decoder/ixheaacd_sbrdecoder.c create mode 100644 decoder/ixheaacd_sbrdecoder.h create mode 100644 decoder/ixheaacd_sbrdecsettings.h create mode 100644 decoder/ixheaacd_sbrqmftrans.h create mode 100644 decoder/ixheaacd_spectrum_dec.c create mode 100644 decoder/ixheaacd_stereo.c create mode 100644 decoder/ixheaacd_stereo.h create mode 100644 decoder/ixheaacd_struct.h create mode 100644 decoder/ixheaacd_struct_def.h create mode 100644 decoder/ixheaacd_tcx_fwd_alcnx.c create mode 100644 decoder/ixheaacd_tcx_fwd_mdct.c create mode 100644 decoder/ixheaacd_td_mdct.h create mode 100644 decoder/ixheaacd_thumb_ps_dec.c create mode 100644 decoder/ixheaacd_tns.c create mode 100644 decoder/ixheaacd_tns.h create mode 100644 decoder/ixheaacd_tns_usac.h create mode 100644 decoder/ixheaacd_type_def.h create mode 100644 decoder/ixheaacd_vec_baisc_ops.h create mode 100644 decoder/ixheaacd_ver_number.h create mode 100644 decoder/ixheaacd_windows.h create mode 100644 decoder/x86/ixheaacd_basic_op.h create mode 100644 decoder/x86/ixheaacd_function_selector_x86.c create mode 100644 decoder/x86_64/ixheaacd_basic_op.h create mode 100644 decoder/x86_64/ixheaacd_function_selector_x86_64.c create mode 100644 test/Android.bp create mode 100644 test/impd_drc_config_params.h create mode 100644 test/ixheaacd_error.c create mode 100644 test/ixheaacd_fileifc.c create mode 100644 test/ixheaacd_fileifc.h create mode 100644 test/ixheaacd_main.c create mode 100644 test/ixheaacd_main_flush_csd.c create mode 100644 test/ixheaacd_metadata_read.c create mode 100644 test/ixheaacd_metadata_read.h diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..148dac3 --- /dev/null +++ b/Android.bp @@ -0,0 +1,293 @@ +cc_library_static { + name: "libia_xaacdec", + + vendor_available: true, + vndk: { + enabled: true, + }, + + cflags: [ + "-O3" + ], + + export_include_dirs: [ + "decoder" + ], + + srcs: [ + "decoder/ixheaacd_aacdecoder.c", + "decoder/ixheaacd_aacpluscheck.c", + "decoder/ixheaacd_aac_imdct.c", + "decoder/ixheaacd_aac_rom.c", + "decoder/ixheaacd_aac_tns.c", + "decoder/ixheaacd_acelp_bitparse.c", + "decoder/ixheaacd_acelp_decode.c", + "decoder/ixheaacd_acelp_mdct.c", + "decoder/ixheaacd_acelp_tools.c", + "decoder/ixheaacd_adts_crc_check.c", + "decoder/ixheaacd_api.c", + "decoder/ixheaacd_arith_dec.c", + "decoder/ixheaacd_avq_dec.c", + "decoder/ixheaacd_avq_rom.c", + "decoder/ixheaacd_basic_ops.c", + "decoder/ixheaacd_bitbuffer.c", + "decoder/ixheaacd_block.c", + "decoder/ixheaacd_channel.c", + "decoder/ixheaacd_common_initfuncs.c", + "decoder/ixheaacd_common_lpfuncs.c", + "decoder/ixheaacd_common_rom.c", + "decoder/ixheaacd_create.c", + "decoder/ixheaacd_decode_main.c", + "decoder/ixheaacd_dsp_fft32x32s.c", + "decoder/ixheaacd_env_calc.c", + "decoder/ixheaacd_env_dec.c", + "decoder/ixheaacd_env_extr.c", + "decoder/ixheaacd_esbr_envcal.c", + "decoder/ixheaacd_esbr_polyphase.c", + "decoder/ixheaacd_esbr_rom.c", + "decoder/ixheaacd_esbr_fft.c", + "decoder/ixheaacd_ext_ch_ele.c", + "decoder/ixheaacd_fft.c", + "decoder/ixheaacd_freq_sca.c", + "decoder/ixheaacd_fwd_alias_cnx.c", + "decoder/ixheaacd_hbe_trans.c", + "decoder/ixheaacd_headerdecode.c", + "decoder/ixheaacd_hufftables.c", + "decoder/ixheaacd_huff_tools.c", + "decoder/ixheaacd_hybrid.c", + "decoder/ixheaacd_imdct.c", + "decoder/ixheaacd_initfuncs.c", + "decoder/ixheaacd_init_config.c", + "decoder/ixheaacd_longblock.c", + "decoder/ixheaacd_lpc.c", + "decoder/ixheaacd_lpc_dec.c", + "decoder/ixheaacd_lpfuncs.c", + "decoder/ixheaacd_lpp_tran.c", + "decoder/ixheaacd_lt_predict.c", + "decoder/ixheaacd_mps_dec.c", + "decoder/ixheaacd_mps_decorr.c", + "decoder/ixheaacd_mps_hybrid_filt.c", + "decoder/ixheaacd_mps_parse.c", + "decoder/ixheaacd_mps_pre_mix.c", + "decoder/ixheaacd_mps_rom.c", + "decoder/ixheaacd_mps_smoothing.c", + "decoder/ixheaacd_mps_temp_process.c", + "decoder/ixheaacd_mps_temp_reshape.c", + "decoder/ixheaacd_pns_js_thumb.c", + "decoder/ixheaacd_pred_vec_block.c", + "decoder/ixheaacd_process.c", + "decoder/ixheaacd_ps_bitdec.c", + "decoder/ixheaacd_ps_dec.c", + "decoder/ixheaacd_pvc_rom.c", + "decoder/ixheaacd_rom.c", + "decoder/ixheaacd_sbrdecoder.c", + "decoder/ixheaacd_sbrdec_initfuncs.c", + "decoder/ixheaacd_sbrdec_lpfuncs.c", + "decoder/ixheaacd_sbr_crc.c", + "decoder/ixheaacd_sbr_dec.c", + "decoder/ixheaacd_sbr_rom.c", + "decoder/ixheaacd_spectrum_dec.c", + "decoder/ixheaacd_stereo.c", + "decoder/ixheaacd_tcx_fwd_alcnx.c", + "decoder/ixheaacd_tcx_fwd_mdct.c", + "decoder/ixheaacd_thumb_ps_dec.c", + "decoder/ixheaacd_tns.c", + "decoder/ixheaacd_basic_funcs.c", + "decoder/ixheaacd_Windowing.c", + "decoder/ixheaacd_latmdemux.c", + "decoder/ixheaacd_multichannel.c", + "decoder/ixheaacd_drc_freq_dec.c", + "decoder/ixheaacd_mps_poly_filt.c", + "decoder/ixheaacd_huff_code_reorder.c", + "decoder/ixheaacd_rev_vlc.c", + "decoder/drc_src/impd_drc_api.c", + "decoder/drc_src/impd_drc_bitbuffer.c", + "decoder/drc_src/impd_drc_dec.c", + "decoder/drc_src/impd_drc_dynamic_payload.c", + "decoder/drc_src/impd_drc_eq.c", + "decoder/drc_src/impd_drc_extr_delta_coded_info.c", + "decoder/drc_src/impd_drc_filter_bank.c", + "decoder/drc_src/impd_drc_gain_dec.c", + "decoder/drc_src/impd_drc_gain_decoder.c", + "decoder/drc_src/impd_drc_host_params.c", + "decoder/drc_src/impd_drc_init.c", + "decoder/drc_src/impd_drc_interface_decoder.c", + "decoder/drc_src/impd_drc_interface_parser.c", + "decoder/drc_src/impd_drc_loudness_control.c", + "decoder/drc_src/impd_drc_main_qmf_process.c", + "decoder/drc_src/impd_drc_main_stft_process.c", + "decoder/drc_src/impd_drc_main_td_process.c", + "decoder/drc_src/impd_drc_main_td_qmf_process.c", + "decoder/drc_src/impd_drc_multiband.c", + "decoder/drc_src/impd_drc_parametric_dec.c", + "decoder/drc_src/impd_drc_peak_limiter.c", + "decoder/drc_src/impd_drc_process.c", + "decoder/drc_src/impd_drc_rom.c", + "decoder/drc_src/impd_drc_selection_process.c", + "decoder/drc_src/impd_drc_selection_process_drcset_selection.c", + "decoder/drc_src/impd_drc_selection_process_init.c", + "decoder/drc_src/impd_drc_shape_filter.c", + "decoder/drc_src/impd_drc_static_payload.c", + ], + + sanitize: { + misc_undefined: [ + "unsigned-integer-overflow", + "signed-integer-overflow", + ], + cfi: true, + diag: { + cfi: true, + }, + }, + arch: { + arm: { + local_include_dirs: [ + "decoder/armv7", + "decoder" + ], + + srcs: [ + "decoder/armv7/ixheaacd_qmf_dec.c", + "decoder/armv7/ixheaacd_fft_armv7.c", + "decoder/armv7/ixheaacd_function_selector_armv7.c", + + "decoder/armv7/ixheaacd_overlap_add1.s", + "decoder/armv7/ixheaacd_overlap_add2.s", + "decoder/armv7/ixheaacd_lap1.s", + "decoder/armv7/ixheaacd_dec_DCT2_64_asm.s", + "decoder/armv7/ixheaacd_apply_rot.s", + "decoder/armv7/ixheaacd_autocorr_st2.s", + "decoder/armv7/ixheaacd_auto_corr.s", + "decoder/armv7/ixheaacd_calcmaxspectralline.s", + "decoder/armv7/ixheaacd_conv_ergtoamplitude.s", + "decoder/armv7/ixheaacd_conv_ergtoamplitudelp.s", + "decoder/armv7/ixheaacd_cos_sin_mod.s", + "decoder/armv7/ixheaacd_dct3_32.s", + "decoder/armv7/ixheaacd_decorr_filter2.s", + "decoder/armv7/ixheaacd_enery_calc_per_subband.s", + "decoder/armv7/ixheaacd_expsubbandsamples.s", + "decoder/armv7/ixheaacd_ffr_divide16.s", + "decoder/armv7/ixheaacd_fwd_modulation.s", + "decoder/armv7/ixheaacd_harm_idx_zerotwolp.s", + "decoder/armv7/ixheaacd_imdct_using_fft.s", + "decoder/armv7/ixheaacd_inv_dit_fft_8pt.s", + "decoder/armv7/ixheaacd_no_lap1.s", + "decoder/armv7/ixheaacd_post_radix_compute2.s", + "decoder/armv7/ixheaacd_post_radix_compute4.s", + "decoder/armv7/ixheaacd_post_twiddle.s", + "decoder/armv7/ixheaacd_pre_twiddle_compute.s", + "decoder/armv7/ixheaacd_post_twiddle_overlap.s", + "decoder/armv7/ixheaacd_radix4_bfly.s", + "decoder/armv7/ixheaacd_rescale_subbandsamples.s", + "decoder/armv7/ixheaacd_sbr_imdct_using_fft.s", + "decoder/armv7/ixheaacd_sbr_qmfanal32_winadds.s", + "decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s", + "decoder/armv7/ixheaacd_shiftrountine.s", + "decoder/armv7/ixheaacd_shiftrountine_with_round.s", + "decoder/armv7/ixheaacd_tns_ar_filter_fixed_32x16.s", + "decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s", + "decoder/armv7/ixheaacd_esbr_radix4bfly.s", + "decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop1.s", + "decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s", + "decoder/armv7/ixheaacd_complex_ifft_p2.s", + "decoder/armv7/ixheaacd_complex_fft_p2.s", + "decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop2.s", + "decoder/armv7/ixheaacd_shiftrountine_with_round_hq.s", + "decoder/armv7/ixheaacd_mps_complex_fft_64_asm.s", + "decoder/armv7/ixheaacd_esbr_fwd_modulation.s", + "decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s", + "decoder/armv7/ixheaacd_mps_synt_post_twiddle.s", + "decoder/armv7/ixheaacd_calc_pre_twid.s", + "decoder/armv7/ixheaacd_calc_post_twid.s", + "decoder/armv7/ixheaacd_mps_synt_out_calc.s", + "decoder/armv7/ixheaacd_mps_synt_post_fft_twiddle.s", + "decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s", + "decoder/armv7/ixheaacd_shiftrountine_with_rnd_eld.s", + "decoder/armv7/ixheaacd_eld_decoder_sbr_pre_twiddle.s", + "decoder/armv7/ixheaacd_fft_15_ld.s", + "decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s", + "decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s", + "decoder/armv7/ixheaacd_apply_scale_fac.s" + ], + + cflags: [ + "-mfloat-abi=softfp", + "-mfpu=neon", + "-mcpu=cortex-a8", + ], + + armv7_a_neon: { + srcs: [ + ], + cflags: [ + ], + }, + }, + + arm64: { + cflags: [ + "-march=armv8-a", + ], + local_include_dirs: [ + "decoder/armv8", + "decoder" + ], + + srcs: [ + + "decoder/armv8/ixheaacd_qmf_dec.c", + "decoder/armv8/ixheaacd_function_selector_armv8.c", + + "decoder/armv8/ixheaacd_calcmaxspectralline.s", + "decoder/armv8/ixheaacd_sbr_imdct_using_fft.s", + "decoder/armv8/ixheaacd_imdct_using_fft.s", + "decoder/armv8/ixheaacd_no_lap1.s", + "decoder/armv8/ixheaacd_post_twiddle.s", + "decoder/armv8/ixheaacd_pre_twiddle.s", + "decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s", + "decoder/armv8/ixheaacd_overlap_add1.s", + "decoder/armv8/ixheaacd_overlap_add2.s", + "decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s", + "decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s", + "decoder/armv8/ixheaacd_inv_dit_fft_8pt.s", + "decoder/armv8/ixheaacd_shiftrountine_with_round.s", + "decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s", + "decoder/armv8/ixheaacd_postradixcompute4.s", + "decoder/armv8/ixheaacd_apply_scale_factors.s", + "decoder/armv8/ixheaacd_cos_sin_mod_loop1.s", + "decoder/armv8/ixheaacd_cos_sin_mod_loop2.s", + ], + }, + + x86: { + local_include_dirs: [ + "decoder" + ], + + srcs: [ + "decoder/ixheaacd_qmf_dec.c", + "decoder/x86/ixheaacd_function_selector_x86.c", + ], + + cflags: [ + ], + }, + + x86_64: { + local_include_dirs: [ + "decoder" + ], + + srcs: [ + "decoder/ixheaacd_qmf_dec.c", + "decoder/x86_64/ixheaacd_function_selector_x86_64.c", + ], + + cflags: [ + ], + }, + }, +} + +subdirs = ["test"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6245b2d --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. +Create Short LinkX \ No newline at end of file diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..75ec98b --- /dev/null +++ b/NOTICE @@ -0,0 +1,19 @@ +/****************************************************************************** + * * + * 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 +*/ diff --git a/decoder/armv7/ia_xheaacd_mps_mulshift.s b/decoder/armv7/ia_xheaacd_mps_mulshift.s new file mode 100644 index 0000000..4410dca --- /dev/null +++ b/decoder/armv7/ia_xheaacd_mps_mulshift.s @@ -0,0 +1,46 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_mps_mulshift + +ixheaacd_mps_mulshift: + + STMFD sp!, {R4-R12} + VPUSH {d8 - d15} +LOOP: + VLD1.32 {Q0, Q1}, [R0]! @LOADING values from R0 + VLD1.32 {Q2, Q3}, [R1]! @LOADING values from R1 + VQDMULL.S32 Q4, D0, D4 + VQDMULL.S32 Q5, D2, D6 + VQDMULL.S32 Q6, D1, D5 + VQDMULL.S32 Q7, D3, D7 + VUZP.32 Q4, Q6 + VUZP.32 Q5, Q7 + VST1.32 {Q6, Q7}, [R2]! @Storing values to R2 + SUBS R3, R3, #8 + BGT LOOP + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12} + BX LR + diff --git a/decoder/armv7/ia_xheaacd_mps_reoder_mulshift_acc.s b/decoder/armv7/ia_xheaacd_mps_reoder_mulshift_acc.s new file mode 100644 index 0000000..241e1ab --- /dev/null +++ b/decoder/armv7/ia_xheaacd_mps_reoder_mulshift_acc.s @@ -0,0 +1,240 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_mps_mulshift_acc + +ixheaacd_mps_mulshift_acc: + + STMFD sp!, {R4-R12, R14} + VPUSH {d8 - d15} + LDR R4, [SP, #104] @Argument V_fix + LDR R5, [SP, #108] @Argument 2*resolution + ASR R6, R5, #1 + + MOV R7, R4 + MOV R11, #40 + MUL R11, R11, R5 + ADD R7, R7, R11 + LSL R8, R5, #2 + SUB R8, R7, R8 + MOV R10, #9 + MUL R9, R5, R10 + +COPYLOOP: + SUB R8, R8, #32 + VLD1.32 {Q0, Q1}, [R8] + SUB R7, R7, #32 + VST1.32 {Q0, Q1}, [R7] + SUBS R9, R9, #8 + BGT COPYLOOP + +LOOP: + VMOV.I64 Q14, #0 + VMOV.I64 Q15, #0 + MOV R7, R6 + MOV R8, R0 + MOV R9, R1 + +LOOP1: + VLD1.32 {Q0, Q1}, [R8]! @LOADING values from R0 Sr_fix + VLD1.32 {Q2, Q3}, [R9]! @LOADING values from R1 Si_fix + VLD1.32 {Q4, Q5}, [R2]! @LOADING values from R2 N.real_fix + VLD1.32 {Q6, Q7}, [R3]! @LOADING values from R3 N.imag_fix + + VMULL.S32 Q12, D0, D8 + VMULL.S32 Q10, D1, D9 + VMULL.S32 Q11, D3, D11 + VMULL.S32 Q13, D2, D10 + + VMULL.S32 Q0, D4, D12 + VMULL.S32 Q4, D5, D13 + VMULL.S32 Q5, D7, D15 + VMULL.S32 Q1, D6, D14 + + VSHR.S64 Q0, Q0, #31 + VSHR.S64 Q1, Q1, #31 + VSHR.S64 Q4, Q4, #31 + VSHR.S64 Q5, Q5, #31 + + VSHR.S64 Q12, Q12, #31 + VSHR.S64 Q13, Q13, #31 + VSHR.S64 Q10, Q10, #31 + VSHR.S64 Q11, Q11, #31 + + VSUB.I64 Q12, Q12, Q0 + VSUB.I64 Q13, Q13, Q1 + VSUB.I64 Q10, Q10, Q4 + VSUB.I64 Q11, Q11, Q5 + + VADD.I64 Q12, Q12, Q13 + VADD.I64 Q10, Q10, Q11 + VADD.I64 Q12, Q12, Q10 + VADD.I64 D24, D24, D25 + VADD.I64 D28, D28, D24 + SUBS R7, R7, #8 + BGT LOOP1 + + + MOV R7, R6 + MOV R8, R0 + MOV R9, R1 + +LOOP2: + VLD1.32 {Q0, Q1}, [R8]! @LOADING values from R0 Sr_fix + VLD1.32 {Q2, Q3}, [R9]! @LOADING values from R1 Si_fix + VLD1.32 {Q4, Q5}, [R2]! @LOADING values from R2 N.real_fix + VLD1.32 {Q6, Q7}, [R3]! @LOADING values from R3 N.imag_fix + + VMULL.S32 Q12, D0, D8 + VMULL.S32 Q10, D1, D9 + VMULL.S32 Q11, D3, D11 + VMULL.S32 Q13, D2, D10 + + VMULL.S32 Q0, D4, D12 + VMULL.S32 Q4, D5, D13 + VMULL.S32 Q5, D7, D15 + VMULL.S32 Q1, D6, D14 + + VSHR.S64 Q12, Q12, #31 + VSHR.S64 Q13, Q13, #31 + VSHR.S64 Q10, Q10, #31 + VSHR.S64 Q11, Q11, #31 + + VSHR.S64 Q0, Q0, #31 + VSHR.S64 Q1, Q1, #31 + VSHR.S64 Q4, Q4, #31 + VSHR.S64 Q5, Q5, #31 + + VSUB.I64 Q12, Q12, Q0 + VSUB.I64 Q13, Q13, Q1 + VSUB.I64 Q10, Q10, Q4 + VSUB.I64 Q11, Q11, Q5 + + VADD.I64 Q12, Q12, Q13 + VADD.I64 Q10, Q10, Q11 + VADD.I64 Q12, Q12, Q10 + VADD.I64 D24, D24, D25 + VADD.I64 D29, D29, D24 + SUBS R7, R7, #8 + BGT LOOP2 + + MOV R7, R6 + MOV R8, R0 + MOV R9, R1 + + +LOOP3: + VLD1.32 {Q0, Q1}, [R8]! @LOADING values from R0 Sr_fix + VLD1.32 {Q2, Q3}, [R9]! @LOADING values from R1 Si_fix + VLD1.32 {Q4, Q5}, [R2]! @LOADING values from R2 N.real_fix + VLD1.32 {Q6, Q7}, [R3]! @LOADING values from R3 N.imag_fix + + VMULL.S32 Q12, D0, D8 + VMULL.S32 Q10, D1, D9 + VMULL.S32 Q11, D3, D11 + VMULL.S32 Q13, D2, D10 + + VMULL.S32 Q0, D4, D12 + VMULL.S32 Q4, D5, D13 + VMULL.S32 Q5, D7, D15 + VMULL.S32 Q1, D6, D14 + + VSHR.S64 Q12, Q12, #31 + VSHR.S64 Q13, Q13, #31 + VSHR.S64 Q10, Q10, #31 + VSHR.S64 Q11, Q11, #31 + + VSHR.S64 Q0, Q0, #31 + VSHR.S64 Q1, Q1, #31 + VSHR.S64 Q4, Q4, #31 + VSHR.S64 Q5, Q5, #31 + + VSUB.I64 Q12, Q12, Q0 + VSUB.I64 Q13, Q13, Q1 + VSUB.I64 Q10, Q10, Q4 + VSUB.I64 Q11, Q11, Q5 + + VADD.I64 Q12, Q12, Q13 + VADD.I64 Q10, Q10, Q11 + VADD.I64 Q12, Q12, Q10 + VADD.I64 D24, D24, D25 + VADD.I64 D30, D30, D24 + SUBS R7, R7, #8 + BGT LOOP3 + + MOV R7, R6 + MOV R8, R0 + MOV R9, R1 + + +LOOP4: + VLD1.32 {Q0, Q1}, [R8]! @LOADING values from R0 Sr_fix + VLD1.32 {Q2, Q3}, [R9]! @LOADING values from R1 Si_fix + VLD1.32 {Q4, Q5}, [R2]! @LOADING values from R2 N.real_fix + VLD1.32 {Q6, Q7}, [R3]! @LOADING values from R3 N.imag_fix + + VMULL.S32 Q12, D0, D8 + VMULL.S32 Q10, D1, D9 + VMULL.S32 Q11, D3, D11 + VMULL.S32 Q13, D2, D10 + + VMULL.S32 Q0, D4, D12 + VMULL.S32 Q4, D5, D13 + VMULL.S32 Q5, D7, D15 + VMULL.S32 Q1, D6, D14 + + VSHR.S64 Q12, Q12, #31 + VSHR.S64 Q13, Q13, #31 + VSHR.S64 Q10, Q10, #31 + VSHR.S64 Q11, Q11, #31 + + VSHR.S64 Q0, Q0, #31 + VSHR.S64 Q1, Q1, #31 + VSHR.S64 Q4, Q4, #31 + VSHR.S64 Q5, Q5, #31 + + VSUB.I64 Q12, Q12, Q0 + VSUB.I64 Q13, Q13, Q1 + VSUB.I64 Q10, Q10, Q4 + VSUB.I64 Q11, Q11, Q5 + + VADD.I64 Q12, Q12, Q13 + VADD.I64 Q10, Q10, Q11 + VADD.I64 Q12, Q12, Q10 + VADD.I64 D24, D24, D25 + VADD.I64 D31, D31, D24 + SUBS R7, R7, #8 + BGT LOOP4 + + VQMOVN.S64 D0, Q14 + VQMOVN.S64 D1, Q15 + + VST1.32 {Q0}, [R4]! @Storing values to R4 + + SUBS R5, R5, #4 + BGT LOOP + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12, R14} + BX LR + diff --git a/decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s b/decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s new file mode 100644 index 0000000..cb42857 --- /dev/null +++ b/decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s @@ -0,0 +1,50 @@ +.text +.p2align 2 +.global ia_aac_ld_dec_rearrange_armv7 + +ia_aac_ld_dec_rearrange_armv7: + STMFD r13!, {r4 - r12, r14} + @ASR r2,r2,#3 @ + MOV R2, R2, ASR #3 + + +LOOP_REARRANGE: + LDRB r4, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r5, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r6, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r7, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r8, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r9, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r10, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + LDRB r11, [r3], #1 @ idx = mdct_tables_ptr->re_arr_tab[n] + ADD r4, r0, r4, lsl #3 + ADD r5, r0, r5, lsl #3 + ADD r6, r0, r6, lsl #3 + ADD r7, r0, r7, lsl #3 + ADD r8, r0, r8, lsl #3 + ADD r9, r0, r9, lsl #3 + ADD r10, r0, r10, lsl #3 + ADD r11, r0, r11, lsl #3 + LDMIA r4, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r5, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r6, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r7, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r8, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r9, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r10, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + LDMIA r11, {r12, r14} @ r12 = inp[idx] and r14 = inp[idx+1] + STMIA r1!, {r12, r14} @ *buf1++ = inp[idx] and *buf1++ = inp[idx+1] + + SUBS r2, r2, #1 + BGT LOOP_REARRANGE + + LDMFD r13!, {r4 - r12, r15} + + diff --git a/decoder/armv7/ixheaacd_apply_rot.s b/decoder/armv7/ixheaacd_apply_rot.s new file mode 100644 index 0000000..ef3b13f --- /dev/null +++ b/decoder/armv7/ixheaacd_apply_rot.s @@ -0,0 +1,229 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_apply_rot_armv7 + +ixheaacd_apply_rot_armv7: + STMFD SP!, {R4-R12, R14} + LDR R5, =0x59e + MOV R4, #22 + ADD R11, R0, R5 +LOOP1: + LDRSH R5, [R11, #-98] + LDRSH R6, [R11, #94] + LDRSH R7, [R11, #-96] + LDRSH R8, [R11, #96] + ADD R9, R5, R6 + STRH R9, [R11, #-98] + ADD R10, R7, R8 + STRH R10, [R11, #-96] + + + LDRSH R5, [R11, #-2] + LDRSH R6, [R11, #190] + LDRSH R7, [R11] + LDRSH R8, [R11, #192] + ADD R9, R5, R6 + STRH R9, [R11, #-2] + ADD R10, R7, R8 + STRH R10, [R11], #4 + + LDRSH R5, [R11, #-98] + LDRSH R6, [R11, #94] + LDRSH R7, [R11, #-96] + LDRSH R8, [R11, #96] + ADD R9, R5, R6 + STRH R9, [R11, #-98] + ADD R10, R7, R8 + STRH R10, [R11, #-96] + + SUBS R4, R4, #2 + + LDRSH R5, [R11, #-2] + LDRSH R6, [R11, #190] + LDRSH R7, [R11] + LDRSH R8, [R11, #192] + ADD R9, R5, R6 + STRH R9, [R11, #-2] + ADD R10, R7, R8 + STRH R10, [R11], #4 + + BGT LOOP1 + + LDR R4, =0x53C + LDR R12, [R0, #44] + ADD R11, R0, R4 + MOV R4, #10 + +LOOP2: + + LDR R5, [R12] + LDR R7, [R11], #4 + LDR R6, [R12, #0x80] + LDR R8, [R11, #92] + + SMULWB R9, R5, R7 + SMULWB R10, R6, R8 + SMULWT R14, R5, R7 + + QADD R5, R9, R10 + SMULWT R6, R6, R8 + + MOV R5, R5, LSL #2 + QADD R14, R14, R6 + STR R5, [R12], #4 + MOV R14, R14, LSL #2 + STR R14, [R12, #0x7c] + + LDR R5, [R12, #0x3c] + LDR R6, [R12, #0xbc] + + SMULWB R9, R5, R7 + SMULWB R10, R6, R8 + SMULWT R14, R5, R7 + + QADD R5, R9, R10 + + SMULWT R6, R6, R8 + + MOV R5, R5, LSL #2 + QADD R14, R14, R6 + STR R5, [R12, #0x3c] + MOV R14, R14, LSL #2 + STR R14, [R12, #0xbc] + + SUBS R4, R4, #1 + + BGT LOOP2 + + LDR R11, =0x6c2 + LDR R5, =0x564 + LDRSH R14, [R0, R11] + ADD R11, R0, R5 + LDR R5, [SP, #44] + SUB SP, SP, #512 + MOV R12, SP + LDR R6, [R5, #12] + MOV R4, #12 + ADD R6, R6, #0xb8 + +LOOP3: + LDRSH R5, [R6], #2 + LDRSH R7, [R6, #-4] + LDR R10, [R11, #96] + LDR R9, [R11], #4 + CMP R14, R5 + SUB R8, R14, R7 + SUBGT R8, R5, R7 + ADD R5, R12, R7, LSL #3 + +LOOP3INN1: + STR R10, [R5, #4] + STR R9, [R5], #8 + SUBS R8, R8, #1 + BGT LOOP3INN1 + + SUBS R4, R4, #1 + BGT LOOP3 + + MOV R4, #3 + LDR R12, [R0, #44] + LDR R9, [SP, #48+512] + LDR R0, [SP, #40+512] + STR R14, [SP, #-4]! + +LOOP4: + LDR R5, [R12], #4 + LDR R6, [R12, #0x3c] + LDR R7, [R12, #0x7c] + LDRSH R10, [R9], #2 + LDR R8, [R12, #0xbc] + MOV R11, #5 + CMP R10, #6 + SUBLT R11, R10, #1 + +LOOP4INN1: + LDR R10, [R12], #4 + LDR R14, [R12, #0x3C] + QADD R5, R5, R10 + QADD R6, R6, R14 + LDR R10, [R12, #0x7C] + LDR R14, [R12, #0xBC] + QADD R7, R7, R10 + QADD R8, R8, R14 + SUBS R11, R11, #1 + BGT LOOP4INN1 + + STR R5, [R1], #4 + STR R6, [R2], #4 + STR R7, [R3], #4 + STR R8, [R0], #4 + SUBS R4, R4, #1 + BGT LOOP4 + + LDR R14, [SP] + ADD R11, SP, #28 + SUB R4, R14, #3 + +LOOP5: + LDR R5, [R1] + LDR R7, [R11], #4 + LDR R6, [R3] + LDR R8, [R11], #4 + + SMULWB R9, R5, R7 + SMULWB R10, R6, R8 + SMULWT R14, R5, R7 + + QADD R5, R9, R10 + SMULWT R6, R6, R8 + + MOV R5, R5, LSL #2 + QADD R14, R14, R6 + STR R5, [R1], #4 + MOV R14, R14, LSL #2 + STR R14, [R3], #4 + + SUBS R4, R4, #1 + + LDR R5, [R2] + LDR R6, [R0] + + SMULWB R9, R5, R7 + SMULWB R10, R6, R8 + SMULWT R14, R5, R7 + + QADD R5, R9, R10 + + SMULWT R6, R6, R8 + + MOV R5, R5, LSL #2 + QADD R14, R14, R6 + STR R5, [R2], #4 + MOV R14, R14, LSL #2 + STR R14, [R0], #4 + + BGT LOOP5 + ADD SP, SP, #516 + LDMFD sp!, {r4-r12, r15} + diff --git a/decoder/armv7/ixheaacd_apply_scale_fac.s b/decoder/armv7/ixheaacd_apply_scale_fac.s new file mode 100644 index 0000000..15f8a19 --- /dev/null +++ b/decoder/armv7/ixheaacd_apply_scale_fac.s @@ -0,0 +1,147 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_scale_factor_process_armv7 + +ixheaacd_scale_factor_process_armv7: + + + + + STMFD sp!, {r4-r12, r14} + LDR r9, [sp, #0x28] + LDR r11, [sp, #0x2c] + + CMP r2, #0 + + BLE END + MOV r10, #0 + CMP r11, #2 + MOVLE r11, #0x25 + MOVGT r11, #0x22 + +TBANDS_LOOP: + + LDRSH r5, [r1], #2 + LDRB r4, [r3], #1 + + LDR r6, [sp, #0x30] + LDR r7, [sp, #0x34] + + CMP r5, #0x18 + BGE SCALE_FACTOR_GE_12 + + CMP r4, #0 + BLE OFFSET_ZERO + +SCALE_FACTOR_LT_12: + + STR r10, [r0], #4 + STR r10, [r0], #4 + STR r10, [r0], #4 + STR r10, [r0], #4 + SUBS r4, r4, #4 + BGT SCALE_FACTOR_LT_12 + B OFFSET_ZERO + +SCALE_FACTOR_GE_12: + + SUBS r6, r11, r5, ASR #2 + + + AND r5, r5, #3 + + + LDR r5, [r9, r5, LSL #2] + + BLE SHIFT_LE_ZERO + + SUB r14, r6, #1 + +SHIFT_POSITIVE: + LDRD r6, [r0, #0] + + SMULWB r6, r6, r5 + SMULWB r7, r7, r5 + + MOV r6, r6, ASR r14 + MOV r7, r7, ASR r14 + + STRD r6, [r0], #8 + + LDRD r6, [r0, #0] + + SMULWB r6, r6, r5 + SMULWB r7, r7, r5 + SUBS r4, r4, #4 + + MOV r6, r6, ASR r14 + MOV r7, r7, ASR r14 + + STRD r6, [r0], #8 + + BGT SHIFT_POSITIVE + B OFFSET_ZERO +SHIFT_LE_ZERO: + + RSBS r14, r6, #0 + BGT SHIFT_NEGTIVE1 + +SHIFT_ZERO: + LDRD r6, [r0, #0] + + SMULWB r6, r6, r5 + SMULWB r7, r7, r5 + MOV r6, r6, LSL #1 + MOV r7, r7, LSL #1 + + STRD r6, [r0], #8 + + SUBS r4, r4, #2 + + BGT SHIFT_ZERO + B OFFSET_ZERO + +SHIFT_NEGTIVE1: + SUB r14, r14, #1 +SHIFT_NEGTIVE: + LDRD r6, [r0, #0] + MOV r6, r6, LSL r14 + MOV r7, r7, LSL r14 + + SMULWB r6, r6, r5 + SMULWB r7, r7, r5 + MOV r6, r6, LSL #2 + MOV r7, r7, LSL #2 + + STRD r6, [r0], #8 + + SUBS r4, r4, #2 + + BGT SHIFT_NEGTIVE + +OFFSET_ZERO: + SUBS r2, r2, #1 + BGT TBANDS_LOOP +END: + LDMFD sp!, {r4-r12, r15} diff --git a/decoder/armv7/ixheaacd_auto_corr.s b/decoder/armv7/ixheaacd_auto_corr.s new file mode 100644 index 0000000..9aeca31 --- /dev/null +++ b/decoder/armv7/ixheaacd_auto_corr.s @@ -0,0 +1,155 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_covariance_matrix_calc_armv7 + + +ixheaacd_covariance_matrix_calc_armv7: + + STMFD sp!, {r4-r12, r14} + MOVS r12, r2 + BLE EXIT +AUTOCORR: + MOV r12, r0 + + MOV r5, #9728 + LDR r4, [r12, r5] + ADD r5, r5, #256 + LDR r3, [r12, r5] + + LDR r6, [r12], #256 + LDR r5, [r12], #256 + + MOV r4, r4, ASR #3 + MOV r3, r3, ASR #3 + MOV r6, r6, ASR #3 + MOV r5, r5, ASR #3 + + SMULWT r11, r3, r4 + SMULWT r9, r5, r6 + + SMULWT r14, r4, r4 + SUB r11, r9, r11 + + + SMULWT r9, r6, r6 + + + MOV r3, #12 + + SUB r14, r9, r14 + + MOV r7, #0 + MOV r8, #0 + MOV r9, #0 + +AUTO_CORR_RIGHT: + LDR r4, [r12], #256 + LDR r10, [r12], #256 + + MOV r4, r4, ASR #3 + SMLAWT r9, r5, r5, r9 + SMLAWT r7, r4, r5, r7 + SMLAWT r8, r4, r6, r8 + + MOV r6, r10, ASR #3 + SMLAWT r9, r4, r4, r9 + SMLAWT r8, r6, r5, r8 + + LDR r5, [r12], #256 + SMLAWT r7, r6, r4, r7 + + + MOV r5, r5, ASR #3 + SMLAWT r9, r6, r6, r9 + SMLAWT r7, r5, r6, r7 + SMLAWT r8, r5, r4, r8 + + SUBS r3, r3, #1 + BNE AUTO_CORR_RIGHT + + LDR r4, [r12], #256 + MOV r4, r4, ASR #3 + SMLAWT r9, r5, r5, r9 + SMLAWT r7, r4, r5, r7 + SMLAWT r8, r4, r6, r8 + + LDR r6, [r12], #256 + MOV r6, r6, ASR #3 + SMLAWT r9, r4, r4, r9 + SMLAWT r7, r6, r4, r7 + SMLAWT r8, r6, r5, r8 + +CAL_AUTOCORR: + + ADD r12, r7, r11 + ADD r14, r9, r14 + + EOR r5, r7, r7, ASR #31 + EOR r6, r8, r8, ASR #31 + + ORR r5, r6, r5 + EOR r6, r12, r12, ASR #31 + ORR r5, r6, r5 + + ORR r5, r9, r5 + ORR r5, r14, r5 + + CLZ r5, r5 + SUB r5, r5, #1 + + MOV r7, r7, LSL r5 + MOV r8, r8, LSL r5 + MOV r9, r9, LSL r5 + MOV r12, r12, LSL r5 + MOV r14, r14, LSL r5 + + + STR r9, [r1], #4 + STR r14, [r1], #4 + STR r7, [r1], #4 + + + SMULL r6, r5, r9, r14 + SMULL r6, r10, r12, r12 + + STR r8, [r1], #4 + STR r12, [r1], #4 + + QSUB r10, r5, r10 + ADD r0, r0, #4 + + ADD r1, r1, #12 + + STR r10, [r1], #4 + + + SUBS r2, r2, #1 + BNE AUTOCORR + + +EXIT: + + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_autocorr_st2.s b/decoder/armv7/ixheaacd_autocorr_st2.s new file mode 100644 index 0000000..8d23e81 --- /dev/null +++ b/decoder/armv7/ixheaacd_autocorr_st2.s @@ -0,0 +1,403 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_covariance_matrix_calc_2_armv7 +ixheaacd_covariance_matrix_calc_2_armv7: + STMFD sp!, {r4-r12, r14} + +AUTO_CORR_LOOP: + + STR r0 , [sp, #-4]! + STR r1 , [sp, #-4]! + LDR r1 , [sp], #4 + + + + + + + + + + + LDR r4 , [r1, #-4*128] + LDR r5 , [r1, #4*(64-128)] + LDR r6 , [r1] + LDR r7 , [r1, #4*64] + + MOV r4, r4, ASR #3 + MOV r5, r5, ASR #3 + MOV r6, r6, ASR #3 + MOV r7, r7, ASR #3 + + + SMULWT r8 , r6 , r4 + SMULWT r9 , r7 , r4 + SMULWT r10, r6 , r5 + SMLAWT r8 , r7 , r5, r8 + SMULWT r11, r4 , r4 + SUB r9 , r9 , r10 + SMLAWT r11, r5 , r5, r11 + + + + + + + + + + + + + + + MOV r10, r1 + ADD r12, r1, #64*4 + MOV r4 , r6 + MOV r5 , r7 + + SUB r14, r3 , #2 + MOVS r14, r14, LSR #1 + BEQ ENDLOOP2 +LOOP2: + LDR r6 , [r10, #4*128]! + LDR r7 , [r12, #4*128]! + + MOV r6, r6, ASR #3 + MOV r7, r7, ASR #3 + + SMLAWT r8 , r6 , r4, r8 + SMLAWT r9 , r7 , r4, r9 + SMLAWT r8 , r7 , r5, r8 + SMULWT r0 , r6 , r5 + SMLAWT r11, r4 , r4, r11 + SUB r9 , r9 , r0 + SMLAWT r11, r5 , r5, r11 + + LDR r4 , [r10, #4*128]! + LDR r5 , [r12, #4*128]! + + MOV r4, r4, ASR #3 + MOV r5, r5, ASR #3 + + SUBS r14, r14, #1 + + SMLAWT r8 , r4 , r6, r8 + SMLAWT r9 , r5 , r6, r9 + SMLAWT r8 , r5 , r7, r8 + SMULWT r0 , r4 , r7 + SMLAWT r11, r6 , r6, r11 + SUB r9 , r9 , r0 + SMLAWT r11, r7 , r7, r11 + + BNE LOOP2 + + ANDS r0, r3, #0x01 + BEQ ENDLOOP2 +ODDLOOP: + + LDR r6 , [r10, #4*128]! + LDR r7 , [r12, #4*128]! + + MOV r6, r6, ASR #3 + MOV r7, r7, ASR #3 + + SMLAWT r8 , r6 , r4, r8 + SMLAWT r9 , r7 , r4, r9 + SMLAWT r8 , r7 , r5, r8 + SMULWT r0 , r6 , r5 + SMLAWT r11, r4 , r4, r11 + SUB r9 , r9 , r0 + SMLAWT r11, r5 , r5, r11 + + + +ENDLOOP2: + + + + + + + + + + MOV r12, r11 + LDR r6 , [r1, #-8*128] + LDR r7 , [r1, #4*64-8*128] + + MOV r6, r6, ASR #3 + MOV r7, r7, ASR #3 + + SMLAWT r12, r6 , r6, r12 + + SUB r10, r3, #2 + SMLAWT r12, r7 , r7, r12 + + + + + MOV r0, r10, LSL #(2+7) + ADD r0, r0, #0x100 + LDR r4 , [r1, r10, LSL #(2+7)] + LDR r5 , [r1, r0] + + MOV r4, r4, ASR #3 + MOV r5, r5, ASR #3 + + SMLAWT r11, r4, r4, r11 + LDR r0 , [sp], #4 + SMLAWT r11, r5, r5, r11 + + STR r12, [r0, #4] + STR r11, [r0] + + + + + + + + + + + + + MOV r11, r8 + LDR r12, [r1, #-4*128] + LDR r14, [r1, #4*(64-128)] + + MOV r12, r12, ASR #3 + MOV r14, r14, ASR #3 + + + SMLAWT r11, r12, r6, r11 + ADD r10, r10, #1 + + LDR r12, [r1, r10, LSL#(2+7)] + SMLAWT r11, r14, r7, r11 + + MOV r14, r10, LSL #(2+7) + ADD r14, r14, #0x100 + + + MOV r12, r12, ASR #3 + + LDR r14, [r1, r14] + + SMLAWT r8 , r12, r4, r8 + + MOV r14, r14, ASR #3 + MOV r10, r9 + + SMLAWT r8 , r14, r5, r8 + STR r11, [r0, #16] + STR r8 , [r0, #8] + + + + + + + + + + + + + SMLAWT r9 , r14, r4 , r9 + SMULWT r8 , r12, r5 + LDR r14, [r1, #4*(64-128)] + SUB r9 , r9 , r8 + + MOV r14, r14, ASR #3 + LDR r12, [r1, #-4*128] + SMLAWT r10, r14, r6 , r10 + + MOV r12, r12, ASR #3 + SMULWT r8 , r12, r7 + STR r9 , [r0, #20] + SUB r10, r10, r8 + STR r10, [r0, #28] + + + + + + + + + STR r1 , [sp, #-4]! + + STMFD sp!, {r0, r3} + MOVS r0 , r3 , LSR #2 + + MOV r12, #0 + MOV r3 , #0 + LDR r5 , [r1, #-8*128] + LDR r7 , [r1, #-4*128] + LDR r9 , [r1, #4*(64-256)] + LDR r11, [r1, #4*(64-128)] + + + + MOV r5, r5, ASR #3 + MOV r7, r7, ASR #3 + MOV r9, r9, ASR #3 + MOV r11, r11, ASR #3 + + + BEQ ENDLOOP3 +LOOP3: + + + + + + + LDR r4 , [r1], #4*128 + LDR r8 , [r1, #4*(64-128)] + + MOV r4, r4, ASR #3 + MOV r8, r8, ASR #3 + + SMLAWT r12, r4 , r5 , r12 + SMLAWT r12, r8 , r9 , r12 + SMULWT r14, r4 , r9 + SMLAWT r3 , r8 , r5 , r3 + + LDR r6 , [r1], #4*128 + SUB r3 , r3 , r14 + + + + + + + + + LDR r10, [r1, #4*(64-128)] + + MOV r6, r6, ASR #3 + MOV r10, r10, ASR #3 + + SMLAWT r12, r6 , r7 , r12 + SMLAWT r12, r10, r11, r12 + SMULWT r14, r6 , r11 + SMLAWT r3 , r10, r7 , r3 + + LDR r5 , [r1], #4*128 + SUB r3 , r3 , r14 + + + + + + + + + LDR r9 , [r1, #4*(64-128)] + + MOV r5, r5, ASR #3 + MOV r9, r9, ASR #3 + + SMLAWT r12, r5 , r4 , r12 + SMLAWT r12, r9 , r8 , r12 + SMULWT r14, r5 , r8 + SMLAWT r3 , r9 , r4 , r3 + + LDR r7 , [r1], #4*128 + SUB r3 , r3 , r14 + + + + + + + + + + + LDR r11, [r1, #4*(64-128)] + + MOV r7, r7, ASR #3 + MOV r11, r11, ASR #3 + + SMLAWT r12, r7 , r6 , r12 + SMLAWT r12, r11, r10, r12 + SMULWT r14, r7 , r10 + SMLAWT r3 , r11, r6 , r3 + + SUBS r0 , r0 , #1 + SUB r3 , r3 , r14 + + BNE LOOP3 +ENDLOOP3: + MOV r4 , r3 + LDMFD sp!, {r0, r3} + + ANDS r5 , r3 , #3 + BEQ ENDLOOP4 + +LOOP4: + LDR r6 , [r1, #-8*128] + LDR r10, [r1, #4*(64-256)] + + LDR r7 , [r1], #4*128 + LDR r11, [r1, #4*(64-128)] + + + MOV r6, r6, ASR #3 + MOV r7, r7, ASR #3 + MOV r10, r10, ASR #3 + MOV r11, r11, ASR #3 + + + SMLAWT r12, r7 , r6 , r12 + SMLAWT r12, r11, r10, r12 + SMULWT r14, r7 , r10 + SMLAWT r4 , r11, r6 , r4 + + SUBSNE r5 , r5 , #1 + + SUB r4 , r4 , r14 + + BNE LOOP4 +ENDLOOP4: + STR r12, [r0, #12] + STR r4 , [r0, #24] + LDR r1 , [sp], #4 + + SUBS R2, R2, #1 + + ADD r0, r0, #4*9 + + + ADD r1, r1, #4 + BGT AUTO_CORR_LOOP + +END_OF_AUT0: + + LDMFD sp!, {r4-r12, r15} + diff --git a/decoder/armv7/ixheaacd_basic_op.h b/decoder/armv7/ixheaacd_basic_op.h new file mode 100644 index 0000000..d0e4720 --- /dev/null +++ b/decoder/armv7/ixheaacd_basic_op.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OP_H +#define IXHEAACD_BASIC_OP_H + +#define add_d(a, b) ((a) + (b)) +#define sub_d(a, b) ((a) - (b)) +#define ixheaacd_cbrt_calc(a) cbrt(1.0f / a) + +static PLATFORM_INLINE WORD32 msu32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b, + WORD16 c2) { + WORD32 result; + WORD32 temp_result; + UWORD32 a_lsb; + WORD32 a_msb; + UWORD32 b_lsb; + WORD32 b_msb; + + a_lsb = a & 65535; + a_msb = a >> 16; + + b_lsb = b & 65535; + b_msb = b >> 16; + temp_result = ((UWORD32)a_lsb * (UWORD32)c1); + temp_result = temp_result - (UWORD32)b_lsb * (UWORD32)c2; + temp_result = ((WORD32)temp_result) >> 16; + result = temp_result + ((a_msb * (WORD32)c1) - (b_msb * (WORD32)c2)); + + return (result); +} + +static PLATFORM_INLINE WORD32 mac32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b, + WORD16 c2) { + WORD32 result; + WORD32 temp_result; + UWORD32 a_lsb; + WORD32 a_msb; + UWORD32 b_lsb; + WORD32 b_msb; + + a_lsb = a & 65535; + a_msb = a >> 16; + + b_lsb = b & 65535; + b_msb = b >> 16; + temp_result = (UWORD32)a_lsb * (UWORD32)c1; + temp_result = temp_result + (UWORD32)b_lsb * (UWORD32)c2; + temp_result = ((UWORD32)temp_result) >> 16; + result = temp_result + ((a_msb * (WORD32)c1)) + ((b_msb * (WORD32)c2)); + 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); +} + +#endif diff --git a/decoder/armv7/ixheaacd_basic_ops16.h b/decoder/armv7/ixheaacd_basic_ops16.h new file mode 100644 index 0000000..271dfd8 --- /dev/null +++ b/decoder/armv7/ixheaacd_basic_ops16.h @@ -0,0 +1,403 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS16_H +#define IXHEAACD_BASIC_OPS16_H + +static PLATFORM_INLINE WORD16 ixheaacd_sat16(WORD32 op1) { + WORD32 var_out; + __asm__( + " MOV %0, %1 \n\t" + " CMP %0, #0x8000 \n\t" + " ITEE GE \n\t" + " MVNGE %0, #0x8000 \n\t" + " CMNLT %0, #0x00008000 \n\t" + " MOVLT %0, #0x00008000 \n\t" + : "=r"(var_out) + : "r"(op1) + : "cc"); + return ((WORD16)var_out); +} + +// add 2 16 bit variables and returns 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_add16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 + op2)); + return (var_out); +} + +// add 2 16 bit variables and returns 16 bit result with saturation +static PLATFORM_INLINE WORD16 ixheaacd_add16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 sum; + + sum = (WORD32)op1 + (WORD32)op2; + var_out = ixheaacd_sat16(sum); + return (var_out); +} + +// subtract 2 16 bit variables and returns 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_sub16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 - op2)); + return (var_out); +} + +// subtract 2 16 bit variables and returns 16 bit result with saturation +static PLATFORM_INLINE WORD16 ixheaacd_sub16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 diff; + + diff = (WORD32)op1 - op2; + var_out = ixheaacd_sat16(diff); + return (var_out); +} + +// multiply 2 16 bit variables and return 31 to 16 bits +static PLATFORM_INLINE WORD16 ixheaacd_mult16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 16)); + return (var_out); +} + +// multiply 2 16 bit variables and return 30 to 15 bits +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 15)); + return (var_out); +} + +// multiply 2 16 bit variables and return 30 to 15 bits with saturation +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl_sat(WORD16 op1, WORD16 op2) { + WORD32 temp; + __asm__( + " SMULBB %0, %1, %2 \n\t" + " MOV %0, %0, ASR #15 \n\t" + " CMP %0, #0x00008000 \n\t" + " IT EQ \n\t" + " SUBEQ %0, %0, #1 \n\t" + : "=r"(temp) + : "r"(op1), "r"(op2) + : "cc"); + return (temp); +} + +// shifts left a 16 bit variable by the shift value and returns a 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_shl16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = (WORD16)(op1 << shift); + return (var_out); +} + +// shifts left a 16 bit variable by the shift value and returns a 16 bit value +// with saturation +static PLATFORM_INLINE WORD16 ixheaacd_shl16_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + WORD32 temp; + + if (shift > 15) { + shift = 15; + } + temp = (WORD32)(op1 << shift); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +// shifts right a 16 bit variable by the shift value and returns a 16 bit value +static PLATFORM_INLINE WORD16 ixheaacd_shr16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = ((WORD16)(op1 >> shift)); + return (var_out); +} + +// shifts left a 16 bit variable by the shift value +// if the value is positive else shifts right and returns a 16 bit + +static PLATFORM_INLINE WORD16 shl16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value +// if the value is negative else shifts right and returns a 16 bit +static PLATFORM_INLINE WORD16 shr16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value +// if the value is positive else shifts right and returns a 16 bit with +// saturation +static PLATFORM_INLINE WORD16 shl16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16_sat(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value +// if the value is negative else shifts right and returns a 16 bit +static PLATFORM_INLINE WORD16 ixheaacd_shr16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16_sat(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +// finds a value which normalizes the input to 16 bit + +static PLATFORM_INLINE WORD16 norm16(WORD16 var1) { + WORD16 var_out; + + __asm__( + "MOVS %1, %1, LSL #16 \n\t" + "MVNMIS %1, %1 \n\t" + "MOVEQ %0, #16 \n\t" + " CLZGT %0, %1 \n\t" + "SUB %0, %0, #1 \n\t" + : "=r"(var_out) + : "r"(var1) + : "cc"); + + return (var_out); +} + +// finds no. of significant bits excluding sign bit +// value 15 returned for zero +static PLATFORM_INLINE WORD16 bin_expo16(WORD16 op1) { + WORD16 var_out; + + var_out = ((WORD16)(15 - norm16(op1))); + return (var_out); +} + +// returns a 16 bit absolute value of a given signed 16 bit value +static PLATFORM_INLINE WORD16 ixheaacd_abs16(WORD16 var1) { + WORD16 var_out; + __asm__( + " MOVS %0, %1, LSL #16 \n\t" + " RSBLTS %0 , %0, #0 \n\t" + " MOV %0, %0, ASR #16 \n\t" + : "=r"(var_out) + : "r"(var1) + : "cc"); + return (var_out); +} + +// returns a 16 bit absolute value of a given signed 16 bit value with +// saturation +static PLATFORM_INLINE WORD16 ixheaacd_abs16_sat(WORD16 var1) { + WORD16 var_out; + __asm__( + " MOVS %0, %1, LSL #16 \n\t" + " RSBLTS %0 , %0, #0 \n\t" + " MOVMI %0, #0x7fffffff \n\t" + " MOV %0, %0, ASR #16 \n\t" + : "=r"(var_out) + : "r"(var1) + : "cc"); + return (var_out); +} + +// returns a 16 bit negative value of a given signed 16 bit value. +static PLATFORM_INLINE WORD16 ixheaacd_negate16(WORD16 op1) { + WORD16 var_out; + + if (-32768 == op1) { + var_out = MAX_16; + } else { + var_out = (WORD16)(-op1); + } + return (var_out); +} + +// returns the minima of 2 16 bit variables +static PLATFORM_INLINE WORD16 ixheaacd_min16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 < op2 ? op1 : op2; + return (var_out); +} + +// returns the maxima of 2 16 bit variables +static PLATFORM_INLINE WORD16 ixheaacd_max16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 > op2 ? op1 : op2; + return (var_out); +} + +/*****************************************************************************/ +/* */ +/* function name : div16 */ +/* */ +/* description : divides 2 16 bit variables and returns the quotient */ +/* the q-format of the result is modified */ +/* ( op1/op2 to 14 bits precision) */ +/* */ +/* inputs : WORD16 op1, WORD16 op2, WORD16 *q_format */ +/* */ +/* globals : none */ +/* */ +/* processing : non-restoration type algorithm(shift & substract) */ +/* */ +/* outputs : WORD16 *q_format */ +/* */ +/* returns : WORD16 var_out */ +/* */ +/* issues : none */ +/* */ +/* revision history : */ +/* */ +/* DD MM YYYY author changes */ +/* 11 11 2003 preethi modified(bug fixes) */ +/* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ +/* */ +/*****************************************************************************/ + +// divides 2 16 bit variables and returns the quotient +static PLATFORM_INLINE WORD16 div16(WORD16 op1, WORD16 op2, WORD16 *q_format) { + WORD32 quotient; + UWORD16 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPIDX i; + WORD16 q_nr, q_dr; + + mantissa_nr = op1; + mantissa_dr = op2; + quotient = 0; + + if (op1 < 0 && op2 != 0) { + op1 = -op1; + sign = (WORD16)(sign ^ -1); + } + + if (op2 < 0) { + op2 = -op2; + sign = (WORD16)(sign ^ -1); + } + + if (op2 == 0) { + *q_format = 0; + return (op1); + } + + quotient = 0; + + q_nr = norm16(op1); + mantissa_nr = (UWORD16)op1 << (q_nr); + q_dr = norm16(op2); + mantissa_dr = (UWORD16)op2 << (q_dr); + *q_format = (WORD16)(14 + q_nr - q_dr); + + for (i = 0; i < 15; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return (WORD16)quotient; +} + +// multiply 2 16 bit variables, add 31 to 16 bits to acc +static PLATFORM_INLINE WORD16 mac16(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 31 to 16 bits to acc with saturation +static PLATFORM_INLINE WORD16 mac16_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16_sat(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 30 to 15 bits to acc +static PLATFORM_INLINE WORD16 mac16_shl(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16_shl(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 30 to 15 bits to acc with saturation +static PLATFORM_INLINE WORD16 mac16_shl_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 temp; + + temp = ((WORD32)op1 * (WORD32)op2) >> 15; + temp += c; + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +// rounds a 32 bit variable to a 16 bit variable with saturation +static PLATFORM_INLINE WORD16 ixheaacd_round16(WORD32 op1) { + WORD16 var_out; + __asm__( + " ADDS %0, %1, #0x8000 \n\t" + " IT VS \n\t" + " MVNVS %0, #0x80000000 \n\t" + " MOV %0, %0, ASR #16 \n\t" + : "=r"(var_out) + : "r"(op1) + : "cc"); + return (var_out); +} +#endif diff --git a/decoder/armv7/ixheaacd_basic_ops32.h b/decoder/armv7/ixheaacd_basic_ops32.h new file mode 100644 index 0000000..e4e546c --- /dev/null +++ b/decoder/armv7/ixheaacd_basic_ops32.h @@ -0,0 +1,516 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS32_H +#define IXHEAACD_BASIC_OPS32_H + +// returns the minima of 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_min32(WORD32 a, WORD32 b) { + WORD32 min_val; + + __asm__ __volatile__( + " CMP %1, %2 \n\t" + " ITE GT \n\t" + " MOVGT %0, %2 \n\t" + " MOVLE %0, %1 \n\t" + : "=r"(min_val) + : "r"(a), "r"(b) + : "cc"); + + return min_val; +} + +// returns the maxima of 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_max32(WORD32 a, WORD32 b) { + WORD32 max_val; + __asm__ __volatile__( + " CMP %1, %2 \n\t" + " MOVLE %0, %2 \n\t" + " MOVGT %0, %1 \n\t" + : "=r"(max_val) + : "r"(a), "r"(b) + : "cc"); + + return max_val; +} + +// shifts a 32-bit value left by specificed bits +static PLATFORM_INLINE WORD32 ixheaacd_shl32(WORD32 a, WORD b) { + WORD32 out_val; + __asm__( + + " MOV %0, %1, LSL %2 \n\t" + : "=r"(out_val) + : "r"(a), "r"(b)); + + return (out_val); +} + +// shifts a 32-bit value right by specificed bits +static PLATFORM_INLINE WORD32 ixheaacd_shr32(WORD32 a, WORD b) { + WORD32 out_val; + __asm__( + + " MOV %0, %1, ASR %2 \n\t" + : "=r"(out_val) + : "r"(a), "r"(b)); + + return out_val; +} + +// shifts a 32-bit value left by specificed bits and saturates it to 32 bits +static PLATFORM_INLINE WORD32 ixheaacd_shl32_sat(WORD32 a, WORD b) { + WORD32 out_val = a; + // WORD32 dummy1=0/*,dummy2=0*/; + + __asm__ __volatile__( + " RSBS r3, %2, #31 \n\t" + " MOVS r3, %1, ASR r3 \n\t" + " ITT LT \n\t" + " CMNLT r3, #1 \n\t" + " MOVLT %0, #0x80000000 \n\t" + " IT GT \n\t" + " MOVGT %0, #0x7fffffff \n\t" + " IT EQ \n\t" + " MOVEQ %0, %1, LSL %2 \n\t" + : "=r"(out_val) + : "r"(a), "r"(b) + : "cc", "r3"); + + return (out_val); +} + +// shifts a 32-bit value left by specificed bits, shifts +// it right if specified no. of bits is negative + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir(WORD32 a, WORD b) { + WORD32 out_val = 0; + // WORD32 dummy=0; + + __asm__ __volatile__( + + " RSBS r3, %2, #0 \n\t" + " MOVMI %0, %1, LSL %2 \n\t" + " MOVPL %0, %1, ASR r3 \n\t" + : "=r"(out_val) + : "r"(a), "r"((WORD)b) + : "cc", "r3"); + return out_val; +} + +// shifts a 32-bit value left by specificed bits with sat, +// shifts it right if specified no. of bits is negative + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shr32(a, -b); + } else { + out_val = ixheaacd_shl32_sat(a, b); + } + + return out_val; +} + +// shifts a 32-bit value right by specificed bits, shifts +// it left if specified no. of bits is negative +static PLATFORM_INLINE WORD32 ixheaacd_shr32_dir(WORD32 a, WORD b) { + WORD32 out_val = 0; + __asm__ __volatile__( + " RSBS r3, %2, #0 \n\t" + " IT MI \n\t" + " MOVMI %0, %1, ASR %2 \n\t" + " IT PL \n\t" + " MOVPL %0, %1, LSL r3 \n\t" + : "=r"(out_val) + : "r"(a), "r"(b) + : "cc", "r3"); + + return out_val; +} + +// shifts a 32-bit value right by specificed bits, shifts +// it left with sat if specified no. of bits is negative +static PLATFORM_INLINE WORD32 shr32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32_sat(a, -b); + } else { + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +// multiplies two 16 bit numbers and returns their 32-bit result +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32(WORD16 a, WORD16 b) { + WORD32 product; + __asm__( + + " SMULBB %0 , %1, %2 \n\t" + : "=r"(product) + : "r"(a), "r"(b)); + return product; +} + +// multiplies two 16 bit numbers and returns their 32-bit +// result after removing 1 redundant sign bit +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl(WORD16 a, WORD16 b) { + WORD32 product; + __asm__( + + " SMULBB %0 , %1, %2 \n\t" + " MOV %0, %0, LSL #1 \n\t" + : "=r"(product) + : "r"(a), "r"(b)); + return product; +} + +// multiplies two 16 bit numbers and returns their 32-bit +// result after removing 1 redundant sign bit with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl_sat(WORD16 a, + WORD16 b) { + WORD32 product; + __asm__( + + " SMULBB %0 , %1, %2 \n\t" + " QADD %0, %0, %0 \n\t" + : "=r"(product) + : "r"(a), "r"(b)); + return product; +} + +// adds 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_add32(WORD32 a, WORD32 b) { + WORD32 sum; + __asm__( + + " ADD %0 , %1, %2 \n\t" + : "=r"(sum) + : "r"(a), "r"(b)); + return (sum); +} + +// subtract 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_sub32(WORD32 a, WORD32 b) { + WORD32 diff; + __asm__( + + " SUB %0 , %1, %2 \n\t" + : "=r"(diff) + : "r"(a), "r"(b)); + return (diff); +} + +// adds 2 32 bit variables with saturation +static PLATFORM_INLINE WORD32 ixheaacd_add32_sat(WORD32 a, WORD32 b) { + WORD32 sum; + __asm__( + + " QADD %0 , %1, %2 \n\t" + : "=r"(sum) + : "r"(a), "r"(b)); + return (sum); +} + +// subtract 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_sub32_sat(WORD32 a, WORD32 b) { + WORD32 diff; + __asm__( + + " QSUB %0 , %1, %2 \n\t" + : "=r"(diff) + : "r"(a), "r"(b)); + return (diff); +} + +// returns number of redundant sign bits in a 32-bit value. +// return zero for a value of zero +static PLATFORM_INLINE WORD ixheaacd_norm32(WORD32 a) { + WORD32 norm_val; + __asm__( + " eor %0 , %1, %1,asr #31 \n\t" + " CLZ %0, %0 \n\t" + " SUB %0, %0, #1 \n\t" + : "=r"(norm_val) + : "r"(a)); + return norm_val; +} + +static PLATFORM_INLINE WORD ixheaacd_pnorm32(WORD32 a) { + WORD32 norm_val; + __asm__( + + " CLZ %0, %1 \n\t" + " SUB %0, %0, #1 \n\t" + : "=r"(norm_val) + : "r"(a)); + return norm_val; +} + +// returns the position of the most significant bit for negative numbers. +// ignores leading zeros to determine the position of most significant bit. +static PLATFORM_INLINE WORD bin_expo32(WORD32 a) { + WORD bin_expo_val; + + bin_expo_val = 31 - ixheaacd_norm32(a); + + return bin_expo_val; +} + +// returns the absolute value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_abs32(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a < 0) { + abs_val = -a; + } + + return abs_val; +} + +// returns the absolute value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_abs32_nrm(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a < 0) { + abs_val = ~a; + } + + return abs_val; +} + +// returns the absolute value of 32-bit number with saturation +static PLATFORM_INLINE WORD32 ixheaacd_abs32_sat(WORD32 a) { + WORD32 abs_val; + __asm__ __volatile__( + + " MOVS %0 , %1 \n\t" + " IT MI \n\t" + " RSBSMI %0 , %1 , #0 \n\t" + " IT MI \n\t" + " MOVMI %0 , #0x7fffffff \n\t" + : "=r"(abs_val) + : "r"(a) + : "cc"); + + return abs_val; +} + +// returns the negated value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_negate32(WORD32 a) { + WORD32 neg_val; + __asm__(" RSB %0, %1, #0 \n\t" : "=r"(neg_val) : "r"(a)); + return neg_val; +} + +// returns the negated value of 32-bit number with saturation +static PLATFORM_INLINE WORD32 ixheaacd_negate32_sat(WORD32 a) { + WORD32 neg_val; + __asm__( + " RSBS %0, %1, #0 \n\t" + " IT VS \n\t" + " MVNVS %0, #0x80000000 \n\t" + : "=r"(neg_val) + : "r"(a) + : "cc"); + return neg_val; +} + +// divides 2 32 bit variables and returns the quotient +static PLATFORM_INLINE WORD32 div32(WORD32 a, WORD32 b, WORD *q_format) { + WORD32 quotient; + UWORD32 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPINDEX i; + WORD q_nr, q_dr; + + mantissa_nr = a; + mantissa_dr = b; + quotient = 0; + + if ((a < 0) && (0 != b)) { + a = -a; + sign = (WORD16)(sign ^ -1); + } + + if (b < 0) { + b = -b; + sign = (WORD16)(sign ^ -1); + } + + if (0 == b) { + *q_format = 0; + return (a); + } + + quotient = 0; + + q_nr = ixheaacd_norm32(a); + mantissa_nr = (UWORD32)a << (q_nr); + q_dr = ixheaacd_norm32(b); + mantissa_dr = (UWORD32)b << (q_dr); + *q_format = (WORD)(30 + q_nr - q_dr); + + for (i = 0; i < 31; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return quotient; +} + +// multiplies two 16 bit numbers and accumulates their result in a 32 bit +// variable +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + __asm__( + + " SMLABB %0, %2, %3, %1 \n\t" + : "=r"(acc) + : "r"(a), "r"(b), "r"(c) + + ); + + return acc; +} + +// multiplies lower 16 bit of one data with upper 16 bit of +// other and accumulates their result in a 32 bit variable +static PLATFORM_INLINE WORD32 mac16x16hin32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32((WORD16)b, (WORD16)(c >> 16)); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and accumulates their result in a 32 bit +// variable +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and accumulates their +// result in a 32 bit variable with saturation + +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_add32_sat(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable +static PLATFORM_INLINE WORD32 msu16x16in32(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable after removing a redundant sign bit in the +// product +static PLATFORM_INLINE WORD32 msu16x16in32_shl(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable with saturation +// after removing a redundant sign bit in the product +static PLATFORM_INLINE WORD32 msu16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_sub32_sat(a, acc); + + return acc; +} + +// adding two 32 bit numbers and taking care of overflow +// by downshifting both numbers before addition +static PLATFORM_INLINE WORD32 add32_shr(WORD32 a, WORD32 b) { + WORD32 sum; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + sum = ixheaacd_add32(a, b); + + return sum; +} + +// subtracting two 32 bit numbers and taking care of +// overflow by downshifting both numbers before addition + +static PLATFORM_INLINE WORD32 sub32_shr(WORD32 a, WORD32 b) { + WORD32 diff; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + diff = ixheaacd_sub32(a, b); + + return diff; +} +#endif diff --git a/decoder/armv7/ixheaacd_basic_ops40.h b/decoder/armv7/ixheaacd_basic_ops40.h new file mode 100644 index 0000000..f7c4df8 --- /dev/null +++ b/decoder/armv7/ixheaacd_basic_ops40.h @@ -0,0 +1,400 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS40_H +#define IXHEAACD_BASIC_OPS40_H +#define lo64(a) (((unsigned *)&a)[0]) /* low 32 bits of a long long */ +#define hi64(a) (((WORD32 *)&a)[1]) /* high 32 bits of a long long */ + +// normalize input to 32 bits, return denormalizing info +static PLATFORM_INLINE WORD16 norm40(WORD40 *in) { + WORD16 expo; + WORD32 tempo; + + if (0 == (*in)) return 31; + + if (((*in) <= 0x7fffffff) && ((WORD40)(*in) >= (WORD40)0xFFFFFFFF80000000)) { + tempo = (WORD32)(*in); + expo = ixheaacd_norm32(tempo); + *in = tempo << expo; + + return (expo); + } + + tempo = (WORD32)((*in) >> 31); + expo = 31 - (ixheaacd_norm32(tempo)); + *in = (*in) >> expo; + + return (-expo); +} + +// adds two numbers and right shifts by 1 +static PLATFORM_INLINE WORD32 add32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a + (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +// subtracts and right shifts by one +static PLATFORM_INLINE WORD32 sub32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a - (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +// multiply WORD32 with WORD16 return bits 46 to 15 +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl(WORD32 a, WORD16 b) { + WORD32 result; + __asm__( + + " SMULWB %0, %1, %2 \n\t" + " MOV %0, %0, LSL #1 \n\t" + : "=r"(result) + : "r"(a), "r"(b)); + return result; +} + +// multiply WORD32 with higher 16 bits of second data and return bits 46 to 15 +static PLATFORM_INLINE WORD32 mult32x16hin32_shl(WORD32 a, WORD32 b) { + WORD32 product; + WORD64 temp_product; + + temp_product = (WORD64)a * (WORD64)(b >> 16); + product = (WORD32)(temp_product >> 16); + + return (product << 1); +} + +// multiply WORD32 with WORD16 return bits 47 to 16 +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32(WORD32 a, WORD16 b) { + WORD32 result; + __asm__( + + " SMULWB %0, %1, %2 \n\t" + : "=r"(result) + : "r"(a), "r"(b)); + return (result); +} + +// multiply WORD32 with WORD16 return bits 46 to 15 with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl_sat(WORD32 a, + WORD16 b) { + WORD32 result; + + __asm__( + + " SMULWB %0, %1, %2 \n\t" + " QADD %0, %0, %0 \n\t" + : "=r"(result) + : "r"(a), "r"(b)); + return (result); +} + +// multiply WORD32 with WORD32 return bits 62 to 31 +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl(WORD32 a, WORD32 b) { + WORD32 resultHi; + + __asm__( + + " smull r3, %0, %1, %2 \n\t" + " MOV %0, %0, LSL #1 \n\t" + : "=r"(resultHi) + : "r"(a), "r"(b) + : "cc", "r3"); + + return resultHi; +} + +// multiply WORD32 with WORD32 return bits 63 to 32 +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { + WORD32 resultHi; + __asm__( + + " smull r3, %0, %1, %2 \n\t" + : "=r"(resultHi) + : "r"(a), "r"(b) + : "r3"); + return resultHi; +} + +// multiply WORD32 with WORD32 return bits 62 to 31 with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl_sat(WORD32 a, WORD32 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD32)0x80000000) { + result = 0x7fffffff; + } else { + result = ixheaacd_mult32_shl(a, b); + } + + return (result); +} + +// multiply WORD32 with WORD16 add bits 47 to 16 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 add bits 46 to 15 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32_shl(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 add bits 46 to 15 to accumulator with saturation +static PLATFORM_INLINE WORD32 mac32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD32 add bits 63 to 32 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 add bits 62 to 31 to accumulator +static PLATFORM_INLINE WORD32 mac32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 add bits 62 to 31 to accumulator with saturation +static PLATFORM_INLINE WORD32 mac32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD16 sub bits 47 to 16 from accumulator +static PLATFORM_INLINE WORD32 msu32x16in32(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 sub bits 46 to 15 from accumulator +static PLATFORM_INLINE WORD32 msu32x16in32_shl(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 sub bits 46 to 15 from accumulator with +// saturation +static PLATFORM_INLINE WORD32 msu32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD32 sub bits 63 to 32 from accumulator +static PLATFORM_INLINE WORD32 msu32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 sub bits 62 to 31 from accumulator +static PLATFORM_INLINE WORD32 msu32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 sub bits 62 to 31 from accumulator with +// saturation +static PLATFORM_INLINE WORD32 msu32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac3216_arr40(WORD32 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32x16in32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return (WORD32)sum; +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac32_arr40(WORD32 *x, WORD32 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac16_arr40(WORD16 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)((WORD32)x[i] * (WORD32)y[i]); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 add32_arr40(WORD32 *in_arr, LOOPINDEX length, + WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)in_arr[i]; + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +// multiply WORD32 with WORD32 return WORD64 +static PLATFORM_INLINE WORD64 ixheaacd_mult32x32in64(WORD32 a, WORD32 b) { + WORD64 result; + + result = (WORD64)a * (WORD64)b; + + return (result); +} + +// multiply WORD32 with WORD32 and accumulate the 64 bit result +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64(WORD64 sum, WORD32 a, + WORD32 b) { + sum += (WORD64)a * (WORD64)b; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_7(WORD64 sum, + const WORD32 *a, + const WORD16 *b) { + sum = (WORD64)a[0] * (WORD64)b[0]; + sum += (WORD64)a[1] * (WORD64)b[1]; + sum += (WORD64)a[2] * (WORD64)b[2]; + sum += (WORD64)a[3] * (WORD64)b[3]; + sum += (WORD64)a[4] * (WORD64)b[4]; + sum += (WORD64)a[5] * (WORD64)b[5]; + sum += (WORD64)a[6] * (WORD64)b[6]; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_n(WORD64 sum, + const WORD32 *a, + const WORD16 *b, + WORD32 n) { + WORD32 k; + + sum += (WORD64)a[0] * (WORD64)b[0]; + for (k = 1; k < n; k++) sum += (WORD64)a[k] * (WORD64)b[k]; + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mult64(WORD32 a, WORD32 b) { + WORD64 result; + result = (WORD64)a * (WORD64)b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_add64(WORD64 a, WORD64 b) { + WORD64 result; + result = a + b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = (WORD64)a - (WORD64)b; + + return diff; +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64_sat(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = ixheaacd_sub64(a, b); + + if ((((WORD64)a ^ (WORD64)b) & (WORD64)MIN_64) != 0) { + if (((WORD64)diff ^ (WORD64)a) & (WORD64)MIN_64) { + diff = (a < 0L) ? MIN_64 : MAX_64; + } + } + + return (diff); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mul32_sh(WORD32 a, WORD32 b, + WORD8 shift) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> shift); + + return (result); +} + +#endif diff --git a/decoder/armv7/ixheaacd_calc_post_twid.s b/decoder/armv7/ixheaacd_calc_post_twid.s new file mode 100644 index 0000000..e2ddbb7 --- /dev/null +++ b/decoder/armv7/ixheaacd_calc_post_twid.s @@ -0,0 +1,109 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_calc_post_twid_armv7 +ixheaacd_calc_post_twid_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + LDR R4, [SP, #104] + LDR R5, [SP, #108] + ADD R6, R0, R3, LSL #3 + SUB R6, R6, #4 + MOV R7, #-8 + MOV R8, #8 + +LOOP1: + VLD1.32 {D0, D1}, [R4]! + VLD1.32 {D2, D3}, [R5]! + VLD1.32 {D4, D5}, [R1]! + VLD1.32 {D6, D7}, [R2]! + + VMULL.S32 Q4, D4, D0 + VMULL.S32 Q5, D6, D2 + VMULL.S32 Q6, D6, D0 + VMULL.S32 Q7, D4, D2 + VMULL.S32 Q8, D5, D1 + VMULL.S32 Q9, D7, D3 + VMULL.S32 Q10, D7, D1 + VMULL.S32 Q11, D5, D3 + + VSHRN.S64 D6, Q4, #32 + VSHRN.S64 D8, Q5, #32 + VSHRN.S64 D10, Q6, #32 + VSHRN.S64 D12, Q7, #32 + VSHRN.S64 D7, Q8, #32 + VSHRN.S64 D9, Q9, #32 + VSHRN.S64 D11, Q10, #32 + VSHRN.S64 D13, Q11, #32 + + VSUB.I32 D0, D6, D8 + VADD.I32 D1, D10, D12 + VSUB.I32 D2, D7, D9 + VADD.I32 D3, D11, D13 + + VNEG.S32 Q0, Q0 + VNEG.S32 Q1, Q1 + SUBS R3, R3, #4 + + VST1.32 {D0[0]}, [R0], R8 + VST1.32 {D1[0]}, [R6], R7 + VST1.32 {D0[1]}, [R0], R8 + VST1.32 {D1[1]}, [R6], R7 + + VST1.32 {D2[0]}, [R0], R8 + VST1.32 {D3[0]}, [R6], R7 + VST1.32 {D2[1]}, [R0], R8 + VST1.32 {D3[1]}, [R6], R7 + BGT LOOP1 + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/decoder/armv7/ixheaacd_calc_pre_twid.s b/decoder/armv7/ixheaacd_calc_pre_twid.s new file mode 100644 index 0000000..2b6565f --- /dev/null +++ b/decoder/armv7/ixheaacd_calc_pre_twid.s @@ -0,0 +1,107 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_calc_pre_twid_armv7 +ixheaacd_calc_pre_twid_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + LDR R4, [SP, #104] + LDR R5, [SP, #108] + ADD R6, R0, R3, LSL #3 + SUB R6, R6, #12 + MOV R7, #-16 + +LOOP1: + VLD1.32 {D0, D1}, [R4]! + VLD1.32 {D2, D3}, [R5]! + VLD2.32 {D4, D5}, [R0]! + VLD2.32 {D6, D7}, [R0]! + VLD2.32 {D8, D9}, [R6], R7 + VLD2.32 {D10, D11}, [R6], R7 + + VREV64.32 D8, D8 + VREV64.32 D9, D10 + VNEG.S32 D5, D4 + VNEG.S32 D7, D6 + + VMULL.S32 Q6, D0, D5 + VMULL.S32 Q7, D2, D8 + VMULL.S32 Q8, D0, D8 + VMULL.S32 Q9, D2, D4 + VMULL.S32 Q10, D1, D7 + VMULL.S32 Q11, D9, D3 + VMULL.S32 Q12, D1, D9 + VMULL.S32 Q13, D3, D6 + + + VSHRN.S64 D12, Q6, #32 + VSHRN.S64 D14, Q7, #32 + VSHRN.S64 D16, Q8, #32 + VSHRN.S64 D18, Q9, #32 + VSHRN.S64 D20, Q10, #32 + VSHRN.S64 D22, Q11, #32 + VSHRN.S64 D24, Q12, #32 + VSHRN.S64 D26, Q13, #32 + + VSUB.I32 D0, D12, D14 + VSUB.I32 D2, D16, D18 + VSUB.I32 D1, D20, D22 + VSUB.I32 D3, D24, D26 + + SUBS R3, R3, #4 + VST1.32 {D0, D1}, [R1]! + VST1.32 {D2, D3}, [R2]! + + BGT LOOP1 + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/decoder/armv7/ixheaacd_calcmaxspectralline.s b/decoder/armv7/ixheaacd_calcmaxspectralline.s new file mode 100644 index 0000000..362a978 --- /dev/null +++ b/decoder/armv7/ixheaacd_calcmaxspectralline.s @@ -0,0 +1,82 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_calc_max_spectral_line_armv7 + +ixheaacd_calc_max_spectral_line_armv7: + + STMFD sp!, {R4-R12, R14} + MOV R4, R1, LSR #3 + MOV R6, R4, LSL #3 + VMOV.S32 D6, #0x00000000 + VMOV.S32 D7, #0x00000000 + +LOOP_1: + VLD1.32 {D0, D1}, [R0]! + + VLD1.32 {D2, D3}, [R0]! + VABS.S32 Q0, Q0 + + + VABS.S32 Q1, Q1 + SUBS R4, R4, #1 + + VORR Q3, Q0, Q3 + + VORR Q3, Q1, Q3 + BGT LOOP_1 + + SUBS R7, R1, R6 + + VMOV.32 R4, D6[0] + VMOV.32 R1, D6[1] + VMOV.32 R2, D7[0] + ORR R4, R4, R1 + VMOV.32 R3, D7[1] + ORR R4, R4, R2 + + + ORR R4, R4, R3 + BEQ END_FUNC +LOOP_2: + + LDR R2, [R0], #4 + MOVS R2, R2 + RSBMI R2, R2, #0 + ORR R4, R4, R2 + SUBS R7, R7, #1 + BGT LOOP_2 + +END_FUNC: + + MOVS R0, R4 + MVNMI R0, R0 + CLZ R0, R0 + SUB R0, R0, #1 + + LDMFD sp!, {R4-R12, R15} + + + + + diff --git a/decoder/armv7/ixheaacd_complex_fft_p2.s b/decoder/armv7/ixheaacd_complex_fft_p2.s new file mode 100644 index 0000000..e427088 --- /dev/null +++ b/decoder/armv7/ixheaacd_complex_fft_p2.s @@ -0,0 +1,809 @@ +.text +.p2align 2 +.global ixheaacd_complex_fft_p2_asm + +ixheaacd_complex_fft_p2_asm: + STMFD sp!, {r0-r12, lr} + SUB sp, sp, #0x28 + LDR r0, [sp, #0x2c] + @LDR r12,[sp,#0x5c+4] + EOR r0, r0, r0, ASR #31 + CLZ r0, r0 + SUB r12, r0, #16 @dig_rev_shift = norm32(npoints) + 1 -16@ + SUB r0, r0, #1 + RSB r0, r0, #0x1e + AND r1, r0, #1 + STR r1, [sp, #0x14] + MOV r1, r0, ASR #1 + LDR r0, [sp, #0x2c] @npoints + STR r1, [sp, #-4]! + MOV lr, r0, LSL #1 @(npoints >>1) * 4 + MOV r0, #0 + +FIRST_STAGE_R4: + LDR r4, =0x33333333 + LDR r5, =0x0F0F0F0F + AND r6, r4, r0 + AND r7, r4, r0, LSR #2 + ORR r4, r7, r6, LSL #2 + AND r6, r5, r4 + AND r7, r5, r4, LSR #4 + ORR r4, r7, r6, LSL #4 + BIC r6, r4, #0x0000FF00 + BIC r7, r4, #0x00FF0000 + MOV r7, r7, LSR #8 + ORR r4, r7, r6, LSL #8 + LDR r5, [sp, #0x18] + MOV r10, r4, LSR r12 + CMP r5, #0 + ADDNE r10, r10, #1 + BICNE r10, r10, #1 + + ADD r1, r2, r10, LSL #2 + LDRD r4, [r1] @r4=x0r, r5=x0i + ADD r1, r1, lr + LDRD r8, [r1] @r8=x1r, r9=x1i + ADD r1, r1, lr + LDRD r6, [r1] @r6=x2r, r7=x2i + ADD r1, r1, lr + LDRD r10, [r1] @r10=x3r, r11=x3i + ADD r0, r0, #4 + CMP r0, lr, ASR #1 + + ADD r4, r4, r6 @x0r = x0r + x2r@ + ADD r5, r5, r7 @x0i = x0i + x2i@ + SUB r6, r4, r6, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r7, r5, r7, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r8, r8, r10 @x1r = x1r + x3r@ + ADD r9, r9, r11 @x1i = x1i + x3i@ + SUB r1, r8, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r9, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r8 @x0r = x0r + x1r@ + ADD r5, r5, r9 @x0i = x0i + x1i@ + SUB r8, r4, r8, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r9, r5, r9, lsl#1 @x1i = x0i - (x1i << 1) + ADD r6, r6, r11 @x2r = x2r + x3i@ + SUB r7, r7, r1 @x2i = x2i - x3r@ + SUB r10, r6, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r11, r7, r1, lsl#1 @x3r = x2i + (x3r << 1)@ + + STMIA r3!, {r4-r11} + BLT FIRST_STAGE_R4 + LDR r1, [sp], #4 + LDR r0, [sp, #0x2c] + MOV r12, #0x40 @nodespacing = 64@ + STR r12, [sp, #0x1c] + LDR r12, [sp, #0x2c] + SUB r3, r3, r0, LSL #3 + SUBS r1, r1, #1 + STR r3, [sp, #0x34] + MOV r4, r12, ASR #4 + MOV r0, #4 + STR r4, [sp, #0x18] + STR r1, [sp, #0x20] + BLE RADIX2 +OUTER_LOOP: + LDR r1, [sp, #0x28] + LDR r12, [sp, #0x34] @WORD32 *data = ptr_y@ + STR r1, [sp, #0x10] + LDR r1, [sp, #0x18] + + MOV r0, r0, LSL #3 @(del<<1) * 4 +LOOP_TRIVIAL_TWIDDLE: + LDRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + LDRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + LDRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + LDRD r10, [r12] @r10=x3r, r11=x3i + +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 +@MOV r6,r6,ASR #1 +@MOV r7,r7,ASR #1 +@MOV r8,r8,ASR #1 +@MOV r9,r9,ASR #1 +@MOV r10,r10,ASR #1 +@MOV r11,r11,ASR #1 + + ADD r4, r4, r8 @x0r = x0r + x2r@ + ADD r5, r5, r9 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl #1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl #1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r2, r6, r10, lsl #1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl #1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 + SUB r6, r4, r6, lsl #1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl #1 @x1i = x0i - (x1i << 1) + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r2 @x2i = x2i - x3r@ + SUB r10, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r11, r9, r2, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r10, [r12] @r10=x3r, r11=x3i + SUB r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + SUB r12, r12, r0 + STRD r8, [r12] @r8=x2r, r9=x2i + SUB r12, r12, r0 + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0, lsl #2 + + SUBS r1, r1, #1 + BNE LOOP_TRIVIAL_TWIDDLE + + MOV r0, r0, ASR #3 + LDR r4, [sp, #0x1c] + LDR r3, [sp, #0x34] + MUL r1, r0, r4 + ADD r12, r3, #8 + STR r1, [sp, #0x24] + MOV r3, r1, ASR #2 + ADD r3, r3, r1, ASR #3 + SUB r3, r3, r1, ASR #4 + ADD r3, r3, r1, ASR #5 + SUB r3, r3, r1, ASR #6 + ADD r3, r3, r1, ASR #7 + SUB r3, r3, r1, ASR #8 + STR r3, [sp, #-4]! +SECOND_LOOP: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY: + + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r9, r9, r8 + SUB r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r11, r11, r10 + SUB r10, r4, r5 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7 + BLE SECOND_LOOP + +SECOND_LOOP_2: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_2: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r9, r9, r8 + SUB r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r10, r11, r10 + SUB r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_2 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7, ASR #1 + BLE SECOND_LOOP_2 + LDR r7, [sp, #0] + CMP r4, r7, LSL #1 + BGT SECOND_LOOP_4 + +SECOND_LOOP_3: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + + +RADIX4_BFLY_3: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r8, r9, r8 + SUB r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r10, r11, r10 + SUB r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_3 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7, LSL #1 + BLE SECOND_LOOP_3 + +SECOND_LOOP_4: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_4: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r8, r9, r8 + SUB r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r11, r11, r10 + SUB r10, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + SUB r7, r7, r11 @x1i = x1i - x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + ADD r11, r7, r11, lsl#1 @x3i = x1i + (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_4 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7 + BLT SECOND_LOOP_4 + ADD sp, sp, #4 + + LDR r1, [sp, #0x1c] + MOV r0, r0, LSL #2 + MOV r1, r1, ASR #2 + STR r1, [sp, #0x1c] + LDR r1, [sp, #0x18] + MOV r1, r1, ASR #2 + STR r1, [sp, #0x18] + LDR r1, [sp, #0x20] + SUBS r1, r1, #1 + STR r1, [sp, #0x20] + BGT OUTER_LOOP + +RADIX2: + LDR r1, [sp, #0x14] + CMP r1, #0 + BEQ EXIT + LDR r12, [sp, #0x1c] + LDR r1, [sp, #0x28] + CMP r12, #0 + LDRNE r12, [sp, #0x1c] + MOVEQ r4, #1 + MOVNE r4, r12, LSL #1 + MOVS r3, r0 + BEQ EXIT + + MOV r3, r3, ASR #1 + LDR r5, [sp, #0x34] + MOV r0, r0, LSL #3 @(del<<1) * 4 + STR r1, [sp, #-4] +RADIX2_BFLY: + LDR r1, [sp, #-4] + LDRD r6, [r5] @r6 = x0r + ADD r5, r5, r0 + LDRD r8, [r5] @r8 = x1r + + LDR r2, [r1] + SUBS r3, r3, #1 + + + SMULL r1, r11, r8, r2 @mult32x16hin32(x1r,W1h) + LSR r1, r1, #31 + ORR r11, r1, r11, LSL#1 + SMULL r1, r10, r9, r2 @mult32x16hin32(x1i,W1h) + LSR r1, r1, #31 + ORR r10, r1, r10, LSL#1 + + + LDR r1, [sp, #-4] + LDR r2, [r1, #4] + ADD r1, r1, r4, LSL #3 + STR r1, [sp, #-4] + + SMULL r1, r8, r8, r2 @ixheaacd_mult32(x1r,w1l) + LSR r1, r1, #31 + ORR r8, r1, r8, LSL#1 + SMULL r1, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r1, r1, #31 + ORR r9, r1, r9, LSL#1 + + SUB r8, r8, r10 + ADD r9, r9, r11 + + + ADD r10, r8, r6 @(x0r/2) + (x1r/2) + ASR r10, r10, #1 + ADD r11, r9, r7 @(x0i/2) + (x1i/2)@ + ASR r11, r11, #1 + SUB r8, r6, r8 @(x0r/2) - (x1r/2) + ASR r8, r8, #1 + SUB r9, r7, r9 @(x0i/2) - (x1i/2)@ + ASR r9, r9, #1 + + STRD r8, [r5] + SUB r5, r5, r0 + STRD r10, [r5], #8 + + BNE RADIX2_BFLY + + LDR r1, [sp, #0x28] + MOV r3, r0, ASR #4 + STR r1, [sp, #-4] +RADIX2_BFLY_2: + LDR r1, [sp, #-4] + LDRD r6, [r5] @r6 = x0r + ADD r5, r5, r0 + LDRD r8, [r5] @r8 = x1r + + LDR r2, [r1] + SUBS r3, r3, #1 + + + + SMULL r1, r11, r8, r2 @mult32x16hin32(x1r,W1h) + LSR r1, r1, #31 + ORR r11, r1, r11, LSL#1 + SMULL r1, r10, r9, r2 @mult32x16hin32(x1i,W1h) + LSR r1, r1, #31 + ORR r10, r1, r10, LSL#1 + + + LDR r1, [sp, #-4] + LDR r2, [r1, #4] + ADD r1, r1, r4, LSL #3 + STR r1, [sp, #-4] + + SMULL r1, r8, r8, r2 @ixheaacd_mult32(x1r,w1l) + LSR r1, r1, #31 + ORR r8, r1, r8, LSL#1 + SMULL r1, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r1, r1, #31 + ORR r9, r1, r9, LSL#1 + + ADD r11, r11, r9 + SUB r9, r10, r8 @ + MOV r8, r11 + + ADD r10, r8, r6 @(x0r>>1) + (x1r) + ASR r10, r10, #1 + ADD r11, r9, r7 @(x0i>>1) + (x1i)@ + ASR r11, r11, #1 + SUB r8, r6, r8 @(x0r>>1) - (x1r) + ASR r8, r8, #1 + SUB r9, r7, r9 @(x0i>>1) - (x1i)@ + ASR r9, r9, #1 + + STRD r8, [r5] + SUB r5, r5, r0 + STRD r10, [r5], #8 + + BNE RADIX2_BFLY_2 + +EXIT: + ADD sp, sp, #0x38 + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_complex_ifft_p2.s b/decoder/armv7/ixheaacd_complex_ifft_p2.s new file mode 100644 index 0000000..81c9716 --- /dev/null +++ b/decoder/armv7/ixheaacd_complex_ifft_p2.s @@ -0,0 +1,809 @@ +.text +.p2align 2 +.global ixheaacd_complex_ifft_p2_asm + +ixheaacd_complex_ifft_p2_asm: + STMFD sp!, {r0-r12, lr} + SUB sp, sp, #0x28 + LDR r0, [sp, #0x2c] + @LDR r12,[sp,#0x5c+4] + EOR r0, r0, r0, ASR #31 + CLZ r0, r0 + SUB r12, r0, #16 @dig_rev_shift = norm32(npoints) + 1 -16@ + SUB r0, r0, #1 + RSB r0, r0, #0x1e + AND r1, r0, #1 + STR r1, [sp, #0x14] + MOV r1, r0, ASR #1 + LDR r0, [sp, #0x2c] @npoints + STR r1, [sp, #-4]! + MOV lr, r0, LSL #1 @(npoints >>1) * 4 + MOV r0, #0 + +FIRST_STAGE_R4: + LDR r4, =0x33333333 + LDR r5, =0x0F0F0F0F + AND r6, r4, r0 + AND r7, r4, r0, LSR #2 + ORR r4, r7, r6, LSL #2 + AND r6, r5, r4 + AND r7, r5, r4, LSR #4 + ORR r4, r7, r6, LSL #4 + BIC r6, r4, #0x0000FF00 + BIC r7, r4, #0x00FF0000 + MOV r7, r7, LSR #8 + ORR r4, r7, r6, LSL #8 + LDR r5, [sp, #0x18] + MOV r10, r4, LSR r12 + CMP r5, #0 + ADDNE r10, r10, #1 + BICNE r10, r10, #1 + + ADD r1, r2, r10, LSL #2 + LDRD r4, [r1] @r4=x0r, r5=x0i + ADD r1, r1, lr + LDRD r8, [r1] @r8=x1r, r9=x1i + ADD r1, r1, lr + LDRD r6, [r1] @r6=x2r, r7=x2i + ADD r1, r1, lr + LDRD r10, [r1] @r10=x3r, r11=x3i + ADD r0, r0, #4 + CMP r0, lr, ASR #1 + + ADD r4, r4, r6 @x0r = x0r + x2r@ + ADD r5, r5, r7 @x0i = x0i + x2i@ + SUB r6, r4, r6, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r7, r5, r7, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r8, r8, r10 @x1r = x1r + x3r@ + ADD r9, r9, r11 @x1i = x1i + x3i@ + SUB r1, r8, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r9, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r8 @x0r = x0r + x1r@ + ADD r5, r5, r9 @x0i = x0i + x1i@ + SUB r8, r4, r8, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r9, r5, r9, lsl#1 @x1i = x0i - (x1i << 1) + SUB r6, r6, r11 @x2r = x2r - x3i@ + ADD r7, r7, r1 @x2i = x2i + x3r@ + ADD r10, r6, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r11, r7, r1, lsl#1 @x3r = x2i - (x3r << 1)@ + + STMIA r3!, {r4-r11} + BLT FIRST_STAGE_R4 + LDR r1, [sp], #4 + LDR r0, [sp, #0x2c] + MOV r12, #0x40 @nodespacing = 64@ + STR r12, [sp, #0x1c] + LDR r12, [sp, #0x2c] + SUB r3, r3, r0, LSL #3 + SUBS r1, r1, #1 + STR r3, [sp, #0x34] + MOV r4, r12, ASR #4 + MOV r0, #4 + STR r4, [sp, #0x18] + STR r1, [sp, #0x20] + BLE RADIX2 +OUTER_LOOP: + LDR r1, [sp, #0x28] + LDR r12, [sp, #0x34] @WORD32 *data = ptr_y@ + STR r1, [sp, #0x10] + LDR r1, [sp, #0x18] + + MOV r0, r0, LSL #3 @(del<<1) * 4 +LOOP_TRIVIAL_TWIDDLE: + LDRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + LDRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + LDRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + LDRD r10, [r12] @r10=x3r, r11=x3i + +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 +@MOV r6,r6,ASR #1 +@MOV r7,r7,ASR #1 +@MOV r8,r8,ASR #1 +@MOV r9,r9,ASR #1 +@MOV r10,r10,ASR #1 +@MOV r11,r11,ASR #1 + + ADD r4, r4, r8 @x0r = x0r + x2r@ + ADD r5, r5, r9 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl #1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl #1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r2, r6, r10, lsl #1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl #1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 + SUB r6, r4, r6, lsl #1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl #1 @x1i = x0i - (x1i << 1) + SUB r8, r8, r11 @x2r = x2r - x3i@ + ADD r9, r9, r2 @x2i = x2i + x3r@ + ADD r10, r8, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r11, r9, r2, lsl#1 @x3r = x2i - (x3r << 1) + + STRD r10, [r12] @r10=x3r, r11=x3i + SUB r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + SUB r12, r12, r0 + STRD r8, [r12] @r8=x2r, r9=x2i + SUB r12, r12, r0 + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0, lsl #2 + + SUBS r1, r1, #1 + BNE LOOP_TRIVIAL_TWIDDLE + + MOV r0, r0, ASR #3 + LDR r4, [sp, #0x1c] + LDR r3, [sp, #0x34] + MUL r1, r0, r4 + ADD r12, r3, #8 + STR r1, [sp, #0x24] + MOV r3, r1, ASR #2 + ADD r3, r3, r1, ASR #3 + SUB r3, r3, r1, ASR #4 + ADD r3, r3, r1, ASR #5 + SUB r3, r3, r1, ASR #6 + ADD r3, r3, r1, ASR #7 + SUB r3, r3, r1, ASR #8 + STR r3, [sp, #-4]! +SECOND_LOOP: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY: + + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + SUB r7, r7, r6 + ADD r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + SUB r9, r9, r8 + ADD r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + SUB r11, r11, r10 + ADD r10, r4, r5 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + SUB r8, r8, r11 @x2r = x2r - x3i@ + ADD r9, r9, r10 @x2i = x2i + x3r@ + ADD r4, r8, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r5, r9, r10, lsl#1 @x3r = x2i - (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7 + BLE SECOND_LOOP + +SECOND_LOOP_2: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_2: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + SUB r7, r7, r6 + ADD r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + SUB r9, r9, r8 + ADD r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + SUB r10, r10, r11 + ADD r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + SUB r8, r8, r11 @x2r = x2r - x3i@ + ADD r9, r9, r10 @x2i = x2i + x3r@ + ADD r4, r8, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r5, r9, r10, lsl#1 @x3r = x2i - (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_2 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7, ASR #1 + BLE SECOND_LOOP_2 + LDR r7, [sp, #0] + CMP r4, r7, LSL #1 + BGT SECOND_LOOP_4 + +SECOND_LOOP_3: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + + +RADIX4_BFLY_3: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + SUB r7, r7, r6 + ADD r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + SUB r8, r8, r9 + ADD r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + SUB r10, r10, r11 + ADD r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + SUB r8, r8, r11 @x2r = x2r - x3i@ + ADD r9, r9, r10 @x2i = x2i + x3r@ + ADD r4, r8, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r5, r9, r10, lsl#1 @x3r = x2i - (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_3 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7, LSL #1 + BLE SECOND_LOOP_3 + +SECOND_LOOP_4: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_4: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + SUB r7, r7, r6 + ADD r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + SUB r8, r8, r9 + ADD r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + SUB r11, r11, r10 + ADD r10, r5, r4 @ + RSB r10, r10, #0 + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + SUB r7, r7, r11 @x1i = x1i - x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + ADD r11, r7, r11, lsl#1 @x3i = x1i + (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + SUB r8, r8, r11 @x2r = x2r - x3i@ + ADD r9, r9, r10 @x2i = x2i + x3r@ + ADD r4, r8, r11, lsl#1 @x3i = x2r + (x3i << 1)@ + SUB r5, r9, r10, lsl#1 @x3r = x2i - (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_4 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7 + BLT SECOND_LOOP_4 + ADD sp, sp, #4 + + LDR r1, [sp, #0x1c] + MOV r0, r0, LSL #2 + MOV r1, r1, ASR #2 + STR r1, [sp, #0x1c] + LDR r1, [sp, #0x18] + MOV r1, r1, ASR #2 + STR r1, [sp, #0x18] + LDR r1, [sp, #0x20] + SUBS r1, r1, #1 + STR r1, [sp, #0x20] + BGT OUTER_LOOP + +RADIX2: + LDR r1, [sp, #0x14] + CMP r1, #0 + BEQ EXIT + LDR r12, [sp, #0x1c] + LDR r1, [sp, #0x28] + CMP r12, #0 + LDRNE r12, [sp, #0x1c] + MOVEQ r4, #1 + MOVNE r4, r12, LSL #1 + MOVS r3, r0 + BEQ EXIT + + MOV r3, r3, ASR #1 + LDR r5, [sp, #0x34] + MOV r0, r0, LSL #3 @(del<<1) * 4 + STR r1, [sp, #-4] +RADIX2_BFLY: + LDR r1, [sp, #-4] + LDRD r6, [r5] @r6 = x0r + ADD r5, r5, r0 + LDRD r8, [r5] @r8 = x1r + + LDR r2, [r1] + SUBS r3, r3, #1 + + + SMULL r1, r11, r8, r2 @mult32x16hin32(x1r,W1h) + LSR r1, r1, #31 + ORR r11, r1, r11, LSL#1 + SMULL r1, r10, r9, r2 @mult32x16hin32(x1i,W1h) + LSR r1, r1, #31 + ORR r10, r1, r10, LSL#1 + + + LDR r1, [sp, #-4] + LDR r2, [r1, #4] + ADD r1, r1, r4, LSL #3 + STR r1, [sp, #-4] + + SMULL r1, r8, r8, r2 @ixheaacd_mult32(x1r,w1l) + LSR r1, r1, #31 + ORR r8, r1, r8, LSL#1 + SMULL r1, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r1, r1, #31 + ORR r9, r1, r9, LSL#1 + + ADD r8, r8, r10 + SUB r9, r9, r11 + + ASR r8, r8, #1 + ASR r6, r6, #1 + ASR r9, r9, #1 + ASR r7, r7, #1 + ADD r10, r8, r6 @(x0r/2) + (x1r/2) + ADD r11, r9, r7 @(x0i/2) + (x1i/2)@ + SUB r8, r6, r8 @(x0r/2) - (x1r/2) + SUB r9, r7, r9 @(x0i/2) - (x1i/2)@ + + STRD r8, [r5] + SUB r5, r5, r0 + STRD r10, [r5], #8 + + BNE RADIX2_BFLY + + LDR r1, [sp, #0x28] + MOV r3, r0, ASR #4 + STR r1, [sp, #-4] +RADIX2_BFLY_2: + LDR r1, [sp, #-4] + LDRD r6, [r5] @r6 = x0r + ADD r5, r5, r0 + LDRD r8, [r5] @r8 = x1r + + LDR r2, [r1] + SUBS r3, r3, #1 + + + + SMULL r1, r11, r8, r2 @mult32x16hin32(x1r,W1h) + LSR r1, r1, #31 + ORR r11, r1, r11, LSL#1 + SMULL r1, r10, r9, r2 @mult32x16hin32(x1i,W1h) + LSR r1, r1, #31 + ORR r10, r1, r10, LSL#1 + + + LDR r1, [sp, #-4] + LDR r2, [r1, #4] + ADD r1, r1, r4, LSL #3 + STR r1, [sp, #-4] + + SMULL r1, r8, r8, r2 @ixheaacd_mult32(x1r,w1l) + LSR r1, r1, #31 + ORR r8, r1, r8, LSL#1 + SMULL r1, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r1, r1, #31 + ORR r9, r1, r9, LSL#1 + + SUB r11, r11, r9 + ADD r9, r10, r8 @ + MOV r8, r11 + + ASR r8, r8, #1 + ASR r6, r6, #1 + ASR r9, r9, #1 + ASR r7, r7, #1 + ADD r10, r8, r6 @(x0r>>1) + (x1r) + ADD r11, r9, r7 @(x0i>>1) + (x1i)@ + SUB r8, r6, r8 @(x0r>>1) - (x1r) + SUB r9, r7, r9 @(x0i>>1) - (x1i)@ + + STRD r8, [r5] + SUB r5, r5, r0 + STRD r10, [r5], #8 + + BNE RADIX2_BFLY_2 + +EXIT: + ADD sp, sp, #0x38 + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_conv_ergtoamplitude.s b/decoder/armv7/ixheaacd_conv_ergtoamplitude.s new file mode 100644 index 0000000..f46464c --- /dev/null +++ b/decoder/armv7/ixheaacd_conv_ergtoamplitude.s @@ -0,0 +1,132 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_conv_ergtoamplitude_armv7 +ixheaacd_conv_ergtoamplitude_armv7: + + STMFD sp!, {r4-r12, r14} + + LDR R5, [SP, #44] + LDR R4, [SP, #40] + LDR R14, =0x1FF + LDR R10, =0x5A82 + +LOOP1: + + LDRSH R6, [R2], #2 + LDRSH R7, [R2], #2 + MOV R12, #0 + MOV R9, #-16 + MOVS R6, R6 + BLE ENDIF1_1 + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R11, R6, LSL R8 + + MOV R11, R11, ASR #5 + ANDS R11, R11, R14 + + BIC R11, R11, #1 + LDRH R12, [R11, R5] + + TST R7, #1 + ADDNE R7, R7, #3 + SMULWBNE R12, R12, R10 + + + MOV R9, R7, ASR #1 +ENDIF1_1: + STRH R12, [R2, #-4] + STRH R9, [R2, #-2] + + + LDRSH R6, [R3], #2 + LDRSH R7, [R3], #2 + MOV R8, #0 + MOV R9, #-16 + MOVS R6, R6 + BLE ENDIF1_2 + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R11, R6, LSL R8 + MOV R11, R11, ASR #5 + ANDS R11, R11, R14 + + BIC R11, R11, #1 + LDRH R8, [R11, R5] + TST R7, #1 + ADDNE R7, R7, #3 + + SMULWBNE R8, R8, R10 + + + MOV R9, R7, ASR #1 +ENDIF1_2: + STRH R8, [R3, #-4] + STRH R9, [R3, #-2] + + + + LDRSH R6, [R4], #2 + LDRSH R7, [R4], #2 + MOV R8, #0 + MOV R9, #-16 + MOVS R6, R6 + BLE ENDIF1_3 + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R11, R6, LSL R8 + MOV R11, R11, ASR #5 + ANDS R11, R11, R14 + + BIC R11, R11, #1 + LDRH R8, [R11, R5] + TST R7, #1 + ADDNE R7, R7, #3 + + SMULWBNE R8, R8, R10 + + + MOV R9, R7, ASR #1 +ENDIF1_3: + STRH R9, [R4, #-2] + + SUB R6, R1, R9 + SUBS R6, R6, #4 + + RSBLE R6, R6, #0 + MOVGT R8, R8, ASR R6 + MOVLE R8, R8, LSL R6 + STRH R8, [R4, #-4] + + SUBS R0, R0, #1 + BGT LOOP1 + LDMFD sp!, {r4-r12, r15} + + + + + diff --git a/decoder/armv7/ixheaacd_conv_ergtoamplitudelp.s b/decoder/armv7/ixheaacd_conv_ergtoamplitudelp.s new file mode 100644 index 0000000..193b116 --- /dev/null +++ b/decoder/armv7/ixheaacd_conv_ergtoamplitudelp.s @@ -0,0 +1,148 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_conv_ergtoamplitudelp_armv7 +ixheaacd_conv_ergtoamplitudelp_armv7: + + STMFD sp!, {r4-r12, r14} + + LDR R5, [SP, #44] + LDR R4, [SP, #40] + LDR R11, =0x5A82 + LDR R10, =0x1FF + +LOOP1: + + LDRSH R6, [R2, #0] + MOV R12, #0 + MOV R14, #-16 + MOVS R6, R6 + BLE ENDIF1_1 + + LDRSH R7, [R2, #2] + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R6, R6, LSL R8 + MOV R6, R6, ASR #5 + AND R6, R6, R10 + + TST R7, #1 + BIC R6, R6, #1 + LDRH R12, [R6, R5] + ADDNE R7, R7, #3 + MOV R14, R7, ASR #1 + SMULWBNE R12, R12, R11 + +ENDIF1_1: + STRH R14, [R2, #2] + + + LDRSH R6, [R3, #0] + MOV R8, #0 + MOV R9, #-16 + + MOVS R6, R6 + BLE ENDIF1_2 + + LDRSH R7, [R3, #2] + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R6, R6, LSL R8 + MOV R6, R6, ASR #5 + AND R6, R6, R10 + + TST R7, #1 + BIC R6, R6, #1 + LDRH R8, [R6, R5] + ADDNE R7, R7, #3 + MOV R9, R7, ASR #1 + SMULWBNE R8, R8, R11 + +ENDIF1_2: + STRH R9, [R3, #2] + STRH R8, [R3], #4 + + + + + LDRSH R6, [R4, #0] + MOV R8, #0 + MOV R9, #-16 + MOVS R6, R6 + BLE ENDIF1_3 + + LDRSH R7, [R4, #2] + CLZ R8, R6 + SUB R8, R8, #17 + SUB R7, R7, R8 + MOV R6, R6, LSL R8 + MOV R6, R6, ASR #5 + ANDS R6, R6, R10 + + TST R7, #1 + BIC R6, R6, #1 + LDRH R8, [R6, R5] + ADDNE R7, R7, #3 + MOV R9, R7, ASR #1 + SMULWBNE R8, R8, R11 + +ENDIF1_3: + STRH R9, [R4, #2] + + SUB R6, R1, R9 + SUBS R6, R6, #4 + + RSBLE R6, R6, #0 + MOVGT R8, R8, ASR R6 + MOVLE R8, R8, LSL R6 + STRH R8, [R4], #4 + + + SUBS R6, R14, R1 + BLE ELSE1 + + CMP R6, #15 + MOVGT R6, #15 + MOV R12, R12, LSL R6 + CMP R12, #0x8000 + MVNGE R12, #0x8000 + CMNLT R12, #0x00008000 + MOVLT R12, #0x00008000 + STRH R12, [R2], #4 + SUBS R0, R0, #1 + BGT LOOP1 + +ELSE1: + RSB R6, R6, #0 + MOV R12, R12, ASR R6 + STRH R12, [R2], #4 + SUBS R0, R0, #1 + BGT LOOP1 + LDMFD sp!, {r4-r12, r15} + + + + + diff --git a/decoder/armv7/ixheaacd_cos_sin_mod.s b/decoder/armv7/ixheaacd_cos_sin_mod.s new file mode 100644 index 0000000..b253b48 --- /dev/null +++ b/decoder/armv7/ixheaacd_cos_sin_mod.s @@ -0,0 +1,472 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .extern ixheaacd_radix4bfly +.hidden ixheaacd_radix4bfly + .extern ixheaacd_postradixcompute2 +.hidden ixheaacd_postradixcompute2 + .extern ixheaacd_postradixcompute4 +.hidden ixheaacd_postradixcompute4 + + + + + .extern ixheaacd_sbr_imdct_using_fft +.hidden ixheaacd_sbr_imdct_using_fft + + + .global ixheaacd_cos_sin_mod +ixheaacd_cos_sin_mod: + STMFD SP!, {R4-R12, R14} + + LDR R5, [R1] + MOV R7, R5, ASR #1 + LDR R4, [R1, #12] + MOV R5, R7, ASR #2 + + MOV R8, R0 + MOV R6, R7, LSL #3 + + + SUB R10, SP, #516 + SUB SP, SP, #516 + + AND R12, R10, #7 + CMP R12, #0 + ADDNE R10, R10, #4 + + + + + + + + STMFD SP!, {R0-R3} + + SUB R6, R6, #4 + ADD R9, R0, R6 + + LDR R2, [R4], #4 + LDR R1, [R9], #-4 + LDR R0, [R8], #4 + ADD R11, R10, R6 + + + + + + + + + + + + + + + + +LOOP1: + + SUBS R5, R5, #1 + + SMULWT R12, R1, R2 + SMULWB R6, R0, R2 + SMULWT R14, R0, R2 + + + LDR R0, [R8, #0xFC] + + QSUB R12, R12, R6 + + SMLAWB R14, R1, R2, R14 + + LDR R1, [R9, #0x104] + + STR R12, [R10, #4] + STR R14, [R10], #8 + + SMULWT R6, R0, R2 + SMULWB R12, R1, R2 + SMULWT R14, R1, R2 + + LDR R1, [R8], #4 + + QSUB R12, R12, R6 + + SMLAWB R14, R0, R2, R14 + + LDR R2, [R4], #4 + LDR R0, [R9], #-4 + + STR R12, [R10, #0xF8] + STR R14, [R10, #0xFC] + + SMULWT R3, R1, R2 + SMULWB R6, R0, R2 + SMULWT R12, R0, R2 + + LDR R0, [R9, #0x104] + + QSUB R3, R3, R6 + + SMLAWB R12, R1, R2, R12 + + LDR R1, [R8, #0xFC] + + STR R12, [R11, #-4] + STR R3, [R11], #-8 + + SMULWT R6, R0, R2 + SMULWB R14, R1, R2 + SMULWT R12, R1, R2 + + LDR R1, [R9], #-4 + + QSUB R14, R14, R6 + + SMLAWB R3, R0, R2, R12 + + LDR R2, [R4], #4 + LDR R0, [R8], #4 + + STR R3, [R11, #0x108] + STR R14, [R11, #0x104] + + SMULWT R12, R1, R2 + SMULWB R6, R0, R2 + SMULWT R14, R0, R2 + + LDR R0, [R8, #0xFC] + + QSUB R12, R12, R6 + + SMLAWB R14, R1, R2, R14 + + LDR R1, [R9, #0x104] + + STR R12, [R10, #4] + STR R14, [R10], #8 + + SMULWT R6, R0, R2 + SMULWB R12, R1, R2 + SMULWT R14, R1, R2 + + LDR R1, [R8], #4 + + QSUB R12, R12, R6 + + SMLAWB R14, R0, R2, R14 + + LDR R2, [R4], #4 + LDR R0, [R9], #-4 + STR R12, [R10, #0xF8] + STR R14, [R10, #0xFC] + + SMULWT R3, R1, R2 + SMULWB R6, R0, R2 + SMULWT R12, R0, R2 + + LDR R0, [R9, #0x104] + + QSUB R3, R3, R6 + SMLAWB R12, R1, R2, R12 + + LDR R1, [R8, #0xFC] + STR R3, [R11], #-4 + STR R12, [R11], #-4 + + SMULWT R6, R0, R2 + SMULWB R3, R1, R2 + SMULWT R12, R1, R2 + + + LDRGT R1, [R9], #-4 + + QSUB R3, R3, R6 + SMLAWB R12, R0, R2, R12 + + + LDRGT R2, [R4], #4 + LDRGT R0, [R8], #4 + + STR R3, [R11, #0x104] + STR R12, [R11, #0x108] + + + BGT LOOP1 + LDR R1, [SP, #4] + LDR R5, [R1] + LDR R4, [SP, #8] + LDR R0, [SP, #8] + ADD R1, SP, #16 + + + AND R2, R1, #7 + CMP R2, #0 + ADDNE R1, R1, #4 + + + CMP R5, #64 + LDR R5, [SP, #12] + MOV R2, #1 + + BNE THIRTY2BAND + + + + + + + MOV R2, R1 + MOV R1, #32 + LDR R3, [SP] + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + + BL ixheaacd_sbr_imdct_using_fft + ADD SP, SP, #16 + + MOV R0, R4 + MOV R1, #32 + ADD R2, SP, #16 + + + AND R6, R2, #7 + CMP R6, #0 + ADDNE R2, R2, #4 + + + LDR R3, [SP] + ADD R2, R2, #256 + ADD R3, R3, #256 + + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + + BL ixheaacd_sbr_imdct_using_fft + + ADD SP, SP, #16 + + LDR R8, [SP] + LDR R12, [SP, #4] + MOV R3, #32 + LDR R6, [R8] + LDR R11, [R8, #4] + + ADD R9, R8, #252 + + + B LOOP2_PRO + +THIRTY2BAND: + + + + MOV R2, R1 + MOV R1, #16 + LDR R3, [SP] + + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + + BL ixheaacd_sbr_imdct_using_fft + ADD SP, SP, #16 + + MOV R0, R4 + MOV R1, #16 + ADD R2, SP, #16 + + + AND R6, R2, #7 + CMP R6, #0 + ADDNE R2, R2, #4 + + + LDR R3, [SP] + ADD R2, R2, #256 + ADD R3, R3, #256 + + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + STR R5, [SP, #-4]! + + BL ixheaacd_sbr_imdct_using_fft + + ADD SP, SP, #16 + LDR R8, [SP] + LDR R12, [SP, #4] + LDR R6, [R8] + LDR R11, [R8, #4] + ADD R9, R8, #124 + + + + +LOOP2_PRO: + + + + + + + + + + + + + + + + + + + LDR R4, [R12, #20] + MOV R6, R6, ASR #1 + STR R6, [R8], #4 + LDR R0, [R9] + LDR R2, [R4], #4 + MOV R11, R11, ASR #1 + LDR R1, [R9, #-4] + RSB R12, R11, #0 + STR R12, [R9], #-4 + + SMULWT R14, R1, R2 + SMULWB R6, R0, R2 + SMULWT R12, R0, R2 + + LDR R0, [R9, #260] + QSUB R14, R14, R6 + SMLAWB R12, R1, R2, R12 + + LDR R6, [R8, #252] + LDR R11, [R8, #256] + STR R14, [R8], #4 + STR R12, [R9], #-4 + + MOV R6, R6, ASR #1 + MOV R11, R11, ASR #1 + LDR R1, [R9, #260] + + RSB R6, R6, #0 + STR R6, [R9, #264] + STR R11, [R8, #248] + + SMULWT R12, R0, R2 + SMULWT R14, R1, R2 + SMULWB R6, R0, R2 + SMLAWB R12, R1, R2, R12 + + MOV R11, #0 + QSUB R14, R6, R14 + QSUB R12, R11, R12 + LDR R0, [R8, #4] + LDR R1, [R8] + STR R12, [R8, #252] + STR R14, [R9, #260] + + LDR R5, [SP, #4] + LDR R5, [R5] + MOV R5, R5, ASR #2 + SUB R5, R5, #2 + + + + + + + +LOOP2: + SMULWB R12, R0, R2 + SMULWB R14, R1, R2 + SMULWT R6, R0, R2 + SMLAWT R12, R1, R2, R12 + + LDR R10, [R9] + QSUB R14, R14, R6 + LDR R0, [R8, #260] + LDR R1, [R8, #256] + STR R12, [R8], #4 + STR R14, [R9], #-4 + + SMULWB R3, R0, R2 + SMULWT R6, R0, R2 + SMULWB R14, R1, R2 + SMLAWT R3, R1, R2, R3 + + LDR R7, [R9, #260] + QSUB R6, R6, R14 + QSUB R3, R11, R3 + LDR R2, [R4], #4 + LDR R1, [R9] + + STR R3, [R9, #260] + STR R6, [R8, #252] + + SMULWT R12, R10, R2 + SMULWT R14, R1, R2 + SMULWB R6, R10, R2 + SMLAWB R12, R1, R2, R12 + + LDR R1, [R9, #256] + QSUB R14, R14, R6 + + STR R12, [R9], #-4 + STR R14, [R8], #4 + + SUBS R5, R5, #1 + + SMULWT R12, R7, R2 + SMULWT R14, R1, R2 + SMULWB R6, R7, R2 + SMLAWB R12, R1, R2, R12 + + LDRGE R0, [R8, #4] + LDRGE R1, [R8] + + QSUB R12, R11, R12 + QSUB R14, R6, R14 + + STR R12, [R8, #252] + STR R14, [R9, #260] + + BGE LOOP2 +ENDLOOP2: + + ADD SP, SP, #532 + LDMFD sp!, {r4-r12, r15} + + + + + + + diff --git a/decoder/armv7/ixheaacd_dct3_32.s b/decoder/armv7/ixheaacd_dct3_32.s new file mode 100644 index 0000000..749f3bb --- /dev/null +++ b/decoder/armv7/ixheaacd_dct3_32.s @@ -0,0 +1,506 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_dct3_32 +.extern ixheaacd_radix4bfly +.hidden ixheaacd_radix4bfly +.extern ixheaacd_postradixcompute4 +.hidden ixheaacd_postradixcompute4 + +ixheaacd_dct3_32: + + + STMFD sp!, {R4-R12, R14} + VPUSH {D8 - D15} + ADD R6, R0, #196 + SUB R7, R6, #8 + ADD R10, R7, #4 + MOV R9, #0 + VDUP.32 D0, R9 + ADD R4, R2, #8 + MOV R8, R1 + + VLD1.32 D0[0], [R10] + MOV R11, #-4 + + VSHR.S32 D0, D0, #7 + VLD4.16 {D12, D13, D14, D15}, [R4]! + + MOV R12, #-16 + VST1.32 D0, [R8]! + SUB R7, R7, #12 + + VLD1.32 {Q0}, [R6]! + VLD1.32 {Q1}, [R7], R12 + SUB R9, R6, #144 + + VREV64.32 Q1, Q1 + SUB R5, R7, #112 + + VSWP D2, D3 + VSHR.S32 Q0, Q0, #7 + + VSHR.S32 Q1, Q1, #7 + VLD1.32 {Q3}, [R9]! + VADD.I32 Q2, Q1, Q0 + + VUZP.16 D4, D5 + VSHR.S32 Q3, Q3, #7 + + + VLD1.32 {Q4}, [R5], R12 + VMULL.U16 Q15, D4, D12 + + VREV64.32 Q4, Q4 + VMULL.U16 Q14, D4, D13 + + VSWP D8, D9 + + VSHR.S32 Q4, Q4, #7 + VLD1.32 {Q0}, [R6]! + VSUB.I32 Q5, Q3, Q4 + + VUZP.16 D10, D11 + + VMLAL.U16 Q15, D10, D13 + VLD1.32 {Q1}, [R7], R12 + VMLSL.U16 Q14, D10, D12 + + VREV64.32 Q1, Q1 + VSHR.S32 Q0, Q0, #7 + + VSWP D2, D3 + + VSHR.U32 Q15, Q15, #16 + VSHR.S32 Q1, Q1, #7 + + VMLAL.S16 Q15, D5, D12 + VMLAL.S16 Q15, D11, D13 + + + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q14, D5, D13 + VADD.I32 Q2, Q1, Q0 + VMLSL.S16 Q14, D11, D12 + + VUZP.16 D4, D5 + SUB R9, R6, #144 + + VSWP Q15, Q14 + SUB R5, R7, #112 + + VST2.32 {Q14, Q15}, [R8]! + + VLD1.32 {Q3}, [R9]! + + VLD1.32 {Q4}, [R5], R12 + VSHR.S32 Q3, Q3, #7 + + VREV64.32 Q4, Q4 + + VSWP D8, D9 + + VSHR.S32 Q4, Q4, #7 + VLD4.16 {D12, D13, D14, D15}, [R4]! + VSUB.I32 Q5, Q3, Q4 + + VUZP.16 D10, D11 + VMULL.U16 Q15, D4, D12 + VMLAL.U16 Q15, D10, D13 + VMULL.U16 Q14, D4, D13 + VLD1.32 {Q0}, [R6]! + VMLSL.U16 Q14, D10, D12 + VLD1.32 {Q1}, [R7], R11 + VSHR.U32 Q15, Q15, #16 + + VREV64.32 Q1, Q1 + VSHR.S32 Q14, Q14, #16 + + VSWP D2, D3 + VSHR.S32 Q0, Q0, #7 + + SUB R9, R6, #144 + + SUB R5, R7, #124 + VLD1.32 {Q3}, [R9]! + VMLAL.S16 Q14, D5, D13 + + VMLSL.S16 Q14, D11, D12 + VLD1.32 {Q4}, [R5], R11 + VMLAL.S16 Q15, D5, D12 + + VREV64.32 Q4, Q4 + VMLAL.S16 Q15, D11, D13 + + VSWP D8, D9 + VSHR.S32 Q1, Q1, #7 + + VADD.I32 Q2, Q1, Q0 + VLD4.16 {D12, D13, D14, D15}, [R4]! + VSHR.S32 Q3, Q3, #7 + + VUZP.16 D4, D5 + VSHR.S32 Q4, Q4, #7 + + VSWP Q15, Q14 + VSUB.I32 Q5, Q3, Q4 + + VST2.32 {Q14, Q15}, [R8]! + + VUZP.16 D10, D11 + VMULL.U16 Q15, D4, D12 + + VMLAL.U16 Q15, D10, D13 + VLD1.32 D0, [R6]! + VMULL.U16 Q14, D4, D13 + + VMLSL.U16 Q14, D10, D12 + VLD1.32 D1[0], [R6]! + + VSHR.U32 Q15, Q15, #16 + VLD1.32 D2[0], [R7], R11 + + VMLAL.S16 Q15, D5, D12 + VLD1.32 D2[1], [R7], R11 + VMLAL.S16 Q15, D11, D13 + + SUB R9, R6, #140 + VLD1.32 D3[0], [R7], R11 + + SUB R5, R7, #116 + VLD1.32 D6, [R9]! + VSHR.S32 Q14, Q14, #16 + + VSHR.S32 Q0, Q0, #7 + VLD1.32 D7[0], [R9]! + VMLAL.S16 Q14, D5, D13 + + VLD1.32 D8[0], [R5], R11 + VMLSL.S16 Q14, D11, D12 + + VSHR.S32 Q1, Q1, #7 + VLD4.16 {D12, D13, D14, D15}, [R4] + VADD.I32 Q2, Q1, Q0 + + VLD1.32 D8[1], [R5], R11 + VSHR.S32 Q3, Q3, #7 + + VSWP Q15, Q14 + + VLD1.32 D9[0], [R5], R11 + + VSHR.S32 Q4, Q4, #7 + VST2.32 {Q14, Q15}, [R8]! + ADD R4, #24 + + VUZP.16 D4, D5 + VSUB.I32 Q5, Q3, Q4 + + VUZP.16 D10, D11 + VMULL.U16 Q15, D4, D12 + + VMLAL.U16 Q15, D10, D13 + VMULL.U16 Q14, D4, D13 + + VMLSL.U16 Q14, D10, D12 + VLD1.16 D0[0], [R4]! + VSHR.U32 Q15, Q15, #16 + + VSHR.S32 Q14, Q14, #16 + VLD1.32 D2[0], [R7], R11 + VMLAL.S16 Q15, D5, D12 + + SUB R5, R7, #124 + VMLAL.S16 Q15, D11, D13 + VLD1.32 D4[0], [R5] + VMLAL.S16 Q14, D5, D13 + + VMLSL.S16 Q14, D11, D12 + + VSHR.S32 D2, D2, #7 + VST1.32 D30[0], [R8]! + VSHR.S32 D4, D4, #7 + VSUB.I32 D2, D2, D4 + + VMOV D4, D2 + VST1.32 D28[0], [R8]! + MOV R6, R1 + + ADD R7, R1, #124 + VST1.32 D30[1], [R8]! + ADD R10, R3, #16 + + SUB R7, R7, #28 + VST1.32 D28[1], [R8]! + MOV R5, #-16 + + MOV R9, #-4 + VST1.32 D31[0], [R8]! + MOV R11, #16 + + VST1.32 D29[0], [R8]! + MOV R12, #4 + + VUZP.16 D4, D5 + MOV R8, #6 + + VLD1.16 D1[0], [R4], R8 + VMULL.U16 Q15, D4, D0 + + + VUZP.16 D2, D3 + VMULL.U16 Q14, D4, D1 + + VMLAL.U16 Q15, D2, D1 + VLD2.32 {D10, D11}, [R6] + VMLSL.U16 Q14, D2, D0 + + ADD R4, R3, #4 + MOV R8, #-32 + VSHR.U32 Q15, Q15, #16 + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q15, D5, D0 + VMLAL.S16 Q15, D3, D1 + VMLAL.S16 Q14, D5, D1 + VMLSL.S16 Q14, D3, D0 + + VADD.I32 D14, D11, D28 + VLD2.32 {Q2, Q3}, [R7] + VNEG.S32 D14, D14 + + VREV64.32 Q2, Q2 + VSUB.I32 D12, D10, D30 + + VREV64.32 Q3, Q3 + VADD.I32 D10, D10, D30 + + VSWP D4, D5 + VADD.I32 D10, D10, D14 + + VSWP D6, D7 + VSUB.I32 D11, D11, D28 + + VADD.I32 D11, D11, D12 + VLD2.16 {D8, D9}, [R10], R5 + VSHR.S32 D10, D10, #1 + + VREV64.16 D8, D8 + VSHR.S32 D11, D11, #1 + + VUZP.32 D10, D11 + + VST1.32 D10, [R6]! + VLD2.32 {Q0, Q1}, [R6] + + VADD.I32 Q7, Q0, Q2 + VLD2.16 {D10, D11}, [R4], R11 + VSUB.I32 Q6, Q0, Q2 + + VUZP.16 D12, D13 + VADD.I32 Q8, Q1, Q3 + + VUZP.16 D16, D17 + VSUB.I32 Q9, Q1, Q3 + + + VMULL.U16 Q15, D12, D8 + VMLAL.U16 Q15, D16, D10 + VMULL.U16 Q14, D12, D10 + VMLSL.U16 Q14, D16, D8 + VSHR.S32 Q7, Q7, #1 + VSHR.U32 Q15, Q15, #16 + VSHR.S32 Q9, Q9, #1 + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q15, D13, D8 + VMLAL.S16 Q15, D17, D10 + VMLAL.S16 Q14, D13, D10 + VMLSL.S16 Q14, D17, D8 + + VSUB.I32 Q10, Q7, Q15 + VLD2.16 {D8, D9}, [R10] + VADD.I32 Q13, Q7, Q15 + + VREV64.32 Q13, Q13 + VSWP D26, D27 + + VADD.I32 Q11, Q9, Q14 + VREV64.16 D8, D8 + + VSUB.I32 Q12, Q14, Q9 + + VREV64.32 Q12, Q12 + + VST2.32 {Q10, Q11}, [R6]! + VSWP D24, D25 + VSWP Q12, Q13 + VST2.32 {Q12, Q13}, [R7], R8 + + VLD2.32 {Q0, Q1}, [R6] + VLD2.32 {Q2, Q3}, [R7] + + VREV64.32 Q2, Q2 + VREV64.32 Q3, Q3 + + VSWP D4, D5 + VSWP D6, D7 + + VSUB.I32 Q6, Q0, Q2 + VADD.I32 Q7, Q0, Q2 + VLD2.16 {D10, D11}, [R4], R11 + VADD.I32 Q8, Q1, Q3 + + VUZP.16 D12, D13 + VSUB.I32 Q9, Q1, Q3 + + + VUZP.16 D16, D17 + VMULL.U16 Q15, D12, D8 + + VMLAL.U16 Q15, D16, D10 + VMULL.U16 Q14, D12, D10 + VMLSL.U16 Q14, D16, D8 + ADD R7, R7, #8 + VSHR.U32 Q15, Q15, #16 + VSHR.S32 Q7, Q7, #1 + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q15, D13, D8 + VMLAL.S16 Q15, D17, D10 + VMLAL.S16 Q14, D13, D10 + VMLSL.S16 Q14, D17, D8 + + VSHR.S32 Q9, Q9, #1 + VSUB.I32 Q10, Q7, Q15 + VSUB.I32 Q12, Q14, Q9 + + VADD.I32 Q11, Q9, Q14 + VST1.32 D20[0], [R6]! + VADD.I32 Q13, Q7, Q15 + + + VST1.32 D22[0], [R6]! + VST1.32 D20[1], [R6]! + VST1.32 D22[1], [R6]! + VST1.32 D21[0], [R6]! + VST1.32 D23[0], [R6]! + + VREV64.32 Q12, Q12 + + VREV64.32 Q13, Q13 + VSWP D24, D25 + VSWP D26, D27 + + + VST1.32 D26[1], [R7]! + VST1.32 D24[1], [R7]! + VST1.32 D27[0], [R7]! + VST1.32 D25[0], [R7]! + VST1.32 D27[1], [R7]! + VST1.32 D25[1], [R7]! + + SUB R7, R7, #32 + VLD2.32 {D0, D1}, [R6] + VLD2.32 {D2, D3}, [R7] + + VSUB.I32 D12, D0, D2 + VLD1.16 D8, [R10], R9 + VADD.I32 D14, D0, D2 + + VADD.I32 D16, D1, D3 + VLD1.16 D10, [R4], R12 + VSUB.I32 D18, D1, D3 + + VUZP.16 D12, D13 + MOV R4, R0 + + VUZP.16 D16, D17 + VMULL.U16 Q15, D12, D8 + VMLAL.U16 Q15, D16, D10 + VMULL.U16 Q14, D12, D10 + VMLSL.U16 Q14, D16, D8 + VSHR.S32 D18, D18, #1 + VSHR.U32 Q15, Q15, #16 + VSHR.S32 Q14, Q14, #16 + + VMLAL.S16 Q15, D13, D8 + VMLAL.S16 Q15, D17, D10 + + MOV R10, R1 + + VMLAL.S16 Q14, D13, D10 + VMLSL.S16 Q14, D17, D8 + VNEG.S32 Q15, Q15 + VSHR.S32 D14, D14, #1 + + VADD.I32 Q13, Q7, Q15 + + VADD.I32 Q11, Q9, Q14 + + LDR r0 , [sp , #104] + VST1.32 D26[0], [R6]! + MOV r2, #1 + + VST1.32 D22[0], [R6]! + MOV r3, #4 + BL ixheaacd_radix4bfly + + MOV r0, r4 + MOV r1, r10 + LDR r2 , [sp , #108] + MOV r3, #16 + BL ixheaacd_postradixcompute4 + + MOV r0, r4 + MOV r1, r10 + LDMIA r0!, {r4, r5} + STR r4, [r1], #4 + STR r5, [r1, #4] + ADD r2, r0, #64 + ADD r3, r1, #116 + MOV r6, #7 + +BACK3: + + LDMIA r0!, {r4, r5} + STR r5, [r1], #8 + STR r4, [r1], #8 + + LDMIA r2!, {r4, r5} + STR r5, [r3], #-8 + STR r4, [r3], #-8 + + SUBS r6, r6, #1 + BNE BACK3 + + LDMIA r0!, {r4, r5} + STR r5, [r1], #8 + STR r4, [r1], #8 + + VPOP {D8 - D15} + LDMFD sp!, {r4-r12, r15} + + + + + + + diff --git a/decoder/armv7/ixheaacd_dec_DCT2_64_asm.s b/decoder/armv7/ixheaacd_dec_DCT2_64_asm.s new file mode 100644 index 0000000..059baec --- /dev/null +++ b/decoder/armv7/ixheaacd_dec_DCT2_64_asm.s @@ -0,0 +1,522 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .extern ixheaacd_radix4bfly +.hidden ixheaacd_radix4bfly + .extern ixheaacd_postradixcompute2 +.hidden ixheaacd_postradixcompute2 + .extern ixheaacd_sbr_imdct_using_fft +.hidden ixheaacd_sbr_imdct_using_fft + + .global ixheaacd_dec_DCT2_64_asm + +ixheaacd_dec_DCT2_64_asm: + + STMFD sp!, {r0-r3, r4-r12, r14} + ADD R2, R1, #252 + MOV R3, #32 + MOV R4, #-4 + + ADD R2, R2, #4 + + +FOR_LOOP: + + VLD2.32 {Q0, Q1}, [R0]! + SUBS R3, R3, #4 + + VST1.32 {Q0}, [R1]! + SUB R2, R2, #16 + + VREV64.32 Q1, Q1 + VSWP D2, D3 + VST1.32 {Q1}, [R2] + BGT FOR_LOOP + + LDR r0, [sp, #8] + MOV r1, #32 + LDR r2, [sp, #4] + LDR r3, [sp] + + LDR r4, [sp, #12] + STR r4, [sp, #-4]! + STR r4, [sp, #-4]! + STR r4, [sp, #-4]! + STR r4, [sp, #-4]! + + BL ixheaacd_sbr_imdct_using_fft + + ADD sp, sp, #16 + + LDR r0, [sp] + + + LDR r2, [sp, #56] + + VPUSH {D8 - D15} + ADD R5, R0, #252 + VLD1.32 D0, [R0] + ADD R3, R2, #2 + VSHL.S32 D0, D0, #1 + VST1.32 D0, [R0]! + SUB R5, R5, #28 + + + VLD2.32 {Q0, Q1}, [R0]! + + VLD2.32 {Q2, Q3}, [R5]! + VREV64.32 Q2, Q2 + VSWP D4, D5 + MOV R10, #-8 + VREV64.32 Q3, Q3 + ADD R4, R2, #30 + VSWP D6, D7 + SUB R4, R4, #6 + VLD1.16 D8, [R3]! + VSUB.I32 Q11, Q3, Q1 + VLD1.16 D10, [R4], R10 + VADD.I32 Q10, Q3, Q1 + VREV64.16 D10, D10 + VSUB.I32 Q9, Q0, Q2 + VUZP.16 D20, D21 + VADD.I32 Q8, Q0, Q2 + VUZP.16 D18, D19 + VMULL.U16 Q15, D20, D8 + VMLSL.U16 Q15, D18, D10 + VMULL.U16 Q14, D18, D8 + VMLAL.U16 Q14, D20, D10 + SUB R11, R0, #32 + VSHR.S32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + SUB R12, R5, #32 + VMLAL.S16 Q15, D21, D8 + VMLSL.S16 Q15, D19, D10 + + VLD2.32 {Q0, Q1}, [R0]! + SUB R5, R5, #64 + VMLAL.S16 Q14, D19, D8 + VLD2.32 {Q2, Q3}, [R5]! + VMLAL.S16 Q14, D21, D10 + VREV64.32 Q2, Q2 + VSHL.S32 Q15, Q15, #1 + VSWP D4, D5 + VSHL.S32 Q14, Q14, #1 + + VREV64.32 Q3, Q3 + VADD.I32 Q13, Q8, Q15 + VSWP D6, D7 + VADD.I32 Q12, Q11, Q14 + + + VLD1.16 D8, [R3]! + VSUB.I32 Q7, Q14, Q11 + VLD1.16 D10, [R4], R10 + + VSUB.I32 Q6, Q8, Q15 + VREV64.32 Q7, Q7 + VREV64.32 Q6, Q6 + VSWP D14, D15 + VSWP D12, D13 + VREV64.16 D10, D10 + + + VSUB.I32 Q11, Q3, Q1 + VSWP Q13, Q12 + VADD.I32 Q10, Q3, Q1 + VST2.32 {Q12, Q13}, [R11]! + VSUB.I32 Q9, Q0, Q2 + + VADD.I32 Q8, Q0, Q2 + VST2.32 {Q6, Q7}, [R12] + SUB R11, R0, #32 + + VUZP.16 D20, D21 + SUB R12, R5, #32 + + VUZP.16 D18, D19 + SUB R5, R5, #64 + + VMULL.U16 Q15, D20, D8 + VLD2.32 {Q0, Q1}, [R0]! + VMLSL.U16 Q15, D18, D10 + VLD2.32 {Q2, Q3}, [R5]! + VMULL.U16 Q14, D18, D8 + VREV64.32 Q2, Q2 + VMLAL.U16 Q14, D20, D10 + VSWP D4, D5 + VSHR.S32 Q15, Q15, #16 + VREV64.32 Q3, Q3 + VMLAL.S16 Q15, D21, D8 + VMLSL.S16 Q15, D19, D10 + VSWP D6, D7 + VSHR.U32 Q14, Q14, #16 + VMLAL.S16 Q14, D19, D8 + VLD1.16 D8, [R3]! + VMLAL.S16 Q14, D21, D10 + VSHL.S32 Q15, Q15, #1 + VLD1.16 D10, [R4], R10 + + VSHL.S32 Q14, Q14, #1 + VREV64.16 D10, D10 + VADD.I32 Q13, Q8, Q15 + VADD.I32 Q12, Q11, Q14 + + + VSUB.I32 Q7, Q14, Q11 + VSUB.I32 Q6, Q8, Q15 + VREV64.32 Q7, Q7 + VSUB.I32 Q11, Q3, Q1 + VREV64.32 Q6, Q6 + VADD.I32 Q10, Q3, Q1 + VSWP D14, D15 + VSUB.I32 Q9, Q0, Q2 + VSWP D12, D13 + VADD.I32 Q8, Q0, Q2 + VSWP Q13, Q12 + + + VUZP.16 D20, D21 + VUZP.16 D18, D19 + VMULL.U16 Q15, D20, D8 + VMLSL.U16 Q15, D18, D10 + VST2.32 {Q12, Q13}, [R11]! + VMULL.U16 Q14, D18, D8 + VMLAL.U16 Q14, D20, D10 + VST2.32 {Q6, Q7}, [R12] + + SUB R11, R0, #32 + VLD2.32 {Q0, Q1}, [R0]! + SUB R12, R5, #32 + SUB R5, R5, #64 + VSHR.S32 Q15, Q15, #16 + VLD2.32 {Q2, Q3}, [R5]! + VMLAL.S16 Q15, D21, D8 + VREV64.32 Q2, Q2 + VMLSL.S16 Q15, D19, D10 + VSWP D4, D5 + VSHR.U32 Q14, Q14, #16 + + VREV64.32 Q3, Q3 + VMLAL.S16 Q14, D19, D8 + VSWP D6, D7 + VMLAL.S16 Q14, D21, D10 + VSHL.S32 Q15, Q15, #1 + + VLD1.16 D8, [R3]! + VSHL.S32 Q14, Q14, #1 + + VADD.I32 Q13, Q8, Q15 + + VLD1.16 D10, [R4], R10 + + VADD.I32 Q12, Q11, Q14 + + + VREV64.16 D10, D10 + VSUB.I32 Q7, Q14, Q11 + + + VSUB.I32 Q6, Q8, Q15 + VREV64.32 Q7, Q7 + VREV64.32 Q6, Q6 + VSWP D14, D15 + VSWP D12, D13 + + VSWP Q13, Q12 + VSUB.I32 Q11, Q3, Q1 + VST2.32 {Q12, Q13}, [R11]! + VADD.I32 Q10, Q3, Q1 + + VST2.32 {Q6, Q7}, [R12] + + SUB R11, R0, #32 + + VSUB.I32 Q9, Q0, Q2 + VADD.I32 Q8, Q0, Q2 + VUZP.16 D20, D21 + SUB R12, R5, #32 + VUZP.16 D18, D19 + SUB R5, R5, #64 + + VMULL.U16 Q15, D20, D8 + VMLSL.U16 Q15, D18, D10 + VMULL.U16 Q14, D18, D8 + VMLAL.U16 Q14, D20, D10 + VSHR.S32 Q15, Q15, #16 + VMLAL.S16 Q15, D21, D8 + VMLSL.S16 Q15, D19, D10 + + VSHR.U32 Q14, Q14, #16 + VMLAL.S16 Q14, D19, D8 + VMLAL.S16 Q14, D21, D10 + + VSHL.S32 Q15, Q15, #1 + VSHL.S32 Q14, Q14, #1 + VADD.I32 Q13, Q8, Q15 + VADD.I32 Q12, Q11, Q14 + + VSUB.I32 Q7, Q14, Q11 + VSUB.I32 Q6, Q8, Q15 + VREV64.32 Q7, Q7 + VREV64.32 Q6, Q6 + VSWP D14, D15 + VSWP D12, D13 + + + VSWP Q13, Q12 + VST2.32 {Q12, Q13}, [R11]! + + VST2.32 {Q6, Q7}, [R12] + VPOP {D8 - D15} + + + + + + + + + + + + + LDMFD sp!, {r0-r2, r3} + LDR R1, [SP, #48] + LDR R2, [SP, #44] + ADD R3, R1, #126 + VLD1.32 D0[0], [R0, :32]! + SUB R4, R1, #2 + + ADD R5, R1, #130 + VLD1.32 D1[0], [R0, :32]! + ADD R7, R2, #4 + + MOV R6, #0x8000 + VDUP.32 Q15, R6 + + VADD.I32 D2, D0, D1 + VSHR.S32 D2, D2, #1 + VSHL.S32 D2, D2, #4 + VADD.I32 Q2, Q1, Q15 + VSHR.S32 Q2, Q2, #16 + VSUB.I32 D6, D0, D1 + VST1.16 D4[0], [R1]! + MOV R8, #28 + + MOV R9, #-2 + VLD2.32 {Q0, Q1}, [R0]! + SUB R4, R4, #6 + + SUB R3, R3, #6 + VLD2.16 {D4, D5}, [R7]! + + VUZP.16 D0, D1 + + VUZP.16 D2, D3 + VMULL.U16 Q14, D0, D4 + + VMLSL.U16 Q14, D2, D5 + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q14, D1, D4 + VMLSL.S16 Q14, D3, D5 + + + VMULL.U16 Q13, D0, D5 + VMLAL.U16 Q13, D2, D4 + VSHR.U32 Q13, Q13, #16 + VMLAL.S16 Q13, D1, D5 + VMLAL.S16 Q13, D3, D4 + + VSHL.S32 Q12, Q14, #4 + VLD2.32 {Q0, Q1}, [R0]! + VADD.I32 Q12, Q12, Q15 + + VSHR.S32 Q12, Q12, #16 + VUZP.16 D24, D25 + + + VSHL.S32 Q11, Q13, #4 + VLD2.16 {D4, D5}, [R7]! + VADD.I32 Q11, Q11, Q15 + + VSHR.S32 Q11, Q11, #16 + VUZP.16 D22, D23 + + + VQNEG.S16 D20, D22 + + VUZP.16 D0, D1 + VUZP.16 D2, D3 + SUB R8, R8, #8 + +LOOP_2: + + VMULL.U16 Q14, D0, D4 + VST1.16 D24, [R1]! + VMLSL.U16 Q14, D2, D5 + + VREV64.16 D24, D24 + VMULL.U16 Q13, D0, D5 + + VMLAL.U16 Q13, D2, D4 + VST1.16 D24, [R4] + SUB R4, R4, #8 + + VREV64.16 D22, D22 + VSHR.S32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VST1.16 D22, [R3] + VMLAL.S16 Q14, D1, D4 + VMLSL.S16 Q14, D3, D5 + VST1.16 D20, [R5]! + VMLAL.S16 Q13, D1, D5 + VMLAL.S16 Q13, D3, D4 + VSHL.S32 Q12, Q14, #4 + + SUB R3, R3, #8 + VLD2.32 {Q0, Q1}, [R0]! + VSHL.S32 Q11, Q13, #4 + + VADD.I32 Q12, Q12, Q15 + VLD2.16 {D4, D5}, [R7]! + + VADD.I32 Q11, Q11, Q15 + VUZP.16 D0, D1 + VSHR.S32 Q12, Q12, #16 + VUZP.16 D24, D25 + + + VSHR.S32 Q11, Q11, #16 + VUZP.16 D22, D23 + SUBS R8, R8, #4 + + VUZP.16 D2, D3 + VQNEG.S16 D20, D22 + + BGT LOOP_2 + + + VMULL.U16 Q14, D0, D4 + VST1.16 D24, [R1]! + VMLSL.U16 Q14, D2, D5 + VREV64.16 D24, D24 + VMULL.U16 Q13, D0, D5 + VMLAL.U16 Q13, D2, D4 + VST1.16 D24, [R4] + VSHR.S32 Q14, Q14, #16 + SUB R4, R4, #8 + VST1.16 D20, [R5]! + + VMLAL.S16 Q14, D1, D4 + VMLSL.S16 Q14, D3, D5 + VREV64.16 D22, D22 + VSHR.U32 Q13, Q13, #16 + VST1.16 D22, [R3] + SUB R3, R3, #8 + VMLAL.S16 Q13, D1, D5 + VSHL.S32 Q12, Q14, #4 + VMLAL.S16 Q13, D3, D4 + VADD.I32 Q12, Q12, Q15 + + VSHL.S32 Q11, Q13, #4 + + VSHR.S32 Q12, Q12, #16 + VUZP.16 D24, D25 + VADD.I32 Q11, Q11, Q15 + + VST1.16 D24, [R1]! + VSHR.S32 Q11, Q11, #16 + VREV64.16 D24, D24 + VUZP.16 D22, D23 + + VST1.16 D24, [R4] + VQNEG.S16 D20, D22 + + SUB R4, R4, #2 + VREV64.16 D22, D22 + VST1.16 D22, [R3] + SUB R3, R3, #2 + + VST1.16 D20, [R5]! + VLD2.32 {Q0, Q1}, [R0]! + + VLD2.16 {Q2}, [R7] + ADD R7, R7, #12 + VUZP.16 D0, D1 + VUZP.16 D2, D3 + + VMULL.U16 Q14, D0, D4 + VMLSL.U16 Q14, D2, D5 + VSHR.S32 Q14, Q14, #16 + VMLAL.S16 Q14, D1, D4 + VMLSL.S16 Q14, D3, D5 + + VMULL.U16 Q13, D0, D5 + VMLAL.U16 Q13, D2, D4 + VSHR.U32 Q13, Q13, #16 + VMLAL.S16 Q13, D1, D5 + VMLAL.S16 Q13, D3, D4 + + VSHL.S32 Q12, Q14, #4 + VADD.I32 Q12, Q12, Q15 + VSHR.S32 Q12, Q12, #16 + VUZP.16 D24, D25 + + VSHL.S32 Q11, Q13, #4 + VADD.I32 Q11, Q11, Q15 + VSHR.S32 Q11, Q11, #16 + VUZP.16 D22, D23 + + VQNEG.S16 D20, D22 + + VST1.16 D24[0], [R1]! + VST1.16 D24[1], [R1]! + VST1.16 D24[2], [R1]! + + VST1.16 D24[0], [R4], R9 + VST1.16 D24[1], [R4], R9 + VST1.16 D24[2], [R4], R9 + + VST1.16 D22[0], [R3], R9 + VST1.16 D22[1], [R3], R9 + VST1.16 D22[2], [R3], R9 + + VST1.16 D20[0], [R5]! + VST1.16 D20[1], [R5]! + VST1.16 D20[2], [R5]! + VUZP.16 D6, D7 + VLD1.16 D0, [R7]! + VMULL.U16 Q1, D0, D6 + VSHR.S32 Q1, Q1, #16 + VMLAL.S16 Q1, D0, D7 + VSHL.S32 Q1, Q1, #4 + + VADD.I32 Q1, Q1, Q15 + VSHR.S32 Q1, Q1, #16 + + VST1.16 D2[0], [R1]! + VST1.16 D2[0], [R4], R9 + + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_decorr_filter2.s b/decoder/armv7/ixheaacd_decorr_filter2.s new file mode 100644 index 0000000..b6529ed --- /dev/null +++ b/decoder/armv7/ixheaacd_decorr_filter2.s @@ -0,0 +1,1071 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_decorr_filter2_armv7 + @PRESERVE8 + +ixheaacd_decorr_filter2_armv7: + + STMFD r13!, {r4-r12, r14} + LDR r12, [r0, #24] + + LDRSH r4, [r0, #12] + LDRSH r5, [r0, #14] + LDRSH r6, [r0, #16] + + MOV r11, #384 + LDR r9, [r13, #44] + LDR r14, [r13, #48] + LDR r10, [r13, #40] + + MLA r4, r11, r4, r12 + + MLA r5, r11, r5, r12 + + MLA r6, r11, r6, r12 + + + ADD r11, r9, #0x0150 + LDRH r7, [r0, #28] + ADD r2, r2, #12 + ADD r10, r10, #12 + + ADD r5, r5, #140 + + ADD r6, r6, #268 + + + STR r10, [r13, #-4]! + STR r2, [r13, #-4]! + LDR r8, [r0] + ADD r11, r11, #0x0c + + MOV r0, #128 + ADD r2, r9, #0x012 + ADD r12, r11, #0x0a0 + + + SUB r10, r11, #0x03A + ADD r3, r3, #12 + MLA r0, r7, r0, r8 + + + + + STR r10, [r13, #-8]! + STR r3, [r13, #-4]! + STR r14, [r13, #-4]! + ADD r1, r1, #12 + ADD r0, r0, #12 + ADD r4, r4, #12 + + + + + + +DE_COR_FIL2_LOOP1: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ADD r12, r12, #12 + + + ADD r11, r11, #12 + + + + + MOV r9, #20 + + STR r9, [r13, #-4]! + STR r1, [r13, #16] + + +DE_COR_FIL2_LOOP2: + + LDR r7, [r0] + LDR r8, [r11], #4 + LDR r14, [r1], #4 + + SMULBT r3, r7, r8 + SMULBB r9, r7, r8 + + + STR r1, [r13, #16] + + SMULTT r10, r7, r8 + + LDR r1, [r13, #20] + + SMLATB r3, r7, r8, r3 + + MOV r8, #0x8000 + + QSUB r9, r9, r10 + LDR r10, [r1], #4 + QADD r14, r14, r8 + + STR r1, [r13, #20] + QADD r1, r10, r8 + + MOV r7, r9, asr #15 + MOV r8, r3, asr #15 + + LDR r10, [r12], #4 + LDR r9, [r4] + + + MOV r14, r14, asr #16 + MOV r1, r1, asr #16 + + SMULBT r3, r10, r9 + + + STRH r14, [r0], #2 + STRH r1, [r0], #2 + + + + + + SMULTT r14, r10, r9 + SMLATB r3, r10, r9, r3 + SMULBB r9, r10, r9 + + LDRSH r10, [r2], #2 + MOV r3, r3, asr #15 + QSUB r9, r9, r14 + + SMULBB r14, r10, r8 + SMULBB r1, r10, r7 + MOV r9, r9, asr #15 + + SUB r3, r3, r14, asr #15 + SUB r9, r9, r1, asr #15 + + SMULBB r14, r9, r10 + SMULBB r1, r3, r10 + + LDR r10, [r12, #124 ] + + ADD r14, r7, r14, asr #15 + LDR r7, [r5] + + ADD r1, r8, r1, asr #15 + + SMULBT r8, r10, r7 + + STRH r14, [r4], #2 + STRH r1, [r4], #2 + + SMULTT r14, r10, r7 + SMLATB r8, r10, r7, r8 + SMULBB r7, r10, r7 + + LDRSH r10, [r2], #2 + MOV r8, r8, asr #15 + QSUB r7, r7, r14 + + SMULBB r14, r10, r3 + SMULBB r1, r10, r9 + MOV r7, r7, asr #15 + + SUB r8, r8, r14, asr #15 + SUB r7, r7, r1, asr #15 + + SMULBB r14, r7, r10 + SMULBB r1, r8, r10 + + LDR r10, [r12, #252] + + ADD r14, r9, r14, asr #15 + LDR r9, [r6] + + ADD r1, r3, r1, asr #15 + + SMULBT r3, r10, r9 + + + STRH r14, [r5], #2 + STRH r1, [r5], #2 + + SMULTT r14, r10, r9 + SMLATB r3, r10, r9, r3 + SMULBB r9, r10, r9 + + LDRSH r10, [r2], #2 + MOV r3, r3, asr #15 + QSUB r9, r9, r14 + + SMULBB r14, r10, r8 + SMULBB r1, r10, r7 + MOV r9, r9, asr #15 + + SUB r3, r3, r14, asr #15 + SUB r9, r9, r1, asr #15 + + SMULBB r14, r9, r10 + SMULBB r1, r3, r10 + + LDR r10, [r13, #12] + ADD r7, r7, r14, asr #15 + ADD r1, r8, r1, asr #15 + + LDRH r8, [r10], #2 + STR r10, [r13, #12] + STRH r7, [r6], #2 + LDR r10, [r13, #4] + + STRH r1, [r6], #2 + + MOV r8, r8, lsl #1 + LDRH r8, [r10, r8] + LDR r10, [r13, #8] + + LDR r1, [r13, #16] + LDR r14, [r13] + LDR r7, [r13, #24] + + SMULBB r3, r3, r8 + SMULBB r9, r9, r8 + + SUBS r14, r14, #1 + MOV r3, r3, lsl #1 + MOV r9, r9, lsl #1 + + STR r3, [r7] , #4 + STR r9, [r10], #4 + STR r14, [r13] + STR r10, [r13, #8] + STR r7, [r13, #24] + BGT DE_COR_FIL2_LOOP2 + + ADD r13, r13, #28 + + LDMFD r13!, {r4-r12, pc} + + + + +.text +.p2align 2 +.global ixheaacd_decorr_filter1_armv7 + +ixheaacd_decorr_filter1_armv7: + + STMFD r13!, {r4-r12, r14} + ADD r12, r0, #0x0bc + + LDRSH r4, [r0, #12] + LDRSH r5, [r0, #14] + LDRSH r6, [r0, #16] + + MOV r11, #192 + LDR r3, [r0, #0x2c] + + MLA r4, r11, r4, r12 + + MLA r5, r11, r5, r12 + + MLA r6, r11, r6, r12 + + + ADD r11, r1, #0x01b0 + LDRH r7, [r0, #28] + + ADD r5, r5, #64 + + ADD r6, r6, #128 + + + ADD r8, r0, #0x03c + ADD r11, r11, #0x0c + + MOV r0, #64 + ADD r12, r11, #0x1c0 + + + SUB r10, r11, #0x0b4 + MLA r0, r7, r0, r8 + + + MOV r9, #10 + STR r10, [r13, #-4]! + STR r3, [r13, #-4]! + STR r2, [r13, #-4]! + STR r9, [r13, #-4]! + ADD r2, r1, #0x096 + MOV r1, r3 + + + +DE_COR_FIL1_LOOP: + + LDR r7, [r0] + LDR r8, [r11], #4 + LDR r14, [r1], #4 + + SMULBT r3, r7, r8 + SMULBB r9, r7, r8 + + STR r1, [r13, #8] + + SMULTT r10, r7, r8 + SMLATB r3, r7, r8, r3 + + MOV r8, #0x8000 + + QSUB r9, r9, r10 + LDR r10, [r1, #0x3c] + QADD r14, r14, r8 + QADD r1, r10, r8 + + MOV r7, r9, asr #15 + MOV r8, r3, asr #15 + + LDR r10, [r12], #4 + LDR r9, [r4] + + + MOV r14, r14, asr #16 + MOV r1, r1, asr #16 + + SMULBT r3, r10, r9 + + STRH r14, [r0], #2 + STRH r1, [r0], #2 + + + + + + SMULTT r14, r10, r9 + SMLATB r3, r10, r9, r3 + SMULBB r9, r10, r9 + + LDRSH r10, [r2] + MOV r3, r3, asr #15 + QSUB r9, r9, r14 + + SMULBB r14, r10, r8 + SMULBB r1, r10, r7 + MOV r9, r9, asr #15 + + SUB r3, r3, r14, asr #15 + SUB r9, r9, r1, asr #15 + + SMULBB r14, r9, r10 + SMULBB r1, r3, r10 + + LDR r10, [r12, #60 ] + + ADD r14, r7, r14, asr #15 + LDR r7, [r5] + + ADD r1, r8, r1, asr #15 + + SMULBT r8, r10, r7 + STRH r14, [r4], #2 + STRH r1, [r4], #2 + + SMULTT r14, r10, r7 + SMLATB r8, r10, r7, r8 + SMULBB r7, r10, r7 + + LDRSH r10, [r2, #2] + MOV r8, r8, asr #15 + QSUB r7, r7, r14 + + SMULBB r14, r10, r3 + SMULBB r1, r10, r9 + MOV r7, r7, asr #15 + + SUB r8, r8, r14, asr #15 + SUB r7, r7, r1, asr #15 + + SMULBB r14, r7, r10 + SMULBB r1, r8, r10 + + LDR r10, [r12, #124] + + ADD r14, r9, r14, asr #15 + LDR r9, [r6] + + ADD r1, r3, r1, asr #15 + + SMULBT r3, r10, r9 + + STRH r14, [r5], #2 + STRH r1, [r5], #2 + + SMULTT r14, r10, r9 + SMLATB r3, r10, r9, r3 + SMULBB r9, r10, r9 + + LDRSH r10, [r2, #4] + MOV r3, r3, asr #15 + QSUB r9, r9, r14 + + SMULBB r14, r10, r8 + SMULBB r1, r10, r7 + MOV r9, r9, asr #15 + + SUB r3, r3, r14, asr #15 + SUB r9, r9, r1, asr #15 + + SMULBB r14, r9, r10 + SMULBB r1, r3, r10 + + LDR r10, [r13, #12] + ADD r7, r7, r14, asr #15 + ADD r1, r8, r1, asr #15 + + LDRH r8, [r10], #2 + STR r10, [r13, #12] + STRH r7, [r6], #2 + LDR r10, [r13, #4] + + STRH r1, [r6], #2 + + MOV r8, r8, lsl #1 + LDRH r8, [r10, r8] + + LDR r14, [r13] + LDR r1, [r13, #8] + + SMULBB r3, r3, r8 + SMULBB r9, r9, r8 + + SUBS r14, r14, #1 + MOV r3, r3, lsl #1 + MOV r9, r9, lsl #1 + + STR r3, [r1 , #0x0bc] + STR r9, [r1, #0x7c] + STR r14, [r13] + BGT DE_COR_FIL1_LOOP + + ADD r13, r13, #16 + + LDMFD r13!, {r4-r12, pc} + + + + + + + + + + + +.text +.p2align 2 +.global ixheaacd_divide16_pos_armv7 + +ixheaacd_divide16_pos_armv7: + CMP r1, #0 + MOV r2, r1 +@ MVNLTS r2, r2 + MVNSLT r2, r2 + CLZ r2, r2 + SUB r2, r2, #1 + MOV r0, r0, LSL r2 + MOV r1, r1, LSL r2 + MOV r2, r1, LSR #16 + MOV r0, r0, LSR #16 + MOVS r0, r0, LSL #16 + MOV r2, r2, LSL #16 + BXEQ r14 + MOV r1, #0x10 + MOV r3, #1 +FFR_DIV_LOOP: + CMP r0, r2 + MOVCC r0, r0, LSL #1 + SUBCS r0, r0, r2 + ADDCS r0, r3, r0, LSL #1 + SUBS r1, r1, #1 + BGT FFR_DIV_LOOP + BX r14 + + + + + + + + + + + + + + + + + + + +.text +.p2align 2 +.global ixheaacd_decorrelation_armv7 + + + + +ixheaacd_decorrelation_armv7: + + STMFD r13!, {r4-r12, r14} + + LDR r4, [r13, #40] + LDR r5, [r13, #44] + LDR r6, [r0, #0x2c] + STR r1, [r13, #-4]! + STR r2, [r13, #-4]! + STR r3, [r13, #-4]! + STR r4, [r13, #-4]! + SUB r13, r13, #124 + + + LDR r7, [r6] + LDR r8, [r6, #20] + LDR r9, [r6, #64] + LDR r10, [r6, #84] + + SMULWT r11, r7, r7 + SMULWT r12, r9, r9 + SMLAWT r11, r8, r8, r11 + SMLAWT r12, r10, r10, r12 + + LDR r10, [r6, #16] + LDR r8, [r6, #80] + LDR r9, [r6, #4] + QADD r14, r11, r12 + LDR r7, [r6, #68] + SMULWT r11, r10, r10 + STR r14, [r13] + + SMULWT r12, r9, r9 + SMLAWT r11, r7, r7, r11 + LDRSH r7, [r5, #0x0aa] + SMLAWT r12, r8, r8, r12 + + + + ADD r10, r6, #0x040 + LDR r8, [r6, r7, lsl #2] + QADD r14, r11, r12 + LDR r9, [r10, r7, lsl #2] + LDRSH r7, [r5, #0x0ac] + SMULWT r11, r8, r8 + STR r14, [r13, #4] + + LDR r8, [r6, r7, lsl #2] + SMLAWT r12, r9, r9, r11 + LDR r9, [r10, r7, lsl #2] + LDRSH r7, [r5, #0x0ae] + SMULWT r11, r8, r8 + STR r12, [r13, #8] + + LDR r8, [r6, r7, lsl #2] + SMLAWT r12, r9, r9, r11 + LDR r9, [r10, r7, lsl #2] + LDRSH r7, [r5, #0x0b0] + SMULWT r11, r8, r8 + STR r12, [r13, #12] + + LDR r8, [r6, r7, lsl #2] + SMLAWT r12, r9, r9, r11 + LDR r9, [r10, r7, lsl #2] + LDRSH r7, [r5, #0x0b2] + SMULWT r11, r8, r8 + STR r12, [r13, #16] + + LDR r8, [r6, r7, lsl #2] + SMLAWT r12, r9, r9, r11 + LDR r9, [r10, r7, lsl #2] + LDRSH r7, [r5, #0x0b4] + SMULWT r11, r8, r8 + STR r12, [r13, #20] + + LDR r8, [r6, r7, lsl #2] + SMLAWT r12, r9, r9, r11 + LDR r9, [r10, r7, lsl #2] + LDR r6, [r1, #12] + SMULWT r11, r8, r8 + LDR r7, [r2, #12] + SMLAWT r14, r9, r9, r11 + STR r12, [r13, #24] + + + LDR r8, [r1, #16] + SMULWT r10, r6, r6 + LDR r9, [r2, #16] + SMLAWT r12, r7, r7, r10 + STR r14, [r13, #28] + + SMULWT r10, r8, r8 + LDR r6, [r1, #20] + SMLAWT r14, r9, r9, r10 + + LDR r7, [r2, #20] + STR r12, [r13, #32] + + LDR r8, [r1, #24] + SMULWT r10, r6, r6 + LDR r9, [r2, #24] + SMLAWT r12, r7, r7, r10 + STR r14, [r13, #36] + + SMULWT r10, r8, r8 + LDR r6, [r1, #28] + SMLAWT r14, r9, r9, r10 + + LDR r7, [r2, #28] + STR r12, [r13, #40] + + + LDR r8, [r1, #32] + SMULWT r10, r6, r6 + LDR r9, [r2, #32] + SMLAWT r12, r7, r7, r10 + STR r14, [r13, #44] + + SMULWT r10, r8, r8 + ADD r7, r0, #0x06c0 + SMLAWT r14, r9, r9, r10 + STR r12, [r13, #48] + LDRSH r12, [r7, #2] + STR r14, [r13, #52] + STR r0, [r13, #-4]! + STR r5, [r13, #-4]! + + + ADD r3, r5, #0x0c2 + MOV r0, #6 + ADD r4, r13, #64 + +DE_COR_LOOP1: + + LDRSH r6, [r3, #2] + LDRSH r7, [r3], #2 + MOV r14, #0 + CMP r6, r12 + MOVGT r6, r12 + + + SUBS r6, r6, r7 + + + ADD r8, r1, r7, lsl #2 + ADD r9, r2, r7, lsl #2 + BLE DE_COR_NEXT1 + LDR r10, [r8], #4 + LDR r11, [r9], #4 + LDRSH r7, [r3, #0x0c] + + +DE_COR_LOOP1_1: + + SMULWT r5, r10, r10 + SUBS r6, r6, #1 + SMLAWT r5, r11, r11, r5 + LDR r10, [r8], #4 + LDR r11, [r9], #4 + MOV r5, r5, asr r7 + QADD r14, r14, r5 + BGT DE_COR_LOOP1_1 + +DE_COR_NEXT1: + SUBS r0, r0, #1 + STR r14, [r4], #4 + BGT DE_COR_LOOP1 + + LDR r5, [r13], #4 + LDR r0, [r13], #4 + + MOV r14, #20 + MOV r7, r13 + LDR r3, [r0, #0x020] + LDR r4, [r0, #0x028] + LDR r12, =0x620a + LDR r6, [r0, #0x024] + STR r0, [r13, #-4]! + STR r5, [r13, #-4]! + MOV r11, #0x6000 + MOV r8, #0x0ff + ADD r5, r7, #80 + ORR r8, r8, #0x07f00 + +DE_COR_LOOP2: + + LDR r9, [r3] + LDR r2, [r7] + LDR r10, [r4] + SMULWB r9, r9, r12 + + MOVS r2, r2, lsl #1 + SMULWB r10, r10, r11 + MOVLT r2, #0 + MOV r9, r9, lsl #1 + CMP r2, r9 + MOVGT r9, r2 + + STR r9, [r3], #4 + QSUB r9, r9, r2 + + MOV r10, r10, lsl #1 + STR r2, [r7], #4 + MOV r9, r9, asr #2 + QADD r9, r9, r10 + + + + + LDR r10, [r6] + MOV r2, r2, asr #2 + STR r9, [r4], #4 + SMULWB r10, r10, r11 + + + MOV r0, r9, asr #1 + QADD r1, r9, r0 + MOV r10, r10, lsl #1 + ADD r0, r10, r2 + + + STR r0, [r6], #4 + CMP r1, r0 + + MOVLE r0, r8 + BLE DE_COR_NEXT2 + + + + + + + + + MOVS r2, r1 + MVNLT r2, r2 + CLZ r2, r2 + SUB r2, r2, #1 + MOV r0, r0, lsl r2 + MOV r1, r1, lsl r2 + MOV r2, r1, lsr #16 + MOV r0, r0, lsr #16 + MOVS r0, r0, lsl #16 + MOV r2, r2, lsl #16 + BEQ DE_COR_NEXT1_1 + MOV r1, #04 + MOV r10, #1 + + +DE_COR_DIV_LOOP: + SUBS r9, r0, r2 + MOVCC r0, r0, lsl #1 + + ADDCS r0, r10, r9, lsl #1 + + + SUBS r9, r0, r2 + MOVCC r0, r0, lsl #1 + + ADDCS r0, r10, r9, lsl #1 + + + SUBS r9, r0, r2 + MOVCC r0, r0, lsl #1 + + ADDCS r0, r10, r9, lsl #1 + + + SUBS r9, r0, r2 + MOVCC r0, r0, lsl #1 + + ADDCS r0, r10, r9, lsl #1 + + + SUBS r1, r1, #1 + BGT DE_COR_DIV_LOOP + + + +DE_COR_NEXT1_1: + + + + + MOV r0, r0, lsl #16 + MOV r0, r0, asr #16 + +DE_COR_NEXT2: + + STRH r0, [r5], #2 + SUBS r14, r14, #1 + BGT DE_COR_LOOP2 + + LDR r5, [r13], #4 + LDR r0, [r13] + MOV r1, r5 + ADD r2, r13, #84 + BL ixheaacd_decorr_filter1_armv7 + + LDR r0, [r13] + LDR r1, [r13, #140] + LDR r2, [r13, #136] + + ADD r7, r13, #84 + MOV r8, #0 + + LDR r3, [r13, #132] + LDR r6, [r13, #128] + + STRH r8, [r7, #40] + STR r7, [r13, #-4]! + STR r5, [r13, #-4]! + STR r6, [r13, #-4]! + BL ixheaacd_decorr_filter2_armv7 + + + + + ADD r13, r13, #12 + LDR r0, [r13], #4 + + LDR r1, [r13, #136] + LDR r2, [r13, #132] + ADD r6, r0, #0x06c0 + LDR r3, [r13, #128] + LDR r4, [r13, #124] + + LDRSH r10, [r0, #0x1e] + LDR r9, [r0, #4] + LDRSH r12, [r6, #2] + LDRSH r14, [r5, #0x0cc] + MOV r6, #0x030 + LDRSH r11, [r5, #0x0ca] + MLA r6, r10, r6, r9 + + + + + ADD r10, r10, #1 + + CMP r10, #14 + MOVGE r10, #0 + + + CMP r12, r14 + MOVLT r14, r12 + STRH r10, [r0, #0x1e] + ADD r1, r1, r11, lsl #2 + ADD r2, r2, r11, lsl #2 + ADD r3, r3, r11, lsl #2 + ADD r4, r4, r11, lsl #2 + LDRSH r8, [r7, #36] + SUBS r14, r14, r11 + MOV r7, #0x08000 + BLE DE_COR_NEXT3 + + + +DE_COR_LOOP3: + + LDR r10, [r1], #4 + LDR r11, [r2], #4 + LDR r9, [r6] + QADD r10, r10, r7 + QADD r11, r11, r7 + SUBS r14, r14, #1 + + MOV r10, r10, asr #16 + STRH r10, [r6], #2 + + SMULBB r10, r9, r8 + + + MOV r11, r11, asr #16 + STRH r11, [r6], #2 + + SMULTB r11, r9, r8 + + + MOV r10, r10, lsl #1 + STR r10, [r3], #4 + + MOV r11, r11, lsl #1 + STR r11, [r4], #4 + BGT DE_COR_LOOP3 + +DE_COR_NEXT3: + LDR r1, [r13, #136] + LDR r2, [r13, #132] + LDR r3, [r13, #128] + LDR r4, [r13, #124] + + LDRSH r8, [r13, #118] + LDRSH r14, [r5, #0x0ce] + LDRSH r11, [r5, #0x0cc] + LDR r6, [r0, #8] + LDRSH r8, [r13, #118] + + CMP r12, r14 + MOVLT r14, r12 + + ADD r1, r1, r11, lsl #2 + ADD r2, r2, r11, lsl #2 + ADD r3, r3, r11, lsl #2 + ADD r4, r4, r11, lsl #2 + + SUBS r14, r14, r11 + BLE DE_COR_NEXT4 + + + +DE_COR_LOOP4: + LDR r10, [r1], #4 + LDR r11, [r2], #4 + LDR r9, [r6] + QADD r10, r10, r7 + QADD r11, r11, r7 + SUBS r14, r14, #1 + + MOV r10, r10, asr #16 + STRH r10, [r6], #2 + + SMULBB r10, r9, r8 + + + MOV r11, r11, asr #16 + STRH r11, [r6], #2 + + SMULTB r11, r9, r8 + + MOV r10, r10, lsl #1 + STR r10, [r3], #4 + + MOV r11, r11, lsl #1 + STR r11, [r4], #4 + BGT DE_COR_LOOP4 + +DE_COR_NEXT4: + + LDR r3, [r13, #128] + LDR r4, [r13, #124] + + RSBS r14, r12, #64 + + + MOV r9, #0 + LDRSH r10, [r0, #0x01c] + ADD r3, r3, r12, lsl #2 + ADD r4, r4, r12, lsl #2 + BLE DE_COR_NEXT5 + +DE_COR_LOOP5: + + STR r9, [r3], #4 + STR r9, [r4], #4 + SUBS r14, r14, #1 + BGT DE_COR_LOOP5 + +DE_COR_NEXT5: + + + ADD r10, r10, #1 + CMP r10, #2 + MOVGE r10, #0 + + STRH r10, [r0, #0x01c] + + + + LDRSH r1, [r0, #0x0c] + LDRSH r4, [r0, #0x12] + LDRSH r2, [r0, #0x0e] + LDRSH r5, [r0, #0x14] + LDRSH r3, [r0, #0x10] + LDRSH r6, [r0, #0x16] + + ADD r13, r13, #140 + ADD r1, r1, #1 + ADD r2, r2, #1 + ADD r3, r3, #1 + + CMP r1, r4 + MOVGE r1, #0 + + + + CMP r2, r5 + MOVGE r2, #0 + + + + CMP r3, r6 + MOVGE r3, #0 + + + + STRH r1, [r0, #0x0c] + STRH r2, [r0, #0x0e] + STRH r3, [r0, #0x10] + + LDMFD r13!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_eld_decoder_sbr_pre_twiddle.s b/decoder/armv7/ixheaacd_eld_decoder_sbr_pre_twiddle.s new file mode 100644 index 0000000..a18afdc --- /dev/null +++ b/decoder/armv7/ixheaacd_eld_decoder_sbr_pre_twiddle.s @@ -0,0 +1,67 @@ +.text +.p2align 2 +.global ia_eld_decoder_sbr_pre_twiddle + + +ia_eld_decoder_sbr_pre_twiddle: + + + + STMFD sp!, {r4-r12, r14} + LDR r4, [r0, #0] @Xre = *pXre + MOV r3, #62 @Loop count + LDR r5, [r1, #0] @Xim = *pXim + +LOOP: + LDR r6, [r2], #4 @Load and increment pointer *pTwiddles++ Lower - cosine , higher - sine + SUBS r3, r3, #1 @Decrement loop count by 1 + + SMULWB r8, r4, r6 @mult32x16in32(Xre, cosine) + LSL r8, r8, #1 @Left shift the multiplied value by 1 + + SMULWT r10, r5, r6 @mult32x16in32( Xim , sine) + + ADD r12, r8, r10, LSL #1 @mac32x16in32_shl( mult32x16in32_shl(Xre, cosine) , mult32x16in32_shl( Xim , sine))@ + + + SMULWT r7, r4, r6 @mult32x16in32(Xre, sine) + LDR r4, [r0, #4] @Load next iteration value Xre = *pXre + + SMULWB r9, r5, r6 @mult32x16in32(Xim, cosine) + STR r12, [r0], #4 @Store and increment pointer *pXre++ = re + + LSL r9, r9, #1 @Left shift the multiplied value by 1 + LDR r5, [r1, #4] @Load next iteration value Xim = *pXim + + + SUB r14, r9, r7, LSL #1 @sub32(mult32x16in32_shl(Xim, cosine) , mult32x16in32_shl(Xre, sine)) + + STR r14, [r1], #4 @Store and increment pointer *pXim++ = im + + BNE LOOP @Check r3 equals 0 and continue + +EPILOUGE: + + LDR r6, [r2], #4 + + SMULWB r8, r4, r6 + LSL r8, r8, #1 + + SMULWT r10, r5, r6 + + ADD r12, r8, r10, LSL #1 + + + SMULWB r9, r5, r6 + LSL r9, r9, #1 + + SMULWT r7, r4, r6 + + SUB r14, r9, r7, LSL #1 + + STR r12, [r0], #4 + STR r14, [r1], #4 + +END_LOOP: + + LDMFD sp!, {r4-r12, pc} diff --git a/decoder/armv7/ixheaacd_enery_calc_per_subband.s b/decoder/armv7/ixheaacd_enery_calc_per_subband.s new file mode 100644 index 0000000..b1812dc --- /dev/null +++ b/decoder/armv7/ixheaacd_enery_calc_per_subband.s @@ -0,0 +1,158 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_enery_calc_per_subband_armv7 + +ixheaacd_enery_calc_per_subband_armv7: + STMFD sp!, {r4-r12, r14} + + LDR r10, [sp, #0x34] + MOV R4, R2 + MOV R5, R3 + MOV R2, R0 + MOV R3, R1 + SUB R12, R3, R2 + LDR r10, [r10, #0] + ADD r10, r10, r12, LSL #1 + LDRSH r9, [r10, #0x20] + LDR R1, [sp, #0x28] + MOV R1, R1, LSL #1 + + SUBS R5, R5, R4 + LDR R0, [sp, #0x38] + LDR R7, [sp, #0x2C] + + + LDR R8, [sp, #0x30] + + BLE ENDCALC + + + MOVS R8, R8 + BEQ HQ_PART + + + ADD R0, R0, R4, LSL #2 + ADD R0, R0, R2, LSL #8 + SUB R2, R3, R2 + MOV R10, #20 + + + B LP_SBR_LOOP + +HQ_PART: + ADD R0, R0, R4, LSL #2 + ADD R0, R0, R2, LSL #9 + SUB R2, R3, R2 + MOV R2, R2, LSL #1 + MOV R10, #21 + SUB R1, R1, #1 + + + +LP_SBR_LOOP: + + MOV R6, #0 + MOV R8, R0 + MOVS R11, R2 + BLE STORE_ZEROES + MOV R6, #1 + +LOOP1_CALC_MAX: + LDR R4, [R8], #0x100 + LDR R12, [R8], #0x100 + EOR R4, R4, R4, ASR #31 + ORR R6, R6, R4 + EOR R12, R12, R12, ASR #31 + SUBS R11, R11, #2 + ORRGE R6, R6, R12 + BGT LOOP1_CALC_MAX + +CALC_NORM: + + CLZ R6, R6 + RSBS R14, R6, R10 + MOV R6, #0 + MOV R8, R0 + MOV R11, R2 + BLE NEG_SHIFT + +LOOP2_APPLY_POS_SHIFT: + LDR R4, [R8], #0x100 + LDR R12, [R8], #0x100 + SUBS R11, R11, #2 + MOV R4, R4, ASR R14 + SMLABB R6, R4, R4, R6 + MOV R12, R12, ASR R14 + SMLABB R6, R12, R12, R6 + BGT LOOP2_APPLY_POS_SHIFT + + B CONVERT_TO_MANT_EXP + +NEG_SHIFT: + RSB R12, R14, #0 + +LOOP2_APPLY_NEG_SHIFT: + LDR R4, [R8], #0x100 + LDR R3, [R8], #0x100 + SUBS R11, R11, #2 + MOV R4, R4, LSL R12 + SMLABB R6, R4, R4, R6 + MOV R3, R3, LSL R12 + SMLABB R6, R3, R3, R6 + BGT LOOP2_APPLY_NEG_SHIFT + + +CONVERT_TO_MANT_EXP: + SUB R14, R14, #23 + ADD R0, R0, #4 + MOVS R6, R6 + BEQ STORE_ZEROES + + CLZ R12, R6 + RSB R12, R12, #17 + MOV R4, R6, ASR R12 + + SMULBB R11, R4, R9 + ADD R12, R12, R14, LSL#1 + + MOV R11, R11, ASR #15 + CMP R11, #0x00008000 + MVNEQ R11, R11 + STRH R11, [R7], #2 + ADD R11, R1, R12 + STRH R11, [R7], #2 + SUBS R5, R5, #1 + BGT LP_SBR_LOOP + + B ENDCALC + +STORE_ZEROES: + STR R6, [R7], #4 + SUBS R5, R5, #1 + BGT LP_SBR_LOOP + +ENDCALC: + + LDMFD sp!, {r4-r12, r15} + diff --git a/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop1.s b/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop1.s new file mode 100644 index 0000000..578f9c1 --- /dev/null +++ b/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop1.s @@ -0,0 +1,172 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_esbr_cos_sin_mod_loop1 +ixheaacd_esbr_cos_sin_mod_loop1: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D11} +@generating load addresses + ADD r4, r0, r1, lsl #3 @psubband1 + SUB r4, r4, #4 + ADD r5, r3, r1, lsl #3 @psubband1_t + SUB r5, r5, #8 + MOV r6, r1, ASR #2 + +LOOP1: +@first part + vld1.32 {d0} , [r2]! + vrev64.32 d1, d0 + vld1.32 {d2[0]}, [r0]! + ADD r7, r0, #252 + vld1.32 {d2[1]}, [r7] + vld1.32 {d3[0]}, [r4] + ADD r7, r4, #256 + vld1.32 {d3[1]}, [r7] + SUB r4, r4, #4 + + VMULL.S32 q2, d0, d2 @qsub 2nd + VMULL.S32 q3, d0, d3 @add 2nd + VMULL.S32 q4, d1, d2 @add 1st + VMULL.S32 q5, d1, d3 @qsub 1st + + vadd.I64 q0, q4, q3 + VQSUB.S64 Q1, Q5, Q2 + + VSHRN.I64 D0, Q0, #32 + VSHRN.I64 D2, Q1, #32 + VMOV.32 D3, D0 + VST2.32 {D0[0], D2[0]}, [R3]! + ADD r7, r3, #248 + VST2.32 {D2[1], D3[1]}, [R7] + +@second part + vld1.32 {d0} , [r2]! + vrev64.32 d1, d0 + vld1.32 {d2[0]}, [r0]! + ADD R7, R0, #252 + vld1.32 {d2[1]}, [r7] + vld1.32 {d3[0]}, [r4] + ADD R7, R4, #256 + vld1.32 {d3[1]}, [r7] + SUB r4, r4, #4 + + VMULL.S32 q2, d0, d2 @add 2nd + VMULL.S32 q3, d0, d3 @sub 2nd + VMULL.S32 q4, d1, d2 @sub 1st + VMULL.S32 q5, d1, d3 @add 1st + + VADD.I64 Q0, Q5, Q2 + VQSUB.S64 Q1, Q4, Q3 + + VSHRN.I64 D0, Q0, #32 + VSHRN.I64 D2, Q1, #32 + VMOV.32 D3, D0 + VST2.32 {D0[0], D2[0]}, [R5] + ADD R7, R5, #256 + VST2.32 {D2[1], D3[1]}, [R7] + SUB r5, r5, #8 +@Third part + vld1.32 {d0} , [r2]! + vrev64.32 d1, d0 + vld1.32 {d2[0]}, [r0]! + ADD r7, r0, #252 + vld1.32 {d2[1]}, [r7] + vld1.32 {d3[0]}, [r4] + ADD r7, r4, #256 + vld1.32 {d3[1]}, [r7] + SUB r4, r4, #4 + + VMULL.S32 q2, d0, d2 @qsub 2nd + VMULL.S32 q3, d0, d3 @add 2nd + VMULL.S32 q4, d1, d2 @add 1st + VMULL.S32 q5, d1, d3 @qsub 1st + + vadd.I64 q0, q4, q3 + VQSUB.S64 Q1, Q5, Q2 + + VSHRN.I64 D0, Q0, #32 + VSHRN.I64 D2, Q1, #32 + VMOV.32 D3, D0 + VST2.32 {D0[0], D2[0]}, [R3]! + ADD r7, r3, #248 + VST2.32 {D2[1], D3[1]}, [R7] + +@Fourth part + vld1.32 {d0} , [r2]! + vrev64.32 d1, d0 + vld1.32 {d2[0]}, [r0]! + ADD R7, R0, #252 + vld1.32 {d2[1]}, [r7] + vld1.32 {d3[0]}, [r4] + ADD R7, R4, #256 + vld1.32 {d3[1]}, [r7] + SUB r4, r4, #4 + + VMULL.S32 q2, d0, d2 @add 2nd + VMULL.S32 q3, d0, d3 @sub 2nd + VMULL.S32 q4, d1, d2 @sub 1st + VMULL.S32 q5, d1, d3 @add 1st + + VADD.I64 Q0, Q5, Q2 + VQSUB.S64 Q1, Q4, Q3 + + VSHRN.I64 D0, Q0, #32 + VSHRN.I64 D2, Q1, #32 + VMOV.32 D3, D0 + VST2.32 {D0[0], D2[0]}, [R5] + ADD R7, R5, #256 + SUBS R6, R6, #1 + VST2.32 {D2[1], D3[1]}, [R7] + SUB r5, r5, #8 + + BGT LOOP1 + VPOP {D8-D11} + LDMFD sp!, {r4-r12, r15} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop2.s b/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop2.s new file mode 100644 index 0000000..732a265 --- /dev/null +++ b/decoder/armv7/ixheaacd_esbr_cos_sin_mod_loop2.s @@ -0,0 +1,180 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_esbr_cos_sin_mod_loop2 +ixheaacd_esbr_cos_sin_mod_loop2: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + @generating load addresses + ADD R3, R0, R2, LSL #3 @psubband1 = &subband[2 * M - 1]; + SUB R3, R3, #4 + ADD R10, R0, #256 + ADD R11, R10, R2, LSL #3 + SUB R11, R11, #4 + MOV R8, #-4 + LDR R6, [R0] + MOV R4, R2, ASR #1 @M_2 = ixheaacd_shr32(M, 1); + SUB R4, R4, #1 + + ASR R6, R6, #1 @*psubband = *psubband >> 1; + VLD1.32 {D2[0]}, [R3] + + STR R6, [R0], #4 @psubband++; + LDR R7, [R0] + ASR R7, R7, #1 + RSB R6, R7, #0 + STR R6, [R3], #-4 + VLD1.32 {D3[0]}, [R3] @ im = *psubband1; + + VLD2.32 {D0[0], D1[0]}, [R1]! + VDUP.32 D0, D0[0] + VDUP.32 D1, D1[0] + + VLD1.32 {D2[1]}, [R11] @re = *psubband12; + + LDR R6, [R10] + ASR R7, R6, #1 + MOV R9, #0 + QSUB R7, R9, R7 + + STR R7, [R11], #-4 + + LDR R6, [R10, #4] + ASR R6, R6, #1 + STR R6, [R10], #4 + + VLD1.32 {D3[1]}, [R11] + + VMULL.S32 q2, d0, d2 @qsub 2nd + VMULL.S32 q3, d0, d3 @add 2nd + VMULL.S32 q4, d1, d2 @add 1st + VMULL.S32 q5, d1, d3 @qsub 1st + + vadd.I64 q6, q4, q3 + VQSUB.S64 Q7, Q5, Q2 + VQSUB.S64 Q8, Q2, Q5 + + VSHRN.I64 D12, Q6, #32 + VSHRN.I64 D14, Q7, #32 + VSHRN.I64 D16, Q8, #32 + + VST1.32 {D12[0]}, [R3], R8 + + VST1.32 {D14[0]}, [R0]! + + VQNEG.S32 D12, D12 + + + VST1.32 {D12[1]}, [R10]! + + VST1.32 {D16[1]}, [R11], R8 + +LOOP1: + VLD1.32 {D2}, [R0] + VLD1.32 {D3}, [R10] + LDR R5, [R3] @RE2 + LDR R6, [R11] @RE3 + VTRN.32 D2, D3 + + VMULL.S32 q2, d0, d2 @qsub 2nd + VMULL.S32 q3, d0, d3 @add 2nd + VMULL.S32 q4, d1, d2 @add 1st + VMULL.S32 q5, d1, d3 @qsub 1st + + vadd.I64 q6, q4, q3 + VQSUB.S64 Q7, Q2, Q5 + VQSUB.S64 Q8, Q5, Q2 + + VSHRN.I64 D12, Q6, #32 + VSHRN.I64 D14, Q7, #32 + VSHRN.I64 D16, Q8, #32 + + VST1.32 {D12[0]}, [R0]! + VST1.32 {D14[0]}, [R3], R8 + VQNEG.S32 D12, D12 + + VST1.32 {D12[1]}, [R11], R8 + VST1.32 {D16[1]}, [R10]! + + @ second part + VLD2.32 {D0[0], D1[0]}, [R1]! + VDUP.32 D0, D0[0] + VDUP.32 D1, D1[0] + + VMOV D3, R5, R6 + VLD1.32 {D2[0]}, [R3] + VLD1.32 {D2[1]}, [R11] + + VMULL.S32 q2, d0, d2 @qsub 2nd + VMULL.S32 q3, d0, d3 @add 2nd + VMULL.S32 q4, d1, d2 @add 1st + VMULL.S32 q5, d1, d3 @qsub 1st + + vadd.I64 q6, q2, q5 + VQSUB.S64 Q7, Q4, Q3 + VQSUB.S64 Q8, Q3, Q4 + + VSHRN.I64 D12, Q6, #32 + VSHRN.I64 D14, Q7, #32 + VSHRN.I64 D16, Q8, #32 + + VST1.32 {D12[0]}, [R3], R8 + VST1.32 {D14[0]}, [R0]! + + VQNEG.S32 D12, D12 + + subs r4, r4, #1 + VST1.32 {D12[1]}, [R10]! + VST1.32 {D16[1]}, [R11], R8 + + BGT LOOP1 + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/decoder/armv7/ixheaacd_esbr_fwd_modulation.s b/decoder/armv7/ixheaacd_esbr_fwd_modulation.s new file mode 100644 index 0000000..98beeec --- /dev/null +++ b/decoder/armv7/ixheaacd_esbr_fwd_modulation.s @@ -0,0 +1,111 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .extern ixheaacd_esbr_cos_sin_mod +.hidden ixheaacd_esbr_cos_sin_mod + .global ixheaacd_esbr_fwd_modulation +ixheaacd_esbr_fwd_modulation: + + STMFD sp!, {r4-r12, lr} + VPUSH {D8 - D15} + LDR R4, [R3] + ADD R5, R0, R4, LSL #3 + MOV R6, R1 + MOV R7, R2 + +LOOP1: + SUB R5, R5, #32 + VLD1.32 {D0, D1, D2, D3}, [R0]! + VLD1.32 {D4, D5, D6, D7}, [R5] + VSHR.S32 Q0, Q0, #4 + VSHR.S32 Q1, Q1, #4 + VSHR.S32 Q2, Q2, #4 + VSHR.S32 Q3, Q3, #4 + + vswp d4, d7 + vswp d5, d6 + + vrev64.32 q2, q2 + vrev64.32 q3, q3 + + VQSUB.S32 Q4, Q0, Q2 + VQSUB.S32 Q5, Q1, Q3 + + VADD.S32 Q6, Q0, Q2 + VADD.S32 Q7, Q1, Q3 + + SUBS R4, R4, #8 + VST1.32 {D8, D9, D10, D11}, [R6]! + VST1.32 {D12, D13, D14, D15}, [R7]! + + BGT LOOP1 + STMFD sp!, {r0-r3, lr} + LDR R4, [SP, #124] + MOV R0, R1 + MOV R1, R3 + ldr R5, =0x41FC + ADD R2, R4, R5 + ADD R3, R4, #0xB8 + + BL ixheaacd_esbr_cos_sin_mod + + LDMFD sp!, {r0-r3, r14} + + LDR R0, [R3, #0x5C] + LDRSH R4, [R3, #0x2C] + LDRSH R5, [R3, #0x2A] + + SUB R4, R4, R5 + +LOOP2: + VLD2.32 {D0, D1}, [R0]! + VLD1.32 {D2}, [R1] + VLD1.32 {D3}, [R2] + + VMULL.S32 q2, d0, d2 + VMULL.S32 q3, d0, d3 + VMULL.S32 q4, d1, d2 + VMULL.S32 q5, d1, d3 + + VADD.I64 Q0, Q2, Q5 + VQSUB.S64 Q1, Q3, Q4 + + VSHRN.I64 D0, Q0, #31 + VSHRN.I64 D2, Q1, #31 + + SUBS R4, R4, #2 + VST1.32 {D0}, [R1]! + VST1.32 {D2}, [R2]! + + BGT LOOP2 + + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + + + + + diff --git a/decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s b/decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s new file mode 100644 index 0000000..fca39c0 --- /dev/null +++ b/decoder/armv7/ixheaacd_esbr_qmfsyn64_winadd.s @@ -0,0 +1,409 @@ +@VOID ixheaacd_esbr_qmfsyn64_winadd( +@WORD32 *tmp1, +@WORD32 *tmp2, +@WORD32 *inp1, +@WORD32 *sample_buffer, +@WORD32 ch_fac) +@R0->Word32 *tmp1 +@R1->Word32 *tmp2 +@R2->Word32 *inp1 +@R3->Word32 *sample_buffer +@R5->ch_fac + +.text +.p2align 2 + .global ixheaacd_esbr_qmfsyn64_winadd + +ixheaacd_esbr_qmfsyn64_winadd: @ PROC + + STMFD sp!, {R4-R12, R14} + VPUSH {D8- D15} + LDR R5, [SP, #104] + + MOV R7, #0 + VLD1.32 {D0, D1}, [R0]! + MOV R12, R2 + + VDUP.32 Q15, R7 + VLD1.32 {D2, D3}, [R2]! + + MOV R10, R0 + MOV R11, R2 + ADD R0, R0, #1008 + ADD R2, R2, #496 + + MOV R6, #64 + MOV R6, R6, LSL #2 + ADD R12, R12, R6 + MOV R7, #256 + MOV R9, R7, LSL #1 + ADD R1, R1, R9 + MOV R6, #64 + MOV R7, #256 + MOV R9, R7, LSL #1 @(256*2) + MOV R7, #512 + MOV R8, R7, LSL #1 @(512*2) + + MOV R5, R5, LSL #2 + VMOV Q13, Q15 + VMOV Q14, Q15 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + + VLD1.32 {D4, D5}, [R0], R8 + VLD1.32 {D6, D7}, [R2], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R0], R8 + VLD1.32 {D10, D11}, [R2], R9 + + VMLAL.S32 Q13, D10, D8 + VMLAL.S32 Q14, D11, D9 + + VLD1.32 {D12, D13}, [R0], R8 + VLD1.32 {D14, D15}, [R2], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R0], R8 + VLD1.32 {D18, D19}, [R2], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + MOV R0, R10 + + + MOV R2, R11 + VLD1.32 {D0, D1}, [R1]! + MOV R10, R1 + VLD1.32 {D2, D3}, [R12]! + ADD R1, R1, #1008 + MOV R11, R12 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + VLD1.32 {D4, D5}, [R1], R8 + ADD R12, R12, #496 + + VLD1.32 {D6, D7}, [R12], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R1], R8 + VLD1.32 {D10, D11}, [R12], R9 + + VMLAL.S32 Q13, D10, D8 + VMLAL.S32 Q14, D11, D9 + + VLD1.32 {D12, D13}, [R1], R8 + VLD1.32 {D14, D15}, [R12], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R1], R8 + VLD1.32 {D18, D19}, [R12], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + VSHRN.S64 D26 , Q13, #31 + + VST1.32 D26[0], [R3], R5 + VST1.32 D26[1], [R3], R5 + + VSHRN.S64 D27 , Q14, #31 + + VST1.32 D27[0], [R3], R5 + VST1.32 D27[1], [R3], R5 + + SUB R6, R6, #8 +LOOP_1: + + VLD1.32 {D0, D1}, [R0]! + MOV R12, R11 + MOV R1, R10 + VLD1.32 {D2, D3}, [R2]! + MOV R10, R0 + + ADD R0, R0, #1008 + + MOV R11, R2 + ADD R2, R2, #496 + + + VMOV Q13, Q15 + VMOV Q14, Q15 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + + VLD1.32 {D4, D5}, [R0], R8 + VLD1.32 {D6, D7}, [R2], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R0], R8 + VLD1.32 {D10, D11}, [R2], R9 + + VMLAL.S32 Q13, D10, D8 + VMLAL.S32 Q14, D11, D9 + + VLD1.32 {D12, D13}, [R0], R8 + VLD1.32 {D14, D15}, [R2], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R0], R8 + VLD1.32 {D18, D19}, [R2], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + MOV R0, R10 + + + MOV R2, R11 + VLD1.32 {D0, D1}, [R1]! + MOV R10, R1 + VLD1.32 {D2, D3}, [R12]! + ADD R1, R1, #1008 + MOV R11, R12 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + VLD1.32 {D4, D5}, [R1], R8 + ADD R12, R12, #496 + + VLD1.32 {D6, D7}, [R12], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R1], R8 + VLD1.32 {D10, D11}, [R12], R9 + + VMLAL.S32 Q13, D10, D8 + VMLAL.S32 Q14, D11, D9 + + VLD1.32 {D12, D13}, [R1], R8 + VLD1.32 {D14, D15}, [R12], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R1], R8 + VLD1.32 {D18, D19}, [R12], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + VSHRN.S64 D26 , Q13, #31 + + VST1.32 D26[0], [R3], R5 + VST1.32 D26[1], [R3], R5 + + VSHRN.S64 D27 , Q14, #31 + + VST1.32 D27[0], [R3], R5 + VST1.32 D27[1], [R3], R5 +@@@ + VLD1.32 {D0, D1}, [R0]! + MOV R12, R11 + MOV R1, R10 + VLD1.32 {D2, D3}, [R2]! + MOV R10, R0 + + VMOV Q13, Q15 + VMLAL.S32 Q13, D0, D2 + VMOV Q14, Q15 + VMLAL.S32 Q14, D1, D3 + + ADD R0, R0, #1008 + + MOV R11, R2 + VLD1.32 {D4, D5}, [R0], R8 + ADD R2, R2, #496 + + + VLD1.32 {D6, D7}, [R2], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R0], R8 + VLD1.32 {D10, D11}, [R2], R9 + + VMLAL.S32 Q13, D8, D10 + VMLAL.S32 Q14, D9, D11 + + VLD1.32 {D12, D13}, [R0], R8 + VLD1.32 {D14, D15}, [R2], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R0], R8 + VLD1.32 {D18, D19}, [R2], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + MOV R0, R10 + + + MOV R2, R11 + VLD1.32 {D0, D1}, [R1]! + + MOV R10, R1 + VLD1.32 {D2, D3}, [R12]! + ADD R1, R1, #1008 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + + MOV R11, R12 + VLD1.32 {D4, D5}, [R1], R8 + ADD R12, R12, #496 + + + VLD1.32 {D6, D7}, [R12], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R1], R8 + VLD1.32 {D10, D11}, [R12], R9 + + VMLAL.S32 Q13, D8, D10 + VMLAL.S32 Q14, D9, D11 + + VLD1.32 {D12, D13}, [R1], R8 + VLD1.32 {D14, D15}, [R12], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R1], R8 + VLD1.32 {D18, D19}, [R12], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + VSHRN.S64 D26 , Q13, #31 + + VST1.32 D26[0], [R3], R5 + VST1.32 D26[1], [R3], R5 + + VSHRN.S64 D27 , Q14, #31 + + VST1.32 D27[0], [R3], R5 + VST1.32 D27[1], [R3], R5 + + SUBS R6, R6, #8 @1 + + BGT LOOP_1 + + VLD1.32 {D0, D1}, [R0]! + MOV R12, R11 + MOV R1, R10 + VLD1.32 {D2, D3}, [R2]! + MOV R10, R0 + + VMOV Q13, Q15 + VMLAL.S32 Q13, D0, D2 + VMOV Q14, Q15 + VMLAL.S32 Q14, D1, D3 + + ADD R0, R0, #1008 + + MOV R11, R2 + VLD1.32 {D4, D5}, [R0], R8 + ADD R2, R2, #496 + + + VLD1.32 {D6, D7}, [R2], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R0], R8 + VLD1.32 {D10, D11}, [R2], R9 + + VMLAL.S32 Q13, D8, D10 + VMLAL.S32 Q14, D9, D11 + + VLD1.32 {D12, D13}, [R0], R8 + VLD1.32 {D14, D15}, [R2], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R0], R8 + VLD1.32 {D18, D19}, [R2], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + MOV R0, R10 + + + MOV R2, R11 + VLD1.32 {D0, D1}, [R1]! + + MOV R10, R1 + VLD1.32 {D2, D3}, [R12]! + ADD R1, R1, #1008 + + VMLAL.S32 Q13, D0, D2 + VMLAL.S32 Q14, D1, D3 + + MOV R11, R12 + VLD1.32 {D4, D5}, [R1], R8 + ADD R12, R12, #496 + + + VLD1.32 {D6, D7}, [R12], R9 + + VMLAL.S32 Q13, D6, D4 + VMLAL.S32 Q14, D7, D5 + + VLD1.32 {D8, D9}, [R1], R8 + VLD1.32 {D10, D11}, [R12], R9 + + VMLAL.S32 Q13, D8, D10 + VMLAL.S32 Q14, D9, D11 + + VLD1.32 {D12, D13}, [R1], R8 + VLD1.32 {D14, D15}, [R12], R9 + + VMLAL.S32 Q13, D12, D14 + VMLAL.S32 Q14, D13, D15 + + VLD1.32 {D16, D17}, [R1], R8 + VLD1.32 {D18, D19}, [R12], R9 + + VMLAL.S32 Q13, D16, D18 + VMLAL.S32 Q14, D17, D19 + + VSHRN.S64 D26 , Q13, #31 + + VST1.32 D26[0], [R3], R5 + VST1.32 D26[1], [R3], R5 + + VSHRN.S64 D27, Q14, #31 + + VST1.32 D27[0], [R3], R5 + VST1.32 D27[1], [R3], R5 + + VPOP {D8 - D15} + LDMFD sp!, {R4-R12, R15} + @ ENDP diff --git a/decoder/armv7/ixheaacd_esbr_radix4bfly.s b/decoder/armv7/ixheaacd_esbr_radix4bfly.s new file mode 100644 index 0000000..7a4560d --- /dev/null +++ b/decoder/armv7/ixheaacd_esbr_radix4bfly.s @@ -0,0 +1,154 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.global ixheaacd_esbr_radix4bfly + +ixheaacd_esbr_radix4bfly: + + STMFD sp!, {r4-r12, r14} + + SUB sp, sp, #16 + + MOV r6, #6 + MUL r7, r6, r3 + MOV r4, r3 + STR r7, [sp] + + + + MOV r3, r3, lsl #1 + + STR r2, [sp, #8] + STR r4, [sp, #12] + STR r4, [sp, #4] + + ADD r2, r1, r3, lsl #2 + ADD r0, r0, #16 + + +RADIX4_OUTLOOP: +RADIX4_INLOOP: + + + LDR r6, [r1] + LDR r7, [r2] + LDR r8, [r2, r3, lsl #2] + LDR r9, [r2, r3, lsl #3] + + ADD r10, r6, r8 + SUB r11, r6, r8 + ADD r12, r7, r9 + SUB r14, r7, r9 + + ADD r6, r10, r12 + SUB r7, r10, r12 + STR r6, [r1], #4 + + LDR r8, [r1] + LDR r6, [r2, #4]! + LDR r9, [r2, r3, lsl #2]! + LDR r10, [r2, r3, lsl #2]! + + ADD r12, r8, r9 + SUB r8, r8, r9 + ADD r9, r6, r10 + SUB r6, r6, r10 + + ADD r10, r12, r9 + STR r10, [r1], #4 + SUB r12, r12, r9 + + ADD r9, r11, r6 + SUB r10, r11, r6 + ADD r11, r8, r14 + LDR r5, [r0], #4 + LDR r4, [r0], #-12 + SUB r6, r8, r14 + + RSB r5, r5, #0 + SMULL r14, r8, r10, r5 + SMLAL r14, r8, r11, r4 + RSB r5, r5, #0 + + MOV r8, r8, lsl #1 + STR r8, [r2], #-4 + + SMULL r14, r8, r10, r4 + SMLAL r14, r8, r11, r5 + LDR r11, [r0], #4 + LDR r4, [r0], #-12 + MOV r8, r8, lsl #1 + STR r8, [r2], -r3, lsl #2 + + SMULL r10, r8, r7, r4 + SMLAL r10, r8, r12, r11 + + LDR r14, [r0], #4 + + MOV r5, r8, lsl #1 + + RSB r11, r11, #0 + SMULL r10, r8, r7, r11 + SMLAL r10, r8, r12, r4 + LDR r4, [r0], #36 + STR r5, [r2], #4 + MOV r7, r8, lsl #1 + + RSB r14, r14, #0 + SMULL r11, r12, r9, r14 + SMLAL r11, r12, r6, r4 + RSB r14, r14, #0 + + STR r7, [r2], -r3, lsl #2 + MOV r12, r12, lsl #1 + + SMULL r10, r7, r9, r4 + SMLAL r10, r7, r6, r14 + + STR r12, [r2], #-4 + MOV r7, r7, lsl #1 + STR r7, [r2], #8 + + LDR r4, [sp, #4] + SUBS r4, r4, #1 + STR r4, [sp, #4] + BGT RADIX4_INLOOP + + LDR r8, [sp] + LDR r4, [sp, #12] + + LDR r6, [sp, #8] + + + SUB r0, r0, r8, lsl #2 + ADD r1, r1, r8, lsl #2 + ADD r2, r2, r8, lsl #2 + STR r4, [sp, #4] + SUBS r6, r6, #1 + STR r6, [sp, #8] + BGT RADIX4_OUTLOOP + + + + ADD sp, sp, #16 + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_expsubbandsamples.s b/decoder/armv7/ixheaacd_expsubbandsamples.s new file mode 100644 index 0000000..8a08246 --- /dev/null +++ b/decoder/armv7/ixheaacd_expsubbandsamples.s @@ -0,0 +1,113 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_expsubbandsamples_armv7 +ixheaacd_expsubbandsamples_armv7: + + STMFD sp!, {r4-r12} + + LDR r7, [sp, #0x24] + LDR r10, [sp, #0x28] + SUB r11, r3, r2 + MOV r12, #1 + CMP r7, r10 + BGE EXIT + + MOVS r3, r11 + BEQ EXIT + + + LDR r4, [sp, #0x2c] + CMP r4, #0 + BEQ HQ_OUTER_LOOP + + + + SUB r10, r10, r7 + ADD r0, r0, r7, LSL #2 + LDR r1, [r0], #4 + +OUTERLOOP: + MOV r3, r11 + ADD r5, r1, r2, LSL #2 +INLOOP: + + LDR r4, [r5], #4 + SUBS r3, r3, #2 + LDRGE r8, [r5], #4 + EOR r1 , r4 , r4, asr #31 + ORR r12, r12, r1 + EORGE r1 , r8 , r8, asr #31 + ORRGE r12, r12, r1 + BGT INLOOP + + SUBS r10, r10, #1 + LDR r1, [r0], #4 + BGT OUTERLOOP + + + + B EXIT + + +HQ_OUTER_LOOP: + LDR r6, [r0, r7, LSL #2] + LDR r5, [r1, r7, LSL #2] + ADD r6, r6, r2, LSL #2 + ADD r5, r5, r2, LSL #2 + MOV r4, r11 + +HQ_IN_LOOP: + LDR r8, [r6], #4 + LDR r9, [r5], #4 + SUBS r4, r4, #2 + + EOR r3 , r8 , r8, asr #31 + ORR r12, r12, r3 + + EOR r3 , r9 , r9, asr #31 + ORR r12, r12, r3 + + LDRGE r8, [r6], #4 + LDRGE r9, [r5], #4 + + EORGE r3 , r8 , r8, asr #31 + ORRGE r12, r12, r3 + + EORGE r3 , r9 , r9, asr #31 + ORRGE r12, r12, r3 + + BGT HQ_IN_LOOP + +INLOEN: + ADD r7, r7, #1 + CMP r7, r10 + BLT HQ_OUTER_LOOP + +EXIT: + + CLZ r0, r12 + SUB r0, r0, #1 + LDMFD sp!, {r4-r12} + BX lr + diff --git a/decoder/armv7/ixheaacd_ffr_divide16.s b/decoder/armv7/ixheaacd_ffr_divide16.s new file mode 100644 index 0000000..ea60e8f --- /dev/null +++ b/decoder/armv7/ixheaacd_ffr_divide16.s @@ -0,0 +1,49 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_fix_div_armv7 + +ixheaacd_fix_div_armv7: + EOR r12, r0, r1 + + MOVS r3, r1, ASR #1 + RSBMI r3, r3, #0 + + MOVS r2, r0, ASR #1 + RSBMI r2, r2, #0 + + MOV r0, #0 + BEQ L2 + MOV r1, #0xf +L1: + MOV r2, r2, LSL #1 + CMP r2, r3 + MOV r0, r0, LSL #1 + ADDCS r0, r0, #1 + SUBCS r2, r2, r3 + SUBS r1, r1, #1 + BGT L1 +L2: + CMP r12, #0 + RSBLT r0, r0, #0 + BX lr diff --git a/decoder/armv7/ixheaacd_fft32x32_ld.s b/decoder/armv7/ixheaacd_fft32x32_ld.s new file mode 100644 index 0000000..8826a80 --- /dev/null +++ b/decoder/armv7/ixheaacd_fft32x32_ld.s @@ -0,0 +1,860 @@ +.text +.p2align 2 +.global DSP_fft32x16_dit + +DSP_fft32x16_dit: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + +@**************Variables Vs Registers************************* +@ r0 = *ptr_w +@ r1 = npoints +@ r2 = ptr_x and +@ r3 = ptr_y +@ r4 = pbit_rev_1024 and pdigRevTable +@ r5 = pbit_rev_512 and p_data1 +@ r6 = pbit_rev_128 and p_data2 +@ r7 = pbit_rev_32 and p_data3 +@ r8 = power and nstages_4 +@ r9 = stage_1_count +@ r10 = first_stage (8 or 4) +@ r11 = p_data4 +@ r12 = bit reverse value + + +@ LDR r4,[sp,#0x68] + LDR r5, [sp, #0x68] + LDR r6, [sp, #0x68+4] + LDR r7, [sp, #0x68+8] + + +@ These conditions can be optimised to lesser number +@************************************************************************************ + +@COND_1 CMP r1, #0x400 @1024 +@ BNE COND_2 +@ @MOV r10, #4 @ because radix 8 first stage is by default +@ MOV r8, #4 +@ B RADIX_4_FIRST_START + +@line 59 "../../algo/aacdec/src/neon_asm/fft32x16ch_neon.s" +COND_2: CMP r1, #0x200 @512 + BNE COND_3 + @MOV r10, #8 + MOV r8, #3 + MOV r4, r5 + B RADIX_8_FIRST_START + +COND_3: CMP r1, #0x100 + BNE COND_4 + @MOV r10, #4 + MOV r8, #3 + MOV r4, r5 + B RADIX_4_FIRST_START + +COND_4: CMP r1, #0x80 @128 + BNE COND_5 + @MOV r10, #8 + MOV r8, #2 + MOV r4, r6 + B RADIX_8_FIRST_START + +COND_5: CMP r1, #0x40 + BNE COND_6 + @MOV r10, #4 + MOV r8, #2 + MOV r4, r6 + B RADIX_4_FIRST_START +COND_6: + @MOV r10, #8 + MOV r8, #1 + MOV r4, r7 +@********************************************************************************** + + + @CMP r10,#4 + @BEQ RADIX_4_FIRST_START + +RADIX_8_FIRST_START: + + + LSR r9 , r1, #5 @ LOOP count for first stage + LSL r1, r1, #1 + +RADIX_8_FIRST_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + +@*************** Register mapping to data **************************************** +@ a_data0_r=q0 +@ a_data0_i=q1 +@ a_data2_r=q2 +@ a_data2_i=q3 +@ a_data4_r=q4 +@ a_data4_i=q5 +@ a_data6_r=q6 +@ a_data6_i=q7 + +@ b_data0_r=q8 +@ b_data0_i=q9 +@ b_data2_r=q10 +@ b_data2_i=q11 +@ b_data4_r=q12 +@ b_data4_i=q13 +@ b_data6_r=q14 +@ b_data6_i=q15 + +@********************************************************************************* + + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + SUB r5, r5, r1, LSL #2 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + SUB r6, r6, r1, LSL #2 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12 , LSL #3 + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + SUB r7, r7, r1, LSL #1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + SUB r11, r11, r1, LSL #1 + + + @VHADD.S32 q8, q0, q4 @b_data0_r=vhaddq_s32(a_data0_r_i.val[0],a_data4_r_i.val[0])@ + VADD.I32 q8, q0, q4 @b_data0_r=vhaddq_s32(a_data0_r_i.val[0],a_data4_r_i.val[0])@ + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + @VHSUB.S32 q9, q0, q4 @b_data4_r=vhsubq_s32(a_data0_r_i.val[0],a_data4_r_i.val[0])@ + VSUB.I32 q9, q0, q4 @b_data4_r=vhsubq_s32(a_data0_r_i.val[0],a_data4_r_i.val[0])@ + VLD2.32 {d13[0], d15[0]}, [r7], r1 + SUB r7, r7, r1, LSL #2 + + + + @VHADD.S32 q0, q1, q5 @b_data0_i=vhaddq_s32(a_data0_r_i.val[1],a_data4_r_i.val[1])@ + VADD.I32 q0, q1, q5 @b_data0_i=vhaddq_s32(a_data0_r_i.val[1],a_data4_r_i.val[1])@ + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + @VHSUB.S32 q4, q1, q5 @b_data4_i=vhsubq_s32(a_data0_r_i.val[1],a_data4_r_i.val[1])@ + VSUB.I32 q4, q1, q5 @b_data4_i=vhsubq_s32(a_data0_r_i.val[1],a_data4_r_i.val[1])@ + VLD2.32 {d13[1], d15[1]}, [r11], r1 + SUB r11, r11, r1, LSL #2 + + + + ADD r4, r4, #4 + + ADD r5, r5, r1, LSR #1 + ADD r6, r6, r1, LSR #1 + ADD r7, r7, r1, LSR #1 + ADD r11, r11, r1, LSR #1 + + @VHADD.S32 q1, q2, q6 @b_data2_r=vhaddq_s32(a_data2_r_i.val[0],a_data6_r_i.val[0])@ + VADD.I32 q1, q2, q6 @b_data2_r=vhaddq_s32(a_data2_r_i.val[0],a_data6_r_i.val[0])@ + VLD2.32 {d28[0], d30[0]}, [r5] , r1 @a_data1_r_i=vld2q_lane_s32(__transfersize(2) p_data1,a_data1_r_i,0)@ + + @VHSUB.S32 q5, q2, q6 @b_data6_r=vhsubq_s32(a_data2_r_i.val[0],a_data6_r_i.val[0])@ + VSUB.I32 q5, q2, q6 @b_data6_r=vhsubq_s32(a_data2_r_i.val[0],a_data6_r_i.val[0])@ + VLD2.32 {d20[0], d22[0]}, [r5] , r1 @a_data3_r_i=vld2q_lane_s32(__transfersize(2) p_data1,a_data3_r_i,0) + + @VHADD.S32 q2, q3, q7 @b_data2_i=vhaddq_s32(a_data2_r_i.val[1],a_data6_r_i.val[1])@ + VADD.I32 q2, q3, q7 @b_data2_i=vhaddq_s32(a_data2_r_i.val[1],a_data6_r_i.val[1])@ + VLD2.32 {d24[0], d26[0]}, [r5] , r1 @a_data5_r_i=vld2q_lane_s32(__transfersize(2) p_data1,a_data5_r_i,0) + + @VHSUB.S32 q6, q3, q7 @b_data6_i=vhsubq_s32(a_data2_r_i.val[1],a_data6_r_i.val[1])@ + VSUB.I32 q6, q3, q7 @b_data6_i=vhsubq_s32(a_data2_r_i.val[1],a_data6_r_i.val[1])@ + VLD2.32 {d28[1], d30[1]}, [r6] , r1 + + VADD.S32 q3, q9, q6 @c_data4_r=vaddq_s32(b_data4_r,b_data6_i)@ + VLD2.32 {d20[1], d22[1]}, [r6] , r1 + + VSUB.S32 q7, q9, q6 @c_data6_r=vsubq_s32(b_data4_r,b_data6_i)@ + VLD2.32 {d24[1], d26[1]}, [r6] , r1 + + VSUB.S32 q6, q4, q5 @c_data4_i=vsubq_s32(b_data4_i,b_data6_r)@ + VLD2.32 {d29[0], d31[0]}, [r7] , r1 + + VADD.S32 q9, q4, q5 @c_data6_i=vaddq_s32(b_data4_i,b_data6_r)@ + VLD2.32 {d21[0], d23[0]}, [r7] , r1 + + VADD.S32 q4, q8, q1 @c_data0_r=vaddq_s32(b_data0_r,b_data2_r)@ + VLD2.32 {d25[0], d27[0]}, [r7] , r1 + + VSUB.S32 q5, q8, q1 @c_data2_r=vsubq_s32(b_data0_r,b_data2_r)@ + VLD2.32 {d29[1], d31[1]}, [r11] , r1 + + VADD.S32 q8, q0, q2 @c_data0_i=vaddq_s32(b_data0_i,b_data2_i)@ + VLD2.32 {d21[1], d23[1]}, [r11] , r1 + + VSUB.S32 q0, q0, q2 @c_data2_i=vsubq_s32(b_data0_i,b_data2_i)@ + VLD2.32 {d25[1], d27[1]}, [r11] , r1 + + + VPUSH {q3} @ VPUSH(c_data4_r, c_data6_r) + VPUSH {q7} + + + + + + + + + VLD2.32 {d2[0], d4[0]}, [r5], r1 @a_data7_r_i=vld2q_lane_s32(__transfersize(2) p_data1,a_data7_r_i,0) + @VHADD.S32 q7, q14, q12 @b_data1_r=vhaddq_s32(a_data1_r,a_data5_r)@ + VADD.I32 q7, q14, q12 @b_data1_r=vhaddq_s32(a_data1_r,a_data5_r)@ + + VLD2.32 {d2[1], d4[1]}, [r6] , r1 + @VHSUB.S32 q3, q14, q12 @b_data5_r=vhsubq_s32(a_data1_r,a_data5_r)@ + VSUB.I32 q3, q14, q12 @b_data5_r=vhsubq_s32(a_data1_r,a_data5_r)@ + + VLD2.32 {d3[0], d5[0]}, [r7] , r1 + @VHADD.S32 q14, q15, q13 @b_data1_i=vhaddq_s32(a_data1_i,a_data5_i)@ + VADD.I32 q14, q15, q13 @b_data1_i=vhaddq_s32(a_data1_i,a_data5_i)@ + + VLD2.32 {d3[1], d5[1]}, [r11] , r1 + @VHSUB.S32 q12, q15, q13 @b_data5_i=vhsubq_s32(a_data1_i,a_data5_i)@ + VSUB.I32 q12, q15, q13 @b_data5_i=vhsubq_s32(a_data1_i,a_data5_i)@ + + + + + @VHADD.S32 q15, q10,q1 @b_data3_r=vhaddq_s32(a_data3_r,a_data7_r)@ + @VHSUB.S32 q13, q10,q1 @b_data7_r=vhsubq_s32(a_data3_r,a_data7_r)@ + @VHADD.S32 q10, q11, q2 @b_data3_i=vhaddq_s32(a_data3_i,a_data7_i)@ + @VHSUB.S32 q1, q11, q2 @b_data7_i=vhsubq_s32(a_data3_i,a_data7_i)@ + + VADD.I32 q15, q10, q1 @b_data3_r=vhaddq_s32(a_data3_r,a_data7_r)@ + VSUB.I32 q13, q10, q1 @b_data7_r=vhsubq_s32(a_data3_r,a_data7_r)@ + VADD.I32 q10, q11, q2 @b_data3_i=vhaddq_s32(a_data3_i,a_data7_i)@ + VSUB.I32 q1, q11, q2 @b_data7_i=vhsubq_s32(a_data3_i,a_data7_i)@ + + + + VADD.S32 q11, q7, q15 @c_data1_r=vaddq_s32(b_data1_r,b_data3_r)@ + VSUB.S32 q2, q7, q15 @c_data3_r=vsubq_s32(b_data1_r,b_data3_r)@ + VADD.S32 q7, q14, q10 @c_data1_i=vaddq_s32(b_data1_i,b_data3_i)@ + VSUB.S32 q15, q14, q10 @c_data3_i=vsubq_s32(b_data1_i,b_data3_i)@ + + VADD.S32 q14, q3, q12 @c_data5_r=vaddq_s32(b_data5_r,b_data5_i)@ + VSUB.S32 q10, q3, q12 @c_data5_i=vsubq_s32(b_data5_r,b_data5_i)@ + VADD.S32 q3, q13, q1 @c_data7_r=vaddq_s32(b_data7_r,b_data7_i)@ + VSUB.S32 q12, q13, q1 @c_data7_i=vsubq_s32(b_data7_r,b_data7_i)@ + + VADD.S32 q1 , q14, q12 @b_data5_r=vaddq_s32(c_data7_i,c_data5_r)@ + VSUB.S32 q13, q14, q12 @b_data7_i=vsubq_s32(c_data5_r,c_data7_i)@ + VSUB.S32 q12, q3, q10 @b_data5_i=vsubq_s32(c_data7_r,c_data5_i)@ + + VUZP.16 d2, d3 @ D0 = b_data5_r_low, D1= b_data5_r_high + VADD.S32 q14, q3, q10 @b_data7_r=vaddq_s32(c_data5_i,c_data7_r)@ + + VUZP.16 d26, d27 + VADD.S32 q3, q4, q11 @b_data0_r=vaddq_s32(c_data0_r,c_data1_r)@ + + VUZP.16 d24, d25 + VSUB.S32 q10, q4, q11 @b_data1_r=vsubq_s32(c_data0_r,c_data1_r)@ + + VUZP.16 d28, d29 + VADD.S32 q4, q8, q7 @b_data0_i=vaddq_s32(c_data0_i,c_data1_i)@ + + LDR r14, = 0x5a82 + + VSUB.S32 q11, q8, q7 @b_data1_i=vsubq_s32(c_data0_i,c_data1_i)@ + + VADD.S32 q8, q5, q15 @b_data2_r=vaddq_s32(c_data2_r,c_data3_i)@ + VSUB.S32 q7, q5, q15 @b_data3_r=vsubq_s32(c_data2_r,c_data3_i)@ + VSUB.S32 q5, q0, q2 @b_data2_i=vsubq_s32(c_data2_i,c_data3_r)@ + VADD.S32 q15, q0, q2 @b_data3_i=vaddq_s32(c_data2_i,c_data3_r)@ + + VPOP {q0} + VPOP {q2} + VPUSH {q3-q4} + VPUSH {q10} + + + + +@******************************************************************** +@ b_data5_r = q1 free regs = q3,q4,q5,q7,q8,q10,q11 +@ b_data5_i = q12 +@ b_data7_r = q14 +@ b_data7_i = q13 + +@ c_data4_r = q2 +@ c_data4_i = q6 +@ c_data6_r = q0 +@ c_data6_i = q9 +@******************************************************************** + + + VDUP.16 d20, r14 + + + VMULL.u16 q4, d26, d20 + VMULL.u16 q3, d28, d20 + + VPUSH {q7-q8} + VPUSH {q5} + + VSHR.S32 q4, q4, #15 + VSHR.S32 q3, q3, #15 + + VQDMLAL.S16 q4, d27, d20 + VQDMLAL.S16 q3, d29, d20 + + + VPUSH {q11} + + VMULL.u16 q13, d24, d20 + VMULL.u16 q14, d2, d20 + + VADD.S32 q5, q2, q4 @q5=b_data7_i + VSUB.S32 q7, q2, q4 @q7=b_data4_r + + VADD.S32 q8, q6, q3 @q10 = b_data4_i + VSUB.S32 q6, q6, q3 @q11 = b_data7_r + + + + + + + VSHR.S32 q13, q13, #15 + VSHR.S32 q14, q14, #15 + + VQDMLAL.S16 q13, d25, d20 + VQDMLAL.S16 q14, d3, d20 + + VPOP {q1} + VPOP {q10} + + VADD.S32 q2, q0, q13 @q2 = b_data5_i + VSUB.S32 q4, q0, q13 @q4 = b_data6_r + + VADD.S32 q11, q9, q14 @q6 = b_data6_i + VSUB.S32 q3, q9, q14 @q8 = b_data5_r + + + + + VPOP {q14} + VPOP {q9} + VPOP {q0} + VPOP {q12, q13} + + + + + +@**************regs maping************ +@b_data0_r = q12 +@b_data0_i = q13 +@b_data1_r = q0 +@b_data1_i = q1 + +@b_data2_r = q9 +@b_data2_i = q10 +@b_data3_r = q14 +@b_data3_i = q15 + +@b_data4_r = q7 +@b_data4_i = q8 +@b_data5_r = q3 +@b_data5_i = q2 + +@b_data6_r = q4 +@b_data6_i = q11 +@b_data7_r = q6 +@b_data7_i = q5 +@****************************************** + +@shifts added (as dual simd instrn) + + VTRN.32 q12, q5 +@line 455 "../../algo/aacdec/src/neon_asm/fft32x16ch_neon.s" + VSHL.S32 q12, q12, #3 @ch + VTRN.32 q9, q2 + VSHL.S32 q5, q5, #3 @ch + + VSHL.S32 q9, q9, #3 @ch + VTRN.32 q0, q7 + VSHL.S32 q2, q2, #3 @ch + + VSHL.S32 q0, q0, #3 @ch + VTRN.32 q14, q4 + VSHL.S32 q7, q7, #3 @ch + + VSHL.S32 q14, q14, #3 @ch + VTRN.32 q13, q6 + VSHL.S32 q4, q4, #3 @ch + + VSHL.S32 q13, q13, #3 @ch + VTRN.32 q10, q3 + VSHL.S32 q6, q6, #3 @ch + + VSHL.S32 q10, q10, #3 @ch + VTRN.32 q1, q8 + VSHL.S32 q3, q3, #3 @ch + + VSHL.S32 q1, q1, #3 @ch + VTRN.32 q15, q11 + VSHL.S32 q8, q8, #3 @ch + + VSHL.S32 q15, q15, #3 @ch + VSWP d18, d25 + + VSHL.S32 q11, q11, #3 @ch + VSWP d4, d11 + + VSWP d1, d28 + VSWP d15, d8 + + VSWP d20, d27 + VSWP d6, d13 + + VSWP d30, d3 + VSWP d22, d17 + + VST2.32 {q12, q13}, [r3]! + VST2.32 {q0, q1}, [r3]! + + VST2.32 {q5, q6}, [r3]! + VST2.32 {q7, q8}, [r3]! + + VMOV q5, q11 + + VST2.32 {q9, q10}, [r3]! + VST2.32 {q14, q15}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q4, q5}, [r3]! + + + SUBS r9, r9, #1 + BNE RADIX_8_FIRST_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + + MOV r5, #8 + MOV r4, #32 + LSR r6, r1, #5 + + B RADIX_4_FIRST_ENDS + +RADIX_8_FIRST_ENDS: + + + + +@************************************RADIX 4 FIRST STAGE********************************** + +RADIX_4_FIRST_START: + + + LSR r9 , r1, #4 @ LOOP count for first stage + LSL r1, r1, #1 + +RADIX_4_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + +@*************** Register mapping to data **************************************** +@ a_data0_r=q0 +@ a_data0_i=q1 +@ a_data1_r=q2 +@ a_data1_i=q3 +@ a_data2_r=q4 +@ a_data2_i=q5 +@ a_data3_r=q6 +@ a_data4_i=q7 + + +@********************************************************************************* + + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12, LSL #3 + + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + + + SUB r7, r7, r1, LSL #1 + VADD.S32 q8, q0, q4 @b_data0_r=vaddq_s32(a_data0_r,a_data2_r)@ + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + VADD.S32 q9, q1, q5 @b_data0_i=vaddq_s32(a_data0_i,a_data2_i)@ + VLD2.32 {d13[0], d15[0]}, [r7], r1 + + + + SUB r11, r11, r1, LSL #1 + VSUB.S32 q10, q0, q4 @b_data2_r=vsubq_s32(a_data0_r,a_data2_r)@ + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + VSUB.S32 q11, q1, q5 @b_data2_i=vsubq_s32(a_data0_i,a_data2_i)@ + VLD2.32 {d13[1], d15[1]}, [r11], r1 + + + ADD r4, r4, #4 + + VADD.S32 q12, q2, q6 @b_data1_r=vaddq_s32(a_data1_r,a_data3_r)@ + VADD.S32 q13, q3, q7 @b_data1_i=vaddq_s32(a_data1_i,a_data3_i)@ + VSUB.S32 q14, q2, q6 @b_data3_r=vsubq_s32(a_data1_r,a_data3_r)@ + VSUB.S32 q15, q3, q7 @b_data3_i=vsubq_s32(a_data1_i,a_data3_i)@ + + VADD.S32 q0, q8, q12 @a_data0_r=vaddq_s32(b_data0_r,b_data1_r)@ + VADD.S32 q1, q9, q13 @a_data0_i=vaddq_s32(b_data0_i,b_data1_i)@ + VSUB.S32 q2, q8, q12 @a_data1_r=vsubq_s32(b_data0_r,b_data1_r)@ + VSUB.S32 q3, q9, q13 @a_data1_i=vsubq_s32(b_data0_i,b_data1_i)@ + + VADD.S32 q4, q10, q15 @a_data2_r=vaddq_s32(b_data2_r,b_data3_i)@ + VSUB.S32 q5, q11, q14 @a_data2_i=vsubq_s32(b_data2_i,b_data3_r)@ + VADD.S32 q7, q11, q14 @a_data3_r=vaddq_s32(b_data2_i,b_data3_r)@ + VSUB.S32 q6, q10, q15 @a_data3_i=vsubq_s32(b_data2_r,b_data3_i)@ + + +@shifts added + + VTRN.32 q0, q4 + + VSHL.S32 q0, q0, #2 @ch + VTRN.32 q2, q6 + VSHL.S32 q4, q4, #2 @ch + + VSHL.S32 q2, q2, #2 @ch + VTRN.32 q1, q5 @ch + VSHL.S32 q6, q6, #2 @ch + + VSHL.S32 q1, q1, #2 @ch + VTRN.32 q3, q7 @ch + VSHL.S32 q5, q5, #2 @ch + + VSHL.S32 q3, q3, #2 @ch + VSWP d4, d1 + + VSHL.S32 q7, q7, #2 @ch + VSWP d12, d9 + + @VTRN.32 q1, q5 + @VTRN.32 q3, q7 + VSWP d6, d3 + VSWP d14, d11 + + + VST2.32 {q0, q1}, [r3]! + VST2.32 {q4, q5}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q6, q7}, [r3]! + + + + SUBS r9, r9, #1 + BNE RADIX_4_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + MOV r5, #4 + MOV r4, #64 + LSR r6, r1, #4 + + +RADIX_4_FIRST_ENDS: + + + +@********************************END OF RADIX 4 FIRST STAGE******************************* + +@*************** register assignment after first radix 8 stage**************************** +@ r1 = npoints +@ r0 = *ptr_w +@ r3 = *ptr_y +@ r8 = nstages_4 +@ free regs r2, r4,r5,r6,r7,r9,r10,r11,r12 +@ r2 = j +@ r4 = node_spacing +@ r5 = del +@ r6 = in_loop_count +@ r7 = middle_loop_count (del*node_spacing) +@ r9 = p_twiddle_factors +@ r10= p_twiddle_factors and inner loop counter +@ r11= +@ r12= +@ r14= *data + + PUSH {r3} + + LSR r5, r5, #2 + +OUTER_LOOP_R4: + + LDR r14, [sp] + @MOV r14,r3 + @LSR r7,r5,#0 @,#2 + MOV r7, r5 + MOV r2, #0 + MOV r9, r0 + LSL r12 , r5, #5 +MIDDLE_LOOP_R4: + + + VLD2.16 {d0[0], d1[0]}, [r9], r2 @cos_1 = d0 , sin_1=d1 + VLD2.16 {d2[0], d3[0]}, [r9], r2 @cos_2 = d2 , sin_2=d3 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[0], d5[0]}, [r9] @cos_3 = d4 , sin_3=d5 + ADD r10, r0, r11 + + + VLD2.16 {d0[1], d1[1]}, [r10], r11 + VLD2.16 {d2[1], d3[1]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[1], d5[1]}, [r10] + ADD r9, r0, r2 + + + VLD2.16 {d0[2], d1[2]}, [r9], r2 + VLD2.16 {d2[2], d3[2]}, [r9], r2 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[2], d5[2]}, [r9] + ADD r10, r0, r11 + + + + VLD2.16 {d0[3], d1[3]}, [r10], r11 + VLD2.16 {d2[3], d3[3]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[3], d5[3]}, [r10] + ADD r9, r0, r2 + + MOV r10, r6 + + + +INNER_LOOP_R4: + + VLD2.32 {q3, q4}, [r14], r12 + + VSHR.S32 q3, q3, #1 + VLD4.16 {q5, q6}, [r14], r12 @a_data1_r_l=d10 , a_data1_r_h=d11, a_data1_i_l=d12, a_data1_i_h=d13 + VSHR.S32 q4, q4, #1 + + VSHR.U16 d10, d10, #1 @a_data1.val[0]= vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data1.val[0]), 1))@ + VLD4.16 {q7, q8}, [r14], r12 + VSHR.U16 d12, d12, #1 @a_data1.val[2]= vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data1.val[2]), 1))@ + + VMULL.S16 q11, d10, d0 @prod_1r=vmull_s16(a_data1.val[0], cos_1)@ + VMLSL.S16 q11, d12, d1 @prod_1r=vmlsl_s16(prod_1r, a_data1.val[2], sin_1)@ + VLD4.16 {q9, q10}, [r14], r12 + VMULL.S16 q12, d10, d1 @prod_1i=vmull_s16(a_data1.val[0], sin_1)@ + VMLAL.S16 q12, d12, d0 @prod_1i=vmlal_s16(prod_1i, a_data1.val[2], cos_1)@ + + VSHR.U16 d14, d14, #1 @a_data2.val[0]=vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data2.val[0]), 1))@ + VSHR.U16 d16, d16, #1 @a_data2.val[2]=vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data2.val[2]), 1))@ + + SUB r14, r14, r12, LSL #2 + + VSHR.U16 d18, d18, #1 @a_data3.val[0]= vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data3.val[0]), 1))@ + VSHR.U16 d20, d20, #1 @a_data3.val[2]= vreinterpret_s16_u16(vshr_n_u16(vreinterpret_u16_s16(a_data3.val[2]), 1))@ + + VMULL.S16 q13, d14, d2 @prod_2r=vmull_s16(a_data2.val[0], cos_2)@ + VMLSL.S16 q13, d16, d3 @prod_2r=vmlsl_s16(prod_2r, a_data2.val[2], sin_2)@ + + VSHR.S32 q11, q11, #15 @a_data1_r=vshrq_n_s32(prod_1r,15)@ + + VMULL.S16 q14, d14, d3 @prod_2i=vmull_s16(a_data2.val[0], sin_2)@ + VMLAL.S16 q14, d16, d2 @prod_2i=vmlal_s16(prod_2i, a_data2.val[2], cos_2)@ + + VMULL.S16 q15, d18, d4 @prod_3r=vmull_s16(a_data3.val[0], cos_3)@ + VMLSL.S16 q15, d20, d5 @prod_3r=vmlsl_s16(prod_3r, a_data3.val[2], sin_3)@ + + VMLAL.S16 q11, d11, d0 @a_data1_r=vmlal_s16(a_data1_r, a_data1.val[1], cos_1)@ + VMLSL.S16 q11, d13, d1 @a_data1_r=vmlsl_s16(a_data1_r, a_data1.val[3], sin_1)@ + + VSHR.S32 q12, q12, #15 @a_data1_i=vshrq_n_s32(prod_1i,15)@ + VSHR.S32 q13, q13, #15 @a_data2_r=vshrq_n_s32(prod_2r,15)@ + VSHR.S32 q14, q14, #15 @a_data2_i=vshrq_n_s32(prod_2i,15)@ + VSHR.S32 q15, q15, #15 @a_data3_r=vshrq_n_s32(prod_3r,15)@ + + + VMLAL.S16 q12, d11, d1 @a_data1_i=vmlal_s16(a_data1_i, a_data1.val[1], sin_1)@ + VMLAL.S16 q12, d13, d0 @a_data1_i=vmlal_s16(a_data1_i, a_data1.val[3], cos_1)@ + + + VMULL.S16 q5, d18, d5 @prod_3i=vmull_s16(a_data3.val[0], sin_3)@ + VMLAL.S16 q5, d20, d4 @prod_3i=vmlal_s16(prod_3i, a_data3.val[2], cos_3)@ + + + VMLAL.S16 q13, d15, d2 @a_data2_r=vmlal_s16(a_data2_r, a_data2.val[1], cos_2)@ + VMLSL.S16 q13, d17, d3 @a_data2_r=vmlsl_s16(a_data2_r, a_data2.val[3], sin_2)@ + + VMLAL.S16 q14, d15, d3 @a_data2_i=vmlal_s16(a_data2_i, a_data2.val[1], sin_2)@ + VMLAL.S16 q14, d17, d2 @a_data2_i=vmlal_s16(a_data2_i, a_data2.val[3], cos_2)@ + + + VMLAL.S16 q15, d19, d4 @a_data3_r=vmlal_s16(a_data3_r, a_data3.val[1], cos_3)@ + VMLSL.S16 q15, d21, d5 @a_data3_r=vmlsl_s16(a_data3_r, a_data3.val[3], sin_3)@ + + VSHR.S32 q5, q5, #15 @a_data3_i=vshrq_n_s32(prod_3i,15)@ + + VMLAL.S16 q5, d19, d5 @a_data3_i=vmlal_s16(a_data3_i, a_data3.val[1], sin_3)@ + VMLAL.S16 q5, d21, d4 @a_data3_i=vmlal_s16(a_data3_i, a_data3.val[3], cos_3)@ + +@**********if condition****************** + + CMP r7, r5 + BNE BYPASS_IF + + ADD r14, r14, r12 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d22[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d26[0], r3 + + LDR r3, [r14] + ASR r3, r3, #1 + VMOV.32 d30[0], r3 + + SUB r14, r14, r12, LSL #1 + ADD r14, r14, #4 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d24[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d28[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d10[0], r3 + + SUB r14, r14, #4 + + SUB r14, r14, r12, LSL #2 +@**************************************** +BYPASS_IF: + + VADD.S32 q6, q3, q13 @b_data0_r=vaddq_s32(a_data0_r,a_data2_r)@ + VADD.S32 q7, q4, q14 @b_data0_i=vaddq_s32(a_data0_i,a_data2_i)@ + VSUB.S32 q3, q3, q13 @b_data2_r=vsubq_s32(a_data0_r,a_data2_r)@ + VSUB.S32 q4, q4, q14 @b_data2_i=vsubq_s32(a_data0_i,a_data2_i)@ + VADD.S32 q8, q11, q15 @b_data1_r=vaddq_s32(a_data1_r,a_data3_r)@ + VADD.S32 q9, q12, q5 @b_data1_i=vaddq_s32(a_data1_i,a_data3_i)@ + + VSUB.S32 q15, q11, q15 @b_data3_r=vsubq_s32(a_data1_r,a_data3_r)@ + VSUB.S32 q14, q12, q5 @b_data3_i=vsubq_s32(a_data1_i,a_data3_i)@ + +@line 882 "../../algo/aacdec/src/neon_asm/fft32x16ch_neon.s" + VADD.S32 q10, q6, q8 @c_data0_r=vaddq_s32(b_data0_r,b_data1_r)@ + VADD.S32 q11, q7, q9 @c_data0_i=vaddq_s32(b_data0_i,b_data1_i)@ + VADD.S32 q12, q3, q14 @c_data2_r=vaddq_s32(b_data2_r,b_data3_i)@ + VSUB.S32 q13, q4, q15 @c_data2_i=vsubq_s32(b_data2_i,b_data3_r)@ + + VSUB.S32 q6, q6, q8 @c_data1_r=vsubq_s32(b_data0_r,b_data1_r)@ + VST2.32 {q10, q11}, [r14], r12 @ storing (c_data0_r,c_data0_i) + VSUB.S32 q7, q7, q9 @c_data1_i=vsubq_s32(b_data0_i,b_data1_i)@ + + VSUB.S32 q8, q3, q14 @c_data3_i=vsubq_s32(b_data2_r,b_data3_i)@ + VST2.32 {q12, q13}, [r14], r12 @ storing (c_data2_r,c_data2_i) + VADD.S32 q9, q4, q15 @c_data3_r=vaddq_s32(b_data2_i,b_data3_r)@ + + + VST2.32 {q6, q7}, [r14], r12 @ storing (c_data1_r,c_data1_i) + VST2.32 {q8, q9}, [r14], r12 @ storing (c_data3_i,c_data3_r) + + + + + SUBS r10, r10, #1 + BNE INNER_LOOP_R4 + + SUB r14, r14, r1, LSL #3 + ADD r14, r14, #32 + + SUBS r7, r7, #1 + BNE MIDDLE_LOOP_R4 + + + + + LSR r4, r4, #2 + LSL r5, r5, #2 + LSR r6, r6, #2 + SUBS r8, r8, #1 + BNE OUTER_LOOP_R4 +END_LOOPS: + POP {r3} + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s b/decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s new file mode 100644 index 0000000..f09ba65 --- /dev/null +++ b/decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s @@ -0,0 +1,373 @@ +.text +.p2align 2 +.global ixheaacd_fft32x32_ld2_armv7 + +ixheaacd_fft32x32_ld2_armv7: + + STMFD sp!, {r4-r12, r14} + + @DIT Radix-4 FFT First Stage + @First Butterfly + MOV r0, r2 + MOV r1, r3 + LDR r2, [r0] @x_0 = x[0 ] + LDR r3, [r0, #32] @x_2 = x[8 ] + LDR r4, [r0, #64] @x_4 = x[16] + LDR r5, [r0, #96] @x_6 = x[24] + ADD r6, r2, r4 @xh0_0 = x_0 + x_4 + SUB r7, r2, r4 @xl0_0 = x_0 - x_4 + ADD r8, r3, r5 @xh0_1 = x_2 + x_6 + SUB r9, r3, r5 @xl0_1 = x_2 - x_6 + + LDR r2, [r0, #4] @x_1 = x[0 +1] + LDR r3, [r0, #36] @x_3 = x[8 +1] + LDR r4, [r0, #68] @x_5 = x[16+1] + LDR r5, [r0, #100] @x_7 = x[24+1] + ADD r10, r2, r4 @xh1_0 = x_1 + x_5 + SUB r11, r2, r4 @xl1_0 = x_1 - x_5 + ADD r12, r3, r5 @xh1_1 = x_3 + x_7 + SUB r14, r3, r5 @xl1_1 = x_3 - x_7 + + ADD r2, r6, r8 @n00 = xh0_0 + xh0_1 + ADD r3, r7, r14 @n10 = xl0_0 + xl1_1 + SUB r4, r6, r8 @n20 = xh0_0 - xh0_1 + SUB r5, r7, r14 @n30 = xl0_0 - xl1_1 + STR r2, [r0] @x[0 ] = n00 + STR r3, [r0, #32] @x[8 ] = n10 + STR r4, [r0, #64] @x[16] = n20 + STR r5, [r0, #96] @x[24] = n30 + + ADD r2, r10, r12 @n01 = xh1_0 + xh1_1 + SUB r3, r11, r9 @n11 = xl1_0 - xl0_1 + SUB r4, r10, r12 @n21 = xh1_0 - xh1_1 + ADD r5, r11, r9 @n31 = xl1_0 + xl0_1 + STR r2, [r0, #4] @x[1 ] = n01 + STR r3, [r0, #36] @x[8+1 ] = n11 + STR r4, [r0, #68] @x[16+1] = n21 + STR r5, [r0, #100] @x[24+1] = n31 + + @Second Butterfly + LDR r2, [r0, #8] @x_0 = x[2 ] + LDR r3, [r0, #40] @x_2 = x[10] + LDR r4, [r0, #72] @x_4 = x[18] + LDR r5, [r0, #104] @x_6 = x[26] + ADD r6, r2, r4 @xh0_0 = x_0 + x_4 + SUB r7, r2, r4 @xl0_0 = x_0 - x_4 + ADD r8, r3, r5 @xh0_1 = x_2 + x_6 + SUB r9, r3, r5 @xl0_1 = x_2 - x_6 + + LDR r2, [r0, #12] @x_1 = x[2 +1] + LDR r3, [r0, #44] @x_3 = x[10+1] + LDR r4, [r0, #76] @x_5 = x[18+1] + LDR r5, [r0, #108] @x_7 = x[26+1] + ADD r10, r2, r4 @xh1_0 = x_1 + x_5 + SUB r11, r2, r4 @xl1_0 = x_1 - x_5 + ADD r12, r3, r5 @xh1_1 = x_3 + x_7 + SUB r14, r3, r5 @xl1_1 = x_3 - x_7 + + ADD r2, r6, r8 @n00 = xh0_0 + xh0_1 + ADD r3, r7, r14 @n10 = xl0_0 + xl1_1 + SUB r4, r6, r8 @n20 = xh0_0 - xh0_1 + SUB r5, r7, r14 @n30 = xl0_0 - xl1_1 + STR r2, [r0, #8] @x[2 ] = n00 + STR r3, [r0, #40] @x[10] = n10 + STR r4, [r0, #72] @x[18] = n20 + STR r5, [r0, #104] @x[26] = n30 + + ADD r2, r10, r12 @n01 = xh1_0 + xh1_1 + SUB r3, r11, r9 @n11 = xl1_0 - xl0_1 + SUB r4, r10, r12 @n21 = xh1_0 - xh1_1 + ADD r5, r11, r9 @n31 = xl1_0 + xl0_1 + STR r2, [r0, #12] @x[2 +1] = n01 + STR r3, [r0, #44] @x[10+1] = n11 + STR r4, [r0, #76] @x[18+1] = n21 + STR r5, [r0, #108] @x[26+1] = n31 + + @Third Butterfly + LDR r2, [r0, #16] @x_0 = x[4 ] + LDR r3, [r0, #48] @x_2 = x[12] + LDR r4, [r0, #80] @x_4 = x[20] + LDR r5, [r0, #112] @x_6 = x[28] + ADD r6, r2, r4 @xh0_0 = x_0 + x_4 + SUB r7, r2, r4 @xl0_0 = x_0 - x_4 + ADD r8, r3, r5 @xh0_1 = x_2 + x_6 + SUB r9, r3, r5 @xl0_1 = x_2 - x_6 + + LDR r2, [r0, #20] @x_1 = x[4 +1] + LDR r3, [r0, #52] @x_3 = x[12+1] + LDR r4, [r0, #84] @x_5 = x[20+1] + LDR r5, [r0, #116] @x_7 = x[28+1] + ADD r10, r2, r4 @xh1_0 = x_1 + x_5 + SUB r11, r2, r4 @xl1_0 = x_1 - x_5 + ADD r12, r3, r5 @xh1_1 = x_3 + x_7 + SUB r14, r3, r5 @xl1_1 = x_3 - x_7 + + ADD r2, r6, r8 @n00 = xh0_0 + xh0_1 + ADD r3, r7, r14 @n10 = xl0_0 + xl1_1 + SUB r4, r6, r8 @n20 = xh0_0 - xh0_1 + SUB r5, r7, r14 @n30 = xl0_0 - xl1_1 + STR r2, [r0, #16] @x[4 ] = n00 + STR r3, [r0, #48] @x[12] = n10 + STR r4, [r0, #80] @x[20] = n20 + STR r5, [r0, #112] @x[28] = n30 + + ADD r2, r10, r12 @n01 = xh1_0 + xh1_1 + SUB r3, r11, r9 @n11 = xl1_0 - xl0_1 + SUB r4, r10, r12 @n21 = xh1_0 - xh1_1 + ADD r5, r11, r9 @n31 = xl1_0 + xl0_1 + STR r2, [r0, #20] @x[4 +1] = n01 + STR r3, [r0, #52] @x[12+1] = n11 + STR r4, [r0, #84] @x[20+1] = n21 + STR r5, [r0, #116] @x[28+1] = n31 + + @Fourth Butterfly + LDR r2, [r0, #24] @x_0 = x[6 ] + LDR r3, [r0, #56] @x_2 = x[14] + LDR r4, [r0, #88] @x_4 = x[22] + LDR r5, [r0, #120] @x_6 = x[30] + ADD r6, r2, r4 @xh0_0 = x_0 + x_4 + SUB r7, r2, r4 @xl0_0 = x_0 - x_4 + ADD r8, r3, r5 @xh0_1 = x_2 + x_6 + SUB r9, r3, r5 @xl0_1 = x_2 - x_6 + + LDR r2, [r0, #28] @x_1 = x[6 +1] + LDR r3, [r0, #60] @x_3 = x[14+1] + LDR r4, [r0, #92] @x_5 = x[22+1] + LDR r5, [r0, #124] @x_7 = x[30+1] + ADD r10, r2, r4 @xh1_0 = x_1 + x_5 + SUB r11, r2, r4 @xl1_0 = x_1 - x_5 + ADD r12, r3, r5 @xh1_1 = x_3 + x_7 + SUB r14, r3, r5 @xl1_1 = x_3 - x_7 + + ADD r2, r6, r8 @n00 = xh0_0 + xh0_1 + ADD r3, r7, r14 @n10 = xl0_0 + xl1_1 + SUB r4, r6, r8 @n20 = xh0_0 - xh0_1 + SUB r5, r7, r14 @n30 = xl0_0 - xl1_1 + STR r2, [r0, #24] @x[6 ] = n00 + STR r3, [r0, #56] @x[14] = n10 + STR r4, [r0, #88] @x[22] = n20 + STR r5, [r0, #120] @x[30] = n30 + + ADD r2, r10, r12 @n01 = xh1_0 + xh1_1 + SUB r3, r11, r9 @n11 = xl1_0 - xl0_1 + SUB r4, r10, r12 @n21 = xh1_0 - xh1_1 + ADD r5, r11, r9 @n31 = xl1_0 + xl0_1 + STR r2, [r0, #28] @x[6 +1] = n01 + STR r3, [r0, #60] @x[14+1] = n11 + STR r4, [r0, #92] @x[22+1] = n21 + STR r5, [r0, #124] @x[30+1] = n31 + + + @DIT Radix-4 FFT Second Stage + @First Butterfly + LDR r2, [r0] @inp_0qr = x[0] + LDR r3, [r0, #8] @inp_1qr = x[2] + LDR r4, [r0, #16] @inp_2qr = x[4] + LDR r5, [r0, #24] @inp_3qr = x[6] + ADD r6, r2, r4 @sum_0qr = mul_0qr + mul_2qr + SUB r7, r2, r4 @sum_1qr = mul_0qr - mul_2qr + ADD r8, r3, r5 @sum_2qr = mul_1qr + mul_3qr + SUB r9, r3, r5 @sum_3qr = mul_1qr - mul_3qr + + LDR r2, [r0, #4] @inp_0qi = x[1] + LDR r3, [r0, #12] @inp_1qi = x[3] + LDR r4, [r0, #20] @inp_2qi = x[5] + LDR r5, [r0, #28] @inp_3qi = x[7] + ADD r10, r2, r4 @sum_0qi = mul_0qi + mul_2qi + SUB r11, r2, r4 @sum_1qi = mul_0qi - mul_2qi + ADD r12, r3, r5 @sum_2qi = mul_1qi + mul_3qi + SUB r14, r3, r5 @sum_3qi = mul_1qi - mul_3qi + + ADD r2, r6, r8 @sum_0qr + sum_2qr + ADD r3, r7, r14 @sum_1qr + sum_3qi + SUB r4, r6, r8 @sum_0qr - sum_2qr + SUB r5, r7, r14 @sum_1qr - sum_3qi + STR r2, [r1] @y[0 ] = sum_0qr + sum_2qr + STR r3, [r1, #32] @y[8 ] = sum_1qr + sum_3qi + STR r4, [r1, #64] @y[16] = sum_0qr - sum_2qr + STR r5, [r1, #96] @y[24] = sum_1qr - sum_3qi + + ADD r2, r10, r12 @sum_0qi + sum_2qi + SUB r3, r11, r9 @sum_1qi - sum_3qr + SUB r4, r10, r12 @sum_0qi - sum_2qi + ADD r5, r11, r9 @sum_1qi + sum_3qr + STR r2, [r1, #4] @y[0 +1] = sum_0qi + sum_2qi + STR r3, [r1, #36] @y[8 +1] = sum_1qi - sum_3qr + STR r4, [r1, #68] @y[16+1] = sum_0qi - sum_2qi + STR r5, [r1, #100] @y[24+1] = sum_1qi + sum_3qr + + + @Load twiddle factors + LDR r11, =2310960706 @0x89BE7642 + LDR r12, =3473158396 @0xCF0430FC + LDR r14, =2776455811 @0xA57D5A83 + + @Second Butterfly + LDR r2, [r0, #32] @mul_0qr = inp_0qr = x[8] + LDR r3, [r0, #36] @mul_0qi = inp_1qr = x[9] + + LDR r5, [r0, #40] @inp_1qr = x[10] + LDR r6, [r0, #44] @inp_1qi = x[11] + SMULWB r4, r5, r11 @mul_1qr = mpy_16_32_ns( 0x7642 , inp_1qr) + SMLAWB r4, r6, r12, r4 @mul_1qr -= mpy_16_32_ns(-0x30FC , inp_1qi) + SMULWT r5, r5, r12 @mul_1qi = mpy_16_32_ns(-0x30FC , inp_1qr) + + LDR r7, [r0, #48] @inp_2qr = x[12] + LDR r8, [r0, #52] @inp_2qi = x[13] + + @Moved for delay slot + SMLAWB r5, r6, r11, r5 @mul_1qi += mpy_16_32_ns( 0x7642 , inp_1qi) + + ADD r6, r7, r8 @(inp_2qr + inp_2qi) + SMULWB r6, r6, r14 @mul_2qr = mpy_16_32_ns(0x5A83 , (inp_2qr + inp_2qi)) + SUB r7, r8, r7 @(-inp_2qr + inp_2qi) + SMULWB r7, r7, r14 @mul_2qi = mpy_16_32_ns(0x5A83 , (-inp_2qr + inp_2qi)) + + LDR r9 , [r0, #56] @inp_3qr = x[14] + LDR r10, [r0, #60] @inp_3qi = x[15] + SMULWB r8, r9 , r12 @mul_3qr = mpy_16_32_ns( 0x30FC , inp_3qr) + SMLAWB r8, r10, r11, r8 @mul_3qr -= mpy_16_32_ns(-0x7642 , inp_3qi)@ + SMULWT r9, r9 , r11 @mul_3qi = mpy_16_32_ns(-0x7642 , inp_3qr) + SMLAWB r9, r10, r12, r9 @mul_3qi += mpy_16_32_ns( 0x30FC , inp_3qi) + + ADD r10, r2, r6, lsl #1 @sum_0qr = mul_0qr + (mul_2qr << 1) + SUB r2 , r2, r6, lsl #1 @sum_1qr = mul_0qr - (mul_2qr << 1) + ADD r6 , r4, r8 @sum_2qr = mul_1qr + mul_3qr + SUB r4 , r4, r8 @sum_3qr = mul_1qr - mul_3qr + + ADD r8 , r3, r7, lsl #1 @sum_0qi = mul_0qi + (mul_2qi << 1) + SUB r3 , r3, r7, lsl #1 @sum_1qi = mul_0qi - (mul_2qi << 1) + ADD r7 , r5, r9 @sum_2qi = mul_1qi + mul_3qi + SUB r5 , r5, r9 @sum_3qi = mul_1qi - mul_3qi + + ADD r9 , r10, r6, lsl #1 @sum_0qr + (sum_2qr << 1) + SUB r10, r10, r6, lsl #1 @sum_0qr - (sum_2qr << 1) + ADD r6 , r2 , r5, lsl #1 @sum_1qr + (sum_3qi << 1) + SUB r2 , r2 , r5, lsl #1 @sum_1qr - (sum_3qi << 1) + STR r9 , [r1, #8] @y[2 ] = sum_0qr + (sum_2qr << 1) + STR r10, [r1, #72] @y[18] = sum_0qr - (sum_2qr << 1) + STR r6 , [r1, #40] @y[10] = sum_1qr + (sum_3qi << 1) + STR r2 , [r1, #104] @y[26] = sum_1qr - (sum_3qi << 1) + + ADD r5 , r8 , r7, lsl #1 @sum_0qi + (sum_2qi << 1) + SUB r8 , r8 , r7, lsl #1 @sum_0qi - (sum_2qi << 1) + SUB r7 , r3 , r4, lsl #1 @sum_1qi - (sum_3qr << 1) + ADD r3 , r3 , r4, lsl #1 @sum_1qi + (sum_3qr << 1) + STR r5 , [r1, #12] @y[2 +1] = sum_0qi + (sum_2qi << 1) + STR r8 , [r1, #76] @y[18+1] = sum_0qi - (sum_2qi << 1) + STR r7 , [r1, #44] @y[10+1] = sum_1qi - (sum_3qr << 1) + STR r3 , [r1, #108] @y[26+1] = sum_1qi + (sum_3qr << 1) + + @Third Butterfly + LDR r2, [r0, #64] @mul_0qr = inp_0qr = x[16] + + LDR r5, [r0, #72] @inp_1qr = x[18] + LDR r6, [r0, #76] @inp_1qi = x[19] + + @Moved for delay slot + LDR r3, [r0, #68] @mul_0qi = inp_1qr = x[17] + + ADD r4, r5, r6 @(inp_1qr + inp_1qi) + SMULWB r4, r4, r14 @mul_1qr = mpy_16_32_ns(0x5A83 , (inp_1qr + inp_1qi)) + SUB r5, r6, r5 @(-inp_1qr + inp_1qi) + SMULWB r5, r5, r14 @mul_1qi = mpy_16_32_ns(0x5A83 , (-inp_1qr + inp_1qi)) + + LDR r6, [r0, #84] @mul_2qr = inp_2qi = x[21] + + LDR r9 , [r0, #88] @inp_3qr = x[22] + LDR r10, [r0, #92] @inp_3qi = x[23] + + @Moved for delay slot + LDR r7, [r0, #80] @mul_2qi = inp_2qr = x[20] + + SUB r8 , r10, r9 @(-inp_3qr + inp_3qi) + SMULWB r8 , r8 , r14 @mul_3qr = mpy_16_32_ns( 0x5A83 , (-inp_3qr + inp_3qi)) + ADD r9 , r9 , r10 @(inp_3qr + inp_3qi) + SMULWT r9 , r9 , r14 @mul_3qi = mpy_16_32_ns(-0x5A83 , (inp_3qr + inp_3qi)) + + ADD r10, r2, r6 @sum_0qr = mul_0qr + mul_2qr + SUB r2 , r2, r6 @sum_1qr = mul_0qr - mul_2qr + ADD r6 , r4, r8 @sum_2qr = mul_1qr + mul_3qr + SUB r4 , r4, r8 @sum_3qr = mul_1qr - mul_3qr + + SUB r8 , r3, r7 @sum_0qi = mul_0qi - mul_2qi + ADD r3 , r3, r7 @sum_1qi = mul_0qi + mul_2qi + ADD r7 , r5, r9 @sum_2qi = mul_1qi + mul_3qi + SUB r5 , r5, r9 @sum_3qi = mul_1qi - mul_3qi + + ADD r9 , r10, r6, lsl #1 @sum_0qr + (sum_2qr << 1) + SUB r10, r10, r6, lsl #1 @sum_0qr - (sum_2qr << 1) + ADD r6 , r2 , r5, lsl #1 @sum_1qr + (sum_3qi << 1) + SUB r2 , r2 , r5, lsl #1 @sum_1qr - (sum_3qi << 1) + STR r9 , [r1, #16] @y[4 ] = sum_0qr + (sum_2qr << 1) + STR r10, [r1, #80] @y[20] = sum_0qr - (sum_2qr << 1) + STR r6 , [r1, #48] @y[12] = sum_1qr + (sum_3qi << 1) + STR r2 , [r1, #112] @y[28] = sum_1qr - (sum_3qi << 1) + + ADD r5, r8, r7, lsl #1 @sum_0qi + (sum_2qi << 1) + SUB r8, r8, r7, lsl #1 @sum_0qi - (sum_2qi << 1) + SUB r7, r3, r4, lsl #1 @sum_1qi - (sum_3qr << 1) + ADD r3, r3, r4, lsl #1 @sum_1qi + (sum_3qr << 1) + STR r5 , [r1, #20] @y[4 +1] = sum_0qi + (sum_2qi << 1) + STR r8 , [r1, #84] @y[20+1] = sum_0qi - (sum_2qi << 1) + STR r7 , [r1, #52] @y[12+1] = sum_1qi - (sum_3qr << 1) + STR r3 , [r1, #116] @y[28+1] = sum_1qi + (sum_3qr << 1) + + @Fourth Butterfly + LDR r2, [r0, #96] @mul_0qr = inp_0qr = x[24] + LDR r3, [r0, #100] @mul_0qi = inp_1qr = x[25] + + LDR r5, [r0, #104] @inp_1qr = x[26] + LDR r6, [r0, #108] @inp_1qi = x[27] + SMULWB r4, r5, r12 @mul_1qr = mpy_16_32_ns( 0x30FC , inp_1qr) + SMLAWB r4, r6, r11, r4 @mul_1qr -= mpy_16_32_ns(-0x7642 , inp_1qi) + SMULWT r5, r5, r11 @mul_1qi = mpy_16_32_ns(-0x7642 , inp_1qr) + + LDR r7, [r0, #112] @inp_2qr = x[28] + LDR r8, [r0, #116] @inp_2qi = x[29] + + @Moved for delay slot + SMLAWB r5, r6, r12, r5 @mul_1qi += mpy_16_32_ns( 0x30FC , inp_1qi) + + SUB r6, r8, r7 @(-inp_2qr + inp_2qi) + SMULWB r6, r6, r14 @mul_2qr = mpy_16_32_ns( 0x5A83 , (-inp_2qr + inp_2qi)) + ADD r7, r8, r7 @(inp_2qr + inp_2qi) + SMULWT r7, r7, r14 @mul_2qi = mpy_16_32_ns(-0x5A83 , (inp_2qr + inp_2qi)) + + LDR r9 , [r0, #120] @inp_3qr = x[30] + LDR r10, [r0, #124] @inp_3qi = x[31] + SMULWT r8, r9 , r11 @mul_3qr = mpy_16_32_ns(-0x7642 , inp_3qr) + SMLAWT r8, r10, r12, r8 @mul_3qr -= mpy_16_32_ns( 0x30FC , inp_3qi)@ + SMULWB r9, r9 , r12 @mul_3qi = mpy_16_32_ns( 0x30FC , inp_3qr) + SMLAWT r9, r10, r11, r9 @mul_3qi += mpy_16_32_ns(-0x7642 , inp_3qi) + + ADD r10, r2, r6, lsl #1 @sum_0qr = mul_0qr + (mul_2qr << 1) + SUB r2 , r2, r6, lsl #1 @sum_1qr = mul_0qr - (mul_2qr << 1) + ADD r6 , r4, r8 @sum_2qr = mul_1qr + mul_3qr + SUB r4 , r4, r8 @sum_3qr = mul_1qr - mul_3qr + + ADD r8 , r3, r7, lsl #1 @sum_0qi = mul_0qi + (mul_2qi << 1) + SUB r3 , r3, r7, lsl #1 @sum_1qi = mul_0qi - (mul_2qi << 1) + ADD r7 , r5, r9 @sum_2qi = mul_1qi + mul_3qi + SUB r5 , r5, r9 @sum_3qi = mul_1qi - mul_3qi + + ADD r9 , r10, r6, lsl #1 @sum_0qr + (sum_2qr << 1) + SUB r10, r10, r6, lsl #1 @sum_0qr - (sum_2qr << 1) + ADD r6 , r2 , r5, lsl #1 @sum_1qr + (sum_3qi << 1) + SUB r2 , r2 , r5, lsl #1 @sum_1qr - (sum_3qi << 1) + STR r9 , [r1, #24] @y[6 ] = sum_0qr + (sum_2qr << 1) + STR r10, [r1, #88] @y[22] = sum_0qr - (sum_2qr << 1) + STR r6 , [r1, #56] @y[14] = sum_1qr + (sum_3qi << 1) + STR r2 , [r1, #120] @y[30] = sum_1qr - (sum_3qi << 1) + + ADD r5 , r8 , r7, lsl #1 @sum_0qi + (sum_2qi << 1) + SUB r8 , r8 , r7, lsl #1 @sum_0qi - (sum_2qi << 1) + SUB r7 , r3 , r4, lsl #1 @sum_1qi - (sum_3qr << 1) + ADD r3 , r3 , r4, lsl #1 @sum_1qi + (sum_3qr << 1) + STR r5 , [r1, #28] @y[6 +1] = sum_0qi + (sum_2qi << 1) + STR r8 , [r1, #92] @y[22+1] = sum_0qi - (sum_2qi << 1) + STR r7 , [r1, #60] @y[14+1] = sum_1qi - (sum_3qr << 1) + STR r3 , [r1, #124] @y[30+1] = sum_1qi + (sum_3qr << 1) + + LDMFD sp!, {r4-r12, r15} + diff --git a/decoder/armv7/ixheaacd_fft_15_ld.s b/decoder/armv7/ixheaacd_fft_15_ld.s new file mode 100644 index 0000000..df9e3e6 --- /dev/null +++ b/decoder/armv7/ixheaacd_fft_15_ld.s @@ -0,0 +1,516 @@ + + +.equ C53_VAL , -11904 +.equ SINMU_VAL , 28378 +.equ C51_52VAL , 0x79BC9D84 +.equ C54_55VAL , 0x478EB000 +.equ FFTOP_OFFSET , -1536 +.equ FFTOP_OFFSET1 , 256 + +.text +.p2align 2 +.global ixheaacd_fft_15_ld_armv7 + +ixheaacd_fft_15_ld_armv7: + + STMFD r13!, {r4 - r12, r14} @ + STR r1 , [r13, #-4]! @ + STR r3 , [r13, #-4]! @ + MOV lr, r2 @ lr - fft3out + MOV r12, #384 @ + + +LOOP_FFT5: + LDRD r2, [r0] @ r2 = buf1a[0] and r3 = buf1a[1] + ADD r0, r0, r12 + LDRD r4, [r0] @ r4 = buf1a[2] and r5 = buf1a[3] + ADD r0, r0, r12 + LDRD r6, [r0] @ r6 = buf1a[4] and r7 = buf1a[5] + ADD r0, r0, r12 + LDRD r8, [r0] @ r8 = buf1a[6] and r9 = buf1a[7] + ADD r0, r0, r12 + LDRD r10, [r0] @ r10 = buf1a[8] and r11 = buf1a[9] + + + ADD r1, r4, r10 @ r1 = buf1a[2] + buf1a[8] + SUB r4, r4, r10 @ r4 = buf1a[2] - buf1a[8]@ + LDR r10, = C54_55VAL + ADD r12, r6, r8 @ r3 = buf1a[4] + buf1a[6] + SUB r8, r6, r8 @ r2 = buf1a[4] - buf1a[6] + + SUB r6, r1, r12 @ (r1 - r3) + SMULWT r6, r6, r10 @ t = mult32x16in32_shl((r1 - r3), C54) + ADD r1, r1, r12 @ r1 = r1 + r3@ + ADD r2, r2, r1 @ temp1 = inp[0] + r1@ + SMULWB r1, r1, r10 @ mult32_shl(r1, C55) + ADD r1, r2, r1, lsl #2 @ r1 = temp1 + ((mult32_shl(r1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r2, [lr], #4 @ *buf2++ = temp1@ + + SUB r12, r1, r6, LSL #1 @ r3 = r1 - t@ + ADD r1, r1, r6, LSL #1 @ r1 = r1 + t@ + + ADD r2, r4, r8 @ (r4 + r2) + SMULWT r2, r2, r10 @ t = mult32_shl((r4 + r2), C51)@ + + @LSL r2, r2, #1 + MOV r2, r2, LSL #1 + + SMULWB r4, r4, r10 @ mult32_shl(r4, C52) + LDR r10, = C53_VAL + ADD r4, r2, r4, LSL #2 @ r4 = t + (mult32_shl(r4, C52) << 1)@ + + SMULWB r8, r8, r10 @ mult32_shl(r2, C53) + ADD r2, r2, r8, LSL #1 @ r2 = t + mult32_shl(r2, C53)@ + + ADD r6, r5, r11 @ s1 = buf1a[3] + buf1a[9] + SUB r8, r5, r11 @ s4 = buf1a[3] - buf1a[9] + LDR r10, = C54_55VAL + ADD r5, r7, r9 @ s3 = buf1a[5] + buf1a[7]@ + SUB r7, r7, r9 @ s2 = buf1a[5] + buf1a[7]@ + + + SUB r9, r6, r5 @ (s1 - s3) + SMULWT r9, r9, r10 @ t = mult32x16in32_shl((s1 - s3), C54) + ADD r6, r6, r5 @ s1 = s1 + s3@ + ADD r3, r3, r6 @ temp2 = buf1a[1] + s1 + SMULWB r6, r6, r10 @ mult32_shl(s1, C55) + ADD r6, r3, r6, lsl #2 @ s1 = temp1 + ((mult32_shl(s1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r3, [lr], #4 @ *buf2++ = temp2@ + + SUB r5, r6, r9, LSL #1 @ s3 = s1 - t@ + ADD r6, r6, r9, LSL #1 @ s1 = s1 + t@ + SUB r0, r0, #896 @ r0 -inp[160] + + ADD r11, r7, r8 @ (s4 + s2) + SMULWT r11, r11, r10 @ t = mult32_shl((s4 + s2), C51)@ + @LSL r11, r11, #1 @ + MOV r11, r11, LSL #1 + + + SMULWB r8, r8, r10 @ mult32_shl(s4, C52) + LDR r10, = C53_VAL + ADD r8, r11, r8, LSL #2 @ s4 = t + (mult32_shl(s4, C52) << 1)@ + + SMULWB r7, r7, r10 @ mult32_shl(s2, C53) + ADD r7, r11, r7, LSL #1 @ s2 = t + mult32_shl(s2, C53)@ + + + ADD r3, r1, r7 @ buf2[2] = r1 + s2 + SUB r9, r6, r2 @ buf2[3] = s1 - r2 + SUB r10, r12, r8 @ buf2[4] = r3 - s4 + ADD r11, r5, r4 @ buf2[5] = s3 + r4 + ADD r12, r12, r8 @ buf2[6] = r3 + s4 + SUB r4, r5, r4 @ buf2[7] = s3 - r4 + SUB r5, r1, r7 @ buf2[8] = r1 - s2 + ADD r6, r6, r2 @ buf2[9] = s1 + r2 + STMIA lr!, {r3, r9-r12} @ + + MOV r12, #384 @ + LDR r1, = FFTOP_OFFSET @ + + STMIA lr!, {r4-r6} @ + + + LDRD r2, [r0] @ r2 = buf1a[0] and r3 = buf1a[1] + ADD r0, r0, r12 + LDRD r4, [r0] @ r4 = buf1a[2] and r5 = buf1a[3] + ADD r0, r0, r12 + LDRD r6, [r0] @ r6 = buf1a[4] and r7 = buf1a[5] + ADD r0, r0, r12 + LDRD r8, [r0] @ r8 = buf1a[6] and r9 = buf1a[7] + ADD r0, r0, r1 + LDRD r10, [r0] @ r10 = buf1a[8] and r11 = buf1a[9] + ADD r0, r0, #1024 @ r0 -inp[320] + + ADD r1, r4, r10 @ r1 = buf1a[2] + buf1a[8] + SUB r4, r4, r10 @ r4 = buf1a[2] - buf1a[8]@ + LDR r10, = C54_55VAL + ADD r12, r6, r8 @ r3 = buf1a[4] + buf1a[6] + SUB r8, r6, r8 @ r2 = buf1a[4] - buf1a[6] + + SUB r6, r1, r12 @ (r1 - r3) + SMULWT r6, r6, r10 @ t = mult32x16in32_shl((r1 - r3), C54) + ADD r1, r1, r12 @ r1 = r1 + r3@ + ADD r2, r2, r1 @ temp1 = inp[0] + r1@ + SMULWB r1, r1, r10 @ mult32_shl(r1, C55) + ADD r1, r2, r1, lsl #2 @ r1 = temp1 + ((mult32_shl(r1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r2, [lr], #4 @ *buf2++ = temp1@ + + SUB r12, r1, r6, LSL #1 @ r3 = r1 - t@ + ADD r1, r1, r6, LSL #1 @ r1 = r1 + t@ + + ADD r2, r4, r8 @ (r4 + r2) + SMULWT r2, r2, r10 @ t = mult32_shl((r4 + r2), C51)@ + @LSL r2, r2, #1 + MOV r2, r2, LSL #1 + + + SMULWB r4, r4, r10 @ mult32_shl(r4, C52) + LDR r10, = C53_VAL + ADD r4, r2, r4, LSL #2 @ r4 = t + (mult32_shl(r4, C52) << 1)@ + + SMULWB r8, r8, r10 @ mult32_shl(r2, C53) + ADD r2, r2, r8, LSL #1 @ r2 = t + mult32_shl(r2, C53)@ + + ADD r6, r5, r11 @ s1 = buf1a[3] + buf1a[9] + SUB r8, r5, r11 @ s4 = buf1a[3] - buf1a[9] + LDR r10, = C54_55VAL + ADD r5, r7, r9 @ s3 = buf1a[5] + buf1a[7]@ + SUB r7, r7, r9 @ s2 = buf1a[5] + buf1a[7]@ + + + SUB r9, r6, r5 @ (s1 - s3) + SMULWT r9, r9, r10 @ t = mult32x16in32_shl((s1 - s3), C54) + ADD r6, r6, r5 @ s1 = s1 + s3@ + ADD r3, r3, r6 @ temp2 = buf1a[1] + s1 + SMULWB r6, r6, r10 @ mult32_shl(s1, C55) + ADD r6, r3, r6, lsl #2 @ s1 = temp1 + ((mult32_shl(s1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r3, [lr], #4 @ *buf2++ = temp2@ + + + SUB r5, r6, r9, LSL #1 @ s3 = s1 - t@ + ADD r6, r6, r9, LSL #1 @ s1 = s1 + t@ + + ADD r11, r7, r8 @ (s4 + s2) + SMULWT r11, r11, r10 @ t = mult32_shl((s4 + s2), C51)@ + @LSL r11, r11, #1 + MOV r11, r11, LSL #1 + + SMULWB r8, r8, r10 @mult32_shl(s4, C52) + LDR r10, = C53_VAL + ADD r8, r11, r8, LSL #2 @s4 = t + (mult32_shl(s4, C52) << 1)@ + + SMULWB r7, r7, r10 @mult32_shl(s2, C53) + ADD r7, r11, r7, LSL #1 @s2 = t + mult32_shl(s2, C53)@ + + ADD r3, r1, r7 @buf2[2] = r1 + s2 + SUB r9, r6, r2 @buf2[3] = s1 - r2 + SUB r10, r12, r8 @buf2[4] = r3 - s4 + ADD r11, r5, r4 @buf2[5] = s3 + r4 + ADD r12, r12, r8 @buf2[6] = r3 + s4 + SUB r4, r5, r4 @buf2[7] = s3 - r4 + SUB r5, r1, r7 @buf2[8] = r1 - s2 + ADD r6, r6, r2 @buf2[9] = s1 + r2 + LDR r1, = FFTOP_OFFSET @ + + STMIA lr!, {r3, r9-r12} + MOV r12, #384 @ + STMIA lr!, {r4-r6} @ + + LDRD r2, [r0] @ r2 = buf1a[0] and r3 = buf1a[1] + ADD r0, r0, r12 + LDRD r4, [r0] @ r4 = buf1a[2] and r5 = buf1a[3] + ADD r0, r0, r1 + + LDRD r6, [r0] @ r6 = buf1a[4] and r7 = buf1a[5] + ADD r0, r0, r12 + LDRD r8, [r0] @ r8 = buf1a[6] and r9 = buf1a[7] + ADD r0, r0, r12 + LDRD r10, [r0] @ r10 = buf1a[8] and r11 = buf1a[9] + ADD r0, r0, r12 + + ADD r1, r4, r10 @ r1 = buf1a[2] + buf1a[8] + SUB r4, r4, r10 @ r4 = buf1a[2] - buf1a[8]@ + LDR r10, = C54_55VAL + ADD r12, r6, r8 @ r3 = buf1a[4] + buf1a[6] + SUB r8, r6, r8 @ r2 = buf1a[4] - buf1a[6] + + SUB r6, r1, r12 @ (r1 - r3) + SMULWT r6, r6, r10 @ t = mult32x16in32_shl((r1 - r3), C54) + ADD r1, r1, r12 @ r1 = r1 + r3@ + ADD r2, r2, r1 @ temp1 = inp[0] + r1@ + SMULWB r1, r1, r10 @ mult32_shl(r1, C55) + ADD r1, r2, r1, lsl #2 @ r1 = temp1 + ((mult32_shl(r1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r2, [lr], #4 @ *buf2++ = temp1@ + + SUB r12, r1, r6, LSL #1 @ r3 = r1 - t@ + ADD r1, r1, r6, LSL #1 @ r1 = r1 + t@ + + ADD r2, r4, r8 @ (r4 + r2) + SMULWT r2, r2, r10 @ t = mult32_shl((r4 + r2), C51)@ + @LSL r2, r2, #1 + MOV r2, r2, LSL #1 + + SMULWB r4, r4, r10 @ mult32_shl(r4, C52) + LDR r10, = C53_VAL + ADD r4, r2, r4, LSL #2 @ r4 = t + (mult32_shl(r4, C52) << 1)@ + + SMULWB r8, r8, r10 @ mult32_shl(r2, C53) + ADD r2, r2, r8, LSL #1 @ r2 = t + mult32_shl(r2, C53)@ + + ADD r6, r5, r11 @ s1 = buf1a[3] + buf1a[9] + SUB r8, r5, r11 @ s4 = buf1a[3] - buf1a[9] + LDR r10, = C54_55VAL + ADD r5, r7, r9 @ s3 = buf1a[5] + buf1a[7]@ + SUB r7, r7, r9 @ s2 = buf1a[5] + buf1a[7]@ + + SUB r9, r6, r5 @ (s1 - s3) + SMULWT r9, r9, r10 @ t = mult32x16in32_shl((s1 - s3), C54) + ADD r6, r6, r5 @ s1 = s1 + s3@ + ADD r3, r3, r6 @ temp2 = buf1a[1] + s1 + SMULWB r6, r6, r10 @ mult32_shl(s1, C55) + ADD r6, r3, r6, lsl #2 @ s1 = temp1 + ((mult32_shl(s1, C55)) << 1)@ + LDR r10, = C51_52VAL @ + STR r3, [lr], #4 @ *buf2++ = temp2@ + + SUB r5, r6, r9, LSL #1 @ s3 = s1 - t@ + ADD r6, r6, r9, LSL #1 @ s1 = s1 + t@ + + ADD r11, r7, r8 @ (s4 + s2) + SMULWT r11, r11, r10 @ t = mult32_shl((s4 + s2), C51)@ + @LSL r11, r11, #1 @ + MOV r11, r11, LSL #1 + + SMULWB r8, r8, r10 @mult32_shl(s4, C52) + LDR r10, = C53_VAL + ADD r8, r11, r8, LSL #2 @s4 = t + (mult32_shl(s4, C52) << 1)@ + + + SMULWB r7, r7, r10 @mult32_shl(s2, C53) + ADD r7, r11, r7, LSL #1 @s2 = t + mult32_shl(s2, C53)@ + + ADD r3, r1, r7 @buf2[2] = r1 + s2 + SUB r9, r6, r2 @buf2[3] = s1 - r2 + SUB r10, r12, r8 @buf2[4] = r3 - s4 + ADD r11, r5, r4 @buf2[5] = s3 + r4 + ADD r12, r12, r8 @buf2[6] = r3 + s4 + SUB r4, r5, r4 @buf2[7] = s3 - r4 + SUB r5, r1, r7 @buf2[8] = r1 - s2 + ADD r6, r6, r2 @buf2[9] = s1 + r2 + + STMIA lr!, {r3, r9-r12} + STMIA lr!, {r4-r6} @ + + SUB lr, lr, #120 @ + LDR r12, = SINMU_VAL @ + LDMFD r13!, {r10, r11} @ + + +LOOP_FFT3: + LDRD r0, [lr] @ r0 = fft3outptr[0] and r1 = fft3outptr[1] + LDRD r2, [lr, #40] @ r2 = fft3outptr[10] and r3 = fft3outptr[11] + LDRD r4, [lr, #80] @ r4 = fft3outptr[20] and r5 = fft3outptr[21] + ADD lr, lr, #8 @ + + ADD r6, r0, r2 @ X01r = add32(buf1[0], buf1[2]) + ADD r7, r1, r3 @ X01i = add32(buf1[1], buf1[3]) + + ADD r8, r2, r4 @ add_r = add32(buf1[2], buf1[4]) + ADD r9, r3, r5 @ add_i = add32(buf1[3], buf1[5]) + + SUB r2, r2, r4 @ sub_r = sub32(buf1[2], buf1[4])@ + SUB r3, r3, r5 @ sub_i = sub32(buf1[3], buf1[5])@ + + @ASR r8, r8, #1 @ p1 = add_r >> 1@ + MOV r8, r8, ASR #1 + + @ASR r9, r9, #1 @ p4 = add_i >> 1@ + MOV r9, r9, ASR #1 + + SMULWB r3, r3, r12 @ p2 = mult32x16in32_shl(sub_i, sinmu)@ + SMULWB r2, r2, r12 @ p3 = mult32x16in32_shl(sub_r, sinmu)@ + + SUB r0, r0, r8 @ temp = sub32(buf1a[0], p1)@ + ADD r8, r1, r2, LSL #1 @ temp1 = add32(buf1a[1], p3)@ + SUB r2, r1, r2, LSL #1 @ temp2 = sub32(buf1a[1], p3)@ + + ADD r4, r6, r4 @ add32(X01r, buf1a[4])@ + ADD r5, r7, r5 @ add32(X01i, buf1a[5])@ + ADD r6, r0, r3, LSL #1 @ add32(temp, p2)@ + SUB r7, r2, r9 @ sub32(temp2, p4)@ + SUB r9, r8, r9 @ sub32(temp1, p4)@ + SUB r8, r0, r3, LSL #1 @ sub32(temp, p2)@ + + MOV r3, r11 @ + LDRB r0, [r10], #1 @ + LDRB r1, [r10], #1 @ + LDRB r2, [r10], #1 @ + ADD r0, r11, r0, lsl #3 @ + ADD r1, r11, r1, lsl #3 @ + ADD r2, r11, r2, lsl #3 @ + STRD r4, [r0] @ + STRD r6, [r1] @ + STRD r8, [r2] @ + + LDRD r0, [lr] @ r0 = fft3outptr[0] and r1 = fft3outptr[1] + LDRD r2, [lr, #40] @ r2 = fft3outptr[10] and r3 = fft3outptr[11] + LDRD r4, [lr, #80] @ r4 = fft3outptr[20] and r5 = fft3outptr[21] + ADD lr, lr, #8 @ + + + ADD r6, r0, r2 @ X01r = add32(buf1[0], buf1[2]) + ADD r7, r1, r3 @ X01i = add32(buf1[1], buf1[3]) + + ADD r8, r2, r4 @ add_r = add32(buf1[2], buf1[4]) + ADD r9, r3, r5 @ add_i = add32(buf1[3], buf1[5]) + + SUB r2, r2, r4 @ sub_r = sub32(buf1[2], buf1[4])@ + SUB r3, r3, r5 @ sub_i = sub32(buf1[3], buf1[5])@ + + @ASR r8, r8, #1 @ p1 = add_r >> 1@ + MOV r8, r8, ASR #1 + @ASR r9, r9, #1 @ p4 = add_i >> 1@ + MOV r9, r9, ASR #1 + + SMULWB r3, r3, r12 @ p2 = mult32x16in32_shl(sub_i, sinmu)@ + SMULWB r2, r2, r12 @ p3 = mult32x16in32_shl(sub_r, sinmu)@ + + SUB r0, r0, r8 @ temp = sub32(buf1a[0], p1)@ + ADD r8, r1, r2, LSL #1 @ temp1 = add32(buf1a[1], p3)@ + SUB r2, r1, r2, LSL #1 @ temp2 = sub32(buf1a[1], p3)@ + + ADD r4, r6, r4 @ add32(X01r, buf1a[4])@ + ADD r5, r7, r5 @ add32(X01i, buf1a[5])@ + ADD r6, r0, r3, LSL #1 @ add32(temp, p2)@ + SUB r7, r2, r9 @ sub32(temp2, p4)@ + SUB r9, r8, r9 @ sub32(temp1, p4)@ + SUB r8, r0, r3, LSL #1 @ sub32(temp, p2)@ + + LDRB r0, [r10], #1 @ + LDRB r1, [r10], #1 @ + LDRB r2, [r10], #1 @ + ADD r0, r11, r0, lsl #3 @ + ADD r1, r11, r1, lsl #3 @ + ADD r2, r11, r2, lsl #3 @ + STRD r4, [r0] @ + STRD r6, [r1] @ + STRD r8, [r2] @ + + LDRD r0, [lr] @ r0 = fft3outptr[0] and r1 = fft3outptr[1] + LDRD r2, [lr, #40] @ r2 = fft3outptr[10] and r3 = fft3outptr[11] + LDRD r4, [lr, #80] @ r4 = fft3outptr[20] and r5 = fft3outptr[21] + ADD lr, lr, #8 @ + + + ADD r6, r0, r2 @ X01r = add32(buf1[0], buf1[2]) + ADD r7, r1, r3 @ X01i = add32(buf1[1], buf1[3]) + + ADD r8, r2, r4 @ add_r = add32(buf1[2], buf1[4]) + ADD r9, r3, r5 @ add_i = add32(buf1[3], buf1[5]) + + SUB r2, r2, r4 @ sub_r = sub32(buf1[2], buf1[4])@ + SUB r3, r3, r5 @ sub_i = sub32(buf1[3], buf1[5])@ + + + @ASR r8, r8, #1 @ p1 = add_r >> 1@ + MOV r8, r8, ASR #1 + @ASR r9, r9, #1 @ p4 = add_i >> 1@ + MOV r9, r9, ASR #1 + + SMULWB r3, r3, r12 @ p2 = mult32x16in32_shl(sub_i, sinmu)@ + SMULWB r2, r2, r12 @ p3 = mult32x16in32_shl(sub_r, sinmu)@ + + SUB r0, r0, r8 @ temp = sub32(buf1a[0], p1)@ + ADD r8, r1, r2, LSL #1 @ temp1 = add32(buf1a[1], p3)@ + SUB r2, r1, r2, LSL #1 @ temp2 = sub32(buf1a[1], p3)@ + + ADD r4, r6, r4 @ add32(X01r, buf1a[4])@ + ADD r5, r7, r5 @ add32(X01i, buf1a[5])@ + ADD r6, r0, r3, LSL #1 @ add32(temp, p2)@ + SUB r7, r2, r9 @ sub32(temp2, p4)@ + SUB r9, r8, r9 @ sub32(temp1, p4)@ + SUB r8, r0, r3, LSL #1 @ sub32(temp, p2)@ + + LDRB r0, [r10], #1 @ + LDRB r1, [r10], #1 @ + LDRB r2, [r10], #1 @ + ADD r0, r11, r0, lsl #3 @ + ADD r1, r11, r1, lsl #3 @ + ADD r2, r11, r2, lsl #3 @ + STRD r4, [r0] @ + STRD r6, [r1] @ + STRD r8, [r2] @ + + LDRD r0, [lr] @ r0 = fft3outptr[0] and r1 = fft3outptr[1] + LDRD r2, [lr, #40] @ r2 = fft3outptr[10] and r3 = fft3outptr[11] + LDRD r4, [lr, #80] @ r4 = fft3outptr[20] and r5 = fft3outptr[21] + ADD lr, lr, #8 @ + + ADD r6, r0, r2 @ X01r = add32(buf1[0], buf1[2]) + ADD r7, r1, r3 @ X01i = add32(buf1[1], buf1[3]) + + ADD r8, r2, r4 @ add_r = add32(buf1[2], buf1[4]) + ADD r9, r3, r5 @ add_i = add32(buf1[3], buf1[5]) + + SUB r2, r2, r4 @ sub_r = sub32(buf1[2], buf1[4])@ + SUB r3, r3, r5 @ sub_i = sub32(buf1[3], buf1[5])@ + + @ASR r8, r8, #1 @ p1 = add_r >> 1@ + MOV r8, r8, ASR #1 + @ASR r9, r9, #1 @ p4 = add_i >> 1@ + MOV r9, r9, ASR #1 + + SMULWB r3, r3, r12 @ p2 = mult32x16in32_shl(sub_i, sinmu)@ + SMULWB r2, r2, r12 @ p3 = mult32x16in32_shl(sub_r, sinmu)@ + + SUB r0, r0, r8 @ temp = sub32(buf1a[0], p1)@ + ADD r8, r1, r2, LSL #1 @ temp1 = add32(buf1a[1], p3)@ + SUB r2, r1, r2, LSL #1 @ temp2 = sub32(buf1a[1], p3)@ + + ADD r4, r6, r4 @ add32(X01r, buf1a[4])@ + ADD r5, r7, r5 @ add32(X01i, buf1a[5])@ + ADD r6, r0, r3, LSL #1 @ add32(temp, p2)@ + SUB r7, r2, r9 @ sub32(temp2, p4)@ + SUB r9, r8, r9 @ sub32(temp1, p4)@ + SUB r8, r0, r3, LSL #1 @ sub32(temp, p2)@ + + LDRB r0, [r10], #1 @ + LDRB r1, [r10], #1 @ + LDRB r2, [r10], #1 @ + ADD r0, r11, r0, lsl #3 @ + ADD r1, r11, r1, lsl #3 @ + ADD r2, r11, r2, lsl #3 @ + STRD r4, [r0] @ + STRD r6, [r1] @ + STRD r8, [r2] @ + + LDRD r0, [lr] @ r0 = fft3outptr[0] and r1 = fft3outptr[1] + LDRD r2, [lr, #40] @ r2 = fft3outptr[10] and r3 = fft3outptr[11] + LDRD r4, [lr, #80] @ r4 = fft3outptr[20] and r5 = fft3outptr[21] + + ADD r6, r0, r2 @ X01r = add32(buf1[0], buf1[2]) + ADD r7, r1, r3 @ X01i = add32(buf1[1], buf1[3]) + + ADD r8, r2, r4 @ add_r = add32(buf1[2], buf1[4]) + ADD r9, r3, r5 @ add_i = add32(buf1[3], buf1[5]) + + SUB r2, r2, r4 @ sub_r = sub32(buf1[2], buf1[4])@ + SUB r3, r3, r5 @ sub_i = sub32(buf1[3], buf1[5])@ + + @ASR r8, r8, #1 @ p1 = add_r >> 1@ + MOV r8, r8, ASR #1 + @ASR r9, r9, #1 @ p4 = add_i >> 1@ + MOV r9, r9, ASR #1 + + SMULWB r3, r3, r12 @ p2 = mult32x16in32_shl(sub_i, sinmu)@ + SMULWB r2, r2, r12 @ p3 = mult32x16in32_shl(sub_r, sinmu)@ + + SUB r0, r0, r8 @ temp = sub32(buf1a[0], p1)@ + ADD r8, r1, r2, LSL #1 @ temp1 = add32(buf1a[1], p3)@ + SUB r2, r1, r2, LSL #1 @ temp2 = sub32(buf1a[1], p3)@ + + ADD r4, r6, r4 @ add32(X01r, buf1a[4])@ + ADD r5, r7, r5 @ add32(X01i, buf1a[5])@ + ADD r6, r0, r3, LSL #1 @ add32(temp, p2)@ + SUB r7, r2, r9 @ sub32(temp2, p4)@ + SUB r9, r8, r9 @ sub32(temp1, p4)@ + SUB r8, r0, r3, LSL #1 @ sub32(temp, p2)@ + + LDRB r0, [r10], #1 @ + LDRB r1, [r10], #1 @ + LDRB r2, [r10], #1 @ + ADD r0, r11, r0, lsl #3 @ + ADD r1, r11, r1, lsl #3 @ + ADD r2, r11, r2, lsl #3 @ + STRD r4, [r0] @ + STRD r6, [r1] @ + STRD r8, [r2] @ + + LDMFD r13!, {r4 - r12, r15} + + diff --git a/decoder/armv7/ixheaacd_fft_armv7.c b/decoder/armv7/ixheaacd_fft_armv7.c new file mode 100644 index 0000000..f4ee8de --- /dev/null +++ b/decoder/armv7/ixheaacd_fft_armv7.c @@ -0,0 +1,89 @@ +#include +#include + +#include +#include "ixheaacd_interface.h" +#include "ixheaacd_constants.h" +#include +#include "ixheaacd_function_selector.h" + +extern const WORD32 ixheaacd_twiddle_table_fft_32x32[514]; +extern const WORD8 ixheaacd_mps_dig_rev[16]; + +VOID ixheaacd_complex_fft_p2_armv7(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift) { + WORD32 i, n_stages; + WORD32 not_power_4; + WORD32 npts, shift; + WORD32 dig_rev_shift; + WORD32 ptr_x[1024]; + WORD32 y[1024]; + WORD32 npoints = nlength; + WORD32 n = 0; + WORD32 *ptr_y = y; + dig_rev_shift = ixheaacd_norm32(npoints) + 1 - 16; + n_stages = 30 - ixheaacd_norm32(npoints); // log2(npoints), if npoints=2^m + not_power_4 = n_stages & 1; + + n_stages = n_stages >> 1; + + npts = npoints; // CALCULATION OF GUARD BITS + while (npts >> 1) { + n++; + npts = npts >> 1; + } + + if (n % 2 == 0) + shift = ((n + 4)) / 2; + else + shift = ((n + 3) / 2); + + for (i = 0; i < nlength; i++) { + ptr_x[2 * i] = (xr[i] / (1 << (shift))); + ptr_x[2 * i + 1] = (xi[i] / (1 << (shift))); + } + + if (fft_mode == -1) { + ixheaacd_complex_fft_p2_asm(ixheaacd_twiddle_table_fft_32x32, nlength, + ptr_x, ptr_y); + if (not_power_4) shift += 1; + } + + else { + ixheaacd_complex_ifft_p2_asm(ixheaacd_twiddle_table_fft_32x32, nlength, + ptr_x, ptr_y); + if (not_power_4) shift += 1; + } + + for (i = 0; i < nlength; i++) { + xr[i] = y[2 * i]; + xi[i] = y[2 * i + 1]; + } + + *preshift = shift - *preshift; + return; +} + +VOID ixheaacd_mps_complex_fft_64_armv7(WORD32 *ptr_x, WORD32 *fin_re, + WORD32 *fin_im, WORD32 nlength) { + WORD32 i, n_stages; + WORD32 y[128]; + WORD32 npoints = nlength; + WORD32 *ptr_y = y; + const WORD32 *ptr_w; + n_stages = 30 - ixheaacd_norm32(npoints); // log2(npoints), if npoints=2^m + + n_stages = n_stages >> 1; + + ptr_w = ixheaacd_twiddle_table_fft_32x32; // 32 BIT TWIDDLE TABLE + + ixheaacd_mps_complex_fft_64_asm(ptr_w, nlength, ptr_x, ptr_y, + ixheaacd_mps_dig_rev); + + for (i = 0; i < 2 * nlength; i += 2) { + fin_re[i] = y[i]; + fin_im[i] = y[i + 1]; + } + + return; +} diff --git a/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c new file mode 100644 index 0000000..9cc568a --- /dev/null +++ b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c @@ -0,0 +1,185 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_block.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_calc.h" + +WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_armv7; + +VOID(*ixheaacd_covariance_matrix_calc) +(WORD32 *, ixheaacd_lpp_trans_cov_matrix *, + WORD32) = &ixheaacd_covariance_matrix_calc_armv7; + +VOID(*ixheaacd_covariance_matrix_calc_2) +(ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, + WORD16) = &ixheaacd_covariance_matrix_calc_2_armv7; + +VOID(*ixheaacd_over_lap_add1) +(WORD32 *, WORD32 *, WORD16 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add1_dec; + +VOID(*ixheaacd_over_lap_add2) +(WORD32 *, WORD32 *, WORD32 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add2_dec; + +VOID(*ixheaacd_decorr_filter2) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter2_armv7; + +VOID(*ixheaacd_decorr_filter1) +(ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter1_armv7; + +WORD32(*ixheaacd_divide16_pos) +(WORD32 op1, WORD32 op2) = &ixheaacd_divide16_pos_armv7; + +VOID(*ixheaacd_decorrelation) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) = &ixheaacd_decorrelation_armv7; + +VOID(*ixheaacd_apply_rot) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, WORD32 *p_qmf_left_im, + WORD32 *p_qmf_right_re, WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res) = &ixheaacd_apply_rot_armv7; + +VOID(*ixheaacd_conv_ergtoamplitudelp) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitudelp_armv7; + +VOID(*ixheaacd_conv_ergtoamplitude) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitude_armv7; + +VOID(*ixheaacd_adjust_scale) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) = &ixheaacd_adjust_scale_armv7; + +WORD16(*ixheaacd_ixheaacd_expsubbandsamples) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, + FLAG low_pow_flag) = &ixheaacd_expsubbandsamples_armv7; + +VOID(*ixheaacd_enery_calc_per_subband) +(WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 frame_exp, WORD16 *nrg_est_mant, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) = &ixheaacd_enery_calc_per_subband_dec; + +VOID(*ixheaacd_harm_idx_zerotwolp) +(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) = &ixheaacd_harm_idx_zerotwolp_armv7; + +VOID(*ixheaacd_tns_ar_filter_fixed) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_armv7; + +VOID(*ixheaacd_tns_ar_filter) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec, + WORD32 *ptr_filter_state) = &ixheaacd_tns_ar_filter_armv7; + +VOID(*ixheaacd_tns_parcor_lpc_convert) +(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, + WORD order) = &ixheaacd_tns_parcor_lpc_convert_armv7; + +WORD32(*ixheaacd_calc_max_spectral_line) +(WORD32 *ptr_tmp, WORD32 size) = &ixheaacd_calc_max_spectral_line_dec; + +VOID(*ixheaacd_post_twiddle) +(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) = &ixheaacd_post_twiddle_dec; + +VOID(*ixheaacd_post_twid_overlap_add) +(WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) = &ixheaacd_post_twid_overlap_add_dec; + +VOID(*ixheaacd_neg_shift_spec) +(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) = &ixheaacd_neg_shift_spec_dec; + +VOID(*ixheaacd_spec_to_overlapbuf) +(WORD32 *ptr_overlap_buf, WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) = &ixheaacd_spec_to_overlapbuf_armv7; + +VOID(*ixheaacd_overlap_buf_out) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac) = &ixheaacd_overlap_buf_out_armv7; + +VOID(*ixheaacd_overlap_out_copy) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) = &ixheaacd_overlap_out_copy_armv7; + +VOID(*ixheaacd_pretwiddle_compute) +(WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) = &ixheaacd_pretwiddle_compute_dec; + +VOID(*ixheaacd_imdct_using_fft) +(ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_dec; diff --git a/decoder/armv7/ixheaacd_function_selector_armv7.c b/decoder/armv7/ixheaacd_function_selector_armv7.c new file mode 100644 index 0000000..0b6594c --- /dev/null +++ b/decoder/armv7/ixheaacd_function_selector_armv7.c @@ -0,0 +1,249 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_block.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_dsp_fft32x32s.h" + +#include "ixheaacd_interface.h" + +WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_armv7; + +VOID(*ixheaacd_covariance_matrix_calc) +(WORD32 *, ixheaacd_lpp_trans_cov_matrix *, + WORD32) = &ixheaacd_covariance_matrix_calc_armv7; + +VOID(*ixheaacd_covariance_matrix_calc_2) +(ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, + WORD16) = &ixheaacd_covariance_matrix_calc_2_armv7; + +VOID(*ixheaacd_over_lap_add1) +(WORD32 *, WORD32 *, WORD16 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add1_armv7; + +VOID(*ixheaacd_over_lap_add2) +(WORD32 *, WORD32 *, WORD32 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add2_armv7; + +VOID(*ixheaacd_decorr_filter2) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter2_armv7; + +VOID(*ixheaacd_decorr_filter1) +(ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter1_armv7; + +WORD32(*ixheaacd_divide16_pos) +(WORD32 op1, WORD32 op2) = &ixheaacd_divide16_pos_armv7; + +VOID(*ixheaacd_decorrelation) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) = &ixheaacd_decorrelation_armv7; + +VOID(*ixheaacd_apply_rot) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *qmf_left_real, WORD32 *qmf_left_imag, + WORD32 *qmf_right_real, WORD32 *qmf_right_imag, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_resol) = &ixheaacd_apply_rot_armv7; + +VOID(*ixheaacd_conv_ergtoamplitudelp) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitudelp_armv7; + +VOID(*ixheaacd_conv_ergtoamplitude) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitude_armv7; + +VOID(*ixheaacd_adjust_scale) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) = &ixheaacd_adjust_scale_armv7; + +WORD16(*ixheaacd_ixheaacd_expsubbandsamples) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, + FLAG low_pow_flag) = &ixheaacd_expsubbandsamples_armv7; + +VOID(*ixheaacd_enery_calc_per_subband) +(WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 frame_exp, WORD16 *nrg_est_mant, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) = &ixheaacd_enery_calc_per_subband_armv7; + +VOID(*ixheaacd_harm_idx_zerotwolp) +(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) = &ixheaacd_harm_idx_zerotwolp_armv7; + +VOID(*ixheaacd_tns_ar_filter_fixed) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_armv7; + +VOID(*ixheaacd_tns_ar_filter) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec, + WORD32 *ptr_filter_state) = &ixheaacd_tns_ar_filter_armv7; + +VOID(*ixheaacd_tns_parcor_lpc_convert) +(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, + WORD order) = &ixheaacd_tns_parcor_lpc_convert_armv7; + +WORD32(*ixheaacd_calc_max_spectral_line) +(WORD32 *ptr_tmp, WORD32 size) = &ixheaacd_calc_max_spectral_line_armv7; + +VOID(*ixheaacd_post_twiddle) +(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) = &ixheaacd_post_twiddle_armv7; + +VOID(*ixheaacd_post_twid_overlap_add) +(WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) = &ixheaacd_post_twid_overlap_add_armv7; +VOID(*ixheaacd_neg_shift_spec) +(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) = &ixheaacd_neg_shift_spec_armv7; + +VOID(*ixheaacd_spec_to_overlapbuf) +(WORD32 *ptr_overlap_buf, WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) = &ixheaacd_spec_to_overlapbuf_armv7; + +VOID(*ixheaacd_overlap_buf_out) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac) = &ixheaacd_overlap_buf_out_armv7; + +VOID(*ixheaacd_overlap_out_copy) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) = &ixheaacd_overlap_out_copy_armv7; + +VOID(*ixheaacd_pretwiddle_compute) +(WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) = &ixheaacd_pretwiddle_compute_armv7; + +VOID(*ixheaacd_imdct_using_fft) +(ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_armv7; + +VOID(*ixheaacd_complex_fft_p2) +(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode, + WORD32 *preshift) = &ixheaacd_complex_fft_p2_armv7; + +VOID(*ixheaacd_mps_complex_fft_64) +(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im, + WORD32 nlength) = &ixheaacd_mps_complex_fft_64_armv7; + +VOID(*ixheaacd_mps_synt_pre_twiddle) +(WORD32 *ptr_in, WORD32 *table_re, 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 resolution) = &ixheaacd_mps_synt_post_twiddle_armv7; + +VOID(*ixheaacd_calc_pre_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_armv7; + +VOID(*ixheaacd_calc_post_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + 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; + +VOID(*ixheaacd_mps_synt_out_calc) +(WORD32 resolution, WORD32 *out, WORD32 *state, + const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_armv7; + +VOID(*ixheaacd_fft_15_ld) +(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr) = &ixheaacd_fft_15_ld_armv7; + +VOID(*ixheaacd_aac_ld_dec_rearrange) +(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab) = &ia_aac_ld_dec_rearrange_armv7; + +VOID (*ixheaacd_fft32x32_ld) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_armv7; + +VOID (*ixheaacd_fft32x32_ld2) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_fft32x32_ld2_armv7; + +WORD16 (*ixheaacd_neg_expo_inc)(WORD16 neg_expo) = &ixheaacd_neg_expo_inc_arm; + +VOID (*ixheaacd_inv_dit_fft_8pt) +(WORD32 *x, WORD32 *real, WORD32 *imag) = &ixheaacd_inv_dit_fft_8pt_armv7; + +VOID (*ixheaacd_scale_factor_process) +(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_armv7; diff --git a/decoder/armv7/ixheaacd_fwd_modulation.s b/decoder/armv7/ixheaacd_fwd_modulation.s new file mode 100644 index 0000000..fec9a4e --- /dev/null +++ b/decoder/armv7/ixheaacd_fwd_modulation.s @@ -0,0 +1,102 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .extern ixheaacd_cos_sin_mod +.hidden ixheaacd_cos_sin_mod + .global ixheaacd_fwd_modulation +ixheaacd_fwd_modulation: + + STMFD sp!, {r3-r9, r12, lr} + MOV r5, r2 + LDR r2, [sp, #0x24] + MOV lr, r1 + MOV r4, r1 + MOV r1, #0x1f + MOV r7, r5 + ADD r8, r0, #0xfc + MOV r6, r3 +LOOP1: + LDR r3, [r0], #4 + LDR r12, [r8], #-4 + + MOV r3, r3, ASR #4 + MOV r12, r12, ASR #4 + + QSUB r9, r3, r12 + ADD r3, r3, r12 + + STR r9, [lr], #4 + SUBS r1, r1, #1 + STR r3, [r7], #4 + + BPL LOOP1 + + MOV r1, r6 + MOV r0, r4 + + + + MOV r3, #0xd8 + LSL r3, r3, #4 + ADD r3, r3, #8 + + ADD r3, r2, r3 + + + ADD r2, r3, #4 + + + + BL ixheaacd_cos_sin_mod + + LDRSH r1, [r6, #0x2c] + LDRSH r2, [r6, #0x2a] + LDR r0, [r6, #0x18] + SUBS r2, r1, r2 + +@ LDMLEFD sp!, {r3-r9, r12, pc} + LDMFDLE sp!, {r3-r9, r12, pc} +LOOP2: + LDR r1, [r0], #4 + LDR r12, [r5, #0] + LDR r3, [r4, #0] + + SMULWT r6, r12, r1 + SMULWB lr, r3, r1 + + SMULWB r12, r12, r1 + SMULWT r1, r3, r1 + + + + + ADD lr, lr, r6 + QSUB r1, r12, r1 + MOV r3, lr, LSL #1 + MOV r1, r1, LSL #1 + STR r3, [r4], #4 + SUBS r2, r2, #1 + STR r1, [r5], #4 + BGT LOOP2 + + LDMFD sp!, {r3-r9, r12, pc} diff --git a/decoder/armv7/ixheaacd_harm_idx_zerotwolp.s b/decoder/armv7/ixheaacd_harm_idx_zerotwolp.s new file mode 100644 index 0000000..6cb05bb --- /dev/null +++ b/decoder/armv7/ixheaacd_harm_idx_zerotwolp.s @@ -0,0 +1,109 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_harm_idx_zerotwolp_armv7 +ixheaacd_harm_idx_zerotwolp_armv7: + STMFD sp!, {r4-r12} + SUB r5, r2, #1 + MOV r2, #-1 + LDR r6, [sp, #52] + LDR r12, [sp, #48] + ADD r10, sp, #36 + LDR r4, [sp, #44] + LDMIA r10, {r9, r10} + CMP r4, #0 + BLE EXIT + CMP r12, #0 + BNE NO_NOISE + + + +LOOP1: + LDR r12, [r0, #0] + LDRSH r7, [r1], #2 + LDRSH r8, [r1], #2 + + ADD r2, r2, #1 + SMULWB r7, r12, r7 + SUBS r8, r8, r5 + + LDRH r12, [r3], #4 + RSBLE r8, r8, #0 + MOVLE r8, r7, ASR r8 + MOVGT r8, r7, LSL r8 + + MOVS r12, r12, LSL #16 + BEQ NEXT + + CMP r6, #0 + QADDEQ r8, r8, r12 + QSUBNE r8, r8, r12 + SUBS r4, r4, #1 + B STORE + +NEXT: + + + LDR r7, [r9, r2, LSL #2] + ADD r12, r10, r2, LSL #2 + LDRSH r12, [r12, #0] + SUBS r4, r4, #1 + SMULTB r7, r7, r12 + ADD r8, r8, r7, LSL #1 + +STORE: + STR r8, [r0], #4 + BGT LOOP1 + B EXIT + + +NO_NOISE: + +LOOP2: + LDR r12, [r0, #0] + LDRSH r7, [r1], #2 + LDRSH r9, [r1], #2 + LDRH r10, [r3], #4 + + SMULWB r7, r12, r7 + SUBS r9, r9, r5 + RSBMI r9, r9, #0 + + MOVMI r12, r7, ASR r9 + MOVPL r12, r7, LSL r9 + + MOV r7, r10, LSL #16 + + CMP r6, #0 + QADDEQ r12, r12, r7 + QSUBNE r12, r12, r7 + + SUBS r4, r4, #1 + STR r12, [r0], #4 + BGT LOOP2 + +EXIT: + LDMFD sp!, {r4-r12} + BX lr + + diff --git a/decoder/armv7/ixheaacd_imdct_using_fft.s b/decoder/armv7/ixheaacd_imdct_using_fft.s new file mode 100644 index 0000000..563c041 --- /dev/null +++ b/decoder/armv7/ixheaacd_imdct_using_fft.s @@ -0,0 +1,825 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_imdct_using_fft_armv7 +ixheaacd_imdct_using_fft_armv7: + + STMFD sp!, {r4-r12, lr} + vpush {d8-d15} + +@ LDR r4, [sp, #0x68] +@ LDR r5, [sp, #0x68+4] +@ LDR r6, [sp, #0x68+8] +@ LDR r7, [sp, #0x68+12] + + LDR r8, =11600 + ADD r4, r0, r8 + LDR r8, =11856 + ADD r5, r0, r8 + LDR r8, =11920 + ADD r6, r0, r8 + LDR r8, =11936 + ADD r7, r0, r8 + + + + + +COND_1: CMP r1, #0x400 + BNE COND_2 + + MOV r8, #4 + B RADIX_4_FIRST_START + + +COND_2: CMP r1, #0x200 + BNE COND_3 + + MOV r8, #3 + MOV r4, r5 + B RADIX_8_FIRST_START + +COND_3: CMP r1, #0x100 + BNE COND_4 + + MOV r8, #3 + MOV r4, r5 + B RADIX_4_FIRST_START + +COND_4: CMP r1, #0x80 + BNE COND_5 + + MOV r8, #2 + MOV r4, r6 + B RADIX_8_FIRST_START + +COND_5: CMP r1, #0x40 + BNE COND_6 + + MOV r8, #2 + MOV r4, r6 + B RADIX_4_FIRST_START +COND_6: + + MOV r8, #1 + MOV r4, r7 + + + + + + +RADIX_8_FIRST_START: + + + LSR r9 , r1, #5 + LSL r1, r1, #1 + +RADIX_8_FIRST_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + SUB r5, r5, r1, LSL #2 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + SUB r6, r6, r1, LSL #2 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12 , LSL #3 + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + SUB r7, r7, r1, LSL #1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + SUB r11, r11, r1, LSL #1 + + + + VADD.I32 q8, q0, q4 + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + + VSUB.I32 q9, q0, q4 + VLD2.32 {d13[0], d15[0]}, [r7], r1 + SUB r7, r7, r1, LSL #2 + + + + + VADD.I32 q0, q1, q5 + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + + VSUB.I32 q4, q1, q5 + VLD2.32 {d13[1], d15[1]}, [r11], r1 + SUB r11, r11, r1, LSL #2 + + + + ADD r4, r4, #4 + + ADD r5, r5, r1, LSR #1 + ADD r6, r6, r1, LSR #1 + ADD r7, r7, r1, LSR #1 + ADD r11, r11, r1, LSR #1 + + + VADD.I32 q1, q2, q6 + VLD2.32 {d28[0], d30[0]}, [r5] , r1 + + + VSUB.I32 q5, q2, q6 + VLD2.32 {d20[0], d22[0]}, [r5] , r1 + + + VADD.I32 q2, q3, q7 + VLD2.32 {d24[0], d26[0]}, [r5] , r1 + + + VSUB.I32 q6, q3, q7 + VLD2.32 {d28[1], d30[1]}, [r6] , r1 + + VADD.S32 q3, q9, q6 + VLD2.32 {d20[1], d22[1]}, [r6] , r1 + + VSUB.S32 q7, q9, q6 + VLD2.32 {d24[1], d26[1]}, [r6] , r1 + + VSUB.S32 q6, q4, q5 + VLD2.32 {d29[0], d31[0]}, [r7] , r1 + + VADD.S32 q9, q4, q5 + VLD2.32 {d21[0], d23[0]}, [r7] , r1 + + VADD.S32 q4, q8, q1 + VLD2.32 {d25[0], d27[0]}, [r7] , r1 + + VSUB.S32 q5, q8, q1 + VLD2.32 {d29[1], d31[1]}, [r11] , r1 + + VADD.S32 q8, q0, q2 + VLD2.32 {d21[1], d23[1]}, [r11] , r1 + + VSUB.S32 q0, q0, q2 + VLD2.32 {d25[1], d27[1]}, [r11] , r1 + + + VPUSH {q3} + VPUSH {q7} + + + + + + + + + VLD2.32 {d2[0], d4[0]}, [r5], r1 + + VADD.I32 q7, q14, q12 + + VLD2.32 {d2[1], d4[1]}, [r6] , r1 + + VSUB.I32 q3, q14, q12 + + VLD2.32 {d3[0], d5[0]}, [r7] , r1 + + VADD.I32 q14, q15, q13 + + VLD2.32 {d3[1], d5[1]}, [r11] , r1 + + VSUB.I32 q12, q15, q13 + + + + + + + + + + VADD.I32 q15, q10, q1 + VSUB.I32 q13, q10, q1 + VADD.I32 q10, q11, q2 + VSUB.I32 q1, q11, q2 + + + + VADD.S32 q11, q7, q15 + VSUB.S32 q2, q7, q15 + VADD.S32 q7, q14, q10 + VSUB.S32 q15, q14, q10 + + VADD.S32 q14, q3, q12 + VSUB.S32 q10, q3, q12 + VADD.S32 q3, q13, q1 + VSUB.S32 q12, q13, q1 + + VADD.S32 q1 , q14, q12 + VSUB.S32 q13, q14, q12 + VSUB.S32 q12, q3, q10 + + VUZP.16 d2, d3 + VADD.S32 q14, q3, q10 + + VUZP.16 d26, d27 + VADD.S32 q3, q4, q11 + + VUZP.16 d24, d25 + VSUB.S32 q10, q4, q11 + + VUZP.16 d28, d29 + VADD.S32 q4, q8, q7 + + LDR r14, =0x5a82 + + VSUB.S32 q11, q8, q7 + + VADD.S32 q8, q5, q15 + VSUB.S32 q7, q5, q15 + VSUB.S32 q5, q0, q2 + VADD.S32 q15, q0, q2 + + VPOP {q0} + VPOP {q2} + VPUSH {q3-q4} + VPUSH {q10} + + + + + + + + + + + + + + + + + + VDUP.16 d20, r14 + + + VMULL.u16 q4, d26, d20 + VMULL.u16 q3, d28, d20 + + VPUSH {q7-q8} + VPUSH {q5} + + VSHR.S32 q4, q4, #15 + VSHR.S32 q3, q3, #15 + + VQDMLAL.S16 q4, d27, d20 + VQDMLAL.S16 q3, d29, d20 + + + VPUSH {q11} + + VMULL.u16 q13, d24, d20 + VMULL.u16 q14, d2, d20 + + VADD.S32 q5, q2, q4 + VSUB.S32 q7, q2, q4 + + VADD.S32 q8, q6, q3 + VSUB.S32 q6, q6, q3 + + + + + + + VSHR.S32 q13, q13, #15 + VSHR.S32 q14, q14, #15 + + VQDMLAL.S16 q13, d25, d20 + VQDMLAL.S16 q14, d3, d20 + + VPOP {q1} + VPOP {q10} + + VADD.S32 q2, q0, q13 + VSUB.S32 q4, q0, q13 + + VADD.S32 q11, q9, q14 + VSUB.S32 q3, q9, q14 + + + + + VPOP {q14} + VPOP {q9} + VPOP {q0} + VPOP {q12, q13} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VTRN.32 q12, q5 + VSHL.S32 q12, q12, #3 + VTRN.32 q9, q2 + VSHL.S32 q5, q5, #3 + + VSHL.S32 q9, q9, #3 + VTRN.32 q0, q7 + VSHL.S32 q2, q2, #3 + + VSHL.S32 q0, q0, #3 + VTRN.32 q14, q4 + VSHL.S32 q7, q7, #3 + + VSHL.S32 q14, q14, #3 + VTRN.32 q13, q6 + VSHL.S32 q4, q4, #3 + + VSHL.S32 q13, q13, #3 + VTRN.32 q10, q3 + VSHL.S32 q6, q6, #3 + + VSHL.S32 q10, q10, #3 + VTRN.32 q1, q8 + VSHL.S32 q3, q3, #3 + + VSHL.S32 q1, q1, #3 + VTRN.32 q15, q11 + VSHL.S32 q8, q8, #3 + + VSHL.S32 q15, q15, #3 + VSWP d18, d25 + + VSHL.S32 q11, q11, #3 + VSWP d4, d11 + + VSWP d1, d28 + VSWP d15, d8 + + VSWP d20, d27 + VSWP d6, d13 + + VSWP d30, d3 + VSWP d22, d17 + + VST2.32 {q12, q13}, [r3]! + VST2.32 {q0, q1}, [r3]! + + VST2.32 {q5, q6}, [r3]! + VST2.32 {q7, q8}, [r3]! + + VMOV q5, q11 + + VST2.32 {q9, q10}, [r3]! + VST2.32 {q14, q15}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q4, q5}, [r3]! + + + SUBS r9, r9, #1 + BNE RADIX_8_FIRST_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + + MOV r5, #8 + MOV r4, #32 + LSR r6, r1, #5 + + B RADIX_4_FIRST_ENDS + +RADIX_8_FIRST_ENDS: + + +RADIX_4_FIRST_START: + + + LSR r9 , r1, #4 + LSL r1, r1, #1 + +RADIX_4_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + + + + + + + + + + + + + + + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12, LSL #3 + + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + + + SUB r7, r7, r1, LSL #1 + VADD.S32 q8, q0, q4 + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + VADD.S32 q9, q1, q5 + VLD2.32 {d13[0], d15[0]}, [r7], r1 + + + + SUB r11, r11, r1, LSL #1 + VSUB.S32 q10, q0, q4 + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + VSUB.S32 q11, q1, q5 + VLD2.32 {d13[1], d15[1]}, [r11], r1 + + + ADD r4, r4, #4 + + VADD.S32 q12, q2, q6 + VADD.S32 q13, q3, q7 + VSUB.S32 q14, q2, q6 + VSUB.S32 q15, q3, q7 + + VADD.S32 q0, q8, q12 + VADD.S32 q1, q9, q13 + VSUB.S32 q2, q8, q12 + VSUB.S32 q3, q9, q13 + + VADD.S32 q4, q10, q15 + VSUB.S32 q5, q11, q14 + VADD.S32 q7, q11, q14 + VSUB.S32 q6, q10, q15 + + + + + VTRN.32 q0, q4 + + VSHL.S32 q0, q0, #2 + VTRN.32 q2, q6 + VSHL.S32 q4, q4, #2 + + VSHL.S32 q2, q2, #2 + VTRN.32 q1, q5 + VSHL.S32 q6, q6, #2 + + VSHL.S32 q1, q1, #2 + VTRN.32 q3, q7 + VSHL.S32 q5, q5, #2 + + VSHL.S32 q3, q3, #2 + VSWP d4, d1 + + VSHL.S32 q7, q7, #2 + VSWP d12, d9 + + + + VSWP d6, d3 + VSWP d14, d11 + + + VST2.32 {q0, q1}, [r3]! + VST2.32 {q4, q5}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q6, q7}, [r3]! + + + + SUBS r9, r9, #1 + BNE RADIX_4_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + MOV r5, #4 + MOV r4, #64 + LSR r6, r1, #4 + + +RADIX_4_FIRST_ENDS: + + PUSH {r3} + LSR r5, r5, #2 + LDR r14, =8528 + ADD r0, r0, r14 + +OUTER_LOOP_R4: + + + LDR r14, [sp] + + MOV r7, r5 + MOV r2, #0 + MOV r9, r0 + LSL r12 , r5, #5 +MIDDLE_LOOP_R4: + + + VLD2.16 {d0[0], d1[0]}, [r9], r2 + VLD2.16 {d2[0], d3[0]}, [r9], r2 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[0], d5[0]}, [r9] + ADD r10, r0, r11 + + + VLD2.16 {d0[1], d1[1]}, [r10], r11 + VLD2.16 {d2[1], d3[1]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[1], d5[1]}, [r10] + ADD r9, r0, r2 + + + VLD2.16 {d0[2], d1[2]}, [r9], r2 + VLD2.16 {d2[2], d3[2]}, [r9], r2 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[2], d5[2]}, [r9] + ADD r10, r0, r11 + + + + VLD2.16 {d0[3], d1[3]}, [r10], r11 + VLD2.16 {d2[3], d3[3]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[3], d5[3]}, [r10] + ADD r9, r0, r2 + + MOV r10, r6 + + + +INNER_LOOP_R4: + + VLD2.32 {q3, q4}, [r14], r12 + + VSHR.S32 q3, q3, #1 + VLD4.16 {q5, q6}, [r14], r12 + VSHR.S32 q4, q4, #1 + + VSHR.U16 d10, d10, #1 + VLD4.16 {q7, q8}, [r14], r12 + VSHR.U16 d12, d12, #1 + + VMULL.S16 q11, d10, d0 + VMLSL.S16 q11, d12, d1 + VLD4.16 {q9, q10}, [r14], r12 + VMULL.S16 q12, d10, d1 + VMLAL.S16 q12, d12, d0 + + VSHR.U16 d14, d14, #1 + VSHR.U16 d16, d16, #1 + + SUB r14, r14, r12, LSL #2 + + VSHR.U16 d18, d18, #1 + VSHR.U16 d20, d20, #1 + + VMULL.S16 q13, d14, d2 + VMLSL.S16 q13, d16, d3 + + VSHR.S32 q11, q11, #15 + + VMULL.S16 q14, d14, d3 + VMLAL.S16 q14, d16, d2 + + VMULL.S16 q15, d18, d4 + VMLSL.S16 q15, d20, d5 + + VMLAL.S16 q11, d11, d0 + VMLSL.S16 q11, d13, d1 + + VSHR.S32 q12, q12, #15 + VSHR.S32 q13, q13, #15 + VSHR.S32 q14, q14, #15 + VSHR.S32 q15, q15, #15 + + + VMLAL.S16 q12, d11, d1 + VMLAL.S16 q12, d13, d0 + + + VMULL.S16 q5, d18, d5 + VMLAL.S16 q5, d20, d4 + + + VMLAL.S16 q13, d15, d2 + VMLSL.S16 q13, d17, d3 + + VMLAL.S16 q14, d15, d3 + VMLAL.S16 q14, d17, d2 + + + VMLAL.S16 q15, d19, d4 + VMLSL.S16 q15, d21, d5 + + VSHR.S32 q5, q5, #15 + + VMLAL.S16 q5, d19, d5 + VMLAL.S16 q5, d21, d4 + + + + CMP r7, r5 + BNE BYPASS_IF + + ADD r14, r14, r12 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d22[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d26[0], r3 + + LDR r3, [r14] + ASR r3, r3, #1 + VMOV.32 d30[0], r3 + + SUB r14, r14, r12, LSL #1 + ADD r14, r14, #4 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d24[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d28[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.32 d10[0], r3 + + SUB r14, r14, #4 + + SUB r14, r14, r12, LSL #2 + +BYPASS_IF: + + VADD.S32 q6, q3, q13 + VADD.S32 q7, q4, q14 + VSUB.S32 q3, q3, q13 + VSUB.S32 q4, q4, q14 + VADD.S32 q8, q11, q15 + VADD.S32 q9, q12, q5 + + VSUB.S32 q15, q11, q15 + VSUB.S32 q14, q12, q5 + + VADD.S32 q10, q6, q8 + VADD.S32 q11, q7, q9 + VADD.S32 q12, q3, q14 + VSUB.S32 q13, q4, q15 + + VSUB.S32 q6, q6, q8 + VST2.32 {q10, q11}, [r14], r12 + VSUB.S32 q7, q7, q9 + + VSUB.S32 q8, q3, q14 + VST2.32 {q12, q13}, [r14], r12 + VADD.S32 q9, q4, q15 + + + VST2.32 {q6, q7}, [r14], r12 + VST2.32 {q8, q9}, [r14], r12 + + + + + SUBS r10, r10, #1 + BNE INNER_LOOP_R4 + + SUB r14, r14, r1, LSL #3 + ADD r14, r14, #32 + + SUBS r7, r7, #1 + BNE MIDDLE_LOOP_R4 + + + + + LSR r4, r4, #2 + LSL r5, r5, #2 + LSR r6, r6, #2 + SUBS r8, r8, #1 + BNE OUTER_LOOP_R4 +END_LOOPS: + POP {r3} + vpop {d8-d15} + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_inv_dit_fft_8pt.s b/decoder/armv7/ixheaacd_inv_dit_fft_8pt.s new file mode 100644 index 0000000..7ed90d9 --- /dev/null +++ b/decoder/armv7/ixheaacd_inv_dit_fft_8pt.s @@ -0,0 +1,163 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_inv_dit_fft_8pt_armv7 + +ixheaacd_inv_dit_fft_8pt_armv7: + + + STMFD sp!, {r4-r12, lr} + LDR r3, [r0, #0] + LDR r4, [r0, #0x20] + LDR r5, [r0, #0x24] + QADD r12, r3, r4 + LDR r6, [r0, #0x30] + QSUB r8, r3, r4 + LDR r3, [r0, #4] + LDR r9, [r0, #0x34] + QADD r4, r3, r5 + SUB sp, sp, #0x14 + QSUB r5, r3, r5 + LDR lr, [r0, #0x10] + LDR r3, [r0, #0x14] + QADD r10, lr, r6 + QSUB r6, lr, r6 + QADD r7, r3, r9 + QSUB r9, r3, r9 + + + QADD r3, r12, r10 + QSUB lr, r12, r10 + QADD r12, r4, r7 + QSUB r7, r4, r7 + QSUB r4, r8, r9 + + STR r7, [sp, #8] + QADD r7, r8, r9 + QADD r8, r5, r6 + STR r7, [sp, #0xc] + QSUB r5, r5, r6 + + STMIA sp, {r8, lr} + STR r5, [sp, #0x10] + + + + LDR r5, [r0, #8] + LDR lr, [r0, #0x28] + LDR r9, [r0, #0x2c] + QADD r7, r5, lr + LDR r11, [r0, #0x38] + LDR r6, [r0, #0xc] + QSUB r5, r5, lr + LDR lr, [r0, #0x18] + QADD r8, r6, r9 + QSUB r6, r6, r9 + + + + QADD r10, lr, r11 + QSUB r9, lr, r11 + LDR r11, [r0, #0x1c] + LDR r0, [r0, #0x3c] + + MOV lr, r11 + QADD r11, r11, r0 + QSUB r0, lr, r0 + + + QADD lr, r7, r10 + QSUB r10, r7, r10 + QADD r7, r8, r11 + QSUB r11, r8, r11 + + QSUB r8, r5, r0 + QADD r5, r5, r0 + QADD r0, r6, r9 + QSUB r6, r6, r9 + + + QADD r9, r3, lr + QSUB r3, r3, lr + STR r9, [r1, #0] + + QADD r9, r12, r7 + LDR lr, [sp, #4] + STR r9, [r2, #0] + QSUB r9, r12, r7 + + + QSUB r12, lr, r11 + QADD r11, lr, r11 + LDR lr, [sp, #8] + STR r11, [r1, #0x10] + QADD r7, lr, r10 + QSUB r10, lr, r10 + + LDR r11, =0x00005a82 + STR r10, [r2, #0x10] + + QSUB r10, r8, r0 + QADD r0, r8, r0 + SMULWB r10, r10, r11 + SMULWB r0, r0, r11 + MOV r10, r10, LSL #1 + + QADD r8, r4, r10 + LDR lr, [sp, #0] + + STR r8, [r1, #4] + MOV r0, r0, LSL #1 + QADD r8, lr, r0 + + QSUB r4, r4, r10 + STR r8, [r2, #4] + QSUB r0, lr, r0 + + QADD r12, r12, r4 + QADD r0, r7, r0 + STR r12, [r1, #8] + STR r0, [r2, #8] + + QADD r0, r5, r6 + LDR r7, [sp, #0xc] + SMULWB r0, r0, r11 + + QSUB r12, r5, r6 + MOV r0, r0, LSL #1 + SMULWB r12, r12, r11 + LDR r5, [sp, #0x10] + QSUB r4, r7, r0 + MOV r12, r12, LSL #1 + QADD r10, r5, r12 + QADD r3, r3, r4 + QADD lr, r9, r10 + QADD r0, r7, r0 + QSUB r10, r5, r12 + STR r3, [r1, #0xc] + STR lr, [r2, #0xc] + STR r0, [r1, #0x14] + STR r10, [r2, #0x14] + ADD sp, sp, #0x14 + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_lap1.s b/decoder/armv7/ixheaacd_lap1.s new file mode 100644 index 0000000..999dd35 --- /dev/null +++ b/decoder/armv7/ixheaacd_lap1.s @@ -0,0 +1,113 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_overlap_out_copy_armv7 + .global ixheaacd_spec_to_overlapbuf_armv7 + .global ixheaacd_overlap_buf_out_armv7 + +ixheaacd_overlap_buf_out_armv7: + + STMFD sp!, {r4-r5} + MOV r3, r3, lsl #1 + +OUTSAMPLE_LOOP: + + LDR r4, [r1], #4 + LDR r5, [r1], #4 + SUBS r2, r2, #2 + + QADD16 r4, r4, r4 + QADD16 r5, r5, r5 + + STRH r4, [r0], r3 + STRH r5, [r0], r3 + + BGT OUTSAMPLE_LOOP + + LDMFD sp!, {r4-r5} + BX lr + + +ixheaacd_overlap_out_copy_armv7: + + STMFD sp!, {r4-r9, r14} + MOV r9, #32 + MOV r8, r1 + MOV r3, r3, LSL #1 + + +OUT_OVERLAP_LOOP: + LDR r4, [r1], #4 + LDR r5, [r1], #4 + SUBS r9, r9, #1 + + QADD16 r4, r4, r4 + QADD16 r5, r5, r5 + + LDR r6, [r2], #4 + LDR r7, [r2], #4 + + STRH r4, [r0], r3 + STRH r5, [r0], r3 + + STR r6, [r8], #4 + STR r7, [r8], #4 + + BGT OUT_OVERLAP_LOOP + + LDMFD sp!, {r4-r9, r15} + + + + +ixheaacd_spec_to_overlapbuf_armv7: + + STMFD sp!, {r4-r10, r14} + + MOV r6, #1 + RSB r2, r2, #16 + AND r2, r2, #0xFF + SUB r7, r2, #1 + LSL r14, r6, r7 + MOV r3, r3, ASR #1 + +OVERLAP_LOOP1: + + + LDMIA r1!, {r4-r5} + SUBS r3, r3, #1 + + QADD r4, r4, r14 + QADD r5, r5, r14 + + MOV r4, r4, ASR r2 + MOV r5, r5, ASR r2 + + STR r4, [r0], #4 + STR r5, [r0], #4 + + + BGT OVERLAP_LOOP1 + LDMFD sp!, {r4-r10, pc} + diff --git a/decoder/armv7/ixheaacd_mps_complex_fft_64_asm.s b/decoder/armv7/ixheaacd_mps_complex_fft_64_asm.s new file mode 100644 index 0000000..38638cf --- /dev/null +++ b/decoder/armv7/ixheaacd_mps_complex_fft_64_asm.s @@ -0,0 +1,694 @@ +.text +.p2align 2 +.global ixheaacd_mps_complex_fft_64_asm + +ixheaacd_mps_complex_fft_64_asm: + @LDR r4,[sp] + STMFD sp!, {r0-r12, lr} + LDR r4, [sp, #0x38] + SUB sp, sp, #0x28 +@ LDR r4,[sp,#0x30] + LDR r0, [sp, #0x2c] + @LDR r12,[sp,#0x5c+4] + EOR r0, r0, r0, ASR #31 + CLZ r0, r0 + SUB r12, r0, #16 @dig_rev_shift = norm32(npoints) + 1 -16@ + SUB r0, r0, #1 + RSB r0, r0, #0x1e + AND r1, r0, #1 + STR r1, [sp, #0x14] + MOV r1, r0, ASR #1 + LDR r0, [sp, #0x2c] @npoints + STR r1, [sp, #-4]! + MOV lr, r0, LSL #1 @(npoints >>1) * 4 + MOV r0, #0 + MOV r12, r4 +FIRST_STAGE_R4: + LDRB r10, [r12, r0, LSR #2] + + + ADD r1, r2, r10, LSL #2 + LDRD r4, [r1] @r4=x0r, r5=x0i + ADD r1, r1, lr + LDRD r8, [r1] @r8=x1r, r9=x1i + ADD r1, r1, lr + LDRD r6, [r1] @r6=x2r, r7=x2i + ADD r1, r1, lr + LDRD r10, [r1] @r10=x3r, r11=x3i + ADD r0, r0, #4 + CMP r0, lr, ASR #1 + + ADD r4, r4, r6 @x0r = x0r + x2r@ + ADD r5, r5, r7 @x0i = x0i + x2i@ + SUB r6, r4, r6, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r7, r5, r7, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r8, r8, r10 @x1r = x1r + x3r@ + ADD r9, r9, r11 @x1i = x1i + x3i@ + SUB r1, r8, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r9, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r8 @x0r = x0r + x1r@ + ADD r5, r5, r9 @x0i = x0i + x1i@ + SUB r8, r4, r8, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r9, r5, r9, lsl#1 @x1i = x0i - (x1i << 1) + ADD r6, r6, r11 @x2r = x2r + x3i@ + SUB r7, r7, r1 @x2i = x2i - x3r@ + SUB r10, r6, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r11, r7, r1, lsl#1 @x3r = x2i + (x3r << 1)@ + + STMIA r3!, {r4-r11} + BLT FIRST_STAGE_R4 + LDR r1, [sp], #4 + LDR r0, [sp, #0x2c] + MOV r12, #0x40 @nodespacing = 64@ + STR r12, [sp, #0x1c] + LDR r12, [sp, #0x2c] + SUB r3, r3, r0, LSL #3 + SUBS r1, r1, #1 + STR r3, [sp, #0x34] + MOV r4, r12, ASR #4 + MOV r0, #4 + STR r4, [sp, #0x18] + STR r1, [sp, #0x20] + BLE EXIT +OUTER_LOOP: + LDR r1, [sp, #0x28] + LDR r12, [sp, #0x34] @WORD32 *data = ptr_y@ + STR r1, [sp, #0x10] + LDR r1, [sp, #0x18] + + MOV r0, r0, LSL #3 @(del<<1) * 4 +LOOP_TRIVIAL_TWIDDLE: + LDRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + LDRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + LDRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + LDRD r10, [r12] @r10=x3r, r11=x3i + +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 +@MOV r6,r6,ASR #1 +@MOV r7,r7,ASR #1 +@MOV r8,r8,ASR #1 +@MOV r9,r9,ASR #1 +@MOV r10,r10,ASR #1 +@MOV r11,r11,ASR #1 + + ADD r4, r4, r8 @x0r = x0r + x2r@ + ADD r5, r5, r9 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl #1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl #1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r2, r6, r10, lsl #1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl #1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ +@MOV r4,r4,ASR #1 +@MOV r5,r5,ASR #1 + SUB r6, r4, r6, lsl #1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl #1 @x1i = x0i - (x1i << 1) + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r2 @x2i = x2i - x3r@ + SUB r10, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r11, r9, r2, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r10, [r12] @r10=x3r, r11=x3i + SUB r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + SUB r12, r12, r0 + STRD r8, [r12] @r8=x2r, r9=x2i + SUB r12, r12, r0 + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0, lsl #2 + + SUBS r1, r1, #1 + BNE LOOP_TRIVIAL_TWIDDLE + + MOV r0, r0, ASR #3 + LDR r4, [sp, #0x1c] + LDR r3, [sp, #0x34] + MUL r1, r0, r4 + ADD r12, r3, #8 + STR r1, [sp, #0x24] + MOV r3, r1, ASR #2 + ADD r3, r3, r1, ASR #3 + SUB r3, r3, r1, ASR #4 + ADD r3, r3, r1, ASR #5 + SUB r3, r3, r1, ASR #6 + ADD r3, r3, r1, ASR #7 + SUB r3, r3, r1, ASR #8 + STR r3, [sp, #-4]! +SECOND_LOOP: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY: + + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r9, r9, r8 + SUB r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r11, r11, r10 + SUB r10, r4, r5 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7 + BLE SECOND_LOOP + +SECOND_LOOP_2: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_2: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r9, r9, r8 + SUB r8, r4, r5 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r10, r11, r10 + SUB r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_2 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7, ASR #1 + BLE SECOND_LOOP_2 + LDR r7, [sp, #0] + CMP r4, r7, LSL #1 + BGT SECOND_LOOP_4 + +SECOND_LOOP_3: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + + +RADIX4_BFLY_3: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r8, r9, r8 + SUB r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r10, r11, r10 + SUB r11, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + ADD r7, r7, r11 @x1i = x1i + x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + SUB r11, r7, r11, lsl#1 @x3i = x1i - (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_3 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0] + ADD r4, r4, r6 + CMP r4, r7, LSL #1 + BLE SECOND_LOOP_3 + +SECOND_LOOP_4: + LDR r3, [sp, #0x10+4] + LDR r14, [sp, #0x18+4] + MOV r0, r0, LSL #3 @(del<<1) * 4 + + LDR r1, [r3, r4, LSL #3]! @ w1h = *(twiddles + 2*j)@ + LDR r2, [r3, #4] @w1l = *(twiddles + 2*j + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r5, [r3, r4, LSL #3]! @w2h = *(twiddles + 2*(j<<1))@ + LDR r6, [r3, #4] @w2l = *(twiddles + 2*(j<<1) + 1)@ + SUB r3, r3, #2048 @ 512 *4 + LDR r7, [r3, r4, LSL #3]! @w3h = *(twiddles + 2*j + 2*(j<<1))@ + LDR r8, [r3, #4] @w3l = *(twiddles + 2*j + 2*(j<<1) + 1)@ + + + STR r4, [sp, #8+4] + STR r1, [sp, #-4] + STR r2, [sp, #-8] + STR r5, [sp, #-12] + STR r6, [sp, #-16] + STR r7, [sp, #-20] + STR r8, [sp, #-24] + +RADIX4_BFLY_4: + LDRD r6, [r12, r0]! @r6=x1r, r7=x1i + LDRD r8, [r12, r0]! @r8=x2r, r9=x2i + LDRD r10, [r12, r0] @r10=x3r, r11=x3i + SUBS r14, r14, #1 + + LDR r1, [sp, #-4] + LDR r2, [sp, #-8] + + SMULL r3, r4, r6, r2 @ixheaacd_mult32(x1r,w1l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r6, r6, r1 @mult32x16hin32(x1r,W1h) + LSR r3, r3, #31 + ORR r6, r3, r6, LSL#1 + SMULL r3, r5, r7, r1 @mult32x16hin32(x1i,W1h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r7, r7, r2 @ixheaacd_mac32(ixheaacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r7, r3, r7, LSL#1 + ADD r7, r7, r6 + SUB r6, r4, r5 @ + + LDR r1, [sp, #-12] + LDR r2, [sp, #-16] + + SMULL r3, r4, r8, r2 @ixheaacd_mult32(x2r,w2l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r8, r8, r1 @mult32x16hin32(x2r,W2h) + LSR r3, r3, #31 + ORR r8, r3, r8, LSL#1 + SMULL r3, r5, r9, r1 @mult32x16hin32(x2i,W2h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r9, r9, r2 @ixheaacd_mac32(ixheacd_mult32(x1r,w1h) ,x1i,w1l) + LSR r3, r3, #31 + ORR r9, r3, r9, LSL#1 + ADD r8, r9, r8 + SUB r9, r5, r4 @ + + LDR r1, [sp, #-20] + LDR r2, [sp, #-24] + + SMULL r3, r4, r10, r2 @ixheaacd_mult32(x3r,w3l) + LSR r3, r3, #31 + ORR r4, r3, r4, LSL#1 + SMULL r3, r10, r10, r1 @mult32x16hin32(x3r,W3h) + LSR r3, r3, #31 + ORR r10, r3, r10, LSL#1 + SMULL r3, r5, r11, r1 @mult32x16hin32(x3i,W3h) + LSR r3, r3, #31 + ORR r5, r3, r5, LSL#1 + SMULL r3, r11, r11, r2 @ixheaacd_mac32(ixheacd_mult32(x3r,w3h) ,x3i,w3l) + LSR r3, r3, #31 + ORR r11, r3, r11, LSL#1 + ADD r11, r11, r10 + SUB r10, r5, r4 @ + + @SUB r12,r12,r0,lsl #1 + @LDRD r4,[r12] @r4=x0r, r5=x0i + LDR r4, [r12, -r0, lsl #1]! @ + LDR r5, [r12, #4] + + + ADD r4, r8, r4 @x0r = x0r + x2r@ + ADD r5, r9, r5 @x0i = x0i + x2i@ + SUB r8, r4, r8, lsl#1 @x2r = x0r - (x2r << 1)@ + SUB r9, r5, r9, lsl#1 @x2i = x0i - (x2i << 1)@ + ADD r6, r6, r10 @x1r = x1r + x3r@ + SUB r7, r7, r11 @x1i = x1i - x3i@ + SUB r10, r6, r10, lsl#1 @x3r = x1r - (x3r << 1)@ + ADD r11, r7, r11, lsl#1 @x3i = x1i + (x3i << 1)@ + + ADD r4, r4, r6 @x0r = x0r + x1r@ + ADD r5, r5, r7 @x0i = x0i + x1i@ + SUB r6, r4, r6, lsl#1 @x1r = x0r - (x1r << 1)@ + SUB r7, r5, r7, lsl#1 @x1i = x0i - (x1i << 1) + STRD r4, [r12] @r4=x0r, r5=x0i + ADD r12, r12, r0 + ADD r8, r8, r11 @x2r = x2r + x3i@ + SUB r9, r9, r10 @x2i = x2i - x3r@ + SUB r4, r8, r11, lsl#1 @x3i = x2r - (x3i << 1)@ + ADD r5, r9, r10, lsl#1 @x3r = x2i + (x3r << 1) + + STRD r8, [r12] @r8=x2r, r9=x2i + ADD r12, r12, r0 + STRD r6, [r12] @r6=x1r, r7=x1i + ADD r12, r12, r0 + STRD r4, [r12] @r10=x3r, r11=x3i + ADD r12, r12, r0 + + BNE RADIX4_BFLY_4 + MOV r0, r0, ASR #3 + + LDR r1, [sp, #0x2c+4] + LDR r4, [sp, #8+4] + SUB r1, r12, r1, LSL #3 + LDR r6, [sp, #0x1c+4] + ADD r12, r1, #8 + LDR r7, [sp, #0x24+4] + ADD r4, r4, r6 + CMP r4, r7 + BLT SECOND_LOOP_4 + ADD sp, sp, #4 + + LDR r1, [sp, #0x1c] + MOV r0, r0, LSL #2 + MOV r1, r1, ASR #2 + STR r1, [sp, #0x1c] + LDR r1, [sp, #0x18] + MOV r1, r1, ASR #2 + STR r1, [sp, #0x18] + LDR r1, [sp, #0x20] + SUBS r1, r1, #1 + STR r1, [sp, #0x20] + BGT OUTER_LOOP + + LDR r1, [sp, #0x14] + CMP r1, #0 + BEQ EXIT + LDR r12, [sp, #0x1c] + LDR r1, [sp, #0x28] + CMP r12, #0 + LDRNE r12, [sp, #0x1c] + MOVEQ r4, #1 + MOVNE r4, r12, LSL #1 + MOVS r3, r0 + BEQ EXIT + + MOV r3, r3, ASR #1 + LDR r5, [sp, #0x34] + MOV r0, r0, LSL #3 @(del<<1) * 4 + STR r1, [sp, #-4] + +EXIT: + ADD sp, sp, #0x38 + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_mps_synt_out_calc.s b/decoder/armv7/ixheaacd_mps_synt_out_calc.s new file mode 100644 index 0000000..1679ec1 --- /dev/null +++ b/decoder/armv7/ixheaacd_mps_synt_out_calc.s @@ -0,0 +1,55 @@ +@ * limitations under the License. +@ * +@ ***************************************************************************** +@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +@*/ + + +.text +.p2align 2 + + .global ixheaacd_mps_synt_out_calc_armv7 +ixheaacd_mps_synt_out_calc_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + MOV R6, #3 + MUL R7, R0, R6 + ADD R4, R1, R0, LSL #2 + ADD R5, R2, R7, LSL #2 + MOV R6, #5 +LOOP1: + MOV R8, R0 +LOOP2: + VLD2.32 {D4, D5}, [R3]! + VLD1.32 {D0, D1}, [R2]! + VLD1.32 {D2, D3}, [R5]! + VLD2.32 {D6, D7}, [R3]! + + + VMULL.S32 Q4, D0, D4 + VMULL.S32 Q5, D1, D6 + VMULL.S32 Q6, D2, D5 + VMULL.S32 Q7, D3, D7 + VSHRN.S64 D8, Q4, #31 + VSHRN.S64 D9, Q5, #31 + VSHRN.S64 D12, Q6, #31 + VSHRN.S64 D13, Q7, #31 + + + SUBS R8, R8, #4 + VST1.32 {D8, D9}, [R1]! + VST1.32 {D12, D13}, [R4]! + BGT LOOP2 + SUBS R6, R6, #1 + ADD R1, R1, R0, LSL #2 + ADD R4, R4, R0, LSL #2 + ADD R2, R2, R7, LSL #2 + ADD R5, R5, R7, LSL #2 + BGT LOOP1 + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + diff --git a/decoder/armv7/ixheaacd_mps_synt_post_fft_twiddle.s b/decoder/armv7/ixheaacd_mps_synt_post_fft_twiddle.s new file mode 100644 index 0000000..8cccfe3 --- /dev/null +++ b/decoder/armv7/ixheaacd_mps_synt_post_fft_twiddle.s @@ -0,0 +1,65 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_mps_synt_post_fft_twiddle_armv7 +ixheaacd_mps_synt_post_fft_twiddle_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + LDR R4, [SP, #104] + LDR R5, [SP, #108] + + ADD R6, R5, R0, LSL #3 + LSL R7, R0, #1 + MOV R8, #-16 + ADD R6, R6, R8 +LOOP1: + VLD1.32 {D0, D1}, [R1]! + VLD1.32 {D2, D3}, [R2]! + VLD1.32 {D4, D5}, [R3]! + VLD1.32 {D6, D7}, [R4]! + + VMULL.S32 Q4, D0, D4 + VMULL.S32 Q5, D2, D6 + VMULL.S32 Q6, D1, D5 + VMULL.S32 Q7, D3, D7 + + VSHRN.S64 D8, Q4, #31 + VSHRN.S64 D10, Q5, #31 + VSHRN.S64 D12, Q6, #31 + VSHRN.S64 D14, Q7, #31 + + VQADD.S32 D1, D8, D10 + VQADD.S32 D0, D12, D14 + + VREV64.32 D1, D1 + VREV64.32 D0, D0 + + + SUBS R7, R7, #4 + VST1.32 {D0, D1}, [R6], R8 + + BGT LOOP1 + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} diff --git a/decoder/armv7/ixheaacd_mps_synt_post_twiddle.s b/decoder/armv7/ixheaacd_mps_synt_post_twiddle.s new file mode 100644 index 0000000..3c2d8de --- /dev/null +++ b/decoder/armv7/ixheaacd_mps_synt_post_twiddle.s @@ -0,0 +1,60 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_mps_synt_post_twiddle_armv7 + + +ixheaacd_mps_synt_post_twiddle_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + lsl R3, R3, #1 +LOOP1: + VLD2.32 {D13, D14}, [R2]! + VLD2.32 {D15, D16}, [R1]! + VLD2.32 {D2, D3}, [R0] + VNEG.S32 D12, D2 + + VMULL.S32 Q2, D13, D12 + VMULL.S32 Q3, D13, D3 + VMULL.S32 Q4, D15, D2 + VMULL.S32 Q5, D15, D3 + + VSHRN.I64 D4, Q2, #31 + VSHRN.I64 D6, Q3, #31 + VSHRN.I64 D8, Q4, #31 + VSHRN.I64 D10, Q5, #31 + + VQADD.S32 D0, D8, D6 + VQADD.S32 D1, D4, D10 + + SUBS R3, R3, #4 + VST2.32 {D0, D1} , [R0]! + BGT LOOP1 + + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + diff --git a/decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s b/decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s new file mode 100644 index 0000000..63a6b2b --- /dev/null +++ b/decoder/armv7/ixheaacd_mps_synt_pre_twiddle.s @@ -0,0 +1,60 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_mps_synt_pre_twiddle_armv7 + + +ixheaacd_mps_synt_pre_twiddle_armv7: + + STMFD sp!, {r4-r12, r14} + VPUSH {D8-D15} + lsl R3, R3, #1 +LOOP1: + VLD1.32 {D0}, [R2]! + VLD1.32 {D1}, [R1]! + VLD2.32 {D2, D3}, [R0] + VNEG.S32 D12, D2 + + VMULL.S32 Q2, D0, D12 + VMULL.S32 Q3, D0, D3 + VMULL.S32 Q4, D1, D2 + VMULL.S32 Q5, D1, D3 + + VSHRN.I64 D4, Q2, #31 + VSHRN.I64 D6, Q3, #31 + VSHRN.I64 D8, Q4, #31 + VSHRN.I64 D10, Q5, #31 + + VQADD.S32 D0, D8, D6 + VQADD.S32 D1, D4, D10 + + SUBS R3, R3, #4 + VST2.32 {D0, D1} , [R0]! + BGT LOOP1 + + VPOP {D8-D15} + LDMFD sp!, {r4-r12, r15} + + + + diff --git a/decoder/armv7/ixheaacd_no_lap1.s b/decoder/armv7/ixheaacd_no_lap1.s new file mode 100644 index 0000000..2884191 --- /dev/null +++ b/decoder/armv7/ixheaacd_no_lap1.s @@ -0,0 +1,110 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_neg_shift_spec_armv7 + +ixheaacd_neg_shift_spec_armv7: + STMFD sp!, {R4-R12, R14} + VPUSH {D8 - D15} + MOV R5, #448 + SUB R6, R5, #1 + MOV R6, R6, LSL #2 + ADD R6, R6, R0 + MOV R8, #-16 + SUB R6, R6, #12 + MOV R7, R3, LSL #1 + VDUP.32 Q1, R2 + MOV R4, #0x8000 + VDUP.32 Q2, R4 + + VLD1.32 {D0, D1}, [R6], R8 + VQNEG.S32 Q0, Q0 + + + VLD1.32 {D6, D7}, [R6], R8 + VQSHL.S32 Q15, Q0, Q1 + VQADD.S32 Q14, Q15, Q2 + VSHR.S32 Q13, Q14, #16 + VREV64.32 Q13, Q13 + SUB R5, R5, #8 + + VUZP.16 D27, D26 + VQNEG.S32 Q3, Q3 + + +LOOP_1: + + + VST1.16 D27[0], [R1], R7 + VQSHL.S32 Q12, Q3, Q1 + VLD1.32 {D0, D1}, [R6], R8 + VST1.16 D27[1], [R1], R7 + VQADD.S32 Q11, Q12, Q2 + VST1.16 D27[2], [R1], R7 + VQNEG.S32 Q0, Q0 + VST1.16 D27[3], [R1], R7 + VSHR.S32 Q10, Q11, #16 + VREV64.32 Q10, Q10 + SUBS R5, R5, #8 + + + VUZP.16 D21, D20 + VQSHL.S32 Q15, Q0, Q1 + VST1.16 D21[0], [R1], R7 + VLD1.32 {D6, D7}, [R6], R8 + VQADD.S32 Q14, Q15, Q2 + VST1.16 D21[1], [R1], R7 + VSHR.S32 Q13, Q14, #16 + VST1.16 D21[2], [R1], R7 + VREV64.32 Q13, Q13 + VST1.16 D21[3], [R1], R7 + + + VUZP.16 D27, D26 + VQNEG.S32 Q3, Q3 + + + + BGT LOOP_1 + + VST1.16 D27[0], [R1], R7 + VQSHL.S32 Q12, Q3, Q1 + VST1.16 D27[1], [R1], R7 + VST1.16 D27[2], [R1], R7 + VQADD.S32 Q11, Q12, Q2 + VST1.16 D27[3], [R1], R7 + VSHR.S32 Q10, Q11, #16 + + + VREV64.32 Q10, Q10 + + VUZP.16 D21, D20 + + VST1.16 D21[0], [R1], R7 + VST1.16 D21[1], [R1], R7 + VST1.16 D21[2], [R1], R7 + VST1.16 D21[3], [R1], R7 + VPOP {D8 - D15} + LDMFD sp!, {R4-R12, R15} +.end + diff --git a/decoder/armv7/ixheaacd_overlap_add1.s b/decoder/armv7/ixheaacd_overlap_add1.s new file mode 100644 index 0000000..b376470 --- /dev/null +++ b/decoder/armv7/ixheaacd_overlap_add1.s @@ -0,0 +1,297 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + + .global ixheaacd_over_lap_add1_armv7 +ixheaacd_over_lap_add1_armv7: + + STMFD sp!, {R4-R12, R14} + VPUSH {d8 - d15} + + LDR R4, [SP, #104] + LDR R5, [SP, #108] + LDR R6, [SP, #112] + MOV R10, R5, LSL #1 + SUB R11, R10, #1 + MOV R10, R11, LSL #2 + ADD R10, R0, R10 + SUB R10, R10, #12 + MOV R8, R11, LSL #1 + ADD R8, R8, R3 + SUB R8, R8, #14 + MOV R12, #0 + VDUP.S16 D12, R12 + MOV R12, #-16 + VDUP.16 Q11, R4 + VLD1.32 {D6, D7}, [R10], R12 + MOV R7, #0x2000 + VREV64.32 Q3, Q3 + RSB R7, R7, #0 + VQNEG.S32 Q0, Q3 + VDUP.32 Q10, R7 + VUZP.16 D1, D0 + SUB R11, R5, #1 + VUZP.16 D7, D6 + SMULBB R11, R11, R6 + MOV R11, R11, LSL #1 + VLD2.16 {D2, D3}, [R8], R12 + ADD R11, R11, R2 + VREV64.16 Q1, Q1 + MOV R4, R6, LSL #1 + RSB R4, R4, #0 + MOV R9, R6, LSL #1 + SMULBB R6, R5, R6 + MOV R6, R6, LSL #1 + ADD R6, R6, R2 + + + + VMULL.U16 Q15, D7, D2 + VLD1.32 {D4, D5}, [R1]! + VSHR.U32 Q15, Q15, #16 + + VMLAL.S16 Q15, D6, D2 + VQSHL.S32 Q15, Q15, Q11 + + + VADDL.S16 Q7, D3, D12 + + VMULL.S32 Q13, D4, D14 + VQMOVN.S64 D28, Q13 + VMULL.S32 Q13, D5, D15 + VQMOVN.S64 D29, Q13 + + VQADD.S32 Q14, Q14, Q10 + VQSUB.S32 Q13, Q15, Q14 + VQSHL.S32 Q13, Q13, #2 + VSHR.S32 Q13, Q13, #16 + VUZP.16 D26, D27 + + + VMULL.U16 Q12, D1, D3 + VSHR.U32 Q12, Q12, #16 + VMLAL.S16 Q12, D0, D3 + VQSHL.S32 Q12, Q12, Q11 + VLD1.32 {D6, D7}, [R10], R12 + + + VADDL.S16 Q7, D2, D12 + + VMULL.S32 Q0, D14, D4 + VQMOVN.S64 D16, Q0 + VMULL.S32 Q0, D15, D5 + VQMOVN.S64 D17, Q0 + + VREV64.32 Q3, Q3 + VQADD.S32 Q8, Q8, Q10 + VQNEG.S32 Q0, Q3 + VUZP.16 D1, D0 + VQSUB.S32 Q9, Q12, Q8 + VUZP.16 D7, D6 + VQSHL.S32 Q9, Q9, #2 + VLD2.16 {D2, D3}, [R8], R12 + VSHR.S32 Q9, Q9, #16 + VREV64.16 Q1, Q1 + VUZP.16 D18, D19 + + VLD1.32 {D4, D5}, [R1]! + SUB R5, R5, #8 + + +LOOP_1: + + VST1.16 D26[0], [R11], R4 + VMULL.U16 Q15, D7, D2 + VST1.16 D26[1], [R11], R4 + VMULL.U16 Q12, D1, D3 + VST1.16 D26[2], [R11], R4 + VSHR.U32 Q15, Q15, #16 + VST1.16 D26[3], [R11], R4 + VSHR.U32 Q12, Q12, #16 + VST1.16 D18[0], [R6], R9 + VMLAL.S16 Q15, D6, D2 + VST1.16 D18[1], [R6], R9 + VMLAL.S16 Q12, D0, D3 + VST1.16 D18[2], [R6], R9 + VQSHL.S32 Q15, Q15, Q11 + VST1.16 D18[3], [R6], R9 + VQSHL.S32 Q12, Q12, Q11 + VLD1.32 {D6, D7}, [R10], R12 + + + VADDL.S16 Q7, D3, D12 + + VMULL.S32 Q8, D4, D14 + VQMOVN.S64 D28, Q8 + VMULL.S32 Q8, D5, D15 + VQMOVN.S64 D29, Q8 + VREV64.32 Q3, Q3 + + + + VADDL.S16 Q7, D2, D12 + + VMULL.S32 Q0, D4, D14 + VQMOVN.S64 D16, Q0 + VMULL.S32 Q0, D5, D15 + VQMOVN.S64 D17, Q0 + + VLD2.16 {D2, D3}, [R8], R12 + VQNEG.S32 Q0, Q3 + VLD1.32 {D4, D5}, [R1]! + VQADD.S32 Q14, Q14, Q10 + VUZP.16 D1, D0 + VQADD.S32 Q8, Q8, Q10 + VUZP.16 D7, D6 + VQSUB.S32 Q13, Q15, Q14 + VREV64.16 Q1, Q1 + VQSUB.S32 Q9, Q12, Q8 + VQSHL.S32 Q13, Q13, #2 + VQSHL.S32 Q9, Q9, #2 + VMULL.U16 Q15, D7, D2 + VSHR.S32 Q13, Q13, #16 + VUZP.16 D26, D27 + VSHR.S32 Q9, Q9, #16 + VST1.16 D26[0], [R11], R4 + VMULL.U16 Q12, D1, D3 + VUZP.16 D18, D19 + VSHR.U32 Q15, Q15, #16 + VST1.16 D26[1], [R11], R4 + VMLAL.S16 Q15, D6, D2 @MLA + VST1.16 D26[2], [R11], R4 + VSHR.U32 Q12, Q12, #16 + VST1.16 D26[3], [R11], R4 + VMLAL.S16 Q12, D0, D3 @MLA + VST1.16 D18[0], [R6], R9 + VQSHL.S32 Q15, Q15, Q11 + VST1.16 D18[1], [R6], R9 + VQSHL.S32 Q12, Q12, Q11 + VST1.16 D18[2], [R6], R9 + + + VADDL.S16 Q7, D3, D12 + + VMULL.S32 Q8, D4, D14 + VQMOVN.S64 D28, Q8 + VMULL.S32 Q8, D5, D15 + VQMOVN.S64 D29, Q8 + + VST1.16 D18[3], [R6], R9 + + + VADDL.S16 Q7, D2, D12 + + VMULL.S32 Q0, D4, D14 + VQMOVN.S64 D16, Q0 + VMULL.S32 Q0, D5, D15 + VQMOVN.S64 D17, Q0 + + VLD1.32 {D6, D7}, [R10], R12 + VQADD.S32 Q14, Q14, Q10 + VREV64.32 Q3, Q3 + VQNEG.S32 Q0, Q3 + VUZP.16 D1, D0 + VQSUB.S32 Q13, Q15, Q14 + VUZP.16 D7, D6 + VQADD.S32 Q8, Q8, Q10 + VLD2.16 {D2, D3}, [R8], R12 + VQSUB.S32 Q9, Q12, Q8 + VREV64.16 Q1, Q1 + VQSHL.S32 Q13, Q13, #2 + VLD1.32 {D4, D5}, [R1]! + VQSHL.S32 Q9, Q9, #2 + VSHR.S32 Q13, Q13, #16 + SUBS R5, R5, #8 + VSHR.S32 Q9, Q9, #16 + VUZP.16 D26, D27 + VUZP.16 D18, D19 + + + + BGT LOOP_1 + + VST1.16 D26[0], [R11], R4 + VMULL.U16 Q15, D7, D2 + VST1.16 D26[1], [R11], R4 + VMULL.U16 Q12, D1, D3 + VST1.16 D26[2], [R11], R4 + VSHR.U32 Q15, Q15, #16 + VST1.16 D26[3], [R11], R4 + VSHR.U32 Q12, Q12, #16 + + VST1.16 D18[0], [R6], R9 + VMLAL.S16 Q15, D6, D2 + VST1.16 D18[1], [R6], R9 + VMLAL.S16 Q12, D0, D3 + VST1.16 D18[2], [R6], R9 + VQSHL.S32 Q15, Q15, Q11 + VST1.16 D18[3], [R6], R9 + VQSHL.S32 Q12, Q12, Q11 + + + + + VADDL.S16 Q7, D3, D12 + + VMULL.S32 Q8, D4, D14 + VQMOVN.S64 D28, Q8 + VMULL.S32 Q8, D5, D15 + VQMOVN.S64 D29, Q8 + + + + VADDL.S16 Q7, D2, D12 + + VMULL.S32 Q13, D4, D14 + VQMOVN.S64 D16, Q13 + VMULL.S32 Q13, D5, D15 + VQMOVN.S64 D17, Q13 + + VQADD.S32 Q14, Q14, Q10 + VQADD.S32 Q8, Q8, Q10 + VQSUB.S32 Q13, Q15, Q14 + VQSUB.S32 Q9, Q12, Q8 + VQSHL.S32 Q13, Q13, #2 + VQSHL.S32 Q9, Q9, #2 + VSHR.S32 Q13, Q13, #16 + VSHR.S32 Q9, Q9, #16 + VUZP.16 D26, D27 + + VUZP.16 D18, D19 + + + + VST1.16 D26[0], [R11], R4 + VST1.16 D26[1], [R11], R4 + VST1.16 D26[2], [R11], R4 + VST1.16 D26[3], [R11], R4 + + VST1.16 D18[0], [R6], R9 + VST1.16 D18[1], [R6], R9 + VST1.16 D18[2], [R6], R9 + VST1.16 D18[3], [R6], R9 + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12, R15} + diff --git a/decoder/armv7/ixheaacd_overlap_add2.s b/decoder/armv7/ixheaacd_overlap_add2.s new file mode 100644 index 0000000..2d0715e --- /dev/null +++ b/decoder/armv7/ixheaacd_overlap_add2.s @@ -0,0 +1,268 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_over_lap_add2_armv7 + +ixheaacd_over_lap_add2_armv7: + + STMFD sp!, {R4-R12, R14} + VPUSH {d8 - d15} + + LDR R4, [SP, #104] + LDR R5, [SP, #108] + LDR R6, [SP, #112] + RSB R4, R4, #15 + CMP R4, #31 + MOVGT R4, #31 + SUB R9, R4, #1 + MOV R8, #1 + MOV R8, R8, LSL R9 + RSB R4, R4, #0 + VDUP.32 Q11, R4 + VDUP.32 Q10, R8 + MOV R8, R5 + SUB R12, R5, #1 + MOV R9, R5, LSL #2 + MOV R12, R12, LSL #2 + ADD R10, R0, R9 + ADD R7, R1, R12 + VLD2.16 {D0, D1}, [R10]! + MOV R11, R6, LSL #2 + SUB R7, R7, #12 + ADD R4, R4, #1 + MOV R12, #-16 + VLD2.16 {D6, D7}, [R7], R12 + MOV R4, #0x8000 + VREV64.16 D4, D6 + VREV64.16 D5, D7 + MOV R4, R3 + + MOV R9, R2 + VLD2.16 {D2, D3}, [R3]! + + VMULL.U16 Q13, D0, D2 + VMLSL.U16 Q13, D4, D3 + VLD2.16 {D8, D9}, [R10]! + VSHR.S32 Q13, Q13, #16 + VLD2.16 {D10, D11}, [R3]! + VMLAL.S16 Q13, D1, D2 + VMLSL.S16 Q13, D5, D3 + VLD2.16 {D14, D15}, [R7], R12 + VREV64.16 Q6, Q7 + VQADD.S32 Q12, Q13, Q10 + VQSHL.S32 Q12, Q12, Q11 + SUB R8, R8, #8 + + +LOOP_1: + + VLD2.16 {D0, D1}, [R10]! + VMULL.U16 Q9, D8, D10 + VLD2.16 {D2, D3}, [R3]! + VMLSL.U16 Q9, D12, D11 + VLD2.16 {D6, D7}, [R7], R12 + VMULL.U16 Q13, D0, D2 + VREV64.16 D4, D6 + VMLSL.U16 Q13, D4, D3 + VREV64.16 D5, D7 + VSHR.S32 Q9, Q9, #16 + VST1.32 {D24[0]}, [R2], R11 + VMLAL.S16 Q9, D9, D10 + VST1.32 {D24[1]}, [R2], R11 + VSHR.S32 Q13, Q13, #16 + VST1.32 {D25[0]}, [R2], R11 + VMLAL.S16 Q13, D1, D2 + + VST1.32 {D25[1]}, [R2], R11 + VMLSL.S16 Q9, D13, D11 + VMLSL.S16 Q13, D5, D3 + + VLD2.16 {D8, D9}, [R10]! + VLD2.16 {D10, D11}, [R3]! + + + VLD2.16 {D14, D15}, [R7], R12 + VQADD.S32 Q8, Q9, Q10 + VREV64.16 Q6, Q7 + VQADD.S32 Q12, Q13, Q10 + VQSHL.S32 Q8, Q8, Q11 + VST1.32 D16[0], [R2], R11 + VQSHL.S32 Q12, Q12, Q11 + + + SUBS R8, R8, #8 + + VST1.32 D16[1], [R2], R11 + VST1.32 D17[0], [R2], R11 + VST1.32 D17[1], [R2], R11 + + + BGT LOOP_1 + + + VST1.32 D24[0], [R2], R11 + VMULL.U16 Q9, D8, D10 + VMLSL.U16 Q9, D12, D11 + VST1.32 D24[1], [R2], R11 + VST1.32 D25[0], [R2], R11 + VSHR.S32 Q9, Q9, #16 + VST1.32 D25[1], [R2], R11 + VMLAL.S16 Q9, D9, D10 + VMLSL.S16 Q9, D13, D11 + MOV R12, #12 + SMULBB R7, R5, R6 + MOV R10, R5, LSL #1 + VQADD.S32 Q8, Q9, Q10 + VQSHL.S32 Q8, Q8, Q11 + + VST1.32 D16[0], [R2], R11 + MOV R7, R7, LSL #2 + + VST1.32 D16[1], [R2], R11 + ADD R7, R7, R9 + + VST1.32 D17[0], [R2], R11 + VST1.32 D17[1], [R2], R11 + + SUB R11, R10, #1 + MOV R10, R11, LSL #2 + ADD R10, R0, R10 + MOV R11, R11, LSL #1 + SUB R10, R10, R12 + MOV R8, R6, LSL #2 + MOV R12, #-16 + ADD R11, R11, R4 + + VLD1.32 {D6, D7}, [R10], R12 + SUB R11, R11, #14 + + + VREV64.32 D0, D6 + VREV64.32 D1, D7 + VQNEG.S32 D0, D0 + VQNEG.S32 D1, D1 + VUZP.16 D1, D0 + VLD2.16 {D2, D3}, [R11], R12 + VREV64.16 D2, D2 + VREV64.16 D3, D3 + + VLD2.16 {D4, D5}, [R1]! + + VMULL.U16 Q13, D1, D3 + VMLSL.U16 Q13, D4, D2 + VSHR.S32 Q13, Q13, #16 + VMLAL.S16 Q13, D0, D3 + VMLSL.S16 Q13, D5, D2 + @VQSHL.S32 Q12,Q13,Q11 + @VQADD.S32 Q12,Q12,Q10 + @VSHR.S32 Q12,Q12,#16 + VQADD.S32 Q12, Q13, Q10 + VQSHL.S32 Q12, Q12, Q11 + VUZP.16 D24, D25 + + + VLD1.32 {D14, D15}, [R10], R12 + VMULL.U16 Q13, D1, D3 + VMLSL.U16 Q13, D4, D2 + VREV64.32 Q4, Q7 + VQNEG.S32 Q4, Q4 + VLD2.16 {D10, D11}, [R11], R12 + VSHR.S32 Q13, Q13, #16 + VLD2.16 {D12, D13}, [R1]! + VMLAL.S16 Q13, D0, D3 + VMLSL.S16 Q13, D5, D2 + VUZP.16 D9, D8 + VREV64.16 Q5, Q5 + VQADD.S32 Q12, Q13, Q10 + SUB R5, R5, #8 + VQSHL.S32 Q12, Q12, Q11 + + + + + +LOOP_2: + + + VLD1.32 {D6, D7}, [R10], R12 + VMULL.U16 Q9, D9, D11 + VREV64.32 Q0, Q3 + VQNEG.S32 Q0, Q0 + VUZP.16 D1, D0 + VLD2.16 {D2, D3}, [R11], R12 + VREV64.16 Q1, Q1 + + VLD2.16 {D4, D5}, [R1]! + VMLSL.U16 Q9, D12, D10 + VST1.32 D24[0], [R7], R8 + VMULL.U16 Q13, D1, D3 + VST1.32 D24[1], [R7], R8 + VSHR.S32 Q9, Q9, #16 + VST1.32 D25[0], [R7], R8 + VMLSL.U16 Q13, D4, D2 + VST1.32 D25[1], [R7], R8 + VMLAL.S16 Q9, D8, D11 + VLD1.32 {D14, D15}, [R10], R12 + VSHR.S32 Q13, Q13, #16 + VMLSL.S16 Q9, D13, D10 + VLD2.16 {D10, D11}, [R11], R12 + VMLAL.S16 Q13, D0, D3 + VMLSL.S16 Q13, D5, D2 + VREV64.32 Q4, Q7 + VLD2.16 {D12, D13}, [R1]! + VQNEG.S32 Q4, Q4 + VREV64.16 Q5, Q5 + VQADD.S32 Q8, Q9, Q10 + VUZP.16 D9, D8 + VQADD.S32 Q12, Q13, Q10 + VQSHL.S32 Q8, Q8, Q11 + SUBS R5, R5, #8 + VST1.32 D16[0], [R7], R8 + VQSHL.S32 Q12, Q12, Q11 + VST1.32 D16[1], [R7], R8 + + VST1.32 D17[0], [R7], R8 + VST1.32 D17[1], [R7], R8 + + BGT LOOP_2 + + VST1.32 D24[0], [R7], R8 + VMULL.U16 Q9, D9, D11 + VMLSL.U16 Q9, D12, D10 + VST1.32 D24[1], [R7], R8 + VST1.32 D25[0], [R7], R8 + VSHR.S32 Q9, Q9, #16 + VST1.32 D25[1], [R7], R8 + + VMLAL.S16 Q9, D8, D11 + VMLSL.S16 Q9, D13, D10 + VQADD.S32 Q8, Q9, Q10 + VQSHL.S32 Q8, Q8, Q11 + + VST1.32 D16[0], [R7], R8 + VST1.32 D16[1], [R7], R8 + VST1.32 D17[0], [R7], R8 + VST1.32 D17[1], [R7], R8 + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12, R15} diff --git a/decoder/armv7/ixheaacd_post_radix_compute2.s b/decoder/armv7/ixheaacd_post_radix_compute2.s new file mode 100644 index 0000000..39280b3 --- /dev/null +++ b/decoder/armv7/ixheaacd_post_radix_compute2.s @@ -0,0 +1,144 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_postradixcompute2 + + +ixheaacd_postradixcompute2: + + STMFD sp!, {r4-r12, r14} + + SUB sp, sp, #20 + + + + + + + + + + + + + STR r0, [sp, #16] + + + ADD r4, r1, r3, lsl #1 + MOV r3, r3, asr #4 + STR r3, [sp, #4] + MOV r5, #1 + STR r5, [sp] + +POSTRADIX2_START: + + LDR r14, [r2] + + LDMIA r1!, {r5-r12} + ADD r0, r0, r14 + + ADD r14, r5, r7 + SUB r5, r5, r7 + + ADD r7, r9, r11 + SUB r9, r9, r11 + + ADD r11, r6, r8 + SUB r6, r6, r8 + + ADD r8, r10, r12 + SUB r10, r10, r12 + + STR r14, [r0], #4 + STR r11, [r0], #32-4 + + STR r7, [r0], #4 + STR r8, [r0], #(32+(32<<1))-4 + + STR r5, [r0], #4 + STR r6, [r0], #32-4 + + STR r9, [r0], #4 + STR r10, [r0], #0 + + LDR r0, [sp, #16] + + LDR r14, [r2], #4 + + LDMIA r4!, {r5-r12} + + ADD r0, r0, r14 + + + ADD r0, r0, #8 + + ADD r14, r5, r7 + SUB r5, r5, r7 + + ADD r7, r9, r11 + SUB r9, r9, r11 + + ADD r11, r6, r8 + SUB r6, r6, r8 + + ADD r8, r10, r12 + SUB r10, r10, r12 + + STR r14, [r0], #4 + STR r11, [r0], #32-4 + + STR r7, [r0], #4 + STR r8, [r0], #(32+(32<<1))-4 + + STR r5, [r0], #4 + STR r6, [r0], #32-4 + + + STR r9, [r0], #4 + STR r10, [r0], #0 + + SUBS r3, r3, #1 + + + LDR r0, [sp, #16] + BGT POSTRADIX2_START + + LDR r0, [sp, #16] + + LDR r3, [sp, #4] + LDR r6, [sp] + + ADD r1, r1, r3, lsl #5 + ADD r4, r4, r3, lsl #5 + + SUBS r6, r6, #1 + STR r6, [sp] + + + BPL POSTRADIX2_START + + + ADD sp, sp, #20 + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_post_radix_compute4.s b/decoder/armv7/ixheaacd_post_radix_compute4.s new file mode 100644 index 0000000..8977213 --- /dev/null +++ b/decoder/armv7/ixheaacd_post_radix_compute4.s @@ -0,0 +1,138 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_postradixcompute4 + + +ixheaacd_postradixcompute4: + + STMFD sp!, {r4-r12, r14} + + + + + + + + + + + + + ADD r4, r1, r3, lsl #1 + MOV r3, #2 + + +POSTRADIX4_START: + + LDMIA r1!, {r5-r12} + + ADD r14, r5, r9 + SUB r5, r5, r9 + + ADD r9, r6, r10 + SUB r6, r6, r10 + + ADD r10, r7, r11 + SUB r7, r7, r11 + + ADD r11, r8, r12 + SUB r8, r8, r12 + + ADD r12, r14, r10 + SUB r14, r14, r10 + + ADD r10, r9, r11 + SUB r9, r9, r11 + + ADD r11, r5, r8 + SUB r5, r5, r8 + + ADD r8, r6, r7 + SUB r6, r6, r7 + + + STR r12, [r0], #4 + STR r10, [r0], #14<<1 + + STR r11, [r0], #4 + STR r6 , [r0], #14<<1 + + STR r14, [r0], #4 + STR r9 , [r0], #14<<1 + + STR r5, [r0], #4 + STR r8, [r0], #0 + + LDMIA r4!, {r5-r12} + SUB r0, r0, #92 + + + ADD r14, r5, r9 + SUB r5, r5, r9 + + ADD r9, r6, r10 + SUB r6, r6, r10 + + ADD r10, r7, r11 + SUB r7, r7, r11 + + ADD r11, r8, r12 + SUB r8, r8, r12 + + ADD r12, r14, r10 + SUB r14, r14, r10 + + ADD r10, r9, r11 + SUB r9, r9, r11 + + ADD r11, r5, r8 + SUB r5, r5, r8 + + ADD r8, r6, r7 + SUB r6, r6, r7 + + STR r12, [r0], #4 + STR r10, [r0], #14<<1 + + STR r11, [r0], #4 + STR r6, [r0], #14<<1 + + STR r14, [r0], #4 + STR r9, [r0], #14<<1 + + + STR r5, [r0], #4 + STR r8, [r0], #0 + + ADD r1, r1, #1 << 5 + ADD r4, r4, #1 << 5 + SUB r0, r0, #100-8 + + SUBS r3, r3, #1 + + BGT POSTRADIX4_START + + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_post_twiddle.s b/decoder/armv7/ixheaacd_post_twiddle.s new file mode 100644 index 0000000..79144da --- /dev/null +++ b/decoder/armv7/ixheaacd_post_twiddle.s @@ -0,0 +1,545 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_post_twiddle_armv7 + +ixheaacd_post_twiddle_armv7: + + STMFD sp!, {R4-R12} + VPUSH {d8 - d15} + LDR R4, [sp, #100] + +ARM_PROLOGUE: + + CMP R3, #0x400 + LDR R6, =7500 + ADD R2, R2, R6 + BLT NEXT + MOV R4, #50 + MOV R5, #-50 + MOV R6, #4 + VDUP.16 D10, R4 + + B NEXT1 + +NEXT: + LDR R4, =0x192 + LDR R5, =0xfe6e + MOV R6, #32 + VDUP.16 D10, R4 + +NEXT1: + LDR R7, [R1], #4 + LDR R8, [R1], #4 + LDR R9, [R2] + ADD R2, R2, R6 + + SMULWT R11, R8, R9 + SMULWB R10, R8, R9 + SMULWT R12, R7, R9 + SMLAWB R8, R7, R9, R11 + + SUB R10, R10, R12 + + MVN R8, R8 + ADD R8, R8, #1 + + SMLAWB R9, R10, R5, R8 + SMLAWB R11, R8, R4, R10 + + LSL R7, R3, #2 + ADD R7, R0, R7 + SUB R7, R7, #4 + + STR R11, [R7], #-4 + STR R9, [R0], #4 + + LSL R5, R3, #2 + ADD R5, R1, R5 + SUB R5, R5, #40 + + SUB R3, R3, #1 + ASR R3, R3, #4 + + + SUB R7, R7, #28 + + + + + + + + + + + + + MOV R8, #-32 + +NEON_PROLOGUE: + + VLD4.16 {D0, D1, D2, D3}, [R5], R8 + VLD4.16 {D4, D5, D6, D7}, [R1]! + + VLD2.16 {D8[0], D9[0]}, [R2], R6 + VLD2.16 {D8[1], D9[1]}, [R2], R6 + VLD2.16 {D8[2], D9[2]}, [R2], R6 + VLD2.16 {D8[3], D9[3]}, [R2], R6 + + VREV64.16 Q6, Q4 + + VMULL.U16 Q15, D2, D13 + VMULL.U16 Q14, D0, D13 + VMULL.U16 Q13, D2, D12 + VMULL.U16 Q12, D0, D12 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D13 + VMLAL.S16 Q14, D1, D13 + VMLAL.S16 Q13, D3, D12 + VMLAL.S16 Q12, D1, D12 + + VMULL.U16 Q11, D6, D9 + VMULL.U16 Q10, D4, D9 + + + VADD.I32 Q14, Q14, Q13 + VSUB.I32 Q15, Q15, Q12 + VNEG.S32 Q14, Q14 + + VMULL.U16 Q9, D6, D8 + VMULL.U16 Q8, D4, D8 + + VMOV Q13, Q15 + VSHR.U32 Q11, Q11, #16 + + VMOV Q12, Q14 + VSHR.U32 Q10, Q10, #16 + + VUZP.16 D26, D27 + VSHR.U32 Q9, Q9, #16 + + VUZP.16 D24, D25 + VSHR.U32 Q8, Q8, #16 + + + VMLAL.S16 Q11, D7, D9 + VMLAL.S16 Q10, D5, D9 + VMLAL.S16 Q9, D7, D8 + VMLAL.S16 Q8, D5, D8 + + VLD2.16 {D8[0], D9[0]}, [R2], R6 + VMULL.U16 Q0, D26, D10 + + VLD2.16 {D8[1], D9[1]}, [R2], R6 + VMULL.U16 Q1, D24, D10 + + VLD2.16 {D8[2], D9[2]}, [R2], R6 + VADD.I32 Q11, Q11, Q8 + + VLD2.16 {D8[3], D9[3]}, [R2], R6 + VSUB.I32 Q10, Q9, Q10 + + VREV64.16 Q6, Q4 + VNEG.S32 Q11, Q11 + + + VMOV Q9, Q11 + VSHR.U32 Q0, Q0, #16 + + VMOV Q8, Q10 + VSHR.U32 Q1, Q1, #16 + + VUZP.16 D18, D19 + VMLAL.S16 Q0, D27, D10 + + VUZP.16 D16, D17 + VMLAL.S16 Q1, D25, D10 + + VMULL.U16 Q2, D18, D10 + VMULL.U16 Q3, D16, D10 + + VNEG.S32 Q0, Q0 + VADD.I32 Q7, Q15, Q1 + VADD.I32 Q13, Q14, Q0 + + VREV64.32 Q7, Q7 + VSHR.U32 Q2, Q2, #16 + + VSWP D14, D15 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D19, D10 + VLD4.16 {D0, D1, D2, D3}, [R5], R8 + VMLAL.S16 Q3, D17, D10 + SUB R3, R3, #2 + + VADD.I32 Q12, Q10, Q2 + + VREV64.32 Q12, Q12 + VNEG.S32 Q8, Q3 + + VLD4.16 {D4, D5, D6, D7}, [R1]! + + VSWP D24, D25 + VADD.I32 Q8, Q11, Q8 + + + + +CORE_LOOP: + VMULL.U16 Q15, D2, D13 + VST2.32 {Q12, Q13}, [R7], R8 + VMULL.U16 Q14, D0, D13 + + VMULL.U16 Q13, D2, D12 + VST2.32 {Q7, Q8}, [R0]! + VMULL.U16 Q12, D0, D12 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D13 + VMLAL.S16 Q14, D1, D13 + VMLAL.S16 Q13, D3, D12 + VMLAL.S16 Q12, D1, D12 + + VMULL.U16 Q11, D6, D9 + VMULL.U16 Q10, D4, D9 + + + VADD.I32 Q14, Q14, Q13 + VSUB.I32 Q15, Q15, Q12 + VNEG.S32 Q14, Q14 + + VMULL.U16 Q9, D6, D8 + VMULL.U16 Q8, D4, D8 + + + VMOV Q13, Q15 + VSHR.U32 Q11, Q11, #16 + + VMOV Q12, Q14 + VSHR.U32 Q10, Q10, #16 + + VUZP.16 D26, D27 + VSHR.U32 Q9, Q9, #16 + + VUZP.16 D24, D25 + VSHR.U32 Q8, Q8, #16 + + + VMLAL.S16 Q11, D7, D9 + VMLAL.S16 Q10, D5, D9 + VMLAL.S16 Q9, D7, D8 + VMLAL.S16 Q8, D5, D8 + + VLD2.16 {D8[0], D9[0]}, [R2], R6 + VMULL.U16 Q0, D26, D10 + + VLD2.16 {D8[1], D9[1]}, [R2], R6 + VMULL.U16 Q1, D24, D10 + + VLD2.16 {D8[2], D9[2]}, [R2], R6 + VADD.I32 Q11, Q11, Q8 + + VLD2.16 {D8[3], D9[3]}, [R2], R6 + VSUB.I32 Q10, Q9, Q10 + + VREV64.16 Q6, Q4 + VNEG.S32 Q11, Q11 + + + VMOV Q9, Q11 + VSHR.U32 Q0, Q0, #16 + + VMOV Q8, Q10 + VSHR.U32 Q1, Q1, #16 + + VUZP.16 D18, D19 + VMLAL.S16 Q0, D27, D10 + + VUZP.16 D16, D17 + VMLAL.S16 Q1, D25, D10 + + VMULL.U16 Q2, D18, D10 + VMULL.U16 Q3, D16, D10 + + VNEG.S32 Q0, Q0 + VADD.I32 Q7, Q15, Q1 + VADD.I32 Q13, Q14, Q0 + + VREV64.32 Q7, Q7 + VSHR.U32 Q2, Q2, #16 + + VSWP D14, D15 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D19, D10 + VLD4.16 {D0, D1, D2, D3}, [R5], R8 + VMLAL.S16 Q3, D17, D10 + + VADD.I32 Q12, Q10, Q2 + VREV64.32 Q12, Q12 + VNEG.S32 Q8, Q3 + + VLD4.16 {D4, D5, D6, D7}, [R1]! + VSWP D24, D25 + VADD.I32 Q8, Q11, Q8 + + SUBS R3, R3, #1 + BNE CORE_LOOP + + + + +NEON_EPILOGUE: + VMULL.U16 Q15, D2, D13 + VST2.32 {Q12, Q13}, [R7], R8 + VMULL.U16 Q14, D0, D13 + + VMULL.U16 Q13, D2, D12 + VST2.32 {Q7, Q8}, [R0]! + VMULL.U16 Q12, D0, D12 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D13 + VMLAL.S16 Q14, D1, D13 + VMLAL.S16 Q13, D3, D12 + VMLAL.S16 Q12, D1, D12 + + VMULL.U16 Q11, D6, D9 + VMULL.U16 Q10, D4, D9 + + + VADD.I32 Q14, Q14, Q13 + VSUB.I32 Q15, Q15, Q12 + VNEG.S32 Q14, Q14 + + VMULL.U16 Q9, D6, D8 + VMULL.U16 Q8, D4, D8 + + + VMOV Q13, Q15 + VSHR.U32 Q11, Q11, #16 + + VMOV Q12, Q14 + VSHR.U32 Q10, Q10, #16 + + VUZP.16 D26, D27 + VSHR.U32 Q9, Q9, #16 + + VUZP.16 D24, D25 + VSHR.U32 Q8, Q8, #16 + + + VMLAL.S16 Q11, D7, D9 + VMLAL.S16 Q10, D5, D9 + VMLAL.S16 Q9, D7, D8 + VMLAL.S16 Q8, D5, D8 + + VMULL.U16 Q0, D26, D10 + VMULL.U16 Q1, D24, D10 + + VADD.I32 Q11, Q11, Q8 + VSUB.I32 Q10, Q9, Q10 + VNEG.S32 Q11, Q11 + + + VMOV Q9, Q11 + VSHR.U32 Q0, Q0, #16 + + VMOV Q8, Q10 + VSHR.U32 Q1, Q1, #16 + + VUZP.16 D18, D19 + VMLAL.S16 Q0, D27, D10 + + VUZP.16 D16, D17 + VMLAL.S16 Q1, D25, D10 + + VMULL.U16 Q2, D18, D10 + VMULL.U16 Q3, D16, D10 + + VNEG.S32 Q0, Q0 + VADD.I32 Q7, Q15, Q1 + VADD.I32 Q13, Q14, Q0 + + VREV64.32 Q7, Q7 + VSHR.U32 Q2, Q2, #16 + + VSWP D14, D15 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D19, D10 + VMLAL.S16 Q3, D17, D10 + + VADD.I32 Q12, Q10, Q2 + + VREV64.32 Q12, Q12 + VNEG.S32 Q8, Q3 + + VSWP D24, D25 + VADD.I32 Q8, Q11, Q8 + + + VST2.32 {Q7, Q8}, [R0]! + VST2.32 {Q12, Q13}, [R7], R8 + + + + VLD4.16 {D0, D1, D2, D3}, [R5], R8 + + VMOV.S32 D5, #0x00000000 + VMOV.S32 D7, #0x00000000 + + VLD2.32 {D4, D6}, [R1]! + VLD2.32 {D5[0], D7[0]}, [R1] + + VLD2.16 {D8[0], D9[0]}, [R2], R6 + VLD2.16 {D8[1], D9[1]}, [R2], R6 + VLD2.16 {D8[2], D9[2]}, [R2], R6 + VLD2.16 {D8[3], D9[3]}, [R2], R6 + + VREV64.16 Q6, Q4 + + VUZP.16 D4, D5 + VUZP.16 D6, D7 + + VMULL.U16 Q15, D2, D13 + VMULL.U16 Q14, D0, D13 + + VMULL.U16 Q13, D2, D12 + VMULL.U16 Q12, D0, D12 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D13 + VMLAL.S16 Q14, D1, D13 + VMLAL.S16 Q13, D3, D12 + VMLAL.S16 Q12, D1, D12 + + VMULL.U16 Q11, D6, D9 + VMULL.U16 Q10, D4, D9 + + + VADD.I32 Q14, Q14, Q13 + VSUB.I32 Q15, Q15, Q12 + VNEG.S32 Q14, Q14 + + VMULL.U16 Q9, D6, D8 + VMULL.U16 Q8, D4, D8 + + + VMOV Q13, Q15 + VSHR.U32 Q11, Q11, #16 + + VMOV Q12, Q14 + VSHR.U32 Q10, Q10, #16 + + VUZP.16 D26, D27 + VSHR.U32 Q9, Q9, #16 + + VUZP.16 D24, D25 + VSHR.U32 Q8, Q8, #16 + + + VMLAL.S16 Q11, D7, D9 + VMLAL.S16 Q10, D5, D9 + VMLAL.S16 Q9, D7, D8 + VMLAL.S16 Q8, D5, D8 + + + VMULL.U16 Q0, D26, D10 + VMULL.U16 Q1, D24, D10 + + + VADD.I32 Q11, Q11, Q8 + VSUB.I32 Q10, Q9, Q10 + VNEG.S32 Q11, Q11 + + + VMOV Q9, Q11 + VSHR.U32 Q0, Q0, #16 + + VMOV Q8, Q10 + VSHR.U32 Q1, Q1, #16 + + VUZP.16 D18, D19 + VMLAL.S16 Q0, D27, D10 + + VUZP.16 D16, D17 + VMLAL.S16 Q1, D25, D10 + + VMULL.U16 Q2, D18, D10 + VMULL.U16 Q3, D16, D10 + + VNEG.S32 Q0, Q0 + VADD.I32 Q7, Q15, Q1 + VADD.I32 Q13, Q14, Q0 + + VREV64.32 Q7, Q7 + VSHR.U32 Q2, Q2, #16 + + VSWP D14, D15 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D19, D10 + + VMLAL.S16 Q3, D17, D10 + + VADD.I32 Q12, Q10, Q2 + + VREV64.32 Q12, Q12 + VNEG.S32 Q8, Q3 + + VSWP D24, D25 + VADD.I32 Q8, Q11, Q8 + + VST2.32 {D14, D16}, [R0]! + VST2.32 {D15[0], D17[0]}, [R0]! + VST1.32 D15[1], [R0] + + ADD R7, R7, #4 + + VST1.32 D26[0], [R7]! + VST2.32 {D24[1], D26[1]}, [R7]! + VST2.32 {D25, D27}, [R7] + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12} + BX LR diff --git a/decoder/armv7/ixheaacd_post_twiddle_overlap.s b/decoder/armv7/ixheaacd_post_twiddle_overlap.s new file mode 100644 index 0000000..f04f3fc --- /dev/null +++ b/decoder/armv7/ixheaacd_post_twiddle_overlap.s @@ -0,0 +1,1277 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_post_twid_overlap_add_armv7 + +ixheaacd_post_twid_overlap_add_armv7: + + STMFD sp!, {R4-R12} + VPUSH {d8 - d15} + + LDR R4, [sp, #100] + LDR R5, [sp, #104] + LDR R6, [sp, #108] + + LSL R9, R3, #2 + ASR R9, R9, #1 + ADD R6, R6, R9 + SUB R6, R6, #4 + + LDR R8, =7500 + ADD R2, R2, R8 + + + + VMOV.S16 D18, #50 + RSB R9, R5, #15 + VMOV.S32 Q10, #0x00008000 + VDUP.32 Q8, R5 + SUB R5, R5, #16 + STR R5, [sp, #116] + MOV R8, #1 + LSL R8, R8, R9 + STR R8, [sp, #120] + + +ARM_PROLOGUE: + + + LDR R8, [R1], #4 + LDR R9, [R1], #4 + + LDR R10, [R2], #4 + + SMULWT R11, R8, R10 + SMULWB R12, R9, R10 + SMULWB R5, R8, R10 + SMLAWT R7, R9, R10, R5 + SUB R8, R12, R11 + MVN R5, R7 + ADD R5, R5, #1 + + MOV R9, #50 + MOV R12, #-50 + SMULWB R10, R5, R9 + SMULWB R11, R8, R12 + + ADD R8, R8, R10 + ADD R5, R5, R11 + + LDR R11, [sp, #104] + LDR R10, [R6], #-32 + + + SMULWB R7, R8, R10 + MVN R8, R8 + ADD R8, R8, #1 + SMULWT R12, R8, R10 + + CMP R11, #0 + BLT NEXT + + RSBS R9, R11, #16 + + + + + LDR R8, [sp, #120] + QADD R5, R5, R8 + ASR R5, R5, R9 + + RSBS R9, R11, #31 + MOVS R8, R7, ASR R9 + CMNLT R8, #1 + MOVLT R7, #0x80000000 + MVNGT R7, #0x80000000 + MOVEQ R7, R7, LSL R11 + + RSBS R9, R11, #31 + MOVS R8, R12, ASR R9 + CMNLT R8, #1 + MOVLT R12, #0x80000000 + MVNGT R12, #0x80000000 + MOVEQ R12, R12, LSL R11 + + B NEXT1 +NEXT: + MVN R11, R11 + ADD R11, R11, #1 + ASR R5, R5, R11 + MOV R8, #0x8000 + QADD R5, R5, R8 + ASR R5, R5, #16 + ASR R7, R7, R11 + ASR R12, R12, R11 + +NEXT1: + LDR R9, [R4] + MOV R8, #0x8000 + + STR R5, [R4], #4 + + + UXTH R5, R10, ROR #16 + UXTH R10, R10 + + + VDUP.32 D0, R9 + VDUP.32 D2, R10 + VDUP.32 D3, R5 + VZIP.32 D2, D3 + VMULL.S32 Q0, D2, D0 + VQMOVN.S64 D8, Q0 + + + VDUP.32 D0, R12 + VDUP.32 D1, R7 + + VZIP.32 D0, D1 + VQSUB.S32 D8, D0, D8 + + + VQSHL.S32 D8, D8, #2 + VDUP.32 D0, R8 + VQADD.S32 D8, D8, D0 + VSHR.S32 D8, D8, #16 + + + + LDR R7, [sp, #112] + LSL R10, R7, #1 + + ASR R5, R3, #1 + SMULBB R5, R10, R5 + ADD R5, R5, R0 + SUB R0, R5, R10 + MVN R9, R10 + ADD R9, R9, #1 + + VST1.16 D8[2], [R0], R9 + VST1.16 D8[0], [R5], R10 + + + MOV R8, R1 + LSL R12, R3, #2 + + ADD R1, R1, R12 + + SUB R1, R1, #40 + + MOV R12, #-32 + + + +PROLOGUE_NEON: + + ASR R3, R3, #2 + SUB R3, R3, #4 + ASR R3, R3, #2 + SUB R3, R3, #2 + + VLD2.32 {Q0, Q1}, [R1], R12 + VUZP.16 D0, D1 + VUZP.16 D2, D3 + + VREV64.16 Q0, Q0 + VREV64.16 Q1, Q1 + VLD2.16 {D8, D9}, [R2]! + + VLD2.32 {Q2, Q3}, [R8]! + VMULL.U16 Q15, D0, D9 + + VUZP.16 D4, D5 + VMULL.U16 Q14, D2, D8 + + VUZP.16 D6, D7 + VMULL.U16 Q13, D0, D8 + + + VMULL.U16 Q12, D2, D9 + + VLD2.32 {Q5, Q6}, [R6], R12 + VSHR.U32 Q15, Q15, #16 + + VUZP.16 D10, D11 + VSHR.U32 Q14, Q14, #16 + + VUZP.16 D12, D13 + VMLAL.S16 Q15, D1, D9 + + VREV64.16 Q5, Q5 + VMLAL.S16 Q14, D3, D8 + + VREV64.16 Q6, Q6 + VSHR.U32 Q13, Q13, #16 + + + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q13, D1, D8 + VMLAL.S16 Q12, D3, D9 + + + + VADD.I32 Q15, Q15, Q14 + VNEG.S32 Q15, Q15 + + VMULL.U16 Q11, D4, D8 + + VSUB.I32 Q14, Q12, Q13 + + + VMOV Q13, Q15 + VMOV Q12, Q14 + + VUZP.16 D24, D25 + + + VUZP.16 D26, D27 + VMULL.U16 Q1, D24, D18 + + VMULL.U16 Q0, D26, D18 + + VSHR.U32 Q11, Q11, #16 + VMLAL.S16 Q11, D5, D8 + + VSHR.U32 Q1, Q1, #16 + VSHR.U32 Q0, Q0, #16 + VMLAL.S16 Q1, D25, D18 + VMLAL.S16 Q0, D27, D18 + + VMULL.U16 Q12, D4, D9 + VMULL.U16 Q13, D6, D8 + + VNEG.S32 Q1, Q1 + VADD.I32 Q14, Q14, Q0 + VADD.I32 Q15, Q15, Q1 + + VMULL.U16 Q0, D6, D9 + VSHR.S32 Q12, Q12, #16 + VMLAL.S16 Q12, D5, D9 + VSHR.S32 Q13, Q13, #16 + VSHR.S32 Q0, Q0, #16 + VMLAL.S16 Q13, D7, D8 + VMLAL.S16 Q0, D7, D9 + + + + + VADD.I32 Q11, Q11, Q0 + VNEG.S32 Q11, Q11 + VSUB.I32 Q12, Q13, Q12 + + + + LDR R11, [sp, #120] + VDUP.S32 Q7, R11 + VQADD.S32 Q14, Q14, Q7 + LDR R11, [sp, #116] + VDUP.S32 Q0, R11 + VQSHL.S32 Q14, Q14, Q0 + + VMOV Q0, Q11 + VMOV Q7, Q12 + + + VUZP.16 D24, D25 + + VUZP.16 D22, D23 + VMULL.U16 Q4, D24, D18 + VMULL.U16 Q13, D22, D18 + + VNEG.S32 Q1, Q15 + VUZP.16 D30, D31 + + VUZP.16 D2, D3 + VMULL.U16 Q2, D30, D12 + + VMULL.U16 Q3, D2, D13 + + VSHR.U32 Q4, Q4, #16 + VSHR.U32 Q13, Q13, #16 + + VMLAL.S16 Q4, D25, D18 + VMLAL.S16 Q13, D23, D18 + + VSHR.U32 Q2, Q2, #16 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D31, D12 + VMLAL.S16 Q3, D3, D13 + + VNEG.S32 Q4, Q4 + VADD.I32 Q7, Q7, Q13 + VADD.I32 Q0, Q0, Q4 + + LDR R11, [sp, #120] + VDUP.S32 Q4, R11 + VQADD.S32 Q0, Q0, Q4 + LDR R11, [sp, #116] + VDUP.S32 Q13, R11 + VQSHL.S32 Q0, Q0, Q13 + + VMOV Q13, Q14 + + VLD2.32 {Q14, Q15}, [R4] + + VZIP.32 Q13, Q0 + VST1.32 {Q13}, [R4]! + VST1.32 {Q0}, [R4]! + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D13, D1 + + + VMULL.S32 Q13, D28, D0 + VQMOVN.S64 D8, Q13 + VMULL.S32 Q13, D29, D1 + VQMOVN.S64 D9, Q13 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D12, D1 + + + VMULL.S32 Q12, D28, D0 + VQMOVN.S64 D26, Q12 + VMULL.S32 Q12, D29, D1 + VQMOVN.S64 D27, Q12 + + VQSHL.S32 Q2, Q2, Q8 + VQSHL.S32 Q3, Q3, Q8 + + VQSUB.S32 Q2, Q2, Q4 + VQSUB.S32 Q3, Q3, Q13 + + VNEG.S32 Q13, Q7 + VUZP.16 D14, D15 + VUZP.16 D26, D27 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D10, D1 + VMULL.S32 Q11, D30, D0 + VQMOVN.S64 D24, Q11 + VMULL.S32 Q11, D31, D1 + VQMOVN.S64 D25, Q11 + VMOV.S32 D1, #0 + VADDL.S16 Q0, D11, D1 + VMULL.S32 Q4, D30, D0 + VQMOVN.S64 D22, Q4 + VMULL.S32 Q4, D31, D1 + VQMOVN.S64 D23, Q4 + VMULL.U16 Q4, D26, D11 + VMULL.U16 Q15, D14, D10 + + VLD2.32 {Q0, Q1}, [R1], R12 + + VUZP.16 D0, D1 + + VUZP.16 D2, D3 + VSHR.U32 Q4, Q4, #16 + + VREV64.16 Q0, Q0 + VSHR.U32 Q15, Q15, #16 + + VREV64.16 Q1, Q1 + VMLAL.S16 Q4, D27, D11 + + VMLAL.S16 Q15, D15, D10 + + VLD2.32 {Q5, Q6}, [R6], R12 + VQSHL.S32 Q2, Q2, #2 + + VUZP.16 D10, D11 + VQSHL.S32 Q3, Q3, #2 + + VUZP.16 D12, D13 + VQADD.S32 Q7, Q2, Q10 + + VREV64.16 Q5, Q5 + VQADD.S32 Q3, Q3, Q10 + + VREV64.16 Q6, Q6 + VSHR.S32 Q7, Q7, #16 + + VUZP.16 D14, D15 + VSHR.S32 Q3, Q3, #16 + + VUZP.16 D6, D7 + + VMOV D15, D6 + VQSHL.S32 Q4, Q4, Q8 + + VLD2.32 {Q2, Q3}, [R8]! + VQSHL.S32 Q15, Q15, Q8 + + VUZP.16 D4, D5 + VQSUB.S32 Q4, Q4, Q12 + + VUZP.16 D6, D7 + VQSUB.S32 Q11, Q15, Q11 + + VQSHL.S32 Q15, Q4, #2 + + VLD2.16 {D8, D9}, [R2]! + VQSHL.S32 Q11, Q11, #2 + + VQADD.S32 Q15, Q15, Q10 + VQADD.S32 Q11, Q11, Q10 + + VSHR.S32 Q15, Q15, #16 + + VUZP.16 D30, D31 + VSHR.S32 Q11, Q11, #16 + + + VUZP.16 D22, D23 + VMOV D23, D30 + +CORE_LOOP: + VST1.16 D14[0], [R0, : 16], R9 + VMULL.U16 Q15, D0, D9 + + VST1.16 D22[0], [R0, : 16], R9 + VMULL.U16 Q14, D2, D8 + + VST1.16 D14[1], [R0, : 16], R9 + VMULL.U16 Q13, D0, D8 + + VST1.16 D22[1], [R0, : 16], R9 + VMULL.U16 Q12, D2, D9 + + VST1.16 D14[2], [R0, : 16], R9 + VSHR.U32 Q15, Q15, #16 + + VST1.16 D22[2], [R0, : 16], R9 + VSHR.U32 Q14, Q14, #16 + + VST1.16 D14[3], [R0, : 16], R9 + VMLAL.S16 Q15, D1, D9 + + VST1.16 D22[3], [R0, : 16], R9 + VMLAL.S16 Q14, D3, D8 + + VST1.16 D15[0], [R5, : 16], R10 + VSHR.U32 Q13, Q13, #16 + + VST1.16 D23[0], [R5, : 16], R10 + VSHR.U32 Q12, Q12, #16 + + VST1.16 D15[1], [R5, : 16], R10 + VMLAL.S16 Q13, D1, D8 + + VST1.16 D23[1], [R5, : 16], R10 + VMLAL.S16 Q12, D3, D9 + + VST1.16 D15[2], [R5, : 16], R10 + VADD.I32 Q15, Q15, Q14 + + VST1.16 D23[2], [R5, : 16], R10 + VNEG.S32 Q15, Q15 + + VST1.16 D15[3], [R5, : 16], R10 + + VST1.16 D23[3], [R5, : 16], R10 + VSUB.I32 Q14, Q12, Q13 + + + VMOV Q13, Q15 + VMULL.U16 Q11, D4, D8 + + VMOV Q12, Q14 + + VUZP.16 D24, D25 + + + VUZP.16 D26, D27 + VMULL.U16 Q1, D24, D18 + VMULL.U16 Q0, D26, D18 + + VSHR.U32 Q11, Q11, #16 + VMLAL.S16 Q11, D5, D8 + + VSHR.U32 Q1, Q1, #16 + VSHR.U32 Q0, Q0, #16 + VMLAL.S16 Q1, D25, D18 + VMLAL.S16 Q0, D27, D18 + + VMULL.U16 Q12, D4, D9 + VMULL.U16 Q13, D6, D8 + + VNEG.S32 Q1, Q1 + VADD.I32 Q14, Q14, Q0 + VADD.I32 Q15, Q15, Q1 + + VMULL.U16 Q0, D6, D9 + VSHR.S32 Q12, Q12, #16 + VMLAL.S16 Q12, D5, D9 + VSHR.S32 Q13, Q13, #16 + VSHR.S32 Q0, Q0, #16 + VMLAL.S16 Q13, D7, D8 + VMLAL.S16 Q0, D7, D9 + + + + VADD.I32 Q11, Q11, Q0 + + VNEG.S32 Q11, Q11 + VSUB.I32 Q12, Q13, Q12 + + + LDR R11, [sp, #120] + VDUP.S32 Q7, R11 + VQADD.S32 Q14, Q14, Q7 + LDR R11, [sp, #116] + VDUP.S32 Q0, R11 + VQSHL.S32 Q14, Q14, Q0 + + + VMOV Q0, Q11 + VMOV Q7, Q12 + + VUZP.16 D24, D25 + + VUZP.16 D22, D23 + VMULL.U16 Q4, D24, D18 + VMULL.U16 Q13, D22, D18 + + VNEG.S32 Q1, Q15 + + VUZP.16 D30, D31 + + VUZP.16 D2, D3 + VMULL.U16 Q2, D30, D12 + VMULL.U16 Q3, D2, D13 + + VSHR.U32 Q4, Q4, #16 + VSHR.U32 Q13, Q13, #16 + + VMLAL.S16 Q4, D25, D18 + VMLAL.S16 Q13, D23, D18 + + VSHR.U32 Q2, Q2, #16 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D31, D12 + VMLAL.S16 Q3, D3, D13 + + VNEG.S32 Q4, Q4 + VADD.I32 Q7, Q7, Q13 + VADD.I32 Q0, Q0, Q4 + + + + LDR R11, [sp, #120] + VDUP.S32 Q4, R11 + VQADD.S32 Q0, Q0, Q4 + LDR R11, [sp, #116] + VDUP.S32 Q13, R11 + VQSHL.S32 Q0, Q0, Q13 + VMOV Q13, Q14 + + VLD2.32 {Q14, Q15}, [R4] + + VZIP.32 Q13, Q0 + VST1.32 {Q13}, [R4]! + VST1.32 {Q0}, [R4]! + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D13, D1 + + + VMULL.S32 Q13, D28, D0 + VQMOVN.S64 D8, Q13 + VMULL.S32 Q13, D29, D1 + VQMOVN.S64 D9, Q13 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D12, D1 + + + VMULL.S32 Q12, D28, D0 + VQMOVN.S64 D26, Q12 + VMULL.S32 Q12, D29, D1 + VQMOVN.S64 D27, Q12 + + VQSHL.S32 Q2, Q2, Q8 + VQSHL.S32 Q3, Q3, Q8 + + + + VQSUB.S32 Q2, Q2, Q4 + VQSUB.S32 Q3, Q3, Q13 + + VNEG.S32 Q13, Q7 + VUZP.16 D26, D27 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D10, D1 + VMULL.S32 Q11, D30, D0 + VQMOVN.S64 D24, Q11 + VMULL.S32 Q11, D31, D1 + VQMOVN.S64 D25, Q11 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D11, D1 + + VMULL.S32 Q4, D30, D0 + VQMOVN.S64 D22, Q4 + VMULL.S32 Q4, D31, D1 + VQMOVN.S64 D23, Q4 + + + VUZP.16 D14, D15 + VMULL.U16 Q4, D26, D11 + VMULL.U16 Q15, D14, D10 + + + VLD2.32 {Q0, Q1}, [R1], R12 + + VUZP.16 D0, D1 + + VUZP.16 D2, D3 + VSHR.U32 Q4, Q4, #16 + + VREV64.16 Q0, Q0 + VSHR.U32 Q15, Q15, #16 + + VREV64.16 Q1, Q1 + VMLAL.S16 Q4, D27, D11 + + VMLAL.S16 Q15, D15, D10 + + VLD2.32 {Q5, Q6}, [R6], R12 + VQSHL.S32 Q2, Q2, #2 + + VUZP.16 D10, D11 + VQSHL.S32 Q3, Q3, #2 + + VUZP.16 D12, D13 + VQADD.S32 Q7, Q2, Q10 + + VREV64.16 Q5, Q5 + VQADD.S32 Q3, Q3, Q10 + + VREV64.16 Q6, Q6 + VSHR.S32 Q7, Q7, #16 + + VUZP.16 D14, D15 + VSHR.S32 Q3, Q3, #16 + + VUZP.16 D6, D7 + + VMOV D15, D6 + VQSHL.S32 Q4, Q4, Q8 + + VLD2.32 {Q2, Q3}, [R8]! + VQSHL.S32 Q15, Q15, Q8 + + VUZP.16 D4, D5 + VQSUB.S32 Q4, Q4, Q12 + + VUZP.16 D6, D7 + VQSUB.S32 Q11, Q15, Q11 + + VQSHL.S32 Q15, Q4, #2 + + VLD2.16 {D8, D9}, [R2]! + VQSHL.S32 Q11, Q11, #2 + + VQADD.S32 Q15, Q15, Q10 + VQADD.S32 Q11, Q11, Q10 + + VSHR.S32 Q15, Q15, #16 + + VUZP.16 D30, D31 + VSHR.S32 Q11, Q11, #16 + + + VUZP.16 D22, D23 + VMOV D23, D30 + + SUBS R3, R3, #1 + BNE CORE_LOOP + + + + + +EPILOGUE: + + VST1.16 D14[0], [R0], R9 + VMULL.U16 Q15, D0, D9 + + VST1.16 D22[0], [R0], R9 + VMULL.U16 Q14, D2, D8 + + VST1.16 D14[1], [R0], R9 + VMULL.U16 Q13, D0, D8 + + VST1.16 D22[1], [R0], R9 + VMULL.U16 Q12, D2, D9 + + VST1.16 D14[2], [R0], R9 + VSHR.U32 Q15, Q15, #16 + + VST1.16 D22[2], [R0], R9 + VSHR.U32 Q14, Q14, #16 + + VST1.16 D14[3], [R0], R9 + VMLAL.S16 Q15, D1, D9 + + VST1.16 D22[3], [R0], R9 + VMLAL.S16 Q14, D3, D8 + + VST1.16 D15[0], [R5], R10 + VSHR.U32 Q13, Q13, #16 + + VST1.16 D23[0], [R5], R10 + VSHR.U32 Q12, Q12, #16 + + VST1.16 D15[1], [R5], R10 + VMLAL.S16 Q13, D1, D8 + + VST1.16 D23[1], [R5], R10 + VMLAL.S16 Q12, D3, D9 + + VST1.16 D15[2], [R5], R10 + VADD.I32 Q15, Q15, Q14 + + VST1.16 D23[2], [R5], R10 + VNEG.S32 Q15, Q15 + + VST1.16 D15[3], [R5], R10 + + + VST1.16 D23[3], [R5], R10 + VSUB.I32 Q14, Q12, Q13 + + + VMULL.U16 Q11, D4, D8 + VMOV Q13, Q15 + VMOV Q12, Q14 + + VMOV Q13, Q15 + VMOV Q12, Q14 + + VUZP.16 D26, D27 + VUZP.16 D24, D25 + + + VMULL.U16 Q1, D24, D18 + VMULL.U16 Q0, D26, D18 + + VSHR.U32 Q11, Q11, #16 + VMLAL.S16 Q11, D5, D8 + + VSHR.U32 Q1, Q1, #16 + VSHR.U32 Q0, Q0, #16 + VMLAL.S16 Q1, D25, D18 + VMLAL.S16 Q0, D27, D18 + + VMULL.U16 Q12, D4, D9 + VMULL.U16 Q13, D6, D8 + + VNEG.S32 Q1, Q1 + VADD.I32 Q14, Q14, Q0 + VADD.I32 Q15, Q15, Q1 + + VMULL.U16 Q0, D6, D9 + VSHR.S32 Q12, Q12, #16 + VMLAL.S16 Q12, D5, D9 + VSHR.S32 Q13, Q13, #16 + VSHR.S32 Q0, Q0, #16 + VMLAL.S16 Q13, D7, D8 + VMLAL.S16 Q0, D7, D9 + + + + + + VADD.I32 Q11, Q11, Q0 + VNEG.S32 Q11, Q11 + VSUB.I32 Q12, Q13, Q12 + + + + + LDR R11, [sp, #120] + VDUP.S32 Q7, R11 + VQADD.S32 Q14, Q14, Q7 + LDR R11, [sp, #116] + VDUP.S32 Q0, R11 + VQSHL.S32 Q14, Q14, Q0 + + + VMOV Q0, Q11 + VMOV Q7, Q12 + + + VUZP.16 D22, D23 + VUZP.16 D24, D25 + + VMULL.U16 Q4, D24, D18 + VMULL.U16 Q13, D22, D18 + + VNEG.S32 Q1, Q15 + VUZP.16 D30, D31 + VUZP.16 D2, D3 + + VMULL.U16 Q2, D30, D12 + VMULL.U16 Q3, D2, D13 + + VSHR.U32 Q4, Q4, #16 + VSHR.U32 Q13, Q13, #16 + + VMLAL.S16 Q4, D25, D18 + VMLAL.S16 Q13, D23, D18 + + VSHR.U32 Q2, Q2, #16 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D31, D12 + VMLAL.S16 Q3, D3, D13 + + VNEG.S32 Q4, Q4 + VADD.I32 Q7, Q7, Q13 + VADD.I32 Q0, Q0, Q4 + + LDR R11, [sp, #120] + VDUP.S32 Q4, R11 + VQADD.S32 Q0, Q0, Q4 + LDR R11, [sp, #116] + VDUP.S32 Q13, R11 + VQSHL.S32 Q0, Q0, Q13 + + + VMOV Q13, Q14 + + VLD2.32 {Q14, Q15}, [R4] + VZIP.32 Q13, Q0 + VST1.32 {Q13}, [R4]! + VST1.32 {Q0}, [R4]! + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D13, D1 + + VMULL.S32 Q13, D28, D0 + VQMOVN.S64 D8, Q13 + VMULL.S32 Q13, D29, D1 + VQMOVN.S64 D9, Q13 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D12, D1 + + VMULL.S32 Q12, D28, D0 + VQMOVN.S64 D26, Q12 + VMULL.S32 Q12, D29, D1 + VQMOVN.S64 D27, Q12 + + VQSHL.S32 Q2, Q2, Q8 + VQSHL.S32 Q3, Q3, Q8 + + VQSUB.S32 Q2, Q2, Q4 + VQSUB.S32 Q3, Q3, Q13 + + VNEG.S32 Q13, Q7 + VUZP.16 D14, D15 + VUZP.16 D26, D27 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D10, D1 + + + VMULL.S32 Q11, D30, D0 + VQMOVN.S64 D24, Q11 + VMULL.S32 Q11, D31, D1 + VQMOVN.S64 D25, Q11 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D11, D1 + + VMULL.S32 Q4, D30, D0 + VQMOVN.S64 D22, Q4 + VMULL.S32 Q4, D31, D1 + VQMOVN.S64 D23, Q4 + + + VMULL.U16 Q4, D26, D11 + VMULL.U16 Q15, D14, D10 + + VSHR.U32 Q4, Q4, #16 + + VSHR.U32 Q15, Q15, #16 + + VMLAL.S16 Q4, D27, D11 + + VMLAL.S16 Q15, D15, D10 + + VQSHL.S32 Q2, Q2, #2 + + VQSHL.S32 Q3, Q3, #2 + + VQADD.S32 Q7, Q2, Q10 + + VQADD.S32 Q3, Q3, Q10 + + VSHR.S32 Q7, Q7, #16 + + VUZP.16 D14, D15 + VSHR.S32 Q3, Q3, #16 + + VUZP.16 D6, D7 + + VMOV D15, D6 + VQSHL.S32 Q4, Q4, Q8 + + VQSHL.S32 Q15, Q15, Q8 + + VQSUB.S32 Q4, Q4, Q12 + + VQSUB.S32 Q11, Q15, Q11 + + VQSHL.S32 Q15, Q4, #2 + + VQSHL.S32 Q11, Q11, #2 + + VQADD.S32 Q15, Q15, Q10 + VQADD.S32 Q11, Q11, Q10 + + VSHR.S32 Q15, Q15, #16 + + VUZP.16 D30, D31 + VSHR.S32 Q11, Q11, #16 + + VUZP.16 D22, D23 + VMOV D23, D30 + + + + + VST1.16 D14[0], [R0], R9 + VST1.16 D22[0], [R0], R9 + VST1.16 D14[1], [R0], R9 + VST1.16 D22[1], [R0], R9 + VST1.16 D14[2], [R0], R9 + VST1.16 D22[2], [R0], R9 + VST1.16 D14[3], [R0], R9 + VST1.16 D22[3], [R0], R9 + VST1.16 D15[0], [R5], R10 + VST1.16 D23[0], [R5], R10 + VST1.16 D15[1], [R5], R10 + VST1.16 D23[1], [R5], R10 + VST1.16 D15[2], [R5], R10 + VST1.16 D23[2], [R5], R10 + VST1.16 D15[3], [R5], R10 + VST1.16 D23[3], [R5], R10 + +ARM_EPILOGUE: + +ARM_LOOP: + + VLD2.32 {Q0, Q1}, [R1] + + VUZP.16 D0, D1 + VUZP.16 D2, D3 + + VREV64.16 Q0, Q0 + VREV64.16 Q1, Q1 + + VLD2.16 {D8, D9}, [R2]! + + VLD2.32 {D4, D6}, [R8]! + VMOV.S32 D5, #0x00000000 + VMOV.S32 D7, #0x00000000 + + VLD1.32 D5[0], [R8]! + VLD1.32 D7[0], [R8] + + MOV R12, #16 + + VUZP.16 D4, D5 + VUZP.16 D6, D7 + + ADD R6, R6, #16 + + MOV R12, #-4 + VLD2.32 {D11, D13}, [R6], R12 + + + VMOV.S32 D10, #0x00000000 + + VLD1.32 D12[1], [R6], R12 + VLD1.32 D10[1], [R6], R12 + VLD1.32 D12[0], [R6], R12 + + VUZP.16 D10, D11 + VUZP.16 D12, D13 + + VREV64.16 Q5, Q5 + VREV64.16 Q6, Q6 + + VMULL.U16 Q15, D0, D9 + VMULL.U16 Q14, D2, D8 + VMULL.U16 Q13, D0, D8 + VMULL.U16 Q12, D2, D9 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + + VMLAL.S16 Q15, D1, D9 + VMLAL.S16 Q14, D3, D8 + + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q13, D1, D8 + VMLAL.S16 Q12, D3, D9 + + VADD.I32 Q15, Q15, Q14 + VNEG.S32 Q15, Q15 + + VMULL.U16 Q11, D4, D8 + + VSUB.I32 Q14, Q12, Q13 + + + VMOV Q13, Q15 + VMOV Q12, Q14 + + VUZP.16 D26, D27 + VUZP.16 D24, D25 + + + VMULL.U16 Q1, D24, D18 + VMULL.U16 Q0, D26, D18 + + VSHR.U32 Q11, Q11, #16 + VMLAL.S16 Q11, D5, D8 + + VSHR.U32 Q1, Q1, #16 + VSHR.U32 Q0, Q0, #16 + VMLAL.S16 Q1, D25, D18 + VMLAL.S16 Q0, D27, D18 + + VMULL.U16 Q12, D4, D9 + VMULL.U16 Q13, D6, D8 + + VNEG.S32 Q1, Q1 + VADD.I32 Q14, Q14, Q0 + VADD.I32 Q15, Q15, Q1 + + VMULL.U16 Q0, D6, D9 + VSHR.S32 Q12, Q12, #16 + VMLAL.S16 Q12, D5, D9 + VSHR.S32 Q13, Q13, #16 + VSHR.S32 Q0, Q0, #16 + VMLAL.S16 Q13, D7, D8 + VMLAL.S16 Q0, D7, D9 + + VADD.I32 Q11, Q11, Q0 + VNEG.S32 Q11, Q11 + VSUB.I32 Q12, Q13, Q12 + + LDR R11, [sp, #120] + VDUP.S32 Q7, R11 + VQADD.S32 Q14, Q14, Q7 + LDR R11, [sp, #116] + VDUP.S32 Q0, R11 + VQSHL.S32 Q14, Q14, Q0 + + VMOV Q0, Q11 + VMOV Q7, Q12 + + VUZP.16 D22, D23 + VUZP.16 D24, D25 + + VMULL.U16 Q4, D24, D18 + VMULL.U16 Q13, D22, D18 + + VNEG.S32 Q1, Q15 + VUZP.16 D30, D31 + VUZP.16 D2, D3 + + VMULL.U16 Q2, D30, D12 + VMULL.U16 Q3, D2, D13 + + VSHR.U32 Q4, Q4, #16 + VSHR.U32 Q13, Q13, #16 + + VMLAL.S16 Q4, D25, D18 + VMLAL.S16 Q13, D23, D18 + + VSHR.U32 Q2, Q2, #16 + VSHR.U32 Q3, Q3, #16 + + VMLAL.S16 Q2, D31, D12 + VMLAL.S16 Q3, D3, D13 + + VNEG.S32 Q4, Q4 + VADD.I32 Q7, Q7, Q13 + VADD.I32 Q0, Q0, Q4 + + LDR R11, [sp, #120] + VDUP.S32 Q4, R11 + VQADD.S32 Q0, Q0, Q4 + LDR R11, [sp, #116] + VDUP.S32 Q13, R11 + VQSHL.S32 Q0, Q0, Q13 + + VMOV Q13, Q14 + + MOV R6, R4 + + VLD1.32 {D28, D29}, [R4]! + VMOV.S32 D31, #0x00000000 + VLD1.32 D30[0], [R4]! + VLD1.32 D30[1], [R4]! + VLD1.32 D31[0], [R4]! + VUZP.32 Q14, Q15 + + + VST1.32 D26[0], [R6]! + VST1.32 D0[0], [R6]! + VST1.32 D26[1], [R6]! + VST1.32 D0[1], [R6]! + VST1.32 D27[0], [R6]! + VST1.32 D1[0], [R6]! + VST1.32 D27[1], [R6]! + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D13, D1 + + VMULL.S32 Q13, D28, D0 + VQMOVN.S64 D8, Q13 + VMULL.S32 Q13, D29, D1 + VQMOVN.S64 D9, Q13 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D12, D1 + + VMULL.S32 Q12, D28, D0 + VQMOVN.S64 D26, Q12 + VMULL.S32 Q12, D29, D1 + VQMOVN.S64 D27, Q12 + + VQSHL.S32 Q2, Q2, Q8 + VQSHL.S32 Q3, Q3, Q8 + + VQSUB.S32 Q2, Q2, Q4 + VQSUB.S32 Q3, Q3, Q13 + + VNEG.S32 Q13, Q7 + VUZP.16 D14, D15 + VUZP.16 D26, D27 + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D10, D1 + + + VMULL.S32 Q11, D30, D0 + VQMOVN.S64 D24, Q11 + VMULL.S32 Q11, D31, D1 + VQMOVN.S64 D25, Q11 + + + VMOV.S32 D1, #0 + VADDL.S16 Q0, D11, D1 + + VMULL.S32 Q4, D30, D0 + VQMOVN.S64 D22, Q4 + VMULL.S32 Q4, D31, D1 + VQMOVN.S64 D23, Q4 + + + VMULL.U16 Q4, D26, D11 + VMULL.U16 Q15, D14, D10 + + VSHR.U32 Q4, Q4, #16 + + VSHR.U32 Q15, Q15, #16 + + VMLAL.S16 Q4, D27, D11 + + VMLAL.S16 Q15, D15, D10 + + VQSHL.S32 Q2, Q2, #2 + + VQSHL.S32 Q3, Q3, #2 + + VQADD.S32 Q7, Q2, Q10 + + VQADD.S32 Q3, Q3, Q10 + + VSHR.S32 Q7, Q7, #16 + + VUZP.16 D14, D15 + VSHR.S32 Q3, Q3, #16 + + VUZP.16 D6, D7 + + VMOV D15, D6 + VQSHL.S32 Q4, Q4, Q8 + + VQSHL.S32 Q15, Q15, Q8 + + VQSUB.S32 Q4, Q4, Q12 + + VQSUB.S32 Q11, Q15, Q11 + + VQSHL.S32 Q15, Q4, #2 + + VQSHL.S32 Q11, Q11, #2 + + VQADD.S32 Q15, Q15, Q10 + VQADD.S32 Q11, Q11, Q10 + + VSHR.S32 Q15, Q15, #16 + + VUZP.16 D30, D31 + VSHR.S32 Q11, Q11, #16 + + VUZP.16 D22, D23 + VMOV D23, D30 + + + + + VST1.16 D14[0], [R0], R9 + VST1.16 D22[0], [R0], R9 + VST1.16 D14[1], [R0], R9 + VST1.16 D22[1], [R0], R9 + VST1.16 D14[2], [R0], R9 + VST1.16 D22[2], [R0], R9 + VST1.16 D14[3], [R0], R9 + + VST1.16 D15[0], [R5], R10 + VST1.16 D23[0], [R5], R10 + VST1.16 D15[1], [R5], R10 + VST1.16 D23[1], [R5], R10 + VST1.16 D15[2], [R5], R10 + VST1.16 D23[2], [R5], R10 + VST1.16 D15[3], [R5], R10 + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12} + BX LR + + diff --git a/decoder/armv7/ixheaacd_pre_twiddle_compute.s b/decoder/armv7/ixheaacd_pre_twiddle_compute.s new file mode 100644 index 0000000..4e586c0 --- /dev/null +++ b/decoder/armv7/ixheaacd_pre_twiddle_compute.s @@ -0,0 +1,388 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 +.global ixheaacd_pretwiddle_compute_armv7 + +ixheaacd_pretwiddle_compute_armv7: + + STMFD sp!, {R4-R12} + VPUSH {d8 - d15} + + LDR R8, =7500 + ADD R3, R3, R8 + LDR R4, [sp, #100] + LDR R5, [sp, #104] + + LSL R7, R4, #4 + ADD R7, R2, R7 + SUB R7, R7, #4 + + MVN R5, R5 + ADD R5, R5, #1 + +ARM_PROLOGUE: + LDR R8, [R3], #4 + LDR R9, [R0], #4 + + SMULWB R12, R9, R8 + LDR R10, [R1], #-4 + SMULWT R11, R9, R8 + SMLAWT R9, R10, R8, R12 + SMULWB R6, R10, R8 + + MVN R9, R9 + ADD R9, R9, #1 + + SUB R11, R11, R6 + + CMP R5, #0 + BGT NEXT + MVN R8, R5 + ADD R8, R8, #1 + ASR R11, R11, R8 + ASR R9, R9, R8 + B NEXT1 + +NEXT: + LSL R11, R11, R5 + LSL R9, R9, R5 + + + +NEXT1: + STR R9, [R2], #4 + STR R11, [R2], #4 + + CMP R4, #0x100 + BNE NXT + MOV R6, #4 + B NXT1 +NXT: + MOV R6, #32 + ADD R3, R3, #28 + +NXT1: + SUB R4, R4, #1 + ASR R4, R4, #2 + SUB R7, R7, #28 + + + + + + + + + + + + +NEON_PROLOGUE: + + MOV R8, #-32 + VDUP.32 Q7, R5 + SUB R1, R1, #28 + + VLD2.16 {D8[0], D9[0]}, [R3], R6 + VLD2.16 {D8[1], D9[1]}, [R3], R6 + VLD2.16 {D8[2], D9[2]}, [R3], R6 + VLD2.16 {D8[3], D9[3]}, [R3], R6 + + VREV64.16 Q5, Q4 + + VLD4.16 {D0, D1, D2, D3}, [R0]! + VLD4.16 {D4, D5, D6, D7}, [R1], R8 + + VREV64.16 Q0, Q0 + VREV64.16 Q2, Q2 + + + + + + + VMULL.U16 Q15, D2, D9 + VMULL.U16 Q14, D4, D9 + VMULL.U16 Q13, D2, D8 + VMULL.U16 Q12, D4, D8 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D9 + VMLAL.S16 Q14, D5, D9 + VMLAL.S16 Q13, D3, D8 + VMLAL.S16 Q12, D5, D8 + + VADD.I32 Q14, Q13, Q14 + VNEG.S32 Q14, Q14 + VSUB.I32 Q15, Q15, Q12 + + VMULL.U16 Q11, D0, D11 + VMULL.U16 Q10, D6, D11 + VMULL.U16 Q9, D0, D10 + VMULL.U16 Q8, D6, D10 + + VSHR.U32 Q11, Q11, #16 + VSHR.U32 Q10, Q10, #16 + VSHR.U32 Q9, Q9, #16 + VSHR.U32 Q8, Q8, #16 + + VMLAL.S16 Q11, D1, D11 + VLD2.16 {D8[0], D9[0]}, [R3], R6 + + VMLAL.S16 Q10, D7, D11 + VLD2.16 {D8[1], D9[1]}, [R3], R6 + + VMLAL.S16 Q9, D1, D10 + VLD2.16 {D8[2], D9[2]}, [R3], R6 + + VMLAL.S16 Q8, D7, D10 + VLD2.16 {D8[3], D9[3]}, [R3], R6 + + VADD.I32 Q10, Q10, Q9 + + VNEG.S32 Q10, Q10 + VREV64.16 Q5, Q4 + + VSUB.I32 Q11, Q8, Q11 + VLD4.16 {D0, D1, D2, D3}, [R0]! + + + + VSHL.S32 Q10, Q10, Q7 + VLD4.16 {D4, D5, D6, D7}, [R1], R8 + + VREV64.16 Q0, Q0 + VSHL.S32 Q11, Q11, Q7 + + VREV64.16 Q2, Q2 + VSHL.S32 Q9, Q15, Q7 + VSHL.S32 Q8, Q14, Q7 + + + + SUB R4, R4, #2 + +CORE_LOOP: + VMULL.U16 Q15, D2, D9 + VST2.32 {Q8, Q9}, [R2]! + VMULL.U16 Q14, D4, D9 + + VMULL.U16 Q13, D2, D8 + VST2.32 {Q10, Q11}, [R7], R8 + VMULL.U16 Q12, D4, D8 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D9 + VMLAL.S16 Q14, D5, D9 + VMLAL.S16 Q13, D3, D8 + VMLAL.S16 Q12, D5, D8 + + VADD.I32 Q14, Q13, Q14 + VNEG.S32 Q14, Q14 + VSUB.I32 Q15, Q15, Q12 + + VMULL.U16 Q11, D0, D11 + VLD2.16 {D8[0], D9[0]}, [R3], R6 + VMULL.U16 Q10, D6, D11 + + VMULL.U16 Q9, D0, D10 + VLD2.16 {D8[1], D9[1]}, [R3], R6 + VMULL.U16 Q8, D6, D10 + + VSHR.U32 Q11, Q11, #16 + VLD2.16 {D8[2], D9[2]}, [R3], R6 + VSHR.U32 Q10, Q10, #16 + + VSHR.U32 Q9, Q9, #16 + VLD2.16 {D8[3], D9[3]}, [R3], R6 + VSHR.U32 Q8, Q8, #16 + + VMLAL.S16 Q11, D1, D11 + VMLAL.S16 Q10, D7, D11 + VMLAL.S16 Q9, D1, D10 + VMLAL.S16 Q8, D7, D10 + + VLD4.16 {D0, D1, D2, D3}, [R0]! + VADD.I32 Q10, Q10, Q9 + + VNEG.S32 Q10, Q10 + VREV64.16 Q5, Q4 + + VSUB.I32 Q11, Q8, Q11 + VLD4.16 {D4, D5, D6, D7}, [R1], R8 + VSHL.S32 Q10, Q10, Q7 + VSHL.S32 Q11, Q11, Q7 + + VREV64.16 Q0, Q0 + VSHL.S32 Q9, Q15, Q7 + + VREV64.16 Q2, Q2 + VSHL.S32 Q8, Q14, Q7 + + SUBS R4, R4, #1 + BNE CORE_LOOP + +NEON_EPILOGUE: + VMULL.U16 Q15, D2, D9 + VST2.32 {Q8, Q9}, [R2]! + VMULL.U16 Q14, D4, D9 + + VMULL.U16 Q13, D2, D8 + VST2.32 {Q10, Q11}, [R7], R8 + VMULL.U16 Q12, D4, D8 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D9 + VMLAL.S16 Q14, D5, D9 + VMLAL.S16 Q13, D3, D8 + VMLAL.S16 Q12, D5, D8 + + VADD.I32 Q14, Q13, Q14 + VNEG.S32 Q14, Q14 + VSUB.I32 Q15, Q15, Q12 + + VMULL.U16 Q11, D0, D11 + VMULL.U16 Q10, D6, D11 + VMULL.U16 Q9, D0, D10 + VMULL.U16 Q8, D6, D10 + + VSHR.U32 Q11, Q11, #16 + VSHR.U32 Q10, Q10, #16 + VSHR.U32 Q9, Q9, #16 + VSHR.U32 Q8, Q8, #16 + + VMLAL.S16 Q11, D1, D11 + VMLAL.S16 Q10, D7, D11 + VMLAL.S16 Q9, D1, D10 + VMLAL.S16 Q8, D7, D10 + + VADD.I32 Q10, Q10, Q9 + VNEG.S32 Q10, Q10 + VSUB.I32 Q11, Q8, Q11 + + + VSHL.S32 Q10, Q10, Q7 + VSHL.S32 Q11, Q11, Q7 + VSHL.S32 Q9, Q15, Q7 + VSHL.S32 Q8, Q14, Q7 + + VST2.32 {Q8, Q9}, [R2]! + VST2.32 {Q10, Q11}, [R7], R8 + + +RESIDUE_NEON: + MOV R10, #-16 + VMOV.S32 D3, #0x00000000 + VMOV.S32 D4, #0x00000000 + + VLD2.32 {D0, D2}, [R0]! + VLD2.32 {D1[0], D3[0]}, [R0]! + VLD1.32 D1[1], [R0] + + VUZP.16 D0, D1 + VUZP.16 D2, D3 + + ADD R1, R1, #4 + + VLD1.32 D6[0], [R1]! + VLD2.32 {D4[1], D6[1]}, [R1]! + VLD2.32 {D5, D7}, [R1]! + + VUZP.16 D4, D5 + VUZP.16 D6, D7 + + VREV64.16 Q0, Q0 + VREV64.16 Q2, Q2 + + VLD2.16 {D8[0], D9[0]}, [R3], R6 + VLD2.16 {D8[1], D9[1]}, [R3], R6 + VLD2.16 {D8[2], D9[2]}, [R3], R6 + VLD2.16 {D8[3], D9[3]}, [R3], R6 + + VREV64.16 Q5, Q4 + + + VMULL.U16 Q15, D2, D9 + VMULL.U16 Q14, D4, D9 + VMULL.U16 Q13, D2, D8 + VMULL.U16 Q12, D4, D8 + + VSHR.U32 Q15, Q15, #16 + VSHR.U32 Q14, Q14, #16 + VSHR.U32 Q13, Q13, #16 + VSHR.U32 Q12, Q12, #16 + + VMLAL.S16 Q15, D3, D9 + VMLAL.S16 Q14, D5, D9 + VMLAL.S16 Q13, D3, D8 + VMLAL.S16 Q12, D5, D8 + + VADD.I32 Q14, Q13, Q14 + VNEG.S32 Q14, Q14 + VSUB.I32 Q15, Q15, Q12 + + VMULL.U16 Q11, D0, D11 + VMULL.U16 Q10, D6, D11 + VMULL.U16 Q9, D0, D10 + VMULL.U16 Q8, D6, D10 + + VSHR.U32 Q11, Q11, #16 + VSHR.U32 Q10, Q10, #16 + VSHR.U32 Q9, Q9, #16 + VSHR.U32 Q8, Q8, #16 + + VMLAL.S16 Q11, D1, D11 + VMLAL.S16 Q10, D7, D11 + VMLAL.S16 Q9, D1, D10 + VMLAL.S16 Q8, D7, D10 + + VADD.I32 Q10, Q10, Q9 + VNEG.S32 Q10, Q10 + VSUB.I32 Q11, Q8, Q11 + + + VSHL.S32 Q10, Q10, Q7 + VSHL.S32 Q11, Q11, Q7 + VSHL.S32 Q9, Q15, Q7 + VSHL.S32 Q8, Q14, Q7 + + VST2.32 {Q10, Q11}, [R7] + VST2.32 {D16, D18}, [R2]! + VST2.32 {D17[0], D19[0]}, [R2]! + + VPOP {d8 - d15} + LDMFD sp!, {R4-R12} + BX LR + diff --git a/decoder/armv7/ixheaacd_qmf_dec.c b/decoder/armv7/ixheaacd_qmf_dec.c new file mode 100644 index 0000000..ca45ca8 --- /dev/null +++ b/decoder/armv7/ixheaacd_qmf_dec.c @@ -0,0 +1,1282 @@ +/****************************************************************************** + * * + * 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 + +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_type_def.h" + +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_qmf_dec.h" + +#include +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_interface.h" + +#include "ixheaacd_function_selector.h" +#include "ixheaacd_audioobjtypes.h" + +#define mult16x16_16(a, b) ixheaacd_mult16((a), (b)) +#define mac16x16(a, b, c) ixheaacd_mac16x16in32((a), (b), (c)) +#define mpy_32x16(a, b) fixmuldiv2_32x16b((a), (b)) +#define mpy_16x16(a, b) ixheaacd_mult16x16in32((a), (b)) +#define mpy_32x32(a, b) ixheaacd_mult32((a), (b)) +#define mpy_32x16H_n(a, b) ixheaacd_mult32x16hin32((a), (b)) +#define msu16x16(a, b, c) msu16x16in32((a), (b), (c)) + +#define DCT3_LEN (32) +#define DCT2_LEN (64) + +#define LP_SHIFT_VAL 7 +#define HQ_SHIFT_64 4 +#define RADIXSHIFT 1 +#define ROUNDING_SPECTRA 1 +#define HQ_SHIFT_VAL 4 + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x32in32_shift25(WORD32 a, + WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 25); + + return (result); +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2(WORD32 *inp, WORD32 *out_fwd) { + WORD32 n; + WORD32 *out_rev = out_fwd + DCT2_LEN - 1; + + for (n = 0; n < DCT2_LEN / 2; n++) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +VOID ixheaacd_fftposttw(WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *p_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 1; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 15; + + p_out_fwd = out; + ptr_out_rev = out + DCT2_LEN - 1; + + in1 = ((*p_out_fwd++) << 1); + val1 = ((*p_out_fwd--) << 1); + + *p_out_fwd++ = in1; + *p_out_fwd++ = val1; + + for (k = 1; k <= DCT2_LEN / 4; k++) { + WORD32 temp[4]; + WORD16 twid_re, twid_im; + + temp[0] = *p_out_fwd++; + temp[1] = *p_out_fwd--; + temp[3] = *ptr_out_rev--; + temp[2] = *ptr_out_rev++; + + in2 = temp[3] - temp[1]; + in1 = temp[3] + temp[1]; + + temp[1] = temp[0] - temp[2]; + temp[3] = temp[0] + temp[2]; + + twid_re = *twidle_fwd++; + twid_im = *twidle_rev--; + val1 = msu32x16in32_dual(in1, twid_re, temp[1], twid_im); + val2 = mac32x16in32_dual(temp[1], twid_re, in1, twid_im); + val1 = val1 << 1; + val2 = val2 << 1; + + *p_out_fwd++ = temp[3] + val1; + *p_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp[3] - val1; + } + + return; +} + +VOID ixheaacd_posttwdct2(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 k; + WORD32 inp_re, inp_im, out_re, out_im, last_val, out_re1; + WORD16 *out_fwd2, *out_rev2, *out_rev; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + + out_rev = out_fwd + DCT2_LEN - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 65; + out_re = *inp++; + out_im = *inp++; + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32(out_re1, (5 - 1))); + + *out_fwd++ = re1; + + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 2; + for (k = DCT2_LEN / 2 - 2; k >= 0; k--) { + inp_re = *inp++; + inp_im = *inp++; + + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd++; + out_re = msu32x16in32_dual(inp_re, twid_re, inp_im, twid_im); + out_im = mac32x16in32_dual(inp_im, twid_re, inp_re, twid_im); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + im1 = ixheaacd_round16(ixheaacd_shl32(out_im, (5 - 1))); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_64(WORD32 *x, WORD32 *X, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + ixheaacd_pretwdct2(x, X); + + ixheaacd_sbr_imdct_using_fft(qmf_dec_tables_ptr->w1024, 32, X, x, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128); + + ixheaacd_fftposttw(x, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2(x, filter_states, qmf_dec_tables_ptr); + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2_32(WORD32 *inp, WORD32 *out_fwd, + int dct2_len) { + WORD32 n; + + WORD32 *out_rev = out_fwd + dct2_len - 1; + for (n = dct2_len / 2 - 1; n >= 0; n--) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_fftposttw_32( + WORD32 *out, int dct2_len, ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *ptr_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 2; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 14; + + ptr_out_fwd = out; + ptr_out_rev = out + dct2_len - 1; + + in1 = ((*ptr_out_fwd++) << 1); + val1 = ((*ptr_out_fwd--) << 1); + + *ptr_out_fwd++ = in1; + *ptr_out_fwd++ = val1; + + for (k = dct2_len / 4 - 1; k >= 0; k--) { + WORD32 temp0, temp1, temp2, temp3; + WORD16 twid_re, twid_im; + + temp0 = *ptr_out_fwd++; + temp1 = *ptr_out_fwd--; + temp3 = *ptr_out_rev--; + temp2 = *ptr_out_rev++; + + in1 = temp1 + temp3; + in2 = -temp1 + temp3; + + temp1 = temp0 - temp2; + temp3 = temp0 + temp2; + + twid_re = *twidle_fwd; + twidle_fwd += 2; + + twid_im = *twidle_rev; + twidle_rev -= 2; + + val1 = ixheaacd_mult32x16in32(in1, twid_re) - + ixheaacd_mult32x16in32(temp1, twid_im); + val2 = ixheaacd_mult32x16in32(temp1, twid_re) + + ixheaacd_mult32x16in32(in1, twid_im); + + val1 = val1 << 1; + val2 = val2 << 1; + + *ptr_out_fwd++ = temp3 + val1; + *ptr_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp3 - val1; + } + + return; +} + +static PLATFORM_INLINE VOID +ixheaacd_posttwdct2_32(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 inp_re, out_re, out_im, last_val, out_re1; + WORD16 *out_rev, *out_rev2, *out_fwd2; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + WORD32 rounding_fac = 0x8000; + + out_rev = out_fwd + 32 - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 32 + 1; + out_fwd[32] = 0; + + out_re = *inp++; + out_im = *inp++; + + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re1, (5 - 1))); + *out_fwd++ = re1; + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 4; + for (k = 14; k >= 0; k--) { + WORD32 temp1, temp2; + inp_re = *inp++; + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd; + twidle_fwd += 3; + + temp1 = ixheaacd_mult32x16in32(inp_re, twid_re); + temp2 = ixheaacd_mult32x16in32(inp_re, twid_im); + + inp_re = *inp++; + + out_re = ixheaacd_sub32(temp1, ixheaacd_mult32x16in32(inp_re, twid_im)); + out_im = ixheaacd_add32(ixheaacd_mult32x16in32(inp_re, twid_re), temp2); + + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, rounding_fac); + out_im = ixheaacd_add32_sat(out_im, rounding_fac); + re1 = (out_re >> 16); + im1 = (out_im >> 16); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re, (5 - 1))); + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_32(WORD32 *inp, WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + WORD32 *output; + + output = out + 16; + filter_states = filter_states + 16; + ixheaacd_pretwdct2_32(inp, output, 32); + + ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_16, output, 1, 4); + ixheaacd_postradixcompute4(inp, output, qmf_dec_tables_ptr->dig_rev_table4_16, + 16); + ixheaacd_fftposttw_32(inp, 32, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2_32(inp, filter_states, qmf_dec_tables_ptr); + + return; +} + +VOID ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 *inp1, WORD16 *inp2, + WORD16 *p_qmf1, WORD16 *p_qmf2, + WORD32 *p_out) { + WORD32 n; + + for (n = 0; n < 32; n += 2) { + WORD32 accu; + accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[(n + 256)])); + p_out[n] = accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[(n + 1 + 256)])); + p_out[n + 1] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[(n + 256)])); + p_out[n + 32] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[(n + 1 + 256)])); + p_out[n + 1 + 32] = accu; + } +} + +#define HQ_SHIFT_VAL 4 + +VOID ixheaacd_esbr_qmfanal32_winadd(WORD32 *inp1, WORD32 *inp2, WORD32 *p_qmf1, + WORD32 *p_qmf2, WORD32 *p_out, + WORD32 num_band_anal_qmf) { + WORD32 n; + WORD64 accu; + + if (num_band_anal_qmf == 32) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } else if (num_band_anal_qmf == 24) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[(n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[(n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + + } else { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } +} + +VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_sample_buf, + ia_sbr_scale_fact_struct *sbr_scale_factor, + WORD32 **qmf_real, WORD32 **qmf_imag, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD32 ch_fac, WORD32 low_pow_flag, + WORD audio_object_type) { + WORD32 i, k; + WORD32 num_time_slots = qmf_bank->num_time_slots; + + WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS]; + WORD16 *filter_states = qmf_bank->core_samples_buffer; + + WORD16 *fp1, *fp2, *tmp; + + WORD16 *filter_1; + WORD16 *filter_2; + WORD16 *filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c_eld3 - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3; + } + + filter_1 = qmf_bank->filter_pos; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_2 = filter_1 + 64; + } else { + filter_2 = filter_1 + 32; + } + + sbr_scale_factor->st_lb_scale = 0; + sbr_scale_factor->lb_scale = -10; + if (!low_pow_flag) { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + sbr_scale_factor->lb_scale = -8; + } else { + sbr_scale_factor->lb_scale = -9; + } + qmf_bank->cos_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->t_cos = (WORD16 *)qmf_dec_tables_ptr->sbr_t_cos_sin_l32; + } else { + qmf_bank->t_cos = + (WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld; + } + } + + fp1 = qmf_bank->anal_filter_states; + fp2 = qmf_bank->anal_filter_states + NO_ANALYSIS_CHANNELS; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + filter_2 = qmf_bank->filter_2; + fp1 = qmf_bank->fp1_anal; + fp2 = qmf_bank->fp2_anal; + } + + for (i = 0; i < num_time_slots; i++) { + for (k = 0; k < NO_ANALYSIS_CHANNELS; k++) + filter_states[NO_ANALYSIS_CHANNELS - 1 - k] = time_sample_buf[ch_fac * k]; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ixheaacd_sbr_qmfanal32_winadds(fp1, fp2, filter_1, filter_2, + analysis_buffer, filter_states, + time_sample_buf, ch_fac); + } else { + ixheaacd_sbr_qmfanal32_winadds_eld(fp1, fp2, filter_1, filter_2, + analysis_buffer, filter_states, + time_sample_buf, ch_fac); + } + + time_sample_buf += NO_ANALYSIS_CHANNELS * ch_fac; + + filter_states -= NO_ANALYSIS_CHANNELS; + if (filter_states < qmf_bank->anal_filter_states) { + filter_states = qmf_bank->anal_filter_states + 288; + } + + tmp = fp1; + fp1 = fp2; + fp2 = tmp; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_1 += 64; + filter_2 += 64; + } else { + filter_1 += 32; + filter_2 += 32; + } + + filt_ptr = filter_1; + filter_1 = filter_2; + filter_2 = filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + if (filter_2 > (qmf_bank->analy_win_coeff + 640)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 64; + } + } else { + if (filter_2 > (qmf_bank->analy_win_coeff + 320)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 32; + } + } + + if (!low_pow_flag) { + ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i], + qmf_bank, qmf_dec_tables_ptr); + } else { + ixheaacd_dct3_32( + (WORD32 *)analysis_buffer, qmf_real[i], qmf_dec_tables_ptr->dct23_tw, + qmf_dec_tables_ptr->post_fft_tbl, qmf_dec_tables_ptr->w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + } + } + + qmf_bank->filter_pos = filter_1; + qmf_bank->core_samples_buffer = filter_states; + + if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD) + + { + qmf_bank->fp1_anal = fp1; + qmf_bank->fp2_anal = fp2; + qmf_bank->filter_2 = filter_2; + } +} + +static PLATFORM_INLINE VOID +ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states, + ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 L = syn_qmf->no_channels; + const WORD32 M = (L >> 1); + WORD32 *dct_in = qmf_real; + WORD32 time_out[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 ui_rem = ((WORD32)(&time_out[0]) % 8); + WORD32 *ptime_out = (pVOID)((WORD8 *)&time_out[0] + 8 - ui_rem); + + if (L == 64) + ixheaacd_dec_DCT2_64_asm(dct_in, ptime_out, qmf_dec_tables_ptr->w1024, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->post_fft_tbl, + qmf_dec_tables_ptr->dct23_tw, filter_states + M); + else + ixheaacd_dct2_32(dct_in, time_out, qmf_dec_tables_ptr, filter_states); + + filter_states[3 * M] = 0; +} + +static VOID ixheaacd_inv_emodulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + ixheaacd_cos_sin_mod(qmf_real, syn_qmf, (WORD16 *)qmf_dec_tables_ptr->w1024, + (WORD32 *)qmf_dec_tables_ptr->dig_rev_table2_128); +} + +#define HQ_SHIFT_64 4 +#define RADIXSHIFT 1 +VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl) { + WORD32 z; + WORD32 temp[128]; + WORD32 scaleshift = 0; + + WORD32 M_2; + WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1); + + const WORD32 *p_sin; + const WORD32 *p_sin_cos; + + WORD32 subband_tmp[128]; + + p_sin_cos = qmf_bank->esbr_cos_twiddle; + ixheaacd_esbr_cos_sin_mod_loop1(subband, M, p_sin_cos, subband_tmp); + + M_2 = ixheaacd_shr32(M, 1); + if (M == 32) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2); + ixheaacd_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2); + ixheaacd_postradixcompute2(&subband[64], &subband_tmp[64], p_dig_rev_tbl, + 32); + + } + + else if (M == 16) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 4); + ixheaacd_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4); + ixheaacd_postradixcompute4(&subband[64], &subband_tmp[64], p_dig_rev_tbl, + 16); + + } + + else if (M == 12) { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[12 + z] = subband_tmp[2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z]; + subband[2 * z + 1] = temp[z + 12]; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[12 + z] = subband_tmp[64 + 2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z]; + subband[64 + 2 * z + 1] = temp[z + 12]; + } + + } + + else { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[8 + z] = subband_tmp[2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z] << scaleshift; + subband[2 * z + 1] = temp[z + 8] << scaleshift; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[8 + z] = subband_tmp[64 + 2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z] << scaleshift; + subband[64 + 2 * z + 1] = temp[8 + z] << scaleshift; + } + } + p_sin = qmf_bank->esbr_alt_sin_twiddle; + ixheaacd_esbr_cos_sin_mod_loop2(subband, p_sin, M); +} + +VOID ixheaacd_esbr_inv_modulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + ixheaacd_esbr_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->esbr_w_32, + qmf_dec_tables_ptr->dig_rev_table2_32); +} + +VOID ixheaacd_sbr_qmfsyn64_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac); + +VOID ixheaacd_sbr_qmfsyn32_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac) { + WORD32 k; + WORD32 rounding_fac = 0x8000; + rounding_fac = rounding_fac >> shift; + + for (k = 0; k < 32; k++) { + WORD32 syn_out = rounding_fac; + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[0 + k], inp1[2 * (k + 0)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[128 + k], inp1[2 * (k + 64)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[256 + k], inp1[2 * (k + 128)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[384 + k], inp1[2 * (k + 192)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[512 + k], inp1[2 * (k + 256)])); + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[64 + k], inp1[2 * (k + 32)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[192 + k], inp1[2 * (k + 96)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[320 + k], inp1[2 * (k + 160)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[448 + k], inp1[2 * (k + 224)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[576 + k], inp1[2 * (k + 288)])); + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + if (shift == 2) { + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + } + sample_buffer[ch_fac * k] = (syn_out >> 16); + } +} + +void ixheaacd_sbr_pre_twiddle(WORD32 *pXre, WORD32 *pXim, WORD16 *pTwiddles) { + int k; + + for (k = 62; k >= 0; k--) { + WORD32 Xre = *pXre; + WORD32 Xim = *pXim; + + WORD16 ixheaacd_cosine = *pTwiddles++; + WORD16 ixheaacd_sine = *pTwiddles++; + + WORD32 re, im; + + re = ixheaacd_mac32x16in32_shl( + ixheaacd_mult32x16in32_shl(Xre, ixheaacd_cosine), Xim, ixheaacd_sine); + im = ixheaacd_sub32(ixheaacd_mult32x16in32_shl(Xim, ixheaacd_cosine), + ixheaacd_mult32x16in32_shl(Xre, ixheaacd_sine)); + + *pXre++ = re; + *pXim++ = im; + } +} + +VOID ixheaacd_cplx_synt_qmffilt( + WORD32 **qmf_real, WORD32 **qmf_imag, WORD32 split, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 *time_out, + ia_sbr_qmf_filter_bank_struct *qmf_bank, ia_ps_dec_struct *ptr_ps_dec, + FLAG active, FLAG low_pow_flag, ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD32 ch_fac, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type) { + WORD32 i; + + WORD32 code_scale_factor; + WORD32 scale_factor; + WORD32 out_scale_factor; + WORD32 low_band_scale_factor; + WORD32 high_band_scale_factor; + WORD16 *filter_states = qmf_bank->filter_states; + WORD32 **ptr_qmf_imag_temp; + WORD32 qmf_real2[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 no_synthesis_channels = qmf_bank->no_channels; + WORD32 p1; + + WORD16 *fp1; + WORD16 *fp2; + + WORD32 sixty4 = NO_SYNTHESIS_CHANNELS; + WORD32 thirty2 = qmf_bank->no_channels; + + WORD16 *filter_coeff; + WORD32 num_time_slots = qmf_bank->num_time_slots; + WORD32 ixheaacd_drc_offset; + WORD32 ov_lb_scale = sbr_scale_factor->ov_lb_scale; + WORD32 lb_scale = sbr_scale_factor->lb_scale; + WORD32 st_syn_scale = sbr_scale_factor->st_syn_scale; + WORD32 ov_lb_shift, lb_shift, hb_shift; + + WORD32 *qmf_real_tmp = qmf_real2; + WORD32 *qmf_imag_tmp = &qmf_real2[NO_SYNTHESIS_CHANNELS]; + WORD32 env = 0; + + WORD32 common_shift; + + if (no_synthesis_channels == 32) { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + qmf_bank->t_cos = + (WORD16 *) + sbr_tables_ptr->qmf_dec_tables_ptr->sbr_cos_sin_twiddle_ds_l32; + } else { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64; + } + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld; + } + + fp1 = &filter_states[0]; + fp2 = fp1 + no_synthesis_channels; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + fp1 = qmf_bank->fp1_syn; + fp2 = qmf_bank->fp2_syn; + sixty4 = qmf_bank->sixty4; + } + + filter_coeff = qmf_bank->filter_pos_syn; + + if (active) { + code_scale_factor = scale_factor = sbr_scale_factor->ps_scale; + } else { + code_scale_factor = ixheaacd_min32(lb_scale, ov_lb_scale); + scale_factor = sbr_scale_factor->hb_scale; + } + + low_band_scale_factor = (st_syn_scale - code_scale_factor); + high_band_scale_factor = (st_syn_scale - scale_factor); + + p1 = 0; + + if (low_pow_flag) + + { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 4; + lb_shift = (st_syn_scale - lb_scale) - 4; + hb_shift = high_band_scale_factor - 4; + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 1)); + ptr_qmf_imag_temp = 0; + + } + + else { + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 3)); + if (active) { + ov_lb_shift = (sbr_scale_factor->ps_scale - ov_lb_scale); + lb_shift = (sbr_scale_factor->ps_scale - lb_scale); + hb_shift = (sbr_scale_factor->ps_scale - sbr_scale_factor->hb_scale); + common_shift = low_band_scale_factor - 8; + + } else { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 8; + lb_shift = (st_syn_scale - lb_scale) - 8; + hb_shift = high_band_scale_factor - 8; + } else { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 7; + lb_shift = (st_syn_scale - lb_scale) - 7; + hb_shift = high_band_scale_factor - 7; + } + common_shift = 0; + } + ptr_qmf_imag_temp = qmf_imag; + } + + { + if (ov_lb_shift == lb_shift) { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + num_time_slots, ov_lb_shift, low_pow_flag); + + } else { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + split, ov_lb_shift, low_pow_flag); + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, + split, num_time_slots, lb_shift, low_pow_flag); + } + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, qmf_bank->lsb, + qmf_bank->usb, 0, num_time_slots, hb_shift, + low_pow_flag); + } + + ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; + + if (1 == drc_on) { + for (i = 0; i < num_time_slots; i++) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + } + + if (low_pow_flag) + + { + WORD16 *fptemp; + + VOID(*sbr_qmf_syn_winadd) + (WORD16 *, WORD16 *, WORD16 *, WORD16 *, FLAG, WORD32); + ia_qmf_dec_tables_struct *qmf_tab_ptr = sbr_tables_ptr->qmf_dec_tables_ptr; + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn32_winadd; + else + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn64_winadd; + + for (i = 0; i < num_time_slots; i++) { + ixheaacd_inv_modulation_lp(qmf_real[i], + &filter_states[ixheaacd_drc_offset], qmf_bank, + qmf_tab_ptr); + + sbr_qmf_syn_winadd(fp1, fp2, filter_coeff, &time_out[ch_fac * p1], 2, + ch_fac); + + ixheaacd_drc_offset -= no_synthesis_channels << 1; + + if (ixheaacd_drc_offset < 0) + ixheaacd_drc_offset += ((no_synthesis_channels << 1) * 10); + + fptemp = fp1; + fp1 = fp2; + fp2 = fptemp; + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + } + + } else { + for (i = 0; i < num_time_slots; i++) { + WORD32 *t_qmf_imag; + t_qmf_imag = qmf_imag[i]; + + if (active) { + if (i == ptr_ps_dec->border_position[env]) { + ixheaacd_init_rot_env(ptr_ps_dec, (WORD16)env, qmf_bank->usb, + sbr_tables_ptr, pstr_common_tables->trig_data); + env++; + } + + ixheaacd_apply_ps(ptr_ps_dec, &qmf_real[i], &qmf_imag[i], qmf_real_tmp, + qmf_imag_tmp, sbr_scale_factor, (WORD16)i, + sbr_tables_ptr); + } + if (1 == drc_on) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + + if (active) { + if (common_shift) + ixheaacd_shiftrountine(qmf_real[i], t_qmf_imag, no_synthesis_channels, + common_shift); + } + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) + ixheaacd_sbr_pre_twiddle( + qmf_real[i], t_qmf_imag, + sbr_tables_ptr->qmf_dec_tables_ptr->ixheaacd_sbr_synth_cos_sin_l32); + + ixheaacd_inv_emodulation(qmf_real[i], qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); + + { + WORD32 temp_out_scale_fac = out_scale_factor + 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp_out_scale_fac = temp_out_scale_fac - 1; + ixheaacd_shiftrountine_with_rnd_eld( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + } + + else { + ixheaacd_shiftrountine_with_rnd( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + } + } + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn32_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += thirty2; + fp2 -= thirty2; + thirty2 = -thirty2; + + ixheaacd_drc_offset -= 64; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 640; + + } else { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn64_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += sixty4; + fp2 -= sixty4; + sixty4 = -sixty4; + ixheaacd_drc_offset -= 128; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; + } + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + + if (active) + memcpy(qmf_real[i], qmf_real_tmp, + 2 * no_synthesis_channels * sizeof(WORD32)); + } + } + + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + qmf_bank->fp1_syn = fp1; + qmf_bank->fp2_syn = fp2; + qmf_bank->sixty4 = sixty4; + } + + qmf_bank->filter_pos_syn = filter_coeff; + qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; +} diff --git a/decoder/armv7/ixheaacd_radix4_bfly.s b/decoder/armv7/ixheaacd_radix4_bfly.s new file mode 100644 index 0000000..cad16ea --- /dev/null +++ b/decoder/armv7/ixheaacd_radix4_bfly.s @@ -0,0 +1,149 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_radix4bfly + +ixheaacd_radix4bfly: + + STMFD sp!, {r4-r12, r14} + + SUB sp, sp, #16 + + MOV r6, #6 + MUL r7, r6, r3 + MOV r4, r3 + STR r7, [sp] + + + + MOV r3, r3, lsl #1 + + STR r2, [sp, #8] + STR r4, [sp, #12] + + + ADD r2, r1, r3, lsl #2 + ADD r0, r0, #8 + + +RADIX4_OUTLOOP: +RADIX4_INLOOP: + + + LDR r6, [r1] + LDR r7, [r2] + LDR r8, [r2, r3, lsl #2] + LDR r9, [r2, r3, lsl #3] + + ADD r10, r6, r8 + SUB r11, r6, r8 + ADD r12, r7, r9 + SUB r14, r7, r9 + + ADD r6, r10, r12 + SUB r7, r10, r12 + STR r6, [r1], #4 + + LDR r8, [r1] + LDR r6, [r2, #4]! + LDR r9, [r2, r3, lsl #2]! + LDR r10, [r2, r3, lsl #2]! + + ADD r12, r8, r9 + SUB r8, r8, r9 + ADD r9, r6, r10 + SUB r6, r6, r10 + + ADD r10, r12, r9 + STR r10, [r1], #4 + SUB r12, r12, r9 + + ADD r9, r11, r6 + SUB r10, r11, r6 + ADD r11, r8, r14 + LDR r5, [r0], #-4 + SUB r6, r8, r14 + + SMULWB r14, r10, r5 + SMULWT r8, r11, r5 + + SUBS r4, r4, #1 + SUB r8, r8, r14 + MOV r8, r8, lsl #1 + STR r8, [r2], #-4 + + SMULWT r14, r10, r5 + SMLAWB r8, r11, r5, r14 + LDR r11, [r0], #-4 + MOV r8, r8, lsl #1 + STR r8, [r2], -r3, lsl #2 + + SMULWT r10, r7, r11 + SMLAWB r8, r12, r11, r10 + + LDR r14, [r0], #20 + MOV r5, r8, lsl #1 + + SMULWB r10, r7, r11 + SMULWT r8, r12, r11 + + STR r5, [r2], #4 + SUB r7, r8, r10 + MOV r7, r7, lsl #1 + + SMULWB r11, r9, r14 + SMULWT r12, r6, r14 + + STR r7, [r2], -r3, lsl #2 + SUB r12, r12, r11 + MOV r12, r12, lsl #1 + + SMULWT r10, r9, r14 + SMLAWB r7, r6, r14, r10 + + STR r12, [r2], #-4 + MOV r7, r7, lsl #1 + STR r7, [r2], #8 + + + BNE RADIX4_INLOOP + + LDR r8, [sp] + LDR r4, [sp, #12] + LDR r6, [sp, #8] + + + SUB r0, r0, r8, lsl #1 + ADD r1, r1, r8, lsl #2 + ADD r2, r2, r8, lsl #2 + + SUBS r6, r6, #1 + STR r6, [sp, #8] + BNE RADIX4_OUTLOOP + + + + ADD sp, sp, #16 + LDMFD sp!, {r4-r12, r15} + + diff --git a/decoder/armv7/ixheaacd_rescale_subbandsamples.s b/decoder/armv7/ixheaacd_rescale_subbandsamples.s new file mode 100644 index 0000000..74cf59d --- /dev/null +++ b/decoder/armv7/ixheaacd_rescale_subbandsamples.s @@ -0,0 +1,205 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_adjust_scale_armv7 +ixheaacd_adjust_scale_armv7: + STMFD SP!, {R4-R11, R14} + LDR R4, [SP, #44] + LDR R5, [SP, #36] + LDR R6, [SP, #40] + MOVS R4, R4 + BEQ ENDRESSCALE + SUBS R3, R3, R2 + BLE ENDRESSCALE + SUBS R6, R6, R5 + BLE ENDRESSCALE + + ADD R9, R0, R5, LSL#2 + LDR R10, [R9], #4 + + CMP R4, #31 + MOVGT R4, #31 + CMP R4, #-31 + MOVLT R4, #-31 + + + LDR R8, [SP, #48] + MOVS R8, R8 + BEQ ELIF1 + + + MOVS R4, R4 + BLE ELIF2_1 + +LOOP1: + ADD R10, R10, R2, LSL #2 + MOV R7, R3 + +INNLOOP1: + LDR R11, [R10] + SUBS R7, R7 , #2 + LDRGE R5, [R10, #4] + + MOV R11, R11, LSL R4 + STR R11, [R10], #4 + + MOVGE R5, R5, LSL R4 + STRGE R5, [R10], #4 + + BGT INNLOOP1 + + LDR R10, [R9], #4 + SUBS R6, R6, #1 + BGT LOOP1 + + B ENDRESSCALE + +ELIF2_1: + RSB R4, R4, #0 + +LOOP2: + ADD R10, R10, R2, LSL #2 + MOV R7, R3 +INNLOOP2: + LDR R11, [R10] + SUBS R7, R7 , #2 + LDRGE R5, [R10, #4] + + MOV R11, R11, ASR R4 + STR R11, [R10], #4 + + MOVGE R5, R5, ASR R4 + STRGE R5, [R10], #4 + + BGT INNLOOP2 + + LDR R10, [R9], #4 + SUBS R6, R6, #1 + BGT LOOP2 + + + + + B ENDRESSCALE + +ELIF1: + ADD R5, R1, R5, LSL#2 + + MOVS R4, R4 + BLE ELIF2_2 +LOOP3: + LDR R8, [R5], #4 + ADD R10, R10, R2, LSL #2 + ADD R8, R8, R2, LSL #2 + BICS R7, R3, #1 + BEQ COUNTODD1 +INNLOOP3: + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, LSL R4 + MOV R1, R1, LSL R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, LSL R4 + MOV R1, R1, LSL R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + SUBS R7, R7 , #2 + BGT INNLOOP3 +COUNTODD1: + BIC R7, R3, #1 + CMP R7, R3 + BEQ INNLOOP3END + + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, LSL R4 + MOV R1, R1, LSL R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + + +INNLOOP3END: + + + LDR R10, [R9], #4 + SUBS R6, R6, #1 + BGT LOOP3 + B ENDRESSCALE + +ELIF2_2: + RSB R4, R4, #0 + +LOOP4: + LDR R8, [R5], #4 + ADD R10, R10, R2, LSL #2 + ADD R8, R8, R2, LSL #2 + BICS R7, R3, #1 + BEQ COUNTODD2 +INNLOOP4: + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, ASR R4 + MOV R1, R1, ASR R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, ASR R4 + MOV R1, R1, ASR R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + + SUBS R7, R7 , #2 + BGT INNLOOP4 +COUNTODD2: + BIC R7, R3, #1 + CMP R7, R3 + BEQ INNLOOP4END + + LDR R11, [R10] + LDR R1, [R8] + MOV R11, R11, ASR R4 + MOV R1, R1, ASR R4 + STR R11, [R10], #4 + STR R1, [R8], #4 + + +INNLOOP4END: + LDR R10, [R9], #4 + SUBS R6, R6, #1 + BGT LOOP4 + + +ENDRESSCALE: + LDMFD sp!, {r4-r11, r15} + + + diff --git a/decoder/armv7/ixheaacd_sbr_imdct_using_fft.s b/decoder/armv7/ixheaacd_sbr_imdct_using_fft.s new file mode 100644 index 0000000..d398eb7 --- /dev/null +++ b/decoder/armv7/ixheaacd_sbr_imdct_using_fft.s @@ -0,0 +1,855 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + + .global ixheaacd_sbr_imdct_using_fft +ixheaacd_sbr_imdct_using_fft: + + STMFD sp!, {r4-r12, lr} + VPUSH {D8 - D15} + + + + + + + + + + + + + + + + + + LDR r5, [sp, #0x68] + LDR r6, [sp, #0x68+4] + LDR r7, [sp, #0x68+8] + + + + + + +COND_6: CMP r1, #0x10 + BNE COND_7 + MOV r8, #1 + MOV r4, r7 + B RADIX_4_FIRST_START + +COND_7: CMP r1, #0x20 + + MOV r8, #1 + MOV r4, r7 + + + + + + + + + +RADIX_8_FIRST_START: + + + LSR r9 , r1, #5 + LSL r1, r1, #1 + +RADIX_8_FIRST_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + + + + + + + + + + + + + + + + + + + + + + + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + SUB r5, r5, r1, LSL #2 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + SUB r6, r6, r1, LSL #2 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12 , LSL #3 + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + SUB r7, r7, r1, LSL #1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + SUB r11, r11, r1, LSL #1 + + + + VADD.I32 q8, q0, q4 + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + + VSUB.I32 q9, q0, q4 + VLD2.32 {d13[0], d15[0]}, [r7], r1 + SUB r7, r7, r1, LSL #2 + + + + + VADD.I32 q0, q1, q5 + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + + VSUB.I32 q4, q1, q5 + VLD2.32 {d13[1], d15[1]}, [r11], r1 + SUB r11, r11, r1, LSL #2 + + + + ADD r4, r4, #4 + + ADD r5, r5, r1, LSR #1 + ADD r6, r6, r1, LSR #1 + ADD r7, r7, r1, LSR #1 + ADD r11, r11, r1, LSR #1 + + + VADD.I32 q1, q2, q6 + VLD2.32 {d28[0], d30[0]}, [r5] , r1 + + + VSUB.I32 q5, q2, q6 + VLD2.32 {d20[0], d22[0]}, [r5] , r1 + + + VADD.I32 q2, q3, q7 + VLD2.32 {d24[0], d26[0]}, [r5] , r1 + + + VSUB.I32 q6, q3, q7 + VLD2.32 {d28[1], d30[1]}, [r6] , r1 + + VADD.S32 q3, q9, q6 + VLD2.32 {d20[1], d22[1]}, [r6] , r1 + + VSUB.S32 q7, q9, q6 + VLD2.32 {d24[1], d26[1]}, [r6] , r1 + + VSUB.S32 q6, q4, q5 + VLD2.32 {d29[0], d31[0]}, [r7] , r1 + + VADD.S32 q9, q4, q5 + VLD2.32 {d21[0], d23[0]}, [r7] , r1 + + VADD.S32 q4, q8, q1 + VLD2.32 {d25[0], d27[0]}, [r7] , r1 + + VSUB.S32 q5, q8, q1 + VLD2.32 {d29[1], d31[1]}, [r11] , r1 + + VADD.S32 q8, q0, q2 + VLD2.32 {d21[1], d23[1]}, [r11] , r1 + + VSUB.S32 q0, q0, q2 + VLD2.32 {d25[1], d27[1]}, [r11] , r1 + + + VPUSH {q3} + VPUSH {q7} + + + + + + + + + VLD2.32 {d2[0], d4[0]}, [r5], r1 + + VADD.I32 q7, q14, q12 + + VLD2.32 {d2[1], d4[1]}, [r6] , r1 + + VSUB.I32 q3, q14, q12 + + VLD2.32 {d3[0], d5[0]}, [r7] , r1 + + VADD.I32 q14, q15, q13 + + VLD2.32 {d3[1], d5[1]}, [r11] , r1 + + VSUB.I32 q12, q15, q13 + + + + + + + + + + VADD.I32 q15, q10, q1 + VSUB.I32 q13, q10, q1 + VADD.I32 q10, q11, q2 + VSUB.I32 q1, q11, q2 + + + + VADD.S32 q11, q7, q15 + VSUB.S32 q2, q7, q15 + VADD.S32 q7, q14, q10 + VSUB.S32 q15, q14, q10 + + VADD.S32 q14, q3, q12 + VSUB.S32 q10, q3, q12 + VADD.S32 q3, q13, q1 + VSUB.S32 q12, q13, q1 + + VADD.S32 q1 , q14, q12 + VSUB.S32 q13, q14, q12 + VSUB.S32 q12, q3, q10 + + VUZP.16 d2, d3 + VADD.S32 q14, q3, q10 + + VUZP.16 d26, d27 + VADD.S32 q3, q4, q11 + + VUZP.16 d24, d25 + VSUB.S32 q10, q4, q11 + + VUZP.16 d28, d29 + VADD.S32 q4, q8, q7 + + LDR r14, =0x5a82 + + VSUB.S32 q11, q8, q7 + + VADD.S32 q8, q5, q15 + VSUB.S32 q7, q5, q15 + VSUB.S32 q5, q0, q2 + VADD.S32 q15, q0, q2 + + VPOP {q0} + VPOP {q2} + VPUSH {q3-q4} + VPUSH {q10} + + + + + + + + + + + + + + + + + + VDUP.16 d20, r14 + + + VMULL.u16 q4, d26, d20 + VMULL.u16 q3, d28, d20 + + VPUSH {q7-q8} + VPUSH {q5} + + VSHR.S32 q4, q4, #15 + VSHR.S32 q3, q3, #15 + + VQDMLAL.S16 q4, d27, d20 + VQDMLAL.S16 q3, d29, d20 + + + VPUSH {q11} + + VMULL.u16 q13, d24, d20 + VMULL.u16 q14, d2, d20 + + VADD.S32 q5, q2, q4 + VSUB.S32 q7, q2, q4 + + VADD.S32 q8, q6, q3 + VSUB.S32 q6, q6, q3 + + + + + + + VSHR.S32 q13, q13, #15 + VSHR.S32 q14, q14, #15 + + VQDMLAL.S16 q13, d25, d20 + VQDMLAL.S16 q14, d3, d20 + + VPOP {q1} + VPOP {q10} + + VADD.S32 q2, q0, q13 + VSUB.S32 q4, q0, q13 + + VADD.S32 q11, q9, q14 + VSUB.S32 q3, q9, q14 + + + + + VPOP {q14} + VPOP {q9} + VPOP {q0} + VPOP {q12, q13} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VTRN.32 q12, q5 + + VSHL.S32 q12, q12, #1 + VTRN.32 q9, q2 + VSHL.S32 q5, q5, #1 + + VSHL.S32 q9, q9, #1 + VTRN.32 q0, q7 + VSHL.S32 q2, q2, #1 + + VSHL.S32 q0, q0, #1 + VTRN.32 q14, q4 + VSHL.S32 q7, q7, #1 + + VSHL.S32 q14, q14, #1 + VTRN.32 q13, q6 + VSHL.S32 q4, q4, #1 + + VSHL.S32 q13, q13, #1 + VTRN.32 q10, q3 + VSHL.S32 q6, q6, #1 + + VSHL.S32 q10, q10, #1 + VTRN.32 q1, q8 + VSHL.S32 q3, q3, #1 + + VSHL.S32 q1, q1, #1 + VTRN.32 q15, q11 + VSHL.S32 q8, q8, #1 + + VSHL.S32 q15, q15, #1 + VSWP d18, d25 + + VSHL.S32 q11, q11, #1 + VSWP d4, d11 + + VSWP d1, d28 + VSWP d15, d8 + + VSWP d20, d27 + VSWP d6, d13 + + VSWP d30, d3 + VSWP d22, d17 + + VST2.32 {q12, q13}, [r3]! + VST2.32 {q0, q1}, [r3]! + + VST2.32 {q5, q6}, [r3]! + VST2.32 {q7, q8}, [r3]! + + VMOV q5, q11 + + VST2.32 {q9, q10}, [r3]! + VST2.32 {q14, q15}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q4, q5}, [r3]! + + + SUBS r9, r9, #1 + BNE RADIX_8_FIRST_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + + MOV r5, #8 + MOV r4, #32 + LSR r6, r1, #5 + + B RADIX_4_FIRST_ENDS + +RADIX_8_FIRST_ENDS: + + + + + + +RADIX_4_FIRST_START: + + + LSR r9 , r1, #4 + LSL r1, r1, #1 + +RADIX_4_LOOP: + + MOV r5 , r2 + MOV r6 , r2 + MOV r7 , r2 + MOV r11 , r2 + + + + + + + + + + + + + + + + LDRB r12, [r4, #0] + ADD r5, r5, r12, LSL #3 + + VLD2.32 {d0[0], d2[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d8[0], d10[0]}, [r5] , r1 + SUB r5, r5, r1, LSL #1 + VLD2.32 {d4[0], d6[0]}, [r5] , r1 + ADD r5, r5, r1 + VLD2.32 {d12[0], d14[0]}, [r5], r1 + + LDRB r12, [r4, #1] + ADD r6, r6, r12, LSL #3 + + VLD2.32 {d0[1], d2[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d8[1], d10[1]}, [r6] , r1 + SUB r6, r6, r1, LSL #1 + VLD2.32 {d4[1], d6[1]}, [r6] , r1 + ADD r6, r6, r1 + VLD2.32 {d12[1], d14[1]}, [r6], r1 + + + LDRB r12, [r4, #2] + ADD r7, r7, r12, LSL #3 + + VLD2.32 {d1[0], d3[0]}, [r7] , r1 + ADD r7, r7, r1 + VLD2.32 {d9[0], d11[0]}, [r7] , r1 + + LDRB r12, [r4, #3] + ADD r11, r11, r12 , LSL #3 + + VLD2.32 {d1[1], d3[1]}, [r11] , r1 + ADD r11, r11, r1 + VLD2.32 {d9[1], d11[1]}, [r11] , r1 + + + SUB r7, r7, r1, LSL #1 + VADD.S32 q8, q0, q4 + VLD2.32 {d5[0], d7[0]}, [r7] , r1 + ADD r7, r7, r1 + VADD.S32 q9, q1, q5 + VLD2.32 {d13[0], d15[0]}, [r7], r1 + + + + SUB r11, r11, r1, LSL #1 + VSUB.S32 q10, q0, q4 + VLD2.32 {d5[1], d7[1]}, [r11] , r1 + ADD r11, r11, r1 + VSUB.S32 q11, q1, q5 + VLD2.32 {d13[1], d15[1]}, [r11], r1 + + + ADD r4, r4, #4 + + VADD.S32 q12, q2, q6 + VADD.S32 q13, q3, q7 + VSUB.S32 q14, q2, q6 + VSUB.S32 q15, q3, q7 + + VADD.S32 q0, q8, q12 + VADD.S32 q1, q9, q13 + VSUB.S32 q2, q8, q12 + VSUB.S32 q3, q9, q13 + + VADD.S32 q4, q10, q15 + VSUB.S32 q5, q11, q14 + VADD.S32 q7, q11, q14 + VSUB.S32 q6, q10, q15 + + + + + VTRN.32 q0, q4 + + VSHL.S32 q0, q0, #1 + VTRN.32 q2, q6 + VSHL.S32 q4, q4, #1 + + VSHL.S32 q2, q2, #1 + VTRN.32 q1, q5 + VSHL.S32 q6, q6, #1 + + VSHL.S32 q1, q1, #1 + VTRN.32 q3, q7 + VSHL.S32 q5, q5, #1 + + VSHL.S32 q3, q3, #1 + VSWP d4, d1 + + VSHL.S32 q7, q7, #1 + VSWP d12, d9 + + + + VSWP d6, d3 + VSWP d14, d11 + + + VST2.32 {q0, q1}, [r3]! + VST2.32 {q4, q5}, [r3]! + + VST2.32 {q2, q3}, [r3]! + VST2.32 {q6, q7}, [r3]! + + + + SUBS r9, r9, #1 + BNE RADIX_4_LOOP + + LSR r1, r1, #1 + SUB r3, r1, LSL #3 + MOV r5, #4 + MOV r4, #64 + LSR r6, r1, #4 + + +RADIX_4_FIRST_ENDS: + + + + + + + + + + + + + + + + + + + + + + + PUSH {r3} + + LSR r5, r5, #2 + +OUTER_LOOP_R4: + + LDR r14, [sp] + + + MOV r7, r5 + MOV r2, #0 + MOV r9, r0 + LSL r12 , r5, #5 +MIDDLE_LOOP_R4: + + + VLD2.16 {d0[0], d1[0]}, [r9], r2 + VLD2.16 {d2[0], d3[0]}, [r9], r2 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[0], d5[0]}, [r9] + ADD r10, r0, r11 + + + VLD2.16 {d0[1], d1[1]}, [r10], r11 + VLD2.16 {d2[1], d3[1]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[1], d5[1]}, [r10] + ADD r9, r0, r2 + + + VLD2.16 {d0[2], d1[2]}, [r9], r2 + VLD2.16 {d2[2], d3[2]}, [r9], r2 + ADD r11, r2, r4, LSL #2 + VLD2.16 {d4[2], d5[2]}, [r9] + ADD r10, r0, r11 + + + + VLD2.16 {d0[3], d1[3]}, [r10], r11 + VLD2.16 {d2[3], d3[3]}, [r10], r11 + ADD r2, r11, r4, LSL #2 + VLD2.16 {d4[3], d5[3]}, [r10] + ADD r9, r0, r2 + + MOV r10, r6 + + + +INNER_LOOP_R4: + + VLD2.32 {q3, q4}, [r14], r12 + + VSHR.S32 q3, q3, #1 + VLD4.16 {q5, q6}, [r14], r12 + VSHR.S32 q4, q4, #1 + + VSHR.U16 d10, d10, #1 + VLD4.16 {q7, q8}, [r14], r12 + VSHR.U16 d12, d12, #1 + + VMULL.S16 q11, d10, d0 + VMLSL.S16 q11, d12, d1 + VLD4.16 {q9, q10}, [r14], r12 + VMULL.S16 q12, d10, d1 + VMLAL.S16 q12, d12, d0 + + VSHR.U16 d14, d14, #1 + VSHR.U16 d16, d16, #1 + + SUB r14, r14, r12, LSL #2 + + VSHR.U16 d18, d18, #1 + VSHR.U16 d20, d20, #1 + + VMULL.S16 q13, d14, d2 + VMLSL.S16 q13, d16, d3 + + VSHR.S32 q11, q11, #15 + + VMULL.S16 q14, d14, d3 + VMLAL.S16 q14, d16, d2 + + VMULL.S16 q15, d18, d4 + VMLSL.S16 q15, d20, d5 + + VMLAL.S16 q11, d11, d0 + VMLSL.S16 q11, d13, d1 + + VSHR.S32 q12, q12, #15 + VSHR.S32 q13, q13, #15 + VSHR.S32 q14, q14, #15 + VSHR.S32 q15, q15, #15 + + + VMLAL.S16 q12, d11, d1 + VMLAL.S16 q12, d13, d0 + + + VMULL.S16 q5, d18, d5 + VMLAL.S16 q5, d20, d4 + + + VMLAL.S16 q13, d15, d2 + VMLSL.S16 q13, d17, d3 + + VMLAL.S16 q14, d15, d3 + VMLAL.S16 q14, d17, d2 + + + VMLAL.S16 q15, d19, d4 + VMLSL.S16 q15, d21, d5 + + VSHR.S32 q5, q5, #15 + + VMLAL.S16 q5, d19, d5 + VMLAL.S16 q5, d21, d4 + + + + CMP r7, r5 + BNE BYPASS_IF + + ADD r14, r14, r12 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.S32 d22[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.S32 d26[0], r3 + + LDR r3, [r14] + ASR r3, r3, #1 + VMOV.S32 d30[0], r3 + + SUB r14, r14, r12, LSL #1 + ADD r14, r14, #4 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.S32 d24[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.S32 d28[0], r3 + + LDR r3, [r14], r12 + ASR r3, r3, #1 + VMOV.S32 d10[0], r3 + + SUB r14, r14, #4 + + SUB r14, r14, r12, LSL #2 + +BYPASS_IF: + + VADD.S32 q6, q3, q13 + VADD.S32 q7, q4, q14 + VSUB.S32 q3, q3, q13 + VSUB.S32 q4, q4, q14 + VADD.S32 q8, q11, q15 + VADD.S32 q9, q12, q5 + + VSUB.S32 q15, q11, q15 + VSUB.S32 q14, q12, q5 + + + VADD.S32 q10, q6, q8 + VADD.S32 q11, q7, q9 + VADD.S32 q12, q3, q14 + VSUB.S32 q13, q4, q15 + + VSUB.S32 q6, q6, q8 + VST2.32 {q10, q11}, [r14], r12 + VSUB.S32 q7, q7, q9 + + VSUB.S32 q8, q3, q14 + VST2.32 {q12, q13}, [r14], r12 + VADD.S32 q9, q4, q15 + + + VST2.32 {q6, q7}, [r14], r12 + VST2.32 {q8, q9}, [r14], r12 + + + + + SUBS r10, r10, #1 + BNE INNER_LOOP_R4 + + SUB r14, r14, r1, LSL #3 + ADD r14, r14, #32 + + SUBS r7, r7, #1 + BNE MIDDLE_LOOP_R4 + + + + + LSR r4, r4, #2 + LSL r5, r5, #2 + LSR r6, r6, #2 + SUBS r8, r8, #1 + BNE OUTER_LOOP_R4 +END_LOOPS: + POP {r3} + VPOP {D8 - D15} + LDMFD sp!, {r4-r12, pc} + diff --git a/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds.s b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds.s new file mode 100644 index 0000000..7ba32ad --- /dev/null +++ b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds.s @@ -0,0 +1,265 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_sbr_qmfanal32_winadds + +ixheaacd_sbr_qmfanal32_winadds: + + STMFD sp!, {R4-R12, R14} + VPUSH {D8 - D15} + LDR R5, [SP, #108] + LDR R6, [SP, #112] + LDR R7, [SP, #116] + + MOV R9, R7, LSL #1 + + ADD r5, r5, #64 + MOV r10, #3 + +LOOP: + LDRSH r4 , [R6], r9 + LDRSH r8 , [R6], r9 + LDRSH r11 , [R6], r9 + LDRSH r12 , [R6], r9 + + + STRH r4 , [r5 , #-2]! + STRH r8 , [r5 , #-2]! + STRH r11 , [r5 , #-2]! + STRH r12 , [r5 , #-2]! + + LDRSH r4 , [R6], r9 + LDRSH r8 , [R6], r9 + LDRSH r11 , [R6], r9 + LDRSH r12 , [R6], r9 + + + STRH r4 , [r5 , #-2]! + STRH r8 , [r5 , #-2]! + STRH r11 , [r5 , #-2]! + STRH r12 , [r5 , #-2]! + + + SUBS r10, r10, #1 + + BPL LOOP + + LDR R4, [SP, #104] + + MOV R5, #8 + VLD1.16 D0, [R0]! + MOV R6, #64 + + MOV R6, R6, LSL #1 + VLD2.16 {D1, D2}, [R2]! + MOV R7, #244 + + MOV R9, R0 + ADD R0, R0, #120 + + MOV R11, R4 + VLD1.16 D2, [R0], R6 + ADD R11, R11, #128 + + + + + MOV R10, R2 + ADD R2, R2, #240 + + VMULL.S16 Q15, D0, D1 + VLD2.16 {D3, D4}, [R2]! + ADD R2, R2, #240 + + + VLD1.16 D4, [R0], R6 + VMLAL.S16 Q15, D2, D3 + + VLD2.16 {D5, D6}, [R2]! + + + ADD R2, R2, #240 + VLD1.16 D6, [R0], R6 + VMLAL.S16 Q15, D4, D5 + + VLD2.16 {D7, D8}, [R2]! + + + ADD R2, R2, #240 + VLD1.16 D8, [R0], R6 + VMLAL.S16 Q15, D6, D7 + + MOV R0, R9 + VLD2.16 {D9, D10}, [R2]! + + + ADD R2, R2, #240 + VLD1.16 D10, [R1]! + VMLAL.S16 Q15, D8, D9 + + + + MOV R9, R1 + VLD2.16 {D11, D12}, [R3]! + ADD R1, R1, #120 + + + MOV R2, R10 + VLD1.16 D12, [R1], R6 + MOV R10, R3 + + ADD R3, R3, #240 + VLD2.16 {D13, D14}, [R3]! + ADD R3, R3, #240 + + + VLD2.16 {D15, D16}, [R3]! + + VLD1.16 D14, [R1], R6 + ADD R3, R3, #240 + + + + VLD1.16 D16, [R1], R6 + SUB R5, R5, #1 + + VLD2.16 {D17, D18}, [R3]! + + + ADD R3, R3, #240 + VLD1.16 D18, [R1], R6 + + MOV R1, R9 + VLD2.16 {D19, D20}, [R3]! + + ADD R3, R3, #240 + + MOV R3, R10 + + +LOOP_1: + + + VLD1.16 D0, [R0]! + + MOV R9, R0 + VLD2.16 {D1, D2}, [R2]! + ADD R0, R0, #120 + + MOV R10, R2 + VST1.32 {Q15}, [R4]! + ADD R2, R2, #240 + + + VMULL.S16 Q15, D10, D11 + VLD1.16 D2, [R0], R6 + VMLAL.S16 Q15, D12, D13 + + VMLAL.S16 Q15, D14, D15 + VLD2.16 {D3, D4}, [R2]! + VMLAL.S16 Q15, D16, D17 + + VMLAL.S16 Q15, D18, D19 + VLD1.16 D4, [R0], R6 + ADD R2, R2, #240 + + VST1.32 {Q15}, [R11]! + + + VMULL.S16 Q15, D0, D1 + VLD2.16 {D5, D6}, [R2]! + VMLAL.S16 Q15, D2, D3 + + + + ADD R2, R2, #240 + VLD1.16 D6, [R0], R6 + VMLAL.S16 Q15, D4, D5 + + VLD2.16 {D7, D8}, [R2]! + + + ADD R2, R2, #240 + VLD1.16 D8, [R0], R6 + VMLAL.S16 Q15, D6, D7 + + MOV R0, R9 + VLD2.16 {D9, D10}, [R2]! + + + + ADD R2, R2, #240 + VLD1.16 D10, [R1]! + MOV R2, R10 + + MOV R9, R1 + VLD2.16 {D11, D12}, [R3]! + ADD R1, R1, #120 + + + VMLAL.S16 Q15, D8, D9 + VLD1.16 D12, [R1], R6 + MOV R10, R3 + + + ADD R3, R3, #240 + VLD2.16 {D13, D14}, [R3]! + ADD R3, R3, #240 + + + + VLD1.16 D14, [R1], R6 + VLD2.16 {D15, D16}, [R3]! + ADD R3, R3, #240 + + + VLD1.16 D16, [R1], R6 + VLD2.16 {D17, D18}, [R3]! + ADD R3, R3, #240 + + + VLD1.16 D18, [R1], R6 + SUBS R5, R5, #1 + + MOV R1, R9 + VLD2.16 {D19, D20}, [R3]! + + ADD R3, R3, #240 + + MOV R3, R10 + + BGT LOOP_1 + + VST1.32 {Q15}, [R4]! + VMULL.S16 Q15, D10, D11 + VMLAL.S16 Q15, D12, D13 + + VMLAL.S16 Q15, D14, D15 + VMLAL.S16 Q15, D16, D17 + VMLAL.S16 Q15, D18, D19 + + VST1.32 {Q15}, [R11]! + + VPOP {D8 - D15} + LDMFD sp!, {R4-R12, R15} + diff --git a/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s new file mode 100644 index 0000000..53392ec --- /dev/null +++ b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s @@ -0,0 +1,245 @@ +.text +.p2align 2 +.global ixheaacd_sbr_qmfanal32_winadds_eld + +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 + + MOV R9, R7, LSL #1 + + ADD r5, r5, #64 + MOV r10, #3 + +LOOP: + LDRSH r4 , [R6], r9 + LDRSH r8 , [R6], r9 + LDRSH r11 , [R6], r9 + LDRSH r12 , [R6], r9 + + + STRH r4 , [r5 , #-2]! + STRH r8 , [r5 , #-2]! + STRH r11 , [r5 , #-2]! + STRH r12 , [r5 , #-2]! + + LDRSH r4 , [R6], r9 + LDRSH r8 , [R6], r9 + LDRSH r11 , [R6], r9 + LDRSH r12 , [R6], r9 + + + STRH r4 , [r5 , #-2]! + STRH r8 , [r5 , #-2]! + STRH r11 , [r5 , #-2]! + STRH r12 , [r5 , #-2]! + + + SUBS r10, r10, #1 + + BPL LOOP + + LDR R4, [SP, #40] @winAdd + + MOV R5, #8 + VLD1.16 D0, [R0]! @tmpQ1[n + 0] load and incremented R0 by 8 + + MOV R6, #64 + MOV R6, R6, LSL #1 @ + VLD1.16 {D1, D2}, [R2]! @ tmpQmf_c1[2*(n + 0)] load and incremented + + MOV R7, #244 @ NOT USED further + + MOV R9, R0 + ADD R0, R0, #120 @ incrementing R0 by 120 + 8 = 128 + + MOV R11, R4 @ Mov winAdd to R11 + VLD1.16 D2, [R0], R6 @ tmpQ1[n + 64] load and incremented by R6 + ADD R11, R11, #128 @ increment winAdd by 128 + + + MOV R10, R2 @ + ADD R2, R2, #112 @ This should be 240 --> 112 + + VMULL.S16 Q15, D0, D1 + VLD1.16 {D3, D4}, [R2]! @ tmpQmf_c1[2*(n + 64)] load and incremented + ADD R2, R2, #112 @ This should be 112 + + + VLD1.16 D4, [R0], R6 @ tmpQ1[n + 128] load and incremented by R6 + VMLAL.S16 Q15, D2, D3 + + VLD1.16 {D5, D6}, [R2]! @ tmpQmf_c1[2*(n + 128)] load and incremented + SUB R10, R10, #8 + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D6, [R0], R6 @ tmpQ1[n + 192] load and incremented by R6 + VMLAL.S16 Q15, D4, D5 + + VLD1.16 {D7, D8}, [R2]! @ tmpQmf_c1[2*(n + 192)] load and incremented + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D8, [R0], R6 @ tmpQ1[n + 256] load and incremented by R6 + VMLAL.S16 Q15, D6, D7 + + MOV R0, R9 + VLD1.16 {D9, D10}, [R2]! @ tmpQmf_c1[2*(n + 256)] load and incremented + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D10, [R1]! @ tmpQ2[n + 0] load and incremented + VMLAL.S16 Q15, D8, D9 + + + + MOV R9, R1 + VLD1.16 {D11, D12}, [R3]! @ tmpQmf_c2[2*(n + 0)] load and incremented + ADD R1, R1, #120 @ incrementing R1 by 120 + 8 = 128 + + + MOV R2, R10 @ + VLD1.16 D12, [R1], R6 @ tmpQ2[n + 64] load and incremented by R6 + MOV R10, R3 + + ADD R3, R3, #112 @ This sholud be 112 + VLD1.16 {D13, D14}, [R3]! @ tmpQmf_c2[2*(n + 64)] load and incremented + ADD R3, R3, #112 @ This sholud be 112 + + + VLD1.16 {D15, D16}, [R3]! @ tmpQmf_c2[2*(n + 128)] load and incremented + + SUB R10, R10, #8 + + VLD1.16 D14, [R1], R6 + ADD R3, R3, #112 @ This should be 112 + + + + VLD1.16 D16, [R1], R6 + SUB R5, R5, #1 + + VLD1.16 {D17, D18}, [R3]! @ tmpQmf_c2[2*(n + 192)] load and incremented + + + ADD R3, R3, #112 @ This should be 112 + VLD1.16 D18, [R1], R6 + + MOV R1, R9 + VLD1.16 {D19, D20}, [R3]! @ tmpQmf_c2[2*(n + 256)] load and incremented + + ADD R3, R3, #112 @ This should be 112 + + MOV R3, R10 + + +LOOP_1: + + + VLD1.16 D0, [R0]! + + MOV R9, R0 + VLD1.16 {D1, D2}, [R2]! + ADD R0, R0, #120 + + MOV R10, R2 + VST1.32 {Q15}, [R4]! + ADD R2, R2, #112 @ This should be 112 + + + VMULL.S16 Q15, D10, D11 + VLD1.16 D2, [R0], R6 + VMLAL.S16 Q15, D12, D13 + + VMLAL.S16 Q15, D14, D15 + VLD1.16 {D3, D4}, [R2]! + VMLAL.S16 Q15, D16, D17 + + VMLAL.S16 Q15, D18, D19 + VLD1.16 D4, [R0], R6 + ADD R2, R2, #112 @ This should be 112 + + VST1.32 {Q15}, [R11]! + SUB R10, R10, #8 + + + VMULL.S16 Q15, D0, D1 + VLD1.16 {D5, D6}, [R2]! + VMLAL.S16 Q15, D2, D3 + + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D6, [R0], R6 + VMLAL.S16 Q15, D4, D5 + + VLD1.16 {D7, D8}, [R2]! + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D8, [R0], R6 + VMLAL.S16 Q15, D6, D7 + + MOV R0, R9 + VLD1.16 {D9, D10}, [R2]! + + + + ADD R2, R2, #112 @ This should be 112 + VLD1.16 D10, [R1]! + MOV R2, R10 + + MOV R9, R1 + VLD1.16 {D11, D12}, [R3]! + ADD R1, R1, #120 + + + VMLAL.S16 Q15, D8, D9 + VLD1.16 D12, [R1], R6 + MOV R10, R3 + + + ADD R3, R3, #112 @ This should be 112 + VLD1.16 {D13, D14}, [R3]! + ADD R3, R3, #112 @ This should be 112 + + + + VLD1.16 D14, [R1], R6 + SUB R10, R10, #8 + VLD1.16 {D15, D16}, [R3]! + ADD R3, R3, #112 @ This should be 112 + + + VLD1.16 D16, [R1], R6 + VLD1.16 {D17, D18}, [R3]! + ADD R3, R3, #112 @ This should be 112 + + + VLD1.16 D18, [R1], R6 + SUBS R5, R5, #1 + + MOV R1, R9 + VLD1.16 {D19, D20}, [R3]! + + ADD R3, R3, #112 @ This should be 112 + + MOV R3, R10 + + BGT LOOP_1 + + VST1.32 {Q15}, [R4]! + VMULL.S16 Q15, D10, D11 + VMLAL.S16 Q15, D12, D13 + + VMLAL.S16 Q15, D14, D15 + VMLAL.S16 Q15, D16, D17 + VMLAL.S16 Q15, D18, D19 + + VST1.32 {Q15}, [R11]! + + LDMFD sp!, {R4-R12, R15} diff --git a/decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s b/decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s new file mode 100644 index 0000000..a998634 --- /dev/null +++ b/decoder/armv7/ixheaacd_sbr_qmfsyn64_winadd.s @@ -0,0 +1,379 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_sbr_qmfsyn64_winadd + +ixheaacd_sbr_qmfsyn64_winadd: + + STMFD sp!, {R4-R12, R14} + VPUSH {D8- D15} + LDR R4, [SP, #104] + LDR R5, [SP, #108] + + MOV R7, #0x8000 + VLD1.16 D0, [R0]! + MOV R12, R2 + + VDUP.32 Q15, R7 + VLD1.16 D1, [R2]! + VDUP.32 Q11, R4 + + MOV R10, R0 + MOV R11, R2 + ADD R0, R0, #504 + ADD R2, R2, #248 + + VNEG.S32 Q14, Q11 + VSHL.S32 Q10, Q15, Q14 + MOV R6, #64 + MOV R6, R6, LSL #1 + ADD R12, R12, R6 + MOV R7, #128 + MOV R9, R7, LSL #1 + ADD R1, R1, R9 + MOV R6, #16 + MOV R7, #128 + MOV R9, R7, LSL #1 + MOV R7, #256 + MOV R8, R7, LSL #1 + + MOV R5, R5, LSL #1 + VLD1.16 D2, [R0], R8 + VMOV Q13, Q10 + + + VMLAL.S16 Q13, D0, D1 + VLD1.16 D3, [R2], R9 + + VLD1.16 D4, [R0], R8 + VMLAL.S16 Q13, D2, D3 + + VLD1.16 D5, [R2], R9 + + VLD1.16 D6, [R0], R8 + VMLAL.S16 Q13, D5, D4 + + VLD1.16 D7, [R2], R9 + + VLD1.16 D8, [R0], R8 + VMLAL.S16 Q13, D7, D6 + + VLD1.16 D9, [R2], R9 + MOV R0, R10 + + + MOV R2, R11 + VLD1.16 D10, [R1]! + VMLAL.S16 Q13, D9, D8 + + MOV R10, R1 + VLD1.16 D11, [R12]! + ADD R1, R1, #504 + + + + MOV R11, R12 + VLD1.16 D12, [R1], R8 + ADD R12, R12, #248 + + VMLAL.S16 Q13, D10, D11 + VLD1.16 D13, [R12], R9 + + VLD1.16 D14, [R1], R8 + VMLAL.S16 Q13, D12, D13 + + VLD1.16 D15, [R12], R9 + + VLD1.16 D16, [R1], R8 + VMLAL.S16 Q13, D15, D14 + + VLD1.16 D17, [R12], R9 + + VLD1.16 D18, [R1], R8 + VMLAL.S16 Q13, D17, D16 + + VLD1.16 D19, [R12], R9 + + VMLAL.S16 Q13, D19, D18 + VLD1.16 D0, [R0]! + MOV R12, R11 + + MOV R1, R10 + VLD1.16 D1, [R2]! + MOV R10, R0 + + VQSHL.S32 Q13, Q13, Q11 + + ADD R0, R0, #504 + + MOV R11, R2 + VLD1.16 D2, [R0], R8 + ADD R2, R2, #248 + + VSHR.S32 Q14, Q13, #16 + VLD1.16 D3, [R2], R9 + + + VUZP.16 D28, D29 + VMOV Q13, Q10 + + + + + + VLD1.16 D4, [R0], R8 + VLD1.16 D5, [R2], R9 + + VLD1.16 D6, [R0], R8 + VLD1.16 D7, [R2], R9 + + VLD1.16 D8, [R0], R8 + VLD1.16 D9, [R2], R9 + MOV R0, R10 + + + MOV R2, R11 + VLD1.16 D10, [R1]! + + MOV R10, R1 + VLD1.16 D11, [R12]! + ADD R1, R1, #504 + + + MOV R11, R12 + VLD1.16 D12, [R1], R8 + ADD R12, R12, #248 + + + VLD1.16 D13, [R12], R9 + + VLD1.16 D14, [R1], R8 + VLD1.16 D15, [R12], R9 + + VLD1.16 D16, [R1], R8 + VLD1.16 D17, [R12], R9 + + VLD1.16 D18, [R1], R8 + SUB R6, R6, #2 + VLD1.16 D19, [R12], R9 + MOV R1, R10 + + MOV R12, R11 + +LOOP_1: + + VMLAL.S16 Q13, D0, D1 + VST1.16 D28[0], [R3], R5 + + VMLAL.S16 Q13, D2, D3 + VLD1.16 D0, [R0]! + VMLAL.S16 Q13, D5, D4 + + VMLAL.S16 Q13, D7, D6 + VST1.16 D28[1], [R3], R5 + + + MOV R10, R0 + VLD1.16 D1, [R2]! + ADD R0, R0, #504 + + VMLAL.S16 Q13, D9, D8 + VST1.16 D28[2], [R3], R5 + + VMLAL.S16 Q13, D10, D11 + VST1.16 D28[3], [R3], R5 + + MOV R11, R2 + VLD1.16 D2, [R0], R8 + ADD R2, R2, #248 + + VMLAL.S16 Q13, D12, D13 + VLD1.16 D3, [R2], R9 + VMLAL.S16 Q13, D15, D14 + + VMLAL.S16 Q13, D17, D16 + VLD1.16 D4, [R0], R8 + VMLAL.S16 Q13, D19, D18 + + VLD1.16 D5, [R2], R9 + + VLD1.16 D6, [R0], R8 + VQSHL.S32 Q13, Q13, Q11 + + VSHR.S32 Q14, Q13, #16 + VLD1.16 D7, [R2], R9 + VMOV Q13, Q10 + + + VUZP.16 D28, D29 + VMLAL.S16 Q13, D0, D1 + + VMLAL.S16 Q13, D2, D3 + VLD1.16 D8, [R0], R8 + VMLAL.S16 Q13, D5, D4 + + VMLAL.S16 Q13, D7, D6 + VLD1.16 D9, [R2], R9 + + + VLD1.16 D10, [R1]! + VMLAL.S16 Q13, D9, D8 + + MOV R2, R11 + VLD1.16 D11, [R12]! + MOV R0, R10 + + MOV R10, R1 + + ADD R1, R1, #504 + + MOV R11, R12 + VLD1.16 D12, [R1], R8 + ADD R12, R12, #248 + + VLD1.16 D13, [R12], R9 + VMLAL.S16 Q13, D10, D11 + + VLD1.16 D14, [R1], R8 + VMLAL.S16 Q13, D12, D13 + + VLD1.16 D15, [R12], R9 + + VLD1.16 D16, [R1], R8 + VMLAL.S16 Q13, D15, D14 + + VLD1.16 D17, [R12], R9 + + VLD1.16 D18, [R1], R8 + VMLAL.S16 Q13, D17, D16 + + VLD1.16 D19, [R12], R9 + MOV R1, R10 + + VMLAL.S16 Q13, D19, D18 + VST1.16 D28[0], [R3], R5 + + MOV R12, R11 + VLD1.16 D0, [R0]! + + VLD1.16 D1, [R2]! + VQSHL.S32 Q13, Q13, Q11 + + + VST1.16 D28[1], [R3], R5 + MOV R10, R0 + + VST1.16 D28[2], [R3], R5 + ADD R0, R0, #504 + + VST1.16 D28[3], [R3], R5 + MOV R11, R2 + + VSHR.S32 Q14, Q13, #16 + VLD1.16 D2, [R0], R8 + ADD R2, R2, #248 + + VLD1.16 D3, [R2], R9 + VLD1.16 D4, [R0], R8 + VLD1.16 D5, [R2], R9 + VLD1.16 D6, [R0], R8 + VLD1.16 D7, [R2], R9 + VLD1.16 D8, [R0], R8 + VLD1.16 D9, [R2], R9 + + VUZP.16 D28, D29 + VMOV Q13, Q10 + + + + + MOV R0, R10 + VLD1.16 D10, [R1]! + MOV R2, R11 + + MOV R10, R1 + VLD1.16 D11, [R12]! + ADD R1, R1, #504 + + + MOV R11, R12 + VLD1.16 D12, [R1], R8 + ADD R12, R12, #248 + + + VLD1.16 D13, [R12], R9 + + VLD1.16 D14, [R1], R8 + VLD1.16 D15, [R12], R9 + + VLD1.16 D16, [R1], R8 + VLD1.16 D17, [R12], R9 + + SUBS R6, R6, #2 + VLD1.16 D18, [R1], R8 + + MOV R1, R10 + VLD1.16 D19, [R12], R9 + + MOV R12, R11 + + + BGT LOOP_1 + + VMLAL.S16 Q13, D0, D1 + VST1.16 D28[0], [R3], R5 + VMLAL.S16 Q13, D2, D3 + + VMLAL.S16 Q13, D5, D4 + VST1.16 D28[1], [R3], R5 + VMLAL.S16 Q13, D7, D6 + + VMLAL.S16 Q13, D9, D8 + VST1.16 D28[2], [R3], R5 + VMLAL.S16 Q13, D10, D11 + + VMLAL.S16 Q13, D12, D13 + VST1.16 D28[3], [R3], R5 + VMLAL.S16 Q13, D15, D14 + + + + VMLAL.S16 Q13, D17, D16 + + VMLAL.S16 Q13, D19, D18 + + VQSHL.S32 Q13, Q13, Q11 + + VSHR.S32 Q14, Q13, #16 + + VUZP.16 D28, D29 + + + VST1.16 D28[0], [R3], R5 + VST1.16 D28[1], [R3], R5 + VST1.16 D28[2], [R3], R5 + VST1.16 D28[3], [R3], R5 + + VPOP {D8 - D15} + LDMFD sp!, {R4-R12, R15} + diff --git a/decoder/armv7/ixheaacd_shiftrountine.s b/decoder/armv7/ixheaacd_shiftrountine.s new file mode 100644 index 0000000..9958e14 --- /dev/null +++ b/decoder/armv7/ixheaacd_shiftrountine.s @@ -0,0 +1,105 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + + .code 32 + .eabi_attribute 24, 1 @Tag_ABI_align_needed + .eabi_attribute 25, 1 @Tag_ABI_align_preserved +.text +.p2align 2 + .global ixheaacd_shiftrountine +ixheaacd_shiftrountine: + CMP r3, #0 + STMFD sp!, {r4-r7, r12} + MOV r12, #0x1f + BGE SROUTINE_L1 + RSB r3, r3, #0 + CMP r3, r12 + MOVGT r3, r12 + SUBS r2, r2, #2 +@ LDMMIFD sp!, {r4-r7, r12} + LDMFDMI sp!, {r4-r7, r12} + BXMI lr +SROUTINE_L2: + LDR r12, [r0, #0] + LDR r4, [r1, #0] + MOV r12, r12, ASR r3 + MOV r4, r4, ASR r3 + STR r12, [r0], #4 + STR r4, [r1], #4 + + LDR r12, [r0, #0] + LDR r4, [r1, #0] + MOV r12, r12, ASR r3 + MOV r4, r4, ASR r3 + SUBS r2, r2, #2 + STR r12, [r0], #4 + STR r4, [r1], #4 + + BPL SROUTINE_L2 + LDMFD sp!, {r4-r7, r12} + BX lr +SROUTINE_L1: + SUBS r4, r2, #2 + RSB r2, r3, #0x1f +@ LDMMIFD sp!, {r4-r7, r12} + LDMFDMI sp!, {r4-r7, r12} + BXMI lr +SROUTINE_L3: + LDR r12, [r0, #0] + LDR r5, [r1, #0] + + MOVS r7, r12, ASR r2 + CMNLT r7, #1 + MOVLT r6, #0x80000000 + MVNGT r6, #0x80000000 + MOVEQ r6, r12, LSL r3 + + MOVS r7, r5, ASR r2 + CMNLT r7, #1 + MOVLT r12, #0x80000000 + MVNGT r12, #0x80000000 + MOVEQ r12, r5, LSL r3 + STR r6, [r0], #4 + STR r12, [r1], #4 + + LDR r12, [r0, #0] + LDR r5, [r1, #0] + + MOVS r7, r12, ASR r2 + CMNLT r7, #1 + MOVLT r6, #0x80000000 + MVNGT r6, #0x80000000 + MOVEQ r6, r12, LSL r3 + + MOVS r7, r5, ASR r2 + CMNLT r7, #1 + MOVLT r12, #0x80000000 + MVNGT r12, #0x80000000 + MOVEQ r12, r5, LSL r3 + SUBS r4, r4, #2 + STR r6, [r0], #4 + STR r12, [r1], #4 + + BPL SROUTINE_L3 + LDMFD sp!, {r4-r7, r12} + BX lr + + diff --git a/decoder/armv7/ixheaacd_shiftrountine_with_rnd_eld.s b/decoder/armv7/ixheaacd_shiftrountine_with_rnd_eld.s new file mode 100644 index 0000000..642a338 --- /dev/null +++ b/decoder/armv7/ixheaacd_shiftrountine_with_rnd_eld.s @@ -0,0 +1,92 @@ +.text +.p2align 2 +.global ixheaacd_shiftrountine_with_rnd_eld + +ixheaacd_shiftrountine_with_rnd_eld: + STMFD sp!, {r4-r12, r14} + MOV r4, #0x1f + ADD r12, r2, r3, LSL #1 + MOV r9, #0x8000 + SUBS r3, r3, #1 + BMI S_WITH_R_L6 + +S_WITH_R_L5: + LDR r5, [r1, r3, LSL #2] @i2 = qmfImag[j] + LDR r7, [r0, r3, LSL #2] @r2 = qmfReal[j] + LDR r14, [r0], #4 @r1 = *qmfReal + LDR r10, [r1], #4 @i1 = *qmfImag + + ADD r6, r5, r7 @*qmfImag++ = add32(i2, r2) + MVN r6, r6 @negate32(add32(i2, r2)) + ADD r6, r6 , #1 + + @SUB r5,r5,r7 @qmfReal[j] = sub32(i2, r2) + SUB r5, r7, r5 @qmfReal[j] = sub32(r2, i2) + + ADD r7, r10, r14 @qmfImag[j] = add32(i1, r1) + MVN r7, r7 @negate32(add32(i1, r1)) + ADD r7, r7 , #1 + + @SUB r4,r10,r14 @*qmfReal++ = sub32(i1, r1) + SUB r4, r14, r10 @*qmfReal++ = sub32(r1, i1) + + @STR r7,[r1,r3,LSL #2] + @STR r5,[r0,r3,LSL #2] + @STR r6,[r1],#4 + @STR r4,[r0],#4 + + + + @LDRD r4,[r0],#8 @DEBUG + + @LDRD r6,[r1],#8 + MOVS r10, r4, ASR #0x16 @Right shift by 22 to check the overflow ( is not AAC_ELD right shifted by 21) + CMNLT r10, #1 @Check r4 is overflow or not + + MOVLT r4, #0x80000000 @saturate value if r4 is overflowed + MVNGT r4, #0x80000000 + MOVEQ r4, r4, LSL #9 @shift by 9(hardcoded value) if not AAC_ELD left shifted by 10 + + MOVS r10, r5, ASR #0x16 + QADD r4, r4, r9 + CMNLT r10, #1 + MOV r4, r4, ASR #16 + MOVLT r5, #0x80000000 + MVNGT r5, #0x80000000 + MOVEQ r5, r5, LSL #9 + MOV r14, r3, lsl #1 + + + MOVS r10, r6, ASR #0x16 + QADD r5, r5, r9 + CMNLT r10, #1 + MOV r5, r5, ASR #16 + MOVLT r6, #0x80000000 + @STRH r5,[r2],#2 + STRH r5, [r2, r14] + MVNGT r6, #0x80000000 + MOVEQ r6, r6, LSL #9 + + MOVS r10, r7, ASR #0x16 + QADD r6, r6, r9 + CMNLT r10, #1 + MOV r6, r6, ASR #16 + MOVLT r7, #0x80000000 + MVNGT r7, #0x80000000 + MOVEQ r7, r7, LSL #9 + + QADD r7, r7, r9 + STRH r4, [r2], #2 + + MOV r7, r7, ASR #16 + + @STRH r7,[r12],#2 + STRH r7, [r12, r14] + SUBS r3, r3, #2 + STRH r6, [r12], #2 + BGE S_WITH_R_L5 +S_WITH_R_L6: + LDMFD sp!, {r4-r12, r15} + + + diff --git a/decoder/armv7/ixheaacd_shiftrountine_with_round.s b/decoder/armv7/ixheaacd_shiftrountine_with_round.s new file mode 100644 index 0000000..9a43315 --- /dev/null +++ b/decoder/armv7/ixheaacd_shiftrountine_with_round.s @@ -0,0 +1,111 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + + .code 32 + .eabi_attribute 24, 1 @Tag_ABI_align_needed + .eabi_attribute 25, 1 @Tag_ABI_align_preserved +.text +.p2align 2 + .global ixheaacd_shiftrountine_with_rnd +ixheaacd_shiftrountine_with_rnd: + STMFD sp!, {r4-r12, r14} + MOV r4, #0x1f + ADD r12, r2, r3, LSL #1 + MOV r9, #0x8000 + SUBS r3, r3, #1 + BMI S_WITH_R_L6 + +S_WITH_R_L5: + LDR r5, [r1, r3, LSL #2] + LDR r7, [r0, r3, LSL #2] + LDR r14, [r0], #4 + LDR r10, [r1], #4 + + ADD r6, r5, r7 + SUB r5, r5, r7 + ADD r7, r10, r14 + SUB r4, r10, r14 + + + + + + + + + + + + MOVS r10, r4, ASR #0x15 + CMNLT r10, #1 + + MOVLT r4, #0x80000000 + MVNGT r4, #0x80000000 + MOVEQ r4, r4, LSL #10 + + MOVS r10, r5, ASR #0x15 + QADD r4, r4, r9 + CMNLT r10, #1 + MOV r4, r4, ASR #16 + MOVLT r5, #0x80000000 + MVNGT r5, #0x80000000 + MOVEQ r5, r5, LSL #10 + MOV r14, r3, lsl #1 + + + MOVS r10, r6, ASR #0x15 + QADD r5, r5, r9 + CMNLT r10, #1 + MOV r5, r5, ASR #16 + MOVLT r6, #0x80000000 + + STRH r5, [r2, r14] + MVNGT r6, #0x80000000 + MOVEQ r6, r6, LSL #10 + + MOVS r10, r7, ASR #0x15 + QADD r6, r6, r9 + CMNLT r10, #1 + MOV r6, r6, ASR #16 + MOVLT r7, #0x80000000 + MVNGT r7, #0x80000000 + MOVEQ r7, r7, LSL #10 + + QADD r7, r7, r9 + STRH r4, [r2], #2 + + MOV r7, r7, ASR #16 + + + STRH r7, [r12, r14] + SUBS r3, r3, #2 + STRH r6, [r12], #2 + BGE S_WITH_R_L5 +S_WITH_R_L6: + LDMFD sp!, {r4-r12, r15} + + + + + + + + diff --git a/decoder/armv7/ixheaacd_shiftrountine_with_round_hq.s b/decoder/armv7/ixheaacd_shiftrountine_with_round_hq.s new file mode 100644 index 0000000..a7b2d12 --- /dev/null +++ b/decoder/armv7/ixheaacd_shiftrountine_with_round_hq.s @@ -0,0 +1,75 @@ + .code 32 + .eabi_attribute 24, 1 @Tag_ABI_align_needed + .eabi_attribute 25, 1 @Tag_ABI_align_preserved +.text +.p2align 2 + .global ixheaacd_shiftrountine_with_rnd_hq +ixheaacd_shiftrountine_with_rnd_hq: + + STMFD sp!, {r4-r12, r14} + ADD r12, r2, r3, LSL #2 + MOV r9, #0x8000 + SUBS r3, r3, #1 + BMI S_WITH_R_L6 + +S_WITH_R_L5: + LDR r5, [r1, r3, LSL #2] + LDR r7, [r0, r3, LSL #2] + LDR r14, [r0], #4 + LDR r10, [r1], #4 + + ADD r6, r5, r7 + SUB r5, r5, r7 + ADD r7, r10, r14 + SUB r4, r10, r14 + + + + + + + + + + + + MOVS r10, r4, ASR #0x19 + CMNLT r10, #1 + + MOVLT r4, #0x80000000 + MVNGT r4, #0x80000000 + MOVEQ r4, r4, LSL #6 + + MOVS r10, r5, ASR #0x19 + CMNLT r10, #1 + MOVLT r5, #0x80000000 + MVNGT r5, #0x80000000 + MOVEQ r5, r5, LSL #6 + MOV r14, r3, lsl #2 + + + MOVS r10, r6, ASR #0x19 + CMNLT r10, #1 + MOVLT r6, #0x80000000 + + STR r5, [r2, r14] + MVNGT r6, #0x80000000 + MOVEQ r6, r6, LSL #6 + + MOVS r10, r7, ASR #0x19 + CMNLT r10, #1 + + MOVLT r7, #0x80000000 + MVNGT r7, #0x80000000 + MOVEQ r7, r7, LSL #6 + + STR r4, [r2], #4 + + + + STR r7, [r12, r14] + SUBS r3, r3, #2 + STR r6, [r12], #4 + BGE S_WITH_R_L5 +S_WITH_R_L6: + LDMFD sp!, {r4-r12, r15} diff --git a/decoder/armv7/ixheaacd_tns_ar_filter_fixed_32x16.s b/decoder/armv7/ixheaacd_tns_ar_filter_fixed_32x16.s new file mode 100644 index 0000000..58a8f37 --- /dev/null +++ b/decoder/armv7/ixheaacd_tns_ar_filter_fixed_32x16.s @@ -0,0 +1,272 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_tns_ar_filter_armv7 + +ixheaacd_tns_ar_filter_armv7: + + STMFD r13! , {r4 - r12, r14} + SUB sp, sp, #4 + LDR r4, [sp, #44] + LDR r6, [sp, #48] + STR r1, [sp] + LDR r12, [sp, #56] + ANDS r5, r4, #3 + ADD r12, r12, #4096 + BEQ FILTER_LOOP + + + + MOV r8, #0 + ADD r14, r3, r4, LSL #1 + RSBS r7, r5, #3 + BEQ ORDER_LOOPEND +ORDER_LOOP: + STRH r8, [r14, #2]! + SUBS r7, r7, #1 + BGT ORDER_LOOP +ORDER_LOOPEND: + STRH r8, [r14, #2] + BIC r4, r4, #3 + ADD r4, r4, #4 + + +FILTER_LOOP: + LDR r1, [sp, #52] + + + + + CMP r2, #1 + MOV r7, r4 + BNE NEG_INC + + LDR r8 , [r0] + SUBS r7 , r7 , #1 + MOV r8, r8, lsl r1 + MOV r9, r8, asr r1 + MOV r8 , r8 , lsl r6 + STR r8 , [r12], #-4 + STR r9, [r0], #4 + + BEQ FILTER_LOOP2 +FILTER_LOOP1: + LDR r8 , [r0] + SUB r5 , r4 , r7 + MOV r5 , r5 , lsl #1 + MOV r11 , #0 + ADD r14, r12, r5, lsl #1 +INNER_LOOP1: + LDRSH r9 , [r3 , r5] + LDR r10 , [r14], #-4 + SUBS r5 , r5 , #2 + SMLAWB r11 , r10, r9, r11 + BGT INNER_LOOP1 + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11, lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #4 + SUBS r7 , r7 , #1 + MOV r8 , r8 , lsl r6 + STR r8 , [r12], #-4 + BGT FILTER_LOOP1 + +FILTER_LOOP2: + LDR r1, [sp] + SUBS r7 , r1 , r4 + BLE EXIT + + LDR r1, [sp, #52] + + + + + CMP r6, #1 + BEQ SHIFT_1 + +OUTER_LOOP2: + LDR r8 , [r0] + MOV r5 , r4 , lsl #1 + MOV r11 , #0 + LDR r9 , [r3 , r5] + ADD r14 , r12, r5, lsl #1 + SUB r5 , r5 , #4 +INNER_LOOP2: + LDR r10 , [r14], #-4 + LDR r2 , [r14] , #-4 + + SMLAWB r11, r10 , r9, r11 + LDR r9 , [r3 , r5] + SUB r5 , r5 , #4 + + SMLAWT r11, r2 , r9, r11 + LDR r10 , [r14] , #-4 + LDR r2 , [r14] , #-4 + + SMLAWB r11, r10 , r9, r11 + LDR r9 , [r3 , r5] + SUBS r5 , r5 , #4 + + SMLAWT r11, r2 , r9, r11 + + BGT INNER_LOOP2 + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11, lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #4 + MOV r2 , r8 , lsl r6 + STR r2 , [r12], #-4 + SUBS r7 , r7 , #1 + BGT OUTER_LOOP2 + B EXIT + +SHIFT_1: + MOV r6, r3 + +OUTER_LOOP2_SHIFT_1: + ADD r3, r6, r4 , lsl #1 + LDR r9 , [r3 ], #-4 + + LDR r8 , [r0] + ADD r14 , r12, r4, lsl #2 + MOV r5 , r4 + MOV r11 , #0 + +INNER_LOOP2_SHIFT_1: + LDR r10 , [r14] , #-4 + LDR r2 , [r14] , #-4 + SMLAWB r11 , r10 , r9, r11 + + LDR r9 , [r3] , #-4 + LDR r10 , [r14] , #-4 + SMLAWT r11, r2 , r9, r11 + + LDR r2 , [r14] , #-4 + SMLAWB r11, r10 , r9, r11 + LDR r9 , [r3 ], #-4 + + SUBS r5 , r5 , #4 + SMLAWT r11, r2 , r9, r11 + + BGT INNER_LOOP2_SHIFT_1 + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11, lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #4 + MOV r2 , r8 , lsl #1 + STR r2 , [r12], #-4 + SUBS r7 , r7 , #1 + + + BGT OUTER_LOOP2_SHIFT_1 + + + B EXIT + + +NEG_INC: + + LDR r8 , [r0] + SUBS r7 , r7 , #1 + MOV r8, r8, lsl r1 + MOV r9, r8, asr r1 + MOV r8 , r8 , lsl r6 + STR r8 , [r12], #-4 + STR r9, [r0], #-4 + + BEQ FILTER_LOOP2_NEG +FILTER_LOOP1_NEG: + LDR r8 , [r0] + SUB r5 , r4 , r7 + MOV r5 , r5 , lsl #1 + MOV r11 , #0 + ADD r14, r12, r5, lsl #1 +INNER_LOOP1_NEG: + LDRSH r9 , [r3 , r5] + LDR r10 , [r14], #-4 + SUBS r5 , r5 , #2 + SMLAWB r11 , r10, r9, r11 + BGT INNER_LOOP1_NEG + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11, lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #-4 + SUBS r7 , r7 , #1 + MOV r8 , r8 , lsl r6 + STR r8 , [r12], #-4 + BGT FILTER_LOOP1_NEG + +FILTER_LOOP2_NEG: + LDR r1, [sp] + SUBS r7 , r1 , r4 + BLE EXIT + + LDR r1, [sp, #52] + + + + +OUTER_LOOP2_NEG: + LDR r8 , [r0] + MOV r5 , r4 , lsl #1 + MOV r11 , #0 + LDR r9 , [r3 , r5] + ADD r14 , r12, r5, lsl #1 + SUB r5 , r5 , #4 +INNER_LOOP2_NEG: + LDR r10 , [r14], #-4 + LDR r2 , [r14] , #-4 + + SMLAWB r11, r10 , r9, r11 + LDR r9 , [r3 , r5] + SUB r5 , r5 , #4 + + SMLAWT r11, r2 , r9, r11 + LDR r10 , [r14] , #-4 + LDR r2 , [r14] , #-4 + + SMLAWB r11, r10 , r9, r11 + LDR r9 , [r3 , r5] + SUBS r5 , r5 , #4 + + SMLAWT r11, r2 , r9, r11 + + BGT INNER_LOOP2_NEG + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11, lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #-4 + MOV r2 , r8 , lsl r6 + STR r2 , [r12], #-4 + SUBS r7 , r7 , #1 + BGT OUTER_LOOP2_NEG + +EXIT: + ADD sp, sp , #4 + LDMFD r13!, {r4 - r12, r15} + diff --git a/decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s b/decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s new file mode 100644 index 0000000..694d1e4 --- /dev/null +++ b/decoder/armv7/ixheaacd_tns_parcor2lpc_32x16.s @@ -0,0 +1,122 @@ +@/****************************************************************************** +@ * +@ * 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 +@*/ + + +.text +.p2align 2 + .global ixheaacd_tns_parcor_lpc_convert_armv7 +ixheaacd_tns_parcor_lpc_convert_armv7: + STMFD SP!, {R2, R4-R12, R14} + SUB SP, SP, #128 + MOV R4, SP + MOV R8, #0 + MOV R5, #0x8000 + +OUTLOOP: + MOV R6, #0 + MOV R7, #16 +LOOP1: + STR R6, [R4], #4 + STR R6, [R4, #60] + SUBS R7, R7, #1 + BGT LOOP1 + + SUB R4, R4, #64 + MOV R9, #0x7FFFFFFF + MOV R10, R9, ASR R8 + + + MOV R7, R3 +LOOP2: + MOV R11, R10 + LDRSH R2, [R4], #2 + LDRSH R14, [R0], #2 + MOV R12, R3 + +LOOP2_1: + SMULBB R2, R2, R14 + QADD R14, R10, R5 + CMP R2, #0x40000000 + MOV R14, R14, ASR #16 + MOVNE R2, R2, LSL #1 + MOVEQ R2, #0x7FFFFFFF + QADD R10, R10, R2 + STRH R14, [R4, #62] + MOVS R2, R10 + RSBSMI R2, R2, #0 + MOVMI R2, #0x7FFFFFFF + CMP R2, #0x7FFFFFFF + MOVEQ R6, #1 + SUBS R12, R12, #1 +@ LDRGTSH R2, [R4], #2 +@ LDRGTSH R14, [R0], #2 + LDRSHGT R2, [R4], #2 + LDRSHGT R14, [R0], #2 + BGT LOOP2_1 + + LDRSH R2, [R4, #62] + MOV R12, R3 +LOOP2_2: + LDRSH R14, [R0, #-2]! + LDRSH R9, [R4, #-2]! + SMULBB R2, R2, R14 + MOV R9, R9, LSL #16 + CMP R2, #0x40000000 + MOVNE R2, R2, LSL #1 + MOVEQ R2, #0x7FFFFFFF + QADD R9, R9, R2 + LDRSH R2, [R4, #62] + QADD R14, R9, R5 + MOVS R9, R9 + MOV R14, R14, ASR #16 + STRH R14, [R4, #2] +@ RSBMIS R9, R9, #0 + RSBSMI R9, R9, #0 + MOVMI R9, #0x7FFFFFFF + CMP R9, #0x7FFFFFFF + MOVEQ R6, #1 + SUBS R12, R12, #1 + BGT LOOP2_2 + + QADD R11, R11, R5 + QADD R2, R10, R5 + MOV R11, R11, ASR #16 + MOV R2, R2, ASR #16 + STRH R11, [R4] + STRH R2, [R1], #2 + MOV R10, #0 + + SUBS R7, R7, #1 + BGE LOOP2 + + SUB R1, R1, R3, LSL #1 + SUB R1, R1, #2 + SUBS R10, R6, #1 + ADDEQ R8, R8, #1 + BEQ OUTLOOP + + LDR R2, [SP, #128] + ADD SP, SP, #132 + STRH R8, [R2] + LDMFD sp!, {r4-r12, r15} + + + + diff --git a/decoder/armv8/ixheaacd_apply_scale_factors.s b/decoder/armv8/ixheaacd_apply_scale_factors.s new file mode 100644 index 0000000..0c87aff --- /dev/null +++ b/decoder/armv8/ixheaacd_apply_scale_factors.s @@ -0,0 +1,166 @@ +//.include "ihevc_neon_macros.s" +.macro push_v_regs + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp x19, x20, [sp, #-16]! + stp x21, x22, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp x21, x22, [sp], #16 + ldp x19, x20, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +.endm + +.text +.p2align 2 +.global ixheaacd_scale_factor_process_armv8 + +ixheaacd_scale_factor_process_armv8: + + push_v_regs + + MOV x9, x4 + + MOV x21, x6 + MOV x22, x7 + CMP x2, #0 // Tbands + + BGT lbl17 + + pop_v_regs + ret +lbl17: + MOV x10, #0 + CMP x5, #2 + BGT ADD_34 + MOV x11, #0x25 + B TBANDS_LOOP +ADD_34: + MOV x11, #0x22 + // MOV x11, #0x25 // temp=37 + +TBANDS_LOOP: + LDRSH x5, [x1], #2 // scale_factor = *Scfactor++; + LDRB w4, [x3], #1 //Offset [1] + sxtw x4, w4 + + + CMP x5, #0x18 //if(scale_factor < 24) + BGE SCALE_FACTOR_GE_12 // + + CMP x4, #0 + BLE OFFSET_ZERO + +SCALE_FACTOR_LT_12: + + STR x10, [x0], #8 + STR x10, [x0], #8 + SUBS x4, x4, #4 + BGT SCALE_FACTOR_LT_12 + B OFFSET_ZERO + +SCALE_FACTOR_GE_12: + + SUBS x6, x11, x5, ASR #2 // 37-(scale_factor >> 2) + AND x5, x5, #3 // scale_factor & 0x0003 + + //ADD x5,x9,x5,LSL #1 ; scale_table_ptr[(scale_factor & 0x0003)]; + LDR w5, [x9, x5, LSL #2] // scale_short = scale_table_ptr[(scale_factor & 0x0003)]; + sxtw x5, w5 + AND w17, w5, #0x0000FFFF + sxth w17, w17 //16-bit value stored as 32-bit,so SMULWB can still be used + BLE SHIFT_LE_ZERO // if shift less than or equal to zero + + SUB x14, x6, #1 //dont do that extra LSL #1 in SMULWB + +SHIFT_POSITIVE: //loop over sfbWidth a multiple of 4 + LDP w6, w7 , [x0, #0] // temp1 = *x_invquant + LDP w19, w20, [x0, #8] + + //SMULWB x6, x6, x5 // buffex1 = mult32x16in32(temp1, scale_short); + SMULL x6, w6, w17 + SMULL x7, w7, w17 + SMULL x19, w19, w17 + SMULL x20, w20, w17 + + ASR x6, x6, #16 + ASR x7, x7 , #16 + ASR x19, x19 , #16 + ASR x20, x20 , #16 + + ASR x6, x6, x14 // buffex1 = shx32(buffex1, shift); + ASR x7, x7, x14 + ASR x19, x19, x14 + ASR x20, x20, x14 + + stp w6, w7, [x0], #8 + stp w19, w20, [x0], #8 + + SUBS x4, x4, #4 + + BGT SHIFT_POSITIVE + B OFFSET_ZERO +SHIFT_LE_ZERO: + + //RSBS x14, x6, #0 //-shift + NEGS x14, x6 + BGT SHIFT_NEGTIVE1 + +SHIFT_ZERO: //loop over sfbWidth a multiple of 4 + LDP w6, w7, [x0, #0] // temp1 = *x_invquant; + + //SMULWB x6, x6, x5 // buffex1 = mult32x16in32(temp1, scale_short); + SMULL x6, w6, w17 + SMULL x7, w7, w17 + + ASR x6, x6, #16 + ASR x7, x7, #16 + + LSL x6, x6, #1 + LSL x7, x7, #1 + + STP w6, w7, [x0], #8 // *x_invquant++ = buffex1; + + SUBS x4, x4, #2 + + BGT SHIFT_ZERO + B OFFSET_ZERO + +SHIFT_NEGTIVE1: + SUB x14, x14, #1 +SHIFT_NEGTIVE: //;loop over sfbWidth a multiple of 4 + + LDP w6, w7, [x0, #0] + LSL w6, w6, w14 // buffex1 = shl32(buffex1, shift-1); + LSL w7, w7, w14 // buffex1 = shl32(buffex1, shift-1); + + //SMULWB x6, x6, x5 // buffex1 = mult32x16in32(temp1, scale_short); + SMULL x6, w6, w17 + SMULL x7, w7, w17 + ASR x6, x6, #16 + ASR x7, x7, #16 + + LSL x6, x6, #2 // shl for fixmul_32x16b and shl32(buffer,1) + LSL x7, x7, #2 // shl for fixmul_32x16b and shl32(buffer,1) + + STP w6, w7, [x0], #8 // *x_invquant++ = buffex1; + + SUBS x4, x4, #2 + + BGT SHIFT_NEGTIVE + +OFFSET_ZERO: + SUBS x2, x2, #1 + BGT TBANDS_LOOP + + pop_v_regs + ret diff --git a/decoder/armv8/ixheaacd_basic_op.h b/decoder/armv8/ixheaacd_basic_op.h new file mode 100644 index 0000000..c39b2ca --- /dev/null +++ b/decoder/armv8/ixheaacd_basic_op.h @@ -0,0 +1,99 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OP_H +#define IXHEAACD_BASIC_OP_H + +#define add_d(a, b) ((a) + (b)) +#define sub_d(a, b) ((a) - (b)) +#define ixheaacd_cbrt_calc(a) cbrt(1.0f / a) + +/* +static PLATFORM_INLINE WORD32 mult32x16in32_dual(WORD32 a , WORD16 b) +{ + WORD32 result; + WORD32 msb; + UWORD32 lsb; + + lsb=a&0x0000FFFF ; + msb=(a>>16); + + result=(UWORD32)(lsb*(UWORD32)b); + result= msb*(WORD32)b+(result>>16); + return(result); +} +*/ + +static PLATFORM_INLINE WORD32 msu32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b, + WORD16 c2) { + WORD32 result; + WORD32 temp_result; + UWORD32 a_lsb; + WORD32 a_msb; + UWORD32 b_lsb; + WORD32 b_msb; + + a_lsb = a & 65535; + a_msb = a >> 16; + + b_lsb = b & 65535; + b_msb = b >> 16; + temp_result = ((UWORD32)a_lsb * (UWORD32)c1); + temp_result = temp_result - (WORD32)((UWORD32)b_lsb * (UWORD32)c2); + temp_result = ((WORD32)temp_result) >> 16; + result = temp_result + ((a_msb * (WORD32)c1) - (b_msb * (WORD32)c2)); + + return (result); +} + +static PLATFORM_INLINE WORD32 mac32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b, + WORD16 c2) { + WORD32 result; + WORD32 temp_result; + UWORD32 a_lsb; + WORD32 a_msb; + UWORD32 b_lsb; + WORD32 b_msb; + + a_lsb = a & 65535; + a_msb = a >> 16; + + b_lsb = b & 65535; + b_msb = b >> 16; + temp_result = (UWORD32)a_lsb * (UWORD32)c1; + temp_result = temp_result + (UWORD32)b_lsb * (UWORD32)c2; + temp_result = ((UWORD32)temp_result) >> 16; + result = temp_result + ((a_msb * (WORD32)c1)) + ((b_msb * (WORD32)c2)); + return (result); +} + +/* +static PLATFORM_INLINE WORD64 mac32x32in64_dual(WORD32 a, WORD32 b,WORD64 c, +WORD32 d) +{ + WORD64 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = c + (temp_result); + return (result); +} +*/ + +#endif diff --git a/decoder/armv8/ixheaacd_basic_ops16.h b/decoder/armv8/ixheaacd_basic_ops16.h new file mode 100644 index 0000000..5a2108d --- /dev/null +++ b/decoder/armv8/ixheaacd_basic_ops16.h @@ -0,0 +1,397 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS16_H +#define IXHEAACD_BASIC_OPS16_H + +// limits the 32 bit input to the range of a 16 bit word +static PLATFORM_INLINE WORD16 ixheaacd_sat16(WORD32 op1) { + WORD16 var_out; + + if (op1 > 0X00007fffL) { + var_out = MAX_16; + } else if (op1 < (WORD32)0xffff8000L) { + var_out = (WORD16)(-32768); + } else { + var_out = (WORD16)(op1); + } + return (var_out); +} + +// add 2 16 bit variables and returns 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_add16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 + op2)); + return (var_out); +} + +// add 2 16 bit variables and returns 16 bit result with saturation +static PLATFORM_INLINE WORD16 ixheaacd_add16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 sum; + + sum = (WORD32)op1 + (WORD32)op2; + var_out = ixheaacd_sat16(sum); + return (var_out); +} + +// subtract 2 16 bit variables and returns 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_sub16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 - op2)); + return (var_out); +} + +// subtract 2 16 bit variables and returns 16 bit result with saturation +static PLATFORM_INLINE WORD16 ixheaacd_sub16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 diff; + + diff = (WORD32)op1 - op2; + var_out = ixheaacd_sat16(diff); + return (var_out); +} + +// multiply 2 16 bit variables and return 31 to 16 bits +static PLATFORM_INLINE WORD16 ixheaacd_mult16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 16)); + return (var_out); +} + +// multiply 2 16 bit variables and return 30 to 15 bits +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 15)); + return (var_out); +} + +// multiply 2 16 bit variables and return 30 to 15 bits with saturation +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 temp; + + temp = ((WORD32)(((WORD32)op1 * (WORD32)op2) >> 15)); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +// shifts left a 16 bit variable by the shift value and returns a 16 bit result +static PLATFORM_INLINE WORD16 ixheaacd_shl16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = (WORD16)(op1 << shift); + return (var_out); +} + +// shifts left a 16 bit variable by the shift value and returns a 16 bit value +// with saturation +static PLATFORM_INLINE WORD16 ixheaacd_shl16_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + WORD32 temp; + + if (shift > 15) { + shift = 15; + } + temp = (WORD32)(op1 << shift); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +// shifts right a 16 bit variable by the shift value and returns a 16 bit value +static PLATFORM_INLINE WORD16 ixheaacd_shr16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = ((WORD16)(op1 >> shift)); + return (var_out); +} + +// shifts left a 16 bit variable by the shift value if the +// value is positive else shifts right and returns a 16 bit result +static PLATFORM_INLINE WORD16 shl16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value if the +// value is negative else shifts right and returns a 16 bit result +static PLATFORM_INLINE WORD16 shr16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value +// if the value is positive else shifts right and returns a 16 bit with +// saturation +static PLATFORM_INLINE WORD16 shl16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16_sat(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +// shifts left a 16 bit variable by the shift value if the +// value is negative else shifts right and returns a 16 bit +// result with saturation +static PLATFORM_INLINE WORD16 ixheaacd_shr16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16_sat(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +// finds a value which normalizes the input to 16 bit +// return zero for value zero +static PLATFORM_INLINE WORD16 norm16(WORD16 op1) { + WORD16 var_out; + + if (0 == op1) { + var_out = 0; + } else { + if ((WORD16)0xffff == op1) { + var_out = 15; + } else { + if (op1 < 0) { + op1 = (WORD16)(~op1); + } + for (var_out = 0; op1 < 0x4000; var_out++) { + op1 <<= 1; + } + } + } + + return (var_out); +} + +// finds no. of significant bits excluding sign bit +// value 15 returned for zero +static PLATFORM_INLINE WORD16 bin_expo16(WORD16 op1) { + WORD16 var_out; + + var_out = ((WORD16)(15 - norm16(op1))); + return (var_out); +} + +// returns a 16 bit absolute value of a given signed 16 bit value +static PLATFORM_INLINE WORD16 ixheaacd_abs16(WORD16 op1) { + WORD16 var_out; + + if (op1 < 0) { + var_out = (WORD16)(-op1); + } else { + var_out = op1; + } + return (var_out); +} + +// returns a 16 bit absolute value of a given signed 16 bit value with +// saturation +static PLATFORM_INLINE WORD16 ixheaacd_abs16_sat(WORD16 op1) { + WORD16 var_out; + + if (-32768 == op1) { + var_out = MAX_16; + } else { + if (op1 < 0) { + var_out = (WORD16)(-op1); + } else { + var_out = op1; + } + } + return (var_out); +} + +// returns a 16 bit negative value of a given signed 16 bit value. +static PLATFORM_INLINE WORD16 ixheaacd_negate16(WORD16 op1) { + WORD16 var_out; + + if (-32768 == op1) { + var_out = MAX_16; + } else { + var_out = (WORD16)(-op1); + } + return (var_out); +} + +// returns the minima of 2 16 bit variables +static PLATFORM_INLINE WORD16 ixheaacd_min16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 < op2 ? op1 : op2; + return (var_out); +} + +// returns the maxima of 2 16 bit variables +static PLATFORM_INLINE WORD16 ixheaacd_max16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 > op2 ? op1 : op2; + return (var_out); +} + +/*****************************************************************************/ +/* */ +/* function name : div16 */ +/* */ +/* description : divides 2 16 bit variables and returns the quotient */ +/* the q-format of the result is modified */ +/* ( op1/op2 to 14 bits precision) */ +/* */ +/* inputs : WORD16 op1, WORD16 op2, WORD16 *q_format */ +/* */ +/* globals : none */ +/* */ +/* processing : non-restoration type algorithm(shift & substract) */ +/* */ +/* outputs : WORD16 *q_format */ +/* */ +/* returns : WORD16 var_out */ +/* */ +/* issues : none */ +/* */ +/* revision history : */ +/* */ +/* DD MM YYYY author changes */ +/* 11 11 2003 preethi modified(bug fixes) */ +/* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ +/* */ +/*****************************************************************************/ + +// divides 2 16 bit variables and returns the quotient +static PLATFORM_INLINE WORD16 div16(WORD16 op1, WORD16 op2, WORD16 *q_format) { + WORD32 quotient; + UWORD16 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPIDX i; + WORD16 q_nr, q_dr; + + mantissa_nr = op1; + mantissa_dr = op2; + quotient = 0; + + if (op1 < 0 && op2 != 0) { + op1 = -op1; + sign = (WORD16)(sign ^ -1); + } + + if (op2 < 0) { + op2 = -op2; + sign = (WORD16)(sign ^ -1); + } + + if (op2 == 0) { + *q_format = 0; + return (op1); + } + + quotient = 0; + + q_nr = norm16(op1); + mantissa_nr = (UWORD16)op1 << (q_nr); + q_dr = norm16(op2); + mantissa_dr = (UWORD16)op2 << (q_dr); + *q_format = (WORD16)(14 + q_nr - q_dr); + + for (i = 0; i < 15; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return (WORD16)quotient; +} + +// multiply 2 16 bit variables, add 31 to 16 bits to acc +static PLATFORM_INLINE WORD16 mac16(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 31 to 16 bits to acc with saturation +static PLATFORM_INLINE WORD16 mac16_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16_sat(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 30 to 15 bits to acc +static PLATFORM_INLINE WORD16 mac16_shl(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16_shl(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +// multiply 2 16 bit variables, add 30 to 15 bits to acc with saturation +static PLATFORM_INLINE WORD16 mac16_shl_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 temp; + + temp = ((WORD32)op1 * (WORD32)op2) >> 15; + temp += c; + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +// rounds a 32 bit variable to a 16 bit variable with saturation +static PLATFORM_INLINE WORD16 ixheaacd_round16(WORD32 op1) { + WORD16 var_out; + + var_out = (WORD16)(ixheaacd_add32_sat(op1, 0x8000) >> 16); + return (var_out); +} +#endif diff --git a/decoder/armv8/ixheaacd_basic_ops32.h b/decoder/armv8/ixheaacd_basic_ops32.h new file mode 100644 index 0000000..a22fe7d --- /dev/null +++ b/decoder/armv8/ixheaacd_basic_ops32.h @@ -0,0 +1,598 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS32_H +#define IXHEAACD_BASIC_OPS32_H + +#if 0 +//returns the minima of 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_min32(WORD32 a, WORD32 b) +{ + WORD32 min_val; + asm ( + "CMP %w[a], %w[b]\n\t" + "CSEL %w[min_val], %w[b], %w[a], GT\n" + : [min_val] "=r" (min_val), [a] "+r" (a) + : [b] "r" (b) + : "cc" + ); + return (min_val); +} + +//returns the maxima of 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_max32(WORD32 a, WORD32 b) +{ + WORD32 max_val; + asm ( + "CMP %w[a], %w[b]\n" + "CSEL %w[max_val], %w[b], %w[a], LT\n" + : [max_val] "=r" (max_val), [a] "+r" (a) + : [b] "r" (b) + : "cc" + ); + return (max_val); +} +#else +static PLATFORM_INLINE WORD32 ixheaacd_min32(WORD32 a, WORD32 b) { + WORD32 min_val; + + min_val = (a < b) ? a : b; + + return min_val; +} + +// returns the maxima of 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_max32(WORD32 a, WORD32 b) { + WORD32 max_val; + + max_val = (a > b) ? a : b; + + return max_val; +} + +#endif + +// shifts a 32-bit value left by specificed bits +static PLATFORM_INLINE WORD32 ixheaacd_shl32(WORD32 a, WORD b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); /* Mod 8 */ + if (b > 31) + out_val = 0; + else + out_val = (WORD32)a << b; + + return out_val; +} + +// shifts a 32-bit value right by specificed bits +static PLATFORM_INLINE WORD32 ixheaacd_shr32(WORD32 a, WORD b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); /* Mod 8 */ + if (b >= 31) { + if (a < 0) + out_val = -1; + else + out_val = 0; + } else { + out_val = (WORD32)a >> b; + } + + return out_val; +} + +// shifts a 32-bit value left by specificed bits and saturates it to 32 bits +static PLATFORM_INLINE WORD32 ixheaacd_shl32_sat(WORD32 a, WORD b) { + WORD32 out_val = a; + for (; b > 0; b--) { + if (a > (WORD32)0X3fffffffL) { + out_val = MAX_32; + break; + } else if (a < (WORD32)0xc0000000L) { + out_val = MIN_32; + break; + } + + a = ixheaacd_shl32(a, 1); + out_val = a; + } + return (out_val); +} + +// shifts a 32-bit value left by specificed bits, shifts +// it right if specified no. of bits is negative + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shr32(a, -b); + } else { + out_val = ixheaacd_shl32(a, b); + } + + return out_val; +} + +// shifts a 32-bit value left by specificed bits with sat, +// shifts it right if specified no. of bits is negative + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shr32(a, -b); + } else { + out_val = ixheaacd_shl32_sat(a, b); + } + + return out_val; +} + +// shifts a 32-bit value right by specificed bits, shifts +// it left if specified no. of bits is negative +static PLATFORM_INLINE WORD32 ixheaacd_shr32_dir(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32(a, -b); + } else { + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +// shifts a 32-bit value right by specificed bits, shifts +// it left with sat if specified no. of bits is negative +static PLATFORM_INLINE WORD32 shr32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32_sat(a, -b); + } else { + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +// multiplies two 16 bit numbers and returns their 32-bit result +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32(WORD16 a, WORD16 b) { + WORD32 product; + + product = (WORD32)a * (WORD32)b; + + return product; +} + +// multiplies two 32 bit numbers considering their last +// 16 bits and returns their 32-bit result +static PLATFORM_INLINE WORD32 mult16x16in32_32(WORD32 a, WORD32 b) { + WORD32 product; + asm("AND %w[a], %w[a], #0x0000FFFF\n" + "SXTH %w[a], %w[a]\n" + "AND %w[b], %w[b], #0x0000FFFF\n" + "SXTH %w[b], %w[b]\n" + "MUL %w[product], %w[a], %w[b]\n" + : [product] "=r"(product) + : [b] "r"(b), [a] "r"(a)); + return product; +} + +// multiplies two 16 bit numbers and returns their 32-bit +// result after removing 1 redundant sign bit +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl(WORD16 a, WORD16 b) { + WORD32 product; + + product = ixheaacd_shl32(ixheaacd_mult16x16in32(a, b), 1); + + return product; +} + +// multiplies two 16 bit numbers and returns their 32-bit +// result after removing 1 redundant sign bit with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl_sat(WORD16 a, + WORD16 b) { + WORD32 product; + product = (WORD32)a * (WORD32)b; + if (product != (WORD32)0x40000000L) { + product = ixheaacd_shl32(product, 1); + } else { + product = MAX_32; + } + return product; +} + +// adds 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_add32(WORD32 a, WORD32 b) { + WORD32 sum; + + sum = (WORD32)a + (WORD32)b; + + return sum; +} + +// subtract 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_sub32(WORD32 a, WORD32 b) { + WORD32 diff; + + diff = (WORD32)a - (WORD32)b; + + return diff; +} + +// adds 2 32 bit variables with saturation +static PLATFORM_INLINE WORD32 ixheaacd_add32_sat(WORD32 a, WORD32 b) { + WORD32 sum; + + sum = ixheaacd_add32(a, 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; + } + } + + return sum; +} + +// subtract 2 32 bit variables +static PLATFORM_INLINE WORD32 ixheaacd_sub32_sat(WORD32 a, WORD32 b) { + WORD32 diff; + + diff = ixheaacd_sub32(a, 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; + } + } + + return (diff); +} + +// returns number of redundant sign bits in a 32-bit value. +// return zero for a value of zero +static PLATFORM_INLINE WORD ixheaacd_norm32(WORD32 a) { +#if 1 + WORD norm_val; + + if (a == 0) { + norm_val = 31; + } else { + if (a == (WORD32)0xffffffffL) { + norm_val = 31; + } else { + if (a < 0) { + a = ~a; + } + for (norm_val = 0; a < (WORD32)0x40000000L; norm_val++) { + a <<= 1; + } + } + } +#else + WORD32 norm_val, temp; + asm("ASR %w[temp], %w[a], #31\n" + "EOR %w[norm_val], %w[a], %w[temp]\n" + "CLZ %w[norm_val], %w[norm_val]\n" + "SUB %w[norm_val], %w[norm_val], #1\n" + : [norm_val] "=r"(norm_val), [temp] "+r"(temp) + : [a] "r"(a) + : "cc"); +#endif + return norm_val; +} + +static PLATFORM_INLINE WORD ixheaacd_pnorm32(WORD32 a) { + WORD32 norm_val; + asm("CLZ %w[norm_val], %w[a]\n" + "SUB %w[norm_val], %w[norm_val], #1\n" + : [norm_val] "=r"(norm_val) + : [a] "r"(a)); + return norm_val; +} + +// returns the position of the most significant bit for negative numbers. +// ignores leading zeros to determine the position of most significant bit. +static PLATFORM_INLINE WORD bin_expo32(WORD32 a) { + WORD bin_expo_val; + + bin_expo_val = 31 - ixheaacd_norm32(a); + + return bin_expo_val; +} + +// returns the absolute value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_abs32(WORD32 a) { + WORD32 abs_val; + asm("CMP %w[a], #0\n" + "NEG %w[abs_val], %w[a]\n" + "CSEL %w[abs_val], %w[abs_val], %w[a], LT\n" + : [abs_val] "=r"(abs_val), [a] "+r"(a) + : + : "cc"); + return (abs_val); +} + +// returns the absolute value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_abs32_nrm(WORD32 a) { + WORD32 abs_val, temp; + asm("ASR %w[temp], %w[a], #31\n" + "EOR %w[abs_val], %w[a], %w[temp]\n" + : [abs_val] "=r"(abs_val), [temp] "+r"(temp) + : [a] "r"(a) + : "cc"); + return abs_val; +} + +#if 0 +//returns the absolute value of 32-bit number with saturation +static PLATFORM_INLINE WORD32 ixheaacd_abs32_sat(WORD32 a) +{ + WORD32 abs_val,temp; + asm ( + "ADDS %w[abs_val], %w[a], #0\n" + "NEG %w[temp], %w[abs_val]\n" + "CSEL %w[abs_val], %w[temp], %w[a], MI\n" + "CMP %w[abs_val], #0\n" + "MOV %w[temp], #2147483647\n" + "CSEL %w[abs_val], %w[temp], %w[abs_val], LT\n" + : [abs_val] "=r" (abs_val), [temp] "+r" (temp) + : [a] "r" (a) + : "cc" + ); + return abs_val; +} + +//returns the negated value of 32-bit number +static PLATFORM_INLINE WORD32 ixheaacd_negate32(WORD32 a) +{ + WORD32 neg_val; + asm ( + "NEG %w[neg_val], %w[a]\n" + : [neg_val] "=r" (neg_val) + : [a] "r" (a) + ); + return neg_val; +} + +//returns the negated value of 32-bit number with saturation +static PLATFORM_INLINE WORD32 ixheaacd_negate32_sat(WORD32 a) +{ + WORD32 neg_val,temp; + asm ( + "NEGS %w[neg_val], %w[a]\n" + "MOV %w[temp], #0x7FFFFFFF\n" + "CSEL %w[neg_val], %w[temp], %w[neg_val], VS\n" + : [neg_val] "=r" (neg_val), [temp] "+r" (temp) + : [a] "r" (a) + :"cc" + ); + return neg_val; +} +#else + +static PLATFORM_INLINE WORD32 ixheaacd_abs32_sat(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a == MIN_32) { + abs_val = MAX_32; + } else if (a < 0) { + abs_val = -a; + } + + return abs_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_negate32(WORD32 a) { + WORD32 neg_val; + + neg_val = -a; + + return neg_val; +} +static PLATFORM_INLINE WORD32 ixheaacd_negate32_sat(WORD32 a) { + WORD32 neg_val; + + neg_val = -a; + if (a == MIN_32) { + neg_val = MAX_32; + } + + return neg_val; +} +#endif + +// divides 2 32 bit variables and returns the quotient +static PLATFORM_INLINE WORD32 div32(WORD32 a, WORD32 b, WORD *q_format) { + WORD32 quotient; + UWORD32 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPINDEX i; + WORD q_nr, q_dr; + + mantissa_nr = a; + mantissa_dr = b; + quotient = 0; + + if ((a < 0) && (0 != b)) { + a = -a; + sign = (WORD16)(sign ^ -1); + } + + if (b < 0) { + b = -b; + sign = (WORD16)(sign ^ -1); + } + + if (0 == b) { + *q_format = 0; + return (a); + } + + quotient = 0; + + q_nr = ixheaacd_norm32(a); + mantissa_nr = (UWORD32)a << (q_nr); + q_dr = ixheaacd_norm32(b); + mantissa_dr = (UWORD32)b << (q_dr); + *q_format = (WORD)(30 + q_nr - q_dr); + + for (i = 0; i < 31; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return quotient; +} + +// multiplies two 16 bit numbers and accumulates their result in a 32 bit +// variable +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32(b, c); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +// multiplies lower 16 bit of one data with upper 16 bit of +// other and accumulates their result in a 32 bit variable +static PLATFORM_INLINE WORD32 mac16x16hin32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32((WORD16)b, (WORD16)(c >> 16)); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and accumulates their result in a 32 bit +// variable +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and accumulates their +// result in a 32 bit variable with saturation + +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_add32_sat(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable +static PLATFORM_INLINE WORD32 msu16x16in32(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable after removing a redundant sign bit in the +// product +static PLATFORM_INLINE WORD32 msu16x16in32_shl(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +// multiplies two 16 bit numbers and subtracts their +// result from a 32 bit variable with saturation +// after removing a redundant sign bit in the product +static PLATFORM_INLINE WORD32 msu16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_sub32_sat(a, acc); + + return acc; +} + +// adding two 32 bit numbers and taking care of overflow +// by downshifting both numbers before addition +static PLATFORM_INLINE WORD32 add32_shr(WORD32 a, WORD32 b) { + WORD32 sum; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + sum = ixheaacd_add32(a, b); + + return sum; +} + +// subtracting two 32 bit numbers and taking care of +// overflow by downshifting both numbers before addition + +static PLATFORM_INLINE WORD32 sub32_shr(WORD32 a, WORD32 b) { + WORD32 diff; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + diff = ixheaacd_sub32(a, b); + + return diff; +} +#endif diff --git a/decoder/armv8/ixheaacd_basic_ops40.h b/decoder/armv8/ixheaacd_basic_ops40.h new file mode 100644 index 0000000..c595fa4 --- /dev/null +++ b/decoder/armv8/ixheaacd_basic_ops40.h @@ -0,0 +1,439 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS40_H +#define IXHEAACD_BASIC_OPS40_H + +#define hi64(a) ((WORD32)((a & (WORD64)0xFFFFFFFF00000000) >> 32)) +#define lo64(a) ((UWORD32)(a)) + +// normalize input to 32 bits, return denormalizing info +static PLATFORM_INLINE WORD16 norm40(WORD40 *in) { + WORD16 expo; + WORD32 tempo; + + if (0 == (*in)) return 31; + + if (((*in) <= 0x7fffffff) && ((WORD40)(*in) >= (WORD40)0xFFFFFFFF80000000)) { + tempo = (WORD32)(*in); + expo = ixheaacd_norm32(tempo); + *in = tempo << expo; + + return (expo); + } + + tempo = (WORD32)((*in) >> 31); + expo = 31 - (ixheaacd_norm32(tempo)); + *in = (*in) >> expo; + + return (-expo); +} + +// adds two numbers and right shifts by 1 +static PLATFORM_INLINE WORD32 add32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a + (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +// subtracts and right shifts by one +static PLATFORM_INLINE WORD32 sub32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a - (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +// multiply WORD32 with WORD16 return bits 46 to 15 +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 16); + + return (result << 1); +} + +// multiply WORD32 with higher 16 bits of second data and return bits 46 to 15 +static PLATFORM_INLINE WORD32 mult32x16hin32_shl(WORD32 a, WORD32 b) { + WORD32 product; + WORD64 temp_product; + + temp_product = (WORD64)a * (WORD64)(b >> 16); + product = (WORD32)(temp_product >> 16); + + return (product << 1); +} + +// multiply WORD32 with WORD16 return bits 47 to 16 +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 16); + + return (result); +} + +// multiply WORD32 with WORD16 return bits 46 to 15 with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl_sat(WORD32 a, + WORD16 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD16)0x8000) { + result = (WORD32)0x7fffffff; + } else { + result = ixheaacd_mult32x16in32_shl(a, b); + } + + return (result); +} + +#if 0 +//multiply WORD32 with WORD32 return bits 62 to 31 +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl(WORD32 a, WORD32 b) +{ + + WORD64 result; + asm ( + "SMULL %[result], %w[a], %w[b]\n" + "ASR %[result], %[result], #32\n" + : [result] "=r" (result) + : [a] "r" (a), [b] "r" (b) + ); + return ((WORD32)(result << 1)); +} + +//multiply WORD32 with WORD32 return bits 63 to 32 +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) +{ + + WORD64 result; + asm ( + "SMULL %[result], %w[a], %w[b]\n" + "ASR %[result], %[result], #32\n" + : [result] "=r" (result) + : [a] "r" (a), [b] "r" (b) + ); + return ((WORD32)result); +} +#else +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + + return (result << 1); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + + return (result); +} +#endif + +// multiply WORD32 with WORD32 return bits 62 to 31 with saturation +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl_sat(WORD32 a, WORD32 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD32)0x80000000) { + result = 0x7fffffff; + } else { + result = ixheaacd_mult32_shl(a, b); + } + + return (result); +} + +// multiply WORD32 with WORD16 add bits 47 to 16 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 add bits 46 to 15 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32_shl(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 add bits 46 to 15 to accumulator with saturation +static PLATFORM_INLINE WORD32 mac32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD32 add bits 63 to 32 to accumulator +static PLATFORM_INLINE WORD32 ixheaacd_mac32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 add bits 62 to 31 to accumulator +static PLATFORM_INLINE WORD32 mac32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 add bits 62 to 31 to accumulator with saturation +static PLATFORM_INLINE WORD32 mac32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD16 sub bits 47 to 16 from accumulator +static PLATFORM_INLINE WORD32 msu32x16in32(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 sub bits 46 to 15 from accumulator +static PLATFORM_INLINE WORD32 msu32x16in32_shl(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD16 sub bits 46 to 15 from accumulator with +// saturation +static PLATFORM_INLINE WORD32 msu32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +// multiply WORD32 with WORD32 sub bits 63 to 32 from accumulator +static PLATFORM_INLINE WORD32 msu32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 sub bits 62 to 31 from accumulator +static PLATFORM_INLINE WORD32 msu32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32_shl(b, c); + + return (result); +} + +// multiply WORD32 with WORD32 sub bits 62 to 31 from accumulator with +// saturation +static PLATFORM_INLINE WORD32 msu32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac3216_arr40(WORD32 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32x16in32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return (WORD32)sum; +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac32_arr40(WORD32 *x, WORD32 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 mac16_arr40(WORD16 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)((WORD32)x[i] * (WORD32)y[i]); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +// returns normalized 32 bit accumulated result +static PLATFORM_INLINE WORD32 add32_arr40(WORD32 *in_arr, LOOPINDEX length, + WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)in_arr[i]; + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +#if 0 +//multiply WORD32 with WORD32 return WORD64 +static PLATFORM_INLINE WORD64 ixheaacd_mult32x32in64(WORD32 a, WORD32 b) +{ + WORD64 result; + + asm ( + "SMULL %[result], %w[a], %w[b]\n" + : [result] "=r" (result) + : [a] "r" (a), [b] "r" (b) + ); + return (result); +} +#else +static PLATFORM_INLINE WORD64 ixheaacd_mult32x32in64(WORD32 a, WORD32 b) { + WORD64 result; + + result = (WORD64)a * (WORD64)b; + + return (result); +} +#endif + +// multiply WORD32 with WORD32 and accumulate the 64 bit result +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64(WORD64 sum, WORD32 a, + WORD32 b) { + sum += (WORD64)a * (WORD64)b; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_7(WORD64 sum, + const WORD32 *a, + const WORD16 *b) { + sum = (WORD64)a[0] * (WORD64)b[0]; + sum += (WORD64)a[1] * (WORD64)b[1]; + sum += (WORD64)a[2] * (WORD64)b[2]; + sum += (WORD64)a[3] * (WORD64)b[3]; + sum += (WORD64)a[4] * (WORD64)b[4]; + sum += (WORD64)a[5] * (WORD64)b[5]; + sum += (WORD64)a[6] * (WORD64)b[6]; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_n(WORD64 sum, + const WORD32 *a, + const WORD16 *b, + WORD32 n) { + WORD32 k; + + sum += (WORD64)a[0] * (WORD64)b[0]; + for (k = 1; k < n; k++) sum += (WORD64)a[k] * (WORD64)b[k]; + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mult64(WORD32 a, WORD32 b) { + WORD64 result; + result = (WORD64)a * (WORD64)b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_add64(WORD64 a, WORD64 b) { + WORD64 result; + result = a + b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = (WORD64)a - (WORD64)b; + + return diff; +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64_sat(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = ixheaacd_sub64(a, b); + + if ((((WORD64)a ^ (WORD64)b) & (WORD64)MIN_64) != 0) { + if (((WORD64)diff ^ (WORD64)a) & (WORD64)MIN_64) { + diff = (a < 0L) ? MIN_64 : MAX_64; + } + } + + return (diff); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mul32_sh(WORD32 a, WORD32 b, + WORD8 shift) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> shift); + + return (result); +} + +#endif diff --git a/decoder/armv8/ixheaacd_calcmaxspectralline.s b/decoder/armv8/ixheaacd_calcmaxspectralline.s new file mode 100644 index 0000000..b9a13d5 --- /dev/null +++ b/decoder/armv8/ixheaacd_calcmaxspectralline.s @@ -0,0 +1,82 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.text +.global ixheaacd_calc_max_spectral_line_armv8 +ixheaacd_calc_max_spectral_line_armv8: + + LSR W4, W1, #3 + LSL W6, W4, #3 + MOV w11, #0x00000000 + MOV V3.S[0], w11 + MOV V3.S[1], w11 + MOV V3.S[2], w11 + MOV V3.S[3], w11 + +LOOP_1: + LD1 {V0.4S}, [X0], #16 + LD1 {V1.4S}, [X0], #16 + + ABS V0.4S, V0.4S + ABS V1.4S, V1.4S + + SUBS W4, W4, #1 + + ORR V3.16B, V0.16B, V3.16B + ORR V3.16B, V1.16B, V3.16B + + BGT LOOP_1 + + SUBS W7, W1, W6 + + MOV W4, V3.S[0] + MOV W1, V3.S[1] + MOV W2, V3.S[2] + ORR W4, W4, W1 + MOV W3, V3.S[3] + ORR W4, W4, W2 + ORR W4, W4, W3 + BEQ END_FUNC +LOOP_2: + + LDR W2, [X0], #4 + + CMP W2, #0 + + CNEG W2, W2, LE + ORR W4, W4, W2 + SUBS W7, W7, #1 + BGT LOOP_2 + +END_FUNC: + + MOV W0, W4 + CMP W0, #0 + + CNEG W0, W0, LE + CLZ W0, W0 + SUB W0, W0, #1 + + RET + + + + diff --git a/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s b/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s new file mode 100644 index 0000000..bbd55df --- /dev/null +++ b/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s @@ -0,0 +1,231 @@ +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X18, X19, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm + +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X18, X19, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.text +.p2align 2 + + .global ixheaacd_cos_sin_mod_loop1 +ixheaacd_cos_sin_mod_loop1: + + // STMFD sp!, {x4-x12, x14} + push_v_regs + //stp x19, x20,[sp,#-16]! + //VPUSH {D8-D11} +//generating load addresses + ADD x4, x0, x1, lsl #3 //psubband1 + SUB x4, x4, #4 + ADD x5, x3, x1, lsl #3 //psubband1_t + SUB x5, x5, #8 + ASR x6, x1, #2 + + LDR w19, =0 + DUP V0.8h, w19 +LOOP1: +//first part + ld1 {v0.h}[0] , [x2] + ADD x2, x2, #2 + ld1 {v0.h}[2] , [x2] + ADD x2, x2, #2 + rev64 v1.2s, v0.2s + ld1 {v2.s}[0], [x0] + ADD x0, x0, #4 + ADD x7, x0, #252 + ld1 {v2.s}[1], [x7] + ld1 {v3.s}[0], [x4] + ADD x7, x4, #256 + ld1 {v3.s}[1], [x7] + SUB x4, x4, #4 + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + add v0.4s, v8.4s , v6.4s + SQSUB v2.4s, v10.4s , v4.4s + + //shrn v0.2s, v0.2d,#32 + //shrn v2.2s, v2.2d,#32 + mov v3.16b, v0.16b + mov v1.16b, v2.16b + ST2 {v0.s, v1.s}[0], [x3] + ADD x3, x3, #8 + ADD x7, x3, #248 + ST2 {v2.s, v3.s}[2], [x7] + LDR w19, =0 + DUP V0.8h, w19 +//second part + ld1 {v0.h}[0] , [x2] + ADD x2, x2, #2 + ld1 {v0.h}[2] , [x2] + ADD x2, x2, #2 + rev64 v1.2s, v0.2s + ld1 {v2.s}[0], [x0] + ADD x0, x0, #4 + ADD x7, x0, #252 + ld1 {v2.s}[1], [x7] + ld1 {v3.s}[0], [x4] + ADD x7, x4, #256 + ld1 {v3.s}[1], [x7] + SUB x4, x4, #4 + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + ADD v0.4s, v10.4s , v4.4s + SQSUB v2.4s, v8.4s , v6.4s + + //shrn v0.2s, v0.2d,#32 + //shrn v2.2s, v2.2d,#32 + mov v3.16b, v0.16b + mov v1.16b, v2.16b + ST2 {v0.s, v1.s}[0], [x5] + ADD x7, x5, #256 + ST2 {v2.s, v3.s}[2], [x7] + SUB x5, x5, #8 + LDR w19, =0 + DUP V0.8h, w19 +//Third part + ld1 {v0.h}[0] , [x2] + ADD x2, x2, #2 + ld1 {v0.h}[2] , [x2] + ADD x2, x2, #2 + rev64 v1.2s, v0.2s + ld1 {v2.s}[0], [x0], #4 + ADD x7, x0, #252 + ld1 {v2.s}[1], [x7] + ld1 {v3.s}[0], [x4] + ADD x7, x4, #256 + ld1 {v3.s}[1], [x7] + SUB x4, x4, #4 + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + add v0.4s, v8.4s , v6.4s + SQSUB v2.4s, v10.4s , v4.4s + + //shrn v0.2s, v0.2d,#32 + //shrn v2.2s, v2.2d,#32 + mov v3.16b, v0.16b + mov v1.16b, v2.16b + ST2 {v0.s, v1.s}[0], [x3] + ADD x3, x3, #8 + ADD x7, x3, #248 + ST2 {v2.s, v3.s}[2], [x7] + LDR w19, =0 + DUP V0.8h, w19 +//Fourth part + ld1 {v0.h}[0] , [x2] + ADD x2, x2, #2 + ld1 {v0.h}[2] , [x2] + ADD x2, x2, #2 + rev64 v1.2s, v0.2s + ld1 {v2.s}[0], [x0] + ADD x0, x0, #4 + ADD x7, x0, #252 + ld1 {v2.s}[1], [x7] + ld1 {v3.s}[0], [x4] + ADD x7, x4, #256 + ld1 {v3.s}[1], [x7] + SUB x4, x4, #4 + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + + ADD v0.4s, v10.4s , v4.4s + SQSUB v2.4s, v8.4s , v6.4s + + //shrn v0.2s, v0.2d,#32 + //shrn v2.2s, v2.2d,#32 + mov v3.16b, v0.16b + mov v1.16b, v2.16b + ST2 {v0.s, v1.s}[0], [x5] + ADD x7, x5, #256 + SUBS x6, x6, #1 + ST2 {v2.s, v3.s}[2], [x7] + SUB x5, x5, #8 + LDR w19, =0 + DUP V0.8h, w19 + BGT LOOP1 + //VPOP {D8-D11} + // LDMFD sp!, {x4-x12, x15} + //ldp x19, x20,[sp],#16 + pop_v_regs + ret + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s b/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s new file mode 100644 index 0000000..294dcc2 --- /dev/null +++ b/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s @@ -0,0 +1,213 @@ +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X18, X19, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm + +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X18, X19, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.text +.p2align 2 + + .global ixheaacd_cos_sin_mod_loop2 +ixheaacd_cos_sin_mod_loop2: + + // STMFD sp!, {x4-x12, x14} + push_v_regs + //stp x19, x20,[sp,#-16]! + //VPUSH {D8-D15} + //generating load addresses + ADD x3, x0, x2, LSL #3 //psubband1 = &subband[2 * M - 1]; + SUB x3, x3, #4 + ADD x10, x0, #256 + ADD x11, x10, x2, LSL #3 + SUB x11, x11, #4 + MOV x8, #-4 + LDR w19, =0 + DUP V0.4s, w19 + DUP V1.4s, w19 + + LDR w6, [x0] + sxtw x6, w6 + ASR x4, x2, #1 //M_2 = ixheaacd_shx32(M, 1); + SUB x4, x4, #1 + + ASR x6, x6, #1 //*psubband = *psubband >> 1; + LD1 {v2.s}[0], [x3] + + STR w6, [x0], #4 //psubband++; + sxtw x6, w6 + LDR w7, [x0] + sxtw x7, w7 + ASR x7, x7, #1 + sub x20, x7, #0 + neg x6, x20 + STR w6, [x3], #-4 + sxtw x6, w6 + LD1 {v3.s}[0], [x3] // im = *psubband1; + + LD2 {v0.h, v1.h}[0], [x1], #4 + sxtl v0.4s, v0.4h + sxtl v1.4s, v1.4h + dup v0.2s, v0.s[0] + dup v1.2s, v1.s[0] + + LD1 {v2.s}[1], [x11] //re = *psubband12; + +// LDR w6, [x10] +// sxtw x6,w6 +// ASR x7, x6, #1 +// MOV x9, #0 +// QSUB x7, x9, x7 + LD1 {v4.s}[0], [x10] + SSHR v4.2s, v4.2s, #1 + MOV x9, #0 + DUP v6.2s, w9 + SQSUB v4.2s, v6.2s, v4.2s + + ST1 {v4.s}[0], [x11] +// str X7, [X11] + SUB x11, x11, #4 +// sxtw x7,w7 + + LDR w6, [x10, #4] + sxtw x6, w6 + ASR x6, x6, #1 + STR w6, [x10], #4 + sxtw x6, w6 + + LD1 {v3.s}[1], [x11] + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + add v12.2d, v8.2d , v6.2d + SQSUB v14.2d, v10.2d , v4.2d + SQSUB v16.2d, v4.2d , v10.2d + + //shrn v12.2s, v12.2d,#32 + //shrn v14.2s, v14.2d,#32 + //shrn v16.2s, v16.2d,#32 + + ST1 {v12.s}[0], [x3], x8 + + ST1 {v14.s}[0], [x0], #4 + + SQNEG v12.4s, v12.4s + + + ST1 {v12.s}[2], [x10], #4 + + ST1 {v16.s}[2], [x11], x8 + +LOOP1: + LD1 {v2.2s}, [x0] + LD1 {v3.2s}, [x10] + LDR w5, [x3] //RE2 + sxtw x5, w5 + LDR w6, [x11] //RE3 + sxtw x6, w6 + //VTRN.32 D2, D3 + TRN1 v4.2s, v2.2s, v3.2s + TRN2 v3.2s, v2.2s, v3.2s + MOV v2.8b, v4.8b + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + add v12.2d, v8.2d , v6.2d + SQSUB v14.2d, v4.2d , v10.2d + SQSUB v16.2d, v10.2d , v4.2d + + //shrn v12.2s, v12.2d,#32 + //shrn v14.2s, v14.2d,#32 + //shrn v16.2s, v16.2d,#32 + + ST1 {v12.s}[0], [x0], #4 + ST1 {v14.s}[0], [x3], x8 + SQNEG v12.4s, v12.4s + + ST1 {v12.s}[2], [x11], x8 + ST1 {v16.s}[2], [x10], #4 + + LDR w19, =0 + DUP V0.4s, w19 + DUP V1.4s, w19 + // second part + LD2 {v0.h, v1.h}[0], [x1], #4 + sxtl v0.4s, v0.4h + sxtl v1.4s, v1.4h + dup v0.2s, v0.s[0] + dup v1.2s, v1.s[0] + + mov v3.s[0], w5 + mov v3.s[1], w6 + LD1 {v2.s}[0], [x3] + LD1 {v2.s}[1], [x11] + + sMULL v4.2d, v0.2s, v2.2s //qsub 2nd + sshr v4.2d, v4.2d, #16 + sMULL v6.2d, v0.2s, v3.2s //add 2nd + sshr v6.2d, v6.2d, #16 + sMULL v8.2d, v1.2s, v2.2s //add 1st + sshr v8.2d, v8.2d, #16 + sMULL v10.2d, v1.2s, v3.2s //qsub 1st + sshr v10.2d, v10.2d, #16 + + add v12.2d, v4.2d , v10.2d + SQSUB v14.2d, v8.2d , v6.2d + SQSUB v16.2d, v6.2d , v8.2d + + //shrn v12.2s, v12.2d,#32 + //shrn v14.2s, v14.2d,#32 + //shrn v16.2s, v16.2d,#32 + + ST1 {v12.s}[0], [x3], x8 + ST1 {v14.s}[0], [x0], #4 + + SQNEG v12.4s, v12.4s + + subs x4, x4, #1 + ST1 {v12.s}[2], [x10], #4 + ST1 {v16.s}[2], [x11], x8 + + BGT LOOP1 + //VPOP {D8-D15} + // LDMFD sp!, {x4-x12, x15} + //ldp x19, x20,[sp],#16 + pop_v_regs + ret diff --git a/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s b/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s new file mode 100644 index 0000000..b20aa46 --- /dev/null +++ b/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s @@ -0,0 +1,555 @@ +.macro push_v_regs + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X18, X19, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X22, X24, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm + +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X22, X24, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X18, X19, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +.endm + + +.text +.p2align 2 +.global ixheaacd_fft32x32_ld2_armv8 + +ixheaacd_fft32x32_ld2_armv8: + + // STMFD sp!, {x4-x12,x14} + push_v_regs + stp x19, x20, [sp, #-16]! + + //DIT Radix-4 FFT First Stage + //First Butterfly + MOV x0, x2 + MOV x1, x3 + LDR w2, [x0] //x_0 = x[0 ] + sxtw x2, w2 + LDR w3, [x0, #32] //x_2 = x[8 ] + sxtw x3, w3 + LDR w4, [x0, #64] //x_4 = x[16] + sxtw x4, w4 + LDR w5, [x0, #96] //x_6 = x[24] + sxtw x5, w5 + ADD w6, w2, w4 //xh0_0 = x_0 + x_4 + SUB w7, w2, w4 //xl0_0 = x_0 - x_4 + ADD w8, w3, w5 //xh0_1 = x_2 + x_6 + SUB w9, w3, w5 //xl0_1 = x_2 - x_6 + + LDR w2, [x0, #4] //x_1 = x[0 +1] + sxtw x2, w2 + LDR w3, [x0, #36] //x_3 = x[8 +1] + sxtw x3, w3 + LDR w4, [x0, #68] //x_5 = x[16+1] + sxtw x4, w4 + LDR w5, [x0, #100] //x_7 = x[24+1] + sxtw x5, w5 + ADD w10, w2, w4 //xh1_0 = x_1 + x_5 + SUB w11, w2, w4 //xl1_0 = x_1 - x_5 + ADD w12, w3, w5 //xh1_1 = x_3 + x_7 + SUB w14, w3, w5 //xl1_1 = x_3 - x_7 + + ADD w2, w6, w8 //n00 = xh0_0 + xh0_1 + ADD w3, w7, w14 //n10 = xl0_0 + xl1_1 + SUB w4, w6, w8 //n20 = xh0_0 - xh0_1 + SUB w5, w7, w14 //n30 = xl0_0 - xl1_1 + STR w2, [x0] //x[0 ] = n00 + STR w3, [x0, #32] //x[8 ] = n10 + STR w4, [x0, #64] //x[16] = n20 + STR w5, [x0, #96] //x[24] = n30 + + ADD w2, w10, w12 //n01 = xh1_0 + xh1_1 + SUB w3, w11, w9 //n11 = xl1_0 - xl0_1 + SUB w4, w10, w12 //n21 = xh1_0 - xh1_1 + ADD w5, w11, w9 //n31 = xl1_0 + xl0_1 + STR w2, [x0, #4] //x[1 ] = n01 + STR w3, [x0, #36] //x[8+1 ] = n11 + STR w4, [x0, #68] //x[16+1] = n21 + STR w5, [x0, #100] //x[24+1] = n31 + + //Second Butterfly + LDR w2, [x0, #8] //x_0 = x[2 ] + sxtw x2, w2 + LDR w3, [x0, #40] //x_2 = x[10] + sxtw x3, w3 + LDR w4, [x0, #72] //x_4 = x[18] + sxtw x4, w4 + LDR w5, [x0, #104] //x_6 = x[26] + sxtw x5, w5 + ADD w6, w2, w4 //xh0_0 = x_0 + x_4 + SUB w7, w2, w4 //xl0_0 = x_0 - x_4 + ADD w8, w3, w5 //xh0_1 = x_2 + x_6 + SUB w9, w3, w5 //xl0_1 = x_2 - x_6 + + LDR w2, [x0, #12] //x_1 = x[2 +1] + sxtw x2, w2 + LDR w3, [x0, #44] //x_3 = x[10+1] + sxtw x3, w3 + LDR w4, [x0, #76] //x_5 = x[18+1] + sxtw x4, w4 + LDR w5, [x0, #108] //x_7 = x[26+1] + sxtw x5, w5 + ADD w10, w2, w4 //xh1_0 = x_1 + x_5 + SUB w11, w2, w4 //xl1_0 = x_1 - x_5 + ADD w12, w3, w5 //xh1_1 = x_3 + x_7 + SUB w14, w3, w5 //xl1_1 = x_3 - x_7 + + ADD w2, w6, w8 //n00 = xh0_0 + xh0_1 + ADD w3, w7, w14 //n10 = xl0_0 + xl1_1 + SUB w4, w6, w8 //n20 = xh0_0 - xh0_1 + SUB w5, w7, w14 //n30 = xl0_0 - xl1_1 + STR w2, [x0, #8] //x[2 ] = n00 + STR w3, [x0, #40] //x[10] = n10 + STR w4, [x0, #72] //x[18] = n20 + STR w5, [x0, #104] //x[26] = n30 + + ADD w2, w10, w12 //n01 = xh1_0 + xh1_1 + SUB w3, w11, w9 //n11 = xl1_0 - xl0_1 + SUB w4, w10, w12 //n21 = xh1_0 - xh1_1 + ADD w5, w11, w9 //n31 = xl1_0 + xl0_1 + STR w2, [x0, #12] //x[2 +1] = n01 + STR w3, [x0, #44] //x[10+1] = n11 + STR w4, [x0, #76] //x[18+1] = n21 + STR w5, [x0, #108] //x[26+1] = n31 + + //Third Butterfly + LDR w2, [x0, #16] //x_0 = x[4 ] + sxtw x2, w2 + LDR w3, [x0, #48] //x_2 = x[12] + sxtw x3, w3 + LDR w4, [x0, #80] //x_4 = x[20] + sxtw x4, w4 + LDR w5, [x0, #112] //x_6 = x[28] + sxtw x5, w5 + ADD w6, w2, w4 //xh0_0 = x_0 + x_4 + SUB w7, w2, w4 //xl0_0 = x_0 - x_4 + ADD w8, w3, w5 //xh0_1 = x_2 + x_6 + SUB w9, w3, w5 //xl0_1 = x_2 - x_6 + + LDR w2, [x0, #20] //x_1 = x[4 +1] + sxtw x2, w2 + LDR w3, [x0, #52] //x_3 = x[12+1] + sxtw x3, w3 + LDR w4, [x0, #84] //x_5 = x[20+1] + sxtw x4, w4 + LDR w5, [x0, #116] //x_7 = x[28+1] + sxtw x5, w5 + ADD w10, w2, w4 //xh1_0 = x_1 + x_5 + SUB w11, w2, w4 //xl1_0 = x_1 - x_5 + ADD w12, w3, w5 //xh1_1 = x_3 + x_7 + SUB w14, w3, w5 //xl1_1 = x_3 - x_7 + + ADD w2, w6, w8 //n00 = xh0_0 + xh0_1 + ADD w3, w7, w14 //n10 = xl0_0 + xl1_1 + SUB w4, w6, w8 //n20 = xh0_0 - xh0_1 + SUB w5, w7, w14 //n30 = xl0_0 - xl1_1 + STR w2, [x0, #16] //x[4 ] = n00 + STR w3, [x0, #48] //x[12] = n10 + STR w4, [x0, #80] //x[20] = n20 + STR w5, [x0, #112] //x[28] = n30 + + ADD w2, w10, w12 //n01 = xh1_0 + xh1_1 + SUB w3, w11, w9 //n11 = xl1_0 - xl0_1 + SUB w4, w10, w12 //n21 = xh1_0 - xh1_1 + ADD w5, w11, w9 //n31 = xl1_0 + xl0_1 + STR w2, [x0, #20] //x[4 +1] = n01 + STR w3, [x0, #52] //x[12+1] = n11 + STR w4, [x0, #84] //x[20+1] = n21 + STR w5, [x0, #116] //x[28+1] = n31 + + //Fourth Butterfly + LDR w2, [x0, #24] //x_0 = x[6 ] + sxtw x2, w2 + LDR w3, [x0, #56] //x_2 = x[14] + sxtw x3, w3 + LDR w4, [x0, #88] //x_4 = x[22] + sxtw x4, w4 + LDR w5, [x0, #120] //x_6 = x[30] + sxtw x5, w5 + ADD w6, w2, w4 //xh0_0 = x_0 + x_4 + SUB w7, w2, w4 //xl0_0 = x_0 - x_4 + ADD w8, w3, w5 //xh0_1 = x_2 + x_6 + SUB w9, w3, w5 //xl0_1 = x_2 - x_6 + + LDR w2, [x0, #28] //x_1 = x[6 +1] + sxtw x2, w2 + LDR w3, [x0, #60] //x_3 = x[14+1] + sxtw x3, w3 + LDR w4, [x0, #92] //x_5 = x[22+1] + sxtw x4, w4 + LDR w5, [x0, #124] //x_7 = x[30+1] + sxtw x5, w5 + ADD w10, w2, w4 //xh1_0 = x_1 + x_5 + SUB w11, w2, w4 //xl1_0 = x_1 - x_5 + ADD w12, w3, w5 //xh1_1 = x_3 + x_7 + SUB w14, w3, w5 //xl1_1 = x_3 - x_7 + + ADD w2, w6, w8 //n00 = xh0_0 + xh0_1 + ADD w3, w7, w14 //n10 = xl0_0 + xl1_1 + SUB w4, w6, w8 //n20 = xh0_0 - xh0_1 + SUB w5, w7, w14 //n30 = xl0_0 - xl1_1 + STR w2, [x0, #24] //x[6 ] = n00 + STR w3, [x0, #56] //x[14] = n10 + STR w4, [x0, #88] //x[22] = n20 + STR w5, [x0, #120] //x[30] = n30 + + ADD w2, w10, w12 //n01 = xh1_0 + xh1_1 + SUB w3, w11, w9 //n11 = xl1_0 - xl0_1 + SUB w4, w10, w12 //n21 = xh1_0 - xh1_1 + ADD w5, w11, w9 //n31 = xl1_0 + xl0_1 + STR w2, [x0, #28] //x[6 +1] = n01 + STR w3, [x0, #60] //x[14+1] = n11 + STR w4, [x0, #92] //x[22+1] = n21 + STR w5, [x0, #124] //x[30+1] = n31 + + + //DIT Radix-4 FFT Second Stage + //First Butterfly + LDR w2, [x0] //inp_0qr = x[0] + sxtw x2, w2 + LDR w3, [x0, #8] //inp_1qr = x[2] + sxtw x3, w3 + LDR w4, [x0, #16] //inp_2qr = x[4] + sxtw x4, w4 + LDR w5, [x0, #24] //inp_3qr = x[6] + sxtw x5, w5 + ADD w6, w2, w4 //sum_0qr = mul_0qr + mul_2qr + SUB w7, w2, w4 //sum_1qr = mul_0qr - mul_2qr + ADD w8, w3, w5 //sum_2qr = mul_1qr + mul_3qr + SUB w9, w3, w5 //sum_3qr = mul_1qr - mul_3qr + + LDR w2, [x0, #4] //inp_0qi = x[1] + sxtw x2, w2 + LDR w3, [x0, #12] //inp_1qi = x[3] + sxtw x3, w3 + LDR w4, [x0, #20] //inp_2qi = x[5] + sxtw x4, w4 + LDR w5, [x0, #28] //inp_3qi = x[7] + sxtw x5, w5 + ADD w10, w2, w4 //sum_0qi = mul_0qi + mul_2qi + SUB w11, w2, w4 //sum_1qi = mul_0qi - mul_2qi + ADD w12, w3, w5 //sum_2qi = mul_1qi + mul_3qi + SUB w14, w3, w5 //sum_3qi = mul_1qi - mul_3qi + + ADD w2, w6, w8 //sum_0qr + sum_2qr + ADD w3, w7, w14 //sum_1qr + sum_3qi + SUB w4, w6, w8 //sum_0qr - sum_2qr + SUB w5, w7, w14 //sum_1qr - sum_3qi + STR w2, [x1] //y[0 ] = sum_0qr + sum_2qr + STR w3, [x1, #32] //y[8 ] = sum_1qr + sum_3qi + STR w4, [x1, #64] //y[16] = sum_0qr - sum_2qr + STR w5, [x1, #96] //y[24] = sum_1qr - sum_3qi + + ADD w2, w10, w12 //sum_0qi + sum_2qi + SUB w3, w11, w9 //sum_1qi - sum_3qr + SUB w4, w10, w12 //sum_0qi - sum_2qi + ADD w5, w11, w9 //sum_1qi + sum_3qr + STR w2, [x1, #4] //y[0 +1] = sum_0qi + sum_2qi + STR w3, [x1, #36] //y[8 +1] = sum_1qi - sum_3qr + STR w4, [x1, #68] //y[16+1] = sum_0qi - sum_2qi + STR w5, [x1, #100] //y[24+1] = sum_1qi + sum_3qr + + + //Load twiddle factors +// LDR w11, =2310960706 //0x89BE7642 + LDR w11, =0x7642 + sxth w11, w11 + LDR w21, =0x89BE + sxth w21, w21 +// LDR w12, =3473158396 //0xCF0430FC + LDR w12, =0x30FC + sxth w12, w12 + LDR w22, =0xCF04 + sxth w22, w22 +// LDR w14, =2776455811 //0xA57D5A83 + LDR w14, =0x5A83 + sxth w14, w14 + LDR w24, =0xA57D + sxth w24, w24 + + //Second Butterfly + LDR w2, [x0, #32] //mul_0qr = inp_0qr = x[8] + sxtw x2, w2 + LDR w3, [x0, #36] //mul_0qi = inp_1qr = x[9] + sxtw x3, w3 + + LDR w5, [x0, #40] //inp_1qr = x[10] + sxtw x5, w5 + LDR w6, [x0, #44] //inp_1qi = x[11] + sxtw x6, w6 + + SMULL x4, w5, w11 + ASR x4, x4, #16 +// SMULWB x4, x5, x11 //mul_1qr = mpy_16_32_ns( 0x7642 , inp_1qr) + + SMULL x20, w6, w12 + ASR x20, x20, #16 + ADD w4, w4, w20 +// SMLAWB x4, x6, x12, x4 //mul_1qr -= mpy_16_32_ns(-0x30FC , inp_1qi) + + SMULL x5, w5, w22 + ASR x5, x5, #16 +// SMULWT x5, x5, x12 //mul_1qi = mpy_16_32_ns(-0x30FC , inp_1qr) + + LDR w7, [x0, #48] //inp_2qr = x[12] + sxtw x7, w7 + LDR w8, [x0, #52] //inp_2qi = x[13] + sxtw x8, w8 + + //Moved for delay slot + SMULL x20, w6, w11 + ASR x20, x20, #16 + ADD w5, w5, w20 +// SMLAWB x5, x6, x11, x5 //mul_1qi += mpy_16_32_ns( 0x7642 , inp_1qi) + + ADD w6, w7, w8 //(inp_2qr + inp_2qi) + + SMULL x6, w6, w14 + ASR x6, x6, #16 +// SMULWB x6, x6, x14 //mul_2qr = mpy_16_32_ns(0x5A83 , (inp_2qr + inp_2qi)) + + SUB w7, w8, w7 //(-inp_2qr + inp_2qi) + + SMULL x7, w7, w14 + ASR x7, x7, #16 +// SMULWB x7, x7, x14 //mul_2qi = mpy_16_32_ns(0x5A83 , (-inp_2qr + inp_2qi)) + + LDR x9 , [x0, #56] //inp_3qr = x[14] + sxtw x9, w9 + LDR w10, [x0, #60] //inp_3qi = x[15] + sxtw x10, w10 + + SMULL x8, w9, w12 + ASR x8, x8, #16 +// SMULWB x8, x9 , x12 //mul_3qr = mpy_16_32_ns( 0x30FC , inp_3qr) + + SMULL x20, w10, w11 + ASR x20, x20, #16 + ADD w8, w8, w20 +// SMLAWB x8, x10, x11, x8 //mul_3qr -= mpy_16_32_ns(-0x7642 , inp_3qi)// + + SMULL x9, w9 , w21 + ASR x9, x9, #16 +// SMULWT x9, x9 , x11 //mul_3qi = mpy_16_32_ns(-0x7642 , inp_3qr) + + SMULL x20, w10, w12 + ASR x20, x20, #16 + ADD w9, w9, w20 +// SMLAWB x9, x10, x12, x9 //mul_3qi += mpy_16_32_ns( 0x30FC , inp_3qi) + + ADD w10, w2, w6, lsl #1 //sum_0qr = mul_0qr + (mul_2qr << 1) + SUB w2 , w2, w6, lsl #1 //sum_1qr = mul_0qr - (mul_2qr << 1) + ADD w6 , w4, w8 //sum_2qr = mul_1qr + mul_3qr + SUB w4 , w4, w8 //sum_3qr = mul_1qr - mul_3qr + + ADD w8 , w3, w7, lsl #1 //sum_0qi = mul_0qi + (mul_2qi << 1) + SUB w3 , w3, w7, lsl #1 //sum_1qi = mul_0qi - (mul_2qi << 1) + ADD w7 , w5, w9 //sum_2qi = mul_1qi + mul_3qi + SUB w5 , w5, w9 //sum_3qi = mul_1qi - mul_3qi + + ADD w9 , w10, w6, lsl #1 //sum_0qr + (sum_2qr << 1) + SUB w10, w10, w6, lsl #1 //sum_0qr - (sum_2qr << 1) + ADD w6 , w2 , w5, lsl #1 //sum_1qr + (sum_3qi << 1) + SUB w2 , w2 , w5, lsl #1 //sum_1qr - (sum_3qi << 1) + STR w9 , [x1, #8] //y[2 ] = sum_0qr + (sum_2qr << 1) + STR w10, [x1, #72] //y[18] = sum_0qr - (sum_2qr << 1) + STR w6 , [x1, #40] //y[10] = sum_1qr + (sum_3qi << 1) + STR w2 , [x1, #104] //y[26] = sum_1qr - (sum_3qi << 1) + + ADD w5 , w8 , w7, lsl #1 //sum_0qi + (sum_2qi << 1) + SUB w8 , w8 , w7, lsl #1 //sum_0qi - (sum_2qi << 1) + SUB w7 , w3 , w4, lsl #1 //sum_1qi - (sum_3qr << 1) + ADD w3 , w3 , w4, lsl #1 //sum_1qi + (sum_3qr << 1) + STR w5 , [x1, #12] //y[2 +1] = sum_0qi + (sum_2qi << 1) + STR w8 , [x1, #76] //y[18+1] = sum_0qi - (sum_2qi << 1) + STR w7 , [x1, #44] //y[10+1] = sum_1qi - (sum_3qr << 1) + STR w3 , [x1, #108] //y[26+1] = sum_1qi + (sum_3qr << 1) + + //Third Butterfly + LDR w2, [x0, #64] //mul_0qr = inp_0qr = x[16] + sxtw x2, w2 + LDR w5, [x0, #72] //inp_1qr = x[18] + sxtw x5, w5 + LDR w6, [x0, #76] //inp_1qi = x[19] + sxtw x6, w6 + //Moved for delay slot + LDR w3, [x0, #68] //mul_0qi = inp_1qr = x[17] + sxtw x3, w3 + + ADD w4, w5, w6 //(inp_1qr + inp_1qi) + + SMULL x4, w4, w14 + ASR x4, x4, #16 +// SMULWB x4, x4, x14 //mul_1qr = mpy_16_32_ns(0x5A83 , (inp_1qr + inp_1qi)) + SUB w5, w6, w5 //(-inp_1qr + inp_1qi) + + SMULL x5, w5, w14 + ASR x5, x5, #16 +// SMULWB x5, x5, x14 //mul_1qi = mpy_16_32_ns(0x5A83 , (-inp_1qr + inp_1qi)) + + LDR w6, [x0, #84] //mul_2qr = inp_2qi = x[21] + sxtw x6, w6 + LDR x9 , [x0, #88] //inp_3qr = x[22] + sxtw x9, w9 + LDR w10, [x0, #92] //inp_3qi = x[23] + sxtw x10, w10 + //Moved for delay slot + LDR w7, [x0, #80] //mul_2qi = inp_2qr = x[20] + sxtw x7, w7 + + SUB w8 , w10, w9 //(-inp_3qr + inp_3qi) + + SMULL x8, w8, w14 + ASR x8, x8, #16 +// SMULWB x8 , x8 , x14 //mul_3qr = mpy_16_32_ns( 0x5A83 , (-inp_3qr + inp_3qi)) + + ADD w9 , w9 , w10 //(inp_3qr + inp_3qi) + + SMULL x9, w9, w24 + ASR x9, x9, #16 +// SMULWT x9 , x9 , x14 //mul_3qi = mpy_16_32_ns(-0x5A83 , (inp_3qr + inp_3qi)) + + ADD w10, w2, w6 //sum_0qr = mul_0qr + mul_2qr + SUB w2 , w2, w6 //sum_1qr = mul_0qr - mul_2qr + ADD w6 , w4, w8 //sum_2qr = mul_1qr + mul_3qr + SUB w4 , w4, w8 //sum_3qr = mul_1qr - mul_3qr + + SUB w8 , w3, w7 //sum_0qi = mul_0qi - mul_2qi + ADD w3 , w3, w7 //sum_1qi = mul_0qi + mul_2qi + ADD w7 , w5, w9 //sum_2qi = mul_1qi + mul_3qi + SUB w5 , w5, w9 //sum_3qi = mul_1qi - mul_3qi + + ADD w9 , w10, w6, lsl #1 //sum_0qr + (sum_2qr << 1) + SUB w10, w10, w6, lsl #1 //sum_0qr - (sum_2qr << 1) + ADD w6 , w2 , w5, lsl #1 //sum_1qr + (sum_3qi << 1) + SUB w2 , w2 , w5, lsl #1 //sum_1qr - (sum_3qi << 1) + STR w9 , [x1, #16] //y[4 ] = sum_0qr + (sum_2qr << 1) + STR w10, [x1, #80] //y[20] = sum_0qr - (sum_2qr << 1) + STR w6 , [x1, #48] //y[12] = sum_1qr + (sum_3qi << 1) + STR w2 , [x1, #112] //y[28] = sum_1qr - (sum_3qi << 1) + + ADD w5, w8, w7, lsl #1 //sum_0qi + (sum_2qi << 1) + SUB w8, w8, w7, lsl #1 //sum_0qi - (sum_2qi << 1) + SUB w7, w3, w4, lsl #1 //sum_1qi - (sum_3qr << 1) + ADD w3, w3, w4, lsl #1 //sum_1qi + (sum_3qr << 1) + STR w5 , [x1, #20] //y[4 +1] = sum_0qi + (sum_2qi << 1) + STR w8 , [x1, #84] //y[20+1] = sum_0qi - (sum_2qi << 1) + STR w7 , [x1, #52] //y[12+1] = sum_1qi - (sum_3qr << 1) + STR w3 , [x1, #116] //y[28+1] = sum_1qi + (sum_3qr << 1) + + //Fourth Butterfly + LDR w2, [x0, #96] //mul_0qr = inp_0qr = x[24] + sxtw x2, w2 + LDR w3, [x0, #100] //mul_0qi = inp_1qr = x[25] + sxtw x3, w3 + + LDR w5, [x0, #104] //inp_1qr = x[26] + sxtw x5, w5 + LDR w6, [x0, #108] //inp_1qi = x[27] + sxtw x6, w6 + + SMULL x4, w5, w12 + ASR x4, x4, #16 +// SMULWB x4, x5, x12 //mul_1qr = mpy_16_32_ns( 0x30FC , inp_1qr) + + SMULL x20, w6, w11 + ASR x20, x20, #16 + ADD w4, w4, w20 +// SMLAWB x4, x6, x11, x4 //mul_1qr -= mpy_16_32_ns(-0x7642 , inp_1qi) + + SMULL x5, w5, w21 + ASR x5, x5, #16 +// SMULWT x5, x5, x11 //mul_1qi = mpy_16_32_ns(-0x7642 , inp_1qr) + + LDR w7, [x0, #112] //inp_2qr = x[28] + sxtw x7, w7 + LDR w8, [x0, #116] //inp_2qi = x[29] + sxtw x8, w8 + + //Moved for delay slot + SMULL x20, w6, w12 + ASR x20, x20, #16 + ADD w5, w5, w20 +// SMLAWB x5, x6, x12, x5 //mul_1qi += mpy_16_32_ns( 0x30FC , inp_1qi) + + SUB w6, w8, w7 //(-inp_2qr + inp_2qi) + + SMULL x6, w6, w14 + ASR x6, x6, #16 +// SMULWB x6, x6, x14 //mul_2qr = mpy_16_32_ns( 0x5A83 , (-inp_2qr + inp_2qi)) + ADD w7, w8, w7 //(inp_2qr + inp_2qi) + + SMULL x7, w7, w24 + ASR x7, x7, #16 +// SMULWT x7, x7, x14 //mul_2qi = mpy_16_32_ns(-0x5A83 , (inp_2qr + inp_2qi)) + + LDR w9 , [x0, #120] //inp_3qr = x[30] + sxtw x9, w9 + LDR w10, [x0, #124] //inp_3qi = x[31] + sxtw x10, w10 + + SMULL x8, w9, w21 + ASR x8, x8, #16 +// SMULWT x8, x9 , x11 //mul_3qr = mpy_16_32_ns(-0x7642 , inp_3qr) + + SMULL x20, w10, w22 + ASR x20, x20, #16 + ADD w8, w8, w20 +// SMLAWT x8, x10, x12, x8 //mul_3qr -= mpy_16_32_ns( 0x30FC , inp_3qi)// + + SMULL x9, w9, w12 + ASR x9, x9, #16 +// SMULWB x9, x9 , x12 //mul_3qi = mpy_16_32_ns( 0x30FC , inp_3qr) + + SMULL x20, w10, w21 + ASR x20, x20, #16 + ADD w9, w9, w20 +// SMLAWT x9, x10, x11, x9 //mul_3qi += mpy_16_32_ns(-0x7642 , inp_3qi) + + ADD w10, w2, w6, lsl #1 //sum_0qr = mul_0qr + (mul_2qr << 1) + SUB w2 , w2, w6, lsl #1 //sum_1qr = mul_0qr - (mul_2qr << 1) + ADD w6 , w4, w8 //sum_2qr = mul_1qr + mul_3qr + SUB w4 , w4, w8 //sum_3qr = mul_1qr - mul_3qr + + ADD w8 , w3, w7, lsl #1 //sum_0qi = mul_0qi + (mul_2qi << 1) + SUB w3 , w3, w7, lsl #1 //sum_1qi = mul_0qi - (mul_2qi << 1) + ADD w7 , w5, w9 //sum_2qi = mul_1qi + mul_3qi + SUB w5 , w5, w9 //sum_3qi = mul_1qi - mul_3qi + + ADD w9 , w10, w6, lsl #1 //sum_0qr + (sum_2qr << 1) + SUB w10, w10, w6, lsl #1 //sum_0qr - (sum_2qr << 1) + ADD w6 , w2 , w5, lsl #1 //sum_1qr + (sum_3qi << 1) + SUB w2 , w2 , w5, lsl #1 //sum_1qr - (sum_3qi << 1) + STR w9 , [x1, #24] //y[6 ] = sum_0qr + (sum_2qr << 1) + STR w10, [x1, #88] //y[22] = sum_0qr - (sum_2qr << 1) + STR w6 , [x1, #56] //y[14] = sum_1qr + (sum_3qi << 1) + STR w2 , [x1, #120] //y[30] = sum_1qr - (sum_3qi << 1) + + ADD w5 , w8 , w7, lsl #1 //sum_0qi + (sum_2qi << 1) + SUB w8 , w8 , w7, lsl #1 //sum_0qi - (sum_2qi << 1) + SUB w7 , w3 , w4, lsl #1 //sum_1qi - (sum_3qr << 1) + ADD w3 , w3 , w4, lsl #1 //sum_1qi + (sum_3qr << 1) + STR w5 , [x1, #28] //y[6 +1] = sum_0qi + (sum_2qi << 1) + STR w8 , [x1, #92] //y[22+1] = sum_0qi - (sum_2qi << 1) + STR w7 , [x1, #60] //y[14+1] = sum_1qi - (sum_3qr << 1) + STR w3 , [x1, #124] //y[30+1] = sum_1qi + (sum_3qr << 1) + + // LDMFD sp!, {x4-x12,x15} + ldp x19, x20, [sp], #16 + pop_v_regs + ret + diff --git a/decoder/armv8/ixheaacd_function_selector_armv8.c b/decoder/armv8/ixheaacd_function_selector_armv8.c new file mode 100644 index 0000000..86592d3 --- /dev/null +++ b/decoder/armv8/ixheaacd_function_selector_armv8.c @@ -0,0 +1,248 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_block.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_dsp_fft32x32s.h" +#include "ixheaacd_interface.h" + +WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_dec; + +VOID(*ixheaacd_covariance_matrix_calc) +(WORD32 *, ixheaacd_lpp_trans_cov_matrix *, + WORD32) = &ixheaacd_covariance_matrix_calc_dec; + +VOID(*ixheaacd_covariance_matrix_calc_2) +(ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, + WORD16) = &ixheaacd_covariance_matrix_calc_2_dec; + +VOID(*ixheaacd_over_lap_add1) +(WORD32 *, WORD32 *, WORD16 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add1_armv8; + +VOID(*ixheaacd_over_lap_add2) +(WORD32 *, WORD32 *, WORD32 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add2_armv8; + +VOID(*ixheaacd_decorr_filter2) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter2_dec; + +VOID(*ixheaacd_decorr_filter1) +(ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter1_dec; + +WORD32(*ixheaacd_divide16_pos) +(WORD32 op1, WORD32 op2) = &ixheaacd_divide16_pos_dec; + +VOID(*ixheaacd_decorrelation) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) = &ixheaacd_decorrelation_dec; + +VOID(*ixheaacd_apply_rot) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, WORD32 *p_qmf_left_im, + WORD32 *p_qmf_right_re, WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res) = &ixheaacd_apply_rot_dec; + +VOID(*ixheaacd_conv_ergtoamplitudelp) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitudelp_dec; + +VOID(*ixheaacd_conv_ergtoamplitude) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitude_dec; + +VOID(*ixheaacd_adjust_scale) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) = &ixheaacd_adjust_scale_dec; + +WORD16(*ixheaacd_ixheaacd_expsubbandsamples) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, + FLAG low_pow_flag) = &ixheaacd_expsubbandsamples_dec; + +VOID(*ixheaacd_enery_calc_per_subband) +(WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 frame_exp, WORD16 *nrg_est_mant, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) = &ixheaacd_enery_calc_per_subband_dec; + +VOID(*ixheaacd_harm_idx_zerotwolp) +(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) = &ixheaacd_harm_idx_zerotwolp_dec; + +VOID(*ixheaacd_tns_ar_filter_fixed) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_armv8; + +VOID(*ixheaacd_tns_ar_filter) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec, + WORD32 *ptr_filter_state) = &ixheaacd_tns_ar_filter_dec; + +VOID(*ixheaacd_tns_parcor_lpc_convert) +(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, + WORD order) = &ixheaacd_tns_parcor_lpc_convert_dec; + +WORD32(*ixheaacd_calc_max_spectral_line) +(WORD32 *ptr_tmp, WORD32 size) = &ixheaacd_calc_max_spectral_line_armv8; + +VOID(*ixheaacd_post_twiddle) +(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) = &ixheaacd_post_twiddle_armv8; + +VOID(*ixheaacd_post_twid_overlap_add) +(WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) = &ixheaacd_post_twid_overlap_add_armv8; + +VOID(*ixheaacd_neg_shift_spec) +(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) = &ixheaacd_neg_shift_spec_armv8; + +VOID(*ixheaacd_spec_to_overlapbuf) +(WORD32 *ptr_overlap_buf, WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) = &ixheaacd_spec_to_overlapbuf_dec; + +VOID(*ixheaacd_overlap_buf_out) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac) = &ixheaacd_overlap_buf_out_dec; + +VOID(*ixheaacd_overlap_out_copy) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) = &ixheaacd_overlap_out_copy_dec; + +VOID(*ixheaacd_pretwiddle_compute) +(WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) = &ixheaacd_pretwiddle_compute_armv8; + +VOID(*ixheaacd_imdct_using_fft) +(ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_armv8; + +VOID(*ixheaacd_complex_fft_p2) +(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode, + WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec; + +VOID(*ixheaacd_mps_complex_fft_64) +(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im, + WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; + +VOID(*ixheaacd_mps_synt_pre_twiddle) +(WORD32 *ptr_in, WORD32 *table_re, 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 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; + +VOID(*ixheaacd_calc_pre_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec; + +VOID(*ixheaacd_calc_post_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + 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; + +VOID(*ixheaacd_mps_synt_out_calc) +(WORD32 resolution, WORD32 *out, WORD32 *state, + const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec; + +VOID(*ixheaacd_fft_15_ld) +(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr) = &ixheaacd_fft_15_ld_dec; + +VOID(*ixheaacd_aac_ld_dec_rearrange) +(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab) = &ixheaacd_rearrange_dec; + +VOID (*ixheaacd_fft32x32_ld) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_armv8; + +VOID (*ixheaacd_fft32x32_ld2) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_fft32x32_ld2_armv8; + +WORD16 (*ixheaacd_neg_expo_inc)(WORD16 neg_expo) = &ixheaacd_neg_expo_inc_arm; + +VOID (*ixheaacd_inv_dit_fft_8pt) +(WORD32 *x, WORD32 *real, WORD32 *imag) = &ixheaacd_inv_dit_fft_8pt_armv8; + +VOID (*ixheaacd_scale_factor_process) +(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_armv8; \ No newline at end of file diff --git a/decoder/armv8/ixheaacd_imdct_using_fft.s b/decoder/armv8/ixheaacd_imdct_using_fft.s new file mode 100644 index 0000000..9f2e204 --- /dev/null +++ b/decoder/armv8/ixheaacd_imdct_using_fft.s @@ -0,0 +1,819 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.macro swp reg1, reg2 + MOv x16, \reg1 + MOv \reg1, \reg2 + MOv \reg2, x16 +.endm +.text +.p2align 2 +.global ixheaacd_imdct_using_fft_armv8 +ixheaacd_imdct_using_fft_armv8: + push_v_regs + + LDR X29, =11600 + ADD X4, X0, X29 + LDR X29, =11856 + ADD X5, X0, X29 + LDR X29, =11920 + ADD X6, X0, X29 + LDR X29, =11936 + ADD X7, X0, X29 + +COND_1: CMP X1, #0x400 + BNE COND_2 + MOv X8, #4 + B RADIX_4_FIRST_START + + +COND_2: CMP X1, #0x200 + BNE COND_3 + MOv X8, #3 + MOv X4, X5 + B RADIX_8_FIRST_START + +COND_3: CMP X1, #0x100 + BNE COND_4 + MOv X8, #3 + MOv X4, X5 + B RADIX_4_FIRST_START + +COND_4: CMP X1, #0x80 + BNE COND_5 + MOv X8, #2 + MOv X4, X6 + B RADIX_8_FIRST_START + +COND_5: CMP X1, #0x40 + BNE COND_6 + MOv X8, #2 + MOv X4, X6 + B RADIX_4_FIRST_START +COND_6: + MOv X8, #1 + MOv X4, X7 + + + +RADIX_8_FIRST_START: + LSR W9 , W1, #5 + LSL W1, W1, #1 + +RADIX_8_FIRST_LOOP: + + MOv X5 , X2 + MOv X6 , X2 + MOv X7 , X2 + MOv X11 , X2 + + + + + + + + + + + + + + + + + + + + + + + LDRB W12, [X4] + ADD X5, X5, X12, LSL #3 + LD2 {v0.S, v1.S}[0], [X5], X1 + ADD X5, X5, X1 + LD2 {v4.S, v5.S}[0], [X5], X1 + SUB X5, X5, X1, LSL #1 + LD2 {v2.S, v3.S}[0], [X5], X1 + ADD X5, X5, X1 + LD2 {v6.S, v7.S}[0], [X5], X1 + SUB X5, X5, X1, LSL #2 + + LDRB W12, [X4, #1] + ADD X6, X6, X12, LSL #3 + LD2 {v0.S, v1.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {v4.S, v5.S}[1], [X6] , X1 + SUB X6, X6, X1, LSL #1 + LD2 {v2.S, v3.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {v6.S, v7.S}[1], [X6], X1 + SUB X6, X6, X1, LSL #2 + + + LDRB W12, [X4, #2] + ADD X7, X7, X12, LSL #3 + LD2 {v0.S, v1.S}[2], [X7] , X1 + ADD X7, X7, X1 + LD2 {v4.S, v5.S}[2], [X7] , X1 + SUB X7, X7, X1, LSL #1 + + LDRB W12, [X4, #3] + ADD X11, X11, X12, LSL #3 + LD2 {v0.S, v1.S}[3], [X11] , X1 + ADD X11, X11, X1 + LD2 {v4.S, v5.S}[3], [X11] , X1 + SUB X11, X11, X1, LSL #1 + + + ADD v8.4S, v0.4S, v4.4S + LD2 {v2.S, v3.S}[2], [X7] , X1 + ADD X7, X7, X1 + + + SUB v9.4S, v0.4S, v4.4S + LD2 {v6.S, v7.S}[2], [X7], X1 + SUB X7, X7, X1, LSL #2 + + + ADD v0.4S, v1.4S, v5.4S + LD2 {v2.S, v3.S}[3], [X11] , X1 + ADD X11, X11, X1 + + SUB v4.4S, v1.4S, v5.4S + LD2 {v6.S, v7.S}[3], [X11], X1 + SUB X11, X11, X1, LSL #2 + + ADD X4, X4, #4 + + ADD X5, X5, X1, LSR #1 + ADD X6, X6, X1, LSR #1 + ADD X7, X7, X1, LSR #1 + ADD X11, X11, X1, LSR #1 + + + ADD v1.4S, v2.4S, v6.4S + LD2 {v14.S, v15.S}[0], [X5] , X1 + + + SUB v5.4S, v2.4S, v6.4S + LD2 {v10.S, v11.S}[0], [X5] , X1 + + + ADD v2.4S, v3.4S, v7.4S + LD2 {v12.S, v13.S}[0], [X5] , X1 + + + SUB v6.4S, v3.4S, v7.4S + LD2 {v14.S, v15.S}[1], [X6] , X1 + + ADD v3.4S, v9.4S, v6.4S + LD2 {v10.S, v11.S}[1], [X6] , X1 + + SUB v7.4S, v9.4S, v6.4S + LD2 {v12.S, v13.S}[1], [X6] , X1 + + SUB v6.4S, v4.4S, v5.4S + LD2 {v14.S, v15.S}[2], [X7] , X1 + + ADD v9.4S, v4.4S, v5.4S + LD2 {v10.S, v11.S}[2], [X7] , X1 + + ADD v4.4S, v8.4S, v1.4S + LD2 {v12.S, v13.S}[2], [X7] , X1 + + SUB v5.4S, v8.4S, v1.4S + LD2 {v14.S, v15.S}[3], [X11] , X1 + + ADD v8.4S, v0.4S, v2.4S + LD2 {v10.S, v11.S}[3], [X11] , X1 + + SUB v0.4S, v0.4S, v2.4S + LD2 {v12.S, v13.S}[3], [X11] , X1 + + + + + + + + + + + + + LD2 {v1.S, v2.S}[0], [X5], X1 + + ADD v17.4S, v14.4S, v12.4S + + LD2 {v1.S, v2.S}[1], [X6] , X1 + + SUB v16.4S, v14.4S, v12.4S + + LD2 {v1.S, v2.S}[2], [X7] , X1 + + ADD v14.4S, v15.4S, v13.4S + + LD2 {v1.S, v2.S}[3], [X11] , X1 + + SUB v12.4S, v15.4S, v13.4S + + ADD v15.4S, v10.4S, v1.4S + SUB v13.4S, v10.4S, v1.4S + ADD v10.4S, v11.4S, v2.4S + SUB v1.4S, v11.4S, v2.4S + + ADD v11.4S, v17.4S, v15.4S + SUB v2.4S, v17.4S, v15.4S + ADD v17.4S, v14.4S, v10.4S + SUB v15.4S, v14.4S, v10.4S + + ADD v14.4S, v16.4S, v12.4S + SUB v10.4S, v16.4S, v12.4S + ADD v16.4S, v13.4S, v1.4S + SUB v12.4S, v13.4S, v1.4S + + ADD v1.4S , v14.4S, v12.4S + SUB v13.4S, v14.4S, v12.4S + SUB v12.4S, v16.4S, v10.4S + + + UZP1 v22.8H, v1.8H, v1.8H + UZP2 v23.8H, v1.8H, v1.8H + ADD v14.4S, v16.4S, v10.4S + + UZP1 v26.8H, v13.8H, v13.8H + UZP2 v27.8H, v13.8H, v13.8H + ADD v16.4S, v4.4S, v11.4S + + UZP1 v24.8H, v12.8H, v12.8H + UZP2 v25.8H, v12.8H, v12.8H + SUB v10.4S, v4.4S, v11.4S + + UZP1 v28.8H, v14.8H, v14.8H + UZP2 v29.8H, v14.8H, v14.8H + ADD v4.4S, v8.4S, v17.4S + + MOv W14, #0x5a82 + + SUB v11.4S, v8.4S, v17.4S + + ADD v8.4S, v5.4S, v15.4S + SUB v17.4S, v5.4S, v15.4S + SUB v5.4S, v0.4S, v2.4S + ADD v15.4S, v0.4S, v2.4S + + + + + + + + + + + + + + + + + + + + + + DUP v31.4H, W14 + + UMULL v19.4S, v26.4H, v31.4H + UMULL v18.4S, v28.4H, v31.4H + SSHR v19.4S, v19.4S, #15 + SSHR v18.4S, v18.4S, #15 + + + SQDMLAL v19.4S, v27.4H, v31.4H + SQDMLAL v18.4S, v29.4H, v31.4H + + + UMULL v13.4S, v24.4H, v31.4H + UMULL v14.4S, v22.4H, v31.4H + + ADD v20.4S, v3.4S, v19.4S + SUB v21.4S, v3.4S, v19.4S + ADD v30.4S, v6.4S, v18.4S + SUB v6.4S, v6.4S, v18.4S + + SSHR v13.4S, v13.4S, #15 + SSHR v14.4S, v14.4S, #15 + + SQDMLAL v13.4S, v25.4H, v31.4H + SQDMLAL v14.4S, v23.4H, v31.4H + + + + + ADD v3.4S, v7.4S, v13.4S + SUB v19.4S, v7.4S, v13.4S + ADD v1.4S, v9.4S, v14.4S + SUB v18.4S, v9.4S, v14.4S + + + + + + + + + + + + + + + + + + + + + + + + swp v17.D[0], v8.D[0] + swp v17.D[1], v8.D[1] + swp v4.D[0], v16.D[0] + swp v4.D[1], v16.D[1] + + TRN1 v12.4S, v4.4S, v20.4S + TRN2 v22.4S, v4.4S, v20.4S + + SHL v12.4S, v12.4S, #3 + TRN1 v9.4S, v17.4S, v3.4S + TRN2 v2.4S, v17.4S, v3.4S + SHL v22.4S, v22.4S, #3 + + SHL v9.4S, v9.4S, #3 + TRN1 v24.4S, v10.4S, v21.4S + TRN2 v7.4S, v10.4S, v21.4S + SHL v2.4S, v2.4S, #3 + + SHL v24.4S, v24.4S, #3 + TRN1 v13.4S, v16.4S, v6.4S + TRN2 v23.4S, v16.4S, v6.4S + SHL v7.4S, v7.4S, #3 + + SHL v13.4S, v13.4S, #3 + TRN1 v10.4S, v5.4S, v18.4S + TRN2 v3.4S, v5.4S, v18.4S + SHL v23.4S, v23.4S, #3 + + SHL v10.4S, v10.4S, #3 + TRN1 v26.4S, v8.4S, v19.4S + TRN2 v4.4S, v8.4S, v19.4S + SHL v3.4S, v3.4S, #3 + + SHL v26.4S, v26.4S, #3 + TRN1 v25.4S, v11.4S, v30.4S + TRN2 v8.4S, v11.4S, v30.4S + SHL v4.4S, v4.4S, #3 + + SHL v25.4S, v25.4S, #3 + TRN1 v27.4S, v15.4S, v1.4S + TRN2 v5.4S, v15.4S, v1.4S + SHL v8.4S, v8.4S, #3 + + SHL v27.4S, v27.4S, #3 + swp v9.D[0], v12.D[1] + SHL v5.4S, v5.4S, #3 + swp v2.D[0], v22.D[1] + + swp v24.D[1], v26.D[0] + swp v7.D[1], v4.D[0] + swp v10.D[0], v13.D[1] + swp v3.D[0], v23.D[1] + swp v27.D[0], v25.D[1] + swp v5.D[0], v8.D[1] + + MOv X15, #32 + ST2 {v12.4S, v13.4S}, [X3], X15 + ST2 {v24.4S, v25.4S}, [X3], X15 + ST2 {v22.4S, v23.4S}, [X3], X15 + ST2 {v7.4S, v8.4S}, [X3], X15 + ST2 {v9.4S, v10.4S}, [X3], X15 + ST2 {v26.4S, v27.4S}, [X3], X15 + ST2 {v2.4S, v3.4S}, [X3], X15 + ST2 {v4.4S, v5.4S}, [X3], X15 + + + SUBS X9, X9, #1 + BNE RADIX_8_FIRST_LOOP + + LSR X1, X1, #1 + LSL X15, X1, #3 + SUB X3, X3, X15 + + MOv X5, #8 + MOv X4, #32 + LSR X15, X1, #5 + MOv X6, X15 + B RADIX_4_FIRST_ENDS +RADIX_8_FIRST_ENDS: + +RADIX_4_FIRST_START: + + LSR W9, W1, #4 + LSL W1, W1, #1 +RADIX_4_LOOP: + + MOv X5 , X2 + MOv X6 , X2 + MOv X7 , X2 + MOv X11 , X2 + + + + + + + + + + + + + + + + LDRB W12, [X4, #0] + ADD X5, X5, X12, LSL #3 + + LD2 {v0.S, v1.S}[0], [X5] , X1 + ADD X5, X5, X1 + LD2 {v8.S, v9.S}[0], [X5] , X1 + SUB X5, X5, X1, LSL #1 + LD2 {v4.S, v5.S}[0], [X5] , X1 + ADD X5, X5, X1 + LD2 {v12.S, v13.S}[0], [X5] , X1 + + LDRB W12, [X4, #1] + ADD X6, X6, X12, LSL #3 + LD2 {v0.S, v1.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {v8.S, v9.S}[1], [X6] , X1 + SUB X6, X6, X1, LSL #1 + LD2 {v4.S, v5.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {v12.S, v13.S}[1], [X6] , X1 + + LDRB W12, [X4, #2] + ADD X7, X7, X12, LSL #3 + + LD2 {v0.S, v1.S}[2], [X7] , X1 + ADD X7, X7, X1 + LD2 {v8.S, v9.S}[2], [X7] , X1 + + + LDRB W12, [X4, #3] + ADD X11, X11, X12 , LSL #3 + + + LD2 {v0.S, v1.S}[3], [X11] , X1 + ADD X11, X11, X1 + LD2 {v8.S, v9.S}[3], [X11] , X1 + + SUB X7, X7, X1, LSL #1 + ADD v16.4S, v0.4S, v8.4S + LD2 {v4.S, v5.S}[2], [X7] , X1 + ADD X7, X7, X1 + ADD v18.4S, v1.4S, v9.4S + LD2 {v12.S, v13.S}[2], [X7] , X1 + + SUB X11, X11, X1, LSL #1 + SUB v20.4S, v0.4S, v8.4S + LD2 {v4.S, v5.S}[3], [X11] , X1 + ADD X11, X11, X1 + SUB v22.4S, v1.4S, v9.4S + LD2 {v12.S, v13.S}[3], [X11] , X1 + + + + + + + ADD X4, X4, #4 + + ADD v24.4S, v4.4S, v12.4S + ADD v26.4S, v5.4S, v13.4S + SUB v28.4S, v4.4S, v12.4S + SUB v30.4S, v5.4S, v13.4S + + ADD v17.4S, v16.4S, v24.4S + ADD v11.4S, v18.4S, v26.4S + SUB v19.4S, v16.4S, v24.4S + SUB v15.4S, v18.4S, v26.4S + + ADD v8.4S, v20.4S, v30.4S + SUB v9.4S, v22.4S, v28.4S + ADD v13.4S, v22.4S, v28.4S + SUB v12.4S, v20.4S, v30.4S + + + + + TRN1 v0.4S, v17.4S, v8.4S + TRN2 v8.4S, v17.4S, v8.4S + + SHL v0.4S, v0.4S, #2 + TRN1 v4.4S, v19.4S, v12.4S + TRN2 v12.4S, v19.4S, v12.4S + SHL v8.4S, v8.4S, #2 + + SHL v4.4S, v4.4S, #2 + TRN1 v1.4S, v11.4S, v9.4S + TRN2 v9.4S, v11.4S, v9.4S + SHL v12.4S, v12.4S, #2 + + SHL v1.4S, v1.4S, #2 + TRN1 v5.4S, v15.4S, v13.4S + TRN2 v13.4S, v15.4S, v13.4S + SHL v9.4S, v9.4S, #2 + + SHL v5.4S, v5.4S, #2 + swp v4.D[0], v0.D[1] + SHL v13.4S, v13.4S, #2 + + swp v12.D[0], v8.D[1] + swp v5.D[0], v1.D[1] + swp v13.D[0], v9.D[1] + + MOv X15, #32 + ST2 {v0.4S, v1.4S}, [X3], X15 + ST2 {v8.4S, v9.4S}, [X3], X15 + ST2 {v4.4S, v5.4S}, [X3], X15 + ST2 {v12.4S, v13.4S}, [X3], X15 + + + SUBS W9, W9, #1 + BNE RADIX_4_LOOP + + LSR X1, X1, #1 + SUB X3, X3, X1, LSL #3 + MOv X5, #4 + MOv X4, #64 + LSR X6, X1, #4 + + +RADIX_4_FIRST_ENDS: + + MOv x30, X3 + LSR X5, X5, #2 + + LDR X14, =8528 + ADD X0, X0, X14 + +OUTER_LOOP_R4: + + MOv X14, x30 + + MOv X7, X5 + MOv X2, #0 + MOv X9, X0 + LSL X12, X5, #5 +MIDDLE_LOOP_R4: + + LD2 {v20.H, v21.H}[0], [X9], X2 + LD2 {v22.H, v23.H}[0], [X9], X2 + ADD X11, X2, X4, LSL #2 + LD2 {v24.H, v25.H}[0], [X9] + ADD X10, X0, X11 + + LD2 {v20.H, v21.H}[1], [X10], X11 + LD2 {v22.H, v23.H}[1], [X10], X11 + ADD X2, X11, X4, LSL #2 + LD2 {v24.H, v25.H}[1], [X10] + ADD X9, X0, X2 + + LD2 {v20.H, v21.H}[2], [X9], X2 + LD2 {v22.H, v23.H}[2], [X9], X2 + ADD X11, X2, X4, LSL #2 + LD2 {v24.H, v25.H}[2], [X9] + ADD X10, X0, X11 + + LD2 {v20.H, v21.H}[3], [X10], X11 + LD2 {v22.H, v23.H}[3], [X10], X11 + ADD X2, X11, X4, LSL #2 + LD2 {v24.H, v25.H}[3], [X10] + ADD X9, X0, X2 + + MOv X10, X6 +INNER_LOOP_R4: + + LD2 {v30.4S, v31.4S}, [X14], X12 + SSHR v30.4S, v30.4S, #1 + LD4 {v16.4H, v17.4H, v18.4H, v19.4H}, [X14], X12 + SSHR v31.4S, v31.4S, #1 + + USHR v16.4H, v16.4H, #1 + LD4 {v26.4H, v27.4H, v28.4H, v29.4H}, [X14], X12 + USHR v18.4H, v18.4H, #1 + + SMULL v11.4S, v16.4H, v20.4H + SMLSL v11.4S, v18.4H, v21.4H + + LD4 {v0.4H, v1.4H, v2.4H, v3.4H}, [X14], X12 + SMULL v12.4S, v16.4H, v21.4H + SMLAL v12.4S, v18.4H, v20.4H + + USHR v26.4H, v26.4H, #1 + USHR v28.4H, v28.4H, #1 + + LSL x29, X12, #2 + SUB X14, X14, X12, LSL #2 + + USHR v0.4H, v0.4H, #1 + USHR v2.4H, v2.4H, #1 + + SMULL v13.4S, v26.4H, v22.4H + SMLSL v13.4S, v28.4H, v23.4H + + SSHR v11.4S, v11.4S, #15 + + SMULL v14.4S, v26.4H, v23.4H + SMLAL v14.4S, v28.4H, v22.4H + + SMULL v15.4S, v0.4H, v24.4H + SMLSL v15.4S, v2.4H, v25.4H + + SMLAL v11.4S, v17.4H, v20.4H + SMLSL v11.4S, v19.4H, v21.4H + + SSHR v12.4S, v12.4S, #15 + SSHR v13.4S, v13.4S, #15 + SSHR v14.4S, v14.4S, #15 + SSHR v15.4S, v15.4S, #15 + + SMLAL v12.4S, v17.4H, v21.4H + SMLAL v12.4S, v19.4H, v20.4H + + SMULL v5.4S, v0.4H, v25.4H + SMLAL v5.4S, v2.4H, v24.4H + + SMLAL v13.4S, v27.4H, v22.4H + SMLSL v13.4S, v29.4H, v23.4H + + SMLAL v14.4S, v27.4H, v23.4H + SMLAL v14.4S, v29.4H, v22.4H + + SMLAL v15.4S, v1.4H, v24.4H + SMLSL v15.4S, v3.4H, v25.4H + + SSHR v5.4S, v5.4S, #15 + + SMLAL v5.4S, v1.4H, v25.4H + SMLAL v5.4S, v3.4H, v24.4H + + + + SUBS x17, X7, X5 + BNE BYPASS_IF + + ADD X14, X14, X12 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + + MOv v11.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOv v13.S[0], W3 + + LDR W3, [X14] + ASR W3, W3, #1 + MOv v15.S[0], W3 + + SUB X14, X14, X12, LSL #1 + ADD X14, X14, #4 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOv v12.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOv v14.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOv v5.S[0], W3 + + SUB X14, X14, #4 + + SUB X14, X14, x29 + + + + + + + + +BYPASS_IF: + + ADD v6.4S, v30.4S, v13.4S + ADD v7.4S, v31.4S, v14.4S + SUB v30.4S, v30.4S, v13.4S + SUB v31.4S, v31.4S, v14.4S + ADD v8.4S, v11.4S, v15.4S + ADD v9.4S, v12.4S, v5.4S + + SUB v15.4S, v11.4S, v15.4S + SUB v14.4S, v12.4S, v5.4S + + + ADD v10.4S, v6.4S, v8.4S + ADD v11.4S, v7.4S, v9.4S + ADD v12.4S, v30.4S, v14.4S + SUB v13.4S, v31.4S, v15.4S + + SUB v6.4S, v6.4S, v8.4S + ST2 {v10.4S, v11.4S}, [X14], X12 + SUB v7.4S, v7.4S, v9.4S + + SUB v8.4S, v30.4S, v14.4S + ST2 {v12.4S, v13.4S}, [X14], X12 + ADD v9.4S, v31.4S, v15.4S + + ST2 {v6.4S, v7.4S}, [X14], X12 + ST2 {v8.4S, v9.4S}, [X14], X12 + SUBS X10, X10, #1 + BNE INNER_LOOP_R4 + + SUB X14, X14, X1, LSL #3 + ADD X14, X14, #32 + + SUBS X7, X7, #1 + BNE MIDDLE_LOOP_R4 + + + + + LSR X4, X4, #2 + LSL X5, X5, #2 + LSR X6, X6, #2 + SUBS X8, X8, #1 + BNE OUTER_LOOP_R4 +END_LOOPS: + pop_v_regs + RET + + + diff --git a/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s b/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s new file mode 100644 index 0000000..51deed7 --- /dev/null +++ b/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s @@ -0,0 +1,174 @@ +//VOID ixheaacd_inv_dit_fft_8pt(WORD32 *y, +// WORD32 *real, +// WORD32 *imag) + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! +.endm +.macro pop_v_regs + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + + +.text +.global ixheaacd_inv_dit_fft_8pt_armv8 +ixheaacd_inv_dit_fft_8pt_armv8: + push_v_regs + LDR w3, =0x5A820000 + DUP v0.2s, w3 + MOV x5, #8 + ADD x6, x0, #4 + + //LD2 {v1.2s,v2.2s},[x0],x5 + //LD2 {v3.2s,v4.2s},[x0],x5 + //LD2 {v5.2s,v6.2s},[x0],x5 + //LD2 {v7.2s,v8.2s},[x0],x5 + + LD1 {v1.s}[0], [x0], x5 + LD1 {v2.s}[0], [x6], x5 + LD1 {v1.s}[1], [x0], x5 + LD1 {v2.s}[1], [x6], x5 + LD1 {v3.s}[0], [x0], x5 + LD1 {v4.s}[0], [x6], x5 + LD1 {v3.s}[1], [x0], x5 + LD1 {v4.s}[1], [x6], x5 + LD1 {v5.s}[0], [x0], x5 + LD1 {v6.s}[0], [x6], x5 + LD1 {v5.s}[1], [x0], x5 + LD1 {v6.s}[1], [x6], x5 + LD1 {v7.s}[0], [x0], x5 + LD1 {v8.s}[0], [x6], x5 + LD1 {v7.s}[1], [x0], x5 + LD1 {v8.s}[1], [x6], x5 + + //v1 - y0_2 + //v2 - y1_3 + //v3 - y4_6 + //v4 - y5_7 + //v5 - y8_10 + //v6 - y9_11 + //v7 - y12_14 + //v8 - y13_15 + + SQADD v9.2s, v1.2s, v5.2s //a00_v = vqadd_s32(y0_2,y8_10); + SQADD v10.2s, v2.2s, v6.2s //a20_v = vqadd_s32(y1_3,y9_11); + SQADD v11.2s, v3.2s, v7.2s //a10_v = vqadd_s32(y4_6,y12_14); + SQADD v12.2s, v4.2s, v8.2s //a30_v = vqadd_s32(y5_7,y13_15); + + SQSUB v1.2s, v1.2s, v5.2s //a0_v = vqsub_s32(y0_2,y8_10); + SQSUB v5.2s, v2.2s, v6.2s //a3_v = vqsub_s32(y1_3,y9_11); + SQSUB v2.2s, v3.2s, v7.2s //a2_v = vqsub_s32(y4_6,y12_14); + SQSUB v6.2s, v4.2s, v8.2s //a1_v = vqsub_s32(y5_7,y13_15); + + SQADD v3.2s, v9.2s, v11.2s //x0_8 = vqadd_s32(a00_v,a10_v); + SQADD v7.2s, v10.2s, v12.2s //x1_9 = vqadd_s32(a20_v,a30_v); + + SQSUB v4.2s, v9.2s, v11.2s //x4_12 = vqsub_s32(a00_v,a10_v); + SQSUB v8.2s, v10.2s, v12.2s //x5_13 = vqsub_s32(a20_v,a30_v); + + SQADD v9.2s, v1.2s, v6.2s //x6_14 = vqadd_s32(a0_v,a1_v); + SQADD v11.2s, v5.2s, v2.2s //x3_11 = vqadd_s32(a3_v,a2_v); + SQSUB v10.2s, v1.2s, v6.2s //x2_10 = vqsub_s32(a0_v,a1_v); + SQSUB v13.2s, v5.2s, v2.2s //x7_15 = vqsub_s32(a3_v,a2_v); + + UZP1 v1.2s, v3.2s, v7.2s //x0_1 = vuzp1_s32(x0_8,x1_9); + UZP2 v5.2s, v3.2s, v7.2s //x8_9 = vuzp2_s32(x0_8,x1_9); + + UZP1 v6.2s, v4.2s, v8.2s //x4_5 = vuzp1_s32(x4_12,x5_13); + UZP2 v7.2s, v4.2s, v8.2s //x12_13 = vuzp2_s32(x4_12,x5_13); + REV64 v7.2s, v7.2s //x13_12 = vrev64_s32(x12_13); + + SQADD v3.2s, v1.2s, v5.2s //real_imag0 = vqadd_s32(x0_1,x8_9); + SQSUB v8.2s, v1.2s, v5.2s //a00_10_v = vqsub_s32(x0_1,x8_9); + + SQADD v12.2s, v6.2s, v7.2s //real_imag4 = vqadd_s32(x4_5,x13_12); + SQSUB v14.2s, v6.2s, v7.2s //a0_1_v = vqsub_s32(x4_5,x13_12); + + + MOV w4, v12.s[1] + MOV v12.s[1], v14.s[1] + MOV v14.s[1], w4 + + UZP1 v6.2s, v10.2s, v11.2s //x2_3 + + SQSUB v1.2s, v10.2s, v11.2s //tempr = vqsub_s32(x2_10,x3_11) + SQADD v5.2s, v10.2s, v11.2s //tempi = vqadd_s32(x2_10,x3_11) + + SMULL v7.2d, v1.2s, v0.2s + SMULL v10.2d, v5.2s, v0.2s + + SSHR v7.2d, v7.2d, #32 //tempr_q + SSHR v10.2d, v10.2d, #32 //tempi_q + + SHL v7.4s, v7.4s, #1 + SHL v10.4s, v10.4s, #1 + + + + MOV v1.s[0], v7.s[2] + MOV v1.s[1], v10.s[2] //vr_i + + SQSUB v7.2s, v6.2s, v1.2s //a2_3_v = vqsub_s32(x2_3,vr_i); + SQADD v4.2s, v6.2s, v1.2s //real_imag1 = vqadd_s32(x2_3,vr_i); + SQADD v5.2s, v14.2s, v7.2s //real_imag2 = vqadd_s32(a0_1_v,a2_3_v); + + UZP1 v1.2s, v9.2s, v13.2s //x6_7 + SQADD v6.2s, v9.2s, v13.2s //tempr = vqadd_s32(x6_14,x7_15); + SQSUB v14.2s, v9.2s, v13.2s //tempi = vqsub_s32(x6_14,x7_15); + + SMULL v9.2d, v6.2s, v0.2s + SMULL v13.2d, v14.2s, v0.2s + + SSHR v9.2d, v9.2d, #32 + SSHR v13.2d, v13.2d, #32 + + SHL v9.4s, v9.4s, #1 + SHL v13.4s, v13.4s, #1 + + + + MOV v0.s[0], v9.s[2] + MOV v0.s[1], v13.s[2] + + SQSUB v9.2s, v1.2s, v0.2s // a20_30_v + SQADD v13.2s, v1.2s, v0.2s //real_imag5 + + + MOV w4, v9.s[1] + MOV v9.s[1], v13.s[1] + MOV v13.s[1], w4 + + SQADD v6.2s, v9.2s, v8.2s //real_imag3 + + ST1 {v3.s}[0], [x1], #4 + ST1 {v4.s}[0], [x1], #4 + ST1 {v5.s}[0], [x1], #4 + ST1 {v6.s}[0], [x1], #4 + ST1 {v12.s}[0], [x1], #4 + ST1 {v13.s}[0], [x1], #4 + + ST1 {v3.s}[1], [x2], #4 + ST1 {v4.s}[1], [x2], #4 + ST1 {v5.s}[1], [x2], #4 + ST1 {v6.s}[1], [x2], #4 + ST1 {v12.s}[1], [x2], #4 + ST1 {v13.s}[1], [x2], #4 + //ST4 {v3.s,v4.s,v5.s,v6.s}[0],[x1],x5 + //ST4 {v3.s,v4.s,v5.s,v6.s}[1],[x2],x5 + //ST2 {v12.s,v13.s}[0],[x1] + //ST2 {v12.s,v13.s}[1],[x2] + pop_v_regs + ret + + + + + + + diff --git a/decoder/armv8/ixheaacd_no_lap1.s b/decoder/armv8/ixheaacd_no_lap1.s new file mode 100644 index 0000000..d339879 --- /dev/null +++ b/decoder/armv8/ixheaacd_no_lap1.s @@ -0,0 +1,123 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm +.text +.global ixheaacd_neg_shift_spec_armv8 +ixheaacd_neg_shift_spec_armv8: + push_v_regs + MOV X5, #448 + SUB X6, X5, #1 + LSL X6, X6, #2 + ADD X6, X6, X0 + MOV X8, #-16 + SUB X6, X6, #12 + LSL X7, X3, #1 + DUP V31.4S, W2 + MOV W4, #0x8000 + DUP V30.4S, W4 + + LD1 {V0.4S}, [X6], X8 + SQNEG V0.4S, V0.4S + + LD1 {V6.4S}, [X6], X8 + SQSHL V25.4S, V0.4S, V31.4S + SQADD V24.4S, V25.4S, V30.4S + SSHR V23.4S, V24.4S, #16 + REV64 V23.4S, V23.4S + SUB X5, X5, #8 + + UZP1 V27.8H, V23.8H, V23.8H + SQNEG V29.4S, V6.4S + +LOOP_1: + + ST1 {V27.H}[2], [X1], X7 + SQSHL V22.4S, V29.4S, V31.4S + LD1 {V0.4S}, [X6], X8 + ST1 {V27.H}[3], [X1], X7 + SQADD V21.4S, V22.4S, V30.4S + ST1 {V27.H}[0], [X1], X7 + SQNEG V0.4S, V0.4S + ST1 {V27.H}[1], [X1], X7 + SSHR V20.4S, V21.4S, #16 + REV64 V20.4S, V20.4S + SUBS X5, X5, #8 + + + UZP1 V27.8H, V20.8H, V20.8H + SQSHL V25.4S, V0.4S, V31.4S + ST1 {V27.H}[2], [X1], X7 + LD1 {V6.4S}, [X6], X8 + SQADD V24.4S, V25.4S, V30.4S + ST1 {V27.H}[3], [X1], X7 + SSHR V23.4S, V24.4S, #16 + ST1 {V27.H}[0], [X1], X7 + REV64 V23.4S, V23.4S + ST1 {V27.H}[1], [X1], X7 + + + UZP1 V27.8H, V23.8H, V23.8H + SQNEG V29.4S, V6.4S + + BGT LOOP_1 + + ST1 {V27.H}[2], [X1], X7 + SQSHL V22.4S, V29.4S, V31.4S + ST1 {V27.H}[3], [X1], X7 + ST1 {V27.H}[0], [X1], X7 + SQADD V21.4S, V22.4S, V30.4S + ST1 {V27.H}[1], [X1], X7 + SSHR V20.4S, V21.4S, #16 + + REV64 V20.4S, V20.4S + + UZP1 V27.8H, V20.8H, V20.8H + + ST1 {V27.H}[2], [X1], X7 + ST1 {V27.H}[3], [X1], X7 + ST1 {V27.H}[0], [X1], X7 + ST1 {V27.H}[1], [X1], X7 + pop_v_regs + RET diff --git a/decoder/armv8/ixheaacd_overlap_add1.s b/decoder/armv8/ixheaacd_overlap_add1.s new file mode 100644 index 0000000..14f5402 --- /dev/null +++ b/decoder/armv8/ixheaacd_overlap_add1.s @@ -0,0 +1,333 @@ +///****************************************************************************** +// * +// * 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 +//*/ + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.text +.global ixheaacd_over_lap_add1_armv8 +ixheaacd_over_lap_add1_armv8: + push_v_regs + LSL X10, X5, #1 + SUB X11, X10, #1 + LSL X10, X11, #2 + ADD X10, X0, X10 + SUB X10, X10, #12 + LSL X8, X11, #1 + ADD X8, X8, X3 + SUB X8, X8, #14 + MOV X12, #-16 + DUP V11.8H, W4 + LD1 {V3.4S}, [X10], X12 + MOV W7, #0x2000 + + NEG W7, W7 + SQNEG V0.4S, V3.4S + DUP V10.4S, W7 + UZP1 V31.8H, V0.8H, V0.8H + UZP2 V30.8H, V0.8H, V0.8H + REV64 V31.8h, V31.8h + REV64 V30.8h, V30.8h + SUB X11, X5, #1 + UZP1 V7.8H, V3.8H, V3.8H + UZP2 V6.8H, V3.8H, V3.8H + REV64 V7.8H, V7.8H + REV64 V6.8H, V6.8H + MOV V16.S[0], W6 + MOV V17.S[0], W11 + SMULL V17.4S, V16.4H, V17.4H + MOV W11, V17.S[0] + LSL X11, X11, #1 + + LD2 {V2.4H, V3.4H}, [X8], X12 + ADD X11, X11, X2 + REV64 V2.4H, V2.4H + REV64 V3.4H, V3.4H + LSL X4, X6, #1 + NEG X4, X4 + LSL X9, X6, #1 + MOV V16.S[0], W5 + MOV V17.S[0], W6 + SMULL V17.4S, V16.4H, V17.4H + MOV W6, V17.S[0] + LSL W6, W6, #1 + ADD X6, X6, X2 + + UMULL V15.4S, V7.4H, V2.4H + LD1 {V4.4S}, [X1], #16 + USHR V15.4S, V15.4S, #16 + + SMLAL V15.4S, V6.4H, V2.4H + SQSHL V15.4S, V15.4S, V11.4S + SSHLL V27.4S, V3.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V14.16B, V28.16B + + SQADD V14.4S, V14.4S, V10.4S + SQSUB V13.4S, V15.4S, V14.4S + SQSHL V13.4S, V13.4S, #2 + SSHR V13.4S, V13.4S, #16 + UZP1 V26.8H, V13.8H, V13.8H + + UMULL V12.4S, V31.4H, V3.4H + USHR V12.4S, V12.4S, #16 + SMLAL V12.4S, V30.4H, V3.4H + SQSHL V12.4S, V12.4S, V11.4S + LD1 {V3.4S}, [X10], X12 + + SSHLL V27.4S, V2.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V8.16B, V28.16B + + SQADD V8.4S, V8.4S, V10.4S + + SQNEG V0.4S, V3.4S + UZP1 V1.8H, V0.8H, V0.8H + UZP2 V0.8H, V0.8H, V0.8H + REV64 V1.8h, V1.8h + REV64 V0.8h, V0.8h + SQSUB V9.4S, V12.4S, V8.4S + UZP1 V7.8H, V3.8H, V3.8H + UZP2 V6.8H, V3.8H, V3.8H + REV64 V7.8h, V7.8h + REV64 V6.8h, V6.8h + SQSHL V9.4S, V9.4S, #2 + LD2 {V2.4H, V3.4H}, [X8], X12 + SSHR V9.4S, V9.4S, #16 + REV64 V2.4H, V2.4H + REV64 V3.4H, V3.4H + UZP1 V18.8H, V9.8H, V9.8H + + LD1 {V4.4S}, [X1], #16 + SUB W5, W5, #8 + + +LOOP_1: + + ST1 {V26.H}[0], [X11], X4 + UMULL V15.4S, V7.4H, V2.4H + ST1 {V26.H}[1], [X11], X4 + UMULL V12.4S, V1.4H, V3.4H + ST1 {V26.H}[2], [X11], X4 + USHR V15.4S, V15.4S, #16 + ST1 {V26.H}[3], [X11], X4 + USHR V12.4S, V12.4S, #16 + ST1 {V18.H}[0], [X6], X9 + SMLAL V15.4S, V6.4H, V2.4H + ST1 {V18.H}[1], [X6], X9 + SMLAL V12.4S, V0.4H, V3.4H + ST1 {V18.H}[2], [X6], X9 + SQSHL V15.4S, V15.4S, V11.4S + ST1 {V18.H}[3], [X6], X9 + SQSHL V12.4S, V12.4S, V11.4S + LD1 {V6.4S}, [X10], X12 + + SSHLL V27.4S, V3.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V14.16B, V28.16B + + SSHLL V27.4S, V2.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V8.16B, V28.16B + + LD2 {V2.4H, V3.4H}, [X8], X12 + + SQNEG V0.4S, V6.4S + + LD1 {V4.4S}, [X1], #16 + + SQADD V14.4S, V14.4S, V10.4S + UZP1 V1.8H, V0.8H, V0.8H + UZP2 V0.8H, V0.8H, V0.8H + REV64 V1.8h, V1.8h + REV64 V0.8h, V0.8h + SQADD V8.4S, V8.4S, V10.4S + UZP1 V7.8H, V6.8H, V6.8H + UZP2 V6.8H, V6.8H, V6.8H + REV64 V7.8h, V7.8h + REV64 V6.8h, V6.8h + SQSUB V13.4S, V15.4S, V14.4S + REV64 V2.4H, V2.4H + REV64 V3.4H, V3.4H + SQSUB V9.4S, V12.4S, V8.4S + SQSHL V13.4S, V13.4S, #2 + SQSHL V9.4S, V9.4S, #2 + UMULL V15.4S, V7.4H, V2.4H + SSHR V13.4S, V13.4S, #16 + UZP1 V26.8H, V13.8H, V13.8H + SSHR V9.4S, V9.4S, #16 + ST1 {V26.H}[0], [X11], X4 + UMULL V12.4S, V1.4H, V3.4H + UZP1 V18.8H, V9.8H, V9.8H + USHR V15.4S, V15.4S, #16 + ST1 {V26.H}[1], [X11], X4 + SMLAL V15.4S, V6.4H, V2.4H + ST1 {V26.H}[2], [X11], X4 + USHR V12.4S, V12.4S, #16 + ST1 {V26.H}[3], [X11], X4 + SMLAL V12.4S, V0.4H, V3.4H + ST1 {V18.H}[0], [X6], X9 + SQSHL V15.4S, V15.4S, V11.4S + ST1 {V18.H}[1], [X6], X9 + SQSHL V12.4S, V12.4S, V11.4S + ST1 {V18.H}[2], [X6], X9 + + SSHLL V27.4S, V3.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V14.16B, V28.16B + + ST1 {V18.H}[3], [X6], X9 + + + SSHLL V27.4S, V2.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V8.16B, V28.16B + + LD1 {V3.4S}, [X10], X12 + SQADD V14.4S, V14.4S, V10.4S + + SQNEG V0.4S, V3.4S + UZP1 V1.8H, V0.8H, V0.8H + UZP2 V0.8H, V0.8H, V0.8H + REV64 V1.8H, V1.8H + REV64 V0.8H, V0.8H + SQSUB V13.4S, V15.4S, V14.4S + UZP1 V7.8H, V3.8H, V3.8H + UZP2 V6.8H, V3.8H, V3.8H + REV64 V7.8H, V7.8H + REV64 V6.8H, V6.8H + SQADD V8.4S, V8.4S, V10.4S + LD2 {V2.4H, V3.4H}, [X8], X12 + SQSUB V9.4S, V12.4S, V8.4S + REV64 V2.4H, V2.4H + REV64 V3.4H, V3.4H + SQSHL V13.4S, V13.4S, #2 + LD1 {V4.4S}, [X1], #16 + + SQSHL V9.4S, V9.4S, #2 + SSHR V13.4S, V13.4S, #16 + SUBS X5, X5, #8 + SSHR V9.4S, V9.4S, #16 + UZP1 V26.8H, V13.8H, V13.8H + UZP1 V18.8H, V9.8H, V9.8H + + BGT LOOP_1 + + ST1 {V26.H}[0], [X11], X4 + UMULL V15.4S, V7.4H, V2.4H + ST1 {V26.H}[1], [X11], X4 + UMULL V12.4s, V1.4H, V3.4H + ST1 {V26.H}[2], [X11], X4 + USHR V15.4S, V15.4S, #16 + ST1 {V26.H}[3], [X11], X4 + USHR V12.4S, V12.4S, #16 + + ST1 {V18.H}[0], [X6], X9 + SMLAL V15.4S, V6.4H, V2.4H + ST1 {V18.H}[1], [X6], X9 + SMLAL V12.4S, V0.4H, V3.4H + ST1 {V18.H}[2], [X6], X9 + SQSHL V15.4S, V15.4S, V11.4S + ST1 {V18.H}[3], [X6], X9 + SQSHL V12.4S, V12.4S, V11.4S + + + SSHLL V27.4S, V3.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V14.16B, V28.16B + + SSHLL V27.4S, V2.4H, #0 + SMULL V28.2D, V27.2S, V4.2S + SMULL2 V29.2D, V27.4S, V4.4S + SQXTN V28.2S, V28.2D + SQXTN2 V28.4S, V29.2D + MOV V8.16B, V28.16B + + SQADD V14.4S, V14.4S, V10.4S + SQADD V8.4S, V8.4S, V10.4S + SQSUB V13.4S, V15.4S, V14.4S + SQSUB V9.4S, V12.4S, V8.4S + SQSHL V13.4S, V13.4S, #2 + SQSHL V9.4S, V9.4S, #2 + SSHR V13.4S, V13.4S, #16 + SSHR V9.4S, V9.4S, #16 + UZP1 V26.8H, V13.8H, V13.8H + + UZP1 V18.8H, V9.8H, V9.8H + + + ST1 {V26.H}[0], [X11], X4 + ST1 {V26.H}[1], [X11], X4 + ST1 {V26.H}[2], [X11], X4 + ST1 {V26.H}[3], [X11], X4 + + ST1 {V18.H}[0], [X6], X9 + ST1 {V18.H}[1], [X6], X9 + ST1 {V18.H}[2], [X6], X9 + ST1 {V18.H}[3], [X6], X9 + pop_v_regs + RET + + + + diff --git a/decoder/armv8/ixheaacd_overlap_add2.s b/decoder/armv8/ixheaacd_overlap_add2.s new file mode 100644 index 0000000..db365e7 --- /dev/null +++ b/decoder/armv8/ixheaacd_overlap_add2.s @@ -0,0 +1,305 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm +.text +.global ixheaacd_over_lap_add2_armv8 + + +ixheaacd_over_lap_add2_armv8: + push_v_regs + MOV X8, X5 + SUB X12, X5, #1 + LSL X9, X5, #2 + LSL X12, X12, #2 + ADD X10, X0, X9 + ADD X7, X1, X12 + ADD X4, X4, #1 + LD2 {V0.4H, V1.4H}, [X10], #16 + LSL X11, X6, #2 + SUB X7, X7, #12 + SUB X4, X4, #16 + MOV X12, #-16 + MOV X13, #1 + ADD X14, X4, #1 + NEG X14, X14 + DUP V21.4S, W4 + LD2 {V6.4H, V7.4H}, [X7], X12 + LSL X4, X13, X14 + REV64 V4.4H, V6.4H + DUP V20.4S, W4 + REV64 V5.4H, V7.4H + MOV X4, X3 + + MOV X9, X2 + LD2 {V2.4H, V3.4H}, [X3], #16 + + UMULL V23.4S, V0.4H, V2.4H + UMLSL V23.4S, V4.4H, V3.4H + LD2 {V8.4H, V9.4H}, [X10], #16 + SSHR V23.4S, V23.4S, #16 + LD2 {V10.4H, V11.4H}, [X3], #16 + SMLAL V23.4S, V1.4H, V2.4H + SMLSL V23.4S, V5.4H, V3.4H + LD2 {V14.4H, V15.4H}, [X7], X12 + REV64 V12.4H, V14.4H + REV64 V13.4H, V15.4H + SQADD V22.4S, V23.4S, V20.4S + SSHL V22.4S, V22.4S, V21.4S + MOV V24.16B, V22.16B + SUB X8, X8, #8 + +LOOP_1: + + LD2 {V0.4H, V1.4H}, [X10], #16 + UMULL V19.4S, V8.4H, V10.4H + LD2 {V2.4H, V3.4H}, [X3], #16 + UMLSL V19.4S, V12.4H, V11.4H + LD2 {V6.4H, V7.4H}, [X7], X12 + UMULL V23.4S, V0.4H, V2.4H + REV64 V4.4H, V6.4H + UMLSL V23.4S, V4.4H, V3.4H + REV64 V5.4H, V7.4H + SSHR V19.4S, V19.4S, #16 + ST1 {V24.S}[0], [X2], X11 + SMLAL V19.4S, V9.4H, V10.4H + ST1 {V24.S}[1], [X2], X11 + SSHR V23.4S, V23.4S, #16 + ST1 {V24.S}[2], [X2], X11 + SMLAL V23.4S, V1.4H, V2.4H + + ST1 {V24.S}[3], [X2], X11 + SMLSL V19.4S, V13.4H, V11.4H + SMLSL V23.4S, V5.4H, V3.4H + + LD2 {V8.4H, V9.4H}, [X10], #16 + LD2 {V10.4H, V11.4H}, [X3], #16 + + + LD2 {V14.4H, V15.4H}, [X7], X12 + SQADD V18.4S, V19.4S, V20.4S + REV64 V12.4H, V14.4H + REV64 V13.4H, V15.4H + SQADD V22.4S, V23.4S, V20.4S + SSHL V18.4S, V18.4S, V21.4S + MOV V16.16B, V18.16B + ST1 {V16.S}[0], [X2], X11 + SSHL V22.4S, V22.4S, V21.4S + + + MOV V24.16B, V22.16B + SUBS X8, X8, #8 + + ST1 {V16.S}[1], [X2], X11 + ST1 {V16.S}[2], [X2], X11 + ST1 {V16.S}[3], [X2], X11 + + + BGT LOOP_1 + + + ST1 {V24.S}[0], [X2], X11 + UMULL V19.4S, V8.4H, V10.4H + UMLSL V19.4S, V12.4H, V11.4H + ST1 {V24.S}[1], [X2], X11 + ST1 {V24.S}[2], [X2], X11 + SSHR V19.4S, V19.4S, #16 + ST1 {V24.S}[3], [X2], X11 + SMLAL V19.4S, V9.4H, V10.4H + SMLSL V19.4S, V13.4H, V11.4H + MOV X12, #12 + MOV V30.S[0], W5 + MOV V31.S[0], W6 + SMULL V29.4S, V30.4H, V31.4H + MOV W7, V29.S[0] + + LSL W10, W5, #1 + SQADD V18.4S, V19.4S, V20.4S + SSHL V18.4S, V18.4S, V21.4S + MOV V16.16B, V18.16B + + ST1 {V16.S}[0], [X2], X11 + LSL X7, X7, #2 + + ST1 {V16.S}[1], [X2], X11 + ADD X7, X7, X9 + + ST1 {V16.S}[2], [X2], X11 + ST1 {V16.S}[3], [X2], X11 + + SUB X11, X10, #1 + LSL X10, X11, #2 + ADD X10, X0, X10 + LSL X11, X11, #1 + SUB X10, X10, X12 + LSL X8, X6, #2 + MOV X12, #-16 + ADD X11, X11, X4 + + LD1 {V6.4S}, [X10], X12 + SUB X11, X11, #14 + + + REV64 V0.4S, V6.4S + SQNEG V0.4S, V0.4S + + + UZP1 V1.8H, V0.8H, V0.8H + UZP2 V0.8H, V0.8H, V0.8H + REV64 V1.4S, V1.4S + REV64 V0.4S, V0.4S + LD2 {V2.4H, V3.4H}, [X11], X12 + REV64 V2.4H, V2.4H + REV64 V3.4H, V3.4H + + LD2 {V4.4H, V5.4H}, [X1], #16 + + UMULL V23.4S, V1.4H, V3.4H + UMLSL V23.4S, V4.4H, V2.4H + SSHR V23.4S, V23.4S, #16 + SMLAL V23.4S, V0.4H, V3.4H + SMLSL V23.4S, V5.4H, V2.4H + SQADD V22.4S, V23.4S, V20.4S + SSHL V22.4S, V22.4S, V21.4S + MOV V24.16B, V22.16B + + + LD1 {V14.4S}, [X10], X12 + UMULL V23.4S, V1.4H, V3.4H + UMLSL V23.4S, V4.4H, V2.4H + REV64 V8.4S, V14.4S + SQNEG V8.4S, V8.4S + LD2 {V10.4H, V11.4H}, [X11], X12 + SSHR V23.4S, V23.4S, #16 + LD2 {V12.4H, V13.4H}, [X1], #16 + SMLAL V23.4S, V0.4H, V3.4H + SMLSL V23.4S, V5.4H, V2.4H + UZP1 V9.8H, V8.8H, V8.8H + UZP2 V8.8H, V8.8H, V8.8H + rev64 v9.4s, v9.4s + rev64 v8.4s, v8.4s + REV64 V10.4H, V10.4H + REV64 V11.4H, V11.4H + SQADD V22.4S, V23.4S, V20.4S + SUB X5, X5, #8 + SSHL V22.4S, V22.4S, V21.4S + MOV V24.16B, V22.16B + + +LOOP_2: + + + LD1 {V6.4S}, [X10], X12 + UMULL V19.4S, V9.4H, V11.4H + REV64 V0.4S, V6.4S + SQNEG V0.4S, V0.4S + UZP1 V1.8H, V0.8H, V0.8H + UZP2 V0.8H, V0.8H, V0.8H + REV64 V1.4S, V1.4S + REV64 V0.4S, V0.4S + LD2 {V2.4H, V3.4H}, [X11], X12 + REV64 V2.8H, V2.8H + REV64 V3.8H, V3.8H + + LD2 {V4.4H, V5.4H}, [X1], #16 + UMLSL V19.4S, V12.4H, V10.4H + ST1 {V24.S}[0], [X7], X8 + UMULL V23.4S, V1.4H, V3.4H + ST1 {V24.S}[1], [X7], X8 + SSHR V19.4S, V19.4S, #16 + ST1 {V24.S}[2], [X7], X8 + UMLSL V23.4S, V4.4H, V2.4H + ST1 {V24.S}[3], [X7], X8 + SMLAL V19.4S, V8.4H, V11.4H + LD1 {V14.4S}, [X10], X12 + SSHR V23.4S, V23.4S, #16 + SMLSL V19.4S, V13.4H, V10.4H + LD2 {V10.4H, V11.4H}, [X11], X12 + SMLAL V23.4S, V0.4H, V3.4H + SMLSL V23.4S, V5.4H, V2.4H + REV64 V8.4S, V14.4S + LD2 {V12.4H, V13.4H}, [X1], #16 + SQNEG V8.4S, V8.4S + REV64 V11.4H, V11.4h + REV64 V10.4H, V10.4H + SQADD V18.4S, V19.4S, V20.4S + UZP1 V9.8H, V8.8H, V8.8H + UZP2 V8.8H, V8.8H, V8.8H + rev64 v9.4s, v9.4s + rev64 v8.4s, v8.4s + SQADD V22.4S, V23.4S, V20.4S + SSHL V18.4S, V18.4S, V21.4S + SUBS X5, X5, #8 + MOV V16.16B, V18.16B + ST1 {V16.S}[0], [X7], X8 + SSHL V22.4S, V22.4S, V21.4S + ST1 {V16.S}[1], [X7], X8 + MOV V24.16B, V22.16B + + ST1 {V16.S}[2], [X7], X8 + ST1 {V16.S}[3], [X7], X8 + + BGT LOOP_2 + + ST1 {V24.S}[0], [X7], X8 + UMULL V19.4S, V9.4H, V11.4H + UMLSL V19.4S, V12.4H, V10.4H + ST1 {V24.S}[1], [X7], X8 + ST1 {V24.S}[2], [X7], X8 + SSHR V19.4S, V19.4S, #16 + ST1 {V24.S}[3], [X7], X8 + + SMLAL V19.4S, V8.4H, V11.4H + SMLSL V19.4S, V13.4H, V10.4H + SQADD V18.4S, V19.4S, V20.4S + SSHL V18.4S, V18.4S, V21.4S + MOV V16.16B, V18.16B + + ST1 {V16.S}[0], [X7], X8 + ST1 {V16.S}[1], [X7], X8 + ST1 {V16.S}[2], [X7], X8 + ST1 {V16.S}[3], [X7], X8 + + pop_v_regs + RET diff --git a/decoder/armv8/ixheaacd_post_twiddle.s b/decoder/armv8/ixheaacd_post_twiddle.s new file mode 100644 index 0000000..2e7f6d4 --- /dev/null +++ b/decoder/armv8/ixheaacd_post_twiddle.s @@ -0,0 +1,713 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp x21, x22, [sp, #-16]! + stp x23, x24, [sp, #-16]! +.endm +.macro pop_v_regs + ldp x23, x24, [sp], #16 + ldp x21, x22, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm +.macro swp reg1, reg2 + MOV X16, \reg1 + MOV \reg1, \reg2 + MOV \reg2, x16 +.endm +.text +.global ixheaacd_post_twiddle_armv8 +ixheaacd_post_twiddle_armv8: + + + push_v_regs + +ARM_PROLOGUE: + CMP w3, #0x400 + LDR x21, =7500 + ADD x2, x2, x21 + BLT NEXT + MOV w4, #50 + MOV w5, #-50 + MOV x6, #4 + dup v10.4h, w4 + B NEXT1 + +NEXT: + MOV w4, #0x192 + MOV w5, #0xfe6e + MOV x6, #32 + dup v10.4h, w4 + +NEXT1: + LDR w9, [x2] + LSL W22, W9, #16 + AND W21, W9, #0xFFFF0000 + + LDR w7, [x1], #4 + LDR w8, [x1], #4 + + ADD x2, x2, x6 + + + SMULL X11, w8, w21 + ASR X11, x11, #32 + SMULL X10, w8, w22 + ASR X10, x10, #32 + SMULL X12, w7, w21 + ASR X12, x12, #32 + SMULL X23, w7, w22 + ASR X23, x23, #32 + ADD w8, w11, w23 + + + SUB w10, w10, w12 + + MVN w8, w8 + ADD w8, w8, #1 + + + + LSL w21, w5, #16 + LSL w22, w4, #16 + SMULL X23, w10, w21 + ASR X23, x23, #32 + ADD w9, w8, w23 + SMULL X23, w8, w22 + ASR X23, x23, #32 + ADD w11, w10, w23 + + LSL x7, x3, #2 + ADD x7, x0, x7 + SUB x7, x7, #4 + + STR w11, [x7], #-4 + + STR w9, [x0], #4 + + LSL x5, x3, #2 + ADD x5, x1, x5 + SUB x5, x5, #40 + + + SUB w3, w3, #1 + ASR w3, w3, #4 + + + SUB x7, x7, #28 + + + + + + + + + + + + + MOV x8, #-32 + +NEON_PROLOGUE: + + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x5], x8 + + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], #32 + LD2 {v8.h, v9.h}[0], [x2], x6 + LD2 {v8.h, v9.h}[1], [x2], x6 + LD2 {v8.h, v9.h}[2], [x2], x6 + LD2 {v8.h, v9.h}[3], [x2], x6 + + rev64 v12.4h, v8.4h + rev64 v13.4h, v9.4h + + uMULL v30.4s, v2.4h, v13.4h + uMULL v28.4s, v0.4h, v13.4h + uMULL v26.4s, v2.4h, v12.4h + uMULL v24.4s, v0.4h, v12.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v13.4h + sMLAL v28.4s, v1.4h, v13.4h + sMLAL v26.4s, v3.4h, v12.4h + sMLAL v24.4s, v1.4h, v12.4h + + uMULL v22.4s, v6.4h, v9.4h + uMULL v20.4s, v4.4h, v9.4h + + ADD v28.4s, v28.4s , v26.4s + SUB v30.4s, v30.4s , v24.4s + NEG v28.4s, v28.4s + + uMULL v18.4s, v6.4h, v8.4h + uMULL v16.4s, v4.4h, v8.4h + + mov v31.8b, v30.8b + mov v27.D[0], v30.D[1] + ushR v22.4s, v22.4s, #16 + + mov v24.8b, v28.8b + mov v25.D[0], v28.D[1] + ushR v20.4s, v20.4s, #16 + + + UZP1 v26.4h, v31.4h, v27.4h + UZP2 v27.4h, v31.4h, v27.4h + ushR v18.4s, v18.4s, #16 + + + mov v31.8B , v24.8B + UZP1 v24.4h, v31.4h, v25.4h + UZP2 v25.4h, v31.4h, v25.4h + ushR v16.4s, v16.4s, #16 + + + sMLAL v22.4s, v7.4h, v9.4h + sMLAL v20.4s, v5.4h, v9.4h + sMLAL v18.4s, v7.4h, v8.4h + sMLAL v16.4s, v5.4h, v8.4h + + LD2 {v8.h, v9.h}[0], [x2], x6 + uMULL v0.4s, v26.4h, v10.4h + + LD2 {v8.h, v9.h}[1], [x2], x6 + uMULL v2.4s, v24.4h, v10.4h + + + LD2 {v8.h, v9.h}[2], [x2], x6 + ADD v22.4s, v22.4s , v16.4s + + LD2 {v8.h, v9.h}[3], [x2], x6 + SUB v20.4s, v18.4s , v20.4s + + rev64 v12.4h, v8.4h + rev64 v13.4h, v9.4h + NEG v22.4s, v22.4s + + + mov v18.8b, v22.8b + mov v19.D[0], v22.D[1] + ushR v0.4s, v0.4s, #16 + + mov v16.16b, v20.16b + mov v17.D[0], v20.D[1] + ushR v2.4s, v2.4s, #16 + + + MOV v31.8b, v18.8b + UZP1 v18.4h, v31.4h, v19.4h + UZP2 v19.4h, v31.4h, v19.4h + sMLAL v0.4s, v27.4h, v10.4h + + + MOV v31.8b, v16.8b + UZP1 v16.4h, v31.4h, v17.4h + UZP2 v17.4h, v31.4h, v17.4h + sMLAL v2.4s, v25.4h, v10.4h + + uMULL v4.4s, v18.4h, v10.4h + uMULL v6.4s, v16.4h, v10.4h + + NEG v0.4s, v0.4s + ADD v14.4s, v30.4s , v2.4s + ADD v26.4s, v28.4s , v0.4s + + rev64 v14.4s, v14.4s + ushR v4.4s, v4.4s, #16 + + swp v14.D[0], v14.D[1] + ushR v6.4s, v6.4s, #16 + + sMLAL v4.4s, v19.4h, v10.4h + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x5], x8 + sMLAL v6.4s, v17.4h, v10.4h + + + SUB x3, x3, #2 + + ADD v24.4s, v20.4s , v4.4s + + rev64 v24.4s, v24.4s + NEG v16.4s, v6.4s + + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], #32 + + swp v24.D[0], v24.D[1] + ADD v16.4s, v22.4s , v16.4s + + + +CORE_LOOP: + uMULL v30.4s, v2.4h, v13.4h + MOV v25.16B, v24.16B + ST2 { v25.4s, v26.4s}, [x7], x8 + uMULL v28.4s, v0.4h, v13.4h + + uMULL v26.4s, v2.4h, v12.4h + MOV v15.16B, v14.16B + ST2 { v15.4s, v16.4s}, [x0], #32 + uMULL v24.4s, v0.4h, v12.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v13.4h + sMLAL v28.4s, v1.4h, v13.4h + sMLAL v26.4s, v3.4h, v12.4h + sMLAL v24.4s, v1.4h, v12.4h + + uMULL v22.4s, v6.4h, v9.4h + uMULL v20.4s, v4.4h, v9.4h + + + ADD v28.4s, v28.4s , v26.4s + SUB v30.4s, v30.4s , v24.4s + NEG v28.4s, v28.4s + + uMULL v18.4s, v6.4h, v8.4h + uMULL v16.4s, v4.4h, v8.4h + + + mov v26.8b, v30.8b + mov v27.D[0], v30.D[1] + ushR v22.4s, v22.4s, #16 + + + mov v24.8b, v28.8b + mov v25.D[0], v28.D[1] + ushR v20.4s, v20.4s, #16 + + + MOV v31.8b, v26.8b + UZP1 v26.4h, v31.4h, v27.4h + UZP2 v27.4h, v31.4h, v27.4h + ushR v18.4s, v18.4s, #16 + + + MOV v31.8b, v24.8b + UZP1 v24.4h, v31.4h, v25.4h + UZP2 v25.4h, v31.4h, v25.4h + ushR v16.4s, v16.4s, #16 + + + sMLAL v22.4s, v7.4h, v9.4h + sMLAL v20.4s, v5.4h, v9.4h + sMLAL v18.4s, v7.4h, v8.4h + sMLAL v16.4s, v5.4h, v8.4h + + LD2 {v8.h, v9.h}[0], [x2], x6 + uMULL v0.4s, v26.4h, v10.4h + + LD2 {v8.h, v9.h}[1], [x2], x6 + uMULL v2.4s, v24.4h, v10.4h + + LD2 {v8.h, v9.h}[2], [x2], x6 + ADD v22.4s, v22.4s , v16.4s + + LD2 {v8.h, v9.h}[3], [x2], x6 + SUB v20.4s, v18.4s , v20.4s + + rev64 v12.4h, v8.4h + rev64 v13.4h, v9.4h + NEG v22.4s, v22.4s + + mov v18.8b, v22.8b + mov v19.D[0], v22.D[1] + ushR v0.4s, v0.4s, #16 + + mov v16.8b, v20.8b + mov v17.D[0], v20.D[1] + ushR v2.4s, v2.4s, #16 + + + MOV v31.8b, v18.8b + UZP1 v18.4h, v31.4h, v19.4h + UZP2 v19.4h, v31.4h, v19.4h + sMLAL v0.4s, v27.4h, v10.4h + + + MOV v31.8b, v16.8b + UZP1 v16.4h, v31.4h, v17.4h + UZP2 v17.4h, v31.4h, v17.4h + sMLAL v2.4s, v25.4h, v10.4h + + uMULL v4.4s, v18.4h, v10.4h + uMULL v6.4s, v16.4h, v10.4h + + NEG v0.4s, v0.4s + ADD v14.4s, v30.4s , v2.4s + ADD v26.4s, v28.4s , v0.4s + + rev64 v14.4s, v14.4s + ushR v4.4s, v4.4s, #16 + + swp v14.D[0], v14.D[1] + ushR v6.4s, v6.4s, #16 + + sMLAL v4.4s, v19.4h, v10.4h + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x5], x8 + sMLAL v6.4s, v17.4h, v10.4h + + + + + + ADD v24.4s, v20.4s , v4.4s + + rev64 v24.4s, v24.4s + NEG v16.4s, v6.4s + + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], #32 + + swp v24.D[0], v24.D[1] + ADD v16.4s, v22.4s , v16.4s + + SUBS x3, x3, #1 + + BNE CORE_LOOP + + + + +NEON_EPILOGUE: + uMULL v30.4s, v2.4h, v13.4h + MOV v25.16B, v24.16B + ST2 { v25.4s, v26.4s}, [x7], x8 + uMULL v28.4s, v0.4h, v13.4h + + uMULL v26.4s, v2.4h, v12.4h + MOV v15.16B, v14.16B + ST2 { v15.4s, v16.4s}, [x0], #32 + uMULL v24.4s, v0.4h, v12.4h + + + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v13.4h + sMLAL v28.4s, v1.4h, v13.4h + sMLAL v26.4s, v3.4h, v12.4h + sMLAL v24.4s, v1.4h, v12.4h + + + uMULL v22.4s, v6.4h, v9.4h + uMULL v20.4s, v4.4h, v9.4h + + + ADD v28.4s, v28.4s , v26.4s + SUB v30.4s, v30.4s , v24.4s + NEG v28.4s, v28.4s + + uMULL v18.4s, v6.4h, v8.4h + uMULL v16.4s, v4.4h, v8.4h + + + mov v26.8b, v30.8b + mov v27.D[0], v30.D[1] + ushR v22.4s, v22.4s, #16 + + mov v24.16b, v28.16b + mov v25.D[0], v28.D[1] + ushR v20.4s, v20.4s, #16 + + + mov v31.8b, v26.8b + UZP1 v26.4h, v31.4h, v27.4h + UZP2 v27.4h, v31.4h, v27.4h + ushR v18.4s, v18.4s, #16 + + + mov v31.8b, v24.8b + UZP1 v24.4h, v31.4h, v25.4h + UZP2 v25.4h, v31.4h, v25.4h + ushR v16.4s, v16.4s, #16 + + + sMLAL v22.4s, v7.4h, v9.4h + sMLAL v20.4s, v5.4h, v9.4h + sMLAL v18.4s, v7.4h, v8.4h + sMLAL v16.4s, v5.4h, v8.4h + + + uMULL v0.4s, v26.4h, v10.4h + + + uMULL v2.4s, v24.4h, v10.4h + + + ADD v22.4s, v22.4s , v16.4s + + + SUB v20.4s, v18.4s , v20.4s + + + NEG v22.4s, v22.4s + + + mov v18.16b, v22.16b + ushR v0.4s, v0.4s, #16 + + mov v16.16b, v20.16b + ushR v2.4s, v2.4s, #16 + + + mov v31.16b, v18.16b + mov v19.d[0], v31.d[1] + UZP1 v18.4h, v31.4h, v19.4h + UZP2 v19.4h, v31.4h, v19.4h + sMLAL v0.4s, v27.4h, v10.4h + + + mov v31.16b, v16.16b + mov v17.d[0], v31.d[1] + UZP1 v16.4h, v31.4h, v17.4h + UZP2 v17.4h, v31.4h, v17.4h + sMLAL v2.4s, v25.4h, v10.4h + + uMULL v4.4s, v18.4h, v10.4h + uMULL v6.4s, v16.4h, v10.4h + + NEG v0.4s, v0.4s + ADD v14.4s, v30.4s , v2.4s + ADD v26.4s, v28.4s , v0.4s + + rev64 v14.4s, v14.4s + ushR v4.4s, v4.4s, #16 + + swp v14.D[0], v14.D[1] + ushR v6.4s, v6.4s, #16 + + sMLAL v4.4s, v19.4h, v10.4h + + sMLAL v6.4s, v17.4h, v10.4h + + + + + ADD v24.4s, v20.4s , v4.4s + + rev64 v24.4s, v24.4s + NEG v16.4s, v6.4s + + + + swp v24.D[0], v24.D[1] + ADD v16.4s, v22.4s , v16.4s + + MOV v25.16B, v24.16B + MOV v15.16B, v14.16B + ST2 { v15.4s, v16.4s}, [x0], #32 + ST2 { v25.4s, v26.4s}, [x7], x8 + + + + + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x5], x8 + + movi v6.2s, #0x00000000 + movi v7.2s, #0x00000000 + + LD2 {v4.2s, v5.2s}, [x1], #16 + LD2 {v6.s, v7.s}[0], [x1] + + LD2 {v8.h, v9.h}[0], [x2], x6 + LD2 {v8.h, v9.h}[1], [x2], x6 + LD2 {v8.h, v9.h}[2], [x2], x6 + LD2 {v8.h, v9.h}[3], [x2], x6 + + rev64 v12.8h, v8.8h + rev64 v13.8h, v9.8h + swp v5.D[0], v6.D[0] + + + MOV v30.8B, V4.8B + UZP1 v4.4h, v30.4h, v5.4h + UZP2 v5.4h, v30.4h, v5.4h + MOV v30.8B, V6.8B + UZP1 v6.4h, v30.4h, v7.4h + UZP2 v7.4h, v30.4h, v7.4h + uMULL v30.4s, v2.4h, v13.4h + uMULL v28.4s, v0.4h, v13.4h + + uMULL v26.4s, v2.4h, v12.4h + uMULL v24.4s, v0.4h, v12.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v13.4h + sMLAL v28.4s, v1.4h, v13.4h + sMLAL v26.4s, v3.4h, v12.4h + sMLAL v24.4s, v1.4h, v12.4h + + uMULL v22.4s, v6.4h, v9.4h + uMULL v20.4s, v4.4h, v9.4h + + + ADD v28.4s, v28.4s , v26.4s + SUB v30.4s, v30.4s , v24.4s + NEG v28.4s, v28.4s + + uMULL v18.4s, v6.4h, v8.4h + uMULL v16.4s, v4.4h, v8.4h + + mov v26.8b, v30.8b + mov v27.D[0], v30.D[1] + ushR v22.4s, v22.4s, #16 + + mov v24.16b, v28.16b + mov v25.D[0], v28.D[1] + ushR v20.4s, v20.4s, #16 + + + MOV v31.8B, V26.8B + UZP1 v26.4h, v31.4h, v27.4h + UZP2 v27.4h, v31.4h, v27.4h + ushr v18.4s, v18.4s, #16 + + MOV v31.8B, V24.8B + UZP1 v24.4h, v31.4h, v25.4h + UZP2 v25.4h, v31.4h, v25.4h + ushR v16.4s, v16.4s, #16 + + sMLAL v22.4s, v7.4h, v9.4h + sMLAL v20.4s, v5.4h, v9.4h + sMLAL v18.4s, v7.4h, v8.4h + sMLAL v16.4s, v5.4h, v8.4h + + + uMULL v0.4s, v26.4h, v10.4h + + + uMULL v2.4s, v24.4h, v10.4h + + ADD v22.4s, v22.4s , v16.4s + + + SUB v20.4s, v18.4s , v20.4s + + + NEG v22.4s, v22.4s + + + mov v18.8B, v22.8B + mov v19.D[0], v22.D[1] + ushR v0.4s, v0.4s, #16 + + mov v16.16b, v20.16b + mov v17.D[0], v20.D[1] + ushR v2.4s, v2.4s, #16 + + + MOV v31.8B, V18.8B + UZP1 v18.4h, v31.4h, v19.4h + UZP2 v19.4h, v31.4h, v19.4h + sMLAL v0.4s, v27.4h, v10.4h + + + MOV v31.8B, V16.8B + UZP1 v16.4h, v31.4h, v17.4h + UZP2 v17.4h, v31.4h, v17.4h + sMLAL v2.4s, v25.4h, v10.4h + + uMULL v4.4s, v18.4h, v10.4h + uMULL v6.4s, v16.4h, v10.4h + + NEG v0.4s, v0.4s + ADD v14.4s, v30.4s , v2.4s + ADD v26.4s, v28.4s , v0.4s + + rev64 v14.4s, v14.4s + ushR v4.4s, v4.4s, #16 + + swp v14.D[0], v14.D[1] + ushR v6.4s, v6.4s, #16 + + sMLAL v4.4s, v19.4h, v10.4h + + sMLAL v6.4s, v17.4h, v10.4h + + + + + ADD v24.4s, v20.4s , v4.4s + + rev64 v24.4s, v24.4s + NEG v16.4s, v6.4s + + swp v24.D[0], v24.D[1] + ADD v16.4s, v22.4s , v16.4s + + + MOV v15.16B, v14.16B + ST2 {v15.2s, v16.2s}, [x0], #16 + + ST2 {v15.s, v16.s}[2], [x0], #8 + + ST1 {v15.s}[3], [x0] + + ADD x7, x7, #4 + + ST1 {v26.s}[0], [x7], #4 + MOV v25.16B, v24.16B + ST2 {v25.s, v26.s}[1], [x7], #8 + MOV v27.D[0], V26.d[1] + mov v26.d[0], v25.d[1] + ST2 {v26.2s, v27.2s}, [x7] + + + + + + + pop_v_regs + ret + + + + + + + + + + + + diff --git a/decoder/armv8/ixheaacd_postradixcompute4.s b/decoder/armv8/ixheaacd_postradixcompute4.s new file mode 100644 index 0000000..ddd60f1 --- /dev/null +++ b/decoder/armv8/ixheaacd_postradixcompute4.s @@ -0,0 +1,148 @@ +//.include "ihevc_neon_macros.s" +.macro push_v_regs + stp x8, x9, [sp, #-16]! + stp x10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +.endm + +.text +.p2align 2 + .global ixheaacd_postradixcompute4 + + +ixheaacd_postradixcompute4: + + // STMFD sp!, {x4-x12, x14} + push_v_regs + //SUB sp, sp, #16 + + //HARD CODED for FFT Length of 16 + // x3 is always 16 + + + //SUB x4, x3, #2 ; y to y offset calculated + //MOV x4, #14 + //STR x4, [sp, #8] ; (npoints / 2)*4bytes - 4bytes + + //STR x0, [sp, #12] ; (3*(npoints/2))*4bytes - 4bytes + // x0 to x2 offset (npoints / 2)*4bytes + ADD x4, x1, x3, lsl #1 // x1 -> x0, x4 -> x2 + MOV x3, #2 + + +POSTRADIX4_START: + +// LDMIA x1!, {x5-x12} // x_0 :x_7 + + LDP w5, w6, [x1], #8 // x_0 :x_1 + LDP w7, w8, [x1], #8 // x_2 :x_3 + LDP w9, w10, [x1], #8 // x_4 :x_5 + LDP w11, w12, [x1], #8 // x_6 :x_7 + + ADD w14, w5, w9 // xh0_0 = x_0 + x_4 + SUB w5, w5, w9 // xl0_0 = x_0 - x_4 + + ADD w9, w6, w10 // xh1_0 = x_1 + x_5 + SUB w6, w6, w10 // xl1_0 = x_1 - x_5 + + ADD w10, w7, w11 // xh0_1 = x_2 + x_6 + SUB w7, w7, w11 // xl0_1 = x_2 - x_6 + + ADD w11, w8, w12 // xh1_1 = x_3 + x_7 + SUB w8, w8, w12 // xl1_1 = x_3 - x_7 + + ADD w12, w14, w10 // n00 = xh0_0 + xh0_1 + SUB w14, w14, w10 // n20 = xh0_0 - xh0_1 + + ADD w10, w9, w11 // n01 = xh1_0 + xh1_1 + SUB w9, w9, w11 // n21 = xh1_0 - xh1_1 + + ADD w11, w5, w8 // n10 = xl0_0 + xl1_1 + SUB w5, w5, w8 // n30 = xl0_0 - xl1_1 + + ADD w8, w6, w7 // n31 = xl1_0 + xl0_1 + SUB w6, w6, w7 // n11 = xl1_0 - xl0_1 + + + STR w12, [x0], #4 // y0[h2] = n00, x7 -> y0[h2 + 1] + + STR w10, [x0], #14<<1 // y0[h2 + 1] = n01, x7 -> y1[h2] + + STR w11, [x0], #4 // y1[h2] = n10, x7 -> y1[h2 + 1] + STR w6 , [x0], #14<<1 // y1[h2 + 1] = n11, x7 -> y2[h2] + + STR w14, [x0], #4 // y2[h2] = n20, x7 -> y2[h2 + 1] + STR w9 , [x0], #14<<1 // y2[h2 + 1] = n21, x7 -> y3[h2] + + STR w5, [x0], #4 // y3[h2] = n30, x7 -> y3[h2 + 1] + STR w8, [x0], #0 // y3[h2 + 1] = n31, x7 -> y0[h2+2] + +// LDMIA x4!, {x5-x12} // x_0 :x_7 + + LDP w5, w6, [x4], #8 // x_8 :x_8 + LDP w7, w8, [x4], #8 // x_a :x_b + LDP w9, w10, [x4], #8 // x_c :x_d + LDP w11, w12, [x4], #8 // x_e :x_f + + SUB x0, x0, #92 // #4*3 + #14<<1 * 3 - 8 + + + ADD w14, w5, w9 + SUB w5, w5, w9 + + ADD w9, w6, w10 + SUB w6, w6, w10 + + ADD w10, w7, w11 + SUB w7, w7, w11 + + ADD w11, w8, w12 + SUB w8, w8, w12 + + ADD w12, w14, w10 + SUB w14, w14, w10 + + ADD w10, w9, w11 + SUB w9, w9, w11 + + ADD w11, w5, w8 + SUB w5, w5, w8 + + ADD w8, w6, w7 + SUB w6, w6, w7 + + STR w12, [x0], #4 + STR w10, [x0], #14<<1 + + STR w11, [x0], #4 + STR w6, [x0], #14<<1 + + STR w14, [x0], #4 + STR w9, [x0], #14<<1 + + + STR w5, [x0], #4 + STR w8, [x0], #0 + + ADD x1, x1, #1 << 5 // x0 += (Word32) npoints >> 1 + ADD x4, x4, #1 << 5 // x2 += (Word32) npoints >> 1 + SUB x0, x0, #100-8 + + SUBS w3, w3, #1 + + BGT POSTRADIX4_START + + // LDMFD sp!, {x4-x12, x15} + pop_v_regs + ret + + diff --git a/decoder/armv8/ixheaacd_pre_twiddle.s b/decoder/armv8/ixheaacd_pre_twiddle.s new file mode 100644 index 0000000..7fae0bd --- /dev/null +++ b/decoder/armv8/ixheaacd_pre_twiddle.s @@ -0,0 +1,512 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X22, X23, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X20, X21, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X20, X21, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X22, X23, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.macro swp reg1, reg2 + MOV X16, \reg1 + MOV \reg1, \reg2 + MOV \reg2, x16 +.endm +.text +.global ixheaacd_pretwiddle_compute_armv8 + +ixheaacd_pretwiddle_compute_armv8: + + push_v_regs + + LSL x7, x4, #4 + ADD x7, x2, x7 + SUB x7, x7, #4 + LDR x22, =7500 + ADD x3, x3, x22 + MVN w5, w5 + ADD w5, w5, #1 + + + + + +ARM_PROLOGUE: + LDRH w21, [x3] + LDRH w22, [x3, #2] + LSL w22, w22, #16 + LSL w21, w21, #16 + + LDR w8, [x3], #4 + LDR w9, [x0], #4 + + + + + + + + + + + + + SMULL X12, w9, w21 + ASR X12, x12, #32 + LDR w10, [x1], #-4 + SMULL X11, w9, w22 + ASR X11, x11, #32 + SMULL X23, w10, w22 + ASR X23, x23, #32 + ADD w9, w12, w23 + SMULL X6, w10, w21 + ASR X6, x6, #32 + + + MVN w9, w9 + ADD w9, w9, #1 + SUB w11, w11, w6 + CMP w5, #0 + BGT NEXT + MVN w8, w5 + ADD w8, w8, #1 + ASR w11, w11, w8 + ASR w9, w9, w8 + B NEXT1 + +NEXT: + LSL w11, w11, w5 + LSL w9, w9, w5 + + + +NEXT1: + STR w9, [x2], #4 + STR w11, [x2], #4 + + CMP X4, #0x100 + BNE NXT + MOV X6, #4 + B NXT1 +NXT: + MOV X6, #32 + ADD X3, X3, #28 + +NXT1: + SUB X4, X4, #1 + ASR X4, X4, #2 + SUB x7, x7, #28 + + + + + + + + + + + + + + +NEON_PROLOGUE: + + MOV x8, #-32 + + dup v14.4s, w5 + + SUB X1, X1, #28 + + LD2 {v8.h, v9.h}[0], [x3], x6 + LD2 {v8.h, v9.h}[1], [x3], x6 + LD2 {v8.h, v9.h}[2], [x3], x6 + LD2 {v8.h, v9.h}[3], [x3], x6 + + rev64 v10.4h, v8.4h + rev64 v11.4h, v9.4h + + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x0], #32 + + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], x8 + + rev64 v0.4h, v0.4h + rev64 v1.4h, v1.4h + rev64 v4.4h, v4.4h + rev64 v5.4h, v5.4h + + + + + + + + uMULL v30.4s, v2.4h, v9.4h + uMULL v28.4s, v4.4h, v9.4h + uMULL v26.4s, v2.4h, v8.4h + uMULL v24.4s, v4.4h, v8.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v9.4h + sMLAL v28.4s, v5.4h, v9.4h + sMLAL v26.4s, v3.4h, v8.4h + sMLAL v24.4s, v5.4h, v8.4h + + ADD v28.4s, v26.4s , v28.4s + NEG v28.4s, v28.4s + SUB v30.4s, v30.4s , v24.4s + + uMULL v22.4s, v0.4h, v11.4h + uMULL v20.4s, v6.4h, v11.4h + uMULL v18.4s, v0.4h, v10.4h + uMULL v16.4s, v6.4h, v10.4h + + ushR v22.4s, v22.4s, #16 + ushR v20.4s, v20.4s, #16 + ushR v18.4s, v18.4s, #16 + ushR v16.4s, v16.4s, #16 + + sMLAL v22.4s, v1.4h, v11.4h + LD2 {v8.h, v9.h}[0], [x3], x6 + + sMLAL v20.4s, v7.4h, v11.4h + LD2 {v8.h, v9.h}[1], [x3], x6 + + sMLAL v18.4s, v1.4h, v10.4h + LD2 {v8.h, v9.h}[2], [x3], x6 + + sMLAL v16.4s, v7.4h, v10.4h + LD2 {v8.h, v9.h}[3], [x3], x6 + + ADD v20.4s, v20.4s , v18.4s + + NEG v20.4s, v20.4s + rev64 v10.4h, v8.4h + rev64 v11.4h, v9.4h + SUB v22.4s, v16.4s , v22.4s + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x0], #32 + + + + sshL v20.4s, v20.4s, v14.4s + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], x8 + + rev64 v0.4h, v0.4h + rev64 v1.4h, v1.4h + sshL v22.4s, v22.4s, v14.4s + + rev64 v4.4h, v4.4h + rev64 v5.4h, v5.4h + sshL v18.4s, v30.4s, v14.4s + + + sshL v16.4s, v28.4s, v14.4s + + + + + + + + + SUB X4, X4, #2 + +CORE_LOOP: + uMULL v30.4s, v2.4h, v9.4h + MOV v17.16B, v18.16B + ST2 { v16.4s, v17.4s}, [x2] + ADD x2, x2, #32 + uMULL v28.4s, v4.4h, v9.4h + + uMULL v26.4s, v2.4h, v8.4h + MOV v21.16B, v22.16B + ST2 { v20.4s, v21.4s}, [x7], x8 + uMULL v24.4s, v4.4h, v8.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v9.4h + sMLAL v28.4s, v5.4h, v9.4h + sMLAL v26.4s, v3.4h, v8.4h + sMLAL v24.4s, v5.4h, v8.4h + + ADD v28.4s, v26.4s , v28.4s + NEG v28.4s, v28.4s + SUB v30.4s, v30.4s , v24.4s + + uMULL v22.4s, v0.4h, v11.4h + LD2 {v8.h, v9.h}[0], [x3], x6 + uMULL v20.4s, v6.4h, v11.4h + + uMULL v18.4s, v0.4h, v10.4h + LD2 {v8.h, v9.h}[1], [x3], x6 + uMULL v16.4s, v6.4h, v10.4h + + ushR v22.4s, v22.4s, #16 + LD2 {v8.h, v9.h}[2], [x3], x6 + ushR v20.4s, v20.4s, #16 + + + ushR v18.4s, v18.4s, #16 + LD2 {v8.h, v9.h}[3], [x3], x6 + ushR v16.4s, v16.4s, #16 + + sMLAL v22.4s, v1.4h, v11.4h + + sMLAL v20.4s, v7.4h, v11.4h + + + sMLAL v18.4s, v1.4h, v10.4h + + + sMLAL v16.4s, v7.4h, v10.4h + LD4 {v0.4h, v1.4h, v2.4h, v3.4h}, [x0], #32 + ADD v20.4s, v20.4s , v18.4s + + NEG v20.4s, v20.4s + rev64 v10.4h, v8.4h + rev64 v11.4h, v9.4h + + SUB v22.4s, v16.4s , v22.4s + LD4 {v4.4h, v5.4h, v6.4h, v7.4h}, [x1], x8 + sshL v20.4s, v20.4s, v14.4s + + + sshL v22.4s, v22.4s, v14.4s + + rev64 v0.4h, v0.4h + rev64 v1.4h, v1.4h + sshL v18.4s, v30.4s, v14.4s + + rev64 v4.4h, v4.4h + rev64 v5.4h, v5.4h + sshL v16.4s, v28.4s, v14.4s + + + SUBS x4, x4, #1 + BNE CORE_LOOP + + + + + + +NEON_EPILOGUE: + uMULL v30.4s, v2.4h, v9.4h + MOV v17.16B, v18.16B + ST2 { v16.4s, v17.4s}, [x2] + ADD x2, x2, #32 + uMULL v28.4s, v4.4h, v9.4h + + uMULL v26.4s, v2.4h, v8.4h + MOV v21.16B, v22.16B + + ST2 { v20.4s, v21.4s}, [x7], x8 + uMULL v24.4s, v4.4h, v8.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v9.4h + sMLAL v28.4s, v5.4h, v9.4h + sMLAL v26.4s, v3.4h, v8.4h + sMLAL v24.4s, v5.4h, v8.4h + + ADD v28.4s, v26.4s , v28.4s + NEG v28.4s, v28.4s + SUB v30.4s, v30.4s , v24.4s + + uMULL v22.4s, v0.4h, v11.4h + uMULL v20.4s, v6.4h, v11.4h + uMULL v18.4s, v0.4h, v10.4h + uMULL v16.4s, v6.4h, v10.4h + + ushR v22.4s, v22.4s, #16 + ushR v20.4s, v20.4s, #16 + ushR v18.4s, v18.4s, #16 + ushR v16.4s, v16.4s, #16 + + sMLAL v22.4s, v1.4h, v11.4h + sMLAL v20.4s, v7.4h, v11.4h + sMLAL v18.4s, v1.4h, v10.4h + sMLAL v16.4s, v7.4h, v10.4h + + ADD v20.4s, v20.4s , v18.4s + NEG v20.4s, v20.4s + SUB v22.4s, v16.4s , v22.4s + + + sshL v20.4s, v20.4s, v14.4s + sshL v22.4s, v22.4s, v14.4s + sshL v18.4s, v30.4s, v14.4s + sshL v16.4s, v28.4s, v14.4s + MOV v17.16B, v18.16B + ST2 { v16.4s, v17.4s}, [x2] + ADD x2, x2, #32 + MOV v21.16B, v22.16B + ST2 { v20.4s, v21.4s}, [x7], x8 + + +RESIDUE_NEON: + MOV x10, #-16 + movi v3.2s, #0x00000000 + movi v4.2s, #0x00000000 + + LD2 {v21.2s, v22.2s}, [x0], #16 + MOV v0.8B, v21.8B + MOV v2.8B, v22.8B + + LD1 {v1.s}[0], [x0], #4; + LD1 {v3.s}[0], [x0], #4; + LD1 {v1.s}[1], [x0] + MOV v21.8B, v0.8B + + UZP1 v0.4h, v21.4h, v1.4h + UZP2 v1.4h, v21.4h, v1.4h + MOV v21.8B, v2.8B + UZP1 v2.4h, v21.4h, v3.4h + UZP2 v3.4h, v21.4h, v3.4h + + ADD x1, x1, #4 + + LD1 {v6.s}[0], [x1], #4 + LD1 {v4.s}[1], [x1], #4 + LD1 {v6.s}[1], [x1], #4 + + + LD2 {v21.2s, v22.2s}, [x1], #16 + MOV v5.8B, v21.8B + MOV v7.8B, v22.8B + + + MOV v21.8B, v4.8B + UZP1 v4.4h, v21.4h, v5.4h + UZP2 v5.4h, v21.4h, v5.4h + MOV v21.8B, v6.8B + UZP1 v6.4h, v21.4h, v7.4h + UZP2 v7.4h, v21.4h, v7.4h + rev64 v0.4h, v0.4h + rev64 v1.4h, v1.4h + rev64 v4.4h, v4.4h + rev64 v5.4h, v5.4h + + LD2 {v8.h, v9.h}[0], [x3], x6 + LD2 {v8.h, v9.h}[1], [x3], x6 + LD2 {v8.h, v9.h}[2], [x3], x6 + LD2 {v8.h, v9.h}[3], [x3], x6 + + rev64 v10.4h, v8.4h + rev64 v11.4h, v9.4h + + + + uMULL v30.4s, v2.4h, v9.4h + uMULL v28.4s, v4.4h, v9.4h + uMULL v26.4s, v2.4h, v8.4h + uMULL v24.4s, v4.4h, v8.4h + + ushR v30.4s, v30.4s, #16 + ushR v28.4s, v28.4s, #16 + ushR v26.4s, v26.4s, #16 + ushR v24.4s, v24.4s, #16 + + sMLAL v30.4s, v3.4h, v9.4h + sMLAL v28.4s, v5.4h, v9.4h + sMLAL v26.4s, v3.4h, v8.4h + sMLAL v24.4s, v5.4h, v8.4h + + ADD v28.4s, v26.4s , v28.4s + NEG v28.4s, v28.4s + SUB v30.4s, v30.4s , v24.4s + + uMULL v22.4s, v0.4h, v11.4h + uMULL v20.4s, v6.4h, v11.4h + uMULL v18.4s, v0.4h, v10.4h + uMULL v16.4s, v6.4h, v10.4h + + ushR v22.4s, v22.4s, #16 + ushR v20.4s, v20.4s, #16 + ushR v18.4s, v18.4s, #16 + ushR v16.4s, v16.4s, #16 + + sMLAL v22.4s, v1.4h, v11.4h + sMLAL v20.4s, v7.4h, v11.4h + sMLAL v18.4s, v1.4h, v10.4h + sMLAL v16.4s, v7.4h, v10.4h + + ADD v20.4s, v20.4s , v18.4s + NEG v20.4s, v20.4s + SUB v22.4s, v16.4s , v22.4s + + + + sshL v20.4s, v20.4s, v14.4s + sshL v22.4s, v22.4s, v14.4s + sshL v18.4s, v30.4s, v14.4s + sshL v16.4s, v28.4s, v14.4s + MOV v21.16B, v22.16B + ST2 { v20.4s, v21.4s}, [x7] + mov v17.16B, v18.16B + ST2 {v16.2s, v17.2s}, [x2] + ADD x2, x2, #16 + + ST2 {v16.s, v17.s}[2], [x2] + ADD x2, x2, #8 + + + + + + +END1: + pop_v_regs + ret + + + diff --git a/decoder/armv8/ixheaacd_qmf_dec.c b/decoder/armv8/ixheaacd_qmf_dec.c new file mode 100644 index 0000000..27c26bd --- /dev/null +++ b/decoder/armv8/ixheaacd_qmf_dec.c @@ -0,0 +1,2415 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_type_def.h" + +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_qmf_dec.h" + +#include +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_interface.h" +#include "ixheaacd_function_selector.h" +#include "ixheaacd_audioobjtypes.h" + +#define mult16x16_16(a, b) ixheaacd_mult16((a), (b)) +#define mac16x16(a, b, c) ixheaacd_mac16x16in32((a), (b), (c)) +#define mpy_32x16(a, b) fixmuldiv2_32x16b((a), (b)) +#define mpy_16x16(a, b) ixheaacd_mult16x16in32((a), (b)) +#define mpy_32x32(a, b) ixheaacd_mult32((a), (b)) +#define mpy_32x16H_n(a, b) ixheaacd_mult32x16hin32((a), (b)) +#define msu16x16(a, b, c) msu16x16in32((a), (b), (c)) + +#define DCT3_LEN (32) +#define DCT2_LEN (64) + +#define LP_SHIFT_VAL 7 +#define HQ_SHIFT_64 4 +#define RADIXSHIFT 1 +#define ROUNDING_SPECTRA 1 +#define HQ_SHIFT_VAL 4 + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x32in32_shift25(WORD32 a, + WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 25); + + return (result); +} + +VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, + const WORD16 *main_twidle_fwd, const WORD16 *post_tbl, + const WORD16 *w_16, const WORD32 *p_table) { + WORD32 n, k; + + WORD32 temp1[6]; + WORD32 temp2[4]; + WORD16 twid_re, twid_im; + WORD32 *ptr_reverse, *ptr_forward, *p_out, *ptr_out1; + const WORD16 *twidle_fwd, *twidle_rev; + + ptr_forward = &input[49]; + ptr_reverse = &input[47]; + + p_out = output; + twidle_fwd = main_twidle_fwd; + twidle_fwd += 4; + + *p_out++ = input[48] >> LP_SHIFT_VAL; + *p_out++ = 0; + + 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[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)); + twid_re = *twidle_fwd++; + + twid_im = *twidle_fwd; + twidle_fwd += 3; + *p_out++ = mac32x16in32_dual(temp1[0], twid_re, temp1[1], twid_im); + *p_out++ = msu32x16in32_dual(temp1[0], twid_im, temp1[1], twid_re); + } + twid_re = *twidle_fwd++; + + twid_im = *twidle_fwd; + twidle_fwd += 3; + + 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[0] = temp1[1]; + + temp2[2] = mac32x16in32_dual(temp1[0], twid_re, temp1[1], twid_im); + temp2[3] = msu32x16in32_dual(temp1[0], twid_im, temp1[1], twid_re); + + ptr_forward = output; + ptr_reverse = &output[DCT3_LEN - 1]; + 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]); + + temp2[0] >>= 1; + temp2[1] >>= 1; + + *ptr_forward++ = temp2[0]; + *ptr_forward++ = temp2[1]; + + twidle_fwd = post_tbl + 2; + twidle_rev = post_tbl + 14; + + for (n = 1; n < DCT3_LEN / 4; n++) { + temp2[0] = *ptr_forward++; + temp2[1] = *ptr_forward--; + temp2[3] = *ptr_reverse--; + temp2[2] = *ptr_reverse++; + + twid_re = *twidle_rev; + twidle_rev -= 2; + twid_im = *twidle_fwd; + twidle_fwd += 2; + + temp1[0] = temp2[0] - temp2[2]; + temp1[1] = (temp2[0] + temp2[2]); + + temp1[2] = temp2[1] + temp2[3]; + temp1[3] = (temp2[1] - temp2[3]); + temp1[4] = mac32x16in32_dual(temp1[0], twid_re, temp1[2], twid_im); + temp1[5] = msu32x16in32_dual(temp1[0], twid_im, temp1[2], twid_re); + + temp1[1] >>= 1; + temp1[3] >>= 1; + + *ptr_forward++ = temp1[1] - temp1[4]; + *ptr_forward++ = temp1[3] + temp1[5]; + + *ptr_reverse-- = -temp1[3] + temp1[5]; + *ptr_reverse-- = temp1[1] + temp1[4]; + } + temp2[0] = *ptr_forward++; + temp2[1] = *ptr_forward--; + temp2[3] = *ptr_reverse--; + temp2[2] = *ptr_reverse++; + + twid_re = *twidle_rev; + twidle_rev -= 2; + twid_im = *twidle_fwd; + twidle_fwd += 2; + + temp1[0] = temp2[0] - temp2[2]; + temp1[1] = (temp2[0] + temp2[2]); + + temp1[2] = temp2[1] + temp2[3]; + temp1[3] = (temp2[1] - temp2[3]); + + temp1[4] = -mac32x16in32_dual(temp1[0], twid_re, temp1[2], twid_im); + temp1[5] = msu32x16in32_dual(temp1[0], twid_im, temp1[2], twid_re); + + temp1[1] >>= 1; + temp1[3] >>= 1; + *ptr_forward++ = temp1[1] + temp1[4]; + *ptr_forward++ = temp1[3] + temp1[5]; + + ixheaacd_radix4bfly(w_16, output, 1, 4); + ixheaacd_postradixcompute4(input, output, p_table, 16); + + output[0] = input[0]; + output[2] = input[1]; + + p_out = input + 2; + ptr_forward = output + 1; + ptr_reverse = output + 30; + ptr_out1 = input + 18; + + for (k = (DCT3_LEN / 4) - 1; k != 0; k--) { + WORD32 tempre, tempim; + + tempre = *p_out++; + tempim = *p_out++; + *ptr_forward = (tempim); + ptr_forward += 2; + *ptr_forward = (tempre); + ptr_forward += 2; + + tempre = *ptr_out1++; + tempim = *ptr_out1++; + *ptr_reverse = (tempim); + ptr_reverse -= 2; + *ptr_reverse = (tempre); + ptr_reverse -= 2; + } + + { + WORD32 tempre, tempim; + tempre = *p_out++; + tempim = *p_out++; + *ptr_forward = (tempim); + ptr_forward += 2; + *ptr_forward = (tempre); + ptr_forward += 2; + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2(WORD32 *inp, WORD32 *out_fwd) { + WORD32 n; + WORD32 *out_rev = out_fwd + DCT2_LEN - 1; + for (n = 0; n < DCT2_LEN / 2; n++) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +VOID ixheaacd_fftposttw(WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *p_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 1; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 15; + + p_out_fwd = out; + ptr_out_rev = out + DCT2_LEN - 1; + + in1 = ((*p_out_fwd++) << 1); + val1 = ((*p_out_fwd--) << 1); + + *p_out_fwd++ = in1; + *p_out_fwd++ = val1; + + for (k = 1; k <= DCT2_LEN / 4; k++) { + WORD32 temp[4]; + WORD16 twid_re, twid_im; + + temp[0] = *p_out_fwd++; + temp[1] = *p_out_fwd--; + temp[3] = *ptr_out_rev--; + temp[2] = *ptr_out_rev++; + + in2 = temp[3] - temp[1]; + in1 = temp[3] + temp[1]; + + temp[1] = temp[0] - temp[2]; + temp[3] = temp[0] + temp[2]; + + twid_re = *twidle_fwd++; + twid_im = *twidle_rev--; + val1 = msu32x16in32_dual(in1, twid_re, temp[1], twid_im); + val2 = mac32x16in32_dual(temp[1], twid_re, in1, twid_im); + val1 = val1 << 1; + val2 = val2 << 1; + + *p_out_fwd++ = temp[3] + val1; + *p_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp[3] - val1; + } + + return; +} + +VOID ixheaacd_posttwdct2(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 k; + WORD32 inp_re, inp_im, out_re, out_im, last_val, out_re1; + WORD16 *out_fwd2, *out_rev2, *out_rev; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + + out_rev = out_fwd + DCT2_LEN - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 65; + out_re = *inp++; + out_im = *inp++; + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32(out_re1, (5 - 1))); + + *out_fwd++ = re1; + + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 2; + for (k = DCT2_LEN / 2 - 2; k >= 0; k--) { + inp_re = *inp++; + inp_im = *inp++; + + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd++; + out_re = msu32x16in32_dual(inp_re, twid_re, inp_im, twid_im); + out_im = mac32x16in32_dual(inp_im, twid_re, inp_re, twid_im); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + im1 = ixheaacd_round16(ixheaacd_shl32(out_im, (5 - 1))); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_64(WORD32 *x, WORD32 *X, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + ixheaacd_pretwdct2(x, X); + + ixheaacd_sbr_imdct_using_fft(qmf_dec_tables_ptr->w1024, 32, X, x, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128, + qmf_dec_tables_ptr->dig_rev_table2_128); + + ixheaacd_fftposttw(x, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2(x, filter_states, qmf_dec_tables_ptr); + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2_32(WORD32 *inp, WORD32 *out_fwd, + int dct2_len) { + WORD32 n; + + WORD32 *out_rev = out_fwd + dct2_len - 1; + for (n = dct2_len / 2 - 1; n >= 0; n--) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_fftposttw_32( + WORD32 *out, int dct2_len, ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *ptr_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 2; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 14; + + ptr_out_fwd = out; + ptr_out_rev = out + dct2_len - 1; + + in1 = ((*ptr_out_fwd++) << 1); + val1 = ((*ptr_out_fwd--) << 1); + + *ptr_out_fwd++ = in1; + *ptr_out_fwd++ = val1; + + for (k = dct2_len / 4 - 1; k >= 0; k--) { + WORD32 temp0, temp1, temp2, temp3; + WORD16 twid_re, twid_im; + + temp0 = *ptr_out_fwd++; + temp1 = *ptr_out_fwd--; + temp3 = *ptr_out_rev--; + temp2 = *ptr_out_rev++; + + in1 = temp1 + temp3; + in2 = -temp1 + temp3; + + temp1 = temp0 - temp2; + temp3 = temp0 + temp2; + + twid_re = *twidle_fwd; + twidle_fwd += 2; + + twid_im = *twidle_rev; + twidle_rev -= 2; + + val1 = ixheaacd_mult32x16in32(in1, twid_re) - + ixheaacd_mult32x16in32(temp1, twid_im); + val2 = ixheaacd_mult32x16in32(temp1, twid_re) + + ixheaacd_mult32x16in32(in1, twid_im); + + val1 = val1 << 1; + val2 = val2 << 1; + + *ptr_out_fwd++ = temp3 + val1; + *ptr_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp3 - val1; + } + + return; +} + +static PLATFORM_INLINE VOID +ixheaacd_posttwdct2_32(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 inp_re, out_re, out_im, last_val, out_re1; + WORD16 *out_rev, *out_rev2, *out_fwd2; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + WORD32 rounding_fac = 0x8000; + + out_rev = out_fwd + 32 - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 32 + 1; + out_fwd[32] = 0; + out_re = *inp++; + out_im = *inp++; + + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re1, (5 - 1))); + *out_fwd++ = re1; + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 4; + for (k = 14; k >= 0; k--) { + WORD32 temp1, temp2; + inp_re = *inp++; + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd; + twidle_fwd += 3; + + temp1 = ixheaacd_mult32x16in32(inp_re, twid_re); + temp2 = ixheaacd_mult32x16in32(inp_re, twid_im); + + inp_re = *inp++; + + out_re = ixheaacd_sub32(temp1, ixheaacd_mult32x16in32(inp_re, twid_im)); + out_im = ixheaacd_add32(ixheaacd_mult32x16in32(inp_re, twid_re), temp2); + + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, rounding_fac); + out_im = ixheaacd_add32_sat(out_im, rounding_fac); + re1 = (out_re >> 16); + im1 = (out_im >> 16); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re, (5 - 1))); + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_32(WORD32 *inp, WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + WORD32 *output; + + output = out + 16; + filter_states = filter_states + 16; + ixheaacd_pretwdct2_32(inp, output, 32); + + ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_16, output, 1, 4); + ixheaacd_postradixcompute4(inp, output, qmf_dec_tables_ptr->dig_rev_table4_16, + 16); + ixheaacd_fftposttw_32(inp, 32, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2_32(inp, filter_states, qmf_dec_tables_ptr); + + return; +} + +VOID ixheaacd_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD16 *p_twiddle, WORD32 *p_dig_rev_tbl) { + WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1); + + const WORD16 *p_sin; + const WORD16 *p_sin_cos = &qmf_bank->cos_twiddle[0]; + WORD32 subband_tmp[128]; + + ixheaacd_cos_sin_mod_loop1(subband, M, p_sin_cos, subband_tmp); + + if (M == 32) { + ixheaacd_sbr_imdct_using_fft( + (const WORD32 *)p_twiddle, 32, subband_tmp, subband, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl); + + ixheaacd_sbr_imdct_using_fft( + (const WORD32 *)p_twiddle, 32, &subband_tmp[64], &subband[64], + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl); + + } else { + ixheaacd_sbr_imdct_using_fft( + (const WORD32 *)p_twiddle, 16, subband_tmp, subband, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl); + + ixheaacd_sbr_imdct_using_fft( + (const WORD32 *)p_twiddle, 16, &subband_tmp[64], &subband[64], + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl, + (UWORD8 *)p_dig_rev_tbl, (UWORD8 *)p_dig_rev_tbl); + } + + p_sin = &qmf_bank->alt_sin_twiddle[0]; + ixheaacd_cos_sin_mod_loop2(subband, p_sin, M); +} + +VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband, + WORD32 *imag_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 i; + const WORD32 *p_time_in2 = &p_time_in1[2 * NO_ANALYSIS_CHANNELS - 1]; + WORD32 temp1, temp2; + WORD32 *t_real_subband = real_subband; + WORD32 *t_imag_subband = imag_subband; + const WORD16 *tcos; + + for (i = NO_ANALYSIS_CHANNELS - 1; i >= 0; i--) { + temp1 = ixheaacd_shr32(*p_time_in1++, HQ_SHIFT_VAL); + temp2 = ixheaacd_shr32(*p_time_in2--, HQ_SHIFT_VAL); + + *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); + ; + *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + ; + } + + ixheaacd_cos_sin_mod(real_subband, qmf_bank, + (WORD16 *)qmf_dec_tables_ptr->w1024, + (WORD32 *)qmf_dec_tables_ptr->dig_rev_table2_128); + + tcos = qmf_bank->t_cos; + + for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) { + WORD16 cosh, sinh; + WORD32 re, im; + + re = *real_subband; + im = *imag_subband; + cosh = *tcos++; + sinh = *tcos++; + *real_subband++ = ixheaacd_add32(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)); + } +} + +VOID ixheaacd_sbr_qmfanal32_winadd(WORD16 *inp1, WORD16 *inp2, WORD16 *p_qmf1, + WORD16 *p_qmf2, WORD32 *p_out) { + WORD32 n; + + for (n = 0; n < 32; n += 2) { + WORD32 accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[2 * (n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[2 * (n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[2 * (n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[2 * (n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[2 * (n + 256)])); + p_out[n] = accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[2 * (n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[2 * (n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[2 * (n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[2 * (n + 1 + 256)])); + p_out[n + 1] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[2 * (n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[2 * (n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[2 * (n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[2 * (n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[2 * (n + 256)])); + p_out[n + 32] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[2 * (n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[2 * (n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[2 * (n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[2 * (n + 1 + 256)])); + p_out[n + 1 + 32] = accu; + } +} + +VOID ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 *inp1, WORD16 *inp2, + WORD16 *p_qmf1, WORD16 *p_qmf2, + WORD32 *p_out) { + WORD32 n; + + for (n = 0; n < 32; n += 2) { + WORD32 accu; + accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[(n + 256)])); + p_out[n] = accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[(n + 1 + 256)])); + p_out[n + 1] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[(n + 256)])); + p_out[n + 32] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[(n + 1 + 256)])); + p_out[n + 1 + 32] = accu; + } +} + +VOID ixheaacd_esbr_qmfanal32_winadd(WORD32 *inp1, WORD32 *inp2, WORD32 *p_qmf1, + WORD32 *p_qmf2, WORD32 *p_out, + WORD32 num_band_anal_qmf) { + WORD32 n; + WORD64 accu; + + if (num_band_anal_qmf == 32) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } else if (num_band_anal_qmf == 24) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[(n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[(n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + + } else { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } +} + +VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_sample_buf, + ia_sbr_scale_fact_struct *sbr_scale_factor, + WORD32 **qmf_real, WORD32 **qmf_imag, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD32 ch_fac, WORD32 low_pow_flag, + WORD audio_object_type) { + WORD32 i, k; + WORD32 num_time_slots = qmf_bank->num_time_slots; + + WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS]; + WORD16 *filter_states = qmf_bank->core_samples_buffer; + + WORD16 *fp1, *fp2, *tmp; + + WORD16 *filter_1; + WORD16 *filter_2; + WORD16 *filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c_eld3 - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3; + } + + filter_1 = qmf_bank->filter_pos; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_2 = filter_1 + 64; + } else { + filter_2 = filter_1 + 32; + } + + sbr_scale_factor->st_lb_scale = 0; + sbr_scale_factor->lb_scale = -10; + if (!low_pow_flag) { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + sbr_scale_factor->lb_scale = -8; + } else { + sbr_scale_factor->lb_scale = -9; + } + qmf_bank->cos_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->t_cos = (WORD16 *)qmf_dec_tables_ptr->sbr_t_cos_sin_l32; + } else { + qmf_bank->t_cos = + (WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld; + } + } + + fp1 = qmf_bank->anal_filter_states; + fp2 = qmf_bank->anal_filter_states + NO_ANALYSIS_CHANNELS; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + filter_2 = qmf_bank->filter_2; + fp1 = qmf_bank->fp1_anal; + fp2 = qmf_bank->fp2_anal; + } + + for (i = 0; i < num_time_slots; i++) { + for (k = 0; k < NO_ANALYSIS_CHANNELS; k++) + filter_states[NO_ANALYSIS_CHANNELS - 1 - k] = time_sample_buf[ch_fac * k]; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ixheaacd_sbr_qmfanal32_winadds(fp1, fp2, filter_1, filter_2, + analysis_buffer, filter_states, + time_sample_buf, ch_fac); + } + + else { + ixheaacd_sbr_qmfanal32_winadd_eld(fp1, fp2, filter_1, filter_2, + analysis_buffer); + } + + time_sample_buf += NO_ANALYSIS_CHANNELS * ch_fac; + + filter_states -= NO_ANALYSIS_CHANNELS; + if (filter_states < qmf_bank->anal_filter_states) { + filter_states = qmf_bank->anal_filter_states + 288; + } + + tmp = fp1; + fp1 = fp2; + fp2 = tmp; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_1 += 64; + filter_2 += 64; + } else { + filter_1 += 32; + filter_2 += 32; + } + + filt_ptr = filter_1; + filter_1 = filter_2; + filter_2 = filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + if (filter_2 > (qmf_bank->analy_win_coeff + 640)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 64; + } + } else { + if (filter_2 > (qmf_bank->analy_win_coeff + 320)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 32; + } + } + + if (!low_pow_flag) { + ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i], + qmf_bank, qmf_dec_tables_ptr); + } else { + ixheaacd_dct3_32( + (WORD32 *)analysis_buffer, qmf_real[i], qmf_dec_tables_ptr->dct23_tw, + qmf_dec_tables_ptr->post_fft_tbl, qmf_dec_tables_ptr->w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + } + } + + qmf_bank->filter_pos = filter_1; + qmf_bank->core_samples_buffer = filter_states; + + if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD) + + { + qmf_bank->fp1_anal = fp1; + qmf_bank->fp2_anal = fp2; + qmf_bank->filter_2 = filter_2; + } +} + +static PLATFORM_INLINE VOID +ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states, + ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 L = syn_qmf->no_channels; + const WORD32 M = (L >> 1); + WORD32 *dct_in = qmf_real; + WORD32 time_out[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 ui_rem = ((WORD64)(&time_out[0]) % 8); + WORD32 *ptime_out = (pVOID)((WORD8 *)&time_out[0] + 8 - ui_rem); + + if (L == 64) + ixheaacd_dct2_64(dct_in, ptime_out, qmf_dec_tables_ptr, filter_states + M); + else + ixheaacd_dct2_32(dct_in, time_out, qmf_dec_tables_ptr, filter_states); + + filter_states[3 * M] = 0; +} + +static VOID ixheaacd_inv_emodulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + ixheaacd_cos_sin_mod(qmf_real, syn_qmf, (WORD16 *)qmf_dec_tables_ptr->w1024, + (WORD32 *)qmf_dec_tables_ptr->dig_rev_table2_128); +} + +VOID ixheaacd_esbr_radix4bfly(const WORD32 *w, WORD32 *x, WORD32 index1, + WORD32 index) { + int i; + WORD32 l1, l2, h2, fft_jmp; + WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0; + WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0; + WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1; + WORD32 x_h2_0, x_h2_1; + WORD32 si10, si20, si30, co10, co20, co30; + + WORD64 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6; + WORD64 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12; + WORD32 *x_l1; + WORD32 *x_l2; + WORD32 *x_h2; + const WORD32 *w_ptr = w; + WORD32 i1; + + h2 = index << 1; + l1 = index << 2; + l2 = (index << 2) + (index << 1); + + x_l1 = &(x[l1]); + x_l2 = &(x[l2]); + x_h2 = &(x[h2]); + + fft_jmp = 6 * (index); + + for (i1 = 0; i1 < index1; i1++) { + for (i = 0; i < index; i++) { + si10 = (*w_ptr++); + co10 = (*w_ptr++); + si20 = (*w_ptr++); + co20 = (*w_ptr++); + si30 = (*w_ptr++); + co30 = (*w_ptr++); + + x_0 = x[0]; + x_h2_0 = x[h2]; + x_l1_0 = x[l1]; + x_l2_0 = x[l2]; + + xh0_0 = x_0 + x_l1_0; + xl0_0 = x_0 - x_l1_0; + + xh20_0 = x_h2_0 + x_l2_0; + xl20_0 = x_h2_0 - x_l2_0; + + x[0] = xh0_0 + xh20_0; + xt0_0 = 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; + + xh21_0 = x_h2_1 + x_l2_1; + xl21_0 = x_h2_1 - x_l2_1; + + x[1] = xh1_0 + xh21_0; + yt0_0 = xh1_0 - xh21_0; + + xt1_0 = xl0_0 + xl21_0; + xt2_0 = xl0_0 - xl21_0; + + yt2_0 = xl1_0 + xl20_0; + yt1_0 = xl1_0 - xl20_0; + + mul_11 = ixheaacd_mult64(xt2_0, co30); + mul_3 = ixheaacd_mult64(yt2_0, si30); + x[l2] = (WORD32)((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; + + mul_12 = ixheaacd_mult64(xt0_0, co20); + mul_2 = ixheaacd_mult64(yt0_0, si20); + x[l1] = (WORD32)((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; + + mul_4 = ixheaacd_mult64(xt1_0, co10); + mul_1 = ixheaacd_mult64(yt1_0, si10); + x[h2] = (WORD32)((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 += 2; + } + x += fft_jmp; + w_ptr = w_ptr - fft_jmp; + } +} + +VOID ixheaacd_esbr_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *pdig_rev_tbl, + WORD32 npoints) { + WORD32 i, k; + WORD32 h2; + WORD32 x_0, x_1, x_2, x_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 2); + y3 = y2 + (WORD32)(npoints >> 2); + j0 = 8; + n0 = npoints >> 1; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *pdig_rev_tbl++ >> 2; + + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + x_6 = *x0++; + x_7 = *x0++; + + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + x_e = *x2++; + x_f = *x2++; + + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} + +VOID ixheaacd_esbr_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, + WORD32 npoints) { + WORD32 i, k; + WORD32 h2; + WORD32 xh0_0, xh1_0, xl0_0, xl1_0; + WORD32 xh0_1, xh1_1, xl0_1, xl1_1; + WORD32 x_0, x_1, x_2, x_3; + WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 1); + y3 = y2 + (WORD32)(npoints >> 1); + + j0 = 4; + n0 = npoints >> 2; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *p_dig_rev_tbl++ >> 2; + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} + +VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl) { + WORD32 z; + WORD32 temp[128]; + WORD32 scaleshift = 0; + + WORD32 re2, re3; + WORD32 wim, wre; + + WORD32 i, M_2; + WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1); + + const WORD32 *p_sin; + const WORD32 *p_sin_cos; + + WORD32 subband_tmp[128]; + WORD32 re; + WORD32 im; + WORD32 *psubband, *psubband1; + WORD32 *psubband_t, *psubband1_t; + WORD32 *psubband2, *psubband12; + WORD32 *psubband_t2, *psubband1_t2; + + M_2 = ixheaacd_shr32(M, 1); + + p_sin_cos = qmf_bank->esbr_cos_twiddle; + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + psubband_t = subband_tmp; + psubband1_t = &subband_tmp[2 * M - 1]; + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + psubband_t2 = &subband_tmp[64]; + psubband1_t2 = &subband_tmp[2 * M - 1 + 64]; + + for (i = (M_2 >> 1) - 1; i >= 0; i--) { + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband_t++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + *psubband_t2++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + + re = *psubband1--; + im = *psubband++; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + *psubband1_t-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + + re = *psubband12--; + im = *psubband2++; + + *psubband1_t2-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1_t2-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband_t++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + *psubband_t2++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + + re = *psubband1--; + im = *psubband++; + ; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + *psubband1_t-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + + re = *psubband12--; + im = *psubband2++; + ; + + *psubband1_t2-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1_t2-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + } + + if (M == 32) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2); + ixheaacd_esbr_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2); + ixheaacd_esbr_postradixcompute2(&subband[64], &subband_tmp[64], + p_dig_rev_tbl, 32); + + } + + else if (M == 16) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 4); + ixheaacd_esbr_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4); + ixheaacd_esbr_postradixcompute4(&subband[64], &subband_tmp[64], + p_dig_rev_tbl, 16); + + } + + else if (M == 12) { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[12 + z] = subband_tmp[2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z]; + subband[2 * z + 1] = temp[z + 12]; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[12 + z] = subband_tmp[64 + 2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z]; + subband[64 + 2 * z + 1] = temp[z + 12]; + } + + } + + else { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[8 + z] = subband_tmp[2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z] << scaleshift; + subband[2 * z + 1] = temp[z + 8] << scaleshift; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[8 + z] = subband_tmp[64 + 2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z] << scaleshift; + subband[64 + 2 * z + 1] = temp[8 + z] << scaleshift; + } + } + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + + re = *psubband1; + + *psubband = *psubband >> 1; + psubband++; + *psubband1 = ixheaacd_negate32(*psubband >> 1); + psubband1--; + + p_sin = qmf_bank->esbr_alt_sin_twiddle; + + wim = *p_sin++; + wre = *p_sin++; + + im = *psubband1; + ; + + *psubband1-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + + re = *psubband12; + ; + + *psubband12-- = ixheaacd_negate32_sat(*psubband2 >> 1); + ; + *psubband2 = psubband2[1] >> 1; + ; + psubband2++; + + im = *psubband12; + ; + + *psubband2++ = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32)); + *psubband12-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re, wim), + ixheaacd_mult64(im, wre))) >> + 32); + + for (i = (M_2 - 2); i >= 0; i--) { + im = psubband[0]; + ; + re = psubband[1]; + ; + re2 = *psubband1; + ; + + *psubband++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + + im = psubband2[0]; + ; + re = psubband2[1]; + ; + re3 = *psubband12; + ; + + *psubband12-- = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32)); + *psubband2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re, wre), + ixheaacd_mult64(im, wim))) >> + 32); + + wim = *p_sin++; + wre = *p_sin++; + im = psubband1[0]; + ; + + *psubband1-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re2, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re2, wim))) >> + 32); + + im = psubband12[0]; + ; + + *psubband2++ = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re3, wre), ixheaacd_mult64(im, wim))) >> + 32)); + *psubband12-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re3, wim), + ixheaacd_mult64(im, wre))) >> + 32); + } +} + +VOID ixheaacd_esbr_fwd_modulation( + const WORD32 *time_sample_buf, WORD32 *real_subband, WORD32 *imag_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 i; + const WORD32 *time_sample_buf1 = + &time_sample_buf[2 * qmf_bank->no_channels - 1]; + WORD32 temp1, temp2; + WORD32 *t_real_subband = real_subband; + WORD32 *t_imag_subband = imag_subband; + const WORD32 *tcos; + + for (i = qmf_bank->no_channels - 1; i >= 0; i--) { + temp1 = ixheaacd_shr32(*time_sample_buf++, HQ_SHIFT_64); + temp2 = ixheaacd_shr32(*time_sample_buf1--, HQ_SHIFT_64); + + *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); + ; + *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + ; + } + + ixheaacd_esbr_cos_sin_mod(real_subband, qmf_bank, + qmf_dec_tables_ptr->esbr_w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + + tcos = qmf_bank->esbr_t_cos; + + for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) { + WORD32 cosh, sinh; + WORD32 re, im; + + re = *real_subband; + im = *imag_subband; + cosh = *tcos++; + sinh = *tcos++; + *real_subband++ = (WORD32)((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); + } +} + +VOID ixheaacd_esbr_inv_modulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + ixheaacd_esbr_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->esbr_w_32, + qmf_dec_tables_ptr->dig_rev_table2_32); +} + +VOID ixheaacd_sbr_qmfsyn64_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac); + +VOID ixheaacd_esbr_qmfsyn64_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *inp1, + WORD32 *sample_buffer, WORD32 ch_fac) { + WORD32 k; + + for (k = 0; k < 64; k++) { + WORD64 syn_out = 0; + + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[0 + k], inp1[k + 0])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[256 + k], inp1[k + 128])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[512 + k], inp1[k + 256])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[768 + k], inp1[k + 384])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[1024 + k], inp1[k + 512])); + + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[128 + k], inp1[k + 64])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[384 + k], inp1[k + 192])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[640 + k], inp1[k + 320])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[896 + k], inp1[k + 448])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[1152 + k], inp1[k + 576])); + + sample_buffer[ch_fac * k] = (WORD32)(syn_out >> 31); + } +} + +VOID ixheaacd_sbr_qmfsyn32_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac) { + WORD32 k; + WORD32 rounding_fac = 0x8000; + rounding_fac = rounding_fac >> shift; + + for (k = 0; k < 32; k++) { + WORD32 syn_out = rounding_fac; + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[0 + k], inp1[2 * (k + 0)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[128 + k], inp1[2 * (k + 64)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[256 + k], inp1[2 * (k + 128)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[384 + k], inp1[2 * (k + 192)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[512 + k], inp1[2 * (k + 256)])); + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[64 + k], inp1[2 * (k + 32)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[192 + k], inp1[2 * (k + 96)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[320 + k], inp1[2 * (k + 160)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[448 + k], inp1[2 * (k + 224)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[576 + k], inp1[2 * (k + 288)])); + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + if (shift == 2) { + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + } + sample_buffer[ch_fac * k] = (syn_out >> 16); + } +} + +VOID ixheaacd_shiftrountine(WORD32 *qmf_real, WORD32 *qmf_imag, WORD32 len, + WORD32 common_shift) { + WORD32 treal, timag; + WORD32 j; + + if (common_shift < 0) { + WORD32 cshift = -common_shift; + cshift = ixheaacd_min32(cshift, 31); + for (j = len - 1; j >= 0; j--) { + treal = *qmf_real; + timag = *qmf_imag; + + treal = (ixheaacd_shr32(treal, cshift)); + timag = (ixheaacd_shr32(timag, cshift)); + + *qmf_real++ = treal; + *qmf_imag++ = timag; + } + } else { + for (j = len - 1; j >= 0; j--) { + treal = (ixheaacd_shl32_sat(*qmf_real, common_shift)); + timag = (ixheaacd_shl32_sat(*qmf_imag, common_shift)); + *qmf_real++ = treal; + *qmf_imag++ = timag; + } + } +} + +VOID ixheaacd_shiftrountine_with_rnd_hq(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD32 *filter_states, WORD32 len, + WORD32 shift) { + WORD32 *filter_states_rev = filter_states + len; + WORD32 treal, timag; + WORD32 j; + + for (j = (len - 1); j >= 0; j -= 2) { + WORD32 r1, r2, i1, i2; + i2 = qmf_imag[j]; + r2 = qmf_real[j]; + r1 = *qmf_real++; + i1 = *qmf_imag++; + + timag = ixheaacd_add32(i1, r1); + timag = (ixheaacd_shl32_sat(timag, shift)); + filter_states_rev[j] = timag; + + treal = ixheaacd_sub32(i2, r2); + treal = (ixheaacd_shl32_sat(treal, shift)); + filter_states[j] = treal; + + treal = ixheaacd_sub32(i1, r1); + treal = (ixheaacd_shl32_sat(treal, shift)); + *filter_states++ = treal; + + timag = ixheaacd_add32(i2, r2); + timag = (ixheaacd_shl32_sat(timag, shift)); + *filter_states_rev++ = timag; + } +} + +void ixheaacd_sbr_pre_twiddle(WORD32 *pXre, WORD32 *pXim, WORD16 *pTwiddles) { + int k; + + for (k = 62; k >= 0; k--) { + WORD32 Xre = *pXre; + WORD32 Xim = *pXim; + + WORD16 ixheaacd_cosine = *pTwiddles++; + + WORD16 ixheaacd_sine = *pTwiddles++; + + WORD32 re, im; + + re = ixheaacd_mac32x16in32_shl( + ixheaacd_mult32x16in32_shl(Xre, ixheaacd_cosine), Xim, ixheaacd_sine); + im = ixheaacd_sub32(ixheaacd_mult32x16in32_shl(Xim, ixheaacd_cosine), + ixheaacd_mult32x16in32_shl(Xre, ixheaacd_sine)); + + *pXre++ = re; + *pXim++ = im; + } +} + +VOID ixheaacd_cplx_synt_qmffilt( + WORD32 **qmf_real, WORD32 **qmf_imag, WORD32 split, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 *time_out, + ia_sbr_qmf_filter_bank_struct *qmf_bank, ia_ps_dec_struct *ptr_ps_dec, + FLAG active, FLAG low_pow_flag, ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD32 ch_fac, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type) { + WORD32 i; + + WORD32 code_scale_factor; + WORD32 scale_factor; + WORD32 out_scale_factor; + WORD32 low_band_scale_factor; + WORD32 high_band_scale_factor; + WORD16 *filter_states = qmf_bank->filter_states; + WORD32 **ptr_qmf_imag_temp; + WORD32 qmf_real2[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 no_synthesis_channels = qmf_bank->no_channels; + WORD32 p1; + + WORD16 *fp1; + WORD16 *fp2; + + WORD32 sixty4 = NO_SYNTHESIS_CHANNELS; + WORD32 thirty2 = qmf_bank->no_channels; + + WORD16 *filter_coeff; + WORD32 num_time_slots = qmf_bank->num_time_slots; + WORD32 ixheaacd_drc_offset; + WORD32 ov_lb_scale = sbr_scale_factor->ov_lb_scale; + WORD32 lb_scale = sbr_scale_factor->lb_scale; + WORD32 st_syn_scale = sbr_scale_factor->st_syn_scale; + WORD32 ov_lb_shift, lb_shift, hb_shift; + + WORD32 *qmf_real_tmp = qmf_real2; + WORD32 *qmf_imag_tmp = &qmf_real2[NO_SYNTHESIS_CHANNELS]; + WORD32 env = 0; + + WORD32 common_shift; + + if (no_synthesis_channels == 32) { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + qmf_bank->t_cos = + (WORD16 *) + sbr_tables_ptr->qmf_dec_tables_ptr->sbr_cos_sin_twiddle_ds_l32; + } else { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64; + } + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld; + } + + fp1 = &filter_states[0]; + fp2 = fp1 + no_synthesis_channels; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + fp1 = qmf_bank->fp1_syn; + fp2 = qmf_bank->fp2_syn; + sixty4 = qmf_bank->sixty4; + } + + filter_coeff = qmf_bank->filter_pos_syn; + + if (active) { + code_scale_factor = scale_factor = sbr_scale_factor->ps_scale; + } else { + code_scale_factor = ixheaacd_min32(lb_scale, ov_lb_scale); + scale_factor = sbr_scale_factor->hb_scale; + } + + low_band_scale_factor = (st_syn_scale - code_scale_factor); + high_band_scale_factor = (st_syn_scale - scale_factor); + + p1 = 0; + + if (low_pow_flag) + + { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 4; + lb_shift = (st_syn_scale - lb_scale) - 4; + hb_shift = high_band_scale_factor - 4; + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 1)); + ptr_qmf_imag_temp = 0; + + } + + else { + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 3)); + if (active) { + ov_lb_shift = (sbr_scale_factor->ps_scale - ov_lb_scale); + lb_shift = (sbr_scale_factor->ps_scale - lb_scale); + hb_shift = (sbr_scale_factor->ps_scale - sbr_scale_factor->hb_scale); + common_shift = low_band_scale_factor - 8; + + } else { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 8; + lb_shift = (st_syn_scale - lb_scale) - 8; + hb_shift = high_band_scale_factor - 8; + } else { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 7; + lb_shift = (st_syn_scale - lb_scale) - 7; + hb_shift = high_band_scale_factor - 7; + } + common_shift = 0; + } + ptr_qmf_imag_temp = qmf_imag; + } + + { + if (ov_lb_shift == lb_shift) { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + num_time_slots, ov_lb_shift, low_pow_flag); + + } else { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + split, ov_lb_shift, low_pow_flag); + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, + split, num_time_slots, lb_shift, low_pow_flag); + } + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, qmf_bank->lsb, + qmf_bank->usb, 0, num_time_slots, hb_shift, + low_pow_flag); + } + + ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; + + if (1 == drc_on) { + for (i = 0; i < num_time_slots; i++) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + } + + if (low_pow_flag) + + { + WORD16 *fptemp; + + VOID(*sbr_qmf_syn_winadd) + (WORD16 *, WORD16 *, WORD16 *, WORD16 *, FLAG, WORD32); + ia_qmf_dec_tables_struct *qmf_tab_ptr = sbr_tables_ptr->qmf_dec_tables_ptr; + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn32_winadd; + else + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn64_winadd; + + for (i = 0; i < num_time_slots; i++) { + ixheaacd_inv_modulation_lp(qmf_real[i], + &filter_states[ixheaacd_drc_offset], qmf_bank, + qmf_tab_ptr); + + sbr_qmf_syn_winadd(fp1, fp2, filter_coeff, &time_out[ch_fac * p1], 2, + ch_fac); + + ixheaacd_drc_offset -= no_synthesis_channels << 1; + + if (ixheaacd_drc_offset < 0) + ixheaacd_drc_offset += ((no_synthesis_channels << 1) * 10); + + fptemp = fp1; + fp1 = fp2; + fp2 = fptemp; + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + } + + } else { + for (i = 0; i < num_time_slots; i++) { + WORD32 *t_qmf_imag; + t_qmf_imag = qmf_imag[i]; + + if (active) { + if (i == ptr_ps_dec->border_position[env]) { + ixheaacd_init_rot_env(ptr_ps_dec, (WORD16)env, qmf_bank->usb, + sbr_tables_ptr, pstr_common_tables->trig_data); + env++; + } + + ixheaacd_apply_ps(ptr_ps_dec, &qmf_real[i], &qmf_imag[i], qmf_real_tmp, + qmf_imag_tmp, sbr_scale_factor, (WORD16)i, + sbr_tables_ptr); + } + if (1 == drc_on) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + + if (active) { + if (common_shift) + ixheaacd_shiftrountine(qmf_real[i], t_qmf_imag, no_synthesis_channels, + common_shift); + } + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) + ixheaacd_sbr_pre_twiddle( + qmf_real[i], t_qmf_imag, + sbr_tables_ptr->qmf_dec_tables_ptr->ixheaacd_sbr_synth_cos_sin_l32); + + ixheaacd_inv_emodulation(qmf_real[i], qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); + + { + WORD32 temp_out_scale_fac = out_scale_factor + 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp_out_scale_fac = temp_out_scale_fac - 1; + ixheaacd_shiftrountine_with_rnd_eld( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + } + + else { + ixheaacd_shiftrountine_with_rnd( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + } + } + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn32_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += thirty2; + fp2 -= thirty2; + thirty2 = -thirty2; + + ixheaacd_drc_offset -= 64; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 640; + + } else { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn64_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += sixty4; + fp2 -= sixty4; + sixty4 = -sixty4; + ixheaacd_drc_offset -= 128; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; + } + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + + if (active) + memcpy(qmf_real[i], qmf_real_tmp, + 2 * no_synthesis_channels * sizeof(WORD32)); + } + } + + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + qmf_bank->fp1_syn = fp1; + qmf_bank->fp2_syn = fp2; + qmf_bank->sixty4 = sixty4; + } + + qmf_bank->filter_pos_syn = filter_coeff; + qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; +} +VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 index1, + WORD32 index) { + int i; + WORD32 l1, l2, h2, fft_jmp; + WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0; + WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0; + WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1; + WORD32 x_h2_0, x_h2_1; + WORD16 si10, si20, si30, co10, co20, co30; + + WORD32 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6; + WORD32 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12; + WORD32 *x_l1; + WORD32 *x_l2; + WORD32 *x_h2; + const WORD16 *w_ptr = w; + WORD32 i1; + + h2 = index << 1; + l1 = index << 2; + l2 = (index << 2) + (index << 1); + + x_l1 = &(x[l1]); + x_l2 = &(x[l2]); + x_h2 = &(x[h2]); + + fft_jmp = 6 * (index); + + for (i1 = 0; i1 < index1; i1++) { + for (i = 0; i < index; i++) { + si10 = (*w_ptr++); + co10 = (*w_ptr++); + si20 = (*w_ptr++); + co20 = (*w_ptr++); + si30 = (*w_ptr++); + co30 = (*w_ptr++); + + x_0 = x[0]; + x_h2_0 = x[h2]; + x_l1_0 = x[l1]; + x_l2_0 = x[l2]; + + xh0_0 = x_0 + x_l1_0; + xl0_0 = x_0 - x_l1_0; + + xh20_0 = x_h2_0 + x_l2_0; + xl20_0 = x_h2_0 - x_l2_0; + + x[0] = xh0_0 + xh20_0; + xt0_0 = 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; + + xh21_0 = x_h2_1 + x_l2_1; + xl21_0 = x_h2_1 - x_l2_1; + + x[1] = xh1_0 + xh21_0; + yt0_0 = xh1_0 - xh21_0; + + xt1_0 = xl0_0 + xl21_0; + xt2_0 = xl0_0 - xl21_0; + + yt2_0 = xl1_0 + xl20_0; + yt1_0 = 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; + + mul_5 = ixheaacd_mult32x16in32(xt2_0, si30); + mul_9 = ixheaacd_mult32x16in32(yt2_0, co30); + x[l2 + 1] = (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; + + mul_6 = ixheaacd_mult32x16in32(xt0_0, si20); + mul_8 = ixheaacd_mult32x16in32(yt0_0, co20); + x[l1 + 1] = (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; + + mul_10 = ixheaacd_mult32x16in32(xt1_0, si10); + mul_7 = ixheaacd_mult32x16in32(yt1_0, co10); + x[h2 + 1] = (mul_7 - mul_10) << RADIXSHIFT; + + x += 2; + } + x += fft_jmp; + w_ptr = w_ptr - fft_jmp; + } +} + +VOID ixheaacd_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *pdig_rev_tbl, WORD32 npoints) { + WORD32 i, k; + WORD32 h2; + WORD32 x_0, x_1, x_2, x_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 2); + y3 = y2 + (WORD32)(npoints >> 2); + j0 = 8; + n0 = npoints >> 1; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *pdig_rev_tbl++ >> 2; + + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + x_6 = *x0++; + x_7 = *x0++; + + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + x_e = *x2++; + x_f = *x2++; + + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} diff --git a/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s b/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s new file mode 100644 index 0000000..baa14de --- /dev/null +++ b/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s @@ -0,0 +1,777 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp d8, d9, [sp, #-16]! + stp d10, d11, [sp, #-16]! + stp d12, d13, [sp, #-16]! + stp d14, d15, [sp, #-16]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp d14, d15, [sp], #16 + ldp d12, d13, [sp], #16 + ldp d10, d11, [sp], #16 + ldp d8, d9, [sp], #16 +.endm + +.macro swp reg1, reg2 + MOV x16, \reg1 + MOV \reg1, \reg2 + MOV \reg2, x16 +.endm +.text +.p2align 2 +.global ixheaacd_sbr_imdct_using_fft +ixheaacd_sbr_imdct_using_fft: + push_v_regs + + +COND_6: cmp x1, #0x10 + bne COND_7 + MOV X8, #1 + MOV X4, X7 + B RADIX_4_FIRST_START + +COND_7: cmp x1, #0x20 + + mov x8, #1 + mov x4, x7 + + +RADIX_8_FIRST_START: + + LSR W9 , W1, #5 + LSL W1, W1, #1 + +RADIX_8_FIRST_LOOP: + + MOV X5 , X2 + MOV X6 , X2 + MOV X7 , X2 + MOV X11 , X2 + + + + + + + + + + + + + + + + + + + + + + + LDRB W12, [X4] + ADD X5, X5, X12, LSL #3 + LD2 {V0.S, V1.S}[0], [X5], X1 + ADD X5, X5, X1 + LD2 {V4.S, V5.S}[0], [X5], X1 + SUB X5, X5, X1, LSL #1 + LD2 {V2.S, V3.S}[0], [X5], X1 + ADD X5, X5, X1 + LD2 {V6.S, V7.S}[0], [X5], X1 + SUB X5, X5, X1, LSL #2 + + LDRB W12, [X4, #1] + ADD X6, X6, X12, LSL #3 + LD2 {V0.S, V1.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {V4.S, V5.S}[1], [X6] , X1 + SUB X6, X6, X1, LSL #1 + LD2 {V2.S, V3.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {V6.S, V7.S}[1], [X6], X1 + SUB X6, X6, X1, LSL #2 + + + LDRB W12, [X4, #2] + ADD X7, X7, X12, LSL #3 + LD2 {V0.S, V1.S}[2], [X7] , X1 + ADD X7, X7, X1 + LD2 {V4.S, V5.S}[2], [X7] , X1 + SUB X7, X7, X1, LSL #1 + + LDRB W12, [X4, #3] + ADD X11, X11, X12, LSL #3 + LD2 {V0.S, V1.S}[3], [X11] , X1 + ADD X11, X11, X1 + LD2 {V4.S, V5.S}[3], [X11] , X1 + SUB X11, X11, X1, LSL #1 + + + ADD V8.4S, V0.4S, V4.4S + LD2 {V2.S, V3.S}[2], [X7] , X1 + ADD X7, X7, X1 + + + SUB V9.4S, V0.4S, V4.4S + LD2 {V6.S, V7.S}[2], [X7], X1 + SUB X7, X7, X1, LSL #2 + + + ADD V0.4S, V1.4S, V5.4S + LD2 {V2.S, V3.S}[3], [X11] , X1 + ADD X11, X11, X1 + + SUB V4.4S, V1.4S, V5.4S + LD2 {V6.S, V7.S}[3], [X11], X1 + SUB X11, X11, X1, LSL #2 + + ADD X4, X4, #4 + + ADD X5, X5, X1, LSR #1 + ADD X6, X6, X1, LSR #1 + ADD X7, X7, X1, LSR #1 + ADD X11, X11, X1, LSR #1 + + + ADD V1.4S, V2.4S, V6.4S + LD2 {V14.S, V15.S}[0], [X5] , X1 + + + SUB V5.4S, V2.4S, V6.4S + LD2 {V10.S, V11.S}[0], [X5] , X1 + + + ADD V2.4S, V3.4S, V7.4S + LD2 {V12.S, V13.S}[0], [X5] , X1 + + + SUB V6.4S, V3.4S, V7.4S + LD2 {V14.S, V15.S}[1], [X6] , X1 + + ADD V3.4S, V9.4S, V6.4S + LD2 {V10.S, V11.S}[1], [X6] , X1 + + SUB V7.4S, V9.4S, V6.4S + LD2 {V12.S, V13.S}[1], [X6] , X1 + + SUB V6.4S, V4.4S, V5.4S + LD2 {V14.S, V15.S}[2], [X7] , X1 + + ADD V9.4S, V4.4S, V5.4S + LD2 {V10.S, V11.S}[2], [X7] , X1 + + ADD V4.4S, V8.4S, V1.4S + LD2 {V12.S, V13.S}[2], [X7] , X1 + + SUB V5.4S, V8.4S, V1.4S + LD2 {V14.S, V15.S}[3], [X11] , X1 + + ADD V8.4S, V0.4S, V2.4S + LD2 {V10.S, V11.S}[3], [X11] , X1 + + SUB V0.4S, V0.4S, V2.4S + LD2 {V12.S, V13.S}[3], [X11] , X1 + + + LD2 {V1.S, V2.S}[0], [X5], X1 + + ADD V17.4S, V14.4S, V12.4S + + LD2 {V1.S, V2.S}[1], [X6] , X1 + + SUB V16.4S, V14.4S, V12.4S + + LD2 {V1.S, V2.S}[2], [X7] , X1 + + ADD V14.4S, V15.4S, V13.4S + + LD2 {V1.S, V2.S}[3], [X11] , X1 + + SUB V12.4S, V15.4S, V13.4S + + ADD V15.4S, V10.4S, V1.4S + SUB V13.4S, V10.4S, V1.4S + ADD V10.4S, V11.4S, V2.4S + SUB V1.4S, V11.4S, V2.4S + + ADD V11.4S, V17.4S, V15.4S + SUB V2.4S, V17.4S, V15.4S + ADD V17.4S, V14.4S, V10.4S + SUB V15.4S, V14.4S, V10.4S + + ADD V14.4S, V16.4S, V12.4S + SUB V10.4S, V16.4S, V12.4S + ADD V16.4S, V13.4S, V1.4S + SUB V12.4S, V13.4S, V1.4S + + ADD V1.4S , V14.4S, V12.4S + SUB V13.4S, V14.4S, V12.4S + SUB V12.4S, V16.4S, V10.4S + + UZP1 V22.8H, V1.8H, V1.8H + UZP2 V23.8H, V1.8H, V1.8H + ADD V14.4S, V16.4S, V10.4S + + UZP1 V26.8H, V13.8H, V13.8H + UZP2 V27.8H, V13.8H, V13.8H + ADD V16.4S, V4.4S, V11.4S + + UZP1 V24.8H, V12.8H, V12.8H + UZP2 V25.8H, V12.8H, V12.8H + SUB V10.4S, V4.4S, V11.4S + + UZP1 V28.8H, V14.8H, V14.8H + UZP2 V29.8H, V14.8H, V14.8H + ADD V4.4S, V8.4S, V17.4S + + MOV W14, #0x5a82 + + SUB V11.4S, V8.4S, V17.4S + + ADD V8.4S, V5.4S, V15.4S + SUB V17.4S, V5.4S, V15.4S + SUB V5.4S, V0.4S, V2.4S + ADD V15.4S, V0.4S, V2.4S + + + + + + + + + + + + + + + + DUP V31.4H, W14 + + UMULL V19.4S, V26.4H, V31.4H + UMULL V18.4S, V28.4H, V31.4H + SSHR V19.4S, V19.4S, #15 + SSHR V18.4S, V18.4S, #15 + + SQDMLAL V19.4S, V27.4H, V31.4H + SQDMLAL V18.4S, V29.4H, V31.4H + + UMULL V13.4S, V24.4H, V31.4H + UMULL V14.4S, V22.4H, V31.4H + + ADD V20.4S, V3.4S, V19.4S + SUB V21.4S, V3.4S, V19.4S + ADD V30.4S, V6.4S, V18.4S + SUB V6.4S, V6.4S, V18.4S + + SSHR V13.4S, V13.4S, #15 + SSHR V14.4S, V14.4S, #15 + + SQDMLAL V13.4S, V25.4H, V31.4H + SQDMLAL V14.4S, V23.4H, V31.4H + + ADD V3.4S, V7.4S, V13.4S + SUB V19.4S, V7.4S, V13.4S + ADD V1.4S, V9.4S, V14.4S + SUB V18.4S, V9.4S, V14.4S + + + + + + + + + + + + + + + + + + + + + + + + + + swp V17.D[0], V8.D[0] + swp V17.D[1], V8.D[1] + swp V4.D[0], V16.D[0] + swp V4.D[1], V16.D[1] + + TRN1 V12.4S, V4.4S, V20.4S + TRN2 V22.4S, V4.4S, V20.4S + + SHL V12.4S, V12.4S, #1 + TRN1 V9.4S, V17.4S, V3.4S + TRN2 V2.4S, V17.4S, V3.4S + SHL V22.4S, V22.4S, #1 + + SHL V9.4S, V9.4S, #1 + TRN1 V24.4S, V10.4S, V21.4S + TRN2 V7.4S, V10.4S, V21.4S + SHL V2.4S, V2.4S, #1 + + SHL V24.4S, V24.4S, #1 + TRN1 V13.4S, V16.4S, V6.4S + TRN2 V23.4S, V16.4S, V6.4S + SHL V7.4S, V7.4S, #1 + + SHL V13.4S, V13.4S, #1 + TRN1 V10.4S, V5.4S, V18.4S + TRN2 V3.4S, V5.4S, V18.4S + SHL V23.4S, V23.4S, #1 + + SHL V10.4S, V10.4S, #1 + TRN1 V26.4S, V8.4S, V19.4S + TRN2 V4.4S, V8.4S, V19.4S + SHL V3.4S, V3.4S, #1 + + SHL V26.4S, V26.4S, #1 + TRN1 V25.4S, V11.4S, V30.4S + TRN2 V8.4S, V11.4S, V30.4S + SHL V4.4S, V4.4S, #1 + + SHL V25.4S, V25.4S, #1 + TRN1 V27.4S, V15.4S, V1.4S + TRN2 V5.4S, V15.4S, V1.4S + SHL V8.4S, V8.4S, #1 + + SHL V27.4S, V27.4S, #1 + swp V9.D[0], V12.D[1] + SHL V5.4S, V5.4S, #1 + swp V2.D[0], V22.D[1] + + swp V24.D[1], V26.D[0] + swp V7.D[1], V4.D[0] + swp V10.D[0], V13.D[1] + swp V3.D[0], V23.D[1] + swp V27.D[0], V25.D[1] + swp V5.D[0], V8.D[1] + + + MOV X15, #32 + ST2 {V12.4S, V13.4S}, [X3], X15 + ST2 {V24.4S, V25.4S}, [X3], X15 + ST2 {V22.4S, V23.4S}, [X3], X15 + ST2 {V7.4S, V8.4S}, [X3], X15 + ST2 {V9.4S, V10.4S}, [X3], X15 + ST2 {V26.4S, V27.4S}, [X3], X15 + ST2 {V2.4S, V3.4S}, [X3], X15 + ST2 {V4.4S, V5.4S}, [X3], X15 + + + SUBS X9, X9, #1 + BNE RADIX_8_FIRST_LOOP + + LSR X1, X1, #1 + LSL X15, X1, #3 + SUB X3, X3, X15 + + MOV X5, #8 + MOV X4, #32 + LSR X15, X1, #5 + MOV X6, X15 + B RADIX_4_FIRST_ENDS + +RADIX_8_FIRST_ENDS: + + + +RADIX_4_FIRST_START: + + + LSR W9, W1, #4 + LSL W1, W1, #1 + +RADIX_4_LOOP: + + MOV X5 , X2 + MOV X6 , X2 + MOV X7 , X2 + MOV X11 , X2 + + + + + + + + + + + + + + + + LDRB W12, [X4, #0] + ADD X5, X5, X12, LSL #3 + + LD2 {V0.S, V1.S}[0], [X5] , X1 + ADD X5, X5, X1 + LD2 {V8.S, V9.S}[0], [X5] , X1 + SUB X5, X5, X1, LSL #1 + LD2 {V4.S, V5.S}[0], [X5] , X1 + ADD X5, X5, X1 + LD2 {V12.S, V13.S}[0], [X5] , X1 + + LDRB W12, [X4, #1] + ADD X6, X6, X12, LSL #3 + LD2 {V0.S, V1.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {V8.S, V9.S}[1], [X6] , X1 + SUB X6, X6, X1, LSL #1 + LD2 {V4.S, V5.S}[1], [X6] , X1 + ADD X6, X6, X1 + LD2 {V12.S, V13.S}[1], [X6] , X1 + + LDRB W12, [X4, #2] + ADD X7, X7, X12, LSL #3 + + LD2 {V0.S, V1.S}[2], [X7] , X1 + ADD X7, X7, X1 + LD2 {V8.S, V9.S}[2], [X7] , X1 + + + LDRB W12, [X4, #3] + ADD X11, X11, X12 , LSL #3 + + + LD2 {V0.S, V1.S}[3], [X11] , X1 + ADD X11, X11, X1 + LD2 {V8.S, V9.S}[3], [X11] , X1 + + SUB X7, X7, X1, LSL #1 + ADD V16.4S, V0.4S, V8.4S + LD2 {V4.S, V5.S}[2], [X7] , X1 + ADD X7, X7, X1 + ADD V18.4S, V1.4S, V9.4S + LD2 {V12.S, V13.S}[2], [X7] , X1 + + SUB X11, X11, X1, LSL #1 + SUB V20.4S, V0.4S, V8.4S + LD2 {V4.S, V5.S}[3], [X11] , X1 + ADD X11, X11, X1 + SUB V22.4S, V1.4S, V9.4S + LD2 {V12.S, V13.S}[3], [X11] , X1 + + ADD X4, X4, #4 + + ADD V24.4S, V4.4S, V12.4S + ADD V26.4S, V5.4S, V13.4S + SUB V28.4S, V4.4S, V12.4S + SUB V30.4S, V5.4S, V13.4S + + ADD V17.4S, V16.4S, V24.4S + ADD V11.4S, V18.4S, V26.4S + SUB V19.4S, V16.4S, V24.4S + SUB V15.4S, V18.4S, V26.4S + + ADD V8.4S, V20.4S, V30.4S + SUB V9.4S, V22.4S, V28.4S + ADD V13.4S, V22.4S, V28.4S + SUB V12.4S, V20.4S, V30.4S + + + + + TRN1 V0.4S, V17.4S, V8.4S + TRN2 V8.4S, V17.4S, V8.4S + + SHL V0.4S, V0.4S, #1 + TRN1 V4.4S, V19.4S, V12.4S + TRN2 V12.4S, V19.4S, V12.4S + SHL V8.4S, V8.4S, #1 + + SHL V4.4S, V4.4S, #1 + TRN1 V1.4S, V11.4S, V9.4S + TRN2 V9.4S, V11.4S, V9.4S + SHL V12.4S, V12.4S, #1 + + SHL V1.4S, V1.4S, #1 + TRN1 V5.4S, V15.4S, V13.4S + TRN2 V13.4S, V15.4S, V13.4S + SHL V9.4S, V9.4S, #1 + + SHL V5.4S, V5.4S, #1 + swp V4.D[0], V0.D[1] + SHL V13.4S, V13.4S, #1 + + swp V12.D[0], V8.D[1] + + + swp V5.D[0], V1.D[1] + swp V13.D[0], V9.D[1] + + MOV X15, #32 + ST2 {V0.4S, V1.4S}, [X3], X15 + ST2 {V8.4S, V9.4S}, [X3], X15 + ST2 {V4.4S, V5.4S}, [X3], X15 + ST2 {V12.4S, V13.4S}, [X3], X15 + + + SUBS W9, W9, #1 + BNE RADIX_4_LOOP + + LSR X1, X1, #1 + SUB X3, X3, X1, LSL #3 + MOV X5, #4 + MOV X4, #64 + LSR X6, X1, #4 + + +RADIX_4_FIRST_ENDS: + + + + + + + + + + + + + + + + + + + + + + + MOV x30, X3 + LSR X5, X5, #2 + +OUTER_LOOP_R4: + + + MOV X14, x30 + + MOV X7, X5 + MOV X2, #0 + MOV X9, X0 + LSL X12, X5, #5 +MIDDLE_LOOP_R4: + + + LD2 {V20.H, V21.H}[0], [X9], X2 + LD2 {V22.H, V23.H}[0], [X9], X2 + ADD X11, X2, X4, LSL #2 + LD2 {V24.H, V25.H}[0], [X9] + ADD X10, X0, X11 + + LD2 {V20.H, V21.H}[1], [X10], X11 + LD2 {V22.H, V23.H}[1], [X10], X11 + ADD X2, X11, X4, LSL #2 + LD2 {V24.H, V25.H}[1], [X10] + ADD X9, X0, X2 + + LD2 {V20.H, V21.H}[2], [X9], X2 + LD2 {V22.H, V23.H}[2], [X9], X2 + ADD X11, X2, X4, LSL #2 + LD2 {V24.H, V25.H}[2], [X9] + ADD X10, X0, X11 + + LD2 {V20.H, V21.H}[3], [X10], X11 + LD2 {V22.H, V23.H}[3], [X10], X11 + ADD X2, X11, X4, LSL #2 + LD2 {V24.H, V25.H}[3], [X10] + ADD X9, X0, X2 + + MOV X10, X6 +INNER_LOOP_R4: + + LD2 {V30.4S, V31.4S}, [X14], X12 + SSHR V30.4S, V30.4S, #1 + LD4 {V16.4H, V17.4H, V18.4H, V19.4H}, [X14], X12 + SSHR V31.4S, V31.4S, #1 + + USHR V16.4H, V16.4H, #1 + LD4 {V26.4H, V27.4H, V28.4H, V29.4H}, [X14], X12 + USHR V18.4H, V18.4H, #1 + + SMULL V11.4S, V16.4H, V20.4H + SMLSL V11.4S, V18.4H, V21.4H + LD4 {V0.4H, V1.4H, V2.4H, V3.4H}, [X14], X12 + SMULL V12.4S, V16.4H, V21.4H + SMLAL V12.4S, V18.4H, V20.4H + + USHR V26.4H, V26.4H, #1 + USHR V28.4H, V28.4H, #1 + + LSL x29, X12, #2 + SUB X14, X14, X12, LSL #2 + + USHR V0.4H, V0.4H, #1 + USHR V2.4H, V2.4H, #1 + + SMULL V13.4S, V26.4H, V22.4H + SMLSL V13.4S, V28.4H, V23.4H + + SSHR V11.4S, V11.4S, #15 + + SMULL V14.4S, V26.4H, V23.4H + SMLAL V14.4S, V28.4H, V22.4H + + SMULL V15.4S, V0.4H, V24.4H + SMLSL V15.4S, V2.4H, V25.4H + + SMLAL V11.4S, V17.4H, V20.4H + SMLSL V11.4S, V19.4H, V21.4H + + SSHR V12.4S, V12.4S, #15 + SSHR V13.4S, V13.4S, #15 + SSHR V14.4S, V14.4S, #15 + SSHR V15.4S, V15.4S, #15 + + SMLAL V12.4S, V17.4H, V21.4H + SMLAL V12.4S, V19.4H, V20.4H + + SMULL V5.4S, V0.4H, V25.4H + SMLAL V5.4S, V2.4H, V24.4H + + SMLAL V13.4S, V27.4H, V22.4H + SMLSL V13.4S, V29.4H, V23.4H + + SMLAL V14.4S, V27.4H, V23.4H + SMLAL V14.4S, V29.4H, V22.4H + + SMLAL V15.4S, V1.4H, V24.4H + SMLSL V15.4S, V3.4H, V25.4H + + SSHR V5.4S, V5.4S, #15 + + SMLAL V5.4S, V1.4H, V25.4H + SMLAL V5.4S, V3.4H, V24.4H + + + + SUBS x17, X7, X5 + BNE BYPASS_IF + + ADD X14, X14, X12 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOV V11.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOV V13.S[0], W3 + + LDR W3, [X14] + ASR W3, W3, #1 + MOV V15.S[0], W3 + + SUB X14, X14, X12, LSL #1 + ADD X14, X14, #4 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOV V12.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOV V14.S[0], W3 + + LDR W3, [X14] + ADD X14, X14, X12 + ASR W3, W3, #1 + MOV V5.S[0], W3 + + SUB X14, X14, #4 + + SUB X14, X14, x29 + +BYPASS_IF: + + ADD V6.4S, V30.4S, V13.4S + ADD V7.4S, V31.4S, V14.4S + SUB V30.4S, V30.4S, V13.4S + SUB V31.4S, V31.4S, V14.4S + ADD V8.4S, V11.4S, V15.4S + ADD V9.4S, V12.4S, V5.4S + + SUB V15.4S, V11.4S, V15.4S + SUB V14.4S, V12.4S, V5.4S + + + ADD V10.4S, V6.4S, V8.4S + ADD V11.4S, V7.4S, V9.4S + ADD V12.4S, V30.4S, V14.4S + SUB V13.4S, V31.4S, V15.4S + + SUB V6.4S, V6.4S, V8.4S + ST2 {V10.4S, V11.4S}, [X14], X12 + SUB V7.4S, V7.4S, V9.4S + + SUB V8.4S, V30.4S, V14.4S + ST2 {V12.4S, V13.4S}, [X14], X12 + ADD V9.4S, V31.4S, V15.4S + + ST2 {V6.4S, V7.4S}, [X14], X12 + ST2 {V8.4S, V9.4S}, [X14], X12 + SUBS X10, X10, #1 + BNE INNER_LOOP_R4 + + SUB X14, X14, X1, LSL #3 + ADD X14, X14, #32 + + SUBS X7, X7, #1 + BNE MIDDLE_LOOP_R4 + + LSR X4, X4, #2 + LSL X5, X5, #2 + LSR X6, X6, #2 + SUBS X8, X8, #1 + BNE OUTER_LOOP_R4 +END_LOOPS: + pop_v_regs + RET diff --git a/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s b/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s new file mode 100644 index 0000000..146f028 --- /dev/null +++ b/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s @@ -0,0 +1,341 @@ +.macro push_v_regs + stp d8, d9, [sp, #-16]! + stp d10, d11, [sp, #-16]! + stp d12, d13, [sp, #-16]! + stp d14, d15, [sp, #-16]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X29, X30, [sp, #-16]! +.endm +.macro pop_v_regs + ldp X29, X30, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 + ldp d14, d15, [sp], #16 + ldp d12, d13, [sp], #16 + ldp d10, d11, [sp], #16 + ldp d8, d9, [sp], #16 +.endm + +.text +.p2align 2 + .global ixheaacd_sbr_qmfanal32_winadds + +ixheaacd_sbr_qmfanal32_winadds: // PROC + + // STMFD sp!, {x4-x12, x14} + push_v_regs + stp x19, x20, [sp, #-16]! + //VPUSH {D8 - D15} + //LDR w5, [SP, #108] //filterStates + //sxtw x5,w5 + //LDR w6, [SP, #112] //timeIn + //sxtw x6,w6 + //LDR w7, [SP, #116] //stride + //sxtw x7,w7 + + LSL x9, x7, #1 + + + MOV x20, x4 + ADD x5, x5, #64 + MOV w10, #3 + + //ADD x5, x5, #56 + //MOV x10, #1 + ////SUB x6, x6, x9 + //CMP x7, #1 + //MOV x11, #-8 + //BGT LOOP_SKIP_ODD + +LOOP: + LDRSH w4 , [x6] + ADD x6, x6, x9 + LDRSH w8 , [x6] + ADD x6, x6, x9 + LDRSH w11 , [x6] + ADD x6, x6, x9 + LDRSH w12 , [x6] + ADD x6, x6, x9 + + STRH w4 , [x5 , #-2]! + STRH w8 , [x5 , #-2]! + STRH w11 , [x5 , #-2]! + STRH w12 , [x5 , #-2]! + + LDRSH w4 , [x6] + ADD x6, x6, x9 + LDRSH w8 , [x6] + ADD x6, x6, x9 + LDRSH w11 , [x6] + ADD x6, x6, x9 + LDRSH w12 , [x6] + ADD x6, x6, x9 + + STRH w4 , [x5 , #-2]! + STRH w8 , [x5 , #-2]! + STRH w11 , [x5 , #-2]! + STRH w12 , [x5 , #-2]! + SUBS w10, w10, #1 + + BPL LOOP + + +//LOOP: +// LD1 {v0.4h} , [x6], #8 +// LD1 {v1.4h} , [x6], #8 +// +// REV64 v4.4h , v0.4h +// REV64 v5.4h , v1.4h +// +// ST1 {v4.4h} , [x5] , x11 +// ST1 {v5.4h} , [x5] , x11 +// +// LD1 {v2.4h} , [x6], #8 +// LD1 {v3.4h} , [x6], #8 +// +// REV64 v6.4h , v2.4h +// REV64 v7.4h , v3.4h +// +// ST1 {v6.4h} , [x5] , x11 +// ST1 {v7.4h} , [x5] , x11 +// +// SUBS x10, x10, #1 +// BPL LOOP +// B SKIP_LOOP +// +//LOOP_SKIP_ODD: +// LD2 {v0.4h , v1.4h} , [x6], #16 +// LD2 {v2.4h , v3.4h} , [x6], #16 +// +// REV64 v1.4h , v0.4h +// REV64 v3.4h , v2.4h +// +// ST1 {v1.4h} , [x5], x11 +// ST1 {v3.4h} , [x5], x11 +// +// LD2 {v4.4h , v5.4h} , [x6], #16 +// LD2 {v6.4h , v7.4h} , [x6], #16 +// +// +// REV64 v5.4h , v4.4h +// REV64 v7.4h , v6.4h +// +// ST1 {v5.4h} , [x5], x11 +// ST1 {v7.4h} , [x5], x11 +// +// SUBS x10, x10, #1 +// BPL LOOP_SKIP_ODD + +SKIP_LOOP: + + //LDR w4, [SP, #104] //winAdd + // sxtw x4,w4 + + MOV x4, x20 + MOV x5, #8 + LD1 {v0.4h}, [x0], #8 + MOV x6, #64 + + LSL x6, x6, #1 + LD2 {v1.4h, v2.4h}, [x2], #16 + MOV x7, #244 + + MOV x9, x0 + ADD x0, x0, #120 + + MOV x11, x4 + LD1 {v2.4h}, [x0], x6 + ADD x11, x11, #128 + + + + + MOV x10, x2 + ADD x2, x2, #240 + + sMULL v30.4s, v0.4h, v1.4h + LD2 {v3.4h, v4.4h}, [x2], #16 + ADD x2, x2, #240 + + + LD1 {v4.4h}, [x0], x6 + sMLAL v30.4s, v2.4h, v3.4h + + LD2 {v5.4h, v6.4h}, [x2], #16 + + + ADD x2, x2, #240 + LD1 {v6.4h}, [x0], x6 + sMLAL v30.4s, v4.4h, v5.4h + + LD2 {v7.4h, v8.4h}, [x2], #16 + + + ADD x2, x2, #240 + LD1 {v8.4h}, [x0], x6 + sMLAL v30.4s, v6.4h, v7.4h + + MOV x0, x9 + LD2 {v9.4h, v10.4h}, [x2], #16 + + + ADD x2, x2, #240 + LD1 {v10.4h}, [x1], #8 + sMLAL v30.4s, v8.4h, v9.4h + + + + MOV x9, x1 + LD2 {v11.4h, v12.4h}, [x3], #16 + ADD x1, x1, #120 + + + MOV x2, x10 + LD1 {v12.4h}, [x1], x6 + MOV x10, x3 + + ADD x3, x3, #240 + LD2 {v13.4h, v14.4h}, [x3], #16 + ADD x3, x3, #240 + + + LD2 {v15.4h, v16.4h}, [x3], #16 + + LD1 {v14.4h}, [x1], x6 + ADD x3, x3, #240 + + + + LD1 {v16.4h}, [x1], x6 + SUB x5, x5, #1 + + LD2 {v17.4h, v18.4h}, [x3], #16 + + + ADD x3, x3, #240 + LD1 {v18.4h}, [x1], x6 + + MOV x1, x9 + LD2 {v19.4h, v20.4h}, [x3], #16 + + ADD x3, x3, #240 + + MOV x3, x10 + + +LOOP_1: + + + LD1 {v0.4h}, [x0], #8 + + MOV x9, x0 + LD2 {v1.4h, v2.4h}, [x2], #16 + ADD x0, x0, #120 + + MOV x10, x2 + ST1 { v30.4s}, [x4], #16 + ADD x2, x2, #240 + + + sMULL v30.4s, v10.4h, v11.4h + LD1 {v2.4h}, [x0], x6 + sMLAL v30.4s, v12.4h, v13.4h + + sMLAL v30.4s, v14.4h, v15.4h + LD2 {v3.4h, v4.4h}, [x2], #16 + sMLAL v30.4s, v16.4h, v17.4h + + sMLAL v30.4s, v18.4h, v19.4h + LD1 {v4.4h}, [x0], x6 + ADD x2, x2, #240 + + ST1 { v30.4s}, [x11], #16 + + + sMULL v30.4s, v0.4h, v1.4h + LD2 {v5.4h, v6.4h}, [x2], #16 + sMLAL v30.4s, v2.4h, v3.4h + + + + ADD x2, x2, #240 + LD1 {v6.4h}, [x0], x6 + sMLAL v30.4s, v4.4h, v5.4h + + LD2 {v7.4h, v8.4h}, [x2], #16 + + + ADD x2, x2, #240 + LD1 {v8.4h}, [x0], x6 + sMLAL v30.4s, v6.4h, v7.4h + + MOV x0, x9 + LD2 {v9.4h, v10.4h}, [x2], #16 + + + + ADD x2, x2, #240 + LD1 {v10.4h}, [x1], #8 + MOV x2, x10 + + MOV x9, x1 + LD2 {v11.4h, v12.4h}, [x3], #16 + ADD x1, x1, #120 + + + sMLAL v30.4s, v8.4h, v9.4h + LD1 {v12.4h}, [x1], x6 + MOV x10, x3 + + + ADD x3, x3, #240 + LD2 {v13.4h, v14.4h}, [x3], #16 + ADD x3, x3, #240 + + + + LD1 {v14.4h}, [x1], x6 + LD2 {v15.4h, v16.4h}, [x3], #16 + ADD x3, x3, #240 + + + LD1 {v16.4h}, [x1], x6 + LD2 {v17.4h, v18.4h}, [x3], #16 + ADD x3, x3, #240 + + + LD1 {v18.4h}, [x1], x6 + SUBS x5, x5, #1 + + MOV x1, x9 + LD2 {v19.4h, v20.4h}, [x3], #16 + + ADD x3, x3, #240 + + MOV x3, x10 + + BGT LOOP_1 + + ST1 { v30.4s}, [x4], #16 + sMULL v30.4s, v10.4h, v11.4h + sMLAL v30.4s, v12.4h, v13.4h + + sMLAL v30.4s, v14.4h, v15.4h + sMLAL v30.4s, v16.4h, v17.4h + sMLAL v30.4s, v18.4h, v19.4h + + ST1 { v30.4s}, [x11], #16 + + //VPOP {D8 - D15} + // LDMFD sp!, {x4-x12, x15} + ldp x19, x20, [sp], #16 + pop_v_regs + ret + // ENDP diff --git a/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s b/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s new file mode 100644 index 0000000..6e2c7eb --- /dev/null +++ b/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s @@ -0,0 +1,403 @@ +///****************************************************************************** +// * +// * 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 +//*/ + + +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! + stp x21, x22, [sp, #-16]! + stp x23, x24, [sp, #-16]! +.endm +.macro pop_v_regs + ldp x23, x24, [sp], #16 + ldp x21, x22, [sp], #16 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + +.macro swp reg1, reg2 + MOV X16, \reg1 + MOV \reg1, \reg2 + MOV \reg2, x16 +.endm +.text +.global ixheaacd_sbr_qmfsyn64_winadd + +ixheaacd_sbr_qmfsyn64_winadd: + + push_v_regs + + + + MOV w7, #0x8000 + LD1 {v0.4h}, [x0], #8 + MOV x12, x2 + + dup v30.4s, w7 + LD1 {v1.4h}, [x2], #8 + dup v22.4s, w4 + + MOV x10, x0 + MOV x11, x2 + ADD x0, x0, #504 + ADD x2, x2, #248 + + NEG v28.4s, v22.4s + sshL v20.4s, v30.4s, v28.4s + MOV x6, #64 + LSL x6, x6, #1 + ADD x12, x12, x6 + MOV x7, #128 + LSL x9, x7, #1 + ADD x1, x1, x9 + MOV x6, #16 + MOV x7, #128 + LSL x9, x7, #1 + MOV x7, #256 + LSL x8, x7, #1 + + LSL x5, x5, #1 + LD1 {v2.4h}, [x0], x8 + mov v26.16b, v20.16b + + + sMLAL v26.4s, v0.4h, v1.4h + LD1 {v3.4h}, [x2], x9 + + LD1 {v4.4h}, [x0], x8 + sMLAL v26.4s, v2.4h, v3.4h + + LD1 {v5.4h}, [x2], x9 + + LD1 {v6.4h}, [x0], x8 + sMLAL v26.4s, v5.4h, v4.4h + + LD1 {v7.4h}, [x2], x9 + + LD1 {v8.4h}, [x0], x8 + sMLAL v26.4s, v7.4h, v6.4h + + LD1 {v9.4h}, [x2], x9 + MOV x0, x10 + + + MOV x2, x11 + LD1 {v10.4h}, [x1], #8 + sMLAL v26.4s, v9.4h, v8.4h + + MOV x10, x1 + LD1 {v11.4h}, [x12], #8 + ADD x1, x1, #504 + + + + MOV x11, x12 + LD1 {v12.4h}, [x1], x8 + ADD x12, x12, #248 + + sMLAL v26.4s, v10.4h, v11.4h + LD1 {v13.4h}, [x12], x9 + + LD1 {v14.4h}, [x1], x8 + sMLAL v26.4s, v12.4h, v13.4h + + LD1 {v15.4h}, [x12], x9 + + LD1 {v16.4h}, [x1], x8 + sMLAL v26.4s, v15.4h, v14.4h + + LD1 {v17.4h}, [x12], x9 + + LD1 {v18.4h}, [x1], x8 + sMLAL v26.4s, v17.4h, v16.4h + + LD1 {v19.4h}, [x12], x9 + + sMLAL v26.4s, v19.4h, v18.4h + LD1 {v0.4h}, [x0], #8 + MOV x12, x11 + + MOV x1, x10 + LD1 {v1.4h}, [x2], #8 + MOV x10, x0 + + sQshL v26.4s, v26.4s, v22.4s + + ADD x0, x0, #504 + + MOV x11, x2 + LD1 {v2.4h}, [x0], x8 + ADD x2, x2, #248 + + sshR v28.4s, v26.4s, #16 + LD1 {v3.4h}, [x2], x9 + + + UZP2 v29.8h, v28.8h, v28.8h + UZP1 v28.8h, v28.8h, v28.8h + mov v26.16b, v20.16b + + + + + LD1 {v4.4h}, [x0], x8 + LD1 {v5.4h}, [x2], x9 + + LD1 {v6.4h}, [x0], x8 + LD1 {v7.4h}, [x2], x9 + + LD1 {v8.4h}, [x0], x8 + LD1 {v9.4h}, [x2], x9 + MOV x0, x10 + + + MOV x2, x11 + LD1 {v10.4h}, [x1], #8 + + MOV x10, x1 + LD1 {v11.4h}, [x12], #8 + ADD x1, x1, #504 + + + MOV x11, x12 + LD1 {v12.4h}, [x1], x8 + ADD x12, x12, #248 + + + LD1 {v13.4h}, [x12], x9 + + LD1 {v14.4h}, [x1], x8 + LD1 {v15.4h}, [x12], x9 + + LD1 {v16.4h}, [x1], x8 + LD1 {v17.4h}, [x12], x9 + + LD1 {v18.4h}, [x1], x8 + SUB x6, x6, #2 + LD1 {v19.4h}, [x12], x9 + MOV x1, x10 + + MOV x12, x11 + +LOOP_1: + + sMLAL v26.4s, v0.4h, v1.4h + ST1 {v28.h}[0], [x3], x5 + + sMLAL v26.4s, v2.4h, v3.4h + LD1 {v0.4h}, [x0], #8 + sMLAL v26.4s, v5.4h, v4.4h + + sMLAL v26.4s, v7.4h, v6.4h + ST1 {v28.h}[1], [x3], x5 + + + MOV x10, x0 + LD1 {v1.4h}, [x2], #8 + ADD x0, x0, #504 + + sMLAL v26.4s, v9.4h, v8.4h + ST1 {v28.h}[2], [x3], x5 + + sMLAL v26.4s, v10.4h, v11.4h + ST1 {v28.h}[3], [x3], x5 + + MOV x11, x2 + LD1 {v2.4h}, [x0], x8 + ADD x2, x2, #248 + + sMLAL v26.4s, v12.4h, v13.4h + LD1 {v3.4h}, [x2], x9 + sMLAL v26.4s, v15.4h, v14.4h + + sMLAL v26.4s, v17.4h, v16.4h + LD1 {v4.4h}, [x0], x8 + sMLAL v26.4s, v19.4h, v18.4h + + LD1 {v5.4h}, [x2], x9 + + LD1 {v6.4h}, [x0], x8 + sQshL v26.4s, v26.4s, v22.4s + + sshR v28.4s, v26.4s, #16 + LD1 {v7.4h}, [x2], x9 + mov v26.16b, v20.16b + + + UZP2 v29.8h, v28.8h, v28.8h + UZP1 v28.8h, v28.8h, v28.8h + sMLAL v26.4s, v0.4h, v1.4h + + sMLAL v26.4s, v2.4h, v3.4h + LD1 {v8.4h}, [x0], x8 + sMLAL v26.4s, v5.4h, v4.4h + + sMLAL v26.4s, v7.4h, v6.4h + LD1 {v9.4h}, [x2], x9 + + + LD1 {v10.4h}, [x1], #8 + sMLAL v26.4s, v9.4h, v8.4h + + MOV x2, x11 + LD1 {v11.4h}, [x12], #8 + MOV x0, x10 + + MOV x10, x1 + + ADD x1, x1, #504 + + MOV x11, x12 + LD1 {v12.4h}, [x1], x8 + ADD x12, x12, #248 + + LD1 {v13.4h}, [x12], x9 + sMLAL v26.4s, v10.4h, v11.4h + + LD1 {v14.4h}, [x1], x8 + sMLAL v26.4s, v12.4h, v13.4h + + LD1 {v15.4h}, [x12], x9 + + LD1 {v16.4h}, [x1], x8 + sMLAL v26.4s, v15.4h, v14.4h + + LD1 {v17.4h}, [x12], x9 + + LD1 {v18.4h}, [x1], x8 + sMLAL v26.4s, v17.4h, v16.4h + + LD1 {v19.4h}, [x12], x9 + MOV x1, x10 + + sMLAL v26.4s, v19.4h, v18.4h + ST1 {v28.h}[0], [x3], x5 + + MOV x12, x11 + LD1 {v0.4h}, [x0], #8 + + LD1 {v1.4h}, [x2], #8 + sQshL v26.4s, v26.4s, v22.4s + + + ST1 {v28.h}[1], [x3], x5 + MOV x10, x0 + + ST1 {v28.h}[2], [x3], x5 + ADD x0, x0, #504 + + ST1 {v28.h}[3], [x3], x5 + MOV x11, x2 + + sshR v28.4s, v26.4s, #16 + LD1 {v2.4h}, [x0], x8 + ADD x2, x2, #248 + + LD1 {v3.4h}, [x2], x9 + LD1 {v4.4h}, [x0], x8 + LD1 {v5.4h}, [x2], x9 + LD1 {v6.4h}, [x0], x8 + LD1 {v7.4h}, [x2], x9 + LD1 {v8.4h}, [x0], x8 + LD1 {v9.4h}, [x2], x9 + + UZP2 v29.8h, v28.8h, v28.8h + UZP1 v28.8h, v28.8h, v28.8h + mov v26.16b, v20.16b + + + + + MOV x0, x10 + LD1 {v10.4h}, [x1], #8 + MOV x2, x11 + + MOV x10, x1 + LD1 {v11.4h}, [x12], #8 + ADD x1, x1, #504 + + + MOV x11, x12 + LD1 {v12.4h}, [x1], x8 + ADD x12, x12, #248 + + + LD1 {v13.4h}, [x12], x9 + + LD1 {v14.4h}, [x1], x8 + LD1 {v15.4h}, [x12], x9 + + LD1 {v16.4h}, [x1], x8 + LD1 {v17.4h}, [x12], x9 + + SUBS x6, x6, #2 + LD1 {v18.4h}, [x1], x8 + + MOV x1, x10 + LD1 {v19.4h}, [x12], x9 + + MOV x12, x11 + + + BGT LOOP_1 + + sMLAL v26.4s, v0.4h, v1.4h + ST1 {v28.h}[0], [x3], x5 + sMLAL v26.4s, v2.4h, v3.4h + + sMLAL v26.4s, v5.4h, v4.4h + ST1 {v28.h}[1], [x3], x5 + sMLAL v26.4s, v7.4h, v6.4h + + sMLAL v26.4s, v9.4h, v8.4h + ST1 {v28.h}[2], [x3], x5 + sMLAL v26.4s, v10.4h, v11.4h + + sMLAL v26.4s, v12.4h, v13.4h + ST1 {v28.h}[3], [x3], x5 + sMLAL v26.4s, v15.4h, v14.4h + + + + sMLAL v26.4s, v17.4h, v16.4h + + sMLAL v26.4s, v19.4h, v18.4h + + sQshL v26.4s, v26.4s, v22.4s + + sshR v28.4s, v26.4s, #16 + + UZP2 v29.8h, v28.8h, v28.8h + UZP1 v28.8h, v28.8h, v28.8h + + + ST1 {v28.h}[0], [x3], x5 + ST1 {v28.h}[1], [x3], x5 + ST1 {v28.h}[2], [x3], x5 + ST1 {v28.h}[3], [x3], x5 + + + pop_v_regs + ret + diff --git a/decoder/armv8/ixheaacd_shiftrountine_with_round.s b/decoder/armv8/ixheaacd_shiftrountine_with_round.s new file mode 100644 index 0000000..95b480c --- /dev/null +++ b/decoder/armv8/ixheaacd_shiftrountine_with_round.s @@ -0,0 +1,73 @@ +.macro push_v_regs + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X26, X17, [sp, #-16]! + stp X27, X28, [sp, #-16]! + stp q2, q3, [sp, #-32]! + stp q0, q1, [sp, #-32]! +.endm +.macro pop_v_regs + ldp q0, q1, [sp], #32 + ldp q2, q3, [sp], #32 + ldp X27, X28, [sp], #16 + ldp X26, X17, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +.endm + +.text +.p2align 2 + .global ixheaacd_shiftrountine_with_rnd +ixheaacd_shiftrountine_with_rnd: + push_v_regs + + ADD x12, x2, x3, LSL #1 + MOV W9, #0x00008000 + DUP V0.4s, w9 + MOVI v3.4s, #10 + MOV W27, #0x80000000 + MOV W28, #0x7fffffff + MOV W26, #0 + SUBS W3, W3, #1 + BMI S_WITH_R_L6 + +S_WITH_R_L5: + LDR w5, [x1, x3, LSL #2] //i2 = qmfImag[j] + LDR w7, [x0, x3, LSL #2] //x2 = qmfReal[j] + LDR w14, [x0], #4 //x1 = *qmfReal + LDR w10, [x1], #4 //i1 = *qmfImag + + ADD w6, w5, w7 //*qmfImag++ = add32(i2, x2) + SUB w5, w5, w7 //qmfReal[j] = sub32(i2, x2) + ADD w7, w10, w14 //qmfImag[j] = add32(i1, x1) + SUB w4, w10, w14 //*qmfReal++ = sub32(i1, x1) + + MOV v1.s[0], W4 //QADD x4, x4, x9 + MOV v1.s[1], W5 //QADD x4, x4, x9 + MOV v1.s[2], W6 //QADD x4, x4, x9 + MOV v1.s[3], W7 //QADD x4, x4, x9 + lsl w14, w3, #1 + + SQSHL v1.4s, v1.4s, v3.4s + ADD X17, X2, X14 + + SQADD v2.4s, v1.4s, v0.4s + + ST1 {v2.h}[1], [x2], #2 + ST1 {v2.h}[3], [X17] + ADD X17, X12, X14 + ST1 {v2.h}[7], [x17] //STRH w7, [x12, x14] + ST1 {v2.h}[5], [x12], #2 //STRH w6, [x12], #2 + + SUBS x3, x3, #2 + + BGE S_WITH_R_L5 +S_WITH_R_L6: + pop_v_regs + ret diff --git a/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s b/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s new file mode 100644 index 0000000..cdbd822 --- /dev/null +++ b/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s @@ -0,0 +1,79 @@ +.macro push_v_regs + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X26, X17, [sp, #-16]! + stp X27, X28, [sp, #-16]! + stp q2, q3, [sp, #-32]! + stp q0, q1, [sp, #-32]! +.endm +.macro pop_v_regs + ldp q0, q1, [sp], #32 + ldp q2, q3, [sp], #32 + ldp X27, X28, [sp], #16 + ldp X26, X17, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +.endm + +.text +.p2align 2 + .global ixheaacd_shiftrountine_with_rnd_eld +ixheaacd_shiftrountine_with_rnd_eld: + push_v_regs + + ADD x12, x2, x3, LSL #1 + MOV W9, #0x00008000 + DUP V0.4s, w9 + MOVI v3.4s, #9 + MOV W27, #0x80000000 + MOV W28, #0x7fffffff + MOV W26, #0 + SUBS W3, W3, #1 + BMI S_WITH_R_L6 + +S_WITH_R_L5: + LDR w5, [x1, x3, LSL #2] //i2 = qmfImag[j] + LDR w7, [x0, x3, LSL #2] //x2 = qmfReal[j] + LDR w14, [x0], #4 //x1 = *qmfReal + LDR w10, [x1], #4 //i1 = *qmfImag + + ADD w6, w5, w7 //*qmfImag++ = add32(i2, x2) + MVN w6, w6 + ADD w6, w6, #1 + SUB w5, w7, w5 //qmfReal[j] = sub32(i2, x2) + ADD w7, w10, w14 //qmfImag[j] = add32(i1, x1) + MVN w7, w7 + ADD w7, w7, #1 + SUB w4, w14, w10 //*qmfReal++ = sub32(i1, x1) + + + + MOV v1.s[0], W4 //QADD x4, x4, x9 + MOV v1.s[1], W5 //QADD x4, x4, x9 + MOV v1.s[2], W6 //QADD x4, x4, x9 + MOV v1.s[3], W7 //QADD x4, x4, x9 + lsl w14, w3, #1 + + SQSHL v1.4s, v1.4s, v3.4s + ADD X17, X2, X14 + + SQADD v2.4s, v1.4s, v0.4s + + ST1 {v2.h}[1], [x2], #2 + ST1 {v2.h}[3], [X17] + ADD X17, X12, X14 + ST1 {v2.h}[7], [x17] //STRH w7, [x12, x14] + ST1 {v2.h}[5], [x12], #2 //STRH w6, [x12], #2 + + SUBS x3, x3, #2 + + BGE S_WITH_R_L5 +S_WITH_R_L6: + pop_v_regs + ret diff --git a/decoder/drc_src/impd_apicmd_standards.h b/decoder/drc_src/impd_apicmd_standards.h new file mode 100644 index 0000000..94316c2 --- /dev/null +++ b/decoder/drc_src/impd_apicmd_standards.h @@ -0,0 +1,106 @@ +/****************************************************************************** + * + * 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_API_CMD_STANDARDS_H +#define IMPD_API_CMD_STANDARDS_H + +/*****************************************************************************/ +/* Ittiam standard API commands */ +/*****************************************************************************/ +#define IA_API_CMD_GET_LIB_ID_STRINGS 0x0001 + +#define IA_API_CMD_GET_API_SIZE 0x0002 +#define IA_API_CMD_INIT 0x0003 + +#define IA_API_CMD_SET_CONFIG_PARAM 0x0004 +#define IA_API_CMD_GET_CONFIG_PARAM 0x0005 + +#define IA_API_CMD_GET_MEMTABS_SIZE 0x0006 +#define IA_API_CMD_SET_MEMTABS_PTR 0x0007 +#define IA_API_CMD_GET_N_MEMTABS 0x0008 + +#define IA_API_CMD_EXECUTE 0x0009 + +#define IA_API_CMD_PUT_INPUT_QUERY 0x000A +#define IA_API_CMD_GET_CURIDX_INPUT_BUF 0x000B +#define IA_API_CMD_SET_INPUT_BYTES 0x000C +#define IA_API_CMD_GET_OUTPUT_BYTES 0x000D +#define IA_API_CMD_RESET 0x0010 + +#define IA_API_CMD_GET_MEM_INFO_SIZE 0x0011 +#define IA_API_CMD_GET_MEM_INFO_ALIGNMENT 0x0012 +#define IA_API_CMD_GET_MEM_INFO_TYPE 0x0013 +#define IA_API_CMD_GET_MEM_INFO_PLACEMENT 0x0014 +#define IA_API_CMD_GET_MEM_INFO_PRIORITY 0x0015 +#define IA_API_CMD_SET_MEM_PTR 0x0016 +#define IA_API_CMD_SET_MEM_INFO_SIZE 0x0017 +#define IA_API_CMD_SET_MEM_PLACEMENT 0x0018 + +#define IA_API_CMD_GET_N_TABLES 0x0019 +#define IA_API_CMD_GET_TABLE_INFO_SIZE 0x001A +#define IA_API_CMD_GET_TABLE_INFO_ALIGNMENT 0x001B +#define IA_API_CMD_GET_TABLE_INFO_PRIORITY 0x001C +#define IA_API_CMD_SET_TABLE_PTR 0x001D +#define IA_API_CMD_GET_TABLE_PTR 0x001E + +#define IA_API_CMD_INPUT_OVER 0x0020 +#define IA_API_CMD_INPUT_OVER_BS 0x0021 +#define IA_API_CMD_INPUT_OVER_IC_BS 0x0022 +#define IA_API_CMD_INPUT_OVER_IG_BS 0x0023 +#define IA_API_CMD_INPUT_OVER_IL_BS 0x0024 +#define IA_API_CMD_INPUT_OVER_IN_BS 0x0025 + +#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 +#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 +#define IA_API_CMD_SET_INPUT_BYTES_IG_BS 0x0028 +#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 +#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A +/*****************************************************************************/ +/* Ittiam standard API command indices */ +/*****************************************************************************/ +/* IA_API_CMD_GET_LIB_ID_STRINGS indices */ +#define IA_CMD_TYPE_LIB_NAME 0x0100 +#define IA_CMD_TYPE_LIB_VERSION 0x0200 +#define IA_CMD_TYPE_API_VERSION 0x0300 + +/* IA_API_CMD_INIT indices */ +#define IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS 0x0100 +#define IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS 0x0200 +#define IA_CMD_TYPE_INIT_PROCESS 0x0300 +#define IA_CMD_TYPE_INIT_DONE_QUERY 0x0400 + +#define IA_CMD_TYPE_INIT_CPY_BSF_BUFF 0x0201 +#define IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF 0x0202 +#define IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF 0x0203 +#define IA_CMD_TYPE_INIT_CPY_IG_BSF_BUFF 0x0204 +#define IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF 0x0205 + +#define IA_CMD_TYPE_INIT_CPY_BSF_BUFF_OVER_QUERY 0x0206 +#define IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF_OVER_QUERY 0x0207 +#define IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF_OVER_QUERY 0x0208 +#define IA_CMD_TYPE_INIT_CPY_IG_BSF_BUFF_OVER_QUERY 0x0209 +#define IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF_OVER_QUERY 0x020A +#define IA_CMD_TYPE_INIT_SET_BUFF_PTR 0x020B + +/* IA_API_CMD_EXECUTE indices */ +#define IA_CMD_TYPE_DO_EXECUTE 0x0100 +#define IA_CMD_TYPE_DONE_QUERY 0x0200 + +#endif diff --git a/decoder/drc_src/impd_drc_api.c b/decoder/drc_src/impd_drc_api.c new file mode 100644 index 0000000..d38c97e --- /dev/null +++ b/decoder/drc_src/impd_drc_api.c @@ -0,0 +1,699 @@ +/****************************************************************************** + * + * 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 +#include + +#include "impd_type_def.h" +#include "impd_error_standards.h" +#include "impd_apicmd_standards.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_parametric_drc_dec.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_drc_eq.h" +#include "impd_drc_gain_decoder.h" +#include "impd_drc_config_params.h" +#include "impd_drc_api_defs.h" +#include "impd_drc_definitions.h" +#include "impd_drc_hashdefines.h" +#include "impd_drc_peak_limiter.h" + +#include "impd_drc_selection_process.h" +#include "impd_drc_api_struct_def.h" +#include "impd_drc_error_codes.h" + +WORD32 impd_init_process_audio_main_qmf(ia_drc_api_struct *p_obj_drc); +WORD32 impd_init_process_audio_main_stft(ia_drc_api_struct *p_obj_drc); +WORD32 impd_init_process_audio_main_td_qmf(ia_drc_api_struct *p_obj_drc); + +IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, + WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); + +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); +IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc); +IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc); + +#define NUM_DRC_TABLES 4 +#define SCRATCH_MEM_SIZE 1024*256*64 + + + +IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, + WORD32 i_cmd, + WORD32 i_idx, + pVOID pv_value) +{ + ia_drc_api_struct *p_obj_drc = p_ia_drc_dec_obj; + IA_ERRORCODE error_code=IA_NO_ERROR; + LOOPIDX i; + + pUWORD32 pui_value = pv_value; + pUWORD32 pus_value = pv_value; + pWORD8 pb_value = pv_value; + SIZE_T *ps_value = pv_value; + + switch(i_cmd) + { + case IA_API_CMD_GET_MEM_INFO_SIZE: + case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: + case IA_API_CMD_GET_MEM_INFO_TYPE: + case IA_API_CMD_GET_MEM_INFO_PLACEMENT: + case IA_API_CMD_GET_MEM_INFO_PRIORITY: + case IA_API_CMD_SET_MEM_PTR: + case IA_API_CMD_SET_MEM_PLACEMENT: + { + return impd_drc_mem_api(p_ia_drc_dec_obj, i_cmd, i_idx, pv_value); + } + }; + + switch(i_cmd) + { + case IA_API_CMD_GET_LIB_ID_STRINGS: + { + switch(i_idx) + { + case IA_CMD_TYPE_LIB_NAME: + { + WORD8 lib_name[] = LIBNAME; + for(i = 0; i < IA_API_STR_LEN && lib_name[i -1] != 0; i++) + { + pb_value[i] = lib_name[i]; + } + break; + } + case IA_CMD_TYPE_LIB_VERSION: + { + break; + } + + case IA_CMD_TYPE_API_VERSION: + { + + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_GET_API_SIZE: + { + *pui_value = sizeof(ia_drc_api_struct)+(sizeof(ia_drc_state_struct)+8)+8080*1024; + + break; + } + 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->pp_mem[IA_DRC_PERSIST_IDX]; + impd_drc_set_struct_pointer(p_obj_drc); + + break; + } + case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: + { + impd_drc_set_default_config(p_obj_drc); + break; + } + case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: + { + p_obj_drc->p_state=(ia_drc_state_struct *)((SIZE_T)p_obj_drc+8000*1024); + p_obj_drc->p_mem_info=(ia_mem_info_struct *)((SIZE_T)p_obj_drc+8002*1024); + p_obj_drc->pp_mem=(pVOID)((SIZE_T)p_obj_drc+8006*1024); + impd_drc_fill_mem_tables(p_obj_drc); + break; + } + case IA_CMD_TYPE_INIT_PROCESS: + { + IA_ERRORCODE Error=0; + + if(p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] == 0) + { + return(-1); + } + + + Error = impd_drc_init(p_obj_drc); + if(Error) + return Error; + p_obj_drc->p_state->ui_init_done = 1; + return Error; + break; + } + case IA_CMD_TYPE_INIT_DONE_QUERY: + { + + if(p_obj_drc->p_state->ui_init_done == 1) + { + *pui_value = 1; + } + else + { + *pui_value = 0; + } + break; + } + + case IA_CMD_TYPE_INIT_CPY_BSF_BUFF_OVER_QUERY: + { + *pui_value = p_obj_drc->str_bit_handler.cpy_over; + break; + } + case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF_OVER_QUERY: + { + *pui_value = p_obj_drc->str_bit_handler.cpy_over_ic; + break; + } + + case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF_OVER_QUERY: + { + *pui_value = p_obj_drc->str_bit_handler.cpy_over_il; + break; + } + case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF_OVER_QUERY: + { + *pui_value = p_obj_drc->str_bit_handler.cpy_over_in; + break; + } + 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->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; + break; + + } + case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF: + { + memcpy(p_obj_drc->str_bit_handler.bitstream_drc_config+p_obj_drc->str_bit_handler.num_bytes_bs_drc_config, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_ic); + p_obj_drc->str_bit_handler.num_bytes_bs_drc_config=p_obj_drc->str_bit_handler.num_bytes_bs_drc_config+p_obj_drc->str_bit_handler.num_byts_cur_ic; + break; + + } + case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF: + { + memcpy(p_obj_drc->str_bit_handler.bitstream_loudness_info+p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_il); + p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info=p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info+p_obj_drc->str_bit_handler.num_byts_cur_il; + break; + + } + case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF: + { + memcpy(p_obj_drc->str_bit_handler.bitstream_unidrc_interface+p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_in); + p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface=p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface+p_obj_drc->str_bit_handler.num_byts_cur_in; + break; + + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_GET_CONFIG_PARAM: + { + switch(i_idx) + { + + case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: + { + + *pus_value=p_obj_drc->str_config.sampling_rate; + break; + } + + case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: + { + + *pus_value=p_obj_drc->str_config.num_ch_out; + break; + } + case IA_DRC_DEC_CONFIG_PROC_OUT_PTR: + { + + *ps_value=(SIZE_T)p_obj_drc->str_payload.pstr_drc_sel_proc_output; + break; + } + + } + break; + } + 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; + } + p_obj_drc->str_config.sampling_rate = *pus_value; + break; + } + case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: + { + p_obj_drc->str_config.num_ch_in = *pus_value; + if(*pus_value < 1 || *pus_value > MAX_CHANNEL_COUNT) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS; + } + break; + } + + 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; + } + + p_obj_drc->str_config.pcm_size = *pus_value; + + + break; + } + + 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: + { + if(*pus_value<1 || *pus_value>4096) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE; + } + + p_obj_drc->str_config.frame_size = *pus_value; + + + break; + } + case IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG: + { + p_obj_drc->str_bit_handler.gain_stream_flag = *pus_value; + break; + } + + default: + { + return -1; + } + } + break; + } + case IA_API_CMD_GET_MEMTABS_SIZE: + { + + break; + } + case IA_API_CMD_SET_MEMTABS_PTR: + { + + break; + } + case IA_API_CMD_GET_N_MEMTABS: + { + + *pui_value = NUM_DRC_TABLES; + break; + } + case IA_API_CMD_GET_N_TABLES: + { + + break; + } + + case IA_API_CMD_EXECUTE: + { + switch(i_idx) + { + case IA_CMD_TYPE_DO_EXECUTE: + { + 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); + } + else if(p_obj_drc->str_config.dec_type==DEC_TYPE_STFT256){ + error_code=impd_init_process_audio_main_stft(p_obj_drc); + } + 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); + } + break; + } + case IA_CMD_TYPE_DONE_QUERY: + { + + *pui_value = p_obj_drc->p_state->ui_exe_done; + break; + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_PUT_INPUT_QUERY: + { + *pui_value = 1; + break; + } + case IA_API_CMD_GET_CURIDX_INPUT_BUF: + { + UWORD32 ui_in_buf_size = + p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX].ui_size; + UWORD32 ui_in_bytes = p_obj_drc->p_state->ui_in_bytes; + *pui_value = ui_in_buf_size > ui_in_bytes ? ui_in_bytes : ui_in_buf_size; + break; + } + case IA_API_CMD_SET_INPUT_BYTES: + { + p_obj_drc->p_state->ui_in_bytes = *pui_value; + break; + } + + case IA_API_CMD_GET_OUTPUT_BYTES: + { + *pui_value = p_obj_drc->p_state->ui_out_bytes; + break; + } + case IA_API_CMD_INPUT_OVER: + { + 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; + } + case IA_API_CMD_SET_INPUT_BYTES_IC_BS: + { + p_obj_drc->str_bit_handler.num_byts_cur_ic=*pus_value; + break; + } + case IA_API_CMD_SET_INPUT_BYTES_IL_BS: + { + p_obj_drc->str_bit_handler.num_byts_cur_il=*pus_value; + break; + } + case IA_API_CMD_SET_INPUT_BYTES_IN_BS: + { + p_obj_drc->str_bit_handler.num_byts_cur_in=*pus_value; + break; + } + default: + { + return -1; + } + }; + return error_code; +} + + +IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, + WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) +{ + pUWORD32 pui_value = pv_value; + + switch(i_cmd) + { + case IA_API_CMD_GET_MEM_INFO_SIZE: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_size; + break; + } + case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_alignment; + break; + } + case IA_API_CMD_GET_MEM_INFO_TYPE: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_type; + break; + } + case IA_API_CMD_GET_MEM_INFO_PLACEMENT: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_placement[0]; + *(pui_value + 1) = p_obj_drc->p_mem_info[i_idx].ui_placement[1]; + break; + } + case IA_API_CMD_GET_MEM_INFO_PRIORITY: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_priority; + break; + } + case IA_API_CMD_SET_MEM_PTR: + { + + pWORD8 pbtemp; + UWORD32 sz; + if(pv_value == 0) + { + return(-1); + } + if(((SIZE_T)pv_value % p_obj_drc->p_mem_info[i_idx].ui_alignment) != 0) + { + return(-1); + } + p_obj_drc->pp_mem[i_idx] = pv_value; + pbtemp = p_obj_drc->pp_mem[i_idx]; + sz = p_obj_drc->p_mem_info[i_idx].ui_size; + + memset(pbtemp,0,sz); + } + case IA_API_CMD_SET_MEM_PLACEMENT: + { + + } + }; + return IA_NO_ERROR; +} + +IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc) +{ + ia_mem_info_struct *p_mem_info; + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_PERSIST_IDX]; + p_mem_info->ui_size = 64*1024*1024; + p_mem_info->ui_alignment = 8; + p_mem_info->ui_type = IA_MEMTYPE_PERSIST; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX]; + p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; + p_mem_info->ui_alignment = 4; + p_mem_info->ui_type = IA_MEMTYPE_INPUT; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_OUTPUT_IDX]; + p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; + p_mem_info->ui_alignment = 4; + p_mem_info->ui_type = IA_MEMTYPE_OUTPUT; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_SCRATCH_IDX]; + p_mem_info->ui_size = SCRATCH_MEM_SIZE; + p_mem_info->ui_alignment = 8; + p_mem_info->ui_type = IA_MEMTYPE_SCRATCH; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + return IA_NO_ERROR; +} diff --git a/decoder/drc_src/impd_drc_api_defs.h b/decoder/drc_src/impd_drc_api_defs.h new file mode 100644 index 0000000..9b7cd9f --- /dev/null +++ b/decoder/drc_src/impd_drc_api_defs.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * + * 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_API_DEFS_H +#define IMPD_API_DEFS_H + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +/* A constant to let API copy small strings to buffers outside */ +#define IA_API_STR_LEN 30 +#define IA_APIVERSION_MAJOR 1 +#define IA_APIVERSION_MINOR 10 + +/* last compatible version */ +/* sometimes a new API version is just for a bugfix, or a added feature in */ +/* this case it is better to use a newer version even though a library was */ +/* made for an older version, library API can then be upgraded to newer API */ +/* version after checking for compatibility or by adding features */ +#define IA_LASTCOMP_APIVERSION_MAJOR 1 +#define IA_LASTCOMP_APIVERSION_MINOR 10 + +#define IA_STR(str) #str +#define IA_MAKE_VERSION_STR(maj, min) IA_STR(maj) "." IA_STR(min) +#define IA_APIVERSION IA_MAKE_VERSION_STR(\ + IA_APIVERSION_MAJOR, \ + IA_APIVERSION_MINOR) + +#define IA_LAST_COMP_APIVERSION IA_MAKE_VERSION_STR(\ + IA_LASTCOMP_APIVERSION_MAJOR, \ + IA_LASTCOMP_APIVERSION_MINOR) + +#endif diff --git a/decoder/drc_src/impd_drc_api_struct_def.h b/decoder/drc_src/impd_drc_api_struct_def.h new file mode 100644 index 0000000..40aeed5 --- /dev/null +++ b/decoder/drc_src/impd_drc_api_struct_def.h @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * 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_API_STRUCT_DEF_H +#define IMPD_DRC_API_STRUCT_DEF_H + +/****************************************************************************/ +/* structure definitions */ +/****************************************************************************/ +/* DRC Configuration */ +typedef struct ia_drc_config_struct +{ + WORD32 bitstream_file_format; + WORD32 dec_type; + WORD32 sub_band_domain_mode; + WORD32 num_ch_in; + WORD32 num_ch_out; + WORD32 sampling_rate; + WORD32 control_parameter_index; + WORD32 delay_mode; + WORD32 absorb_delay_on; + WORD32 gain_delay_samples; + WORD32 subband_domain_io_flag; + WORD32 frame_size; + WORD32 sub_band_down_sampling_factor; + WORD32 sub_band_count; + WORD32 peak_limiter; + WORD32 interface_bitstream_present; + WORD32 pcm_size; + WORD32 parametric_drc_delay_gain_dec_instance ; + WORD32 parametric_drc_delay; + WORD32 parametric_drc_delay_max; + WORD32 eq_delay_gain_dec_instance; + WORD32 eq_delay; + WORD32 eq_delay_max; + WORD32 delay_line_samples; + WORD32 constant_delay_on; + WORD32 audio_delay_samples; + +}ia_drc_config_struct; + +/* DRC bitsteam handler */ +typedef struct bits_handler +{ + UWORD8* bitstream_drc_config; + UWORD8* bitstream_loudness_info ; + UWORD8* bitstream_unidrc_interface ; + UWORD8* it_bit_buf; + WORD32 num_bytes_bs_drc_config; + WORD32 num_bytes_bs_loudness_info; + WORD32 num_bits_read_bs_unidrc_interface; + WORD32 num_bytes_bs_unidrc_interface; + WORD32 num_bits_read_bs; + WORD32 num_bytes_read_bs; + WORD32 num_bytes_bs; + WORD32 num_bits_offset_bs; + WORD32 byte_index_bs; + WORD32 num_byts_cur; + WORD32 num_byts_cur_ic; + WORD32 num_byts_cur_il; + WORD32 num_byts_cur_in; + WORD32 cpy_over; + WORD32 cpy_over_ic; + WORD32 cpy_over_il; + WORD32 cpy_over_in; + WORD32 gain_stream_flag; +}ia_drc_bits_handler_struct; + +typedef struct +{ + ia_drc_bits_dec_struct *pstr_bitstream_dec; + ia_drc_gain_dec_struct *pstr_gain_dec[2]; + ia_drc_sel_pro_struct *pstr_selection_proc; + ia_drc_config *pstr_drc_config; + ia_drc_loudness_info_set_struct *pstr_loudness_info; + ia_drc_gain_struct *pstr_drc_gain; + ia_drc_interface_struct *pstr_drc_interface; + + ia_drc_peak_limiter_struct *pstr_peak_limiter; + ia_drc_qmf_filt_struct *pstr_qmf_filter; + ia_drc_sel_proc_params_struct *pstr_drc_sel_proc_params; + ia_drc_sel_proc_output_struct *pstr_drc_sel_proc_output; + +}ia_drc_payload_struct; + +typedef struct ia_drc_state_struct +{ + UWORD32 ui_out_bytes; + UWORD32 ui_in_bytes; + UWORD32 ui_ir_bytes; + UWORD32 total_num_out_samples; + UWORD32 frame_no; + UWORD32 out_size; + UWORD32 ui_init_done; + UWORD32 ui_exe_done; + UWORD32 ui_ir_used; + WORD32 delay_in_output; + WORD32 delay_adjust_samples; + pVOID persistant_ptr; +}ia_drc_state_struct; + +typedef struct IA_PSM_API_Struct +{ + ia_drc_state_struct *p_state; + ia_drc_config_struct str_config; + ia_drc_payload_struct str_payload; + ia_drc_bits_handler_struct str_bit_handler; + ia_mem_info_struct *p_mem_info; + pVOID *pp_mem; + struct ia_bit_buf_struct str_bit_buf, *pstr_bit_buf; + +} ia_drc_api_struct; + +#endif diff --git a/decoder/drc_src/impd_drc_bitbuffer.c b/decoder/drc_src/impd_drc_bitbuffer.c new file mode 100644 index 0000000..cea9296 --- /dev/null +++ b/decoder/drc_src/impd_drc_bitbuffer.c @@ -0,0 +1,291 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#include + +#include "impd_type_def.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_parser.h" + + +WORD32 impd_read_bits_buf(ia_bit_buf_struct* it_bit_buff, + WORD no_of_bits) +{ + + UWORD32 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + it_bit_buff->error = 0; + + if(it_bit_buff->cnt_bits <= 0) + { + it_bit_buff->error = 1; + return -1; + } + + if (no_of_bits==0){ + return 0; + } + + it_bit_buff->cnt_bits -= no_of_bits; + ret_val = (UWORD32)*ptr_read_next; + + bit_pos -= no_of_bits; + while (bit_pos < 0) { + bit_pos += 8; + ptr_read_next++; + + if(ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + + ret_val <<= 8; + + ret_val |= (UWORD32)*ptr_read_next; + } + + ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); + it_bit_buff->ptr_read_next = ptr_read_next; + it_bit_buff->bit_pos = (WORD16)bit_pos; + return ret_val; +} + +ia_bit_buf_struct* impd_create_bit_buf(ia_bit_buf_struct* it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) +{ + + it_bit_buff->ptr_bit_buf_base = ptr_bit_buf_base; + it_bit_buff->ptr_bit_buf_end = ptr_bit_buf_base + bit_buf_size - 1; + + it_bit_buff->ptr_read_next = ptr_bit_buf_base; + it_bit_buff->bit_pos = 7; + + it_bit_buff->cnt_bits = 0; + it_bit_buff->size = bit_buf_size << 3; + + return it_bit_buff; +} + +ia_bit_buf_struct* impd_create_init_bit_buf(ia_bit_buf_struct* it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) +{ + impd_create_bit_buf(it_bit_buff,ptr_bit_buf_base,bit_buf_size); + it_bit_buff->cnt_bits = (bit_buf_size << 3); + return (it_bit_buff); +} + +WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, + WORD32 sample_rate, + WORD32 frame_size, + WORD32 delay_mode, + WORD32 lfe_channel_map_count, + WORD32* lfe_channel_map) +{ + WORD32 i, err_code = 0; + + 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; + 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 / ia_drc_params_struct->delta_tmin_default; + ia_drc_params_struct->delay_mode = delay_mode; + + if ((frame_size < 1)||(frame_size > AUDIO_CODEC_FRAME_SIZE_MAX)||(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) + { + return -1; + } + + if (lfe_channel_map_count >= 0) + { + if ((lfe_channel_map == NULL) || (lfe_channel_map_count > MAX_CHANNEL_COUNT)) + { + return(-1); + } + + ia_drc_params_struct->lfe_channel_map_count = lfe_channel_map_count; + + for (i=0; ilfe_channel_map[i] = lfe_channel_map[i]; + } + } + else + { + ia_drc_params_struct->lfe_channel_map_count = -1; + + for (i=0; ilfe_channel_map[i] = 0; + } + } + + err_code = impd_init_tbls(ia_drc_params_struct->num_gain_values_max_default, &p_drc_bs_dec_struct->tables_default); + + 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, + WORD32 num_bytes) +{ + WORD32 err_code = 0; + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); + + 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); + + return err_code; +} + + +WORD32 impd_process_drc_bitstream_dec_gain(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_gain_struct *pstr_drc_gain, + UWORD8* bitstream_gain, + WORD32 num_bytes, + WORD32 num_bits_offset, + WORD32* num_bits_read) +{ + WORD32 err_code = 0; + + WORD32 dummy; + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_gain, num_bytes); + + dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); + if(it_bit_buff->error) + return it_bit_buff->error; + + err_code = impd_drc_uni_gain_read( + it_bit_buff, + p_drc_bs_dec_struct, + pstr_drc_config, + pstr_drc_gain); + + if (err_code > PROC_COMPLETE) + return (err_code); + + *num_bits_read = (it_bit_buff->size) - it_bit_buff->cnt_bits; + + if (err_code == PROC_COMPLETE) + { + return err_code; + } + + return 0; +} + + +WORD32 impd_process_drc_bitstream_dec_loudness_info_set(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct *pstr_loudness_info, + UWORD8* bit_stream_loudness, + WORD32 num_bytes_loudness) +{ + WORD32 err_code = 0; + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bit_stream_loudness, num_bytes_loudness); + + err_code = impd_parse_loudness_info_set(it_bit_buff, pstr_loudness_info); + if (err_code) + return(err_code); + + + return 0; +} diff --git a/decoder/drc_src/impd_drc_bitbuffer.h b/decoder/drc_src/impd_drc_bitbuffer.h new file mode 100644 index 0000000..ab0b2c7 --- /dev/null +++ b/decoder/drc_src/impd_drc_bitbuffer.h @@ -0,0 +1,53 @@ +/****************************************************************************** + * + * 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_BITBUFFER_H +#define IMPD_DRC_BITBUFFER_H + + +typedef struct ia_bit_buf_struct +{ + UWORD8 *ptr_bit_buf_base; + UWORD8 *ptr_bit_buf_end; + + UWORD8 *ptr_read_next; + + WORD32 bit_pos; + WORD32 cnt_bits; + + WORD32 size; + WORD32 error; + + +}ia_bit_buf_struct; + + +ia_bit_buf_struct * impd_create_bit_buf(ia_bit_buf_struct* it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); + +ia_bit_buf_struct * impd_create_init_bit_buf(ia_bit_buf_struct* it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); + +WORD32 impd_read_bits_buf(ia_bit_buf_struct* it_bit_buff, + WORD no_of_bits); + + +#endif diff --git a/decoder/drc_src/impd_drc_bitstream_dec_api.h b/decoder/drc_src/impd_drc_bitstream_dec_api.h new file mode 100644 index 0000000..d110d73 --- /dev/null +++ b/decoder/drc_src/impd_drc_bitstream_dec_api.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * 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_BITSTREAM_DEC_API_H +#define IMPD_DRC_BITSTREAM_DEC_API_H + + +WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, + WORD32 sample_rate, + 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, + UWORD8* bitstream_config, + WORD32 num_bytes); + +WORD32 impd_process_drc_bitstream_dec_gain(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_gain_struct* pstr_drc_gain, + UWORD8* bitstream_gain, + WORD32 num_bytes, + WORD32 num_bits_offset, + WORD32* num_bits_read); + +WORD32 impd_process_drc_bitstream_dec_loudness_info_set(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + UWORD8* bitstream_loudness, + WORD32 num_bytes_loudness + ); +#endif + + + diff --git a/decoder/drc_src/impd_drc_common.h b/decoder/drc_src/impd_drc_common.h new file mode 100644 index 0000000..2ae6873 --- /dev/null +++ b/decoder/drc_src/impd_drc_common.h @@ -0,0 +1,221 @@ +/****************************************************************************** + * + * 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_COMMON_H +#define IMPD_DRC_COMMON_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#define EQ_IS_SUPPORTED 1 + +#define MEASURE_AVERAGE_BITRATE 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 DRC_BAND_COUNT_MAX BAND_COUNT_MAX +#define SPLIT_CHARACTERISTIC_COUNT_MAX 8 +#define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX +#define SHAPE_FILTER_COUNT_MAX 8 +#define DRC_SET_ID_COUNT_MAX 16 +#define EQ_SET_ID_COUNT_MAX 8 +#define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX 4 +#define FILTER_ELEMENT_COUNT_MAX 16 +#define REAL_ZERO_RADIUS_ONE_COUNT_MAX 14 +#define REAL_ZERO_COUNT_MAX 64 +#define COMPLEX_ZERO_COUNT_MAX 64 +#define REAL_POLE_COUNT_MAX 16 +#define COMPLEX_POLE_COUNT_MAX 16 +#define FIR_ORDER_MAX 128 +#define EQ_NODE_COUNT_MAX 33 +#define EQ_SUBBAND_GAIN_COUNT_MAX 135 +#define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16 +#define FILTER_BLOCK_COUNT_MAX 16 +#define FILTER_ELEMENT_COUNT_MAX 16 +#define UNIQUE_SUBBAND_GAINS_COUNT_MAX 8 +#define EQ_CHANNEL_GROUP_COUNT_MAX 4 +#define EQ_FILTER_BLOCK_COUNT_MAX 4 +#define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8 +#define EQ_INSTRUCTIONS_COUNT_MAX 8 +#define SELECTED_EQ_SET_COUNT_MAX 2 +#define SUB_EQ_COUNT 2 + +#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 UNIDRCCONFEXT_PARAM_DRC 0x1 + +#define PARAM_DRC_INSTRUCTIONS_COUNT_MAX 8 +#define PARAM_DRC_INSTANCE_COUNT_MAX 8 + +#define PARAM_DRC_TYPE_FF 0x0 +#define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX 9 +#define PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX 64 + +#define PARAM_DRC_TYPE_LIM 0x1 +#define PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT (-1.f) +#define PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT 5 +#define PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT 50 + + +#define UNIDRCCONFEXT_V1 0x2 +#define UNIDRCLOUDEXT_EQ 0x1 +#define UNIDRCINTERFACEEXT_EQ 0x1 + +#define LOUD_EQ_REQUEST_OFF 0x0 +#define LOUD_EQ_REQUEST_LIGHT 0x1 +#define LOUD_EQ_REQUEST_REGULAR 0x2 +#define LOUD_EQ_REQUEST_HEAVY 0x3 + +#define EQ_PURPOSE_EQ_OFF 0 +#define EQ_PURPOSE_DEFAULT (1<<0) +#define EQ_PURPOSE_LARGE_ROOM (1<<1) +#define EQ_PURPOSE_SMALL_SPACE (1<<2) +#define EQ_PURPOSE_AVERAGE_ROOM (1<<3) +#define EQ_PURPOSE_CAR_CABIN (1<<4) +#define EQ_PURPOSE_HEADPHONES (1<<5) +#define EQ_PURPOSE_LATE_NIGHT (1<<6) + + + +#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; + + + FLOAT32 mixing_level; + WORD32 sel_eq_set_ids[SELECTED_EQ_SET_COUNT_MAX]; + WORD32 sel_loud_eq_id; +} ia_drc_sel_proc_output_struct; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_config_params.h b/decoder/drc_src/impd_drc_config_params.h new file mode 100644 index 0000000..252dcce --- /dev/null +++ b/decoder/drc_src/impd_drc_config_params.h @@ -0,0 +1,42 @@ +/****************************************************************************** + * + * 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_CONFIG_PARAMS_H +#define IMPD_DRC_CONFIG_PARAMS_H + + +#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 +#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 +#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 +#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 +#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 +#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 +#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 +#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 +#define IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT 0x0008 +#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 +#define IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY 0x000A +#define IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY 0x000B +#define IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE 0x000C +#define IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF 0x000D +#define IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE 0x000E +#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F +#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 +#endif diff --git a/decoder/drc_src/impd_drc_dec.c b/decoder/drc_src/impd_drc_dec.c new file mode 100644 index 0000000..be4347d --- /dev/null +++ b/decoder/drc_src/impd_drc_dec.c @@ -0,0 +1,378 @@ +/****************************************************************************** + * + * 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 +#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_parametric_drc_dec.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_multi_band.h" + + +WORD32 impd_init_drc_params(WORD32 frame_size, + WORD32 sample_rate, + WORD32 gain_delay_samples, + WORD32 delay_mode, + WORD32 sub_band_domain_mode, + ia_drc_params_struct* ia_drc_params_struct) +{ + WORD32 k; + if (frame_size < 1|| frame_size > AUDIO_CODEC_FRAME_SIZE_MAX) + { + return -1; + } + + if (sample_rate < 1000) + { + return -1; + } + + ia_drc_params_struct->drc_frame_size = frame_size; + + if (ia_drc_params_struct->drc_frame_size < 0.001f * sample_rate) + { + return -1; + } + + ia_drc_params_struct->sample_rate = sample_rate; + + ia_drc_params_struct->delta_tmin_default = impd_get_delta_tmin(sample_rate); + + if (ia_drc_params_struct->delta_tmin_default > ia_drc_params_struct->drc_frame_size) + { + return -1; + } + + if ((delay_mode != DELAY_MODE_REGULAR_DELAY) && (delay_mode != DELAY_MODE_LOW_DELAY)) + { + return -1; + } + + ia_drc_params_struct->delay_mode = delay_mode; + + ia_drc_params_struct->drc_set_counter = 0; + ia_drc_params_struct->multiband_sel_drc_idx = -1; + + for (k = 0; k < SEL_DRC_COUNT; k++) + { + ia_drc_params_struct->sel_drc_array[k].drc_instructions_index = -1; + ia_drc_params_struct->sel_drc_array[k].dwnmix_instructions_index = -1; + ia_drc_params_struct->sel_drc_array[k].drc_coeff_idx = -1; + } + + if ((gain_delay_samples > MAX_SIGNAL_DELAY) || (gain_delay_samples < 0)) + { + return -1; + } + else + { + ia_drc_params_struct->gain_delay_samples = gain_delay_samples; + } + + switch (sub_band_domain_mode) + { + case SUBBAND_DOMAIN_MODE_OFF: + case SUBBAND_DOMAIN_MODE_QMF64: + case SUBBAND_DOMAIN_MODE_QMF71: + case SUBBAND_DOMAIN_MODE_STFT256: + ia_drc_params_struct->sub_band_domain_mode = sub_band_domain_mode; + break; + default: + return -1; + break; + } + + ia_drc_params_struct->parametric_drc_delay = 0; + ia_drc_params_struct->eq_delay = 0; + + return 0; +} + + +WORD32 impd_select_drc_coefficients(ia_drc_config* drc_config, + ia_uni_drc_coeffs_struct** drc_coefficients_drc, + WORD32* drc_coefficients_selected) +{ + WORD32 i; + WORD32 cof1 = -1; + WORD32 cof0 = -1; + for(i=0; idrc_coefficients_drc_count; i++) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[i].drc_location == 1) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[i].version == 0) + { + cof0 = i; + *drc_coefficients_selected = cof0; + } + else + { + cof1 = i; + *drc_coefficients_selected = cof1; + } + } + } + + + if (cof1 >= 0) { + *drc_coefficients_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cof1]); + } + else if (cof0 >= 0) { + *drc_coefficients_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cof0]); + } + else { + *drc_coefficients_drc = NULL; + } + + + return 0; +} + + +WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, + ia_drc_params_struct* ia_drc_params_struct, + ia_parametric_drc_params_struct* p_parametric_drc_params, + WORD32 audio_num_chan, + WORD32 drc_set_id_selected, + WORD32 downmix_id_selected, + ia_filter_banks_struct* ia_filter_banks_struct, + ia_overlap_params_struct* pstr_overlap_params + + , shape_filter_block* shape_filter_block + ) +{ + WORD32 g, n, c, err = 0; + WORD32 channel_count = 0; + WORD32 i; + + ia_drc_instructions_struct* drc_instructions_uni_drc = NULL; + ia_uni_drc_coeffs_struct* drc_coefficients_uni_drc = NULL; + WORD32 selected_drc_is_multiband = 0; + WORD32 drc_instructions_selected = -1; + WORD32 downmix_instructions_selected = -1; + WORD32 drc_coefficients_selected = -1; + p_parametric_drc_params->parametric_drc_instance_count = 0; + + if (drc_config->drc_coefficients_drc_count && drc_config->str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc->drc_frame_size != ia_drc_params_struct->drc_frame_size) + { + return -1; + } + } + + + for(n=0; ndrc_instructions_count_plus; n++) + { + if (drc_config->str_drc_instruction_str[n].drc_set_id == drc_set_id_selected) + break; + } + if (n == drc_config->drc_instructions_count_plus) + { + return -1; + } + drc_instructions_selected = n; + drc_instructions_uni_drc = &(drc_config->str_drc_instruction_str[drc_instructions_selected]); + + if (downmix_id_selected == ID_FOR_BASE_LAYOUT) + { + channel_count = drc_config->channel_layout.base_channel_count; + } + else if (downmix_id_selected == ID_FOR_ANY_DOWNMIX) + { + channel_count = audio_num_chan; + } + else + { + for(n=0; ndwnmix_instructions_count; n++) + { + if (drc_config->dwnmix_instructions[n].downmix_id == downmix_id_selected) + break; + } + if (n == drc_config->dwnmix_instructions_count) + { + return (UNEXPECTED_ERROR); + } + channel_count = drc_config->dwnmix_instructions[n].target_channel_count; + + downmix_instructions_selected = n; + } + drc_instructions_uni_drc->audio_num_chan = channel_count; + + if (drc_instructions_uni_drc->drc_set_id <= 0) + { + drc_coefficients_selected = 0; + } + else + { + err = impd_select_drc_coefficients(drc_config, &drc_coefficients_uni_drc, &drc_coefficients_selected); + } + + ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].drc_instructions_index = drc_instructions_selected; + ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].dwnmix_instructions_index = downmix_instructions_selected; + ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].drc_coeff_idx = drc_coefficients_selected; + + if ((drc_instructions_uni_drc->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (drc_instructions_uni_drc->dwnmix_id_count > 1)) + { + WORD32 idx = drc_instructions_uni_drc->gain_set_index[0]; + for (c=0; caudio_num_chan; c++) + { + drc_instructions_uni_drc->channel_group_of_ch[c] = (idx >= 0) ? 0 : -1; + } + } + + for (g=0; gnum_drc_ch_groups; g++) { + drc_instructions_uni_drc->num_chan_per_ch_group[g] = 0; + for (c=0; caudio_num_chan; c++) { + if (drc_instructions_uni_drc->channel_group_of_ch[c] == g) { + drc_instructions_uni_drc->num_chan_per_ch_group[g]++; + } + } + } + + if (drc_instructions_uni_drc->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) { + drc_instructions_uni_drc->multiband_audio_sig_count = drc_instructions_uni_drc->audio_num_chan; + } else { + drc_instructions_uni_drc->multiband_audio_sig_count = 0; + for (c=0; caudio_num_chan; c++) { + g = drc_instructions_uni_drc->channel_group_of_ch[c]; + if (g < 0) { + drc_instructions_uni_drc->multiband_audio_sig_count++; + } else { + drc_instructions_uni_drc->multiband_audio_sig_count += drc_instructions_uni_drc->band_count_of_ch_group[g]; + } + } + } + + for (g=0; gnum_drc_ch_groups; g++) + { + if (g==0) { + drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max = 0; + } + if (drc_instructions_uni_drc->ch_group_parametric_drc_flag[g] == 0) { + if (drc_instructions_uni_drc->band_count_of_ch_group[g] > 1) + { + if (ia_drc_params_struct->multiband_sel_drc_idx != -1) + { + return (UNEXPECTED_ERROR); + } + selected_drc_is_multiband = 1; + } + } else { + WORD32 gain_set_index = drc_instructions_uni_drc->gain_set_idx_of_ch_group_parametric_drc[g]; + WORD32 parametric_drc_id = drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].parametric_drc_id; + WORD32 parametric_drc_look_ahead_samples = 0; + ia_parametric_drc_instructions_struct* str_parametric_drc_instructions; + + for(i=0; istr_drc_config_ext.parametric_drc_instructions_count; i++) + { + if (parametric_drc_id == drc_config->str_drc_config_ext.str_parametric_drc_instructions[i].parametric_drc_id) break; + } + if (i == drc_config->str_drc_config_ext.parametric_drc_instructions_count) + { + return (UNEXPECTED_ERROR); + } + str_parametric_drc_instructions = &drc_config->str_drc_config_ext.str_parametric_drc_instructions[i]; + + p_parametric_drc_params->parametric_drc_idx[p_parametric_drc_params->parametric_drc_instance_count] = i; + p_parametric_drc_params->gain_set_index[p_parametric_drc_params->parametric_drc_instance_count] = gain_set_index; + if (drc_instructions_uni_drc->drc_apply_to_dwnmix == 0) { + p_parametric_drc_params->dwnmix_id_from_drc_instructions[p_parametric_drc_params->parametric_drc_instance_count] = ID_FOR_BASE_LAYOUT; + } else { + if (drc_instructions_uni_drc->dwnmix_id_count > 1) { + p_parametric_drc_params->dwnmix_id_from_drc_instructions[p_parametric_drc_params->parametric_drc_instance_count] = ID_FOR_ANY_DOWNMIX; + } else { + p_parametric_drc_params->dwnmix_id_from_drc_instructions[p_parametric_drc_params->parametric_drc_instance_count] = drc_instructions_uni_drc->downmix_id[0]; + } + } + p_parametric_drc_params->audio_num_chan = channel_count; + for (i=0; iaudio_num_chan;i++) { + if (drc_instructions_uni_drc->channel_group_of_ch[i] == g) { + p_parametric_drc_params->channel_map[p_parametric_drc_params->parametric_drc_instance_count][i] = 1; + } else { + p_parametric_drc_params->channel_map[p_parametric_drc_params->parametric_drc_instance_count][i] = 0; + } + } + drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g] = 0; + if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) { + parametric_drc_look_ahead_samples = (WORD32)((FLOAT32)str_parametric_drc_instructions->parametric_drc_look_ahead*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); + } else { + if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + parametric_drc_look_ahead_samples = (WORD32)(10.0f*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) + { + parametric_drc_look_ahead_samples = (WORD32)(5.0f*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); + } else + { + return (UNEXPECTED_ERROR); + } + } + drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g] = parametric_drc_look_ahead_samples; + if (drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max < drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g]) + { + drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max = drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g]; + } + p_parametric_drc_params->parametric_drc_instance_count += 1; + selected_drc_is_multiband = 0; + } + } + ia_drc_params_struct->parametric_drc_delay += drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max; + + if (selected_drc_is_multiband == 1) + { + ia_drc_params_struct->multiband_sel_drc_idx = ia_drc_params_struct->drc_set_counter; + err = impd_init_all_filter_banks(drc_coefficients_uni_drc, + &(drc_config->str_drc_instruction_str[drc_instructions_selected]), + ia_filter_banks_struct); + if (err) + return (err); + + err = impd_init_overlap_weight (drc_coefficients_uni_drc, + &(drc_config->str_drc_instruction_str[drc_instructions_selected]), + ia_drc_params_struct->sub_band_domain_mode, + pstr_overlap_params); + if (err) + return (err); + } + else + { + ia_gain_modifiers_struct* gain_modifiers = drc_config->str_drc_instruction_str->str_gain_modifiers_of_ch_group; + for (g=0; gnum_drc_ch_groups; g++) + { + if (gain_modifiers[g].shape_filter_flag == 1) + { + impd_shape_filt_block_init(&drc_coefficients_uni_drc->str_shape_filter_block_params[gain_modifiers[g].shape_filter_idx], + &shape_filter_block[g]); + } + else + { + shape_filter_block[g].shape_flter_block_flag = 0; + } + } + } + + ia_drc_params_struct->drc_set_counter++; + + return (0); +} diff --git a/decoder/drc_src/impd_drc_dec.h b/decoder/drc_src/impd_drc_dec.h new file mode 100644 index 0000000..c44cf14 --- /dev/null +++ b/decoder/drc_src/impd_drc_dec.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * 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_DEC_H +#define IMPD_DRC_DEC_H + +WORD32 impd_init_drc_params(WORD32 frame_size, + WORD32 sample_rate, + WORD32 gain_delay_samples, + WORD32 delay_mode, + WORD32 sub_band_domain_mode, + ia_drc_params_struct* ia_drc_params_struct); + + +WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, + ia_drc_params_struct* ia_drc_params_struct, + ia_parametric_drc_params_struct* p_parametricdrc_params, + WORD32 audio_num_chan, + WORD32 drc_set_id_selected, + WORD32 downmix_id_selected, + ia_filter_banks_struct* ia_filter_banks_struct, + ia_overlap_params_struct* pstr_overlap_params + + , shape_filter_block* shape_filter_block + ); + +WORD32 impd_apply_gains_and_add(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, + shape_filter_block shape_filter_block[], + FLOAT32* deinterleaved_audio[], + + FLOAT32* channel_audio[], + WORD32 impd_apply_gains); + + +#endif diff --git a/decoder/drc_src/impd_drc_definitions.h b/decoder/drc_src/impd_drc_definitions.h new file mode 100644 index 0000000..9ca6a2f --- /dev/null +++ b/decoder/drc_src/impd_drc_definitions.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * + * 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_DEFINITIONS_H +#define IMPD_DRC_DEFINITIONS_H + + + +#define LIBNAME "IA_DRC" +#define LIB_APIVERSION 1 + + +#define IA_DRC_PERSIST_IDX (0) +#define IA_DRC_SCRATCH_IDX (1) +#define IA_DRC_INPUT_IDX (2) +#define IA_DRC_OUTPUT_IDX (3) + +#define FRAME_SIZE 512 + +#endif diff --git a/decoder/drc_src/impd_drc_dynamic_payload.c b/decoder/drc_src/impd_drc_dynamic_payload.c new file mode 100644 index 0000000..99661e7 --- /dev/null +++ b/decoder/drc_src/impd_drc_dynamic_payload.c @@ -0,0 +1,1527 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include "impd_type_def.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_parser.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_rom.h" + +WORD32 impd_parse_loud_eq_instructions(ia_bit_buf_struct* it_bit_buff, + ia_loud_eq_instructions_struct* loud_eq_instructions); + +WORD32 impd_parse_eq_coefficients(ia_bit_buf_struct* it_bit_buff, + ia_eq_coeff_struct* str_eq_coeff); + +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 impd_dec_initial_gain(ia_bit_buf_struct* it_bit_buff, + const WORD32 gain_coding_profile, + FLOAT32* initial_gain) +{ + WORD32 sign, magn,bit_2_extract; + switch (gain_coding_profile) + { + case GAIN_CODING_PROFILE_REGULAR: + sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + magn = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + *initial_gain = magn * 0.125f; + if (sign) *initial_gain = - *initial_gain; + break; + case GAIN_CODING_PROFILE_FADING: + case GAIN_CODING_PROFILE_CLIPPING: + bit_2_extract= (gain_coding_profile==GAIN_CODING_PROFILE_FADING )?10:8; + sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (sign==0) *initial_gain = 0.0f; + else + { + magn = impd_read_bits_buf(it_bit_buff, bit_2_extract); + if(it_bit_buff->error) + return it_bit_buff->error; + *initial_gain = - (magn + 1) * 0.125f; + } + break; + + case GAIN_CODING_PROFILE_CONSTANT: + break; + default: + return(UNEXPECTED_ERROR); + } + return (0); +} + +WORD32 impd_dec_gains(ia_bit_buf_struct* it_bit_buff, + WORD32 no_nodes, + WORD32 gain_coding_profile, + ia_node_struct* str_node) +{ + WORD32 err = 0, k, e, m; + WORD32 bit; + WORD32 num_bits_read; + WORD32 code; + WORD32 code_found; + FLOAT32 drc_gain_delta = 0; + const ia_delta_gain_code_table_struct *ptr_delta_gain_code_table; + WORD32 no_delta_gain_entries; + + err = impd_dec_initial_gain(it_bit_buff, gain_coding_profile, &(str_node[0].loc_db_gain)); + if (err) return(err); + + impd_get_delta_gain_code_tbl(gain_coding_profile, &ptr_delta_gain_code_table, &no_delta_gain_entries); + for (k=1; kerror) + return it_bit_buff->error; + code = (code << 1) + bit; + num_bits_read++; + } + while (num_bits_read == ptr_delta_gain_code_table[e].size) + { + if (code == ptr_delta_gain_code_table[e].code) + { + drc_gain_delta = ptr_delta_gain_code_table[e].value; + code_found = 1; + break; + } + e++; + } + } + if (code_found == 0) + { + return (UNEXPECTED_ERROR); + } + str_node[k].loc_db_gain = str_node[k-1].loc_db_gain + drc_gain_delta; + } + return (0); +} + +WORD32 impd_dec_slopes(ia_bit_buf_struct* it_bit_buff, + WORD32* no_nodes, + WORD32 gain_interpolation_type, + ia_node_struct* str_node) +{ + WORD32 k, e, m, bit; + WORD32 code; + WORD32 code_found; + FLOAT32 slope_value = 0; + bool end_marker = 0; + WORD32 num_bits_read; + const ia_slope_code_table_struct* ptr_slope_code_table; + WORD32 no_slope_code_entries; + + ptr_slope_code_table = &(slope_code_tbl_entries_by_size[0]); + no_slope_code_entries = NUM_SLOPE_TBL_ENTRIES; + + + k=0; + while(end_marker != 1) + { + k++; + end_marker = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + *no_nodes = k; + + if (gain_interpolation_type == GAIN_INTERPOLATION_TYPE_SPLINE) + { + for (k=0; k<*no_nodes; k++) + { + num_bits_read = 0; + code = 0; + code_found = 0; + e = 0; + while ((e < no_slope_code_entries) && (!code_found)) + { + for (m=0; merror) + return it_bit_buff->error; + code = (code << 1) + bit; + num_bits_read++; + } + while (num_bits_read == ptr_slope_code_table[e].size) + { + if (code == ptr_slope_code_table[e].code) + { + slope_value = ptr_slope_code_table[e].value; + code_found = 1; + break; + } + e++; + } + } + str_node[k].slope = slope_value; + } + } + else + { + for (k=0; k<*no_nodes; k++) + { + str_node[k].slope = 0.0f; + } + } + return(0); +} + +WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, + ia_tables_struct* str_tables, + WORD32 num_nodes, + WORD32 delta_tmin, + WORD32 drc_frame_size, + WORD32 full_frame, + WORD32 time_offset, + ia_node_struct* str_node) +{ + WORD32 k, e, m; + WORD32 bit; + WORD32 num_bits_read; + WORD32 code; + WORD32 code_found = 0; + WORD32 time_delta = 0; + WORD32 time_offs = time_offset; + ia_delta_time_code_table_entry_struct* delta_time_code_table = str_tables->delta_time_code_table; + bool frame_end_flag; + WORD32 node_time_tmp; + bool node_res_flag; + WORD32 exit_cnt; + if (full_frame == 0) + { + frame_end_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + frame_end_flag = 1; + } + + if (frame_end_flag == 1) + { + node_res_flag = 0; + for (k=0; k 100000) { + return -1; + } + for (m=0; merror) + return it_bit_buff->error; + code = (code << 1) + bit; + num_bits_read++; + } + while (num_bits_read == delta_time_code_table[e].size) + { + if (code == delta_time_code_table[e].code) + { + time_delta = delta_time_code_table[e].value; + code_found = 1; + break; + } + e++; + } + } + node_time_tmp = time_offs + time_delta * delta_tmin; + if (node_time_tmp > drc_frame_size + time_offset) + { + if (node_res_flag == 0) + { + str_node[k].time = drc_frame_size + time_offset; + node_res_flag = 1; + } + str_node[k+1].time = node_time_tmp; + } + else + { + str_node[k].time = node_time_tmp; + } + time_offs = node_time_tmp; + } + if (node_res_flag == 0) + { + str_node[k].time = drc_frame_size + time_offset; + } + } + else + { + for (k=0; k 100000) { + return(BITSTREAM_ERROR); + } + for (m=0; merror) + return it_bit_buff->error; + code = (code << 1) + bit; + num_bits_read++; + } + while (num_bits_read == delta_time_code_table[e].size) + { + if (code == delta_time_code_table[e].code) + { + time_delta = delta_time_code_table[e].value; + code_found = 1; + break; + } + e++; + } + } + str_node[k].time = time_offs + time_delta * delta_tmin; + time_offs = str_node[k].time; + } + } + return (0); +} + +WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_drc_config* drc_config, + ia_drc_gain_struct* pstr_uni_drc_gain) +{ + WORD32 err = 0; + WORD32 seq; + static WORD32 pkt_loss_frame_cnt = 0; + ia_spline_nodes_struct* str_spline_nodes = {0}; + + { + WORD32 gain_sequence_count = drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_sequence_count; + + for (seq=0; seqstr_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]); + if (gain_set_params->gain_coding_profile == GAIN_CODING_PROFILE_CONSTANT) + { + str_spline_nodes = &(pstr_uni_drc_gain->drc_gain_sequence[seq].str_spline_nodes[0]); + str_spline_nodes->num_nodes = 1; + str_spline_nodes->str_node[0].slope = 0.0; + str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size - 1; + str_spline_nodes->str_node[0].loc_db_gain = 0.0f; + } + else + { + err = impd_parse_drc_gain_sequence( it_bit_buff, pstr_drc_uni_bs_dec, gain_set_params, &(pstr_uni_drc_gain->drc_gain_sequence[seq])); + if (err) return(err); + } + } + } + + if (it_bit_buff->ptr_bit_buf_base == NULL) + { + pkt_loss_frame_cnt++; + + if (pkt_loss_frame_cnt*(FLOAT32)pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size/drc_config->sampling_rate > MAXPACKETLOSSTIME) + { + drc_config->apply_drc = 0; + } + } + else + { + pstr_uni_drc_gain->uni_drc_gain_ext_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_uni_drc_gain->uni_drc_gain_ext_flag == 1) + { + err = impd_parse_uni_drc_gain_ext(it_bit_buff, &(pstr_uni_drc_gain->uni_drc_gain_ext)); + if (err) return(err); + } + pkt_loss_frame_cnt = 0; + drc_config->apply_drc = 1; + } + + return(0); +} + +WORD32 impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, + ia_uni_drc_gain_ext_struct* uni_drc_gain_ext) +{ + WORD32 i, k; + WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; + + k = 0; + uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(uni_drc_gain_ext->uni_drc_gain_ext_type[k] != UNIDRCGAINEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + uni_drc_gain_ext->ext_bit_size[k] = bit_size + 1; + + switch(uni_drc_gain_ext->uni_drc_gain_ext_type[k]) + { + default: + for(i = 0; iext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); +} + +WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_spline_nodes_struct* str_spline_nodes) +{ + WORD32 err = 0; + WORD32 time_offset; + if (gain_set_params->time_alignment==0) { + time_offset = -1; + } + else + { + if (gain_set_params->time_delt_min_flag) + { + time_offset = - gain_set_params->time_delt_min_val + (gain_set_params->time_delt_min_val-1)/2; + } + else + { + time_offset = - pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default + (pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default-1)/2; + + } + } + + if(it_bit_buff->ptr_bit_buf_base == NULL) + { + 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; + + str_spline_nodes->num_nodes = 1; + + if (prev_db_gain < 0) + { + str_spline_nodes->str_node[0].loc_db_gain = prev_db_gain; + } + else + { + str_spline_nodes->str_node[0].loc_db_gain = 0.f; + } + + str_spline_nodes->str_node[0].slope = 0.0; + str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size + time_offset; + } + else + { + str_spline_nodes->drc_gain_coding_mode = impd_read_bits_buf(it_bit_buff, 1); + if (it_bit_buff->error == PROC_COMPLETE) + { + str_spline_nodes->drc_gain_coding_mode = 0; + str_spline_nodes->str_node[0].slope = 0.0; + str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size + time_offset; + str_spline_nodes->str_node[0].loc_db_gain = str_spline_nodes->str_node[str_spline_nodes->num_nodes-1].loc_db_gain; + str_spline_nodes->num_nodes = 1; + } + else + { + if (it_bit_buff->error) + return(it_bit_buff->error); + } + if (str_spline_nodes->drc_gain_coding_mode == 0) + { + str_spline_nodes->num_nodes = 1; + + err = impd_dec_initial_gain(it_bit_buff, gain_set_params->gain_coding_profile, &(str_spline_nodes->str_node[0].loc_db_gain)); + if (err) return(err); + + str_spline_nodes->str_node[0].slope = 0.0; + str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size + time_offset; + } + else + { + err = impd_dec_slopes(it_bit_buff, &str_spline_nodes->num_nodes, gain_set_params->gain_interpolation_type, str_spline_nodes->str_node); + if (err) return(err); + if (gain_set_params->time_delt_min_flag) + { + err = impd_dec_times(it_bit_buff, &gain_set_params->str_tables, str_spline_nodes->num_nodes, gain_set_params->time_delt_min_val, (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size, gain_set_params->full_frame, time_offset, str_spline_nodes->str_node); + if (err) return(err); + err = impd_dec_gains(it_bit_buff, + str_spline_nodes->num_nodes, + gain_set_params->gain_coding_profile, + str_spline_nodes->str_node); + if (err) return(err); + } + else + { + err = impd_dec_times(it_bit_buff, &pstr_drc_uni_bs_dec->tables_default, str_spline_nodes->num_nodes, (pstr_drc_uni_bs_dec->ia_drc_params_struct).delta_tmin_default, (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size, gain_set_params->full_frame, time_offset, str_spline_nodes->str_node); + if (err) return(err); + err = impd_dec_gains(it_bit_buff, + str_spline_nodes->num_nodes, + gain_set_params->gain_coding_profile, + str_spline_nodes->str_node); + if (err) return(err); + } + + } + } + return(0); +} + +WORD32 impd_parse_drc_gain_sequence(ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_drc_gain_sequence_struct* drc_gain_sequence) +{ + WORD32 err = 0, i; + WORD32 prev_frame_time_buf[NODE_COUNT_MAX], cur_frame_time_buf[NODE_COUNT_MAX]; + WORD32 num_nodes_node_reservoir, num_nodes_cur, k, m; + + if (((pstr_drc_uni_bs_dec->ia_drc_params_struct).delay_mode == DELAY_MODE_LOW_DELAY) && (gain_set_params->full_frame == 0)) + { + return (PARAM_ERROR); + } + i=0; + { + err = impd_parse_spline_nodes( it_bit_buff, pstr_drc_uni_bs_dec, gain_set_params, &(drc_gain_sequence->str_spline_nodes[i])); + if (err) return(err); + + num_nodes_node_reservoir = 0; + num_nodes_cur = 0; + for (k = 0; k < drc_gain_sequence->str_spline_nodes[i].num_nodes; k++){ + if(drc_gain_sequence->str_spline_nodes[i].str_node[k].time >= pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size){ + prev_frame_time_buf[num_nodes_node_reservoir] = drc_gain_sequence->str_spline_nodes[i].str_node[k].time; + num_nodes_node_reservoir++; + } + else{ + cur_frame_time_buf[num_nodes_cur] = drc_gain_sequence->str_spline_nodes[i].str_node[k].time; + num_nodes_cur++; + } + } + 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; + } + for (m = 0; m < num_nodes_cur; m++, k++){ + drc_gain_sequence->str_spline_nodes[i].str_node[k].time = cur_frame_time_buf[m]; + } + } + return(0); +} +WORD32 impd_parse_drc_ext_v1(ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config, + ia_drc_config_ext* str_drc_config_ext) +{ + WORD32 dwnmix_instructions_v1_flag; + WORD32 dwnmix_instructions_v1_count; + WORD32 drc_coeffs_and_instructions_uni_drc_v1_flag; + WORD32 drc_coefficients_uni_drc_v1_count; + WORD32 drc_instructions_uni_drc_v1_count; + + WORD32 i = 0, err = 0; + const WORD32 version = 1; + + dwnmix_instructions_v1_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (dwnmix_instructions_v1_flag == 1) + { + dwnmix_instructions_v1_count = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; ichannel_layout, &drc_config->dwnmix_instructions[i + drc_config->dwnmix_instructions_count]); + if (err) return(err); + } + drc_config->dwnmix_instructions_count += dwnmix_instructions_v1_count; + } + + drc_coeffs_and_instructions_uni_drc_v1_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (drc_coeffs_and_instructions_uni_drc_v1_flag == 1) + { + drc_coefficients_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; istr_p_loc_drc_coefficients_uni_drc[i + drc_config->drc_coefficients_drc_count]); + if (err) return(err); + } + drc_config->drc_coefficients_drc_count += drc_coefficients_uni_drc_v1_count; + + drc_instructions_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; istr_drc_instruction_str[i + drc_config->drc_instructions_uni_drc_count]); + if (err) return(err); + } + drc_config->drc_instructions_uni_drc_count += drc_instructions_uni_drc_v1_count; + } + + str_drc_config_ext->loud_eq_instructions_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + 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(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; iloud_eq_instructions_count; i++) + { + err = impd_parse_loud_eq_instructions(it_bit_buff, &str_drc_config_ext->loud_eq_instructions[i]); + if (err) return(err); + } + } + else + { + str_drc_config_ext->loud_eq_instructions_count = 0; + } + + str_drc_config_ext->eq_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_config_ext->eq_flag == 1) + { + err = impd_parse_eq_coefficients( it_bit_buff, &str_drc_config_ext->str_eq_coeff); + if (err) return(err); + str_drc_config_ext->eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; ieq_instructions_count; i++) + { + err = impd_parse_eq_instructions(it_bit_buff, drc_config, &str_drc_config_ext->str_eq_instructions[i]); + if (err) return(err); + } + } + return 0; +} + + + + +WORD32 impd_parse_filt_block(ia_bit_buf_struct* it_bit_buff, + ia_filt_block_struct* str_filter_block, + WORD32 block_count) +{ +// WORD32 err = 0; + WORD32 k,j,temp; + ia_filt_ele_struct* str_filter_element; + + for (j=0; jfilter_element_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_filter_element=&str_filter_block->str_filter_element[0]; + for (k=0; kfilter_element_count; k++) + { + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_filter_element->filt_ele_idx= (temp&0x7E)>>1; + str_filter_element->filt_ele_gain_flag = temp&1;; + + if (str_filter_element->filt_ele_gain_flag) + { + WORD32 bs_filter_element_gain; + bs_filter_element_gain = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; + str_filter_element->filt_ele_gain = bs_filter_element_gain * 0.125f - 96.0f; + } + + str_filter_element++; + } + str_filter_block++; + } + return(0); +} + +WORD32 impd_parse_unique_td_filt_ele(ia_bit_buf_struct* it_bit_buff, + ia_unique_td_filt_element* unique_td_filt_ele, + WORD32 td_filter_element_count) +{ + WORD32 m, sign, j, temp; + FLOAT32 tmp; + + for (j=0; jeq_filter_format = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (unique_td_filt_ele->eq_filter_format == 0) + { + WORD32 bs_real_zero_radius, bs_generic_zero_radius, bs_generic_zero_angle; + WORD32 bs_real_pole_radius, bs_cmplx_pole_radius, bs_cmplx_pole_angle; + WORD32 bs_real_zero_radius_one_count; + + temp = impd_read_bits_buf(it_bit_buff, 23); + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_real_zero_radius_one_count=(temp>>20)&7; + + unique_td_filt_ele->bs_real_zero_radius_one_count = 2 * bs_real_zero_radius_one_count; + unique_td_filt_ele->real_zero_count = (temp&0xFC000)>>14; + + unique_td_filt_ele->generic_zero_count = (temp& 0x3F00)>>8; + + unique_td_filt_ele->real_pole_count = (temp&0xF0)>>4; + + unique_td_filt_ele->cmplx_pole_count = temp& 0xF; + + + temp= impd_read_bits_buf(it_bit_buff, unique_td_filt_ele->bs_real_zero_radius_one_count); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (m=unique_td_filt_ele->bs_real_zero_radius_one_count-1; m>=0; m--) + { + unique_td_filt_ele->zero_sign[m] =(temp &1); + temp=temp>>1; + } + + + for (m=0; mreal_zero_count; m++) + { + temp= impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_real_zero_radius = (temp&0xFE)>>1; + + sign = temp&0x01; + + tmp = 1.0f - zero_pole_radius_tbl[bs_real_zero_radius]; + + sign=sign<<1; + + unique_td_filt_ele->real_zero_radius[m] = (1-sign)*tmp; + } + for (m=0; mgeneric_zero_count; m++) + { + temp=impd_read_bits_buf(it_bit_buff, 14); + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_generic_zero_radius = (temp&0x3F80)>>7; + + unique_td_filt_ele->generic_zero_radius[m] = 1.0f - zero_pole_radius_tbl[bs_generic_zero_radius]; + + bs_generic_zero_angle = (temp&0x7F); + + unique_td_filt_ele->generic_zero_angle[m] = zero_pole_angle_tbl[bs_generic_zero_angle]; + } + for (m=0; mreal_pole_count; m++) + { + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_real_pole_radius = (temp&0xFE)>>1; + + sign = temp&0x01; + + tmp = 1.0f - zero_pole_radius_tbl[bs_real_pole_radius]; + + sign=sign<<1; + + unique_td_filt_ele->real_pole_radius[m] = (1-sign)*tmp; + } + for (m=0; mcmplx_pole_count; m++) + { + temp= impd_read_bits_buf(it_bit_buff, 14); + + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_cmplx_pole_radius = (temp&0x3F80)>>7; + + unique_td_filt_ele->complex_pole_radius[m] = 1.0f - zero_pole_radius_tbl[bs_cmplx_pole_radius]; + + bs_cmplx_pole_angle = (temp&0x7F); + + unique_td_filt_ele->complex_pole_angle[m] = zero_pole_angle_tbl[bs_cmplx_pole_angle]; + } + } + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + unique_td_filt_ele->fir_filt_order = (temp&0xFE)>>1; + + unique_td_filt_ele->fir_symmetry = temp&0x01; + + for (m=0; mfir_filt_order/2+1; m++) + { + WORD32 sign, bs_fir_coeff; + FLOAT32 tmp; + + temp= impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + sign = (temp>>10)&0x01; + + bs_fir_coeff = temp&0x03FF; + + tmp = (FLOAT32)pow(10.0f, -0.05f * bs_fir_coeff * 0.0625f); + + sign=sign<<1; + + unique_td_filt_ele->fir_coeff[m] = (1-sign)*tmp; + } + } + unique_td_filt_ele++; + } + return(0); +} + +WORD32 impd_decode_eq_slope_code(ia_bit_buf_struct* it_bit_buff, + FLOAT32* eq_slope, + WORD32 num_eq_nodes) +{ + WORD32 bits = 0; + WORD32 k; + + for (k=0; kerror) + return it_bit_buff->error; + if (bits == 0x1) { + *eq_slope = 0.0f; + } + else { + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_slope = eq_slope_tbl[bits]; + } + eq_slope++; + + } + return(0); +} + + + +WORD32 +impd_decode_gain_initial_code(ia_bit_buf_struct* it_bit_buff, + FLOAT32* eq_gain_initial) +{ + WORD32 bits,bits1; + + bits1 = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + + switch (bits1) { + case 0x0: + bits = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_gain_initial = 0.5f * bits - 8.0f; + break; + case 0x1: + case 0x2: + + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + if (bits<8) { + *eq_gain_initial = bits1*bits - bits1*16.0f; + } + else { + *eq_gain_initial = (FLOAT32)bits1*bits; + } + break; + + case 0x3: + bits = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_gain_initial = 4.0f * bits - 64.0f; + break; + + default: + break; + } + return(0); +} + + + +WORD32 impd_parse_eq_subband_gain_spline(ia_bit_buf_struct* it_bit_buff, + ia_eq_subband_gain_spline_struct* str_eq_subband_gain_spline, + WORD32 eq_subband_gains_count) +{ + WORD32 err=0, eq_nodes_cnt, j,k, bits, *eq_freq_delta; + FLOAT32 *peq_gain_delta; + + for (j=0; jerror) + return it_bit_buff->error; + + str_eq_subband_gain_spline->num_eq_nodes = eq_nodes_cnt + 2; + + + err = impd_decode_eq_slope_code(it_bit_buff, &(str_eq_subband_gain_spline->eq_slope[0]),str_eq_subband_gain_spline->num_eq_nodes); + if (err) return (err); + + eq_freq_delta=&(str_eq_subband_gain_spline->eq_freq_delta[1]); + for (k=1; knum_eq_nodes; k++) + { + + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_freq_delta = bits+1; + eq_freq_delta++; + + } + + err = impd_decode_gain_initial_code( it_bit_buff, &(str_eq_subband_gain_spline->eq_gain_initial)); + if (err) + return (err); + + peq_gain_delta=&(str_eq_subband_gain_spline->eq_gain_delta[1]); + for (k=1; knum_eq_nodes; k++) + { + + bits = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + *peq_gain_delta = eq_gain_delta_tbl[bits]; + peq_gain_delta++; + + } + str_eq_subband_gain_spline++; + } + return (0); +} + +WORD32 impd_parse_eq_subband_gain_vector(ia_bit_buf_struct* it_bit_buff, + const WORD32 eq_subband_gain_count, + ia_eq_subband_gain_vector* str_eq_subband_gain_vector, + WORD32 eq_subband_gains_count) +{ + WORD32 m,k,temp; + + for (k=0; kerror) + return it_bit_buff->error; + + sign= (temp>>8)&1; + bs_eq_subband_gain = temp & 0x7F; + + sign=sign<<1; + str_eq_subband_gain_vector->eq_subband_gain[m] = ((1-sign)*bs_eq_subband_gain) * 0.125f; + } + str_eq_subband_gain_vector++; + } + return (0); +} + +WORD32 impd_parse_eq_coefficients(ia_bit_buf_struct* it_bit_buff, + ia_eq_coeff_struct* str_eq_coeff) +{ + WORD32 err = 0; + WORD32 eq_gain_cnt, mu, nu,temp; + WORD32 subband_gain_len_tbl[7]={0,32,39,64,71,128,135}; + + str_eq_coeff->eq_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_coeff->eq_delay_max_present) + { + mu = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + nu = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_delay_max = 16 * mu * (1<unique_filter_block_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + + err = impd_parse_filt_block (it_bit_buff, &(str_eq_coeff->str_filter_block[0]),str_eq_coeff->unique_filter_block_count); + if (err) + return(err); + + str_eq_coeff->unique_td_filter_element_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + + err = impd_parse_unique_td_filt_ele ( it_bit_buff, &(str_eq_coeff->unique_td_filt_ele[0]),str_eq_coeff->unique_td_filter_element_count); + if (err) + return(err); + + str_eq_coeff->unique_eq_subband_gains_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_coeff->unique_eq_subband_gains_count>0) + { + temp=impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_subband_gain_representation = (temp>>4)&0x01; + + str_eq_coeff->eq_subband_gain_format = temp&0x0F; + + if (str_eq_coeff->eq_subband_gain_format==GAINFORMAT_UNIFORM) + { + eq_gain_cnt = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_subband_gain_count = eq_gain_cnt + 1; + + } + else + str_eq_coeff->eq_subband_gain_count=subband_gain_len_tbl[str_eq_coeff->eq_subband_gain_format]; + + + + if (str_eq_coeff->eq_subband_gain_representation == 1) + { + + err = impd_parse_eq_subband_gain_spline( it_bit_buff, &(str_eq_coeff->str_eq_subband_gain_spline[0]),str_eq_coeff->unique_eq_subband_gains_count); + if (err) + return(err); + } + else + { + + err = impd_parse_eq_subband_gain_vector( it_bit_buff, str_eq_coeff->eq_subband_gain_count, &(str_eq_coeff->str_eq_subband_gain_vector[0]),str_eq_coeff->unique_eq_subband_gains_count); + if (err) + return(err); + + } + } + + return(0); +} + + + +WORD32 impd_parser_td_filter_cascade (ia_bit_buf_struct* it_bit_buff, + ia_eq_instructions_struct* str_eq_instructions, + ia_td_filter_cascade_struct* str_td_filter_cascade) +{ + //WORD32 err=0, + WORD32 i, ii, k; + WORD32 eq_cascade_gain; + ia_filter_block_refs_struct* str_filter_block_refs=&(str_td_filter_cascade->str_filter_block_refs[0]); + + for (i=0; ieq_ch_group_count; i++) + { + str_td_filter_cascade->eq_cascade_gain_present[i] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_td_filter_cascade->eq_cascade_gain_present[i]) { + eq_cascade_gain = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; + str_td_filter_cascade->eq_cascade_gain[i] = 0.125f * eq_cascade_gain - 96.0f; + } + else + { + str_td_filter_cascade->eq_cascade_gain[i] = 0.0f; + } + + + str_filter_block_refs->filter_block_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (ii=0; iifilter_block_count; ii++) + { + str_filter_block_refs->filter_block_index[ii] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_filter_block_refs++; + } + + str_td_filter_cascade->eq_phase_alignment_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_td_filter_cascade->eq_phase_alignment_present) + { + + for (i=0; ieq_ch_group_count; i++) + { + for (k=i+1; keq_ch_group_count; k++) + { + str_td_filter_cascade->eq_phase_alignment[i][k] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + } + + } + else + { + for (i=0; ieq_ch_group_count; i++) + { + for (k=i+1; keq_ch_group_count; k++) + str_td_filter_cascade->eq_phase_alignment[i][k] = 1; + + } + } + + + return(0); +} + + +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 dmix_id_present, additional_dmix_id_present, additional_dmix_id_cnt=0; + WORD32 additional_drc_set_id_present, additional_drc_set_id_cnt; + + temp=impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->eq_set_id = (temp>>5)&0x3F; + + str_eq_instructions->eq_set_complexity_level = (temp>>1)&0x0F; + + dmix_id_present = temp&0x01; + + if (dmix_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->downmix_id[0] = (temp>>2)&0x7F; + + str_eq_instructions->eq_apply_to_downmix = (temp>>1)&0x01; + + additional_dmix_id_present = temp&0x01; + + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + str_eq_instructions->downmix_id[0] = 0; + } + + str_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; + + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; + + additional_drc_set_id_present = temp&0x01; + + if (additional_drc_set_id_present) + { + additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + else + { + additional_drc_set_id_cnt = 0; + } + str_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; + + temp=impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->eq_set_purpose =(temp>>1)&0xFFFF; + + str_eq_instructions->depends_on_eq_set_present = temp&0x01; + + if (str_eq_instructions->depends_on_eq_set_present) + { + str_eq_instructions->depends_on_eq_set = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + str_eq_instructions->no_independent_eq_use = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + str_eq_instructions->eq_channel_count = channel_count = drc_config->channel_layout.base_channel_count; + + if ((dmix_id_present == 1) && (str_eq_instructions->eq_apply_to_downmix == 1) && + (str_eq_instructions->downmix_id[0] != 0) && (str_eq_instructions->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_eq_instructions->dwnmix_id_count==1)) + { + for(i=0; idwnmix_instructions_count; i++) + { + if (str_eq_instructions->downmix_id[0] == drc_config->dwnmix_instructions[i].downmix_id) + break; + } + if (i == drc_config->dwnmix_instructions_count) + { + return UNEXPECTED_ERROR; + } + + str_eq_instructions->eq_channel_count = channel_count = drc_config->dwnmix_instructions[i].target_channel_count; + } + else if ((str_eq_instructions->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_eq_instructions->dwnmix_id_count > 1)) + { + channel_count = 1; + } + + str_eq_instructions->eq_ch_group_count = 0; + + for (i=0; ieq_ch_group_of_channel[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (k=0; keq_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; + } + } + + str_eq_instructions->td_filter_cascade_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_instructions->td_filter_cascade_present) + { + impd_parser_td_filter_cascade (it_bit_buff, str_eq_instructions, &(str_eq_instructions->str_td_filter_cascade)); + } + + str_eq_instructions->subband_gains_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_instructions->subband_gains_present) + { + for (i=0; ieq_ch_group_count; i++) + { + str_eq_instructions->subband_gains_index[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + + str_eq_instructions->eq_transition_duration_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_instructions->eq_transition_duration_present) + { + WORD32 bs_eq_transition_duration; + bs_eq_transition_duration = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->eq_transition_duration = (WORD32)(0.001f * (FLOAT32)pow(2.0f, 2.0f + bs_eq_transition_duration * 0.0625f)); + } + return(0); +} + +WORD32 impd_parse_loud_eq_instructions(ia_bit_buf_struct* it_bit_buff, + ia_loud_eq_instructions_struct* loud_eq_instructions) +{ + WORD32 i, bs_loud_eq_scaling, bs_loud_eq_offset, temp; + WORD32 dmix_id_present, additional_dmix_id_present, additional_dmix_id_cnt = 0; + WORD32 drc_set_id_present, additional_drc_set_id_present, additional_drc_set_id_cnt = 0; + WORD32 eq_set_id_present, additional_eq_set_id_present, additional_eq_set_id_cnt = 0; + + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; + loud_eq_instructions->loud_eq_set_id = (temp>>5)&0x0F; + + loud_eq_instructions->drc_location = (temp>>1)&0x0F; + + dmix_id_present = temp&0x01; + + if (dmix_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->downmix_id[0] = (temp>>1)&0x7F; + + additional_dmix_id_present = temp&0x01; + + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->downmix_id[0] = 0; + } + + loud_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; + + drc_set_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (drc_set_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; + + additional_drc_set_id_present = temp&0x01; + + if (additional_drc_set_id_present) + { + additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->drc_set_id[0] = 0; + } + + loud_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; + + eq_set_id_present = impd_read_bits_buf(it_bit_buff, 1); + + if(it_bit_buff->error) + return it_bit_buff->error; + + if (eq_set_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->eq_set_id[0] = (temp>>1)&0x3F; + + additional_eq_set_id_present = temp&0x01; + + if (additional_eq_set_id_present) + { + additional_eq_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + for (i=0; ieq_set_id[i+1] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->eq_set_id[0] = 0; + } + loud_eq_instructions->eq_set_id_count = 1 + additional_eq_set_id_cnt; + + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->loudness_after_drc = (temp>>7)&0x01; + + loud_eq_instructions->loudness_after_eq = (temp>>6)&0x01; + + loud_eq_instructions->loud_eq_gain_sequence_count = temp&0x3F; + + for (i=0; iloud_eq_gain_sequence_count; i++) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->gain_seq_idx[i] = (temp>>1)&0x3F; + + loud_eq_instructions->drc_characteristic_format_is_cicp[i] = temp&0x01; + + if (loud_eq_instructions->drc_characteristic_format_is_cicp[i]) + { + loud_eq_instructions->drc_characteristic[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->drc_characteristic_left_index[i] = (temp>>4)&0x0F; + + loud_eq_instructions->drc_characteristic_right_index[i] = temp&0x0F; + + } + + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->frequency_range_index[i] = (temp>>3)&0x3F; + + bs_loud_eq_scaling = temp&0x07; + + loud_eq_instructions->loud_eq_scaling[i] = (FLOAT32)pow (2.0f, -0.5f * bs_loud_eq_scaling); + + bs_loud_eq_offset = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->loud_eq_offset[i] = 1.5f * bs_loud_eq_offset - 16.0f; + + } + return(0); +} + + diff --git a/decoder/drc_src/impd_drc_eq.c b/decoder/drc_src/impd_drc_eq.c new file mode 100644 index 0000000..b46d94c --- /dev/null +++ b/decoder/drc_src/impd_drc_eq.c @@ -0,0 +1,1554 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#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_gain_dec.h" +#include "impd_drc_eq.h" + + +#define CONFIG_REAL_POLE 0 +#define CONFIG_COMPLEX_POLE 1 +#define CONFIG_REAL_ZERO_RADIUS_ONE 2 +#define CONFIG_REAL_ZERO 3 +#define CONFIG_GENERIC_ZERO 4 + +#define STEP_RATIO_F_LO 20.0f +#define STEP_RATIO_F_HI 24000.0f +#define STEP_RATIO_EQ_NODE_COUNT_MAX 33 + +#define FILTER_ELEMENT_FORMAT_POLE_ZERO 0 +#define FILTER_ELEMENT_FORMAT_FIR 1 + +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +WORD32 impd_derive_subband_center_freq(WORD32 eq_subband_gain_count, + WORD32 eq_subband_gain_format, + FLOAT32 sample_rate, + FLOAT32* subband_center_freq) +{ + WORD32 i; + FLOAT32 width, offset; + switch (eq_subband_gain_format) + { + case GAINFORMAT_QMF32: + case GAINFORMAT_QMF64: + case GAINFORMAT_QMF128: + case GAINFORMAT_UNIFORM: + width = 0.5f * sample_rate / (FLOAT32) eq_subband_gain_count; + offset = 0.5f * width; + for (i=0; ieq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { + for (i=0; ibs_real_zero_radius_one_count; i++) + { + part_response = 1.0f + 1.0f - 2.0f * 1.0f * (FLOAT32)cos(frequency_radian - (FLOAT32) element->zero_sign[i]); + total_response *= part_response; + } + for (i=0; ireal_zero_count; i++) + { + if (element->real_zero_radius[i] < 0.0f) + { + radius = - element->real_zero_radius[i]; + angle_radian =(FLOAT32) M_PI; + } + else + { + radius = element->real_zero_radius[i]; + angle_radian = 0.0f; + } + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); + total_response *= part_response; + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); + total_response *= part_response; + } + + total_response = sqrt(total_response); + + for (i=0; igeneric_zero_count; i++) + { + radius = element->generic_zero_radius[i]; + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); + total_response *= part_response; + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); + total_response *= part_response; + } + for (i=0; ireal_pole_count; i++) + { + if (element->real_pole_radius[i] < 0.0f) + { + radius = - element->real_pole_radius[i]; + angle_radian =(FLOAT32)( - M_PI); + } + else + { + radius = element->real_pole_radius[i]; + angle_radian = 0.0f; + } + part_response = 1/(1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian)); + total_response *= part_response; + } + for (i=0; icmplx_pole_count; i++) + { + part_response = 1/(1.0f + element->real_pole_radius[i] * element->real_pole_radius[i] - 2.0f * element->real_pole_radius[i] * (FLOAT32)cos(frequency_radian - element->complex_pole_angle[i])); + total_response *= part_response * part_response; + } + } + else + { + impd_calc_fir_filt_response(element->fir_filt_order, + element->fir_symmetry, + element->fir_coeff, + frequency_radian, + &part_response); + + total_response *= part_response; + } + *response = (FLOAT32)total_response; + return; +} + +VOID impd_calc_filt_block_response(ia_unique_td_filt_element* unique_td_filt_ele, + ia_filt_block_struct* str_filter_block, + FLOAT32 frequency_radian, + FLOAT32 *response) +{ + WORD32 i; + FLOAT32 part_response; + FLOAT64 total_response = 1.0; + for (i=0; ifilter_element_count; i++) + { + ia_filt_ele_struct* str_filter_element = &str_filter_block->str_filter_element[i]; + + impd_calc_filt_ele_response(&(unique_td_filt_ele[str_filter_element->filt_ele_idx]), + frequency_radian, + &part_response); + total_response *= part_response; + + if (str_filter_element->filt_ele_gain_flag == 1) + { + total_response *= pow(10.0f, 0.05f * str_filter_element->filt_ele_gain); + } + } + *response = (FLOAT32) total_response; + return; +} + +WORD32 impd_calc_subband_gains_td_cascade(ia_unique_td_filt_element* unique_td_filt_ele, + ia_filt_block_struct* str_filter_block, + ia_td_filter_cascade_struct* str_td_filter_cascade, + WORD32 eq_subband_gain_format, + WORD32 eq_ch_group_count, + FLOAT32 sample_rate, + WORD32 eq_frame_size_subband, + ia_subband_filt_struct* subband_filt) +{ + WORD32 i, err = 0, g, b; + FLOAT32 response, frequency_radian; + FLOAT32 subband_center_freq[256]; + FLOAT64 total_response; + + WORD32 eq_subband_gain_count = subband_filt->coeff_count; + + err = impd_derive_subband_center_freq(eq_subband_gain_count, eq_subband_gain_format, sample_rate, subband_center_freq); + if (err) + return(err); + + for (g=0; geq_cascade_gain[g]); + frequency_radian = (FLOAT32)(2.0f * M_PI * subband_center_freq[b] / sample_rate); + for (i=0; istr_filter_block_refs[g].filter_block_count; i++) + { + impd_calc_filt_block_response(unique_td_filt_ele, + &(str_filter_block[str_td_filter_cascade->str_filter_block_refs[g].filter_block_index[i]]), + frequency_radian, + &response); + total_response *= response; + } + subband_filt[g].subband_coeff[b] = (FLOAT32) total_response; + } + subband_filt[g].eq_frame_size_subband = eq_frame_size_subband; + } + return(0); +} + +VOID impd_add_cascade(ia_cascade_align_group_struct* pstr_cascade_align_grp, + WORD32 c1, + WORD32 c2, + WORD32* done) +{ + WORD32 m, n; + + *done = 0; + for (m=0; mmember_count; m++) + { + if (pstr_cascade_align_grp->member_idx[m] == c1) + { + for (n=0; nmember_count; n++) + { + if (pstr_cascade_align_grp->member_idx[n] == c2) + { + *done = 1; + } + } + if (*done == 0) + { + pstr_cascade_align_grp->member_idx[pstr_cascade_align_grp->member_count] = c2; + pstr_cascade_align_grp->member_count++; + *done = 1; + } + } + } + return; +} + +VOID impd_calc_cascade_align_groups(WORD32 eq_ch_group_count, + WORD32 eq_phase_alignment_present, + WORD32 eq_phase_alignment[][EQ_CHANNEL_GROUP_COUNT_MAX], + WORD32* cascade_align_grp_cnt, + ia_cascade_align_group_struct* pstr_cascade_align_grp) +{ + WORD32 i, k, g, group_count, done; + + group_count = 0; + + if (eq_phase_alignment_present == 0) + { + if (eq_ch_group_count > 1) + { + for (i=0; isection_count; + ia_filt_sect_struct* filt_section = &ph_alignment_filt->filt_section[section]; + switch (config) + { + case CONFIG_REAL_POLE: + ph_alignment_filt->gain *= (-radius); + filt_section->a1 = - radius; + filt_section->a2 = 0.0f; + filt_section->b1 = - 1.0f / radius; + filt_section->b2 = 0.0f; + ph_alignment_filt->section_count++; + break; + case CONFIG_COMPLEX_POLE: + zReal = radius * (FLOAT32)cos(M_PI * angle); + zImag = radius * (FLOAT32)sin(M_PI * angle); + prod = zReal * zReal + zImag * zImag; + ph_alignment_filt->gain *= prod; + filt_section->a1 = - 2.0f * zReal; + filt_section->a2 = prod; + filt_section->b1 = - 2.0f * zReal / prod; + filt_section->b2 = 1.0f / prod; + ph_alignment_filt->section_count++; + break; + default: + break; + } + for (channel=0; channelfilt_sect_state[channel].in_state_1 = 0.0f; + filt_section->filt_sect_state[channel].in_state_2 = 0.0f; + filt_section->filt_sect_state[channel].out_state_1 = 0.0f; + filt_section->filt_sect_state[channel].out_state_2 = 0.0f; + } + + return; +} + + +VOID impd_calc_phase_filt_delay(ia_unique_td_filt_element* element, + ia_ph_alignment_filt_struct* ph_alignment_filt) +{ + WORD32 i, delay=0, channel; + if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { + if (element->bs_real_zero_radius_one_count == 0) + { + delay = element->real_zero_count + 2 * element->generic_zero_count - element->real_pole_count - 2 * element->cmplx_pole_count; + delay = max(0, delay); + ph_alignment_filt->validity_flag = 1; + } + } + ph_alignment_filt->audio_delay.delay = delay; + for (channel=0; channelaudio_delay.state[channel][i] = 0.0f; + } + } + + return; +} + +VOID impd_calc_phase_filt(ia_unique_td_filt_element* element, + WORD32 filt_ele_idx, + ia_matching_ph_filt_struct* matching_ph_filt) +{ + WORD32 i; + + memset(matching_ph_filt, 0, sizeof(ia_matching_ph_filt_struct)); + matching_ph_filt->gain = 1.0f; + + if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { + for (i=0; ireal_pole_count; i++) + { + impd_calc_phase_filt_params(CONFIG_REAL_POLE, + element->real_pole_radius[i], + 0.0f, + matching_ph_filt); + } + for (i=0; icmplx_pole_count; i++) + { + impd_calc_phase_filt_params(CONFIG_COMPLEX_POLE, + element->complex_pole_radius[i], + element->complex_pole_angle[i], + matching_ph_filt); + } + } + impd_calc_phase_filt_delay(element, matching_ph_filt); + + matching_ph_filt->num_matches_filter = 1; + matching_ph_filt->matches_filter[0] = filt_ele_idx; + + return; +} + +WORD32 impd_calc_filt_params(ia_unique_td_filt_element* element, + ia_interm_filt_params_struct* interm_filt_params) +{ + FLOAT32 zReal; + FLOAT32* coeff; + //WORD32 offset_idx = 0; + WORD32 i; + WORD32 param_idx = 0; + + ia_2nd_order_filt_params_struct *pstr_2nd_oder_filt_params = &interm_filt_params->ord_2_filt_params_of_zeros[0]; + + for (i=0; ibs_real_zero_radius_one_count; i+=2) + { + FLOAT32 radius = (FLOAT32)element->zero_sign[i + 0]; + FLOAT32 angle = (FLOAT32)element->zero_sign[i + 1]; + FLOAT32 angle1 = radius; + FLOAT32 angle2 = angle; + pstr_2nd_oder_filt_params->radius = 1.0f; + coeff = pstr_2nd_oder_filt_params->coeff; + + if (angle1 != angle2) + { + coeff[0] = 0.0f; + coeff[1] = -1.0f; + } + else if (angle1 == 1.0f) + { + coeff[0] = -2.0f; + coeff[1] = 1.0f; + } + else + { + coeff[0] = 2.0f; + coeff[1] = 1.0f; + } + pstr_2nd_oder_filt_params += 1; + param_idx += 1; + } + for (i=0; ireal_zero_count; i++) + { + FLOAT32 radius = element->real_zero_radius[i]; + //FLOAT32 angle = 0.0f; + + pstr_2nd_oder_filt_params->radius = radius; + if (fabs(radius) == 1.0f) + { + return (-1); + } + else + { + coeff = pstr_2nd_oder_filt_params->coeff; + coeff[0] = - (radius + 1.0f / radius); + coeff[1] = 1.0f; + } + pstr_2nd_oder_filt_params += 1; + param_idx += 1; + } + + for (i=0; igeneric_zero_count; i++) + { + FLOAT32 radius = element->generic_zero_radius[i]; + FLOAT32 angle = element->generic_zero_angle[i]; + zReal = radius * (FLOAT32)cos(M_PI * angle); + pstr_2nd_oder_filt_params->radius = radius; + coeff = pstr_2nd_oder_filt_params->coeff; + coeff[0] = -2.0f * zReal; + coeff[1] = radius * radius; + + pstr_2nd_oder_filt_params += 1; + + zReal = (FLOAT32)cos(M_PI * angle) / radius; + pstr_2nd_oder_filt_params->radius = radius; + coeff = pstr_2nd_oder_filt_params->coeff; + coeff[0] = -2.0f * zReal; + coeff[1] = 1.0f / (radius * radius); + + pstr_2nd_oder_filt_params += 1; + + param_idx += 2; + } + + interm_filt_params->filter_param_count_of_zeros = param_idx; + param_idx = 0; + + pstr_2nd_oder_filt_params = &interm_filt_params->ord_2_filt_params_of_poles[0]; + + for (i=0; ireal_pole_count; i++) + { + FLOAT32 radius = element->real_pole_radius[i]; + pstr_2nd_oder_filt_params->radius = radius; + coeff = pstr_2nd_oder_filt_params->coeff; + coeff[0] = -2.0f * radius; + coeff[1] = radius * radius; + param_idx += 1; + pstr_2nd_oder_filt_params += 1; + } + + for (i=0; icmplx_pole_count; i++) + { + FLOAT32 radius = element->complex_pole_radius[i]; + FLOAT32 angle = element->complex_pole_angle[i]; + + zReal = radius * (FLOAT32)cos(M_PI * angle); + pstr_2nd_oder_filt_params->radius = radius; + coeff = pstr_2nd_oder_filt_params->coeff; + coeff[0] = -2.0f * zReal; + coeff[1] = radius * radius; + + pstr_2nd_oder_filt_params += 1; + + pstr_2nd_oder_filt_params->radius = radius; + pstr_2nd_oder_filt_params->coeff[0] = coeff[0]; + pstr_2nd_oder_filt_params->coeff[1] = coeff[1]; + + pstr_2nd_oder_filt_params += 1; + param_idx += 2; + } + interm_filt_params->filter_param_count_of_poles = param_idx; + return 0; +} + +VOID impd_convert_fir_filt_params(WORD32 fir_filt_order, + WORD32 fir_symmetry, + FLOAT32* fir_coeff, + ia_fir_filter_struct* fir_filter) +{ + WORD32 i, channel; + FLOAT32* coeff = fir_filter->coeff; + + fir_filter->coeff_count = fir_filt_order + 1; + for (i=0; istate[channel][i] = 0.0f; + } + } + return; +} + +WORD32 impd_calc_filt_params_all(ia_unique_td_filt_element* element, + ia_interm_filt_params_struct* interm_filt_params) +{ + WORD32 err = 0; + + interm_filt_params->filter_format = element->eq_filter_format; + if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { + err = impd_calc_filt_params(element, + interm_filt_params); + if(err) + return err; + } + else + { + interm_filt_params->filter_param_count_of_zeros = 0; + interm_filt_params->filter_param_count_of_poles = 0; + + impd_convert_fir_filt_params (element->fir_filt_order, + element->fir_symmetry, + element->fir_coeff, + &interm_filt_params->fir_filter); + } + return (0); +} + +VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params, + ia_eq_filt_ele_struct* eq_filt_element) +{ + WORD32 i, poles_idx, zeros_idx, pole_order = 0, section, channel; + WORD32 poles_over[REAL_POLE_COUNT_MAX + COMPLEX_POLE_COUNT_MAX]; + WORD32 zeros_over[REAL_ZERO_COUNT_MAX + COMPLEX_ZERO_COUNT_MAX]; + FLOAT32 max_radius, diff_radius; + WORD32 coeff_count; + FLOAT32* coeff; + + for (i=0; ifilter_param_count_of_poles; i++) + { + if (poles_over[i] == 0) + { + if (interm_filt_params->filter_format == 0) + { + if (max_radius < fabs(interm_filt_params->ord_2_filt_params_of_poles[i].radius)) + { + max_radius = (FLOAT32)fabs(interm_filt_params->ord_2_filt_params_of_poles[i].radius); + poles_idx = i; + if (interm_filt_params->ord_2_filt_params_of_poles[i].coeff[1] != 0.0f) + { + pole_order = 2; + } + else + { + pole_order = 1; + } + } + } + } + } + if (poles_idx >= 0) + { + diff_radius = 10.0f; + zeros_idx = -1; + for (i=0; ifilter_param_count_of_zeros; i++) + { + if (zeros_over[i] == 0) + { + if (interm_filt_params->filter_format == 0) + { + if (pole_order == 2) { + if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] != 0.0f) + { + if (diff_radius > fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)) + { + diff_radius = (FLOAT32)fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius); + zeros_idx = i; + } + } + } + else + { + if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] == 0.0f) + { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { + diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); + zeros_idx = i; + } + } + } + } + } + } + if (zeros_idx == -1) + { + for (i=0; ifilter_param_count_of_zeros; i++) + { + if (zeros_over[i] == 0) + { + if (interm_filt_params->filter_format == 0) + { + if (pole_order == 2) { + if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] == 0.0f) + { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { + diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); + zeros_idx = i; + } + } + } + else + { + if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] != 0.0f) + { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { + diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); + zeros_idx = i; + } + } + } + } + } + } + } + eq_filt_element->pstr_pole_zero_filt.filt_section[section].a1 = interm_filt_params->ord_2_filt_params_of_poles[poles_idx].coeff[0]; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].a2 = interm_filt_params->ord_2_filt_params_of_poles[poles_idx].coeff[1]; + if (zeros_idx >= 0) + { + eq_filt_element->pstr_pole_zero_filt.filt_section[section].b1 = interm_filt_params->ord_2_filt_params_of_zeros[zeros_idx].coeff[0]; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].b2 = interm_filt_params->ord_2_filt_params_of_zeros[zeros_idx].coeff[1]; + } + else + { + eq_filt_element->pstr_pole_zero_filt.filt_section[section].b1 = 0.0f; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].b2 = 0.0f; + eq_filt_element->pstr_pole_zero_filt.audio_delay.delay++; + } + for (channel=0; channelpstr_pole_zero_filt.filt_section[section].filt_sect_state[channel].in_state_1 = 0.0f; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].filt_sect_state[channel].in_state_2 = 0.0f; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].filt_sect_state[channel].out_state_1 = 0.0f; + eq_filt_element->pstr_pole_zero_filt.filt_section[section].filt_sect_state[channel].out_state_2 = 0.0f; + } + if (zeros_idx >= 0) zeros_over[zeros_idx] = 1; + if (poles_idx >= 0) poles_over[poles_idx] = 1; + section++; + } + } while (poles_idx >= 0); + + eq_filt_element->pstr_pole_zero_filt.section_count = section; + + coeff_count = 1; + coeff = eq_filt_element->pstr_pole_zero_filt.fir_filter.coeff; + coeff[0] = 1.0f; + for (i=0; ifilter_param_count_of_zeros; i++) + { + if (zeros_over[i] == 0) + { + if (interm_filt_params->filter_format == 0) + { + WORD32 k; + FLOAT32 b1, b2; + b1 = interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[0]; + b2 = interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1]; + + coeff_count += 2; + k = coeff_count - 1; + coeff[k] = b2 * coeff[k-2]; + k--; + if (k>1) + { + coeff[k] = b1 * coeff[k-1] + b2 * coeff[k-2]; + k--; + for ( ; k>1; k--) + { + coeff[k] += b1 * coeff[k-1] + b2 * coeff[k-2]; + } + coeff[1] += b1 * coeff[0]; + } + else + { + coeff[1] = b1 * coeff[0]; + } + } + } + zeros_over[i] = 1; + } + if (coeff_count > 1) + { + eq_filt_element->pstr_pole_zero_filt.filt_coeffs_flag = 1; + eq_filt_element->pstr_pole_zero_filt.fir_filter.coeff_count = coeff_count; + } + else + { + eq_filt_element->pstr_pole_zero_filt.filt_coeffs_flag = 0; + eq_filt_element->pstr_pole_zero_filt.fir_filter.coeff_count = 0; + } + + return; +} + +WORD32 impd_calc_filt_block(ia_unique_td_filt_element* unique_td_filt_ele, + ia_filt_block_struct* str_filter_block, + ia_eq_filt_block_struct* pstr_eq_filt_block) +{ + WORD32 i, k, err; + ia_interm_filt_params_struct interm_filt_params; + ia_matching_ph_filt_struct matching_ph_filt[FILTER_ELEMENT_COUNT_MAX]; + + for (i=0; ifilter_element_count; i++) + { + if ((unique_td_filt_ele[str_filter_block->str_filter_element[i].filt_ele_idx].eq_filter_format == FILTER_ELEMENT_FORMAT_FIR) && (str_filter_block->filter_element_count > 1)) + { + return (-1); + } + } + for (i=0; ifilter_element_count; i++) + { + ia_eq_filt_ele_struct* eq_filt_element = &pstr_eq_filt_block->eq_filt_element[i]; + ia_filt_ele_struct* str_filter_element = &str_filter_block->str_filter_element[i]; + WORD32 filterIndex = str_filter_element->filt_ele_idx; + + if (unique_td_filt_ele[filterIndex].eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { + err = impd_calc_filt_params_all(&(unique_td_filt_ele[filterIndex]), + &interm_filt_params); + if (err) + return (err); + + impd_calc_eq_filt_elements(&interm_filt_params, eq_filt_element); + + eq_filt_element->format = FILTER_ELEMENT_FORMAT_POLE_ZERO; + } + else + { + impd_convert_fir_filt_params (unique_td_filt_ele[filterIndex].fir_filt_order, + unique_td_filt_ele[filterIndex].fir_symmetry, + unique_td_filt_ele[filterIndex].fir_coeff, + &eq_filt_element->fir_filter); + + eq_filt_element->format = FILTER_ELEMENT_FORMAT_FIR; + } + if (str_filter_element->filt_ele_gain_flag == 1) + { + eq_filt_element->elementGainLinear = (FLOAT32)(pow(10.0f, 0.05f * str_filter_element->filt_ele_gain)); + } + else + { + eq_filt_element->elementGainLinear = 1.0f; + } + for (k=0; k 0.0f) + { + eq_filt_element->elementGainLinear = - eq_filt_element->elementGainLinear; + } + } + impd_calc_phase_filt(&(unique_td_filt_ele[filterIndex]), + i, + &matching_ph_filt[i]); + } + pstr_eq_filt_block->element_count = str_filter_block->filter_element_count; + + pstr_eq_filt_block->matching_ph_filt_ele_0 = matching_ph_filt[0]; + + return(0); +} + +VOID impd_calc_cascade_phase_align_filt(ia_td_filter_cascade_struct* str_td_filter_cascade, + WORD32 ch_group_cnt) +{ + //WORD32 err = 0; + WORD32 cascade_align_grp_cnt = 0; + ia_cascade_align_group_struct pstr_cascade_align_grp[EQ_CHANNEL_GROUP_COUNT_MAX/2]; + + impd_calc_cascade_align_groups(ch_group_cnt, + str_td_filter_cascade->eq_phase_alignment_present, + str_td_filter_cascade->eq_phase_alignment, + &cascade_align_grp_cnt, + pstr_cascade_align_grp); + return; +} + + +WORD32 impd_calc_filt_cascade(ia_unique_td_filt_element* unique_td_filt_ele, + ia_filt_block_struct* str_filter_block, + ia_td_filter_cascade_struct* str_td_filter_cascade, + WORD32 ch_group_cnt, + ia_filt_cascade_td_struct filt_cascade_td[]) +{ + WORD32 i, err, g; + + for (g=0; gstr_filter_block_refs[g].filter_block_count; i++) + { + err = impd_calc_filt_block(unique_td_filt_ele, + &(str_filter_block[str_td_filter_cascade->str_filter_block_refs[g].filter_block_index[i]]), + &(filt_cascade_td[g].pstr_eq_filt_block[i])); + if (err) + return(err); + } + filt_cascade_td[g].block_count = i; + filt_cascade_td[g].cascade_gain_linear = (FLOAT32)(pow(10.0f, 0.05f * str_td_filter_cascade->eq_cascade_gain[g])); + } + + impd_calc_cascade_phase_align_filt(str_td_filter_cascade, + ch_group_cnt); + return(0); +} + + +VOID impd_calc_subband_eq(ia_eq_subband_gain_vector* str_eq_subband_gain_vector, + WORD32 eq_subband_gain_count, + ia_subband_filt_struct* subband_filt) +{ + WORD32 i; + + for (i=0; isubband_coeff[i] = str_eq_subband_gain_vector->eq_subband_gain[i]; + } + subband_filt->coeff_count = eq_subband_gain_count; + return ; +} + +FLOAT32 impd_decode_eq_node_freq(WORD32 eq_node_freq_idx) +{ + /*((FLOAT32)((log10(STEP_RATIO_F_HI) / log10(STEP_RATIO_F_LO) - 1.0f) / (STEP_RATIO_EQ_NODE_COUNT_MAX - 1.0f)))*/ + FLOAT32 step_ratio = 0.0739601809794f; + return((FLOAT32)(pow(STEP_RATIO_F_LO, 1.0f + eq_node_freq_idx * step_ratio))); +} + +FLOAT32 impd_calc_warp_freq_delta(FLOAT32 fsubband, + FLOAT32 node_freq, + WORD32 eq_node_freq_idx) +{ + /*((FLOAT32)((log10(STEP_RATIO_F_HI) / log10(STEP_RATIO_F_LO) - 1.0f) / (STEP_RATIO_EQ_NODE_COUNT_MAX - 1.0f)))*/ + FLOAT32 step_ratio = 0.0739601809794f; + return((FLOAT32)((log10(fsubband)/log10(node_freq) - 1.0f) / step_ratio - (FLOAT32) eq_node_freq_idx)); +} + +VOID impd_interpolate_eq_gain(WORD32 band_step, + FLOAT32 left_gain, + FLOAT32 right_gain, + FLOAT32 left_slope, + FLOAT32 right_slope, + FLOAT32 f, + FLOAT32* interpolated_gain) +{ + FLOAT32 k1, k2, a, b, c, d; + FLOAT32 inv_band_step =(FLOAT32)( 1.0 / (FLOAT32)band_step); + FLOAT32 inv_band_step_sqr = inv_band_step * inv_band_step; k1 = (right_gain - left_gain) * inv_band_step_sqr; + left_slope = (FLOAT32) (left_slope / 3.128f); + right_slope = (FLOAT32) (right_slope / 3.128f); + + k2 = right_slope + left_slope; + a = inv_band_step * (inv_band_step * k2 - 2.0f * k1); b = 3.0f * k1 - inv_band_step * (k2 + left_slope); + c = left_slope; + d = left_gain; + *interpolated_gain = (((a * f + b ) * f + c ) * f ) + d; + return; +} + +WORD32 impd_interpolate_subband_spline(ia_eq_subband_gain_spline_struct* str_eq_subband_gain_spline, + WORD32 eq_subband_gain_count, + WORD32 eq_subband_gain_format, + FLOAT32 sample_rate, + ia_subband_filt_struct* subband_filt) +{ + WORD32 b, n, err; + + FLOAT32 eq_gain[32]; + WORD32 eq_node_freq_idx[32]; + FLOAT32 eq_node_freq[32]; + FLOAT32 subband_center_freq[256]; + WORD32 num_eq_nodes = str_eq_subband_gain_spline->num_eq_nodes; + + FLOAT32* eq_slope = str_eq_subband_gain_spline->eq_slope; + WORD32* eq_freq_delta = str_eq_subband_gain_spline->eq_freq_delta; + FLOAT32 eq_gain_initial = str_eq_subband_gain_spline->eq_gain_initial; + FLOAT32* eq_gain_delta = str_eq_subband_gain_spline->eq_gain_delta; + + FLOAT32* subband_coeff = subband_filt->subband_coeff; + WORD32 max_eq_node_idx = 32; + + eq_gain[0] = eq_gain_initial; + eq_node_freq_idx[0] = 0; + eq_node_freq[0] = impd_decode_eq_node_freq(eq_node_freq_idx[0]); + for (n=1; n= eq_node_freq[n]) && (fSub <= eq_node_freq[n+1])) + { + FLOAT32 warpedDeltaFreq = impd_calc_warp_freq_delta (fSub, eq_node_freq[0], eq_node_freq_idx[n]); + FLOAT32 gEqSubbandDb; + impd_interpolate_eq_gain(eq_freq_delta[n+1], eq_gain[n], eq_gain[n+1], + eq_slope[n], eq_slope[n+1], warpedDeltaFreq, &gEqSubbandDb); + + subband_coeff[b] = (FLOAT32)pow(2.0, gEqSubbandDb / 6.0f); + } + } + } + subband_filt->coeff_count = eq_subband_gain_count; + return (0); +} + +WORD32 impd_calc_subband_gains(ia_eq_coeff_struct* str_eq_coeff, + WORD32 eq_ch_group_count, + WORD32* subband_gains_index, + FLOAT32 sample_rate, + WORD32 eq_frame_size_subband, + ia_subband_filt_struct* subband_filt) +{ + WORD32 g, err; + WORD32 eq_subband_gain_representation = str_eq_coeff->eq_subband_gain_representation; + WORD32 eq_subband_gain_count = str_eq_coeff->eq_subband_gain_count; + WORD32 eq_subband_gain_format = str_eq_coeff->eq_subband_gain_format; + + for (g=0; gstr_eq_subband_gain_spline[subband_gains_index[g]]), + eq_subband_gain_count, + eq_subband_gain_format, + sample_rate, + &(subband_filt[g])); + if (err) + return(err); + } + else + { + impd_calc_subband_eq(&(str_eq_coeff->str_eq_subband_gain_vector[subband_gains_index[g]]), + eq_subband_gain_count, + &(subband_filt[g])); + } + subband_filt[g].eq_frame_size_subband = eq_frame_size_subband; + } + return (0); +} + +VOID impd_calc_filt_sect_delay(WORD32 section_count, + ia_filt_sect_struct* filt_section, + FLOAT32* delay) +{ + WORD32 i; + FLOAT32 d = 0.0f; + for (i=0; iaudio_num_chan; c++) + { + g = eq_set->eq_ch_group_of_channel[c]; + if (g>=0) + { + switch (eq_set->domain) + { + case EQ_FILTER_DOMAIN_TIME: + { + ia_filt_cascade_td_struct* filt_cascade_td = &eq_set->filt_cascade_td[g]; + for (b=0; bblock_count; b++) + { + ia_eq_filt_ele_struct* eq_filt_element = &filt_cascade_td->pstr_eq_filt_block[b].eq_filt_element[0]; + switch (eq_filt_element->format) + { + case FILTER_ELEMENT_FORMAT_POLE_ZERO: + impd_calc_filt_sect_delay(eq_filt_element->pstr_pole_zero_filt.section_count, + eq_filt_element->pstr_pole_zero_filt.filt_section, + §_delay); + delay += sect_delay; + if (eq_filt_element->pstr_pole_zero_filt.filt_coeffs_flag) + { + delay += 0.5f * (eq_filt_element->pstr_pole_zero_filt.fir_filter.coeff_count - 1); + } + break; + case FILTER_ELEMENT_FORMAT_FIR: + delay += 0.5f * (eq_filt_element->fir_filter.coeff_count - 1); + break; + default: + break; + } + for (k=0; k < eq_filt_element->num_ph_align_filt; k++) + { + ia_ph_alignment_filt_struct* ph_alignment_filt = &eq_filt_element->ph_alignment_filt[k]; + impd_calc_filt_sect_delay(ph_alignment_filt->section_count, + ph_alignment_filt->filt_section, + §_delay); + delay += sect_delay; + } + } + for (b=0; bnum_ph_align_filt; b++) + { + ia_ph_alignment_filt_struct* ph_alignment_filt = &filt_cascade_td->ph_alignment_filt[b]; + impd_calc_filt_sect_delay(ph_alignment_filt->section_count, + ph_alignment_filt->filt_section, + §_delay); + delay += sect_delay; + } + } + break; + case EQ_FILTER_DOMAIN_SUBBAND: + case EQ_FILTER_DOMAIN_NONE: + default: + break; + } + } + break; + } + *cascade_delay = (WORD32)delay; + return; +} + +WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, + ia_eq_instructions_struct* str_eq_instructions, + FLOAT32 sample_rate, + WORD32 drc_frame_size, + WORD32 sub_band_domain_mode, + ia_eq_set_struct* eq_set) +{ + WORD32 err, i, eq_frame_size_subband; + + eq_set->domain = EQ_FILTER_DOMAIN_NONE; + + if (sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + if (str_eq_instructions->td_filter_cascade_present== 1) + { + err = impd_calc_filt_cascade(str_eq_coeff->unique_td_filt_ele, + str_eq_coeff->str_filter_block, + &str_eq_instructions->str_td_filter_cascade, + str_eq_instructions->eq_ch_group_count, + eq_set->filt_cascade_td); + if (err) + return (err); + } + + eq_set->domain |= EQ_FILTER_DOMAIN_TIME; + } + if (sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF) + { + switch (sub_band_domain_mode) + { + case SUBBAND_DOMAIN_MODE_QMF64: + if (str_eq_coeff->eq_subband_gain_count != AUDIO_CODEC_SUBBAND_COUNT_QMF64) + { + return (-1); + } + eq_frame_size_subband = drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; + break; + case SUBBAND_DOMAIN_MODE_QMF71: + if (str_eq_coeff->eq_subband_gain_count != AUDIO_CODEC_SUBBAND_COUNT_QMF71) + { + return (-1); + } + eq_frame_size_subband = drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; + break; + case SUBBAND_DOMAIN_MODE_STFT256: + if (str_eq_coeff->eq_subband_gain_count != AUDIO_CODEC_SUBBAND_COUNT_STFT256) + { + return (-1); + } + eq_frame_size_subband = drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; + break; + default: + return (-1); + break; + } + if (str_eq_instructions->subband_gains_present== 1) + { + err = impd_calc_subband_gains(str_eq_coeff, + str_eq_instructions->eq_ch_group_count, + str_eq_instructions->subband_gains_index, + sample_rate, + eq_frame_size_subband, + eq_set->subband_filt); + if (err) + return (err); + } + else + { + if (str_eq_instructions->td_filter_cascade_present== 1) + { + err = impd_calc_subband_gains_td_cascade(str_eq_coeff->unique_td_filt_ele, + str_eq_coeff->str_filter_block, + &str_eq_instructions->str_td_filter_cascade, + str_eq_coeff->eq_subband_gain_format, + str_eq_instructions->eq_ch_group_count, + sample_rate, + eq_frame_size_subband, + eq_set->subband_filt); + if (err) + return (err); + } + + } + eq_set->domain |= EQ_FILTER_DOMAIN_SUBBAND; + } + eq_set->audio_num_chan = str_eq_instructions->eq_channel_count; + eq_set->eq_ch_group_count = str_eq_instructions->eq_ch_group_count; + + for (i=0; ieq_channel_count; i++) + { + eq_set->eq_ch_group_of_channel[i] = str_eq_instructions->eq_ch_group_of_channel[i]; + } + + return (0); +} + +VOID impd_process_filt_sect(ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX], + WORD32 channel, + FLOAT32* audio_out, + WORD32 section_count) +{ + WORD32 i; + + for(i = 0; i < section_count; i++) + { + ia_filt_sect_state_struct* filt_sect_state = &filt_section[i].filt_sect_state[channel]; + FLOAT32 audio_in = *audio_out; + *audio_out = audio_in + filt_section[i].b1 * filt_sect_state->in_state_1 + + filt_section[i].b2 * filt_sect_state->in_state_2 + - filt_section[i].a1 * filt_sect_state->out_state_1 + - filt_section[i].a2 * filt_sect_state->out_state_2; + + filt_sect_state->in_state_2 = filt_sect_state->in_state_1; + filt_sect_state->in_state_1 = audio_in; + filt_sect_state->out_state_2 = filt_sect_state->out_state_1; + filt_sect_state->out_state_1 = *audio_out; + } + return; +} + +VOID impd_fir_filt_process(ia_fir_filter_struct* fir_filter, + WORD32 channel, + FLOAT32 audio_in, + FLOAT32* audio_out) +{ + WORD32 i; + FLOAT32* coeff = fir_filter->coeff; + FLOAT32* state = fir_filter->state[channel]; + FLOAT32 sum; + sum = coeff[0] * audio_in; + for (i=1; icoeff_count; i++) + { + sum += coeff[i] * state[i-1]; + } + *audio_out = sum; + for (i=fir_filter->coeff_count-2; i>0; i--) + { + state[i] = state[i-1]; + } + state[0] = audio_in; + return; +} + +VOID impd_audio_delay_process(ia_audio_delay_struct* audio_delay, + WORD32 channel, + FLOAT32 audio_in, + FLOAT32* ptr_audio_out) +{ + WORD32 i; + FLOAT32* state = audio_delay->state[channel]; + if (audio_delay->delay > 0) + { + *ptr_audio_out = state[audio_delay->delay-1]; + for (i=audio_delay->delay-1; i>0; i--) + { + state[i] = state[i-1]; + } + state[0] = audio_in; + } + else + { + *ptr_audio_out = audio_in; + } + return; +} + + +VOID impd_pole_zero_filt_process(ia_pole_zero_filt_struct* pstr_pole_zero_filt, + WORD32 channel, + FLOAT32 audio_in, + FLOAT32* ptr_audio_out) +{ + FLOAT32 inp = audio_in; + FLOAT32 out = inp; + + impd_process_filt_sect(pstr_pole_zero_filt->filt_section, channel, &out, pstr_pole_zero_filt->section_count); + inp = out; + + if (pstr_pole_zero_filt->filt_coeffs_flag == 1) + { + impd_fir_filt_process(&pstr_pole_zero_filt->fir_filter, channel, inp, &out); + inp = out; + } + impd_audio_delay_process(&pstr_pole_zero_filt->audio_delay, channel, inp, &out); + + *ptr_audio_out = out; + 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) +{ + FLOAT32 audio_in = *ptr_audio_out; + FLOAT32 inp = audio_in; + FLOAT32 out = inp; + + impd_process_filt_sect(ph_alignment_filt->filt_section, channel, &out, ph_alignment_filt->section_count); + inp = out; + + impd_audio_delay_process(&ph_alignment_filt->audio_delay, channel, inp, &out); + + *ptr_audio_out = out * ph_alignment_filt->gain; + return; +} + + +VOID impd_eq_filt_element_process(ia_eq_filt_block_struct str_eq_filt_block[EQ_FILTER_BLOCK_COUNT_MAX], + WORD32 channel, + FLOAT32 audio_in, + FLOAT32* ptr_audio_out, + WORD32 block_count) +{ + WORD32 i; + FLOAT32 inp = audio_in; + FLOAT32 out = inp; + WORD32 k,j; + WORD32 element_count; + for(j = 0; j < block_count; j++) + { + FLOAT32 sum = 0.0f; + element_count = str_eq_filt_block[j].element_count; + for (k=0; k < element_count; k++) + { + switch (str_eq_filt_block[j].eq_filt_element[k].format) + { + case FILTER_ELEMENT_FORMAT_POLE_ZERO: + impd_pole_zero_filt_process(&str_eq_filt_block[j].eq_filt_element[k].pstr_pole_zero_filt, channel, inp, &out); + break; + case FILTER_ELEMENT_FORMAT_FIR: + impd_fir_filt_process(&str_eq_filt_block[j].eq_filt_element[k].fir_filter, channel, inp, &out); + break; + default: + break; + } + out *= str_eq_filt_block[j].eq_filt_element[k].elementGainLinear; + + for (i=0; i < str_eq_filt_block[j].eq_filt_element[k].num_ph_align_filt; i++) + { + inp = out; + impd_phase_align_filt_process(&str_eq_filt_block[j].eq_filt_element[k].ph_alignment_filt[i], + channel, + &out); + } + sum += out; + } + inp = sum; + } + *ptr_audio_out = inp; + return; +} + + +WORD32 impd_process_eq_set_time_domain(ia_eq_set_struct* pstr_eq_set, + WORD32 channel, + FLOAT32 *ptr_audio_in, + FLOAT32 *ptr_audio_out, + WORD32 frame_size) +{ + WORD32 g=pstr_eq_set->eq_ch_group_of_channel[channel],i,j; + //FLOAT32 sum = 0.0f; + //FLOAT32 temp1 = 0.0f; + + if(pstr_eq_set==NULL || g<0) + return 0; + + if (pstr_eq_set->domain | EQ_FILTER_DOMAIN_TIME) + { + for(i=0;ifilt_cascade_td[g].pstr_eq_filt_block), + channel, + ptr_audio_in[i], + &ptr_audio_out[i], + pstr_eq_set->filt_cascade_td[g].block_count); + + for (j=0; jfilt_cascade_td[g].num_ph_align_filt; j++) + { + impd_phase_align_filt_process(&pstr_eq_set->filt_cascade_td[g].ph_alignment_filt[j], + channel, + &ptr_audio_out[i]); + } + + ptr_audio_out[i] = ptr_audio_out[i] * pstr_eq_set->filt_cascade_td[g].cascade_gain_linear; + } + } + else + { + return -1; + } + 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 new file mode 100644 index 0000000..4f24106 --- /dev/null +++ b/decoder/drc_src/impd_drc_eq.h @@ -0,0 +1,196 @@ +/****************************************************************************** + * + * 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_EQ_H +#define IMPD_DRC_EQ_H + +#ifndef COMPILE_FOR_DRC_ENCODER +#endif + +#define EQ_CHANNEL_COUNT_MAX 8 +#define EQ_AUDIO_DELAY_MAX 1024 +#define EQ_FIR_FILTER_SIZE_MAX 128 +#define EQ_SUBBAND_COUNT_MAX 256 +#define EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT_MAX 32 +#define EQ_INTERMEDIATE_PARAMETER_COUNT_MAX 32 +#define EQ_FILTER_SECTION_COUNT_MAX 8 +#define EQ_FILTER_ELEMENT_COUNT_MAX 4 +#define EQ_FILTER_COUNT_MAX 4 +#define MATCHING_PHASE_FILTER_COUNT_MAX 32 + +#define EQ_FILTER_DOMAIN_NONE 0 +#define EQ_FILTER_DOMAIN_TIME (1<<0) +#define EQ_FILTER_DOMAIN_SUBBAND (1<<1) + +#ifdef __cplusplus +extern "C" +{ +#endif + + + +typedef struct { + WORD32 delay; + FLOAT32 state[EQ_CHANNEL_COUNT_MAX][EQ_AUDIO_DELAY_MAX]; +} ia_audio_delay_struct; + +typedef struct { + FLOAT32 radius; + FLOAT32 coeff[2]; +} ia_2nd_order_filt_params_struct; + +typedef struct { + WORD32 coeff_count; + FLOAT32 coeff[EQ_FIR_FILTER_SIZE_MAX]; + FLOAT32 state[EQ_CHANNEL_COUNT_MAX][EQ_FIR_FILTER_SIZE_MAX]; +} ia_fir_filter_struct; + +typedef struct { + WORD32 eq_frame_size_subband; + WORD32 coeff_count; + FLOAT32 subband_coeff[EQ_SUBBAND_COUNT_MAX]; +} ia_subband_filt_struct; + +typedef struct { + WORD32 filter_format; + WORD32 filter_param_count_of_zeros; + ia_2nd_order_filt_params_struct ord_2_filt_params_of_zeros[EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT_MAX]; + WORD32 filter_param_count_of_poles; + ia_2nd_order_filt_params_struct ord_2_filt_params_of_poles[EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT_MAX]; + WORD32 filter_param_count_of_fir; + ia_fir_filter_struct fir_filter; +} ia_interm_filt_params_struct; + +typedef struct { + WORD32 interm_filt_param_count; + ia_interm_filt_params_struct interm_filt_params[EQ_INTERMEDIATE_PARAMETER_COUNT_MAX]; +} IntermediateParams; + +typedef struct { + FLOAT32 in_state_1; + FLOAT32 in_state_2; + FLOAT32 out_state_1; + FLOAT32 out_state_2; +} ia_filt_sect_state_struct; + +typedef struct { + FLOAT32 a1; + FLOAT32 a2; + FLOAT32 b1; + FLOAT32 b2; + ia_filt_sect_state_struct filt_sect_state[EQ_CHANNEL_COUNT_MAX]; +} ia_filt_sect_struct; + +typedef struct { + WORD32 member_count; + WORD32 member_idx[EQ_CHANNEL_GROUP_COUNT_MAX]; +} ia_cascade_align_group_struct; + +typedef struct { + WORD32 validity_flag; + WORD32 num_matches_filter; + WORD32 matches_filter[EQ_FILTER_SECTION_COUNT_MAX]; + FLOAT32 gain; + WORD32 section_count; + ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX]; + ia_audio_delay_struct audio_delay; +} ia_ph_alignment_filt_struct; + +typedef ia_ph_alignment_filt_struct ia_matching_ph_filt_struct; + +typedef struct { + WORD32 matches_cascade_idx; + WORD32 all_pass_count; + ia_matching_ph_filt_struct matching_ph_filt[MATCHING_PHASE_FILTER_COUNT_MAX]; +} ia_all_pass_chain_struct; + +typedef struct { + WORD32 section_count; + ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX]; + WORD32 filt_coeffs_flag; + ia_fir_filter_struct fir_filter; + ia_audio_delay_struct audio_delay; +} ia_pole_zero_filt_struct; + +typedef struct { + FLOAT32 elementGainLinear; + WORD32 format; + ia_pole_zero_filt_struct pstr_pole_zero_filt; + ia_fir_filter_struct fir_filter; + WORD32 num_ph_align_filt; + ia_ph_alignment_filt_struct ph_alignment_filt[EQ_FILTER_ELEMENT_COUNT_MAX]; +} ia_eq_filt_ele_struct; + +typedef struct { + WORD32 element_count; + ia_eq_filt_ele_struct eq_filt_element[EQ_FILTER_ELEMENT_COUNT_MAX]; + ia_matching_ph_filt_struct matching_ph_filt_ele_0; +} ia_eq_filt_block_struct; + +typedef struct { + FLOAT32 cascade_gain_linear; + WORD32 block_count; + ia_eq_filt_block_struct pstr_eq_filt_block[EQ_FILTER_BLOCK_COUNT_MAX]; + WORD32 num_ph_align_filt; + ia_ph_alignment_filt_struct ph_alignment_filt[EQ_FILTER_BLOCK_COUNT_MAX * EQ_FILTER_BLOCK_COUNT_MAX]; +} ia_filt_cascade_td_struct; + +typedef struct { + WORD32 domain; + WORD32 audio_num_chan; + WORD32 eq_ch_group_count; + WORD32 eq_ch_group_of_channel[EQ_CHANNEL_COUNT_MAX]; + ia_filt_cascade_td_struct filt_cascade_td[EQ_CHANNEL_GROUP_COUNT_MAX]; + ia_subband_filt_struct subband_filt[EQ_CHANNEL_GROUP_COUNT_MAX]; +} ia_eq_set_struct; + + + +WORD32 +impd_derive_eq_set (ia_eq_coeff_struct* str_eq_coeff, + ia_eq_instructions_struct* str_eq_instructions, + FLOAT32 sample_rate, + WORD32 drc_frame_size, + WORD32 sub_band_domain_mode, + ia_eq_set_struct* eq_set); + +VOID impd_get_eq_set_delay (ia_eq_set_struct* eq_set, + WORD32* cascade_delay); +WORD32 +impd_process_eq_set_td(ia_eq_set_struct* eq_set, + WORD32 channel, + FLOAT32 audio_in, + FLOAT32* audio_out); + +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 +#endif diff --git a/decoder/drc_src/impd_drc_error_codes.h b/decoder/drc_src/impd_drc_error_codes.h new file mode 100644 index 0000000..3a6940b --- /dev/null +++ b/decoder/drc_src/impd_drc_error_codes.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * 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_ERROR_CODES_H +#define IMPD_DRC_ERROR_CODES_H + +#define IA_ERROR_CODE WORD32 +#define IA_NO_ERROR 0x00000000 + +/*API Non-Fatal Errors */ +#define IA_DRC_DEC_API_NONFATAL_NO_ERROR 0x00000000 +#define IA_DRC_DEC_API_NONFATAL_CMD_NOT_SUPPORTED 0x00000001 +#define IA_DRC_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED 0x00000002 + + +/*API Fatal Errors */ +#define IA_DRC_DEC_API_FATAL_INVALID_MEMTAB_INDEX 0xFFFF8000 +#define IA_DRC_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX 0xFFFF8001 +#define IA_DRC_DEC_API_FATAL_MEM_ALLOC 0xFFFF8002 +#define IA_DRC_DEC_API_FATAL_INVALID_CONFIG_PARAM 0xFFFF8003 +#define IA_DRC_DEC_API_FATAL_INVALID_EXECUTE_TYPE 0xFFFF8004 +#define IA_DRC_DEC_API_FATAL_INVALID_CMD 0xFFFF8005 +#define IA_DRC_DEC_API_FATAL_MEM_ALIGN 0xFFFF8006 +/*****************************************************************************/ +/* Class 1: Configuration Errors */ +/*****************************************************************************/ + + +/* Non Fatal Errors */ +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS 0x00000800 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ 0x00000801 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE 0x00000802 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE 0x00000803 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE 0x00000804 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000805 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG 0x00000806 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX 0x00000807 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY 0x00000808 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CONST_DELAY_MODE 0x00000809 + +#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 new file mode 100644 index 0000000..9332a24 --- /dev/null +++ b/decoder/drc_src/impd_drc_extr_delta_coded_info.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * 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 +#include + +#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_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_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 = ia_drc_gain_tbls_prof_2; + *num_entries = NUM_GAIN_TBL_PROF_2_ENTRIES; + } + else + { + *delta_time_code_tbl = ia_drc_gain_tbls_prof_0_1; + *num_entries = NUM_GAIN_TBL_PROF_0_1_ENTRIES; + } +} + +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< +#include +#include + +#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; gnum_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; gnum_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; gnum_drc_ch_groups; g++) + { + for (b=1; bgain_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 CHANNEL_GROUP_COUNT_MAX * 3) + { + return -1 ; + } + } + } + } + } + + i=0; + while (i0){ + for(i=0;istr_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; ix_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; ix_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; inum_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_filter_bank.c b/decoder/drc_src/impd_drc_filter_bank.c new file mode 100644 index 0000000..23cd21d --- /dev/null +++ b/decoder/drc_src/impd_drc_filter_bank.c @@ -0,0 +1,505 @@ +/****************************************************************************** + * + * 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 +#include +#include + +#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_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; gnum_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; gnum_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; gnum_drc_ch_groups; g++) + { + for (b=1; bgain_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 CHANNEL_GROUP_COUNT_MAX * 3) + { + return -1 ; + } + } + } + } + } + + i=0; + while (i0){ + for(i=0;istr_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; ix_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; ix_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; inum_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_filter_bank.h b/decoder/drc_src/impd_drc_filter_bank.h new file mode 100644 index 0000000..5ab4f8a --- /dev/null +++ b/decoder/drc_src/impd_drc_filter_bank.h @@ -0,0 +1,165 @@ +/****************************************************************************** + * + * 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_FILTER_BANK_H +#define IMPD_DRC_FILTER_BANK_H + +#define FILTER_BANK_PARAMETER_COUNT 16 +#define CASCADE_ALLPASS_COUNT_MAX 9 +#define QMF_NUM_FILT_BANDS 64 +#define QMF_FILT_RESOLUTION 64 + + +typedef struct ia_drc_qmf_filt_struct +{ + +FLOAT64* ana_buff; +FLOAT64* syn_buff; +FLOAT64 ana_tab_real[QMF_NUM_FILT_BANDS][2*QMF_NUM_FILT_BANDS]; +FLOAT64 ana_tab_imag[QMF_NUM_FILT_BANDS][2*QMF_NUM_FILT_BANDS]; +FLOAT64 syn_tab_real[2*QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS]; +FLOAT64 syn_tab_imag[2*QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS]; + +}ia_drc_qmf_filt_struct; + +typedef struct { + FLOAT32 f_cross_norm; + FLOAT32 gamma; + FLOAT32 delta; +} ia_filter_bank_params_struct; + + +typedef struct { + FLOAT32 s00; + FLOAT32 s01; + FLOAT32 s10; + FLOAT32 s11; +} ia_lr_filter_state_struct; + + +typedef struct { + FLOAT32 s0; + FLOAT32 s1; +} ia_all_pass_filter_state_struct; + +typedef struct { + FLOAT32 a0; + FLOAT32 a1; + FLOAT32 a2; + FLOAT32 b0; + FLOAT32 b1; + FLOAT32 b2; + FLOAT32 x_p[MAX_CHANNEL_COUNT*2]; + FLOAT32 y_p[MAX_CHANNEL_COUNT*2]; +} ia_iir_filter_struct; +typedef struct { + ia_iir_filter_struct low_pass; + ia_iir_filter_struct high_pass; +} ia_two_band_filt_struct; + +typedef struct { + ia_iir_filter_struct str_low_pass_stage_1; + ia_iir_filter_struct str_high_pass_stage_1; + ia_iir_filter_struct str_low_pass_stage_2; + ia_iir_filter_struct str_high_pass_stage_2; + ia_iir_filter_struct str_all_pass_stage_2; +} ia_three_band_filt_struct; + +typedef struct { + ia_iir_filter_struct str_low_pass_stage_1; + ia_iir_filter_struct str_high_pass_stage_1; + ia_iir_filter_struct str_all_pass_stage_2_high; + ia_iir_filter_struct str_all_pass_stage_2_low; + ia_iir_filter_struct str_low_pass_stage_3_high; + ia_iir_filter_struct str_high_pass_stage_3_high; + ia_iir_filter_struct str_low_pass_stage_3_low; + ia_iir_filter_struct str_high_pass_stage_3_low; +} ia_four_band_filt_struct; + +typedef struct { + ia_iir_filter_struct str_all_pass_stage; +} ia_all_pass_filter_sturct; + +typedef struct { + ia_all_pass_filter_sturct str_all_pass_cascade_filter[CASCADE_ALLPASS_COUNT_MAX]; + WORD32 num_filter; +} ia_all_pass_cascade_struct; + +typedef struct { + WORD32 num_bands; + WORD32 complexity; + 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; + ia_all_pass_cascade_struct str_all_pass_cascade; +} ia_drc_filter_bank_struct; + +typedef struct { + WORD32 nfilter_banks; + WORD32 num_ph_align_ch_groups; + WORD32 complexity; + ia_drc_filter_bank_struct str_drc_filter_bank[8]; +} ia_filter_banks_struct; + + +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); + +VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); + +VOID impd_three_band_filter_process(ia_three_band_filt_struct* str_three_band_bank, + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); + +VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); + +VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_cascade, + WORD32 c, + WORD32 size, + FLOAT32* audio_in); + +WORD32 +impd_shape_filt_block_init(ia_shape_filter_block_params_struct* pstr_shape_filter_block_params, + shape_filter_block* shape_filter_block); + +WORD32 +impd_shape_filt_block_adapt(const FLOAT32 drc_gain, + shape_filter_block* shape_filter_block); + + + +WORD32 impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block, + FLOAT32* drc_gain, + const WORD32 channel, + FLOAT32 *audio_in, + WORD32 start, + WORD32 end); +#endif diff --git a/decoder/drc_src/impd_drc_gain_dec.c b/decoder/drc_src/impd_drc_gain_dec.c new file mode 100644 index 0000000..562e056 --- /dev/null +++ b/decoder/drc_src/impd_drc_gain_dec.c @@ -0,0 +1,752 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#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_filter_bank.h" +#include "impd_drc_gain_dec.h" +#include "impd_parametric_drc_dec.h" +#include "impd_drc_multi_band.h" +#include "impd_drc_process_audio.h" +#include "impd_drc_eq.h" +#include "impd_drc_gain_decoder.h" + +extern ia_cicp_sigmoid_characteristic_param_struct pstr_cicp_sigmoid_characteristic_param[]; + +WORD32 impd_gain_db_to_lin (ia_interp_params_struct* interp_params_str, + WORD32 drc_band, + FLOAT32 in_param_db_gain, + FLOAT32 in_param_db_slope, + FLOAT32* out_param_lin_gain, + FLOAT32* out_param_lin_slope) +{ + + FLOAT32 loc_db_gain = in_param_db_gain; + FLOAT32 gain_ratio = 1.0; + + ia_gain_modifiers_struct* pstr_gain_modifiers = interp_params_str->pstr_gain_modifiers; + if (interp_params_str->gain_modification_flag) { + + if ((interp_params_str->characteristic_index > 0) && (loc_db_gain != 0.0f)){ + + gain_ratio = 1.0f; + } + + + if (loc_db_gain < 0.0f) { + gain_ratio *= interp_params_str->compress; + } + else { + gain_ratio *= interp_params_str->boost; + } + } + if (pstr_gain_modifiers->gain_scaling_flag[drc_band] == 1) { + if (loc_db_gain < 0.0) { + gain_ratio *= pstr_gain_modifiers->attn_scaling[drc_band]; + } + else { + gain_ratio *= pstr_gain_modifiers->ampl_scaling[drc_band]; + } + } + if ((interp_params_str->pstr_ducking_modifiers->ducking_scaling_flag == 1) && (interp_params_str->ducking_flag == 1)) { + gain_ratio *= interp_params_str->pstr_ducking_modifiers->ducking_scaling; + } + + { + *out_param_lin_gain = (FLOAT32)pow(2.0, (FLOAT64)(gain_ratio * loc_db_gain / 6.0f)); + *out_param_lin_slope = SLOPE_FACTOR_DB_TO_LINEAR * gain_ratio * *out_param_lin_gain * in_param_db_slope; + + if (pstr_gain_modifiers->gain_offset_flag[drc_band] == 1) { + *out_param_lin_gain *= (FLOAT32)pow(2.0, (FLOAT64)(pstr_gain_modifiers->gain_offset[drc_band]/6.0f)); + } + if ((interp_params_str->limiter_peak_target_present == 1) && (interp_params_str->clipping_flag == 1)) { + *out_param_lin_gain *= (FLOAT32)pow(2.0, max(0.0, -interp_params_str->limiter_peak_target - interp_params_str->loudness_normalization_gain_db)/6.0); + if (*out_param_lin_gain >= 1.0) { + *out_param_lin_gain = 1.0; + *out_param_lin_slope = 0.0; + } + } + } + return (0); +} + + + + + + + +WORD32 +impd_compressor_io_sigmoid(ia_split_drc_characteristic_struct* split_drc_characteristic, + FLOAT32 in_db_level, + FLOAT32* out_db_gain) +{ + FLOAT32 tmp; + FLOAT32 in_out_ratio = split_drc_characteristic->in_out_ratio; + FLOAT32 gainDbLimit = split_drc_characteristic->gain; + FLOAT32 exp = split_drc_characteristic->exp; + + tmp = (DRC_INPUT_LOUDNESS_TARGET - in_db_level) * in_out_ratio; + if (exp < 1000.0f) { + FLOAT32 x = tmp/gainDbLimit; + if (x < 0.0f) + { + return(UNEXPECTED_ERROR); + } + *out_db_gain = (FLOAT32)(tmp / pow(1.0f + pow(x, exp), 1.0f/exp)); + } else { + *out_db_gain = tmp; + } + if (split_drc_characteristic->flip_sign == 1) { + *out_db_gain = - *out_db_gain; + } + return (0); +} + +WORD32 +impd_compressor_io_sigmoid_inv(ia_split_drc_characteristic_struct* split_drc_characteristic, + FLOAT32 loc_db_gain, + FLOAT32* in_level) +{ + FLOAT32 in_out_ratio = split_drc_characteristic->in_out_ratio; + FLOAT32 gainDbLimit = split_drc_characteristic->gain; + FLOAT32 exp = split_drc_characteristic->exp; + FLOAT32 tmp = loc_db_gain; + + if (split_drc_characteristic->flip_sign == 1) { + tmp = - loc_db_gain; + } + if (exp < 1000.0f) { + FLOAT32 x = tmp/gainDbLimit; + if (x < 0.0f) + { + return(UNEXPECTED_ERROR); + } + tmp = (FLOAT32)(tmp / pow(1.0f - pow(x, exp), 1.0f / exp)); + } + *in_level = DRC_INPUT_LOUDNESS_TARGET - tmp / in_out_ratio; + + return(0); +} + +WORD32 +impd_compressor_io_nodes_lt(ia_split_drc_characteristic_struct* split_drc_characteristic, + FLOAT32 in_db_level, + FLOAT32 *out_db_gain) +{ + WORD32 n; + FLOAT32 w; + FLOAT32* node_level = split_drc_characteristic->node_level; + FLOAT32* node_gain = split_drc_characteristic->node_gain; + + if (in_db_level > DRC_INPUT_LOUDNESS_TARGET) + { + return (UNEXPECTED_ERROR); + } + for (n=1; n<=split_drc_characteristic->characteristic_node_count; n++) { + if ((in_db_level <= node_level[n-1]) && (in_db_level > node_level[n])) { + w = (node_level[n]- in_db_level)/(node_level[n]-node_level[n-1]); + *out_db_gain =(FLOAT32) (w * node_gain[n-1] + (1.0-w) * node_gain[n]); + } + } + *out_db_gain = node_gain[split_drc_characteristic->characteristic_node_count]; + return (0); +} + +WORD32 +impd_compressor_io_nodes_rt(ia_split_drc_characteristic_struct* split_drc_characteristic, + FLOAT32 in_db_level, + FLOAT32 *out_db_gain) +{ + WORD32 n; + FLOAT32 w; + FLOAT32* node_level = split_drc_characteristic->node_level; + FLOAT32* node_gain = split_drc_characteristic->node_gain; + + if (in_db_level < DRC_INPUT_LOUDNESS_TARGET) + { + return (UNEXPECTED_ERROR); + } + for (n=1; n<=split_drc_characteristic->characteristic_node_count; n++) { + if ((in_db_level >= node_level[n-1]) && (in_db_level < node_level[n])) { + w =(FLOAT32) (node_level[n]- in_db_level)/(node_level[n]-node_level[n-1]); + *out_db_gain = (FLOAT32)(w * node_gain[n-1] + (1.0-w) * node_gain[n]); + } + } + *out_db_gain = (node_gain[split_drc_characteristic->characteristic_node_count]); + return (0); +} + + +WORD32 +impd_compressor_io_nodes_inverse(ia_split_drc_characteristic_struct* split_drc_characteristic, + FLOAT32 loc_db_gain, + FLOAT32 *in_level) +{ + WORD32 n; + FLOAT32 w; + FLOAT32* node_level = split_drc_characteristic->node_level; + FLOAT32* node_gain = split_drc_characteristic->node_gain; + WORD32 node_count = split_drc_characteristic->characteristic_node_count; + + if (node_gain[1] < 0.0f) { + if (loc_db_gain <= node_gain[node_count]) { + *in_level = node_level[node_count]; + } + else { + if (loc_db_gain >= 0.0f) { + *in_level = DRC_INPUT_LOUDNESS_TARGET; + } + else { + for (n=1; n<=node_count; n++) { + if ((loc_db_gain <= node_gain[n-1]) && (loc_db_gain > node_gain[n])) { + w = (node_gain[n]-loc_db_gain)/(node_gain[n]-node_gain[n-1]); + *in_level =(FLOAT32) (w * node_level[n-1] + (1.0-w) * node_level[n]); + } + } + } + } + } + else { + if (loc_db_gain >= node_gain[node_count]) { + *in_level = node_level[node_count]; + } + else { + if (loc_db_gain <= 0.0f) { + *in_level = DRC_INPUT_LOUDNESS_TARGET; + } + else { + for (n=1; n<=node_count; n++) { + if ((loc_db_gain >= node_gain[n-1]) && (loc_db_gain < node_gain[n])) { + w = (FLOAT32)(node_gain[n]-loc_db_gain)/(node_gain[n]-node_gain[n-1]); + *in_level =(FLOAT32) (w * node_level[n-1] + (1.0-w) * node_level[n]); + } + } + } + } + } + return (0); +} + + +WORD32 +impd_map_gain ( + ia_split_drc_characteristic_struct* split_drc_characteristic_source, + ia_split_drc_characteristic_struct* split_drc_characteristic_target, + FLOAT32 gain_in_db, + FLOAT32* gain_out_db) +{ + FLOAT32 inLevel; + WORD32 err = 0; + + switch (split_drc_characteristic_source->characteristic_format) { + case CHARACTERISTIC_SIGMOID: + err = impd_compressor_io_sigmoid_inv(split_drc_characteristic_source, gain_in_db, &inLevel); + if (err) return (err); + break; + case CHARACTERISTIC_NODES: + err = impd_compressor_io_nodes_inverse(split_drc_characteristic_source, gain_in_db, &inLevel); + if (err) return (err); + break; + case CHARACTERISTIC_PASS_THRU: + inLevel = gain_in_db; + break; + default: + return(UNEXPECTED_ERROR); + break; + } + switch (split_drc_characteristic_target->characteristic_format) { + case CHARACTERISTIC_SIGMOID: + err = impd_compressor_io_sigmoid(split_drc_characteristic_target, inLevel, gain_out_db); + if (err) return (err); + break; + case CHARACTERISTIC_NODES: + if (inLevel < DRC_INPUT_LOUDNESS_TARGET) { + err = impd_compressor_io_nodes_lt(split_drc_characteristic_target, inLevel, gain_out_db); + if (err) return (err); + } + else { + err = impd_compressor_io_nodes_rt(split_drc_characteristic_target, inLevel, gain_out_db); + if (err) return (err); + } + break; + case CHARACTERISTIC_PASS_THRU: + *gain_out_db = inLevel; + break; + default: + break; + } + return (0); +} + +WORD32 +impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, + WORD32 drc_band, + FLOAT32 in_param_db_gain, + FLOAT32 in_param_db_slope, + FLOAT32* out_param_lin_gain, + FLOAT32* out_param_lin_slope) +{ + WORD32 err = 0; + FLOAT32 loc_db_gain = in_param_db_gain; + FLOAT32 gain_ratio = 1.0; + FLOAT32 mapped_db_gain; + ia_gain_modifiers_struct* pstr_gain_modifiers = interp_params_str->pstr_gain_modifiers; + if (interp_params_str->gain_modification_flag) { + ia_split_drc_characteristic_struct* split_drc_characteristic_source; + + WORD32 slopeIsNegative; + + if (interp_params_str->drc_characteristic_present) { + if (interp_params_str->drc_source_characteristic_cicp_format) + { + + } + else { + slopeIsNegative = 0; + split_drc_characteristic_source = interp_params_str->split_source_characteristic_left; + if (split_drc_characteristic_source->characteristic_format == 0) + { + slopeIsNegative = 1; + } + else + { + if (split_drc_characteristic_source->node_gain[1] > 0.0f) { + slopeIsNegative = 1; + } + } + if (loc_db_gain == 0.0f) { + if (((pstr_gain_modifiers->target_characteristic_left_present[drc_band] == 1) && + (interp_params_str->split_target_characteristic_left->characteristic_format == CHARACTERISTIC_PASS_THRU)) || + ((pstr_gain_modifiers->target_characteristic_right_present[drc_band] == 1) && + (interp_params_str->split_target_characteristic_right->characteristic_format == CHARACTERISTIC_PASS_THRU))) + { + mapped_db_gain = DRC_INPUT_LOUDNESS_TARGET; + loc_db_gain = DRC_INPUT_LOUDNESS_TARGET; + } + } + else + { + if (((loc_db_gain > 0.0f) && (slopeIsNegative == 1)) || ((loc_db_gain < 0.0f) && (slopeIsNegative == 0))) + { + if (pstr_gain_modifiers->target_characteristic_left_present[drc_band] == 1) + { + err = impd_map_gain(split_drc_characteristic_source, interp_params_str->split_target_characteristic_left, loc_db_gain, &mapped_db_gain); + if (err) return (err); + gain_ratio = mapped_db_gain / loc_db_gain; + } + + } + else if (((loc_db_gain < 0.0f) && (slopeIsNegative == 1)) || ((loc_db_gain > 0.0f) && (slopeIsNegative == 0))) + { + if (pstr_gain_modifiers->target_characteristic_right_present[drc_band] == 1) + { + split_drc_characteristic_source = interp_params_str->split_source_characteristic_right; + err = impd_map_gain(split_drc_characteristic_source, interp_params_str->split_target_characteristic_right, loc_db_gain, &mapped_db_gain); + if (err) return (err); + gain_ratio = mapped_db_gain / loc_db_gain; + } + } + } + } + } + + if (loc_db_gain < 0.0f) { + gain_ratio *= interp_params_str->compress; + } + else { + gain_ratio *= interp_params_str->boost; + } + } + if (pstr_gain_modifiers->gain_scaling_flag[drc_band] == 1) { + if (loc_db_gain < 0.0) { + gain_ratio *= pstr_gain_modifiers->attn_scaling[drc_band]; + } + else { + gain_ratio *= pstr_gain_modifiers->ampl_scaling[drc_band]; + } + } + if ((interp_params_str->pstr_ducking_modifiers->ducking_scaling_flag == 1) && (interp_params_str->ducking_flag == 1)) { + gain_ratio *= interp_params_str->pstr_ducking_modifiers->ducking_scaling; + } + + if (interp_params_str->interpolation_loud_eq == 1) + { + *out_param_lin_gain = gain_ratio * loc_db_gain + pstr_gain_modifiers->gain_offset[drc_band]; + *out_param_lin_slope = 0.0f; + } + else + { + *out_param_lin_gain = (FLOAT32)pow(2.0, (FLOAT64)(gain_ratio * loc_db_gain / 6.0f)); + *out_param_lin_slope = SLOPE_FACTOR_DB_TO_LINEAR * gain_ratio * *out_param_lin_gain * in_param_db_slope; + + if (pstr_gain_modifiers->gain_offset_flag[drc_band] == 1) { + *out_param_lin_gain *= (FLOAT32)pow(2.0, (FLOAT64)(pstr_gain_modifiers->gain_offset[drc_band]/6.0f)); + } + if ((interp_params_str->limiter_peak_target_present == 1) && (interp_params_str->clipping_flag == 1)) { + *out_param_lin_gain *= (FLOAT32)pow(2.0, max(0.0, -interp_params_str->limiter_peak_target - interp_params_str->loudness_normalization_gain_db)/6.0); + if (*out_param_lin_gain >= 1.0) { + *out_param_lin_gain = 1.0; + *out_param_lin_slope = 0.0; + } + } + } + return (0); +} + +WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, + WORD32 drc_band, + WORD32 gain_step_tdomain, + FLOAT32 gain0, + FLOAT32 gain1, + FLOAT32 slope0, + FLOAT32 slope1, + FLOAT32* result) +{ + WORD32 err = 0; + WORD32 n; + FLOAT32 k1, k2, a, b, c, d; + FLOAT32 slope_t1; + FLOAT32 slope_t2; + FLOAT32 gain_t1; + FLOAT32 gain_t2; + + WORD32 cubic_interpolation = 1; + WORD32 node_inser; + FLOAT32 node_inser_float; + + if (gain_step_tdomain <= 0) + { + 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) { + 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)) { + node_inser_float = 2.0f * (gain_t2 - gain_t1 - slope_t2 * gain_step_tdomain) / + (slope_t1 - slope_t2); + node_inser = (WORD32) (0.5f + node_inser_float); + if ((node_inser >= 0) && (node_inser < gain_step_tdomain)) { + cubic_interpolation = 0; + + result[0] = gain_t1; + result[gain_step_tdomain] = gain_t2; + + a = 0.5f*(slope_t2 - slope_t1) / node_inser_float; + b = slope_t1; + c = gain_t1; + for (n=1; n= 0) && (node_inser < gain_step_tdomain)) { + cubic_interpolation = 0; + + result[0] = gain_t1; + result[gain_step_tdomain] = gain_t2; + + a = slope_t1; + b = gain_t1; + for (n=1; nbuf_interpolation_count; n++) + { + buf_interpolation = &(pstr_gain_buf->buf_interpolation[n]); + buf_interpolation->prev_node = buf_interpolation->str_node; + buf_interpolation->prev_node.time -= drc_frame_size; + memmove(buf_interpolation->lpcm_gains, buf_interpolation->lpcm_gains + drc_frame_size, sizeof(FLOAT32) * (drc_frame_size + MAX_SIGNAL_DELAY)); + } + return(0); +} +WORD32 +impd_concatenate_segments(WORD32 drc_frame_size, + WORD32 drc_band, + ia_interp_params_struct* interp_params_str, + ia_spline_nodes_struct* str_spline_nodes, + ia_interp_buf_struct* buf_interpolation) +{ + WORD32 timePrev, duration, n, err = 0; + FLOAT32 loc_db_gain = 0.0f, prev_db_gain, slope = 0.0f, slopePrev; + + timePrev = buf_interpolation->prev_node.time; + prev_db_gain = buf_interpolation->prev_node.loc_db_gain; + slopePrev = buf_interpolation->prev_node.slope; + for (n=0; nnum_nodes; n++) + { + duration = str_spline_nodes->str_node[n].time - timePrev; + loc_db_gain = str_spline_nodes->str_node[n].loc_db_gain; + slope = str_spline_nodes->str_node[n].slope; + + err = impd_interpolate_drc_gain(interp_params_str, + drc_band, + duration, + prev_db_gain, + loc_db_gain, + slopePrev, + slope, + buf_interpolation->lpcm_gains + MAX_SIGNAL_DELAY + drc_frame_size + timePrev); + if (err) return (err); + + timePrev = str_spline_nodes->str_node[n].time; + prev_db_gain = loc_db_gain; + slopePrev = slope; + } + + buf_interpolation->str_node.loc_db_gain = loc_db_gain; + buf_interpolation->str_node.slope = slope; + buf_interpolation->str_node.time = timePrev; + + + return(0); +} + +WORD32 +impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + ia_drc_gain_struct* pstr_drc_gain, + FLOAT32 compress, + FLOAT32 boost, + WORD32 characteristic_index, + FLOAT32 loudness_normalization_gain_db, + WORD32 sel_drc_index, + ia_drc_gain_buffers_struct* drc_gain_buffers) +{ + ia_drc_params_struct* ia_drc_params_struct = &(p_drc_gain_dec_structs->ia_drc_params_struct); + WORD32 drc_instructions_index = ia_drc_params_struct->sel_drc_array[sel_drc_index].drc_instructions_index; + if (drc_instructions_index >= 0) + { + WORD32 b, g, gainElementIndex, err = 0; + WORD32 parametricDrcInstanceIndex = 0; + ia_interp_params_struct interp_params_str = {0}; + + ia_drc_instructions_struct* str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[drc_instructions_index]); + WORD32 drc_set_effect = str_drc_instruction_str->drc_set_effect; + WORD32 num_drc_ch_groups = str_drc_instruction_str->num_drc_ch_groups; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; + WORD32 drc_coeff_idx = ia_drc_params_struct->sel_drc_array[sel_drc_index].drc_coeff_idx; + if (drc_coeff_idx >= 0) + { + str_p_loc_drc_coefficients_uni_drc = &(pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[drc_coeff_idx]); + interp_params_str.interpolation_loud_eq = 0; + } + else + { + return (UNEXPECTED_ERROR); + } + + interp_params_str.loudness_normalization_gain_db = loudness_normalization_gain_db; + interp_params_str.characteristic_index = characteristic_index; + interp_params_str.compress = compress; + interp_params_str.boost = boost; + interp_params_str.limiter_peak_target_present = str_drc_instruction_str->limiter_peak_target_present; + interp_params_str.limiter_peak_target = str_drc_instruction_str->limiter_peak_target; + + if ( ((drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) && (drc_set_effect != EFFECT_BIT_FADE) && (drc_set_effect != EFFECT_BIT_CLIPPING)) + { + interp_params_str.gain_modification_flag = 1; + } + else + { + interp_params_str.gain_modification_flag = 0; + } + if (drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + interp_params_str.ducking_flag = 1; + } + else + { + interp_params_str.ducking_flag = 0; + } + if (drc_set_effect == EFFECT_BIT_CLIPPING) + { + interp_params_str.clipping_flag = 1; + } + else + { + interp_params_str.clipping_flag = 0; + } + + err = impd_advance_buf(ia_drc_params_struct->drc_frame_size, &(drc_gain_buffers->pstr_gain_buf[sel_drc_index])); + if (err) return (err); + + gainElementIndex = 0; + for(g=0; ggain_interpolation_type_for_channel_group[g]; + interp_params_str.delta_tmin = str_drc_instruction_str->time_delta_min_for_channel_group[g]; + interp_params_str.pstr_ducking_modifiers = &(str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g]); + interp_params_str.pstr_gain_modifiers = &(str_drc_instruction_str->str_gain_modifiers_of_ch_group[g]); + if (str_drc_instruction_str->ch_group_parametric_drc_flag[g] == 0) { + gainSet = str_drc_instruction_str->gain_set_index_for_channel_group[g]; + num_drc_bands = str_drc_instruction_str->band_count_of_ch_group[g]; + for(b=0; bgain_set_params[gainSet].gain_params[b]); + WORD32 seq = gain_params->gain_seq_idx; + interp_params_str.drc_characteristic_present = gain_params->drc_characteristic_present; + interp_params_str.drc_source_characteristic_cicp_format = gain_params->drc_characteristic_format_is_cicp; + interp_params_str.source_drc_characteristic = gain_params->drc_characteristic; + interp_params_str.split_source_characteristic_left = &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_left [gain_params->drc_characteristic_left_index]); + interp_params_str.split_source_characteristic_right = &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_right[gain_params->drc_characteristic_right_index]); + interp_params_str.split_target_characteristic_left = &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_left [interp_params_str.pstr_gain_modifiers->target_characteristic_left_index[b]]); + interp_params_str.split_target_characteristic_right = &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_right[interp_params_str.pstr_gain_modifiers->target_characteristic_right_index[b]]); + err = impd_concatenate_segments (ia_drc_params_struct->drc_frame_size, + b, + &interp_params_str, + &(pstr_drc_gain->drc_gain_sequence[seq].str_spline_nodes[0]), + &(drc_gain_buffers->pstr_gain_buf[sel_drc_index].buf_interpolation[gainElementIndex])); + if (err) return (err); + gainElementIndex++; + } + } else { + if (ia_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF && !(p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].parametric_drc_type == PARAM_DRC_TYPE_LIM)) { + err = impd_parametric_drc_instance_process (p_drc_gain_dec_structs->audio_in_out_buf.audio_in_out_buf, + NULL, + NULL, + &p_drc_gain_dec_structs->parametricdrc_params, + &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex]); + if (err) return (err); + + err = impd_concatenate_segments(ia_drc_params_struct->drc_frame_size, + 0, + &interp_params_str, + &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].str_spline_nodes, + &(drc_gain_buffers->pstr_gain_buf[sel_drc_index].buf_interpolation[gainElementIndex])); + if (err) return (err); + } else if (ia_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF && p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].parametric_drc_type == PARAM_DRC_TYPE_LIM) { + FLOAT32* lpcm_gains = (drc_gain_buffers->pstr_gain_buf[sel_drc_index].buf_interpolation[gainElementIndex]).lpcm_gains + MAX_SIGNAL_DELAY; + err = impd_parametric_lim_type_drc_process(p_drc_gain_dec_structs->audio_in_out_buf.audio_in_out_buf, + loudness_normalization_gain_db, + &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].str_parametric_drc_type_lim_params, + lpcm_gains); + if (err) return (err); + } else if (ia_drc_params_struct->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && !(p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].parametric_drc_type == PARAM_DRC_TYPE_LIM)) { + err = impd_parametric_drc_instance_process (NULL, + p_drc_gain_dec_structs->audio_in_out_buf.audio_real_buff, + p_drc_gain_dec_structs->audio_in_out_buf.audio_imag_buff, + &p_drc_gain_dec_structs->parametricdrc_params, + &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex]); + if (err) return (err); + + err = impd_concatenate_segments(ia_drc_params_struct->drc_frame_size, + 0, + &interp_params_str, + &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].str_spline_nodes, + &(drc_gain_buffers->pstr_gain_buf[sel_drc_index].buf_interpolation[gainElementIndex])); + if (err) return (err); + + } else { + return (UNEXPECTED_ERROR); + } + gainElementIndex++; + parametricDrcInstanceIndex++; + } + } + } + return (0); +} + diff --git a/decoder/drc_src/impd_drc_gain_dec.h b/decoder/drc_src/impd_drc_gain_dec.h new file mode 100644 index 0000000..5fc7280 --- /dev/null +++ b/decoder/drc_src/impd_drc_gain_dec.h @@ -0,0 +1,97 @@ +/****************************************************************************** + * + * 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_GAIN_DEC_H +#define IMPD_DRC_GAIN_DEC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + ia_node_struct str_node; + ia_node_struct prev_node; + FLOAT32 lpcm_gains[2 * AUDIO_CODEC_FRAME_SIZE_MAX + MAX_SIGNAL_DELAY]; +} ia_interp_buf_struct; + +typedef struct { + WORD32 buf_interpolation_count; + ia_interp_buf_struct* buf_interpolation; +} ia_gain_buffer_struct; + +typedef struct { + ia_gain_buffer_struct pstr_gain_buf[SEL_DRC_COUNT]; +} ia_drc_gain_buffers_struct; + +typedef struct { + WORD32 gain_interpolation_type; + WORD32 gain_modification_flag; + WORD32 ducking_flag; + WORD32 clipping_flag; + ia_ducking_modifiers_struct* pstr_ducking_modifiers; + ia_gain_modifiers_struct* pstr_gain_modifiers; + WORD32 drc_characteristic_present; + WORD32 drc_source_characteristic_cicp_format; + WORD32 source_drc_characteristic; + ia_split_drc_characteristic_struct* split_source_characteristic_left; + ia_split_drc_characteristic_struct* split_source_characteristic_right; + WORD32 drc_target_characteristic_cicp_format; + WORD32 target_drc_characteristic; + ia_split_drc_characteristic_struct* split_target_characteristic_left; + ia_split_drc_characteristic_struct* split_target_characteristic_right; + WORD32 interpolation_loud_eq; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + FLOAT32 loudness_normalization_gain_db; + WORD32 delta_tmin; + WORD32 characteristic_index; + FLOAT32 compress; + FLOAT32 boost; +} ia_interp_params_struct; + + +typedef struct { + WORD32 drc_instructions_index; + WORD32 drc_coeff_idx; + WORD32 dwnmix_instructions_index; +} ia_sel_drc_struct; + +typedef struct { + WORD32 sample_rate; + WORD32 delta_tmin_default; + WORD32 drc_frame_size; + WORD32 delay_mode; + WORD32 sub_band_domain_mode; + WORD32 gain_delay_samples; + WORD32 parametric_drc_delay; + WORD32 eq_delay; + WORD32 audio_delay_samples; + WORD32 drc_set_counter; + WORD32 multiband_sel_drc_idx; + + ia_sel_drc_struct sel_drc_array[SEL_DRC_COUNT]; + +} ia_drc_params_struct; + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_gain_decoder.c b/decoder/drc_src/impd_drc_gain_decoder.c new file mode 100644 index 0000000..0b09722 --- /dev/null +++ b/decoder/drc_src/impd_drc_gain_decoder.c @@ -0,0 +1,498 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include + +#include "impd_type_def.h" +#include "impd_error_standards.h" +#include "impd_drc_extr_delta_coded_info.h" +#include "impd_drc_common.h" +#include "impd_drc_struct.h" +#include "impd_parametric_drc_dec.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_multi_band.h" +#include "impd_drc_interface.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_eq.h" +#include "impd_drc_process_audio.h" +#include "impd_drc_gain_decoder.h" +#include "impd_drc_dec.h" + +IA_ERRORCODE impd_init_drc_decode( WORD32 frame_size, + WORD32 sample_rate, + WORD32 gain_delay_samples, + WORD32 delay_mode, + WORD32 sub_band_domain_mode, + ia_drc_gain_dec_struct* p_drc_gain_dec_structs) +{ + IA_ERRORCODE err_code = IA_NO_ERROR; + + + err_code = impd_init_drc_params(frame_size, + sample_rate, + gain_delay_samples, + delay_mode, + sub_band_domain_mode, + &p_drc_gain_dec_structs->ia_drc_params_struct); + + if (err_code!=IA_NO_ERROR) + return (err_code); + + impd_init_parametric_drc(p_drc_gain_dec_structs->ia_drc_params_struct.drc_frame_size, + sample_rate, + sub_band_domain_mode, + &p_drc_gain_dec_structs->parametricdrc_params); + + if (err_code!=IA_NO_ERROR) + return (err_code); + + return err_code; +} + + +IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num_chan, + WORD32* drc_set_id_processed, + WORD32* downmix_id_processed, + WORD32 num_sets_processed, + WORD32 eq_set_id_processed, + + ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + pVOID *mem_ptr + ) +{ + + IA_ERRORCODE err_code = 0; + WORD32 i,j,k, maxMultibandAudioSignalCount=0; + ia_drc_params_struct* p_drc_params_struct = &p_drc_gain_dec_structs->ia_drc_params_struct; + ia_audio_in_out_buf* p_audio_in_out_buf = &p_drc_gain_dec_structs->audio_in_out_buf; + + for (i = 0; i < num_sets_processed; i++) + { + err_code = impd_init_selected_drc_set(pstr_drc_config, + p_drc_params_struct, + &p_drc_gain_dec_structs->parametricdrc_params, + audio_num_chan, + drc_set_id_processed[i], + downmix_id_processed[i], + &p_drc_gain_dec_structs->ia_filter_banks_struct, + &p_drc_gain_dec_structs->str_overlap_params + ,p_drc_gain_dec_structs->shape_filter_block + ); + if (err_code) + return (err_code); + } + + p_drc_gain_dec_structs->audio_num_chan = audio_num_chan; + p_drc_gain_dec_structs->ia_drc_params_struct.audio_delay_samples = p_drc_gain_dec_structs->ia_drc_params_struct.parametric_drc_delay; + if (pstr_drc_config->str_drc_config_ext.parametric_drc_present) { + err_code = impd_init_parametric_drc_after_config(pstr_drc_config, + pstr_loudness_info, + &p_drc_gain_dec_structs->parametricdrc_params, + mem_ptr); + if (err_code) + return (err_code); + } + + p_audio_in_out_buf->audio_num_chan = audio_num_chan; + p_audio_in_out_buf->audio_delay_samples = p_drc_params_struct->audio_delay_samples; + p_audio_in_out_buf->frame_size = p_drc_params_struct->drc_frame_size; + + + if(p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF64){ + p_audio_in_out_buf->audio_delay_sub_band_samples = p_drc_params_struct->audio_delay_samples / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; + p_audio_in_out_buf->audio_sub_band_frame_size = p_drc_params_struct->drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; + p_audio_in_out_buf->audio_sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_QMF64; + } + else if(p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF71){ + p_audio_in_out_buf->audio_delay_sub_band_samples = p_drc_params_struct->audio_delay_samples / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; + p_audio_in_out_buf->audio_sub_band_frame_size = p_drc_params_struct->drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; + p_audio_in_out_buf->audio_sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_QMF71; + } + else if(p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_STFT256){ + p_audio_in_out_buf->audio_delay_sub_band_samples = p_drc_params_struct->audio_delay_samples / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; + p_audio_in_out_buf->audio_sub_band_frame_size = p_drc_params_struct->drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; + p_audio_in_out_buf->audio_sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_STFT256; + } + else{ + p_audio_in_out_buf->audio_delay_sub_band_samples = 0; + p_audio_in_out_buf->audio_sub_band_frame_size = 0; + p_audio_in_out_buf->audio_sub_band_count = 0; + } + + + + + for (k=0; ksel_drc_array[k].drc_instructions_index >= 0) + { + ia_drc_instructions_struct* drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[p_drc_params_struct->sel_drc_array[k].drc_instructions_index]); + if (drc_instruction_str->gain_element_count > 0) + { + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k].buf_interpolation = (ia_interp_buf_struct*)*mem_ptr; + *mem_ptr=(pVOID)((SIZE_T)*mem_ptr+drc_instruction_str->gain_element_count*sizeof(ia_interp_buf_struct)+32); + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k].buf_interpolation_count = drc_instruction_str->gain_element_count; + for (i=0; idrc_gain_buffers.pstr_gain_buf[i].buf_interpolation_count; i++) + { + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].str_node.time = 0; + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].prev_node.time = -1; + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].str_node.loc_db_gain = 0.0f; + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].str_node.slope = 0.0f; + + for (j=0; j<2 * AUDIO_CODEC_FRAME_SIZE_MAX + MAX_SIGNAL_DELAY; j++) + { + p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].lpcm_gains[j] = 1.f; + } + } + } + } + } + + + + + if (eq_set_id_processed > 0) + { + for(i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + if (pstr_drc_config->str_drc_config_ext.str_eq_instructions[i].eq_set_id == eq_set_id_processed) + break; + } + if (i==pstr_drc_config->str_drc_config_ext.eq_instructions_count) + { + return -1; + } + + + p_drc_gain_dec_structs->eq_set=(ia_eq_set_struct*)*mem_ptr ; + *mem_ptr=(pVOID)((SIZE_T)*mem_ptr+sizeof(ia_eq_set_struct)+32); + + if (err_code) + return (err_code); + + err_code = impd_derive_eq_set (&pstr_drc_config->str_drc_config_ext.str_eq_coeff, + &(pstr_drc_config->str_drc_config_ext.str_eq_instructions[i]), + (FLOAT32)p_drc_gain_dec_structs->ia_drc_params_struct.sample_rate, + p_drc_gain_dec_structs->ia_drc_params_struct.drc_frame_size, + p_drc_gain_dec_structs->ia_drc_params_struct.sub_band_domain_mode, + p_drc_gain_dec_structs->eq_set); + if (err_code) + return (err_code); + + impd_get_eq_set_delay (p_drc_gain_dec_structs->eq_set, + &p_drc_gain_dec_structs->ia_drc_params_struct.eq_delay); + + } + + + + for (i=0; idrc_set_counter; i++) + { + ia_drc_instructions_struct* drc_instruction_str; + drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[p_drc_params_struct->sel_drc_array[i].drc_instructions_index]); + maxMultibandAudioSignalCount = max(maxMultibandAudioSignalCount, drc_instruction_str->multiband_audio_sig_count); + } + + + + + p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio = *mem_ptr; + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(maxMultibandAudioSignalCount*sizeof(FLOAT32*))+32); + + + + for (i=0;iaudio_band_buffer.non_interleaved_audio[i] = *mem_ptr; + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_drc_params_struct->drc_frame_size*sizeof(FLOAT32))+32); + + } + p_drc_gain_dec_structs->audio_band_buffer.multiband_audio_sig_count = maxMultibandAudioSignalCount; + p_drc_gain_dec_structs->audio_band_buffer.frame_size = p_drc_params_struct->drc_frame_size;; + + + if (p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_samples) { + p_audio_in_out_buf->audio_io_buffer_delayed = *mem_ptr; + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_in_out_buf = *mem_ptr; + *mem_ptr =(pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + + for (i=0; iaudio_num_chan; i++) { + p_audio_in_out_buf->audio_io_buffer_delayed[i]=*mem_ptr; + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+((p_audio_in_out_buf->frame_size + p_audio_in_out_buf->audio_delay_samples)*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_in_out_buf[i] = &p_audio_in_out_buf->audio_io_buffer_delayed[i][p_audio_in_out_buf->audio_delay_samples]; + + } + } + if (p_drc_params_struct->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_sub_band_samples) { + + p_audio_in_out_buf->audio_buffer_delayed_real = *mem_ptr; + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_buffer_delayed_imag = *mem_ptr; + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_real_buff = *mem_ptr; + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_imag_buff = *mem_ptr; + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + + + for (i=0; iaudio_num_chan; i++) { + p_audio_in_out_buf->audio_buffer_delayed_real[i] = *mem_ptr; + *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); + p_audio_in_out_buf->audio_buffer_delayed_imag[i] = *mem_ptr; + *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); + + p_audio_in_out_buf->audio_real_buff[i] = &p_audio_in_out_buf->audio_buffer_delayed_real[i][ p_audio_in_out_buf->audio_delay_sub_band_samples * p_audio_in_out_buf->audio_sub_band_count]; + p_audio_in_out_buf->audio_imag_buff[i] = &p_audio_in_out_buf->audio_buffer_delayed_imag[i][ p_audio_in_out_buf->audio_delay_sub_band_samples * p_audio_in_out_buf->audio_sub_band_count]; + } + } + + return err_code; +} + + + + + +IA_ERRORCODE impd_drc_process_time_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_in_out_buf[], + FLOAT32 loudness_normalization_gain_db, + FLOAT32 boost, + FLOAT32 compress, + WORD32 drc_characteristic_target) +{ + WORD32 sel_drc_index; + IA_ERRORCODE err_code = 0; + WORD32 passThru; + 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; + FLOAT32* audio_channel; + for (ch=0; cheq_set->audio_num_chan; ch++) + { + audio_channel = audio_in_out_buf[ch]; + + impd_process_eq_set_time_domain(p_drc_gain_dec_structs->eq_set, ch, audio_channel, audio_channel, p_drc_gain_dec_structs->ia_drc_params_struct.drc_frame_size); + + } + } + + err_code = impd_store_audio_io_buffer_time(audio_in_out_buf, + &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_indexia_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_io_buffer_time(audio_in_out_buf, + &p_drc_gain_dec_structs->audio_in_out_buf); + if (err_code) return (err_code); + } else + { + + for (sel_drc_index=0; sel_drc_indexia_drc_params_struct.drc_set_counter; sel_drc_index++) + { + if (p_drc_gain_dec_structs->ia_drc_params_struct.multiband_sel_drc_idx == sel_drc_index) + { + passThru = 0; + } + else + { + passThru = 1; + } + err_code = impd_filter_banks_process(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->audio_in_out_buf.audio_io_buffer_delayed, + &p_drc_gain_dec_structs->audio_band_buffer, + &p_drc_gain_dec_structs->ia_filter_banks_struct, + passThru); + if(err_code!=IA_NO_ERROR) + return (err_code); + + err_code = impd_apply_gains_and_add(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->shape_filter_block, + p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio, + audio_in_out_buf, + 1); + if(err_code!=IA_NO_ERROR) + return (err_code); + + } + } + } + + err_code = impd_advance_audio_io_buffer_time(&p_drc_gain_dec_structs->audio_in_out_buf); + if(err_code!=IA_NO_ERROR) + return (err_code); + + 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; cheq_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_indexia_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_indexia_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, + ia_drc_config* pstr_drc_config, + WORD32* parametric_drc_delay, + WORD32* parametric_drc_delay_max) +{ + *parametric_drc_delay = p_drc_gain_dec_structs->ia_drc_params_struct.parametric_drc_delay; + + if (pstr_drc_config->str_drc_config_ext.parametric_drc_present && pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_delay_max_present) { + *parametric_drc_delay_max = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_delay_max; + } else if (pstr_drc_config->str_drc_config_ext.parametric_drc_present == 0) { + *parametric_drc_delay_max = 0; + } else { + *parametric_drc_delay_max = -1; + } + + return; +} + +VOID impd_get_eq_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + WORD32* eq_delay, + WORD32* eq_delay_max) +{ + *eq_delay = p_drc_gain_dec_structs->ia_drc_params_struct.eq_delay; + + if (pstr_drc_config->str_drc_config_ext.eq_flag && pstr_drc_config->str_drc_config_ext.str_eq_coeff.eq_delay_max_present) { + *eq_delay_max = pstr_drc_config->str_drc_config_ext.str_eq_coeff.eq_delay_max; + } else if (pstr_drc_config->str_drc_config_ext.eq_flag == 0) { + *eq_delay_max = 0; + } else { + *eq_delay_max = -1; + } + + return; +} + + diff --git a/decoder/drc_src/impd_drc_gain_decoder.h b/decoder/drc_src/impd_drc_gain_decoder.h new file mode 100644 index 0000000..a1d7aef --- /dev/null +++ b/decoder/drc_src/impd_drc_gain_decoder.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * + * 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_GAIN_DECODER2_H +#define IMPD_DRC_GAIN_DECODER2_H + + +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +typedef struct ia_drc_gain_dec_struct +{ + WORD32 audio_num_chan; + ia_drc_params_struct ia_drc_params_struct; + ia_drc_gain_buffers_struct drc_gain_buffers; + ia_audio_band_buffer_struct audio_band_buffer; + ia_overlap_params_struct str_overlap_params; + ia_filter_banks_struct ia_filter_banks_struct; + ia_audio_in_out_buf audio_in_out_buf; + ia_parametric_drc_params_struct parametricdrc_params; + shape_filter_block shape_filter_block[CHANNEL_GROUP_COUNT_MAX]; + ia_eq_set_struct* eq_set; +}ia_drc_gain_dec_struct; + + +WORD32 impd_init_drc_decode( WORD32 frame_size, + WORD32 sample_rate, + WORD32 gain_delay_samples, + WORD32 delay_mode, + WORD32 sub_band_domain_mode, + ia_drc_gain_dec_struct* p_drc_gain_dec_structs); + +WORD32 impd_init_drc_decode_post_config( WORD32 audio_num_chan, + WORD32* drc_set_id_processed, + WORD32* downmix_id_processed, + WORD32 num_sets_processed, + WORD32 eq_set_id_processed, + + ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config * pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + pVOID *mem_ptr + + ); + +WORD32 impd_drc_process_time_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_in_out_buf[], + FLOAT32 loudness_normalization_gain_db, + FLOAT32 boost, + FLOAT32 compress, + WORD32 drc_characteristic); + +WORD32 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); + +VOID impd_get_parametric_drc_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + WORD32* parametric_drc_delay, + WORD32* parametric_drc_delay_max); + +VOID impd_get_eq_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + WORD32* eq_delay, + WORD32* eq_delay_max); + +WORD32 +impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, + ia_drc_config* pstr_drc_config, + ia_drc_gain_struct* pstr_drc_gain, + FLOAT32 compress, + FLOAT32 boost, + WORD32 characteristic_index, + FLOAT32 loudness_normalization_gain_db, + WORD32 sub_drc_index, + ia_drc_gain_buffers_struct* drc_gain_buffers); + + + + + +#endif diff --git a/decoder/drc_src/impd_drc_hashdefines.h b/decoder/drc_src/impd_drc_hashdefines.h new file mode 100644 index 0000000..befa808 --- /dev/null +++ b/decoder/drc_src/impd_drc_hashdefines.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * 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_HASHDEFINES_H +#define IMPD_DRC_HASHDEFINES_H + + +#define DEC_TYPE_TD 0 +#define DEC_TYPE_TD_QMF64 1 +#define DEC_TYPE_QMF64 2 +#define DEC_TYPE_STFT256 3 +#define BITSTREAM_FILE_FORMAT_SPLIT 1 + +#endif diff --git a/decoder/drc_src/impd_drc_host_params.c b/decoder/drc_src/impd_drc_host_params.c new file mode 100644 index 0000000..932a586 --- /dev/null +++ b/decoder/drc_src/impd_drc_host_params.c @@ -0,0 +1,160 @@ +/****************************************************************************** + * + * 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 +#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; inum_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; inum_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; krequested_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 new file mode 100644 index 0000000..61b6970 --- /dev/null +++ b/decoder/drc_src/impd_drc_host_params.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * + * 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 new file mode 100644 index 0000000..77465ac --- /dev/null +++ b/decoder/drc_src/impd_drc_init.c @@ -0,0 +1,573 @@ +/****************************************************************************** + * + * 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 +#include +#include "impd_type_def.h" +#include "impd_error_standards.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_memory_standards.h" +#include "impd_drc_peak_limiter.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_peak_limiter.h" +#include "impd_drc_host_params.h" + + +#define PARAMETRIC_DRC_DELAY_MAX_DEFAULT 4096 +#define EQ_DELAY_MAX_DEFAULT 256 + +IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, + WORD32 iCmd, WORD32 iIdx, pVOID pvValue); + +IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc); + +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); + + + +#define NUM_GAIN_DEC_INSTANCES 2 + +#define BITSTREAM_FILE_FORMAT_SPLIT 1 +#define LIM_DEFAULT_THRESHOLD (0.89125094f) + +static WORD32 impd_match_downmix(WORD32 downmix_id, WORD32 dec_downmix_id) +{ + WORD32 id_match = 0; + + switch (dec_downmix_id ) + { + case 0: + id_match = (downmix_id == 0); + break; + case 1: + id_match = ( (downmix_id == 0) || (downmix_id == 0x7F) ); + break; + case 2: + id_match = (downmix_id == 0x7F); + break; + case 3: + id_match = ( (downmix_id != 0) && (downmix_id != 0x7F) ); + break; + case 4: + id_match = (downmix_id != 0); + break; + } + return id_match; +} + +IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) +{ + p_obj_drc->str_config.bitstream_file_format = 0; + 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; + p_obj_drc->str_config.sub_band_down_sampling_factor = 0; + p_obj_drc->str_config.sampling_rate = 0; + p_obj_drc->str_config.frame_size = 1024; + p_obj_drc->str_config.num_ch_in = -1; + p_obj_drc->str_config.num_ch_out = -1; + 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.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_config.constant_delay_on = 0; + p_obj_drc->str_config.audio_delay_samples = 0; + p_obj_drc->str_bit_handler.byte_index_bs = 0; + p_obj_drc->str_bit_handler.num_bytes_bs = 0; + p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; + p_obj_drc->str_bit_handler.num_bits_read_bs = 0; + p_obj_drc->str_bit_handler.cpy_over = 0; + p_obj_drc->str_bit_handler.num_bytes_bs_drc_config = 0; + p_obj_drc->str_bit_handler.cpy_over_ic = 0; + p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info = 0; + p_obj_drc->str_bit_handler.cpy_over_il = 0; + p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface = 0; + p_obj_drc->str_bit_handler.num_bits_read_bs_unidrc_interface = 0; + p_obj_drc->str_bit_handler.cpy_over_in = 0; + p_obj_drc->str_bit_handler.gain_stream_flag = 0; + + return IA_NO_ERROR; +} + + +IA_ERRORCODE impd_drc_set_default_bitstream_config(ia_drc_config *pstr_drc_config) +{ + WORD32 i; + + pstr_drc_config->sample_rate_present=0; + pstr_drc_config->sampling_rate=0; + pstr_drc_config->dwnmix_instructions_count=0; + pstr_drc_config->drc_coefficients_drc_count=1; + pstr_drc_config->drc_instructions_uni_drc_count=4; + pstr_drc_config->drc_instructions_count_plus=5; + pstr_drc_config->drc_description_basic_present=0; + pstr_drc_config->drc_coefficients_basic_count=0; + pstr_drc_config->drc_instructions_basic_count=0; + pstr_drc_config->drc_config_ext_present=1; + pstr_drc_config->apply_drc=0; + pstr_drc_config->str_drc_config_ext.drc_config_ext_type[0]=2; + pstr_drc_config->str_drc_config_ext.ext_bit_size[0]=345; + pstr_drc_config->str_drc_config_ext.parametric_drc_present=0; + pstr_drc_config->str_drc_config_ext.drc_extension_v1_present=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].version=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].drc_location=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count=4; + for(i=0;istr_p_loc_drc_coefficients_uni_drc[0].gain_set_count;i++) + { + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].gain_interpolation_type=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].band_count=1; + } + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_sequence_count=4; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[0]=0; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[1]=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[2]=2; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[3]=3; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count_plus=4; + pstr_drc_config->str_drc_instruction_str[0].drc_set_id=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[0].drc_location=1; + pstr_drc_config->str_drc_instruction_str[0].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_effect=1; + pstr_drc_config->str_drc_instruction_str[0].gain_set_index[1]=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[0].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[0].gain_set_index_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[0].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[1].drc_set_id=2; + pstr_drc_config->str_drc_instruction_str[1].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[1].drc_location=1; + pstr_drc_config->str_drc_instruction_str[1].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[1].drc_set_effect=2; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index[1]=2; + pstr_drc_config->str_drc_instruction_str[1].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[1].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[1]=2; + pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[1].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[2].drc_set_id=3; + pstr_drc_config->str_drc_instruction_str[2].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[2].drc_location=1; + pstr_drc_config->str_drc_instruction_str[2].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[2].drc_set_effect=4; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index[0]=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index[1]=3; + pstr_drc_config->str_drc_instruction_str[2].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[2].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[0]=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[1]=3; + pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[2].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[3].drc_set_id=4; + pstr_drc_config->str_drc_instruction_str[3].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[3].drc_location=1; + pstr_drc_config->str_drc_instruction_str[3].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[3].drc_set_effect=32; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index[0]=3; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index[1]=0; + pstr_drc_config->str_drc_instruction_str[3].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[3].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[0]=3; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[1]=0; + pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[3].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[4].drc_set_id=-1; + pstr_drc_config->str_drc_instruction_str[4].dwnmix_id_count=1; + pstr_drc_config->channel_layout.base_channel_count=2; + + return IA_NO_ERROR; +} + + +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; + + p_obj_drc->str_payload.pstr_bitstream_dec = (ia_drc_bits_dec_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_bits_dec_struct)+32; + + p_obj_drc->str_payload.pstr_gain_dec[0] = (ia_drc_gain_dec_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_dec_struct)+32; + + p_obj_drc->str_payload.pstr_gain_dec[1] = (ia_drc_gain_dec_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_dec_struct)+32; + + p_obj_drc->str_payload.pstr_loudness_info = (ia_drc_loudness_info_set_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_loudness_info_set_struct)+32; + + p_obj_drc->str_payload.pstr_drc_gain = (ia_drc_gain_struct*)persistant_ptr;; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_struct)+32; + + p_obj_drc->str_payload.pstr_drc_interface = (ia_drc_interface_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_interface_struct)+32; + + p_obj_drc->str_payload.pstr_drc_config = (ia_drc_config*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_config)+32; + + p_obj_drc->str_payload.pstr_selection_proc = (ia_drc_sel_pro_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_sel_pro_struct)+32; + + p_obj_drc->str_bit_handler.it_bit_buf = (UWORD8*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 32*1024; /*varify the sizelater*/ + + p_obj_drc->str_payload.pstr_drc_sel_proc_params = (ia_drc_sel_proc_params_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_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 = (SIZE_T)persistant_ptr + sizeof(ia_drc_sel_proc_output_struct)+16*1024; + + p_obj_drc->str_bit_handler.bitstream_drc_config = (UWORD8*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; + + p_obj_drc->str_bit_handler.bitstream_loudness_info = (UWORD8*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; + + p_obj_drc->str_bit_handler.bitstream_unidrc_interface = (UWORD8*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; + + p_obj_drc->str_payload.pstr_peak_limiter = (ia_drc_peak_limiter_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_peak_limiter_struct)+32; + + 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)+32); + persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; + + p_obj_drc->str_payload.pstr_qmf_filter = (ia_drc_qmf_filt_struct*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_qmf_filt_struct)+32; + + p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; + + p_obj_drc->str_payload.pstr_qmf_filter->syn_buff = (FLOAT64*)persistant_ptr; + persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; + + p_obj_drc->p_state->persistant_ptr=(pVOID)persistant_ptr; + return IA_NO_ERROR; +} + +VOID init_qmf_filt_bank(ia_drc_qmf_filt_struct *qmf_filt) +{ + + WORD32 l,k; + + FLOAT64 gain_ana =64.0 / QMF_FILT_RESOLUTION; + FLOAT64 gain_syn =1.0 / 64.0; + for ( l=0; l<2*QMF_FILT_RESOLUTION; l++ ) + { + for ( k=0; ksyn_tab_real[l][k] = gain_syn * cos((0.0245436926) * (k+0.5) * (2*l-255.0)); + qmf_filt->syn_tab_imag[l][k] = gain_syn * sin((0.0245436926) * (k+0.5) * (2*l-255.0)); + qmf_filt->ana_tab_real[k][l] = gain_ana * cos((0.0245436926) * (k+0.5) * (2*l-1.0)); + qmf_filt->ana_tab_imag[k][l] = gain_ana * sin((0.0245436926) * (k+0.5) * (2*l-1.0)); + } + } + +} + + + + + +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; + + struct ia_bit_buf_struct *it_bit_buff; + + WORD32 decDownmixIdList[NUM_GAIN_DEC_INSTANCES] = { 0, 4 }; + + + p_obj_drc->p_state->delay_in_output =0; + p_obj_drc->str_payload.pstr_selection_proc->first_frame=1; + + + p_obj_drc->pstr_bit_buf = impd_create_init_bit_buf(&p_obj_drc->str_bit_buf, p_obj_drc->str_bit_handler.it_bit_buf, p_obj_drc->str_bit_handler.num_bytes_bs/8); + it_bit_buff = p_obj_drc->pstr_bit_buf; + + + err_code = impd_init_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, + p_obj_drc->str_config.sampling_rate, + p_obj_drc->str_config.frame_size, + p_obj_drc->str_config.delay_mode, + -1, + 0); + + + + for (i=0; istr_config.frame_size, + p_obj_drc->str_config.sampling_rate, + p_obj_drc->str_config.gain_delay_samples, + p_obj_drc->str_config.delay_mode, + p_obj_drc->str_config.sub_band_domain_mode, + p_obj_drc->str_payload.pstr_gain_dec[i]); + + } + + if (p_obj_drc->str_config.interface_bitstream_present) { + + err_code = impd_drc_dec_interface_process( + p_obj_drc->pstr_bit_buf, + p_obj_drc->str_payload.pstr_drc_interface, + p_obj_drc->str_bit_handler.bitstream_unidrc_interface, + p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface*8, + &p_obj_drc->str_bit_handler.num_bits_read_bs_unidrc_interface); + + 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; + } + } + 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) + { + err_code=impd_drc_set_default_bitstream_config(p_obj_drc->str_payload.pstr_drc_config); + } + + + 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_drc_uni_sel_proc_process(p_obj_drc->str_payload.pstr_selection_proc, + p_obj_drc->str_payload.pstr_drc_config, + p_obj_drc->str_payload.pstr_loudness_info, + p_obj_drc->str_payload.pstr_drc_sel_proc_output); + if (err_code!=IA_NO_ERROR) + return err_code; + + for (i=0; istr_payload.pstr_drc_sel_proc_output->num_sel_drc_sets; j++) { + + if (impd_match_downmix(p_obj_drc->str_payload.pstr_drc_sel_proc_output->sel_downmix_ids[j], decDownmixIdList[i])) { + matchingDrcSetIds[numMatchingDrcSets] = p_obj_drc->str_payload.pstr_drc_sel_proc_output->sel_drc_set_ids[j]; + matchingDownmixIds[numMatchingDrcSets] = p_obj_drc->str_payload.pstr_drc_sel_proc_output->sel_downmix_ids[j]; + numMatchingDrcSets++; + } + } + if (i==0) + { + if (p_obj_drc->str_config.num_ch_in != p_obj_drc->str_payload.pstr_drc_sel_proc_output->base_channel_count) + + return -1; + audio_num_chan = p_obj_drc->str_config.num_ch_in; + } else if (i==1) + { + p_obj_drc->str_config.num_ch_out = p_obj_drc->str_payload.pstr_drc_sel_proc_output->target_channel_count; + audio_num_chan = p_obj_drc->str_config.num_ch_out; + } + + err_code = impd_init_drc_decode_post_config(audio_num_chan, + matchingDrcSetIds, + matchingDownmixIds, + numMatchingDrcSets + , p_obj_drc->str_payload.pstr_drc_sel_proc_output->sel_eq_set_ids[i] + + , 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 + ); + + impd_get_parametric_drc_delay(p_obj_drc->str_payload.pstr_gain_dec[i], p_obj_drc->str_payload.pstr_drc_config, & p_obj_drc->str_config.parametric_drc_delay_gain_dec_instance, &p_obj_drc->str_config.parametric_drc_delay_max); + impd_get_eq_delay(p_obj_drc->str_payload.pstr_gain_dec[i], p_obj_drc->str_payload.pstr_drc_config, & p_obj_drc->str_config.eq_delay_gain_dec_instance, & p_obj_drc->str_config.eq_delay_max); + p_obj_drc->str_config.parametric_drc_delay += p_obj_drc->str_config.parametric_drc_delay_gain_dec_instance; + p_obj_drc->str_config.eq_delay += p_obj_drc->str_config.eq_delay_gain_dec_instance; + + } + + { + if (p_obj_drc->str_config.parametric_drc_delay_max == -1) { + p_obj_drc->str_config.parametric_drc_delay_max = PARAMETRIC_DRC_DELAY_MAX_DEFAULT; + } + if (p_obj_drc->str_config.eq_delay_max == -1) { + p_obj_drc->str_config.eq_delay_max = EQ_DELAY_MAX_DEFAULT; + } + + if (!p_obj_drc->str_config.constant_delay_on) { + + p_obj_drc->p_state->delay_in_output += p_obj_drc->str_config.parametric_drc_delay + p_obj_drc->str_config.eq_delay + p_obj_drc->str_config.audio_delay_samples; + p_obj_drc->str_config.delay_line_samples = p_obj_drc->str_config.audio_delay_samples; + + if (!p_obj_drc->str_config.absorb_delay_on) { + p_obj_drc->p_state->delay_in_output = 0; + } + } else { + p_obj_drc->p_state->delay_in_output += p_obj_drc->str_config.parametric_drc_delay_max + p_obj_drc->str_config.eq_delay_max + p_obj_drc->str_config.audio_delay_samples; + p_obj_drc->str_config.delay_line_samples = p_obj_drc->p_state->delay_in_output - p_obj_drc->str_config.parametric_drc_delay + p_obj_drc->str_config.eq_delay; + + if (!p_obj_drc->str_config.absorb_delay_on ) { + p_obj_drc->p_state->delay_in_output = 0; + } + } + + } + if(p_obj_drc->str_config.dec_type==1) + { + init_qmf_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter); + } + + if (p_obj_drc->str_config.peak_limiter) + { + impd_peak_limiter_init(p_obj_drc->str_payload.pstr_peak_limiter, + DEFAULT_ATTACK_TIME_MS, + DEFAULT_RELEASE_TIME_MS, + LIM_DEFAULT_THRESHOLD, + p_obj_drc->str_config.num_ch_out, + p_obj_drc->str_config.sampling_rate, + p_obj_drc->str_payload.pstr_peak_limiter->buffer); + } + + return IA_NO_ERROR; +} + + + + + + + diff --git a/decoder/drc_src/impd_drc_interface.h b/decoder/drc_src/impd_drc_interface.h new file mode 100644 index 0000000..875ddb6 --- /dev/null +++ b/decoder/drc_src/impd_drc_interface.h @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * 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_INTERFACE_H +#define IMPD_DRC_INTERFACE_H + +typedef struct { + WORD32 loudness_eq_request_flag; + WORD32 loudness_eq_request; + WORD32 sensitivity_flag; + FLOAT32 sensitivity; + WORD32 playback_gain_flag; + FLOAT32 playback_gain; +} ia_loudness_eq_parameter_interface_struct; + +typedef struct { + WORD32 eq_set_purpose_request; +} ia_equalization_ctrl_interface_struct; + +typedef struct { + WORD32 ext_size_bits; + WORD32 ext_bit_size; + WORD32 uni_drc_interface_ext_type; +} ia_specific_interface_extension_struct; + +typedef struct { + WORD32 interface_ext_count; + ia_specific_interface_extension_struct specific_interface_ext[EXT_COUNT_MAX]; + WORD32 loudness_eq_parameter_interface_flag; + WORD32 eq_ctrl_interface_flag; + ia_loudness_eq_parameter_interface_struct loudness_eq_parameter_interface; + ia_equalization_ctrl_interface_struct eq_ctrl_interface; +} ia_drc_uni_interface_ext_struct; + +typedef struct { + WORD32 change_compress; + WORD32 change_boost; + FLOAT32 compress; + FLOAT32 boost; + WORD32 change_drc_characteristic_target; + WORD32 drc_characteristic_target; +} ia_drc_parameter_interface_struct; + +typedef struct { + WORD32 dynamic_range_control_on; + WORD32 num_drc_feature_requests; + WORD32 drc_feature_req_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_num_drc_effects[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 desired_num_drc_effects_of_requested[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_effect_type[MAX_NUM_DRC_FEATURE_REQUESTS][MAX_NUM_DRC_EFFECT_TYPE_REQUESTS]; + WORD32 requested_dyn_rng_measurement_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_dyn_range_is_single_val_flag[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_value[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_min_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_max_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_characteristic[MAX_NUM_DRC_FEATURE_REQUESTS]; +} ia_dyn_rng_ctrl_interface_struct; + +typedef struct { + WORD32 album_mode; + WORD32 peak_limiter; + WORD32 change_loudness_deviation_max; + WORD32 loudness_deviation_max; + WORD32 change_loudness_measur_method; + WORD32 loudness_measurement_method; + WORD32 change_loudness_measur_system; + WORD32 loudness_measurement_system; + WORD32 change_loudness_measur_pre_proc; + WORD32 loudness_measurement_pre_proc; + WORD32 change_device_cut_off_freq; + WORD32 device_cut_off_frequency; + WORD32 change_loudness_norm_gain_db_max; + FLOAT32 loudness_norm_gain_db_max; + WORD32 change_loudness_norm_gain_modification_db; + FLOAT32 loudness_norm_gain_modification_db; + WORD32 change_output_peak_level_max; + FLOAT32 output_peak_level_max; +} ia_loudness_norm_parameter_interface_struct; + +typedef struct { + WORD32 loudness_normalization_on; + FLOAT32 target_loudness; +} ia_loudness_norm_ctrl_interface_struct; + +typedef struct { + WORD32 target_config_request_type; + WORD32 num_downmix_id_requests; + WORD32 requested_dwnmix_id[MAX_NUM_DOWNMIX_ID_REQUESTS]; + WORD32 requested_target_layout; + WORD32 requested_target_ch_count; +} ia_system_interface_struct; + +typedef struct { + WORD32 interface_signat_type; + WORD32 interface_signat_data_len; + UWORD32 interface_signat_data[MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE*8]; +} ia_drc_uni_interface_signat_struct; + +typedef struct ia_drc_interface_struct{ + WORD32 interface_signat_flag; + WORD32 system_interface_flag; + WORD32 loudness_norm_ctrl_interface_flag; + WORD32 loudness_norm_parameter_interface_flag; + WORD32 drc_interface_flag; + WORD32 drc_parameter_interface_flag; + WORD32 drc_uni_interface_ext_flag; + ia_drc_uni_interface_signat_struct drc_uni_interface_signature; + ia_system_interface_struct system_interface; + ia_loudness_norm_ctrl_interface_struct loudness_norm_ctrl_interface; + ia_loudness_norm_parameter_interface_struct loudness_norm_param_interface; + ia_dyn_rng_ctrl_interface_struct drc_ctrl_interface; + ia_drc_parameter_interface_struct drc_parameter_interface; + ia_drc_uni_interface_ext_struct drc_uni_interface_ext; +} ia_drc_interface_struct; + +#endif diff --git a/decoder/drc_src/impd_drc_interface_decoder.c b/decoder/drc_src/impd_drc_interface_decoder.c new file mode 100644 index 0000000..a880959 --- /dev/null +++ b/decoder/drc_src/impd_drc_interface_decoder.c @@ -0,0 +1,57 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#include +#include "impd_type_def.h" + +#include "impd_drc_bitbuffer.h" +#include "impd_drc_common.h" +#include "impd_drc_interface.h" +#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; + +} + diff --git a/decoder/drc_src/impd_drc_interface_parser.c b/decoder/drc_src/impd_drc_interface_parser.c new file mode 100644 index 0000000..27cec33 --- /dev/null +++ b/decoder/drc_src/impd_drc_interface_parser.c @@ -0,0 +1,515 @@ +/****************************************************************************** + * + * 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 +#include +#include + +#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; ierror) + 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; inum_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; inum_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; jrequested_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 new file mode 100644 index 0000000..8b93ec6 --- /dev/null +++ b/decoder/drc_src/impd_drc_loud_eq.c @@ -0,0 +1,191 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#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; caudio_num_chan; c++) + + { + g = str_drc_instruction_str->channel_group_of_ch[c]; + if (g>=0) + { + for (i=0; idrc_frame_size; i++) + { + sum = 0.0f; + for (b=0; bband_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; caudio_num_chan; c++) + + { + for (i=0; idrc_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; kdrc_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; mstr_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 new file mode 100644 index 0000000..23853cd --- /dev/null +++ b/decoder/drc_src/impd_drc_loudness_control.c @@ -0,0 +1,987 @@ +/****************************************************************************** + * + * 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 +#include + +#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_signal_peak_level_info(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_instructions_struct* str_drc_instruction_str, + WORD32 requested_dwnmix_id, + WORD32 album_mode, + WORD32 num_compression_eq_count, + WORD32* num_compression_eq_id, + WORD32* peak_info_count, + WORD32 eq_set_id[], + FLOAT32 signal_peak_level[], + WORD32 explicit_peak_information_present[]) +{ + WORD32 c, d, i, k, n, base_channel_count, mode; + WORD32 pre_lim_count; + WORD32 peak_count = 0; + WORD32 loudness_info_count = 0; + ia_loudness_info_struct* loudness_info; + FLOAT32 sum, max_sum; + WORD32 drc_set_id_requested = str_drc_instruction_str->drc_set_id; + WORD32 loudness_drc_set_id_requested; + WORD32 match_found_flag = 0; + + FLOAT32 signal_peak_level_tmp; + eq_set_id[0] = 0; + signal_peak_level[0] = 0.0f; + explicit_peak_information_present[0] = 0; + + k=0; + if (drc_set_id_requested < 0) + { + for (k=0; kloudness_info_album_count; + } + else + { + mode = 0; + loudness_info_count = pstr_loudness_info->loudness_info_count; + } + + for (n=0; nstr_loudness_info_album[n]); + } + else + { + loudness_info = &(pstr_loudness_info->loudness_info[n]); + } + if (loudness_drc_set_id_requested == loudness_info->drc_set_id && requested_dwnmix_id == loudness_info->downmix_id) + { + if (loudness_info->true_peak_level_present) + { + + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->true_peak_level; + explicit_peak_information_present[peak_count] = 1; + + match_found_flag = 1; + peak_count++; + + } + if (match_found_flag == 0) { + if (loudness_info->sample_peak_level_present) + { + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->sample_peak_level; + explicit_peak_information_present[peak_count] = 1; + + match_found_flag = 1; + peak_count++; + + } + } + } + } + if (match_found_flag == 0) { + for (n=0; nstr_loudness_info_album[n]); + } + else + { + loudness_info = &(pstr_loudness_info->loudness_info[n]); + } + if (ID_FOR_ANY_DRC == loudness_info->drc_set_id && requested_dwnmix_id == loudness_info->downmix_id) + { + if (loudness_info->true_peak_level_present) + { + + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->true_peak_level; + explicit_peak_information_present[peak_count] = 1; + + match_found_flag = 1; + peak_count++; + + } + if (match_found_flag == 0) { + if (loudness_info->sample_peak_level_present) + { + + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->sample_peak_level; + explicit_peak_information_present[peak_count] = 1; + + match_found_flag = 1; + peak_count++; + + } + } + } + } + } + if (match_found_flag == 0) { + for (i=0; idwnmix_id_count; i++) + { + if (requested_dwnmix_id == str_drc_instruction_str->downmix_id[0] || ID_FOR_ANY_DOWNMIX == str_drc_instruction_str->downmix_id[0]) + { + if (str_drc_instruction_str->limiter_peak_target_present) + { + if (str_drc_instruction_str->requires_eq == 1) + { + for (d=0; dstr_drc_config_ext.eq_instructions_count; d++) { + ia_eq_instructions_struct* eq_instructions = &pstr_drc_config->str_drc_config_ext.str_eq_instructions[d]; + for (c=0; cdrc_set_id_count; c++) { + if ((eq_instructions->drc_set_id[c] == loudness_drc_set_id_requested) || (eq_instructions->drc_set_id[c] == ID_FOR_ANY_DRC)) { + for (i=0; idwnmix_id_count; i++) { + if ((eq_instructions->downmix_id[i] == requested_dwnmix_id) || (eq_instructions->downmix_id[i] == ID_FOR_ANY_DOWNMIX)) { + eq_set_id[peak_count] = eq_instructions->eq_set_id; + signal_peak_level[peak_count] = str_drc_instruction_str->limiter_peak_target; + explicit_peak_information_present[peak_count] = 1; + match_found_flag = 1; + peak_count++; + } + } + } + } + } + } + else + + { + eq_set_id[peak_count] = 0; + signal_peak_level[peak_count] = str_drc_instruction_str->limiter_peak_target; + explicit_peak_information_present[peak_count] = 1; + match_found_flag = 1; + peak_count++; + } + } + } + } +} + if (match_found_flag == 0) { + for (i=1; idwnmix_id_count; i++) + { + if (requested_dwnmix_id == str_drc_instruction_str->downmix_id[i]) + { + if (str_drc_instruction_str->limiter_peak_target_present) + { + + { + eq_set_id[peak_count] = 0; + signal_peak_level[peak_count] = str_drc_instruction_str->limiter_peak_target; + explicit_peak_information_present[peak_count] = 1; + match_found_flag = 1; + peak_count++; + } + } + } + } + } + if (match_found_flag == 0) { + if (requested_dwnmix_id != ID_FOR_BASE_LAYOUT) { + signal_peak_level_tmp = 0.f; + for (i=0; idwnmix_instructions_count; i++) + { + if (pstr_drc_config->dwnmix_instructions[i].downmix_id == requested_dwnmix_id) + { + if (pstr_drc_config->dwnmix_instructions[i].downmix_coefficients_present) + { + base_channel_count = pstr_drc_config->channel_layout.base_channel_count; + max_sum = 0.0f; + for (c=0; cdwnmix_instructions[i].target_channel_count; c++) + { + sum = 0.0f; + for (d=0; ddwnmix_instructions[i].downmix_coefficient[c * base_channel_count + d]; + } + if (max_sum < sum) max_sum = sum; + } + signal_peak_level_tmp = 20.0f * (FLOAT32)log10(max_sum); + } else { + + } + break; + } + } + for (n=0; nstr_loudness_info_album[n]); + } + else + { + loudness_info = &(pstr_loudness_info->loudness_info[n]); + } + if (loudness_drc_set_id_requested == loudness_info->drc_set_id && ID_FOR_BASE_LAYOUT == loudness_info->downmix_id) { + if (loudness_info->true_peak_level_present) + { + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->true_peak_level + signal_peak_level_tmp; + explicit_peak_information_present[peak_count] = 0; + + match_found_flag = 1; + peak_count++; + + } + if (match_found_flag == 0) { + if (loudness_info->sample_peak_level_present) + { + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->sample_peak_level + signal_peak_level_tmp; + explicit_peak_information_present[peak_count] = 0; + + match_found_flag = 1; + peak_count++; + + } + } + } + } + if (match_found_flag == 0) { + for (n=0; nstr_loudness_info_album[n]); + } + else + { + loudness_info = &(pstr_loudness_info->loudness_info[n]); + } + if (ID_FOR_ANY_DRC == loudness_info->drc_set_id && ID_FOR_BASE_LAYOUT == loudness_info->downmix_id) { + if (loudness_info->true_peak_level_present) + { + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->true_peak_level + signal_peak_level_tmp; + explicit_peak_information_present[peak_count] = 0; + + match_found_flag = 1; + peak_count++; + + } + if (match_found_flag == 0) { + if (loudness_info->sample_peak_level_present) + { + eq_set_id[peak_count] = loudness_info->eq_set_id; + + signal_peak_level[peak_count] = loudness_info->sample_peak_level + signal_peak_level_tmp; + explicit_peak_information_present[peak_count] = 0; + + match_found_flag = 1; + peak_count++; + + } + } + } + } + } + if (match_found_flag == 0) { + ia_drc_instructions_struct* drc_instructions_drc_tmp; + for (n=0; ndrc_instructions_count_plus; n++) { + drc_instructions_drc_tmp = &pstr_drc_config->str_drc_instruction_str[n]; + if (loudness_drc_set_id_requested == drc_instructions_drc_tmp->drc_set_id) { + for (k=0; kdwnmix_id_count; k++) { + if (ID_FOR_BASE_LAYOUT == drc_instructions_drc_tmp->downmix_id[k]) { + if (drc_instructions_drc_tmp->limiter_peak_target_present) { + eq_set_id[peak_count] = -1; + signal_peak_level[peak_count] = drc_instructions_drc_tmp->limiter_peak_target + signal_peak_level_tmp; + explicit_peak_information_present[peak_count] = 0; + match_found_flag = 1; + peak_count++; + } + } + break; + } + } + } + } + } + } + if (peak_count > 0) + { + *peak_info_count = peak_count; + } + else + { + *peak_info_count = pre_lim_count; + } + return (0); +} + + + +WORD32 +impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_info, + WORD32 dyn_range_measurement_type, + WORD32 * loudness_peak_2_avg_value_present, + FLOAT32* loudness_peak_2_avg_value) +{ + WORD32 k; + WORD32 program_loudness_present = 0; + WORD32 peak_loudness_present = 0; + WORD32 match_measure_program_loudness = 0; + WORD32 match_measure_peak_loudness = 0; + FLOAT32 program_loudness = 0.0f; + FLOAT32 peak_loudness = 0.0f; + ia_loudness_measure_struct* loudness_measure = NULL; + + for (k=0; kmeasurement_count; k++) + { + loudness_measure = &(loudness_info->loudness_measure[k]); + if (loudness_measure->method_def == METHOD_DEFINITION_PROGRAM_LOUDNESS) + { + if (match_measure_program_loudness < measurement_method_prog_loudness_tbl[loudness_measure->measurement_system]) + { + program_loudness = loudness_measure->method_val; + program_loudness_present = 1; + match_measure_program_loudness = measurement_method_prog_loudness_tbl[loudness_measure->measurement_system]; + } + } + switch (dyn_range_measurement_type) { + case SHORT_TERM_LOUDNESS_TO_AVG: + if (loudness_measure->method_def == METHOD_DEFINITION_SHORT_TERM_LOUDNESS_MAX) + { + if (match_measure_peak_loudness < measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]) + { + peak_loudness = loudness_measure->method_val; + peak_loudness_present = 1; + match_measure_peak_loudness = measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]; + } + } + break; + + case MOMENTARY_LOUDNESS_TO_AVG: + if (loudness_measure->method_def == METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX) + { + if (match_measure_peak_loudness < measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]) + { + peak_loudness = loudness_measure->method_val; + peak_loudness_present = 1; + match_measure_peak_loudness = measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]; + } + } + break; + + case TOP_OF_LOUDNESS_RANGE_TO_AVG: + if (loudness_measure->method_def == METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE) + { + if (match_measure_peak_loudness < measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]) + { + peak_loudness = loudness_measure->method_val; + peak_loudness_present = 1; + match_measure_peak_loudness = measurement_method_peak_loudness_tbl[loudness_measure->measurement_system]; + } + } + break; + + default: + return (UNEXPECTED_ERROR); + + break; + } + } + if ((program_loudness_present == 1) && (peak_loudness_present == 1)) + { + *loudness_peak_2_avg_value = peak_loudness - program_loudness; + *loudness_peak_2_avg_value_present = 1; + } + return (0); +} + +WORD32 impd_loudness_peak_to_average_info( + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_instructions_struct* str_drc_instruction_str, + WORD32 requested_dwnmix_id, + WORD32 dyn_range_measurement_type, + WORD32 album_mode, + WORD32* loudness_peak_2_avg_value_present, + FLOAT32* loudness_peak_2_avg_value) +{ + WORD32 n, err; + WORD32 drc_set_id = max(0,str_drc_instruction_str->drc_set_id); + + *loudness_peak_2_avg_value_present = 0; + + if (album_mode == 1) + { + for (n=0; nloudness_info_album_count; n++) + { + ia_loudness_info_struct* loudness_info = &(pstr_loudness_info->str_loudness_info_album[n]); + if (drc_set_id == loudness_info->drc_set_id) + { + if (requested_dwnmix_id == loudness_info->downmix_id) + { + + err = impd_extract_loudness_peak_to_average_info(loudness_info, + dyn_range_measurement_type, + loudness_peak_2_avg_value_present, + loudness_peak_2_avg_value); + if (err) return (err); + + } + } + } + } + if (*loudness_peak_2_avg_value_present == 0) + { + for (n=0; nloudness_info_count; n++) + { + ia_loudness_info_struct* loudness_info = &(pstr_loudness_info->loudness_info[n]); + if (drc_set_id == loudness_info->drc_set_id) + { + if (requested_dwnmix_id == loudness_info->downmix_id) + { + + err = impd_extract_loudness_peak_to_average_info(loudness_info, + dyn_range_measurement_type, + loudness_peak_2_avg_value_present, + loudness_peak_2_avg_value); + if (err) return (err); + + } + } + } + } + return (0); +} + + +WORD32 impd_overall_loudness_present( ia_loudness_info_struct* loudness_info, + WORD32* loudness_info_present) +{ + WORD32 m; + + *loudness_info_present = 0; + for (m=0; mmeasurement_count; m++) + { + if ((loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_PROGRAM_LOUDNESS) || + (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_ANCHOR_LOUDNESS)) + { + *loudness_info_present = 1; + } + } + return (0); +} + +WORD32 impd_check_loud_info(WORD32 loudness_info_count, + ia_loudness_info_struct* loudness_info, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32* info_count, + ia_loudness_info_struct* loudness_info_matching[]) +{ + WORD32 n, err; + WORD32 loudness_info_present; + for (n=0; nalbum_mode == 1) + { + err = impd_check_loud_payload(pstr_loudness_info->loudness_info_album_count, + pstr_loudness_info->str_loudness_info_album, + requested_dwnmix_id, + loudness_drc_set_id_requested, + info_count, + loudness_info_matching); + if (err) return (err); + + } + if (*info_count == 0) + { + err = impd_check_loud_payload(pstr_loudness_info->loudness_info_count, + pstr_loudness_info->loudness_info, + requested_dwnmix_id, + loudness_drc_set_id_requested, + + info_count, + loudness_info_matching); + if (err) return (err); + } + *overall_loudness_info_present = (*info_count > 0); + return(0); +} + + +WORD32 +impd_high_pass_loudness_adjust_info( ia_loudness_info_struct* loudness_info, + WORD32* loudness_hp_adjust_present, + FLOAT32* loudness_hp_adjust) +{ + WORD32 m, k; + + *loudness_hp_adjust_present = 0; + *loudness_hp_adjust = 0.0f; + for (m=0; mmeasurement_count; m++) + { + if (loudness_info->loudness_measure[m].measurement_system == MEASUREMENT_SYSTEM_BS_1770_4_PRE_PROCESSING) + { + for (k=0; kmeasurement_count; k++) + { + if (loudness_info->loudness_measure[k].measurement_system == MEASUREMENT_SYSTEM_BS_1770_4) + { + if (loudness_info->loudness_measure[m].method_def == loudness_info->loudness_measure[k].method_def) + { + *loudness_hp_adjust_present = 1; + *loudness_hp_adjust = loudness_info->loudness_measure[m].method_val - loudness_info->loudness_measure[k].method_val; + } + } + } + } + } + return (0); +} + +WORD32 impd_find_high_pass_loudness_adjust( + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32 album_mode, + FLOAT32 device_cutoff_freq, + WORD32* loudness_hp_adjust_present, + FLOAT32* loudness_hp_adjust) +{ + WORD32 n, err; + WORD32 loudness_drc_set_id_requested; + + if (drc_set_id_requested < 0) + { + loudness_drc_set_id_requested = 0; + } + else + { + loudness_drc_set_id_requested = drc_set_id_requested; + } + + *loudness_hp_adjust_present = 0; + + if (album_mode == 1) + { + for (n=0; nloudness_info_album_count; n++) + { + if ((requested_dwnmix_id == pstr_loudness_info->str_loudness_info_album[n].downmix_id) || (ID_FOR_ANY_DOWNMIX == pstr_loudness_info->str_loudness_info_album[n].downmix_id)) + { + if (loudness_drc_set_id_requested == pstr_loudness_info->str_loudness_info_album[n].drc_set_id) + { + err = impd_high_pass_loudness_adjust_info(&(pstr_loudness_info->loudness_info[n]), loudness_hp_adjust_present, loudness_hp_adjust); + if (err) return (err); + } + } + } + } + if (*loudness_hp_adjust_present == 0) + { + for (n=0; nloudness_info_count; n++) + { + if ((requested_dwnmix_id == pstr_loudness_info->loudness_info[n].downmix_id) || (ID_FOR_ANY_DOWNMIX == pstr_loudness_info->loudness_info[n].downmix_id)) + { + if (loudness_drc_set_id_requested == pstr_loudness_info->loudness_info[n].drc_set_id) + { + err = impd_high_pass_loudness_adjust_info(&(pstr_loudness_info->loudness_info[n]), loudness_hp_adjust_present, loudness_hp_adjust); + if (err) return (err); + } + } + } + } + if (*loudness_hp_adjust_present == 0) + { + for (n=0; nloudness_info_count; n++) + { + if (ID_FOR_BASE_LAYOUT == pstr_loudness_info->loudness_info[n].downmix_id) /* base layout */ + { + if (loudness_drc_set_id_requested == pstr_loudness_info->loudness_info[n].drc_set_id) + { + err = impd_high_pass_loudness_adjust_info(&(pstr_loudness_info->loudness_info[n]), loudness_hp_adjust_present, loudness_hp_adjust); + if (err) return (err); + } + } + } + } + if (*loudness_hp_adjust_present == 0) + { + for (n=0; nloudness_info_count; n++) + { + if (ID_FOR_BASE_LAYOUT == pstr_loudness_info->loudness_info[n].downmix_id) /* base layout */ + { + if (0 == pstr_loudness_info->loudness_info[n].drc_set_id) + { + err = impd_high_pass_loudness_adjust_info(&(pstr_loudness_info->loudness_info[n]), loudness_hp_adjust_present, loudness_hp_adjust); + if (err) return (err); + } + } + } + } + if (*loudness_hp_adjust_present == 0) + { + *loudness_hp_adjust = 0.0f; + } + else + { + *loudness_hp_adjust *= (max(20.0f, min(500.0f, device_cutoff_freq)) - 20.0f) / (500.0f - 20.0f); + } + return(0); +} + + +WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32 num_compression_eq_count, + WORD32* num_compression_eq_id, + WORD32* loudness_info_count, + WORD32 eq_set_id[], + FLOAT32 loudness_normalization_gain_db[], + FLOAT32 loudness[]) +{ + WORD32 err, k, info_count = 0, pre_lim_count; + WORD32 loudness_hp_adjust_present; + WORD32 overall_loudness_info_present; + FLOAT32 pre_proc_adjust; + + k=0; + if (drc_set_id_requested < 0) + { + for (k=0; kloudness_normalization_on == 1) + { + WORD32 n; + ia_loudness_info_struct* loudness_info[16]; + err = impd_find_overall_loudness_info(pstr_drc_sel_proc_params_struct, + pstr_loudness_info, + requested_dwnmix_id, + drc_set_id_requested, + &overall_loudness_info_present, + &info_count, + loudness_info); + if (err) return (err); + + if (overall_loudness_info_present == 1) + { + WORD32 requested_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; + WORD32 other_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; + WORD32 requested_measurement_system = MEASUREMENT_SYSTEM_BS_1770_4; + WORD32 requested_preprocessing = 0; + + WORD32* system_bonus = measurement_system_default_tbl; + + WORD32 match_measure; + FLOAT32 method_val = 0; + + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_method) { + case USER_METHOD_DEFINITION_DEFAULT: + case USER_METHOD_DEFINITION_PROGRAM_LOUDNESS: + requested_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; + other_method_definition = METHOD_DEFINITION_ANCHOR_LOUDNESS; + break; + case USER_METHOD_DEFINITION_ANCHOR_LOUDNESS: + requested_method_definition = METHOD_DEFINITION_ANCHOR_LOUDNESS; + other_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; + break; + + default: + return (UNEXPECTED_ERROR); + break; + } + + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_system) { + case USER_MEASUREMENT_SYSTEM_DEFAULT: + case USER_MEASUREMENT_SYSTEM_BS_1770_4: + requested_measurement_system = MEASUREMENT_SYSTEM_BS_1770_4; + system_bonus = measurement_system_bs1770_3_tbl; + break; + case USER_MEASUREMENT_SYSTEM_USER: + requested_measurement_system = MEASUREMENT_SYSTEM_USER; + system_bonus = measurement_system_user_tbl; + break; + case USER_MEASUREMENT_SYSTEM_EXPERT_PANEL: + requested_measurement_system = MEASUREMENT_SYSTEM_EXPERT_PANEL; + system_bonus = measurement_system_expert_tbl; + break; + case USER_MEASUREMENT_SYSTEM_RESERVED_A: + requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_A; + system_bonus = measurement_system_rms_a_tbl; + break; + case USER_MEASUREMENT_SYSTEM_RESERVED_B: + requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_B; + system_bonus = measurement_system_rms_b_tbl; + break; + case USER_MEASUREMENT_SYSTEM_RESERVED_C: + requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_C; + system_bonus = measurement_system_rms_c_tbl; + break; + case USER_MEASUREMENT_SYSTEM_RESERVED_D: + requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_D; + system_bonus = measurement_system_rms_d_tbl; + break; + case USER_MEASUREMENT_SYSTEM_RESERVED_E: + requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_E; + system_bonus = measurement_system_rms_e_tbl; + break; + + default: + return (UNEXPECTED_ERROR); + break; + } + + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_pre_proc) { + case USER_LOUDNESS_PREPROCESSING_DEFAULT: + case USER_LOUDNESS_PREPROCESSING_OFF: + requested_preprocessing = 0; + break; + case USER_LOUDNESS_PREPROCESSING_HIGHPASS: + requested_preprocessing = 1; + break; + + default: + return (UNEXPECTED_ERROR); + break; + } + + for (k=0; kmeasurement_count; n++) + { + ia_loudness_measure_struct* loudness_measure = &(loudness_info[k]->loudness_measure[n]); + if (match_measure < system_bonus[loudness_measure->measurement_system] && requested_method_definition == loudness_measure->method_def) + { + method_val = loudness_measure->method_val; + match_measure = system_bonus[loudness_measure->measurement_system]; + } + } + if (match_measure == -1) + { + for (n=0; nmeasurement_count; n++) + { + ia_loudness_measure_struct* loudness_measure = &(loudness_info[k]->loudness_measure[n]); + if (match_measure < system_bonus[loudness_measure->measurement_system] && other_method_definition == loudness_measure->method_def) + { + method_val = loudness_measure->method_val; + match_measure = system_bonus[loudness_measure->measurement_system]; + } + } + } + + if (requested_preprocessing == 1) + { + err = impd_find_high_pass_loudness_adjust(pstr_loudness_info, requested_dwnmix_id, drc_set_id_requested, pstr_drc_sel_proc_params_struct->album_mode, (FLOAT32)pstr_drc_sel_proc_params_struct->device_cut_off_frequency, + &loudness_hp_adjust_present, &pre_proc_adjust); + if (err) return (err); + + if (loudness_hp_adjust_present == 0) + { + pre_proc_adjust = -2.0f; + } + method_val += pre_proc_adjust; + } + + eq_set_id[k] = 0; + + loudness_normalization_gain_db[k] = pstr_drc_sel_proc_params_struct->target_loudness - method_val; + loudness[k] = method_val; + } + } + } + if (info_count > 0) + { + *loudness_info_count = info_count; + } + else + { + *loudness_info_count = pre_lim_count; + } + + return (0); +} + + +#define MIXING_LEVEL_DEFAULT 85.0f +WORD32 +impd_mixing_level_info(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32 eq_set_id_requested, + FLOAT32* mixing_level) +{ + WORD32 n, k, info_count; + WORD32 album_mode = pstr_drc_sel_proc_params_struct->album_mode; + WORD32 loudness_drc_set_id_requested; + ia_loudness_info_struct* loudness_info; + + *mixing_level = MIXING_LEVEL_DEFAULT; + if (drc_set_id_requested < 0) + { + loudness_drc_set_id_requested = 0; + } + else + { + loudness_drc_set_id_requested = drc_set_id_requested; + } + if (album_mode == 1) + { + info_count = pstr_loudness_info->loudness_info_album_count; + loudness_info = pstr_loudness_info->str_loudness_info_album; + } + else + { + info_count = pstr_loudness_info->loudness_info_count; + loudness_info = pstr_loudness_info->loudness_info; + } + for (n=0; n +#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; idownmix_matrix[i_ch][o_ch]; + } + } + for (o_ch=0; o_chpp_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;istr_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;jstr_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 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 new file mode 100644 index 0000000..7aefc14 --- /dev/null +++ b/decoder/drc_src/impd_drc_main_stft_process.c @@ -0,0 +1,232 @@ +/****************************************************************************** + * + * 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 +#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; idownmix_matrix[i_ch][o_ch]; + } + } + for (o_ch=0; o_chpp_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;istr_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;jstr_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 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 new file mode 100644 index 0000000..ea72ea2 --- /dev/null +++ b/decoder/drc_src/impd_drc_main_td_process.c @@ -0,0 +1,312 @@ +/****************************************************************************** + * + * 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 +#include +#include "impd_type_def.h" +#include "impd_error_standards.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_peak_limiter.h" + +static IA_ERRORCODE 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; idownmix_matrix[i_ch][o_ch]; + } + } + for (o_ch=0; o_chpp_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 IA_NO_ERROR; + } + + err_code = 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 (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; + 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; + } + } + } + + num_sample_to_process=(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)); + + if(num_sample_to_processstr_config.frame_size) + last_frame=1; + + if(p_obj_drc->str_config.pcm_size==16) + { + for(i=0;istr_config.num_ch_in;i++) + { + audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); + + for(j=0;jstr_config.num_ch_in + i])/32767.0f; + } + } + } + else + { + for(i=0;istr_config.num_ch_in;i++) + { + audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); + + for(j=0;jstr_config.num_ch_in + i]; + } + } + } + + err_code = impd_drc_process_time_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_buff, + 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 (err_code!=IA_NO_ERROR) + return err_code; + + if(p_obj_drc->str_payload.pstr_drc_sel_proc_output->downmix_matrix_present!=0) + err_code = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, + audio_buff, + p_obj_drc->str_config.frame_size); + + if (err_code!=IA_NO_ERROR) + return err_code; + + err_code = impd_drc_process_time_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_buff, + 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 (err_code!=IA_NO_ERROR) + return err_code; + + if (p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db != 0.0f) + { + FLOAT32 gain_value = (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_buff[i][j] *= gain_value; + } + } + } + + if (p_obj_drc->str_config.peak_limiter) + { + 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_buff[i][j]; + } + } + + err_code=impd_limiter_process(p_obj_drc->str_payload.pstr_peak_limiter, + output_buffer, + p_obj_drc->str_config.frame_size); + + + if (err_code!=IA_NO_ERROR) + return err_code; + + 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_buff[i][j] = output_buffer[j*p_obj_drc->str_config.num_ch_out + i]; + } + } + } + + if(p_obj_drc->str_config.pcm_size==16) + { + 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) + output_buffer16[j*p_obj_drc->str_config.num_ch_out + i] = -32767; + + else if (audio_buff[i][j]>1.0f) + output_buffer16[j*p_obj_drc->str_config.num_ch_out + i] = 32767; + + else + output_buffer16[j*p_obj_drc->str_config.num_ch_out + i] = (WORD16)(audio_buff[i][j]*32767.0f); + } + } + } + else + { + 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_buff[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->p_state->delay_in_output!=0){ + 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)*(p_obj_drc->str_config.pcm_size>>3); + if(p_obj_drc->str_config.pcm_size==16) + memcpy(output_buffer16,(output_buffer16+(p_obj_drc->p_state->delay_in_output*p_obj_drc->str_config.num_ch_out)),p_obj_drc->p_state->ui_out_bytes); + else + memcpy(output_buffer,(output_buffer+(p_obj_drc->p_state->delay_in_output*p_obj_drc->str_config.num_ch_out)),p_obj_drc->p_state->ui_out_bytes); + + p_obj_drc->p_state->delay_adjust_samples = p_obj_drc->p_state->delay_in_output; + p_obj_drc->p_state->delay_in_output=0; + + } + if(last_frame==1) + { + if((num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)<=p_obj_drc->str_config.frame_size) + p_obj_drc->p_state->ui_out_bytes = (num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)*p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.pcm_size>>3); + else + p_obj_drc->p_state->ui_out_bytes = (p_obj_drc->str_config.frame_size)*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 new file mode 100644 index 0000000..15cfddb --- /dev/null +++ b/decoder/drc_src/impd_drc_main_td_qmf_process.c @@ -0,0 +1,371 @@ +/****************************************************************************** + * + * 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 +#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; jsyn_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; 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; iana_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; idownmix_matrix[i_ch][o_ch]; + } + } + for (o_ch=0; o_chpp_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;istr_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;jstr_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_countstr_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 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_multi_band.h b/decoder/drc_src/impd_drc_multi_band.h new file mode 100644 index 0000000..1a733be --- /dev/null +++ b/decoder/drc_src/impd_drc_multi_band.h @@ -0,0 +1,72 @@ +/****************************************************************************** + * + * 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_MULTI_BAND_H +#define IMPD_DRC_MULTI_BAND_H + +#define DRC_SUBBAND_COUNT_WITH_AUDIO_CODEC_FILTERBANK_MAX FILTER_BANK_PARAMETER_COUNT + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + FLOAT32 overlap_weight[AUDIO_CODEC_SUBBAND_COUNT_MAX]; +} ia_band_overlap_params_struct; + +typedef struct { + ia_band_overlap_params_struct str_band_overlap_params[BAND_COUNT_MAX]; +} ia_group_overlap_params_struct; + +typedef struct { + ia_group_overlap_params_struct str_group_overlap_params[CHANNEL_GROUP_COUNT_MAX]; +} ia_overlap_params_struct; + + + +WORD32 +impd_fcenter_norm_sb_init(WORD32 num_subbands, + FLOAT32* fcenter_norm_subband); + +WORD32 +impd_generate_slope (WORD32 num_subbands, + FLOAT32* fcenter_norm_subband, + FLOAT32 fcross_norm_lo, + FLOAT32 fcross_norm_hi, + FLOAT32* response); + +WORD32 +impd_generate_overlap_weights (WORD32 num_drc_bands, + WORD32 drc_band_type, + ia_gain_params_struct* gain_params, + WORD32 dec_subband_count, + ia_group_overlap_params_struct* pstr_group_overlap_params); + +WORD32 +impd_init_overlap_weight ( ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc, + ia_drc_instructions_struct* str_drc_instruction_str, + WORD32 sub_band_domain_mode, + ia_overlap_params_struct* pstr_overlap_params); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_multiband.c b/decoder/drc_src/impd_drc_multiband.c new file mode 100644 index 0000000..cdb51f4 --- /dev/null +++ b/decoder/drc_src/impd_drc_multiband.c @@ -0,0 +1,186 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include "impd_type_def.h" +#include "impd_error_standards.h" +#include "impd_drc_extr_delta_coded_info.h" +#include "impd_drc_common.h" +#include "impd_drc_struct.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_multi_band.h" +#include "impd_drc_rom.h" + +IA_ERRORCODE impd_fcenter_norm_sb_init(WORD32 num_subbands, + FLOAT32* fcenter_norm_subband) +{ + WORD32 s; + for (s=0; sstr_band_overlap_params[b].overlap_weight); + + fcross_norm_lo = fcross_norm_hi; + } + for (s=0; sstr_band_overlap_params[0].overlap_weight[s]; + for (b=1; bstr_band_overlap_params[b].overlap_weight[s]; + } + } + + for (s=0; sstr_band_overlap_params[b].overlap_weight[s] /= w_norm[s]; + } + } + } else { + start_subband_index = 0; + for (b=0; b= start_subband_index && s <= stop_sub_band_index) + { + pstr_group_overlap_params->str_band_overlap_params[b].overlap_weight[s] = 1.0; + } + else + { + pstr_group_overlap_params->str_band_overlap_params[b].overlap_weight[s] = 0.0; + } + } + start_subband_index = stop_sub_band_index+1; + } + } + + return (0); +} + +IA_ERRORCODE impd_init_overlap_weight ( ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc, + ia_drc_instructions_struct* str_drc_instruction_str, + WORD32 sub_band_domain_mode, + ia_overlap_params_struct* pstr_overlap_params) +{ + WORD32 err = 0, g; + WORD32 dec_subband_count = 0; + switch (sub_band_domain_mode) { + case SUBBAND_DOMAIN_MODE_QMF64: + dec_subband_count = AUDIO_CODEC_SUBBAND_COUNT_QMF64; + break; + case SUBBAND_DOMAIN_MODE_QMF71: + dec_subband_count = AUDIO_CODEC_SUBBAND_COUNT_QMF71; + break; + case SUBBAND_DOMAIN_MODE_STFT256: + dec_subband_count = AUDIO_CODEC_SUBBAND_COUNT_STFT256; + break; + } + + for (g=0; gnum_drc_ch_groups; g++) + { + if (str_drc_instruction_str->band_count_of_ch_group[g] > 1) + { + err = impd_generate_overlap_weights(str_drc_instruction_str->band_count_of_ch_group[g], + str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].drc_band_type, + str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].gain_params, + dec_subband_count, + &(pstr_overlap_params->str_group_overlap_params[g])); + if (err) return (err); + } + } + + return (0); +} + + + diff --git a/decoder/drc_src/impd_drc_parametric_dec.c b/decoder/drc_src/impd_drc_parametric_dec.c new file mode 100644 index 0000000..4c48d24 --- /dev/null +++ b/decoder/drc_src/impd_drc_parametric_dec.c @@ -0,0 +1,1031 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#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_parametric_drc_dec.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_rom.h" + + +#define PI 3.14159265f + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + + +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}; + 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; + + p_parametricdrc_params->sub_band_count=sub_band_count_tbl[sub_band_domain_mode]; + + return 0; +} + +WORD32 impd_init_parametric_drc_feed_fwd(ia_drc_config* pstr_drc_config, + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params) +{ + WORD32 err = 0, i = 0; + + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; + WORD32 gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; + WORD32* channel_map = p_parametricdrc_params->channel_map[instance_idx]; + + ia_drc_coeff_parametric_drc_struct* hDrcCoefficientsParametricDrcBs = &(pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc); + ia_parametric_drc_type_feed_forward_struct* hParametricDrcTypeFeedForwardBs = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx].str_parametric_drc_type_feed_forward); + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params = &(p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_parametric_drc_type_ff_params); + + /* level estimation */ + pstr_parametric_ffwd_type_drc_params->frame_size = p_parametricdrc_params->parametric_drc_frame_size; + pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode = p_parametricdrc_params->sub_band_domain_mode; + pstr_parametric_ffwd_type_drc_params->sub_band_count = p_parametricdrc_params->sub_band_count; + pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type = 0; + + if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF64) + { + if (p_parametricdrc_params->sampling_rate == 48000) + { + pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type = 1; + } + else + { + /* support of other sampling rates than 48000 might be missing */ + return UNEXPECTED_ERROR; + } + } + + pstr_parametric_ffwd_type_drc_params->audio_num_chan = p_parametricdrc_params->audio_num_chan; + pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type = hParametricDrcTypeFeedForwardBs->level_estim_k_weighting_type; + pstr_parametric_ffwd_type_drc_params->level_estim_integration_time = hParametricDrcTypeFeedForwardBs->level_estim_integration_time; + pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; + pstr_parametric_ffwd_type_drc_params->level_estim_frame_count = hParametricDrcTypeFeedForwardBs->level_estim_integration_time/pstr_parametric_ffwd_type_drc_params->frame_size; + + + memset(pstr_parametric_ffwd_type_drc_params->level,0,PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX*sizeof(FLOAT32)); + + if (ch_count_from_dwnmix_id != 0) + { + + memcpy(pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight, + hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); + } + else + { + + for (i=0; iaudio_num_chan; i++) + { + pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; + } + + } + + if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode==SUBBAND_DOMAIN_MODE_OFF) + { + err = impd_init_lvl_est_filt_time(pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type, + p_parametricdrc_params->sampling_rate, + &pstr_parametric_ffwd_type_drc_params->pre_filt_coeff, + &pstr_parametric_ffwd_type_drc_params->rlb_filt_coeff); + + if (err) + return (err); + } + else + { + err = impd_init_lvl_est_filt_subband(pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type, + p_parametricdrc_params->sampling_rate, + p_parametricdrc_params->sub_band_domain_mode, + p_parametricdrc_params->sub_band_count, + pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type, + pstr_parametric_ffwd_type_drc_params->weighting_filt, + &pstr_parametric_ffwd_type_drc_params->filt_coeff_subband); + + if (err) + return (err); + } + + pstr_parametric_ffwd_type_drc_params->node_count = hParametricDrcTypeFeedForwardBs->node_count; + + + memcpy(pstr_parametric_ffwd_type_drc_params->node_level,hParametricDrcTypeFeedForwardBs->node_level,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); + memcpy(pstr_parametric_ffwd_type_drc_params->node_gain,hParametricDrcTypeFeedForwardBs->node_gain,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); + + pstr_parametric_ffwd_type_drc_params->ref_level_parametric_drc = hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness; + + { + WORD32 gain_smooth_attack_time_fast = hParametricDrcTypeFeedForwardBs->gain_smooth_attack_time_fast; + WORD32 gain_smooth_release_time_fast = hParametricDrcTypeFeedForwardBs->gain_smooth_release_time_fast; + WORD32 gain_smooth_attack_time_slow = hParametricDrcTypeFeedForwardBs->gain_smooth_attack_time_slow; + WORD32 gain_smooth_release_time_slow = hParametricDrcTypeFeedForwardBs->gain_smooth_release_time_slow; + WORD32 gain_smooth_hold_off = hParametricDrcTypeFeedForwardBs->gain_smooth_hold_off; + WORD32 sampling_rate = p_parametricdrc_params->sampling_rate; + WORD32 parametric_drc_frame_size = p_parametricdrc_params->parametric_drc_frame_size; + + pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_fast = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_attack_time_fast * sampling_rate * 0.001)); + pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_alpha_fast = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_release_time_fast * sampling_rate * 0.001)); + pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_slow = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_attack_time_slow * sampling_rate * 0.001)); + pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_alpha_slow = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_release_time_slow * sampling_rate * 0.001)); + pstr_parametric_ffwd_type_drc_params->gain_smooth_hold_off_count = gain_smooth_hold_off * 256 * sampling_rate / (parametric_drc_frame_size * 48000); + pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_threshold = hParametricDrcTypeFeedForwardBs->gain_smooth_attack_threshold; + pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_threshold = hParametricDrcTypeFeedForwardBs->gain_smooth_rel_threshold; + } + + err = impd_parametric_ffwd_type_drc_reset(pstr_parametric_ffwd_type_drc_params); + + if (err) + return (err); + + return 0; +} + +WORD32 impd_init_parametric_drc_lim(ia_drc_config* pstr_drc_config, + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params, + pVOID *mem_ptr) +{ + WORD32 err = 0, i = 0; + UWORD32 j; + UWORD32 attack, sec_len; + + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; + WORD32 gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; + WORD32* channel_map = p_parametricdrc_params->channel_map[instance_idx]; + + ia_drc_coeff_parametric_drc_struct* hDrcCoefficientsParametricDrcBs = &(pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc); + ia_parametric_drc_lim_struct* hParametricDrcTypeLimBs = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx].parametric_drc_lim); + ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params = &(p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_parametric_drc_type_lim_params); + + pstr_parametric_lim_type_drc_params->frame_size = p_parametricdrc_params->drc_frame_size; + pstr_parametric_lim_type_drc_params->audio_num_chan = p_parametricdrc_params->audio_num_chan; + + if (ch_count_from_dwnmix_id != 0) + { + memcpy(pstr_parametric_lim_type_drc_params->level_estim_ch_weight, + hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); + } + else + { + for (i=0; iaudio_num_chan; i++) + { + pstr_parametric_lim_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; + } + + } + + attack = (UWORD32)(hParametricDrcTypeLimBs->parametric_lim_attack * p_parametricdrc_params->sampling_rate / 1000); + + sec_len = (UWORD32)sqrt(attack+1); + + pstr_parametric_lim_type_drc_params->sec_len = sec_len; + pstr_parametric_lim_type_drc_params->num_max_buf_sec = (attack+1)/sec_len; + if (pstr_parametric_lim_type_drc_params->num_max_buf_sec*sec_len < (attack+1)) + pstr_parametric_lim_type_drc_params->num_max_buf_sec++; + + pstr_parametric_lim_type_drc_params->max_buf =(FLOAT32*)(*mem_ptr); + *mem_ptr =(pVOID)((SIZE_T)(*mem_ptr)+pstr_parametric_lim_type_drc_params->num_max_buf_sec * sec_len*sizeof(FLOAT32)); + + pstr_parametric_lim_type_drc_params->attack_ms = (FLOAT32)hParametricDrcTypeLimBs->parametric_lim_attack; + pstr_parametric_lim_type_drc_params->release_ms = (FLOAT32)hParametricDrcTypeLimBs->parametric_lim_release; + pstr_parametric_lim_type_drc_params->attack = attack; + pstr_parametric_lim_type_drc_params->attack_constant = (FLOAT32)pow(0.1, 1.0 / (attack + 1)); + pstr_parametric_lim_type_drc_params->release_constant = (FLOAT32)pow(0.1, 1.0 / (hParametricDrcTypeLimBs->parametric_lim_release * p_parametricdrc_params->sampling_rate / 1000 + 1)); + pstr_parametric_lim_type_drc_params->threshold = (FLOAT32)pow(10.0f, 0.05f * hParametricDrcTypeLimBs->parametric_lim_threshold); + pstr_parametric_lim_type_drc_params->channels = pstr_parametric_lim_type_drc_params->audio_num_chan; + pstr_parametric_lim_type_drc_params->sampling_rate = p_parametricdrc_params->sampling_rate; + pstr_parametric_lim_type_drc_params->cor = 1.0f; + pstr_parametric_lim_type_drc_params->smooth_state_0 = 1.0; + + + + for (j=0; jnum_max_buf_sec * pstr_parametric_lim_type_drc_params->sec_len; j++) { + pstr_parametric_lim_type_drc_params->max_buf[j] = 0.f; + } + + + + if (err) return (err); + + return 0; +} + +WORD32 impd_init_parametric_drcInstance(ia_drc_config* pstr_drc_config, + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params, + pVOID *mem_ptr) +{ + WORD32 err = 0; + + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; + ia_parametric_drc_instructions_struct *hParametricDrcInstructions = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx]); + + p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].disable_paramteric_drc = hParametricDrcInstructions->disable_paramteric_drc; + p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type = hParametricDrcInstructions->parametric_drc_type; + p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_spline_nodes.num_nodes = p_parametricdrc_params->num_nodes; + + if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].disable_paramteric_drc == 0) + { + + if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_FF) + { + + err = impd_init_parametric_drc_feed_fwd(pstr_drc_config, + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params); + + if (err) + return (err); + + } + else if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_LIM) + { + + p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_spline_nodes.num_nodes = p_parametricdrc_params->drc_frame_size; + + err = impd_init_parametric_drc_lim(pstr_drc_config, + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params, + mem_ptr); + + if (err) + return (err); + + } else { + + return (UNEXPECTED_ERROR); + + } + } + + return 0; +} + + + +WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_parametric_drc_params_struct *p_parametricdrc_params, + pVOID *mem_ptr) +{ + + WORD32 err = 0, instance_idx = 0, gain_set_index = 0, side_chain_config_type = 0, downmix_id = 0, ch_count_from_dwnmix_id = 0, L = 0; + + p_parametricdrc_params->parametric_drc_frame_size = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_frame_size; + p_parametricdrc_params->reset_parametric_drc = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.reset_parametric_drc; + p_parametricdrc_params->num_nodes = p_parametricdrc_params->drc_frame_size/p_parametricdrc_params->parametric_drc_frame_size; + + switch (p_parametricdrc_params->sub_band_domain_mode) { + case SUBBAND_DOMAIN_MODE_QMF64: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; + break; + case SUBBAND_DOMAIN_MODE_QMF71: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; + break; + case SUBBAND_DOMAIN_MODE_STFT256: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; + break; + case SUBBAND_DOMAIN_MODE_OFF: + default: + L = 0; + break; + } + + if (p_parametricdrc_params->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_parametricdrc_params->parametric_drc_frame_size != L) + { + return (EXTERNAL_ERROR); + } + + for (instance_idx=0; instance_idxparametric_drc_instance_count; instance_idx++) { + + gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; + side_chain_config_type = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].side_chain_config_type; + downmix_id = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].downmix_id; + + if (side_chain_config_type==1 && downmix_id == p_parametricdrc_params->dwnmix_id_from_drc_instructions[instance_idx]) { + ch_count_from_dwnmix_id = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].ch_count_from_dwnmix_id; + } else { + ch_count_from_dwnmix_id = 0; + } + + if (pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness_present == 0) { + WORD32 n = 0, m = 0, drcInputLoudnessFound = 0; + FLOAT32 drc_input_loudness = 0.f; + + + for (n=0; nloudness_info_count; n++) + { + ia_loudness_info_struct* loudness_info = &pstr_loudness_info->loudness_info[n]; + if (p_parametricdrc_params->dwnmix_id_from_drc_instructions[instance_idx] == loudness_info->downmix_id) + { + if (0 == loudness_info->drc_set_id) + { + for (m=0; mmeasurement_count; m++) + { + if (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_PROGRAM_LOUDNESS) + { + drc_input_loudness = loudness_info->loudness_measure[m].method_val; + drcInputLoudnessFound = 1; + break; + } + } + if (drcInputLoudnessFound == 0) + { + for (m=0; mmeasurement_count; m++) + { + if (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_ANCHOR_LOUDNESS) + { + drc_input_loudness = loudness_info->loudness_measure[m].method_val; + drcInputLoudnessFound = 1; + break; + } + } + } + } + } + } + if (drcInputLoudnessFound == 0) + { + for (n=0; nloudness_info_count; n++) + { + ia_loudness_info_struct* loudness_info = &pstr_loudness_info->loudness_info[n]; + if (0 == loudness_info->downmix_id) + { + if (0 == loudness_info->drc_set_id) + { + for (m=0; mmeasurement_count; m++) + { + if (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_PROGRAM_LOUDNESS) + { + drc_input_loudness = loudness_info->loudness_measure[m].method_val; + drcInputLoudnessFound = 1; + break; + } + } + if (drcInputLoudnessFound == 0) { + for (m=0; mmeasurement_count; m++) + { + if (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_ANCHOR_LOUDNESS) + { + drc_input_loudness = loudness_info->loudness_measure[m].method_val; + drcInputLoudnessFound = 1; + break; + } + } + } + } + } + } + } + if (drcInputLoudnessFound == 0) { + return (UNEXPECTED_ERROR); + } else { + pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness = drc_input_loudness; + } + } + + impd_init_parametric_drcInstance(pstr_drc_config, + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params, + mem_ptr); + if (err) return (err); + } + + return 0; +} + + + +WORD32 impd_init_lvl_est_filt_time( WORD32 level_estim_k_weighting_type, + WORD32 sampling_rate, + ia_2nd_order_filt_coeff_struct* pre_filt_coeff, + ia_2nd_order_filt_coeff_struct* rlb_filt_coeff) +{ + + WORD32 i; + const FLOAT32* ptr_samp_tbl; + + switch(sampling_rate) + { + case 96000:i=0; + break; + case 88200:i=1; + break; + case 64000:i=2; + break; + case 48000:i=3; + break; + case 44100:i=4; + break; + case 32000:i=5; + break; + case 24000:i=6; + break; + case 22050:i=7; + break; + case 16000:i=8; + break; + case 12000:i=9; + break; + case 11025:i=10; + break; + case 8000:i=11; + break; + case 7350:i=12; + break; + default:i=3; + break; + } + + ptr_samp_tbl = samp_rate_tbl[i]; + + if (level_estim_k_weighting_type==2) { + + pre_filt_coeff->b0 = ptr_samp_tbl[0]; + pre_filt_coeff->b1 = ptr_samp_tbl[1]; + pre_filt_coeff->b2 = ptr_samp_tbl[2]; + pre_filt_coeff->a1 = ptr_samp_tbl[3]; + pre_filt_coeff->a2 = ptr_samp_tbl[4]; + + + } + + if (level_estim_k_weighting_type == 1 || level_estim_k_weighting_type == 2) { + + rlb_filt_coeff->b0 = ptr_samp_tbl[5]; + rlb_filt_coeff->b1 = ptr_samp_tbl[6]; + rlb_filt_coeff->b2 = ptr_samp_tbl[7]; + rlb_filt_coeff->a1 = ptr_samp_tbl[8]; + rlb_filt_coeff->a2 = ptr_samp_tbl[9]; + + } + + return 0; +} + +WORD32 impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_type, + WORD32 sampling_rate, + WORD32 sub_band_domain_mode, + WORD32 sub_band_count, + WORD32 sub_band_compensation_type, + FLOAT32 *weighting_filt, + ia_2nd_order_filt_coeff_struct* filt_coeff_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; + WORD32 b; + WORD32 i; + const FLOAT32* ptr_samp_tbl; + + switch(sampling_rate) + { + case 96000:i=0; + break; + case 88200:i=1; + break; + case 64000:i=2; + break; + case 48000:i=3; + break; + case 44100:i=4; + break; + case 32000:i=5; + break; + case 24000:i=6; + break; + case 22050:i=7; + break; + case 16000:i=8; + break; + case 12000:i=9; + break; + case 11025:i=10; + break; + case 8000:i=11; + break; + case 7350:i=12; + break; + default:i=3; + break; + } + + ptr_samp_tbl = samp_rate_tbl[i]; + + switch (sub_band_domain_mode) + { + case SUBBAND_DOMAIN_MODE_QMF64: + f_bands_nrm = f_bands_nrm_QMF64; + break; + case SUBBAND_DOMAIN_MODE_QMF71: + f_bands_nrm = f_bands_nrm_QMF71; + break; + case SUBBAND_DOMAIN_MODE_STFT256: + f_bands_nrm = f_bands_nrm_STFT256; + break; + default: + return UNEXPECTED_ERROR; + break; + } + + for (b=0; bb0 = b0/a0; + filt_coeff_subband->b1 = b1/a0; + filt_coeff_subband->b2 = b2/a0; + filt_coeff_subband->a1 = a1/a0; + filt_coeff_subband->a2 = a2/a0; + } + } + + return 0; +} + +WORD32 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params) +{ + WORD32 i = 0; + + pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; + pstr_parametric_ffwd_type_drc_params->start_up_phase = 1; + for (i=0; ilevel[i] = 0.f; + } + + for (i=0; ipre_filt_state[i].z1 = 0.f; + pstr_parametric_ffwd_type_drc_params->pre_filt_state[i].z2 = 0.f; + pstr_parametric_ffwd_type_drc_params->rlb_filt_state[i].z1 = 0.f; + pstr_parametric_ffwd_type_drc_params->rlb_filt_state[i].z2 = 0.f; + pstr_parametric_ffwd_type_drc_params->filt_state_subband_real[i].z1 = 0.f; + pstr_parametric_ffwd_type_drc_params->filt_state_subband_real[i].z2 = 0.f; + pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag[i].z1 = 0.f; + pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag[i].z2 = 0.f; + } + + pstr_parametric_ffwd_type_drc_params->db_level_smooth = -135.f; + pstr_parametric_ffwd_type_drc_params->db_gain_smooth = 0.f; + pstr_parametric_ffwd_type_drc_params->hold_counter = 0; + + return 0; +} + +WORD32 impd_parametric_drc_instance_process (FLOAT32* audio_in_out_buf[], + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + ia_parametric_drc_params_struct* p_parametricdrc_params, + ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params) +{ + WORD32 err = 0, i = 0; + + if (pstr_parametric_drc_instance_params->disable_paramteric_drc) { + + for (i=0; inum_nodes; i++) { + + pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].loc_db_gain = 0.f; + pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].slope = 0.f; + pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].time = (i+1) * p_parametricdrc_params->parametric_drc_frame_size - 1; + + } + + } else { + + 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); + for (i=0; inum_nodes; i++) { + err = impd_parametric_ffwd_type_drc_process(audio_in_out_buf, + audio_real_buff, + audio_imag_buff, + i, + pstr_parametric_ffwd_type_drc_params, + &pstr_parametric_drc_instance_params->str_spline_nodes); + if (err) return (err); + } + + } else if (pstr_parametric_drc_instance_params->parametric_drc_type == PARAM_DRC_TYPE_LIM) { + + return (UNEXPECTED_ERROR); + + } else { + return (UNEXPECTED_ERROR); + + } + + } + + return 0; +} + +VOID iir_second_order_filter (ia_2nd_order_filt_coeff_struct* coeff, + ia_2nd_order_filt_state_struct* state, + WORD32 frame_len, + FLOAT32* input, + FLOAT32* output) +{ + FLOAT32 z2=state->z2; + FLOAT32 z1=state->z1; + FLOAT32 z0; + WORD32 i; + + for (i=0; ia1 * z1 - coeff->a2 * z2; + output[i] = coeff->b0 * z0 + coeff->b1 * z1 + coeff->b2 * z2; + z2 = z1; + z1 = z0; + + } + state->z1=z1; + state->z2=z2; +} +WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* audio_in_out_buf[], + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + WORD32 nodeIdx, + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params, + ia_spline_nodes_struct* str_spline_nodes) +{ + WORD32 c, t, b, n, i, offset; + FLOAT32 x, y, channelLevel, level, levelDb, loc_db_gain, levelDelta, alpha; + + WORD32 frame_size = pstr_parametric_ffwd_type_drc_params->frame_size; + WORD32 sub_band_count = pstr_parametric_ffwd_type_drc_params->sub_band_count; + FLOAT32 *level_estim_ch_weight = pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight; + WORD32 level_estim_k_weighting_type = pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type; + + ia_2nd_order_filt_coeff_struct preC = pstr_parametric_ffwd_type_drc_params->pre_filt_coeff; + ia_2nd_order_filt_coeff_struct rlbC = pstr_parametric_ffwd_type_drc_params->rlb_filt_coeff; + ia_2nd_order_filt_state_struct* preS = pstr_parametric_ffwd_type_drc_params->pre_filt_state; + ia_2nd_order_filt_state_struct* rlbS = pstr_parametric_ffwd_type_drc_params->rlb_filt_state; + + ia_2nd_order_filt_coeff_struct rlbC_sb = pstr_parametric_ffwd_type_drc_params->filt_coeff_subband; + ia_2nd_order_filt_state_struct* rlbS_sbReal = pstr_parametric_ffwd_type_drc_params->filt_state_subband_real; + ia_2nd_order_filt_state_struct* rlbS_sbImag = pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag; + FLOAT32 *weighting_filt = pstr_parametric_ffwd_type_drc_params->weighting_filt; + WORD32 sub_band_compensation_type = pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type; + + if (audio_in_out_buf != NULL) { + + level = 0; + offset = nodeIdx * pstr_parametric_ffwd_type_drc_params->frame_size; + for(c=0; caudio_num_chan; c++) { + channelLevel = 0.f; + + if (!level_estim_ch_weight[c]) continue; + + if (level_estim_k_weighting_type == 0) { + + for(t=0; tsub_band_count; + for(c=0; caudio_num_chan; c++) { + channelLevel = 0.f; + + if (!level_estim_ch_weight[c]) continue; + + if (level_estim_k_weighting_type == 0) { + + for(b=0; blevel[pstr_parametric_ffwd_type_drc_params->level_estim_frame_index] = level; + pstr_parametric_ffwd_type_drc_params->level_estim_frame_index++; + + level = 0.f; + if (pstr_parametric_ffwd_type_drc_params->start_up_phase) { + for (i=0; ilevel_estim_frame_index; i++) { + level += pstr_parametric_ffwd_type_drc_params->level[i]; + } + level /= pstr_parametric_ffwd_type_drc_params->level_estim_frame_index * pstr_parametric_ffwd_type_drc_params->frame_size; + } else { + for (i=0; ilevel_estim_frame_count; i++) { + level += pstr_parametric_ffwd_type_drc_params->level[i]; + } + level /= pstr_parametric_ffwd_type_drc_params->level_estim_integration_time; + } + if (pstr_parametric_ffwd_type_drc_params->level_estim_frame_index == pstr_parametric_ffwd_type_drc_params->level_estim_frame_count) { + pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; + pstr_parametric_ffwd_type_drc_params->start_up_phase = 0; + } + + if (level < 1e-10f) level = 1e-10f; + if (level_estim_k_weighting_type == 2) { + levelDb = -0.691f + 10 * (FLOAT32)log10(level) + 3; + } else { + levelDb = 10 * (FLOAT32)log10(level) + 3; + } + levelDb -= pstr_parametric_ffwd_type_drc_params->ref_level_parametric_drc; + + for(n=0; nnode_count; n++) { + if (levelDb <= (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_level[n]) { + break; + } + } + if (n == 0) { + loc_db_gain = (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_gain[n]; + } else if (n == pstr_parametric_ffwd_type_drc_params->node_count) { + loc_db_gain = (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_gain[n-1] - levelDb + (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_level[n-1]; + } else { + loc_db_gain = (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_gain[n] + (levelDb - (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_level[n]) / (FLOAT32)(pstr_parametric_ffwd_type_drc_params->node_level[n-1] - pstr_parametric_ffwd_type_drc_params->node_level[n]) * (FLOAT32)(pstr_parametric_ffwd_type_drc_params->node_gain[n-1] - pstr_parametric_ffwd_type_drc_params->node_gain[n]); + } + + levelDelta = levelDb - pstr_parametric_ffwd_type_drc_params->db_level_smooth; + if (loc_db_gain < pstr_parametric_ffwd_type_drc_params->db_gain_smooth) { + if (levelDelta > pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_threshold) { + alpha = pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_fast; + } else { + alpha = pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_slow; + } + } else { + if (levelDelta < -pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_threshold) { + alpha = pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_alpha_fast; + } else { + alpha = pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_alpha_slow; + } + } + if (loc_db_gain < pstr_parametric_ffwd_type_drc_params->db_gain_smooth || pstr_parametric_ffwd_type_drc_params->hold_counter == 0) { + pstr_parametric_ffwd_type_drc_params->db_level_smooth = (1-alpha) * pstr_parametric_ffwd_type_drc_params->db_level_smooth + alpha * levelDb; + pstr_parametric_ffwd_type_drc_params->db_gain_smooth = (1-alpha) * pstr_parametric_ffwd_type_drc_params->db_gain_smooth + alpha * loc_db_gain; + } + if (pstr_parametric_ffwd_type_drc_params->hold_counter) { + pstr_parametric_ffwd_type_drc_params->hold_counter -= 1; + } + if (loc_db_gain < pstr_parametric_ffwd_type_drc_params->db_gain_smooth) { + pstr_parametric_ffwd_type_drc_params->hold_counter = pstr_parametric_ffwd_type_drc_params->gain_smooth_hold_off_count; + } + + + str_spline_nodes->str_node[nodeIdx].loc_db_gain = pstr_parametric_ffwd_type_drc_params->db_gain_smooth; + str_spline_nodes->str_node[nodeIdx].slope = 0.f; + str_spline_nodes->str_node[nodeIdx].time = pstr_parametric_ffwd_type_drc_params->frame_size + offset - 1; + + + return 0; +} + + +WORD32 impd_parametric_lim_type_drc_process(FLOAT32* samples[], + FLOAT32 loudness_normalization_gain_db, + ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params, + FLOAT32* lpcm_gains) +{ + WORD32 i, j; + FLOAT32 tmp, gain; +// FLOAT32 min_gain = 1; + FLOAT32 maximum, sectionMaximum; + FLOAT32 loudness_normalization_gain = (FLOAT32)pow(10.0f, 0.05f * loudness_normalization_gain_db); + FLOAT32* level_estim_ch_weight = pstr_parametric_lim_type_drc_params->level_estim_ch_weight; + WORD32 num_channels = pstr_parametric_lim_type_drc_params->channels; + WORD32 attack_time_samples = pstr_parametric_lim_type_drc_params->attack; + FLOAT32 attack_constant = pstr_parametric_lim_type_drc_params->attack_constant; + FLOAT32 release_constant = pstr_parametric_lim_type_drc_params->release_constant; + FLOAT32 limit_threshold = pstr_parametric_lim_type_drc_params->threshold; + FLOAT32* max_buf = pstr_parametric_lim_type_drc_params->max_buf; + FLOAT32 gain_modified = pstr_parametric_lim_type_drc_params->cor; + FLOAT64 pre_smoothed_gain = pstr_parametric_lim_type_drc_params->smooth_state_0; + + + + + + for (i = 0; i < pstr_parametric_lim_type_drc_params->frame_size; i++) { + tmp =0.0f; + for (j = 0; j < num_channels; j++){ + if (!level_estim_ch_weight[j]) + continue; + tmp = max(tmp, (FLOAT32)fabs(loudness_normalization_gain*(level_estim_ch_weight[j])*(samples[j][i]))); + } + + for (j = attack_time_samples; j >0; j--) { + max_buf[j]=max_buf[j-1]; + } + max_buf[0] = tmp; + sectionMaximum=tmp; + for (j = 1; j < (attack_time_samples+1); j++) { + if (max_buf[j] > sectionMaximum) + sectionMaximum = max_buf[j]; + } + maximum=sectionMaximum; + + if (maximum > limit_threshold) { + gain = limit_threshold / maximum; + } + else { + gain = 1; + } + + if (gain < pre_smoothed_gain) { + gain_modified = min(gain_modified, (gain - 0.1f * (FLOAT32)pre_smoothed_gain) * 1.11111111f); + } + else { + gain_modified = gain; + } + + if (gain_modified < pre_smoothed_gain) { + pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = max(pre_smoothed_gain, gain); + } + else { + pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + } + + gain = (FLOAT32)pre_smoothed_gain; + + lpcm_gains[i] = gain; + } + + + pstr_parametric_lim_type_drc_params->cor = gain_modified; + pstr_parametric_lim_type_drc_params->smooth_state_0 = pre_smoothed_gain; + return 0; +} + + + + + diff --git a/decoder/drc_src/impd_drc_parser.h b/decoder/drc_src/impd_drc_parser.h new file mode 100644 index 0000000..bb6c07a --- /dev/null +++ b/decoder/drc_src/impd_drc_parser.h @@ -0,0 +1,109 @@ +/****************************************************************************** + * + * 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_PARSER_H +#define IMPD_DRC_PARSER_H + +WORD32 +impd_dec_ducking_scaling(ia_bit_buf_struct* it_bit_buff, + WORD32* ducking_scaling_flag, + FLOAT32* ducking_scaling); + +WORD32 +impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_loudness_info_struct* loudness_info); + + +WORD32 +impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set); + +WORD32 +impd_sel_drc_coeff(ia_drc_config* drc_config, + WORD32 location, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_drc_parse_instructions_basic(ia_bit_buf_struct* it_bit_buff, + ia_drc_instructions_basic_struct* str_drc_instructions_basic); + +WORD32 +impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_config* drc_config, + ia_drc_instructions_struct* str_drc_instruction_str); + + +WORD32 +impd_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + WORD32* gain_seq_idx, + ia_gain_set_params_struct* gain_set_params); + +WORD32 +impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout, + ia_downmix_instructions_struct* dwnmix_instructions); + +WORD32 +impd_parse_drc_ext_v1( + ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config, + ia_drc_config_ext* str_drc_config_ext); + +WORD32 +impd_parse_drc_config( + ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config + ); + +WORD32 +impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set); + +WORD32 +impd_parse_drc_gain_sequence( + ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_drc_gain_sequence_struct* drc_gain_sequence); + +WORD32 +impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, + ia_uni_drc_gain_ext_struct* uni_drc_gain_ext); + +WORD32 impd_drc_uni_gain_read( + ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_drc_config* drc_config, + ia_drc_gain_struct* pstr_uni_drc_gain); + + +#endif diff --git a/decoder/drc_src/impd_drc_parser_interface.h b/decoder/drc_src/impd_drc_parser_interface.h new file mode 100644 index 0000000..c690026 --- /dev/null +++ b/decoder/drc_src/impd_drc_parser_interface.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * 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_PARSER_INTERFACE_H +#define IMPD_DRC_PARSER_INTERFACE_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 +impd_sys_interface_read(ia_bit_buf_struct* it_bit_buff, + ia_system_interface_struct* system_interface); + +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 +impd_loudness_norm_param_interface_read(ia_bit_buf_struct* it_bit_buff, + ia_loudness_norm_parameter_interface_struct* loudness_norm_param_interface); + +WORD32 +impd_drc_interface_read(ia_bit_buf_struct* it_bit_buff, + ia_dyn_rng_ctrl_interface_struct* drc_ctrl_interface); + +WORD32 +impd_drc_param_interface_read(ia_bit_buf_struct* it_bit_buff, + ia_drc_parameter_interface_struct* drc_parameter_interface); + +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 +impd_unidrc_interface_read(ia_bit_buf_struct* it_bit_buff, + ia_drc_interface_struct* impd_drc_uni_interface); + +#endif diff --git a/decoder/drc_src/impd_drc_peak_limiter.c b/decoder/drc_src/impd_drc_peak_limiter.c new file mode 100644 index 0000000..d02e3bb --- /dev/null +++ b/decoder/drc_src/impd_drc_peak_limiter.c @@ -0,0 +1,193 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include + +#include "impd_type_def.h" +#include "impd_drc_peak_limiter.h" + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + + + +WORD32 impd_peak_limiter_init( ia_drc_peak_limiter_struct *peak_limiter, + FLOAT32 attack_time, + FLOAT32 release_time, + FLOAT32 limit_threshold, + UWORD32 num_channels, + UWORD32 sample_rate, + FLOAT32 *buffer + ) +{ + + UWORD32 attack; + attack = (UWORD32)(attack_time * sample_rate / 1000); + + if (attack < 1) + return 0; + + peak_limiter->max_buf=buffer; + peak_limiter->delayed_input=buffer+attack*4+32; + + peak_limiter->delayed_input_index = 0; + peak_limiter->attack_time = attack_time; + peak_limiter->release_time = release_time; + peak_limiter->attack_time_samples = attack; + peak_limiter->attack_constant = (FLOAT32)pow(0.1, 1.0 / (attack + 1)); + peak_limiter->release_constant = (FLOAT32)pow(0.1, 1.0 / (release_time * sample_rate / 1000 + 1)); + peak_limiter->limit_threshold = limit_threshold; + peak_limiter->num_channels = num_channels; + peak_limiter->sample_rate = sample_rate; + peak_limiter->min_gain = 1.0f; + peak_limiter->limiter_on=1; + peak_limiter->pre_smoothed_gain=1.0f; + peak_limiter->gain_modified=1.0f; + + return 0; +} + +WORD32 impd_peak_limiter_reinit(ia_drc_peak_limiter_struct *peak_limiter) +{ + if (peak_limiter) + { + peak_limiter->delayed_input_index = 0; + peak_limiter->pre_smoothed_gain=1.0f; + peak_limiter->gain_modified=1.0f; + peak_limiter->min_gain = 1.0f; + memset(peak_limiter->max_buf, 0, (peak_limiter->attack_time_samples + 1) * sizeof(FLOAT32) ); + memset(peak_limiter->delayed_input, 0, peak_limiter->attack_time_samples * peak_limiter->num_channels * sizeof(FLOAT32) ); + } + + return 0; +} + +WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *samples, UWORD32 frame_len) +{ + UWORD32 i, j; + FLOAT32 tmp, gain; + FLOAT32 min_gain = 1; + FLOAT32 maximum, sectionMaximum; + UWORD32 num_channels = peak_limiter->num_channels; + UWORD32 attack_time_samples = peak_limiter->attack_time_samples; + FLOAT32 attack_constant = peak_limiter->attack_constant; + FLOAT32 release_constant = peak_limiter->release_constant; + FLOAT32 limit_threshold = peak_limiter->limit_threshold; + FLOAT32* max_buf = peak_limiter->max_buf; + FLOAT32 gain_modified = peak_limiter->gain_modified; + FLOAT32* delayed_input = peak_limiter->delayed_input; + UWORD32 delayed_input_index = peak_limiter->delayed_input_index; + FLOAT64 pre_smoothed_gain = peak_limiter->pre_smoothed_gain; + + + + + if (peak_limiter->limiter_on || (FLOAT32)pre_smoothed_gain < 1.0f) { + for (i = 0; i < frame_len; i++) { + tmp =0.0f; + for (j = 0; j < num_channels; j++) { + tmp = max(tmp, (FLOAT32)fabs(samples[i * num_channels + j])); + } + + for (j = attack_time_samples; j >0; j--) { + max_buf[j]=max_buf[j-1]; + } + max_buf[0] = tmp; + sectionMaximum=tmp; + for (j = 1; j < (attack_time_samples+1); j++) { + if (max_buf[j] > sectionMaximum) + sectionMaximum = max_buf[j]; + } + maximum=sectionMaximum; + + if (maximum > limit_threshold) { + gain = limit_threshold / maximum; + } + else { + gain = 1; + } + + if (gain < pre_smoothed_gain) { + gain_modified = min(gain_modified, (gain - 0.1f * (FLOAT32)pre_smoothed_gain) * 1.11111111f); + } + else { + gain_modified = gain; + } + + if (gain_modified < pre_smoothed_gain) { + pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = max(pre_smoothed_gain, gain); + } + else { + pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + } + + gain = (FLOAT32)pre_smoothed_gain; + + for (j = 0; j < num_channels; j++) { + tmp = delayed_input[delayed_input_index * num_channels + j]; + delayed_input[delayed_input_index * num_channels + j] = samples[i * num_channels + j]; + + tmp *= gain; + if (tmp > limit_threshold) + tmp = limit_threshold; + else if (tmp < -limit_threshold) + tmp = -limit_threshold; + + samples[i * num_channels + j] = tmp; + } + + delayed_input_index++; + if (delayed_input_index >= attack_time_samples) + delayed_input_index = 0; + + if (gain < min_gain) + min_gain = gain; + } + } + else { + for (i = 0; i < frame_len; i++) { + for (j = 0; j < num_channels; j++) { + tmp = delayed_input[delayed_input_index * num_channels + j]; + delayed_input[delayed_input_index * num_channels + j] = samples[i * num_channels + j]; + samples[i * num_channels + j] = tmp; + } + + delayed_input_index++; + if (delayed_input_index >= attack_time_samples) + delayed_input_index = 0; + } + } + + peak_limiter->gain_modified = gain_modified; + peak_limiter->delayed_input_index = delayed_input_index; + peak_limiter->pre_smoothed_gain = pre_smoothed_gain; + peak_limiter->min_gain = min_gain; + + return 0; +} + + diff --git a/decoder/drc_src/impd_drc_peak_limiter.h b/decoder/drc_src/impd_drc_peak_limiter.h new file mode 100644 index 0000000..0257201 --- /dev/null +++ b/decoder/drc_src/impd_drc_peak_limiter.h @@ -0,0 +1,57 @@ +/****************************************************************************** + * + * 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_PEAK_LIMITER_H +#define IMPD_DRC_PEAK_LIMITER_H + + +#define DEFAULT_ATTACK_TIME_MS (5.0f) /* default attack time in ms */ +#define DEFAULT_RELEASE_TIME_MS (50.0f) /* default release time in ms */ + + +typedef struct ia_drc_peak_limiter_struct { + FLOAT32 attack_time; + FLOAT32 release_time; + FLOAT32 attack_constant; + FLOAT32 release_constant; + FLOAT32 limit_threshold; + UWORD32 num_channels; + UWORD32 sample_rate; + UWORD32 attack_time_samples; + UWORD32 limiter_on; + FLOAT32 gain_modified; + FLOAT64 pre_smoothed_gain; + FLOAT32* delayed_input; + UWORD32 delayed_input_index; + FLOAT32* max_buf; + FLOAT32 min_gain; + FLOAT32* buffer; +}ia_drc_peak_limiter_struct; + +WORD32 impd_peak_limiter_init(ia_drc_peak_limiter_struct *peak_limiter, + FLOAT32 attack_time, + FLOAT32 release_time, + FLOAT32 limit_threshold, + UWORD32 num_channels, + UWORD32 sample_rate, + FLOAT32 *buffer); + +WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *samples, UWORD32 frame_len); + +#endif diff --git a/decoder/drc_src/impd_drc_peak_limiter_struct.h b/decoder/drc_src/impd_drc_peak_limiter_struct.h new file mode 100644 index 0000000..38b31e8 --- /dev/null +++ b/decoder/drc_src/impd_drc_peak_limiter_struct.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * 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_PEAK_LIMITER_STRUCT_H +#define IMPD_DRC_PEAK_LIMITER_STRUCT_H + + + +#define DEFAULT_ATTACK_TIME_MS (5.0f) /* default attack time in ms */ +#define DEFAULT_RELEASE_TIME_MS (50.0f) /* default release time in ms */ + + +typedef struct ia_drc_peak_limiter_struct { + FLOAT32 attack_time; + FLOAT32 release_time; + FLOAT32 attack_constant; + FLOAT32 release_constant; + FLOAT32 limit_threshold; + UWORD32 num_channels; + UWORD32 sample_rate; + UWORD32 attack_time_samples; + UWORD32 limiter_on; + FLOAT32 gain_modified; + FLOAT64 pre_smoothed_gain; + FLOAT32* delayed_input; + UWORD32 delayed_input_index; + FLOAT32* max_buf; + FLOAT32 min_gain; + FLOAT32* buffer; +}ia_drc_peak_limiter_struct; + +#endif + + diff --git a/decoder/drc_src/impd_drc_process.c b/decoder/drc_src/impd_drc_process.c new file mode 100644 index 0000000..fb8be2c --- /dev/null +++ b/decoder/drc_src/impd_drc_process.c @@ -0,0 +1,557 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include + +#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_filter_bank.h" +#include "impd_drc_multi_band.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_process_audio.h" + + +WORD32 impd_apply_gains_and_add(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, + shape_filter_block shape_filter_block[], + FLOAT32* deinterleaved_audio[], + + FLOAT32* channel_audio[], + WORD32 impd_apply_gains) +{ + WORD32 c, b, g, i; + WORD32 offset = 0, signalIndex = 0; + WORD32 gainIndexForGroup[CHANNEL_GROUP_COUNT_MAX]; + WORD32 signalIndexForChannel[MAX_CHANNEL_COUNT]; + FLOAT32* lpcm_gains; + FLOAT32 sum; + FLOAT32 drc_gain_last, gainThr; + WORD32 iEnd, iStart; + ia_drc_instructions_struct* str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); + + 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; gnum_drc_ch_groups-1; g++) + { + gainIndexForGroup[g+1] = gainIndexForGroup[g] + str_drc_instruction_str->band_count_of_ch_group[g]; + } + signalIndexForChannel[0] = 0; + for (c=0; caudio_num_chan-1; c++) + { + if (str_drc_instruction_str->channel_group_of_ch[c] >= 0) + { + signalIndexForChannel[c+1] = signalIndexForChannel[c] + str_drc_instruction_str->band_count_of_ch_group[str_drc_instruction_str->channel_group_of_ch[c]]; + } + else + { + signalIndexForChannel[c+1] = signalIndexForChannel[c] + 1; + } + } + + for (g=0; gnum_drc_ch_groups; g++) + { + for (b=0; bband_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; + } + iEnd = 0; + iStart = 0; + while (iEnd < ia_drc_params_struct->drc_frame_size) + { + if (shape_filter_block[g].shape_flter_block_flag) { + drc_gain_last = shape_filter_block[g].drc_gain_last; + gainThr = 0.0001f * drc_gain_last; + while ((iEnddrc_frame_size) && (fabs(lpcm_gains[iEnd] - drc_gain_last) <= gainThr)) iEnd++; + } + else + { + iEnd = ia_drc_params_struct->drc_frame_size; + } + + for (c=0; caudio_num_chan; c++) + + { + if (g == str_drc_instruction_str->channel_group_of_ch[c]) + { + signalIndex = signalIndexForChannel[c] + b; + + if(impd_apply_gains == 1) { + + impd_shape_filt_block_time_process(&shape_filter_block[g], + &lpcm_gains[0], + signalIndex, + &deinterleaved_audio[signalIndex][0], + iStart, + iEnd); + + } + else { + for (i=iStart; idrc_frame_size) && (shape_filter_block[g].shape_flter_block_flag)) + { + impd_shape_filt_block_adapt(lpcm_gains[iEnd], &shape_filter_block[g]); + } + iStart = iEnd; + } + } + } + } + } + } + +signalIndex=0; + +if (str_drc_instruction_str->drc_set_id > 0) + { + + for (c=0; caudio_num_chan; c++) + + { + g = str_drc_instruction_str->channel_group_of_ch[c]; + if (g>=0) + { + for (i=0; idrc_frame_size; i++) + { + sum = 0.0f; + for (b=0; bband_count_of_ch_group[g]; b++) + { + sum += deinterleaved_audio[signalIndex+b][i]; + } + + channel_audio[c][i] = sum; + + } + signalIndex += str_drc_instruction_str->band_count_of_ch_group[g]; + } + else + { + for (i=0; idrc_frame_size; i++) + { + channel_audio[c][i] = deinterleaved_audio[signalIndex][i]; + } + signalIndex++; + } + } + } + else + { + for (c=0; caudio_num_chan; c++) + + { + for (i=0; idrc_frame_size; i++) + { + channel_audio[c][i] = deinterleaved_audio[c][i]; + } + } + } + + + + + + + + + + + + + + + + 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; gnum_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; caudio_num_chan; c++) + + { + g = str_drc_instruction_str->channel_group_of_ch[c]; + if (g>=0) + { + for (m=0; mband_count_of_ch_group[g] > 1) + { /* multiband DRC */ + for (s=0; sband_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; sdrc_frame_size; + + if (drc_instructions_index >= 0) { + str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); + } else { + return -1; + } + + e=0; + + for (c=0; caudio_num_chan; c++) + + { + str_drc_filter_bank = NULL; + + audio_in = audio_io_buf[c]; + + audio_out = &(audio_band_buffer->non_interleaved_audio[e]); + if ((passThru == 0) && (drc_instructions_index >= 0)) + { + if (str_drc_instruction_str->drc_set_id < 0) + { + num_bands = 1; + } + else + { + g = str_drc_instruction_str->channel_group_of_ch[c]; + if (g== -1) + { + num_bands = 1; + //if (ia_filter_banks_struct->str_drc_filter_bank != NULL) + //{ + str_drc_filter_bank = &(ia_filter_banks_struct->str_drc_filter_bank[str_drc_instruction_str->num_drc_ch_groups]); + //} + } + else + { + num_bands = str_drc_instruction_str->band_count_of_ch_group[g]; + //if (ia_filter_banks_struct->str_drc_filter_bank != NULL) + //{ + str_drc_filter_bank = &(ia_filter_banks_struct->str_drc_filter_bank[g]); + //} + } + //if (ia_filter_banks_struct->str_drc_filter_bank != NULL) + //{ + //if (&str_drc_filter_bank->str_all_pass_cascade != NULL) + //{ + impd_all_pass_cascade_process(&str_drc_filter_bank->str_all_pass_cascade, c, drc_frame_size, audio_in); + //} + //} + } + } + else + { + num_bands = 1; + } + switch (num_bands) { + case 1: + for (i=0; istr_two_band_bank, + c, + drc_frame_size, + audio_in, + audio_out); + e+=2; + break; + case 3: + impd_three_band_filter_process(&str_drc_filter_bank->str_three_band_bank, + c, + drc_frame_size, + audio_in, + audio_out); + e+=3; + break; + case 4: + impd_four_band_filter_process(&str_drc_filter_bank->str_four_band_bank, + c, + drc_frame_size, + audio_in, + audio_out); + e+=4; + break; + default: + return (PARAM_ERROR); + break; + } + } + + return (0); +} + + + +WORD32 +impd_store_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], + ia_audio_in_out_buf* audio_io_buf_internal) +{ + WORD32 i,j; + + if (audio_io_buf_internal->audio_delay_samples) { + for (i=0; iaudio_num_chan; i++) { + for (j=0; jframe_size; j++) { + audio_io_buf_internal->audio_io_buffer_delayed[i][audio_io_buf_internal->audio_delay_samples+j] = audio_in_out_buf[i][j]; + } + } + } else { + audio_io_buf_internal->audio_io_buffer_delayed = audio_in_out_buf; + audio_io_buf_internal->audio_in_out_buf = audio_in_out_buf; + } + + return 0; +} + +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; iaudio_num_chan; i++) { + for (j=0; jaudio_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; + + if (audio_io_buf_internal->audio_delay_samples) { + for (i=0; iaudio_num_chan; i++) { + for (j=0; jframe_size; j++) { + audio_in_out_buf[i][j] = audio_io_buf_internal->audio_io_buffer_delayed[i][j]; + } + } + } + + return 0; +} + +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; iaudio_num_chan; i++) { + for (j=0; jaudio_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) { + for (i=0; iaudio_num_chan; i++) { + memmove(audio_io_buf_internal->audio_io_buffer_delayed[i], &audio_io_buf_internal->audio_io_buffer_delayed[i][audio_io_buf_internal->frame_size],sizeof(FLOAT32) * audio_io_buf_internal->audio_delay_samples); + } + } + + 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; iaudio_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 new file mode 100644 index 0000000..485cc71 --- /dev/null +++ b/decoder/drc_src/impd_drc_process_audio.h @@ -0,0 +1,98 @@ +/****************************************************************************** + * + * 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_PROCESS_AUDIO_H +#define IMPD_DRC_PROCESS_AUDIO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + WORD32 multiband_audio_sig_count; + WORD32 frame_size; + FLOAT32** non_interleaved_audio; +} ia_audio_band_buffer_struct; + +typedef struct { + WORD32 audio_num_chan; + WORD32 frame_size; + WORD32 audio_sub_band_count; + WORD32 audio_sub_band_frame_size; + WORD32 audio_delay_samples; + WORD32 audio_delay_sub_band_samples; + FLOAT32** audio_io_buffer_delayed; + FLOAT32** audio_buffer_delayed_real; + FLOAT32** audio_buffer_delayed_imag; + FLOAT32** audio_in_out_buf; + FLOAT32** audio_real_buff; + FLOAT32** audio_imag_buff; +} 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, + FLOAT32* audio_io_buf[], + ia_audio_band_buffer_struct* audio_band_buffer, + ia_filter_banks_struct* ia_filter_banks_struct, + const WORD32 passThru); + +WORD32 +impd_store_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], + ia_audio_in_out_buf* audio_io_buf_internal); + +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 +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 +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_qmf_filter.h b/decoder/drc_src/impd_drc_qmf_filter.h new file mode 100644 index 0000000..702ba35 --- /dev/null +++ b/decoder/drc_src/impd_drc_qmf_filter.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * + * 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_QMF_FILTER_H +#define IMPD_DRC_QMF_FILTER_H + + +#define QMF_NUM_FILT_BANDS 64 +#define QMF_FILT_RESOLUTION 64 + + +typedef struct ia_drc_qmf_filt_struct +{ + +FLOAT64* ana_buff; +FLOAT64* syn_buff; +FLOAT64 ana_tab_real[QMF_NUM_FILT_BANDS][2*QMF_NUM_FILT_BANDS]; +FLOAT64 ana_tab_imag[QMF_NUM_FILT_BANDS][2*QMF_NUM_FILT_BANDS]; +FLOAT64 syn_tab_real[2*QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS]; +FLOAT64 syn_tab_imag[2*QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS]; + +}ia_drc_qmf_filt_struct; + +#endif diff --git a/decoder/drc_src/impd_drc_rom.c b/decoder/drc_src/impd_drc_rom.c new file mode 100644 index 0000000..c1b678a --- /dev/null +++ b/decoder/drc_src/impd_drc_rom.c @@ -0,0 +1,1291 @@ +/****************************************************************************** + * + * 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 +#include +#include "impd_type_def.h" +#include "impd_drc_common.h" +#include "impd_drc_extr_delta_coded_info.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" + +const FLOAT32 samp_rate_tbl[13][12]= +{ + {1.559742927551f,-2.926673889160f,1.378173947334f,-1.844531774521f,0.855774641037f,0.997517585754f,-1.995035171509f,0.997517585754f,-1.995032072067f,0.995038211346f}, + {1.557545065880f,-2.905559301376f,1.361245870590f,-1.830842256546f,0.844074070454f,0.997298538685f,-1.994597077370f,0.997298538685f,-1.994593381882f,0.994600534439f}, + {1.547380685806f,-2.808161973953f,1.285161137581f,-1.767331838608f,0.791711509228f,0.996279776096f,-1.992559552193f,0.996279776096f,-1.992552518845f,0.992566406727f}, + {1.535182833672f,-2.691803932190f,1.198426246643f,-1.690699458122f,0.732504665852f,0.995044350624f,-1.990088701248f,0.995044350624f,-1.990076303482f,0.990100920200f}, + {1.530909657478f,-2.651169300079f,1.169166922569f,-1.663750052452f,0.712657511234f,0.994607865810f,-1.989215731621f,0.994607865810f,-1.989201068878f,0.989230215549f}, + {1.511321425438f,-2.465713739395f,1.042117238045f,-1.539572954178f,0.627297878265f,0.992580235004f,-1.985160470009f,0.992580235004f,-1.985132932663f,0.985188126564f}, + {1.488207340240f,-2.248480796814f,0.906192243099f,-1.391770243645f,0.537688970566f,0.990125238895f,-1.980250477791f,0.990125238895f,-1.980201482773f,0.980299532413f}, + {1.480212569237f,-2.173723459244f,0.862487196922f,-1.340346932411f,0.509323298931f,0.989259064198f,-1.978518128395f,0.989259064198f,-1.978460073471f,0.978576123714f}, + {1.444234013557f,-1.839543223381f,0.685432314873f,-1.107139229774f,0.397262454033f,0.985242545605f,-1.970485091209f,0.985242545605f,-1.970375299454f,0.970594763756f}, + {1.403080821037f,-1.461511373520f,0.519652962685f,-0.837045848370f,0.298268288374f,0.980395674706f,-1.960791349411f,0.980395674706f,-1.960597157478f,0.960985362530f}, + {1.389132857323f,-1.334347724915f,0.471855700016f,-0.744739949703f,0.271380871534f,0.978689610958f,-1.957379221916f,0.978689610958f,-1.957149744034f,0.957608699799f}, + {1.327733159065f,-0.780098080635f,0.309720277786f,-0.334008187056f,0.191363617778f,0.970807731152f,-1.941615462303f,0.970807731152f,-1.941183090210f,0.942047894001f}, + {1.308971643448f,-0.612507879734f,0.275601744652f,-0.207099482417f,0.179165065289f,0.968287348747f,-1.936574697495f,0.968287348747f,-1.936063885689f,0.937085747719f} +}; + + + +const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_0_1[NUM_GAIN_TBL_PROF_0_1_ENTRIES] = +{ + { 2, 0x003 , -0.125f }, + { 2, 0x002 , 0.125f }, + { 3, 0x001 , -0.250f }, + { 3, 0x002 , 0.000f }, + { 4, 0x000 , -2.000f }, + { 5, 0x002 , -0.500f }, + { 5, 0x00F , -0.375f }, + { 5, 0x00E , 1.000f }, + { 6, 0x019 , -0.625f }, + { 6, 0x018 , 0.250f }, + { 6, 0x006 , 0.375f }, + { 7, 0x00F , -1.000f }, + { 7, 0x034 , -0.875f }, + { 7, 0x036 , -0.750f }, + { 7, 0x037 , 0.500f }, + { 8, 0x01D , 0.625f }, + { 9, 0x039 , -1.875f }, + { 9, 0x0D5 , -1.125f }, + { 9, 0x0D7 , 0.750f }, + { 9, 0x0D4 , 0.875f }, + { 10, 0x070 , -1.500f }, + { 10, 0x1AC , -1.375f }, + { 10, 0x1AD , -1.250f }, + { 11, 0x0E2 , -1.750f }, + { 11, 0x0E3 , -1.625f } + +}; + +const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_2[NUM_GAIN_TBL_PROF_2_ENTRIES] = +{ + { 3, 0x007, -0.125f }, + { 4, 0x00C, -0.625f }, + { 4, 0x009, -0.500f }, + { 4, 0x005, -0.375f }, + { 4, 0x003, -0.250f }, + { 4, 0x001, 0.000f }, + { 4, 0x00B, 0.125f }, + { 5, 0x011, -0.875f }, + { 5, 0x00E, -0.750f }, + { 5, 0x005, 0.250f }, + { 5, 0x004, 0.375f }, + { 5, 0x008, 0.500f }, + { 5, 0x000, 0.625f }, + { 5, 0x00D, 0.750f }, + { 5, 0x00F, 0.875f }, + { 5, 0x010, 1.000f }, + { 5, 0x01B, 1.125f }, + { 6, 0x02B, -1.250f }, + { 6, 0x028, -1.125f }, + { 6, 0x002, -1.000f }, + { 6, 0x012, 1.250f }, + { 6, 0x018, 1.375f }, + { 6, 0x029, 1.500f }, + { 7, 0x06A, -4.000f }, + { 7, 0x054, -1.750f }, + { 7, 0x068, -1.625f }, + { 7, 0x026, -1.500f }, + { 7, 0x006, -1.375f }, + { 7, 0x032, 1.625f }, + { 8, 0x0D2, -2.250f }, + { 8, 0x0AB, -2.125f }, + { 8, 0x0AA, -2.000f }, + { 8, 0x04F, -1.875f }, + { 8, 0x04E, 1.750f }, + { 8, 0x0D7, 1.875f }, + { 8, 0x00E, 2.000f }, + { 9, 0x1AD, -3.625f }, + { 9, 0x1AC, -3.375f }, + { 9, 0x1A6, -3.250f }, + { 9, 0x0CD, -3.125f }, + { 9, 0x0CE, -2.750f }, + { 9, 0x1A7, -2.625f }, + { 9, 0x01F, -2.500f }, + { 9, 0x0CC, -2.375f }, + { 10, 0x03C, -3.500f }, + { 10, 0x19E, -3.000f }, + { 10, 0x19F, -2.875f }, + { 11, 0x07A, -3.875f }, + { 11, 0x07B, -3.750f } +}; + +const FLOAT32 channel_weight[] = +{ + 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 +}; + +const FLOAT32 dwnmix_coeff_v1[] = +{ + 10.00f, + 6.00f, + 4.50f, + 3.00f, + 1.50f, + 0.00f, + -0.50f, + -1.00f, + -1.50f, + -2.00f, + -2.50f, + -3.00f, + -3.50f, + -4.00f, + -4.50f, + -5.00f, + -5.50f, + -6.00f, + -6.50f, + -7.00f, + -7.50f, + -8.00f, + -9.00f, + -10.00f, + -11.00f, + -12.00f, + -15.00f, + -20.00f, + -25.00f, + -30.00f, + -40.00f, + -100000.0f +}; + +const FLOAT32 eq_slope_tbl [] = +{ + -32.0f, + -24.0f, + -18.0f, + -12.0f, + -7.0f, + -4.0f, + -2.0f, + -1.0f, + 1.0f, + 2.0f, + 4.0f, + 7.0f, + 12.0f, + 18.0f, + 24.0f, + 32.0f +}; + + +const FLOAT32 eq_gain_delta_tbl[] = +{ + -22.0f, + -16.0f, + -13.0f, + -11.0f, + -9.0f, + -7.0f, + -6.0f, + -5.0f, + -4.0f, + -3.0f, + -2.5f, + -2.0f, + -1.5f, + -1.0f, + -0.5f, + 0.0f, + 0.5f, + 1.0f, + 1.5f, + 2.0f, + 2.5f, + 3.0f, + 4.0f, + 5.0f, + 6.0f, + 7.0f, + 9.0f, + 11.0f, + 13.0f, + 16.0f, + 22.0f, + 32.0f, +}; + + +const FLOAT32 zero_pole_radius_tbl[] = +{ + 0.00000000E+00f, + 7.57409621E-11f, + 7.47451079E-09f, + 7.37623509E-08f, + 3.37872933E-07f, + 1.05439995E-06f, + 2.61370951E-06f, + 5.55702854E-06f, + 1.05878771E-05f, + 1.85806475E-05f, + 3.05868707E-05f, + 4.78395414E-05f, + 7.17558214E-05f, + 1.03938342E-04f, + 1.46175269E-04f, + 2.00439375E-04f, + 2.68886099E-04f, + 3.53850890E-04f, + 4.57845890E-04f, + 5.83555840E-04f, + 7.33833469E-04f, + 9.11694835E-04f, + 1.12031354E-03f, + 1.36301492E-03f, + 1.64327072E-03f, + 1.96469179E-03f, + 2.33102194E-03f, + 2.74613220E-03f, + 3.21401190E-03f, + 3.73876374E-03f, + 4.32459544E-03f, + 4.97581391E-03f, + 5.69681637E-03f, + 6.49208482E-03f, + 7.36617809E-03f, + 8.32372531E-03f, + 9.36941616E-03f, + 1.05079999E-02f, + 1.17442720E-02f, + 1.30830696E-02f, + 1.45292655E-02f, + 1.60877611E-02f, + 1.77634824E-02f, + 1.95613634E-02f, + 2.14863531E-02f, + 2.35434026E-02f, + 2.57374570E-02f, + 2.80734543E-02f, + 3.05563174E-02f, + 3.31909470E-02f, + 3.59822176E-02f, + 3.89349759E-02f, + 4.20540236E-02f, + 4.53441292E-02f, + 4.88100089E-02f, + 5.24563305E-02f, + 5.62877022E-02f, + 6.03086725E-02f, + 6.45237267E-02f, + 6.89372867E-02f, + 7.35536888E-02f, + 7.83772022E-02f, + 8.34120139E-02f, + 8.86622295E-02f, + 9.41318572E-02f, + 9.98248383E-02f, + 1.05744988E-01f, + 1.11896060E-01f, + 1.18281692E-01f, + 1.24905407E-01f, + 1.31770656E-01f, + 1.38880774E-01f, + 1.46238968E-01f, + 1.53848350E-01f, + 1.61711931E-01f, + 1.69832602E-01f, + 1.78213134E-01f, + 1.86856180E-01f, + 1.95764288E-01f, + 2.04939872E-01f, + 2.14385241E-01f, + 2.24102572E-01f, + 2.34093949E-01f, + 2.44361281E-01f, + 2.54906416E-01f, + 2.65731007E-01f, + 2.76836663E-01f, + 2.88224846E-01f, + 2.99896836E-01f, + 3.11853856E-01f, + 3.24096978E-01f, + 3.36627185E-01f, + 3.49445283E-01f, + 3.62551987E-01f, + 3.75947863E-01f, + 3.89633417E-01f, + 4.03608948E-01f, + 4.17874694E-01f, + 4.32430804E-01f, + 4.47277188E-01f, + 4.62413728E-01f, + 4.77840215E-01f, + 4.93556231E-01f, + 5.09561300E-01f, + 5.25854886E-01f, + 5.42436182E-01f, + 5.59304416E-01f, + 5.76458573E-01f, + 5.93897760E-01f, + 6.11620665E-01f, + 6.29626155E-01f, + 6.47912800E-01f, + 6.66479111E-01f, + 6.85323536E-01f, + 7.04444408E-01f, + 7.23839939E-01f, + 7.43508339E-01f, + 7.63447523E-01f, + 7.83655465E-01f, + 8.04130018E-01f, + 8.24868977E-01f, + 8.45869958E-01f, + 8.67130578E-01f, + 8.88648331E-01f, + 9.10420537E-01f, + 9.32444632E-01f, + 9.54717815E-01f, + 9.77237225E-01f +}; + +const FLOAT32 zero_pole_angle_tbl[] = +{ + 0.00000000E+00f, + 6.90533966E-04f, + 7.31595252E-04f, + 7.75098170E-04f, + 8.21187906E-04f, + 8.70018279E-04f, + 9.21752258E-04f, + 9.76562500E-04f, + 1.03463193E-03f, + 1.09615434E-03f, + 1.16133507E-03f, + 1.23039165E-03f, + 1.30355455E-03f, + 1.38106793E-03f, + 1.46319050E-03f, + 1.55019634E-03f, + 1.64237581E-03f, + 1.74003656E-03f, + 1.84350452E-03f, + 1.95312500E-03f, + 2.06926386E-03f, + 2.19230869E-03f, + 2.32267015E-03f, + 2.46078330E-03f, + 2.60710909E-03f, + 2.76213586E-03f, + 2.92638101E-03f, + 3.10039268E-03f, + 3.28475162E-03f, + 3.48007312E-03f, + 3.68700903E-03f, + 3.90625000E-03f, + 4.13852771E-03f, + 4.38461738E-03f, + 4.64534029E-03f, + 4.92156660E-03f, + 5.21421818E-03f, + 5.52427173E-03f, + 5.85276202E-03f, + 6.20078536E-03f, + 6.56950324E-03f, + 6.96014624E-03f, + 7.37401807E-03f, + 7.81250000E-03f, + 8.27705542E-03f, + 8.76923475E-03f, + 9.29068059E-03f, + 9.84313320E-03f, + 1.04284364E-02f, + 1.10485435E-02f, + 1.17055240E-02f, + 1.24015707E-02f, + 1.31390065E-02f, + 1.39202925E-02f, + 1.47480361E-02f, + 1.56250000E-02f, + 1.65541108E-02f, + 1.75384695E-02f, + 1.85813612E-02f, + 1.96862664E-02f, + 2.08568727E-02f, + 2.20970869E-02f, + 2.34110481E-02f, + 2.48031414E-02f, + 2.62780130E-02f, + 2.78405849E-02f, + 2.94960723E-02f, + 3.12500000E-02f, + 3.31082217E-02f, + 3.50769390E-02f, + 3.71627223E-02f, + 3.93725328E-02f, + 4.17137454E-02f, + 4.41941738E-02f, + 4.68220962E-02f, + 4.96062829E-02f, + 5.25560260E-02f, + 5.56811699E-02f, + 5.89921445E-02f, + 6.25000000E-02f, + 6.62164434E-02f, + 7.01538780E-02f, + 7.43254447E-02f, + 7.87450656E-02f, + 8.34274909E-02f, + 8.83883476E-02f, + 9.36441923E-02f, + 9.92125657E-02f, + 1.05112052E-01f, + 1.11362340E-01f, + 1.17984289E-01f, + 1.25000000E-01f, + 1.32432887E-01f, + 1.40307756E-01f, + 1.48650889E-01f, + 1.57490131E-01f, + 1.66854982E-01f, + 1.76776695E-01f, + 1.87288385E-01f, + 1.98425131E-01f, + 2.10224104E-01f, + 2.22724680E-01f, + 2.35968578E-01f, + 2.50000000E-01f, + 2.64865774E-01f, + 2.80615512E-01f, + 2.97301779E-01f, + 3.14980262E-01f, + 3.33709964E-01f, + 3.53553391E-01f, + 3.74576769E-01f, + 3.96850263E-01f, + 4.20448208E-01f, + 4.45449359E-01f, + 4.71937156E-01f, + 5.00000000E-01f, + 5.29731547E-01f, + 5.61231024E-01f, + 5.94603558E-01f, + 6.29960525E-01f, + 6.67419927E-01f, + 7.07106781E-01f, + 7.49153538E-01f, + 7.93700526E-01f, + 8.40896415E-01f, + 8.90898718E-01f, + 9.43874313E-01f, + 1.00000000E+00f +}; + +const FLOAT32 shape_filt_lf_y1_bound_tbl[][3] = +{ + {-0.994f,-0.996f, -1.0f}, + {-0.99f, -0.995f, -0.999f}, + {-0.98f, -0.989f, -0.996f}, + {-0.97f, -0.983f, -0.994f}, +}; + +const FLOAT32 shape_filt_hf_y1_bound_tbl[][3] = +{ + {0.15f, 0.75f, 1.05f }, + {0.43f, 0.87f, 1.07f}, + {0.60f, 0.92f, 1.07f}, + {0.80f, 1.00f, 1.06f}, + {0.90f, 1.04f, 1.073f}, +}; + +const FLOAT32 shape_filt_lf_gain_offset_tbl[][3] = { + {3.0f, 2.0f, 1.2f}, + {3.0f, 2.0f, 1.5f}, + {3.0f, 2.0f, 2.0f}, + {3.0f, 2.0f, 2.0f}, +}; + +const FLOAT32 shape_filt_hf_gain_offset_tbl[][3] = { + {4.5f, 6.0f, 3.5f}, + {3.7f, 4.0f, 2.7f}, + {3.0f, 3.5f, 2.0f}, + {2.0f, 2.5f, 1.5f}, + {1.5f, 2.0f, 1.31f}, +}; + +const FLOAT32 shape_filt_lf_radius_tbl[] = { + 0.988f, + 0.98f, + 0.96f, + 0.94f, +}; + +const FLOAT32 shape_filt_hf_radius_tbl[] = { + 0.45f, + 0.40f, + 0.35f, + 0.30f, + 0.30f +}; + +const FLOAT32 shape_filt_cutoff_freq_norm_hf_tbl[] = { + 0.15f, + 0.20f, + 0.25f, + 0.35f, + 0.45f +}; + +const ia_cicp_sigmoid_characteristic_param_struct pstr_cicp_sigmoid_characteristic_param[] = { + {0.0f, 9.0f, 12.0f}, + {0.2f, 9.0f, 12.0f}, + {0.4f, 9.0f, 12.0f}, + {0.6f, 9.0f, 12.0f}, + {0.8f, 6.0f, 8.0f}, + {1.0f, 5.0f, 6.0f} +}; + + +const ia_slope_code_table_struct slope_code_tbl_entries_by_size[NUM_SLOPE_TBL_ENTRIES] = +{ + { 1, 0x001, 0.0f, 7 }, + { 2, 0x000, -0.005f, 6 }, + { 4, 0x007, 0.005f, 8 }, + { 5, 0x00A, -0.1953f, 3 }, + { 5, 0x009, -0.0781f, 4 }, + { 5, 0x00D, -0.0312f, 5 }, + { 5, 0x00B, 0.0312f, 9 }, + { 6, 0x018, -3.0518f, 0 }, + { 6, 0x011, 0.0781f, 10 }, + { 7, 0x032, -0.4883f, 2 }, + { 7, 0x020, 1.2207f, 13 }, + { 7, 0x033, 3.0518f, 14 }, + { 8, 0x042, -1.2207f, 1 }, + { 9, 0x087, 0.1953f, 11 }, + { 9, 0x086, 0.4883f, 12 }, +}; + +const FLOAT32 dwnmix_coeff[] = +{ + 0.0f, + -0.5f, + -1.0f, + -1.5f, + -2.0f, + -2.5f, + -3.0f, + -3.5f, + -4.0f, + -4.5f, + -5.0f, + -5.5f, + -6.0f, + -7.5f, + -9.0f, + -1000.0f +}; + +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] = +{ + {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}; + +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 ia_loc_sys_interface_struct loc_sys_interface[]= +{ + {0, 1, {0,0,0}, 0, 0}, + {0, 1, {2,0,0}, 0, 0}, +}; + +const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[] = +{ + {0,0.0f}, + {0,0.0f}, +}; + +const ia_loc_loudness_norm_param_interface_struct loc_loudness_norm_param_interface[] = { + + + {0, 0, LOUDNESS_DEVIATION_MAX_DEFAULT, USER_METHOD_DEFINITION_PROGRAM_LOUDNESS, USER_MEASUREMENT_SYSTEM_BS_1770_3, USER_LOUDNESS_PREPROCESSING_OFF, 20, LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT, 0.0f, 0.0f}, + {0, 0, LOUDNESS_DEVIATION_MAX_DEFAULT, USER_METHOD_DEFINITION_PROGRAM_LOUDNESS, USER_MEASUREMENT_SYSTEM_BS_1770_3, USER_LOUDNESS_PREPROCESSING_OFF, 20, LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT, 0.0f, 0.0f}, + +}; + +const ia_loc_drc_interface_struct loc_dyn_range_ctrl_interface[] = { + + + {1, 3, {MATCH_EFFECT_TYPE, MATCH_DYNAMIC_RANGE, MATCH_DRC_CHARACTERISTIC}, SHORT_TERM_LOUDNESS_TO_AVG, 1, 5.0f, 3.0f, 10.0f, 3}, + {1, 3, {MATCH_EFFECT_TYPE, MATCH_DYNAMIC_RANGE, MATCH_DRC_CHARACTERISTIC}, TOP_OF_LOUDNESS_RANGE_TO_AVG, 0, 5.0f, 3.0f, 10.0f, 3}, + + + +}; + +const ia_loc_requested_drc_effect_struct loc_requested_drc_effect_type_str[] = { + + {1, 1, {EFFECT_TYPE_REQUESTED_NIGHT, EFFECT_TYPE_REQUESTED_GENERAL_COMPR, EFFECT_TYPE_REQUESTED_ARTISTIC, EFFECT_TYPE_REQUESTED_LIMITED, EFFECT_TYPE_REQUESTED_DIALOG}}, + {4, 1, {EFFECT_TYPE_REQUESTED_LOWLEVEL, EFFECT_TYPE_REQUESTED_NIGHT, EFFECT_TYPE_REQUESTED_LIMITED, EFFECT_TYPE_REQUESTED_ARTISTIC, EFFECT_TYPE_REQUESTED_DIALOG}}, + + +}; + +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] = { + 0.004583300000000f, + 0.000833330000000f, + 0.002083300000000f, + 0.005875000000000f, + 0.009791700000000f, + 0.014292000000000f, + 0.019792000000000f, + 0.027000000000000f, + 0.035417000000000f, + 0.042625000000000f, + 0.056750000000000f, + 0.072375000000000f, + 0.088000000000000f, + 0.103620000000000f, + 0.119250000000000f, + 0.134870000000000f, + 0.150500000000000f, + 0.166120000000000f, + 0.181750000000000f, + 0.197370000000000f, + 0.213000000000000f, + 0.228620000000000f, + 0.244250000000000f, + 0.259880000000000f, + 0.275500000000000f, + 0.291130000000000f, + 0.306750000000000f, + 0.322380000000000f, + 0.338000000000000f, + 0.353630000000000f, + 0.369250000000000f, + 0.384880000000000f, + 0.400500000000000f, + 0.416130000000000f, + 0.431750000000000f, + 0.447380000000000f, + 0.463000000000000f, + 0.478630000000000f, + 0.494250000000000f, + 0.509870000000000f, + 0.525500000000000f, + 0.541120000000000f, + 0.556750000000000f, + 0.572370000000000f, + 0.588000000000000f, + 0.603620000000000f, + 0.619250000000000f, + 0.634870000000000f, + 0.650500000000000f, + 0.666120000000000f, + 0.681750000000000f, + 0.697370000000000f, + 0.713000000000000f, + 0.728620000000000f, + 0.744250000000000f, + 0.759870000000000f, + 0.775500000000000f, + 0.791120000000000f, + 0.806750000000000f, + 0.822370000000000f, + 0.838000000000000f, + 0.853620000000000f, + 0.869250000000000f, + 0.884870000000000f, + 0.900500000000000f, + 0.916120000000000f, + 0.931750000000000f, + 0.947370000000000f, + 0.963000000000000f, + 0.974540000000000f, + 0.999040000000000f +}; + + FLOAT32 f_bands_nrm_QMF64[64] = { + 0.0078125000000000f, + 0.0234380000000000f, + 0.0390620000000000f, + 0.0546880000000000f, + 0.0703120000000000f, + 0.0859380000000000f, + 0.1015600000000000f, + 0.1171900000000000f, + 0.1328100000000000f, + 0.1484400000000000f, + 0.1640600000000000f, + 0.1796900000000000f, + 0.1953100000000000f, + 0.2109400000000000f, + 0.2265600000000000f, + 0.2421900000000000f, + 0.2578100000000000f, + 0.2734400000000000f, + 0.2890600000000000f, + 0.3046900000000000f, + 0.3203100000000000f, + 0.3359400000000000f, + 0.3515600000000000f, + 0.3671900000000000f, + 0.3828100000000000f, + 0.3984400000000000f, + 0.4140600000000000f, + 0.4296900000000000f, + 0.4453100000000000f, + 0.4609400000000000f, + 0.4765600000000000f, + 0.4921900000000000f, + 0.5078100000000000f, + 0.5234400000000000f, + 0.5390600000000000f, + 0.5546900000000000f, + 0.5703100000000000f, + 0.5859400000000000f, + 0.6015600000000000f, + 0.6171900000000000f, + 0.6328100000000000f, + 0.6484400000000000f, + 0.6640600000000000f, + 0.6796900000000000f, + 0.6953100000000000f, + 0.7109400000000000f, + 0.7265600000000000f, + 0.7421900000000000f, + 0.7578100000000000f, + 0.7734400000000000f, + 0.7890600000000000f, + 0.8046900000000000f, + 0.8203100000000000f, + 0.8359400000000000f, + 0.8515600000000000f, + 0.8671900000000000f, + 0.8828100000000000f, + 0.8984400000000000f, + 0.9140600000000000f, + 0.9296900000000000f, + 0.9453100000000000f, + 0.9609400000000000f, + 0.9765600000000000f, + 0.9921900000000000f +}; + + FLOAT32 f_bands_nrm_STFT256[257]={ + 0.000000000000000f, + 0.003906250000000f, + 0.007812500000000f, + 0.011718750000000f, + 0.015625000000000f, + 0.019531250000000f, + 0.023437500000000f, + 0.027343750000000f, + 0.031250000000000f, + 0.035156250000000f, + 0.039062500000000f, + 0.042968750000000f, + 0.046875000000000f, + 0.050781250000000f, + 0.054687500000000f, + 0.058593750000000f, + 0.062500000000000f, + 0.066406250000000f, + 0.070312500000000f, + 0.074218750000000f, + 0.078125000000000f, + 0.082031250000000f, + 0.085937500000000f, + 0.089843750000000f, + 0.093750000000000f, + 0.097656250000000f, + 0.101562500000000f, + 0.105468750000000f, + 0.109375000000000f, + 0.113281250000000f, + 0.117187500000000f, + 0.121093750000000f, + 0.125000000000000f, + 0.128906250000000f, + 0.132812500000000f, + 0.136718750000000f, + 0.140625000000000f, + 0.144531250000000f, + 0.148437500000000f, + 0.152343750000000f, + 0.156250000000000f, + 0.160156250000000f, + 0.164062500000000f, + 0.167968750000000f, + 0.171875000000000f, + 0.175781250000000f, + 0.179687500000000f, + 0.183593750000000f, + 0.187500000000000f, + 0.191406250000000f, + 0.195312500000000f, + 0.199218750000000f, + 0.203125000000000f, + 0.207031250000000f, + 0.210937500000000f, + 0.214843750000000f, + 0.218750000000000f, + 0.222656250000000f, + 0.226562500000000f, + 0.230468750000000f, + 0.234375000000000f, + 0.238281250000000f, + 0.242187500000000f, + 0.246093750000000f, + 0.250000000000000f, + 0.253906250000000f, + 0.257812500000000f, + 0.261718750000000f, + 0.265625000000000f, + 0.269531250000000f, + 0.273437500000000f, + 0.277343750000000f, + 0.281250000000000f, + 0.285156250000000f, + 0.289062500000000f, + 0.292968750000000f, + 0.296875000000000f, + 0.300781250000000f, + 0.304687500000000f, + 0.308593750000000f, + 0.312500000000000f, + 0.316406250000000f, + 0.320312500000000f, + 0.324218750000000f, + 0.328125000000000f, + 0.332031250000000f, + 0.335937500000000f, + 0.339843750000000f, + 0.343750000000000f, + 0.347656250000000f, + 0.351562500000000f, + 0.355468750000000f, + 0.359375000000000f, + 0.363281250000000f, + 0.367187500000000f, + 0.371093750000000f, + 0.375000000000000f, + 0.378906250000000f, + 0.382812500000000f, + 0.386718750000000f, + 0.390625000000000f, + 0.394531250000000f, + 0.398437500000000f, + 0.402343750000000f, + 0.406250000000000f, + 0.410156250000000f, + 0.414062500000000f, + 0.417968750000000f, + 0.421875000000000f, + 0.425781250000000f, + 0.429687500000000f, + 0.433593750000000f, + 0.437500000000000f, + 0.441406250000000f, + 0.445312500000000f, + 0.449218750000000f, + 0.453125000000000f, + 0.457031250000000f, + 0.460937500000000f, + 0.464843750000000f, + 0.468750000000000f, + 0.472656250000000f, + 0.476562500000000f, + 0.480468750000000f, + 0.484375000000000f, + 0.488281250000000f, + 0.492187500000000f, + 0.496093750000000f, + 0.500000000000000f, + 0.503906250000000f, + 0.507812500000000f, + 0.511718750000000f, + 0.515625000000000f, + 0.519531250000000f, + 0.523437500000000f, + 0.527343750000000f, + 0.531250000000000f, + 0.535156250000000f, + 0.539062500000000f, + 0.542968750000000f, + 0.546875000000000f, + 0.550781250000000f, + 0.554687500000000f, + 0.558593750000000f, + 0.562500000000000f, + 0.566406250000000f, + 0.570312500000000f, + 0.574218750000000f, + 0.578125000000000f, + 0.582031250000000f, + 0.585937500000000f, + 0.589843750000000f, + 0.593750000000000f, + 0.597656250000000f, + 0.601562500000000f, + 0.605468750000000f, + 0.609375000000000f, + 0.613281250000000f, + 0.617187500000000f, + 0.621093750000000f, + 0.625000000000000f, + 0.628906250000000f, + 0.632812500000000f, + 0.636718750000000f, + 0.640625000000000f, + 0.644531250000000f, + 0.648437500000000f, + 0.652343750000000f, + 0.656250000000000f, + 0.660156250000000f, + 0.664062500000000f, + 0.667968750000000f, + 0.671875000000000f, + 0.675781250000000f, + 0.679687500000000f, + 0.683593750000000f, + 0.687500000000000f, + 0.691406250000000f, + 0.695312500000000f, + 0.699218750000000f, + 0.703125000000000f, + 0.707031250000000f, + 0.710937500000000f, + 0.714843750000000f, + 0.718750000000000f, + 0.722656250000000f, + 0.726562500000000f, + 0.730468750000000f, + 0.734375000000000f, + 0.738281250000000f, + 0.742187500000000f, + 0.746093750000000f, + 0.750000000000000f, + 0.753906250000000f, + 0.757812500000000f, + 0.761718750000000f, + 0.765625000000000f, + 0.769531250000000f, + 0.773437500000000f, + 0.777343750000000f, + 0.781250000000000f, + 0.785156250000000f, + 0.789062500000000f, + 0.792968750000000f, + 0.796875000000000f, + 0.800781250000000f, + 0.804687500000000f, + 0.808593750000000f, + 0.812500000000000f, + 0.816406250000000f, + 0.820312500000000f, + 0.824218750000000f, + 0.828125000000000f, + 0.832031250000000f, + 0.835937500000000f, + 0.839843750000000f, + 0.843750000000000f, + 0.847656250000000f, + 0.851562500000000f, + 0.855468750000000f, + 0.859375000000000f, + 0.863281250000000f, + 0.867187500000000f, + 0.871093750000000f, + 0.875000000000000f, + 0.878906250000000f, + 0.882812500000000f, + 0.886718750000000f, + 0.890625000000000f, + 0.894531250000000f, + 0.898437500000000f, + 0.902343750000000f, + 0.906250000000000f, + 0.910156250000000f, + 0.914062500000000f, + 0.917968750000000f, + 0.921875000000000f, + 0.925781250000000f, + 0.929687500000000f, + 0.933593750000000f, + 0.937500000000000f, + 0.941406250000000f, + 0.945312500000000f, + 0.949218750000000f, + 0.953125000000000f, + 0.957031250000000f, + 0.960937500000000f, + 0.964843750000000f, + 0.968750000000000f, + 0.972656250000000f, + 0.976562500000000f, + 0.980468750000000f, + 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 ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT] = { + {2.0f/1024.0f, 0.0000373252f, 0.9913600345f}, + {3.0f/1024.0f, 0.0000836207f, 0.9870680830f}, + {4.0f/1024.0f, 0.0001480220f, 0.9827947083f}, + {5.0f/1024.0f, 0.0002302960f, 0.9785398263f}, + {6.0f/1024.0f, 0.0003302134f, 0.9743033527f}, + {2.0f/256.0f, 0.0005820761f, 0.9658852897f}, + {3.0f/256.0f, 0.0012877837f, 0.9492662926f}, + {2.0f/128.0f, 0.0022515827f, 0.9329321561f}, + {3.0f/128.0f, 0.0049030350f, 0.9010958535f}, + {2.0f/64.0f, 0.0084426929f, 0.8703307793f}, + {3.0f/64.0f, 0.0178631928f, 0.8118317459f}, + {2.0f/32.0f, 0.0299545822f, 0.7570763753f}, + {3.0f/32.0f, 0.0604985076f, 0.6574551915f}, + {2.0f/16.0f, 0.0976310729f, 0.5690355937f}, + {3.0f/16.0f, 0.1866943331f, 0.4181633458f}, + {2.0f/8.0f, 0.2928932188f, 0.2928932188f}, +}; + diff --git a/decoder/drc_src/impd_drc_rom.h b/decoder/drc_src/impd_drc_rom.h new file mode 100644 index 0000000..7078f95 --- /dev/null +++ b/decoder/drc_src/impd_drc_rom.h @@ -0,0 +1,156 @@ +/****************************************************************************** + * + * 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_ROM_H +#define IMPD_DRC_ROM_H +#define MAX_NUM_QMF_BANDS 128 + +#define NUM_GAIN_TBL_PROF_0_1_ENTRIES 25 +#define NUM_GAIN_TBL_PROF_2_ENTRIES 49 +#define NUM_SLOPE_TBL_ENTRIES 15 + +extern const FLOAT32 samp_rate_tbl[13][12]; + +extern const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_0_1[NUM_GAIN_TBL_PROF_0_1_ENTRIES]; + +extern const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_2[NUM_GAIN_TBL_PROF_2_ENTRIES]; + +extern const FLOAT32 channel_weight[]; + +extern const FLOAT32 dwnmix_coeff_v1[]; +extern const FLOAT32 eq_slope_tbl []; + +extern const FLOAT32 eq_gain_delta_tbl[]; + +extern const FLOAT32 zero_pole_radius_tbl[]; +extern const FLOAT32 zero_pole_angle_tbl[]; + +extern const FLOAT32 shape_filt_lf_y1_bound_tbl[][3]; +extern const FLOAT32 shape_filt_hf_y1_bound_tbl[][3]; + +extern const FLOAT32 shape_filt_lf_gain_offset_tbl[][3]; + +extern const FLOAT32 shape_filt_hf_gain_offset_tbl[][3]; + +extern const FLOAT32 shape_filt_lf_radius_tbl[]; + +extern const FLOAT32 shape_filt_hf_radius_tbl[]; + +extern const FLOAT32 shape_filt_cutoff_freq_norm_hf_tbl[]; + +extern const ia_cicp_sigmoid_characteristic_param_struct pstr_cicp_sigmoid_characteristic_param[]; + + +extern const ia_slope_code_table_struct slope_code_tbl_entries_by_size[NUM_SLOPE_TBL_ENTRIES]; + +extern const FLOAT32 dwnmix_coeff[]; + + +extern const FLOAT32 dwnmix_coeff_lfe[]; + +extern WORD32 drc_characteristic_order_default[][3]; + +extern 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[]; + +#define MAX_NUM_DOWNMIX_ID_REQUESTS_LOCAL 3 + +typedef struct { + WORD32 target_config_request_type; + WORD32 num_downmix_id_requests; + WORD32 requested_dwnmix_id[MAX_NUM_DOWNMIX_ID_REQUESTS_LOCAL]; + WORD32 requested_target_layout; + WORD32 requested_target_ch_count; +} ia_loc_sys_interface_struct; + + +extern const ia_loc_sys_interface_struct loc_sys_interface[]; + +typedef struct { + WORD32 loudness_normalization_on; + FLOAT32 target_loudness; +} ia_loc_loudness_norm_ctrl_interface_struct; + +extern const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[]; + +typedef struct { + WORD32 album_mode; + WORD32 peak_limiter; + WORD32 loudness_deviation_max; + WORD32 loudness_measurement_method; + WORD32 loudness_measurement_system; + WORD32 loudness_measurement_pre_proc; + WORD32 device_cut_off_frequency; + FLOAT32 loudness_norm_gain_db_max; + FLOAT32 loudness_norm_gain_modification_db; + FLOAT32 output_peak_level_max; +} ia_loc_loudness_norm_param_interface_struct; + +extern const ia_loc_loudness_norm_param_interface_struct loc_loudness_norm_param_interface[]; + +#define MAX_NUM_DRC_FEATURE_REQUESTS_LOCAL 3 +typedef struct { + WORD32 dynamic_range_control_on; + WORD32 num_drc_feature_requests; + WORD32 drc_feature_req_type[MAX_NUM_DRC_FEATURE_REQUESTS_LOCAL]; + WORD32 requested_dyn_rng_measurement_type; + WORD32 requested_dyn_range_is_single_val_flag; + FLOAT32 requested_dyn_range_value; + FLOAT32 requested_dyn_range_min_val; + FLOAT32 requested_dyn_range_max_val; + WORD32 requested_drc_characteristic; +} ia_loc_drc_interface_struct; + +extern const ia_loc_drc_interface_struct loc_dyn_range_ctrl_interface[]; + +#define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS_LOCAL 5 +typedef struct { + WORD32 requested_num_drc_effects; + WORD32 desired_num_drc_effects_of_requested; + WORD32 requested_drc_effect_type[MAX_NUM_DRC_EFFECT_TYPE_REQUESTS_LOCAL]; +} ia_loc_requested_drc_effect_struct; + +extern const ia_loc_requested_drc_effect_struct loc_requested_drc_effect_type_str[]; + +typedef struct { + FLOAT32 compress; + FLOAT32 boost; + WORD32 drc_characteristic_target; +} ia_loc_drc_parameter_interface_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]; + +FLOAT64 qmf_filter_coeff[640]; + +extern const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT]; +#endif diff --git a/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h b/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h new file mode 100644 index 0000000..77747ee --- /dev/null +++ b/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * + * 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_SEL_PROC_DRC_SET_SEL_H +#define IMPD_DRC_SEL_PROC_DRC_SET_SEL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH (1<<0) +#define SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT (1<<1) + +typedef struct { + WORD32 drc_instructions_index; + WORD32 downmix_id_request_index; + WORD32 eq_set_id; + FLOAT32 output_peak_level; + FLOAT32 loudness_norm_db_gain_adjusted; + FLOAT32 output_loudness; + FLOAT32 mixing_level; + WORD32 selection_flags; +} ia_selection_candidate_info_struct; + + +WORD32 +impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); + +WORD32 +impd_map_requested_effect_bit_idx(WORD32 requested_effect_type, + WORD32* effect_bit_idx); + +WORD32 +impd_get_fading_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_ducking_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_selected_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 drc_set_id_selected); + +WORD32 +impd_get_dependent_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_dependent_drc_instructions(const ia_drc_config* drc_config, + const ia_drc_instructions_struct* str_drc_instruction_str, + ia_drc_instructions_struct** ppstr_drc_instructions_dependent); + +WORD32 +impd_manage_drc_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config); + +WORD32 +impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config); + +WORD32 +impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config, + WORD32* repeat_selection); + +WORD32 +impd_get_selected_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 eq_set_id_selected); +WORD32 +impd_get_dependent_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_selected_loud_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 loudEqSetIdSelected); + +WORD32 +impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_effect_type_attempt(ia_drc_config* pstr_drc_config, + WORD32 requested_effect_type, + WORD32 stateRequested, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_effect_types(ia_drc_config* pstr_drc_config, + WORD32 total_effect_type_requested, + WORD32 desired_effect_type_requested, + WORD32* requested_effect_type, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32 num_drc_requests, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, + WORD32 requested_drc_characteristic, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, + WORD32 requested_drc_characteristic, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +VOID impd_select_drc_coeff3(ia_drc_config* drc_config, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 restrict_to_drc_with_album_loudness, + ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info + , WORD32* eq_set_id_valid_flag +); + +WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, + WORD32 eq_set_purpose_requested, + WORD32* eq_set_id_valid_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ); + +WORD32 +impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32* drc_set_id_selected + , WORD32* eq_set_id_selected + , WORD32* loud_eq_id_sel + ); + +WORD32 +impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); + +WORD32 +impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_interface_struct* pstr_drc_interface); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/decoder/drc_src/impd_drc_selection_process.c b/decoder/drc_src/impd_drc_selection_process.c new file mode 100644 index 0000000..606a689 --- /dev/null +++ b/decoder/drc_src/impd_drc_selection_process.c @@ -0,0 +1,1101 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include +#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_sel_proc_drc_set_sel.h" + +WORD32 impd_drc_uni_selction_proc_init(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_interface_struct* pstr_drc_interface, + WORD32 subband_domain_mode) +{ + WORD32 err = 0; + + if (pstr_drc_uni_sel_proc == NULL) { + return 1; + } + + if (pstr_drc_uni_sel_proc->first_frame == 1) { + err = impd_drc_sel_proc_init_dflt(pstr_drc_uni_sel_proc); + if (err) return (err); + } + + err = impd_drc_sel_proc_init_sel_proc_params(pstr_drc_uni_sel_proc, + pstr_drc_sel_proc_params_struct); + if (err) return (err); + { + WORD32 i; + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[0] = 1; + for (i=1; idrc_set_id_valid_flag[i] = 0; + } + + pstr_drc_uni_sel_proc->eq_set_id_valid_flag[0] = 1; + for (i=1; ieq_set_id_valid_flag[i] = 0; + } + } + err = impd_drc_sel_proc_init_interface_params(pstr_drc_uni_sel_proc, + pstr_drc_interface); + if (err) return (err); + + pstr_drc_uni_sel_proc->subband_domain_mode = subband_domain_mode; + + return 0; +} + + +WORD32 +impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_sel_proc_output_struct* hia_drc_sel_proc_output_struct) +{ + WORD32 i, err, drc_set_id_selected, activeDrcSetIndex; + WORD32 eq_set_id_selected; + WORD32 loudEqSetIdSelected; + + + if (pstr_drc_config != NULL) + { + if ( memcmp ( &pstr_drc_uni_sel_proc->drc_config, pstr_drc_config, sizeof(ia_drc_config) )) + { + pstr_drc_uni_sel_proc->drc_config = *pstr_drc_config; + pstr_drc_uni_sel_proc->drc_config_flag = 1; + + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count != pstr_drc_uni_sel_proc->drc_config.channel_layout.base_channel_count) + { + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count = pstr_drc_uni_sel_proc->drc_config.channel_layout.base_channel_count; + } + if (pstr_drc_uni_sel_proc->drc_config.channel_layout.layout_signaling_present == 1 && pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_layout != pstr_drc_uni_sel_proc->drc_config.channel_layout.defined_layout) + { + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_layout = pstr_drc_uni_sel_proc->drc_config.channel_layout.defined_layout; + } + } + else + { + pstr_drc_uni_sel_proc->drc_config_flag = 0; + } + } + if (pstr_loudness_info != NULL) + { + if ( memcmp ( &pstr_drc_uni_sel_proc->loudness_info_set, pstr_loudness_info, sizeof(ia_drc_loudness_info_set_struct) )) + { + pstr_drc_uni_sel_proc->loudness_info_set = *pstr_loudness_info; + pstr_drc_uni_sel_proc->loudness_info_set_flag = 1; + } + else + { + pstr_drc_uni_sel_proc->loudness_info_set_flag = 0; + } + } + + if ((pstr_drc_uni_sel_proc->drc_config_flag && pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type != 0) || + (pstr_drc_uni_sel_proc->sel_proc_request_flag && pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type != 0) || + (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type == 0 && pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0)) + { + err = impd_map_target_config_req_downmix_id(pstr_drc_uni_sel_proc, + &pstr_drc_uni_sel_proc->drc_config); + if (err) return (err); + } + + if (pstr_drc_uni_sel_proc->drc_config_flag || 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); + err = impd_manage_eq_complexity (pstr_drc_uni_sel_proc, pstr_drc_config); + if (err) return(err); + while (repeat_selection==1) + { + err = impd_select_drc_set(pstr_drc_uni_sel_proc, + &drc_set_id_selected + , &eq_set_id_selected + , &loudEqSetIdSelected + ); + if (err) return (err); + + err = impd_get_selected_drc_set(pstr_drc_uni_sel_proc, + drc_set_id_selected); + if (err) return (err); + + err = impd_get_dependent_drc_set(pstr_drc_uni_sel_proc); + if (err) return (err); + + err = impd_get_fading_drc_set(pstr_drc_uni_sel_proc); + if (err) return (err); + + err = impd_get_ducking_drc_set(pstr_drc_uni_sel_proc); + if (err) return (err); + + pstr_drc_uni_sel_proc->eq_inst_index[0] = -1; + pstr_drc_uni_sel_proc->eq_inst_index[1] = -1; + + err = impd_get_selected_eq_set(pstr_drc_uni_sel_proc, eq_set_id_selected); + if (err) return (err); + + err = impd_get_dependent_eq_set(pstr_drc_uni_sel_proc); + if (err) return (err); + + err = impd_get_selected_loud_eq_set(pstr_drc_uni_sel_proc, loudEqSetIdSelected); + if (err) return (err); + + activeDrcSetIndex = 0; + 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; + + str_drc_instruction_str = pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[drc_instructions_index]; + + if (drc_instructions_index >= 0 && str_drc_instruction_str.drc_set_id > 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[activeDrcSetIndex] = str_drc_instruction_str.drc_set_id; + + if ((i==3) && (str_drc_instruction_str.drc_set_effect & (EFFECT_BIT_DUCK_SELF | EFFECT_BIT_DUCK_OTHER))) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_downmix_ids[activeDrcSetIndex] = 0; + } + else { + if (str_drc_instruction_str.drc_apply_to_dwnmix == 1) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_downmix_ids[activeDrcSetIndex] = str_drc_instruction_str.downmix_id[0]; + } else { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_downmix_ids[activeDrcSetIndex] = 0; + } + } + + activeDrcSetIndex++; + } + } + if (activeDrcSetIndex <= 3) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.num_sel_drc_sets = activeDrcSetIndex; + } else + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.num_sel_drc_sets = -1; + return(UNEXPECTED_ERROR); + } + + impd_sel_downmix_matrix(pstr_drc_uni_sel_proc, + &pstr_drc_uni_sel_proc->drc_config); + + 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; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.boost = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.boost; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.compress = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.drc_characteristic_target = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db += pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db; + + + + } + for (i=0; i<2; i++) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_eq_set_ids[i] = pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[pstr_drc_uni_sel_proc->eq_inst_index[i]].eq_set_id; + } + if (pstr_drc_uni_sel_proc->loud_eq_inst_index_sel >= 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_loud_eq_id = pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.loud_eq_instructions[pstr_drc_uni_sel_proc->loud_eq_inst_index_sel].loud_eq_set_id; + } + else + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_loud_eq_id = 0; + } + *hia_drc_sel_proc_output_struct = pstr_drc_uni_sel_proc->uni_drc_sel_proc_output; + + return 0; +} + +WORD32 impd_map_target_config_req_downmix_id(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config) +{ + WORD32 i, dwnmix_instructions_count; + WORD32 target_ch_count_prelim = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 0; + switch (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type) { + case 0: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[0] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 1; + } + break; + case 1: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_layout == pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_layout) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[0] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0) { + dwnmix_instructions_count = pstr_drc_uni_sel_proc->drc_config.dwnmix_instructions_count; + for (i=0; idwnmix_instructions[i]); + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_layout == dwnmix_instructions->target_layout) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests] = dwnmix_instructions->downmix_id; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests += 1; + target_ch_count_prelim = dwnmix_instructions->target_channel_count; + } + } + } + + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[0] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 1; + } + break; + case 2: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_ch_count == pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[0] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0) + { + dwnmix_instructions_count = pstr_drc_uni_sel_proc->drc_config.dwnmix_instructions_count; + for (i=0; idwnmix_instructions[i]); + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_ch_count == dwnmix_instructions->target_channel_count) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests] = dwnmix_instructions->downmix_id; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests += 1; + target_ch_count_prelim = dwnmix_instructions->target_channel_count; + } + } + } + + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests == 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[0] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 1; + } + break; + default: + return UNEXPECTED_ERROR; + break; + } + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_ch_count_prelim = target_ch_count_prelim; + + return 0; +} + +VOID impd_sel_downmix_matrix(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config) +{ + WORD32 i, j, n; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count = pstr_drc_config->channel_layout.base_channel_count; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = pstr_drc_config->channel_layout.base_channel_count; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_layout = -1; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix_present = 0; + pstr_drc_uni_sel_proc->downmix_inst_index_sel = -1; + + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id != 0) { + + for (n=0; ndwnmix_instructions_count; n++) { + ia_downmix_instructions_struct* dwnmix_instructions = &(pstr_drc_config->dwnmix_instructions[n]); + + + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id == dwnmix_instructions->downmix_id) { + pstr_drc_uni_sel_proc->downmix_inst_index_sel = n; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = dwnmix_instructions->target_channel_count; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_layout = dwnmix_instructions->target_layout; + if (dwnmix_instructions->downmix_coefficients_present) { + for( i =0 ; i < pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count; i++) + { + for( j =0 ; j < pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count; j++) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix[i][j] = dwnmix_instructions->downmix_coefficient[i+j*pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count]; + } + } + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix_present = 1; + } + break; + } + } + } + return; +} + + +WORD32 impd_get_selected_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 eq_set_id_selected) +{ + WORD32 n; + + pstr_drc_uni_sel_proc->eq_inst_index_sel = -1; + + if (eq_set_id_selected > 0) + { + for(n=0; ndrc_config.str_drc_config_ext.eq_instructions_count; n++) + { + if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[n].eq_set_id == eq_set_id_selected) break; + } + if (n == pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.eq_instructions_count) + { + return(EXTERNAL_ERROR); + } + pstr_drc_uni_sel_proc->eq_inst_index_sel = n; + if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[n].eq_apply_to_downmix == 1) + { + pstr_drc_uni_sel_proc->eq_inst_index[1] = pstr_drc_uni_sel_proc->eq_inst_index_sel; + } + else + { + pstr_drc_uni_sel_proc->eq_inst_index[0] = pstr_drc_uni_sel_proc->eq_inst_index_sel; + } + } + return (0); +} + +WORD32 impd_get_dependent_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) +{ + ia_eq_instructions_struct* str_eq_instructions = NULL; + + if (pstr_drc_uni_sel_proc->eq_inst_index_sel >= 0) + { + str_eq_instructions = &(pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[pstr_drc_uni_sel_proc->eq_inst_index_sel]); + + if (str_eq_instructions->depends_on_eq_set_present == 1) + { + WORD32 n; + WORD32 dependsOnEqSetID = str_eq_instructions->depends_on_eq_set; + + for(n=0; ndrc_config.str_drc_config_ext.eq_instructions_count; n++) + { + if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[n].eq_set_id == dependsOnEqSetID) break; + } + if (n == pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.eq_instructions_count) + { + return(UNEXPECTED_ERROR); + } + if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[n].eq_apply_to_downmix == 1) + { + pstr_drc_uni_sel_proc->eq_inst_index[1] = n; + } + else + { + pstr_drc_uni_sel_proc->eq_inst_index[0] = n; + } + } + } + return (0); +} + +WORD32 impd_get_selected_loud_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 loudEqSetIdSelected) +{ + WORD32 n; + + pstr_drc_uni_sel_proc->loud_eq_inst_index_sel = -1; + + if (loudEqSetIdSelected > 0) + { + for(n=0; ndrc_config.str_drc_config_ext.loud_eq_instructions_count; n++) + { + if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.loud_eq_instructions[n].loud_eq_set_id == loudEqSetIdSelected) break; + } + if (n == pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.loud_eq_instructions_count) + { + return(EXTERNAL_ERROR); + } + pstr_drc_uni_sel_proc->loud_eq_inst_index_sel = n; + } + return (0); +} + +WORD32 impd_select_loud_eq(ia_drc_config* pstr_drc_config, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32 eq_set_id_requested, + WORD32* loud_eq_id_sel) +{ + WORD32 i, c, d, e; + + *loud_eq_id_sel = 0; + for (i=0; istr_drc_config_ext.loud_eq_instructions_count; i++) + { + ia_loud_eq_instructions_struct* loud_eq_instructions = &pstr_drc_config->str_drc_config_ext.loud_eq_instructions[i]; + if (loud_eq_instructions->drc_location == LOCATION_SELECTED) { + for (d=0; ddwnmix_id_count; d++) + { + if ((loud_eq_instructions->downmix_id[d] == requested_dwnmix_id) || (loud_eq_instructions->downmix_id[d] == ID_FOR_ANY_DOWNMIX)) { + for (c=0; cdrc_set_id_count; c++) + { + if ((loud_eq_instructions->drc_set_id[c] == drc_set_id_requested) || (loud_eq_instructions->drc_set_id[c] == ID_FOR_ANY_DRC)) { + for (e=0; eeq_set_id_count; e++) + { + if ((loud_eq_instructions->eq_set_id[e] == eq_set_id_requested) || (loud_eq_instructions->eq_set_id[e] == ID_FOR_ANY_EQ)) { + *loud_eq_id_sel = loud_eq_instructions->loud_eq_set_id; + } + } + } + } + } + } + } + } + return (0); +} + +WORD32 impd_match_eq_set(ia_drc_config* drc_config, + WORD32 downmix_id, + WORD32 drc_set_id, + WORD32* eq_set_id_valid_flag, + WORD32* matching_eq_set_count, + WORD32* matching_eq_set_idx) +{ + ia_eq_instructions_struct* str_eq_instructions = NULL; + WORD32 i, k, n; + WORD32 match = 0; + *matching_eq_set_count = 0; + for (i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; + + if (str_eq_instructions->depends_on_eq_set_present == 0) { + if (str_eq_instructions->no_independent_eq_use == 1) continue; + } + if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; + for (k=0; kdwnmix_id_count; k++) { + if ((str_eq_instructions->downmix_id[k] == ID_FOR_ANY_DOWNMIX) || (downmix_id == str_eq_instructions->downmix_id[k])) { + for (n=0; ndrc_set_id_count; n++) { + if ((str_eq_instructions->drc_set_id[n] == ID_FOR_ANY_DRC) || (drc_set_id == str_eq_instructions->drc_set_id[n])) { + match = 1; + matching_eq_set_idx[*matching_eq_set_count] = i; + (*matching_eq_set_count)++; + } + } + } + } + } + return(0); +} + +WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, + WORD32 eq_set_purpose_requested, + WORD32* eq_set_id_valid_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ) +{ + WORD32 i,j,k; + WORD32 match_found_flag; + WORD32 loop_cnt = 0; + ia_eq_instructions_struct* str_eq_instructions = NULL; + match_found_flag = 0; + + k = 0; + while ((k==0) && (loop_cnt < 2)) + { + for (j=0; j < *selection_candidate_count; j++) + { + WORD32 eq_set_id_requested = selection_candidate_info[j].eq_set_id; + + for (i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; + + if (str_eq_instructions->depends_on_eq_set_present == 0) { + if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; + } + if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; + if ((str_eq_instructions->eq_set_id == eq_set_id_requested) && (str_eq_instructions->eq_set_purpose & eq_set_purpose_requested)) + { + match_found_flag = 1; + } + } + + if (match_found_flag > 0) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[j], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + eq_set_purpose_requested = EQ_PURPOSE_DEFAULT; + loop_cnt++; + } + + if (k>0) { + memcpy(&selection_candidate_info[0], &selection_candidate_info_step_2[0], k * sizeof(ia_selection_candidate_info_struct)); + *selection_candidate_count = k; + } + + return(0); +} + +WORD32 impd_find_eq_set_no_compression(ia_drc_config* pstr_drc_config, + WORD32 requested_dwnmix_id, + WORD32* num_compression_eq_count, + WORD32* num_compression_eq_id) +{ + WORD32 i, d, k, c; + k=0; + for (i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + ia_eq_instructions_struct* str_eq_instructions = &pstr_drc_config->str_drc_config_ext.str_eq_instructions[i]; + for (d=0; ddwnmix_id_count; d++) + { + if (requested_dwnmix_id == str_eq_instructions->downmix_id[d]) + { + for (c=0; cdrc_set_id_count; c++) + { + if ((str_eq_instructions->drc_set_id[c] == ID_FOR_ANY_DRC) || (str_eq_instructions->drc_set_id[c] == 0)) + { + num_compression_eq_id[k] = str_eq_instructions->eq_set_id; + k++; + } + } + } + } + } + *num_compression_eq_count = k; + return (0); +} + + +VOID impd_select_drc_coeff3(ia_drc_config* drc_config, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc) +{ + WORD32 n; + WORD32 cV1 = -1; + WORD32 cV0 = -1; + for(n=0; ndrc_coefficients_drc_count; n++) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].drc_location == 1) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].version == 0) + { + cV0 = n; + } + else + { + cV1 = n; + } + } + } + if (cV1 >= 0) { + *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cV1]); + } + else if (cV0 >= 0) { + *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cV0]); + } + else { + *str_p_loc_drc_coefficients_uni_drc = NULL; + } + return; +} + + + +WORD32 impd_manage_drc_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config) +{ + WORD32 i, j, err, channel_count; + WORD32 numBandsTooLarge = 0; + FLOAT32 complexityDrcPrelim; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc; + FLOAT32 complexitySupportedTotal = (FLOAT32)(pow(2.0f, pstr_drc_uni_sel_proc->compl_level_supported_total)); + ia_drc_instructions_struct* str_drc_instruction_str; + ia_drc_instructions_struct* drc_inst_uni_drc_dependent; + ia_drc_sel_proc_output_struct* uni_drc_sel_proc_output = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_output; + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; + + impd_select_drc_coeff3(pstr_drc_config, &str_p_loc_drc_coefficients_uni_drc); + + for (i=0; idrc_instructions_uni_drc_count; i++) + { + str_drc_instruction_str = &pstr_drc_config->str_drc_instruction_str[i]; + if (str_drc_instruction_str->no_independent_use) continue; + + numBandsTooLarge = 0; + if (str_drc_instruction_str->drc_apply_to_dwnmix == 1) + { + channel_count = uni_drc_sel_proc_output->target_channel_count; + } + else + { + channel_count = uni_drc_sel_proc_output->base_channel_count; + } + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + for (j=0; jnum_drc_ch_groups; j++) + { + ia_gain_set_params_struct* gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[j]]); + if (gain_set_params->band_count > pstr_drc_sel_proc_params_struct->num_bands_supported) + { + numBandsTooLarge = 1; + } + else + { + if (gain_set_params->band_count > 4) + { + /* Add complexity for analysis and synthesis QMF bank here, if supported */ + } + } + } + } + complexityDrcPrelim =(FLOAT32)( channel_count * (1 << str_drc_instruction_str->drc_set_complexity_level)); + + if (str_drc_instruction_str->depends_on_drc_set > 0) + { + err = impd_find_drc_instructions_uni_drc(pstr_drc_config, str_drc_instruction_str->depends_on_drc_set, &drc_inst_uni_drc_dependent); + if (err) return (err); + if (drc_inst_uni_drc_dependent->drc_apply_to_dwnmix == 1) + { + channel_count = uni_drc_sel_proc_output->target_channel_count; + } + else + { + channel_count = uni_drc_sel_proc_output->base_channel_count; + } + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + for (j=0; jnum_drc_ch_groups; j++) + { + ia_gain_set_params_struct* gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[drc_inst_uni_drc_dependent->gain_set_index_for_channel_group[j]]); + if (gain_set_params->band_count > pstr_drc_sel_proc_params_struct->num_bands_supported) + { + numBandsTooLarge = 1; + } + else + { + if (gain_set_params->band_count > 4) + { + /* Add complexity for analysis and synthesis QMF bank here, if supported */ + } + } + } + } + complexityDrcPrelim += channel_count * (1 << drc_inst_uni_drc_dependent->drc_set_complexity_level); + } + + complexityDrcPrelim *= pstr_drc_config->sampling_rate / 48000.0f; + + if ((complexityDrcPrelim <= complexitySupportedTotal) && (numBandsTooLarge == 0)) + { + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 1; + } + } + return (0); +} + +WORD32 impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config) +{ + WORD32 k, n, m, err; + WORD32 eqComplexityPrimary = 0; + WORD32 eqComplexityDependent = 0; + WORD32 eqChannelCountPrimary = 0, eqChannelCountDependent = 0; + FLOAT32 complexityTotalEq; + ia_drc_config* drc_config = &pstr_drc_uni_sel_proc->drc_config; + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; + FLOAT32 complexitySupportedTotal =(FLOAT32)( pow(2.0f, pstr_drc_uni_sel_proc->compl_level_supported_total)); + + for (n=0; nstr_drc_config_ext.eq_instructions_count; n++) + { + ia_eq_instructions_struct* str_eq_instructions = &pstr_drc_config->str_drc_config_ext.str_eq_instructions[n]; + + eqChannelCountPrimary = pstr_drc_sel_proc_params_struct->base_channel_count; + eqChannelCountDependent = pstr_drc_sel_proc_params_struct->base_channel_count; + + eqComplexityPrimary = 1 << str_eq_instructions->eq_set_complexity_level; + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + if (str_eq_instructions->td_filter_cascade_present == 0) + { + eqComplexityPrimary = 0; + } + } + else + { + if (str_eq_instructions->td_filter_cascade_present == 1) + { + eqComplexityPrimary =(WORD32) 2.5f; + } + } + if (str_eq_instructions->eq_apply_to_downmix == 1) + { + if (str_eq_instructions->downmix_id[0] == ID_FOR_ANY_DOWNMIX) + { + eqChannelCountPrimary = pstr_drc_sel_proc_params_struct->target_ch_count_prelim; + } + else + { + for (k=0; kdwnmix_instructions_count; k++) + { + for (m=0; mdwnmix_id_count; m++) + { + if (pstr_drc_config->dwnmix_instructions[k].downmix_id == str_eq_instructions->downmix_id[m]) + { + if (eqChannelCountPrimary > pstr_drc_config->dwnmix_instructions[k].target_channel_count) { + eqChannelCountPrimary = pstr_drc_config->dwnmix_instructions[k].target_channel_count; + } + } + } + } + } + } + complexityTotalEq = (FLOAT32)(eqChannelCountPrimary * eqComplexityPrimary); + + if (str_eq_instructions->depends_on_eq_set_present > 0) + { + ia_eq_instructions_struct* eq_instructionsDependent; + err = impd_find_eq_instructions(drc_config, str_eq_instructions->depends_on_eq_set, &eq_instructionsDependent); + if (err) return (err); + eqComplexityDependent = 1 << eq_instructionsDependent->eq_set_complexity_level; + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + if (str_eq_instructions->td_filter_cascade_present == 0) + { + eqComplexityDependent = 0; + } + } + else + { + if (str_eq_instructions->td_filter_cascade_present == 1) + { + eqComplexityDependent =(WORD32) 2.5f; + } + } + if (eq_instructionsDependent->eq_apply_to_downmix == 1) + { + if (eq_instructionsDependent->downmix_id[0] == ID_FOR_ANY_DOWNMIX) + { + eqChannelCountDependent = pstr_drc_sel_proc_params_struct->target_ch_count_prelim; + } + else + { + for (k=0; kdwnmix_instructions_count; k++) + { + for (m=0; mdwnmix_id_count; m++) + { + if (pstr_drc_config->dwnmix_instructions[k].downmix_id == eq_instructionsDependent->downmix_id[m]) + { + if (eqChannelCountDependent > pstr_drc_config->dwnmix_instructions[k].target_channel_count) { + eqChannelCountDependent = pstr_drc_config->dwnmix_instructions[k].target_channel_count; + } + } + } + } + } + } + complexityTotalEq += eqChannelCountDependent * eqComplexityDependent; + } + + pstr_drc_uni_sel_proc->eq_set_id_valid_flag[str_eq_instructions->eq_set_id] = 0; + complexityTotalEq *= pstr_drc_config->sampling_rate / 48000.0f; + + if (complexityTotalEq <= complexitySupportedTotal) + { + pstr_drc_uni_sel_proc->eq_set_id_valid_flag[str_eq_instructions->eq_set_id] = 1; + } + } + return 0; +} + + +WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config, + WORD32* repeat_selection) +{ + WORD32 i, j, p, err; + WORD32 channel_count; + WORD32 numBandsTooLarge = 0; + WORD32 drcRequiresEq; + FLOAT32 complexityEq; + FLOAT32 complexityDrcTotal = 0.0f; + FLOAT32 complexityEqTotal = 0.0f; + FLOAT32 freqNorm = pstr_drc_config->sampling_rate / 48000.0f; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc; + ia_drc_instructions_struct* str_drc_instruction_str = &pstr_drc_config->str_drc_instruction_str[0]; + ia_drc_sel_proc_output_struct* uni_drc_sel_proc_output = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_output; + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; + FLOAT32 complexitySupportedTotal =(FLOAT32)( pow(2.0f, pstr_drc_uni_sel_proc->compl_level_supported_total)); + + impd_select_drc_coeff3(pstr_drc_config, &str_p_loc_drc_coefficients_uni_drc); + + for (p=0; p<4; p++) + { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] <= 0) continue; + err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p], &str_drc_instruction_str); + if (err) return (err); + + if (str_drc_instruction_str->drc_apply_to_dwnmix == 1) + { + channel_count = uni_drc_sel_proc_output->target_channel_count; + } + else + { + channel_count = uni_drc_sel_proc_output->base_channel_count; + } + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + for (j=0; jnum_drc_ch_groups; j++) + { + ia_gain_set_params_struct* gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[j]]); + if (gain_set_params->band_count > pstr_drc_sel_proc_params_struct->num_bands_supported) + { + if (p<2) + { + numBandsTooLarge = 1; + } + else + { + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] = 0; + } + } + else + { + if (gain_set_params->band_count > 4) + { + /* Add complexity for analysis and synthesis QMF bank here, if supported */ + } + } + } + } + complexityDrcTotal += channel_count * (1 << str_drc_instruction_str->drc_set_complexity_level); + } + + if (uni_drc_sel_proc_output->active_downmix_id > 0) + { + FLOAT32 complexityPerCoeff; + ia_downmix_instructions_struct* dwnmix_instructions; + + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + complexityPerCoeff = 1.0f; + } + else + { + complexityPerCoeff = 2.0f; + } + impd_find_downmix(pstr_drc_config, uni_drc_sel_proc_output->active_downmix_id, &dwnmix_instructions); + if (dwnmix_instructions->downmix_coefficients_present == 1) + { + for (i=0; ibase_channel_count; i++) + { + for (j=0; jtarget_channel_count; j++) + { + if (uni_drc_sel_proc_output->downmix_matrix[i][j] != 0.0f) + { + complexityDrcTotal += complexityPerCoeff; + } + } + } + } + else + { + /* add standard downmix here */ + } + } + + for (p=0; p<2; p++) + { + if(pstr_drc_uni_sel_proc->eq_inst_index[p] >= 0) + { + ia_eq_instructions_struct* str_eq_instructions = &pstr_drc_config->str_drc_config_ext.str_eq_instructions[pstr_drc_uni_sel_proc->eq_inst_index[p]]; + if (p==0) + { + channel_count = uni_drc_sel_proc_output->base_channel_count; + } + else + { + channel_count = uni_drc_sel_proc_output->target_channel_count; + } + + complexityEq =(FLOAT32)(1 << str_eq_instructions->eq_set_complexity_level); + if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) + { + if (str_eq_instructions->td_filter_cascade_present == 0) + { + complexityEq = 0.0; + } + } + else + { + if (str_eq_instructions->td_filter_cascade_present == 1) + { + complexityEq = 2.5; + } + } + + complexityEqTotal += channel_count * complexityEq; + } + } + + complexityDrcTotal *= freqNorm; + complexityEqTotal *= freqNorm; + + if (numBandsTooLarge == 1) + { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0] > 0) + { + err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0], &str_drc_instruction_str); + if (err) return (err); + + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; + } + *repeat_selection = 1; + } + else + { + if (complexityDrcTotal + complexityEqTotal <= complexitySupportedTotal) + { + *repeat_selection = 0; + } + else + { + drcRequiresEq = 0; + for (p=0; p<2; p++) + { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] <= 0) continue; + err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p], &str_drc_instruction_str); + if (err) return (err); + if (str_drc_instruction_str->requires_eq == 1) + { + drcRequiresEq = 1; + } + } + if ((drcRequiresEq == 0) && (complexityDrcTotal <= complexitySupportedTotal)) + { + for (p=0; p<2; p++) + { + pstr_drc_uni_sel_proc->eq_inst_index[p] = 0; + } + *repeat_selection = 0; + } + else + { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0] > 0) + { + err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0], &str_drc_instruction_str); + if (err) return (err); + + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; + } + else + { + for (p=2; p<4; p++) + { + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] = 0; + } + } + *repeat_selection = 1; + } + } + } + + if (*repeat_selection == 1) + { + memset (&pstr_drc_uni_sel_proc->uni_drc_sel_proc_output, 0, sizeof(ia_drc_sel_proc_output_struct)); + } + return (0); +} + + + +WORD32 impd_find_loud_eq_instructions_idx_for_id(ia_drc_config* drc_config, + WORD32 loud_eq_set_id_requested, + WORD32* instructions_idx) +{ + WORD32 i; + if (loud_eq_set_id_requested > 0) + { + for (i=0; istr_drc_config_ext.loud_eq_instructions_count; i++) + { + if (drc_config->str_drc_config_ext.loud_eq_instructions[i].loud_eq_set_id == loud_eq_set_id_requested) break; + } + if (i == drc_config->str_drc_config_ext.loud_eq_instructions_count) + { + return (UNEXPECTED_ERROR); + } + *instructions_idx = i; + } + else + { + *instructions_idx = -1; + } + return (0); +} + + +WORD32 impd_find_eq_instructions(ia_drc_config* drc_config, + WORD32 eq_set_id_requested, + ia_eq_instructions_struct** str_eq_instructions) +{ + WORD32 i; + for (i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + if (eq_set_id_requested == drc_config->str_drc_config_ext.str_eq_instructions[i].eq_set_id) break; + } + if (i == drc_config->str_drc_config_ext.eq_instructions_count) + { + return (UNEXPECTED_ERROR); + } + *str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; + return (0); +} + +WORD32 impd_find_downmix(ia_drc_config* drc_config, + WORD32 requested_dwnmix_id, + ia_downmix_instructions_struct** dwnmix_instructions) +{ + WORD32 i; + for (i=0; idwnmix_instructions_count; i++) + { + if (requested_dwnmix_id == drc_config->dwnmix_instructions[i].downmix_id) break; + } + if (i == drc_config->dwnmix_instructions_count) + { + + return (UNEXPECTED_ERROR); + } + *dwnmix_instructions = &drc_config->dwnmix_instructions[i]; + return (0); +} + \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_selection_process.h b/decoder/drc_src/impd_drc_selection_process.h new file mode 100644 index 0000000..6e6cefb --- /dev/null +++ b/decoder/drc_src/impd_drc_selection_process.h @@ -0,0 +1,190 @@ +/****************************************************************************** + * + * 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_SECLECTION_PROCESS_H +#define IMPD_DRC_SECLECTION_PROCESS_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EFFECT_TYPE_REQUESTED_NONE 0 +#define EFFECT_TYPE_REQUESTED_NIGHT 1 +#define EFFECT_TYPE_REQUESTED_NOISY 2 +#define EFFECT_TYPE_REQUESTED_LIMITED 3 +#define EFFECT_TYPE_REQUESTED_LOWLEVEL 4 +#define EFFECT_TYPE_REQUESTED_DIALOG 5 +#define EFFECT_TYPE_REQUESTED_GENERAL_COMPR 6 +#define EFFECT_TYPE_REQUESTED_EXPAND 7 +#define EFFECT_TYPE_REQUESTED_ARTISTIC 8 +#define EFFECT_TYPE_REQUESTED_COUNT 9 + +#define MATCH_EFFECT_TYPE 0 +#define MATCH_DYNAMIC_RANGE 1 +#define MATCH_DRC_CHARACTERISTIC 2 + + +typedef struct ia_drc_sel_proc_params_struct +{ + WORD32 base_channel_count; + WORD32 base_layout; + WORD32 target_config_request_type; + WORD32 num_downmix_id_requests; + WORD32 requested_dwnmix_id[MAX_NUM_DOWNMIX_ID_REQUESTS]; + WORD32 requested_target_layout; + WORD32 requested_target_ch_count; + WORD32 target_ch_count_prelim; + + WORD32 loudness_normalization_on; + FLOAT32 target_loudness; + WORD32 album_mode; + WORD32 peak_limiter; + WORD32 loudness_deviation_max; + WORD32 loudness_measurement_method; + WORD32 loudness_measurement_system; + WORD32 loudness_measurement_pre_proc; + WORD32 device_cut_off_frequency; + FLOAT32 loudness_norm_gain_db_max; + FLOAT32 loudness_norm_gain_modification_db; + FLOAT32 output_peak_level_max; + + WORD32 num_bands_supported; + WORD32 dynamic_range_control_on; + WORD32 num_drc_feature_requests; + WORD32 drc_feature_req_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_num_drc_effects[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 desired_num_drc_effects_of_requested[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_effect_type[MAX_NUM_DRC_FEATURE_REQUESTS][MAX_NUM_DRC_EFFECT_TYPE_REQUESTS]; + WORD32 requested_dyn_range_measur_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_dyn_range_range_flag[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_value[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_min_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_max_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_characteristic[MAX_NUM_DRC_FEATURE_REQUESTS]; + + + WORD32 loudness_eq_request; + FLOAT32 sensitivity; + FLOAT32 playback_gain; + WORD32 eq_set_purpose_request; + + FLOAT32 boost; + FLOAT32 compress; + WORD32 drc_characteristic_target; +} ia_drc_sel_proc_params_struct; + +typedef struct ia_drc_sel_pro_struct +{ + + WORD32 first_frame; + WORD32 drc_config_flag; + WORD32 loudness_info_set_flag; + WORD32 sel_proc_request_flag; + WORD32 subband_domain_mode; + WORD32 eq_inst_index[SUB_EQ_COUNT]; + WORD32 drc_instructions_index[SUB_DRC_COUNT]; + + ia_drc_sel_proc_params_struct uni_drc_sel_proc_params; + + ia_drc_config drc_config; + ia_drc_loudness_info_set_struct loudness_info_set; + + WORD32 drc_inst_index_sel; + WORD32 drc_coef_index_sel; + WORD32 downmix_inst_index_sel; + + WORD32 drc_set_id_valid_flag[DRC_INSTRUCTIONS_COUNT_MAX]; + WORD32 eq_set_id_valid_flag[EQ_INSTRUCTIONS_COUNT_MAX]; + + WORD32 eq_inst_index_sel; + WORD32 loud_eq_inst_index_sel; + + FLOAT32 compl_level_supported_total; + + ia_drc_sel_proc_output_struct uni_drc_sel_proc_output; + +} ia_drc_sel_pro_struct; + +WORD32 impd_map_target_config_req_downmix_id(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config); + +VOID impd_sel_downmix_matrix(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config); + +WORD32 +impd_find_drc_instructions_uni_drc(ia_drc_config* drc_config, + WORD32 drc_set_id_requested, + ia_drc_instructions_struct** str_drc_instruction_str); +WORD32 +impd_find_eq_instructions(ia_drc_config* drc_config, + WORD32 eq_set_id_requested, + ia_eq_instructions_struct** str_eq_instructions); +WORD32 +impd_find_downmix(ia_drc_config* drc_config, + WORD32 requested_dwnmix_id, + ia_downmix_instructions_struct** dwnmix_instructions); + + + WORD32 +impd_find_eq_set_no_compression(ia_drc_config* pstr_drc_config, + WORD32 requested_dwnmix_id, + WORD32* no_compression_eq_cnt, + WORD32* no_compression_eq_id); + WORD32 +impd_match_eq_set(ia_drc_config* drc_config, + WORD32 downmix_id, + WORD32 drc_set_id, + WORD32* eq_set_id_valid_flag, + WORD32* matching_eq_set_cnt, + WORD32* matching_eq_set_idx); + + + + WORD32 +impd_select_loud_eq(ia_drc_config* pstr_drc_config, + WORD32 requested_dwnmix_id, + WORD32 drc_set_id_requested, + WORD32 eq_set_id_requested, + WORD32* loud_eq_id_selected); + +WORD32 +impd_drc_uni_selction_proc_init(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_proc_params_struct * pstr_drc_sel_proc_params_struct, + ia_drc_interface_struct* pstr_drc_interface, + WORD32 sub_band_domain_mode); + +WORD32 +impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_sel_proc_output_struct* hia_drc_sel_proc_output_struct); + +WORD32 +impd_find_loud_eq_instructions_idx_for_id(ia_drc_config* drc_config, + WORD32 loud_eq_set_id_requested, + WORD32* instructions_idx); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/decoder/drc_src/impd_drc_selection_process_drcset_selection.c b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c new file mode 100644 index 0000000..042218e --- /dev/null +++ b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c @@ -0,0 +1,1537 @@ +/****************************************************************************** + * + * 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 +#include +#include +#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_sel_proc_drc_set_sel.h" +#include "impd_drc_loudness_control.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_rom.h" + +static 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 +}; + + +WORD32 impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct) +{ + WORD32 i,j; + + for (i=0; inum_drc_feature_requests; i++) + { + switch (pstr_drc_sel_proc_params_struct->drc_feature_req_type[i]) { + case MATCH_EFFECT_TYPE: + for (j=0; jdesired_num_drc_effects_of_requested[i]; j++) + { + if (pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i][j] == EFFECT_TYPE_REQUESTED_NONE) + { + if (pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i] > 1) + { + return (UNEXPECTED_ERROR); + } + } + } + break; + case MATCH_DYNAMIC_RANGE: + break; + case MATCH_DRC_CHARACTERISTIC: + break; + default: + return (UNEXPECTED_ERROR); + break; + } + } + return (0); +} + +WORD32 impd_find_drc_instructions_uni_drc(ia_drc_config* drc_config, + WORD32 drc_set_id_requested, + ia_drc_instructions_struct** str_drc_instruction_str) +{ + WORD32 i; + for (i=0; idrc_instructions_uni_drc_count; i++) + { + if (drc_set_id_requested == drc_config->str_drc_instruction_str[i].drc_set_id) break; + } + if (i == drc_config->drc_instructions_uni_drc_count) { + return (UNEXPECTED_ERROR); + } + *str_drc_instruction_str = &drc_config->str_drc_instruction_str[i]; + return (0); +} + +WORD32 impd_map_requested_effect_bit_idx( WORD32 requested_effect_type, + WORD32* effect_bit_idx) +{ + switch (requested_effect_type) { + case EFFECT_TYPE_REQUESTED_NONE: + *effect_bit_idx = EFFECT_BIT_NONE; + break; + case EFFECT_TYPE_REQUESTED_NIGHT: + *effect_bit_idx = EFFECT_BIT_NIGHT; + break; + case EFFECT_TYPE_REQUESTED_NOISY: + *effect_bit_idx = EFFECT_BIT_NOISY; + break; + case EFFECT_TYPE_REQUESTED_LIMITED: + *effect_bit_idx = EFFECT_BIT_LIMITED; + break; + case EFFECT_TYPE_REQUESTED_LOWLEVEL: + *effect_bit_idx = EFFECT_BIT_LOWLEVEL; + break; + case EFFECT_TYPE_REQUESTED_DIALOG: + *effect_bit_idx = EFFECT_BIT_DIALOG; + break; + case EFFECT_TYPE_REQUESTED_GENERAL_COMPR: + *effect_bit_idx = EFFECT_BIT_GENERAL_COMPR; + break; + case EFFECT_TYPE_REQUESTED_EXPAND: + *effect_bit_idx = EFFECT_BIT_EXPAND; + break; + case EFFECT_TYPE_REQUESTED_ARTISTIC: + *effect_bit_idx = EFFECT_BIT_ARTISTIC; + break; + + default: + return (UNEXPECTED_ERROR); + + break; + } + return (0); +} + + +WORD32 impd_get_fading_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) +{ + pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode == 0) + { + WORD32 n; + ia_drc_instructions_struct* str_drc_instruction_str = NULL; + for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) + { + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); + + if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_FADE) + { + if (str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) + { + pstr_drc_uni_sel_proc->drc_instructions_index[2] = n; + + } + else + { + return (UNEXPECTED_ERROR); + } + } + } + } + return (0); +} + +WORD32 impd_get_ducking_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) +{ + WORD32 drc_instructions_index; + WORD32 n, k; + ia_drc_instructions_struct* str_drc_instruction_str; + + WORD32 requested_dwnmix_id = pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id; + + pstr_drc_uni_sel_proc->drc_instructions_index[3] = -1; + drc_instructions_index = -1; + str_drc_instruction_str = NULL; + + for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) + { + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); + + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + for (k=0; kdwnmix_id_count; k++) { + if (str_drc_instruction_str->downmix_id[k] == requested_dwnmix_id) + { + + drc_instructions_index = n; + + } + } + } + } + if (drc_instructions_index == -1) + { + for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) + { + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); + + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + for (k=0; kdwnmix_id_count; k++) { + if (str_drc_instruction_str->downmix_id[k] == ID_FOR_BASE_LAYOUT) + { + drc_instructions_index = n; + } + } + } + } + } + if (drc_instructions_index > -1) + { + pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[3] = drc_instructions_index; + } + return (0); +} + +WORD32 impd_get_selected_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 drc_set_id_selected) +{ + WORD32 n; + + ia_drc_instructions_struct* str_drc_instruction_str = NULL; + + for(n=0; ndrc_config.drc_instructions_count_plus; n++) + { + if (pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n].drc_set_id == drc_set_id_selected) break; + } + if (n == pstr_drc_uni_sel_proc->drc_config.drc_instructions_count_plus) + { + return(EXTERNAL_ERROR); + } + pstr_drc_uni_sel_proc->drc_inst_index_sel = n; + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[pstr_drc_uni_sel_proc->drc_inst_index_sel]); + + pstr_drc_uni_sel_proc->drc_instructions_index[0] = pstr_drc_uni_sel_proc->drc_inst_index_sel; + return (0); +} + + +WORD32 impd_get_dependent_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) +{ + ia_drc_instructions_struct* str_drc_instruction_str = NULL; + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[pstr_drc_uni_sel_proc->drc_inst_index_sel]); + + if (str_drc_instruction_str->depends_on_drc_set_present == 1) + { + WORD32 n; + WORD32 drc_dependent_set_id = str_drc_instruction_str->depends_on_drc_set; + + for (n=0; ndrc_config.drc_instructions_count_plus; n++) + { + if (pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n].drc_set_id == drc_dependent_set_id) break; + } + if (n == pstr_drc_uni_sel_proc->drc_config.drc_instructions_count_plus) + { + return(UNEXPECTED_ERROR); + } + pstr_drc_uni_sel_proc->drc_instructions_index[1] = n; + } + else + { + pstr_drc_uni_sel_proc->drc_instructions_index[1] = -1; + } + return (0); +} + +WORD32 impd_get_dependent_drc_instructions(const ia_drc_config* drc_config, + const ia_drc_instructions_struct* str_drc_instruction_str, + ia_drc_instructions_struct** drc_instructions_dependent) +{ + WORD32 j; + ia_drc_instructions_struct* dependent_drc = NULL; + for (j=0; jdrc_instructions_uni_drc_count; j++) + { + dependent_drc = (ia_drc_instructions_struct*) &(drc_config->str_drc_instruction_str[j]); + if (dependent_drc->drc_set_id == str_drc_instruction_str->depends_on_drc_set) + { + break; + } + } + if (j == drc_config->drc_instructions_uni_drc_count) + { + return (UNEXPECTED_ERROR); + } + if (dependent_drc->depends_on_drc_set_present == 1) + { + return (UNEXPECTED_ERROR); + } + *drc_instructions_dependent = dependent_drc; + return(0); +} + +WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info) +{ + WORD32 i, k, n; + WORD32 selection_candidate_step_2_count=0; + ia_selection_candidate_info_struct selection_candidate_info_step_2[SELECTION_CANDIDATE_COUNT_MAX]; + WORD32 effect_types_request_table_size; + WORD32 match; + ia_drc_instructions_struct* str_drc_instruction_str; + + effect_types_request_table_size = sizeof(effect_types_request_table) / sizeof(WORD32); + + k=0; + for (i=0; i < *selection_candidate_count; i++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); + + match = 1; + for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) + { + match = 0; + } + } + if (match == 1) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + + if (selection_candidate_step_2_count > 0) + { + *match_found_flag = 1; + for (i=0; istr_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); + if (str_drc_instruction_str->depends_on_drc_set_present == 1) + { + err = impd_get_dependent_drc_instructions(pstr_drc_config, str_drc_instruction_str, &drc_instructions_dependent); + if (err) return (err); + + if (state_requested == 1) + { + if (((str_drc_instruction_str->drc_set_effect & effect_bit_idx) != 0x0) || + ((drc_instructions_dependent->drc_set_effect & effect_bit_idx) != 0x0)) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + else + { + if (((str_drc_instruction_str->drc_set_effect & effect_bit_idx) == 0x0) && + ((drc_instructions_dependent->drc_set_effect & effect_bit_idx) == 0x0)) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + } + else + { + if (state_requested == 1) + { + if ((str_drc_instruction_str->drc_set_effect & effect_bit_idx) != 0x0) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + else + { + if ((str_drc_instruction_str->drc_set_effect & effect_bit_idx) == 0x0) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + } + } + selection_candidate_step_2_count = k; + + if (selection_candidate_step_2_count > 0) + { + *match_found_flag = 1; + for (i=0; i + requested_dyn_range_measur_type[num_drc_requests]; + + WORD32 requested_dyn_range_range_flag = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_range_flag[num_drc_requests]; + + FLOAT32 dynamic_range_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_value[num_drc_requests]; + + FLOAT32 dynamic_range_min_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_min_val[num_drc_requests]; + + FLOAT32 dynamic_range_max_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_max_val[num_drc_requests]; + + WORD32* requested_dwnmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id; + + WORD32 album_mode = pstr_drc_sel_proc_params_struct->album_mode; + + k=0; + for (i=0; i < *selection_candidate_count; i++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); + + err = impd_loudness_peak_to_average_info( + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[selection_candidate_info[i].downmix_id_request_index], + dynamic_range_measurement_type, + album_mode, + &lp_avg_present_val, + &lp_avg_val); + if (err) return (err); + + if (lp_avg_present_val == 1) + { + if (requested_dyn_range_range_flag == 1) + { + if ((lp_avg_val >= dynamic_range_min_requested) && (lp_avg_val <= dynamic_range_max_requested)) + { + selected[k] = i; + k++; + } + } + else + { + FLOAT32 deviation = (FLOAT32)fabs((FLOAT64)(dynamic_range_requested - lp_avg_val)); + if (deviation_min >= deviation) + { + if (deviation_min > deviation) + { + deviation_min = deviation; + k = 0; + } + selected[k] = i; + k++; + } + } + } + } + if (k>0) + { + for (i=0; idrc_coefficients_drc_count) { + for (i=0; idrc_coefficients_drc_count; i++) + { + str_p_loc_drc_coefficients_uni_drc = &(pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[i]); + if (str_p_loc_drc_coefficients_uni_drc->drc_location == LOCATION_SELECTED) break; + } + + if (i == pstr_drc_config->drc_coefficients_drc_count) + { + return (UNEXPECTED_ERROR); + } + } + + n = 0; + for (i=0; i < *selection_candidate_count; i++) + { + ref_count = 0; + match_count = 0; + + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); + for (k=0; knum_drc_ch_groups; k++) + { + gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[k]]); + for (b=0; bband_count; b++) + { + ref_count++; + drc_characteristic = gain_set_params->gain_params[b].drc_characteristic; + if ( drc_characteristic == drc_characteristic_request_1) match_count += 1.0f; + else if ( drc_characteristic == drc_characteristic_request_2) match_count += 0.75f; + else if ( drc_characteristic == drc_characteristic_request_3) match_count += 0.5f; + } + } + if (str_drc_instruction_str->depends_on_drc_set_present == 1) + { + WORD32 depends_on_drc_set = str_drc_instruction_str->depends_on_drc_set; + for (m=0; mdrc_instructions_uni_drc_count; m++) + { + if (pstr_drc_config->str_drc_instruction_str[m].drc_set_id == depends_on_drc_set) break; + } + if (m == pstr_drc_config->drc_instructions_uni_drc_count) + { + return (UNEXPECTED_ERROR); + } + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[m]); + if ((str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_FADE | EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) + { + if (str_drc_instruction_str->drc_set_effect != EFFECT_BIT_CLIPPING) { + for (k=0; knum_drc_ch_groups; k++) + { + gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[k]]); + for (b=0; bband_count; b++) + { + ref_count++; + drc_characteristic = gain_set_params->gain_params[b].drc_characteristic; + if ( drc_characteristic == drc_characteristic_request_1) match_count += 1.0f; + else if ( drc_characteristic == drc_characteristic_request_2) match_count += 0.75f; + else if ( drc_characteristic == drc_characteristic_request_3) match_count += 0.5; + } + } + } + } + } + if ((ref_count > 0) && (((FLOAT32)match_count) > 0.5f * ref_count)) + { + memcpy(&selection_candidate_info[n], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + n++; + } + } + if (n > 0) + { + *selection_candidate_count = n; + *match_found_flag = 1; + } + + return(0); +} + + + +WORD32 impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, + WORD32 requested_drc_characteristic, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info) +{ + WORD32 k, err; + WORD32 match_found_flag = 0; + + WORD32* drc_characteristic_order = drc_characteristic_order_default[requested_drc_characteristic-1]; + WORD32 drc_characteristic_order_count = sizeof(drc_characteristic_order_default[requested_drc_characteristic]) / sizeof(WORD32); + k = 0; + while ((k 0)) + { + err = impd_match_drc_characteristic_attempt(pstr_drc_config, + drc_characteristic_order[k], + &match_found_flag, + selection_candidate_count, + selection_candidate_info); + if (err) return (err); + k++; + } + return (0); +} + + +WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 restrict_to_drc_with_album_loudness, + ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info) +{ + WORD32 i, j, k, l, d, n, err; + WORD32 downmix_id_match = 0; + + + WORD32 selection_candidate_step_2_count; + ia_selection_candidate_info_struct selection_candidate_info_step_2[SELECTION_CANDIDATE_COUNT_MAX]; + + WORD32 num_downmix_id_requests = pstr_drc_sel_proc_params_struct->num_downmix_id_requests; + WORD32* requested_dwnmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id; + FLOAT32 output_peak_level_max = pstr_drc_sel_proc_params_struct->output_peak_level_max; + WORD32 loudness_deviation_max = pstr_drc_sel_proc_params_struct->loudness_deviation_max; + WORD32* drc_set_id_valid_flag = pstr_drc_uni_sel_proc->drc_set_id_valid_flag; + WORD32* eq_set_id_valid_flag = pstr_drc_uni_sel_proc->eq_set_id_valid_flag; + + FLOAT32 output_peak_level_min = 1000.0f; + FLOAT32 adjustment; + WORD32 loudness_drc_set_id_requested; + + WORD32 num_compression_eq_count = 0; + WORD32 num_compression_eq_id[16]; + + WORD32 loudness_info_count = 0; + WORD32 eq_set_id_loudness[16]; + FLOAT32 loudness_normalization_gain_db[16]; + FLOAT32 loudness[16]; + WORD32 peak_info_count; + WORD32 eq_set_id_Peak[16]; + FLOAT32 signal_peak_level[16]; + WORD32 explicit_peak_information_present[16]; + + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; + ia_drc_instructions_struct* str_drc_instruction_str = NULL; + + impd_select_drc_coeff3(pstr_drc_config, &str_p_loc_drc_coefficients_uni_drc); + + k=0; + for (d=0; ddrc_instructions_count_plus; i++) + { + downmix_id_match = 0; + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[i]); + + for (j=0; jdwnmix_id_count; j++) + { + if ((str_drc_instruction_str->downmix_id[j] == requested_dwnmix_id[d]) || + ((str_drc_instruction_str->downmix_id[j] == ID_FOR_BASE_LAYOUT) && (str_drc_instruction_str->drc_set_id > 0)) || + (str_drc_instruction_str->downmix_id[j] == ID_FOR_ANY_DOWNMIX)) + { + downmix_id_match = 1; + } + } + if (downmix_id_match == 1) + { + if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) + { + if ((str_drc_instruction_str->drc_set_effect != EFFECT_BIT_FADE) && + (str_drc_instruction_str->drc_set_effect != EFFECT_BIT_DUCK_OTHER) && + (str_drc_instruction_str->drc_set_effect != EFFECT_BIT_DUCK_SELF) && + (str_drc_instruction_str->drc_set_effect != 0 || str_drc_instruction_str->drc_set_id < 0) && + (((str_drc_instruction_str->depends_on_drc_set_present == 0) && (str_drc_instruction_str->no_independent_use == 0)) || + (str_drc_instruction_str->depends_on_drc_set_present == 1)) ) + { + WORD32 drc_is_permitted = 1; + if (str_drc_instruction_str->drc_set_id > 0) + { + drc_is_permitted = drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id]; + } + if (drc_is_permitted == 1) + { + + err = impd_init_loudness_control (pstr_drc_sel_proc_params_struct, + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + + num_compression_eq_count, + num_compression_eq_id, + &loudness_info_count, + eq_set_id_loudness, + loudness_normalization_gain_db, + loudness); + if (err) return (err); + + err = impd_signal_peak_level_info(pstr_drc_config, + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[d], + pstr_drc_sel_proc_params_struct->album_mode, + num_compression_eq_count, + num_compression_eq_id, + &peak_info_count, + eq_set_id_Peak, + signal_peak_level, + explicit_peak_information_present); + if (err) return (err); + + for (l=0; lloudness_norm_gain_db_max); + + if (loudness[l] != UNDEFINED_LOUDNESS_VALUE) + { + selection_candidate_info[k].output_loudness = loudness[l] + selection_candidate_info[k].loudness_norm_db_gain_adjusted; + } + else + { + selection_candidate_info[k].output_loudness = UNDEFINED_LOUDNESS_VALUE; + } + + for (p=0; prequires_eq == 1) && (eq_set_id_valid_flag[eq_set_id_loudness[l]] == 0)) continue; + selection_candidate_info[k].drc_instructions_index = i; + selection_candidate_info[k].downmix_id_request_index = d; + selection_candidate_info[k].eq_set_id = eq_set_id_loudness[l]; + if (explicit_peak_information_present[p] == 1) + { + selection_candidate_info[k].selection_flags = SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT; + } + else + { + selection_candidate_info[k].selection_flags = 0; + } + impd_mixing_level_info(pstr_drc_sel_proc_params_struct, + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + eq_set_id_loudness[l], + &selection_candidate_info[k].mixing_level); + if (str_drc_instruction_str->drc_set_target_loudness_present && + ((pstr_drc_sel_proc_params_struct->loudness_normalization_on && + str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && + str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) || + !pstr_drc_sel_proc_params_struct->loudness_normalization_on)) { + selection_candidate_info[k].selection_flags |= SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH; + if (!explicit_peak_information_present[p]) + { + if (pstr_drc_sel_proc_params_struct->loudness_normalization_on) { + selection_candidate_info[k].output_peak_level = pstr_drc_sel_proc_params_struct->target_loudness - str_drc_instruction_str->drc_set_target_loudness_value_upper; + } + else { + selection_candidate_info[k].output_peak_level = 0.0f; + } + } + } + if ((selection_candidate_info[k].selection_flags & (SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH | SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT) || !str_drc_instruction_str->drc_set_target_loudness_present)) + { + k++; + } else { + } + } + } + } + } + else + { + if (str_drc_instruction_str->drc_set_id < 0) + { + + + + err = impd_init_loudness_control (pstr_drc_sel_proc_params_struct, + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + num_compression_eq_count, + num_compression_eq_id, + &loudness_info_count, + eq_set_id_loudness, + loudness_normalization_gain_db, + loudness); + if (err) return (err); + + err = impd_signal_peak_level_info(pstr_drc_config, + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[d], + pstr_drc_sel_proc_params_struct->album_mode, + num_compression_eq_count, + num_compression_eq_id, + &peak_info_count, + eq_set_id_Peak, + signal_peak_level, + explicit_peak_information_present); + if (err) return (err); + for (l=0; loutput_peak_level_max); + adjustment = min(adjustment, max(0.0f, loudness_deviation_max)); + selection_candidate_info[k].loudness_norm_db_gain_adjusted = loudness_normalization_gain_db[l] - adjustment; + + selection_candidate_info[k].loudness_norm_db_gain_adjusted = min(selection_candidate_info[k].loudness_norm_db_gain_adjusted, pstr_drc_sel_proc_params_struct->loudness_norm_gain_db_max); + + selection_candidate_info[k].output_peak_level = signal_peak_level[p] + selection_candidate_info[k].loudness_norm_db_gain_adjusted; + if (loudness[l] != UNDEFINED_LOUDNESS_VALUE) + { + selection_candidate_info[k].output_loudness = loudness[l] + selection_candidate_info[k].loudness_norm_db_gain_adjusted; + } + else + { + selection_candidate_info[k].output_loudness = UNDEFINED_LOUDNESS_VALUE; + } + selection_candidate_info[k].drc_instructions_index = i; + selection_candidate_info[k].downmix_id_request_index = d; + selection_candidate_info[k].eq_set_id = eq_set_id_loudness[l]; + if (explicit_peak_information_present[p]==1) + { + selection_candidate_info[k].selection_flags = SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT; + } + else + { + selection_candidate_info[k].selection_flags = 0; + } + impd_mixing_level_info(pstr_drc_sel_proc_params_struct, + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + eq_set_id_loudness[l], + &selection_candidate_info[k].mixing_level); + k++; + } + } + } + } + } + } + } + *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) + { + n = 0; + for (k=0; k<*selection_candidate_count; k++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[k].drc_instructions_index]); + + if (pstr_drc_sel_proc_params_struct->eq_set_purpose_request != EQ_PURPOSE_EQ_OFF) + { + WORD32 matching_eq_set_count = 0; + WORD32 matching_eq_instrucions_index[64]; + err = impd_match_eq_set(pstr_drc_config, + requested_dwnmix_id[selection_candidate_info[k].downmix_id_request_index], + str_drc_instruction_str->drc_set_id, + eq_set_id_valid_flag, + &matching_eq_set_count, + matching_eq_instrucions_index); + if (err) return(err); + for (j=0; jstr_drc_config_ext.str_eq_instructions[matching_eq_instrucions_index[j]].eq_set_id; + n++; + } + } + if (str_drc_instruction_str->requires_eq == 0) { + memcpy(&selection_candidate_info_step_2[n], &selection_candidate_info[k], sizeof(ia_selection_candidate_info_struct)); + selection_candidate_info_step_2[n].eq_set_id = 0; + n++; + } + } + for (k=0; kstr_drc_instruction_str[selection_candidate_info[k].drc_instructions_index].drc_set_id); + for (n=0; nloudness_info_album_count; n++) + { + if (loudness_drc_set_id_requested == pstr_loudness_info->str_loudness_info_album[n].drc_set_id) + { + memcpy(&selection_candidate_info[j], &selection_candidate_info[k], sizeof(ia_selection_candidate_info_struct)); + j++; + break; + } + } + } + *selection_candidate_count = j; + } + return (0); +} + +WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info + , WORD32* eq_set_id_valid_flag + ) +{ + WORD32 k, i, n, err; + WORD32 selection_candidate_step_2_count; + ia_selection_candidate_info_struct selection_candidate_info_step_2[SELECTION_CANDIDATE_COUNT_MAX]; + WORD32 drc_set_id_max; + FLOAT32 output_level_max; + FLOAT32 output_level_min; + WORD32 effect_count, effect_count_min; + WORD32 effect_types_request_table_size; + WORD32 drc_set_target_loudness_val_upper_min; + ia_drc_instructions_struct* str_drc_instruction_str; + ia_drc_instructions_struct* drc_instructions_dependent; + + + if (pstr_drc_sel_proc_params_struct->eq_set_purpose_request > 0) + { + WORD32 eq_purpose_requested = pstr_drc_sel_proc_params_struct->eq_set_purpose_request; + + impd_match_eq_set_purpose(pstr_drc_config, + eq_purpose_requested, + eq_set_id_valid_flag, + selection_candidate_count, + selection_candidate_info, + selection_candidate_info_step_2); + } + + output_level_min = 10000.0f; + k = 0; + for (i=0; i < *selection_candidate_count; i++) + { + if (output_level_min >= selection_candidate_info[i].output_peak_level) + { + if (output_level_min > selection_candidate_info[i].output_peak_level) + { + output_level_min = selection_candidate_info[i].output_peak_level; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + + if (output_level_min <= 0.0f ) + { + selection_candidate_step_2_count = *selection_candidate_count; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + for (n=0; ndwnmix_id_count; n++) { + 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]) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + } + if (k > 0) + { + selection_candidate_step_2_count = k; + } + + effect_types_request_table_size = sizeof(effect_types_request_table) / sizeof(WORD32); + effect_count_min = 100; + k=0; + for (i=0; i < selection_candidate_step_2_count; i++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + effect_count = 0; + if (str_drc_instruction_str->depends_on_drc_set_present == 1) + { + err = impd_get_dependent_drc_instructions(pstr_drc_config, str_drc_instruction_str, &drc_instructions_dependent); + if (err) return (err); + + for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) || + ((drc_instructions_dependent->drc_set_effect & effect_types_request_table[n]) != 0x0)) + { + effect_count++; + } + } + } + } + else + { + for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) + { + effect_count++; + } + } + } + } + if (effect_count_min >= effect_count) + { + if (effect_count_min > effect_count) + { + effect_count_min = effect_count; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { + k++; + } + } + if (k != 0 && k != selection_candidate_step_2_count) + { + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + else if (k == selection_candidate_step_2_count) + { + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + k = 0; + output_level_max = -1000.0f; + for (i=0; i < selection_candidate_step_2_count; i++) + { + if ((selection_candidate_info_step_2[i].output_peak_level <= 0.0f) && (output_level_max <= selection_candidate_info_step_2[i].output_peak_level)) + { + if (output_level_max < selection_candidate_info_step_2[i].output_peak_level) + { + output_level_max = selection_candidate_info_step_2[i].output_peak_level; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + output_level_max = selection_candidate_info_step_2[i].output_peak_level; + } + } + selection_candidate_step_2_count = k; + } + + drc_set_id_max = -1000; + for (i=0; i < selection_candidate_step_2_count; i++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (drc_set_id_max < str_drc_instruction_str->drc_set_id) + { + drc_set_id_max = str_drc_instruction_str->drc_set_id; + memcpy(&selection_candidate_info_step_2[0], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + } + } + memcpy(&selection_candidate_info[0], &selection_candidate_info_step_2[0], sizeof(ia_selection_candidate_info_struct)); + *selection_candidate_count = 1; + + return 0; +} + +WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32* drc_set_id_selected + , WORD32* eq_set_id_selected + , WORD32* loud_eq_id_sel + ) +{ + WORD32 i, err; + + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; + ia_drc_config* pstr_drc_config = &pstr_drc_uni_sel_proc->drc_config; + ia_drc_loudness_info_set_struct* pstr_loudness_info = &pstr_drc_uni_sel_proc->loudness_info_set; + + WORD32 selection_candidate_count = 0; + WORD32 restrict_to_drc_with_album_loudness = 0; + ia_selection_candidate_info_struct selection_candidate_info[SELECTION_CANDIDATE_COUNT_MAX]; + +// WORD32 selected_eq_set_count = 0; + + if (pstr_drc_sel_proc_params_struct->album_mode == 1) + { + restrict_to_drc_with_album_loudness = 1; + } + + while (!selection_candidate_count) + { + impd_drc_set_preselection(pstr_drc_sel_proc_params_struct, + pstr_drc_config, + pstr_loudness_info, + restrict_to_drc_with_album_loudness, + pstr_drc_uni_sel_proc, + &selection_candidate_count, + selection_candidate_info); + + if (selection_candidate_count == 0) + { + if (restrict_to_drc_with_album_loudness == 1) + { + restrict_to_drc_with_album_loudness = 0; + continue; + } + else + { + return(UNEXPECTED_ERROR); + } + } + + err = impd_validate_requested_drc_feature(pstr_drc_sel_proc_params_struct); + if (err) return (err); + + if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) + { + if (pstr_drc_sel_proc_params_struct->num_drc_feature_requests > 0) + { + for (i=0; inum_drc_feature_requests; i++) + { + switch (pstr_drc_sel_proc_params_struct->drc_feature_req_type[i]) + { + case MATCH_EFFECT_TYPE: + err = impd_match_effect_types(pstr_drc_config, + pstr_drc_sel_proc_params_struct->requested_num_drc_effects[i], + pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i], + pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i], + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + case MATCH_DYNAMIC_RANGE: + err = impd_match_dynamic_range(pstr_drc_config, + pstr_loudness_info, + pstr_drc_sel_proc_params_struct, + i, + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + case MATCH_DRC_CHARACTERISTIC: + err = impd_match_drc_characteristic(pstr_drc_config, + pstr_drc_sel_proc_params_struct->requested_drc_characteristic[i], + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + + default: + return (UNEXPECTED_ERROR); + break; + } + } + } + else + { + WORD32 match_found_flag = 0; + + err = impd_select_drcs_without_compr_effects (pstr_drc_config, + &match_found_flag, + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + + if (match_found_flag == 0) + { + WORD32 requested_num_drc_effects = 5; + WORD32 desired_num_drc_effects_of_requested = 1; + WORD32 requested_drc_effect_type[5] = { + EFFECT_TYPE_REQUESTED_GENERAL_COMPR, + EFFECT_TYPE_REQUESTED_NIGHT, + EFFECT_TYPE_REQUESTED_NOISY, + EFFECT_TYPE_REQUESTED_LIMITED, + EFFECT_TYPE_REQUESTED_LOWLEVEL + }; + + err = impd_match_effect_types(pstr_drc_config, + requested_num_drc_effects, + desired_num_drc_effects_of_requested, + requested_drc_effect_type, + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + } + } + + if (selection_candidate_count > 0) + { + err = impd_drc_set_final_selection (pstr_drc_config, + pstr_drc_sel_proc_params_struct, + &selection_candidate_count, + selection_candidate_info + , pstr_drc_uni_sel_proc->eq_set_id_valid_flag + ); + if (err) return (err); + } + else + { + selection_candidate_count = 0; + return(UNEXPECTED_ERROR); + } + + } + + if (selection_candidate_count == 0) + { + if (restrict_to_drc_with_album_loudness == 1) + { + restrict_to_drc_with_album_loudness = 0; + } + else + { + return(UNEXPECTED_ERROR); + } + } + } + *drc_set_id_selected = pstr_drc_config->str_drc_instruction_str[selection_candidate_info[0].drc_instructions_index].drc_set_id; + *eq_set_id_selected = selection_candidate_info[0].eq_set_id; + + impd_select_loud_eq(pstr_drc_config, + pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info[0].downmix_id_request_index], + *drc_set_id_selected, + *eq_set_id_selected, + loud_eq_id_sel); + if (selection_candidate_count > 0) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db = selection_candidate_info[0].loudness_norm_db_gain_adjusted; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_peak_level_db = selection_candidate_info[0].output_peak_level; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_loudness = selection_candidate_info[0].output_loudness; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info[0].downmix_id_request_index]; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.mixing_level = selection_candidate_info[0].mixing_level; + } + return(0); +} + + diff --git a/decoder/drc_src/impd_drc_selection_process_init.c b/decoder/drc_src/impd_drc_selection_process_init.c new file mode 100644 index 0000000..38e9bef --- /dev/null +++ b/decoder/drc_src/impd_drc_selection_process_init.c @@ -0,0 +1,336 @@ +/****************************************************************************** + * + * 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 +#include +#include +#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" + +WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) +{ + if (pstr_drc_uni_sel_proc != NULL) { + + pstr_drc_uni_sel_proc->first_frame = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count = -1; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_layout = -1; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_normalization_on = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_loudness = -24.0f; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_deviation_max = LOUDNESS_DEVIATION_MAX_DEFAULT; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_method = USER_METHOD_DEFINITION_DEFAULT; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_system = USER_MEASUREMENT_SYSTEM_DEFAULT; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_pre_proc = USER_LOUDNESS_PREPROCESSING_DEFAULT; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.device_cut_off_frequency = 500; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db = 0.0f; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max = 0.0f; + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter == 1) { + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max = 6.0f; + + } + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on = 1; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_bands_supported = 4; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_drc_feature_requests = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.boost = 1.f; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress = 1.f; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target = 0; + + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_eq_request = LOUD_EQ_REQUEST_OFF; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.eq_set_purpose_request = EQ_PURPOSE_EQ_OFF; + pstr_drc_uni_sel_proc->compl_level_supported_total = COMPLEXITY_LEVEL_SUPPORTED_TOTAL; + + pstr_drc_uni_sel_proc->drc_inst_index_sel = -1; + pstr_drc_uni_sel_proc->drc_coef_index_sel = -1; + pstr_drc_uni_sel_proc->downmix_inst_index_sel = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[0] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[1] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[3] = -1; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_peak_level_db = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_loudness = UNDEFINED_LOUDNESS_VALUE; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.num_sel_drc_sets = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = 0; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix_present = 0; + + pstr_drc_uni_sel_proc->eq_inst_index[0] = -1; + pstr_drc_uni_sel_proc->eq_inst_index[1] = -1; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } else { + return 1; + } + + return 0; +} +WORD32 +impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct) +{ + + if (pstr_drc_uni_sel_proc != NULL && pstr_drc_sel_proc_params_struct != NULL) { + + if ( memcmp ( &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params, pstr_drc_sel_proc_params_struct, sizeof(ia_drc_sel_proc_params_struct) )) + { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params = *pstr_drc_sel_proc_params_struct; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + + return 0; +} +WORD32 +impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_interface_struct* pstr_drc_interface) +{ + WORD32 i,j; + + if (pstr_drc_uni_sel_proc != NULL && pstr_drc_interface != NULL) { + + if (pstr_drc_interface->system_interface_flag) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type != pstr_drc_interface->system_interface.target_config_request_type) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type = pstr_drc_interface->system_interface.target_config_request_type; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + switch (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type) { + case 0: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests != pstr_drc_interface->system_interface.num_downmix_id_requests) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = pstr_drc_interface->system_interface.num_downmix_id_requests; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + for (i=0; iuni_drc_sel_proc_params.num_downmix_id_requests; i++) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[i] != pstr_drc_interface->system_interface.requested_dwnmix_id[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dwnmix_id[i] = pstr_drc_interface->system_interface.requested_dwnmix_id[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + break; + case 1: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_layout != pstr_drc_interface->system_interface.requested_target_layout) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_layout = pstr_drc_interface->system_interface.requested_target_layout; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + break; + case 2: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_ch_count != pstr_drc_interface->system_interface.requested_target_ch_count) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_target_ch_count = pstr_drc_interface->system_interface.requested_target_ch_count; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + break; + } + } + if (pstr_drc_interface->loudness_norm_ctrl_interface_flag) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_normalization_on != pstr_drc_interface->loudness_norm_ctrl_interface.loudness_normalization_on) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_normalization_on = pstr_drc_interface->loudness_norm_ctrl_interface.loudness_normalization_on; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_normalization_on) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_loudness != pstr_drc_interface->loudness_norm_ctrl_interface.target_loudness) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_loudness = pstr_drc_interface->loudness_norm_ctrl_interface.target_loudness; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + } + if (pstr_drc_interface->loudness_norm_parameter_interface_flag) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode != pstr_drc_interface->loudness_norm_param_interface.album_mode) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode = pstr_drc_interface->loudness_norm_param_interface.album_mode; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter != pstr_drc_interface->loudness_norm_param_interface.peak_limiter) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter = pstr_drc_interface->loudness_norm_param_interface.peak_limiter; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_deviation_max) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_deviation_max != pstr_drc_interface->loudness_norm_param_interface.loudness_deviation_max) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_deviation_max = pstr_drc_interface->loudness_norm_param_interface.loudness_deviation_max; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_method) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_method != pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_method) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_method = pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_method; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_pre_proc) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_pre_proc != pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_pre_proc) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_pre_proc = pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_pre_proc; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_system) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_system != pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_system) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_system = pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_system; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_device_cut_off_freq) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.device_cut_off_frequency != pstr_drc_interface->loudness_norm_param_interface.device_cut_off_frequency) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.device_cut_off_frequency = pstr_drc_interface->loudness_norm_param_interface.device_cut_off_frequency; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_norm_gain_db_max) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_db_max != pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_db_max) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_db_max = pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_db_max; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_loudness_norm_gain_modification_db ) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db != pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_modification_db) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db = pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_modification_db; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->loudness_norm_param_interface.change_output_peak_level_max) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max != pstr_drc_interface->loudness_norm_param_interface.output_peak_level_max) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max = pstr_drc_interface->loudness_norm_param_interface.output_peak_level_max; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + } + if (pstr_drc_interface->drc_interface_flag) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on != pstr_drc_interface->drc_ctrl_interface.dynamic_range_control_on) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on = pstr_drc_interface->drc_ctrl_interface.dynamic_range_control_on; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + if (!pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_drc_feature_requests = 0; + } + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_drc_feature_requests != pstr_drc_interface->drc_ctrl_interface.num_drc_feature_requests) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_drc_feature_requests = pstr_drc_interface->drc_ctrl_interface.num_drc_feature_requests; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + for (i=0; iuni_drc_sel_proc_params.num_drc_feature_requests; i++) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_feature_req_type[i] != pstr_drc_interface->drc_ctrl_interface.drc_feature_req_type[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_feature_req_type[i] = pstr_drc_interface->drc_ctrl_interface.drc_feature_req_type[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + switch (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_feature_req_type[i]) { + case 0: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_num_drc_effects[i] != pstr_drc_interface->drc_ctrl_interface.requested_num_drc_effects[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_num_drc_effects[i] = pstr_drc_interface->drc_ctrl_interface.requested_num_drc_effects[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.desired_num_drc_effects_of_requested[i] != pstr_drc_interface->drc_ctrl_interface.desired_num_drc_effects_of_requested[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.desired_num_drc_effects_of_requested[i] = pstr_drc_interface->drc_ctrl_interface.desired_num_drc_effects_of_requested[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + for (j=0; juni_drc_sel_proc_params.requested_num_drc_effects[i]; j++) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_drc_effect_type[i][j] != pstr_drc_interface->drc_ctrl_interface.requested_drc_effect_type[i][j]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_drc_effect_type[i][j] = pstr_drc_interface->drc_ctrl_interface.requested_drc_effect_type[i][j]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + break; + case 1: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_measur_type[i] != pstr_drc_interface->drc_ctrl_interface.requested_dyn_rng_measurement_type[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_measur_type[i] = pstr_drc_interface->drc_ctrl_interface.requested_dyn_rng_measurement_type[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_range_flag[i] != pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_is_single_val_flag[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_range_flag[i] = pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_is_single_val_flag[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_range_flag[i] == 0) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_value[i] != pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_value[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_value[i] = pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_value[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } else { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_min_val[i] != pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_min_val[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_min_val[i] = pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_min_val[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_max_val[i] != pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_max_val[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_dyn_range_max_val[i] = pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_max_val[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + break; + case 2: + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_drc_characteristic[i] != pstr_drc_interface->drc_ctrl_interface.requested_drc_characteristic[i]) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.requested_drc_characteristic[i] = pstr_drc_interface->drc_ctrl_interface.requested_drc_characteristic[i]; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + break; + } + } + } + } + if (pstr_drc_interface->drc_parameter_interface_flag) { + if (pstr_drc_interface->drc_parameter_interface.change_compress) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress != pstr_drc_interface->drc_parameter_interface.compress) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress = pstr_drc_interface->drc_parameter_interface.compress; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->drc_parameter_interface.change_boost) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.boost != pstr_drc_interface->drc_parameter_interface.boost) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.boost = pstr_drc_interface->drc_parameter_interface.boost; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + if (pstr_drc_interface->drc_parameter_interface.change_drc_characteristic_target) { + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target != pstr_drc_interface->drc_parameter_interface.drc_characteristic_target) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target = pstr_drc_interface->drc_parameter_interface.drc_characteristic_target; + pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; + } + } + } + if (pstr_drc_interface->drc_uni_interface_ext_flag) { + ia_drc_uni_interface_ext_struct* drc_uni_interface_ext = &pstr_drc_interface->drc_uni_interface_ext; + if (drc_uni_interface_ext->loudness_eq_parameter_interface_flag) { + ia_loudness_eq_parameter_interface_struct* loudness_eq_parameter_interface = &drc_uni_interface_ext->loudness_eq_parameter_interface; + if (loudness_eq_parameter_interface->loudness_eq_request_flag) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_eq_request = loudness_eq_parameter_interface->loudness_eq_request; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.sensitivity = loudness_eq_parameter_interface->sensitivity; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.playback_gain = loudness_eq_parameter_interface->playback_gain; + } + } + if (drc_uni_interface_ext->eq_ctrl_interface_flag) { + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.eq_set_purpose_request = drc_uni_interface_ext->eq_ctrl_interface.eq_set_purpose_request; + } + } + } + + return 0; +} + + + diff --git a/decoder/drc_src/impd_drc_shape_filter.c b/decoder/drc_src/impd_drc_shape_filter.c new file mode 100644 index 0000000..4579681 --- /dev/null +++ b/decoder/drc_src/impd_drc_shape_filter.c @@ -0,0 +1,265 @@ +/****************************************************************************** + * + * 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 +#include +#include +#include + +#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_parametric_drc_dec.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_multi_band.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_process_audio.h" +#include "impd_drc_interface.h" +#include "impd_drc_gain_dec.h" +#include "impd_drc_eq.h" +#include "impd_drc_gain_decoder.h" +#include "impd_drc_rom.h" + +WORD32 impd_shape_filt_block_adapt(const FLOAT32 drc_gain, + shape_filter_block* shape_filter_block) +{ +// WORD32 err = 0; + WORD32 i; + FLOAT32 warpedGain, x1, y1; + shape_filter_block->drc_gain_last = drc_gain; + for (i=0; i<4; i++) { + + if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_OFF) + continue; + else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_LF_CUT||shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_HF_CUT) + { + if (drc_gain < 1.0f) + warpedGain = -1.0f; + else + warpedGain = (drc_gain - 1.0f) / (drc_gain - 1.0f + shape_filter_block->shape_filter[i].gain_offset); + x1 = shape_filter_block->shape_filter[i].a1; + } + else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_LF_BOOST||shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_HF_BOOST) + { + if (drc_gain >= 1.0f) + warpedGain = -1.0f; + else + warpedGain = (1.0f - drc_gain) / (1.0f + drc_gain * (shape_filter_block->shape_filter[i].gain_offset - 1.0f)); + x1 = shape_filter_block->shape_filter[i].b1; + + } + + if (warpedGain <= 0.0f) + { + y1 = x1; + } + else if (warpedGain < shape_filter_block->shape_filter[i].warped_gain_max) { + y1 = x1 + shape_filter_block->shape_filter[i].factor * warpedGain; + } + else + { + y1 = shape_filter_block->shape_filter[i].y1_bound; + } + if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_LF_CUT) + { + shape_filter_block->shape_filter[i].b1 = y1; + } + else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_HF_CUT) + { + shape_filter_block->shape_filter[i].g_norm = shape_filter_block->shape_filter[i].coeff_sum / (shape_filter_block->shape_filter[i].partial_coeff_sum + y1); + shape_filter_block->shape_filter[i].b1 = y1; +} + else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_HF_BOOST) +{ + shape_filter_block->shape_filter[i].g_norm = (shape_filter_block->shape_filter[i].partial_coeff_sum + y1) / shape_filter_block->shape_filter[i].coeff_sum; + shape_filter_block->shape_filter[i].a1 = y1; + } + else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_LF_BOOST) + { + shape_filter_block->shape_filter[i].a1 = y1; +} + + } + return (0); +} + +WORD32 resetshape_flter_block(shape_filter_block* shape_filter_block) +{ + WORD32 i, c; + shape_filter_block->drc_gain_last = -1.0f; + impd_shape_filt_block_adapt(1.0f, shape_filter_block); + for (i=0; i<4; i++) { + for (c=0; cshape_filter[i].audio_in_state_1[c] = 0.0f; + shape_filter_block->shape_filter[i].audio_in_state_2[c] = 0.0f; + shape_filter_block->shape_filter[i].audio_out_state_1[c] = 0.0f; + shape_filter_block->shape_filter[i].audio_out_state_2[c] = 0.0f; + } + } + return (0); +} + + +WORD32 impd_shape_filt_block_init(ia_shape_filter_block_params_struct* shape_flter_block_params, + shape_filter_block* shape_filter_block) +{ + //WORD32 err = 0; + FLOAT32 x1; + FLOAT32 x2 = 0.0f; + FLOAT32 radius; + if (shape_flter_block_params->lf_cut_filter_present) { + + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_lf_cut_params; + shape_filter_block->shape_filter[0].type = SHAPE_FILTER_TYPE_LF_CUT; + shape_filter_block->shape_filter[0].gain_offset = shape_filt_lf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; + shape_filter_block->shape_filter[0].y1_bound = shape_filt_lf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; + x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; + shape_filter_block->shape_filter[0].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[0].gain_offset); + shape_filter_block->shape_filter[0].factor = (shape_filter_block->shape_filter[0].y1_bound - x1) / shape_filter_block->shape_filter[0].warped_gain_max; + shape_filter_block->shape_filter[0].a1 = x1; + + } + else + { + shape_filter_block->shape_filter[0].type = SHAPE_FILTER_TYPE_OFF; + } + if (shape_flter_block_params->lf_boost_filter_present) { + + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_lf_boost_params; + shape_filter_block->shape_filter[1].type = SHAPE_FILTER_TYPE_LF_BOOST; + shape_filter_block->shape_filter[1].gain_offset = shape_filt_lf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; + shape_filter_block->shape_filter[1].y1_bound = shape_filt_lf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; + x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; + shape_filter_block->shape_filter[1].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[1].gain_offset); + shape_filter_block->shape_filter[1].factor = (shape_filter_block->shape_filter[1].y1_bound - x1) / shape_filter_block->shape_filter[1].warped_gain_max; + shape_filter_block->shape_filter[1].b1 = x1; + + } + else + { + shape_filter_block->shape_filter[1].type = SHAPE_FILTER_TYPE_OFF; + } + if (shape_flter_block_params->hf_cut_filter_present) { + + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_hfCutParams; + shape_filter_block->shape_filter[2].type = SHAPE_FILTER_TYPE_HF_CUT; + shape_filter_block->shape_filter[2].gain_offset = shape_filt_hf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; + shape_filter_block->shape_filter[2].y1_bound = shape_filt_hf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; + radius = shape_filt_hf_radius_tbl[params->corner_freq_index]; + x1 = (FLOAT32)(- 2.0f * radius * cos(2.0f * M_PI * shape_filt_cutoff_freq_norm_hf_tbl[params->corner_freq_index])); + x2 = radius * radius; + shape_filter_block->shape_filter[2].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[2].gain_offset); + shape_filter_block->shape_filter[2].factor = (shape_filter_block->shape_filter[2].y1_bound - x1) / shape_filter_block->shape_filter[2].warped_gain_max; + shape_filter_block->shape_filter[2].coeff_sum = 1.0f + x1 + x2; + shape_filter_block->shape_filter[2].partial_coeff_sum = 1.0f + x2; + shape_filter_block->shape_filter[2].a1 = x1; + shape_filter_block->shape_filter[2].a2 = x2; + shape_filter_block->shape_filter[2].b2 = x2; + } + else + { + shape_filter_block->shape_filter[2].type = SHAPE_FILTER_TYPE_OFF; + } + if (shape_flter_block_params->hf_boost_filter_present) { + + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_hf_boost_params; + shape_filter_block->shape_filter[3].type = SHAPE_FILTER_TYPE_HF_BOOST; + shape_filter_block->shape_filter[3].gain_offset = shape_filt_hf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; + shape_filter_block->shape_filter[3].y1_bound = shape_filt_hf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; + radius = shape_filt_hf_radius_tbl[params->corner_freq_index]; + x1 = (FLOAT32)(- 2.0f * radius * cos(2.0f * M_PI * shape_filt_cutoff_freq_norm_hf_tbl[params->corner_freq_index])); + x2 = radius * radius; + shape_filter_block->shape_filter[3].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[3].gain_offset); + shape_filter_block->shape_filter[3].factor = (shape_filter_block->shape_filter[3].y1_bound - x1) / shape_filter_block->shape_filter[3].warped_gain_max; + shape_filter_block->shape_filter[3].coeff_sum = 1.0f + x1 + x2; + shape_filter_block->shape_filter[3].partial_coeff_sum = 1.0f + x2; + shape_filter_block->shape_filter[3].b1 = x1; + shape_filter_block->shape_filter[3].b2 = x2; + shape_filter_block->shape_filter[3].a2 = x2; + + + } + else + { + shape_filter_block->shape_filter[3].type = SHAPE_FILTER_TYPE_OFF; + } + resetshape_flter_block(shape_filter_block); + shape_filter_block->shape_flter_block_flag = 1; + return (0); +} + + + +WORD32 impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block, + FLOAT32* drc_gain, + const WORD32 channel, + FLOAT32 *audio_in, + WORD32 start, + WORD32 end) +{ + WORD32 i,j, err=0; + FLOAT32 audio_out; + + if(shape_filter_block->shape_flter_block_flag){ + for (i=start; ishape_filter[j].type==SHAPE_FILTER_TYPE_LF_CUT||shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_LF_BOOST){ + + audio_out = tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] + - shape_filter_block->shape_filter[j].a1 * shape_filter_block->shape_filter[j].audio_out_state_1[channel]; + shape_filter_block->shape_filter[j].audio_in_state_1[channel] = tmp; + shape_filter_block->shape_filter[j].audio_out_state_1[channel] = audio_out; + + } + else if(shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_HF_CUT||shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_HF_BOOST){ + + audio_out = shape_filter_block->shape_filter[j].g_norm * tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] + + shape_filter_block->shape_filter[j].b2 * shape_filter_block->shape_filter[j].audio_in_state_2[channel] + - shape_filter_block->shape_filter[j].a1 * shape_filter_block->shape_filter[j].audio_out_state_1[channel] + - shape_filter_block->shape_filter[j].a2 * shape_filter_block->shape_filter[j].audio_out_state_2[channel]; + shape_filter_block->shape_filter[j].audio_in_state_2[channel] = shape_filter_block->shape_filter[j].audio_in_state_1[channel]; + shape_filter_block->shape_filter[j].audio_in_state_1[channel] = shape_filter_block->shape_filter[j].g_norm * tmp; + shape_filter_block->shape_filter[j].audio_out_state_2[channel] = shape_filter_block->shape_filter[j].audio_out_state_1[channel]; + shape_filter_block->shape_filter[j].audio_out_state_1[channel] = audio_out; + } + else + { + audio_out = tmp; + } + tmp = audio_out; + + } + + audio_in[i] = audio_out * drc_gain[i]; + } + + } + else{ + for (i=start; i +#include +#include +#include "impd_type_def.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_parser.h" +#include "impd_drc_filter_bank.h" +#include "impd_drc_rom.h" + + +static VOID impd_parametric_drc_ffwd_init_drc_curve_params(WORD32 drc_characteristic, + ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) +{ + WORD32* node_level = str_parametric_drc_type_feed_forward->node_level; + WORD32* node_gain = str_parametric_drc_type_feed_forward->node_gain; + + switch (drc_characteristic) { + case 7: + str_parametric_drc_type_feed_forward->node_count = 5; + node_level[0] = -22; node_gain[0] = 6; + node_level[1] = -10; node_gain[1] = 0; + node_level[2] = 10; node_gain[2] = 0; + node_level[3] = 20; node_gain[3] = -5; + node_level[4] = 40; node_gain[4] = -24; + break; + case 8: + str_parametric_drc_type_feed_forward->node_count = 5; + node_level[0] = -12; node_gain[0] = 6; + node_level[1] = 0; node_gain[1] = 0; + node_level[2] = 5; node_gain[2] = 0; + node_level[3] = 15; node_gain[3] = -5; + node_level[4] = 35; node_gain[4] = -24; + break; + case 9: + str_parametric_drc_type_feed_forward->node_count = 4; + node_level[0] = -34; node_gain[0] = 12; + node_level[1] = -10; node_gain[1] = 0; + node_level[2] = 10; node_gain[2] = 0; + node_level[3] = 40; node_gain[3] = -15; + break; + case 10: + str_parametric_drc_type_feed_forward->node_count = 5; + node_level[0] = -24; node_gain[0] = 12; + node_level[1] = 0; node_gain[1] = 0; + node_level[2] = 5; node_gain[2] = 0; + node_level[3] = 15; node_gain[3] = -5; + node_level[4] = 35; node_gain[4] = -24; + break; + case 11: + str_parametric_drc_type_feed_forward->node_count = 5; + node_level[0] = -19; node_gain[0] = 15; + node_level[1] = 0; node_gain[1] = 0; + node_level[2] = 5; node_gain[2] = 0; + node_level[3] = 15; node_gain[3] = -5; + node_level[4] = 35; node_gain[4] = -24; + break; + default: + str_parametric_drc_type_feed_forward->disable_paramteric_drc = 1; + } + + return; +} + +static VOID impd_parametric_drc_ffwd_init_drc_gain_smooth_params(WORD32 drc_characteristic, + ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) +{ + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = 100; + str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = 10; + str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_hold_off = 10; + + switch (drc_characteristic) + { + case 7: + case 8: + case 9: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; + case 10: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 10000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; + case 11: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 200; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 10; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 10; + break; + default: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; + } + + return; +} + +static WORD32 impd_parse_parametric_drc_ffwd(ia_bit_buf_struct* it_bit_buff, + WORD32 parametric_drc_frame_size, + ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) +{ + WORD32 i = 0, tmp = 0; + //WORD32 err = 0; + + str_parametric_drc_type_feed_forward->disable_paramteric_drc = 0; + + tmp = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->level_estim_k_weighting_type = (tmp>>1)&3; + str_parametric_drc_type_feed_forward->level_estim_integration_time_present = tmp&1; + + if (str_parametric_drc_type_feed_forward->level_estim_integration_time_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_type_feed_forward->level_estim_integration_time = (tmp+1)*parametric_drc_frame_size; + } else + { + str_parametric_drc_type_feed_forward->level_estim_integration_time = parametric_drc_frame_size; + } + + str_parametric_drc_type_feed_forward->drc_curve_definition_type = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_type_feed_forward->drc_curve_definition_type == 0) + { + str_parametric_drc_type_feed_forward->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); + } + else + { + str_parametric_drc_type_feed_forward->drc_characteristic = 0; + + tmp = impd_read_bits_buf(it_bit_buff, 15); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->node_count = ((tmp>>12)&3) + 2; + str_parametric_drc_type_feed_forward->node_level[0] = -11-((tmp>>6)&0x3f); + str_parametric_drc_type_feed_forward->node_gain[0] = (tmp&0x3f)-39; + + for (i=1; inode_count; i++) + { + tmp = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->node_level[i] = str_parametric_drc_type_feed_forward->node_level[i-1]+1+((tmp>>6)&0x1f); + str_parametric_drc_type_feed_forward->node_gain[i] = (tmp&0x3f)-39; + } + } + + impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); + + str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present) + { + + tmp = impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = ((tmp>>9)&0xff)*5; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = ((tmp>>1)&0xff)*40; + str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = tmp&1; + + if (str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present) + { + + tmp = impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = ((tmp>>9)&0xff)*5; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = ((tmp>>1)&0xff)*20; + str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = tmp&1; + + if (str_parametric_drc_type_feed_forward->gain_smooth_threshold_present) + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if ( str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold == 31) + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 1000; + } + + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold == 31) + { + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 1000; + } + } + } + else + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow; + } + + str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present) + { + str_parametric_drc_type_feed_forward->gain_smooth_hold_off = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + return 0; +} + +static WORD32 impd_parse_parametric_drc_lim(ia_bit_buf_struct* it_bit_buff, + ia_parametric_drc_lim_struct* parametric_drc_lim) +{ + //WORD32 err = 0; + WORD32 tmp = 0; + + parametric_drc_lim->disable_paramteric_drc = 0; + + parametric_drc_lim->parametric_lim_threshold_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (parametric_drc_lim->parametric_lim_threshold_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + parametric_drc_lim->parametric_lim_threshold = - tmp * 0.125f; + } else + { + parametric_drc_lim->parametric_lim_threshold = PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT; + } + + parametric_drc_lim->parametric_lim_release_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (parametric_drc_lim->parametric_lim_release_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + parametric_drc_lim->parametric_lim_release = tmp*10; + } + else + { + parametric_drc_lim->parametric_lim_release = PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT; + } + + parametric_drc_lim->parametric_lim_attack = PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT; + parametric_drc_lim->drc_characteristic = 0; + + return 0; +} + +WORD32 +impd_parametric_drc_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, + ia_drc_config* drc_config, + ia_parametric_drc_gain_set_params_struct* str_parametric_drc_gain_set_params) +{ + WORD32 i = 0, bsDrcInputLoudness = 0, bs_channel_weight = 0, temp; + //WORD32 err = 0; + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + 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) + { + + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_gain_set_params->downmix_id = (temp>>1)&0x7f; + str_parametric_drc_gain_set_params->level_estim_channel_weight_format = temp&1; + + if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_BASE_LAYOUT) + { + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->channel_layout.base_channel_count; + } + else if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_ANY_DOWNMIX) + { + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 1; + } else + { + for(i=0; idwnmix_instructions_count; i++) + { + if (str_parametric_drc_gain_set_params->downmix_id == drc_config->dwnmix_instructions[i].downmix_id) break; + } + if (i == drc_config->dwnmix_instructions_count) + { + /* dwnmix_instructions not found */ + return(UNEXPECTED_ERROR); + } + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->dwnmix_instructions[i].target_channel_count; + } + + for (i=0; ich_count_from_dwnmix_id; i++) + { + if (str_parametric_drc_gain_set_params->level_estim_channel_weight_format == 0) + { + str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } else + { + bs_channel_weight = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)pow(10.0f, 0.05f * channel_weight[bs_channel_weight]); + } + } + } + else + { + str_parametric_drc_gain_set_params->downmix_id = 0; + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 0; + } + + str_parametric_drc_gain_set_params->drc_input_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_gain_set_params->drc_input_loudness_present) + { + bsDrcInputLoudness = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_gain_set_params->drc_input_loudness = -57.75f + bsDrcInputLoudness * 0.25f; + } + + return 0; +} + +static WORD32 impd_parametric_drc_gen_virtual_gain_sets(ia_drc_config* drc_config) +{ + + WORD32 i = 0, j = 0, c1 = -1, c0 = -1, parametric_drc_id = 0, drc_characteristic = 0; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc; + ia_parametric_drc_instructions_struct* str_parametric_drc_instructions; + ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc = &(drc_config->str_drc_config_ext.str_drc_coeff_param_drc); + + for(i=0; idrc_coefficients_drc_count; i++) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[i].drc_location == str_drc_coeff_param_drc->drc_location) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[i].version == 0) + { + c0 = i; + } + else + { + c1 = i; + } + } + } + if (c1 >= 0) + { + str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c1]); + } + else if (c0 >= 0) + { + str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c0]); + } + else + { + str_p_loc_drc_coefficients_uni_drc = &drc_config->str_p_loc_drc_coefficients_uni_drc[drc_config->drc_coefficients_drc_count]; + + str_p_loc_drc_coefficients_uni_drc->version = 1; + str_p_loc_drc_coefficients_uni_drc->drc_location = str_drc_coeff_param_drc->drc_location; + str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = 0; + + str_p_loc_drc_coefficients_uni_drc->gain_set_count = 0; + str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = 0; + + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = 0; + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = 0; + str_p_loc_drc_coefficients_uni_drc->shape_filters_present = 0; + 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; + for (i=str_p_loc_drc_coefficients_uni_drc->gain_set_count; igain_set_count_plus; i++) + { + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].band_count = 1; + + parametric_drc_id = drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[i-str_p_loc_drc_coefficients_uni_drc->gain_set_count].parametric_drc_id; + + for(j=0; jstr_drc_config_ext.parametric_drc_instructions_count; j++) + { + if (parametric_drc_id == drc_config->str_drc_config_ext.str_parametric_drc_instructions[j].parametric_drc_id) break; + } + if (j == drc_config->str_drc_config_ext.parametric_drc_instructions_count) + { + /* str_parametric_drc_instructions not found */ + return(UNEXPECTED_ERROR); + } + str_parametric_drc_instructions = &drc_config->str_drc_config_ext.str_parametric_drc_instructions[j]; + + drc_characteristic = 0; + if (str_parametric_drc_instructions->parametric_drc_preset_id_present) + { + drc_characteristic = str_parametric_drc_instructions->drc_characteristic; + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + if (str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_curve_definition_type == 0) + { + drc_characteristic = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_characteristic; + } + } + if (drc_characteristic != 0) + { + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_present = 1; + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_format_is_cicp = 1; + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic = drc_characteristic; + } + else + { + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_present = 0; + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_format_is_cicp = 0; + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic = 0; + } + } + + return 0; +} + + +static WORD32 impd_parametic_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, + ia_drc_config* drc_config, + ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc) +{ + WORD32 i = 0, err = 0, code = 0, mu = 0, nu = 0, temp; + + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_coeff_param_drc->drc_location = (temp>>1)&0xf; + str_drc_coeff_param_drc->parametric_drc_frame_size_format = temp&1; + + if (str_drc_coeff_param_drc->parametric_drc_frame_size) + { + 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; + } + else + { + code = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_coeff_param_drc->parametric_drc_frame_size = 1 << code; + } + + str_drc_coeff_param_drc->parametric_drc_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); + 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; + + mu = (temp>>3)&0x1f; + nu = temp&3; + + str_drc_coeff_param_drc->parametric_drc_delay_max = 16 * mu * (1<error) + return it_bit_buff->error; + + str_drc_coeff_param_drc->reset_parametric_drc = (temp>>6)&1; + str_drc_coeff_param_drc->parametric_drc_gain_set_count = temp&0x3f; + + for(i=0; iparametric_drc_gain_set_count; i++) + { + err = impd_parametric_drc_parse_gain_set_params(it_bit_buff, drc_config, &(str_drc_coeff_param_drc->str_parametric_drc_gain_set_params[i])); + if (err) return (err); + } + + return 0; +} + +static WORD32 impd_parse_parametric_drc_instructions(ia_bit_buf_struct* it_bit_buff, + WORD32 parametric_drc_frame_size, + ia_parametric_drc_instructions_struct* str_parametric_drc_instructions) +{ + WORD32 i = 0, err = 0, temp; + WORD32 bit_size_len, bit_size, other_bit; + + str_parametric_drc_instructions->drc_characteristic = 0; + str_parametric_drc_instructions->disable_paramteric_drc = 0; + + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_instructions->parametric_drc_id = (temp>>1)&0xf; + str_parametric_drc_instructions->parametric_drc_look_ahead_flag = temp&1; + + if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) + { + str_parametric_drc_instructions->parametric_drc_look_ahead = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + str_parametric_drc_instructions->parametric_drc_look_ahead = 0; + } + + str_parametric_drc_instructions->parametric_drc_preset_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_instructions->parametric_drc_preset_id_present) + { + str_parametric_drc_instructions->parametric_drc_preset_id = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + switch (str_parametric_drc_instructions->parametric_drc_preset_id) + { + case 0: + case 1: + case 2: + case 3: + case 4: + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_preset_id + 7; + str_parametric_drc_instructions->parametric_drc_type = PARAM_DRC_TYPE_FF; + + str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_k_weighting_type = 2; + str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_integration_time = parametric_drc_frame_size; + + impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); + impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); + + break; + default: + str_parametric_drc_instructions->disable_paramteric_drc = 1; + break; + } + } + else + { + str_parametric_drc_instructions->parametric_drc_type = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + err = impd_parse_parametric_drc_ffwd(it_bit_buff, parametric_drc_frame_size, &(str_parametric_drc_instructions->str_parametric_drc_type_feed_forward)); + if (err) return (err); + str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.disable_paramteric_drc; + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_characteristic; + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) + { + err = impd_parse_parametric_drc_lim(it_bit_buff, &(str_parametric_drc_instructions->parametric_drc_lim)); + if (err) return (err); + str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->parametric_drc_lim.disable_paramteric_drc; + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_lim.drc_characteristic; + if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) + { + str_parametric_drc_instructions->parametric_drc_lim.parametric_lim_attack = str_parametric_drc_instructions->parametric_drc_look_ahead; + } + } + else + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 3) + 4; + if(it_bit_buff->error) + return it_bit_buff->error; + + bit_size = impd_read_bits_buf(it_bit_buff, bit_size_len); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_instructions->len_bit_size = bit_size + 1; + + switch(str_parametric_drc_instructions->parametric_drc_type) + { + + default: + str_parametric_drc_instructions->disable_paramteric_drc = 1; + for(i = 0; ilen_bit_size; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + } + } + + return 0; +} + +WORD32 impd_parse_loud_info_set_ext_eq(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set) +{ + WORD32 err, i, offset, version = 1, temp; + WORD32 loudness_info_v1_album_cnt, loudness_info_v1_cnt; + + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info_v1_album_cnt = (temp>>6)&0x3f; + loudness_info_v1_cnt = temp&0x3f; + + offset = loudness_info_set->loudness_info_album_count; + loudness_info_set->loudness_info_album_count += loudness_info_v1_album_cnt; + for (i=0; istr_loudness_info_album[i + offset]); + if (err) return(err); + } + offset = loudness_info_set->loudness_info_count; + loudness_info_set->loudness_info_count += loudness_info_v1_cnt; + for (i=0; iloudness_info[i + offset]); + if (err) return(err); + } + return (0); +} + +WORD32 impd_parse_ch_layout(ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout) +{ + //WORD32 err = 0; + WORD32 i; + + channel_layout->base_channel_count = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (ia_drc_params_struct->lfe_channel_map_count != -1 && channel_layout->base_channel_count != ia_drc_params_struct->lfe_channel_map_count) + { + return (UNEXPECTED_ERROR); + } + channel_layout->layout_signaling_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (channel_layout->layout_signaling_present) + { + channel_layout->defined_layout = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (channel_layout->defined_layout == 0) + { + for (i=0; ibase_channel_count; i++) + { + channel_layout->speaker_position[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (channel_layout->speaker_position[i] == 3 || channel_layout->speaker_position[i] == 26) { + ia_drc_params_struct->lfe_channel_map[i] = 1; + } + else + { + ia_drc_params_struct->lfe_channel_map[i] = 0; + } + } + } + } + + return(0); +} + +WORD32 +impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout, + ia_downmix_instructions_struct* dwnmix_instructions) +{ + //WORD32 err = 0; + WORD32 i, j, k, temp; + + temp = impd_read_bits_buf(it_bit_buff, 23); + if(it_bit_buff->error) + return it_bit_buff->error; + + dwnmix_instructions->downmix_id = (temp>>16)&0x7f; + dwnmix_instructions->target_channel_count = (temp>>9)&0x7f; + dwnmix_instructions->target_layout = (temp>>1)&0xff; + dwnmix_instructions->downmix_coefficients_present = temp&1; + + if (dwnmix_instructions->downmix_coefficients_present) + { + if (version == 0) + { + WORD32 dmix_coeff; + k=0; + for (i=0; itarget_channel_count; i++) + { + for (j=0; jbase_channel_count; j++) + { + dmix_coeff = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (ia_drc_params_struct->lfe_channel_map[j]) + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff_lfe[dmix_coeff]); + } + else + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff[dmix_coeff]); + } + k++; + } + } + } + else + { + WORD32 dmix_coeff_v1, bs_dmix_offset; + FLOAT32 a, b, dmix_offset, sum; + + bs_dmix_offset = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + k=0; + for (i=0; itarget_channel_count; i++) + { + for (j=0; jbase_channel_count; j++) + { + dmix_coeff_v1 = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + dwnmix_instructions->downmix_coefficient[k] = dwnmix_coeff_v1[dmix_coeff_v1]; + k++; + } + } + switch (bs_dmix_offset) + { + case 0: + dmix_offset = 0.0f; + break; + case 1: + a = 20.0f * (FLOAT32)log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); + dmix_offset = 0.5f *(FLOAT32) floor(0.5f + a); + break; + case 2: + a = 20.0f *(FLOAT32) log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); + dmix_offset = 0.5f *(FLOAT32) floor(0.5f + 2.0f * a); + break; + case 3: + sum = 0.0f; + for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) + { + sum += (FLOAT32)pow(10.0f, 0.1f * dwnmix_instructions->downmix_coefficient[k]); + } + b = 10.0f * (FLOAT32)log10(sum); + dmix_offset = 0.5f * (FLOAT32)floor(0.5f + 2.0f * b); + break; + + default: + return (BITSTREAM_ERROR); + break; + } + for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * (dwnmix_instructions->downmix_coefficient[k] + dmix_offset)); + } + } + } + return(0); +} + +VOID impd_drc_gen_instructions_for_drc_off(ia_drc_config* drc_config) +{ + WORD32 i, k, s; + ia_drc_instructions_struct* str_drc_instruction_str; + s = -1; + + + k = drc_config->drc_instructions_uni_drc_count; + + str_drc_instruction_str = &(drc_config->str_drc_instruction_str[k]); + memset(str_drc_instruction_str, 0, sizeof(ia_drc_instructions_struct)); + str_drc_instruction_str->drc_set_id = s; + s--; + str_drc_instruction_str->downmix_id[0] = ID_FOR_BASE_LAYOUT; + str_drc_instruction_str->dwnmix_id_count = 1; + str_drc_instruction_str->drc_apply_to_dwnmix = 0; + str_drc_instruction_str->depends_on_drc_set_present = 0; + str_drc_instruction_str->no_independent_use = 0; + str_drc_instruction_str->gain_element_count = 0; + for (i=1; idwnmix_instructions_count + 1; i++) + { + str_drc_instruction_str = &(drc_config->str_drc_instruction_str[k+i]); + memset(str_drc_instruction_str, 0, sizeof(ia_drc_instructions_struct)); + str_drc_instruction_str->drc_set_id = s; + s--; + str_drc_instruction_str->drc_set_complexity_level = 0; + str_drc_instruction_str->requires_eq = 0; + str_drc_instruction_str->downmix_id[0] = drc_config->dwnmix_instructions[i-1].downmix_id; + str_drc_instruction_str->dwnmix_id_count = 1; + str_drc_instruction_str->drc_apply_to_dwnmix = 0; + str_drc_instruction_str->depends_on_drc_set_present = 0; + str_drc_instruction_str->no_independent_use = 0; + str_drc_instruction_str->gain_element_count = 0; + } + drc_config->drc_instructions_count_plus = drc_config->drc_instructions_uni_drc_count + drc_config->dwnmix_instructions_count + 1; + return; +} + +WORD32 +impd_parse_drc_config_ext(ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config, + ia_drc_config_ext* str_drc_config_ext) +{ + WORD32 err = 0, i, k; + WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; + + k = 0; + str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(str_drc_config_ext->drc_config_ext_type[k] != UNIDRCCONFEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_config_ext->ext_bit_size[k] = bit_size + 1; + + switch(str_drc_config_ext->drc_config_ext_type[k]) + { + case UNIDRCCONFEXT_PARAM_DRC: + str_drc_config_ext->parametric_drc_present = 1; + err = impd_parametic_drc_parse_coeff(it_bit_buff, drc_config, &(str_drc_config_ext->str_drc_coeff_param_drc)); + if (err) return(err); + str_drc_config_ext->parametric_drc_instructions_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; iparametric_drc_instructions_count; i++) + { + err = impd_parse_parametric_drc_instructions(it_bit_buff, str_drc_config_ext->str_drc_coeff_param_drc.parametric_drc_frame_size, &(str_drc_config_ext->str_parametric_drc_instructions[i])); + if (err) return (err); + } + break; + case UNIDRCCONFEXT_V1: + str_drc_config_ext->drc_extension_v1_present = 1; + err = impd_parse_drc_ext_v1( it_bit_buff, ia_drc_params_struct, drc_config, str_drc_config_ext); + if (err) return(err); + break; + default: + for(i = 0; iext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); +} + +static WORD32 impd_parse_split_drc_characteristic(ia_bit_buf_struct* it_bit_buff, const WORD32 side, ia_split_drc_characteristic_struct* split_drc_characteristic) { + //WORD32 err = 0; + WORD32 i, temp; + + split_drc_characteristic->characteristic_format = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (split_drc_characteristic->characteristic_format == 0) + { + WORD32 bsGain, bsIoRatio, bsExp; + bsGain = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + if (side == LEFT_SIDE) + { + split_drc_characteristic->gain = (FLOAT32)bsGain; + } + else + { + split_drc_characteristic->gain = (FLOAT32)- bsGain; + } + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + bsIoRatio = (temp>>4)&0xf; + bsExp = temp&0xf; + split_drc_characteristic->in_out_ratio = 0.05f + 0.15f * bsIoRatio; + + if (bsExp<15) + { + split_drc_characteristic->exp = 1.0f + 2.0f * bsExp; + } + else + { + split_drc_characteristic->exp = 1000.0f; + } + split_drc_characteristic->flip_sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + WORD32 char_node_cnt, node_level_delta, node_gain; + char_node_cnt = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + split_drc_characteristic->characteristic_node_count = char_node_cnt + 1; + split_drc_characteristic->node_level[0] = DRC_INPUT_LOUDNESS_TARGET; + split_drc_characteristic->node_gain[0] = 0.0f; + for (i=1; i<=split_drc_characteristic->characteristic_node_count; i++) + { + node_level_delta = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if (side == LEFT_SIDE) + { + split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] - (1.0f + node_level_delta); + } + else + { + split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] + (1.0f + node_level_delta); + } + node_gain = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + split_drc_characteristic->node_gain[i] = 0.5f * node_gain - 64.0f; + } + } + return(0); +} + + +WORD32 +impd_drc_gen_instructions_derived_data(ia_drc_config* drc_config, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_instructions_struct* str_drc_instruction_str) +{ + WORD32 n, g; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; + ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc = NULL; + WORD32 gain_element_count = 0; + + for(n=0; ndrc_coefficients_drc_count; n++) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].drc_location == str_drc_instruction_str->drc_location) break; + } + if ((n == drc_config->drc_coefficients_drc_count) + && (drc_config->drc_coefficients_drc_count > 0) + ) + { + return -1; + } + str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[n]); + + if (drc_config->drc_config_ext_present && drc_config->str_drc_config_ext.parametric_drc_present && + drc_config->str_drc_config_ext.str_drc_coeff_param_drc.drc_location == str_drc_instruction_str->drc_location) + { + str_drc_coeff_param_drc = &drc_config->str_drc_config_ext.str_drc_coeff_param_drc; + } + + for (g=0; gnum_drc_ch_groups; g++) + { + WORD32 seq = str_drc_instruction_str->gain_set_index_for_channel_group[g]; + if (seq != -1 && (drc_config->drc_coefficients_drc_count == 0 || seq >= str_p_loc_drc_coefficients_uni_drc->gain_set_count)) + { + str_drc_instruction_str->ch_group_parametric_drc_flag[g] = 1; + if (drc_config->drc_coefficients_drc_count != 0) + { + seq = seq - str_p_loc_drc_coefficients_uni_drc->gain_set_count; + } + str_drc_instruction_str->gain_set_idx_of_ch_group_parametric_drc[g] = seq; + + if (str_drc_coeff_param_drc == NULL || seq>=str_drc_coeff_param_drc->parametric_drc_gain_set_count) + { + /* parametric drc gain set not available */ + return(EXTERNAL_ERROR); + } + str_drc_instruction_str->gain_interpolation_type_for_channel_group[g] = 1; + str_drc_instruction_str->time_delta_min_for_channel_group[g] = str_drc_coeff_param_drc->parametric_drc_frame_size; + str_drc_instruction_str->time_alignment_for_channel_group[g] = 0; + } else { + str_drc_instruction_str->ch_group_parametric_drc_flag[g] = 0; + } + if (str_drc_instruction_str->ch_group_parametric_drc_flag[g] == 0) { + if (seq>=str_p_loc_drc_coefficients_uni_drc->gain_set_count) { + return -1; + } + str_drc_instruction_str->gain_interpolation_type_for_channel_group[g] = str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].gain_interpolation_type; + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].time_delt_min_flag) + { + str_drc_instruction_str->time_delta_min_for_channel_group[g] = str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].time_delt_min_val; + } + else + { + str_drc_instruction_str->time_delta_min_for_channel_group[g] = ia_drc_params_struct->delta_tmin_default; + } + str_drc_instruction_str->time_alignment_for_channel_group[g] = str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].time_alignment; + } + } + + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + str_drc_instruction_str->gain_element_count = str_drc_instruction_str->num_drc_ch_groups; + } + else + { + for (g=0; gnum_drc_ch_groups; g++) + { + if (str_drc_instruction_str->ch_group_parametric_drc_flag[g] == 1) + { + gain_element_count++; + str_drc_instruction_str->band_count_of_ch_group[g] = 1; + } + else + { + WORD32 seq, band_count; + seq = str_drc_instruction_str->gain_set_index_for_channel_group[g]; + band_count = str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].band_count; + str_drc_instruction_str->band_count_of_ch_group[g] = band_count; + gain_element_count += band_count; + } + } + str_drc_instruction_str->gain_element_count = gain_element_count; + } + + return(0); +} + +WORD32 +impd_parse_drc_config(ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config + ) +{ + WORD32 i, err = 0, temp; + WORD32 version = 0; + + drc_config->sample_rate_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if(drc_config->sample_rate_present == 1) + { + WORD32 bssample_rate; + bssample_rate = impd_read_bits_buf(it_bit_buff, 18); + if(it_bit_buff->error) + return it_bit_buff->error; + drc_config->sampling_rate = bssample_rate + 1000; + } + + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_config->dwnmix_instructions_count = (temp>>1)&0x7f; + drc_config->drc_description_basic_present = temp&1; + + if (drc_config->drc_description_basic_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_config->drc_coefficients_basic_count = (temp>>4)&7; + drc_config->drc_instructions_basic_count = temp&0xf; + + } + else + { + drc_config->drc_coefficients_basic_count = 0; + drc_config->drc_instructions_basic_count = 0; + } + + temp = impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_config->drc_coefficients_drc_count = (temp>>6)&7; + drc_config->drc_instructions_uni_drc_count = temp&0x3f; + + err = impd_parse_ch_layout(it_bit_buff, ia_drc_params_struct, &drc_config->channel_layout); + if (err) return(err); + + for(i=0; idwnmix_instructions_count; i++) + { + err = impd_parse_dwnmix_instructions(it_bit_buff, version, ia_drc_params_struct, &drc_config->channel_layout, &(drc_config->dwnmix_instructions[i])); + if (err) return(err); + } + for(i=0; idrc_coefficients_basic_count ; i++) + { + temp = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_config->str_drc_coefficients_basic[i].drc_location = (temp>>7)&0xf; + drc_config->str_drc_coefficients_basic[i].drc_characteristic = temp&0x3f; + + } + for(i=0; idrc_instructions_basic_count; i++) + { + err = impd_drc_parse_instructions_basic(it_bit_buff, &(drc_config->str_drc_instructions_basic[i])); + if (err) return(err); + } + for(i=0; idrc_coefficients_drc_count; i++) + { + err = impd_drc_parse_coeff(it_bit_buff, version, ia_drc_params_struct, &(drc_config->str_p_loc_drc_coefficients_uni_drc[i])); + if (err) return(err); + } + for(i=0; idrc_instructions_uni_drc_count; i++) + { + err = impd_parse_drc_instructions_uni_drc(it_bit_buff, version, drc_config, &(drc_config->str_drc_instruction_str[i])); + if (err) return(err); + } + + drc_config->drc_config_ext_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (drc_config->drc_config_ext_present == 1) + { + err = impd_parse_drc_config_ext( it_bit_buff, ia_drc_params_struct, drc_config, &(drc_config->str_drc_config_ext)); + if (err) return(err); + } + + if ( drc_config->str_drc_config_ext.parametric_drc_present ) + { + err = impd_parametric_drc_gen_virtual_gain_sets(drc_config); + if (err) return(err); + } + + for(i=0; idrc_instructions_uni_drc_count; i++) + { + err = impd_drc_gen_instructions_derived_data(drc_config, ia_drc_params_struct, &(drc_config->str_drc_instruction_str[i])); + if (err) return(err); + } + + impd_drc_gen_instructions_for_drc_off(drc_config); + return(0); +} + +WORD32 +impd_dec_method_value(ia_bit_buf_struct* it_bit_buff, + WORD32 method_def, + FLOAT32* method_val) +{ + //WORD32 err = 0; + WORD32 tmp; + FLOAT32 val; + switch (method_def) { + case METHOD_DEFINITION_UNKNOWN_OTHER: + case METHOD_DEFINITION_PROGRAM_LOUDNESS: + case METHOD_DEFINITION_ANCHOR_LOUDNESS: + case METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE: + case METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX: + case METHOD_DEFINITION_SHORT_TERM_LOUDNESS_MAX: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + val = -57.75f + tmp * 0.25f; + break; + case METHOD_DEFINITION_LOUDNESS_RANGE: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + if (tmp == 0) + val = 0.0f; + else if(tmp <= 128) + val = tmp * 0.25f; + else if(tmp <= 204) + val = 0.5f * tmp - 32.0f; + else + val = tmp - 134.0f; + break; + case METHOD_DEFINITION_MIXING_LEVEL: + tmp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + val = tmp + 80.0f; + break; + case METHOD_DEFINITION_ROOM_TYPE: + tmp = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + val = (FLOAT32)tmp; + break; + case METHOD_DEFINITION_SHORT_TERM_LOUDNESS: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + val = -116.f + tmp * 0.5f; + break; + default: + return -1; + break; + } + *method_val = val; + return 0; +} + + +WORD32 +impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set) +{ + WORD32 err = 0, i, version = 0, offset, temp; + WORD32 loudness_info_album_count, loudness_info_count; + + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info_album_count = (temp>>6)&0x3f; + loudness_info_count = temp&0x3f; + + offset = loudness_info_set->loudness_info_album_count; + loudness_info_set->loudness_info_album_count += loudness_info_album_count; + for (i = 0; i< loudness_info_set->loudness_info_album_count; i++) + { + err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->str_loudness_info_album[i+offset])); + if (err) return(err); + } + + offset = loudness_info_set->loudness_info_count; + loudness_info_set->loudness_info_count += loudness_info_count; + for (i = 0; iloudness_info_count; i++) + { + err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->loudness_info[i+offset])); + if (err) return(err); + } + + loudness_info_set->loudness_info_set_ext_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ( loudness_info_set->loudness_info_set_ext_present == 1) + { + err = impd_parse_loudness_info_set_ext(it_bit_buff, loudness_info_set); + if (err) return(err); + } + + return (0); +} + +WORD32 +impd_parse_gain_set_params_characteristics(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_gain_params_struct* gain_params) +{ + //WORD32 err = 0; + WORD32 temp; + if (version == 0) + { + gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic > 0) + { + gain_params->drc_characteristic_present = 1; + gain_params->drc_characteristic_format_is_cicp = 1; + } + else + { + gain_params->drc_characteristic_present = 0; + } + } + else { + gain_params->drc_characteristic_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic_present) + { + gain_params->drc_characteristic_format_is_cicp = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic_format_is_cicp) + { + gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + gain_params->drc_characteristic_left_index = (temp>>4)&0xf; + gain_params->drc_characteristic_right_index = temp&0xf; + + } + } + } + return(0); +} + +WORD32 +impd_parse_loudness_measure(ia_bit_buf_struct* it_bit_buff, + ia_loudness_measure_struct* loudness_measure) +{ + WORD32 err = 0, temp; + + loudness_measure->method_def = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + err = impd_dec_method_value(it_bit_buff, loudness_measure->method_def, &(loudness_measure->method_val)); + if(err) return err; + + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_measure->measurement_system = (temp>>2)&0xf; + loudness_measure->reliability = temp&3; + + return (0); +} + + +WORD32 +impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + WORD32 band_count, + ia_gain_modifiers_struct* pstr_gain_modifiers) +{ + + //WORD32 err = 0; + WORD32 sign, temp; + + if (version > 0) + { + WORD32 b; + for (b=0; btarget_characteristic_left_present[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->target_characteristic_left_present[b]) + { + pstr_gain_modifiers->target_characteristic_left_index[b] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + pstr_gain_modifiers->target_characteristic_right_present[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->target_characteristic_right_present[b]) + { + pstr_gain_modifiers->target_characteristic_right_index[b] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + pstr_gain_modifiers->gain_scaling_flag[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->gain_scaling_flag[b]) + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_gain_modifiers->attn_scaling[b] = ((temp>>4)&0xf) * 0.125f; + pstr_gain_modifiers->ampl_scaling[b] = (temp&0xf) * 0.125f; + } + + pstr_gain_modifiers->gain_offset_flag[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->gain_offset_flag[b]) + { + FLOAT32 gain_offset; + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + sign = ((temp>>5)&1); + gain_offset = (1+(temp&0x1f)) * 0.25f; + + if (sign) + { + gain_offset = - gain_offset; + } + pstr_gain_modifiers->gain_offset[b] = gain_offset; + } + } + if (band_count == 1) + { + 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); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else if (version == 0) + { + WORD32 b, gain_scaling_flag, gain_offset_flag; + FLOAT32 attn_scaling = 1.0f, ampl_scaling = 1.0f, gain_offset = 0.0f; + + gain_scaling_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if(gain_scaling_flag) + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + attn_scaling = ((temp>>4)&0xf) * 0.125f; + ampl_scaling = (temp&0xf) * 0.125f; + + } + + gain_offset_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if(gain_offset_flag) + { + + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + sign = ((temp>>5)&1); + gain_offset = (1+(temp&0x1f)) * 0.25f; + + if (sign) + { + gain_offset = - gain_offset; + } + } + for (b=0; btarget_characteristic_left_present[b] = 0; + pstr_gain_modifiers->target_characteristic_right_present[b] = 0; + pstr_gain_modifiers->gain_scaling_flag[b] = gain_scaling_flag; + pstr_gain_modifiers->attn_scaling[b] = attn_scaling; + pstr_gain_modifiers->ampl_scaling[b] = ampl_scaling; + pstr_gain_modifiers->gain_offset_flag[b] = gain_offset_flag; + pstr_gain_modifiers->gain_offset[b] = gain_offset; + } + pstr_gain_modifiers->shape_filter_flag = 0; + } + return (0); +} + +WORD32 +impd_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + WORD32* gain_seq_idx, + ia_gain_set_params_struct* gain_set_params) +{ + WORD32 err = 0, i, temp; + + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + gain_set_params->gain_coding_profile = (temp>>4)&3; + gain_set_params->gain_interpolation_type = (temp>>3)&1; + gain_set_params->full_frame = (temp>>2)&1; + gain_set_params->time_alignment = (temp>>1)&1; + gain_set_params->time_delt_min_flag = temp&1; + + if(gain_set_params->time_delt_min_flag) + { + WORD32 time_delta_min; + time_delta_min = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + gain_set_params->time_delt_min_val = time_delta_min + 1; + } + + if (gain_set_params->gain_coding_profile == GAIN_CODING_PROFILE_CONSTANT) + { + gain_set_params->band_count = 1; + *gain_seq_idx = (*gain_seq_idx) + 1; + } + else + { + gain_set_params->band_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + if(gain_set_params->band_count>1) + { + gain_set_params->drc_band_type = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + for(i=0; iband_count; i++) + { + if (version == 0) { + *gain_seq_idx = (*gain_seq_idx) + 1; + } + else + { + WORD32 indexPresent; + indexPresent = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (indexPresent) + { + WORD32 bsIndex; + bsIndex = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + *gain_seq_idx = bsIndex; + } + else + { + *gain_seq_idx = (*gain_seq_idx) + 1; + } + } + gain_set_params->gain_params[i].gain_seq_idx = *gain_seq_idx; + err = impd_parse_gain_set_params_characteristics(it_bit_buff, version, &(gain_set_params->gain_params[i])); + if (err) return(err); + } + if (gain_set_params->drc_band_type) + { + for(i=1; iband_count; i++) + { + gain_set_params->gain_params[i].crossover_freq_idx = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + else + { + for(i=1; iband_count; i++) + { + gain_set_params->gain_params[i].start_subband_index = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + + } + + return(0); +} + +WORD32 +impd_sel_drc_coeff(ia_drc_config* drc_config, + WORD32 location, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc) +{ + WORD32 n; + WORD32 c1 = -1; + WORD32 c0 = -1; + for(n=0; ndrc_coefficients_drc_count; n++) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].drc_location == location) + { + if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].version == 0) + { + c0 = n; + } + else + { + c1 = n; + } + } + } + if (c1 >= 0) { + *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c1]); + } + else if (c0 >= 0) { + *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c0]); + } + else { + *str_p_loc_drc_coefficients_uni_drc = NULL; + } + return (0); +} + + + +WORD32 +impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set) +{ + WORD32 err = 0, i, k; + WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; + + k = 0; + loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] != UNIDRCLOUDEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + loudness_info_set->str_loudness_info_set_ext.ext_bit_size[k] = bit_size + 1; + + switch(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k]) + { + case UNIDRCLOUDEXT_EQ: + err = impd_parse_loud_info_set_ext_eq(it_bit_buff, loudness_info_set); + if (err) return(err); + break; + default: + for(i = 0; istr_loudness_info_set_ext.ext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); +} + +WORD32 +impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc) +{ + WORD32 err = 0, i, drc_frame_size, temp; + WORD32 gain_seq_idx = -1; + + str_p_loc_drc_coefficients_uni_drc->version = version; + if (version == 0) { + WORD32 gain_sequence_count = 0; + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; + str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; + + if (str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present == 1) + { + 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; + } + + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = 0; + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = 0; + str_p_loc_drc_coefficients_uni_drc->shape_filters_present = 0; + str_p_loc_drc_coefficients_uni_drc->gain_set_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = str_p_loc_drc_coefficients_uni_drc->gain_set_count; + for(i=0; igain_set_count; i++) + { + err = impd_parse_gain_set_params(it_bit_buff, version, &gain_seq_idx, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i])); + if (err) return (err); + + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_flag) + { + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) + { + /* drc time interval too big */ + return(PARAM_ERROR); + } + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values = ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val; + err = impd_init_tbls(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].str_tables)); + if (err) return (err); + } + gain_sequence_count += str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].band_count; + } + str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = gain_sequence_count; + } + else { + + ia_shape_filter_block_params_struct* pstr_shape_filter_block_params; + for (i=0; igain_set_params_index_for_gain_sequence[i] = -1; + } + + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; + str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; + + if (str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present == 1) + { + 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; + } + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present == 1) + { + str_p_loc_drc_coefficients_uni_drc->characteristic_left_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->characteristic_left_count; i++) + { + err = impd_parse_split_drc_characteristic(it_bit_buff, LEFT_SIDE, &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_left[i])); + if (err) return(err); + } + } + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present == 1) + { + str_p_loc_drc_coefficients_uni_drc->characteristic_right_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->characteristic_right_count; i++) + { + err = impd_parse_split_drc_characteristic(it_bit_buff, RIGHT_SIDE, &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_right[i])); + if (err) return(err); + } + } + str_p_loc_drc_coefficients_uni_drc->shape_filters_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_p_loc_drc_coefficients_uni_drc->shape_filters_present == 1) + { + str_p_loc_drc_coefficients_uni_drc->shape_num_filter = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->shape_num_filter; i++) + { + pstr_shape_filter_block_params = &(str_p_loc_drc_coefficients_uni_drc->str_shape_filter_block_params[i]); + pstr_shape_filter_block_params->lf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (pstr_shape_filter_block_params->lf_cut_filter_present == 1) + { + + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_lf_cut_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_lf_cut_params.filter_strength_index = temp&3; + } + pstr_shape_filter_block_params->lf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_shape_filter_block_params->lf_boost_filter_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_lf_boost_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_lf_boost_params.filter_strength_index = temp&3; + + } + pstr_shape_filter_block_params->hf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_shape_filter_block_params->hf_cut_filter_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_hfCutParams.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_hfCutParams.filter_strength_index = temp&3; + + } + pstr_shape_filter_block_params->hf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_shape_filter_block_params->hf_boost_filter_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_hf_boost_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_hf_boost_params.filter_strength_index = temp&3; + + } + } + } + + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = (temp>>6)&0x3f; + str_p_loc_drc_coefficients_uni_drc->gain_set_count = temp&0x3f; + + str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = str_p_loc_drc_coefficients_uni_drc->gain_set_count; + for(i=0; igain_set_count; i++) + { + err = impd_parse_gain_set_params(it_bit_buff, version, &gain_seq_idx, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i])); + if (err) return (err); + + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_flag) + { + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) + { + /* drc time interval too big */ + return(PARAM_ERROR); + } + str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values = ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val; + err = impd_init_tbls(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].str_tables)); + if (err) return (err); + } + } + + for(i=0; igain_set_count; i++) + { + WORD32 b; + for (b=0; bgain_set_params[i].band_count; b++) { + str_p_loc_drc_coefficients_uni_drc->gain_set_params_index_for_gain_sequence[str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[b].gain_seq_idx] = i; + } + } + } + return(0); +} + + +WORD32 +impd_drc_parse_instructions_basic(ia_bit_buf_struct* it_bit_buff, + ia_drc_instructions_basic_struct* str_drc_instructions_basic) +{ + //WORD32 err = 0; + WORD32 i, limiter_peak_target, temp; + WORD32 additional_dmix_id_present, additional_dmix_id_cnt; + + temp = impd_read_bits_buf(it_bit_buff, 18); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_instructions_basic->drc_set_id = (temp>>12)&0x3f; + str_drc_instructions_basic->drc_location = (temp>>8)&0xf; + str_drc_instructions_basic->downmix_id[0] = (temp>>1)&0x7f; + additional_dmix_id_present = temp&1; + str_drc_instructions_basic->dwnmix_id_count = 1; + + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instructions_basic->dwnmix_id_count = 1 + additional_dmix_id_cnt; + } + + + str_drc_instructions_basic->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ((str_drc_instructions_basic->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) + { + str_drc_instructions_basic->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instructions_basic->limiter_peak_target_present) + { + + limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->limiter_peak_target = - limiter_peak_target * 0.125f; + } + } + + str_drc_instructions_basic->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_instructions_basic->drc_set_target_loudness_value_upper = 0; + str_drc_instructions_basic->drc_set_target_loudness_value_lower = -63; + + if (str_drc_instructions_basic->drc_set_target_loudness_present == 1) + { + WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; + bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; + + str_drc_instructions_basic->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_drc_instructions_basic->drc_set_target_loudness_value_lower_present == 1) + { + bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; + } + } + + return(0); +} + +WORD32 +impd_dec_ducking_scaling(ia_bit_buf_struct* it_bit_buff, + WORD32* ducking_scaling_flag, + FLOAT32* p_ducking_scaling) +{ + WORD32 ducking_scaling_present, ducking_scaling, sigma, mu; + + ducking_scaling_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (ducking_scaling_present == 0) + { + *ducking_scaling_flag = 0; + *p_ducking_scaling = 1.0f; + } + else + { + *ducking_scaling_flag = 1; + ducking_scaling = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + + sigma = ducking_scaling >> 3; + mu = ducking_scaling & 0x7; + + if (sigma == 0) + { + *p_ducking_scaling = 1.0f + 0.125f * (1.0f + mu); + } + else + { + *p_ducking_scaling = 1.0f - 0.125f * (1.0f + mu); + } + } + return (0); +} + +WORD32 +impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_config* drc_config, + ia_drc_instructions_struct* str_drc_instruction_str) +{ + WORD32 err = 0, i, n, k, g, c, limiter_peak_target, idx; + WORD32 additional_dmix_id_present, additional_dmix_id_cnt; + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; + WORD32 ch_cnt; + WORD32 unique_idx[MAX_CHANNEL_COUNT]; + FLOAT32 unique_scaling[MAX_CHANNEL_COUNT]; + WORD32 match; + WORD32 dmix_id_present; + WORD32 repeat_parameters, repeat_parameters_cnt; + WORD32 ducking_sequence; + FLOAT32 factor; + + str_drc_instruction_str->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + if (version == 0) + { + str_drc_instruction_str->drc_set_complexity_level = DRC_COMPLEXITY_LEVEL_MAX; + } + else + { + str_drc_instruction_str->drc_set_complexity_level = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instruction_str->drc_location = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + dmix_id_present = 1; + if (version >= 1) + { + dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + if (dmix_id_present == 1) + { + str_drc_instruction_str->downmix_id[0] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (version >= 1) + { + str_drc_instruction_str->drc_apply_to_dwnmix = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + if (version == 0) + { + if (str_drc_instruction_str->downmix_id[0] == 0) + { + str_drc_instruction_str->drc_apply_to_dwnmix = 0; + } + else + { + str_drc_instruction_str->drc_apply_to_dwnmix = 1; + } + } + additional_dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instruction_str->dwnmix_id_count = 1 + additional_dmix_id_cnt; + } else + { + str_drc_instruction_str->dwnmix_id_count = 1; + } + } + else + { + str_drc_instruction_str->downmix_id[0] = 0; + str_drc_instruction_str->dwnmix_id_count = 1; + } + + str_drc_instruction_str->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ((str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) + { + str_drc_instruction_str->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instruction_str->limiter_peak_target_present) + { + limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->limiter_peak_target = - limiter_peak_target * 0.125f; + } + } + + str_drc_instruction_str->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_instruction_str->drc_set_target_loudness_value_upper = 0; + str_drc_instruction_str->drc_set_target_loudness_value_lower = -63; + + if (str_drc_instruction_str->drc_set_target_loudness_present == 1) + { + WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; + bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; + str_drc_instruction_str->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instruction_str->drc_set_target_loudness_value_lower_present == 1) + { + bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; + } + } + + + str_drc_instruction_str->depends_on_drc_set_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + + str_drc_instruction_str->no_independent_use = 0; + if (str_drc_instruction_str->depends_on_drc_set_present) + { + + str_drc_instruction_str->depends_on_drc_set = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + + str_drc_instruction_str->no_independent_use = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + if (version == 0) + { + str_drc_instruction_str->requires_eq = 0; + } + else + { + + str_drc_instruction_str->requires_eq = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + + err = impd_sel_drc_coeff(drc_config, str_drc_instruction_str->drc_location, &str_p_loc_drc_coefficients_uni_drc); + if (err) return (err); + + ch_cnt = drc_config->channel_layout.base_channel_count; + + for (c=0; cdrc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + c=0; + while (cerror) + return it_bit_buff->error; + str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; + impd_dec_ducking_scaling(it_bit_buff, + &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag), + &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling)); + + c++; + + repeat_parameters = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + + if (repeat_parameters == 1) + { + + repeat_parameters_cnt = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + repeat_parameters_cnt += 1; + for (k=0; kgain_set_index[c] = str_drc_instruction_str->gain_set_index[c-1]; + str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling_flag; + str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling; + c++; + } + } + } + if (c>ch_cnt) + { + return(UNEXPECTED_ERROR); + } + ducking_sequence = -1; + g = 0; + if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) + { + for (c=0; cgain_set_index[c]; + factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; + if (idx < 0) { + for (n=0; nchannel_group_of_ch[c] = n; + break; + } + } + if (match == 0) + { + unique_idx[g] = idx; + unique_scaling[g] = factor; + str_drc_instruction_str->channel_group_of_ch[c] = g; + g++; + } + } + else + { + if ((ducking_sequence > 0) && (ducking_sequence != idx)) + { + /* drc for ducking can have only one ducking sequence */ + return(UNEXPECTED_ERROR); + } + ducking_sequence = idx; + str_drc_instruction_str->channel_group_of_ch[c] = -1; + } + } + str_drc_instruction_str->num_drc_ch_groups = g; + if (ducking_sequence == -1) + { + /* ducking sequence not found */ + return(UNEXPECTED_ERROR); + } + } else if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_SELF) + { + for (c=0; cgain_set_index[c]; + factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; + if (idx >= 0) { + for (n=0; nchannel_group_of_ch[c] = n; + break; + } + } + if (match == 0) + { + unique_idx[g] = idx; + unique_scaling[g] = factor; + str_drc_instruction_str->channel_group_of_ch[c] = g; + g++; + } + } + else + { + str_drc_instruction_str->channel_group_of_ch[c] = -1; + } + } + str_drc_instruction_str->num_drc_ch_groups = g; + } + + for (g=0; gnum_drc_ch_groups; g++) + { + WORD32 set = (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) ? ducking_sequence : unique_idx[g]; + 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]; + if (unique_scaling[g] != 1.0f) + { + str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 1; + } + else + { + str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 0; + } + str_drc_instruction_str->band_count_of_ch_group[g] = 1; + } + } + else + { + if ( + ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && + (str_drc_instruction_str->downmix_id[0] != 0) && (str_drc_instruction_str->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_drc_instruction_str->dwnmix_id_count==1)) + { + for(i=0; idwnmix_instructions_count; i++) + { + if (str_drc_instruction_str->downmix_id[0] == drc_config->dwnmix_instructions[i].downmix_id) break; + } + if (i == drc_config->dwnmix_instructions_count) + { + /* dwnmix_instructions not found */ + return(UNEXPECTED_ERROR); + } + ch_cnt = drc_config->dwnmix_instructions[i].target_channel_count; + } + else if ( + ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && + ((str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1))) + { + ch_cnt = 1; + } + + c=0; + while (cerror) + return it_bit_buff->error; + + bs_gain_set_idx = (temp>>1)&0x7f; + repeat_gain_set_idx = temp&1; + + str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; + c++; + + if (repeat_gain_set_idx == 1) + { + + repeat_gain_set_idx_cnt = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + repeat_gain_set_idx_cnt += 1; + for (k=0; kgain_set_index[c] = bs_gain_set_idx - 1; + c++; + } + } + } + if (c>ch_cnt) + { + return(UNEXPECTED_ERROR); + } + + g = 0; + if ((str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1)) + { + WORD32 idx = str_drc_instruction_str->gain_set_index[0]; + if (idx >= 0) + { + unique_idx[0] = idx; + g = 1; + } + } + else { + for (c=0; cgain_set_index[c]; + match = 0; + if (idx>=0) + { + for (n=0; nchannel_group_of_ch[c] = n; + break; + } + } + if (match == 0) + { + unique_idx[g] = idx; + str_drc_instruction_str->channel_group_of_ch[c] = g; + g++; + } + } + else + { + str_drc_instruction_str->channel_group_of_ch[c] = -1; + } + } + } + + str_drc_instruction_str->num_drc_ch_groups = g; + for (g=0; gnum_drc_ch_groups; g++) + { + WORD32 set, band_count; + + set = unique_idx[g]; + str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; + + if (str_p_loc_drc_coefficients_uni_drc != NULL && set < str_p_loc_drc_coefficients_uni_drc->gain_set_count) + { + band_count = str_p_loc_drc_coefficients_uni_drc->gain_set_params[set].band_count; + } else + { + band_count = 1; + } + + err = impd_dec_gain_modifiers(it_bit_buff, version, band_count, &(str_drc_instruction_str->str_gain_modifiers_of_ch_group[g])); + if (err) return (err); + } + } + + return(0); +} +WORD32 +impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_loudness_info_struct* loudness_info) +{ + WORD32 err = 0, sample_peak_level, true_peak_level, i, temp; + + loudness_info->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (version >= 1) + { + loudness_info->eq_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + loudness_info->eq_set_id = 0; + } + + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info->downmix_id = (temp>>1)&0x7f; + loudness_info->sample_peak_level_present = temp&1; + + if(loudness_info->sample_peak_level_present) + { + + sample_peak_level = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (sample_peak_level == 0) + { + loudness_info->sample_peak_level_present = 0; + loudness_info->sample_peak_level = 0.0f; + } + else + { + loudness_info->sample_peak_level = 20.0f - sample_peak_level * 0.03125f; + } + } + + loudness_info->true_peak_level_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if(loudness_info->true_peak_level_present) + { + + true_peak_level = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (true_peak_level == 0) + { + loudness_info->true_peak_level_present = 0; + loudness_info->true_peak_level = 0.0f; + } + else + { + loudness_info->true_peak_level = 20.0f - true_peak_level * 0.03125f; + } + + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info->true_peak_level_measurement_system = (temp>>2)&0xf; + loudness_info->true_peak_level_reliability = temp&3; + } + + loudness_info->measurement_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + + for (i=0; imeasurement_count; i++) + { + err = impd_parse_loudness_measure(it_bit_buff, &(loudness_info->loudness_measure[i])); + if (err) return(err); + } + + return(0); +} \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_struct.h b/decoder/drc_src/impd_drc_struct.h new file mode 100644 index 0000000..83348a1 --- /dev/null +++ b/decoder/drc_src/impd_drc_struct.h @@ -0,0 +1,660 @@ +/****************************************************************************** + * + * 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_STURCT_H +#define IMPD_DRC_STURCT_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define METHOD_DEFINITION_UNKNOWN_OTHER 0 +#define METHOD_DEFINITION_PROGRAM_LOUDNESS 1 +#define METHOD_DEFINITION_ANCHOR_LOUDNESS 2 +#define METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE 3 +#define METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX 4 +#define METHOD_DEFINITION_SHORT_TERM_LOUDNESS_MAX 5 +#define METHOD_DEFINITION_LOUDNESS_RANGE 6 +#define METHOD_DEFINITION_MIXING_LEVEL 7 +#define METHOD_DEFINITION_ROOM_TYPE 8 +#define METHOD_DEFINITION_SHORT_TERM_LOUDNESS 9 + +#define MEASUREMENT_SYSTEM_UNKNOWN_OTHER 0 +#define MEASUREMENT_SYSTEM_EBU_R_128 1 +#define MEASUREMENT_SYSTEM_BS_1770_4 2 +#define MEASUREMENT_SYSTEM_BS_1770_3 MEASUREMENT_SYSTEM_BS_1770_4 +#define MEASUREMENT_SYSTEM_BS_1770_4_PRE_PROCESSING 3 +#define MEASUREMENT_SYSTEM_BS_1770_3_PRE_PROCESSING MEASUREMENT_SYSTEM_BS_1770_4_PRE_PROCESSING +#define MEASUREMENT_SYSTEM_USER 4 +#define MEASUREMENT_SYSTEM_EXPERT_PANEL 5 +#define MEASUREMENT_SYSTEM_BS_1771_1 6 +#define MEASUREMENT_SYSTEM_RESERVED_A 7 +#define MEASUREMENT_SYSTEM_RESERVED_B 8 +#define MEASUREMENT_SYSTEM_RESERVED_C 9 +#define MEASUREMENT_SYSTEM_RESERVED_D 10 +#define MEASUREMENT_SYSTEM_RESERVED_E 11 + +#define RELIABILITY_UKNOWN 0 +#define RELIABILITY_UNVERIFIED 1 +#define RELIABILITY_CEILING 2 +#define RELIABILITY_ACCURATE 3 + +#define EFFECT_BIT_COUNT 12 + +#define EFFECT_BIT_NONE (-1) +#define EFFECT_BIT_NIGHT 0x0001 +#define EFFECT_BIT_NOISY 0x0002 +#define EFFECT_BIT_LIMITED 0x0004 +#define EFFECT_BIT_LOWLEVEL 0x0008 +#define EFFECT_BIT_DIALOG 0x0010 +#define EFFECT_BIT_GENERAL_COMPR 0x0020 +#define EFFECT_BIT_EXPAND 0x0040 +#define EFFECT_BIT_ARTISTIC 0x0080 +#define EFFECT_BIT_CLIPPING 0x0100 +#define EFFECT_BIT_FADE 0x0200 +#define EFFECT_BIT_DUCK_OTHER 0x0400 +#define EFFECT_BIT_DUCK_SELF 0x0800 + +#define GAIN_CODING_PROFILE_REGULAR 0 +#define GAIN_CODING_PROFILE_FADING 1 +#define GAIN_CODING_PROFILE_CLIPPING 2 +#define GAIN_CODING_PROFILE_CONSTANT 3 +#define GAIN_CODING_PROFILE_DUCKING GAIN_CODING_PROFILE_CLIPPING + +#define GAIN_INTERPOLATION_TYPE_SPLINE 0 +#define GAIN_INTERPOLATION_TYPE_LINEAR 1 + +#define USER_METHOD_DEFINITION_DEFAULT 0 +#define USER_METHOD_DEFINITION_PROGRAM_LOUDNESS 1 +#define USER_METHOD_DEFINITION_ANCHOR_LOUDNESS 2 + +#define USER_MEASUREMENT_SYSTEM_DEFAULT 0 +#define USER_MEASUREMENT_SYSTEM_BS_1770_4 1 +#define USER_MEASUREMENT_SYSTEM_BS_1770_3 USER_MEASUREMENT_SYSTEM_BS_1770_4 +#define USER_MEASUREMENT_SYSTEM_USER 2 +#define USER_MEASUREMENT_SYSTEM_EXPERT_PANEL 3 +#define USER_MEASUREMENT_SYSTEM_RESERVED_A 4 +#define USER_MEASUREMENT_SYSTEM_RESERVED_B 5 +#define USER_MEASUREMENT_SYSTEM_RESERVED_C 6 +#define USER_MEASUREMENT_SYSTEM_RESERVED_D 7 +#define USER_MEASUREMENT_SYSTEM_RESERVED_E 8 + +#define USER_LOUDNESS_PREPROCESSING_DEFAULT 0 +#define USER_LOUDNESS_PREPROCESSING_OFF 1 +#define USER_LOUDNESS_PREPROCESSING_HIGHPASS 2 + +#define LOUDNESS_DEVIATION_MAX_DEFAULT 63 +#define LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT 1000 + +#define SHORT_TERM_LOUDNESS_TO_AVG 0 +#define MOMENTARY_LOUDNESS_TO_AVG 1 +#define TOP_OF_LOUDNESS_RANGE_TO_AVG 2 + +#define DRC_COMPLEXITY_LEVEL_MAX 0xF +#define EQ_COMPLEXITY_LEVEL_MAX 0xF +#define COMPLEXITY_LEVEL_SUPPORTED_TOTAL 20.0f + +#define COMPLEXITY_W_SUBBAND_EQ 2.5f +#define COMPLEXITY_W_FIR 0.4f +#define COMPLEXITY_W_IIR 5.0f +#define COMPLEXITY_W_MOD_TIME 1.0f +#define COMPLEXITY_W_MOD_SUBBAND 2.0f +#define COMPLEXITY_W_LAP 2.0f +#define COMPLEXITY_W_SHAPE 6.0f +#define COMPLEXITY_W_SPLINE 5.0f +#define COMPLEXITY_W_LINEAR 2.5f +#define COMPLEXITY_W_PARAM_DRC_FILT 5.0f +#define COMPLEXITY_W_PARAM_DRC_SUBBAND 5.0f +#define COMPLEXITY_W_PARAM_LIM_FILT 4.5f +#define COMPLEXITY_W_PARAM_DRC_ATTACK 136.0f + +#define LEFT_SIDE 0 +#define RIGHT_SIDE 1 + +#define CHARACTERISTIC_SIGMOID 0 +#define CHARACTERISTIC_NODES 1 +#define CHARACTERISTIC_PASS_THRU 2 + +#define GAINFORMAT_QMF32 0x1 +#define GAINFORMAT_QMFHYBRID39 0x2 +#define GAINFORMAT_QMF64 0x3 +#define GAINFORMAT_QMFHYBRID71 0x4 +#define GAINFORMAT_QMF128 0x5 +#define GAINFORMAT_QMFHYBRID135 0x6 +#define GAINFORMAT_UNIFORM 0x7 + +#define DRC_INPUT_LOUDNESS_TARGET (-31.0f) + +#define SHAPE_FILTER_TYPE_OFF 0 +#define SHAPE_FILTER_TYPE_LF_CUT 1 +#define SHAPE_FILTER_TYPE_LF_BOOST 2 +#define SHAPE_FILTER_TYPE_HF_CUT 3 +#define SHAPE_FILTER_TYPE_HF_BOOST 4 + +#define SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE 1583.8931924611f + +typedef struct { + WORD32 type; + FLOAT32 gain_offset; + FLOAT32 y1_bound; + FLOAT32 warped_gain_max; + FLOAT32 factor; + FLOAT32 coeff_sum; + FLOAT32 partial_coeff_sum; + FLOAT32 g_norm; + FLOAT32 a1; + FLOAT32 a2; + FLOAT32 b1; + FLOAT32 b2; + FLOAT32 audio_in_state_1[MAX_CHANNEL_COUNT]; + FLOAT32 audio_in_state_2[MAX_CHANNEL_COUNT]; + FLOAT32 audio_out_state_1[MAX_CHANNEL_COUNT]; + FLOAT32 audio_out_state_2[MAX_CHANNEL_COUNT]; +} ia_shape_filter_struct; + +typedef struct { + WORD32 shape_flter_block_flag; + FLOAT32 drc_gain_last; + ia_shape_filter_struct shape_filter[4]; +} shape_filter_block; + +typedef struct { + WORD32 level_estim_k_weighting_type; + WORD32 level_estim_integration_time_present; + WORD32 level_estim_integration_time; + WORD32 drc_curve_definition_type; + WORD32 drc_characteristic; + WORD32 node_count; + WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + WORD32 drc_gain_smooth_parameters_present; + WORD32 gain_smooth_attack_time_slow; + WORD32 gain_smooth_release_time_slow; + WORD32 gain_smooth_time_fast_present; + WORD32 gain_smooth_attack_time_fast; + WORD32 gain_smooth_release_time_fast; + WORD32 gain_smooth_threshold_present; + WORD32 gain_smooth_attack_threshold; + WORD32 gain_smooth_rel_threshold; + WORD32 gain_smooth_hold_off_count_present; + WORD32 gain_smooth_hold_off; + + WORD32 disable_paramteric_drc; +} ia_parametric_drc_type_feed_forward_struct; + +typedef struct { + WORD32 parametric_lim_threshold_present; + FLOAT32 parametric_lim_threshold; + WORD32 parametric_lim_attack; + WORD32 parametric_lim_release_present; + WORD32 parametric_lim_release; + WORD32 drc_characteristic; + + WORD32 disable_paramteric_drc; +} ia_parametric_drc_lim_struct; + +typedef struct { + WORD32 parametric_drc_id; + WORD32 parametric_drc_look_ahead_flag; + WORD32 parametric_drc_look_ahead; + WORD32 parametric_drc_preset_id_present; + WORD32 parametric_drc_preset_id; + WORD32 parametric_drc_type; + WORD32 len_bit_size; + ia_parametric_drc_type_feed_forward_struct str_parametric_drc_type_feed_forward; + ia_parametric_drc_lim_struct parametric_drc_lim; + + WORD32 drc_characteristic; + WORD32 disable_paramteric_drc; +} ia_parametric_drc_instructions_struct; + +typedef struct { + WORD32 parametric_drc_id; + WORD32 side_chain_config_type; + WORD32 downmix_id; + WORD32 level_estim_channel_weight_format; + FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; + WORD32 drc_input_loudness_present; + FLOAT32 drc_input_loudness; + + WORD32 ch_count_from_dwnmix_id; +} ia_parametric_drc_gain_set_params_struct; + +typedef struct { + WORD32 drc_location; + WORD32 parametric_drc_frame_size_format; + WORD32 parametric_drc_frame_size; + WORD32 parametric_drc_delay_max_present; + WORD32 parametric_drc_delay_max; + WORD32 reset_parametric_drc; + WORD32 parametric_drc_gain_set_count; + ia_parametric_drc_gain_set_params_struct str_parametric_drc_gain_set_params[SEQUENCE_COUNT_MAX]; +} ia_drc_coeff_parametric_drc_struct; + +typedef struct { + WORD32 base_channel_count; + WORD32 layout_signaling_present; + WORD32 defined_layout; + WORD32 speaker_position[SPEAKER_POS_COUNT_MAX]; +} ia_channel_layout_struct; + +typedef struct { + WORD32 downmix_id; + WORD32 target_channel_count; + WORD32 target_layout; + WORD32 downmix_coefficients_present; + FLOAT32 downmix_coefficient[DOWNMIX_COEFF_COUNT_MAX]; +} ia_downmix_instructions_struct; + +typedef struct { + WORD32 gain_seq_idx; + WORD32 drc_characteristic; + WORD32 drc_characteristic_present; + WORD32 drc_characteristic_format_is_cicp; + WORD32 drc_characteristic_left_index; + WORD32 drc_characteristic_right_index; + WORD32 crossover_freq_idx; + WORD32 start_subband_index; +} ia_gain_params_struct; + +typedef struct { + WORD32 ducking_scaling_flag; + FLOAT32 ducking_scaling; + FLOAT32 ducking_scaling_quantized; +} ia_ducking_modifiers_struct; + +typedef struct { + WORD32 target_characteristic_left_present [DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_left_index [DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_right_present[DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_right_index [DRC_BAND_COUNT_MAX]; + WORD32 shape_filter_flag; + WORD32 shape_filter_idx; + WORD32 gain_scaling_flag [BAND_COUNT_MAX]; + FLOAT32 attn_scaling [BAND_COUNT_MAX]; + FLOAT32 ampl_scaling[BAND_COUNT_MAX]; + WORD32 gain_offset_flag [BAND_COUNT_MAX]; + FLOAT32 gain_offset [BAND_COUNT_MAX]; +} ia_gain_modifiers_struct; + +typedef struct { + WORD32 gain_coding_profile; + WORD32 gain_interpolation_type; + WORD32 full_frame; + WORD32 time_alignment; + WORD32 time_delt_min_flag; + WORD32 time_delt_min_val; + WORD32 band_count; + WORD32 drc_band_type; + ia_gain_params_struct gain_params[BAND_COUNT_MAX]; + + WORD32 num_gain_max_values; + ia_tables_struct str_tables; +} ia_gain_set_params_struct; + +#define SPLIT_CHARACTERISTIC_NODE_COUNT_MAX 4 +typedef struct { + WORD32 characteristic_format; + FLOAT32 in_out_ratio; + FLOAT32 gain; + FLOAT32 exp; + WORD32 flip_sign; + WORD32 characteristic_node_count; + FLOAT32 node_level[SPLIT_CHARACTERISTIC_NODE_COUNT_MAX+1]; + FLOAT32 node_gain [SPLIT_CHARACTERISTIC_NODE_COUNT_MAX+1]; +} ia_split_drc_characteristic_struct; + +typedef struct { + WORD32 corner_freq_index; + WORD32 filter_strength_index; +} ia_shape_filter_params_struct; + +typedef struct { + WORD32 lf_cut_filter_present; + ia_shape_filter_params_struct str_lf_cut_params; + WORD32 lf_boost_filter_present; + ia_shape_filter_params_struct str_lf_boost_params; + WORD32 hf_cut_filter_present; + ia_shape_filter_params_struct str_hfCutParams; + WORD32 hf_boost_filter_present; + ia_shape_filter_params_struct str_hf_boost_params; +} ia_shape_filter_block_params_struct; + +typedef struct { + WORD32 drc_location; + WORD32 drc_characteristic; +} ia_drc_coefficients_basic_struct; + +typedef struct { + WORD32 version; + WORD32 drc_location; + WORD32 drc_frame_size_present; + WORD32 drc_frame_size; + WORD32 gain_set_count; + ia_gain_set_params_struct gain_set_params[GAIN_SET_COUNT_MAX]; + WORD32 drc_characteristic_left_present; + WORD32 characteristic_left_count; + ia_split_drc_characteristic_struct str_split_characteristic_left [SPLIT_CHARACTERISTIC_COUNT_MAX]; + WORD32 drc_characteristic_right_present; + WORD32 characteristic_right_count; + ia_split_drc_characteristic_struct str_split_characteristic_right[SPLIT_CHARACTERISTIC_COUNT_MAX]; + WORD32 shape_filters_present; + WORD32 shape_num_filter; + ia_shape_filter_block_params_struct str_shape_filter_block_params[SHAPE_FILTER_COUNT_MAX+1]; + WORD32 gain_sequence_count; + WORD32 gain_set_params_index_for_gain_sequence[SEQUENCE_COUNT_MAX]; + WORD32 gain_set_count_plus; + +} ia_uni_drc_coeffs_struct; + +typedef struct { + WORD32 drc_set_id; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 drc_set_effect; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + WORD32 drc_set_target_loudness_present; + WORD32 drc_set_target_loudness_value_upper; + WORD32 drc_set_target_loudness_value_lower_present; + WORD32 drc_set_target_loudness_value_lower; +} ia_drc_instructions_basic_struct; + +typedef struct { + WORD32 drc_set_id; + WORD32 drc_set_complexity_level; + WORD32 requires_eq; + WORD32 drc_apply_to_dwnmix; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 depends_on_drc_set_present; + WORD32 depends_on_drc_set; + WORD32 no_independent_use; + WORD32 drc_set_effect; + WORD32 gain_set_index[MAX_CHANNEL_COUNT]; + ia_gain_modifiers_struct str_gain_modifiers_of_ch_group[CHANNEL_GROUP_COUNT_MAX]; + ia_ducking_modifiers_struct str_ducking_modifiers_for_channel[MAX_CHANNEL_COUNT]; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + WORD32 drc_set_target_loudness_present; + WORD32 drc_set_target_loudness_value_upper; + WORD32 drc_set_target_loudness_value_lower_present; + WORD32 drc_set_target_loudness_value_lower; + + WORD32 audio_num_chan; + WORD32 num_drc_ch_groups; + WORD32 gain_set_index_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 band_count_of_ch_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_interpolation_type_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 time_delta_min_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 time_alignment_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + ia_ducking_modifiers_struct str_ducking_modifiers_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 channel_group_of_ch[MAX_CHANNEL_COUNT]; + WORD32 num_chan_per_ch_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_element_count; + WORD32 multiband_audio_sig_count; + WORD32 ch_group_parametric_drc_flag[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_set_idx_of_ch_group_parametric_drc[CHANNEL_GROUP_COUNT_MAX]; + WORD32 parametric_drc_look_ahead_samples[CHANNEL_GROUP_COUNT_MAX]; + WORD32 parametric_drc_look_ahead_samples_max; +} ia_drc_instructions_struct; + +typedef struct { + WORD32 method_def; + FLOAT32 method_val; + WORD32 measurement_system; + WORD32 reliability; +} ia_loudness_measure_struct; + +typedef struct { + WORD32 drc_set_id; + WORD32 eq_set_id; + WORD32 downmix_id; + WORD32 sample_peak_level_present; + FLOAT32 sample_peak_level; + WORD32 true_peak_level_present; + FLOAT32 true_peak_level; + WORD32 true_peak_level_measurement_system; + WORD32 true_peak_level_reliability; + WORD32 measurement_count; + ia_loudness_measure_struct loudness_measure[MEASUREMENT_COUNT_MAX]; +} ia_loudness_info_struct; + +typedef struct { + WORD32 loud_eq_set_id; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id [DOWNMIX_ID_COUNT_MAX]; + WORD32 drc_set_id_count; + WORD32 drc_set_id [DRC_SET_ID_COUNT_MAX]; + WORD32 eq_set_id_count; + WORD32 eq_set_id [EQ_SET_ID_COUNT_MAX]; + WORD32 loudness_after_drc; + WORD32 loudness_after_eq; + WORD32 loud_eq_gain_sequence_count; + WORD32 gain_seq_idx [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_format_is_cicp [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_left_index [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_right_index [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 frequency_range_index [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + FLOAT32 loud_eq_scaling [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + FLOAT32 loud_eq_offset [LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; +} ia_loud_eq_instructions_struct; + +typedef struct { + WORD32 filt_ele_idx; + WORD32 filt_ele_gain_flag; + FLOAT32 filt_ele_gain; +} ia_filt_ele_struct; + +typedef struct { + WORD32 filter_element_count; + ia_filt_ele_struct str_filter_element[FILTER_ELEMENT_COUNT_MAX]; +} ia_filt_block_struct; + +typedef struct { + WORD32 eq_filter_format; + WORD32 bs_real_zero_radius_one_count; + WORD32 real_zero_count; + WORD32 generic_zero_count; + WORD32 real_pole_count; + WORD32 cmplx_pole_count; + WORD32 zero_sign [REAL_ZERO_RADIUS_ONE_COUNT_MAX]; + FLOAT32 real_zero_radius [REAL_ZERO_COUNT_MAX]; + FLOAT32 generic_zero_radius [COMPLEX_ZERO_COUNT_MAX]; + FLOAT32 generic_zero_angle [COMPLEX_ZERO_COUNT_MAX]; + FLOAT32 real_pole_radius [REAL_POLE_COUNT_MAX]; + FLOAT32 complex_pole_radius [COMPLEX_POLE_COUNT_MAX]; + FLOAT32 complex_pole_angle [COMPLEX_POLE_COUNT_MAX]; + WORD32 fir_filt_order; + WORD32 fir_symmetry; + FLOAT32 fir_coeff [FIR_ORDER_MAX/2]; +} ia_unique_td_filt_element; + +typedef struct { + WORD32 num_eq_nodes; + FLOAT32 eq_slope [EQ_NODE_COUNT_MAX]; + WORD32 eq_freq_delta [EQ_NODE_COUNT_MAX]; + FLOAT32 eq_gain_initial; + FLOAT32 eq_gain_delta [EQ_NODE_COUNT_MAX]; +} ia_eq_subband_gain_spline_struct; + +typedef struct { + FLOAT32 eq_subband_gain [EQ_SUBBAND_GAIN_COUNT_MAX]; +} ia_eq_subband_gain_vector; + +typedef struct { + WORD32 eq_delay_max_present; + WORD32 eq_delay_max; + WORD32 unique_filter_block_count; + ia_filt_block_struct str_filter_block [FILTER_BLOCK_COUNT_MAX]; + WORD32 unique_td_filter_element_count; + ia_unique_td_filt_element unique_td_filt_ele [FILTER_ELEMENT_COUNT_MAX]; + WORD32 unique_eq_subband_gains_count; + WORD32 eq_subband_gain_representation; + WORD32 eq_subband_gain_format; + WORD32 eq_subband_gain_count; + ia_eq_subband_gain_spline_struct str_eq_subband_gain_spline [UNIQUE_SUBBAND_GAIN_COUNT_MAX]; + ia_eq_subband_gain_vector str_eq_subband_gain_vector [UNIQUE_SUBBAND_GAIN_COUNT_MAX]; +} ia_eq_coeff_struct; + +typedef struct { + WORD32 filter_block_count; + WORD32 filter_block_index[EQ_FILTER_BLOCK_COUNT_MAX]; +} ia_filter_block_refs_struct; + +typedef struct { + WORD32 eq_cascade_gain_present [EQ_CHANNEL_GROUP_COUNT_MAX]; + FLOAT32 eq_cascade_gain [EQ_CHANNEL_GROUP_COUNT_MAX]; + ia_filter_block_refs_struct str_filter_block_refs [EQ_CHANNEL_GROUP_COUNT_MAX]; + WORD32 eq_phase_alignment_present; + WORD32 eq_phase_alignment [EQ_CHANNEL_GROUP_COUNT_MAX][EQ_CHANNEL_GROUP_COUNT_MAX]; +} ia_td_filter_cascade_struct; + +typedef struct { + WORD32 eq_set_id; + WORD32 eq_set_complexity_level; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 eq_apply_to_downmix; + WORD32 drc_set_id_count; + WORD32 drc_set_id[DRC_SET_ID_COUNT_MAX]; + WORD32 eq_set_purpose; + WORD32 depends_on_eq_set_present; + WORD32 depends_on_eq_set; + WORD32 no_independent_eq_use; + WORD32 eq_channel_count; + WORD32 eq_ch_group_count; + WORD32 eq_ch_group_of_channel [MAX_CHANNEL_COUNT]; + WORD32 td_filter_cascade_present; + ia_td_filter_cascade_struct str_td_filter_cascade; + WORD32 subband_gains_present; + WORD32 subband_gains_index [EQ_CHANNEL_GROUP_COUNT_MAX]; + WORD32 eq_transition_duration_present; + WORD32 eq_transition_duration; +} ia_eq_instructions_struct; + +typedef struct { + WORD32 drc_config_ext_type[EXT_COUNT_MAX]; + WORD32 ext_bit_size[EXT_COUNT_MAX-1]; + + WORD32 parametric_drc_present; + ia_drc_coeff_parametric_drc_struct str_drc_coeff_param_drc; + WORD32 parametric_drc_instructions_count; + ia_parametric_drc_instructions_struct str_parametric_drc_instructions[PARAM_DRC_INSTRUCTIONS_COUNT_MAX]; + WORD32 drc_extension_v1_present; + WORD32 loud_eq_instructions_flag; + WORD32 loud_eq_instructions_count; + ia_loud_eq_instructions_struct loud_eq_instructions [LOUD_EQ_INSTRUCTIONS_COUNT_MAX]; + WORD32 eq_flag; + ia_eq_coeff_struct str_eq_coeff; + WORD32 eq_instructions_count; + ia_eq_instructions_struct str_eq_instructions [EQ_INSTRUCTIONS_COUNT_MAX]; +} ia_drc_config_ext; + +typedef struct ia_drc_config{ + WORD32 sample_rate_present; + WORD32 sampling_rate; + WORD32 dwnmix_instructions_count; + WORD32 drc_coefficients_drc_count; + WORD32 drc_instructions_uni_drc_count; + WORD32 drc_instructions_count_plus; + WORD32 drc_description_basic_present; + WORD32 drc_coefficients_basic_count; + WORD32 drc_instructions_basic_count; + WORD32 drc_config_ext_present; + WORD32 apply_drc; + ia_drc_config_ext str_drc_config_ext; + ia_drc_coefficients_basic_struct str_drc_coefficients_basic[DRC_COEFF_COUNT_MAX]; + ia_drc_instructions_basic_struct str_drc_instructions_basic[DRC_INSTRUCTIONS_COUNT_MAX]; + ia_uni_drc_coeffs_struct str_p_loc_drc_coefficients_uni_drc[DRC_COEFF_COUNT_MAX]; + ia_drc_instructions_struct str_drc_instruction_str[DRC_INSTRUCTIONS_COUNT_MAX]; + ia_channel_layout_struct channel_layout; + ia_downmix_instructions_struct dwnmix_instructions[DOWNMIX_INSTRUCTION_COUNT_MAX]; +} ia_drc_config; + +typedef struct { + WORD32 loudness_info_set_ext_type[EXT_COUNT_MAX]; + WORD32 ext_bit_size[EXT_COUNT_MAX-1]; +} ia_loudness_info_set_ext_struct; + +typedef struct ia_drc_loudness_info_set_struct{ + WORD32 loudness_info_album_count; + WORD32 loudness_info_count; + WORD32 loudness_info_set_ext_present; + ia_loudness_info_struct str_loudness_info_album[LOUDNESS_INFO_COUNT_MAX]; + ia_loudness_info_struct loudness_info[LOUDNESS_INFO_COUNT_MAX]; + ia_loudness_info_set_ext_struct str_loudness_info_set_ext; +} ia_drc_loudness_info_set_struct; + +typedef struct { + FLOAT32 loc_db_gain; + FLOAT32 slope; + WORD32 time; +} ia_node_struct; + +typedef struct { + WORD32 drc_gain_coding_mode; + WORD32 num_nodes; + ia_node_struct str_node[NODE_COUNT_MAX]; +} ia_spline_nodes_struct; + +typedef struct { + ia_spline_nodes_struct str_spline_nodes [1]; +} ia_drc_gain_sequence_struct; + +typedef struct { + WORD32 uni_drc_gain_ext_type[EXT_COUNT_MAX]; + WORD32 ext_bit_size[EXT_COUNT_MAX-1]; +} ia_uni_drc_gain_ext_struct; + +typedef struct ia_drc_gain_struct{ + WORD32 num_drc_gain_sequences; + ia_drc_gain_sequence_struct drc_gain_sequence[SEQUENCE_COUNT_MAX]; + WORD32 uni_drc_gain_ext_flag; + ia_uni_drc_gain_ext_struct uni_drc_gain_ext; +} ia_drc_gain_struct; + +typedef struct { + WORD32 delta_tmin_default; + WORD32 drc_frame_size; + WORD32 num_gain_values_max_default; + WORD32 delay_mode; + WORD32 lfe_channel_map_count; + WORD32 lfe_channel_map[MAX_CHANNEL_COUNT]; +} ia_drc_params_bs_dec_struct; + +typedef struct ia_drc_bits_dec_struct +{ + + ia_tables_struct tables_default; + ia_drc_params_bs_dec_struct ia_drc_params_struct; + +}ia_drc_bits_dec_struct; + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_tables.c b/decoder/drc_src/impd_drc_tables.c new file mode 100644 index 0000000..8a9481a --- /dev/null +++ b/decoder/drc_src/impd_drc_tables.c @@ -0,0 +1,120 @@ +/****************************************************************************** + * + * 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 +#include + +#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< (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/drc_src/impd_drc_uni_dec.h b/decoder/drc_src/impd_drc_uni_dec.h new file mode 100644 index 0000000..878a3bc --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_dec.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * + * 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_DEC_H +#define IMPD_DRC_UNI_DEC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +WORD32 impd_select_drc_coefficients(ia_drc_config* drc_config, + ia_uni_drc_coeffs_struct** drc_coefficients_drc, + WORD32* drc_coefficients_selected); + +WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, + ia_drc_params_struct* ia_drc_params_struct, + WORD32 audio_num_chan, + WORD32 drc_set_id_selected, + WORD32 downmix_id_selected, + ia_filter_banks_struct* ia_filter_banks_struct, + ia_overlap_params_struct* pstr_overlap_params + ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_eq.h b/decoder/drc_src/impd_drc_uni_eq.h new file mode 100644 index 0000000..963897a --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_eq.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * + * 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_EQ_H +#define IMPD_DRC_UNI_EQ_H + +#ifndef COMPILE_FOR_DRC_ENCODER +#endif + +#define EQ_CHANNEL_COUNT_MAX 8 +#define EQ_AUDIO_DELAY_MAX 1024 +#define EQ_FIR_FILTER_SIZE_MAX 128 +#define EQ_SUBBAND_COUNT_MAX 256 +#define EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT_MAX 32 +#define EQ_INTERMEDIATE_PARAMETER_COUNT_MAX 32 +#define EQ_FILTER_SECTION_COUNT_MAX 8 +#define EQ_FILTER_ELEMENT_COUNT_MAX 4 +#define EQ_FILTER_COUNT_MAX 4 +#define MATCHING_PHASE_FILTER_COUNT_MAX 32 + +#define EQ_FILTER_DOMAIN_NONE 0 +#define EQ_FILTER_DOMAIN_TIME (1<<0) +#define EQ_FILTER_DOMAIN_SUBBAND (1<<1) + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_gain_dec.h b/decoder/drc_src/impd_drc_uni_gain_dec.h new file mode 100644 index 0000000..c01cd6e --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_gain_dec.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * 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_GAIN_DEC_H +#define IMPD_DRC_UNI_GAIN_DEC_H + + + + + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + ia_node_struct str_node; + ia_node_struct prev_node; + FLOAT32 lpcm_gains[2 * AUDIO_CODEC_FRAME_SIZE_MAX + MAX_SIGNAL_DELAY]; +} ia_interp_buf_struct; + +typedef struct { +#if DRC_GAIN_DEBUG_FILE + FILE* f_gain_debug; +#endif + WORD32 buf_interpolation_count; + ia_interp_buf_struct* buf_interpolation; +} ia_gain_buffer_struct; + +typedef struct { + ia_gain_buffer_struct pstr_gain_buf[SEL_DRC_COUNT]; +} ia_drc_gain_buffers_struct; + +typedef struct { + WORD32 gain_interpolation_type; + WORD32 gain_modification_flag; + WORD32 ducking_flag; + WORD32 clipping_flag; + ia_ducking_modifiers_struct* pstr_ducking_modifiers; + ia_gain_modifiers_struct* pstr_gain_modifiers; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + FLOAT32 loudness_normalization_gain_db; + WORD32 delta_tmin; + WORD32 characteristic_index; + FLOAT32 compress; + FLOAT32 boost; +} ia_interp_params_struct; + + +typedef struct { + WORD32 drc_instructions_index; + WORD32 drc_coeff_idx; + WORD32 dwnmix_instructions_index; +} ia_sel_drc_struct; + +typedef struct { + WORD32 sample_rate; + WORD32 delta_tmin_default; + WORD32 drc_frame_size; + WORD32 delay_mode; + WORD32 sub_band_domain_mode; + WORD32 gain_delay_samples; + WORD32 audio_delay_samples; + WORD32 drc_set_counter; + WORD32 multiband_sel_drc_idx; + + ia_sel_drc_struct sel_drc_array[SEL_DRC_COUNT]; + +} ia_drc_params_struct; + +WORD32 +impd_gain_buf_init(WORD32 index, + WORD32 gain_element_count, + WORD32 drc_frame_size, + ia_gain_buffer_struct* pstr_gain_buf); + +WORD32 +impd_advance_buf(WORD32 drc_frame_size, + ia_gain_buffer_struct* pstr_gain_buf); + + +WORD32 +impd_map_gain ( + FLOAT32 gain_in_db, + FLOAT32* gain_out_db); + +WORD32 +impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, + WORD32 drc_band, + FLOAT32 loc_db_gain, + FLOAT32 in_param_db_slope, + FLOAT32* out_param_lin_gain, + FLOAT32* out_param_lin_slope); + +WORD32 +impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, + WORD32 drc_band, + WORD32 gain_step_tdomain, + FLOAT32 gain0, + FLOAT32 gain1, + FLOAT32 slope0, + FLOAT32 slope1, + FLOAT32* result); + +WORD32 +impd_concatenate_segments(WORD32 drc_frame_size, + WORD32 drc_band, + ia_interp_params_struct* interp_params_str, + ia_spline_nodes_struct* str_spline_nodes, + ia_interp_buf_struct* buf_interpolation); + + + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_interface.h b/decoder/drc_src/impd_drc_uni_interface.h new file mode 100644 index 0000000..54ba750 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_interface.h @@ -0,0 +1,116 @@ +/****************************************************************************** + * + * 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_INTERFACE_H +#define IMPD_DRC_UNI_INTERFACE_H + + +typedef struct { + WORD32 ext_size_bits; + WORD32 ext_bit_size; + WORD32 uni_drc_interface_ext_type; +} ia_specific_interface_extension_struct; + +typedef struct { + WORD32 interface_ext_count; + ia_specific_interface_extension_struct specific_interface_ext[EXT_COUNT_MAX]; +} ia_drc_uni_interface_ext_struct; + +typedef struct { + WORD32 change_compress; + WORD32 change_boost; + FLOAT32 compress; + FLOAT32 boost; + WORD32 change_drc_characteristic_target; + WORD32 drc_characteristic_target; +} ia_drc_parameter_interface_struct; + +typedef struct { + WORD32 dynamic_range_control_on; + WORD32 num_drc_feature_requests; + WORD32 drc_feature_req_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_num_drc_effects[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 desired_num_drc_effects_of_requested[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_effect_type[MAX_NUM_DRC_FEATURE_REQUESTS][MAX_NUM_DRC_EFFECT_TYPE_REQUESTS]; + WORD32 requested_dyn_rng_measurement_type[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_dyn_range_is_single_val_flag[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_value[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_min_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + FLOAT32 requested_dyn_range_max_val[MAX_NUM_DRC_FEATURE_REQUESTS]; + WORD32 requested_drc_characteristic[MAX_NUM_DRC_FEATURE_REQUESTS]; +} ia_dyn_rng_ctrl_interface_struct; + +typedef struct { + WORD32 album_mode; + WORD32 peak_limiter; + WORD32 change_loudness_deviation_max; + WORD32 loudness_deviation_max; + WORD32 change_loudness_measur_method; + WORD32 loudness_measurement_method; + WORD32 change_loudness_measur_system; + WORD32 loudness_measurement_system; + WORD32 change_loudness_measur_pre_proc; + WORD32 loudness_measurement_pre_proc; + WORD32 change_device_cut_off_freq; + WORD32 device_cut_off_frequency; + WORD32 change_loudness_norm_gain_db_max; + FLOAT32 loudness_norm_gain_db_max; + WORD32 change_loudness_norm_gain_modification_db; + FLOAT32 loudness_norm_gain_modification_db; + WORD32 change_output_peak_level_max; + FLOAT32 output_peak_level_max; +} ia_loudness_norm_parameter_interface_struct; + +typedef struct { + WORD32 loudness_normalization_on; + FLOAT32 target_loudness; +} ia_loudness_norm_ctrl_interface_struct; + +typedef struct { + WORD32 target_config_request_type; + WORD32 num_downmix_id_requests; + WORD32 requested_dwnmix_id[MAX_NUM_DOWNMIX_ID_REQUESTS]; + WORD32 requested_target_layout; + WORD32 requested_target_ch_count; +} ia_system_interface_struct; + +typedef struct { + WORD32 interface_signat_type; + WORD32 interface_signat_data_len; + UWORD32 interface_signat_data[MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE*8]; +} ia_drc_uni_interface_signat_struct; + +typedef struct ia_drc_interface_struct{ + WORD32 interface_signat_flag; + WORD32 system_interface_flag; + WORD32 loudness_norm_ctrl_interface_flag; + WORD32 loudness_norm_parameter_interface_flag; + WORD32 drc_interface_flag; + WORD32 drc_parameter_interface_flag; + WORD32 drc_uni_interface_ext_flag; + ia_drc_uni_interface_signat_struct drc_uni_interface_signature; + ia_system_interface_struct system_interface; + ia_loudness_norm_ctrl_interface_struct loudness_norm_ctrl_interface; + ia_loudness_norm_parameter_interface_struct loudness_norm_param_interface; + ia_dyn_rng_ctrl_interface_struct drc_ctrl_interface; + ia_drc_parameter_interface_struct drc_parameter_interface; + ia_drc_uni_interface_ext_struct drc_uni_interface_ext; +} ia_drc_interface_struct; + +#endif diff --git a/decoder/drc_src/impd_drc_uni_loud_eq.h b/decoder/drc_src/impd_drc_uni_loud_eq.h new file mode 100644 index 0000000..2c3d3f0 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_loud_eq.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * 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_LOUD_EQ_H +#define IMPD_DRC_UNI_LOUD_EQ_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_multi_band.h b/decoder/drc_src/impd_drc_uni_multi_band.h new file mode 100644 index 0000000..7eb677e --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_multi_band.h @@ -0,0 +1,72 @@ +/****************************************************************************** + * + * 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_MULTI_BAND_H +#define IMPD_DRC_UNI_MULTI_BAND_H + +#define DRC_SUBBAND_COUNT_WITH_AUDIO_CODEC_FILTERBANK_MAX FILTER_BANK_PARAMETER_COUNT + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + FLOAT32 overlap_weight[AUDIO_CODEC_SUBBAND_COUNT_MAX]; +} ia_band_overlap_params_struct; + +typedef struct { + ia_band_overlap_params_struct str_band_overlap_params[BAND_COUNT_MAX]; +} ia_group_overlap_params_struct; + +typedef struct { + ia_group_overlap_params_struct str_group_overlap_params[CHANNEL_GROUP_COUNT_MAX]; +} ia_overlap_params_struct; + + + +WORD32 +impd_fcenter_norm_sb_init(WORD32 num_subbands, + FLOAT32* fcenter_norm_subband); + +WORD32 +impd_generate_slope (WORD32 num_subbands, + FLOAT32* fcenter_norm_subband, + FLOAT32 fcross_norm_lo, + FLOAT32 fcross_norm_hi, + FLOAT32* response); + +WORD32 +impd_generate_overlap_weights (WORD32 num_drc_bands, + WORD32 drc_band_type, + ia_gain_params_struct* gain_params, + WORD32 dec_subband_count, + ia_group_overlap_params_struct* pstr_group_overlap_params); + +WORD32 +impd_init_overlap_weight ( ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc, + ia_drc_instructions_struct* str_drc_instruction_str, + WORD32 sub_band_domain_mode, + ia_overlap_params_struct* pstr_overlap_params); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_parser.h b/decoder/drc_src/impd_drc_uni_parser.h new file mode 100644 index 0000000..f7c7f19 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_parser.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * + * 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_PARSER_H +#define IMPD_DRC_UNI_PARSER_H + +WORD32 +impd_dec_ducking_scaling(ia_bit_buf_struct* it_bit_buff, + WORD32* ducking_scaling_flag, + FLOAT32* ducking_scaling); + +WORD32 +impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_loudness_info_struct* loudness_info); + + +WORD32 +impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* loudness_info_set); + +WORD32 +impd_sel_drc_coeff(ia_drc_config* drc_config, + WORD32 location, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_drc_parse_instructions_basic(ia_bit_buf_struct* it_bit_buff, + ia_drc_config* drc_config, + ia_drc_instructions_basic_struct* str_drc_instructions_basic); + +WORD32 +impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_config* drc_config, + ia_channel_layout_struct* channel_layout, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_instructions_struct* str_drc_instruction_str); + + +WORD32 +impd_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + WORD32* gain_seq_idx, + ia_gain_set_params_struct* gain_set_params); + +WORD32 +impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout, + ia_downmix_instructions_struct* dwnmix_instructions); + + +WORD32 +impd_parse_drc_config( + ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config + ); + +WORD32 +impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_loudness_info_set_struct* loudness_info_set); + +WORD32 +impd_parse_drc_gain_sequence( + ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_drc_gain_sequence_struct* drc_gain_sequence); + +WORD32 +impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, + ia_uni_drc_gain_ext_struct* uni_drc_gain_ext); + +WORD32 impd_drc_uni_gain_read( + ia_bit_buf_struct* it_bit_buff, + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_drc_config* drc_config, + ia_drc_gain_struct* pstr_uni_drc_gain); + + +#endif diff --git a/decoder/drc_src/impd_drc_uni_process_audio.h b/decoder/drc_src/impd_drc_uni_process_audio.h new file mode 100644 index 0000000..07b2749 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_process_audio.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * 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_PROCESS_AUDIO_H +#define IMPD_DRC_UNI_PROCESS_AUDIO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + WORD32 multiband_audio_sig_count; + WORD32 frame_size; + FLOAT32** non_interleaved_audio; +} ia_audio_band_buffer_struct; + + + +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_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, + FLOAT32* audio_io_buf[], + ia_audio_band_buffer_struct* audio_band_buffer, + ia_filter_banks_struct* ia_filter_banks_struct, + const WORD32 passThru); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h b/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h new file mode 100644 index 0000000..92a158f --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h @@ -0,0 +1,145 @@ +/****************************************************************************** + * + * 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_SEL_PROC_DRC_SET_SEL_H +#define IMPD_DRC_UNI_SEL_PROC_DRC_SET_SEL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH (1<<0) +#define SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT (1<<1) + +typedef struct { + WORD32 drc_instructions_index; + WORD32 downmix_id_request_index; + WORD32 eq_set_id; + FLOAT32 output_peak_level; + FLOAT32 loudness_norm_db_gain_adjusted; + FLOAT32 output_loudness; + FLOAT32 mixing_level; + WORD32 selection_flags; +} ia_selection_candidate_info_struct; + + +WORD32 +impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); + +WORD32 +impd_map_requested_effect_bit_idx(WORD32 requested_effect_type, + WORD32* effect_bit_idx); + +WORD32 +impd_get_fading_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_ducking_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_selected_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32 drc_set_id_selected); + +WORD32 +impd_get_dependent_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_get_dependent_drc_instructions(const ia_drc_config* drc_config, + const ia_drc_instructions_struct* str_drc_instruction_str, + ia_drc_instructions_struct** ppstr_drc_instructions_dependent); + + +WORD32 +impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_effect_type_attempt(ia_drc_config* pstr_drc_config, + WORD32 requested_effect_type, + WORD32 stateRequested, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_effect_types(ia_drc_config* pstr_drc_config, + WORD32 total_effect_type_requested, + WORD32 desired_effect_type_requested, + WORD32* requested_effect_type, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32 num_drc_requests, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, + WORD32 requested_drc_characteristic, + WORD32* match_found_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 +impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, + WORD32 requested_drc_characteristic, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +VOID impd_select_drc_coeff3(ia_drc_config* drc_config, + ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); + +WORD32 +impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + WORD32 restrict_to_drc_with_album_loudness, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info); + +WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info +); + +WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, + WORD32 eq_set_purpose_requested, + WORD32* eq_set_id_valid_flag, + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ); + +WORD32 +impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + WORD32* drc_set_id_selected + ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_init.h b/decoder/drc_src/impd_drc_uni_sel_proc_init.h new file mode 100644 index 0000000..82565b1 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_sel_proc_init.h @@ -0,0 +1,42 @@ +/****************************************************************************** + * + * 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_SEL_PROC_INIT_H +#define IMPD_DRC_UNI_SEL_PROC_INIT_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +WORD32 +impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); + +WORD32 +impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); + +WORD32 +impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_interface_struct* pstr_drc_interface); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h b/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h new file mode 100644 index 0000000..95b8e8a --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h @@ -0,0 +1,90 @@ +/****************************************************************************** + * + * 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_SEL_PROC_LOUDNESS_CONTROL_H +#define IMPD_DRC_UNI_SEL_PROC_LOUDNESS_CONTROL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +WORD32 +impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_instructions_struct* str_drc_instruction_str, + const WORD32 requested_dwnmix_id, + const WORD32 album_mode, + const WORD32 num_compression_eq_count, + const WORD32* num_compression_eq_id, + WORD32* peak_info_count, + WORD32 eq_set_id[], + FLOAT32 signal_peak_level[], + WORD32 explicit_peak_information_present[]); + +WORD32 +impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_info, + const WORD32 dyn_range_measurement_type, + WORD32 * loudness_peak_2_avg_value_present, + FLOAT32* loudness_peak_2_avg_value); + +WORD32 +impd_overall_loudness_present(const ia_loudness_info_struct* loudness_info, + WORD32* loudness_info_present); + +WORD32 +impd_find_overall_loudness_info(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + const WORD32 requested_dwnmix_id, + const WORD32 drc_set_id_requested, + WORD32* overall_loudness_info_present, + WORD32* loudness_info_count, + ia_loudness_info_struct* loudness_info[]); + +WORD32 +impd_high_pass_loudness_adjust_info(const ia_loudness_info_struct* loudness_info, + WORD32* loudness_hp_adjust_present, + FLOAT32* loudness_hp_adjust); + +WORD32 +impd_find_high_pass_loudness_adjust( + ia_drc_loudness_info_set_struct* pstr_loudness_info, + const WORD32 requested_dwnmix_id, + const WORD32 drc_set_id_requested, + const WORD32 album_mode, + const FLOAT32 device_cutoff_freq, + WORD32* loudness_hp_adjust_present, + FLOAT32* loudness_hp_adjust); + +WORD32 +impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + const WORD32 requested_dwnmix_id, + const WORD32 drc_set_id_requested, + const WORD32 num_compression_eq_count, + const WORD32* num_compression_eq_id, + WORD32* loudness_info_count, + WORD32 eq_set_id[], + FLOAT32 loudness_normalization_gain_db[], + FLOAT32 loudness[]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/decoder/drc_src/impd_drc_uni_shape_filter.h b/decoder/drc_src/impd_drc_uni_shape_filter.h new file mode 100644 index 0000000..ac38099 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_shape_filter.h @@ -0,0 +1,25 @@ +/****************************************************************************** + * + * 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_SHAPE_FILTER_H +#define IMPD_DRC_UNI_SHAPE_FILTER_H + + + +#endif diff --git a/decoder/drc_src/impd_drc_uni_tables.h b/decoder/drc_src/impd_drc_uni_tables.h new file mode 100644 index 0000000..3f3fc35 --- /dev/null +++ b/decoder/drc_src/impd_drc_uni_tables.h @@ -0,0 +1,92 @@ +/****************************************************************************** + * + * 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_TABLES_H +#define IMPD_DRC_UNI_TABLES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX (512+14) + +typedef struct { + WORD32 size; + WORD32 code; + WORD32 value; +} ia_delta_time_code_table_entry_struct; + +typedef struct { + WORD32 size; + WORD32 code; + FLOAT32 value; + WORD32 index; +} ia_slope_code_table_struct; + +typedef struct { + WORD32 size; + WORD32 code; + FLOAT32 value; +} ia_delta_gain_code_table_struct; + +typedef struct { + ia_delta_time_code_table_entry_struct delta_time_code_table[N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX]; +} ia_tables_struct; + +typedef struct { + FLOAT32 in_out_ratio; + FLOAT32 exp_lo; + FLOAT32 exp_hi; +} ia_cicp_sigmoid_characteristic_param_struct; + +typedef struct { + FLOAT32 inLevel; + FLOAT32 gain; +} ia_characteristic_node_coordinate_struct; + +typedef struct { + WORD32 coordinateCount; + ia_characteristic_node_coordinate_struct characteristicNodeCoordinate[5]; +} ia_cicp_node_characteristic_param; + +WORD32 +impd_init_tbls(const WORD32 num_gain_max_values, + ia_tables_struct* str_tables); + +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); + +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); + +void +impd_get_slope_code_tbl_and_size(ia_slope_code_table_struct const** slope_code_tbl_entry, + WORD32* num_slope_code_tbl_entries); + +WORD32 +impd_get_delta_tmin (const WORD32 sampling_rate); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/decoder/drc_src/impd_error_handler.h b/decoder/drc_src/impd_error_handler.h new file mode 100644 index 0000000..2ac84c3 --- /dev/null +++ b/decoder/drc_src/impd_error_handler.h @@ -0,0 +1,94 @@ +/****************************************************************************** + * + * 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_ERROR_HANDLER_H +#define IMPD_ERROR_HANDLER_H + +/*****************************************************************************/ +/* File includes */ +/*****************************************************************************/ + +/* these definitions are used by error handling function */ +/* the error handler will work on a structure which identifies a */ +/* particular error with a module, context and error_code */ +/* within error_code, MSB identifies FATAL (1), NONFATAL (0) */ +/* next 4 ms_bs identify a class of error */ + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +#define IA_ERROR_NON_FATAL_IDX 0x0 +#define IA_ERROR_FATAL_IDX 0x1 + +#define IA_ERROR_CLASS_0 0x0 +#define IA_ERROR_CLASS_1 0x1 +#define IA_ERROR_CLASS_2 0x2 +#define IA_ERROR_CLASS_3 0x3 +#define IA_ERROR_CLASS_4 0x4 +#define IA_ERROR_CLASS_5 0x5 +#define IA_ERROR_CLASS_6 0x6 +#define IA_ERROR_CLASS_7 0x7 +#define IA_ERROR_CLASS_8 0x8 +#define IA_ERROR_CLASS_9 0x9 +#define IA_ERROR_CLASS_A 0xA +#define IA_ERROR_CLASS_B 0xB +#define IA_ERROR_CLASS_C 0xC +#define IA_ERROR_CLASS_D 0xD +#define IA_ERROR_CLASS_E 0xE +#define IA_ERROR_CLASS_F 0xF + +/* each module, hence, needs to copy the following structure */ +/* the first index is for FATAL/NONFATAL */ +/* the second index is for the classes */ +/* then in a module specific initialization, fill in the following */ +/* structure with the pointers to the particular error message arrays */ + +/*****************************************************************************/ +/* Type definitions */ +/*****************************************************************************/ +typedef struct +{ + pWORD8 pb_module_name; + pWORD8 ppb_class_names[16]; + WORD8 **ppppb_error_msg_pointers[2][16]; +} ia_error_info_struct; + +/*****************************************************************************/ +/* Function prototypes */ +/*****************************************************************************/ +/* this error handler maps the code generated by a module to a error string */ +/* pb_context is a string to specify where the module broke */ +IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, + WORD8 *pb_context, IA_ERRORCODE code); + +/*****************************************************************************/ +/* Macro functions */ +/*****************************************************************************/ +/* the following macro does a line job of returning back to the parent */ +/* in case a fatal error occurs after calling the errorhandler */ +#define _IA_HANDLE_ERROR(p_mod_err_info, context, e) \ + if((e) != IA_NO_ERROR) \ + { \ + ia_error_handler((p_mod_err_info), (context), (e)); \ + if((e) & IA_FATAL_ERROR) \ + return (e); \ + } + +#endif diff --git a/decoder/drc_src/impd_error_standards.h b/decoder/drc_src/impd_error_standards.h new file mode 100644 index 0000000..2edc0a6 --- /dev/null +++ b/decoder/drc_src/impd_error_standards.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * + * 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_ERROR_STANDARDS_H +#define IMPD_ERROR_STANDARDS_H + +/*****************************************************************************/ +/* File includes */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Type definitions */ +/*****************************************************************************/ +typedef WORD32 IA_ERRORCODE; + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +#define IA_NO_ERROR 0x00000000 +/* error handling 'AND' definition */ +#define IA_FATAL_ERROR 0x80000000 + +#endif /* __IMPD_ERROR_STANDARDS_H__ */ diff --git a/decoder/drc_src/impd_memory_standards.h b/decoder/drc_src/impd_memory_standards.h new file mode 100644 index 0000000..14b8a52 --- /dev/null +++ b/decoder/drc_src/impd_memory_standards.h @@ -0,0 +1,109 @@ +/****************************************************************************** + * + * 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_MEMORY_STANDARDS_H +#define IMPD_MEMORY_STANDARDS_H + +/*****************************************************************************/ +/* Type definitions */ +/*****************************************************************************/ +/* standard memory table descriptor for libraries */ +typedef struct +{ + UWORD32 ui_size; /* size of the memory in bytes */ + UWORD32 ui_alignment; /* alignment in bytes */ + UWORD32 ui_type; /* type of memory */ + UWORD32 ui_placement[2]; /* 64 bit placement info */ + UWORD32 ui_priority; /* the importance for placement */ + UWORD32 ui_placed[2]; /* the o_red location for placement */ +}ia_mem_info_struct; + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +/* when you don't need alignment, pass this to memory library */ +#define IA_MEM_NO_ALIGN 0x01 + +/* ittiam standard memory types */ +/* to be used inter frames */ +#define IA_MEMTYPE_PERSIST 0x00 +/* read write, to be used intra frames */ +#define IA_MEMTYPE_SCRATCH 0x01 +/* read only memory, intra frame */ +#define IA_MEMTYPE_INPUT 0x02 +/* read-write memory, for usable output, intra frame */ +#define IA_MEMTYPE_OUTPUT 0x03 +/* readonly memory, inter frame */ +#define IA_MEMTYPE_TABLE 0x04 +/* input buffer before mem tabs allocation */ +#define IA_MEMTYPE_PRE_FRAME_INPUT 0x05 +/* input buffer before mem tabs allocation */ +#define IA_MEMTYPE_PRE_FRAME_SCRATCH 0x06 +/* for local variables */ +#define IA_MEMTYPE_AUTO_VAR 0x80 + +/* ittiam standard memory priorities */ +#define IA_MEMPRIORITY_ANYWHERE 0x00 +#define IA_MEMPRIORITY_LOWEST 0x01 +#define IA_MEMPRIORITY_LOW 0x02 +#define IA_MEMPRIORITY_NORM 0x03 +#define IA_MEMPRIORITY_ABOVE_NORM 0x04 +#define IA_MEMPRIORITY_HIGH 0x05 +#define IA_MEMPRIORITY_HIGHER 0x06 +#define IA_MEMPRIORITY_CRITICAL 0x07 + +/* ittiam standard memory placements */ +/* placement is defined by 64 bits */ + +#define IA_MEMPLACE_FAST_RAM_0 0x000001 +#define IA_MEMPLACE_FAST_RAM_1 0x000002 +#define IA_MEMPLACE_FAST_RAM_2 0x000004 +#define IA_MEMPLACE_FAST_RAM_3 0x000008 +#define IA_MEMPLACE_FAST_RAM_4 0x000010 +#define IA_MEMPLACE_FAST_RAM_5 0x000020 +#define IA_MEMPLACE_FAST_RAM_6 0x000040 +#define IA_MEMPLACE_FAST_RAM_7 0x000080 + +#define IA_MEMPLACE_INT_RAM_0 0x000100 +#define IA_MEMPLACE_INT_RAM_1 0x000200 +#define IA_MEMPLACE_INT_RAM_2 0x000400 +#define IA_MEMPLACE_INT_RAM_3 0x000800 +#define IA_MEMPLACE_INT_RAM_4 0x001000 +#define IA_MEMPLACE_INT_RAM_5 0x002000 +#define IA_MEMPLACE_INT_RAM_6 0x004000 +#define IA_MEMPLACE_INT_RAM_7 0x008000 + +#define IA_MEMPLACE_EXT_RAM_0 0x010000 +#define IA_MEMPLACE_EXT_RAM_1 0x020000 +#define IA_MEMPLACE_EXT_RAM_2 0x040000 +#define IA_MEMPLACE_EXT_RAM_3 0x080000 +#define IA_MEMPLACE_EXT_RAM_4 0x100000 +#define IA_MEMPLACE_EXT_RAM_5 0x200000 +#define IA_MEMPLACE_EXT_RAM_6 0x400000 +#define IA_MEMPLACE_EXT_RAM_7 0x800000 + +#define IA_MEMPLACE_DONTCARE_H 0xFFFFFFFF +#define IA_MEMPLACE_DONTCARE_L 0xFFFFFFFF + +/* the simple common PC RAM */ +#define IA_PC_RAM_H 0x00000000 +#define IA_PC_RAM_L IA_MEMPLACE_EXT_RAM_0 + +#endif diff --git a/decoder/drc_src/impd_parametric_drc_dec.h b/decoder/drc_src/impd_parametric_drc_dec.h new file mode 100644 index 0000000..abf0c72 --- /dev/null +++ b/decoder/drc_src/impd_parametric_drc_dec.h @@ -0,0 +1,198 @@ +/****************************************************************************** + * + * 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_PARAMETRIC_DRC_DEC_H +#define IMPD_PARAMETRIC_DRC_DEC_H + + + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct ia_2nd_order_filt_coeff_struct_t { + FLOAT32 b0, b1, b2; + FLOAT32 a1, a2; +} ia_2nd_order_filt_coeff_struct; + +typedef struct ia_2nd_order_filt_state_struct_t { + FLOAT32 z1, z2; +} ia_2nd_order_filt_state_struct; + +typedef struct ia_parametric_drc_type_ff_params_struct_t { + + WORD32 audio_num_chan; + WORD32 frame_size; + WORD32 sub_band_domain_mode; + WORD32 sub_band_count; + WORD32 level_estim_integration_time; + WORD32 level_estim_frame_index; + WORD32 level_estim_frame_count; + FLOAT32 level[PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX]; + WORD32 start_up_phase; + FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; + WORD32 level_estim_k_weighting_type; + ia_2nd_order_filt_coeff_struct pre_filt_coeff; + ia_2nd_order_filt_coeff_struct rlb_filt_coeff; + ia_2nd_order_filt_state_struct pre_filt_state[MAX_CHANNEL_COUNT]; + ia_2nd_order_filt_state_struct rlb_filt_state[MAX_CHANNEL_COUNT]; + FLOAT32 weighting_filt[AUDIO_CODEC_SUBBAND_COUNT_MAX]; + WORD32 sub_band_compensation_type; + ia_2nd_order_filt_coeff_struct filt_coeff_subband; + ia_2nd_order_filt_state_struct filt_state_subband_real[MAX_CHANNEL_COUNT]; + ia_2nd_order_filt_state_struct filt_state_subband_imag[MAX_CHANNEL_COUNT]; + FLOAT32 ref_level_parametric_drc; + + WORD32 node_count; + WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + + FLOAT32 gain_smooth_attack_alpha_slow; + FLOAT32 gain_smooth_rel_alpha_slow; + FLOAT32 gain_smooth_attack_alpha_fast; + FLOAT32 gain_smooth_rel_alpha_fast; + WORD32 gain_smooth_attack_threshold; + WORD32 gain_smooth_rel_threshold; + WORD32 gain_smooth_hold_off_count; + FLOAT32 db_level_smooth; + FLOAT32 db_gain_smooth; + WORD32 hold_counter; + +} ia_parametric_drc_type_ff_params_struct; + +typedef struct ia_parametric_drc_type_lim_params_struct_t { + + WORD32 audio_num_chan; + WORD32 frame_size; + FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; + + UWORD32 attack; + FLOAT32 attack_constant; + FLOAT32 release_constant; + FLOAT32 attack_ms; + FLOAT32 release_ms; + FLOAT32 threshold; + UWORD32 channels; + UWORD32 sampling_rate; + FLOAT32 cor; + FLOAT32* max_buf; + FLOAT32* max_buf_slow; + UWORD32 max_buf_idx; + UWORD32 max_buf_slow_idx; + UWORD32 sec_len; + UWORD32 num_max_buf_sec; + UWORD32 max_buf_sec_idx; + UWORD32 max_buf_sec_ctr; + FLOAT64 smooth_state_0; + +} ia_parametric_drc_type_lim_params_struct; + +typedef struct ia_parametric_drc_instance_params_struct_t { + WORD32 disable_paramteric_drc; + WORD32 parametric_drc_type; + ia_spline_nodes_struct str_spline_nodes; + ia_parametric_drc_type_ff_params_struct str_parametric_drc_type_ff_params; + ia_parametric_drc_type_lim_params_struct str_parametric_drc_type_lim_params; +} ia_parametric_drc_instance_params_struct; + +typedef struct ia_parametric_drc_params_struct_t { + WORD32 sampling_rate; + WORD32 audio_num_chan; + WORD32 sub_band_domain_mode; + WORD32 sub_band_count; + + WORD32 num_nodes; + WORD32 drc_frame_size; + WORD32 parametric_drc_frame_size; + WORD32 parametric_drc_look_ahead_samples_max; + WORD32 reset_parametric_drc; + + WORD32 parametric_drc_instance_count; + WORD32 parametric_drc_idx[PARAM_DRC_INSTANCE_COUNT_MAX]; + WORD32 gain_set_index[PARAM_DRC_INSTANCE_COUNT_MAX]; + WORD32 dwnmix_id_from_drc_instructions[PARAM_DRC_INSTANCE_COUNT_MAX]; + WORD32 channel_map[PARAM_DRC_INSTANCE_COUNT_MAX][MAX_CHANNEL_COUNT]; + + ia_parametric_drc_instance_params_struct str_parametric_drc_instance_params[PARAM_DRC_INSTANCE_COUNT_MAX]; + +} ia_parametric_drc_params_struct; + +WORD32 impd_init_parametric_drc( WORD32 drc_frame_size, + WORD32 sampling_rate, + WORD32 sub_band_domain_mode, + ia_parametric_drc_params_struct* pstr_parametric_drc_params); + +WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_config, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_parametric_drc_params_struct *pstr_parametric_drc_params, + pVOID *mem_ptr); + + +WORD32 +impd_init_lvl_est_filt_time( WORD32 level_estim_k_weighting_type, + WORD32 sampling_rate, + ia_2nd_order_filt_coeff_struct* pre_filt_coeff, + ia_2nd_order_filt_coeff_struct* rlb_filt_coeff); + +WORD32 +impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_type, + WORD32 sampling_rate, + WORD32 sub_band_domain_mode, + WORD32 sub_band_count, + WORD32 sub_band_compensation_type, + FLOAT32 *weighting_filt, + ia_2nd_order_filt_coeff_struct* filt_coeff_subband); + + +WORD32 +impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params); + +WORD32 +impd_parametric_lim_type_drc_reset( WORD32 instance_idx, + ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params); + +WORD32 +impd_parametric_drc_instance_process (FLOAT32* audio_in_out_buf[], + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + ia_parametric_drc_params_struct* pstr_parametric_drc_params, + ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params); + + +WORD32 +impd_parametric_ffwd_type_drc_process(FLOAT32* audio_in_out_buf[], + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + WORD32 nodeIdx, + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params, + ia_spline_nodes_struct* str_spline_nodes); + +WORD32 +impd_parametric_lim_type_drc_process(FLOAT32* audio_in_out_buf[], + FLOAT32 loudness_normalization_gain_db, + ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params, + FLOAT32* lpcm_gains); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/decoder/drc_src/impd_type_def.h b/decoder/drc_src/impd_type_def.h new file mode 100644 index 0000000..9916940 --- /dev/null +++ b/decoder/drc_src/impd_type_def.h @@ -0,0 +1,114 @@ +/****************************************************************************** + * + * 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_TYPE_DEF_H +#define IMPD_TYPE_DEF_H + +/****************************************************************************/ +/* types type define prefix examples bytes */ +/************************ *********** ****** **************** ***** */ +typedef char CHAR8 ;/* c CHAR8 c_name 1 */ +typedef char * pCHAR8 ;/* pc pCHAR8 pc_nmae 1 */ + +typedef signed char WORD8 ;/* b WORD8 b_name 1 */ +typedef signed char * pWORD8 ;/* pb pWORD8 pb_nmae 1 */ + +typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */ +typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */ + +typedef signed short WORD16 ;/* s WORD16 s_count 2 */ +typedef signed short * pWORD16 ;/* ps pWORD16 ps_count 2 */ +typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */ +typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */ + +typedef signed int WORD24 ;/* k WORD24 k_count 3 */ +typedef signed int * pWORD24 ;/* pk pWORD24 pk_count 3 */ +typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */ +typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */ + +typedef signed int WORD32 ;/* i WORD32 i_count 4 */ +typedef signed int * pWORD32 ;/* pi pWORD32 pi_count 4 */ +typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */ +typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */ + +#ifdef WIN32 +#ifndef ECLIPSE +typedef signed __int64 WORD40 ;/* m WORD40 m_count 5 */ +typedef signed __int64 * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned __int64 UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned __int64 * pUWORD40;/* pum pUWORD40 pum_count 5 */ + +typedef signed __int64 WORD64 ;/* h WORD64 h_count 8 */ +typedef signed __int64 * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned __int64 UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned __int64 * pUWORD64;/* puh pUWORD64 puh_count 8 */ +#else +typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ +typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ + +typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ +typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ +#endif +#else + +typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ +typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ + +typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ +typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ + +#endif + + +typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */ +typedef float * pFLOAT32;/* pf pFLOAT32 pf_count 4 */ +typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */ +typedef double * pFlOAT64;/* pd pFLOAT64 pd_count 8 */ + +typedef void VOID ;/* v VOID v_flag 4 */ +typedef void * pVOID ;/* pv pVOID pv_flag 4 */ + +/* variable size types: platform optimized implementation */ +typedef signed int BOOL ;/* bool BOOL bool_true */ +typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */ +typedef signed int FLAG ;/* flag FLAG flag_false */ +typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */ +typedef signed int LOOPIDX ;/* lp LOOPIDX lp_index */ +typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */ +typedef signed int WORD ;/* lp LOOPIDX lp_index */ +typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */ + +typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */ +typedef ULOOPIDX ULOOPINDEX;/* ulp SLOOPIDX ulp_index */ + +#define SIZE_T size_t + +#define PLATFORM_INLINE __inline + +#endif + diff --git a/decoder/ixheaacd_Windowing.c b/decoder/ixheaacd_Windowing.c new file mode 100644 index 0000000..41450a3 --- /dev/null +++ b/decoder/ixheaacd_Windowing.c @@ -0,0 +1,104 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_cnst.h" + +#include "ixheaacd_constants.h" +#include +#include +#include + +#include "ixheaacd_windows.h" + +WORD32 ixheaacd_calc_window(WORD32 **win, WORD32 win_sz, WORD32 win_sel) { + switch (win_sel) { + case WIN_SEL_0: + switch (win_sz) { + case WIN_LEN_128: + *win = (WORD32 *)ixheaacd_sine_win_128; + break; + case WIN_LEN_1024: + *win = (WORD32 *)ixheaacd_sine_win_1024; + break; + case WIN_LEN_64: + *win = (WORD32 *)ixheaacd_sine_win_64; + break; + case WIN_LEN_768: + *win = (WORD32 *)ixheaacd_sine_win_768; + break; + case WIN_LEN_192: + *win = (WORD32 *)ixheaacd_sine_win_192; + break; + case WIN_LEN_96: + *win = (WORD32 *)ixheaacd_sine_win_96; + break; + case WIN_LEN_256: + *win = (WORD32 *)ixheaacd_sine_win_256; + break; + default:; + } + break; + + case WIN_SEL_1: + switch (win_sz) { + case WIN_LEN_120: + *win = (WORD32 *)ixheaacd_kbd_win120; + break; + case WIN_LEN_128: + *win = (WORD32 *)ixheaacd_kbd_win128; + break; + case WIN_LEN_960: + *win = (WORD32 *)ixheaacd_kbd_win960; + break; + case WIN_LEN_1024: + *win = (WORD32 *)ixheaacd_kbd_win1024; + break; + case WIN_LEN_4: + *win = (WORD32 *)ixheaacd_kbd_win4; + break; + case WIN_LEN_16: + *win = (WORD32 *)ixheaacd_kbd_win16; + break; + case WIN_LEN_64: + *win = (WORD32 *)ixheaacd_kbd_win_64; + break; + case WIN_LEN_768: + *win = (WORD32 *)ixheaacd_kbd_win768; + break; + case WIN_LEN_192: + *win = (WORD32 *)ixheaacd_kbd_win192; + break; + case WIN_LEN_96: + *win = (WORD32 *)ixheaacd_kbd_win96; + break; + case WIN_LEN_48: + *win = (WORD32 *)ixheaacd_kbd_win48; + break; + default: + return -1; + break; + } + break; + + default: + return -1; + break; + } + return 0; +} diff --git a/decoder/ixheaacd_aac_config.h b/decoder/ixheaacd_aac_config.h new file mode 100644 index 0000000..a126d1e --- /dev/null +++ b/decoder/ixheaacd_aac_config.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_AAC_CONFIG_H +#define IXHEAACD_AAC_CONFIG_H + +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK 0x0003 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE 0x0004 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE 0x0005 + +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX 0x0006 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT08KHZ 0x0007 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT16KHZ 0x0008 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO 0x0009 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE 0x000A +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMEOK 0x000B +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4 0x000C +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL 0x000D +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL 0x000E +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO 0x000F +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC 0x0010 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE 0x0011 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS 0x0012 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE 0x0013 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT 0x0014 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST 0x0015 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL 0x0016 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP 0x0017 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE 0x0018 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ELD_SBR_PRESENT 0x0019 + +#ifdef ENABLE_DRC +#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR 0x001A +#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES 0x001B +#define IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE 0x001C +#define IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT 0x001D +#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN 0x001E +#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF 0x001F +#endif + +#endif /* IXHEAACD_AAC_CONFIG_H */ diff --git a/decoder/ixheaacd_aac_imdct.c b/decoder/ixheaacd_aac_imdct.c new file mode 100644 index 0000000..db0df51 --- /dev/null +++ b/decoder/ixheaacd_aac_imdct.c @@ -0,0 +1,2812 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_intrinsics.h" + +#include +#include "ixheaacd_function_selector.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_tns.h" + +#define DIG_REV(i, m, j) \ + do { \ + unsigned _ = (i); \ + _ = ((_ & 0x33333333) << 2) | ((_ & ~0x33333333) >> 2); \ + _ = ((_ & 0x0F0F0F0F) << 4) | ((_ & ~0x0F0F0F0F) >> 4); \ + _ = ((_ & 0x00FF00FF) << 8) | ((_ & ~0x00FF00FF) >> 8); \ + _ = ((_ & 0x0000FFFF) << 16) | ((_ & ~0x0000FFFF) >> 16); \ + (j) = _ >> (m); \ + } while (0) + +#define MPYHIRC(x, y) \ + \ +(((WORD32)((short)(x >> 16) * (unsigned short)(y & 0x0000FFFF) + 0x4000) >> \ + 15) + \ + ((WORD32)((short)(x >> 16) * (short)((y) >> 16)) << 1)) + +#define MPYLUHS(x, y) \ + ((WORD32)((unsigned short)(x & 0x0000FFFF) * (short)(y >> 16))) + +#define MDCT_LEN 480 +#define FFT15X2 30 +#define MDCT_LEN_BY2 240 +#define FFT5 5 +#define FFT16 16 +#define FFT15 15 +#define FFT16X2 32 + +WORD32 ixheaacd_fft5out[FFT15X2]; + +static PLATFORM_INLINE WORD32 ixheaacd_shr32_drc(WORD32 a, WORD32 b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); + if (b >= 31) { + if (a < 0) + out_val = -1; + else + out_val = 0; + } else { + a += (1 << (b - 1)); + out_val = (WORD32)a >> b; + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16hin32_drc(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + temp_result = (WORD64)a * (WORD64)(b >> 16); + result = (WORD32)(temp_result >> 16); + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16lin32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + temp_result = (WORD64)a * (WORD64)(((b & 0xFFFF) << 16) >> 16); + result = (WORD32)(temp_result >> 16); + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16lin32(WORD32 a, WORD32 b, + WORD32 c) { + WORD32 result; + result = a + ixheaacd_mult32x16lin32(b, c); + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16lin32_drc(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + temp_result = (WORD64)a * (WORD64)(((b & 0xFFFF) << 16) >> 16); + if (temp_result < (WORD64)MIN_32) + result = MIN_32; + else if (temp_result > (WORD64)MAX_32) + result = MAX_32; + else + result = (WORD32)(temp_result); + return (result); +} + +WORD16 ixheaacd_neg_expo_inc_dec(WORD16 neg_expo) { return (neg_expo + 2); } + +WORD16 ixheaacd_neg_expo_inc_arm(WORD16 neg_expo) { return (neg_expo + 3); } + +VOID ixheaacd_pretwiddle_compute_dec( + WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) { + WORD32 i; + WORD32 tempr, tempi; + WORD32 tempr1, tempi1; + WORD32 npoints2 = npoints4 * 2; + WORD32 *out_ptr1 = out_ptr + (npoints2 << 1) - 1; + const WORD16 *cos_sin_ptr = ptr_imdct_tables->cosine_array_2048_256; + + WORD16 cos = 0, cos1 = 0, sin = 0, sin1 = 0; + if (neg_expo < 0) { + neg_expo = -neg_expo; + if (npoints4 == 256) { + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + } else if (npoints4 == 32) { + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr; + cos_sin_ptr += 15; + } + tempr = *spec_data1++; + tempi = *spec_data2--; + + *out_ptr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + + *out_ptr = ixheaacd_shl32(*out_ptr, neg_expo); + out_ptr++; + + *out_ptr = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + + *out_ptr = ixheaacd_shl32(*out_ptr, neg_expo); + out_ptr++; + + for (i = 0; i < npoints4 - 1; i++) { + if (npoints4 == 256) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + } else if (npoints4 == 32) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr; + cos_sin_ptr += 15; + } + + tempi1 = *spec_data1++; + tempr = *spec_data1++; + tempr1 = *spec_data2--; + tempi = *spec_data2--; + + *out_ptr1 = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi1, cos), + ixheaacd_mult32x16in32(tempr1, sin)); + + *out_ptr1 = ixheaacd_shl32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr1 = ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr1, cos), + tempi1, sin); + *out_ptr1 = ixheaacd_shl32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, sin), tempi, cos); + *out_ptr = ixheaacd_shl32(*out_ptr, neg_expo); + out_ptr++; + + *out_ptr = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), + ixheaacd_mult32x16in32(tempr, cos)); + *out_ptr = ixheaacd_shl32(*out_ptr, neg_expo); + out_ptr++; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempr1 = *spec_data2; + tempi1 = *spec_data1; + + *out_ptr1 = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi1, cos1), + ixheaacd_mult32x16in32(tempr1, sin1)); + *out_ptr1 = ixheaacd_shl32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr1 = ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr1, cos1), + tempi1, sin1); + *out_ptr1 = ixheaacd_shl32(*out_ptr1, neg_expo); + out_ptr1--; + + } else { + if (npoints4 == 256) { + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + + } else if (npoints4 == 32) { + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr; + cos_sin_ptr += 15; + } + tempr = *spec_data1++; + tempi = *spec_data2--; + + *out_ptr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + *out_ptr = ixheaacd_shr32(*out_ptr, neg_expo); + out_ptr++; + + *out_ptr = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + + *out_ptr = ixheaacd_shr32(*out_ptr, neg_expo); + out_ptr++; + + for (i = 0; i < npoints4 - 1; i++) { + if (npoints4 == 256) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + } else if (npoints4 == 32) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr; + cos_sin_ptr += 15; + } + + tempi1 = *spec_data1++; + tempr = *spec_data1++; + tempr1 = *spec_data2--; + tempi = *spec_data2--; + + *out_ptr1 = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi1, cos), + ixheaacd_mult32x16in32(tempr1, sin)); + *out_ptr1 = ixheaacd_shr32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr1 = ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr1, cos), + tempi1, sin); + *out_ptr1 = ixheaacd_shr32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, sin), tempi, cos); + *out_ptr = ixheaacd_shr32(*out_ptr, neg_expo); + out_ptr++; + + *out_ptr = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), + ixheaacd_mult32x16in32(tempr, cos)); + *out_ptr = ixheaacd_shr32(*out_ptr, neg_expo); + out_ptr++; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempr1 = *spec_data2; + tempi1 = *spec_data1; + + *out_ptr1 = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi1, cos1), + ixheaacd_mult32x16in32(tempr1, sin1)); + *out_ptr1 = ixheaacd_shr32(*out_ptr1, neg_expo); + out_ptr1--; + + *out_ptr1 = ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr1, cos1), + tempi1, sin1); + *out_ptr1 = ixheaacd_shr32(*out_ptr1, neg_expo); + out_ptr1--; + } +} + +VOID ixheaacd_post_twiddle_dec(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) { + WORD i; + WORD16 cos, cos1, sin, sin1; + WORD32 *spec_data1 = spec_data + npoints - 1; + WORD32 *out_ptr1 = out_ptr + npoints - 1; + WORD16 adjust = 50, adjust1 = -50; + const WORD16 *cos_sin_ptr = ptr_imdct_tables->cosine_array_2048_256; + + if (npoints == 1024) { + WORD32 tempr, tempi, outi, outr, temp1, temp2; + tempr = *spec_data++; + tempi = *spec_data++; + + cos = *cos_sin_ptr; + cos_sin_ptr++; + sin = *cos_sin_ptr; + cos_sin_ptr++; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + *out_ptr1-- = outi; + *out_ptr++ = outr; + + for (i = 0; i < (npoints / 2 - 2); i++) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + + tempi = *spec_data1--; + tempr = *spec_data1--; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr++ = outi; + *out_ptr1-- = outr; + + i++; + tempr = *spec_data++; + tempi = *spec_data++; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, sin), tempi, cos); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr1-- = outi; + *out_ptr++ = outr; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempi = *spec_data1--; + tempr = *spec_data1--; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin1), + ixheaacd_mult32x16in32(tempi, cos1)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos1), tempi, sin1); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr++ = outi; + *out_ptr1-- = outr; + } else if (npoints == 128) { + WORD32 tempr, tempi, outi, outr, temp1, temp2; + tempr = *spec_data++; + tempi = *spec_data++; + + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr; + cos_sin_ptr += 15; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + + temp1 = ixheaacd_mult32x16in32(outi, -(201 << 1)); + temp2 = ixheaacd_mult32x16in32(outr, 201 << 1); + + outr = outr + temp1; + outi = outi + temp2; + *out_ptr1-- = outi; + *out_ptr++ = outr; + + for (i = 0; i < (npoints / 2 - 2); i++) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr; + cos_sin_ptr += 15; + + tempi = *spec_data1--; + tempr = *spec_data1--; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos), tempi, sin); + + temp1 = ixheaacd_mult32x16in32(outi, -(201 << 1)); + temp2 = ixheaacd_mult32x16in32(outr, 201 << 1); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr++ = outi; + *out_ptr1-- = outr; + + i++; + tempr = *spec_data++; + tempi = *spec_data++; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, sin), tempi, cos); + + temp1 = ixheaacd_mult32x16in32(outi, -(201 << 1)); + temp2 = ixheaacd_mult32x16in32(outr, 201 << 1); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr1-- = outi; + *out_ptr++ = outr; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempi = *spec_data1--; + tempr = *spec_data1--; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin1), + ixheaacd_mult32x16in32(tempi, cos1)); + outr = + ixheaacd_mac32x16in32(ixheaacd_mult32x16in32(tempr, cos1), tempi, sin1); + + temp1 = ixheaacd_mult32x16in32(outi, -(201 << 1)); + temp2 = ixheaacd_mult32x16in32(outr, 201 << 1); + + outr = outr + temp1; + outi = outi + temp2; + + *out_ptr++ = outi; + *out_ptr1-- = outr; + } +} + +VOID ixheaacd_post_twid_overlap_add_dec( + WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) { + WORD i; + WORD16 cos, cos1, sin, sin1; + WORD32 size = npoints / 2; + WORD16 *pcmout1 = pcm_out + (ch_fac * size); + const WORD16 *cos_sin_ptr = ptr_imdct_tables->cosine_array_2048_256; + + pcm_out = pcmout1 - ch_fac; + spec_data += size; + + if (q_shift > 0) { + WORD32 tempr, tempi, outr, outi, win1, accu, temp1, temp2; + WORD16 adjust, adjust1; + WORD32 overlap_data; + + tempr = *(spec_data - size); + tempi = *(spec_data - size + 1); + adjust = 50; + adjust1 = -50; + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); + + win1 = *((WORD32 *)window + size - 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcmout1 += ch_fac; + + for (i = size - 2; i != 0;) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + overlap_data = *ptr_overlap_buf; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + tempr = *(spec_data - i); + tempi = *(spec_data - i + 1); + + i -= 2; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); + + win1 = *((WORD32 *)window + i + 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), + ixheaacd_mult32x16in32(tempi, sin1)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin1), + ixheaacd_mult32x16in32(tempi, cos1)); + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + overlap_data = *ptr_overlap_buf; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } else { + q_shift = -q_shift; + { + WORD32 tempr, tempi, temp1, temp2, outr, outi, win1, accu; + WORD16 adjust, adjust1; + WORD16 overlap_data; + tempr = *(spec_data - size); + tempi = *(spec_data - size + 1); + + adjust = 50; + adjust1 = -50; + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); + + win1 = *((WORD32 *)window + size - 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + for (i = size - 2; i != 0;) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + + temp2 = ixheaacd_mult32x16in32(outr, adjust); + outr = outr + temp1; + outi = outi + temp2; + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + tempr = *(spec_data - i); + tempi = *(spec_data - i + 1); + i -= 2; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); + + win1 = *((WORD32 *)window + i + 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), + ixheaacd_mult32x16in32(tempi, sin1)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempr, sin1), + ixheaacd_mult32x16in32(tempi, cos1)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + } +} + +VOID ixheaacd_post_twid_overlap_add_armv8( + WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) { + WORD i; + WORD16 cos, cos1, sin, sin1; + WORD32 size = npoints / 2; + WORD16 *pcmout1 = pcm_out + (ch_fac * size); + const WORD16 *cos_sin_ptr = ptr_imdct_tables->cosine_array_2048_256p; + + pcm_out = pcmout1 - ch_fac; + spec_data += size; + + if (q_shift > 0) { + WORD32 tempr, tempi, outr, outi, win1, accu, temp1, temp2; + WORD16 adjust, adjust1; + WORD32 overlap_data; + + tempr = *(spec_data - size); + tempi = *(spec_data - size + 1); + adjust = 50; + adjust1 = -50; + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); + + win1 = *((WORD32 *)window + size - 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcmout1 += ch_fac; + + for (i = size - 2; i != 0;) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = -1 * temp1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + overlap_data = *ptr_overlap_buf; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + tempr = *(spec_data - i); + tempi = *(spec_data - i + 1); + + i -= 2; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), + ixheaacd_mult32x16in32(tempr, cos)); + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = temp1 * -1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); + + win1 = *((WORD32 *)window + i + 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), + ixheaacd_mult32x16in32(tempi, sin1)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos1), + ixheaacd_mult32x16in32(tempr, sin1)); + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = -1 * temp1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + overlap_data = *ptr_overlap_buf; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_sat( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } else { + q_shift = -q_shift; + { + WORD32 tempr, tempi, temp1, temp2, outr, outi, win1, accu; + WORD16 adjust, adjust1; + WORD16 overlap_data; + tempr = *(spec_data - size); + tempi = *(spec_data - size + 1); + + adjust = 50; + adjust1 = -50; + cos = *cos_sin_ptr++; + sin = *cos_sin_ptr++; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust1); + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); + + win1 = *((WORD32 *)window + size - 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + for (i = size - 2; i != 0;) { + sin = *cos_sin_ptr++; + cos = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), + ixheaacd_mult32x16in32(tempi, sin)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), + ixheaacd_mult32x16in32(tempr, sin)); + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = -1 * temp1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + outr = outr + temp1; + outi = outi + temp2; + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + + tempr = *(spec_data - i); + tempi = *(spec_data - i + 1); + i -= 2; + + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), + ixheaacd_mult32x16in32(tempr, cos)); + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), + ixheaacd_mult32x16in32(tempi, cos)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = -1 * temp1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); + + win1 = *((WORD32 *)window + i + 1); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); + + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + cos1 = *cos_sin_ptr++; + sin1 = *cos_sin_ptr++; + + tempr = *(spec_data + i); + tempi = *(spec_data + i + 1); + + outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), + ixheaacd_mult32x16in32(tempi, sin1)); + outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos1), + ixheaacd_mult32x16in32(tempr, sin1)); + + overlap_data = *ptr_overlap_buf; + + temp1 = ixheaacd_mult32x16in32(outi, adjust); + temp1 = -1 * temp1; + temp2 = ixheaacd_mult32x16in32(outr, adjust); + + outr = outr + temp1; + outi = outi + temp2; + + *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); + + win1 = *((WORD32 *)window + i); + accu = ixheaacd_sub32_sat( + ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); + + *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcm_out -= ch_fac; + accu = ixheaacd_sub32_sat( + ixheaacd_shr32( + ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), + q_shift), + ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); + *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); + pcmout1 += ch_fac; + } + } +} + +VOID ixheaacd_imdct_using_fft_dec( + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) + +{ + WORD32 i, j, k, k1, n_stages; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, + x7r, x7i; + WORD32 del, nodespacing, in_loop_cnt, tmp, twiddle_val, *ptr_tmp; + const WORD32 *ptr_twiddle; + WORD8 *ptr_dig_rev_table; + n_stages = ixheaacd_norm32(npoints); + + n_stages = (30 - n_stages) / 3; + + ptr_tmp = ptr_y; + + ptr_twiddle = ptr_imdct_tables->fft_twiddle; + ptr_dig_rev_table = ((npoints << 1) == 1024) + ? ptr_imdct_tables->dig_rev_table8_long + : ptr_imdct_tables->dig_rev_table8_short; + + for (i = npoints; i != 0; i -= 8) { + WORD32 *data = ptr_x; + data = data + (*ptr_dig_rev_table++ << 1); + + x0r = *data; + x0i = *(data + 1); + data += (npoints >> 1); + + x2r = *data; + x2i = *(data + 1); + data += (npoints >> 1); + + x4r = *data; + x4i = *(data + 1); + data += (npoints >> 1); + + x6r = *data; + x6i = *(data + 1); + data -= 5 * (npoints >> 2); + + x0r = x0r + x4r; + x0i = x0i + x4i; + x4r = x0r - (x4r << 1); + x4i = x0i - (x4i << 1); + + x2r = x2r + x6r; + x2i = x2i + x6i; + x6r = x2r - (x6r << 1); + x6i = x2i - (x6i << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + + x4r = x4r + x6i; + x4i = x4i - x6r; + tmp = x6r; + x6r = x4r - (x6i << 1); + x6i = x4i + (tmp << 1); + + x1r = *data; + x1i = *(data + 1); + data += (npoints >> 1); + + x3r = *data; + x3i = *(data + 1); + data += (npoints >> 1); + + x5r = *data; + x5i = *(data + 1); + data += (npoints >> 1); + + x7r = *data; + x7i = *(data + 1); + data -= 7 * (npoints >> 2); + + x1r = x1r + x5r; + x1i = x1i + x5i; + x5r = x1r - (x5r << 1); + x5i = x1i - (x5i << 1); + + x3r = x3r + x7r; + x3i = x3i + x7i; + x7r = x3r - (x7r << 1); + x7i = x3i - (x7i << 1); + + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x5r = x5r + x5i; + x5i = x5r - (x5i << 1); + + x7r = x7r + x7i; + x7i = x7r - (x7i << 1); + + x7i = x5r - x7i; + x5r = x7i - (x5r << 1); + + x5i = x7r - x5i; + x7r = x5i - (x7r << 1); + + x7i = x7i << 1; + x5r = x5r << 1; + x5i = x5i << 1; + x7r = x7r << 1; + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + + x2r = x2r + x3i; + tmp = x2r - (x3i << 1); + x2i = x2i - x3r; + x3i = x2i + (x3r << 1); + + *ptr_tmp = x0r; + *(ptr_tmp + 1) = x0i; + ptr_tmp += 4; + + *ptr_tmp = x2r; + *(ptr_tmp + 1) = x2i; + ptr_tmp += 4; + + *ptr_tmp = x1r; + *(ptr_tmp + 1) = x1i; + ptr_tmp += 4; + + *ptr_tmp = tmp; + *(ptr_tmp + 1) = x3i; + ptr_tmp -= 10; + + tmp = 0x5A82; + + x7i = x4r + (ixheaacd_mult32x16lin32(x7i, tmp)); + x4r = x7i - (x4r << 1); + + x7r = x4i + (ixheaacd_mult32x16lin32(x7r, tmp)); + x4i = x7r - (x4i << 1); + + x5i = x6r + (ixheaacd_mult32x16lin32(x5i, tmp)); + x6r = x5i - (x6r << 1); + + x5r = x6i + (ixheaacd_mult32x16lin32(x5r, tmp)); + x6i = x5r - (x6i << 1); + + *ptr_tmp = x7i; + *(ptr_tmp + 1) = x7r; + ptr_tmp += 4; + + *ptr_tmp = x5i; + *(ptr_tmp + 1) = x5r; + ptr_tmp += 4; + + *ptr_tmp = -x4r; + *(ptr_tmp + 1) = -x4i; + ptr_tmp += 4; + + *ptr_tmp = -x6r; + *(ptr_tmp + 1) = -x6i; + ptr_tmp += 2; + } + + del = 8; + + nodespacing = 64; + in_loop_cnt = npoints >> 6; + + for (k1 = n_stages - 2; k1 > 0; k1--) { + WORD32 *data = ptr_y; + const WORD32 *twiddles; + + for (i = 0; i != npoints; i += 8 * del) { + data = ptr_y + (i << 1); + x0r = *data; + x0i = *(data + 1); + data += (del << 2); + + x2r = *data; + x2i = *(data + 1); + data += (del << 2); + + x4r = *data; + x4i = *(data + 1); + data += (del << 2); + + x6r = *data; + x6i = *(data + 1); + data -= 5 * (del << 1); + + x0r = x0r + x4r; + x0i = x0i + x4i; + x4r = x0r - (x4r << 1); + x4i = x0i - (x4i << 1); + + x2r = x2r + x6r; + x2i = x2i + x6i; + x6r = x2r - (x6r << 1); + x6i = x2i - (x6i << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + + x4r = x4r + x6i; + x4i = x4i - x6r; + tmp = x6r; + x6r = x4r - (x6i << 1); + x6i = x4i + (tmp << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 2); + + x3r = *data; + x3i = *(data + 1); + data += (del << 2); + + x5r = *data; + x5i = *(data + 1); + data += (del << 2); + + x7r = *data; + x7i = *(data + 1); + data -= 7 * (del << 1); + + x1r = x1r + x5r; + x1i = x1i + x5i; + x5r = x1r - (x5r << 1); + x5i = x1i - (x5i << 1); + + x3r = x3r + x7r; + x3i = x3i + x7i; + x7r = x3r - (x7r << 1); + x7i = x3i - (x7i << 1); + + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x5r = x5r + x5i; + x5i = x5r - (x5i << 1); + + x7r = x7r + x7i; + x7i = x7r - (x7i << 1); + + x7i = x5r - x7i; + x5r = x7i - (x5r << 1); + + x5i = x7r - x5i; + x7r = x5i - (x7r << 1); + + x7i = x7i << 1; + x5r = x5r << 1; + x5i = x5i << 1; + x7r = x7r << 1; + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + + x2r = x2r + x3i; + tmp = x2r - (x3i << 1); + x2i = x2i - x3r; + x3i = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 2); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 2); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 2); + + *data = tmp; + *(data + 1) = x3i; + data -= 5 * (del << 1); + + tmp = 0x5A82; + + x7i = x4r + (ixheaacd_mult32x16lin32(x7i, tmp)); + x4r = x7i - (x4r << 1); + x7r = x4i + (ixheaacd_mult32x16lin32(x7r, tmp)); + x4i = x7r - (x4i << 1); + + x5i = x6r + (ixheaacd_mult32x16lin32(x5i, tmp)); + x6r = x5i - (x6r << 1); + x5r = x6i + (ixheaacd_mult32x16lin32(x5r, tmp)); + x6i = x5r - (x6i << 1); + + *data = x7i; + *(data + 1) = x7r; + data += (del << 2); + + *data = x5i; + *(data + 1) = x5r; + data += (del << 2); + + *data = -x4r; + *(data + 1) = -x4i; + data += (del << 2); + + *data = -x6r; + *(data + 1) = -x6i; + + data -= 7 * (del << 1); + } + + twiddles = ptr_twiddle; + data = ptr_y; + + for (j = nodespacing; j < nodespacing * del; j += nodespacing) { + data = data + 2; + + for (k = in_loop_cnt; k != 0; k--) { + data += (del << 2); + x2r = *data; + x2i = *(data + 1); + + data += (del << 2); + x4r = *data; + x4i = *(data + 1); + + data += (del << 2); + x6r = *data; + x6i = *(data + 1); + + data -= 6 * (del << 1); + + twiddles += (j >> 2); + + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x2r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x2i, twiddle_val)); + x2i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x2r, twiddle_val), x2i, + twiddle_val)) + << 1; + x2r = tmp << 1; + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x4r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x4i, twiddle_val)); + x4i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x4r, twiddle_val), x4i, + twiddle_val)) + << 1; + x4r = tmp << 1; + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x6r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x6i, twiddle_val)); + x6i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x6r, twiddle_val), x6i, + twiddle_val)) + << 1; + x6r = tmp << 1; + + x0r = *data; + x0i = *(data + 1); + data += (del << 1); + + x0r = x0r + x4r; + x0i = x0i + x4i; + x4r = x0r - (x4r << 1); + x4i = x0i - (x4i << 1); + + x2r = x2r + x6r; + x2i = x2i + x6i; + x6r = x2r - (x6r << 1); + x6i = x2i - (x6i << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + + x4r = x4r + x6i; + x4i = x4i - x6r; + tmp = x6r; + x6r = x4r - (x6i << 1); + x6i = x4i + (tmp << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 2); + + twiddles -= 5 * (j >> 3); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x1r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x1i, twiddle_val)); + x1i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x1r, twiddle_val), x1i, + twiddle_val)) + << 1; + x1r = tmp << 1; + + x3r = *data; + x3i = *(data + 1); + data += (del << 2); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x3r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x3i, twiddle_val)); + x3i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x3r, twiddle_val), x3i, twiddle_val)); + x3r = tmp; + + x5r = *data; + x5i = *(data + 1); + data += (del << 2); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x5r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x5i, twiddle_val)); + x5i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x5r, twiddle_val), x5i, twiddle_val)); + x5r = tmp; + + x7r = *data; + x7i = *(data + 1); + data -= 7 * (del << 1); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + twiddles -= 7 * (j >> 3); + + tmp = (ixheaacd_mult32x16lin32(x7r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x7i, twiddle_val)); + x7i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x7r, twiddle_val), x7i, twiddle_val)); + x7r = tmp; + + x1r = x1r + (x5r << 1); + x1i = x1i + (x5i << 1); + x5r = x1r - (x5r << 2); + x5i = x1i - (x5i << 2); + + x3r = x3r + x7r; + x3i = x3i + x7i; + x7r = x3r - (x7r << 1); + x7i = x3i - (x7i << 1); + + x1r = x1r + (x3r << 1); + x1i = x1i + (x3i << 1); + x3r = x1r - (x3r << 2); + x3i = x1i - (x3i << 2); + + x5r = x5r + x5i; + x5i = x5r - (x5i << 1); + + x7r = x7r + x7i; + x7i = x7r - (x7i << 1); + + x7i = x5r - (x7i << 1); + x5r = x7i - (x5r << 1); + + x5i = (x7r << 1) - x5i; + x7r = x5i - (x7r << 2); + + x7i = x7i << 1; + x5r = x5r << 1; + x5i = x5i << 1; + x7r = x7r << 1; + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + + x2r = x2r + x3i; + tmp = x2r - (x3i << 1); + x2i = x2i - x3r; + x3i = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 2); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 2); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 2); + + *data = tmp; + *(data + 1) = x3i; + data -= 5 * (del << 1); + + tmp = 0x5A82; + + x7i = x4r + (ixheaacd_mult32x16lin32(x7i, tmp)); + x4r = x7i - (x4r << 1); + + x7r = x4i + (ixheaacd_mult32x16lin32(x7r, tmp)); + x4i = x7r - (x4i << 1); + + x5i = x6r + (ixheaacd_mult32x16lin32(x5i, tmp)); + x6r = x5i - (x6r << 1); + + x5r = x6i + (ixheaacd_mult32x16lin32(x5r, tmp)); + x6i = x5r - (x6i << 1); + + *data = x7i; + *(data + 1) = x7r; + data += (del << 2); + + *data = x5i; + *(data + 1) = x5r; + data += (del << 2); + + *data = -x4r; + *(data + 1) = -x4i; + data += (del << 2); + + *data = -x6r; + *(data + 1) = -x6i; + + data -= 7 * (del << 1); + data += (del << 4); + } + data -= npoints << 1; + } + nodespacing >>= 3; + del <<= 3; + in_loop_cnt >>= 3; + } + + { + WORD32 *data = ptr_y; + const WORD32 *twiddles; + twiddles = ptr_twiddle; + data = ptr_y; + data = data - 2; + + for (j = 0; j < nodespacing * del; j += nodespacing) { + data = data + 2; + + { + data += (del << 2); + x2r = *data; + x2i = *(data + 1); + + data += (del << 2); + x4r = *data; + x4i = *(data + 1); + + data += (del << 2); + x6r = *data; + x6i = *(data + 1); + + data -= 6 * (del << 1); + + twiddles += (j >> 2); + + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x2r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x2i, twiddle_val)); + x2i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x2r, twiddle_val), x2i, + twiddle_val)) + << 1; + x2r = tmp << 1; + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x4r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x4i, twiddle_val)); + x4i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x4r, twiddle_val), x4i, + twiddle_val)) + << 1; + x4r = tmp << 1; + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x6r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x6i, twiddle_val)); + x6i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x6r, twiddle_val), x6i, + twiddle_val)) + << 1; + x6r = tmp << 1; + + x0r = *data; + x0i = *(data + 1); + data += (del << 1); + + x0r = x0r + x4r; + x0i = x0i + x4i; + x4r = x0r - (x4r << 1); + x4i = x0i - (x4i << 1); + + x2r = x2r + x6r; + x2i = x2i + x6i; + x6r = x2r - (x6r << 1); + x6i = x2i - (x6i << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + + x4r = x4r + x6i; + x4i = x4i - x6r; + tmp = x6r; + x6r = x4r - (x6i << 1); + x6i = x4i + (tmp << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 2); + + twiddles -= 5 * (j >> 3); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x1r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x1i, twiddle_val)); + x1i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x1r, twiddle_val), x1i, + twiddle_val)) + << 1; + x1r = tmp << 1; + + x3r = *data; + x3i = *(data + 1); + data += (del << 2); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x3r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x3i, twiddle_val)); + x3i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x3r, twiddle_val), x3i, twiddle_val)); + x3r = tmp; + + x5r = *data; + x5i = *(data + 1); + data += (del << 2); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + + tmp = (ixheaacd_mult32x16lin32(x5r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x5i, twiddle_val)); + x5i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x5r, twiddle_val), x5i, twiddle_val)); + x5r = tmp; + + x7r = *data; + x7i = *(data + 1); + data -= 7 * (del << 1); + + twiddles += (j >> 2); + twiddle_val = *(twiddles); + twiddles -= 7 * (j >> 3); + + tmp = (ixheaacd_mult32x16lin32(x7r, twiddle_val) - + ixheaacd_mult32x16hin32_drc(x7i, twiddle_val)); + x7i = (ixheaacd_mac32x16lin32( + ixheaacd_mult32x16hin32_drc(x7r, twiddle_val), x7i, twiddle_val)); + x7r = tmp; + + x1r = x1r + (x5r << 1); + x1i = x1i + (x5i << 1); + x5r = x1r - (x5r << 2); + x5i = x1i - (x5i << 2); + + x3r = x3r + x7r; + x3i = x3i + x7i; + x7r = x3r - (x7r << 1); + x7i = x3i - (x7i << 1); + + x1r = x1r + (x3r << 1); + x1i = x1i + (x3i << 1); + x3r = x1r - (x3r << 2); + x3i = x1i - (x3i << 2); + + x5r = x5r + x5i; + x5i = x5r - (x5i << 1); + + x7r = x7r + x7i; + x7i = x7r - (x7i << 1); + + x7i = x5r - (x7i << 1); + x5r = x7i - (x5r << 1); + + x5i = (x7r << 1) - x5i; + x7r = x5i - (x7r << 2); + + x7i = x7i << 1; + x5r = x5r << 1; + x5i = x5i << 1; + x7r = x7r << 1; + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + + x2r = x2r + x3i; + tmp = x2r - (x3i << 1); + x2i = x2i - x3r; + x3i = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 2); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 2); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 2); + + *data = tmp; + *(data + 1) = x3i; + data -= 5 * (del << 1); + + tmp = 0x5A82; + + x7i = x4r + (ixheaacd_mult32x16lin32(x7i, tmp)); + x4r = x7i - (x4r << 1); + + x7r = x4i + (ixheaacd_mult32x16lin32(x7r, tmp)); + x4i = x7r - (x4i << 1); + + x5i = x6r + (ixheaacd_mult32x16lin32(x5i, tmp)); + x6r = x5i - (x6r << 1); + + x5r = x6i + (ixheaacd_mult32x16lin32(x5r, tmp)); + x6i = x5r - (x6i << 1); + + *data = x7i; + *(data + 1) = x7r; + data += (del << 2); + + *data = x5i; + *(data + 1) = x5r; + data += (del << 2); + + *data = -x4r; + *(data + 1) = -x4i; + data += (del << 2); + + *data = -x6r; + *(data + 1) = -x6i; + + data -= 7 * (del << 1); + data += (del << 4); + } + data -= npoints << 1; + } + + nodespacing >>= 3; + del <<= 3; + in_loop_cnt >>= 3; + } +} + +WORD32 ixheaacd_inverse_transform( + WORD32 spec_data[], WORD32 scratch[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 expo, + WORD32 npoints) { + (*ixheaacd_pretwiddle_compute)(spec_data, spec_data + npoints - 1, scratch, + ptr_imdct_tables, (npoints >> 2), expo); + + (*ixheaacd_imdct_using_fft)(ptr_imdct_tables, npoints >> 1, scratch, + spec_data); + + expo += 2; + + return expo; +} + +VOID ixheaacd_mdct_480_ld(WORD32 *inp, WORD32 *scratch, WORD32 *mdct_scale, + WORD32 mdct_flag, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, + WORD32 object_type) { + WORD32 expo, neg_expo = 0, k; + + WORD32 const_mltfac = 1145324612; + + expo = (*ixheaacd_calc_max_spectral_line)(inp, MDCT_LEN) - 1; + ; + + memcpy(scratch, inp, sizeof(WORD32) * MDCT_LEN); + + neg_expo = 7 - expo; + + ixheaacd_pre_twiddle(inp, scratch, 480, imdct_tables_ptr->cosine_array_960, + neg_expo); + + ixheaacd_fft_480_ld(inp, scratch, imdct_tables_ptr); + + if (object_type == AOT_ER_AAC_LD) { + ixheaacd_post_twiddle_ld(inp, scratch, imdct_tables_ptr->cosine_array_960, + 480); + } else if (object_type == AOT_ER_AAC_ELD) { + ixheaacd_post_twiddle_eld(inp + (480), scratch, + imdct_tables_ptr->cosine_array_960, 480); + } + + if (0 == mdct_flag) { + WORD32 *data = inp; + + if (object_type != AOT_ER_AAC_ELD) { + for (k = MDCT_LEN - 1; k >= 0; k -= 2) { + *data = ixheaacd_mult32_shl(*data, const_mltfac); + data++; + *data = ixheaacd_mult32_shl(*data, const_mltfac); + data++; + } + neg_expo += 1; + } else { + data = inp + 480; + for (k = (MDCT_LEN << 1) - 1; k >= 0; k -= 2) { + *data = ixheaacd_mult32_shl(*data, const_mltfac); + data++; + *data = ixheaacd_mult32_shl(*data, const_mltfac); + data++; + } + neg_expo += 1; + } + } + + *mdct_scale = neg_expo + 3; +} + +VOID ixheaacd_inverse_transform_512( + WORD32 data[], WORD32 temp[], WORD32 *imdct_scale, WORD32 *cos_sin_ptr, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 object_type) { + WORD32 n; + WORD32 npoints_2; + WORD16 expo, neg_expo; + + n = 512; + + npoints_2 = n >> 1; + + expo = (*ixheaacd_calc_max_spectral_line)(data, n) - 1; + + memcpy(temp, data, sizeof(WORD32) * n); + + neg_expo = 7 - expo; + + ixheaacd_pre_twiddle(data, temp, n, cos_sin_ptr, neg_expo); + + (*ixheaacd_fft32x32_ld)(imdct_tables_ptr, npoints_2, data, temp); + + neg_expo = (*ixheaacd_neg_expo_inc)(neg_expo); + + *imdct_scale = neg_expo + 1; + + if (object_type == AOT_ER_AAC_ELD) + ixheaacd_post_twiddle_eld((data + n), temp, cos_sin_ptr, n); + else + ixheaacd_post_twiddle_ld((data), temp, cos_sin_ptr, n); +} + +VOID ixheaacd_fft_480_ld(WORD32 *inp, WORD32 *op, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr) { + WORD32 i; + WORD32 *buf1, *buf2; + UWORD8 *re_arr_tab_sml_240_ptr; + + (*ixheaacd_aac_ld_dec_rearrange)(inp, op, MDCT_LEN_BY2, + imdct_tables_ptr->re_arr_tab_16); + + buf1 = op; + buf2 = inp; + + for (i = 0; i < FFT15; i++) { + (*ixheaacd_fft32x32_ld2)(imdct_tables_ptr, 16, buf1, buf2); + + buf1 += (FFT16X2); + buf2 += (FFT16X2); + } + re_arr_tab_sml_240_ptr = imdct_tables_ptr->re_arr_tab_sml_240; + buf1 = inp; + + for (i = 0; i < FFT16; i++) { + (*ixheaacd_fft_15_ld)(buf1, op, ixheaacd_fft5out, re_arr_tab_sml_240_ptr); + re_arr_tab_sml_240_ptr += FFT15; + buf1 += 2; + } +} + +static PLATFORM_INLINE VOID ixheaacd_pre_twiddle_compute_ld( + WORD32 *in_ptr1, WORD32 *in_ptr2, WORD32 *xptr, WORD32 *cos_sin_ptr, + WORD npoints_4, WORD32 neg_expo) { + WORD32 i; + WORD32 tempr, tempi, temp; + + WORD32 c, c1, s, s1; + + if (neg_expo >= 0) { + for (i = npoints_4 - 1; i >= 0; i--) { + c = *cos_sin_ptr++; + c1 = *cos_sin_ptr++; + s = *cos_sin_ptr++; + s1 = *cos_sin_ptr++; + + tempr = *in_ptr1; + tempi = *in_ptr2; + + in_ptr1 += 2; + in_ptr2 -= 2; + + temp = + -ixheaacd_add32(ixheaacd_mult32(tempr, c), ixheaacd_mult32(tempi, s)); + *xptr++ = ixheaacd_shr32(temp, neg_expo); + + temp = + ixheaacd_sub32(ixheaacd_mult32(tempr, s), ixheaacd_mult32(tempi, c)); + *xptr++ = ixheaacd_shr32(temp, neg_expo); + + tempr = *in_ptr1; + tempi = *in_ptr2; + + in_ptr1 += 2; + in_ptr2 -= 2; + + temp = -ixheaacd_add32(ixheaacd_mult32(tempr, c1), + ixheaacd_mult32(tempi, s1)); + *xptr++ = ixheaacd_shr32(temp, neg_expo); + + temp = ixheaacd_sub32(ixheaacd_mult32(tempr, s1), + ixheaacd_mult32(tempi, c1)); + *xptr++ = ixheaacd_shr32(temp, neg_expo); + } + } else { + neg_expo = -neg_expo; + + for (i = npoints_4 - 1; i >= 0; i--) { + c = *cos_sin_ptr++; + c1 = *cos_sin_ptr++; + s = *cos_sin_ptr++; + s1 = *cos_sin_ptr++; + + tempr = *in_ptr1; + tempi = *in_ptr2; + + in_ptr1 += 2; + in_ptr2 -= 2; + + temp = + -ixheaacd_add32(ixheaacd_mult32(tempr, c), ixheaacd_mult32(tempi, s)); + *xptr++ = ixheaacd_shl32(temp, neg_expo); + + temp = + ixheaacd_sub32(ixheaacd_mult32(tempr, s), ixheaacd_mult32(tempi, c)); + *xptr++ = ixheaacd_shl32(temp, neg_expo); + + tempr = *in_ptr1; + tempi = *in_ptr2; + + in_ptr1 += 2; + in_ptr2 -= 2; + + temp = -ixheaacd_add32(ixheaacd_mult32(tempr, c1), + ixheaacd_mult32(tempi, s1)); + *xptr++ = ixheaacd_shl32(temp, neg_expo); + + temp = ixheaacd_sub32(ixheaacd_mult32(tempr, s1), + ixheaacd_mult32(tempi, c1)); + *xptr++ = ixheaacd_shl32(temp, neg_expo); + } + } +} + +VOID ixheaacd_pre_twiddle(WORD32 *xptr, WORD32 *data, WORD32 n, + WORD32 *cos_array_ptr, WORD32 neg_expo) { + WORD npoints_4; + WORD32 *in_ptr1, *in_ptr2; + + npoints_4 = n >> 2; + + in_ptr1 = data; + in_ptr2 = data + n - 1; + + ixheaacd_pre_twiddle_compute_ld(in_ptr1, in_ptr2, xptr, cos_array_ptr, + npoints_4, neg_expo); +} + +VOID ixheaacd_post_twiddle_ld(WORD32 out[], WORD32 x[], + const WORD32 *cos_sin_ptr, WORD m) { + WORD i; + + WORD32 *ptr_x = &x[0]; + WORD32 *ptr_out, *ptr_out1; + + ptr_out = &out[0]; + ptr_out1 = &out[m - 1]; + + for (i = (m >> 2) - 1; i >= 0; i--) { + WORD32 c, c1, s, s1; + WORD32 re, im; + + c = *cos_sin_ptr++; + c1 = *cos_sin_ptr++; + s = *cos_sin_ptr++; + s1 = *cos_sin_ptr++; + + re = *ptr_x++; + im = *ptr_x++; + + *ptr_out1 = ixheaacd_sub32(ixheaacd_mult32(im, c), ixheaacd_mult32(re, s)); + + *ptr_out = -ixheaacd_add32(ixheaacd_mult32(re, c), ixheaacd_mult32(im, s)); + + ptr_out += 2; + ptr_out1 -= 2; + + re = *ptr_x++; + im = *ptr_x++; + + *ptr_out1 = + ixheaacd_sub32(ixheaacd_mult32(im, c1), ixheaacd_mult32(re, s1)); + *ptr_out = + -ixheaacd_add32(ixheaacd_mult32(re, c1), ixheaacd_mult32(im, s1)); + + ptr_out += 2; + ptr_out1 -= 2; + } +} + +VOID ixheaacd_post_twiddle_eld(WORD32 out[], WORD32 x[], + const WORD32 *cos_sin_ptr, WORD m) { + WORD i = 0; + + WORD32 *ptr_x = &x[0]; + WORD32 *ptr_out_767, *ptr_out_256; + WORD32 *ptr_out_768, *ptr_out_255; + WORD32 *ptr_out_0, *ptr_out_1279; + WORD32 tempr, tempi; + + ptr_out_767 = &out[m + (m >> 1) - 1 - 2 * i]; + ptr_out_256 = &out[(m >> 1) + 2 * i]; + + ptr_out_768 = &out[m + (m >> 1) + 2 * i]; + ptr_out_255 = &out[(m >> 1) - 1 - 2 * i]; + + for (i = 0; i < (m >> 3); i++) { + WORD32 c, c1, s, s1; + WORD32 re, im; + + c = *cos_sin_ptr++; + c1 = *cos_sin_ptr++; + s = *cos_sin_ptr++; + s1 = *cos_sin_ptr++; + + re = *ptr_x++; + im = *ptr_x++; + + tempi = ixheaacd_sub32(ixheaacd_mult32(im, c), ixheaacd_mult32(re, s)); + tempr = -ixheaacd_add32(ixheaacd_mult32(re, c), ixheaacd_mult32(im, s)); + + *ptr_out_767 = tempr; + *ptr_out_256 = tempi; + + *ptr_out_768 = *ptr_out_767; + *ptr_out_255 = -*ptr_out_256; + + ptr_out_256 += 2; + ptr_out_767 -= 2; + ptr_out_768 += 2; + ptr_out_255 -= 2; + + re = *ptr_x++; + im = *ptr_x++; + + tempi = ixheaacd_sub32(ixheaacd_mult32(im, c1), ixheaacd_mult32(re, s1)); + tempr = -ixheaacd_add32(ixheaacd_mult32(re, c1), ixheaacd_mult32(im, s1)); + + *ptr_out_767 = tempr; + *ptr_out_256 = tempi; + + *ptr_out_768 = *ptr_out_767; + *ptr_out_255 = -*ptr_out_256; + + ptr_out_256 += 2; + ptr_out_767 -= 2; + ptr_out_768 += 2; + ptr_out_255 -= 2; + } + + ptr_out_0 = &out[2 * 2 * i - (m >> 1)]; + ptr_out_1279 = &out[m + m + (m >> 1) - 1 - 2 * 2 * i]; + + for (; i < (m >> 2); i++) { + WORD32 c, c1, s, s1; + WORD32 re, im; + + c = *cos_sin_ptr++; + c1 = *cos_sin_ptr++; + s = *cos_sin_ptr++; + s1 = *cos_sin_ptr++; + + re = *ptr_x++; + im = *ptr_x++; + + tempi = ixheaacd_sub32(ixheaacd_mult32(im, c), ixheaacd_mult32(re, s)); + tempr = -ixheaacd_add32(ixheaacd_mult32(re, c), ixheaacd_mult32(im, s)); + + *ptr_out_767 = tempr; + *ptr_out_256 = tempi; + + *ptr_out_0 = -*ptr_out_767; + *ptr_out_1279 = *ptr_out_256; + + ptr_out_256 += 2; + ptr_out_767 -= 2; + ptr_out_0 += 2; + ptr_out_1279 -= 2; + + re = *ptr_x++; + im = *ptr_x++; + + tempi = ixheaacd_sub32(ixheaacd_mult32(im, c1), ixheaacd_mult32(re, s1)); + tempr = -ixheaacd_add32(ixheaacd_mult32(re, c1), ixheaacd_mult32(im, s1)); + + *ptr_out_767 = tempr; + *ptr_out_256 = tempi; + + *ptr_out_0 = -*ptr_out_767; + *ptr_out_1279 = *ptr_out_256; + + ptr_out_256 += 2; + ptr_out_767 -= 2; + ptr_out_0 += 2; + ptr_out_1279 -= 2; + } +} + +VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, + WORD32 npoints, WORD32 *ptr_x, WORD32 *ptr_y) { + WORD32 i, j, l1, l2, h2, predj, tw_offset, stride, fft_jmp; + WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0; + WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0; + WORD32 xh0_1, xh1_1, xl0_1, xl1_1; + WORD32 x_0, x_1, x_2, x_3, x_l1_0, x_l1_1, x_l2_0, x_l2_1; + WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3; + WORD32 x_4, x_5, x_6, x_7, x_h2_0, x_h2_1; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 si10, si20, si30, co10, co20, co30; + WORD32 *w; + WORD32 *x, *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 radix; + WORD32 norm; + WORD32 m; + WORD32 *ptr_w; + + if (npoints == 256) + ptr_w = imdct_tables_ptr->w_256; + else + ptr_w = imdct_tables_ptr->w_16; + + for (i = 31, m = 1; (npoints & (1 << i)) == 0; i--, m++) + ; + radix = m & 1 ? 2 : 4; + norm = m - 2; + + stride = npoints; + tw_offset = 0; + fft_jmp = 6 * stride; + + while (stride > radix) { + j = 0; + fft_jmp >>= 2; + + h2 = stride >> 1; + l1 = stride; + l2 = stride + (stride >> 1); + + x = ptr_x; + w = ptr_w + tw_offset; + tw_offset += fft_jmp; + + stride >>= 2; + + for (i = 0; i < npoints; i += 4) { + co10 = w[j + 1]; + si10 = w[j + 0]; + co20 = w[j + 3]; + si20 = w[j + 2]; + co30 = w[j + 5]; + si30 = w[j + 4]; + + x_0 = x[0]; + x_1 = x[1]; + x_l1_0 = x[l1]; + x_l1_1 = x[l1 + 1]; + x_l2_0 = x[l2]; + x_l2_1 = x[l2 + 1]; + 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; + + x0 = x; + x2 = x0; + + j += 6; + x += 2; + predj = (j - fft_jmp); + 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; + + x2[h2] = + MPYHIRC(si10, yt1_0) + MPYHIRC(co10, xt1_0) + + (((MPYLUHS(si10, yt1_0) + MPYLUHS(co10, xt1_0) + 0x8000) >> 16) << 1); + + x2[h2 + 1] = + MPYHIRC(co10, yt1_0) - MPYHIRC(si10, xt1_0) + + (((MPYLUHS(co10, yt1_0) - MPYLUHS(si10, xt1_0) + 0x8000) >> 16) << 1); + + x2[l1] = + MPYHIRC(si20, yt0_0) + MPYHIRC(co20, xt0_0) + + (((MPYLUHS(si20, yt0_0) + MPYLUHS(co20, xt0_0) + 0x8000) >> 16) << 1); + + x2[l1 + 1] = + MPYHIRC(co20, yt0_0) - MPYHIRC(si20, xt0_0) + + (((MPYLUHS(co20, yt0_0) - MPYLUHS(si20, xt0_0) + 0x8000) >> 16) << 1); + + x2[l2] = + MPYHIRC(si30, yt2_0) + MPYHIRC(co30, xt2_0) + + (((MPYLUHS(si30, yt2_0) + MPYLUHS(co30, xt2_0) + 0x8000) >> 16) << 1); + + x2[l2 + 1] = + MPYHIRC(co30, yt2_0) - MPYHIRC(si30, xt2_0) + + (((MPYLUHS(co30, yt2_0) - MPYLUHS(si30, xt2_0) + 0x8000) >> 16) << 1); + } + } + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + if (radix == 2) { + y1 = y0 + (WORD32)(npoints >> 2); + y3 = y2 + (WORD32)(npoints >> 2); + l1 = norm + 1; + j0 = 8; + n0 = npoints >> 1; + } else { + y1 = y0 + (WORD32)(npoints >> 1); + y3 = y2 + (WORD32)(npoints >> 1); + l1 = norm + 2; + j0 = 4; + n0 = npoints >> 2; + } + + j = 0; + + for (i = 0; i < npoints; i += 8) { + DIG_REV(j, l1, h2); + + x_0 = x0[0]; + x_1 = x0[1]; + x_2 = x0[2]; + x_3 = x0[3]; + x_4 = x0[4]; + x_5 = x0[5]; + x_6 = x0[6]; + 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; + + 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; + } + + y0[2 * h2] = n00; + y0[2 * h2 + 1] = n01; + y1[2 * h2] = n10; + y1[2 * h2 + 1] = n11; + y2[2 * h2] = n20; + y2[2 * h2 + 1] = n21; + y3[2 * h2] = n30; + y3[2 * h2 + 1] = n31; + + x_8 = x2[0]; + x_9 = x2[1]; + x_a = x2[2]; + x_b = x2[3]; + x_c = x2[4]; + x_d = x2[5]; + x_e = x2[6]; + 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; + + 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; + } + + y0[2 * h2 + 2] = n02; + y0[2 * h2 + 3] = n03; + y1[2 * h2 + 2] = n12; + y1[2 * h2 + 3] = n13; + y2[2 * h2 + 2] = n22; + y2[2 * h2 + 3] = n23; + y3[2 * h2 + 2] = n32; + y3[2 * h2 + 3] = n33; + + j += j0; + + if (j == n0) { + j += n0; + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } + } +} + +VOID ixheaacd_rearrange_dec(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab) { + WORD32 n, i = 0; + + for (n = 0; n < mdct_len_2; n++) { + WORD32 idx = re_arr_tab[n] << 1; + + op[i++] = ip[idx]; + op[i++] = ip[idx + 1]; + } +} + +VOID ixheaacd_fft_15_ld_dec(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr) { + WORD32 i, n, idx; + WORD32 *buf1, *buf2, *buf1a; + WORD32 add_r, sub_r; + WORD32 add_i, sub_i; + WORD32 x01_real, x_01_imag, temp; + WORD32 p1, p2, p3, p4; + + WORD32 sinmu = 1859775393; + WORD32 cos_51 = 2042378317; + WORD32 cos_52 = -1652318768; + WORD32 cos_53 = -780119100; + WORD32 cos_54 = 1200479854; + WORD32 cos_55 = -1342177280; + + WORD32 r1, r2, r3, r4; + WORD32 s1, s2, s3, s4, t, temp1, temp2; + WORD32 *fft3outptr = fft3out; + + WORD32 xr_0, xr_1, xr_2; + WORD32 xi_0, xi_1, xi_2; + + buf2 = fft3out; + buf1 = buf1a = fft3out; + n = 0; + + { + *buf1++ = inp[0]; + *buf1++ = inp[1]; + + *buf1++ = inp[96]; + *buf1++ = inp[97]; + + *buf1++ = inp[192]; + *buf1++ = inp[193]; + + *buf1++ = inp[288]; + *buf1++ = inp[289]; + + *buf1++ = inp[384]; + *buf1++ = inp[385]; + + r1 = buf1a[2] + buf1a[8]; + r4 = buf1a[2] - buf1a[8]; + r3 = buf1a[4] + buf1a[6]; + r2 = buf1a[4] - buf1a[6]; + + t = ixheaacd_mult32_shl((r1 - r3), cos_54); + + r1 = r1 + r3; + + temp1 = buf1a[0] + r1; + + r1 = temp1 + ((ixheaacd_mult32_shl(r1, cos_55)) << 1); + + r3 = r1 - t; + r1 = r1 + t; + + t = ixheaacd_mult32_shl((r4 + r2), cos_51); + r4 = t + (ixheaacd_mult32_shl(r4, cos_52) << 1); + r2 = t + ixheaacd_mult32_shl(r2, cos_53); + + s1 = buf1a[3] + buf1a[9]; + s4 = buf1a[3] - buf1a[9]; + s3 = buf1a[5] + buf1a[7]; + s2 = buf1a[5] - buf1a[7]; + + t = ixheaacd_mult32_shl((s1 - s3), cos_54); + s1 = s1 + s3; + + temp2 = buf1a[1] + s1; + + s1 = temp2 + ((ixheaacd_mult32_shl(s1, cos_55)) << 1); + + s3 = s1 - t; + s1 = s1 + t; + + t = ixheaacd_mult32_shl((s4 + s2), cos_51); + s4 = t + ((ixheaacd_mult32_shl(s4, cos_52)) << 1); + s2 = t + (ixheaacd_mult32_shl(s2, cos_53)); + + *buf2++ = temp1; + *buf2++ = temp2; + *buf2++ = r1 + s2; + *buf2++ = s1 - r2; + *buf2++ = r3 - s4; + *buf2++ = s3 + r4; + *buf2++ = r3 + s4; + *buf2++ = s3 - r4; + *buf2++ = r1 - s2; + *buf2++ = s1 + r2; + buf1a = buf1; + + *buf1++ = inp[160]; + *buf1++ = inp[161]; + + *buf1++ = inp[256]; + *buf1++ = inp[257]; + + *buf1++ = inp[352]; + *buf1++ = inp[353]; + + *buf1++ = inp[448]; + *buf1++ = inp[449]; + + *buf1++ = inp[64]; + *buf1++ = inp[65]; + + r1 = buf1a[2] + buf1a[8]; + r4 = buf1a[2] - buf1a[8]; + r3 = buf1a[4] + buf1a[6]; + r2 = buf1a[4] - buf1a[6]; + + t = ixheaacd_mult32_shl((r1 - r3), cos_54); + + r1 = r1 + r3; + + temp1 = buf1a[0] + r1; + + r1 = temp1 + ((ixheaacd_mult32_shl(r1, cos_55)) << 1); + + r3 = r1 - t; + r1 = r1 + t; + + t = ixheaacd_mult32_shl((r4 + r2), cos_51); + r4 = t + (ixheaacd_mult32_shl(r4, cos_52) << 1); + r2 = t + ixheaacd_mult32_shl(r2, cos_53); + + s1 = buf1a[3] + buf1a[9]; + s4 = buf1a[3] - buf1a[9]; + s3 = buf1a[5] + buf1a[7]; + s2 = buf1a[5] - buf1a[7]; + + t = ixheaacd_mult32_shl((s1 - s3), cos_54); + + s1 = s1 + s3; + + temp2 = buf1a[1] + s1; + + s1 = temp2 + ((ixheaacd_mult32_shl(s1, cos_55)) << 1); + + s3 = s1 - t; + s1 = s1 + t; + + t = ixheaacd_mult32_shl((s4 + s2), cos_51); + s4 = t + ((ixheaacd_mult32_shl(s4, cos_52)) << 1); + s2 = t + (ixheaacd_mult32_shl(s2, cos_53)); + + *buf2++ = temp1; + *buf2++ = temp2; + *buf2++ = r1 + s2; + *buf2++ = s1 - r2; + *buf2++ = r3 - s4; + *buf2++ = s3 + r4; + *buf2++ = r3 + s4; + *buf2++ = s3 - r4; + *buf2++ = r1 - s2; + *buf2++ = s1 + r2; + buf1a = buf1; + ; + + *buf1++ = inp[320]; + *buf1++ = inp[321]; + + *buf1++ = inp[416]; + *buf1++ = inp[417]; + + *buf1++ = inp[32]; + *buf1++ = inp[33]; + + *buf1++ = inp[128]; + *buf1++ = inp[129]; + + *buf1++ = inp[224]; + *buf1++ = inp[225]; + + r1 = buf1a[2] + buf1a[8]; + r4 = buf1a[2] - buf1a[8]; + r3 = buf1a[4] + buf1a[6]; + r2 = buf1a[4] - buf1a[6]; + + t = ixheaacd_mult32_shl((r1 - r3), cos_54); + + r1 = r1 + r3; + + temp1 = buf1a[0] + r1; + + r1 = temp1 + ((ixheaacd_mult32_shl(r1, cos_55)) << 1); + + r3 = r1 - t; + r1 = r1 + t; + + t = ixheaacd_mult32_shl((r4 + r2), cos_51); + r4 = t + (ixheaacd_mult32_shl(r4, cos_52) << 1); + r2 = t + ixheaacd_mult32_shl(r2, cos_53); + + s1 = buf1a[3] + buf1a[9]; + s4 = buf1a[3] - buf1a[9]; + s3 = buf1a[5] + buf1a[7]; + s2 = buf1a[5] - buf1a[7]; + + t = ixheaacd_mult32_shl((s1 - s3), cos_54); + + s1 = s1 + s3; + + temp2 = buf1a[1] + s1; + + s1 = temp2 + ((ixheaacd_mult32_shl(s1, cos_55)) << 1); + + s3 = s1 - t; + s1 = s1 + t; + + t = ixheaacd_mult32_shl((s4 + s2), cos_51); + s4 = t + ((ixheaacd_mult32_shl(s4, cos_52)) << 1); + s2 = t + (ixheaacd_mult32_shl(s2, cos_53)); + + *buf2++ = temp1; + *buf2++ = temp2; + *buf2++ = r1 + s2; + *buf2++ = s1 - r2; + *buf2++ = r3 - s4; + *buf2++ = s3 + r4; + *buf2++ = r3 + s4; + *buf2++ = s3 - r4; + *buf2++ = r1 - s2; + *buf2++ = s1 + r2; + buf1a = buf1; + ; + } + + n = 0; + for (i = 0; i < FFT5; i++) { + xr_0 = fft3outptr[0]; + xi_0 = fft3outptr[1]; + + xr_1 = fft3outptr[10]; + xi_1 = fft3outptr[11]; + + xr_2 = fft3outptr[20]; + xi_2 = fft3outptr[21]; + + x01_real = ixheaacd_add32(xr_0, xr_1); + x_01_imag = ixheaacd_add32(xi_0, xi_1); + + add_r = ixheaacd_add32(xr_1, xr_2); + add_i = ixheaacd_add32(xi_1, xi_2); + + sub_r = ixheaacd_sub32(xr_1, xr_2); + sub_i = ixheaacd_sub32(xi_1, xi_2); + + p1 = add_r >> 1; + + p2 = ixheaacd_mult32_shl(sub_i, sinmu); + p3 = ixheaacd_mult32_shl(sub_r, sinmu); + + p4 = add_i >> 1; + + temp = ixheaacd_sub32(xr_0, p1); + temp1 = ixheaacd_add32(xi_0, p3); + temp2 = ixheaacd_sub32(xi_0, p3); + + idx = re_arr_tab_sml_240_ptr[n++] << 1; + op[idx] = ixheaacd_add32(x01_real, xr_2); + op[idx + 1] = ixheaacd_add32(x_01_imag, xi_2); + + idx = re_arr_tab_sml_240_ptr[n++] << 1; + op[idx] = ixheaacd_add32(temp, p2); + op[idx + 1] = ixheaacd_sub32(temp2, p4); + + idx = re_arr_tab_sml_240_ptr[n++] << 1; + op[idx] = ixheaacd_sub32(temp, p2); + op[idx + 1] = ixheaacd_sub32(temp1, p4); + fft3outptr += 2; + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_aac_imdct.h b/decoder/ixheaacd_aac_imdct.h new file mode 100644 index 0000000..d6dc58f --- /dev/null +++ b/decoder/ixheaacd_aac_imdct.h @@ -0,0 +1,132 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_AAC_IMDCT_H +#define IXHEAACD_AAC_IMDCT_H + +WORD32 ixheaacd_inverse_transform( + WORD32 spec_data[], WORD32 scratch[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 expo, + WORD32 npoints); + +VOID ixheaacd_post_twiddle_dec(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD32 npoints); + +VOID ixheaacd_post_twiddle_armv7( + WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints); + +VOID ixheaacd_post_twiddle_armv8( + WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints); + +VOID ixheaacd_post_twid_overlap_add_dec( + WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac); + +VOID ixheaacd_post_twid_overlap_add_armv7( + WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac); + +VOID ixheaacd_post_twid_overlap_add_armv8( + WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac); + +VOID ixheaacd_pretwiddle_compute_dec( + WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo); + +VOID ixheaacd_pretwiddle_compute_armv7( + WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo); + +VOID ixheaacd_pretwiddle_compute_armv8( + WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo); + +VOID ixheaacd_imdct_using_fft_dec( + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +VOID ixheaacd_imdct_using_fft_armv7( + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +VOID ixheaacd_imdct_using_fft_armv8( + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +VOID ixheaacd_fft_480_ld(WORD32 *inp, WORD32 *op, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr); + +VOID ixheaacd_pre_twiddle(WORD32 *xptr, WORD32 *data, WORD32 n, + WORD32 *cos_array_ptr, WORD32 neg_expo); + +VOID ixheaacd_post_twiddle_ld(WORD32 out[], WORD32 x[], + const WORD32 *cos_sin_ptr, WORD m); + +VOID ixheaacd_post_twiddle_eld(WORD32 out[], WORD32 x[], + const WORD32 *cos_sin_ptr, WORD m); + +VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, + WORD32 npoints, WORD32 *ptr_x, WORD32 *ptr_y); + +VOID ixheaacd_fft32x32_ld2_armv7( + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +VOID ixheaacd_fft32x32_ld2_armv8( + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +WORD16 ixheaacd_neg_expo_inc_dec(WORD16 neg_expo); + +WORD16 ixheaacd_neg_expo_inc_arm(WORD16 neg_expo); + +VOID ixheaacd_rearrange_dec(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab); + +VOID ia_aac_ld_dec_rearrange_armv7(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab); + +VOID ixheaacd_fft_15_ld_dec(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr); + +VOID ixheaacd_fft_15_ld_armv7(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr); + +VOID ixheaacd_inverse_transform_512( + WORD32 data[], WORD32 temp[], WORD32 *imdct_scale, WORD32 *cos_sin_ptr, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 object_type); + +VOID ixheaacd_mdct_480_ld(WORD32 *inp, WORD32 *scratch, WORD32 *mdct_scale, + WORD32 mdct_flag, + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, + WORD32 object_type); +#endif diff --git a/decoder/ixheaacd_aac_rom.c b/decoder/ixheaacd_aac_rom.c new file mode 100644 index 0000000..ca52137 --- /dev/null +++ b/decoder/ixheaacd_aac_rom.c @@ -0,0 +1,2265 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_intrinsics.h" + +// -1 is appended at the end of each table to identify +// number of scf bands at run time +// +const ia_aac_dec_huffman_tables_struct ixheaacd_aac_huffmann_tables = { + + // static const WORD8 ixheaacd_sfb_96_1024[42] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, + 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, -1}, + + // 12 scfbands + // static const WORD8 ixheaacd_sfb_96_128[13] = + {4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36, -1}, + + // 47 scfbands + // static const WORD8 ixheaacd_sfb_64_1024[48] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, + 8, 8, 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, -1}, + + // 12 scfbands */ + // static const WORD8 ixheaacd_sfb_64_128[13] = + // same as ixheaacd_sfb_96_128 + + // 49 scfbands + // static const WORD8 ixheaacd_sfb_48_1024[50] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, + 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 96, -1}, + + // 14 scfbands + // static const WORD8 ixheaacd_sfb_48_128[15] = + {4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16, -1}, + + // 51 scfbands + // static const WORD8 ixheaacd_sfb_32_1024[52] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, + 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, -1}, + + // 47 scfbands + // static const WORD8 ixheaacd_sfb_24_1024[48] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, + 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64, -1}, + + // 15 scfbands + // static const WORD8 ixheaacd_sfb_24_128[16] = + {4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20, -1}, + + // 43 scfbands + // static const WORD8 ixheaacd_sfb_16_1024[44] = + {8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, + 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64, -1}, + + // 15 scfbands + // static const WORD8 ixheaacd_sfb_16_128[16] = + {4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20, -1}, + + // 40 scfbands + // static const WORD8 ixheaacd_sfb_8_1024[41] = + {12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, + 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, + 28, 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80, -1}, + + // 15 scfbands + // static const WORD8 ixheaacd_sfb_8_128[16] = + {4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20, -1}, + + // const ia_sampling_rate_info_struct str_sample_rate_info[16] = + {{96000}, + {88200}, + {64000}, + {48000}, + {44100}, + {32000}, + {24000}, + {22050}, + {16000}, + {12000}, + {11025}, + {8000}, + {7350}}, + + // 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 + // +------------------------------------------------+ + // | 1| Len | Symbol | + // +------------------------------------------------+ + // | 0| | Offset | + // +------------------------------------------------+ + // LSB (00) is set 1 when the codeword is decoded + // + // HuffmanCodeBook_1 + // idx_hf11 + { + 0x20100001, 0x41e00045, 0x659000c6, 0x890001c4, 0x0e6003df, 0xaef003e8, + 0x10d007ef, 0x115007f7, 0x119007fb, 0xd1a007fc, 0x11e00ffd, 0x11f00ffe, + 0x12000fff, 0xc0700009, 0x052000bf, 0x08b001bf, 0x0c6003bf, 0x0fd007df, + 0x11c00ffb, 0x20e0001a, 0x0180003f, + }, + + // idx_hf10 + {0x10200002, 0x21800029, 0x32900064, 0x442000e2, 0x561001e4, + 0x087003ef, 0x68a003f2, 0x09c007f7, 0x0a0007fb, 0x0a400ffb, + 0x0a600ffd, 0x0a700ffe, 0x0a800fff, 0x60a0000d, 0x0240005f, + 0x03f000df, 0x05c001df, 0x077003df, 0x094007ef, 0x00e0001f}, + + // idx_hf9 + {0x00000000, 0x00200005, 0x1030000c, 0x20a00072, 0x31d001e6, 0x431003e1, + 0x550007e2, 0x67600feb, 0x08e01fef, 0x09601ff7, 0x09e03ff7, 0x0a203ffb, + 0x0a403ffd, 0x0a607ffd, 0x0a707ffe, 0x0a807fff, 0x00700037, 0x512000ed, + 0x02f003df, 0x04d007df, 0x06a00fdf, 0x07e01fdf, 0x016001df}, + // idx_hf8 + {0x10000000, 0x20c00014, 0x31600033, 0x42400075, 0x030000f7, 0x533000fa, + 0x039001fb, 0x03b001fd, 0x03d003fd, 0x03e003fe, 0x03f003ff, 0x50500006, + 0x0120002f, 0x01e0006f, 0x028000ef, 0x035001f7, 0x0070000f}, + + // idx_hf7 + {0x00000000, 0x00200005, 0x1030000c, 0x20c00074, 0x316000f3, 0x424001f5, + 0x030003f7, 0x533003fa, 0x039007fb, 0x03b007fd, 0x03d00ffd, 0x03e00ffe, + 0x03f00fff, 0x00700037, 0x012000ef, 0x01e001ef, 0x028003ef, 0x035007f7}, + + // idx_hf6 + {0x00700007, 0x10800008, 0x21800033, 0x32500074, 0x42d000f1, 0x041001f7, + 0x544001fa, 0x04a003fb, 0x04c003fd, 0x04e007fd, 0x04f007fe, 0x050007ff, + 0x0140002f, 0x0200006f, 0x02b000ef, 0x039001ef, 0x046003f7}, + + // idx_hf5 + {0x00000000, 0x0040000b, 0x0080001b, 0x10c00073, 0x218000f3, 0x324001f3, + 0x430003f3, 0x040007f7, 0x542007f9, 0x04a00ffb, 0x04c00ffd, 0x04e01ffd, + 0x04f01ffe, 0x05001fff, 0x014000ef, 0x020001ef, 0x02c003ef, 0x038007ef, + 0x04600ff7}, + + // idx_hf4 + {0x00700007, 0x10900009, 0x20f00019, 0x31800070, 0x42d000f6, 0x535001f5, + 0x041003f7, 0x643003f9, 0x04b007fb, 0x04d007fd, 0x04e007fe, 0x04f00ffe, + 0x05000fff, 0x00d00017, 0x0170006f, 0x026000ef, 0x02f001ef, 0x039003ef, + 0x047007f7}, + + // idx_hf3 + {0x00000000, 0x0040000b, 0x10600019, 0x20c00039, 0x314000f2, 0x423001f4, + 0x031003f7, 0x532003f8, 0x63a007f9, 0x04200ffb, 0x74300ffc, 0x84601ffc, + 0x94903ffc, 0x04d07ffd, 0x04e07ffe, 0x04f0fffe, 0x0500ffff, 0x00a00037, + 0x80f00076, 0x01e001ef, 0x029003ef, 0x038007f7, 0x03e00ff7, 0x04501ffb, + 0x04803ffb, 0x04b07ffb, 0x011000ef}, + + // idx_hf2 + {0x10000000, 0x01e0002f, 0x22000031, 0x32f00072, 0x041000f7, 0x442000f8, + 0x04c001fb, 0x04e001fd, 0x04f001fe, 0x050001ff, 0x40100002, 0x02c0006f, + 0x039000ef, 0x048001f7, 0x1080000c, 0x00e0001f}, + + // idx_hf1 + {0x00000000, 0x00800017, 0x0180006f, 0x02000077, 0x030001ef, 0x038001f7, + 0x040003f7, 0x048007f7, 0x04c007fb, 0x04e007fd, 0x04f007fe, 0x050007ff}, + + // inp_hf11 + {0x000c, 0x0004, 0x0244, 0x2405, 0x0225, 0x0025, 0x0465, 0x0265, 0x0485, + 0x0286, 0x0686, 0x06a6, 0x0446, 0x04a6, 0x0046, 0x06c6, 0x08a7, 0x02a7, + 0x08c7, 0x04c7, 0x08e7, 0x06e7, 0x0667, 0x0067, 0x0ac7, 0x0ae7, 0x04e7, + 0x0907, 0x02c7, 0x0b07, 0x0707, 0x0b27, 0x0928, 0x0d08, 0x0508, 0x0ce8, + 0x0d28, 0x0728, 0x02e8, 0x0a88, 0x0868, 0x22a8, 0x2268, 0x2288, 0x0d48, + 0x22c8, 0x0888, 0x0948, 0x0088, 0x0648, 0x0b48, 0x0ca8, 0x22e8, 0x2248, + 0x2308, 0x0528, 0x0f28, 0x0748, 0x0d68, 0x0b68, 0x0ec8, 0x2348, 0x0f48, + 0x0f08, 0x2328, 0x10e8, 0x0428, 0x0308, 0x0968, 0x2368, 0x0f68, 0x2388, + 0x1308, 0x2228, 0x0d88, 0x1528, 0x0548, 0x0b88, 0x1748, 0x23a8, 0x1168, + 0x1148, 0x0768, 0x0aa8, 0x23c8, 0x1968, 0x0f88, 0x0988, 0x0da8, 0x0fa8, + 0x00a8, 0x1189, 0x23e9, 0x1b89, 0x0329, 0x1129, 0x1fc9, 0x0ba9, 0x1da9, + 0x0789, 0x11a9, 0x0fc9, 0x0569, 0x11c9, 0x1369, 0x1389, 0x21e9, 0x09a9, + 0x0dc9, 0x0cc9, 0x13a9, 0x0bc9, 0x11e9, 0x0fe9, 0x0349, 0x15a9, 0x00c9, + 0x1589, 0x1349, 0x13c9, 0x09c9, 0x0589, 0x13e9, 0x07a9, 0x0de9, 0x15c9, + 0x1209, 0x15e9, 0x1409, 0x17c9, 0x0369, 0x0ee9, 0x1609, 0x1009, 0x07c9, + 0x0be9, 0x1569, 0x09e9, 0x17a9, 0x1be9, 0x0e09, 0x1c09, 0x05a9, 0x2209, + 0x0c09, 0x1809, 0x17ea, 0x142a, 0x102a, 0x122a, 0x020a, 0x0a2a, 0x00ea, + 0x080a, 0x182a, 0x1bca, 0x1c2a, 0x19ea, 0x05ea, 0x1c4a, 0x124a, 0x0e2a, + 0x164a, 0x162a, 0x1e0a, 0x1a0a, 0x038a, 0x0a0a, 0x178a, 0x07ea, 0x03ca, + 0x19ca, 0x104a, 0x082a, 0x0c2a, 0x0c4a, 0x1e4a, 0x0a4a, 0x184a, 0x1e2a, + 0x1a2a, 0x1c6a, 0x1a4a, 0x110a, 0x186a, 0x05ca, 0x144a, 0x1e6a, 0x0e6a, + 0x168a, 0x202a, 0x126a, 0x146a, 0x1e8a, 0x166a, 0x0c6a, 0x188a, 0x1dea, + 0x060a, 0x0e4a, 0x03aa, 0x1caa, 0x010a, 0x1c8a, 0x106a, 0x1a6a, 0x108a, + 0x204a, 0x19aa, 0x0e8a, 0x062a, 0x208a, 0x206a, 0x03ea, 0x148a, 0x0a6a, + 0x1eaa, 0x12aa, 0x1cca, 0x128a, 0x0c8a, 0x084a, 0x16aa, 0x18aa, 0x1a8a, + 0x20aa, 0x20ca, 0x12ca, 0x200a, 0x10aa, 0x132a, 0x012a, 0x14ca, 0x14aa, + 0x1aaa, 0x1eca, 0x16ea, 0x1eea, 0x1aca, 0x0eaa, 0x10ca, 0x14eb, 0x20eb, + 0x18cb, 0x192b, 0x040b, 0x16cb, 0x170b, 0x1d0b, 0x1ceb, 0x190b, 0x18eb, + 0x12eb, 0x1f2b, 0x1d2b, 0x1b2b, 0x210b, 0x1f0b, 0x154b, 0x1aeb, 0x150b, + 0x014b, 0x1b0b, 0x176b, 0x1b4b, 0x172b, 0x1d4b, 0x01ab, 0x1f4b, 0x212b, + 0x214b, 0x194b, 0x1f6b, 0x1bab, 0x016b, 0x1d6b, 0x216b, 0x218b, 0x1b6b, + 0x1dcb, 0x1f8b, 0x1d8b, 0x198b, 0x1fab, 0x01cc, 0x018c, 0x21ac, 0x1fec, + 0x01ec, 0x21cc}, + // inp_hf10 + {0x000c, 0x01c4, 0x01e4, 0x0364, 0x0385, 0x01a5, 0x0025, 0x0205, 0x0525, + 0x0505, 0x03a5, 0x0545, 0x0346, 0x0046, 0x03c6, 0x06c6, 0x0226, 0x06a6, + 0x0006, 0x06e6, 0x0566, 0x04e6, 0x0066, 0x0706, 0x03e6, 0x0866, 0x0247, + 0x0847, 0x0887, 0x0587, 0x08a7, 0x0727, 0x0a07, 0x0407, 0x0a27, 0x0687, + 0x09e7, 0x0087, 0x0267, 0x05a7, 0x08c7, 0x0a47, 0x0747, 0x0a68, 0x0ba8, + 0x05c8, 0x0428, 0x08e8, 0x0d48, 0x0bc8, 0x0828, 0x0b88, 0x00a8, 0x0d28, + 0x0288, 0x0d68, 0x0be8, 0x0768, 0x0448, 0x0a88, 0x0c08, 0x02a8, 0x05e8, + 0x0d88, 0x0788, 0x0908, 0x0da8, 0x0928, 0x0c29, 0x0aa9, 0x0ee9, 0x09c9, + 0x0ac9, 0x0f09, 0x0609, 0x0ec9, 0x0469, 0x00c9, 0x0dc9, 0x0f29, 0x07a9, + 0x1089, 0x02c9, 0x0c49, 0x0de9, 0x0f49, 0x0c69, 0x10a9, 0x0949, 0x10c9, + 0x0489, 0x1069, 0x0629, 0x0f69, 0x0ae9, 0x0d09, 0x07c9, 0x0b69, 0x1229, + 0x0c8a, 0x124a, 0x110a, 0x02ea, 0x120a, 0x0f8a, 0x00ea, 0x0e0a, 0x10ea, + 0x064a, 0x096a, 0x0e2a, 0x128a, 0x010a, 0x126a, 0x04aa, 0x0caa, 0x0b0a, + 0x112a, 0x07ea, 0x030a, 0x13ca, 0x0faa, 0x13ea, 0x12aa, 0x098a, 0x140a, + 0x12ca, 0x142a, 0x066a, 0x0b2a, 0x0eaa, 0x114a, 0x104a, 0x13aa, 0x012a, + 0x080a, 0x0fca, 0x144a, 0x04ca, 0x0e4a, 0x0feb, 0x032b, 0x12eb, 0x146b, + 0x0ccb, 0x09ab, 0x0b4b, 0x116b, 0x0e6b, 0x148b, 0x014b, 0x0ceb, 0x11eb, + 0x118b, 0x130b, 0x132b, 0x016b, 0x134b, 0x100b, 0x11ab, 0x138b, 0x0e8b, + 0x14ac, 0x11cc, 0x102c, 0x136c, 0x14ec, 0x018c, 0x14cc, 0x150c}, + // inp_hf9 + {0x000f, 0x0001, 0x01a3, 0x0023, 0x01c4, 0x0366, 0x01e6, 0x0346, 0x0046, + 0x0507, 0x0387, 0x0207, 0x04e8, 0x0068, 0x03a8, 0x0528, 0x0228, 0x06a8, + 0x03c8, 0x0248, 0x06c9, 0x0549, 0x0089, 0x0689, 0x0849, 0x03e9, 0x0269, + 0x0569, 0x0869, 0x09e9, 0x06e9, 0x00aa, 0x040a, 0x082a, 0x028a, 0x058a, + 0x02aa, 0x0d2a, 0x070a, 0x088a, 0x0a0a, 0x0b8a, 0x00ca, 0x0d4a, 0x044a, + 0x05aa, 0x042a, 0x072a, 0x0eca, 0x02ca, 0x0baa, 0x09cb, 0x08ab, 0x0a2b, + 0x0d6b, 0x00eb, 0x0eeb, 0x05eb, 0x074b, 0x05cb, 0x010b, 0x106b, 0x0a4b, + 0x046b, 0x08cb, 0x0d0b, 0x0b6b, 0x0bcb, 0x108b, 0x0f0b, 0x0d8b, 0x02eb, + 0x0beb, 0x0a6b, 0x08eb, 0x078b, 0x076b, 0x060b, 0x120b, 0x092b, 0x0eab, + 0x0dab, 0x10ac, 0x048c, 0x012c, 0x122c, 0x0f2c, 0x0a8c, 0x13ac, 0x07ac, + 0x0dcc, 0x030c, 0x0f4c, 0x10cc, 0x090c, 0x0c0c, 0x04ac, 0x032c, 0x13cc, + 0x124c, 0x062c, 0x094c, 0x0aac, 0x0dec, 0x126c, 0x014c, 0x0c2c, 0x13ec, + 0x104c, 0x10ec, 0x07cc, 0x0acc, 0x04cc, 0x0f6c, 0x0f8c, 0x07ec, 0x11ec, + 0x0aec, 0x064c, 0x096c, 0x0e0d, 0x0c6d, 0x142d, 0x066d, 0x128d, 0x0c4d, + 0x140d, 0x12ad, 0x110d, 0x080d, 0x0c8d, 0x098d, 0x016d, 0x144d, 0x0b0d, + 0x138d, 0x112d, 0x09ad, 0x0cad, 0x0fad, 0x018d, 0x12cd, 0x0e2d, 0x0fcd, + 0x114d, 0x0ccd, 0x146d, 0x0b2d, 0x0e6d, 0x12ed, 0x0ced, 0x0b4d, 0x0e4e, + 0x116e, 0x0e8e, 0x0fee, 0x100e, 0x102e, 0x11ae, 0x14ae, 0x118e, 0x130e, + 0x148e, 0x132e, 0x14ce, 0x14ee, 0x11cf, 0x134f, 0x136f, 0x150f}, + + // inp_hf8 + {0x000a, 0x0123, 0x0224, 0x0104, 0x0144, 0x0024, 0x0244, 0x0005, 0x0205, + 0x0045, 0x0325, 0x0165, 0x0345, 0x0265, 0x0366, 0x0426, 0x0186, 0x0446, + 0x0286, 0x0306, 0x0066, 0x0466, 0x0386, 0x0546, 0x0527, 0x02a7, 0x01a7, + 0x0567, 0x03a7, 0x0487, 0x0587, 0x0087, 0x04a7, 0x0407, 0x02c7, 0x0647, + 0x0627, 0x01c7, 0x03c8, 0x0668, 0x05a8, 0x0508, 0x0688, 0x00a8, 0x04c8, + 0x0728, 0x0748, 0x02e8, 0x06a8, 0x0768, 0x01e8, 0x05c8, 0x03e8, 0x06c9, + 0x0789, 0x0609, 0x04e9, 0x00c9, 0x07a9, 0x07c9, 0x06e9, 0x05ea, 0x070a, + 0x00ea, 0x07ea}, + + // inp_hf7 + {0x000c, 0x0001, 0x0103, 0x0023, 0x0124, 0x0226, 0x0146, 0x0206, 0x0046, + 0x0327, 0x0167, 0x0247, 0x0307, 0x0067, 0x0268, 0x0348, 0x0188, 0x0428, + 0x01a8, 0x0528, 0x0368, 0x0288, 0x0088, 0x0408, 0x0449, 0x02a9, 0x0549, + 0x00a9, 0x0629, 0x0509, 0x01c9, 0x0469, 0x03a9, 0x0389, 0x0569, 0x02c9, + 0x0649, 0x01e9, 0x03ca, 0x00ca, 0x060a, 0x048a, 0x072a, 0x04aa, 0x074a, + 0x058a, 0x066a, 0x02ea, 0x076a, 0x068a, 0x05aa, 0x04ca, 0x03ea, 0x070b, + 0x00eb, 0x06ab, 0x05cb, 0x078b, 0x04eb, 0x05eb, 0x07ab, 0x07cc, 0x06cc, + 0x06ec, 0x07ec}, + + // inp_hf6 + {0x000b, 0x0504, 0x0624, 0x04e4, 0x0524, 0x03e4, 0x0644, 0x0404, 0x0604, + 0x03c4, 0x0726, 0x0766, 0x02e6, 0x02a6, 0x02c6, 0x0426, 0x0746, 0x05e6, + 0x0666, 0x04c6, 0x03a6, 0x0546, 0x0706, 0x0306, 0x0286, 0x0786, 0x01c7, + 0x0887, 0x0847, 0x0447, 0x0187, 0x0687, 0x05c7, 0x0387, 0x0867, 0x01a7, + 0x04a7, 0x0567, 0x08a7, 0x0168, 0x0328, 0x07a8, 0x0828, 0x06e8, 0x0268, + 0x01e8, 0x08c8, 0x0809, 0x0149, 0x0209, 0x05a9, 0x0369, 0x09a9, 0x00a9, + 0x0069, 0x06a9, 0x0969, 0x0469, 0x0489, 0x00c9, 0x0049, 0x07c9, 0x0249, + 0x0089, 0x09c9, 0x0949, 0x0349, 0x0989, 0x06c9, 0x0589, 0x012a, 0x022a, + 0x07ea, 0x092a, 0x08ea, 0x09ea, 0x00ea, 0x002a, 0x0a0b, 0x010b, 0x000b, + 0x090b}, + + // inp_hf5 + {0x000d, 0x0501, 0x03e4, 0x0624, 0x0524, 0x04e4, 0x0605, 0x0405, 0x03c5, + 0x0645, 0x02c7, 0x0547, 0x0747, 0x04c7, 0x02a8, 0x0768, 0x03a8, 0x0668, + 0x02e8, 0x0728, 0x0428, 0x05e8, 0x01a8, 0x0868, 0x04a8, 0x0568, 0x0189, + 0x0689, 0x0889, 0x0389, 0x01c9, 0x0849, 0x05c9, 0x0449, 0x0309, 0x0789, + 0x0289, 0x0709, 0x016a, 0x082a, 0x032a, 0x06ea, 0x08aa, 0x07aa, 0x01ea, + 0x026a, 0x048a, 0x008a, 0x09aa, 0x098a, 0x006b, 0x058b, 0x096b, 0x036b, + 0x06ab, 0x046b, 0x00ab, 0x05ab, 0x080b, 0x014b, 0x020b, 0x034b, 0x004b, + 0x09cb, 0x06cb, 0x07cb, 0x08cb, 0x00cb, 0x024c, 0x094c, 0x07ec, 0x002c, + 0x00ec, 0x08ec, 0x022c, 0x09ec, 0x092c, 0x012c, 0x090d, 0x010d, 0x0a0d, + 0x000d}, + + // inp_hf4 + {0x000c, 0x0504, 0x01a4, 0x04a4, 0x04e4, 0x03e4, 0x0364, 0x0484, 0x0004, + 0x0084, 0x03c4, 0x0385, 0x0185, 0x0025, 0x0145, 0x0065, 0x0125, 0x0867, + 0x0567, 0x0627, 0x0527, 0x0847, 0x0807, 0x0607, 0x0747, 0x0207, 0x01c8, + 0x0548, 0x02c8, 0x0408, 0x05c8, 0x04c8, 0x0448, 0x07e8, 0x0728, 0x05a8, + 0x06e8, 0x0168, 0x02a8, 0x00a8, 0x01e8, 0x0268, 0x03a8, 0x00e8, 0x0428, + 0x06c8, 0x0048, 0x0249, 0x00c9, 0x0689, 0x0989, 0x08c9, 0x0589, 0x0649, + 0x0889, 0x066a, 0x096a, 0x08aa, 0x032a, 0x022a, 0x092a, 0x02ea, 0x07aa, + 0x046a, 0x09ea, 0x05ea, 0x076a, 0x082a, 0x06aa, 0x08eb, 0x09ab, 0x030b, + 0x090b, 0x010b, 0x078b, 0x028b, 0x070b, 0x0a0b, 0x034b, 0x09cb, 0x094c, + 0x07cc}, + + // inp_hf3 + {0x0010, 0x0001, 0x0364, 0x0024, 0x0124, 0x0064, 0x0485, 0x0085, 0x0186, + 0x0146, 0x03c6, 0x01a6, 0x0386, 0x04e6, 0x0507, 0x03e7, 0x04a7, 0x06c8, + 0x0048, 0x00a8, 0x07e8, 0x0608, 0x00e9, 0x0209, 0x05a9, 0x01c9, 0x0849, + 0x00c9, 0x02a9, 0x01e9, 0x0249, 0x0169, 0x0729, 0x0629, 0x02c9, 0x0549, + 0x0569, 0x05ca, 0x042a, 0x044a, 0x026a, 0x086a, 0x052a, 0x080a, 0x040a, + 0x010a, 0x022a, 0x096a, 0x066a, 0x03aa, 0x06ea, 0x032a, 0x090b, 0x068b, + 0x04cb, 0x074b, 0x058b, 0x098b, 0x030b, 0x02eb, 0x046c, 0x092c, 0x08ac, + 0x09cc, 0x034c, 0x09ec, 0x08cc, 0x064c, 0x06ac, 0x028d, 0x078d, 0x05ed, + 0x07ae, 0x088e, 0x082e, 0x0a0f, 0x09af, 0x08ef, 0x076f, 0x070f, 0x0950, + 0x07d0}, + // inp_hf2 + {0x0009, 0x0503, 0x0864, 0x01a5, 0x0525, 0x04a5, 0x04e5, 0x03e5, 0x0565, + 0x0625, 0x0446, 0x02c6, 0x05c6, 0x0546, 0x0606, 0x04c6, 0x0186, 0x0746, + 0x0806, 0x0086, 0x0486, 0x08c6, 0x0886, 0x0406, 0x0206, 0x0646, 0x0386, + 0x01c6, 0x03c6, 0x0146, 0x0986, 0x0686, 0x0586, 0x0846, 0x05e7, 0x0827, + 0x0267, 0x0427, 0x07a7, 0x0967, 0x08e7, 0x0327, 0x03a7, 0x09e7, 0x01e7, + 0x0027, 0x0167, 0x06e7, 0x0927, 0x0768, 0x02a8, 0x00e8, 0x0228, 0x00a8, + 0x0068, 0x0368, 0x08a8, 0x07e8, 0x05a8, 0x06a8, 0x02e8, 0x0128, 0x0668, + 0x0728, 0x0468, 0x09a8, 0x0788, 0x0288, 0x0709, 0x0009, 0x0309, 0x0349, + 0x0a09, 0x00c9, 0x07c9, 0x0249, 0x0109, 0x0909, 0x06c9, 0x0049, 0x0949, + 0x09c9}, + + // inp_hf1 + {0x000b, 0x0501, 0x0865, 0x01a5, 0x04e5, 0x0625, 0x0525, 0x04a5, 0x0565, + 0x03e5, 0x0747, 0x02c7, 0x04c7, 0x05c7, 0x0447, 0x0547, 0x0987, 0x0487, + 0x0087, 0x0387, 0x0807, 0x0607, 0x0207, 0x0587, 0x08c7, 0x0407, 0x0687, + 0x0647, 0x0147, 0x0887, 0x0187, 0x0847, 0x01c7, 0x03c7, 0x0929, 0x0269, + 0x07a9, 0x0669, 0x05e9, 0x0469, 0x0429, 0x06e9, 0x0829, 0x05a9, 0x0329, + 0x01e9, 0x00e9, 0x03a9, 0x0769, 0x0729, 0x02a9, 0x0029, 0x0369, 0x06a9, + 0x08a9, 0x09a9, 0x02e9, 0x09e9, 0x00aa, 0x012a, 0x096a, 0x07ea, 0x016a, + 0x006a, 0x022a, 0x08ea, 0x078b, 0x028b, 0x030b, 0x070b, 0x0a0b, 0x010b, + 0x090b, 0x00cb, 0x000b, 0x094b, 0x07cb, 0x034b, 0x024b, 0x004b, 0x06cb, + 0x09cb}, + + // UWORD16 huffman_code_book_scl[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, + 0x05ea, 0x094a, 0x05ca, 0x098b, 0x096b, 0x09ab, 0x09cb, 0x05ab, 0x056b, + 0x058c, 0x09ec, 0x054c, 0x052c, 0x0a0c, 0x050c, 0x0a2d, 0x04ed, 0x0a4d, + 0x04cd, 0x0a6d, 0x04ae, 0x046e, 0x0aae, 0x042e, 0x048e, 0x044e, 0x0a8e, + 0x040e, 0x0aef, 0x0b2f, 0x03cf, 0x03ef, 0x0ad0, 0x03b0, 0x0350, 0x0370, + 0x0390, 0x0310, 0x0b10, 0x0331, 0x02d1, 0x02f1, 0x0b52, 0x02b2, 0x0272, + 0x0072, 0x0032, 0x0052, 0x0012, 0x0c53, 0x0c73, 0x0c93, 0x0cb3, 0x0cd3, + 0x0eb3, 0x0c33, 0x0b73, 0x0b93, 0x0bb3, 0x0bd3, 0x0bf3, 0x0c13, 0x0d13, + 0x0df3, 0x0e13, 0x0e33, 0x0e53, 0x0e73, 0x0e93, 0x0dd3, 0x0d33, 0x0d53, + 0x0d73, 0x0d93, 0x0db3, 0x0ed3, 0x00d3, 0x0113, 0x0133, 0x0153, 0x00b3, + 0x0cf3, 0x0f13, 0x0ef3, 0x0093, 0x00f3, 0x01f3, 0x0213, 0x0253, 0x0293, + 0x0233, 0x0173, 0x0193, 0x01d3, 0x01b3}, + + // UWORD32 huffman_code_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}, + + // const WORD16 ixheaacd_sfb_48_512[37] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, + 8, 12, 12, 12, 12, 16, 20, 24, 28, 32, 32, 32, 32, 32, 32, 32, 52, -1}, + // const WORD16 ixheaacd_sfb_32_512[38] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, + 20, 24, 24, 28, 32, 32, 32, 32, 32, 32, 32, -1}, + // const WORD16 ixheaacd_sfb_24_512[32] = + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, + 12, 16, 20, 24, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, -1}, + // const WORD16 ixheaacd_sfb_48_480[36] = + { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, + 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 32, 32, 32, 32, 32, 32, 48, -1, + }, + // const WORD16 ixheaacd_sfb_32_480[38] = + { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, + 8, 8, 8, 12, 12, 12, 16, 16, 20, 24, 32, 32, 32, 32, 32, 32, 32, 32, -1, + }, + // const WORD16 ixheaacd_sfb_24_480[31] = + { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, + 12, 16, 20, 24, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, -1, + }, + +}; // end of ia_aac_dec_huffman_tables_struct + +const ia_aac_dec_block_tables_struct ixheaacd_aac_block_tables = { + + // const WORD32 ixheaacd_pow_table_Q13[129] = + {0 >> 4, 131072 >> 4, 330281 >> 4, 567116 >> 4, 832256 >> 4, + 1120650 >> 4, 1429042 >> 4, 1755122 >> 4, 2097152 >> 4, 2453767 >> 4, + 2823861 >> 4, 3206517 >> 4, 3600960 >> 4, 4006524 >> 4, 4422631 >> 4, + 4848770 >> 4, 5284492 >> 4, 5729392 >> 4, 6183105 >> 4, 6645302 >> 4, + 7115683 >> 4, 7593972 >> 4, 8079916 >> 4, 8573281 >> 4, 9073850 >> 4, + 9581422 >> 4, 10095808 >> 4, 10616832 >> 4, 11144330 >> 4, 11678147 >> 4, + 12218136 >> 4, 12764159 >> 4, 13316085 >> 4, 13873792 >> 4, 14437162 >> 4, + 15006082 >> 4, 15580448 >> 4, 16160157 >> 4, 16745112 >> 4, 17335222 >> 4, + 17930398 >> 4, 18530554 >> 4, 19135610 >> 4, 19745488 >> 4, 20360112 >> 4, + 20979411 >> 4, 21603314 >> 4, 22231755 >> 4, 22864669 >> 4, 23501994 >> 4, + 24143669 >> 4, 24789637 >> 4, 25439841 >> 4, 26094226 >> 4, 26752740 >> 4, + 27415332 >> 4, 28081952 >> 4, 28752552 >> 4, 29427086 >> 4, 30105507 >> 4, + 30787772 >> 4, 31473838 >> 4, 32163664 >> 4, 32857208 >> 4, 33554432 >> 4, + 34255297 >> 4, 34959765 >> 4, 35667801 >> 4, 36379368 >> 4, 37094431 >> 4, + 37812958 >> 4, 38534914 >> 4, 39260268 >> 4, 39988988 >> 4, 40721043 >> 4, + 41456403 >> 4, 42195038 >> 4, 42936921 >> 4, 43682022 >> 4, 44430314 >> 4, + 45181770 >> 4, 45936364 >> 4, 46694070 >> 4, 47454862 >> 4, 48218716 >> 4, + 48985607 >> 4, 49755512 >> 4, 50528406 >> 4, 51304267 >> 4, 52083073 >> 4, + 52864802 >> 4, 53649431 >> 4, 54436939 >> 4, 55227306 >> 4, 56020511 >> 4, + 56816534 >> 4, 57615355 >> 4, 58416954 >> 4, 59221313 >> 4, 60028412 >> 4, + 60838233 >> 4, 61650759 >> 4, 62465970 >> 4, 63283850 >> 4, 64104381 >> 4, + 64927547 >> 4, 65753329 >> 4, 66581713 >> 4, 67412681 >> 4, 68246218 >> 4, + 69082308 >> 4, 69920936 >> 4, 70762086 >> 4, 71605743 >> 4, 72451892 >> 4, + 73300519 >> 4, 74151609 >> 4, 75005149 >> 4, 75861124 >> 4, 76719520 >> 4, + 77580324 >> 4, 78443523 >> 4, 79309103 >> 4, 80177051 >> 4, 81047354 >> 4, + 81920000 >> 4, 82794977 >> 4, 83672271 >> 4, 84551871 >> 4}, + + // const WORD16 scale_table[4] = + { + + 16384, 19484, 23171, 27555}, + + // const WORD8 tns_max_bands_tbl[12][2] = + { + // Long //Short + {31, 9}, // 96000 + {31, 9}, // 88200 + {34, 10}, // 64000 + {40, 14}, // 48000 + {42, 14}, // 44100 + {51, 14}, // 32000 + {46, 14}, // 24000 + {46, 14}, // 22050 + {42, 14}, // 16000 + {42, 14}, // 12000 + {42, 14}, // 11025 + {39, 14} // 8000 + }, + + // const WORD16 tns_coeff3_16[8] = + {(WORD16)-0x7e0e, (WORD16)-0x6eda, (WORD16)-0x5247, (WORD16)-0x2bc7, + (WORD16)0x0000, (WORD16)0x378a, (WORD16)0x6413, (WORD16)0x7cca}, + + // const WORD16 tns_coeff4_16[16] = + {(WORD16)-0x7f74, (WORD16)-0x7b1d, (WORD16)-0x7295, (WORD16)-0x6625, + (WORD16)-0x563c, (WORD16)-0x4362, (WORD16)-0x2e3d, (WORD16)-0x1785, + (WORD16)0x0000, (WORD16)0x1a9d, (WORD16)0x3410, (WORD16)0x4b3d, + (WORD16)0x5f1f, (WORD16)0x6eda, (WORD16)0x79bc, (WORD16)0x7f4c}, + + // const WORD32 scale_mant_tab[PNS_SCALE_MANT_TAB_SIZE] = + {0x08000000, 0x09837f05, 0x0b504f33, 0x0d744fcc}, + // const WORD32 tns_coeff3[8] = + { + -2114858540, -1859775364, -1380375817, -734482679, 0, 931758215, + 1678970362, 2093641723, + }, + + // const WORD32 tns_coeff4[16] = + { + -2138322869, -2065504899, -1922348549, -1713729017, -1446750457, + -1130504584, -775760644, -394599111, 0, 446486976, 873460283, + 1262259191, 1595891328, 1859775364, 2042378368, 2135719561, + }, + + // const WORD32 tns_coeff3_32[8] = + {(WORD32)-0x7e0e2e31, (WORD32)-0x6ed9eba0, (WORD32)-0x5246dd48, + (WORD32)-0x2bc750e8, (WORD32)0x00000000, (WORD32)0x3789809a, + (WORD32)0x64130dd3, (WORD32)0x7cca7014}, + + // const WORD32 tns_coeff4_32[16] = + {(WORD32)-0x7f7437ac, (WORD32)-0x7b1d1a47, (WORD32)-0x7294b5f1, + (WORD32)-0x66256db1, (WORD32)-0x563ba8a9, (WORD32)-0x4362210d, + (WORD32)-0x2e3d2aba, (WORD32)-0x17851aac, (WORD32)0x00000000, + (WORD32)0x1a9cd9ac, (WORD32)0x340ff241, (WORD32)0x4b3c8c11, + (WORD32)0x5f1f5ea0, (WORD32)0x6ed9eba0, (WORD32)0x79bc384c, + (WORD32)0x7f4c7e52}, + + // const WORD32 tns_max_bands_tbl_usac[(1<> 1] = + {0, 160, 80, 96, 16, 176, 192, 112, 32, 48, 208, 128, 144, 64, 224, + 225, 145, 65, 81, 1, 161, 177, 97, 17, 33, 193, 113, 129, 49, 209, + 210, 130, 50, 66, 226, 146, 162, 82, 2, 18, 178, 98, 114, 34, 194, + 195, 115, 35, 51, 211, 131, 147, 67, 227, 3, 163, 83, 99, 19, 179, + 180, 100, 20, 36, 196, 116, 132, 52, 212, 228, 148, 68, 84, 4, 164, + 165, 85, 5, 21, 181, 101, 117, 37, 197, 213, 133, 53, 69, 229, 149, + 150, 70, 230, 6, 166, 86, 102, 22, 182, 198, 118, 38, 54, 214, 134, + 135, 55, 215, 231, 151, 71, 87, 7, 167, 183, 103, 23, 39, 199, 119, + 120, 40, 200, 216, 136, 56, 72, 232, 152, 168, 88, 8, 24, 184, 104, + 105, 25, 185, 201, 121, 41, 57, 217, 137, 153, 73, 233, 9, 169, 89, + 90, 10, 170, 186, 106, 26, 42, 202, 122, 138, 58, 218, 234, 154, 74, + 75, 235, 155, 171, 91, 11, 27, 187, 107, 123, 43, 203, 219, 139, 59, + 60, 220, 140, 156, 76, 236, 12, 172, 92, 108, 28, 188, 204, 124, 44, + 45, 205, 125, 141, 61, 221, 237, 157, 77, 93, 13, 173, 189, 109, 29, + 30, 190, 110, 126, 46, 206, 222, 142, 62, 78, 238, 158, 174, 94, 14, + 15, 175, 95, 111, 31, 191, 207, 127, 47, 63, 223, 143, 159, 79, 239}, + + // WORD32 cosine_array_960[480] = + { + 2147482880, 2147425408, 1756906, 15812012, 2147275904, 2147034496, + 29866440, 43919588, 2146701056, 2146275712, 57970856, 72019640, + 2145758336, 2145149056, 86065336, 100107352, 2144447872, 2143654912, + 114145072, 128177912, 2142770048, 2141793536, 142205248, 156226512, + 2140725120, 2139565056, 170241056, 184248336, 2138313344, 2136969984, + 198247712, 212238592, 2135535104, 2134008832, 226220384, 240192480, + 2132391040, 2130681984, 254154288, 268105216, 2128881536, 2126990080, + 282044640, 295972000, 2125007360, 2122933632, 309886688, 323788096, + 2120769024, 2118513536, 337675616, 351548704, 2116167296, 2113730432, + 365406720, 379249056, 2111202944, 2108585088, 393075168, 406884448, + 2105876864, 2103078528, 420676288, 434450112, 2100189952, 2097211520, + 448205344, 461941344, 2094143232, 2090985216, 475657568, 489353408, + 2087737600, 2084400640, 503028320, 516681664, 2080974336, 2077458944, + 530312864, 543921344, 2073854464, 2070161280, 557506560, 571067840, + 2066379264, 2062508800, 584604672, 598116480, 2058550016, 2054503040, + 611602688, 625062656, 2050368000, 2046145152, 638495872, 651901696, + 2041834752, 2037436800, 665279680, 678629120, 2032951552, 2028379264, + 691949440, 705240192, 2023720064, 2018974208, 718500672, 731730432, + 2014141824, 2009223168, 744928832, 758095296, 2004218368, 1999127808, + 771229312, 784330240, 1993951616, 1988690048, 797397632, 810430848, + 1983343232, 1977911424, 823429312, 836392576, 1972394880, 1966793856, + 849319936, 862210944, 1961108608, 1955339392, 875065024, 887881600, + 1949486464, 1943549824, 900660160, 913400192, 1937530112, 1931427328, + 926100992, 938762176, 1925241856, 1918973824, 951383168, 963963392, + 1912623616, 1906191616, 976502272, 988999360, 1899677824, 1893082624, + 1001454080, 1013865920, 1886406400, 1879649408, 1026234304, 1038558720, + 1872811776, 1865894016, 1050838720, 1063073600, 1858896256, 1851819008, + 1075262976, 1087406336, 1844662272, 1837426560, 1099503104, 1111552768, + 1830112256, 1822719360, 1123554816, 1135508736, 1815248512, 1807699840, + 1147414016, 1159270016, 1800073856, 1792370688, 1171076480, 1182832768, + 1784590720, 1776734336, 1194538496, 1206192896, 1768801792, 1760793472, + 1217795712, 1229346304, 1752709760, 1744551040, 1240844288, 1252289024, + 1736317440, 1728009600, 1263680256, 1275017216, 1719627648, 1711172096, + 1286299648, 1297526912, 1702643200, 1694041344, 1308698624, 1319814272, + 1685367040, 1676620416, 1330873472, 1341875584, 1667801984, 1658912128, + 1352820224, 1363706880, 1649951232, 1640919680, 1374535168, 1385304576, + 1631817728, 1622646016, 1396014592, 1406664832, 1613404672, 1604094336, + 1417254784, 1427784064, 1594715136, 1585267712, 1438252160, 1448658688, + 1575752448, 1566169600, 1459003136, 1469285120, 1556519680, 1546803072, + 1479504128, 1489659776, 1537020160, 1527171456, 1499751552, 1509779200, + 1517257344, 1507278336, 1519742080, 1529639936, 1497234560, 1487126784, + 1539472128, 1549238528, 1476955264, 1466720512, 1558938496, 1568571648, + 1456422784, 1446062848, 1578137728, 1587636096, 1435640832, 1425157376, + 1597066496, 1606428416, 1414612992, 1404007808, 1615721600, 1624945536, + 1393342592, 1382617728, 1634099840, 1643184256, 1371833472, 1360990592, + 1652198144, 1661141376, 1350089344, 1339130368, 1670013440, 1678813824, + 1328113920, 1317040640, 1687542400, 1696198656, 1305910912, 1294725248, + 1704782336, 1713292928, 1283484032, 1272188032, 1721730176, 1730093568, + 1260837376, 1249432832, 1738382848, 1746597760, 1237974656, 1226463488, + 1754737792, 1762802688, 1214899712, 1203283968, 1770792064, 1778705536, + 1191616768, 1179898368, 1786542976, 1794303744, 1168129536, 1156310656, + 1801987584, 1809594368, 1144442112, 1132524672, 1817123584, 1824574976, + 1120558720, 1108544640, 1831948160, 1839243008, 1096483200, 1084374784, + 1846458880, 1853595776, 1072219904, 1060019072, 1860653312, 1867630976, + 1047772800, 1035481728, 1874528768, 1881346176, 1023146240, 1010766912, + 1888083072, 1894739072, 998344320, 985878976, 1901313920, 1907807232, + 973371392, 960822080, 1914219008, 1920548608, 948231616, 935600576, + 1926796032, 1932960896, 922929408, 910218752, 1939042944, 1945041920, + 897469056, 884680960, 1950957568, 1956789632, 871854912, 858991552, + 1962537856, 1968202112, 846091392, 833155008, 1973782016, 1979277312, + 820182912, 807175680, 1984687872, 1990013440, 794133888, 781058048, + 1995253760, 2000408576, 767948800, 754806592, 2005477632, 2010460928, + 741632064, 728425792, 2015357952, 2020168832, 715188352, 701920192, + 2024893056, 2029530496, 688622016, 675294336, 2034081024, 2038544512, + 661937728, 648552768, 2042920576, 2047209216, 635140032, 621700032, + 2051410048, 2055523072, 608233472, 594740864, 2059548032, 2063484800, + 581222720, 567679680, 2067333120, 2071092864, 554112384, 540521280, + 2074763904, 2078346112, 526907072, 513270272, 2081839360, 2085243264, + 499611488, 485931296, 2088557952, 2091783168, 472230304, 458509088, + 2094918784, 2097964544, 444768224, 431008288, 2100920576, 2103786496, + 417229920, 403433664, 2106562432, 2109248000, 389620128, 375789888, + 2111843328, 2114348160, 361943552, 348081728, 2116762368, 2119085952, + 334204992, 320313920, 2121318656, 2123460608, 306409152, 292491232, + 2125511552, 2127471488, 278560800, 264618448, 2129340288, 2131117824, + 250664736, 236700304, 2132804096, 2134398976, 222725728, 208741600, + 2135902464, 2137314432, 194748544, 180747136, 2138634880, 2139863680, + 166737984, 152721696, 2141000832, 2142046208, 138698864, 124670096, + 2142999936, 2143861760, 110635984, 96597136, 2144631808, 2145309952, + 82554144, 68507616, 2145896320, 2146390656, 54458156, 40406360, + 2146793088, 2147103488, 26352836, 12298181, 2147321984, 2147448448, + }, + + // WORD32 w_16[24] = + { + 0x00000000, 0x7fffffff, 0x00000000, 0x7fffffff, 0x00000000, 0x7fffffff, + 0x30fbc54d, 0x7641af3d, 0x5a82799a, 0x5a82799a, 0x7641af3d, 0x30fbc54d, + 0x5a82799a, 0x5a82799a, 0x7fffffff, 0x00000000, 0x5a82799a, 0xa57d8667, + 0x7641af3d, 0x30fbc54d, 0x5a82799a, 0xa57d8667, 0xcf043ab3, 0x89be50c5, + }, + + // WORD32 window_sine_480_eld[1920]; + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 72, 118, 176, 239, 307, 378, 451, 524, 597, + 669, 741, 812, 883, 954, 1024, 1095, 1165, 1235, 1305, + 1375, 1444, 1514, 1583, 1652, 1722, 1792, 1863, 1933, 2005, + 2077, 2150, 2224, 2299, 2374, 2451, 2529, 2607, 2686, 2766, + 2847, 2928, 3009, 3091, 3174, 3256, 3339, 3423, 3507, 3591, + 3676, 3760, 3846, 3932, 4018, 4104, 4191, 4278, 4366, 4454, + 4542, 4631, 4720, 4809, 4899, 4988, 5078, 5168, 5257, 5347, + 5436, 5524, 5613, 5702, 5790, 5878, 5967, 6056, 6144, 6233, + 6321, 6410, 6498, 6586, 6673, 6761, 6848, 6934, 7020, 7106, + 7192, 7276, 7361, 7445, 7529, 7614, 7698, 7781, 7865, 7947, + 8030, 8112, 8193, 8274, 8354, 8434, 8514, 8594, 8673, 8751, + 8830, 8908, 8985, 9063, 9139, 9216, 9292, 9367, 9442, 9517, + 9621, 9695, 9769, 9842, 9915, 9988, 10060, 10132, 10203, 10274, + 10345, 10415, 10485, 10554, 10623, 10691, 10760, 10827, 10895, 10962, + 11029, 11095, 11161, 11226, 11291, 11356, 11420, 11484, 11548, 11611, + 11674, 11736, 11798, 11859, 11921, 11981, 12042, 12102, 12161, 12220, + 12279, 12337, 12395, 12452, 12509, 12565, 12621, 12677, 12732, 12787, + 12841, 12895, 12948, 13000, 13053, 13104, 13156, 13206, 13257, 13306, + 13356, 13404, 13452, 13500, 13547, 13594, 13639, 13685, 13730, 13774, + 13818, 13861, 13904, 13946, 13988, 14029, 14069, 14109, 14148, 14187, + 14225, 14263, 14300, 14336, 14372, 14408, 14443, 14477, 14511, 14544, + 14577, 14609, 14641, 14673, 14704, 14734, 14764, 14794, 14823, 14852, + 14881, 14909, 14938, 14966, 14994, 15021, 15049, 15076, 15104, 15131, + 15159, 15186, 15213, 15239, 15265, 15289, 15312, 15333, 15351, 15372, + 15382, 15386, 15392, 15398, 15404, 15411, 15418, 15425, 15431, 15438, + 15444, 15451, 15458, 15464, 15471, 15478, 15485, 15492, 15499, 15505, + 15512, 15519, 15526, 15534, 15541, 15548, 15555, 15562, 15569, 15577, + 15584, 15592, 15599, 15606, 15614, 15621, 15629, 15637, 15644, 15652, + 15660, 15668, 15675, 15683, 15691, 15699, 15707, 15715, 15723, 15731, + 15740, 15748, 15756, 15764, 15773, 15781, 15789, 15798, 15806, 15815, + 15824, 15832, 15841, 15849, 15858, 15867, 15876, 15884, 15893, 15902, + 15911, 15920, 15929, 15938, 15947, 15956, 15965, 15974, 15983, 15993, + 16002, 16011, 16020, 16030, 16039, 16048, 16057, 16067, 16076, 16086, + 16095, 16104, 16114, 16123, 16133, 16142, 16152, 16161, 16171, 16181, + 16190, 16200, 16209, 16219, 16229, 16238, 16248, 16258, 16267, 16277, + 16287, 16296, 16306, 16316, 16326, 16335, 16345, 16355, 16365, 16374, + 16394, 16403, 16413, 16423, 16433, 16443, 16452, 16462, 16472, 16482, + 16492, 16502, 16511, 16521, 16531, 16541, 16551, 16561, 16570, 16580, + 16590, 16600, 16610, 16619, 16629, 16639, 16649, 16659, 16668, 16678, + 16688, 16698, 16707, 16717, 16727, 16737, 16746, 16756, 16766, 16775, + 16785, 16795, 16804, 16814, 16823, 16833, 16842, 16852, 16861, 16871, + 16880, 16890, 16899, 16909, 16918, 16927, 16937, 16946, 16955, 16964, + 16974, 16983, 16992, 17001, 17010, 17019, 17028, 17037, 17046, 17055, + 17064, 17072, 17081, 17090, 17099, 17107, 17116, 17125, 17133, 17142, + 17150, 17159, 17167, 17175, 17184, 17192, 17200, 17209, 17217, 17225, + 17233, 17241, 17249, 17257, 17265, 17273, 17281, 17289, 17297, 17305, + 17312, 17320, 17328, 17335, 17343, 17351, 17358, 17366, 17373, 17381, + 17388, 17396, 17403, 17411, 17418, 17426, 17433, 17440, 17446, 17452, + 17454, 17449, 17444, 17437, 17428, 17418, 17407, 17396, 17385, 17374, + 17363, 17352, 17340, 17329, 17316, 17304, 17291, 17278, 17264, 17250, + 17236, 17221, 17207, 17193, 17179, 17165, 17150, 17136, 17121, 17107, + 17091, 17076, 17059, 17042, 17024, 17005, 16986, 16966, 16945, 16923, + 16901, 16878, 16855, 16831, 16807, 16783, 16759, 16734, 16709, 16684, + 16658, 16633, 16607, 16581, 16554, 16527, 16500, 16471, 16443, 16414, + 16384, 16353, 16322, 16290, 16257, 16224, 16190, 16155, 16120, 16085, + 16050, 16016, 15981, 15947, 15912, 15878, 15843, 15807, 15771, 15735, + 15697, 15659, 15621, 15581, 15542, 15502, 15461, 15421, 15380, 15339, + 15299, 15259, 15219, 15180, 15140, 15099, 15058, 15016, 14974, 14931, + 14887, 14844, 14800, 14757, 14714, 14671, 14628, 14584, 14541, 14497, + 14453, 14408, 14364, 14319, 14274, 14229, 14184, 14139, 14094, 14049, + 14004, 13958, 13912, 13865, 13819, 13772, 13725, 13678, 13631, 13584, + 13537, 13491, 13444, 13396, 13349, 13301, 13253, 13205, 13156, 13106, + 13057, 13008, 12960, 12912, 12864, 12817, 12770, 12723, 12675, 12626, + 12576, 12526, 12475, 12424, 12373, 12321, 12270, 12220, 12170, 12120, + 12071, 12022, 11974, 11926, 11878, 11829, 11780, 11730, 11679, 11627, + 11575, 11521, 11467, 11414, 11360, 11307, 11255, 11203, 11152, 11101, + 11051, 11001, 10952, 10903, 10853, 10804, 10755, 10705, 10656, 10605, + 10554, 10503, 10450, 10397, 10343, 10289, 10234, 10179, 10124, 10069, + 10014, 9960, 9907, 9854, 9803, 9752, 9703, 9654, 9606, 9559, + 9513, 9466, 9419, 9371, 9322, 9271, 9219, 9165, 9109, 9053, + 8996, 8939, 8883, 8828, 8775, 8723, 8674, 8625, 8578, 8532, + 8486, 8440, 8392, 8344, 8295, 8244, 8192, 8140, 8088, 8036, + 7983, 7931, 7879, 7829, 7779, 7731, 7682, 7634, 7586, 7537, + 7488, 7439, 7390, 7340, 7290, 7241, 7192, 7144, 7096, 7049, + 7001, 6953, 6904, 6856, 6807, 6757, 6708, 6659, 6610, 6561, + 6513, 6465, 6418, 6370, 6323, 6277, 6230, 6183, 6137, 6090, + 6044, 5997, 5951, 5905, 5858, 5812, 5766, 5720, 5674, 5628, + 5583, 5537, 5491, 5446, 5401, 5355, 5310, 5265, 5221, 5175, + 5130, 5084, 5037, 4991, 4945, 4899, 4853, 4807, 4761, 4716, + 4671, 4626, 4581, 4536, 4491, 4447, 4403, 4359, 4315, 4271, + 4228, 4185, 4142, 4099, 4056, 4014, 3972, 3929, 3887, 3846, + 3804, 3762, 3721, 3680, 3639, 3598, 3558, 3517, 3477, 3437, + 3397, 3357, 3318, 3278, 3239, 3199, 3160, 3122, 3083, 3044, + 3006, 2967, 2929, 2891, 2853, 2815, 2778, 2741, 2704, 2668, + 2620, 2585, 2550, 2515, 2481, 2447, 2413, 2380, 2347, 2314, + 2281, 2248, 2215, 2183, 2151, 2119, 2087, 2055, 2024, 1993, + 1962, 1931, 1901, 1870, 1840, 1810, 1781, 1751, 1722, 1693, + 1664, 1636, 1608, 1579, 1552, 1524, 1497, 1470, 1443, 1416, + 1390, 1364, 1338, 1312, 1287, 1261, 1236, 1212, 1187, 1163, + 1139, 1115, 1092, 1068, 1045, 1022, 1000, 977, 955, 934, + 912, 891, 869, 848, 828, 807, 787, 767, 747, 728, + 709, 690, 671, 652, 634, 616, 598, 581, 563, 546, + 529, 513, 496, 480, 464, 448, 433, 417, 402, 387, + 372, 358, 344, 329, 316, 302, 289, 276, 263, 251, + 238, 226, 214, 203, 191, 180, 169, 158, 147, 137, + 127, 117, 107, 97, 88, 78, 70, 61, 52, 44, + 36, 28, 21, 13, 6, -2, -9, -16, -23, -30, + -37, -43, -49, -55, -60, -65, -69, -73, -78, -81, + -85, -89, -93, -97, -101, -105, -109, -113, -116, -120, + -123, -126, -129, -131, -133, -135, -137, -138, -139, -140, + -141, -142, -143, -143, -144, -144, -145, -145, -146, -146, + -147, -147, -147, -147, -147, -147, -147, -146, -146, -145, + -144, -143, -141, -140, -139, -137, -135, -134, -132, -130, + -129, -127, -125, -123, -122, -120, -118, -116, -114, -111, + -109, -107, -104, -102, -99, -96, -94, -91, -88, -86, + -83, -81, -78, -75, -72, -70, -67, -64, -61, -58, + -55, -52, -49, -46, -44, -41, -38, -35, -32, -29, + -26, -23, -20, -17, -14, -11, -9, -6, -3, 0, + 0, 3, 6, 8, 11, 14, 17, 19, 22, 24, + 27, 29, 32, 34, 37, 39, 42, 44, 46, 48, + 50, 53, 55, 57, 59, 61, 62, 64, 66, 67, + 69, 71, 72, 74, 75, 76, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 86, 87, 87, 88, 88, + 88, 89, 89, 89, 90, 90, 90, 90, 90, 90, + 90, 89, 89, 88, 88, 87, 86, 85, 85, 84, + 83, 82, 81, 80, 78, 77, 76, 75, 74, 73, + 72, 70, 69, 68, 66, 65, 63, 61, 59, 57, + 55, 53, 51, 49, 47, 44, 42, 40, 38, 36, + 34, 32, 30, 28, 26, 23, 21, 19, 16, 14, + 11, 8, 6, 3, 1, -2, -4, -7, -9, -12, + -14, -17, -20, -22, -25, -27, -30, -32, -35, -38, + -40, -43, -45, -48, -50, -53, -55, -58, -60, -63, + -65, -68, -70, -73, -75, -78, -80, -82, -85, -87, + -90, -92, -94, -97, -99, -102, -104, -106, -109, -111, + -113, -116, -118, -121, -123, -125, -128, -130, -133, -135, + -138, -140, -143, -145, -148, -151, -153, -156, -159, -162, + -165, -168, -170, -173, -176, -178, -181, -183, -185, -188, + -190, -192, -194, -196, -197, -199, -201, -202, -204, -205, + -206, -208, -209, -210, -211, -212, -213, -214, -214, -215, + -216, -216, -217, -218, -218, -218, -219, -219, -219, -219, + -219, -219, -220, -219, -219, -219, -219, -219, -218, -218, + -218, -217, -217, -216, -216, -215, -214, -214, -213, -212, + -214, -214, -213, -212, -211, -211, -210, -209, -208, -207, + -206, -204, -203, -202, -201, -199, -198, -196, -195, -193, + -192, -190, -189, -187, -185, -184, -182, -180, -178, -176, + -175, -173, -171, -169, -167, -165, -163, -162, -160, -158, + -156, -154, -152, -150, -149, -147, -145, -143, -142, -140, + -139, -137, -135, -134, -133, -131, -130, -129, -127, -126, + -125, -123, -122, -120, -118, -117, -115, -113, -111, -109, + -107, -105, -103, -100, -98, -96, -94, -91, -89, -87, + -84, -82, -79, -77, -75, -72, -70, -67, -65, -63, + -60, -58, -56, -53, -51, -49, -47, -44, -42, -40, + -38, -36, -34, -32, -30, -28, -26, -25, -23, -21, + -20, -18, -16, -15, -13, -12, -10, -9, -8, -6, + -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, + 5, 6, 6, 7, 8, 8, 9, 9, 9, 10, + 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, + 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, + 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, + 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, + 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 3, 4, 4, 4, 4, 4, 4, 4, 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, 5, 5, 5, 5, 5, 5, 4, 4, + 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, + 1, 1, 1, 0, 0, 0, -1, -1, -1, -2, + -2, -2, -3, -3, -4, -4, -5, -5, -5, -6, + -6, -7, -7, -7, -8, -8, -9, -9, -10, -10, + -10, -11, -11, -12, -12, -13, -13, -13, -14, -14, + -15, -15, -15, -16, -16, -16, -17, -17, -17, -18, + -18, -18, -19, -19, -19, -19, -20, -20, -20, -20, + -21, -21, -21, -21, -21, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -21, + -21, -21, -21, -21, -21, -20, -20, -20, -20, -20, + -19, -19, -19, -19, -19, -18, -18, -18, -18, -17}, + // WORD16 window_sine_512_eld[2048]; + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 56, 93, + 139, 192, 251, 314, 380, 447, 515, 583, 651, 718, + 784, 849, 914, 979, 1044, 1109, 1174, 1239, 1304, 1368, + 1433, 1498, 1563, 1628, 1693, 1758, 1824, 1890, 1956, 2022, + 2090, 2157, 2226, 2295, 2365, 2436, 2508, 2580, 2653, 2727, + 2802, 2877, 2952, 3029, 3105, 3182, 3260, 3338, 3416, 3494, + 3573, 3652, 3731, 3811, 3891, 3971, 4052, 4133, 4214, 4296, + 4378, 4460, 4542, 4625, 4708, 4791, 4874, 4957, 5041, 5125, + 5209, 5293, 5377, 5460, 5544, 5627, 5710, 5794, 5877, 5960, + 6042, 6125, 6208, 6291, 6373, 6456, 6538, 6620, 6702, 6784, + 6865, 6947, 7028, 7108, 7189, 7269, 7349, 7428, 7507, 7586, + 7665, 7743, 7821, 7899, 7976, 8054, 8131, 8207, 8283, 8359, + 8434, 8510, 8584, 8659, 8733, 8807, 8880, 8953, 9026, 9099, + 9171, 9243, 9314, 9385, 9456, 9526, 9583, 9653, 9723, 9792, + 9860, 9929, 9997, 10064, 10132, 10199, 10265, 10331, 10397, 10463, + 10528, 10593, 10657, 10721, 10785, 10849, 10912, 10974, 11037, 11099, + 11161, 11222, 11283, 11344, 11404, 11464, 11524, 11583, 11642, 11701, + 11759, 11817, 11875, 11932, 11989, 12045, 12102, 12157, 12213, 12268, + 12322, 12377, 12431, 12484, 12537, 12590, 12642, 12694, 12746, 12797, + 12848, 12898, 12948, 12997, 13046, 13095, 13143, 13191, 13238, 13285, + 13331, 13377, 13422, 13467, 13512, 13556, 13599, 13642, 13685, 13727, + 13769, 13810, 13850, 13891, 13930, 13969, 14008, 14046, 14084, 14121, + 14158, 14194, 14230, 14265, 14300, 14334, 14368, 14401, 14434, 14466, + 14498, 14530, 14561, 14591, 14621, 14651, 14680, 14709, 14738, 14766, + 14794, 14821, 14849, 14876, 14902, 14929, 14955, 14981, 15007, 15033, + 15059, 15085, 15111, 15137, 15162, 15188, 15213, 15238, 15262, 15285, + 15307, 15327, 15345, 15361, 15384, 15388, 15394, 15400, 15406, 15412, + 15418, 15425, 15431, 15437, 15443, 15449, 15456, 15462, 15468, 15475, + 15481, 15487, 15494, 15500, 15507, 15513, 15520, 15526, 15533, 15540, + 15546, 15553, 15560, 15567, 15574, 15580, 15587, 15594, 15601, 15608, + 15615, 15622, 15630, 15637, 15644, 15651, 15658, 15666, 15673, 15680, + 15688, 15695, 15703, 15710, 15718, 15725, 15733, 15741, 15748, 15756, + 15764, 15772, 15780, 15787, 15795, 15803, 15811, 15819, 15827, 15835, + 15843, 15852, 15860, 15868, 15876, 15884, 15893, 15901, 15909, 15918, + 15926, 15935, 15943, 15952, 15960, 15969, 15977, 15986, 15994, 16003, + 16012, 16020, 16029, 16038, 16046, 16055, 16064, 16073, 16081, 16090, + 16099, 16108, 16117, 16126, 16135, 16144, 16152, 16161, 16170, 16179, + 16188, 16197, 16206, 16215, 16224, 16233, 16242, 16251, 16261, 16270, + 16279, 16288, 16297, 16306, 16315, 16324, 16334, 16343, 16352, 16361, + 16370, 16379, 16389, 16398, 16407, 16416, 16425, 16435, 16444, 16453, + 16462, 16472, 16481, 16490, 16499, 16508, 16518, 16527, 16536, 16545, + 16554, 16564, 16573, 16582, 16591, 16600, 16610, 16619, 16628, 16637, + 16646, 16656, 16665, 16674, 16683, 16692, 16701, 16710, 16720, 16729, + 16738, 16747, 16756, 16765, 16774, 16783, 16792, 16801, 16810, 16819, + 16828, 16837, 16846, 16855, 16864, 16873, 16882, 16890, 16899, 16908, + 16917, 16926, 16934, 16943, 16952, 16960, 16969, 16978, 16986, 16995, + 17003, 17012, 17020, 17029, 17037, 17045, 17054, 17062, 17070, 17078, + 17087, 17095, 17103, 17111, 17119, 17127, 17135, 17143, 17151, 17159, + 17167, 17175, 17183, 17191, 17198, 17206, 17214, 17221, 17229, 17237, + 17244, 17252, 17259, 17267, 17274, 17282, 17289, 17296, 17304, 17311, + 17318, 17325, 17333, 17340, 17347, 17354, 17361, 17368, 17375, 17382, + 17389, 17396, 17403, 17410, 17417, 17424, 17431, 17438, 17444, 17449, + 17446, 17444, 17440, 17434, 17426, 17417, 17408, 17398, 17388, 17377, + 17367, 17357, 17347, 17336, 17326, 17315, 17303, 17292, 17280, 17267, + 17254, 17241, 17228, 17215, 17202, 17188, 17175, 17162, 17149, 17135, + 17122, 17108, 17094, 17080, 17065, 17049, 17033, 17016, 16999, 16980, + 16962, 16942, 16922, 16901, 16880, 16858, 16836, 16814, 16792, 16769, + 16746, 16723, 16699, 16676, 16652, 16628, 16604, 16579, 16555, 16529, + 16504, 16478, 16451, 16424, 16397, 16368, 16340, 16310, 16280, 16249, + 16218, 16186, 16154, 16121, 16088, 16055, 16023, 15990, 15958, 15926, + 15894, 15861, 15828, 15795, 15761, 15727, 15692, 15656, 15620, 15583, + 15546, 15508, 15471, 15433, 15395, 15357, 15319, 15281, 15244, 15207, + 15169, 15132, 15094, 15055, 15016, 14976, 14936, 14895, 14855, 14814, + 14773, 14733, 14692, 14652, 14611, 14570, 14530, 14488, 14447, 14406, + 14364, 14322, 14280, 14238, 14195, 14153, 14111, 14068, 14025, 13983, + 13940, 13897, 13854, 13810, 13767, 13723, 13680, 13636, 13593, 13549, + 13505, 13462, 13418, 13374, 13330, 13286, 13241, 13195, 13150, 13104, + 13058, 13013, 12968, 12923, 12879, 12835, 12792, 12748, 12703, 12658, + 12612, 12565, 12518, 12471, 12423, 12376, 12328, 12281, 12233, 12187, + 12140, 12095, 12049, 12004, 11959, 11915, 11870, 11825, 11779, 11732, + 11684, 11635, 11586, 11536, 11486, 11435, 11385, 11336, 11287, 11239, + 11191, 11143, 11096, 11050, 11003, 10957, 10911, 10865, 10819, 10773, + 10727, 10680, 10633, 10585, 10537, 10488, 10439, 10389, 10338, 10287, + 10236, 10184, 10133, 10081, 10030, 9979, 9929, 9880, 9832, 9784, + 9737, 9691, 9646, 9602, 9558, 9514, 9470, 9426, 9381, 9334, + 9286, 9237, 9186, 9134, 9081, 9028, 8974, 8921, 8869, 8818, + 8769, 8721, 8675, 8630, 8586, 8542, 8499, 8455, 8410, 8365, + 8318, 8270, 8222, 8173, 8124, 8074, 8026, 7976, 7926, 7878, + 7831, 7784, 7738, 7693, 7647, 7602, 7556, 7509, 7463, 7416, + 7369, 7322, 7275, 7228, 7182, 7137, 7091, 7046, 7001, 6955, + 6909, 6863, 6817, 6770, 6723, 6676, 6629, 6583, 6537, 6491, + 6446, 6401, 6356, 6311, 6267, 6222, 6178, 6133, 6089, 6045, + 6000, 5956, 5912, 5868, 5824, 5780, 5736, 5692, 5648, 5604, + 5560, 5516, 5473, 5429, 5386, 5343, 5300, 5257, 5214, 5171, + 5128, 5085, 5043, 5000, 4958, 4915, 4873, 4831, 4789, 4747, + 4705, 4664, 4622, 4581, 4539, 4498, 4457, 4416, 4375, 4334, + 4293, 4253, 4212, 4172, 4132, 4092, 4052, 4012, 3972, 3933, + 3893, 3854, 3815, 3776, 3737, 3699, 3660, 3622, 3583, 3545, + 3507, 3469, 3432, 3394, 3357, 3319, 3282, 3245, 3208, 3171, + 3135, 3098, 3062, 3025, 2989, 2953, 2917, 2881, 2846, 2810, + 2775, 2740, 2706, 2671, 2638, 2604, 2572, 2539, 2507, 2475, + 2443, 2411, 2380, 2349, 2318, 2287, 2256, 2226, 2195, 2165, + 2135, 2105, 2075, 2046, 2016, 1987, 1958, 1929, 1901, 1872, + 1844, 1816, 1788, 1760, 1733, 1706, 1679, 1652, 1625, 1599, + 1572, 1546, 1521, 1495, 1470, 1444, 1419, 1395, 1370, 1346, + 1322, 1298, 1274, 1250, 1227, 1204, 1181, 1158, 1136, 1114, + 1092, 1070, 1048, 1027, 1005, 984, 964, 943, 923, 903, + 883, 863, 843, 824, 805, 786, 767, 749, 730, 712, + 694, 677, 659, 642, 625, 608, 592, 575, 559, 543, + 527, 512, 496, 481, 466, 451, 436, 422, 408, 394, + 380, 366, 352, 339, 326, 313, 301, 288, 276, 264, + 252, 241, 229, 218, 207, 196, 185, 175, 165, 155, + 145, 135, 125, 116, 107, 98, 89, 80, 72, 63, + 55, 48, 40, 33, 25, 18, 11, 4, -3, -9, + -16, -23, -29, -35, -41, -47, -53, -58, -62, -67, + -71, -75, -79, -82, -86, -89, -93, -97, -101, -104, + -108, -112, -115, -118, -122, -125, -127, -130, -132, -134, + -136, -137, -138, -139, -140, -141, -142, -143, -143, -144, + -144, -145, -145, -146, -146, -146, -147, -147, -147, -147, + -147, -147, -147, -146, -146, -145, -144, -143, -142, -141, + -140, -138, -137, -135, -134, -132, -130, -129, -127, -126, + -124, -122, -121, -119, -117, -115, -113, -111, -109, -106, + -104, -102, -99, -97, -94, -92, -89, -87, -85, -82, + -80, -77, -74, -72, -69, -67, -64, -61, -59, -56, + -53, -50, -48, -45, -42, -39, -37, -34, -31, -28, + -26, -23, -20, -17, -15, -12, -9, -7, -4, -1, + 1, 4, 7, 9, 12, 14, 17, 19, 22, 24, + 27, 29, 31, 34, 36, 38, 40, 43, 45, 47, + 49, 51, 53, 55, 57, 59, 60, 62, 64, 65, + 67, 69, 70, 71, 73, 74, 76, 77, 78, 79, + 81, 82, 83, 84, 84, 85, 86, 86, 87, 88, + 88, 88, 89, 89, 89, 90, 90, 90, 90, 91, + 91, 91, 91, 90, 90, 90, 89, 89, 88, 88, + 87, 86, 85, 84, 83, 83, 82, 81, 80, 79, + 78, 77, 75, 74, 73, 72, 71, 70, 68, 67, + 66, 64, 62, 61, 59, 57, 55, 53, 51, 49, + 47, 44, 42, 40, 38, 36, 34, 33, 31, 29, + 27, 25, 23, 20, 18, 16, 13, 11, 8, 6, + 3, 1, -1, -4, -6, -9, -11, -13, -16, -18, + -21, -23, -25, -28, -30, -33, -35, -38, -40, -43, + -45, -47, -50, -52, -55, -57, -59, -62, -64, -66, + -69, -71, -73, -76, -78, -80, -83, -85, -87, -89, + -92, -94, -96, -99, -101, -103, -105, -107, -110, -112, + -114, -116, -119, -121, -123, -125, -128, -130, -132, -135, + -137, -139, -142, -144, -146, -149, -151, -154, -156, -159, + -162, -164, -167, -170, -172, -175, -178, -180, -182, -185, + -187, -189, -191, -193, -195, -197, -199, -201, -202, -204, + -205, -207, -208, -209, -210, -211, -213, -214, -214, -215, + -216, -217, -218, -219, -219, -220, -220, -221, -221, -222, + -222, -222, -222, -223, -223, -223, -223, -223, -223, -223, + -223, -222, -222, -222, -222, -221, -221, -220, -220, -219, + -219, -218, -217, -217, -216, -215, -215, -214, -213, -213, + -212, -211, -210, -210, -209, -208, -207, -206, -205, -204, + -202, -201, -200, -199, -197, -196, -195, -193, -192, -190, + -189, -187, -185, -184, -182, -181, -179, -177, -176, -174, + -172, -170, -169, -167, -165, -163, -162, -160, -158, -156, + -154, -153, -151, -149, -148, -146, -144, -143, -141, -140, + -138, -137, -135, -134, -133, -131, -130, -129, -128, -127, + -125, -124, -123, -121, -120, -118, -116, -115, -113, -111, + -109, -107, -105, -103, -101, -99, -97, -95, -93, -91, + -88, -86, -84, -82, -79, -77, -75, -73, -70, -68, + -66, -64, -61, -59, -57, -55, -53, -51, -49, -46, + -44, -42, -40, -39, -37, -35, -33, -31, -29, -28, + -26, -24, -22, -21, -19, -18, -16, -15, -13, -12, + -11, -9, -8, -7, -6, -5, -4, -3, -2, -1, + 0, 1, 2, 3, 4, 5, 5, 6, 7, 7, + 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, + 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, + 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, + 10, 9, 9, 9, 9, 9, 8, 8, 8, 7, + 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, + 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, + 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, + 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, + 4, 4, 4, 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, + 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, + 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, + 1, 1, 0, 0, 0, -1, -1, -1, -2, -2, + -2, -3, -3, -3, -4, -4, -5, -5, -5, -6, + -6, -7, -7, -7, -8, -8, -9, -9, -9, -10, + -10, -11, -11, -11, -12, -12, -13, -13, -13, -14, + -14, -14, -15, -15, -16, -16, -16, -17, -17, -17, + -18, -18, -18, -18, -19, -19, -19, -19, -20, -20, + -20, -20, -21, -21, -21, -21, -21, -22, -22, -22, + -22, -22, -22, -22, -22, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -22, + -22, -22, -22, -22, -22, -22, -22, -21, -21, -21, + -21, -21, -21, -20, -20, -20, -20, -20, -20, -19, + -19, -19, -19, -18, -18, -18, -18, -18} + +}; diff --git a/decoder/ixheaacd_aac_rom.h b/decoder/ixheaacd_aac_rom.h new file mode 100644 index 0000000..0d99e9e --- /dev/null +++ b/decoder/ixheaacd_aac_rom.h @@ -0,0 +1,173 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_AAC_ROM_H +#define IXHEAACD_AAC_ROM_H + +#define AAC_NF_NO_RANDOM_VAL 512 + +typedef struct { + WORD32 ixheaacd_pow_table_Q13[129]; + WORD32 scale_table[4]; + WORD8 tns_max_bands_tbl[12][2]; + WORD16 tns_coeff3_16[8]; + WORD16 tns_coeff4_16[16]; + WORD32 scale_mant_tab[4]; + + WORD32 tns_coeff3[8]; + WORD32 tns_coeff4[16]; + + WORD32 tns_coeff3_32[8]; + WORD32 tns_coeff4_32[16]; + WORD32 tns_max_bands_tbl_usac[16][2]; + + WORD8 tns_max_bands_tbl_ld[12]; + WORD8 tns_max_bands_tbl_480[12]; + +} ia_aac_dec_block_tables_struct; + +extern const ia_aac_dec_block_tables_struct ixheaacd_aac_block_tables; + +typedef struct { + WORD8 ixheaacd_sfb_96_1024[43]; + WORD8 ixheaacd_sfb_96_128[14]; + WORD8 ixheaacd_sfb_64_1024[49]; + WORD8 ixheaacd_sfb_48_1024[51]; + WORD8 ixheaacd_sfb_48_128[16]; + WORD8 ixheaacd_sfb_32_1024[53]; + WORD8 ixheaacd_sfb_24_1024[49]; + WORD8 ixheaacd_sfb_24_128[17]; + WORD8 ixheaacd_sfb_16_1024[45]; + WORD8 ixheaacd_sfb_16_128[17]; + WORD8 ixheaacd_sfb_8_1024[42]; + WORD8 ixheaacd_sfb_8_128[17]; + + ia_sampling_rate_info_struct str_sample_rate_info[13]; + + UWORD32 idx_table_hf11[21]; + UWORD32 idx_table_hf10[20]; + UWORD32 idx_table_hf9[23]; + UWORD32 idx_table_hf8[17]; + UWORD32 idx_table_hf7[18]; + UWORD32 idx_table_hf6[17]; + UWORD32 idx_table_hf5[19]; + UWORD32 idx_table_hf4[19]; + UWORD32 idx_table_hf3[27]; + UWORD32 idx_table_hf2[16]; + UWORD32 idx_table_hf1[12]; + + UWORD16 input_table_cb11[290]; + UWORD16 input_table_cb10[170]; + UWORD16 input_table_cb9[170]; + UWORD16 input_table_cb8[65]; + UWORD16 input_table_cb7[65]; + UWORD16 input_table_cb6[82]; + UWORD16 input_table_cb5[82]; + UWORD16 input_table_cb4[82]; + UWORD16 input_table_cb3[82]; + UWORD16 input_table_cb2[82]; + UWORD16 input_table_cb1[82]; + UWORD16 huffman_code_book_scl[122]; + UWORD32 huffman_code_book_scl_index[33]; + + WORD8 ixheaacd_sfb_48_512[37]; + WORD8 ixheaacd_sfb_32_512[38]; + WORD8 ixheaacd_sfb_24_512[32]; + + WORD8 ixheaacd_sfb_48_480[36]; + WORD8 ixheaacd_sfb_32_480[38]; + WORD8 ixheaacd_sfb_24_480[31]; + +} ia_aac_dec_huffman_tables_struct; + +extern const ia_aac_dec_huffman_tables_struct ixheaacd_aac_huffmann_tables; + +typedef struct { + WORD16 cosine_array_2048_256[514]; + WORD8 dig_rev_table8_long[64]; + WORD8 dig_rev_table8_short[8]; + WORD32 fft_twiddle[64 * 7]; + + WORD16 only_long_window_sine[1024]; + WORD16 only_long_window_kbd[1024]; + WORD16 only_short_window_sine[128]; + WORD16 only_short_window_kbd[128]; + + WORD16 cosine_array_2048_256p[514]; + WORD32 w1024[768]; + UWORD8 bit_rev_1024[256]; + UWORD8 bit_rev_512[64]; + UWORD8 bit_rev_128[16]; + UWORD8 bit_rev_32[4]; + WORD32 w_256[504]; + WORD32 low_overlap_win[512]; + WORD32 window_sine_512[512]; + WORD32 cosine_array_1024[512]; + + WORD32 low_overlap_win_480[480]; + WORD32 window_sine_480[480]; + + UWORD8 re_arr_tab_16[240]; + UWORD8 re_arr_tab_sml_240[240]; + + WORD32 cosine_array_960[480]; + WORD32 w_16[24]; + + WORD16 window_sine_480_eld[1920]; + WORD16 window_sine_512_eld[2048]; + +} ia_aac_dec_imdct_tables_struct; + +extern const ia_aac_dec_imdct_tables_struct ixheaacd_imdct_tables; + +typedef struct { + WORD16 *sfb_index; + WORD8 *sfb_width; + +} ia_aac_sfb_info; + +typedef struct { + ia_aac_dec_block_tables_struct *pstr_block_tables; + ia_aac_dec_huffman_tables_struct *pstr_huffmann_tables; + ia_aac_dec_imdct_tables_struct *pstr_imdct_tables; + + ia_aac_sfb_info str_aac_sfb_info[4]; + WORD8 *scale_factor_bands_long[12]; + WORD8 *scale_factor_bands_short[12]; + WORD16 sfb_long_table[52]; + WORD16 sfb_short_table[16]; + + UWORD16 *code_book[13]; + UWORD32 *index_table[13]; + + WORD8 *scale_fac_bands_512[16]; + WORD8 *scale_fac_bands_480[16]; + +} ia_aac_dec_tables_struct; + +#define ixheaacd_huff_cb_0 0 +#define ixheaacd_huff_cb_1 1 +#define ixheaacd_huff_cb_2 2 +#define ixheaacd_huff_cb_3 3 +#define ixheaacd_huff_cb_4 4 +#define ixheaacd_huff_cb_5 5 +#define ixheaacd_huff_cb_6 6 +#define ixheaacd_huff_cb_7 7 + +#endif /* #ifndef IXHEAACD_AAC_ROM_H */ diff --git a/decoder/ixheaacd_aac_tns.c b/decoder/ixheaacd_aac_tns.c new file mode 100644 index 0000000..a439628 --- /dev/null +++ b/decoder/ixheaacd_aac_tns.c @@ -0,0 +1,452 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_error_codes.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_common_rom.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" + +static PLATFORM_INLINE WORD32 ixheaacd_mac32_tns(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + result = ixheaacd_add32(c, result); + 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) { + WORD32 i; + WORD32 tmp; + WORD32 *aptr = a; + WORD32 *tns_coeff_ptr; + WORD8 ixheaacd_drc_offset; + + tmp = filter->resolution; + if (tmp == 0) { + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff3; + ixheaacd_drc_offset = 4; + + } else { + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff4; + ixheaacd_drc_offset = 8; + } + + for (i = 0; i < filter->order; i++) { + *aptr++ = tns_coeff_ptr[filter->coef[i] + ixheaacd_drc_offset]; + } +} + +VOID ixheaacd_tns_parcor_to_lpc(WORD32 *parcor, WORD32 *lpc, WORD16 *scale, + WORD32 order) + +{ + WORD i, j, status; + WORD32 z1; + WORD32 z[MAX_ORDER + 1]; + WORD32 w[MAX_ORDER + 1]; + WORD32 accu1, accu2; + + status = 1; + *scale = 1; + + while (status) { + status = 0; + + for (i = MAX_ORDER; i >= 0; i--) { + z[i] = 0; + w[i] = 0; + } + + accu1 = (0x40000000 >> (*scale - 1)); + + for (i = 0; i <= order; i++) { + z1 = accu1; + + for (j = 0; j < order; j++) { + w[j] = (accu1); + + accu1 = ixheaacd_add32_sat(accu1, + ixheaacd_mult32_shl_sat(parcor[j], (z[j]))); + if (ixheaacd_abs32_sat(accu1) == 0x7fffffff) status = 1; + } + for (j = (order - 1); j >= 0; j--) { + accu2 = (z[j]); + accu2 = ixheaacd_add32_sat(accu2, + ixheaacd_mult32_shl_sat(parcor[j], (w[j]))); + z[j + 1] = (accu2); + if (ixheaacd_abs32_sat(accu2) == 0x7fffffff) status = 1; + } + + z[0] = (z1); + lpc[i] = (accu1); + accu1 = 0; + } + + accu1 = (status - 1); + + if (accu1 == 0) { + *scale = *scale + 1; + } + } +} + +VOID ixheaacd_tns_parcor_lpc_convert_dec(WORD16 *parcor, WORD16 *lpc, + WORD16 *scale, WORD order) + +{ + WORD i, j, status; + WORD32 accu; + WORD16 temp_buf1[MAX_ORDER + 1]; + WORD16 temp_buf2[MAX_ORDER + 1]; + WORD32 accu1, accu2; + + status = 1; + *scale = 0; + + while (status) { + status = 0; + + for (i = MAX_ORDER; i >= 0; i--) { + temp_buf1[i] = 0; + temp_buf2[i] = 0; + } + + accu1 = (0x7fffffff >> *scale); + + for (i = 0; i <= order; i++) { + accu = accu1; + + for (j = 0; j < order; j++) { + temp_buf2[j] = ixheaacd_round16(accu1); + accu1 = ixheaacd_mac16x16in32_shl_sat(accu1, parcor[j], temp_buf1[j]); + + if (ixheaacd_abs32_sat(accu1) == 0x7fffffff) { + status = 1; + } + } + + for (j = (order - 1); j >= 0; j--) { + accu2 = ixheaacd_deposit16h_in32(temp_buf1[j]); + accu2 = ixheaacd_mac16x16in32_shl_sat(accu2, parcor[j], temp_buf2[j]); + temp_buf1[j + 1] = ixheaacd_round16(accu2); + if (ixheaacd_abs32_sat(accu2) == 0x7fffffff) { + status = 1; + } + } + + temp_buf1[0] = ixheaacd_round16(accu); + lpc[i] = ixheaacd_round16(accu1); + accu1 = 0; + } + + accu1 = (status - 1); + + if (accu1 == 0) { + *scale = *scale + 1; + } + } +} + +VOID ixheaacd_tns_ar_filter_fixed_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) + +{ + WORD32 i, j; + WORD32 y, state[MAX_ORDER + 1]; + WORD32 acc; + + if ((order & 3) != 0) { + for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + lpc[i] = 0; + } + lpc[i] = 0; + order = ((order & 0xfffffffc) + 4); + } + { + WORD32 temp_lo = 0; + for (i = 0; i < order; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + + for (j = i; j > 0; j--) { + acc = ixheaacd_mac32_tns(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + y = ixheaacd_sub32(y, (acc << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + temp_lo = 0; + for (i = order; i < size; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + for (j = order; j > 0; j--) { + acc = ixheaacd_mac32_tns(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + y = ixheaacd_sub32(y, (acc << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + } +} + +VOID ixheaacd_tns_ar_filter_fixed_armv7(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) { + WORD32 i, j; + WORD32 y, state[MAX_ORDER + 1]; + WORD32 acc; + + if ((order & 3) != 0) { + for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + lpc[i] = 0; + } + lpc[i] = 0; + order = ((order & 0xfffffffc) + 4); + } + { + WORD32 temp_lo = 0; + for (i = 0; i < order; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + + for (j = i; j > 0; j--) { + acc = ixheaacd_mac32_tns(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + y = ixheaacd_sub32(y, (acc << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + temp_lo = 0; + for (i = order; i < size; i++) { + WORD64 acc = 0; + WORD32 acc1; + y = (*spectrum) << scale_spec; + for (j = order; j > 0; j--) { + acc = mac32x32in64_dual(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + acc1 = (WORD32)(acc >> 32); + + y = ixheaacd_sub32(y, (acc1 << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + } +} + +VOID ixheaacd_tns_ar_filter_fixed_armv8(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) { + WORD32 i, j; + WORD32 y, state[MAX_ORDER + 1]; + WORD32 acc; + + if ((order & 3) != 0) { + for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + lpc[i] = 0; + } + lpc[i] = 0; + order = ((order & 0xfffffffc) + 4); + } + { + WORD32 temp_lo = 0; + for (i = 0; i < order; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + + for (j = i; j > 0; j--) { + acc = ixheaacd_mac32_tns(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + y = ixheaacd_sub32(y, (acc << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + temp_lo = 0; + for (i = order; i < size; i++) { + WORD64 acc = 0; + WORD32 acc1; + y = (*spectrum) << scale_spec; + for (j = order; j > 0; j--) { + acc = ixheaacd_mac32x32in64_dual(state[j - 1], lpc[j], acc); + state[j] = state[j - 1]; + } + acc1 = (WORD32)(acc >> 32); + + y = ixheaacd_sub32(y, (acc1 << 1)); + state[0] = ixheaacd_shl32(y, shift_value); + + *spectrum = y >> scale_spec; + spectrum += inc; + } + } +} + +void ixheaacd_tns_ma_filter_fixed_ld(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD32 *lpc, WORD32 order, + WORD16 shift_value) { + WORD32 i, j; + WORD32 y, state[MAX_ORDER]; + + for (i = 0; i < order; i++) state[i] = 0; + + for (i = 0; i < size; i++) { + y = *spectrum; + + for (j = 0; j < order; j++) y += ixheaacd_mult32_shl(state[j], lpc[j + 1]); + + for (j = order - 1; j > 0; j--) state[j] = state[j - 1]; + + state[0] = ixheaacd_shl32_dir_sat(*spectrum, shift_value); + *spectrum = y; + spectrum += inc; + } +} + +VOID ixheaacd_tns_ar_filter_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD16 *lpc, WORD32 order, WORD32 shift_value, + WORD scale_spec, WORD32 *ptr_filter_state) { + WORD32 i, j; + WORD32 y; + WORD32 acc; + + if ((order & 3) != 0) { + for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + lpc[i] = 0; + } + lpc[i] = 0; + order = ((order & 0xfffffffc) + 4); + } + + for (i = 0; i < order; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + + for (j = i; j > 0; j--) { + acc = ixheaacd_add32( + acc, ixheaacd_mult32x16in32(ptr_filter_state[j - 1], lpc[j])); + ptr_filter_state[j] = ptr_filter_state[j - 1]; + } + + y = ixheaacd_sub32(y, (acc << 1)); + ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); + *spectrum = y >> scale_spec; + spectrum += inc; + } + + for (i = order; i < size; i++) { + y = (*spectrum) << scale_spec; + acc = 0; + for (j = order; j > 0; j--) { + acc = ixheaacd_add32( + acc, ixheaacd_mult32x16in32(ptr_filter_state[j - 1], lpc[j])); + ptr_filter_state[j] = ptr_filter_state[j - 1]; + } + + y = ixheaacd_sub32(y, (acc << 1)); + ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); + *spectrum = y >> scale_spec; + spectrum += inc; + } +} + +WORD32 ixheaacd_calc_max_spectral_line_dec(WORD32 *ptr_tmp, WORD32 size) { + WORD32 max_spec_line = 0, i; + WORD unroll_cnt, rem; + + unroll_cnt = size >> 3; + for (i = unroll_cnt; i--;) { + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + } + + rem = size - (unroll_cnt << 3); + + if (rem) { + for (i = rem; i--;) { + max_spec_line = ixheaacd_abs32_nrm(*ptr_tmp++) | max_spec_line; + } + } + + return ixheaacd_norm32(max_spec_line); +} \ No newline at end of file diff --git a/decoder/ixheaacd_aacdec.h b/decoder/ixheaacd_aacdec.h new file mode 100644 index 0000000..ec1af57 --- /dev/null +++ b/decoder/ixheaacd_aacdec.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_AACDEC_H +#define IXHEAACD_AACDEC_H + +#define AAC_DEC_OK IA_ENHAACPLUS_DEC_API_NONFATAL_NO_ERROR + +#define IA_ENHAACPDEC_NUM_MEMTABS (4) +#define IA_MPS_DEC_NUM_MEMTABS (4) + +#define FRAME_SIZE 1024 + +#define ADTS_BSFORMAT 2 +#define LOAS_BSFORMAT 3 + +typedef struct ia_aac_decoder_struct { + FLAG frame_status; + WORD32 byte_align_bits; + ia_aac_dec_sbr_bitstream_struct *pstr_sbr_bitstream; + ia_aac_dec_channel_info_struct *pstr_aac_dec_ch_info[CHANNELS]; + + ia_aac_dec_channel_info *ptr_aac_dec_static_channel_info[CHANNELS]; + + ia_aac_dec_overlap_info *pstr_aac_dec_overlap_info[CHANNELS]; + ia_pns_rand_vec_struct *pstr_pns_rand_vec_data; + void *p_ind_channel_info; + WORD32 block_number; + WORD16 sampling_rate_index; + WORD32 sampling_rate; + WORD32 samples_per_frame; + WORD16 channels; + WORD8 num_swb_window[2]; + ia_aac_dec_tables_struct *pstr_aac_tables; + ixheaacd_misc_tables *pstr_common_tables; +} ia_aac_decoder_struct; + +struct ia_aac_persistent_struct { + WORD32 *overlap_buffer; + ia_aac_dec_overlap_info str_aac_dec_overlap_info[CHANNELS]; + ia_pns_rand_vec_struct str_pns_rand_vec_data; + struct ia_aac_decoder_struct str_aac_decoder; + WORD8 *sbr_payload_buffer; + + ia_aac_dec_channel_info *ptr_aac_dec_static_channel_info[CHANNELS]; + WORD16 *ltp_buf[CHANNELS]; +}; + +typedef struct { + VOID *base_scr_8k; + VOID *extra_scr_4k[4]; + + WORD32 *in_data; + WORD32 *out_data; + +} ia_aac_dec_scratch_struct; + +WORD16 ixheaacd_individual_ch_stream( + ia_bit_buf_struct *it_bit_buff, ia_aac_decoder_struct *aac_dec_handle, + WORD32 num_ch, WORD32 frame_size, WORD32 total_channels, WORD32 object_type, + ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type); + +VOID ixheaacd_huff_tables_create(ia_aac_dec_tables_struct *); + +WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v, + WORD32 channels); + +VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len, + const UWORD16 *input_table, + const UWORD32 *idx_table); + +#endif /* #ifndef IXHEAACD_AACDEC_H */ diff --git a/decoder/ixheaacd_aacdecoder.c b/decoder/ixheaacd_aacdecoder.c new file mode 100644 index 0000000..faffd27 --- /dev/null +++ b/decoder/ixheaacd_aacdecoder.c @@ -0,0 +1,886 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_bitbuffer.h" + +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_defines.h" + +#include + +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_common_rom.h" + +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_stereo.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_headerdecode.h" +#include "ixheaacd_multichannel.h" +#include "ixheaacd_adts_crc_check.h" + +#include "ixheaacd_hcr.h" + +#define SIZEOF_INT(x) ((sizeof(x) + sizeof(WORD32) - 1) / sizeof(WORD32)) + +#define EXT_FILL_DATA 1 +#define EXT_FIL 0 + +WORD32 ixheaacd_aacdec_decodeframe( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, + ia_aac_dec_scratch_struct *aac_scratch_ptrs, WORD16 *time_data, + FLAG frame_status, WORD *type, WORD *ch_idx, WORD init_flag, WORD channel, + WORD *element_index_order, WORD skip_full_decode, WORD ch_fac, + WORD slot_element, WORD max_channels, WORD32 total_channels, + WORD32 frame_length, WORD32 frame_size, ia_drc_dec_struct *pstr_drc_dec, + WORD32 object_type, WORD32 ch_config, + ia_eld_specific_config_struct eld_specific_config, WORD16 adtsheader, + ia_drc_dec_struct *drc_dummy) + +{ + WORD ch, ele_type; + ia_aac_dec_state_struct *p_state_enhaacplus_dec; + ia_aac_decoder_struct *aac_dec_handle; + ia_bit_buf_struct *it_bit_buff; + ixheaacd_latm_struct *latm_element; + + WORD error_code = (WORD)frame_status; + WORD previous_element; + WORD prev_data_ele_present = 0; + WORD new_element; + WORD32 num_ch = 0; + + WORD32 crc_reg = 0; + ia_adts_crc_info_struct *ptr_adts_crc_info; + + WORD32 cnt_bits = 0; + + WORD32 eld_sbr_flag = eld_specific_config.ld_sbr_flag_present; + WORD32 ld_sbr_crc_flag = eld_specific_config.ld_sbr_crc_flag; + WORD32 aac_spect_data_resil_flag = + eld_specific_config.aac_spect_data_resil_flag; + + WORD32 ele_ch = 0; + + ia_aac_sfb_code_book_struct *ptr_aac_sfb_code_book_data[CHANNELS]; + ia_pns_stereo_data_struct *ptr_pns_stereo_data; + + WORD32 *work_buffer_core = aac_scratch_ptrs->base_scr_8k; + WORD32 *work_buffer_1 = aac_scratch_ptrs->extra_scr_4k[0]; + WORD32 *work_buffer_2 = aac_scratch_ptrs->extra_scr_4k[2]; + p_state_enhaacplus_dec = p_obj_exhaacplus_dec->p_state_aac; + + aac_dec_handle = p_state_enhaacplus_dec->pstr_aac_dec_info[*ch_idx]; + it_bit_buff = p_state_enhaacplus_dec->ptr_bit_stream; + + ptr_adts_crc_info = it_bit_buff->pstr_adts_crc_info; + + latm_element = &p_state_enhaacplus_dec->latm_struct_element; + + ptr_pns_stereo_data = + (ia_pns_stereo_data_struct + *)&work_buffer_1[2 * SIZEOF_INT(ia_aac_dec_channel_info_struct) + + 2 * SIZEOF_INT(ia_aac_sfb_code_book_struct)]; + + aac_dec_handle->frame_status = 1; + + for (ch = 0; ch < channel; ch++) { + const ia_aac_dec_imdct_tables_struct *pstr_imdct_tables; + aac_dec_handle->pstr_aac_dec_ch_info[ch] = + (ia_aac_dec_channel_info_struct + *)&work_buffer_1[ch * SIZEOF_INT(ia_aac_dec_channel_info_struct)]; + ptr_aac_sfb_code_book_data[ch] = + (ia_aac_sfb_code_book_struct + *)&work_buffer_1[2 * SIZEOF_INT(ia_aac_dec_channel_info_struct) + + (ch * SIZEOF_INT(ia_aac_sfb_code_book_struct))]; + + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ptr_scale_factor = + ptr_aac_sfb_code_book_data[ch]->scale_factor; + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ptr_code_book = + ptr_aac_sfb_code_book_data[ch]->code_book; + + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ptr_spec_coeff = + &work_buffer_core[ch * MAX_BINS_LONG]; + + if (object_type == AOT_ER_AAC_ELD) { + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ptr_spec_coeff = + &work_buffer_core[2 * ch * MAX_BINS_LONG]; + } + + aac_dec_handle->pstr_aac_dec_ch_info[ch]->pstr_stereo_info = + &ptr_pns_stereo_data->str_stereo_info; + aac_dec_handle->pstr_aac_dec_ch_info[ch]->pstr_pns_corr_info = + &ptr_pns_stereo_data->str_pns_corr_info; + aac_dec_handle->pstr_aac_dec_ch_info[ch]->pstr_pns_rand_vec_data = + aac_dec_handle->pstr_pns_rand_vec_data; + + pstr_imdct_tables = aac_dec_handle->pstr_aac_tables->pstr_imdct_tables; + + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[0] = + pstr_imdct_tables->only_long_window_sine; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_short_window[0] = + pstr_imdct_tables->only_short_window_sine; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[1] = + pstr_imdct_tables->only_long_window_kbd; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_short_window[1] = + pstr_imdct_tables->only_short_window_kbd; + + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ptr_long_window[0] = + pstr_imdct_tables->only_long_window_sine; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ptr_short_window[0] = + pstr_imdct_tables->only_short_window_sine; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ptr_long_window[1] = + pstr_imdct_tables->only_long_window_kbd; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ptr_short_window[1] = + pstr_imdct_tables->only_short_window_kbd; + + if (object_type == AOT_ER_AAC_ELD || object_type == AOT_ER_AAC_LD || + object_type == AOT_AAC_LTP) { + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info.frame_length = + frame_length; + + if (512 == aac_dec_handle->samples_per_frame) { + if (object_type != AOT_ER_AAC_ELD) { + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->low_overlap_win; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_512; + + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->low_overlap_win; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_512; + } else { + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->window_sine_512_eld; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_512_eld; + } + } else if (480 == aac_dec_handle->samples_per_frame) { + if (object_type != AOT_ER_AAC_ELD) { + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->low_overlap_win_480; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_480; + + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->low_overlap_win_480; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_480; + + } else { + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[1] = + (WORD16 *)pstr_imdct_tables->window_sine_480_eld; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_long_window[0] = + (WORD16 *)pstr_imdct_tables->window_sine_480_eld; + } + } + } + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP)) { + if (aac_dec_handle->samples_per_frame <= 512) { + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info.ltp.lag = + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ltp_lag; + } + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ltp_buf = + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ltp_buf; + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ltp_lag = + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ltp_lag; + } + + aac_dec_handle->pstr_aac_dec_ch_info[ch]->scratch_buf_ptr = work_buffer_2; + if (object_type == AOT_ER_AAC_ELD) { + aac_dec_handle->pstr_aac_dec_ch_info[ch]->pulse_scratch = + aac_scratch_ptrs->extra_scr_4k[3]; + } + } + + if (channel == 2) { + if (aac_dec_handle->pstr_aac_dec_ch_info[1]->ptr_spec_coeff == + aac_scratch_ptrs->extra_scr_4k[0]) { + aac_dec_handle->pstr_aac_dec_ch_info[1]->ptr_spec_coeff = + aac_dec_handle->pstr_aac_dec_ch_info[0]->ptr_spec_coeff; + } + } + + for (ch = 0; ch < channel; ch++) { + ia_pns_info_struct *ptr_pns_info = + &aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_pns_info; + memset(ptr_pns_info, 0, sizeof(ia_pns_info_struct)); + } + + { + ia_pns_correlation_info_struct *ptr_corr_info = + aac_dec_handle->pstr_aac_dec_ch_info[0]->pstr_pns_corr_info; + memset(ptr_corr_info->correlated, 0, sizeof(UWORD8) * PNS_BAND_FLAGS_SIZE); + } + + for (ch = 0; ch < channel; ch++) { + memset(&aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_hcr_info, 0, + sizeof(ia_hcr_info_struct)); + ixheaacd_huff_code_reorder_tbl_init( + &aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_hcr_info); + } + + for (ch = 0; ch < channel; ch++) { + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info.ltp.data_present = 0; + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info.ltp2.data_present = + 0; + } + + previous_element = ID_END; + + aac_dec_handle->pstr_sbr_bitstream->no_elements = 0; + new_element = 0; + ele_type = *type; + + cnt_bits = it_bit_buff->cnt_bits; + + if (((object_type != AOT_ER_AAC_ELD) && (object_type != AOT_ER_AAC_LD)) || + (object_type < ER_OBJECT_START)) { + while (ele_type != ID_END && aac_dec_handle->frame_status) { + ele_type = (WORD)ixheaacd_read_bits_buf(it_bit_buff, 3); + ixheaacd_read_bidirection(it_bit_buff, -3); + + if (it_bit_buff->cnt_bits < 3) { + it_bit_buff->cnt_bits = -1; + error_code = (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + break; + } + + if ((ele_type == ID_FIL) || (ele_type == ID_DSE) || (new_element == 0)) { + ele_type = (WORD)ixheaacd_read_bits_buf(it_bit_buff, 3); + new_element = 1; + } else if ((ele_type != ID_END)) { + ele_type = -1; + break; + } else { + ele_type = (WORD)ixheaacd_read_bits_buf(it_bit_buff, 3); + } + + if (it_bit_buff->cnt_bits < 0) { + aac_dec_handle->frame_status = 0; + } + + switch (ele_type) { + case ID_SCE: + case ID_CPE: + case ID_LFE: + + if (aac_dec_handle->frame_status) { + ia_aac_dec_channel_info_struct *pstr_aac_dec_ch_info = + aac_dec_handle->pstr_aac_dec_ch_info[LEFT]; + ia_ics_info_struct *ptr_ics_info = + &pstr_aac_dec_ch_info->str_ics_info; + ele_ch = 1; + if (ele_type == ID_CPE) { + ele_ch = 2; + } else { + ele_ch = 1; + } + + prev_data_ele_present = 1; + + if (ptr_adts_crc_info->crc_active == 1) { + crc_reg = ixheaacd_adts_crc_start_reg( + ptr_adts_crc_info, it_bit_buff, CRC_ADTS_RAW_DATA_BLK_LEN); + } + + pstr_aac_dec_ch_info->element_instance_tag = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 4); + + element_index_order[*ch_idx] = + pstr_aac_dec_ch_info->element_instance_tag; + pstr_aac_dec_ch_info->common_window = 0; + + ptr_ics_info->num_swb_window = 0; + ptr_ics_info->sampling_rate_index = + aac_dec_handle->sampling_rate_index; + if ((object_type == AOT_ER_AAC_LD) || + (object_type == AOT_AAC_LTP)) { + ptr_ics_info->ltp.data_present = 0; + ptr_ics_info->ltp2.data_present = 0; + ptr_ics_info->predictor_data_present = 0; + } + + if (ele_ch > 1) { + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT] + ->str_ics_info.num_swb_window = 0; + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT] + ->str_ics_info.sampling_rate_index = + aac_dec_handle->sampling_rate_index; + + pstr_aac_dec_ch_info->common_window = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_aac_dec_ch_info->common_window) { + error_code = ixheaacd_ics_read( + it_bit_buff, ptr_ics_info, aac_dec_handle->num_swb_window, + object_type, pstr_aac_dec_ch_info->common_window, + aac_dec_handle->samples_per_frame); + if (error_code) { + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + goto _ia_handle_error; + } + + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT]->str_ics_info = + pstr_aac_dec_ch_info->str_ics_info; + + ixheaacd_read_ms_data(it_bit_buff, pstr_aac_dec_ch_info); + } + } + + error_code = ixheaacd_individual_ch_stream( + it_bit_buff, aac_dec_handle, ele_ch, frame_length, + total_channels, object_type, eld_specific_config, ele_type); + + if (ptr_adts_crc_info->crc_active == 1) { + ixheaacd_adts_crc_end_reg(ptr_adts_crc_info, it_bit_buff, + crc_reg); + } + + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + if (error_code) { + goto _ia_handle_error; + } + + _ia_handle_error: + if (error_code) { + aac_dec_handle->frame_status = 0; + if ((ele_type >= ID_SCE) && (ele_type <= ID_LFE)) + num_ch = num_ch + ele_ch; + break; + } else { + ixheaacd_channel_pair_process( + aac_dec_handle->pstr_aac_dec_ch_info, ele_ch, + aac_dec_handle->pstr_aac_tables, total_channels, object_type, + aac_spect_data_resil_flag, + eld_specific_config.aac_sf_data_resil_flag, + aac_scratch_ptrs->in_data, aac_scratch_ptrs->out_data, + (void *)aac_dec_handle); + num_ch = num_ch + ele_ch; + } + } + + break; + case ID_CCE: + if (max_channels > 2) { + prev_data_ele_present = 1; + error_code = ixheaacd_dec_coupling_channel_element( + it_bit_buff, aac_dec_handle, + aac_dec_handle->sampling_rate_index, + aac_dec_handle->pstr_aac_tables, + aac_dec_handle->pstr_common_tables, + &element_index_order[*ch_idx], + (ia_enhaacplus_dec_ind_cc *)aac_dec_handle->p_ind_channel_info, + total_channels, frame_length, object_type, eld_specific_config, + ele_type); + + num_ch = num_ch + 1; + + if (error_code) { + aac_dec_handle->frame_status = 0; + + break; + } else { + ixheaacd_channel_pair_process( + aac_dec_handle->pstr_aac_dec_ch_info, 1, + aac_dec_handle->pstr_aac_tables, total_channels, object_type, + aac_spect_data_resil_flag, + eld_specific_config.aac_sf_data_resil_flag, + aac_scratch_ptrs->in_data, aac_scratch_ptrs->out_data, + (void *)aac_dec_handle); + } + } else { + error_code = + (WORD32)((WORD32)IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE); + } + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)(( + WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + goto _ia_handle_error; + } + break; + + case ID_DSE: + case ID_PCE: + case ID_FIL: + + { + WORD32 flag = 1; + + if ((ele_type != ID_FIL) && (ptr_adts_crc_info->crc_active == 1)) { + crc_reg = + ixheaacd_adts_crc_start_reg(ptr_adts_crc_info, it_bit_buff, 0); + } + if (ele_type == ID_DSE) { + ixheaacd_read_data_stream_element( + it_bit_buff, &aac_dec_handle->byte_align_bits, + p_obj_exhaacplus_dec->p_state_aac->pstr_drc_dec); + } + + else if (ele_type == ID_PCE) { + error_code = ixheaacd_decode_pce( + it_bit_buff, + &p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr, + &p_obj_exhaacplus_dec->aac_config.str_prog_config); + if (error_code != 0) { + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + goto _ia_handle_error; + } + aac_dec_handle->frame_status = 0; + error_code = IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + } + + else if (ele_type == ID_FIL) { + WORD32 bits_decoded = 0; + if (object_type == AOT_ER_AAC_ELD) { + bits_decoded = (it_bit_buff->size - it_bit_buff->cnt_bits); + cnt_bits = (frame_size * 8 - bits_decoded); + if (adtsheader == 1) { + if (cnt_bits > it_bit_buff->cnt_bits) + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + } + } + + if (ixheaacd_check_for_sbr_payload( + it_bit_buff, aac_dec_handle->pstr_sbr_bitstream, + (WORD16)previous_element, pstr_drc_dec, object_type, + adtsheader, cnt_bits, ld_sbr_crc_flag, drc_dummy)) { + flag = 0; + } + } + + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)(( + WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + goto _ia_handle_error; + } + + if (flag) { + if (prev_data_ele_present == 0) { + new_element = 0; + } + } + if ((ele_type != ID_FIL) && (ptr_adts_crc_info->crc_active == 1)) { + ixheaacd_adts_crc_end_reg(ptr_adts_crc_info, it_bit_buff, crc_reg); + } + + if (ele_type == ID_PCE) { + if (ptr_adts_crc_info->str_crc_reg_data[crc_reg].bit_buf_cnt) { + ptr_adts_crc_info->str_crc_reg_data[crc_reg].max_bits = + ptr_adts_crc_info->str_crc_reg_data[crc_reg].bit_buf_cnt; + } + } + } + + break; + + case ID_END: + error_code = 0; + break; + } + + previous_element = ele_type; + + if (init_flag) { + if ((ele_type >= ID_SCE) && (ele_type <= ID_LFE)) { + p_obj_exhaacplus_dec->aac_config.element_type[*ch_idx] = ele_type; + } + } + } + } else { + { + switch (ch_config) { + default: + if (aac_dec_handle->frame_status) { + ia_aac_dec_channel_info_struct *pstr_aac_dec_ch_info = + aac_dec_handle->pstr_aac_dec_ch_info[LEFT]; + ia_ics_info_struct *ptr_ics_info = + &pstr_aac_dec_ch_info->str_ics_info; + + if (ch_config == 2) + ele_ch = 2, ele_type = 1; + else + ele_ch = 1, ele_type = 0; + + prev_data_ele_present = 1; + + if (ptr_adts_crc_info->crc_active == 1) { + crc_reg = ixheaacd_adts_crc_start_reg( + ptr_adts_crc_info, it_bit_buff, CRC_ADTS_RAW_DATA_BLK_LEN); + } + + if (object_type != AOT_ER_AAC_ELD) + pstr_aac_dec_ch_info->element_instance_tag = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 4); + + element_index_order[*ch_idx] = + pstr_aac_dec_ch_info->element_instance_tag; + pstr_aac_dec_ch_info->common_window = 0; + + ptr_ics_info->num_swb_window = 0; + ptr_ics_info->sampling_rate_index = + aac_dec_handle->sampling_rate_index; + + if (object_type == AOT_ER_AAC_LD) { + ptr_ics_info->ltp.data_present = 0; + ptr_ics_info->ltp2.data_present = 0; + ptr_ics_info->predictor_data_present = 0; + } + if (ele_ch > 1) { + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT] + ->str_ics_info.num_swb_window = 0; + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT] + ->str_ics_info.sampling_rate_index = + aac_dec_handle->sampling_rate_index; + + if (object_type != 39) + pstr_aac_dec_ch_info->common_window = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 1); + else + pstr_aac_dec_ch_info->common_window = 1; + + if (pstr_aac_dec_ch_info->common_window) { + error_code = ixheaacd_ics_read( + it_bit_buff, ptr_ics_info, aac_dec_handle->num_swb_window, + object_type, pstr_aac_dec_ch_info->common_window, + aac_dec_handle->samples_per_frame); + if (error_code) { + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + goto _ia_handle_error1; + } + + aac_dec_handle->pstr_aac_dec_ch_info[RIGHT]->str_ics_info = + pstr_aac_dec_ch_info->str_ics_info; + + ixheaacd_read_ms_data(it_bit_buff, pstr_aac_dec_ch_info); + + { + if (object_type == AOT_ER_AAC_LD) { + WORD16 temp = ixheaacd_ltp_decode( + it_bit_buff, ptr_ics_info, object_type, + aac_dec_handle->samples_per_frame, LEFT); + + if(temp!=0) + { + return temp; + } + } + } + } + } + + error_code = ixheaacd_individual_ch_stream( + it_bit_buff, aac_dec_handle, ele_ch, frame_length, + total_channels, object_type, eld_specific_config, ele_type); + + if (ptr_adts_crc_info->crc_active == 1) { + ixheaacd_adts_crc_end_reg(ptr_adts_crc_info, it_bit_buff, + crc_reg); + } + + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + if (error_code) { + goto _ia_handle_error1; + } + + _ia_handle_error1: + if (error_code) { + aac_dec_handle->frame_status = 0; + if ((ele_type >= ID_SCE) && (ele_type <= ID_LFE)) + num_ch = num_ch + ele_ch; + break; + } else { + ixheaacd_channel_pair_process( + aac_dec_handle->pstr_aac_dec_ch_info, ele_ch, + aac_dec_handle->pstr_aac_tables, total_channels, object_type, + aac_spect_data_resil_flag, + eld_specific_config.aac_sf_data_resil_flag, + aac_scratch_ptrs->in_data, aac_scratch_ptrs->out_data, + (void *)aac_dec_handle); + num_ch = num_ch + ele_ch; + } + } + + p_obj_exhaacplus_dec->aac_config.element_type[*ch_idx] = ele_ch - 1; + break; + } + + if ((object_type != AOT_ER_AAC_ELD) || (!eld_sbr_flag)) { + WORD32 bits_decoded, cnt_bits; + bits_decoded = (it_bit_buff->size - it_bit_buff->cnt_bits); + + cnt_bits = (frame_size * 8 - bits_decoded); + if (cnt_bits >= 8) { + ixheaacd_extension_payload(it_bit_buff, cnt_bits); + } + + if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { + if (it_bit_buff->cnt_bits) { + WORD32 alignment = it_bit_buff->bit_pos & 0x07; + it_bit_buff->cnt_bits = (it_bit_buff->cnt_bits + alignment) & 7; + it_bit_buff->bit_pos = 7; + it_bit_buff->ptr_read_next++; + } + } else { + if (it_bit_buff->bit_pos != 7) { + WORD32 alignment = it_bit_buff->bit_pos & 0x07; + it_bit_buff->cnt_bits -= alignment + 1; + it_bit_buff->bit_pos += 7 - alignment; + it_bit_buff->ptr_read_next++; + } + } + } else { + WORD32 bits_decoded, cnt_bits; + bits_decoded = (it_bit_buff->size - it_bit_buff->cnt_bits); + cnt_bits = (frame_size * 8 - bits_decoded); + if (adtsheader == 1) { + if (cnt_bits > it_bit_buff->cnt_bits) + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + } + ixheaacd_check_for_sbr_payload( + it_bit_buff, aac_dec_handle->pstr_sbr_bitstream, + (WORD16)(ch_config - 1), pstr_drc_dec, object_type, adtsheader, + cnt_bits, ld_sbr_crc_flag, drc_dummy); + } + } + } + + if (ele_type == ID_END && + p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { + WORD16 tmp; + tmp = ((WORD16)latm_element->layer_info[0][0].frame_len_bits) - + (it_bit_buff->initial_cnt_bits - it_bit_buff->cnt_bits); + + if (tmp > 0) ixheaacd_read_bidirection(it_bit_buff, tmp); + + if (latm_element->other_data_present) { + tmp = latm_element->other_data_length; + ixheaacd_read_bidirection(it_bit_buff, tmp); + } + } + + if (p_obj_exhaacplus_dec->aac_config.ui_drc_enable) { + for (ch = 0; ch < num_ch; ch++) { + pstr_drc_dec->is_longblock[*ch_idx + ch] = + (aac_dec_handle->pstr_aac_dec_ch_info[ch] + ->str_ics_info.window_sequence == EIGHT_SHORT_SEQUENCE) + ? 0 + : 1; + } + } + + if (object_type == AOT_ER_AAC_LD) { + for (ch = 0; ch < channel; ch++) { + aac_dec_handle->ptr_aac_dec_static_channel_info[ch]->ltp_lag = + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info.ltp.lag; + } + } + aac_dec_handle->frame_status = aac_dec_handle->frame_status && frame_status; + + aac_dec_handle->channels = num_ch; + + if (error_code == 0) + if ((skip_full_decode == 0) || ((skip_full_decode == 1) && error_code)) { + ia_ics_info_struct str_ics_info[2]; + WORD32 *spec_coef[2]; + WORD32 *scratch[2]; + + for (ch = 0; ch < channel; ch++) { + str_ics_info[ch] = + aac_dec_handle->pstr_aac_dec_ch_info[ch]->str_ics_info; + spec_coef[ch] = + aac_dec_handle->pstr_aac_dec_ch_info[ch]->ptr_spec_coeff; + } + + scratch[0] = (WORD32 *)aac_scratch_ptrs->extra_scr_4k[2]; + scratch[1] = (WORD32 *)aac_scratch_ptrs->extra_scr_4k[1]; + + ixheaacd_drc_map_channels( + pstr_drc_dec, aac_dec_handle->channels, + aac_dec_handle->pstr_aac_dec_ch_info[0]->str_ics_info.frame_length); + + for (ch = 0; ch < aac_dec_handle->channels; ch++) { + WORD32 *overlap1 = aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->overlap_add_data.ptr_overlap_buf; + const WORD16 *ptr_long_window_next = + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_long_window[(int)str_ics_info[ch].window_shape]; + const WORD16 *ptr_short_window_next = + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ptr_short_window[(int)str_ics_info[ch].window_shape]; + if (pstr_drc_dec->drc_on) { + ixheaacd_drc_apply(pstr_drc_dec, spec_coef[ch], + str_ics_info[ch].window_sequence, ch, + str_ics_info[ch].frame_length); + } + if (skip_full_decode == 0) { + ixheaacd_imdct_process( + aac_dec_handle->pstr_aac_dec_overlap_info[ch], spec_coef[ch], + &str_ics_info[ch], time_data + slot_element, (WORD16)ch_fac, + scratch[ch], aac_dec_handle->pstr_aac_tables, object_type); + + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->overlap_add_data.win_shape = str_ics_info[ch].window_shape; + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->overlap_add_data.win_seq = str_ics_info[ch].window_sequence; + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP)) { + { + if ((str_ics_info[ch].window_sequence == ONLY_LONG_SEQUENCE) || + (str_ics_info[ch].window_sequence == LONG_STOP_SEQUENCE)) { + ixheaacd_lt_update_state( + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ltp_buf, + time_data + slot_element, overlap1, + aac_dec_handle->samples_per_frame, object_type, + (WORD16)ch_fac, str_ics_info[ch].window_sequence, + (WORD16 *)ptr_long_window_next); + } else { + ixheaacd_lt_update_state( + aac_dec_handle->ptr_aac_dec_static_channel_info[ch] + ->ltp_buf, + time_data + slot_element, overlap1, + aac_dec_handle->samples_per_frame, object_type, + (WORD16)ch_fac, str_ics_info[ch].window_sequence, + (WORD16 *)ptr_short_window_next); + } + } + } + slot_element++; + } + } + } + + if (ele_type == ID_END) { + ixheaacd_byte_align(it_bit_buff, &aac_dec_handle->byte_align_bits); + if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { + ixheaacd_byte_align(it_bit_buff, &it_bit_buff->audio_mux_align); + } + } + *type = ele_type; + + aac_dec_handle->block_number = + ixheaacd_add32(aac_dec_handle->block_number, 1); + return error_code; +} + +WORD32 ixheaacd_extension_payload(ia_bit_buf_struct *it_bit_buff, WORD32 cnt) { + WORD16 extension_type, discard; + WORD32 i; + WORD32 fill_nibble; + + WORD32 err = 0; + extension_type = (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 4); + switch (extension_type) { + case EXT_FILL_DATA: + + fill_nibble = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if (fill_nibble == 0) { + for (i = 0; i < (cnt >> 3) - 1; i++) { + ixheaacd_read_bits_buf(it_bit_buff, 8); + } + + } else + err = -1; + break; + case EXT_FIL: + default: + for (i = 0; i < ((cnt)-8) + 4; i++) { + discard = (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 1); + } + } + + return err; +} \ No newline at end of file diff --git a/decoder/ixheaacd_aacpluscheck.c b/decoder/ixheaacd_aacpluscheck.c new file mode 100644 index 0000000..dafbdfa --- /dev/null +++ b/decoder/ixheaacd_aacpluscheck.c @@ -0,0 +1,164 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_audioobjtypes.h" + +#define SBR_EXTENSION_MPEG SBR_EXTENSION + +#define SBR_EXTENSION_CRC_MPEG SBR_EXTENSION_CRC + +FLAG ixheaacd_check_for_sbr_payload( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_sbr_bitstream_struct *pstr_stream_sbr, WORD16 prev_element, + ia_drc_dec_struct *pstr_drc_dec, WORD32 object_type, WORD32 adtsheader, + WORD32 cnt_bits, WORD32 ld_sbr_crc_flag, ia_drc_dec_struct *drc_dummy) { + FLAG ret = 0; + WORD32 count; + + if (object_type == AOT_ER_AAC_ELD) { + count = it_bit_buff->cnt_bits >> 3; + if (adtsheader == 1) count = cnt_bits >> 3; + } else { + count = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if ((count - 15) == 0) { + WORD32 esc_count; + esc_count = ixheaacd_read_bits_buf(it_bit_buff, 8); + count = (esc_count + 14); + } + } + + if (count > 0) { + WORD32 extension_type; + + if (object_type == AOT_ER_AAC_ELD) + extension_type = ld_sbr_crc_flag ? SBR_EXTENSION_CRC : SBR_EXTENSION; + else + extension_type = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if (((count < MAXSBRBYTES)) && (((extension_type == SBR_EXTENSION)) || + ((extension_type == SBR_EXTENSION_CRC))) && + ((prev_element == SBR_ID_SCE) || (prev_element == SBR_ID_CPE) || + sub_d(prev_element, SBR_ID_CCE) == 0) + + ) { + WORD32 no_elements = pstr_stream_sbr->no_elements; + WORD32 byte_count; + ia_sbr_element_stream_struct *ptr_stream_sbr; + + ret = 1; + + ptr_stream_sbr = &pstr_stream_sbr->str_sbr_ele[no_elements]; + ptr_stream_sbr->size_payload = count; + byte_count = ptr_stream_sbr->size_payload; + ptr_stream_sbr->extension_type = extension_type; + ptr_stream_sbr->sbr_ele_id = prev_element; + pstr_stream_sbr->no_elements = no_elements + 1; + + if (pstr_drc_dec) pstr_drc_dec->sbr_found = 1; + + if (byte_count > 0 && sub_d(byte_count, MAXSBRBYTES) <= 0) { + WORD32 i; + WORD8 *ptr_sbr_data; + if (object_type != AOT_ER_AAC_ELD) { + ptr_sbr_data = &ptr_stream_sbr->ptr_sbr_data[1]; + ptr_stream_sbr->ptr_sbr_data[0] = + (WORD8)ixheaacd_read_bits_buf(it_bit_buff, 4); + } else + ptr_sbr_data = ptr_stream_sbr->ptr_sbr_data; + + for (i = byte_count - 2; i >= 0; i--) { + *ptr_sbr_data++ = (WORD8)ixheaacd_read_bits_buf(it_bit_buff, 8); + if (object_type == AOT_ER_AAC_ELD) { + if (adtsheader == 1) { + cnt_bits = cnt_bits - 8; + } + } + } + + if (object_type == AOT_ER_AAC_ELD) { + *ptr_sbr_data++ = (WORD8)ixheaacd_read_bits_buf(it_bit_buff, 8); + if (adtsheader == 1) { + cnt_bits = cnt_bits - 8; + if (cnt_bits > 0) { + WORD32 unaligned_bits = (8 - it_bit_buff->cnt_bits); + *ptr_sbr_data = + (WORD8)ixheaacd_read_bits_buf(it_bit_buff, cnt_bits); + *ptr_sbr_data = *ptr_sbr_data << unaligned_bits; + ptr_stream_sbr->size_payload++; + } + } else { + if (it_bit_buff->cnt_bits > 0) { + WORD32 unaligned_bits = (8 - it_bit_buff->cnt_bits); + *ptr_sbr_data = (WORD8)ixheaacd_read_bits_buf( + it_bit_buff, it_bit_buff->cnt_bits); + *ptr_sbr_data = *ptr_sbr_data << unaligned_bits; + ptr_stream_sbr->size_payload++; + } + } + } + } + + } else if (extension_type == EXT_DYNAMIC_RANGE) { + pstr_drc_dec->drc_element_found = 1; + count -= + ixheaacd_dec_drc_read_element(pstr_drc_dec, drc_dummy, it_bit_buff); + } else { + ixheaacd_read_bits_buf(it_bit_buff, 4); + + it_bit_buff->ptr_read_next += count - 1; + it_bit_buff->cnt_bits -= ((count - 1) << 3); + + if (it_bit_buff->ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + it_bit_buff->ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + } + } + if (it_bit_buff->cnt_bits < 0) ret = -1; + return (ret); +} diff --git a/decoder/ixheaacd_acelp_bitparse.c b/decoder/ixheaacd_acelp_bitparse.c new file mode 100644 index 0000000..17f669b --- /dev/null +++ b/decoder/ixheaacd_acelp_bitparse.c @@ -0,0 +1,560 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include + +#include "ixheaacd_acelp_com.h" +#include "ixheaacd_windows.h" +#include "ixheaacd_vec_baisc_ops.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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_bit_extract.h" +#include "ixheaacd_main.h" +#include "ixheaacd_func_def.h" +#include "ixheaacd_constants.h" +#include +#include +#include + +WORD32 ixheaacd_get_mode_lpc(WORD32 lpc_set, ia_bit_buf_struct *it_bit_buff, + WORD32 *nk_mode) { + WORD32 mode_lpc = 0; + switch (lpc_set) { + case 4: + mode_lpc = 0; + break; + case 0: + case 2: + mode_lpc = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (mode_lpc == 1) *nk_mode = 3; + break; + case 1: + if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0) + mode_lpc = *nk_mode = 2; + else { + if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0) + mode_lpc = *nk_mode = 0; + else + mode_lpc = *nk_mode = 1; + } + break; + case 3: + if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0) + mode_lpc = *nk_mode = 1; + else { + if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0) + mode_lpc = *nk_mode = 0; + else { + if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0) + mode_lpc = 2; + else + mode_lpc = 3; + *nk_mode = 2; + } + } + break; + } + return mode_lpc; +} + +VOID ixheaacd_qn_data(WORD32 nk_mode, WORD32 *qn, + ia_bit_buf_struct *it_bit_buff) { + WORD32 k; + switch (nk_mode) { + case 1: + for (k = 0; k < 2; k++) { + while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) { + qn[k] += 1; + } + if (qn[k] > 0) qn[k] += 1; + } + break; + case 0: + case 2: + case 3: + for (k = 0; k < 2; k++) + qn[k] = 2 + ixheaacd_read_bits_buf(it_bit_buff, 2); + + if (nk_mode == 2) { + for (k = 0; k < 2; k++) { + if (qn[k] > 4) { + qn[k] = 0; + + while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) qn[k] += 1; + + if (qn[k] > 0) qn[k] += 4; + } + } + } else { + for (k = 0; k < 2; k++) { + if (qn[k] > 4) { + WORD32 qn_ext = 0; + while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) qn_ext += 1; + + switch (qn_ext) { + case 0: + qn[k] = 5; + break; + case 1: + qn[k] = 6; + break; + case 2: + qn[k] = 0; + break; + default: + qn[k] = qn_ext + 4; + break; + } + } + } + } + break; + } + return; +} + +VOID ixheaacd_code_book_indices(ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 nk_mode, WORD32 *pos, + ia_bit_buf_struct *it_bit_buff) { + WORD32 k, qn[2] = {0, 0}, nk, n, i; + + ixheaacd_qn_data(nk_mode, &qn[0], it_bit_buff); + + pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = qn[0]; + pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = qn[1]; + + for (k = 0; k < 2; k++) { + if (qn[k] > 0) { + if (qn[k] > 4) { + nk = (qn[k] - 3) / 2; + n = qn[k] - nk * 2; + } else { + nk = 0; + n = qn[k]; + } + pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = + ixheaacd_read_bits_buf(it_bit_buff, 4 * n); + + for (i = 0; i < 8; i++) + pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = + ixheaacd_read_bits_buf(it_bit_buff, nk); + } + } + return; +} + +VOID ixheaacd_lpc_data(WORD32 first_lpd_flag, WORD32 mod[], + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff) { + WORD32 mode_lpc, nk_mode = 0, j = 0; + + mode_lpc = ixheaacd_get_mode_lpc(4, it_bit_buff, &nk_mode); + + pstr_td_frame_data->lpc_first_approx_idx[j++] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff); + if (first_lpd_flag) { + mode_lpc = ixheaacd_get_mode_lpc(0, it_bit_buff, &nk_mode); + pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc; + + if (mode_lpc == 0) + pstr_td_frame_data->lpc_first_approx_idx[j++] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff); + } + if (mod[0] < 3) { + mode_lpc = ixheaacd_get_mode_lpc(2, it_bit_buff, &nk_mode); + pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc; + + if (mode_lpc == 0) + pstr_td_frame_data->lpc_first_approx_idx[j++] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff); + } + if (mod[0] < 2) { + mode_lpc = ixheaacd_get_mode_lpc(1, it_bit_buff, &nk_mode); + pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc; + + if (mode_lpc == 0) + pstr_td_frame_data->lpc_first_approx_idx[j++] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (mode_lpc != 1) + ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff); + } + if (mod[2] < 2) { + mode_lpc = ixheaacd_get_mode_lpc(3, it_bit_buff, &nk_mode); + pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc; + + if (mode_lpc == 0) + pstr_td_frame_data->lpc_first_approx_idx[j++] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff); + } + return; +} + +VOID ixheaacd_fac_decoding(WORD32 fac_length, WORD32 k, WORD32 *fac_prm, + ia_bit_buf_struct *it_bit_buff) { + WORD32 i, j, n, qn, nk, kv[8]; + long code_book_index; + + for (i = 0; i < fac_length; i += 8) { + qn = 0; + while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) { + qn += 1; + } + if (qn != 0) qn += 1; + + nk = 0; + n = qn; + if (qn > 4) { + nk = (qn - 3) >> 1; + n = qn - nk * 2; + } + + code_book_index = ixheaacd_read_bits_buf(it_bit_buff, 4 * n); + + for (j = 0; j < 8; j++) { + kv[j] = ixheaacd_read_bits_buf(it_bit_buff, nk); + } + + ixheaacd_rotated_gosset_mtx_dec(qn, code_book_index, kv, + &fac_prm[k * FAC_LENGTH + i]); + } +} + +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}}; + +VOID ixheaacd_acelp_decoding(WORD32 k, ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff, WORD32 chan) { + WORD32 sfr, kk; + WORD32 nb_subfr = usac_data->num_subfrm; + UWORD8 *ptr_num_bits = + &ixheaacd_num_bites_celp_coding[pstr_td_frame_data->acelp_core_mode][0]; + + chan = 0; + pstr_td_frame_data->mean_energy[k] = ixheaacd_read_bits_buf(it_bit_buff, 2); + + for (sfr = 0; sfr < nb_subfr; sfr++) { + kk = k * 4 + sfr; + + if ((sfr == 0) || ((nb_subfr == 4) && (sfr == 2))) + pstr_td_frame_data->acb_index[kk] = + ixheaacd_read_bits_buf(it_bit_buff, 9); + + else + pstr_td_frame_data->acb_index[kk] = + ixheaacd_read_bits_buf(it_bit_buff, 6); + + pstr_td_frame_data->ltp_filtering_flag[kk] = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_td_frame_data->acelp_core_mode == 5) { + pstr_td_frame_data->icb_index[kk][0] = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_td_frame_data->icb_index[kk][1] = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_td_frame_data->icb_index[kk][2] = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_td_frame_data->icb_index[kk][3] = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_td_frame_data->icb_index[kk][4] = + ixheaacd_read_bits_buf(it_bit_buff, 14); + pstr_td_frame_data->icb_index[kk][5] = + ixheaacd_read_bits_buf(it_bit_buff, 14); + pstr_td_frame_data->icb_index[kk][6] = + ixheaacd_read_bits_buf(it_bit_buff, 14); + pstr_td_frame_data->icb_index[kk][7] = + ixheaacd_read_bits_buf(it_bit_buff, 14); + } else { + pstr_td_frame_data->icb_index[kk][0] = + ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[0]); + pstr_td_frame_data->icb_index[kk][1] = + ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[1]); + pstr_td_frame_data->icb_index[kk][2] = + ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[2]); + pstr_td_frame_data->icb_index[kk][3] = + ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[3]); + } + + pstr_td_frame_data->gains[kk] = ixheaacd_read_bits_buf(it_bit_buff, 7); + } +} + +VOID ixheaacd_tcx_coding(ia_usac_data_struct *usac_data, pWORD32 quant, + WORD32 k, WORD32 first_tcx_flag, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff + + ) { + pstr_td_frame_data->noise_factor[k] = ixheaacd_read_bits_buf(it_bit_buff, 3); + + pstr_td_frame_data->global_gain[k] = ixheaacd_read_bits_buf(it_bit_buff, 7); + + switch (pstr_td_frame_data->mod[k]) { + case 1: + pstr_td_frame_data->tcx_lg[k] = usac_data->len_subfrm; + break; + case 2: + pstr_td_frame_data->tcx_lg[k] = 2 * (usac_data->len_subfrm); + break; + case 3: + pstr_td_frame_data->tcx_lg[k] = 4 * (usac_data->len_subfrm); + break; + } + + if (first_tcx_flag) { + if (usac_data->usac_independency_flg) { + pstr_td_frame_data->arith_reset_flag = 1; + } else { + pstr_td_frame_data->arith_reset_flag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + } + } + + ixheaacd_arith_data(pstr_td_frame_data, quant, usac_data, it_bit_buff, + (first_tcx_flag), k); +} + +WORD32 ixheaacd_lpd_channel_stream(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff, + FLOAT32 *synth + + ) + +{ + WORD32 lpd_mode, k, cnt, ii; + WORD32 first_tcx_flag; + WORD32 *quant; + WORD32 core_mode_last, fac_data_present; + WORD32 *fac_data; + WORD32 first_lpd_flag; + WORD32 short_fac_flag; + WORD32 bpf_control_info; + WORD32 chan = usac_data->present_chan; + WORD32 last_lpd_mode = usac_data->str_tddec[chan]->mode_prev; + WORD32 err = 0; + short_fac_flag = 0; + + pstr_td_frame_data->acelp_core_mode = ixheaacd_read_bits_buf(it_bit_buff, 3); + + lpd_mode = ixheaacd_read_bits_buf(it_bit_buff, 5); + + if (lpd_mode == 25) { + pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] = + pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 3; + } else if (lpd_mode == 24) { + pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] = + pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2; + } else { + if (lpd_mode >= 20) { + pstr_td_frame_data->mod[0] = lpd_mode & 1; + pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1; + pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2; + } else if (lpd_mode >= 16) { + pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] = 2; + pstr_td_frame_data->mod[2] = lpd_mode & 1; + pstr_td_frame_data->mod[3] = (lpd_mode >> 1) & 1; + } else { + pstr_td_frame_data->mod[0] = lpd_mode & 1; + pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1; + pstr_td_frame_data->mod[2] = (lpd_mode >> 2) & 1; + pstr_td_frame_data->mod[3] = (lpd_mode >> 3) & 1; + } + } + + bpf_control_info = ixheaacd_read_bits_buf(it_bit_buff, 1); + + core_mode_last = ixheaacd_read_bits_buf(it_bit_buff, 1); + + fac_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + first_lpd_flag = (core_mode_last == 0) ? 1 : 0; + + quant = pstr_td_frame_data->x_tcx_invquant; + first_tcx_flag = 1; + k = 0; + while (k < 4) { + if (k == 0) { + if ((core_mode_last == 1) && (fac_data_present == 1)) + ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k, + pstr_td_frame_data->fac, it_bit_buff); + } else { + if (((last_lpd_mode == 0) && (pstr_td_frame_data->mod[k] > 0)) || + ((last_lpd_mode > 0) && (pstr_td_frame_data->mod[k] == 0))) + ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k, + pstr_td_frame_data->fac, it_bit_buff); + } + + if (pstr_td_frame_data->mod[k] == 0) { + ixheaacd_acelp_decoding(k, usac_data, pstr_td_frame_data, it_bit_buff, + chan); + last_lpd_mode = 0; + pstr_td_frame_data->tcx_lg[k] = 0; + k += 1; + } else { + ixheaacd_tcx_coding(usac_data, quant, k, first_tcx_flag, + pstr_td_frame_data, it_bit_buff); + last_lpd_mode = pstr_td_frame_data->mod[k]; + quant += pstr_td_frame_data->tcx_lg[k]; + + cnt = 1 << (pstr_td_frame_data->mod[k] - 1); + + for (ii = 0; ii < cnt - 1; ii++) + pstr_td_frame_data->tcx_lg[k + 1 + ii] = 0; + + k += cnt; + first_tcx_flag = 0; + } + } + + ixheaacd_lpc_data(first_lpd_flag, pstr_td_frame_data->mod, pstr_td_frame_data, + it_bit_buff); + + if ((core_mode_last == 0) && (fac_data_present == 1)) { + WORD32 fac_length; + short_fac_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + + fac_length = + (short_fac_flag) ? ((usac_data->ccfl) / 16) : ((usac_data->ccfl) / 8); + + fac_data = pstr_td_frame_data->fac_data; + fac_data[0] = ixheaacd_read_bits_buf(it_bit_buff, 7); + ixheaacd_fac_decoding(fac_length, 0, &fac_data[1], it_bit_buff); + } + + err = ixheaacd_lpd_dec(usac_data, usac_data->str_tddec[chan], + pstr_td_frame_data, synth, first_lpd_flag, + short_fac_flag, bpf_control_info); + + return (err); +} + +WORD32 ixheaacd_tw_buff_update(ia_usac_data_struct *usac_data, WORD32 i, + ia_usac_lpd_decoder_handle st) { + WORD32 *p_ioverlap = usac_data->overlap_data_ptr[i]; + WORD32 td_frame_prev = usac_data->td_frame_prev[i]; + WORD32 window_sequence_last = usac_data->window_sequence_last[i]; + WORD32 tw_mdct = usac_data->tw_mdct[0]; + + if (!td_frame_prev) { + if (tw_mdct) { + return -1; + } else { + ixheaacd_reset_acelp_data_fix( + usac_data, st, p_ioverlap, + (window_sequence_last == EIGHT_SHORT_SEQUENCE), 0); + } + } + return 0; +} + +VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k, + WORD32 mod0) { + WORD32 i; + WORD32 lfac = 0; + + WORD32 *p_out_idata = usac_data->output_data_ptr[k]; + WORD32 *p_ioverlap = usac_data->overlap_data_ptr[k]; + WORD32 nlong = usac_data->ccfl; + WORD32 window_sequence_last = usac_data->window_sequence_last[k]; + WORD32 td_frame_prev = usac_data->td_frame_prev[k]; + WORD32 tw_mdct = usac_data->tw_mdct[0]; + WORD32 nshort = nlong / 8; + WORD32 *p_in_idata = p_out_idata; + + if (!td_frame_prev) { + if (window_sequence_last == EIGHT_SHORT_SEQUENCE) { + lfac = nshort / 2; + } else { + lfac = nshort; + } + } + + if (!td_frame_prev && (mod0 == 0)) { + for (i = 0; i < (nlong / 2) - lfac - (LEN_SUBFR); i++) { + p_in_idata[i] = 0; + } + } else if (!td_frame_prev && (mod0 > 0)) { + for (i = 0; i < (nlong / 2) - lfac; i++) { + p_in_idata[i] = 0; + } + } + + if (tw_mdct) { + if (!td_frame_prev && (mod0 == 0)) { + for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) { + p_ioverlap[i + (nlong / 2)] = 0; + } + } + for (i = 0; i < nlong / 2; i++) { + p_out_idata[i] = p_ioverlap[i] << 1; + p_out_idata[i + nlong / 2] = + ixheaacd_add32_sat(p_ioverlap[i + nlong / 2] << 1, p_in_idata[i]); + p_ioverlap[i] = ixheaacd_add32_sat(p_in_idata[i + (nlong / 2)] >> 1, + p_ioverlap[i + nlong]); + p_ioverlap[i + (nlong / 2)] = 0; + p_ioverlap[i + nlong] = 0; + p_ioverlap[i + nlong + (nlong / 2)] = 0; + } + } else { + if (!td_frame_prev && (mod0 == 0)) { + for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) { + p_ioverlap[i] = 0; + } + } else if (!td_frame_prev) { + for (i = (nlong / 2) - lfac; i < nlong; i++) { + p_ioverlap[i] = 0; + } + } + for (i = 0; i < nlong; i++) { + p_out_idata[i] = ixheaacd_add32_sat(p_ioverlap[i] << 1, p_in_idata[i]); + p_ioverlap[i] = 0; + } + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_acelp_com.h b/decoder/ixheaacd_acelp_com.h new file mode 100644 index 0000000..363f25f --- /dev/null +++ b/decoder/ixheaacd_acelp_com.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ACELP_COM_H +#define IXHEAACD_ACELP_COM_H + +#define LEN_ABS_LEADER 37 +#define LEN_SIGN_LEADER 226 +#define LEN_I3 9 +#define LEN_I4 28 + +extern const FLOAT32 ixheaacd_int_leave_gain_table[256]; + +VOID ixheaacd_rotated_gosset_mtx_dec(WORD32 qn, WORD32 code_book_idx, + WORD32 kv[], WORD32 y[]); + +VOID ixheaacd_residual_tool(WORD32 *a, WORD32 *x, WORD32 *y, WORD32 l, + WORD32 n); + +VOID ixheaacd_synthesis_tool_float(FLOAT32 a[], FLOAT32 x[], FLOAT32 y[], + WORD32 l, FLOAT32 mem[]); + +VOID ixheaacd_synthesis_tool_float1(FLOAT32 a[], FLOAT32 x[], WORD32 l); + +VOID ixheaacd_lpc_wt_synthesis_tool(FLOAT32 a[], FLOAT32 x[], WORD32 l); + +WORD16 ixheaacd_rand_gen(WORD16 *seed); + +VOID ixheaacd_preemphsis_tool(WORD32 *signal, WORD32 mu, WORD32 len, + WORD32 mem); + +VOID ixheaacd_deemphsis_tool(FLOAT32 *signal, WORD32 len, FLOAT32 mem); + +VOID ixheaacd_residual_tool_float(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, + WORD32 loop_count); + +VOID ixheaacd_residual_tool_float1(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, + WORD32 loop_count); + +VOID ixheaacd_preemphsis_tool_float(FLOAT32 *signal, FLOAT32 mu, WORD32 len, + FLOAT32 mem); + +VOID ixheaacd_lsp_to_lp_conversion(FLOAT32 *lsp, FLOAT32 *a); + +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, + FLOAT32 code[]); + +#endif diff --git a/decoder/ixheaacd_acelp_decode.c b/decoder/ixheaacd_acelp_decode.c new file mode 100644 index 0000000..00ee182 --- /dev/null +++ b/decoder/ixheaacd_acelp_decode.c @@ -0,0 +1,597 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include + +#include + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_interface.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" + +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_td_mdct.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_func_def.h" + +#include "ixheaacd_acelp_com.h" + +#define F_PIT_SHARP 0.85F +#define MEAN_ENER 30 + +extern const FLOAT32 ixheaacd_interpol_filt[INTER_LP_FIL_LEN]; + +VOID ixheaacd_acelp_pitch_sharpening(FLOAT32 *x, WORD32 pit_lag) { + WORD32 i; + for (i = pit_lag; i < LEN_SUBFR; i++) { + x[i] += x[i - pit_lag] * F_PIT_SHARP; + } + return; +} + +static VOID ixheaacd_acelp_decode_1sp_per_track(WORD32 idx_1p, WORD32 M, + WORD32 ixheaacd_drc_offset, + WORD32 track, + FLOAT32 code_vec[]) { + WORD32 sign_index, mask, m; + WORD32 sp_pos; + mask = ((1 << M) - 1); + + sp_pos = (idx_1p & mask) + ixheaacd_drc_offset; + sign_index = ((idx_1p >> M) & 1); + + m = (sp_pos << 2) + track; + if (sign_index == 1) + code_vec[m] = (code_vec[m] - 1.0f); + else + code_vec[m] = (code_vec[m] + 1.0f); + + return; +} + +static VOID ixheaacd_acelp_decode_2sp_per_track(WORD32 idx_2p, WORD32 M, + WORD32 ixheaacd_drc_offset, + WORD32 track, + FLOAT32 code_vec[]) { + WORD32 sign_index; + WORD32 mask, m0, m1; + WORD32 sp_pos[2]; + mask = ((1 << M) - 1); + + sp_pos[0] = (((idx_2p >> M) & mask) + ixheaacd_drc_offset); + sp_pos[1] = ((idx_2p & mask) + ixheaacd_drc_offset); + + sign_index = (idx_2p >> 2 * M) & 1; + + m0 = (sp_pos[0] << 2) + track; + m1 = (sp_pos[1] << 2) + track; + + if ((sp_pos[1] - sp_pos[0]) < 0) { + if (sign_index == 1) { + code_vec[m0] = (code_vec[m0] - 1.0f); + code_vec[m1] = (code_vec[m1] + 1.0f); + } else { + code_vec[m0] = (code_vec[m0] + 1.0f); + code_vec[m1] = (code_vec[m1] - 1.0f); + } + } else { + if (sign_index == 1) { + code_vec[m0] = (code_vec[m0] - 1.0f); + code_vec[m1] = (code_vec[m1] - 1.0f); + } else { + code_vec[m0] = (code_vec[m0] + 1.0f); + code_vec[m1] = (code_vec[m1] + 1.0f); + } + } + return; +} + +static VOID ixheaacd_acelp_decode_3sp_per_track(WORD32 idx_3p, WORD32 M, + WORD32 ixheaacd_drc_offset, + WORD32 track, + FLOAT32 code_vec[]) { + WORD32 j, mask, idx_2p, idx_1p; + + mask = ((1 << (2 * M - 1)) - 1); + idx_2p = idx_3p & mask; + j = ixheaacd_drc_offset; + if (((idx_3p >> ((2 * M) - 1)) & 1) == 1) { + j += (1 << (M - 1)); + } + ixheaacd_acelp_decode_2sp_per_track(idx_2p, M - 1, j, track, code_vec); + mask = ((1 << (M + 1)) - 1); + idx_1p = (idx_3p >> 2 * M) & mask; + ixheaacd_acelp_decode_1sp_per_track(idx_1p, M, ixheaacd_drc_offset, track, + code_vec); + return; +} + +static VOID ixheaacd_d_acelp_decode_4sp_per_track_section( + WORD32 index, WORD32 ixheaacd_drc_offset, WORD32 track, + FLOAT32 code_vec[]) { + WORD32 j, idx_2p; + + idx_2p = index & 31; + j = ixheaacd_drc_offset; + if (((index >> 5) & 1) == 1) { + j += 4; + } + ixheaacd_acelp_decode_2sp_per_track(idx_2p, 2, j, track, code_vec); + idx_2p = (index >> 6) & 127; + ixheaacd_acelp_decode_2sp_per_track(idx_2p, 3, ixheaacd_drc_offset, track, + code_vec); + return; +} + +static VOID ixheaacd_acelp_decode_4sp_per_track(WORD32 idx_4p, WORD32 track, + FLOAT32 code_vec[]) { + WORD32 idx_1p, idx_2p, idx_3p; + + switch ((idx_4p >> 14) & 3) { + case 0: + if (((idx_4p >> 13) & 1) == 0) + ixheaacd_d_acelp_decode_4sp_per_track_section(idx_4p, 0, track, + code_vec); + else + ixheaacd_d_acelp_decode_4sp_per_track_section(idx_4p, 8, track, + code_vec); + break; + case 1: + idx_1p = idx_4p >> 10; + ixheaacd_acelp_decode_1sp_per_track(idx_1p, 3, 0, track, code_vec); + ixheaacd_acelp_decode_3sp_per_track(idx_4p, 3, 8, track, code_vec); + break; + case 2: + idx_2p = idx_4p >> 7; + ixheaacd_acelp_decode_2sp_per_track(idx_2p, 3, 0, track, code_vec); + ixheaacd_acelp_decode_2sp_per_track(idx_4p, 3, 8, track, code_vec); + break; + case 3: + idx_3p = idx_4p >> 4; + ixheaacd_acelp_decode_3sp_per_track(idx_3p, 3, 0, track, code_vec); + ixheaacd_acelp_decode_1sp_per_track(idx_4p, 3, 8, track, code_vec); + break; + } + return; +} + +static VOID ixheaacd_d_acelp_add_pulse(WORD32 pos[], WORD32 nb_pulse, + WORD32 track, FLOAT32 code[]) { + WORD32 i, k; + for (k = 0; k < nb_pulse; k++) { + i = ((pos[k] & (16 - 1)) << 2) + track; + if ((pos[k] & 16) == 0) { + code[i] = (WORD16)(code[i] + 1.0f); + } else { + code[i] = (WORD16)(code[i] - 1.0f); + } + } + return; +} + +static VOID ixheaacd_d_acelp_decode_1p_n1(WORD32 index, WORD32 N, + WORD32 ixheaacd_drc_offset, + WORD32 pos[]) { + WORD32 i, pos1, mask; + mask = ((1 << N) - 1); + + pos1 = ((index & mask) + ixheaacd_drc_offset); + i = ((index >> N) & 1); + if (i == 1) { + pos1 += 16; + } + pos[0] = pos1; + return; +} + +VOID ixheaacd_acelp_decode_pulses_per_track(WORD32 cb_index[], WORD16 code_bits, + FLOAT32 code_vec[]) { + WORD32 track_idx, index, ixheaacd_drc_offset, pos[6], i; + memset(code_vec, 0, 64 * sizeof(FLOAT32)); + + if (code_bits == 12) { + for (track_idx = 0; track_idx < 4; track_idx += 2) { + ixheaacd_drc_offset = cb_index[2 * (track_idx / 2)]; + index = cb_index[2 * (track_idx / 2) + 1]; + ixheaacd_d_acelp_decode_1p_n1(index, 4, 0, pos); + ixheaacd_d_acelp_add_pulse( + pos, 1, 2 * ixheaacd_drc_offset + track_idx / 2, code_vec); + } + } else if (code_bits == 16) { + i = 0; + ixheaacd_drc_offset = cb_index[i++]; + ixheaacd_drc_offset = (ixheaacd_drc_offset == 0) ? 1 : 3; + for (track_idx = 0; track_idx < 4; track_idx++) { + if (track_idx != ixheaacd_drc_offset) { + index = cb_index[i++]; + ixheaacd_d_acelp_decode_1p_n1(index, 4, 0, pos); + ixheaacd_d_acelp_add_pulse(pos, 1, track_idx, code_vec); + } + } + } else if (code_bits == 20) { + for (track_idx = 0; track_idx < 4; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_1sp_per_track(index, 4, 0, track_idx, code_vec); + } + } else if (code_bits == 28) { + for (track_idx = 0; track_idx < 2; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_2sp_per_track(index, 4, 0, track_idx, code_vec); + } + for (track_idx = 2; track_idx < 4; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_1sp_per_track(index, 4, 0, track_idx, code_vec); + } + } else if (code_bits == 36) { + for (track_idx = 0; track_idx < 4; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_2sp_per_track(index, 4, 0, track_idx, code_vec); + } + } else if (code_bits == 44) { + for (track_idx = 0; track_idx < 2; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_3sp_per_track(index, 4, 0, track_idx, code_vec); + } + for (track_idx = 2; track_idx < 4; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_2sp_per_track(index, 4, 0, track_idx, code_vec); + } + } else if (code_bits == 52) { + for (track_idx = 0; track_idx < 4; track_idx++) { + index = cb_index[track_idx]; + ixheaacd_acelp_decode_3sp_per_track(index, 4, 0, track_idx, code_vec); + } + } else if (code_bits == 64) { + for (track_idx = 0; track_idx < 4; track_idx++) { + index = ((cb_index[track_idx] << 14) + cb_index[track_idx + 4]); + ixheaacd_acelp_decode_4sp_per_track(index, track_idx, code_vec); + } + } + return; +} + +static void ixheaacd_acelp_decode_gains(WORD32 index, FLOAT32 code_vec[], + FLOAT32 *pitch_gain, + FLOAT32 *codebook_gain, + FLOAT32 mean_exc_energy, + FLOAT32 *energy) { + WORD32 i; + FLOAT32 avg_innov_energy, est_gain; + const FLOAT32 *gain_table = ixheaacd_int_leave_gain_table; + + avg_innov_energy = 0.01f; + for (i = 0; i < LEN_SUBFR; i++) { + avg_innov_energy += code_vec[i] * code_vec[i]; + } + *energy = avg_innov_energy; + + avg_innov_energy = + (FLOAT32)(10.0 * log10(avg_innov_energy / (FLOAT32)LEN_SUBFR)); + + est_gain = mean_exc_energy - avg_innov_energy; + + est_gain = (FLOAT32)pow(10.0, 0.05 * est_gain); + *pitch_gain = gain_table[index * 2]; + + *codebook_gain = gain_table[index * 2 + 1] * est_gain; + + return; +} + +static VOID ixheaacd_cb_exc_calc(FLOAT32 xcitation_curr[], WORD32 pitch_lag, + WORD32 frac) { + WORD32 i, j; + FLOAT32 s, *x0, *x1, *x2; + const FLOAT32 *c1, *c2; + + x0 = &xcitation_curr[-pitch_lag]; + frac = -frac; + if (frac < 0) { + frac += UP_SAMP; + x0--; + } + for (j = 0; j < LEN_SUBFR + 1; j++) { + x1 = x0++; + x2 = x1 + 1; + c1 = &ixheaacd_interpol_filt[frac]; + c2 = &ixheaacd_interpol_filt[UP_SAMP - frac]; + s = 0.0; + for (i = 0; i < INTER_LP_FIL_ORDER; i++, c1 += UP_SAMP, c2 += UP_SAMP) { + s += (*x1--) * (*c1) + (*x2++) * (*c2); + } + xcitation_curr[j] = s; + } + return; +} + +WORD32 ixheaacd_acelp_alias_cnx(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 k, FLOAT32 lp_filt_coeff[], + FLOAT32 stability_factor, + ia_usac_lpd_decoder_handle st) { + WORD32 i, subfr_idx; + WORD32 pitch_lag, pitch_lag_frac, index, pitch_flag, pitch_lag_max; + WORD32 pitch_lag_min = 0; + 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 gain_smooth_factor; + FLOAT32 *ptr_lp_filt_coeff; + WORD32 pitch_min; + WORD32 pitch_fr2; + 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]; + WORD32 TTT; + WORD32 len_subfr = usac_data->len_subfrm; + WORD32 fac_length; + WORD8 shiftp; + WORD32 preshift; + WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; + WORD32 *int_xn2 = &usac_data->x_ac_dec[0]; + WORD32 loop_count = 0; + WORD32 core_mode = pstr_td_frame_data->acelp_core_mode; + FLOAT32 *synth_signal = + &usac_data->synth_buf[len_subfr * k + MAX_PITCH + + (((NUM_FRAMES * usac_data->num_subfrm) / 2) - 1) * + LEN_SUBFR]; + FLOAT32 *xcitation_curr = + &usac_data->exc_buf[len_subfr * k + MAX_PITCH + (INTER_LP_FIL_ORDER + 1)]; + FLOAT32 *ptr_pitch_gain = + &usac_data->pitch_gain[k * usac_data->num_subfrm + + (((NUM_FRAMES * usac_data->num_subfrm) / 2) - 1)]; + WORD32 *ptr_pitch = + &usac_data->pitch[k * usac_data->num_subfrm + + (((NUM_FRAMES * usac_data->num_subfrm) / 2) - 1)]; + WORD32 err = 0; + fac_length = len_subfr / 2; + + if (st->mode_prev > 0) { + for (i = 0; i < fac_length / 2; i++) { + x[i] = st->fac_gain * pstr_td_frame_data->fac[k * FAC_LENGTH + 2 * i]; + x[fac_length / 2 + i] = + st->fac_gain * + pstr_td_frame_data->fac[k * FAC_LENGTH + fac_length - 2 * i - 1]; + } + for (i = 0; i < fac_length / 8; i++) { + x[i] *= st->fac_fd_data[2 * i]; + x[fac_length - i - 1] *= st->fac_fd_data[2 * i + 1]; + } + + preshift = 0; + shiftp = ixheaacd_float2fix(x, int_x, fac_length); + + err = + ixheaacd_acelp_mdct(int_x, int_xn2, &preshift, fac_length, ptr_scratch); + if (err == -1) return err; + ixheaacd_fix2float(int_xn2, xn2 + fac_length, fac_length, &shiftp, + &preshift); + + ixheaacd_vec_cnst_mul((2.0f / (FLOAT32)fac_length), xn2 + fac_length, + xn2 + fac_length, fac_length); + + memset(xn2, 0, fac_length * sizeof(FLOAT32)); + + ixheaacd_lpc_wt_synthesis_tool(st->lp_flt_coeff_a_prev, xn2 + fac_length, + fac_length); + + for (i = 0; i < 2 * fac_length; i++) + xn2[i] += synth_signal[i - (2 * fac_length)]; + + memcpy(synth_signal - fac_length, xn2 + fac_length, + fac_length * sizeof(FLOAT32)); + + tmp = 0.0; + ixheaacd_preemphsis_tool_float(xn2, PREEMPH_FILT_FAC, 2 * fac_length, tmp); + + ptr_lp_filt_coeff = st->lp_flt_coeff_a_prev; + TTT = fac_length % LEN_SUBFR; + if (TTT != 0) { + ixheaacd_residual_tool_float( + ptr_lp_filt_coeff, &xn2[fac_length], + &xcitation_curr[fac_length - (2 * fac_length)], TTT, 1); + ptr_lp_filt_coeff += (ORDER + 1); + } + + loop_count = (fac_length + TTT) / LEN_SUBFR; + ixheaacd_residual_tool_float(ptr_lp_filt_coeff, &xn2[fac_length + TTT], + &xcitation_curr[TTT - fac_length], LEN_SUBFR, + loop_count); + } + + for (i = 0; i < ORDER; i++) + synth_temp[i] = synth_signal[i - ORDER] - + (PREEMPH_FILT_FAC * synth_signal[i - ORDER - 1]); + + i = (((st->fscale * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN; + pitch_min = TMIN + i; + pitch_fr2 = TFR2 - i; + pitch_fr1 = TFR1; + pitch_max = TMAX + (6 * i); + + ptr_lp_filt_coeff = lp_filt_coeff; + for (subfr_idx = 0; subfr_idx < len_subfr; subfr_idx += LEN_SUBFR) { + pitch_flag = subfr_idx; + if ((len_subfr == 256) && (subfr_idx == (2 * LEN_SUBFR))) { + pitch_flag = 0; + } + index = pstr_td_frame_data->acb_index[k * 4 + subfr_nb]; + + if (pitch_flag == 0) { + if (index < (pitch_fr2 - pitch_min) * 4) { + pitch_lag = pitch_min + (index / 4); + pitch_lag_frac = index - (pitch_lag - pitch_min) * 4; + } else if (index < + ((pitch_fr2 - pitch_min) * 4 + (pitch_fr1 - pitch_fr2) * 2)) { + index -= (pitch_fr2 - pitch_min) * 4; + pitch_lag = pitch_fr2 + (index / 2); + pitch_lag_frac = index - (pitch_lag - pitch_fr2) * 2; + pitch_lag_frac *= 2; + } else { + pitch_lag = index + pitch_fr1 - ((pitch_fr2 - pitch_min) * 4) - + ((pitch_fr1 - pitch_fr2) * 2); + pitch_lag_frac = 0; + } + pitch_lag_min = pitch_lag - 8; + if (pitch_lag_min < pitch_min) pitch_lag_min = pitch_min; + + pitch_lag_max = pitch_lag_min + 15; + if (pitch_lag_max > pitch_max) { + pitch_lag_max = pitch_max; + pitch_lag_min = pitch_lag_max - 15; + } + } else { + pitch_lag = pitch_lag_min + index / 4; + pitch_lag_frac = index - (pitch_lag - pitch_lag_min) * 4; + } + + ixheaacd_cb_exc_calc(&xcitation_curr[subfr_idx], pitch_lag, pitch_lag_frac); + + mean_ener_code = + (((FLOAT32)pstr_td_frame_data->mean_energy[k]) * 12.0f) + 18.0f; + + if (pstr_td_frame_data->ltp_filtering_flag[k * 4 + subfr_nb] == 0) { + for (i = 0; i < LEN_SUBFR; i++) + code[i] = (FLOAT32)(0.18 * xcitation_curr[i - 1 + subfr_idx] + + 0.64 * xcitation_curr[i + subfr_idx] + + 0.18 * xcitation_curr[i + 1 + subfr_idx]); + + ixheaacd_mem_cpy(code, &xcitation_curr[subfr_idx], LEN_SUBFR); + } + + ixheaacd_acelp_decode_pulses_per_track( + &(pstr_td_frame_data->icb_index[k * 4 + subfr_nb][0]), + num_codebits_table[core_mode], code); + + tmp = 0.0; + ixheaacd_preemphsis_tool_float(code, TILT_CODE, LEN_SUBFR, tmp); + i = pitch_lag; + if (pitch_lag_frac > 2) i++; + + ixheaacd_acelp_pitch_sharpening(code, i); + + index = pstr_td_frame_data->gains[k * 4 + subfr_nb]; + + ixheaacd_acelp_decode_gains(index, code, &pitch_gain, &gain_code, + mean_ener_code, &innov_energy); + + pitch_energy = 0.0; + for (i = 0; i < LEN_SUBFR; i++) + pitch_energy += + xcitation_curr[i + subfr_idx] * xcitation_curr[i + subfr_idx]; + + pitch_energy *= (pitch_gain * pitch_gain); + + innov_energy *= gain_code * gain_code; + + r_v = (FLOAT32)((pitch_energy - innov_energy) / + (pitch_energy + innov_energy)); + + for (i = 0; i < LEN_SUBFR; i++) + post_process_exc[i] = pitch_gain * xcitation_curr[i + subfr_idx]; + + for (i = 0; i < LEN_SUBFR; i++) + xcitation_curr[i + subfr_idx] = + pitch_gain * xcitation_curr[i + subfr_idx] + gain_code * code[i]; + + i = pitch_lag; + if (pitch_lag_frac > 2) i++; + + if (i > pitch_max) i = pitch_max; + + *ptr_pitch++ = i; + *ptr_pitch_gain++ = pitch_gain; + + voicing_factor = (FLOAT32)(0.5 * (1.0 - r_v)); + gain_smooth_factor = stability_factor * voicing_factor; + gain_code0 = gain_code; + if (gain_code0 < st->gain_threshold) { + gain_code0 = (FLOAT32)(gain_code0 * 1.19); + if (gain_code0 > st->gain_threshold) gain_code0 = st->gain_threshold; + } else { + gain_code0 = (FLOAT32)(gain_code0 / 1.19); + if (gain_code0 < st->gain_threshold) gain_code0 = st->gain_threshold; + } + st->gain_threshold = gain_code0; + gain_smooth = (FLOAT32)((gain_smooth_factor * gain_code0) + + ((1.0 - gain_smooth_factor) * gain_code)); + for (i = 0; i < LEN_SUBFR; i++) code[i] *= gain_smooth; + + cpe = (FLOAT32)(0.125 * (1.0 + r_v)); + + post_process_exc[0] += code[0] - (cpe * code[1]); + + for (i = 1; i < LEN_SUBFR - 1; i++) + post_process_exc[i] += code[i] - (cpe * (code[i - 1] + code[i + 1])); + + post_process_exc[LEN_SUBFR - 1] += + code[LEN_SUBFR - 1] - (cpe * code[LEN_SUBFR - 2]); + + ixheaacd_synthesis_tool_float(ptr_lp_filt_coeff, post_process_exc, + &synth_signal[subfr_idx], LEN_SUBFR, + synth_temp); + memcpy(synth_temp, &synth_signal[subfr_idx + LEN_SUBFR - ORDER], + ORDER * sizeof(FLOAT32)); + + ptr_lp_filt_coeff += (ORDER + 1); + subfr_nb++; + } + + ixheaacd_deemphsis_tool(synth_signal, len_subfr, synth_signal[-1]); + + memset(synth_temp + 16, 0, 128 * sizeof(FLOAT32)); + ixheaacd_synthesis_tool_float1(ptr_lp_filt_coeff, synth_temp + 16, 128); + + ptr_lp_filt_coeff -= (2 * (ORDER + 1)); + memcpy(st->lp_flt_coeff_a_prev, ptr_lp_filt_coeff, + (2 * (ORDER + 1)) * sizeof(FLOAT32)); + + memcpy(st->exc_prev, synth_signal + len_subfr - (1 + fac_length), + (1 + fac_length) * sizeof(FLOAT32)); + + memcpy(st->exc_prev + 1 + fac_length, synth_temp + 16, + fac_length * sizeof(FLOAT32)); + ixheaacd_deemphsis_tool(st->exc_prev + 1 + fac_length, fac_length, + synth_signal[len_subfr - 1]); + + return err; +} diff --git a/decoder/ixheaacd_acelp_info.h b/decoder/ixheaacd_acelp_info.h new file mode 100644 index 0000000..b6b45e4 --- /dev/null +++ b/decoder/ixheaacd_acelp_info.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ACELP_INFO_H +#define IXHEAACD_ACELP_INFO_H + +typedef struct { + WORD32 acelp_core_mode; + WORD32 mod[NUM_FRAMES]; + + WORD32 fac[NUM_FRAMES * FAC_LENGTH]; + WORD32 fac_data[FAC_LENGTH + 1]; + WORD32 mean_energy[NUM_FRAMES]; + WORD32 acb_index[NUM_SUBFR_SUPERFRAME]; + WORD32 noise_factor[NUM_FRAMES]; + WORD32 global_gain[NUM_FRAMES]; + WORD32 arith_reset_flag; + WORD32 x_tcx_invquant[LEN_SUPERFRAME]; + WORD32 tcx_lg[4 * NUM_FRAMES]; + WORD32 ltp_filtering_flag[NUM_SUBFR_SUPERFRAME]; + WORD32 icb_index[NUM_SUBFR_SUPERFRAME][8]; + WORD32 gains[NUM_SUBFR_SUPERFRAME]; + WORD32 mode_lpc[NUM_FRAMES]; + WORD32 lpc_first_approx_idx[110]; +} ia_td_frame_data_struct; + +typedef struct { + WORD32 islong; + WORD32 max_win_len; + WORD32 samp_per_bk; + WORD32 sfb_per_bk; + WORD32 bins_per_sbk; + WORD32 sfb_per_sbk; + + const WORD16 *ptr_sfb_tbl; + pWORD16 sfb_width; + WORD16 sfb_idx_tbl[125]; + WORD32 num_groups; + WORD16 group_len[8]; + +} ia_sfb_info_struct; + +#endif diff --git a/decoder/ixheaacd_acelp_mdct.c b/decoder/ixheaacd_acelp_mdct.c new file mode 100644 index 0000000..63713cd --- /dev/null +++ b/decoder/ixheaacd_acelp_mdct.c @@ -0,0 +1,246 @@ +/****************************************************************************** + * * + * 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 +#include + +#include + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" + +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_td_mdct.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_func_def.h" +#include "ixheaacd_constants.h" +#include +#include +#include + +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_512[4][512]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_384[4][384]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_256[4][256]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_192[4][192]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_128[4][128]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_96[4][96]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_64[4][64]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_48[4][48]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_32[4][32]; +extern const WORD32 ixheaacd_pre_post_twid_cos_sin_24[4][24]; + +static PLATFORM_INLINE WORD32 ixheaacd_mul_sub64_sat_32(WORD32 a, WORD32 b, + WORD32 c, WORD32 d) { + WORD64 diff; + WORD64 temp_result1; + WORD64 temp_result2; + + temp_result1 = (WORD64)a * (WORD64)c; + temp_result2 = (WORD64)b * (WORD64)d; + + diff = (temp_result1 - temp_result2) >> 32; + + if (diff >= 2147483647) + diff = 2147483647; + else if (diff <= -2147483647 - 1) + diff = -2147483647 - 1; + + return ((WORD32)diff); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mul_add64_sat_32(WORD32 a, WORD32 b, + WORD32 c, WORD32 d) { + WORD64 sum; + WORD64 temp_result1; + WORD64 temp_result2; + + temp_result1 = (WORD64)a * (WORD64)c; + temp_result2 = (WORD64)b * (WORD64)d; + + sum = (temp_result1 + temp_result2) >> 32; + + if (sum >= 2147483647) + sum = 2147483647; + else if (sum <= -2147483647 - 1) + sum = -2147483647 - 1; + + return ((WORD32)sum); +} + +static void ixheaacd_pre_twid(WORD32 *in, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *ptr_pre_cos_sin) { + WORD32 i; + + const WORD32 *cos_ptr = &ptr_pre_cos_sin[0]; + const WORD32 *sin_ptr = &ptr_pre_cos_sin[nlength]; + + for (i = 0; i < nlength; i += 4) { + *r_ptr++ = ixheaacd_mul_sub64_sat_32(in[i], in[nlength + i], cos_ptr[i], + sin_ptr[i]); + *i_ptr++ = ixheaacd_mul_add64_sat_32(in[i], in[nlength + i], sin_ptr[i], + cos_ptr[i]); + + *r_ptr++ = ixheaacd_mul_sub64_sat_32(in[i + 1], in[nlength + i + 1], + cos_ptr[i + 1], sin_ptr[i + 1]); + *i_ptr++ = ixheaacd_mul_add64_sat_32(in[i + 1], in[nlength + i + 1], + sin_ptr[i + 1], cos_ptr[i + 1]); + + *r_ptr++ = ixheaacd_mul_sub64_sat_32(in[i + 2], in[nlength + i + 2], + cos_ptr[i + 2], sin_ptr[i + 2]); + *i_ptr++ = ixheaacd_mul_add64_sat_32(in[i + 2], in[nlength + i + 2], + sin_ptr[i + 2], cos_ptr[i + 2]); + + *r_ptr++ = ixheaacd_mul_sub64_sat_32(in[i + 3], in[nlength + i + 3], + cos_ptr[i + 3], sin_ptr[i + 3]); + *i_ptr++ = ixheaacd_mul_add64_sat_32(in[i + 3], in[nlength + i + 3], + sin_ptr[i + 3], cos_ptr[i + 3]); + } +} + +static void ixheaacd_post_twid(WORD32 *data_re, WORD32 *data_im, WORD32 *out, + WORD32 nlength, const WORD32 *ptr_post_cos_sin) { + WORD32 i; + + const WORD32 *cos_ptr = &ptr_post_cos_sin[nlength * 2]; + const WORD32 *sin_ptr = &ptr_post_cos_sin[nlength * 3]; + + WORD32 *out_ptr = &out[2 * nlength - 1]; + for (i = 0; i < nlength; i += 4) { + out[0] = ixheaacd_mul_sub64_sat_32(data_re[i], data_im[i], cos_ptr[i], + sin_ptr[i]); + out_ptr[0] = -ixheaacd_mul_add64_sat_32(data_re[i], data_im[i], sin_ptr[i], + cos_ptr[i]); + + out[2] = ixheaacd_mul_sub64_sat_32(data_re[i + 1], data_im[i + 1], + cos_ptr[i + 1], sin_ptr[i + 1]); + out_ptr[-2] = -ixheaacd_mul_add64_sat_32(data_re[i + 1], data_im[i + 1], + sin_ptr[i + 1], cos_ptr[i + 1]); + + out[4] = ixheaacd_mul_sub64_sat_32(data_re[i + 2], data_im[i + 2], + cos_ptr[i + 2], sin_ptr[i + 2]); + out_ptr[-4] = -ixheaacd_mul_add64_sat_32(data_re[i + 2], data_im[i + 2], + sin_ptr[i + 2], cos_ptr[i + 2]); + + out[6] = ixheaacd_mul_sub64_sat_32(data_re[i + 3], data_im[i + 3], + cos_ptr[i + 3], sin_ptr[i + 3]); + out_ptr[-6] = -ixheaacd_mul_add64_sat_32(data_re[i + 3], data_im[i + 3], + sin_ptr[i + 3], cos_ptr[i + 3]); + out += 8; + out_ptr -= 8; + } +} + +WORD32 ixheaacd_acelp_mdct(WORD32 *ptr_in, WORD32 *ptr_out, WORD32 *preshift, + WORD32 length, WORD32 *ptr_scratch) { + WORD32 *ptr_data_r = ptr_scratch; + WORD32 *ptr_data_i = ptr_scratch + 512; + const WORD32 *ptr_pre_post_twid; + WORD32 err = 0; + + switch (length) { + case 1024: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_512[0][0]; + break; + case 768: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_384[0][0]; + break; + case 512: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_256[0][0]; + break; + case 384: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_192[0][0]; + break; + case 256: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_128[0][0]; + break; + case 192: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_96[0][0]; + break; + case 128: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_64[0][0]; + break; + case 96: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_48[0][0]; + break; + case 64: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_32[0][0]; + break; + case 48: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_24[0][0]; + break; + default: + ptr_pre_post_twid = &ixheaacd_pre_post_twid_cos_sin_24[0][0]; + break; + } + + ixheaacd_pre_twid(ptr_in, ptr_data_r, ptr_data_i, length / 2, + ptr_pre_post_twid); + + ixheaacd_complex_fft(ptr_data_r, ptr_data_i, length / 2, -1, preshift); + *preshift += 1; + + ixheaacd_post_twid(ptr_data_r, ptr_data_i, ptr_out, length / 2, + ptr_pre_post_twid); + *preshift += 1; + return err; +} + +WORD32 ixheaacd_acelp_mdct_main(ia_usac_data_struct *usac_data, WORD32 *in, + WORD32 *out, WORD32 l, WORD32 m, + WORD32 *preshift) { + WORD32 i; + WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; + WORD32 *output_buffer = &usac_data->x_ac_dec[0]; + WORD32 err = 0; + + err = ixheaacd_acelp_mdct(in, output_buffer, preshift, l + m, ptr_scratch); + if (err == -1) return err; + + for (i = 0; i < m / 2; i++) { + out[l + m / 2 - 1 - i] = -output_buffer[m / 2 + l / 2 + i]; + } + for (i = 0; i < l / 2; i++) { + out[i] = output_buffer[m + l / 2 + i]; + out[l - 1 - i] = -output_buffer[m + l / 2 + i]; + } + for (i = 0; i < m / 2; i++) { + out[l + m / 2 + i] = -output_buffer[m / 2 + l / 2 - 1 - i]; + } + for (i = 0; i < l / 2; i++) { + out[l + m + i] = -output_buffer[l / 2 - 1 - i]; + out[2 * l + m - 1 - i] = -output_buffer[l / 2 - 1 - i]; + } + return err; +} diff --git a/decoder/ixheaacd_acelp_tools.c b/decoder/ixheaacd_acelp_tools.c new file mode 100644 index 0000000..430b6f4 --- /dev/null +++ b/decoder/ixheaacd_acelp_tools.c @@ -0,0 +1,208 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include "ixheaacd_cnst.h" +#include "ixheaacd_constants.h" +#include +#include + +static 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}; + +WORD16 ixheaacd_rand_gen(WORD16 *seed) { + *seed = (WORD16)(*seed * 31821L + 13849L); + return (*seed); +} + +VOID ixheaacd_preemphsis_tool(WORD32 *signal, WORD32 mu, WORD32 len, + WORD32 mem) { + WORD32 i; + WORD32 temp; + + temp = signal[len - 1]; + for (i = len - 1; i > 0; i--) { + signal[i] -= (WORD32)ixheaacd_mul32_sh(mu, signal[i - 1], 16); + } + signal[0] -= (WORD32)ixheaacd_mul32_sh(mu, mem, 16); + return; +} + +VOID ixheaacd_preemphsis_tool_float(FLOAT32 *signal, FLOAT32 mu, WORD32 len, + FLOAT32 mem) { + WORD32 i; + FLOAT32 temp; + temp = signal[len - 1]; + for (i = len - 1; i > 0; i--) { + signal[i] = signal[i] - mu * signal[i - 1]; + } + signal[0] -= mu * mem; + return; +} + +VOID ixheaacd_deemphsis_tool(FLOAT32 *signal, WORD32 len, FLOAT32 mem) { + WORD32 i; + signal[0] = signal[0] + PREEMPH_FILT_FAC * mem; + for (i = 1; i < len; i++) { + signal[i] = signal[i] + PREEMPH_FILT_FAC * signal[i - 1]; + } + return; +} + +VOID ixheaacd_lpc_wt_synthesis_tool(FLOAT32 a[], FLOAT32 x[], WORD32 l) { + FLOAT32 s; + WORD32 i, j; + + for (i = 0; i < l; i++) { + s = x[i]; + for (j = 1; j <= ORDER; j += 4) { + s -= (a[j] * ixheaacd_gamma_table[j]) * x[i - j]; + s -= (a[j + 1] * ixheaacd_gamma_table[j + 1]) * x[i - (j + 1)]; + s -= (a[j + 2] * ixheaacd_gamma_table[j + 2]) * x[i - (j + 2)]; + s -= (a[j + 3] * ixheaacd_gamma_table[j + 3]) * x[i - (j + 3)]; + } + x[i] = s; + } + + return; +} + +VOID ixheaacd_synthesis_tool_float(FLOAT32 a[], FLOAT32 x[], FLOAT32 y[], + WORD32 l, FLOAT32 mem[]) { + FLOAT32 buf[LEN_FRAME * 2]; + FLOAT32 s; + FLOAT32 *yy; + WORD32 i, j; + memcpy(buf, mem, ORDER * sizeof(FLOAT32)); + yy = &buf[ORDER]; + for (i = 0; i < l; i++) { + s = x[i]; + for (j = 1; j <= ORDER; j += 4) { + s -= a[j] * yy[i - j]; + s -= a[j + 1] * yy[i - (j + 1)]; + s -= a[j + 2] * yy[i - (j + 2)]; + s -= a[j + 3] * yy[i - (j + 3)]; + } + yy[i] = s; + y[i] = s; + } + + return; +} + +VOID ixheaacd_synthesis_tool_float1(FLOAT32 a[], FLOAT32 x[], WORD32 l) { + FLOAT32 s; + WORD32 i, j; + for (i = 0; i < l; i++) { + s = x[i]; + for (j = 1; j <= ORDER; j += 4) { + s -= a[j] * x[i - j]; + s -= a[j + 1] * x[i - (j + 1)]; + s -= a[j + 2] * x[i - (j + 2)]; + s -= a[j + 3] * x[i - (j + 3)]; + } + x[i] = s; + } + + return; +} + +VOID ixheaacd_residual_tool(WORD32 *a, WORD32 *x, WORD32 *y, WORD32 l, + WORD32 count) { + WORD32 s; + WORD32 i, j; + WORD32 n = l * count; + + for (i = 0; i < n; i++) { + s = x[i]; + for (j = 1; j <= 16; j++) + s += (WORD32)ixheaacd_mul32_sh(a[j], x[i - j], 24); + y[i] = s; + } + + return; +} + +VOID ixheaacd_residual_tool_float(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, + WORD32 loop_count) { + FLOAT32 s; + WORD32 i, j; + for (j = 0; j < loop_count; j++) { + for (i = 0; i < l; i++) { + s = x[i]; + s += a[1] * x[i - 1]; + s += a[2] * x[i - 2]; + s += a[3] * x[i - 3]; + s += a[4] * x[i - 4]; + s += a[5] * x[i - 5]; + s += a[6] * x[i - 6]; + s += a[7] * x[i - 7]; + s += a[8] * x[i - 8]; + s += a[9] * x[i - 9]; + s += a[10] * x[i - 10]; + s += a[11] * x[i - 11]; + s += a[12] * x[i - 12]; + s += a[13] * x[i - 13]; + s += a[14] * x[i - 14]; + s += a[15] * x[i - 15]; + s += a[16] * x[i - 16]; + y[i] = s; + } + a += 17; + x += l; + y += l; + } + return; +} + +VOID ixheaacd_residual_tool_float1(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, + WORD32 loop_count) { + FLOAT32 s; + WORD32 i, j; + for (j = 0; j < loop_count; j++) { + for (i = 0; i < l; i++) { + s = x[i]; + s += a[1] * x[i - 1]; + s += a[2] * x[i - 2]; + s += a[3] * x[i - 3]; + s += a[4] * x[i - 4]; + s += a[5] * x[i - 5]; + s += a[6] * x[i - 6]; + s += a[7] * x[i - 7]; + s += a[8] * x[i - 8]; + s += a[9] * x[i - 9]; + s += a[10] * x[i - 10]; + s += a[11] * x[i - 11]; + s += a[12] * x[i - 12]; + s += a[13] * x[i - 13]; + s += a[14] * x[i - 14]; + s += a[15] * x[i - 15]; + s += a[16] * x[i - 16]; + y[i] = s; + } + x += l; + y += l; + } + return; +} diff --git a/decoder/ixheaacd_adts.h b/decoder/ixheaacd_adts.h new file mode 100644 index 0000000..30dbca0 --- /dev/null +++ b/decoder/ixheaacd_adts.h @@ -0,0 +1,46 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ADTS_H +#define IXHEAACD_ADTS_H + +typedef struct { + WORD16 sync_word; + WORD32 id; + WORD32 layer; + WORD32 protection_absent; + WORD32 profile; + WORD32 samp_freq_index; + WORD32 channel_configuration; + WORD16 aac_frame_length; + WORD32 no_raw_data_blocks; + WORD32 crc_check; +} ia_adts_header_struct; + +WORD32 ixheaacd_find_syncword(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff); + +WORD32 ixheaacd_adtsframe(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff); + +WORD32 ixheaacd_check_if_adts(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff, + WORD32 usr_max_ch); + +#endif /* IXHEAACD_ADTS_H */ diff --git a/decoder/ixheaacd_adts_crc_check.c b/decoder/ixheaacd_adts_crc_check.c new file mode 100644 index 0000000..6761a76 --- /dev/null +++ b/decoder/ixheaacd_adts_crc_check.c @@ -0,0 +1,210 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_common_rom.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_channel.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" + +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" + +#include "ixheaacd_struct_def.h" +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_adts_crc_check.h" + +VOID ixheaacd_adts_crc_open(ia_adts_crc_info_struct *ptr_adts_crc_info) { + WORD32 i, j; + UWORD16 val; + + ptr_adts_crc_info->no_reg = 0; + ptr_adts_crc_info->crc_active = 0; + + for (i = 0; i <= 255; ++i) { + for (val = i << 8, j = 8; --j >= 0;) { + val = (val & 0x8000) ? (val << 1) ^ 0x8005 : val << 1; + } + + ptr_adts_crc_info->crc_lookup[i] = val; + } +} + +VOID ixheaacd_copy_bit_buf_state( + ia_bit_buf_struct *it_bit_buff_src, + ia_crc_bit_buf_struct_handle it_crc_bit_buff_dst) { + it_crc_bit_buff_dst->ptr_bit_buf_base = it_bit_buff_src->ptr_bit_buf_base; + it_crc_bit_buff_dst->ptr_bit_buf_end = it_bit_buff_src->ptr_bit_buf_end; + it_crc_bit_buff_dst->ptr_read_next = it_bit_buff_src->ptr_read_next; + it_crc_bit_buff_dst->bit_pos = it_bit_buff_src->bit_pos; + it_crc_bit_buff_dst->cnt_bits = it_bit_buff_src->cnt_bits; + it_crc_bit_buff_dst->size = it_bit_buff_src->size; +} + +WORD32 ixheaacd_adts_crc_start_reg(ia_adts_crc_info_struct *ptr_adts_crc_info, + ia_bit_buf_struct *it_bit_buff_src, + WORD32 no_bits) { + UWORD32 no_bytes; + + ptr_adts_crc_info->str_crc_reg_data[ptr_adts_crc_info->no_reg].bit_cnt = 0; + ptr_adts_crc_info->str_crc_reg_data[ptr_adts_crc_info->no_reg].max_bits = + no_bits; + + if (no_bits < 0) { + no_bits = -no_bits; + } + + if (no_bits == 0) { + no_bits = 16 << 3; + } + + no_bytes = no_bits >> 3; + + if (no_bytes << 3 < (UWORD32)no_bits) { + no_bytes++; + } + + ptr_adts_crc_info->str_crc_reg_data[ptr_adts_crc_info->no_reg].buf_size = + no_bytes; + ptr_adts_crc_info->str_crc_reg_data[ptr_adts_crc_info->no_reg].active = 1; + + ixheaacd_copy_bit_buf_state( + it_bit_buff_src, + &(ptr_adts_crc_info->str_crc_reg_data[ptr_adts_crc_info->no_reg] + .str_bit_buf)); + + ptr_adts_crc_info->no_reg += 1; + + return (ptr_adts_crc_info->no_reg - 1); +} + +VOID ixheaacd_adts_crc_end_reg(ia_adts_crc_info_struct *ptr_adts_crc_info, + ia_bit_buf_struct *it_bit_buff_src, WORD32 reg) { + ptr_adts_crc_info->str_crc_reg_data[reg].active = 0; + ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt = + ptr_adts_crc_info->str_crc_reg_data[reg].str_bit_buf.cnt_bits - + it_bit_buff_src->cnt_bits; +} + +VOID ixheaacd_adts_crc_fast_crc(ia_adts_crc_info_struct *ptr_adts_crc_info, + UWORD16 *crc_reg, UWORD8 feed) { + *crc_reg = + (*crc_reg << 8) ^ ptr_adts_crc_info->crc_lookup[(*crc_reg >> 8) ^ feed]; +} + +VOID ixheaacd_adts_crc_slow_crc(UWORD16 *crc_reg, UWORD8 feed, + UWORD32 no_bits) { + UWORD32 i; + UWORD16 tmp; + for (i = 0; i < no_bits; i++) { + tmp = (feed & (1 << (7 - i))) >> (7 - i); + tmp ^= (*crc_reg & (1 << 15)) >> 15; + tmp *= 32773; + *crc_reg <<= 1; + *crc_reg ^= tmp; + } +} + +WORD32 ixheaacd_adts_crc_check_crc(ia_adts_crc_info_struct *ptr_adts_crc_info) { + WORD32 error_code = AAC_DEC_OK; + UWORD16 crc = 65535; + WORD32 reg; + ia_crc_reg_data_struct *ptr_reg_data; + + for (reg = 0; reg < ptr_adts_crc_info->no_reg; reg++) { + UWORD8 bits; + UWORD32 bits_remaining; + + ptr_reg_data = &ptr_adts_crc_info->str_crc_reg_data[reg]; + + if (ptr_reg_data->max_bits > 0) { + if (ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt > + ptr_reg_data->max_bits) + bits_remaining = ptr_reg_data->max_bits; + else + bits_remaining = ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt; + } else { + bits_remaining = ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt; + } + + while (bits_remaining >= 8) { + bits = (UWORD8)ixheaacd_read_bits_buf( + (ia_bit_buf_struct *)(&ptr_adts_crc_info->str_crc_reg_data[reg] + .str_bit_buf), + 8); + ixheaacd_adts_crc_fast_crc(ptr_adts_crc_info, &crc, bits); + bits_remaining -= 8; + } + + bits = (UWORD8)ixheaacd_read_bits_buf( + (ia_bit_buf_struct *)(&ptr_adts_crc_info->str_crc_reg_data[reg] + .str_bit_buf), + bits_remaining); + ixheaacd_adts_crc_slow_crc(&crc, (UWORD8)(bits << (8 - bits_remaining)), + bits_remaining); + + if (ptr_reg_data->max_bits > + ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt) { + bits_remaining = ptr_reg_data->max_bits - + ptr_adts_crc_info->str_crc_reg_data[reg].bit_buf_cnt; + + for (; bits_remaining >= 8; bits_remaining -= 8) { + ixheaacd_adts_crc_fast_crc(ptr_adts_crc_info, &crc, 0); + } + + ixheaacd_adts_crc_slow_crc(&crc, 0, bits_remaining); + } + } + + ptr_adts_crc_info->no_reg = 0; + + if (crc != ptr_adts_crc_info->file_value) { + return (IA_ENHAACPLUS_DEC_EXE_NONFATAL_ADTS_HDR_CRC_FAIL); + } + + return (error_code); +} diff --git a/decoder/ixheaacd_adts_crc_check.h b/decoder/ixheaacd_adts_crc_check.h new file mode 100644 index 0000000..38da5c2 --- /dev/null +++ b/decoder/ixheaacd_adts_crc_check.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ADTS_CRC_CHECK_H +#define IXHEAACD_ADTS_CRC_CHECK_H + +VOID ixheaacd_adts_crc_open(ia_adts_crc_info_struct *ptr_adts_crc_info); +WORD32 ixheaacd_adts_crc_start_reg(ia_adts_crc_info_struct *ptr_adts_crc_info, + ia_bit_buf_struct *it_bit_buff_src, + WORD32 no_bits); +VOID ixheaacd_adts_crc_end_reg(ia_adts_crc_info_struct *ptr_adts_crc_info, + ia_bit_buf_struct *it_bit_buff_src, WORD32 reg); +WORD32 ixheaacd_adts_crc_check_crc(ia_adts_crc_info_struct *ptr_adts_crc_info); + +#endif /* #ifndef IXHEAACD_ADTS_CRC_CHECK_H */ diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c new file mode 100644 index 0000000..c050b23 --- /dev/null +++ b/decoder/ixheaacd_api.c @@ -0,0 +1,2618 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include "ixheaacd_sbr_common.h" +#include +#include +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_error_standards.h" +#include "ixheaacd_apicmd_standards.h" +#include "ixheaacd_aac_config.h" +#include "ixheaacd_api_defs.h" + +#include "ixheaacd_definitions.h" +#include "ixheaacd_error_codes.h" +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_defines.h" +#include + +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_freq_sca.h" +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_headerdecode.h" +#include "ixheaacd_adts_crc_check.h" + +#include "ixheaacd_multichannel.h" +#include "ixheaacd_ver_number.h" + +#include "ixheaacd_interface.h" +#include "ixheaacd_info.h" + +#include "ixheaacd_config.h" + +#include "ixheaacd_struct.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_main.h" +#include "ixheaacd_arith_dec.h" +#include "ixheaacd_create.h" +#include "ixheaacd_function_selector.h" + +#define MAX_TRACKS_PER_LAYER 50 + +#define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) + +#define IA_ENHAACPDEC_NUM_MEMTABS (4) + +#define NUM_AAC_TABLES 8 + +#define IXHEAACD_CCE_DEC_INFO_MEM_SIZE (610) +#define IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 (IXHEAACD_CCE_DEC_INFO_MEM_SIZE + 8) + +IA_ERRORCODE ixheaacd_dec_mem_api( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD32 i_cmd, + WORD32 i_idx, VOID *pv_value) { + pUWORD32 pui_value = pv_value; + + if (i_idx < 0 || i_idx >= IA_ENHAACPDEC_NUM_MEMTABS) { + return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_MEMTAB_INDEX; + } + + if (i_cmd == IA_API_CMD_SET_MEM_PTR) { + if (pv_value == 0) { + return (IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALLOC); + } + if (((SIZE_T)pv_value % + p_obj_exhaacplus_dec->p_mem_info_aac[i_idx].ui_alignment) != 0) { + return (IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALIGN); + } + p_obj_exhaacplus_dec->pp_mem_aac[i_idx] = pv_value; + + if (i_idx == IA_ENHAACPLUS_DEC_PERSIST_IDX) { + pUWORD8 p_temp = pv_value; + UWORD32 *meminfo = + (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac + i_idx; + UWORD32 pers_size = meminfo[0]; + p_temp = p_temp + pers_size - (sizeof(ia_dec_data_struct) + + sizeof(ia_audio_specific_config_struct) + (8300)); + p_obj_exhaacplus_dec->p_state_aac = pv_value; + + memset(p_obj_exhaacplus_dec->p_state_aac, 0, + sizeof(ia_aac_dec_state_struct)); + + p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = + p_temp + sizeof(ia_dec_data_struct); +p_obj_exhaacplus_dec->p_state_aac->header_ptr = p_temp + sizeof(ia_dec_data_struct) + + sizeof(ia_audio_specific_config_struct); + } + + } else { + UWORD32 *meminfo = + (UWORD32 *)(p_obj_exhaacplus_dec->p_mem_info_aac + i_idx); + *pui_value = *(meminfo + (i_cmd - IA_API_CMD_GET_MEM_INFO_SIZE)); + } + + return IA_NO_ERROR; +} + +PLATFORM_INLINE VOID +ixheaacd_init_sbr_tables(ia_sbr_tables_struct *ptr_sbr_tables) { + ptr_sbr_tables->env_calc_tables_ptr = + (ia_env_calc_tables_struct *)&ixheaacd_aac_dec_env_calc_tables; + ptr_sbr_tables->qmf_dec_tables_ptr = + (ia_qmf_dec_tables_struct *)&ixheaacd_aac_qmf_dec_tables; + ptr_sbr_tables->env_extr_tables_ptr = + (ia_env_extr_tables_struct *)&ixheaacd_aac_dec_env_extr_tables; + ptr_sbr_tables->ps_tables_ptr = + (ia_ps_tables_struct *)&ixheaacd_aac_dec_ps_tables; +} + +VOID ixheaacd_updatebytesconsumed( + ia_aac_dec_state_struct *p_state_enhaacplus_dec, + struct ia_bit_buf_struct *it_bit_buff) { + p_state_enhaacplus_dec->i_bytes_consumed = + (it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base); + if ((p_state_enhaacplus_dec->i_bytes_consumed == 0) && + (it_bit_buff->cnt_bits == 0)) { + p_state_enhaacplus_dec->i_bytes_consumed = + p_state_enhaacplus_dec->ui_in_bytes; + } + if (it_bit_buff->cnt_bits < 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + p_state_enhaacplus_dec->ui_out_bytes = 0; + p_state_enhaacplus_dec->b_n_raw_data_blk = 0; + } +} + +WORD32 ixheaacd_readifadts(ia_aac_dec_state_struct *p_state_enhaacplus_dec, + struct ia_bit_buf_struct *it_bit_buff, + ia_adts_header_struct *adts) { + WORD error; + + if ((error = ixheaacd_find_syncword(adts, it_bit_buff)) != 0) { + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_ADTS_SYNC_LOST; + } + if ((error = ixheaacd_check_if_adts( + adts, it_bit_buff, + p_state_enhaacplus_dec->p_config->ui_max_channels)) != 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + + if (it_bit_buff->cnt_bits < 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + p_state_enhaacplus_dec->ui_out_bytes = 0; + error = IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + return error; + } + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_ADTS_SYNC_LOST; + } + p_state_enhaacplus_dec->b_n_raw_data_blk = + (WORD8)(adts->no_raw_data_blocks + 1); + return 0; +} + +static VOID ixheaacd_allocate_aac_scr( + ia_aac_dec_scratch_struct *aac_scratch_struct, VOID *base_scratch_ptr, + VOID *output_ptr, WORD channel, WORD max_channel, + WORD32 audio_object_type) { + aac_scratch_struct->base_scr_8k = base_scratch_ptr; + aac_scratch_struct->extra_scr_4k[1] = (WORD8 *)base_scratch_ptr; + if (channel == 1) { + aac_scratch_struct->extra_scr_4k[0] = + (WORD8 *)base_scratch_ptr + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + + (4 * 1024); + } else { + aac_scratch_struct->extra_scr_4k[0] = output_ptr; + + if (max_channel > 2) { + aac_scratch_struct->extra_scr_4k[0] = + (WORD8 *)base_scratch_ptr + + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + (8 * 1024); + } + } + + aac_scratch_struct->extra_scr_4k[2] = + (WORD8 *)base_scratch_ptr + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + + (46 * 1024); + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + aac_scratch_struct->extra_scr_4k[0] = + (WORD8 *)base_scratch_ptr + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + + (4 * 1024); + + aac_scratch_struct->extra_scr_4k[2] = + (WORD8 *)base_scratch_ptr + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + + (46 * 1024); + + aac_scratch_struct->extra_scr_4k[3] = + (WORD8 *)base_scratch_ptr + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + + (54 * 1024); + } + if ((audio_object_type == AOT_ER_AAC_LD) || + (audio_object_type == AOT_AAC_LTP)) { + aac_scratch_struct->in_data = + (WORD32 *)((WORD8 *)base_scratch_ptr + + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + (62 * 1024) + + (4 * 16)); + aac_scratch_struct->out_data = + (WORD32 *)((WORD8 *)base_scratch_ptr + + (IXHEAACD_CCE_DEC_INFO_MEM_SIZE_8 * 1024) + (56 * 1024) + + (4 * 16)); + } +} + +VOID ixheaacd_allocate_sbr_scr(ia_sbr_scr_struct *sbr_scratch_struct, + VOID *base_scratch_ptr, VOID *output_ptr, + WORD total_elements, WORD ch_fac, + WORD32 audio_object_type) { + WORD32 temp = 0; + sbr_scratch_struct->ptr_work_buf_core = base_scratch_ptr; + sbr_scratch_struct->ptr_work_buf = (WORD8 *)base_scratch_ptr + (18 * 1024); + + if (total_elements > 1) { + sbr_scratch_struct->extra_scr_1k[0] = + (WORD8 *)base_scratch_ptr + (18 * 1024); + + sbr_scratch_struct->extra_scr_1k[1] = + (WORD8 *)base_scratch_ptr + (19 * 1024); + } + + else { + if (ch_fac == 1) { + temp = 2; + } else { + temp = 4; + } + + if (audio_object_type != AOT_ER_AAC_ELD) { + sbr_scratch_struct->extra_scr_1k[0] = (WORD8 *)output_ptr + (temp * 1024); + + sbr_scratch_struct->extra_scr_1k[1] = + (WORD8 *)base_scratch_ptr + (18 * 1024); + } else { + sbr_scratch_struct->extra_scr_1k[0] = + (WORD8 *)base_scratch_ptr + (18 * 1024); + + sbr_scratch_struct->extra_scr_1k[1] = + (WORD8 *)base_scratch_ptr + (19 * 1024); + } + } +} + +IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, + WORD32 i_idx, pVOID pv_value) { + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec = p_ia_enhaacplus_dec_obj; + pUWORD32 pui_value = pv_value; + pWORD8 pb_value = pv_value; +#ifdef ENABLE_DRC + pVOID *pp_value = (pVOID *)pv_value; +#endif + + if ((i_cmd != IA_API_CMD_GET_API_SIZE) && + (i_cmd != IA_API_CMD_GET_LIB_ID_STRINGS)) { + if (p_ia_enhaacplus_dec_obj == 0) { + return (IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALLOC); + } + if (((SIZE_T)p_ia_enhaacplus_dec_obj & 3) != 0) { + return (IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALIGN); + } + } + + switch (i_cmd) { + case IA_API_CMD_GET_MEM_INFO_SIZE: + case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: + case IA_API_CMD_GET_MEM_INFO_TYPE: + case IA_API_CMD_SET_MEM_PTR: { + return ixheaacd_dec_mem_api(p_ia_enhaacplus_dec_obj, i_cmd, i_idx, + pv_value); + } + + case IA_API_CMD_GET_TABLE_INFO_SIZE: + case IA_API_CMD_GET_TABLE_INFO_ALIGNMENT: + case IA_API_CMD_SET_TABLE_PTR: + case IA_API_CMD_GET_TABLE_PTR: { + return ixheaacd_dec_table_api(p_ia_enhaacplus_dec_obj, i_cmd, i_idx, + pv_value); + } + }; + + switch (i_cmd) { + case IA_API_CMD_GET_LIB_ID_STRINGS: { + WORD8 *i1_ver; + WORD8 ver_char; + + if (i_idx == IA_CMD_TYPE_LIB_NAME) + i1_ver = (WORD8 *)LIBNAME; + else if (i_idx == IA_CMD_TYPE_LIB_VERSION) + i1_ver = (WORD8 *)xHE_AAC_DEC_ITTIAM_VER; + else + return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX; + + ver_char = *i1_ver++; + + for (; ver_char != '\0';) { + if (ver_char != '$') { + *pb_value++ = ver_char; + } + ver_char = *i1_ver++; + } + *pb_value = ver_char; + + break; + } + case IA_API_CMD_GET_API_SIZE: { + *pui_value = sizeof(ia_exhaacplus_dec_api_struct); + break; + } + case IA_API_CMD_INIT: { + switch (i_idx) { + case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: { + p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; + p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; + p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; + p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; + p_obj_exhaacplus_dec->aac_config.frame_status = 1; + p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 0; + p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; + p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; + p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; + p_obj_exhaacplus_dec->aac_config.loas_present = 0; + + p_obj_exhaacplus_dec->aac_config.ui_drc_enable = 1; + p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; + p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; + + p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; + + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; + p_obj_exhaacplus_dec->aac_config.downmix = 0; + + { + ia_aac_dec_tables_struct *pstr_aac_tables = + &p_obj_exhaacplus_dec->aac_tables; + pstr_aac_tables->pstr_huffmann_tables = + (ia_aac_dec_huffman_tables_struct + *)&ixheaacd_aac_huffmann_tables; + pstr_aac_tables->pstr_block_tables = + (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; + pstr_aac_tables->pstr_imdct_tables = + (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; + + ixheaacd_huff_tables_create(pstr_aac_tables); + } + ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); + p_obj_exhaacplus_dec->common_tables = + (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; + p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; + + break; + } + case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: { + ixheaacd_fill_aac_mem_tables(p_obj_exhaacplus_dec); + break; + } + case IA_CMD_TYPE_INIT_PROCESS: { + WORD32 err_code = 0; + err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); + if (err_code != 0) { + p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = + p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; + } + return err_code; + break; + } + case IA_CMD_TYPE_INIT_DONE_QUERY: { + if (p_obj_exhaacplus_dec->p_state_aac->ui_init_done == 1) { + *pui_value = 1; + } else { + *pui_value = 0; + } + break; + } + + case IA_CMD_TYPE_GA_HDR: { + return ixheaacd_decoder_2_ga_hdr(p_obj_exhaacplus_dec); + break; + } + + case IA_CMD_TYPE_FLUSH_MEM: { + return ixheaacd_decoder_flush_api(p_obj_exhaacplus_dec); + break; + } + + default: { + return IA_ENHAACPLUS_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED; + } + }; + break; + } + case IA_API_CMD_SET_CONFIG_PARAM: { + switch (i_idx) { + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ: { + if ((*pui_value < 8000) || (*pui_value > 96000)) { + return (IA_ENHAACPLUS_DEC_CONFIG_FATAL_INVALID_SAMPLE_RATE); + } + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ: { + if ((*pui_value != 16) && (*pui_value != 24)) { + p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_PCM_WDSZ); + } + p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DOWNMIX); + } + p_obj_exhaacplus_dec->aac_config.flag_downmix = *pui_value; + p_obj_exhaacplus_dec->aac_config.downmix = *pui_value; + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 1; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_TOSTEREO); + } + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DSAMPLE); + } + p_obj_exhaacplus_dec->aac_config.down_sample_flag = *pui_value; + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMEOK: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.frame_status = 1; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_FRAMEOK); + } + p_obj_exhaacplus_dec->aac_config.frame_status = *pui_value; + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MP4FLAG); + } + p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.loas_present = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_LOASFLAG); + } + p_obj_exhaacplus_dec->aac_config.loas_present = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.ui_drc_enable = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRCFLAG); + } + p_obj_exhaacplus_dec->aac_config.ui_drc_enable = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT: { + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; + if (*pui_value > 127) { + p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_CUT); + } + p_obj_exhaacplus_dec->aac_config.ui_drc_cut = + (WORD32)((*pui_value / 127.0) * 100); + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST: { + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; + if (*pui_value > 127) { + p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_BOOST); + } + p_obj_exhaacplus_dec->aac_config.ui_drc_boost = + (WORD32)((*pui_value / 127.0) * 100); + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL: { + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; + if (*pui_value > 127) { + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_TARGET); + } + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP: { + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRCFLAG); + } + p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_SYNCFLAG); + } + p_obj_exhaacplus_dec->aac_config.ui_disable_sync = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_SBRUPFLAG); + } + p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL: { + if (*pui_value > 8) { + p_obj_exhaacplus_dec->aac_config.ui_max_channels = 8; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL); + } + if (*pui_value < 2) { + p_obj_exhaacplus_dec->aac_config.ui_max_channels = 2; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL); + } + p_obj_exhaacplus_dec->aac_config.ui_max_channels = *pui_value; + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE: { + if (*pui_value == 1) { + p_obj_exhaacplus_dec->aac_config.framesize_480 = 1; + } else if (*pui_value == 0) { + p_obj_exhaacplus_dec->aac_config.framesize_480 = 0; + } else { + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_FRAMSZ); + } + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_ELD_SBR_PRESENT: { + if (*pui_value == 1) { + p_obj_exhaacplus_dec->aac_config.eld_sbr_present = 1; + } else if (*pui_value == 0) { + p_obj_exhaacplus_dec->aac_config.eld_sbr_present = 0; + } else { + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_ELDSBR); + } + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL: { + if (*pui_value > 16) { + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 1; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_COUP_CHANNEL); + } + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = *pui_value; + break; + } + + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO: { + if ((*pui_value != 1) && (*pui_value != 0)) { + p_obj_exhaacplus_dec->aac_config.downmix = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DOWNMIX); + } + p_obj_exhaacplus_dec->aac_config.downmix = *pui_value; + break; + } + + default: { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM; } + } + break; + } + + case IA_API_CMD_GET_CONFIG_PARAM: { +#ifdef ENABLE_DRC + UWORD32 i; +#endif + WORD32 *pvalue = + (WORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz); + + if (i_idx >= 0 && i_idx <= 5) { + *pui_value = pvalue[i_idx]; + } +#ifdef ENABLE_DRC + 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 *) + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); + + for (i = 0; i < ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_config_extensions; + i++) { + pp_value[i] = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.usac_cfg_ext_info_buf[i]; + } + + for (i = 0; i < ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_elements; + i++) { + if (ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_ele_payload_present[i]) { + pp_value[i + 16] = + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_ele_payload_buf[i]; + } + } + } else if (IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES == 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 < ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_config_extensions; + i++) { + ptri_value[i] = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.usac_cfg_ext_info_len[i]; + } + for (i = 0; i < ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_elements; + i++) { + ptri_value[i + 16] = + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_ele_payload_len[i]; + } + + } else if (IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE == i_idx) { + UWORD32 *ptri_value = (UWORD32 *)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); + *ptri_value = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_elements; + + } else if (IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT == i_idx) { + UWORD32 *ptri_value = (UWORD32 *)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); + *ptri_value = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.num_config_extensions; + } else if (IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN == i_idx) { + UWORD32 *ptri_value = (UWORD32 *)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); + *ptri_value = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.usac_ext_gain_payload_len; + } else if (IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF == i_idx) { + 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); + *pp_value = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.usac_ext_gain_payload_buf; + } +#endif + else { + return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM; + } + break; + } + + case IA_API_CMD_GET_MEMTABS_SIZE: { + *pui_value = (sizeof(ia_mem_info_struct) + sizeof(pVOID *)) * + (IA_ENHAACPDEC_NUM_MEMTABS + IA_MPS_DEC_NUM_MEMTABS); + break; + } + case IA_API_CMD_SET_MEMTABS_PTR: { + p_obj_exhaacplus_dec->p_mem_info_aac = pv_value; + p_obj_exhaacplus_dec->pp_mem_aac = + (pVOID *)((WORD8 *)pv_value + + sizeof(ia_mem_info_struct) * IA_ENHAACPDEC_NUM_MEMTABS); + + break; + } + case IA_API_CMD_GET_N_MEMTABS: { + *pui_value = IA_ENHAACPDEC_NUM_MEMTABS; + break; + } + + case IA_API_CMD_GET_N_TABLES: { + *pui_value = NUM_AAC_TABLES; + break; + } + case IA_API_CMD_EXECUTE: { + switch (i_idx) { + case IA_CMD_TYPE_DO_EXECUTE: { + WORD32 err_code = 0; + err_code = ixheaacd_dec_execute(p_obj_exhaacplus_dec); + if (err_code != 0) { + p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = + p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; + } + return err_code; + break; + } + case IA_CMD_TYPE_DONE_QUERY: { + if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 1) { + *pui_value = 1; + } else { + *pui_value = 0; + } + + break; + } + default: { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_EXECUTE_TYPE; } + }; + break; + } + case IA_API_CMD_GET_CURIDX_INPUT_BUF: { + *pui_value = p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed; + break; + } + case IA_API_CMD_SET_INPUT_BYTES: { + p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes = *pui_value; + break; + } + case IA_API_CMD_GET_OUTPUT_BYTES: { + *pui_value = p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes; + break; + } + case IA_API_CMD_INPUT_OVER: { + p_obj_exhaacplus_dec->p_state_aac->ui_input_over = 1; + break; + } + default: { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CMD; } + }; + return IA_NO_ERROR; +} + +IA_ERRORCODE ixheaacd_decoder_2_ga_hdr( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { + if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { + p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; + p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; + p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; + p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; + p_obj_exhaacplus_dec->aac_config.frame_status = 1; + p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 1; + p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; + p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 2; + p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; + p_obj_exhaacplus_dec->aac_config.loas_present = 0; + + p_obj_exhaacplus_dec->aac_config.ui_drc_enable = 1; + p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; + p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 1; + + p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; + + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; + p_obj_exhaacplus_dec->aac_config.downmix = 0; + + { + ia_aac_dec_tables_struct *pstr_aac_tables = + &p_obj_exhaacplus_dec->aac_tables; + pstr_aac_tables->pstr_huffmann_tables = + (ia_aac_dec_huffman_tables_struct *)&ixheaacd_aac_huffmann_tables; + pstr_aac_tables->pstr_block_tables = + (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; + pstr_aac_tables->pstr_imdct_tables = + (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; + + ixheaacd_huff_tables_create(pstr_aac_tables); + } + ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); + p_obj_exhaacplus_dec->common_tables = + (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; + p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; + p_obj_exhaacplus_dec->p_state_aac->ui_init_done = 0; + + return ixheaacd_dec_init(p_obj_exhaacplus_dec); + } else { + p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; + return ixheaacd_dec_init(p_obj_exhaacplus_dec); + } +} + +IA_ERRORCODE ixheaacd_decoder_flush_api( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { + UWORD8 *header_temp_ptr; + WORD32 header_length; + if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { + header_temp_ptr = p_obj_exhaacplus_dec->p_state_aac->header_ptr; + header_length = p_obj_exhaacplus_dec->p_state_aac->header_length; + memset(p_obj_exhaacplus_dec->p_state_aac, 0, + sizeof(ia_aac_dec_state_struct)); + { + pUWORD8 p_temp = (pUWORD8)p_obj_exhaacplus_dec->p_state_aac; + UWORD32 *meminfo = + (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac; + UWORD32 pers_size = meminfo[0]; + p_temp = p_temp + pers_size - (sizeof(ia_dec_data_struct) + + sizeof(ia_audio_specific_config_struct) + (8300)); + + p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = + p_temp + sizeof(ia_dec_data_struct); +p_obj_exhaacplus_dec->p_state_aac->header_ptr = p_temp + sizeof(ia_dec_data_struct) + + sizeof(ia_audio_specific_config_struct); +} + memset(&(p_obj_exhaacplus_dec->aac_config), 0, + sizeof(ia_aac_dec_config_struct)); + + p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; + p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; + p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; + p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; + p_obj_exhaacplus_dec->aac_config.frame_status = 1; + p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 1; + p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; + p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 2; + p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; + p_obj_exhaacplus_dec->aac_config.loas_present = 0; + + p_obj_exhaacplus_dec->aac_config.ui_drc_enable = 1; + p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; + p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; + p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 1; + + p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; + + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; + p_obj_exhaacplus_dec->aac_config.downmix = 0; + + { + ia_aac_dec_tables_struct *pstr_aac_tables = + &p_obj_exhaacplus_dec->aac_tables; + pstr_aac_tables->pstr_huffmann_tables = + (ia_aac_dec_huffman_tables_struct *)&ixheaacd_aac_huffmann_tables; + pstr_aac_tables->pstr_block_tables = + (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; + pstr_aac_tables->pstr_imdct_tables = + (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; + + ixheaacd_huff_tables_create(pstr_aac_tables); + } + ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); + p_obj_exhaacplus_dec->common_tables = + (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; + p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; + p_obj_exhaacplus_dec->p_state_aac->header_ptr = header_temp_ptr; + p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes = header_length; + p_obj_exhaacplus_dec->p_state_aac->header_length = header_length; + + return ixheaacd_dec_init(p_obj_exhaacplus_dec); + + } else { + p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; + return ixheaacd_dec_init(p_obj_exhaacplus_dec); + } +} + +static PLATFORM_INLINE WORD32 +ixheaacd_persistent_buffer_sizes(WORD32 num_channel) { + WORD32 size_buffers = 0; + + WORD32 temp; + WORD32 max_channels; + + size_buffers += 4 * 512 * num_channel * sizeof(WORD32); + + size_buffers += (ltp_buffer_size * num_channel * sizeof(WORD16)); + + if (num_channel > 2) { + max_channels = MAX_BS_ELEMENT; + } else { + max_channels = 2; + } + size_buffers += + (max_channels)*2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct)); + + size_buffers += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8); + + size_buffers += num_channel * + (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(WORD16); + + size_buffers += num_channel * + (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(WORD32); + + size_buffers += num_channel * + (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(WORD16); + + size_buffers += num_channel * + (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(WORD32); + + if (num_channel <= 2) { + size_buffers += + num_channel * 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + } else { + size_buffers += + num_channel * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + } + + size_buffers += + LPC_ORDER * num_channel * NO_ANALYSIS_CHANNELS * sizeof(WORD32); + + if (num_channel <= 2) { + size_buffers += + LPC_ORDER * num_channel * NO_ANALYSIS_CHANNELS * sizeof(WORD32); + } + + size_buffers += num_channel * 3 * MAX_FREQ_COEFFS * sizeof(WORD16); + + temp = sizeof(ia_freq_band_data_struct) + + sizeof(ia_sbr_prev_frame_data_struct) + sizeof(ia_sbr_channel_struct) + + sizeof(ia_sbr_header_data_struct); + size_buffers += num_channel * ALIGN_SIZE64(temp); + + size_buffers += MAX_BS_ELEMENT * sizeof(ixheaac_drc_bs_data_struct *); + + if (num_channel <= 2) { + size_buffers += sizeof(ia_ps_dec_struct); + } + + { + WORD32 temp_size = 0; + size_buffers += + MAXNRSBRCHANNELS * (sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8); + temp_size += sizeof(ia_pvc_data_struct); + temp_size += sizeof(ia_esbr_hbe_txposer_struct) * 2; + temp_size += (MAX_HBE_PERSISTENT_SIZE * 2); + temp_size += (MAX_QMF_BUF_LEN * 2 * 2 * sizeof(FLOAT32 *)); + temp_size += (MAX_QMF_BUF_LEN * MAX_QMF_BUF_LEN * 2 * 2 * sizeof(FLOAT32)); + size_buffers += temp_size * num_channel; + } + + return (size_buffers); +} + +IA_ERRORCODE ixheaacd_fill_aac_mem_tables( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { + ia_mem_info_struct *p_mem_info_aac; + + WORD32 num_channels; + WORD32 channels; + WORD32 buffer_size; + + if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { + num_channels = (p_obj_exhaacplus_dec->aac_config.ui_max_channels + 1); + } else + + { + num_channels = p_obj_exhaacplus_dec->aac_config.ui_max_channels; + } + + channels = num_channels; + buffer_size = ixheaacd_persistent_buffer_sizes(num_channels); + + { + p_mem_info_aac = + &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; + p_mem_info_aac->ui_size = + sizeof(ia_aac_dec_state_struct) + + channels * sizeof(struct ia_aac_persistent_struct) + + + buffer_size + channels * ixheaacd_getsize_sbr_persistent() + + channels * 16; + + p_mem_info_aac->ui_size += sizeof(ia_dec_data_struct); + p_mem_info_aac->ui_size += sizeof(ia_audio_specific_config_struct); + p_mem_info_aac->ui_size += 8300; + + p_mem_info_aac->ui_alignment = 8; + p_mem_info_aac->ui_type = IA_MEMTYPE_PERSIST; + } + + { + p_mem_info_aac = + &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; + + { + if (num_channels > 2) { + WORD32 other_scr1; + WORD32 other_scr2 = 0; + + p_mem_info_aac->ui_size = + 2 * sizeof(WORD32) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME; + + other_scr2 = 2 * sizeof(WORD32) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME; + + other_scr1 = (4 * 1024); + + if (MAX_CC_CHANNEL_NUM > 0) { + other_scr1 += + sizeof(WORD16) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * 2; + other_scr1 += (4 * 1024); + + other_scr1 += 4 * 12; + } + + p_mem_info_aac->ui_size += max(other_scr1, other_scr2); + + } else { + p_mem_info_aac->ui_size = + 2 * sizeof(WORD32) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME; + + p_mem_info_aac->ui_size += + 2 * sizeof(WORD32) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME; + + p_mem_info_aac->ui_size += + sizeof(WORD32) * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME; + p_mem_info_aac->ui_size += 4 * 12; + + p_mem_info_aac->ui_size += + ((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME << 1) * sizeof(WORD32)); + p_mem_info_aac->ui_size += + ((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME << 1) * sizeof(WORD32)); + p_mem_info_aac->ui_size += + 2 * (sizeof(ia_sbr_frame_info_data_struct) + 232); + } + } + + p_mem_info_aac->ui_size += 2200000 + 2048; + p_mem_info_aac->ui_alignment = 8; + p_mem_info_aac->ui_type = IA_MEMTYPE_SCRATCH; + } + { + p_mem_info_aac = + &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; + + p_mem_info_aac->ui_size = 8 * 1024 + 11; + + p_mem_info_aac->ui_alignment = 8; + p_mem_info_aac->ui_type = IA_MEMTYPE_INPUT; + } + { + 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_alignment = 8; + p_mem_info_aac->ui_type = IA_MEMTYPE_OUTPUT; + } + return IA_NO_ERROR; +} + +IA_ERRORCODE ixheaacd_dec_table_api( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD32 i_cmd, + WORD32 i_idx, pVOID pv_value) { + pUWORD32 pui_value = pv_value; + pUWORD32 *p_pui_value = pv_value; + SIZE_T ui_get_vals[5]; + + pVOID *table_ptrs[8]; + UWORD32 table_sizes[8] = {sizeof(ixheaacd_aac_huffmann_tables), + sizeof(ixheaacd_aac_block_tables), + sizeof(ixheaacd_imdct_tables), + sizeof(ixheaacd_str_fft_n_transcendent_tables), + sizeof(ixheaacd_aac_dec_env_calc_tables), + sizeof(ixheaacd_aac_qmf_dec_tables), + sizeof(ixheaacd_aac_dec_env_extr_tables), + sizeof(ixheaacd_aac_dec_ps_tables)}; + + table_ptrs[0] = + (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables); + table_ptrs[1] = + (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_block_tables); + table_ptrs[2] = + (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_imdct_tables); + table_ptrs[3] = (pVOID *)&(p_obj_exhaacplus_dec->common_tables); + table_ptrs[4] = + (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.env_calc_tables_ptr; + table_ptrs[5] = + (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.qmf_dec_tables_ptr; + table_ptrs[6] = + (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.env_extr_tables_ptr; + table_ptrs[7] = (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.ps_tables_ptr; + + if (i_idx < 0 || i_idx >= NUM_AAC_TABLES) { + return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_MEMTAB_INDEX; + } + + ui_get_vals[0] = table_sizes[i_idx]; + ui_get_vals[1] = 4; + ui_get_vals[4] = (SIZE_T)(*table_ptrs[i_idx]); + + if (i_cmd == IA_API_CMD_SET_TABLE_PTR) { + if (pv_value == 0) { + return (IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALLOC); + } + if (((SIZE_T)pv_value) & 3) { + return IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALIGN; + } + + *table_ptrs[i_idx] = pv_value; + + if (i_idx == 0) { + ixheaacd_huff_tables_create(&p_obj_exhaacplus_dec->aac_tables); + } + + } + + else if (i_cmd == IA_API_CMD_GET_TABLE_PTR) { + *p_pui_value = (UWORD32 *)((SIZE_T)( + ui_get_vals[i_cmd - IA_API_CMD_GET_TABLE_INFO_SIZE])); + } else { + *pui_value = (WORD32)(ui_get_vals[i_cmd - IA_API_CMD_GET_TABLE_INFO_SIZE]); + } + + return IA_NO_ERROR; +} + +IA_ERRORCODE ixheaacd_dec_init( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { + FLAG frame_status = 1; + WORD32 frame_size_1; + WORD32 sample_rate_1; + WORD16 num_channels_1; + WORD32 ps_detected = 0; + UWORD8 *in_buffer; + WORD16 *time_data; + WORD ch_idx; + WORD sbr_present_flag = 0; + ia_aac_dec_state_struct *p_state_enhaacplus_dec; + + WORD32 error_code = IA_NO_ERROR; + WORD32 persistent_used = 0; + IA_ERRORCODE err_code = IA_NO_ERROR; + struct ia_aac_persistent_struct *aac_persistent_mem; + struct ia_sbr_pers_struct *sbr_persistent_mem; + + p_obj_exhaacplus_dec->p_state_aac = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; + + time_data = (WORD16 *)(p_obj_exhaacplus_dec + ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); + + if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { + in_buffer = p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; + } else { + in_buffer = p_obj_exhaacplus_dec->p_state_aac->header_ptr; + } + + p_state_enhaacplus_dec = p_obj_exhaacplus_dec->p_state_aac; + + p_state_enhaacplus_dec->aac_scratch_mem_v = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; + p_obj_exhaacplus_dec->p_state_aac->huffman_code_book_scl = + p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables + ->huffman_code_book_scl; + p_obj_exhaacplus_dec->p_state_aac->huffman_code_book_scl_index = + p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables + ->huffman_code_book_scl_index; + + p_state_enhaacplus_dec->pstr_aac_tables = &p_obj_exhaacplus_dec->aac_tables; + if (p_obj_exhaacplus_dec->aac_config.header_dec_done == 0) { + WORD32 channels; + + p_obj_exhaacplus_dec->p_state_aac->p_config = + &p_obj_exhaacplus_dec->aac_config; + + p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr = + (pVOID)((SIZE_T)((pWORD8)p_obj_exhaacplus_dec->p_state_aac + + sizeof(ia_aac_dec_state_struct) + sizeof(SIZE_T) - 1) & + (SIZE_T)(~(sizeof(SIZE_T) - 1))); + if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { + p_state_enhaacplus_dec->aac_persistent_mem_v = + (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + + (MAX_BS_ELEMENT)*2 * + ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + + memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, + (MAX_BS_ELEMENT)*2 * + ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + } else { + p_state_enhaacplus_dec->aac_persistent_mem_v = (pVOID)( + (pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + + (2) * 2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + + memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, + (2) * 2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + } + if (1 == p_obj_exhaacplus_dec->aac_config.ui_max_channels) + channels = 1; + else + channels = 2; + + persistent_used = ixheaacd_set_aac_persistent_buffers( + p_state_enhaacplus_dec->aac_persistent_mem_v, channels); + + p_state_enhaacplus_dec->sbr_persistent_mem_v = + (pVOID)((SIZE_T)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + + persistent_used + sizeof(SIZE_T) - 1) & + (SIZE_T)(~(sizeof(SIZE_T) - 1))); + + persistent_used = ixheaacd_getsize_sbr_persistent(); + ixheaacd_set_sbr_persistent_buffers( + p_state_enhaacplus_dec->sbr_persistent_mem_v, &persistent_used, + channels, 1); + + aac_persistent_mem = (struct ia_aac_persistent_struct *) + p_state_enhaacplus_dec->aac_persistent_mem_v; + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) + p_state_enhaacplus_dec->frame_len_flag = + p_obj_exhaacplus_dec->aac_config.framesize_480; + + p_state_enhaacplus_dec->ptr_overlap_buf = + aac_persistent_mem->overlap_buffer; + + p_state_enhaacplus_dec->bit_count = 0; + p_state_enhaacplus_dec->sync_status = 0; + p_state_enhaacplus_dec->bs_format = ADTS_BSFORMAT; + p_state_enhaacplus_dec->latm_initialized = 0; + p_state_enhaacplus_dec->frame_size = 0; + memset(&p_state_enhaacplus_dec->latm_struct_element, 0, + sizeof(ixheaacd_latm_struct)); + memset(&p_state_enhaacplus_dec->b_n_raw_data_blk, 0, + sizeof(WORD32) * (9 + MAX_BS_ELEMENT)); + + p_state_enhaacplus_dec->sbr_present_flag = 0; + + for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + } + + memset(&p_state_enhaacplus_dec->ind_cc_info, 0, + sizeof(ia_enhaacplus_dec_ind_cc)); + + p_state_enhaacplus_dec->last_frame_ok = 1; + p_obj_exhaacplus_dec->aac_config.header_dec_done = 1; + + aac_persistent_mem->str_aac_decoder.pstr_aac_tables = + &p_obj_exhaacplus_dec->aac_tables; + aac_persistent_mem->str_aac_decoder.pstr_common_tables = + p_obj_exhaacplus_dec->common_tables; + + p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_u = + p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_v; + + p_obj_exhaacplus_dec->p_state_aac->sbr_scratch_mem_u = + p_obj_exhaacplus_dec->p_state_aac->aac_scratch_mem_v; + + ixheaacd_set_sbr_persistent_table_pointer( + p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_v, + &p_obj_exhaacplus_dec->str_sbr_tables, + p_obj_exhaacplus_dec->common_tables); + } + + if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 1) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_EO_INPUT_REACHED; + } + + if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done == 0) { + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) + p_state_enhaacplus_dec->frame_len_flag = + p_obj_exhaacplus_dec->aac_config.framesize_480; + + aac_persistent_mem = (struct ia_aac_persistent_struct *) + p_state_enhaacplus_dec->aac_persistent_mem_v; + sbr_persistent_mem = (struct ia_sbr_pers_struct *) + p_state_enhaacplus_dec->sbr_persistent_mem_v; + + if (p_obj_exhaacplus_dec->aac_config.ui_samp_freq == 0) { + WORD32 header_bytes_consumed, return_val; + + if (p_state_enhaacplus_dec->ui_in_bytes == 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + return IA_NO_ERROR; + } + + return_val = ixheaacd_aac_headerdecode( + p_obj_exhaacplus_dec, (UWORD8 *)in_buffer, &header_bytes_consumed, + aac_persistent_mem->str_aac_decoder.pstr_aac_tables + ->pstr_huffmann_tables); + + memcpy(sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[0], + &p_obj_exhaacplus_dec->p_state_aac->str_sbr_config, + sizeof(ia_sbr_header_data_struct)); + memcpy(sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[1], + &p_obj_exhaacplus_dec->p_state_aac->str_sbr_config, + sizeof(ia_sbr_header_data_struct)); + + if (return_val < 0) { + if (return_val == + (WORD32)IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX) { + p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; + return return_val; + } + p_state_enhaacplus_dec->i_bytes_consumed = 1; + + return return_val; + } + + if (return_val == + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES) { + p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; + return return_val; + } + + p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; + + if ((return_val == 0) && + (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_USAC)) { + { + WORD32 pcm_size = p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz; + WORD8 *inbuffer = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; + WORD8 *outbuffer = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]; + WORD32 out_bytes = 0; + WORD32 frames_done = p_obj_exhaacplus_dec->p_state_aac->frame_counter; + + if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 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); + if (error_code == -1) return error_code; + p_obj_exhaacplus_dec->p_state_aac->frame_counter++; + } else { + out_bytes = 0; + } + + p_obj_exhaacplus_dec->aac_config.ui_n_channels = + p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch; + } + if (return_val == 0) + p_obj_exhaacplus_dec->p_state_aac->ui_init_done = 1; + + p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 1; + return return_val; + } + + if (return_val == 0) { + p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 1; + if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { + memcpy(p_state_enhaacplus_dec->header_ptr, in_buffer, + header_bytes_consumed * sizeof(UWORD8)); + p_state_enhaacplus_dec->header_length = header_bytes_consumed; + } + } + + if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done != 1) + return IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START; + + if (p_state_enhaacplus_dec->dwnsmp_signal == 1 && + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 1; + + if (p_state_enhaacplus_dec->sampling_rate == + p_state_enhaacplus_dec->extension_samp_rate) { + p_obj_exhaacplus_dec->aac_config.down_sample_flag = 1; + } + + } else { + p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 1; + p_state_enhaacplus_dec->i_bytes_consumed = 0; + + p_state_enhaacplus_dec->sampling_rate = + p_obj_exhaacplus_dec->aac_config.ui_samp_freq; + } + + p_state_enhaacplus_dec->pstr_bit_buf = ixheaacd_create_bit_buf( + &p_state_enhaacplus_dec->str_bit_buf, (UWORD8 *)in_buffer, + p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_INPUT_IDX] + .ui_size); + + p_state_enhaacplus_dec->ptr_bit_stream = + p_state_enhaacplus_dec->pstr_bit_buf; + + if ((p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) || + (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD)) + if (p_state_enhaacplus_dec->s_adts_hdr_present) { + if (p_obj_exhaacplus_dec->aac_config.ld_decoder == 1) + p_state_enhaacplus_dec->audio_object_type = 23; + + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_samp_rate = 1; + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_crc_flag = 0; + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present = 0; + + if (p_obj_exhaacplus_dec->aac_config.eld_sbr_present == 1) { + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present = 1; + } + } + if (p_obj_exhaacplus_dec->aac_config.framesize_480) + p_state_enhaacplus_dec->frame_length = 480; + else + p_state_enhaacplus_dec->frame_length = 512; + } + + { + for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + WORD32 channels; + channels = 2; + + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = + ixheaacd_aac_decoder_init( + p_state_enhaacplus_dec, + + p_state_enhaacplus_dec->pstr_stream_sbr[0], channels, + p_state_enhaacplus_dec->aac_persistent_mem_v, + p_state_enhaacplus_dec->frame_length); + + if (!p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + } + + { + p_state_enhaacplus_dec->pstr_drc_dec = + &p_state_enhaacplus_dec->str_drc_dec_info; + ixheaacd_drc_dec_create(p_state_enhaacplus_dec->pstr_drc_dec, 127, 127); + } + p_state_enhaacplus_dec->pstr_drc_dec->cut_factor = + p_obj_exhaacplus_dec->aac_config.ui_drc_cut; + p_state_enhaacplus_dec->pstr_drc_dec->boost_factor = + p_obj_exhaacplus_dec->aac_config.ui_drc_boost; + p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level; + p_state_enhaacplus_dec->pstr_drc_dec->prog_ref_level = + p_obj_exhaacplus_dec->aac_config.ui_drc_target_level; + + if (1 == p_obj_exhaacplus_dec->aac_config.ui_drc_set) { + if (p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp == 1) { + p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; + p_state_enhaacplus_dec->pstr_drc_dec->heavy_mode = 1; + } else { + p_state_enhaacplus_dec->pstr_drc_dec->heavy_mode = 0; + if (p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level > 127) + p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = 127; + if (p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level < 0) { + if (p_state_enhaacplus_dec->pstr_drc_dec->cut_factor > 0 || + p_state_enhaacplus_dec->pstr_drc_dec->boost_factor > 0) + p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; + else + p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 0; + p_state_enhaacplus_dec->pstr_drc_dec->drc_dig_norm = 0; + p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = 108; + } else { + p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; + p_state_enhaacplus_dec->pstr_drc_dec->drc_dig_norm = 1; + } + } + } + } + } else { + struct ia_bit_buf_struct temp_bit_buff; + ia_adts_header_struct adts; + struct ia_bit_buf_struct *it_bit_buff; + + WORD16 frame_size_2 = 0; + WORD32 sample_rate_2 = 0; + WORD32 sample_rate = 0; + WORD type, i; + WORD elements_number; + + memset(&adts, 0, sizeof(ia_adts_header_struct)); + + for (i = 0; i < MAX_BS_ELEMENT + 1; i++) { + p_obj_exhaacplus_dec->aac_config.element_type[i] = -1; + } + + it_bit_buff = p_state_enhaacplus_dec->pstr_bit_buf; + + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; + + if (p_state_enhaacplus_dec->ui_in_bytes == 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + return IA_NO_ERROR; + } + + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { + if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag) + p_state_enhaacplus_dec->frame_size = + p_state_enhaacplus_dec->ui_in_bytes; + } + + ixheaacd_create_init_bit_buf(it_bit_buff, in_buffer, + p_state_enhaacplus_dec->ui_in_bytes); + + it_bit_buff->adts_header_present = + p_state_enhaacplus_dec->s_adts_hdr_present; + it_bit_buff->no_raw_data_blocks = + (WORD8)p_state_enhaacplus_dec->b_n_raw_data_blk; + it_bit_buff->protection_absent = p_state_enhaacplus_dec->protection_absent; + + memcpy(&temp_bit_buff, it_bit_buff, sizeof(struct ia_bit_buf_struct)); + + if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) + elements_number = MAX_BS_ELEMENT; + else + elements_number = 2; + + for (i = 0; i < elements_number; i++) + p_state_enhaacplus_dec->pstr_stream_sbr[i][0].no_elements = 0; + + { it_bit_buff->initial_cnt_bits = it_bit_buff->cnt_bits; } + + ixheaacd_byte_align( + p_state_enhaacplus_dec->ptr_bit_stream, + &p_state_enhaacplus_dec->pstr_aac_dec_info[0]->byte_align_bits); + + if (p_state_enhaacplus_dec->s_adts_hdr_present) { + WORD32 error; + + if (p_state_enhaacplus_dec->b_n_raw_data_blk == 0) { + error = ixheaacd_readifadts(p_state_enhaacplus_dec, it_bit_buff, &adts); + + if (error) return error; + + p_state_enhaacplus_dec->protection_absent = adts.protection_absent; + + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { + p_state_enhaacplus_dec->frame_size = adts.aac_frame_length; + if (p_obj_exhaacplus_dec->aac_config.framesize_480) + p_state_enhaacplus_dec->frame_length = 480; + else + p_state_enhaacplus_dec->frame_length = 512; + } + } + } + + if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { + WORD32 result; + WORD32 sync; + WORD32 cnt_bits; + + sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + cnt_bits = it_bit_buff->cnt_bits; + if (it_bit_buff->cnt_bits <= 24) { + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + } + + while (sync != 0x2b7) { + sync = ((sync & 0x3ff) << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); + if (it_bit_buff->cnt_bits < 11) { + ixheaacd_read_bidirection(it_bit_buff, -11); + p_state_enhaacplus_dec->i_bytes_consumed = + (cnt_bits - it_bit_buff->cnt_bits) / 8; + return (IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START); + } + } + + it_bit_buff->audio_mux_align = it_bit_buff->cnt_bits - 13; + + if (sync == 0x2b7) { + result = ixheaacd_latm_audio_mux_element( + it_bit_buff, &p_state_enhaacplus_dec->latm_struct_element, + 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; + } + } + } + + p_state_enhaacplus_dec->pstr_aac_dec_info[0]->byte_align_bits = + it_bit_buff->cnt_bits; + + type = -1; + ch_idx = 0; + + while ((type != 7)) { + ia_aac_dec_scratch_struct aac_scratch_struct; + + if (ch_idx >= elements_number) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + + return IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX; + } + + ixheaacd_allocate_aac_scr( + &aac_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, + time_data, 1, p_obj_exhaacplus_dec->aac_config.ui_max_channels, + p_state_enhaacplus_dec->audio_object_type); + + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = + &p_state_enhaacplus_dec->ind_cc_info; + + error_code = ixheaacd_aacdec_decodeframe( + p_obj_exhaacplus_dec, &aac_scratch_struct, time_data, frame_status, + &type, &ch_idx, 1, 2, + p_obj_exhaacplus_dec->aac_config.element_instance_order, 0, 1, 0, + p_obj_exhaacplus_dec->aac_config.ui_max_channels, 2, + p_obj_exhaacplus_dec->p_state_aac->frame_length, + p_obj_exhaacplus_dec->p_state_aac->frame_size, + p_state_enhaacplus_dec->pstr_drc_dec, + p_state_enhaacplus_dec->audio_object_type, + p_state_enhaacplus_dec->ch_config, + p_state_enhaacplus_dec->eld_specific_config, + p_state_enhaacplus_dec->s_adts_hdr_present, + &p_state_enhaacplus_dec->drc_dummy); + + memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] + ->pstr_aac_dec_ch_info[0] + ->str_ics_info.ltp), + 0, sizeof(ltp_info)); + memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] + ->pstr_aac_dec_ch_info[0] + ->str_ics_info.ltp2), + 0, sizeof(ltp_info)); + memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] + ->pstr_aac_dec_ch_info[1] + ->str_ics_info.ltp), + 0, sizeof(ltp_info)); + memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] + ->pstr_aac_dec_ch_info[1] + ->str_ics_info.ltp2), + 0, sizeof(ltp_info)); + + { + if ((p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LD) && + (p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_ELD)) + frame_size_1 = 1024; + else + frame_size_1 = p_state_enhaacplus_dec->frame_length; + sample_rate_1 = + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->sampling_rate; + num_channels_1 = + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->channels; + } + + if ((p_obj_exhaacplus_dec->aac_config.ui_max_channels <= 2) && + (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 2)) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE; + } + + if (p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { + sbr_present_flag = 1; + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 1; + } + + if (error_code) { + if (p_state_enhaacplus_dec->ui_input_over) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_EO_INPUT_REACHED; + } + + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + return error_code; + } + + if (p_state_enhaacplus_dec->s_adts_hdr_present) { + if (adts.no_raw_data_blocks != 0) { + if (adts.protection_absent == 0) { + adts.crc_check = ixheaacd_read_bits_buf(it_bit_buff, 16); + } + } + p_state_enhaacplus_dec->b_n_raw_data_blk--; + } + + if (!p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] && + p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { + if ((p_obj_exhaacplus_dec->aac_config.flag_16khz_out == 1) && + (sample_rate_1 == 8000)) { + p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; + } + + sample_rate_2 = sample_rate_1; + frame_size_2 = frame_size_1; + + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( + sample_rate_1, frame_size_1, + (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, + p_state_enhaacplus_dec->sbr_persistent_mem_v, + p_state_enhaacplus_dec->ptr_overlap_buf, MAXNRSBRCHANNELS, (WORD)1, + 1, frame_size_1 * 2, NULL, NULL, + p_state_enhaacplus_dec->str_sbr_config, + p_state_enhaacplus_dec->audio_object_type); + } else { + } + + if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { + ia_sbr_scr_struct sbr_scratch_struct; + WORD16 num_channels_1_t = num_channels_1; + ixheaacd_allocate_sbr_scr( + &sbr_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, + time_data, 1, 1, p_state_enhaacplus_dec->audio_object_type); + + if (ixheaacd_applysbr( + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], + &p_state_enhaacplus_dec->pstr_stream_sbr[0][0], time_data, + &num_channels_1, frame_status, + p_obj_exhaacplus_dec->aac_config.down_sample_flag, 0, + &sbr_scratch_struct, 1, 1, 0, NULL, NULL, + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, + p_state_enhaacplus_dec->audio_object_type) != SBRDEC_OK) { + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + } else { + if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { + sample_rate_1 *= 2; + } + } + + if (p_obj_exhaacplus_dec->aac_config.flag_downmix) { + num_channels_1 = 1; + } + if (num_channels_1_t == 1 && num_channels_1 == 2) ps_detected = 1; + } + + p_state_enhaacplus_dec->i_bytes_consumed = 0; + p_state_enhaacplus_dec->pstr_bit_buf = it_bit_buff; + + { + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = + ixheaacd_aac_decoder_init( + p_state_enhaacplus_dec, + p_state_enhaacplus_dec->pstr_stream_sbr[0], 2, + p_state_enhaacplus_dec->aac_persistent_mem_v, + p_state_enhaacplus_dec->frame_length); + + if (!p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + + if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( + sample_rate_2, frame_size_2, + (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, + p_state_enhaacplus_dec->sbr_persistent_mem_v, + p_state_enhaacplus_dec->ptr_overlap_buf, MAXNRSBRCHANNELS, 1, 1, + frame_size_2 * 2, NULL, NULL, + p_state_enhaacplus_dec->str_sbr_config, + p_state_enhaacplus_dec->audio_object_type); + } + } + + if (sample_rate < sample_rate_1) sample_rate = sample_rate_1; + + ch_idx++; + + if (p_state_enhaacplus_dec->audio_object_type >= ER_OBJECT_START && + (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD)) + break; + } + + { + ia_adts_crc_info_struct *ptr_adts_crc_info = + p_state_enhaacplus_dec->ptr_bit_stream->pstr_adts_crc_info; + if (ptr_adts_crc_info->crc_active == 1) { + if ((error_code = ixheaacd_adts_crc_check_crc(ptr_adts_crc_info))) { + return error_code; + } + } + } + + { + VOID *temp; + WORD prev_persistent_used_t; + WORD prev_sbrpersistent_used_t; + WORD ps_enable; + WORD ch_idx_err = 0; + WORD persistent_used_t = 0; + WORD channel_check = 0; + WORD max_ch_num = p_obj_exhaacplus_dec->aac_config.ui_max_channels; + i = 0; + + while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx_err] <= 3 && + p_obj_exhaacplus_dec->aac_config.element_type[ch_idx_err] >= 0) { + ch_idx_err++; + } + + if (ch_idx_err == 0) { + p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 0; + p_state_enhaacplus_dec->i_bytes_consumed = + it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + + if (ch_idx == 1) + ps_enable = 1; + else + ps_enable = 0; + + 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) { + i++; + continue; + } + channel = 1; + } else + + { + i++; + continue; + } + } + if (ps_enable == 1) { + channel = 2; + } + + if (p_obj_exhaacplus_dec->aac_config.element_type[i] != 2) { + channel_check += channel; + } + + if (channel_check > max_ch_num) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX; + } + + temp = p_state_enhaacplus_dec->aac_persistent_mem_v; + + prev_persistent_used_t = persistent_used_t; + + ixheaacd_allocate_mem_persistent( + p_obj_exhaacplus_dec, p_state_enhaacplus_dec, channel, + &persistent_used_t, &prev_sbrpersistent_used_t, ps_enable); + + p_state_enhaacplus_dec->aac_persistent_mem_v = temp; + p_state_enhaacplus_dec->last_frame_ok = 1; + + p_state_enhaacplus_dec->num_channel_last = 0; + p_state_enhaacplus_dec->ui_init_done = 0; + p_state_enhaacplus_dec->ui_input_over = 0; + p_state_enhaacplus_dec->ptr_bit_stream = + p_state_enhaacplus_dec->pstr_bit_buf; + + p_state_enhaacplus_dec->pstr_aac_dec_info[i] = 0; + + p_state_enhaacplus_dec->pstr_aac_dec_info[i] = + ixheaacd_aac_decoder_init( + p_state_enhaacplus_dec, + p_state_enhaacplus_dec->pstr_stream_sbr[i], channel, + (WORD8 *)p_state_enhaacplus_dec->aac_persistent_mem_v + + prev_persistent_used_t, + p_state_enhaacplus_dec->frame_length); + + if (!p_state_enhaacplus_dec->pstr_aac_dec_info[i]) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + + p_state_enhaacplus_dec->str_sbr_dec_info[i] = 0; + if (sbr_present_flag) { + p_state_enhaacplus_dec->str_sbr_dec_info[i] = ixheaacd_init_sbr( + sample_rate_2, frame_size_2, + (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, + p_state_enhaacplus_dec->sbr_persistent_mem_v, + p_state_enhaacplus_dec->ptr_overlap_buf, channel, ps_enable, 1, + frame_size_2 * 2, NULL, NULL, + p_state_enhaacplus_dec->str_sbr_config, + p_state_enhaacplus_dec->audio_object_type); + } + + i++; + } + + p_obj_exhaacplus_dec->aac_config.i_channel_mask = + ixheaacd_get_channel_mask(p_obj_exhaacplus_dec); + + { + num_channels_1 = 0; + ch_idx = 0; + while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] >= 0 && + p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] <= 3) { + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 0 || + p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 3) + num_channels_1 += 1; + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 1) + num_channels_1 += 2; + ch_idx++; + } + + if (ch_idx == 2 && num_channels_1 == 2) { + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 2; + } + if (ch_idx == 1) { + if (num_channels_1 == 1) + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 0; + if (num_channels_1 == 2) + p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 1; + } + + if (ps_detected == 1 && num_channels_1 == 1) num_channels_1 = 2; + } + } + if (1 == p_obj_exhaacplus_dec->aac_config.downmix) num_channels_1 = 2; + + if (p_obj_exhaacplus_dec->aac_config.flag_downmix == 1) { + num_channels_1 = 1; + } + + if ((p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1) && + (ch_idx == 1 || num_channels_1 <= 2)) { + num_channels_1 = 2; + } + + p_obj_exhaacplus_dec->aac_config.ui_n_channels = num_channels_1; + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; + p_state_enhaacplus_dec->ui_init_done = 1; + + memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); + + p_state_enhaacplus_dec->b_n_raw_data_blk = 0; + } + return err_code; +} + +VOID ixheaacd_fill_slot_order(ia_aac_dec_state_struct *p_state_enhaacplus_dec, + WORD32 ch, WORD8 *ptr_is_cpe, + WORD8 *ptr_tag_select, WORD32 *ptr_idx_no) { + WORD32 i; + WORD32 idx_no = *ptr_idx_no; + WORD *p_slot_element = p_state_enhaacplus_dec->p_config->slot_element; + WORD *p_element_type = p_state_enhaacplus_dec->p_config->element_type; + WORD *p_element_instance_order = + p_state_enhaacplus_dec->p_config->element_instance_order; + + for (i = 0; i < ch; i++) { + if (ptr_is_cpe[i] == 0) { + *p_slot_element++ = idx_no++; + *p_element_type++ = 0; + *p_element_instance_order++ = ptr_tag_select[i]; + } + } + *ptr_idx_no = idx_no; +} + +VOID ixheaacd_fill_prog_config_slots( + ia_aac_dec_state_struct *p_state_enhaacplus_dec) { + WORD32 idx_no = 0; + + ixheaacd_fill_slot_order( + p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config + .num_front_channel_elements, + p_state_enhaacplus_dec->p_config->str_prog_config.front_element_is_cpe, + p_state_enhaacplus_dec->p_config->str_prog_config + .front_element_tag_select, + &idx_no); + + ixheaacd_fill_slot_order( + p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config + .num_side_channel_elements, + p_state_enhaacplus_dec->p_config->str_prog_config.side_element_is_cpe, + p_state_enhaacplus_dec->p_config->str_prog_config.side_element_tag_select, + &idx_no); + + ixheaacd_fill_slot_order( + p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config + .num_back_channel_elements, + p_state_enhaacplus_dec->p_config->str_prog_config.back_element_is_cpe, + p_state_enhaacplus_dec->p_config->str_prog_config.back_element_tag_select, + &idx_no); +} + +IA_ERRORCODE ixheaacd_dec_execute( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { + ia_adts_header_struct adts; + ia_aac_dec_state_struct *p_state_enhaacplus_dec; + + UWORD8 *in_buffer; + WORD16 *time_data; + WORD16 num_of_out_samples = 0; + WORD16 frame_size = 0; + WORD32 sample_rate_dec = 0; + WORD32 sample_rate = 0; + WORD16 num_ch; + struct ia_bit_buf_struct *it_bit_buff; + WORD32 error_code = IA_NO_ERROR; + WORD ch_idx1; + WORD type; + WORD total_channels = 0; + WORD total_elements = 0; + WORD16 *actual_out_buffer; + WORD ps_enable; + WORD esbr_mono_downmix = 0; + WORD8 element_used[MAX_BS_ELEMENT]; + WORD32 channel_coupling_flag = 0; + + SIZE_T bytes_for_sync; + WORD32 audio_mux_length_bytes_last = 0; + + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; + + time_data = (WORD16 *)(p_obj_exhaacplus_dec + ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); + in_buffer = p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; + p_state_enhaacplus_dec = p_obj_exhaacplus_dec->p_state_aac; + p_state_enhaacplus_dec->aac_scratch_mem_v = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; + + it_bit_buff = p_state_enhaacplus_dec->pstr_bit_buf; + + ch_idx1 = 0; + p_state_enhaacplus_dec->i_bytes_consumed = 0; + + if (p_state_enhaacplus_dec->audio_object_type == AOT_USAC) { + WORD32 pcm_size = p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz; + WORD8 *inbuffer = (WORD8 *)(p_obj_exhaacplus_dec + ->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]); + WORD8 *outbuffer = + (WORD8 *)(p_obj_exhaacplus_dec + ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); + WORD32 out_bytes = 0; + + WORD32 frames_done = p_obj_exhaacplus_dec->p_state_aac->frame_counter; + + if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 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); + if (error_code == -1) return error_code; + p_obj_exhaacplus_dec->p_state_aac->frame_counter++; + } else { + out_bytes = 0; + } + + p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = + p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = out_bytes; + p_obj_exhaacplus_dec->aac_config.ui_n_channels = + p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch; + + return 0; + } + + while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] <= 3 && + p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] >= 0) { + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 0 || + p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 3) { + total_channels += 1; + total_elements += 1; + } + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 1) { + total_elements += 1; + total_channels += 2; + } + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 2) { + total_elements += 1; + } + + ch_idx1++; + } + + if (ch_idx1 != 1) { + ps_enable = 0; + if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { + WORD32 scratch_pointer; + + scratch_pointer = 12 * 1024; + + p_state_enhaacplus_dec->coup_ch_output = + (WORD16 *)((WORD8 *) + p_obj_exhaacplus_dec->p_state_aac->aac_scratch_mem_v + + scratch_pointer); + } + + } + + else { + if (total_channels < (WORD)p_obj_exhaacplus_dec->aac_config.ui_n_channels) + total_channels = p_obj_exhaacplus_dec->aac_config.ui_n_channels; + ps_enable = 1; + } + + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; + + if (p_state_enhaacplus_dec->ui_in_bytes == 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + return IA_NO_ERROR; + } + + if (ch_idx1 == 0) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + if (total_channels > (WORD)p_obj_exhaacplus_dec->aac_config.ui_max_channels) { + p_state_enhaacplus_dec->i_bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL; + } + + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { + if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag) + p_state_enhaacplus_dec->frame_size = p_state_enhaacplus_dec->ui_in_bytes; + } + + { + ixheaacd_create_init_bit_buf(it_bit_buff, in_buffer, + p_state_enhaacplus_dec->ui_in_bytes); + + it_bit_buff->adts_header_present = + p_state_enhaacplus_dec->s_adts_hdr_present; + it_bit_buff->no_raw_data_blocks = + (WORD8)p_state_enhaacplus_dec->b_n_raw_data_blk; + it_bit_buff->protection_absent = p_state_enhaacplus_dec->protection_absent; + + if (p_state_enhaacplus_dec->s_adts_hdr_present) { + if (p_state_enhaacplus_dec->b_n_raw_data_blk == 0) { + WORD32 error; + + error = ixheaacd_readifadts(p_state_enhaacplus_dec, it_bit_buff, &adts); + + if (error) return error; + + if ((WORD32)p_state_enhaacplus_dec->sampling_rate != + (WORD32)((p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables + ->str_sample_rate_info[adts.samp_freq_index] + .sampling_frequency))) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_CHANGED_ADTS_SF; + } + } + } + + bytes_for_sync = (SIZE_T)it_bit_buff->ptr_read_next; + + if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { + WORD32 result, audio_mux_len_bytes_last; + WORD32 cnt_bits = it_bit_buff->cnt_bits; + WORD32 sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + UWORD32 curr_samp_rate = 0; + + if (p_state_enhaacplus_dec->latm_initialized) + curr_samp_rate = + p_state_enhaacplus_dec->latm_struct_element.layer_info[0][0] + .asc.sampling_freq; + + while (sync != 0x2b7) { + sync = ((sync & 0x3ff) << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); + if (it_bit_buff->cnt_bits < 13) { + ixheaacd_read_bidirection(it_bit_buff, -11); + p_state_enhaacplus_dec->i_bytes_consumed = + (cnt_bits - it_bit_buff->cnt_bits) / 8; + + if (p_state_enhaacplus_dec->i_bytes_consumed == 0) + p_state_enhaacplus_dec->i_bytes_consumed = 1; + + return (IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START); + } + } + + it_bit_buff->audio_mux_align = it_bit_buff->cnt_bits - 13; + + audio_mux_len_bytes_last = ixheaacd_read_bits_buf(it_bit_buff, 13); + + audio_mux_length_bytes_last = audio_mux_len_bytes_last; + + bytes_for_sync = (SIZE_T)it_bit_buff->ptr_read_next - bytes_for_sync; + + if (it_bit_buff->cnt_bits < (audio_mux_len_bytes_last << 3)) { + ixheaacd_read_bidirection(it_bit_buff, -(13 + 11)); + p_state_enhaacplus_dec->i_bytes_consumed = + (cnt_bits - it_bit_buff->cnt_bits) / 8; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + } else { + ixheaacd_read_bidirection(it_bit_buff, -(13)); + } + + if (sync == 0x2b7) { + result = ixheaacd_latm_audio_mux_element( + it_bit_buff, &p_state_enhaacplus_dec->latm_struct_element, + 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 (!p_state_enhaacplus_dec->latm_initialized) { + p_state_enhaacplus_dec->sampling_rate = + p_state_enhaacplus_dec->latm_struct_element.layer_info[0][0] + .asc.sampling_freq; + p_state_enhaacplus_dec->latm_initialized = 1; + } else { + if (p_state_enhaacplus_dec->sampling_rate != curr_samp_rate) { + p_state_enhaacplus_dec->i_bytes_consumed = 0; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_CHANGED_ADTS_SF; + } + } + } + } + } + + if (total_elements == 2 && total_channels == 2 && + (p_state_enhaacplus_dec->p_config->ui_pce_found_in_hdr == 1 || + p_state_enhaacplus_dec->p_config->ui_pce_found_in_hdr == 3)) { + ixheaacd_fill_prog_config_slots(p_state_enhaacplus_dec); + } + + memset(element_used, 0, sizeof(WORD8) * MAX_BS_ELEMENT); + + if (it_bit_buff->cnt_bits <= 0) { + it_bit_buff->cnt_bits = -1; + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + { it_bit_buff->initial_cnt_bits = it_bit_buff->cnt_bits; } + + if (p_state_enhaacplus_dec->pstr_drc_dec) { + p_state_enhaacplus_dec->pstr_drc_dec->num_drc_elements = 0; + + p_state_enhaacplus_dec->pstr_drc_dec->state = 1; + } + + for (ch_idx1 = 0; ch_idx1 < total_elements; ch_idx1++) { + WORD32 skip_full_decode = 0; + WORD32 ch_idx = ch_idx1; + WORD32 channel; + WORD ch_fac, slot_ele; + + if (p_state_enhaacplus_dec->audio_object_type < ER_OBJECT_START || + (p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LD && + p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_ELD)) { + error_code = ixheaacd_get_element_index_tag( + p_obj_exhaacplus_dec, ch_idx1, &ch_idx, &channel, + p_obj_exhaacplus_dec->aac_config.element_instance_order, + total_elements, element_used, total_channels, + p_state_enhaacplus_dec->pstr_drc_dec, + &p_state_enhaacplus_dec->drc_dummy); + + if (error_code) { + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + p_state_enhaacplus_dec->i_bytes_consumed = 1; + p_state_enhaacplus_dec->b_n_raw_data_blk = 0; + return error_code; + } + } else { + if (p_obj_exhaacplus_dec->aac_config.element_type[0] == ID_SCE) + channel = 1; + else + channel = 2; + } + + ch_fac = total_channels; + slot_ele = p_obj_exhaacplus_dec->aac_config.slot_element[ch_idx]; + actual_out_buffer = time_data; + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 2) { + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = + &p_state_enhaacplus_dec->ind_cc_info; + if (p_obj_exhaacplus_dec->aac_config.element_instance_order[ch_idx] != + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel) { + 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); + + { + struct ia_aac_persistent_struct *aac_persistent_mem = + (struct ia_aac_persistent_struct + *)((WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + + (8 * 1024)); + aac_persistent_mem->str_aac_decoder.pstr_aac_tables = + &p_obj_exhaacplus_dec->aac_tables; + aac_persistent_mem->str_aac_decoder.pstr_common_tables = + p_obj_exhaacplus_dec->common_tables; + } + + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = 0; + + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = + ixheaacd_aac_decoder_init( + p_state_enhaacplus_dec, + + p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx], + + channel, + (WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + (8 * 1024), + p_state_enhaacplus_dec->frame_length + + ); + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = + (WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + (8 * 1024) + + pers_used; + } + actual_out_buffer = p_state_enhaacplus_dec->coup_ch_output; + ch_fac = 1; + slot_ele = 0; + } + + type = -1; + p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements = 0; + + { + WORD element_index_order1[MAX_BS_ELEMENT]; + ia_aac_dec_scratch_struct aac_scratch_struct; + ixheaacd_allocate_aac_scr( + &aac_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, + time_data, channel, p_obj_exhaacplus_dec->aac_config.ui_max_channels, + p_state_enhaacplus_dec->audio_object_type); + + error_code = ixheaacd_aacdec_decodeframe( + p_obj_exhaacplus_dec, &aac_scratch_struct, actual_out_buffer, + p_obj_exhaacplus_dec->aac_config.frame_status, &type, &ch_idx, 0, + channel, element_index_order1, skip_full_decode, ch_fac, slot_ele, + p_obj_exhaacplus_dec->aac_config.ui_max_channels, total_channels, + p_obj_exhaacplus_dec->p_state_aac->frame_length, + p_obj_exhaacplus_dec->p_state_aac->frame_size, + p_state_enhaacplus_dec->pstr_drc_dec, + p_state_enhaacplus_dec->audio_object_type, + p_state_enhaacplus_dec->ch_config, + p_state_enhaacplus_dec->eld_specific_config, + p_state_enhaacplus_dec->s_adts_hdr_present, + &p_state_enhaacplus_dec->drc_dummy); + + if (p_state_enhaacplus_dec->audio_object_type < ER_OBJECT_START || + (p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LD && + p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_ELD)) { + if ((error_code == 0) && ((ch_idx1 + 1) == total_elements) && + (type != ID_END)) { + { + p_state_enhaacplus_dec->i_bytes_consumed = + it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base; + p_state_enhaacplus_dec->b_n_raw_data_blk = 0; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_ELE_INSTANCE_TAG_NOT_FOUND; + } + } + } + + if (skip_full_decode == 0) { + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD || + p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD) + frame_size = p_state_enhaacplus_dec->frame_length; + else + frame_size = 1024; + + sample_rate_dec = + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->sampling_rate; + num_ch = p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->channels; + } + } + + if (skip_full_decode == 1) { + p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements = 0; + } + + if (p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements != 0) { + p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 1; + } + + if (error_code) { + if (p_state_enhaacplus_dec->ui_input_over) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_EO_INPUT_REACHED; + } + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes += + p_state_enhaacplus_dec->num_of_out_samples * num_ch * sizeof(WORD16); + return error_code; + } + + error_code = IA_NO_ERROR; + + if (p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample == 0) { + if (p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements == 0 && + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + error_code = IA_ENHAACPLUS_DEC_EXE_NONFATAL_SBR_TURNED_OFF; + } + } + if ((!p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) && + p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements) { + error_code = IA_ENHAACPLUS_DEC_EXE_NONFATAL_SBR_TURNED_ON; + + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( + sample_rate_dec, frame_size, + (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, + p_state_enhaacplus_dec->sbr_persistent_mem_v, + p_state_enhaacplus_dec->ptr_overlap_buf, ps_enable ? 2 : channel, + ps_enable, 1, frame_size * 2, NULL, NULL, + p_state_enhaacplus_dec->str_sbr_config, + p_state_enhaacplus_dec->audio_object_type); + } + + { + if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { + ia_sbr_scr_struct sbr_scratch_struct; + ixheaacd_allocate_sbr_scr(&sbr_scratch_struct, + p_state_enhaacplus_dec->aac_scratch_mem_v, + time_data, total_elements, ch_fac, + p_state_enhaacplus_dec->audio_object_type); + + if (ixheaacd_applysbr( + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], + &p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0], + actual_out_buffer, &num_ch, + p_obj_exhaacplus_dec->aac_config.frame_status, + p_obj_exhaacplus_dec->aac_config.down_sample_flag, + esbr_mono_downmix, &sbr_scratch_struct, ps_enable, ch_fac, + slot_ele, NULL, &p_state_enhaacplus_dec->str_drc_dec_info, + p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, + p_state_enhaacplus_dec->audio_object_type) != SBRDEC_OK) { + p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + } else { + if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { + frame_size = (WORD16)(frame_size * 2); + sample_rate_dec *= 2; + } + } + } + } + if (sample_rate < sample_rate_dec) { + sample_rate = sample_rate_dec; + } + + p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; + num_of_out_samples = frame_size; + + p_state_enhaacplus_dec->num_channel_last = num_ch; + p_state_enhaacplus_dec->num_of_out_samples = num_of_out_samples; + + if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] != 2) + + { + if (p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1 && + channel == 1 && total_elements == 1 && num_ch == 1) { + WORD i; + num_ch = 2; + + for (i = 0; i < frame_size; i++) { + actual_out_buffer[2 * i + 1] = actual_out_buffer[2 * i + 0]; + } + } + + p_obj_exhaacplus_dec->aac_config.ui_n_channels = num_ch; + + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes += + p_state_enhaacplus_dec->num_of_out_samples * num_ch * sizeof(WORD16); + + } + + else { + channel_coupling_flag = 1; + } + } + + { + ia_adts_crc_info_struct *ptr_adts_crc_info = + p_state_enhaacplus_dec->ptr_bit_stream->pstr_adts_crc_info; + if (ptr_adts_crc_info->crc_active == 1) { + if ((error_code = ixheaacd_adts_crc_check_crc(ptr_adts_crc_info))) { + return error_code; + } + } + } + + p_obj_exhaacplus_dec->aac_config.ui_n_channels = total_channels; + + p_state_enhaacplus_dec->frame_counter++; + + if (channel_coupling_flag) { + ixheaacd_dec_ind_coupling(p_obj_exhaacplus_dec, + p_state_enhaacplus_dec->coup_ch_output, + num_of_out_samples, total_channels, time_data); + } + + if ((total_channels > 2) && (1 == p_obj_exhaacplus_dec->aac_config.downmix)) { + ixheaacd_dec_downmix_to_stereo(p_obj_exhaacplus_dec, num_of_out_samples, + total_elements, time_data, total_channels); + + total_channels = 2; + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = + p_state_enhaacplus_dec->num_of_out_samples * 2 * sizeof(WORD16); + } + + if (p_obj_exhaacplus_dec->aac_config.flag_downmix && total_channels == 2) { + WORD32 out_ch = 1; + WORD i; + if (p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1) { + out_ch = 2; + } + + p_obj_exhaacplus_dec->aac_config.ui_n_channels = out_ch; + p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = + p_state_enhaacplus_dec->num_of_out_samples * out_ch * sizeof(WORD16); + + for (i = 0; i < num_of_out_samples; i++) { + WORD16 temp; + + temp = (time_data[2 * i + 0] >> 1) + (time_data[2 * i + 1] >> 1); + + if (out_ch == 2) { + time_data[2 * i + 0] = temp; + time_data[2 * i + 1] = time_data[2 * i + 0]; + } else { + time_data[i] = temp; + } + } + } + + if (p_state_enhaacplus_dec->s_adts_hdr_present) { + if (adts.no_raw_data_blocks != 0) { + if (adts.protection_absent == 0) { + adts.crc_check = ixheaacd_read_bits_buf(it_bit_buff, 16); + } + } + p_state_enhaacplus_dec->b_n_raw_data_blk--; + } + + ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); + + if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) + p_state_enhaacplus_dec->i_bytes_consumed = + (audio_mux_length_bytes_last + (SIZE_T)bytes_for_sync); + + return error_code; +} diff --git a/decoder/ixheaacd_api_defs.h b/decoder/ixheaacd_api_defs.h new file mode 100644 index 0000000..bd43c51 --- /dev/null +++ b/decoder/ixheaacd_api_defs.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_API_DEFS_H +#define IXHEAACD_API_DEFS_H + +#define IA_API_STR_LEN 30 +#define IA_APIVERSION_MAJOR 1 +#define IA_APIVERSION_MINOR 10 + +#define IA_LASTCOMP_APIVERSION_MAJOR 1 +#define IA_LASTCOMP_APIVERSION_MINOR 10 + +#define IA_STR(str) #str +#define IA_MAKE_VERSION_STR(maj, min) IA_STR(maj) "." IA_STR(min) +#define IA_APIVERSION \ + IA_MAKE_VERSION_STR(IA_APIVERSION_MAJOR, IA_APIVERSION_MINOR) + +#define IA_LAST_COMP_APIVERSION \ + IA_MAKE_VERSION_STR(IA_LASTCOMP_APIVERSION_MAJOR, \ + IA_LASTCOMP_APIVERSION_MINOR) + +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_apicmd_standards.h b/decoder/ixheaacd_apicmd_standards.h new file mode 100644 index 0000000..802585d --- /dev/null +++ b/decoder/ixheaacd_apicmd_standards.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_APICMD_STANDARDS_H +#define IXHEAACD_APICMD_STANDARDS_H + +/*****************************************************************************/ +/* Ittiam standard API commands */ +/*****************************************************************************/ +#define IA_API_CMD_GET_LIB_ID_STRINGS 0x0001 + +#define IA_API_CMD_GET_API_SIZE 0x0002 +#define IA_API_CMD_INIT 0x0003 + +#define IA_API_CMD_SET_CONFIG_PARAM 0x0004 +#define IA_API_CMD_GET_CONFIG_PARAM 0x0005 + +#define IA_API_CMD_GET_MEMTABS_SIZE 0x0006 +#define IA_API_CMD_SET_MEMTABS_PTR 0x0007 +#define IA_API_CMD_GET_N_MEMTABS 0x0008 + +#define IA_API_CMD_EXECUTE 0x0009 + +#define IA_API_CMD_PUT_INPUT_QUERY 0x000A +#define IA_API_CMD_GET_CURIDX_INPUT_BUF 0x000B +#define IA_API_CMD_SET_INPUT_BYTES 0x000C +#define IA_API_CMD_GET_OUTPUT_BYTES 0x000D +#define IA_API_CMD_INPUT_OVER 0x000E +#define IA_API_CMD_INPUT_SEEK 0x000F +#define IA_API_CMD_RESET 0x0010 + +#define IA_API_CMD_GET_MEM_INFO_SIZE 0x0011 +#define IA_API_CMD_GET_MEM_INFO_ALIGNMENT 0x0012 +#define IA_API_CMD_GET_MEM_INFO_TYPE 0x0013 +#define IA_API_CMD_GET_MEM_INFO_PLACEMENT 0x0014 +#define IA_API_CMD_GET_MEM_INFO_PRIORITY 0x0015 +#define IA_API_CMD_SET_MEM_PTR 0x0016 +#define IA_API_CMD_SET_MEM_INFO_SIZE 0x0017 +#define IA_API_CMD_SET_MEM_PLACEMENT 0x0018 + +#define IA_API_CMD_GET_N_TABLES 0x0019 +#define IA_API_CMD_GET_TABLE_INFO_SIZE 0x001A +#define IA_API_CMD_GET_TABLE_INFO_ALIGNMENT 0x001B +#define IA_API_CMD_GET_TABLE_INFO_PRIORITY 0x001C +#define IA_API_CMD_SET_TABLE_PTR 0x001D +#define IA_API_CMD_GET_TABLE_PTR 0x001E + +/*****************************************************************************/ +/* Ittiam standard API command indices */ +/*****************************************************************************/ +/* IA_API_CMD_GET_LIB_ID_STRINGS indices */ +#define IA_CMD_TYPE_LIB_NAME 0x0100 +#define IA_CMD_TYPE_LIB_VERSION 0x0200 +#define IA_CMD_TYPE_API_VERSION 0x0300 + +/* IA_API_CMD_INIT indices */ +#define IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS 0x0100 +#define IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS 0x0200 +#define IA_CMD_TYPE_INIT_PROCESS 0x0300 +#define IA_CMD_TYPE_INIT_DONE_QUERY 0x0400 +#define IA_CMD_TYPE_GA_HDR 0x0800 +#define IA_CMD_TYPE_FLUSH_MEM 0x1000 + +/* IA_API_CMD_EXECUTE indices */ +#define IA_CMD_TYPE_DO_EXECUTE 0x0100 +#define IA_CMD_TYPE_DONE_QUERY 0x0200 + +#endif /* IXHEAACD_APICMD_STANDARDS_H */ diff --git a/decoder/ixheaacd_arith_dec.c b/decoder/ixheaacd_arith_dec.c new file mode 100644 index 0000000..b0fdbf2 --- /dev/null +++ b/decoder/ixheaacd_arith_dec.c @@ -0,0 +1,2122 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_bit_extract.h" + +#define ARITH_ESCAPE 16 + +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] = { + 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, + 0x00, 0x21, 0x24, 0x12, 0x2C, 0x1E, 0x37, 0x24, 0x1F, 0x35, 0x37, 0x24, + 0x35, 0x37, 0x35, 0x37, 0x38, 0x2D, 0x21, 0x29, 0x1E, 0x21, 0x13, 0x2D, + 0x36, 0x38, 0x29, 0x36, 0x37, 0x24, 0x36, 0x38, 0x37, 0x38, 0x00, 0x20, + 0x23, 0x20, 0x23, 0x36, 0x38, 0x24, 0x3B, 0x24, 0x26, 0x29, 0x1F, 0x30, + 0x2D, 0x0D, 0x12, 0x3F, 0x2D, 0x21, 0x1C, 0x2A, 0x00, 0x21, 0x12, 0x1E, + 0x36, 0x38, 0x36, 0x37, 0x3F, 0x1E, 0x0D, 0x1F, 0x2A, 0x1E, 0x21, 0x24, + 0x12, 0x2A, 0x3C, 0x21, 0x24, 0x1F, 0x3C, 0x21, 0x29, 0x36, 0x38, 0x36, + 0x37, 0x38, 0x21, 0x1E, 0x00, 0x3B, 0x25, 0x1E, 0x20, 0x10, 0x1F, 0x3C, + 0x20, 0x23, 0x29, 0x08, 0x23, 0x12, 0x08, 0x23, 0x21, 0x38, 0x00, 0x20, + 0x13, 0x20, 0x3B, 0x1C, 0x20, 0x3B, 0x29, 0x20, 0x23, 0x24, 0x21, 0x24, + 0x21, 0x24, 0x3B, 0x13, 0x23, 0x26, 0x23, 0x13, 0x21, 0x24, 0x26, 0x29, + 0x12, 0x22, 0x2B, 0x02, 0x1E, 0x0D, 0x1F, 0x2D, 0x00, 0x0D, 0x12, 0x00, + 0x3C, 0x21, 0x29, 0x3C, 0x21, 0x2A, 0x3C, 0x3B, 0x22, 0x1E, 0x20, 0x10, + 0x1F, 0x3C, 0x0D, 0x29, 0x3C, 0x21, 0x24, 0x08, 0x23, 0x20, 0x38, 0x39, + 0x3C, 0x20, 0x13, 0x3C, 0x00, 0x0D, 0x13, 0x1F, 0x3C, 0x09, 0x26, 0x1F, + 0x08, 0x09, 0x26, 0x12, 0x08, 0x23, 0x29, 0x20, 0x23, 0x21, 0x24, 0x20, + 0x13, 0x20, 0x3B, 0x16, 0x20, 0x3B, 0x29, 0x20, 0x3B, 0x29, 0x20, 0x3B, + 0x13, 0x21, 0x24, 0x29, 0x0B, 0x13, 0x09, 0x3B, 0x13, 0x09, 0x3B, 0x13, + 0x21, 0x3B, 0x13, 0x0D, 0x26, 0x29, 0x26, 0x29, 0x3D, 0x12, 0x22, 0x28, + 0x2E, 0x04, 0x08, 0x13, 0x3C, 0x3B, 0x3C, 0x20, 0x10, 0x3C, 0x21, 0x07, + 0x08, 0x10, 0x00, 0x08, 0x0D, 0x29, 0x08, 0x0D, 0x29, 0x08, 0x09, 0x13, + 0x20, 0x23, 0x39, 0x08, 0x09, 0x13, 0x08, 0x09, 0x16, 0x08, 0x09, 0x10, + 0x12, 0x20, 0x3B, 0x3D, 0x09, 0x26, 0x20, 0x3B, 0x24, 0x39, 0x09, 0x26, + 0x20, 0x0D, 0x13, 0x00, 0x09, 0x13, 0x20, 0x0D, 0x26, 0x12, 0x20, 0x3B, + 0x13, 0x21, 0x26, 0x0B, 0x12, 0x09, 0x3B, 0x16, 0x09, 0x3B, 0x3D, 0x09, + 0x26, 0x0D, 0x13, 0x26, 0x3D, 0x1C, 0x12, 0x1F, 0x28, 0x2E, 0x07, 0x0B, + 0x08, 0x09, 0x00, 0x39, 0x0B, 0x08, 0x26, 0x08, 0x09, 0x13, 0x20, 0x0B, + 0x39, 0x10, 0x39, 0x0D, 0x13, 0x20, 0x10, 0x12, 0x09, 0x13, 0x20, 0x3B, + 0x13, 0x09, 0x26, 0x0B, 0x09, 0x3B, 0x1C, 0x09, 0x3B, 0x13, 0x20, 0x3B, + 0x13, 0x09, 0x26, 0x0B, 0x16, 0x0D, 0x13, 0x09, 0x13, 0x09, 0x13, 0x26, + 0x3D, 0x1C, 0x1F, 0x28, 0x2E, 0x07, 0x10, 0x39, 0x0B, 0x39, 0x39, 0x13, + 0x39, 0x0B, 0x39, 0x0B, 0x39, 0x26, 0x39, 0x10, 0x20, 0x3B, 0x16, 0x20, + 0x10, 0x09, 0x26, 0x0B, 0x13, 0x09, 0x13, 0x26, 0x1C, 0x0B, 0x3D, 0x1C, + 0x1F, 0x28, 0x2B, 0x07, 0x0C, 0x39, 0x0B, 0x39, 0x0B, 0x0C, 0x0B, 0x26, + 0x0B, 0x26, 0x3D, 0x0D, 0x1C, 0x14, 0x28, 0x2B, 0x39, 0x0B, 0x0C, 0x0E, + 0x3D, 0x1C, 0x0D, 0x12, 0x22, 0x2B, 0x07, 0x0C, 0x0E, 0x3D, 0x1C, 0x10, + 0x1F, 0x2B, 0x0C, 0x0E, 0x19, 0x14, 0x10, 0x1F, 0x28, 0x0C, 0x0E, 0x19, + 0x14, 0x26, 0x22, 0x2B, 0x0C, 0x0E, 0x19, 0x14, 0x26, 0x28, 0x0E, 0x19, + 0x14, 0x26, 0x28, 0x0E, 0x19, 0x14, 0x28, 0x0E, 0x19, 0x14, 0x22, 0x28, + 0x2B, 0x0E, 0x14, 0x2B, 0x31, 0x00, 0x3A, 0x3A, 0x05, 0x05, 0x1B, 0x1D, + 0x33, 0x06, 0x35, 0x35, 0x20, 0x21, 0x37, 0x21, 0x24, 0x05, 0x1B, 0x2C, + 0x2C, 0x2C, 0x06, 0x34, 0x1E, 0x34, 0x00, 0x08, 0x36, 0x09, 0x21, 0x26, + 0x1C, 0x2C, 0x00, 0x02, 0x02, 0x02, 0x3F, 0x04, 0x04, 0x04, 0x34, 0x39, + 0x20, 0x0A, 0x0C, 0x39, 0x0B, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x34, 0x39, + 0x39, 0x0A, 0x0C, 0x39, 0x0C, 0x0F, 0x07, 0x07, 0x07, 0x00, 0x39, 0x39, + 0x0C, 0x0F, 0x07, 0x07, 0x39, 0x0C, 0x0F, 0x07, 0x39, 0x0C, 0x0F, 0x39, + 0x39, 0x0C, 0x0F, 0x39, 0x0C, 0x39, 0x0C, 0x0F, 0x00, 0x11, 0x27, 0x17, + 0x2F, 0x27, 0x00, 0x27, 0x17, 0x00, 0x11, 0x17, 0x00, 0x11, 0x17, 0x11, + 0x00, 0x27, 0x15, 0x11, 0x17, 0x01, 0x15, 0x11, 0x15, 0x11, 0x15, 0x15, + 0x17, 0x00, 0x27, 0x01, 0x27, 0x27, 0x15, 0x00, 0x27, 0x11, 0x27, 0x15, + 0x15, 0x15, 0x27, 0x15, 0x15, 0x15, 0x15, 0x17, 0x2F, 0x11, 0x17, 0x27, + 0x27, 0x27, 0x11, 0x27, 0x15, 0x27, 0x27, 0x15, 0x15, 0x27, 0x17, 0x2F, + 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, + 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, + 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, + 0x17, 0x2F, 0x2B, 0x00, 0x27, 0x00, 0x00, 0x11, 0x15, 0x00, 0x11, 0x11, + 0x27, 0x27, 0x15, 0x17, 0x15, 0x17, 0x15, 0x17, 0x27, 0x17, 0x27, 0x17, + 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] = { + 0x00000104UL >> 8, 0x0000030AUL >> 8, 0x00000510UL >> 8, 0x00000716UL >> 8, + 0x00000A1FUL >> 8, 0x00000F2EUL >> 8, 0x00011100UL >> 8, 0x00111103UL >> 8, + 0x00111306UL >> 8, 0x00111436UL >> 8, 0x00111623UL >> 8, 0x00111929UL >> 8, + 0x00111F2EUL >> 8, 0x0011221BUL >> 8, 0x00112435UL >> 8, 0x00112621UL >> 8, + 0x00112D12UL >> 8, 0x00113130UL >> 8, 0x0011331DUL >> 8, 0x00113535UL >> 8, + 0x00113938UL >> 8, 0x0011411BUL >> 8, 0x00114433UL >> 8, 0x00114635UL >> 8, + 0x00114F29UL >> 8, 0x00116635UL >> 8, 0x00116F24UL >> 8, 0x00117433UL >> 8, + 0x0011FF0FUL >> 8, 0x00121102UL >> 8, 0x0012132DUL >> 8, 0x00121436UL >> 8, + 0x00121623UL >> 8, 0x00121912UL >> 8, 0x0012213FUL >> 8, 0x0012232DUL >> 8, + 0x00122436UL >> 8, 0x00122638UL >> 8, 0x00122A29UL >> 8, 0x00122F2BUL >> 8, + 0x0012322DUL >> 8, 0x00123436UL >> 8, 0x00123738UL >> 8, 0x00123B29UL >> 8, + 0x0012411DUL >> 8, 0x00124536UL >> 8, 0x00124938UL >> 8, 0x00124F12UL >> 8, + 0x00125535UL >> 8, 0x00125F29UL >> 8, 0x00126535UL >> 8, 0x0012B837UL >> 8, + 0x0013112AUL >> 8, 0x0013131EUL >> 8, 0x0013163BUL >> 8, 0x0013212DUL >> 8, + 0x0013233CUL >> 8, 0x00132623UL >> 8, 0x00132F2EUL >> 8, 0x0013321EUL >> 8, + 0x00133521UL >> 8, 0x00133824UL >> 8, 0x0013411EUL >> 8, 0x00134336UL >> 8, + 0x00134838UL >> 8, 0x00135135UL >> 8, 0x00135537UL >> 8, 0x00135F12UL >> 8, + 0x00137637UL >> 8, 0x0013FF29UL >> 8, 0x00140024UL >> 8, 0x00142321UL >> 8, + 0x00143136UL >> 8, 0x00143321UL >> 8, 0x00143F25UL >> 8, 0x00144321UL >> 8, + 0x00148638UL >> 8, 0x0014FF29UL >> 8, 0x00154323UL >> 8, 0x0015FF12UL >> 8, + 0x0016F20CUL >> 8, 0x0018A529UL >> 8, 0x00210031UL >> 8, 0x0021122CUL >> 8, + 0x00211408UL >> 8, 0x00211713UL >> 8, 0x00211F2EUL >> 8, 0x0021222AUL >> 8, + 0x00212408UL >> 8, 0x00212710UL >> 8, 0x00212F2EUL >> 8, 0x0021331EUL >> 8, + 0x00213436UL >> 8, 0x00213824UL >> 8, 0x0021412DUL >> 8, 0x0021431EUL >> 8, + 0x00214536UL >> 8, 0x00214F1FUL >> 8, 0x00216637UL >> 8, 0x00220004UL >> 8, + 0x0022122AUL >> 8, 0x00221420UL >> 8, 0x00221829UL >> 8, 0x00221F2EUL >> 8, + 0x0022222DUL >> 8, 0x00222408UL >> 8, 0x00222623UL >> 8, 0x00222929UL >> 8, + 0x00222F2BUL >> 8, 0x0022321EUL >> 8, 0x00223408UL >> 8, 0x00223724UL >> 8, + 0x00223A29UL >> 8, 0x0022411EUL >> 8, 0x00224436UL >> 8, 0x00224823UL >> 8, + 0x00225134UL >> 8, 0x00225621UL >> 8, 0x00225F12UL >> 8, 0x00226336UL >> 8, + 0x00227637UL >> 8, 0x0022FF29UL >> 8, 0x0023112DUL >> 8, 0x0023133CUL >> 8, + 0x00231420UL >> 8, 0x00231916UL >> 8, 0x0023212DUL >> 8, 0x0023233CUL >> 8, + 0x00232509UL >> 8, 0x00232929UL >> 8, 0x0023312DUL >> 8, 0x00233308UL >> 8, + 0x00233509UL >> 8, 0x00233724UL >> 8, 0x0023413CUL >> 8, 0x00234421UL >> 8, + 0x00234A13UL >> 8, 0x0023513CUL >> 8, 0x00235421UL >> 8, 0x00235F1FUL >> 8, + 0x00236421UL >> 8, 0x0023FF29UL >> 8, 0x00240024UL >> 8, 0x0024153BUL >> 8, + 0x00242108UL >> 8, 0x00242409UL >> 8, 0x00242726UL >> 8, 0x00243108UL >> 8, + 0x00243409UL >> 8, 0x00243610UL >> 8, 0x00244136UL >> 8, 0x00244321UL >> 8, + 0x00244523UL >> 8, 0x00244F1FUL >> 8, 0x00245423UL >> 8, 0x0024610AUL >> 8, + 0x00246423UL >> 8, 0x0024FF29UL >> 8, 0x00252510UL >> 8, 0x00253121UL >> 8, + 0x0025343BUL >> 8, 0x00254121UL >> 8, 0x00254510UL >> 8, 0x00254F25UL >> 8, + 0x00255221UL >> 8, 0x0025FF12UL >> 8, 0x00266513UL >> 8, 0x0027F529UL >> 8, + 0x0029F101UL >> 8, 0x002CF224UL >> 8, 0x00310030UL >> 8, 0x0031122AUL >> 8, + 0x00311420UL >> 8, 0x00311816UL >> 8, 0x0031212CUL >> 8, 0x0031231EUL >> 8, + 0x00312408UL >> 8, 0x00312710UL >> 8, 0x0031312AUL >> 8, 0x0031321EUL >> 8, + 0x00313408UL >> 8, 0x00313623UL >> 8, 0x0031411EUL >> 8, 0x0031433CUL >> 8, + 0x00320007UL >> 8, 0x0032122DUL >> 8, 0x00321420UL >> 8, 0x00321816UL >> 8, + 0x0032212DUL >> 8, 0x0032233CUL >> 8, 0x00322509UL >> 8, 0x00322916UL >> 8, + 0x0032312DUL >> 8, 0x00323420UL >> 8, 0x00323710UL >> 8, 0x00323F2BUL >> 8, + 0x00324308UL >> 8, 0x00324623UL >> 8, 0x00324F25UL >> 8, 0x00325421UL >> 8, + 0x00325F1FUL >> 8, 0x00326421UL >> 8, 0x0032FF29UL >> 8, 0x00331107UL >> 8, + 0x00331308UL >> 8, 0x0033150DUL >> 8, 0x0033211EUL >> 8, 0x00332308UL >> 8, + 0x00332420UL >> 8, 0x00332610UL >> 8, 0x00332929UL >> 8, 0x0033311EUL >> 8, + 0x00333308UL >> 8, 0x0033363BUL >> 8, 0x00333A29UL >> 8, 0x0033413CUL >> 8, + 0x00334320UL >> 8, 0x0033463BUL >> 8, 0x00334A29UL >> 8, 0x0033510AUL >> 8, + 0x00335320UL >> 8, 0x00335824UL >> 8, 0x0033610AUL >> 8, 0x00336321UL >> 8, + 0x00336F12UL >> 8, 0x00337623UL >> 8, 0x00341139UL >> 8, 0x0034153BUL >> 8, + 0x00342108UL >> 8, 0x00342409UL >> 8, 0x00342610UL >> 8, 0x00343108UL >> 8, + 0x00343409UL >> 8, 0x00343610UL >> 8, 0x00344108UL >> 8, 0x0034440DUL >> 8, + 0x00344610UL >> 8, 0x0034510AUL >> 8, 0x00345309UL >> 8, 0x0034553BUL >> 8, + 0x0034610AUL >> 8, 0x00346309UL >> 8, 0x0034F824UL >> 8, 0x00350029UL >> 8, + 0x00352510UL >> 8, 0x00353120UL >> 8, 0x0035330DUL >> 8, 0x00353510UL >> 8, + 0x00354120UL >> 8, 0x0035430DUL >> 8, 0x00354510UL >> 8, 0x00354F28UL >> 8, + 0x0035530DUL >> 8, 0x00355510UL >> 8, 0x00355F1FUL >> 8, 0x00356410UL >> 8, + 0x00359626UL >> 8, 0x0035FF12UL >> 8, 0x00366426UL >> 8, 0x0036FF12UL >> 8, + 0x0037F426UL >> 8, 0x0039D712UL >> 8, 0x003BF612UL >> 8, 0x003DF81FUL >> 8, + 0x00410004UL >> 8, 0x00411207UL >> 8, 0x0041150DUL >> 8, 0x0041212AUL >> 8, + 0x00412420UL >> 8, 0x0041311EUL >> 8, 0x00413308UL >> 8, 0x00413509UL >> 8, + 0x00413F2BUL >> 8, 0x00414208UL >> 8, 0x00420007UL >> 8, 0x0042123CUL >> 8, + 0x00421409UL >> 8, 0x00422107UL >> 8, 0x0042223CUL >> 8, 0x00422409UL >> 8, + 0x00422610UL >> 8, 0x0042313CUL >> 8, 0x00423409UL >> 8, 0x0042363BUL >> 8, + 0x0042413CUL >> 8, 0x00424320UL >> 8, 0x0042463BUL >> 8, 0x00425108UL >> 8, + 0x00425409UL >> 8, 0x0042FF29UL >> 8, 0x00431107UL >> 8, 0x00431320UL >> 8, + 0x0043153BUL >> 8, 0x0043213CUL >> 8, 0x00432320UL >> 8, 0x00432610UL >> 8, + 0x0043313CUL >> 8, 0x00433320UL >> 8, 0x0043353BUL >> 8, 0x00433813UL >> 8, + 0x00434108UL >> 8, 0x00434409UL >> 8, 0x00434610UL >> 8, 0x00435108UL >> 8, + 0x0043553BUL >> 8, 0x00435F25UL >> 8, 0x00436309UL >> 8, 0x0043753BUL >> 8, + 0x0043FF29UL >> 8, 0x00441239UL >> 8, 0x0044143BUL >> 8, 0x00442139UL >> 8, + 0x00442309UL >> 8, 0x0044253BUL >> 8, 0x00443108UL >> 8, 0x00443220UL >> 8, + 0x0044353BUL >> 8, 0x0044410AUL >> 8, 0x00444309UL >> 8, 0x0044453BUL >> 8, + 0x00444813UL >> 8, 0x0044510AUL >> 8, 0x00445309UL >> 8, 0x00445510UL >> 8, + 0x00445F25UL >> 8, 0x0044630DUL >> 8, 0x00450026UL >> 8, 0x00452713UL >> 8, + 0x00453120UL >> 8, 0x0045330DUL >> 8, 0x00453510UL >> 8, 0x00454120UL >> 8, + 0x0045430DUL >> 8, 0x00454510UL >> 8, 0x00455120UL >> 8, 0x0045530DUL >> 8, + 0x00456209UL >> 8, 0x00456410UL >> 8, 0x0045FF12UL >> 8, 0x00466513UL >> 8, + 0x0047FF22UL >> 8, 0x0048FF25UL >> 8, 0x0049F43DUL >> 8, 0x004BFB25UL >> 8, + 0x004EF825UL >> 8, 0x004FFF18UL >> 8, 0x00511339UL >> 8, 0x00512107UL >> 8, + 0x00513409UL >> 8, 0x00520007UL >> 8, 0x00521107UL >> 8, 0x00521320UL >> 8, + 0x00522107UL >> 8, 0x00522409UL >> 8, 0x0052313CUL >> 8, 0x00523320UL >> 8, + 0x0052353BUL >> 8, 0x00524108UL >> 8, 0x00524320UL >> 8, 0x00531139UL >> 8, + 0x00531309UL >> 8, 0x00532139UL >> 8, 0x00532309UL >> 8, 0x0053253BUL >> 8, + 0x00533108UL >> 8, 0x0053340DUL >> 8, 0x00533713UL >> 8, 0x00534108UL >> 8, + 0x0053453BUL >> 8, 0x00534F2BUL >> 8, 0x00535309UL >> 8, 0x00535610UL >> 8, + 0x00535F25UL >> 8, 0x0053643BUL >> 8, 0x00541139UL >> 8, 0x00542139UL >> 8, + 0x00542309UL >> 8, 0x00542613UL >> 8, 0x00543139UL >> 8, 0x00543309UL >> 8, + 0x00543510UL >> 8, 0x00543F2BUL >> 8, 0x00544309UL >> 8, 0x00544510UL >> 8, + 0x00544F28UL >> 8, 0x0054530DUL >> 8, 0x0054FF12UL >> 8, 0x00553613UL >> 8, + 0x00553F2BUL >> 8, 0x00554410UL >> 8, 0x0055510AUL >> 8, 0x0055543BUL >> 8, + 0x00555F25UL >> 8, 0x0055633BUL >> 8, 0x0055FF12UL >> 8, 0x00566513UL >> 8, + 0x00577413UL >> 8, 0x0059FF28UL >> 8, 0x005CC33DUL >> 8, 0x005EFB28UL >> 8, + 0x005FFF18UL >> 8, 0x00611339UL >> 8, 0x00612107UL >> 8, 0x00613320UL >> 8, + 0x0061A724UL >> 8, 0x00621107UL >> 8, 0x0062140BUL >> 8, 0x00622107UL >> 8, + 0x00622320UL >> 8, 0x00623139UL >> 8, 0x00623320UL >> 8, 0x00631139UL >> 8, + 0x0063130CUL >> 8, 0x00632139UL >> 8, 0x00632309UL >> 8, 0x00633139UL >> 8, + 0x00633309UL >> 8, 0x00633626UL >> 8, 0x00633F2BUL >> 8, 0x00634309UL >> 8, + 0x00634F2BUL >> 8, 0x0063543BUL >> 8, 0x0063FF12UL >> 8, 0x0064343BUL >> 8, + 0x00643F2BUL >> 8, 0x0064443BUL >> 8, 0x00645209UL >> 8, 0x00665513UL >> 8, + 0x0066610AUL >> 8, 0x00666526UL >> 8, 0x0067A616UL >> 8, 0x0069843DUL >> 8, + 0x006CF612UL >> 8, 0x006EF326UL >> 8, 0x006FFF18UL >> 8, 0x0071130CUL >> 8, + 0x00721107UL >> 8, 0x00722239UL >> 8, 0x0072291CUL >> 8, 0x0072340BUL >> 8, + 0x00731139UL >> 8, 0x00732239UL >> 8, 0x0073630BUL >> 8, 0x0073FF12UL >> 8, + 0x0074430BUL >> 8, 0x00755426UL >> 8, 0x00776F28UL >> 8, 0x00777410UL >> 8, + 0x0078843DUL >> 8, 0x007CF416UL >> 8, 0x007EF326UL >> 8, 0x007FFF18UL >> 8, + 0x00822239UL >> 8, 0x00831139UL >> 8, 0x0083430BUL >> 8, 0x0084530BUL >> 8, + 0x0087561CUL >> 8, 0x00887F25UL >> 8, 0x00888426UL >> 8, 0x008AF61CUL >> 8, + 0x008F0018UL >> 8, 0x008FFF18UL >> 8, 0x00911107UL >> 8, 0x0093230BUL >> 8, + 0x0094530BUL >> 8, 0x0097743DUL >> 8, 0x00998C25UL >> 8, 0x00999616UL >> 8, + 0x009EF825UL >> 8, 0x009FFF18UL >> 8, 0x00A3430BUL >> 8, 0x00A4530BUL >> 8, + 0x00A7743DUL >> 8, 0x00AA9F2BUL >> 8, 0x00AAA616UL >> 8, 0x00ABD61FUL >> 8, + 0x00AFFF18UL >> 8, 0x00B3330BUL >> 8, 0x00B44426UL >> 8, 0x00B7643DUL >> 8, + 0x00BB971FUL >> 8, 0x00BBB53DUL >> 8, 0x00BEF512UL >> 8, 0x00BFFF18UL >> 8, + 0x00C22139UL >> 8, 0x00C5330EUL >> 8, 0x00C7633DUL >> 8, 0x00CCAF2EUL >> 8, + 0x00CCC616UL >> 8, 0x00CFFF18UL >> 8, 0x00D4440EUL >> 8, 0x00D6420EUL >> 8, + 0x00DDCF2EUL >> 8, 0x00DDD516UL >> 8, 0x00DFFF18UL >> 8, 0x00E4330EUL >> 8, + 0x00E6841CUL >> 8, 0x00EEE61CUL >> 8, 0x00EFFF18UL >> 8, 0x00F3320EUL >> 8, + 0x00F55319UL >> 8, 0x00F8F41CUL >> 8, 0x00FAFF2EUL >> 8, 0x00FF002EUL >> 8, + 0x00FFF10CUL >> 8, 0x00FFF33DUL >> 8, 0x00FFF722UL >> 8, 0x00FFFF18UL >> 8, + 0x01000232UL >> 8, 0x0111113EUL >> 8, 0x01112103UL >> 8, 0x0111311AUL >> 8, + 0x0112111AUL >> 8, 0x01122130UL >> 8, 0x01123130UL >> 8, 0x0112411DUL >> 8, + 0x01131102UL >> 8, 0x01132102UL >> 8, 0x01133102UL >> 8, 0x01141108UL >> 8, + 0x01142136UL >> 8, 0x01143136UL >> 8, 0x01144135UL >> 8, 0x0115223BUL >> 8, + 0x01211103UL >> 8, 0x0121211AUL >> 8, 0x01213130UL >> 8, 0x01221130UL >> 8, + 0x01222130UL >> 8, 0x01223102UL >> 8, 0x01231104UL >> 8, 0x01232104UL >> 8, + 0x01233104UL >> 8, 0x01241139UL >> 8, 0x01241220UL >> 8, 0x01242220UL >> 8, + 0x01251109UL >> 8, 0x0125223BUL >> 8, 0x0125810AUL >> 8, 0x01283212UL >> 8, + 0x0131111AUL >> 8, 0x01312130UL >> 8, 0x0131222CUL >> 8, 0x0131322AUL >> 8, + 0x0132122AUL >> 8, 0x0132222DUL >> 8, 0x0132322DUL >> 8, 0x01331207UL >> 8, + 0x01332234UL >> 8, 0x01333234UL >> 8, 0x01341139UL >> 8, 0x01343134UL >> 8, + 0x01344134UL >> 8, 0x01348134UL >> 8, 0x0135220BUL >> 8, 0x0136110BUL >> 8, + 0x01365224UL >> 8, 0x01411102UL >> 8, 0x01412104UL >> 8, 0x01431239UL >> 8, + 0x01432239UL >> 8, 0x0143320AUL >> 8, 0x01435134UL >> 8, 0x01443107UL >> 8, + 0x01444134UL >> 8, 0x01446134UL >> 8, 0x0145220EUL >> 8, 0x01455134UL >> 8, + 0x0147110EUL >> 8, 0x01511102UL >> 8, 0x01521239UL >> 8, 0x01531239UL >> 8, + 0x01532239UL >> 8, 0x01533107UL >> 8, 0x0155220EUL >> 8, 0x01555134UL >> 8, + 0x0157110EUL >> 8, 0x01611107UL >> 8, 0x01621239UL >> 8, 0x01631239UL >> 8, + 0x01661139UL >> 8, 0x01666134UL >> 8, 0x01711107UL >> 8, 0x01721239UL >> 8, + 0x01745107UL >> 8, 0x0177110CUL >> 8, 0x01811107UL >> 8, 0x01821107UL >> 8, + 0x0185110CUL >> 8, 0x0188210CUL >> 8, 0x01911107UL >> 8, 0x01933139UL >> 8, + 0x01A11107UL >> 8, 0x01A31139UL >> 8, 0x01F5220EUL >> 8, 0x02000001UL >> 8, + 0x02000127UL >> 8, 0x02000427UL >> 8, 0x02000727UL >> 8, 0x02000E2FUL >> 8, + 0x02110000UL >> 8, 0x02111200UL >> 8, 0x02111411UL >> 8, 0x02111827UL >> 8, + 0x02111F2FUL >> 8, 0x02112411UL >> 8, 0x02112715UL >> 8, 0x02113200UL >> 8, + 0x02113411UL >> 8, 0x02113715UL >> 8, 0x02114200UL >> 8, 0x02121200UL >> 8, + 0x02121301UL >> 8, 0x02121F2FUL >> 8, 0x02122200UL >> 8, 0x02122615UL >> 8, + 0x02122F2FUL >> 8, 0x02123311UL >> 8, 0x02123F2FUL >> 8, 0x02124411UL >> 8, + 0x02131211UL >> 8, 0x02132311UL >> 8, 0x02133211UL >> 8, 0x02184415UL >> 8, + 0x02211200UL >> 8, 0x02211311UL >> 8, 0x02211F2FUL >> 8, 0x02212311UL >> 8, + 0x02212F2FUL >> 8, 0x02213211UL >> 8, 0x02221201UL >> 8, 0x02221311UL >> 8, + 0x02221F2FUL >> 8, 0x02222311UL >> 8, 0x02222F2FUL >> 8, 0x02223211UL >> 8, + 0x02223F2FUL >> 8, 0x02231211UL >> 8, 0x02232211UL >> 8, 0x02232F2FUL >> 8, + 0x02233211UL >> 8, 0x02233F2FUL >> 8, 0x02287515UL >> 8, 0x022DAB17UL >> 8, + 0x02311211UL >> 8, 0x02311527UL >> 8, 0x02312211UL >> 8, 0x02321211UL >> 8, + 0x02322211UL >> 8, 0x02322F2FUL >> 8, 0x02323311UL >> 8, 0x02323F2FUL >> 8, + 0x02331211UL >> 8, 0x02332211UL >> 8, 0x02332F2FUL >> 8, 0x02333F2FUL >> 8, + 0x0237FF17UL >> 8, 0x02385615UL >> 8, 0x023D9517UL >> 8, 0x02410027UL >> 8, + 0x02487827UL >> 8, 0x024E3117UL >> 8, 0x024FFF2FUL >> 8, 0x02598627UL >> 8, + 0x025DFF2FUL >> 8, 0x025FFF2FUL >> 8, 0x02687827UL >> 8, 0x026DFA17UL >> 8, + 0x026FFF2FUL >> 8, 0x02796427UL >> 8, 0x027E4217UL >> 8, 0x027FFF2FUL >> 8, + 0x02888727UL >> 8, 0x028EFF2FUL >> 8, 0x028FFF2FUL >> 8, 0x02984327UL >> 8, + 0x029F112FUL >> 8, 0x029FFF2FUL >> 8, 0x02A76527UL >> 8, 0x02AEF717UL >> 8, + 0x02AFFF2FUL >> 8, 0x02B7C827UL >> 8, 0x02BEF917UL >> 8, 0x02BFFF2FUL >> 8, + 0x02C66527UL >> 8, 0x02CD5517UL >> 8, 0x02CFFF2FUL >> 8, 0x02D63227UL >> 8, + 0x02DDD527UL >> 8, 0x02DFFF2BUL >> 8, 0x02E84717UL >> 8, 0x02EEE327UL >> 8, + 0x02EFFF2FUL >> 8, 0x02F54527UL >> 8, 0x02FCF817UL >> 8, 0x02FFEF2BUL >> 8, + 0x02FFFA2FUL >> 8, 0x02FFFE2FUL >> 8, 0x03000127UL >> 8, 0x03000201UL >> 8, + 0x03111200UL >> 8, 0x03122115UL >> 8, 0x03123200UL >> 8, 0x03133211UL >> 8, + 0x03211200UL >> 8, 0x03213127UL >> 8, 0x03221200UL >> 8, 0x03345215UL >> 8, + 0x04000F17UL >> 8, 0x04122F17UL >> 8, 0x043F6515UL >> 8, 0x043FFF17UL >> 8, + 0x044F5527UL >> 8, 0x044FFF17UL >> 8, 0x045F0017UL >> 8, 0x045FFF17UL >> 8, + 0x046F6517UL >> 8, 0x04710027UL >> 8, 0x047F4427UL >> 8, 0x04810027UL >> 8, + 0x048EFA15UL >> 8, 0x048FFF2FUL >> 8, 0x049F4427UL >> 8, 0x049FFF2FUL >> 8, + 0x04AEA727UL >> 8, 0x04AFFF2FUL >> 8, 0x04BE9C15UL >> 8, 0x04BFFF2FUL >> 8, + 0x04CE5427UL >> 8, 0x04CFFF2FUL >> 8, 0x04DE3527UL >> 8, 0x04DFFF17UL >> 8, + 0x04EE4627UL >> 8, 0x04EFFF17UL >> 8, 0x04FEF327UL >> 8, 0x04FFFF2FUL >> 8, + 0x06000F27UL >> 8, 0x069FFF17UL >> 8, 0x06FFFF17UL >> 8, 0x08110017UL >> 8, + 0x08EFFF15UL >> 8, 0xFFFFFF00UL >> 8}; + +static 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, + (UWORD8)0x21, (UWORD8)0x12, (UWORD8)0x30, (UWORD8)0x1D, (UWORD8)0x35, + (UWORD8)0x38, (UWORD8)0x1B, (UWORD8)0x33, (UWORD8)0x35, (UWORD8)0x29, + (UWORD8)0x35, (UWORD8)0x24, (UWORD8)0x33, (UWORD8)0x0F, (UWORD8)0x02, + (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x23, (UWORD8)0x12, (UWORD8)0x3F, + (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x2B, + (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x1D, + (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x12, (UWORD8)0x35, (UWORD8)0x29, + (UWORD8)0x35, (UWORD8)0x37, (UWORD8)0x2A, (UWORD8)0x1E, (UWORD8)0x3B, + (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x23, (UWORD8)0x2E, (UWORD8)0x1E, + (UWORD8)0x21, (UWORD8)0x24, (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x38, + (UWORD8)0x35, (UWORD8)0x37, (UWORD8)0x12, (UWORD8)0x37, (UWORD8)0x29, + (UWORD8)0x24, (UWORD8)0x21, (UWORD8)0x36, (UWORD8)0x21, (UWORD8)0x25, + (UWORD8)0x21, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x23, (UWORD8)0x12, + (UWORD8)0x0C, (UWORD8)0x29, (UWORD8)0x31, (UWORD8)0x2C, (UWORD8)0x08, + (UWORD8)0x13, (UWORD8)0x2E, (UWORD8)0x2A, (UWORD8)0x08, (UWORD8)0x10, + (UWORD8)0x2E, (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x24, (UWORD8)0x2D, + (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x1F, (UWORD8)0x37, (UWORD8)0x04, + (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x29, (UWORD8)0x2E, (UWORD8)0x2D, + (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x2B, (UWORD8)0x1E, + (UWORD8)0x08, (UWORD8)0x24, (UWORD8)0x29, (UWORD8)0x1E, (UWORD8)0x36, + (UWORD8)0x23, (UWORD8)0x34, (UWORD8)0x21, (UWORD8)0x12, (UWORD8)0x36, + (UWORD8)0x37, (UWORD8)0x29, (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x20, + (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x29, + (UWORD8)0x2D, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x24, (UWORD8)0x3C, + (UWORD8)0x21, (UWORD8)0x13, (UWORD8)0x3C, (UWORD8)0x21, (UWORD8)0x1F, + (UWORD8)0x21, (UWORD8)0x29, (UWORD8)0x24, (UWORD8)0x3B, (UWORD8)0x08, + (UWORD8)0x09, (UWORD8)0x26, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10, + (UWORD8)0x36, (UWORD8)0x21, (UWORD8)0x23, (UWORD8)0x1F, (UWORD8)0x23, + (UWORD8)0x0A, (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x10, (UWORD8)0x21, + (UWORD8)0x3B, (UWORD8)0x21, (UWORD8)0x10, (UWORD8)0x25, (UWORD8)0x21, + (UWORD8)0x12, (UWORD8)0x13, (UWORD8)0x29, (UWORD8)0x01, (UWORD8)0x24, + (UWORD8)0x30, (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x16, (UWORD8)0x2C, + (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x10, (UWORD8)0x2A, (UWORD8)0x1E, + (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x1E, (UWORD8)0x3C, (UWORD8)0x07, + (UWORD8)0x2D, (UWORD8)0x20, (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x3C, + (UWORD8)0x09, (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x20, (UWORD8)0x10, + (UWORD8)0x2B, (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x25, (UWORD8)0x21, + (UWORD8)0x1F, (UWORD8)0x21, (UWORD8)0x29, (UWORD8)0x07, (UWORD8)0x08, + (UWORD8)0x0D, (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x20, (UWORD8)0x10, + (UWORD8)0x29, (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x3B, (UWORD8)0x29, + (UWORD8)0x3C, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x29, (UWORD8)0x0A, + (UWORD8)0x20, (UWORD8)0x24, (UWORD8)0x0A, (UWORD8)0x21, (UWORD8)0x12, + (UWORD8)0x23, (UWORD8)0x39, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x09, + (UWORD8)0x10, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x08, + (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x3B, + (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x24, (UWORD8)0x29, (UWORD8)0x10, + (UWORD8)0x20, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x20, (UWORD8)0x0D, + (UWORD8)0x10, (UWORD8)0x28, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x1F, + (UWORD8)0x10, (UWORD8)0x26, (UWORD8)0x12, (UWORD8)0x26, (UWORD8)0x12, + (UWORD8)0x26, (UWORD8)0x12, (UWORD8)0x12, (UWORD8)0x1F, (UWORD8)0x04, + (UWORD8)0x07, (UWORD8)0x0D, (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x1E, + (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x2B, (UWORD8)0x08, (UWORD8)0x07, + (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x07, (UWORD8)0x3C, (UWORD8)0x09, + (UWORD8)0x10, (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x3C, + (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x29, + (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x3C, (UWORD8)0x20, + (UWORD8)0x10, (UWORD8)0x3C, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x13, + (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x08, (UWORD8)0x3B, + (UWORD8)0x25, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x29, (UWORD8)0x39, + (UWORD8)0x3B, (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x08, + (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x3B, + (UWORD8)0x13, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x25, + (UWORD8)0x0D, (UWORD8)0x26, (UWORD8)0x13, (UWORD8)0x20, (UWORD8)0x0D, + (UWORD8)0x10, (UWORD8)0x20, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x20, + (UWORD8)0x0D, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x12, (UWORD8)0x13, + (UWORD8)0x22, (UWORD8)0x25, (UWORD8)0x3D, (UWORD8)0x25, (UWORD8)0x25, + (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x09, (UWORD8)0x07, + (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x07, (UWORD8)0x09, (UWORD8)0x3C, + (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x20, (UWORD8)0x39, + (UWORD8)0x09, (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x08, + (UWORD8)0x0D, (UWORD8)0x13, (UWORD8)0x08, (UWORD8)0x3B, (UWORD8)0x2B, + (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x25, (UWORD8)0x3B, (UWORD8)0x39, + (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x13, (UWORD8)0x39, (UWORD8)0x09, + (UWORD8)0x10, (UWORD8)0x2B, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x28, + (UWORD8)0x0D, (UWORD8)0x12, (UWORD8)0x13, (UWORD8)0x2B, (UWORD8)0x10, + (UWORD8)0x0A, (UWORD8)0x3B, (UWORD8)0x25, (UWORD8)0x3B, (UWORD8)0x12, + (UWORD8)0x13, (UWORD8)0x13, (UWORD8)0x28, (UWORD8)0x3D, (UWORD8)0x28, + (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x24, + (UWORD8)0x07, (UWORD8)0x0B, (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x39, + (UWORD8)0x20, (UWORD8)0x39, (UWORD8)0x0C, (UWORD8)0x39, (UWORD8)0x09, + (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x26, (UWORD8)0x2B, (UWORD8)0x09, + (UWORD8)0x2B, (UWORD8)0x3B, (UWORD8)0x12, (UWORD8)0x3B, (UWORD8)0x2B, + (UWORD8)0x3B, (UWORD8)0x09, (UWORD8)0x13, (UWORD8)0x0A, (UWORD8)0x26, + (UWORD8)0x16, (UWORD8)0x3D, (UWORD8)0x12, (UWORD8)0x26, (UWORD8)0x18, + (UWORD8)0x0C, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x1C, (UWORD8)0x0B, + (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x0B, (UWORD8)0x12, (UWORD8)0x0B, + (UWORD8)0x26, (UWORD8)0x28, (UWORD8)0x10, (UWORD8)0x3D, (UWORD8)0x16, + (UWORD8)0x26, (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x0B, + (UWORD8)0x0B, (UWORD8)0x1C, (UWORD8)0x25, (UWORD8)0x26, (UWORD8)0x1C, + (UWORD8)0x18, (UWORD8)0x18, (UWORD8)0x07, (UWORD8)0x0B, (UWORD8)0x0B, + (UWORD8)0x3D, (UWORD8)0x25, (UWORD8)0x16, (UWORD8)0x25, (UWORD8)0x18, + (UWORD8)0x0B, (UWORD8)0x0B, (UWORD8)0x3D, (UWORD8)0x2B, (UWORD8)0x16, + (UWORD8)0x1F, (UWORD8)0x18, (UWORD8)0x0B, (UWORD8)0x26, (UWORD8)0x3D, + (UWORD8)0x1F, (UWORD8)0x3D, (UWORD8)0x12, (UWORD8)0x18, (UWORD8)0x39, + (UWORD8)0x0E, (UWORD8)0x3D, (UWORD8)0x2E, (UWORD8)0x16, (UWORD8)0x18, + (UWORD8)0x0E, (UWORD8)0x0E, (UWORD8)0x2E, (UWORD8)0x16, (UWORD8)0x18, + (UWORD8)0x0E, (UWORD8)0x1C, (UWORD8)0x1C, (UWORD8)0x18, (UWORD8)0x0E, + (UWORD8)0x19, (UWORD8)0x1C, (UWORD8)0x2E, (UWORD8)0x2E, (UWORD8)0x0C, + (UWORD8)0x3D, (UWORD8)0x22, (UWORD8)0x18, (UWORD8)0x32, (UWORD8)0x3E, + (UWORD8)0x03, (UWORD8)0x1A, (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x30, + (UWORD8)0x1D, (UWORD8)0x02, (UWORD8)0x02, (UWORD8)0x02, (UWORD8)0x08, + (UWORD8)0x36, (UWORD8)0x36, (UWORD8)0x35, (UWORD8)0x3B, (UWORD8)0x03, + (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x30, (UWORD8)0x30, (UWORD8)0x02, + (UWORD8)0x04, (UWORD8)0x04, (UWORD8)0x04, (UWORD8)0x39, (UWORD8)0x20, + (UWORD8)0x20, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x0A, (UWORD8)0x12, + (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x2C, (UWORD8)0x2A, (UWORD8)0x2A, + (UWORD8)0x2D, (UWORD8)0x2D, (UWORD8)0x07, (UWORD8)0x34, (UWORD8)0x34, + (UWORD8)0x39, (UWORD8)0x34, (UWORD8)0x34, (UWORD8)0x34, (UWORD8)0x0B, + (UWORD8)0x0B, (UWORD8)0x24, (UWORD8)0x02, (UWORD8)0x04, (UWORD8)0x39, + (UWORD8)0x39, (UWORD8)0x0A, (UWORD8)0x34, (UWORD8)0x07, (UWORD8)0x34, + (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x02, + (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x0E, + (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x39, + (UWORD8)0x39, (UWORD8)0x34, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x07, + (UWORD8)0x0C, (UWORD8)0x07, (UWORD8)0x07, (UWORD8)0x0C, (UWORD8)0x0C, + (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x0E, + (UWORD8)0x01, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x2F, + (UWORD8)0x00, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x27, (UWORD8)0x2F, + (UWORD8)0x11, (UWORD8)0x15, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x15, + (UWORD8)0x00, (UWORD8)0x00, (UWORD8)0x01, (UWORD8)0x2F, (UWORD8)0x00, + (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, + (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x15, (UWORD8)0x00, + (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, + (UWORD8)0x01, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F, + (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F, + (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x11, + (UWORD8)0x27, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F, + (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F, + (UWORD8)0x2F, (UWORD8)0x17, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x27, + (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, + (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, + (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x2F, + (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, + (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, + (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x2B, + (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, + (UWORD8)0x2B, (UWORD8)0x2F, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x01, + (UWORD8)0x00, (UWORD8)0x15, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x00, + (UWORD8)0x27, (UWORD8)0x00, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x17, + (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x17, + (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x27, + (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x27, + (UWORD8)0x2F, (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, + (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x27, + (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x17, + (UWORD8)0x15, (UWORD8)0x00}; + +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, + 2904, 2718, 2631, 2590, 0}, + {7263, 4888, 4810, 4803, 1889, 415, 335, 327, 195, 72, 52, 49, 36, 20, 15, + 14, 0}, + {3626, 2197, 2188, 2187, 582, 57, 47, 46, 30, 12, 9, 8, 6, 4, 3, 2, 0}, + {7806, 5541, 5451, 5441, 2720, 834, 691, 674, 487, 243, 179, 167, 139, 98, + 77, 70, 0}, + {6684, 4101, 4058, 4055, 1748, 426, 368, 364, 322, 257, 235, 232, 228, 222, + 217, 215, 0}, + {9162, 5964, 5831, 5819, 3269, 866, 658, 638, 535, 348, 258, 244, 234, 214, + 195, 186, 0}, + {10638, 8491, 8365, 8351, 4418, 2067, 1859, 1834, 1190, 601, 495, 478, 356, + 217, 174, 164, 0}, + {13389, 10514, 10032, 9961, 7166, 3488, 2655, 2524, 2015, 1140, 760, 672, + 585, 426, 325, 283, 0}, + {14861, 12788, 12115, 11952, 9987, 6657, 5323, 4984, 4324, 3001, 2205, 1943, + 1764, 1394, 1115, 978, 0}, + {12876, 10004, 9661, 9610, 7107, 3435, 2711, 2595, 2257, 1508, 1059, 952, + 893, 753, 609, 538, 0}, + {15125, 13591, 13049, 12874, 11192, 8543, 7406, 7023, 6291, 4922, 4104, + 3769, 3465, 2890, 2486, 2275, 0}, + {14574, 13106, 12731, 12638, 10453, 7947, 7233, 7037, 6031, 4618, 4081, + 3906, 3465, 2802, 2476, 2349, 0}, + {15070, 13179, 12517, 12351, 10742, 7657, 6200, 5825, 5264, 3998, 3014, + 2662, 2510, 2153, 1799, 1564, 0}, + {15542, 14466, 14007, 13844, 12489, 10409, 9481, 9132, 8305, 6940, 6193, + 5867, 5458, 4743, 4291, 4047, 0}, + {15165, 14384, 14084, 13934, 12911, 11485, 10844, 10513, 10002, 8993, 8380, + 8051, 7711, 7036, 6514, 6233, 0}, + {15642, 14279, 13625, 13393, 12348, 9971, 8405, 7858, 7335, 6119, 4918, + 4376, 4185, 3719, 3231, 2860, 0}, + {13408, 13407, 11471, 11218, 11217, 11216, 9473, 9216, 6480, 3689, 2857, + 2690, 2256, 1732, 1405, 1302, 0}, + {16098, 15584, 15191, 14931, 14514, 13578, 12703, 12103, 11830, 11172, + 10475, 9867, 9695, 9281, 8825, 8389, 0}, + {15844, 14873, 14277, 13996, 13230, 11535, 10205, 9543, 9107, 8086, 7085, + 6419, 6214, 5713, 5195, 4731, 0}, + {16131, 15720, 15443, 15276, 14848, 13971, 13314, 12910, 12591, 11874, + 11225, 10788, 10573, 10077, 9585, 9209, 0}, + {16331, 16330, 12283, 11435, 11434, 11433, 8725, 8049, 6065, 4138, 3187, + 2842, 2529, 2171, 1907, 1745, 0}, + {16011, 15292, 14782, 14528, 14008, 12767, 11556, 10921, 10591, 9759, 8813, + 8043, 7855, 7383, 6863, 6282, 0}, + {16380, 16379, 15159, 14610, 14609, 14608, 12859, 12111, 11046, 9536, 8348, + 7713, 7216, 6533, 5964, 5546, 0}, + {16367, 16333, 16294, 16253, 16222, 16143, 16048, 15947, 15915, 15832, + 15731, 15619, 15589, 15512, 15416, 15310, 0}, + {15967, 15319, 14937, 14753, 14010, 12638, 11787, 11360, 10805, 9706, 8934, + 8515, 8166, 7456, 6911, 6575, 0}, + {4906, 3005, 2985, 2984, 875, 102, 83, 81, 47, 17, 12, 11, 8, 5, 4, 3, 0}, + {7217, 4346, 4269, 4264, 1924, 428, 340, 332, 280, 203, 179, 175, 171, 164, + 159, 157, 0}, + {16010, 15415, 15032, 14805, 14228, 13043, 12168, 11634, 11265, 10419, 9645, + 9110, 8892, 8378, 7850, 7437, 0}, + {8573, 5218, 5046, 5032, 2787, 771, 555, 533, 443, 286, 218, 205, 197, 181, + 168, 162, 0}, + {11474, 8095, 7822, 7796, 4632, 1443, 1046, 1004, 748, 351, 218, 194, 167, + 121, 93, 83, 0}, + {16152, 15764, 15463, 15264, 14925, 14189, 13536, 13070, 12846, 12314, + 11763, 11277, 11131, 10777, 10383, 10011, 0}, + {14187, 11654, 11043, 10919, 8498, 4885, 3778, 3552, 2947, 1835, 1283, 1134, + 998, 749, 585, 514, 0}, + {14162, 11527, 10759, 10557, 8601, 5417, 4105, 3753, 3286, 2353, 1708, 1473, + 1370, 1148, 959, 840, 0}, + {16205, 15902, 15669, 15498, 15213, 14601, 14068, 13674, 13463, 12970, + 12471, 12061, 11916, 11564, 11183, 10841, 0}, + {15043, 12972, 12092, 11792, 10265, 7446, 5934, 5379, 4883, 3825, 3036, + 2647, 2507, 2185, 1901, 1699, 0}, + {15320, 13694, 12782, 12352, 11191, 8936, 7433, 6671, 6255, 5366, 4622, + 4158, 4020, 3712, 3420, 3198, 0}, + {16255, 16020, 15768, 15600, 15416, 14963, 14440, 14006, 13875, 13534, + 13137, 12697, 12602, 12364, 12084, 11781, 0}, + {15627, 14503, 13906, 13622, 12557, 10527, 9269, 8661, 8117, 6933, 5994, + 5474, 5222, 4664, 4166, 3841, 0}, + {16366, 16365, 14547, 14160, 14159, 14158, 11969, 11473, 8735, 6147, 4911, + 4530, 3865, 3180, 2710, 2473, 0}, + {16257, 16038, 15871, 15754, 15536, 15071, 14673, 14390, 14230, 13842, + 13452, 13136, 13021, 12745, 12434, 12154, 0}, + {15855, 14971, 14338, 13939, 13239, 11782, 10585, 9805, 9444, 8623, 7846, + 7254, 7079, 6673, 6262, 5923, 0}, + {9492, 6318, 6197, 6189, 3004, 652, 489, 477, 333, 143, 96, 90, 78, 60, 50, + 47, 0}, + {16313, 16191, 16063, 15968, 15851, 15590, 15303, 15082, 14968, 14704, + 14427, 14177, 14095, 13899, 13674, 13457, 0}, + {8485, 5473, 5389, 5383, 2411, 494, 386, 377, 278, 150, 117, 112, 103, 89, + 81, 78, 0}, + {10497, 7154, 6959, 6943, 3788, 1004, 734, 709, 517, 238, 152, 138, 120, 90, + 72, 66, 0}, + {16317, 16226, 16127, 16040, 15955, 15762, 15547, 15345, 15277, 15111, + 14922, 14723, 14671, 14546, 14396, 14239, 0}, + {16382, 16381, 15858, 15540, 15539, 15538, 14704, 14168, 13768, 13092, + 12452, 11925, 11683, 11268, 10841, 10460, 0}, + {5974, 3798, 3758, 3755, 1275, 205, 166, 162, 95, 35, 26, 24, 18, 11, 8, 7, + 0}, + {3532, 2258, 2246, 2244, 731, 135, 118, 115, 87, 45, 36, 34, 29, 21, 17, 16, + 0}, + {7466, 4882, 4821, 4811, 2476, 886, 788, 771, 688, 531, 469, 457, 437, 400, + 369, 361, 0}, + {9580, 5772, 5291, 5216, 3444, 1496, 1025, 928, 806, 578, 433, 384, 366, + 331, 296, 273, 0}, + {10692, 7730, 7543, 7521, 4679, 1746, 1391, 1346, 1128, 692, 495, 458, 424, + 353, 291, 268, 0}, + {11040, 7132, 6549, 6452, 4377, 1875, 1253, 1130, 958, 631, 431, 370, 346, + 296, 253, 227, 0}, + {12687, 9332, 8701, 8585, 6266, 3093, 2182, 2004, 1683, 1072, 712, 608, 559, + 458, 373, 323, 0}, + {13429, 9853, 8860, 8584, 6806, 4039, 2862, 2478, 2239, 1764, 1409, 1224, + 1178, 1077, 979, 903, 0}, + {14685, 12163, 11061, 10668, 9101, 6345, 4871, 4263, 3908, 3200, 2668, 2368, + 2285, 2106, 1942, 1819, 0}, + {13295, 11302, 10999, 10945, 7947, 5036, 4490, 4385, 3391, 2185, 1836, 1757, + 1424, 998, 833, 785, 0}, + {4992, 2993, 2972, 2970, 1269, 575, 552, 549, 530, 505, 497, 495, 493, 489, + 486, 485, 0}, + {15419, 13862, 13104, 12819, 11429, 8753, 7220, 6651, 6020, 4667, 3663, + 3220, 2995, 2511, 2107, 1871, 0}, + {12468, 9263, 8912, 8873, 5758, 2193, 1625, 1556, 1187, 589, 371, 330, 283, + 200, 149, 131, 0}, + {15870, 15076, 14615, 14369, 13586, 12034, 10990, 10423, 9953, 8908, 8031, + 7488, 7233, 6648, 6101, 5712, 0}, + {1693, 978, 976, 975, 194, 18, 16, 15, 11, 7, 6, 5, 4, 3, 2, 1, 0}, + {7992, 5218, 5147, 5143, 2152, 366, 282, 276, 173, 59, 38, 35, 27, 16, 11, + 10, 0}}; + +typedef struct { WORD32 low, high, value; } state_arith; + +const WORD32 ixheaacd_table_frac[7] = { + 638450709, 759250126, 902905651, 1073741824, + 1276901417, 1518500250, 1805811302, +}; + +const WORD64 ixheaacd_table_exp[32] = { + 1, 2, 4, 8, 16, 32, 64, + 128, 256, 512, 1024, 2048, 4096, 8192, + 16384, 32768, 65536, 131072, 262144, 524288, 1048576, + 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, + 268435456, 536870912, 1073741824, 2147483648}; + +static const WORD32 ixheaacd_pow_14_3[8] = {0, 3251, 4096, 5161, + 6502, 8192, 10321, 13004}; + +const WORD32 ixheaacd_pow_table_Q13[1024] = {0, + 131072 >> 4, + 330281 >> 4, + 567116 >> 4, + 832256 >> 4, + 1120650 >> 4, + 1429042 >> 4, + 1755122 >> 4, + 2097152 >> 4, + 2453767 >> 4, + 2823861 >> 4, + 3206517 >> 4, + 3600960 >> 4, + 4006524 >> 4, + 4422631 >> 4, + 4848770 >> 4, + 5284492 >> 4, + 5729392 >> 4, + 6183105 >> 4, + 6645302 >> 4, + 7115683 >> 4, + 7593972 >> 4, + 8079916 >> 4, + 8573281 >> 4, + 9073850 >> 4, + 9581422 >> 4, + 10095808 >> 4, + 10616832 >> 4, + 11144330 >> 4, + 11678147 >> 4, + 12218136 >> 4, + 12764159 >> 4, + 13316085 >> 4, + 13873792 >> 4, + 14437162 >> 4, + 15006082 >> 4, + 15580448 >> 4, + 16160157 >> 4, + 16745112 >> 4, + 17335222 >> 4, + 17930398 >> 4, + 18530554 >> 4, + 19135610 >> 4, + 19745488 >> 4, + 20360112 >> 4, + 20979411 >> 4, + 21603314 >> 4, + 22231755 >> 4, + 22864669 >> 4, + 23501994 >> 4, + 24143669 >> 4, + 24789637 >> 4, + 25439841 >> 4, + 26094226 >> 4, + 26752740 >> 4, + 27415332 >> 4, + 28081952 >> 4, + 28752552 >> 4, + 29427086 >> 4, + 30105507 >> 4, + 30787772 >> 4, + 31473838 >> 4, + 32163664 >> 4, + 32857208 >> 4, + 33554432 >> 4, + 34255297 >> 4, + 34959765 >> 4, + 35667801 >> 4, + 36379368 >> 4, + 37094431 >> 4, + 37812958 >> 4, + 38534914 >> 4, + 39260268 >> 4, + 39988988 >> 4, + 40721043 >> 4, + 41456403 >> 4, + 42195038 >> 4, + 42936921 >> 4, + 43682022 >> 4, + 44430314 >> 4, + 45181770 >> 4, + 45936364 >> 4, + 46694070 >> 4, + 47454862 >> 4, + 48218716 >> 4, + 48985607 >> 4, + 49755512 >> 4, + 50528406 >> 4, + 51304267 >> 4, + 52083073 >> 4, + 52864802 >> 4, + 53649431 >> 4, + 54436939 >> 4, + 55227306 >> 4, + 56020511 >> 4, + 56816534 >> 4, + 57615355 >> 4, + 58416954 >> 4, + 59221313 >> 4, + 60028412 >> 4, + 60838233 >> 4, + 61650759 >> 4, + 62465970 >> 4, + 63283850 >> 4, + 64104381 >> 4, + 64927547 >> 4, + 65753329 >> 4, + 66581713 >> 4, + 67412681 >> 4, + 68246218 >> 4, + 69082308 >> 4, + 69920936 >> 4, + 70762086 >> 4, + 71605743 >> 4, + 72451892 >> 4, + 73300519 >> 4, + 74151609 >> 4, + 75005149 >> 4, + 75861124 >> 4, + 76719520 >> 4, + 77580324 >> 4, + 78443523 >> 4, + 79309103 >> 4, + 80177051 >> 4, + 81047354 >> 4, + 81920000 >> 4, + 82794977 >> 4, + 83672271 >> 4, + 84551871 >> 4, + 5339610, + 5394871, + 5450274, + 5505818, + 5561502, + 5617327, + 5673290, + 5729391, + 5785631, + 5842007, + 5898519, + 5955168, + 6011951, + 6068869, + 6125920, + 6183105, + 6240422, + 6297871, + 6355451, + 6413162, + 6471004, + 6528974, + 6587074, + 6645302, + 6703658, + 6762141, + 6820751, + 6879487, + 6938349, + 6997336, + 7056447, + 7115683, + 7175042, + 7234524, + 7294129, + 7353855, + 7413703, + 7473672, + 7533762, + 7593972, + 7654301, + 7714750, + 7775317, + 7836002, + 7896805, + 7957725, + 8018762, + 8079916, + 8141185, + 8202570, + 8264070, + 8325685, + 8387413, + 8449256, + 8511212, + 8573281, + 8635462, + 8697756, + 8760161, + 8822678, + 8885305, + 8948043, + 9010892, + 9073850, + 9136917, + 9200094, + 9263379, + 9326772, + 9390274, + 9453882, + 9517598, + 9581421, + 9645351, + 9709386, + 9773527, + 9837774, + 9902125, + 9966582, + 10031143, + 10095807, + 10160576, + 10225448, + 10290423, + 10355500, + 10420681, + 10485963, + 10551347, + 10616832, + 10682419, + 10748106, + 10813894, + 10879782, + 10945770, + 11011857, + 11078044, + 11144330, + 11210715, + 11277198, + 11343779, + 11410458, + 11477234, + 11544108, + 11611079, + 11678147, + 11745311, + 11812571, + 11879927, + 11947378, + 12014925, + 12082567, + 12150304, + 12218135, + 12286061, + 12354081, + 12422194, + 12490401, + 12558701, + 12627094, + 12695580, + 12764158, + 12832829, + 12901592, + 12970446, + 13039392, + 13108429, + 13177557, + 13246776, + 13316085, + 13385485, + 13454975, + 13524554, + 13594224, + 13663982, + 13733830, + 13803767, + 13873792, + 13943906, + 14014108, + 14084398, + 14154776, + 14225242, + 14295794, + 14366435, + 14437162, + 14507975, + 14578876, + 14649862, + 14720935, + 14792093, + 14863337, + 14934667, + 15006082, + 15077582, + 15149167, + 15220837, + 15292591, + 15364429, + 15436351, + 15508358, + 15580448, + 15652621, + 15724878, + 15797217, + 15869640, + 15942146, + 16014734, + 16087404, + 16160156, + 16232991, + 16305907, + 16378905, + 16451984, + 16525145, + 16598386, + 16671709, + 16745112, + 16818596, + 16892160, + 16965804, + 17039528, + 17113332, + 17187216, + 17261179, + 17335222, + 17409343, + 17483544, + 17557824, + 17632182, + 17706618, + 17781133, + 17855726, + 17930397, + 18005146, + 18079973, + 18154877, + 18229858, + 18304917, + 18380052, + 18455265, + 18530554, + 18605920, + 18681362, + 18756880, + 18832475, + 18908145, + 18983891, + 19059713, + 19135610, + 19211583, + 19287630, + 19363753, + 19439951, + 19516223, + 19592571, + 19668992, + 19745488, + 19822058, + 19898702, + 19975420, + 20052211, + 20129076, + 20206015, + 20283027, + 20360112, + 20437270, + 20514501, + 20591805, + 20669181, + 20746630, + 20824151, + 20901745, + 20979410, + 21057148, + 21134957, + 21212838, + 21290791, + 21368815, + 21446910, + 21525076, + 21603314, + 21681622, + 21760001, + 21838451, + 21916971, + 21995561, + 22074222, + 22152953, + 22231754, + 22310625, + 22389566, + 22468576, + 22547656, + 22626806, + 22706024, + 22785312, + 22864669, + 22944094, + 23023589, + 23103152, + 23182783, + 23262484, + 23342252, + 23422089, + 23501993, + 23581966, + 23662007, + 23742115, + 23822291, + 23902534, + 23982845, + 24063223, + 24143669, + 24224181, + 24304761, + 24385407, + 24466120, + 24546899, + 24627745, + 24708658, + 24789637, + 24870682, + 24951793, + 25032970, + 25114213, + 25195521, + 25276895, + 25358335, + 25439841, + 25521411, + 25603047, + 25684748, + 25766514, + 25848345, + 25930241, + 26012201, + 26094226, + 26176316, + 26258469, + 26340688, + 26422970, + 26505317, + 26587727, + 26670202, + 26752740, + 26835342, + 26918008, + 27000737, + 27083530, + 27166386, + 27249305, + 27332287, + 27415332, + 27498440, + 27581611, + 27664845, + 27748142, + 27831501, + 27914922, + 27998406, + 28081952, + 28165561, + 28249231, + 28332963, + 28416758, + 28500614, + 28584532, + 28668511, + 28752552, + 28836655, + 28920819, + 29005044, + 29089330, + 29173677, + 29258086, + 29342555, + 29427086, + 29511676, + 29596328, + 29681040, + 29765813, + 29850646, + 29935539, + 30020493, + 30105507, + 30190581, + 30275714, + 30360908, + 30446162, + 30531475, + 30616848, + 30702280, + 30787772, + 30873323, + 30958934, + 31044604, + 31130332, + 31216120, + 31301967, + 31387873, + 31473838, + 31559862, + 31645944, + 31732084, + 31818284, + 31904541, + 31990857, + 32077231, + 32163664, + 32250154, + 32336703, + 32423309, + 32509974, + 32596696, + 32683476, + 32770313, + 32857208, + 32944161, + 33031171, + 33118238, + 33205363, + 33292544, + 33379783, + 33467079, + 33554432, + 33641842, + 33729308, + 33816832, + 33904412, + 33992048, + 34079741, + 34167491, + 34255297, + 34343159, + 34431078, + 34519052, + 34607083, + 34695170, + 34783312, + 34871511, + 34959765, + 35048075, + 35136441, + 35224862, + 35313339, + 35401872, + 35490459, + 35579102, + 35667801, + 35756554, + 35845363, + 35934226, + 36023145, + 36112118, + 36201147, + 36290230, + 36379367, + 36468560, + 36557807, + 36647108, + 36736464, + 36825875, + 36915339, + 37004858, + 37094431, + 37184058, + 37273739, + 37363474, + 37453263, + 37543106, + 37633003, + 37722953, + 37812957, + 37903015, + 37993126, + 38083291, + 38173509, + 38263780, + 38354105, + 38444483, + 38534914, + 38625398, + 38715935, + 38806525, + 38897168, + 38987864, + 39078612, + 39169414, + 39260268, + 39351174, + 39442133, + 39533145, + 39624209, + 39715325, + 39806494, + 39897714, + 39988987, + 40080312, + 40171690, + 40263119, + 40354600, + 40446133, + 40537718, + 40629354, + 40721042, + 40812782, + 40904574, + 40996417, + 41088311, + 41180257, + 41272254, + 41364303, + 41456402, + 41548553, + 41640755, + 41733008, + 41825313, + 41917668, + 42010074, + 42102530, + 42195038, + 42287596, + 42380205, + 42472865, + 42565575, + 42658336, + 42751147, + 42844009, + 42936921, + 43029883, + 43122895, + 43215958, + 43309071, + 43402233, + 43495446, + 43588709, + 43682022, + 43775384, + 43868797, + 43962259, + 44055771, + 44149332, + 44242943, + 44336604, + 44430314, + 44524073, + 44617882, + 44711741, + 44805648, + 44899605, + 44993611, + 45087666, + 45181770, + 45275923, + 45370126, + 45464377, + 45558677, + 45653025, + 45747423, + 45841869, + 45936364, + 46030908, + 46125500, + 46220141, + 46314830, + 46409567, + 46504353, + 46599187, + 46694070, + 46789001, + 46883980, + 46979007, + 47074082, + 47169205, + 47264376, + 47359595, + 47454862, + 47550177, + 47645540, + 47740950, + 47836408, + 47931914, + 48027467, + 48123068, + 48218716, + 48314412, + 48410155, + 48505945, + 48601783, + 48697668, + 48793601, + 48889580, + 48985607, + 49081681, + 49177802, + 49273969, + 49370184, + 49466446, + 49562754, + 49659109, + 49755511, + 49851960, + 49948456, + 50044998, + 50141586, + 50238222, + 50334903, + 50431631, + 50528406, + 50625227, + 50722094, + 50819007, + 50915967, + 51012973, + 51110025, + 51207123, + 51304267, + 51401457, + 51498694, + 51595976, + 51693304, + 51790677, + 51888097, + 51985562, + 52083073, + 52180630, + 52278232, + 52375880, + 52473573, + 52571312, + 52669097, + 52766926, + 52864801, + 52962722, + 53060688, + 53158699, + 53256755, + 53354856, + 53453002, + 53551194, + 53649430, + 53747712, + 53846038, + 53944410, + 54042826, + 54141287, + 54239793, + 54338344, + 54436939, + 54535579, + 54634263, + 54732993, + 54831766, + 54930585, + 55029447, + 55128354, + 55227306, + 55326302, + 55425342, + 55524426, + 55623555, + 55722728, + 55821945, + 55921206, + 56020511, + 56119860, + 56219253, + 56318690, + 56418171, + 56517696, + 56617265, + 56716877, + 56816534, + 56916234, + 57015977, + 57115765, + 57215595, + 57315470, + 57415388, + 57515349, + 57615354, + 57715403, + 57815494, + 57915629, + 58015808, + 58116030, + 58216294, + 58316602, + 58416954, + 58517348, + 58617785, + 58718266, + 58818789, + 58919356, + 59019965, + 59120617, + 59221312, + 59322050, + 59422831, + 59523654, + 59624521, + 59725429, + 59826381, + 59927375, + 60028412, + 60129491, + 60230613, + 60331777, + 60432983, + 60534232, + 60635524, + 60736857, + 60838233, + 60939651, + 61041112, + 61142614, + 61244159, + 61345746, + 61447375, + 61549046, + 61650759, + 61752513, + 61854310, + 61956149, + 62058030, + 62159952, + 62261916, + 62363922, + 62465970, + 62568059, + 62670191, + 62772363, + 62874578, + 62976833, + 63079131, + 63181470, + 63283850, + 63386272, + 63488735, + 63591239, + 63693785, + 63796372, + 63899001, + 64001670, + 64104381, + 64207133, + 64309926, + 64412760, + 64515636, + 64618552, + 64721509, + 64824507, + 64927546, + 65030627, + 65133747, + 65236909, + 65340112, + 65443355, + 65546639, + 65649964, + 65753329, + 65856735, + 65960182, + 66063669, + 66167197, + 66270765, + 66374374, + 66478023, + 66581713, + 66685443, + 66789213, + 66893024, + 66996875, + 67100766, + 67204698, + 67308669, + 67412681, + 67516733, + 67620825, + 67724957, + 67829130, + 67933342, + 68037594, + 68141886, + 68246218, + 68350590, + 68455002, + 68559454, + 68663945, + 68768476, + 68873047, + 68977658, + 69082308, + 69186998, + 69291728, + 69396497, + 69501306, + 69606154, + 69711042, + 69815969, + 69920936, + 70025942, + 70130987, + 70236072, + 70341196, + 70446360, + 70551562, + 70656804, + 70762085, + 70867406, + 70972765, + 71078164, + 71183601, + 71289078, + 71394594, + 71500149, + 71605742, + 71711375, + 71817046, + 71922757, + 72028506, + 72134294, + 72240121, + 72345987, + 72451892, + 72557835, + 72663817, + 72769837, + 72875896, + 72981994, + 73088130, + 73194305, + 73300519, + 73406770, + 73513061, + 73619390, + 73725757, + 73832162, + 73938606, + 74045088, + 74151609, + 74258168, + 74364765, + 74471400, + 74578073, + 74684785, + 74791535, + 74898323, + 75005149, + 75112012, + 75218914, + 75325854, + 75432832, + 75539848, + 75646902, + 75753994, + 75861123, + 75968291, + 76075496, + 76182739, + 76290020, + 76397338, + 76504694, + 76612088, + 76719520, + 76826989, + 76934495, + 77042040, + 77149622, + 77257241, + 77364898, + 77472592, + 77580324, + 77688093, + 77795899, + 77903743, + 78011625, + 78119543, + 78227499, + 78335492, + 78443522, + 78551590, + 78659695, + 78767836, + 78876015, + 78984232, + 79092485, + 79200775, + 79309102, + 79417467, + 79525868, + 79634306, + 79742781, + 79851293, + 79959842, + 80068428, + 80177050, + 80285710, + 80394406, + 80503139, + 80611908, + 80720715, + 80829558, + 80938438, + 81047354, + 81156307, + 81265296, + 81374322, + 81483385, + 81592484, + 81701620, + 81810792, + 81920000, + 82029245, + 82138526, + 82247844, + 82357198, + 82466588, + 82576014, + 82685477, + 82794976, + 82904512, + 83014083, + 83123691, + 83233334, + 83343014, + 83452730, + 83562482, + 83672271, + 83782095, + 83891955, + 84001851, + 84111783, + 84221751, + 84331755, + 84441795}; + +static 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, + WORD32 arith_reset_flag, + WORD8 *ptr_scratch) { + WORD32 i, k; + FLOAT32 ratio; + WORD8 *c_prev_tmp = ptr_scratch; + WORD8 *c_tmp = ptr_scratch + 516; + + if (arith_reset_flag) { + for (i = 0; i < (1024 / 2) + 4; i++) { + c_prev[i] = 0; + c[i] = 0; + } + + } else { + for (i = 2; i < (prev_n / 2 + 4); i++) { + c_prev_tmp[i] = c_prev[i]; + c_tmp[i] = c[i]; + } + + ratio = (FLOAT32)(prev_n) / (FLOAT32)(pres_n); + for (i = 0; i < (pres_n / 2); i++) { + k = (WORD32)((FLOAT32)(i)*ratio); + c_prev[2 + i] = c_prev_tmp[2 + k]; + c[2 + i] = c_tmp[2 + k]; + } + c_prev[(pres_n / 2) + 2] = c_prev_tmp[(prev_n / 2) + 2]; + c[(pres_n / 2) + 3] = c_tmp[(prev_n / 2) + 3]; + } +} + +VOID ixheaacd_copy_to_bitbuff(ia_bit_buf_struct *it_bit_buff_src, + ia_bit_buf_struct *it_bit_buff_dst) { + it_bit_buff_dst->ptr_bit_buf_base = it_bit_buff_src->ptr_bit_buf_base; + it_bit_buff_dst->ptr_bit_buf_end = it_bit_buff_src->ptr_bit_buf_end; + + it_bit_buff_dst->ptr_read_next = it_bit_buff_src->ptr_read_next; + + it_bit_buff_dst->bit_pos = it_bit_buff_src->bit_pos; + it_bit_buff_dst->cnt_bits = it_bit_buff_src->cnt_bits; + + it_bit_buff_dst->size = it_bit_buff_src->size; +} + +static WORD32 ixheaacd_arith_get_context(WORD8 *c_prev, WORD8 *c_pres, + WORD32 *c, WORD32 i) { + WORD32 tmp = (WORD32)c_prev[1] << 12; + + *c = *c >> 4; + *c = *c + tmp; + *c = (*c & 0xFFF0) + c_pres[-1]; + + if (i > 3) { + if ((c_pres[-1] + c_pres[-2] + c_pres[-3]) < 5) { + return (*c + 0x10000); + } + } + + return (*c); +} + +static WORD32 ixheaacd_arith_first_symbol(ia_bit_buf_struct *it_bit_buff, + state_arith *s) { + register WORD32 val; + + WORD32 bit_count = 16; + + val = 0; + val = ixheaacd_read_bits_buf(it_bit_buff, 16); + + s->low = 0; + s->high = 65535; + s->value = val; + + return bit_count; +} + +static UWORD32 ixheaacd_arith_get_pk(UWORD32 c) { + UWORD32 j; + WORD32 i, i_min, i_max; + + i_min = -1; + i = i_min; + i_max = 742 - 1; + while ((i_max - i_min) > 1) { + i = i_min + ((i_max - i_min) >> 1); + j = ixheaacd_ari_hash_m[i]; + if (c < j) + i_max = i; + else if (c > j) + i_min = i; + else + return (UWORD32)ixheaacd_ari_hash_m_1[i]; + } + + return (ixheaacd_ari_lookup_m[i_max]); +} + +static WORD32 ixheaacd_arith_decode(ia_bit_buf_struct *it_bit_buff, + WORD32 bit_count, WORD32 *m, state_arith *s, + UWORD16 const *cum_freq, WORD32 cfl) { + register WORD32 symbol; + register WORD32 low, high, range, value; + register WORD32 cum; + register UWORD16 const *p; + register UWORD16 const *q; + + low = s->low; + high = s->high; + value = s->value; + + range = high - low + 1; + cum = ((((WORD32)(value - low + 1)) << 14) - ((WORD32)1)) / ((WORD32)range); + + p = cum_freq - 1; + + do { + q = p + (cfl >> 1); + + if (*q > cum) { + p = q; + cfl++; + } + cfl >>= 1; + } while (cfl > 1); + + symbol = p - cum_freq + 1; + + if (symbol) high = low + ((range * cum_freq[symbol - 1]) >> 14) - 1; + + low += ((range * cum_freq[symbol]) >> 14); + + for (;;) { + if (high < 32768) { + } else if (low >= 32768) { + value -= 32768; + low -= 32768; + high -= 32768; + } else if (low >= 16384 && high < 49152) { + value -= 16384; + low -= 16384; + high -= 16384; + } else + break; + + low += low; + high += high + 1; + + value = (value << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); + bit_count++; + } + + s->low = low; + s->high = high; + s->value = value; + + *m = symbol; + + return bit_count; +} + +WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, + WORD8 *c_prev, WORD8 *c_pres, WORD32 n, + WORD32 pres_n, WORD32 *quant) { + state_arith as; + WORD32 a, b; + WORD32 i, j, lev, pki, esc_nb; + WORD32 m; + WORD32 c = 0; + struct ia_bit_buf_struct it_bit_buff_temp; + WORD32 bit_count = 0; + WORD32 s1; + WORD32 temp; + WORD32 bit_count_5; + ixheaacd_copy_to_bitbuff(it_bit_buff, &it_bit_buff_temp); + + for (i = 0; i < pres_n; i++) { + c_prev[i] = c_pres[i]; + c_pres[i] = 1; + } + + bit_count = ixheaacd_arith_first_symbol(&it_bit_buff_temp, &as); + + c = (WORD32)c_prev[0] << 12; + lev = 0; + + for (i = 0; i < n; i++) { + s1 = ixheaacd_arith_get_context(c_prev + i, c_pres + i, &c, i); + + for (lev = esc_nb = 0;;) { + pki = ixheaacd_arith_get_pk(s1 + ixheaacd_esc_nb_offset[esc_nb]); + bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as, + ixheaacd_ari_cf_m[pki], 17); + + if (m < ARITH_ESCAPE) { + break; + } + + lev += 1; + esc_nb = lev; + + if (esc_nb > 7) { + esc_nb = 7; + } + } + + if (m == 0) { + if (esc_nb > 0) break; + + quant[2 * i + 0] = 0; + quant[2 * i + 1] = 0; + c_pres[i] = 1; + } else { + b = m >> 2; + a = m & 0x3; + + for (j = 0; j < lev; j++) { + WORD32 lsbidx = (a == 0) ? 1 : ((b == 0) ? 0 : 2); + bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as, + ixheaacd_ari_cf_r[lsbidx], 4); + + a = (a << 1) | (m & 1); + b = (b << 1) | ((m >> 1) & 1); + } + quant[2 * i + 0] = a; + quant[2 * i + 1] = b; + temp = a + b + 1; + c_pres[i] = (WORD8)temp; + if (temp > 0xF) { + c_pres[i] = 0xF; + } + } + } + + bit_count -= 16 - 2; + + 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); + } + + for (i = 0; i < pres_n; i++) { + WORD32 temp0 = quant[0]; + WORD32 temp1 = quant[1]; + if (temp0) { + m = ixheaacd_read_bits_buf(it_bit_buff, 1); + bit_count++; + + m = (m << 1) * temp0; + temp0 = m - (temp0); + } + + if (temp1) { + m = ixheaacd_read_bits_buf(it_bit_buff, 1); + bit_count++; + + m = (m << 1) * temp1; + temp1 = m - (temp1); + } + *quant++ = temp0; + *quant++ = temp1; + } + return 0; +} + +static WORD32 ixheaacd_randomsign_fix(UWORD32 *seed) { + WORD32 sign = 0; + *seed = (UWORD32)(((UWORD64)(*seed) * (UWORD64)69069) + 5); + if (((*seed) & 0x10000) > 0) { + sign = -1; + } else { + sign = +1; + } + return sign; +} + +static VOID ixheaacd_esc_iquant(WORD32 *q, WORD32 *coef, WORD32 noise_level, + WORD32 with_noise, UWORD32 *seed_value, + WORD32 length, WORD64 fac_fix) { + WORD32 q1 = 0; + WORD64 temp; + WORD16 interp; + WORD32 i; + WORD16 flag; + + for (i = 0; i < length; i++) { + flag = 1; + + if (with_noise) { + if (q[i] == 0) { + coef[i] = (ixheaacd_randomsign_fix(seed_value) * noise_level); + temp = (fac_fix * coef[i]); + coef[i] = (WORD32)(temp >> 25); + continue; + } + } + + if (q[i] >= 8192) { + q[i] = 8191; + } + + if (q[i] < 0) { + flag = -1; + q[i] = -q[i]; + } + + if (q[i] < 1024) { + coef[i] = flag * ixheaacd_pow_table_Q13[q[i]]; + } else { + q1 = (q[i]) >> 3; + + interp = q[i] - (q1 << 3); + + coef[i] = ixheaacd_pow_table_Q13[q1 + 1] - ixheaacd_pow_table_Q13[q1]; + + coef[i] = (WORD32)(coef[i] * (WORD32)interp); + + coef[i] = coef[i] + (ixheaacd_pow_table_Q13[q1] << 3); + + coef[i] = flag * (coef[i] << 1); + } + temp = (fac_fix * coef[i]); + + coef[i] = (WORD32)(temp >> 22); + } + + return; +} + +static void ixheaacd_apply_scfs_and_nf(WORD32 noise_filling, + ia_usac_data_struct *usac_data, + WORD32 *quant, WORD32 noise_level, + WORD32 noise_offset, UWORD8 max_sfb, + WORD32 ch) { + WORD32 grp = 0, win_tot = 0, sfb = 0; + WORD32 noise_filling_start_offset = 0; + WORD32 fac = 0, length = 0; + WORD64 fac_fix; + WORD32 noise_level_fix = 0; + ia_sfb_info_struct *pstr_sfb_info = usac_data->pstr_sfb_info[ch]; + WORD32 *coef = &usac_data->coef_fix[ch][0]; + WORD16 *factors = usac_data->factors[ch]; + UWORD32 *seed_value = &usac_data->seed_value[ch]; + + if (noise_filling) { + noise_level_fix = ixheaacd_pow_14_3[noise_level]; + noise_filling_start_offset = (usac_data->ccfl == 768) + ? (pstr_sfb_info->islong ? 120 : 15) + : (pstr_sfb_info->islong ? 160 : 20); + } + + for (grp = 0; grp < pstr_sfb_info->num_groups; grp++) { + WORD32 grp_win = 0; + for (sfb = 0; sfb < (WORD32)max_sfb; sfb++) { + WORD32 noise_filling_present = 0; + WORD32 band_quantized_to_zero = 1; + + WORD32 sfb_offset = win_tot * pstr_sfb_info->sfb_per_sbk; + fac = (WORD32)(factors[sfb_offset + sfb] - SF_OFFSET); + + if (noise_filling) { + for (grp_win = 0; grp_win < pstr_sfb_info->group_len[grp]; grp_win++) { + WORD32 win = grp_win + win_tot; + WORD32 ixheaacd_drc_offset = win * pstr_sfb_info->bins_per_sbk; + WORD32 start = (sfb == 0) ? 0 : pstr_sfb_info->ptr_sfb_tbl[sfb - 1]; + WORD32 idx = 0; + for (idx = start; idx < pstr_sfb_info->ptr_sfb_tbl[sfb]; idx++) { + if (quant[ixheaacd_drc_offset + idx] != 0) { + band_quantized_to_zero = 0; + break; + } + if (!band_quantized_to_zero) break; + } + } + } + + if (band_quantized_to_zero && noise_filling) fac += (noise_offset - 16); + { + WORD16 exp, frac; + + exp = fac >> 2; + frac = fac & 3; + + if (exp > 31) exp = 31; + + if (fac < 0) + fac_fix = 0; + else { + fac_fix = (WORD64)((WORD64)ixheaacd_table_frac[3 + frac] * + (WORD64)ixheaacd_table_exp[exp]); + fac_fix >>= 15; + } + } + + for (grp_win = 0; grp_win < pstr_sfb_info->group_len[grp]; grp_win++) { + WORD32 win = win_tot + grp_win; + WORD32 start = (sfb == 0) ? 0 : pstr_sfb_info->ptr_sfb_tbl[sfb - 1]; + WORD32 ixheaacd_drc_offset = win * pstr_sfb_info->bins_per_sbk; + + if (noise_filling) { + noise_filling_present = + (start >= noise_filling_start_offset) & noise_filling; + } + + length = pstr_sfb_info->ptr_sfb_tbl[sfb] - start; + + ixheaacd_esc_iquant(&quant[ixheaacd_drc_offset + start], + &coef[ixheaacd_drc_offset + start], noise_level_fix, + noise_filling_present, seed_value, length, fac_fix); + } + } + + win_tot += pstr_sfb_info->group_len[grp]; + } + + return; +} + +WORD32 ixheaacd_ac_spectral_data(ia_usac_data_struct *usac_data, + WORD32 max_spec_coefficients, + WORD32 noise_level, WORD32 noise_offset, + WORD32 arith_pres_n, + ia_bit_buf_struct *it_bit_buff, UWORD8 max_sfb, + WORD32 arith_reset_flag, WORD32 noise_filling, + WORD32 ch) { + WORD32 i; + + WORD32 *x_ac_dec = usac_data->x_ac_dec; + WORD32 sbk; + WORD32 err_code = 0; + + const WORD32 max_win_len = usac_data->pstr_sfb_info[ch]->max_win_len; + WORD8 *c_prev = &usac_data->c_prev[ch][0]; + WORD8 *c_pres = &usac_data->c[ch][0]; + + WORD8 *ptr_scratch_buf = (WORD8 *)&usac_data->scratch_buffer[0]; + + memset(x_ac_dec, 0, 1024 * sizeof(WORD32)); + + ixheaacd_arith_map_context(arith_pres_n, usac_data->arith_prev_n[ch], c_prev, + c_pres, arith_reset_flag, ptr_scratch_buf); + + usac_data->arith_prev_n[ch] = arith_pres_n; + + if (max_spec_coefficients > 0) { + for (sbk = 0; sbk < max_win_len; sbk++) { + err_code = ixheaacd_arth_decoding_level2( + it_bit_buff, c_prev + 2, c_pres + 2, max_spec_coefficients / 2, + arith_pres_n / 2, &x_ac_dec[sbk * arith_pres_n]); + if (err_code != 0) { + return err_code; + } + + for (i = max_spec_coefficients / 2; i < arith_pres_n / 2; i++) { + x_ac_dec[sbk * arith_pres_n + 2 * i + 0] = 0; + x_ac_dec[sbk * arith_pres_n + 2 * i + 1] = 0; + } + } + } else { + for (i = 0; i < (arith_pres_n / 2); i++) { + c_pres[i + 2] = 1; + } + } + + ixheaacd_apply_scfs_and_nf(noise_filling, usac_data, x_ac_dec, noise_level, + noise_offset, max_sfb, ch); + + return 0; +} + +WORD32 ixheaacd_arith_data(ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 *x_ac_dec, ia_usac_data_struct *usac_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 first_tcx_flag, WORD32 k) { + WORD32 *arith_prev_n = &usac_data->arith_prev_n[usac_data->present_chan]; + WORD32 arith_reset_flag = + first_tcx_flag && pstr_td_frame_data->arith_reset_flag; + WORD32 err_code = 0; + WORD32 tcx_size = pstr_td_frame_data->tcx_lg[k]; + WORD8 *c_prev = usac_data->c_prev[usac_data->present_chan]; + WORD8 *c_pres = usac_data->c[usac_data->present_chan]; + + WORD8 *ptr_scratch_buf = (WORD8 *)&usac_data->scratch_buffer[0]; + + memset(x_ac_dec, 0, tcx_size * sizeof(WORD32)); + + ixheaacd_arith_map_context(tcx_size, *arith_prev_n, c_prev, c_pres, + arith_reset_flag, ptr_scratch_buf); + + *arith_prev_n = tcx_size; + + err_code = + ixheaacd_arth_decoding_level2(it_bit_buff, c_prev + 2, c_pres + 2, + tcx_size / 2, tcx_size / 2, x_ac_dec); + + return err_code; +} diff --git a/decoder/ixheaacd_arith_dec.h b/decoder/ixheaacd_arith_dec.h new file mode 100644 index 0000000..9c58b06 --- /dev/null +++ b/decoder/ixheaacd_arith_dec.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ARITH_DEC_H +#define IXHEAACD_ARITH_DEC_H + +WORD32 ixheaacd_ac_spectral_data(ia_usac_data_struct *usac_data, + WORD32 max_spec_coefficients, + WORD32 noise_level, WORD32 noise_offset, + WORD32 arth_size, + ia_bit_buf_struct *it_bit_buff, UWORD8 max_sfb, + WORD32 reset, WORD32 noise_filling, WORD32 ch); + +WORD32 ixheaacd_arith_data(ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 *quant, ia_usac_data_struct *usac_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 first_tcx_flag, WORD32 k); + +#endif diff --git a/decoder/ixheaacd_audioobjtypes.h b/decoder/ixheaacd_audioobjtypes.h new file mode 100644 index 0000000..64d4ba8 --- /dev/null +++ b/decoder/ixheaacd_audioobjtypes.h @@ -0,0 +1,66 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_AUDIOOBJTYPES_H +#define IXHEAACD_AUDIOOBJTYPES_H + +typedef enum AUDIO_OBJECT_TYPE { + AOT_NULL_OBJECT = 0, + AOT_AAC_MAIN = 1, + AOT_AAC_LC = 2, + AOT_AAC_SSR = 3, + AOT_AAC_LTP = 4, + AOT_SBR = 5, + AOT_AAC_SCAL = 6, + AOT_TWIN_VQ = 7, + AOT_CELP = 8, + AOT_HVXC = 9, + AOT_RSVD_10 = 10, + AOT_RSVD_11 = 11, + + AOT_TTSI = 12, + AOT_MAIN_SYNTH = 13, + AOT_WAV_TAB_SYNTH = 14, + AOT_GEN_MIDI = 15, + AOT_ALG_SYNTH_AUD_FX = 16, + AOT_ER_AAC_LC = 17, + AOT_RSVD_18 = 18, + AOT_ER_AAC_LTP = 19, + AOT_ER_AAC_SCAL = 20, + AOT_ER_TWIN_VQ = 21, + AOT_ER_BSAC = 22, + AOT_ER_AAC_LD = 23, + AOT_ER_CELP = 24, + AOT_ER_HVXC = 25, + AOT_ER_HILN = 26, + AOT_ER_PARA = 27, + AOT_RSVD_28 = 28, + AOT_PS = 29, + AOT_RSVD_30 = 30, + AOT_RSVD_31 = 31, + AOT_ESC = 31, + AOT_ER_AAC_ELD = 39, + + AOT_USAC = 42 + +} AUDIO_OBJECT_TYPE; + +#define ER_OBJECT_START 17 + +#endif diff --git a/decoder/ixheaacd_avq_dec.c b/decoder/ixheaacd_avq_dec.c new file mode 100644 index 0000000..ac1824d --- /dev/null +++ b/decoder/ixheaacd_avq_dec.c @@ -0,0 +1,294 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include +#include +#include "ixheaacd_acelp_com.h" + +extern const WORD32 ixheaacd_factorial_7[8]; +extern const WORD32 ixheaacd_iso_code_index_table[LEN_ABS_LEADER]; +extern const UWORD8 ixheaacd_iso_code_data_table[LEN_ABS_LEADER]; +extern const UWORD32 ixheaacd_signed_leader_is[LEN_ABS_LEADER]; +extern const WORD32 ixheaacd_iso_code_num_table[], + ixheaacd_pos_abs_leaders_a3[], ixheaacd_pos_abs_leaders_a4[]; +extern const UWORD8 ixheaacd_absolute_leader_tab_da[][8]; +extern const UWORD32 ixheaacd_cardinality_offset_table_i3[], + ixheaacd_cardinality_offset_tab_i4[]; + +static VOID ixheaacd_nearest_neighbor_2d(WORD32 x[], WORD32 y[], WORD32 count, + WORD32 *rem) { + WORD32 i, j, sum; + WORD32 s, e[8], em; + WORD32 rem_temp[8]; + + memcpy(rem_temp, rem, 8 * sizeof(WORD32)); + + sum = 0; + for (i = 0; i < 8; i++) { + if (x[i] < 0) { + y[i] = -2 * (((WORD32)(1 - x[i])) >> 1); + } else { + y[i] = 2 * (((WORD32)(1 + x[i])) >> 1); + } + sum += y[i]; + + if (x[i] % 2 != 0) { + if (x[i] < 0) { + rem_temp[i] = -(rem_temp[i] - (1 << count)); + } else { + rem_temp[i] = rem_temp[i] - (1 << count); + } + } + } + + if (sum % 4) { + em = 0; + j = 0; + for (i = 0; i < 8; i++) { + e[i] = rem_temp[i]; + } + for (i = 0; i < 8; i++) { + if (e[i] < 0) { + s = -e[i]; + } else { + s = e[i]; + } + + if (em < s) { + em = s; + j = i; + } + } + + if (e[j] < 0) { + y[j] -= 2; + rem_temp[j] = rem_temp[j] + (2 << count); + } else { + y[j] += 2; + rem_temp[j] = rem_temp[j] - (2 << count); + } + } + + memcpy(rem, rem_temp, 8 * sizeof(WORD32)); + return; +} + +VOID ixheaacd_voronoi_search(WORD32 x[], WORD32 y[], WORD32 count, WORD32 *rem1, + WORD32 *rem2) { + WORD32 i, y0[8], y1[8]; + WORD32 e0, e1, x1[8], tmp; + + ixheaacd_nearest_neighbor_2d(x, y0, count, rem1); + for (i = 0; i < 8; i++) { + if (x[i] == 0) { + if (rem2[i] == 0) { + x1[i] = x[i] - 1; + } else { + x1[i] = 0; + rem2[i] = rem2[i] - (1 << count); + } + } else { + x1[i] = x[i] - 1; + } + } + + ixheaacd_nearest_neighbor_2d(x1, y1, count, rem2); + + for (i = 0; i < 8; i++) { + y1[i] += 1; + } + + e0 = e1 = 0; + for (i = 0; i < 8; i++) { + tmp = rem1[i]; + e0 += tmp * tmp; + tmp = rem2[i]; + e1 += tmp * tmp; + } + + if (e0 < e1) { + for (i = 0; i < 8; i++) { + y[i] = y0[i]; + } + } else { + for (i = 0; i < 8; i++) { + y[i] = y1[i]; + } + } + return; +} + +VOID ixheaacd_voronoi_idx_dec(WORD32 *kv, WORD32 m, WORD32 *y, WORD32 count) { + WORD32 i, v[8], tmp, sum, *ptr1, *ptr2; + WORD32 z[8]; + WORD32 rem1[8], rem2[8]; + + for (i = 0; i < 8; i++) y[i] = kv[7]; + + z[7] = y[7] >> count; + rem1[7] = y[7] & (m - 1); + sum = 0; + for (i = 6; i >= 1; i--) { + tmp = 2 * kv[i]; + sum += tmp; + y[i] += tmp; + z[i] = y[i] >> count; + rem1[i] = y[i] & (m - 1); + } + y[0] += (4 * kv[0] + sum); + z[0] = (y[0] - 2) >> count; + rem1[0] = (y[0] - 2) % m; + + memcpy(rem2, rem1, 8 * sizeof(WORD32)); + + ixheaacd_voronoi_search(z, v, count, rem1, rem2); + + ptr1 = y; + ptr2 = v; + for (i = 0; i < 8; i++) { + *ptr1++ -= m * *ptr2++; + } +} + +static VOID ixheaacd_gosset_rank_of_permutation(WORD32 rank, WORD32 *xs) { + WORD32 i, j, a[8], w[8], base, fac, fac_b, target; + + j = 0; + w[j] = 1; + a[j] = xs[0]; + base = 1; + for (i = 1; i < 8; i++) { + if (xs[i] != xs[i - 1]) { + j++; + w[j] = 1; + a[j] = xs[i]; + } else { + w[j]++; + base *= w[j]; + } + } + + if (w[0] == 8) { + for (i = 0; i < 8; i++) xs[i] = a[0]; + } else { + target = rank * base; + fac_b = 1; + + for (i = 0; i < 8; i++) { + fac = fac_b * ixheaacd_factorial_7[i]; + j = -1; + do { + target -= w[++j] * fac; + } while (target >= 0); + xs[i] = a[j]; + + target += w[j] * fac; + fac_b *= w[j]; + w[j]--; + } + } + + return; +} + +static WORD32 ixheaacd_get_abs_leader_tbl(const UWORD32 *table, + UWORD32 code_book_ind, WORD32 size) { + WORD32 i; + + for (i = 4; i < size; i += 4) { + if (code_book_ind < table[i]) break; + } + if (i > size) i = size; + + if (code_book_ind < table[i - 2]) i -= 2; + if (code_book_ind < table[i - 1]) i--; + i--; + + return (i); +} + +static VOID ixheaacd_gosset_decode_base_index(WORD32 n, UWORD32 code_book_ind, + WORD32 *ya) { + WORD32 i, im, t, sign_code, idx = 0, ks, rank; + + if (n < 2) { + for (i = 0; i < 8; i++) ya[i] = 0; + } else { + switch (n) { + case 2: + case 3: + i = ixheaacd_get_abs_leader_tbl(ixheaacd_cardinality_offset_table_i3, + code_book_ind, LEN_I3); + idx = ixheaacd_pos_abs_leaders_a3[i]; + break; + case 4: + i = ixheaacd_get_abs_leader_tbl(ixheaacd_cardinality_offset_tab_i4, + code_book_ind, LEN_I4); + idx = ixheaacd_pos_abs_leaders_a4[i]; + break; + } + + for (i = 0; i < 8; i++) ya[i] = ixheaacd_absolute_leader_tab_da[idx][i]; + + t = ixheaacd_iso_code_index_table[idx]; + im = ixheaacd_iso_code_num_table[idx]; + ks = ixheaacd_get_abs_leader_tbl(ixheaacd_signed_leader_is + t, + code_book_ind, im); + + sign_code = 2 * ixheaacd_iso_code_data_table[t + ks]; + for (i = 7; i >= 0; i--) { + ya[i] *= (1 - (sign_code & 2)); + sign_code >>= 1; + } + + rank = code_book_ind - ixheaacd_signed_leader_is[t + ks]; + + ixheaacd_gosset_rank_of_permutation(rank, ya); + } + return; +} + +VOID ixheaacd_rotated_gosset_mtx_dec(WORD32 qn, WORD32 code_book_idx, + WORD32 *kv, WORD32 *b) { + WORD32 i, m, c[8]; + WORD32 count = 0; + + if (qn <= 4) { + ixheaacd_gosset_decode_base_index(qn, code_book_idx, b); + } else { + m = 1; + while (qn > 4) { + m *= 2; + count++; + qn -= 2; + } + + ixheaacd_gosset_decode_base_index(qn, code_book_idx, b); + + ixheaacd_voronoi_idx_dec(kv, m, c, count); + + for (i = 0; i < 8; i++) b[i] = m * b[i] + c[i]; + } + return; +} diff --git a/decoder/ixheaacd_avq_rom.c b/decoder/ixheaacd_avq_rom.c new file mode 100644 index 0000000..af2b803 --- /dev/null +++ b/decoder/ixheaacd_avq_rom.c @@ -0,0 +1,1227 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_acelp_com.h" +#include "ixheaacd_cnst.h" + +const WORD32 ixheaacd_factorial_7[8] = {5040, 720, 120, 24, 6, 2, 1, 1}; + +const UWORD8 ixheaacd_absolute_leader_tab_da[LEN_ABS_LEADER][8] = { + {1, 1, 1, 1, 1, 1, 1, 1}, {2, 2, 0, 0, 0, 0, 0, 0}, + {2, 2, 2, 2, 0, 0, 0, 0}, {3, 1, 1, 1, 1, 1, 1, 1}, + {4, 0, 0, 0, 0, 0, 0, 0}, {2, 2, 2, 2, 2, 2, 0, 0}, + {3, 3, 1, 1, 1, 1, 1, 1}, {4, 2, 2, 0, 0, 0, 0, 0}, + {2, 2, 2, 2, 2, 2, 2, 2}, {3, 3, 3, 1, 1, 1, 1, 1}, + {4, 2, 2, 2, 2, 0, 0, 0}, {4, 4, 0, 0, 0, 0, 0, 0}, + {5, 1, 1, 1, 1, 1, 1, 1}, {3, 3, 3, 3, 1, 1, 1, 1}, + {4, 2, 2, 2, 2, 2, 2, 0}, {4, 4, 2, 2, 0, 0, 0, 0}, + {5, 3, 1, 1, 1, 1, 1, 1}, {6, 2, 0, 0, 0, 0, 0, 0}, + {4, 4, 4, 0, 0, 0, 0, 0}, {6, 2, 2, 2, 0, 0, 0, 0}, + {6, 4, 2, 0, 0, 0, 0, 0}, {7, 1, 1, 1, 1, 1, 1, 1}, + {8, 0, 0, 0, 0, 0, 0, 0}, {6, 6, 0, 0, 0, 0, 0, 0}, + {8, 2, 2, 0, 0, 0, 0, 0}, {8, 4, 0, 0, 0, 0, 0, 0}, + {9, 1, 1, 1, 1, 1, 1, 1}, {10, 2, 0, 0, 0, 0, 0, 0}, + {8, 8, 0, 0, 0, 0, 0, 0}, {10, 6, 0, 0, 0, 0, 0, 0}, + {12, 0, 0, 0, 0, 0, 0, 0}, {12, 4, 0, 0, 0, 0, 0, 0}, + {10, 10, 0, 0, 0, 0, 0, 0}, {14, 2, 0, 0, 0, 0, 0, 0}, + {12, 8, 0, 0, 0, 0, 0, 0}, {16, 0, 0, 0, 0, 0, 0, 0}, + {20, 0, 0, 0, 0, 0, 0, 0}}; + +const UWORD8 ixheaacd_iso_code_data_table[LEN_SIGN_LEADER] = { + 0, 3, 15, 63, 255, 0, 64, 192, 0, 16, 48, 112, 240, 1, 7, + 31, 127, 128, 131, 143, 191, 0, 128, 0, 4, 12, 28, 60, 124, 252, + 0, 3, 15, 63, 65, 71, 95, 192, 195, 207, 255, 0, 32, 96, 128, + 160, 224, 0, 1, 3, 7, 15, 31, 63, 127, 255, 1, 7, 31, 32, + 35, 47, 97, 103, 127, 224, 227, 239, 0, 8, 24, 56, 120, 128, 136, + 152, 184, 248, 0, 64, 192, 0, 3, 15, 63, 129, 135, 159, 255, 0, + 3, 15, 17, 23, 48, 51, 63, 113, 119, 240, 243, 255, 0, 2, 6, + 14, 30, 62, 126, 128, 130, 134, 142, 158, 190, 254, 0, 16, 48, 64, + 80, 112, 192, 208, 240, 1, 7, 31, 64, 67, 79, 127, 128, 131, 143, + 191, 193, 199, 223, 0, 64, 128, 192, 0, 32, 96, 224, 0, 16, 48, + 112, 128, 144, 176, 240, 0, 32, 64, 96, 128, 160, 192, 224, 1, 7, + 31, 127, 128, 131, 143, 191, 0, 128, 0, 64, 192, 0, 32, 96, 128, + 160, 224, 0, 64, 128, 192, 0, 3, 15, 63, 129, 135, 159, 255, 0, + 64, 128, 192, 0, 64, 192, 0, 64, 128, 192, 0, 128, 0, 64, 128, + 192, 0, 64, 192, 0, 64, 128, 192, 0, 64, 128, 192, 0, 128, 0, + 128}; + +const WORD32 ixheaacd_iso_code_num_table[LEN_ABS_LEADER] = { + 5, 3, 5, 8, 2, 7, 11, 6, 9, 12, 10, 3, 8, 13, 14, 9, 14, 4, 4, + 8, 8, 8, 2, 3, 6, 4, 8, 4, 3, 4, 2, 4, 3, 4, 4, 2, 2}; + +const WORD32 ixheaacd_iso_code_index_table[LEN_ABS_LEADER] = { + 0, 5, 8, 13, 21, 23, 30, 41, 47, 56, 68, 78, 81, + 89, 102, 116, 125, 139, 143, 147, 155, 163, 171, 173, 176, 182, + 186, 194, 198, 201, 205, 207, 211, 214, 218, 222, 224}; + +const UWORD32 ixheaacd_signed_leader_is[LEN_SIGN_LEADER] = { + 0, 1, 29, 99, 127, 128, 156, 212, 256, 326, 606, + 1026, 1306, 1376, 1432, 1712, 1880, 1888, 1896, 2064, 2344, 240, + 248, 0, 28, 196, 616, 1176, 1596, 1764, 1792, 1820, 2240, + 2660, 2688, 3024, 4144, 4480, 4508, 4928, 5348, 2400, 2568, 2904, + 3072, 3240, 3576, 5376, 5377, 5385, 5413, 5469, 5539, 5595, 5623, + 5631, 5632, 5912, 6472, 6528, 6696, 8376, 9216, 10056, 11736, 11904, + 11960, 12520, 12800, 13080, 14200, 15880, 17000, 17280, 17560, 18680, 20360, + 21480, 3744, 3772, 3828, 21760, 21768, 21936, 22216, 22272, 22328, 22608, + 22776, 22784, 22854, 23274, 23344, 24464, 25584, 26004, 28524, 28944, 30064, + 31184, 31254, 31674, 31744, 31800, 32136, 32976, 34096, 34936, 35272, 35328, + 35384, 35720, 36560, 37680, 38520, 38856, 38912, 39332, 40172, 40592, 41432, + 43112, 43952, 44372, 45212, 45632, 45968, 47088, 47424, 47480, 48320, 49160, + 49216, 49272, 50112, 50952, 51008, 51344, 52464, 3856, 3912, 3968, 4024, + 52800, 52856, 53024, 53192, 53248, 53528, 54368, 55208, 55488, 55768, 56608, + 57448, 57728, 58064, 58400, 58736, 59072, 59408, 59744, 60080, 60416, 60472, + 60752, 60920, 60928, 60936, 61104, 61384, 4080, 4088, 61440, 61468, 61524, + 61552, 61720, 62056, 62224, 62392, 62728, 62896, 62952, 63008, 63064, 63120, + 63128, 63296, 63576, 63632, 63688, 63968, 64136, 64144, 64200, 64256, 64312, + 64368, 64396, 64452, 64480, 64536, 64592, 64648, 64704, 64712, 64720, 64776, + 64832, 64888, 64944, 64972, 65028, 65056, 65112, 65168, 65224, 65280, 65336, + 65392, 65448, 65504, 65512, 65520, 65528}; + +const WORD32 ixheaacd_pos_abs_leaders_a3[LEN_I3] = {0, 1, 4, 2, 3, + 7, 11, 17, 22}; + +const WORD32 ixheaacd_pos_abs_leaders_a4[LEN_I4] = { + 5, 6, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}; + +const UWORD32 ixheaacd_cardinality_offset_table_i3[LEN_I3] = { + 0, 128, 240, 256, 1376, 2400, 3744, 3856, 4080}; + +const UWORD32 ixheaacd_cardinality_offset_tab_i4[LEN_I4] = { + 0, 1792, 5376, 5632, 12800, 21760, 22784, 31744, 38912, 45632, + 52800, 53248, 57728, 60416, 61440, 61552, 62896, 63120, 64144, 64368, + 64480, 64704, 64720, 64944, 65056, 65280, 65504, 65520}; + +const FLOAT32 ixheaacd_sine_window96[96] = { + 0.008181F, 0.024541F, 0.040895F, 0.057237F, 0.073565F, 0.089872F, 0.106156F, + 0.122411F, 0.138633F, 0.154818F, 0.170962F, 0.187060F, 0.203108F, 0.219101F, + 0.235036F, 0.250908F, 0.266713F, 0.282446F, 0.298104F, 0.313682F, 0.329176F, + 0.344581F, 0.359895F, 0.375112F, 0.390229F, 0.405241F, 0.420145F, 0.434936F, + 0.449611F, 0.464166F, 0.478596F, 0.492898F, 0.507068F, 0.521103F, 0.534998F, + 0.548749F, 0.562354F, 0.575808F, 0.589108F, 0.602251F, 0.615232F, 0.628048F, + 0.640696F, 0.653173F, 0.665475F, 0.677598F, 0.689541F, 0.701298F, 0.712868F, + 0.724247F, 0.735432F, 0.746420F, 0.757209F, 0.767795F, 0.778175F, 0.788346F, + 0.798307F, 0.808054F, 0.817585F, 0.826897F, 0.835987F, 0.844854F, 0.853494F, + 0.861906F, 0.870087F, 0.878035F, 0.885748F, 0.893224F, 0.900461F, 0.907457F, + 0.914210F, 0.920718F, 0.926979F, 0.932993F, 0.938756F, 0.944269F, 0.949528F, + 0.954533F, 0.959283F, 0.963776F, 0.968011F, 0.971987F, 0.975702F, 0.979156F, + 0.982349F, 0.985278F, 0.987943F, 0.990344F, 0.992480F, 0.994350F, 0.995953F, + 0.997290F, 0.998361F, 0.999163F, 0.999699F, 0.999967F}; + +const FLOAT32 ixheaacd_sine_window128[128] = { + 0.006136F, 0.018407F, 0.030675F, 0.042938F, 0.055195F, 0.067444F, 0.079682F, + 0.091909F, 0.104122F, 0.116319F, 0.128498F, 0.140658F, 0.152797F, 0.164913F, + 0.177004F, 0.189069F, 0.201105F, 0.213110F, 0.225084F, 0.237024F, 0.248928F, + 0.260794F, 0.272621F, 0.284408F, 0.296151F, 0.307850F, 0.319502F, 0.331106F, + 0.342661F, 0.354164F, 0.365613F, 0.377007F, 0.388345F, 0.399624F, 0.410843F, + 0.422000F, 0.433094F, 0.444122F, 0.455084F, 0.465977F, 0.476799F, 0.487550F, + 0.498228F, 0.508830F, 0.519356F, 0.529804F, 0.540172F, 0.550458F, 0.560662F, + 0.570781F, 0.580814F, 0.590760F, 0.600617F, 0.610383F, 0.620057F, 0.629638F, + 0.639124F, 0.648514F, 0.657807F, 0.667000F, 0.676093F, 0.685084F, 0.693971F, + 0.702755F, 0.711432F, 0.720003F, 0.728464F, 0.736817F, 0.745058F, 0.753187F, + 0.761202F, 0.769103F, 0.776888F, 0.784557F, 0.792107F, 0.799537F, 0.806848F, + 0.814036F, 0.821103F, 0.828045F, 0.834863F, 0.841555F, 0.848120F, 0.854558F, + 0.860867F, 0.867046F, 0.873095F, 0.879012F, 0.884797F, 0.890449F, 0.895966F, + 0.901349F, 0.906596F, 0.911706F, 0.916679F, 0.921514F, 0.926210F, 0.930767F, + 0.935184F, 0.939459F, 0.943593F, 0.947586F, 0.951435F, 0.955141F, 0.958703F, + 0.962121F, 0.965394F, 0.968522F, 0.971504F, 0.974339F, 0.977028F, 0.979570F, + 0.981964F, 0.984210F, 0.986308F, 0.988258F, 0.990058F, 0.991710F, 0.993212F, + 0.994565F, 0.995767F, 0.996820F, 0.997723F, 0.998476F, 0.999078F, 0.999529F, + 0.999831F, 0.999981F}; + +const FLOAT32 ixheaacd_sine_window192[192] = { + + 0.004091F, 0.012272F, 0.020452F, 0.028630F, 0.036807F, 0.044982F, 0.053153F, + 0.061321F, 0.069484F, 0.077643F, 0.085797F, 0.093945F, 0.102087F, 0.110222F, + 0.118350F, 0.126469F, 0.134581F, 0.142683F, 0.150776F, 0.158858F, 0.166930F, + 0.174991F, 0.183040F, 0.191077F, 0.199101F, 0.207111F, 0.215108F, 0.223091F, + 0.231058F, 0.239010F, 0.246946F, 0.254866F, 0.262768F, 0.270653F, 0.278520F, + 0.286368F, 0.294197F, 0.302006F, 0.309795F, 0.317563F, 0.325310F, 0.333036F, + 0.340739F, 0.348419F, 0.356076F, 0.363709F, 0.371317F, 0.378901F, 0.386459F, + 0.393992F, 0.401498F, 0.408978F, 0.416430F, 0.423854F, 0.431249F, 0.438616F, + 0.445954F, 0.453261F, 0.460539F, 0.467785F, 0.475000F, 0.482184F, 0.489335F, + 0.496453F, 0.503538F, 0.510590F, 0.517607F, 0.524590F, 0.531537F, 0.538449F, + 0.545325F, 0.552164F, 0.558967F, 0.565732F, 0.572459F, 0.579148F, 0.585798F, + 0.592409F, 0.598980F, 0.605511F, 0.612002F, 0.618451F, 0.624859F, 0.631226F, + 0.637550F, 0.643832F, 0.650070F, 0.656265F, 0.662416F, 0.668522F, 0.674584F, + 0.680601F, 0.686572F, 0.692497F, 0.698376F, 0.704208F, 0.709993F, 0.715731F, + 0.721420F, 0.727062F, 0.732654F, 0.738198F, 0.743692F, 0.749136F, 0.754531F, + 0.759874F, 0.765167F, 0.770409F, 0.775599F, 0.780737F, 0.785823F, 0.790857F, + 0.795837F, 0.800764F, 0.805638F, 0.810457F, 0.815223F, 0.819933F, 0.824589F, + 0.829190F, 0.833735F, 0.838225F, 0.842658F, 0.847035F, 0.851355F, 0.855618F, + 0.859824F, 0.863973F, 0.868063F, 0.872096F, 0.876070F, 0.879986F, 0.883842F, + 0.887640F, 0.891378F, 0.895056F, 0.898674F, 0.902233F, 0.905731F, 0.909168F, + 0.912544F, 0.915860F, 0.919114F, 0.922306F, 0.925437F, 0.928506F, 0.931513F, + 0.934457F, 0.937339F, 0.940158F, 0.942914F, 0.945607F, 0.948237F, 0.950803F, + 0.953306F, 0.955745F, 0.958120F, 0.960431F, 0.962677F, 0.964859F, 0.966976F, + 0.969029F, 0.971017F, 0.972940F, 0.974798F, 0.976590F, 0.978317F, 0.979979F, + 0.981575F, 0.983105F, 0.984570F, 0.985969F, 0.987301F, 0.988568F, 0.989768F, + 0.990903F, 0.991970F, 0.992972F, 0.993907F, 0.994775F, 0.995577F, 0.996313F, + 0.996981F, 0.997583F, 0.998118F, 0.998586F, 0.998988F, 0.999322F, 0.999590F, + 0.999791F, 0.999925F, 0.999992F}; + +const FLOAT32 ixheaacd__sine_window256[256] = { + 0.00306796F, 0.00920375F, 0.01533921F, 0.02147408F, 0.02760815F, + 0.03374117F, 0.03987293F, 0.04600318F, 0.05213170F, 0.05825826F, + 0.06438263F, 0.07050457F, 0.07662386F, 0.08274026F, 0.08885355F, + 0.09496350F, 0.10106986F, 0.10717242F, 0.11327095F, 0.11936521F, + 0.12545498F, 0.13154003F, 0.13762012F, 0.14369503F, 0.14976453F, + 0.15582840F, 0.16188639F, 0.16793829F, 0.17398387F, 0.18002290F, + 0.18605515F, 0.19208040F, 0.19809841F, 0.20410897F, 0.21011184F, + 0.21610680F, 0.22209362F, 0.22807208F, 0.23404196F, 0.24000302F, + 0.24595505F, 0.25189782F, 0.25783110F, 0.26375468F, 0.26966833F, + 0.27557182F, 0.28146494F, 0.28734746F, 0.29321916F, 0.29907983F, + 0.30492923F, 0.31076715F, 0.31659338F, 0.32240768F, 0.32820984F, + 0.33399965F, 0.33977688F, 0.34554132F, 0.35129276F, 0.35703096F, + 0.36275572F, 0.36846683F, 0.37416406F, 0.37984721F, 0.38551605F, + 0.39117038F, 0.39680999F, 0.40243465F, 0.40804416F, 0.41363831F, + 0.41921689F, 0.42477968F, 0.43032648F, 0.43585708F, 0.44137127F, + 0.44686884F, 0.45234959F, 0.45781330F, 0.46325978F, 0.46868882F, + 0.47410021F, 0.47949376F, 0.48486925F, 0.49022648F, 0.49556526F, + 0.50088538F, 0.50618665F, 0.51146885F, 0.51673180F, 0.52197529F, + 0.52719913F, 0.53240313F, 0.53758708F, 0.54275078F, 0.54789406F, + 0.55301671F, 0.55811853F, 0.56319934F, 0.56825895F, 0.57329717F, + 0.57831380F, 0.58330865F, 0.58828155F, 0.59323230F, 0.59816071F, + 0.60306660F, 0.60794978F, 0.61281008F, 0.61764731F, 0.62246128F, + 0.62725182F, 0.63201874F, 0.63676186F, 0.64148101F, 0.64617601F, + 0.65084668F, 0.65549285F, 0.66011434F, 0.66471098F, 0.66928259F, + 0.67382900F, 0.67835004F, 0.68284555F, 0.68731534F, 0.69175926F, + 0.69617713F, 0.70056879F, 0.70493408F, 0.70927283F, 0.71358487F, + 0.71787005F, 0.72212819F, 0.72635916F, 0.73056277F, 0.73473888F, + 0.73888732F, 0.74300795F, 0.74710061F, 0.75116513F, 0.75520138F, + 0.75920919F, 0.76318842F, 0.76713891F, 0.77106052F, 0.77495311F, + 0.77881651F, 0.78265060F, 0.78645521F, 0.79023022F, 0.79397548F, + 0.79769084F, 0.80137617F, 0.80503133F, 0.80865618F, 0.81225059F, + 0.81581441F, 0.81934752F, 0.82284978F, 0.82632106F, 0.82976123F, + 0.83317016F, 0.83654773F, 0.83989379F, 0.84320824F, 0.84649094F, + 0.84974177F, 0.85296060F, 0.85614733F, 0.85930182F, 0.86242396F, + 0.86551362F, 0.86857071F, 0.87159509F, 0.87458665F, 0.87754529F, + 0.88047089F, 0.88336334F, 0.88622253F, 0.88904836F, 0.89184071F, + 0.89459949F, 0.89732458F, 0.90001589F, 0.90267332F, 0.90529676F, + 0.90788612F, 0.91044129F, 0.91296219F, 0.91544872F, 0.91790078F, + 0.92031828F, 0.92270113F, 0.92504924F, 0.92736253F, 0.92964090F, + 0.93188427F, 0.93409255F, 0.93626567F, 0.93840353F, 0.94050607F, + 0.94257320F, 0.94460484F, 0.94660091F, 0.94856135F, 0.95048607F, + 0.95237501F, 0.95422810F, 0.95604525F, 0.95782641F, 0.95957151F, + 0.96128049F, 0.96295327F, 0.96458979F, 0.96619000F, 0.96775384F, + 0.96928124F, 0.97077214F, 0.97222650F, 0.97364425F, 0.97502535F, + 0.97636973F, 0.97767736F, 0.97894818F, 0.98018214F, 0.98137919F, + 0.98253930F, 0.98366242F, 0.98474850F, 0.98579751F, 0.98680940F, + 0.98778414F, 0.98872169F, 0.98962202F, 0.99048508F, 0.99131086F, + 0.99209931F, 0.99285041F, 0.99356414F, 0.99424045F, 0.99487933F, + 0.99548076F, 0.99604470F, 0.99657115F, 0.99706007F, 0.99751146F, + 0.99792529F, 0.99830154F, 0.99864022F, 0.99894129F, 0.99920476F, + 0.99943060F, 0.99961882F, 0.99976941F, 0.99988235F, 0.99995764F, + 0.99999529F}; + +const FLOAT32 _sine_window1024[1024] = { + 0.000767F, 0.002301F, 0.003835F, 0.005369F, 0.006903F, 0.008437F, 0.009971F, + 0.011505F, 0.013038F, 0.014572F, 0.016106F, 0.017640F, 0.019174F, 0.020707F, + 0.022241F, 0.023774F, 0.025308F, 0.026841F, 0.028375F, 0.029908F, 0.031441F, + 0.032975F, 0.034508F, 0.036041F, 0.037574F, 0.039107F, 0.040639F, 0.042172F, + 0.043705F, 0.045237F, 0.046769F, 0.048302F, 0.049834F, 0.051366F, 0.052898F, + 0.054429F, 0.055961F, 0.057493F, 0.059024F, 0.060555F, 0.062086F, 0.063617F, + 0.065148F, 0.066679F, 0.068209F, 0.069739F, 0.071270F, 0.072800F, 0.074329F, + 0.075859F, 0.077389F, 0.078918F, 0.080447F, 0.081976F, 0.083505F, 0.085033F, + 0.086561F, 0.088090F, 0.089617F, 0.091145F, 0.092673F, 0.094200F, 0.095727F, + 0.097254F, 0.098780F, 0.100307F, 0.101833F, 0.103359F, 0.104884F, 0.106410F, + 0.107935F, 0.109460F, 0.110984F, 0.112509F, 0.114033F, 0.115557F, 0.117080F, + 0.118604F, 0.120127F, 0.121649F, 0.123172F, 0.124694F, 0.126216F, 0.127737F, + 0.129259F, 0.130780F, 0.132300F, 0.133821F, 0.135341F, 0.136860F, 0.138380F, + 0.139899F, 0.141418F, 0.142936F, 0.144454F, 0.145972F, 0.147489F, 0.149006F, + 0.150523F, 0.152039F, 0.153555F, 0.155071F, 0.156586F, 0.158101F, 0.159615F, + 0.161129F, 0.162643F, 0.164157F, 0.165670F, 0.167182F, 0.168694F, 0.170206F, + 0.171718F, 0.173229F, 0.174739F, 0.176249F, 0.177759F, 0.179268F, 0.180777F, + 0.182286F, 0.183794F, 0.185301F, 0.186809F, 0.188315F, 0.189822F, 0.191328F, + 0.192833F, 0.194338F, 0.195843F, 0.197347F, 0.198850F, 0.200353F, 0.201856F, + 0.203358F, 0.204860F, 0.206361F, 0.207862F, 0.209362F, 0.210862F, 0.212361F, + 0.213860F, 0.215358F, 0.216856F, 0.218353F, 0.219850F, 0.221346F, 0.222841F, + 0.224337F, 0.225831F, 0.227325F, 0.228819F, 0.230312F, 0.231804F, 0.233296F, + 0.234788F, 0.236278F, 0.237769F, 0.239258F, 0.240748F, 0.242236F, 0.243724F, + 0.245212F, 0.246698F, 0.248185F, 0.249670F, 0.251155F, 0.252640F, 0.254124F, + 0.255607F, 0.257090F, 0.258572F, 0.260054F, 0.261534F, 0.263015F, 0.264494F, + 0.265973F, 0.267452F, 0.268930F, 0.270407F, 0.271883F, 0.273359F, 0.274834F, + 0.276309F, 0.277783F, 0.279256F, 0.280729F, 0.282201F, 0.283672F, 0.285143F, + 0.286613F, 0.288082F, 0.289551F, 0.291019F, 0.292486F, 0.293952F, 0.295418F, + 0.296883F, 0.298348F, 0.299812F, 0.301275F, 0.302737F, 0.304199F, 0.305660F, + 0.307120F, 0.308579F, 0.310038F, 0.311496F, 0.312953F, 0.314410F, 0.315866F, + 0.317321F, 0.318775F, 0.320229F, 0.321682F, 0.323134F, 0.324585F, 0.326035F, + 0.327485F, 0.328934F, 0.330382F, 0.331830F, 0.333277F, 0.334723F, 0.336168F, + 0.337612F, 0.339055F, 0.340498F, 0.341940F, 0.343381F, 0.344821F, 0.346261F, + 0.347700F, 0.349138F, 0.350575F, 0.352011F, 0.353446F, 0.354881F, 0.356314F, + 0.357747F, 0.359179F, 0.360611F, 0.362041F, 0.363470F, 0.364899F, 0.366327F, + 0.367754F, 0.369180F, 0.370605F, 0.372029F, 0.373453F, 0.374875F, 0.376297F, + 0.377718F, 0.379138F, 0.380557F, 0.381975F, 0.383392F, 0.384808F, 0.386224F, + 0.387638F, 0.389052F, 0.390464F, 0.391876F, 0.393287F, 0.394697F, 0.396106F, + 0.397514F, 0.398921F, 0.400327F, 0.401732F, 0.403137F, 0.404540F, 0.405942F, + 0.407344F, 0.408744F, 0.410144F, 0.411542F, 0.412940F, 0.414337F, 0.415732F, + 0.417127F, 0.418520F, 0.419913F, 0.421305F, 0.422696F, 0.424085F, 0.425474F, + 0.426862F, 0.428248F, 0.429634F, 0.431019F, 0.432402F, 0.433785F, 0.435167F, + 0.436547F, 0.437927F, 0.439305F, 0.440683F, 0.442059F, 0.443435F, 0.444809F, + 0.446183F, 0.447555F, 0.448926F, 0.450296F, 0.451665F, 0.453034F, 0.454401F, + 0.455766F, 0.457131F, 0.458495F, 0.459858F, 0.461219F, 0.462580F, 0.463939F, + 0.465298F, 0.466655F, 0.468011F, 0.469366F, 0.470720F, 0.472073F, 0.473425F, + 0.474775F, 0.476125F, 0.477473F, 0.478821F, 0.480167F, 0.481512F, 0.482856F, + 0.484198F, 0.485540F, 0.486880F, 0.488220F, 0.489558F, 0.490895F, 0.492231F, + 0.493565F, 0.494899F, 0.496231F, 0.497563F, 0.498893F, 0.500221F, 0.501549F, + 0.502876F, 0.504201F, 0.505525F, 0.506848F, 0.508170F, 0.509490F, 0.510810F, + 0.512128F, 0.513445F, 0.514760F, 0.516075F, 0.517388F, 0.518700F, 0.520011F, + 0.521321F, 0.522629F, 0.523937F, 0.525243F, 0.526547F, 0.527851F, 0.529153F, + 0.530454F, 0.531754F, 0.533052F, 0.534350F, 0.535645F, 0.536940F, 0.538234F, + 0.539526F, 0.540817F, 0.542106F, 0.543395F, 0.544682F, 0.545968F, 0.547252F, + 0.548536F, 0.549818F, 0.551098F, 0.552378F, 0.553656F, 0.554932F, 0.556208F, + 0.557482F, 0.558755F, 0.560026F, 0.561297F, 0.562565F, 0.563833F, 0.565099F, + 0.566364F, 0.567628F, 0.568890F, 0.570151F, 0.571410F, 0.572669F, 0.573925F, + 0.575181F, 0.576435F, 0.577688F, 0.578939F, 0.580189F, 0.581438F, 0.582686F, + 0.583932F, 0.585176F, 0.586419F, 0.587661F, 0.588902F, 0.590141F, 0.591378F, + 0.592615F, 0.593850F, 0.595083F, 0.596315F, 0.597546F, 0.598775F, 0.600003F, + 0.601230F, 0.602455F, 0.603678F, 0.604900F, 0.606121F, 0.607341F, 0.608559F, + 0.609775F, 0.610990F, 0.612204F, 0.613416F, 0.614627F, 0.615836F, 0.617044F, + 0.618250F, 0.619455F, 0.620659F, 0.621861F, 0.623061F, 0.624260F, 0.625458F, + 0.626654F, 0.627849F, 0.629042F, 0.630234F, 0.631424F, 0.632613F, 0.633800F, + 0.634986F, 0.636170F, 0.637353F, 0.638534F, 0.639714F, 0.640892F, 0.642069F, + 0.643245F, 0.644418F, 0.645590F, 0.646761F, 0.647930F, 0.649098F, 0.650264F, + 0.651429F, 0.652592F, 0.653753F, 0.654913F, 0.656072F, 0.657229F, 0.658384F, + 0.659538F, 0.660690F, 0.661841F, 0.662990F, 0.664138F, 0.665284F, 0.666428F, + 0.667571F, 0.668713F, 0.669852F, 0.670990F, 0.672127F, 0.673262F, 0.674396F, + 0.675527F, 0.676658F, 0.677786F, 0.678913F, 0.680039F, 0.681163F, 0.682285F, + 0.683406F, 0.684525F, 0.685642F, 0.686758F, 0.687872F, 0.688985F, 0.690096F, + 0.691205F, 0.692313F, 0.693419F, 0.694524F, 0.695626F, 0.696728F, 0.697827F, + 0.698925F, 0.700021F, 0.701116F, 0.702209F, 0.703300F, 0.704390F, 0.705478F, + 0.706564F, 0.707649F, 0.708732F, 0.709813F, 0.710893F, 0.711971F, 0.713047F, + 0.714122F, 0.715195F, 0.716266F, 0.717336F, 0.718404F, 0.719470F, 0.720535F, + 0.721597F, 0.722659F, 0.723718F, 0.724776F, 0.725832F, 0.726886F, 0.727939F, + 0.728990F, 0.730039F, 0.731086F, 0.732132F, 0.733176F, 0.734218F, 0.735259F, + 0.736298F, 0.737335F, 0.738370F, 0.739404F, 0.740436F, 0.741466F, 0.742494F, + 0.743521F, 0.744546F, 0.745569F, 0.746591F, 0.747610F, 0.748628F, 0.749644F, + 0.750659F, 0.751671F, 0.752682F, 0.753691F, 0.754698F, 0.755704F, 0.756708F, + 0.757710F, 0.758710F, 0.759708F, 0.760705F, 0.761700F, 0.762693F, 0.763684F, + 0.764673F, 0.765661F, 0.766647F, 0.767631F, 0.768613F, 0.769593F, 0.770572F, + 0.771549F, 0.772524F, 0.773497F, 0.774468F, 0.775438F, 0.776405F, 0.777371F, + 0.778335F, 0.779297F, 0.780258F, 0.781216F, 0.782173F, 0.783128F, 0.784081F, + 0.785032F, 0.785981F, 0.786929F, 0.787874F, 0.788818F, 0.789760F, 0.790700F, + 0.791638F, 0.792575F, 0.793509F, 0.794442F, 0.795372F, 0.796301F, 0.797228F, + 0.798153F, 0.799076F, 0.799998F, 0.800917F, 0.801835F, 0.802750F, 0.803664F, + 0.804576F, 0.805486F, 0.806394F, 0.807300F, 0.808205F, 0.809107F, 0.810008F, + 0.810906F, 0.811803F, 0.812698F, 0.813591F, 0.814482F, 0.815371F, 0.816258F, + 0.817143F, 0.818026F, 0.818908F, 0.819787F, 0.820665F, 0.821540F, 0.822414F, + 0.823285F, 0.824155F, 0.825023F, 0.825889F, 0.826753F, 0.827615F, 0.828475F, + 0.829333F, 0.830189F, 0.831043F, 0.831895F, 0.832746F, 0.833594F, 0.834440F, + 0.835285F, 0.836127F, 0.836968F, 0.837806F, 0.838643F, 0.839477F, 0.840310F, + 0.841140F, 0.841969F, 0.842796F, 0.843620F, 0.844443F, 0.845264F, 0.846082F, + 0.846899F, 0.847714F, 0.848526F, 0.849337F, 0.850146F, 0.850953F, 0.851757F, + 0.852560F, 0.853361F, 0.854159F, 0.854956F, 0.855751F, 0.856543F, 0.857334F, + 0.858123F, 0.858909F, 0.859694F, 0.860476F, 0.861257F, 0.862035F, 0.862812F, + 0.863586F, 0.864359F, 0.865129F, 0.865898F, 0.866664F, 0.867428F, 0.868190F, + 0.868951F, 0.869709F, 0.870465F, 0.871219F, 0.871971F, 0.872721F, 0.873469F, + 0.874215F, 0.874958F, 0.875700F, 0.876440F, 0.877177F, 0.877913F, 0.878646F, + 0.879378F, 0.880107F, 0.880834F, 0.881559F, 0.882283F, 0.883004F, 0.883723F, + 0.884439F, 0.885154F, 0.885867F, 0.886578F, 0.887286F, 0.887993F, 0.888697F, + 0.889399F, 0.890099F, 0.890797F, 0.891493F, 0.892187F, 0.892879F, 0.893569F, + 0.894256F, 0.894942F, 0.895625F, 0.896307F, 0.896986F, 0.897663F, 0.898338F, + 0.899011F, 0.899681F, 0.900350F, 0.901016F, 0.901681F, 0.902343F, 0.903003F, + 0.903661F, 0.904317F, 0.904971F, 0.905622F, 0.906272F, 0.906919F, 0.907564F, + 0.908207F, 0.908848F, 0.909487F, 0.910124F, 0.910758F, 0.911391F, 0.912021F, + 0.912649F, 0.913275F, 0.913899F, 0.914520F, 0.915140F, 0.915757F, 0.916372F, + 0.916985F, 0.917596F, 0.918205F, 0.918811F, 0.919416F, 0.920018F, 0.920618F, + 0.921216F, 0.921812F, 0.922405F, 0.922997F, 0.923586F, 0.924173F, 0.924758F, + 0.925340F, 0.925921F, 0.926499F, 0.927075F, 0.927649F, 0.928221F, 0.928791F, + 0.929358F, 0.929923F, 0.930486F, 0.931047F, 0.931606F, 0.932162F, 0.932716F, + 0.933269F, 0.933818F, 0.934366F, 0.934912F, 0.935455F, 0.935996F, 0.936535F, + 0.937072F, 0.937606F, 0.938138F, 0.938668F, 0.939196F, 0.939722F, 0.940245F, + 0.940766F, 0.941285F, 0.941802F, 0.942317F, 0.942829F, 0.943339F, 0.943847F, + 0.944353F, 0.944856F, 0.945358F, 0.945857F, 0.946353F, 0.946848F, 0.947340F, + 0.947830F, 0.948318F, 0.948804F, 0.949287F, 0.949768F, 0.950247F, 0.950724F, + 0.951199F, 0.951671F, 0.952141F, 0.952609F, 0.953074F, 0.953537F, 0.953998F, + 0.954457F, 0.954914F, 0.955368F, 0.955820F, 0.956270F, 0.956717F, 0.957163F, + 0.957606F, 0.958047F, 0.958485F, 0.958921F, 0.959355F, 0.959787F, 0.960217F, + 0.960644F, 0.961069F, 0.961492F, 0.961912F, 0.962330F, 0.962746F, 0.963160F, + 0.963571F, 0.963980F, 0.964387F, 0.964792F, 0.965194F, 0.965594F, 0.965992F, + 0.966388F, 0.966781F, 0.967172F, 0.967560F, 0.967947F, 0.968331F, 0.968713F, + 0.969092F, 0.969470F, 0.969845F, 0.970217F, 0.970588F, 0.970956F, 0.971322F, + 0.971685F, 0.972047F, 0.972406F, 0.972762F, 0.973117F, 0.973469F, 0.973819F, + 0.974166F, 0.974512F, 0.974855F, 0.975195F, 0.975534F, 0.975870F, 0.976204F, + 0.976535F, 0.976864F, 0.977191F, 0.977516F, 0.977838F, 0.978158F, 0.978476F, + 0.978791F, 0.979104F, 0.979415F, 0.979724F, 0.980030F, 0.980334F, 0.980635F, + 0.980935F, 0.981232F, 0.981526F, 0.981819F, 0.982109F, 0.982396F, 0.982682F, + 0.982965F, 0.983246F, 0.983524F, 0.983800F, 0.984074F, 0.984346F, 0.984615F, + 0.984882F, 0.985146F, 0.985408F, 0.985668F, 0.985926F, 0.986181F, 0.986434F, + 0.986685F, 0.986933F, 0.987179F, 0.987423F, 0.987664F, 0.987903F, 0.988140F, + 0.988374F, 0.988607F, 0.988836F, 0.989064F, 0.989289F, 0.989511F, 0.989732F, + 0.989950F, 0.990166F, 0.990379F, 0.990590F, 0.990799F, 0.991006F, 0.991210F, + 0.991411F, 0.991611F, 0.991808F, 0.992003F, 0.992195F, 0.992385F, 0.992573F, + 0.992759F, 0.992942F, 0.993122F, 0.993301F, 0.993477F, 0.993651F, 0.993822F, + 0.993991F, 0.994158F, 0.994322F, 0.994484F, 0.994644F, 0.994802F, 0.994957F, + 0.995109F, 0.995260F, 0.995408F, 0.995553F, 0.995697F, 0.995838F, 0.995976F, + 0.996113F, 0.996247F, 0.996378F, 0.996507F, 0.996634F, 0.996759F, 0.996881F, + 0.997001F, 0.997119F, 0.997234F, 0.997347F, 0.997457F, 0.997565F, 0.997671F, + 0.997774F, 0.997876F, 0.997974F, 0.998071F, 0.998165F, 0.998257F, 0.998346F, + 0.998433F, 0.998518F, 0.998600F, 0.998680F, 0.998758F, 0.998833F, 0.998906F, + 0.998976F, 0.999044F, 0.999110F, 0.999174F, 0.999235F, 0.999294F, 0.999350F, + 0.999404F, 0.999456F, 0.999506F, 0.999553F, 0.999597F, 0.999640F, 0.999680F, + 0.999717F, 0.999753F, 0.999786F, 0.999816F, 0.999844F, 0.999870F, 0.999894F, + 0.999915F, 0.999934F, 0.999950F, 0.999964F, 0.999976F, 0.999986F, 0.999993F, + 0.999997F, 1.000000F}; + +const FLOAT32 lsf_init[ORDER] = {375.0, 750.0, 1125.0, 1500.0, 1875.0, 2250.0, + 2625.0, 3000.0, 3375.0, 3750.0, 4125.0, 4500.0, + 4875.0, 5250.0, 5625.0, 6000.0}; + +const FLOAT32 ixheaacd_fir_lp_filt[1 + FILTER_DELAY] = { + 0.088250f, 0.086410f, 0.081074f, 0.072768f, 0.062294f, 0.050623f, 0.038774f, + 0.027692f, 0.018130f, 0.010578f, 0.005221f, 0.001946f, 0.000385f}; + +const FLOAT32 ixheaacd_interpol_filt[INTER_LP_FIL_LEN] = { + + 0.940000f, 0.856390f, 0.632268f, 0.337560f, 0.059072f, -0.131059f, + -0.199393f, -0.158569f, -0.056359f, 0.047606f, 0.106749f, 0.103705f, + 0.052062f, -0.015182f, -0.063705f, -0.073660f, -0.046497f, -0.000983f, + 0.038227f, 0.053143f, 0.040059f, 0.009308f, -0.021674f, -0.037767f, + -0.033186f, -0.013028f, 0.010702f, 0.025901f, 0.026318f, 0.013821f, + -0.003645f, -0.016813f, -0.019855f, -0.012766f, -0.000530f, 0.010080f, + 0.014122f, 0.010657f, 0.002594f, -0.005363f, -0.009344f, -0.008101f, + -0.003182f, 0.002330f, 0.005635f, 0.005562f, 0.002844f, -0.000627f, + -0.002993f, -0.003362f, -0.002044f, -0.000116f, 0.001315f, 0.001692f, + 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] = { + 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, + 62.89968491f, 79.35706329f, 57.65787888f, 43.80548859f, 44.34786987f, + 49.37105942f, 52.12645721f, 52.39661407f, 51.44091797f, 53.65204239f, + 54.99522400f, 55.84826660f, 57.42644501f, 55.41738892f, 55.37759781f, + 55.74499512f, 59.74597931f, 61.79740143f, 58.52257538f, 54.83450699f, + 39.92340088f, 41.08345413f, 48.60131073f, 56.50695801f, 58.68046570f, + 56.46740341f, 51.33567429f, 48.75782394f, 51.25039291f, 52.71126175f, + 56.05620575f, 63.08797836f, 71.41320038f, 58.74863434f, 61.31116104f, + 60.36767578f, 46.94881821f, 43.05058289f, 42.52682114f, 43.48771667f, + 46.60663605f, 51.67750168f, 56.51754761f, 61.39179230f, 65.45318604f, + 64.42360687f, 60.87530899f, 59.40535355f, 63.21428299f, 27.50454903f, + 26.01443100f, 72.88661957f, 65.15971375f, 36.36797714f, 42.51214218f, + 41.14509583f, 48.70087433f, 54.13247681f, 43.03520584f, 41.80447006f, + 71.41699219f, 105.12626648f, 69.40705109f, 52.51038361f, 56.15418625f, + 39.32154846f, 34.86045837f, 57.52830505f, 38.65613937f, 37.07442474f, + 62.72042465f, 46.04343796f, 43.27716446f, 49.77703857f, 37.05713272f, + 36.10309601f, 56.60759354f, 106.72460175f, 97.56930542f, 56.78072357f, + 53.92894363f, 34.82147217f, 30.41595840f, 58.92755508f, 45.38528824f, + 38.98734283f, 50.23058701f, 45.37584686f, 46.23588562f, 47.50640869f, + 39.13286209f, 50.53511810f, 101.81655884f, 78.84753418f, 46.91825104f, + 58.04839706f, 73.15898132f, 27.94698906f, 30.04294586f, 44.24326324f, + 65.08174133f, 64.29788971f, 41.61458588f, 43.46092987f, 41.12305069f, + 38.71143723f, 62.77682114f, 95.97928619f, 70.68365479f, 49.17075729f, + 55.24934769f, 72.21697235f, 69.08310699f, 33.39015961f, 27.74524498f, + 36.86309052f, 30.59696388f, 56.86837006f, 83.52423096f, 46.90863037f, + 57.32517624f, 51.75178146f, 47.19896698f, 76.48811340f, 70.14212036f, + 54.70843124f, 53.00719070f, 55.14438629f, 64.12015533f, 33.25688553f, + 31.20080376f, 44.00421906f, 32.94925308f, 32.29811096f, 70.08818054f, + 77.54248810f, 43.61351013f, 64.04222107f, 68.27146912f, 46.11806488f, + 52.08075714f, 58.43544388f, 54.48910904f, 62.15877533f, 76.94892883f, + 25.21123314f, 31.07140923f, 64.18517303f, 73.08840942f, 47.01982117f, + 34.56942749f, 46.08865356f, 69.39517212f, 52.05731583f, 51.76427460f, + 84.72058105f, 60.20022964f, 42.68987656f, 53.64936829f, 68.98681641f, + 72.44443512f, 36.95545197f, 38.50978470f, 56.65228653f, 45.21320343f, + 44.33461761f, 57.71500015f, 54.59541702f, 62.43425369f, 78.33283234f, + 79.26461029f, 75.88914490f, 60.52022934f, 47.70919800f, 48.37574768f, + 47.72063828f, 54.86680984f, 34.00415802f, 43.60775757f, 54.13970566f, + 36.29747391f, 37.44327545f, 55.93651199f, 72.11687469f, 62.85591125f, + 62.00658417f, 64.02756500f, 61.66854858f, 63.54419708f, 60.88019562f, + 59.24253845f, 58.56096268f, 63.18069458f, 39.50523376f, 31.70396233f, + 60.26929474f, 53.91211700f, 35.68880844f, 53.01742935f, 51.46334457f, + 51.23356247f, 63.81703568f, 48.14149475f, 50.73869705f, 69.80355835f, + 54.97037888f, 44.55532837f, 54.06734467f, 79.62593842f, 22.60673714f, + 32.73123550f, 82.47475433f, 44.38219070f, 35.63208771f, 42.75865173f, + 49.92489243f, 43.19778061f, 55.33113861f, 87.77682495f, 56.83572006f, + 47.62418365f, 51.46238708f, 53.71224594f, 66.54789734f, 74.52059937f, + 26.84594345f, 35.30788040f, 82.43469238f, 49.02751923f, 48.64369965f, + 59.62556458f, 52.84436417f, 72.91526031f, 58.08168411f, 47.03381729f, + 49.28859329f, 50.73176956f, 51.04360962f, 54.03795242f, 57.46273804f, + 63.96378708f, 32.17285919f, 24.71391678f, 37.14886475f, 33.37641144f, + 49.10292053f, 115.65037537f, 90.32772827f, 44.33675385f, 40.08665085f, + 42.54581070f, 38.19865417f, 42.49585724f, 55.98930359f, 59.49616241f, + 61.68011475f, 79.99797821f, 29.85901451f, 30.74155617f, 54.27659607f, + 40.60262680f, 30.69586563f, 36.18083954f, 77.88475037f, 92.04877472f, + 46.81482697f, 47.34019089f, 43.41049576f, 52.65546417f, 85.05891418f, + 75.23082733f, 56.83453369f, 54.87760544f, 33.44684601f, 29.41145706f, + 55.29323578f, 53.15122604f, 36.81983185f, 63.03656006f, 82.19124603f, + 47.44927979f, 52.44190216f, 66.40546417f, 44.05239105f, 43.74975967f, + 65.73956299f, 68.40489197f, 58.48169327f, 62.60677338f, 33.30772781f, + 33.08448029f, 40.88723755f, 66.69921875f, 83.21170807f, 63.38944244f, + 61.16099548f, 44.00226974f, 39.25312042f, 51.35705566f, 69.19556427f, + 70.41883087f, 54.19179535f, 46.41978073f, 52.78839111f, 66.43840790f, + 24.30754089f, 25.26133537f, 57.25505447f, 66.19188690f, 63.78697586f, + 71.96389771f, 51.85918427f, 32.98119736f, 35.85763931f, 71.08959198f, + 85.39947510f, 60.78678131f, 58.38899231f, 68.80822754f, 60.99251938f, + 51.26571274f, 24.37443733f, 22.46492004f, 33.02930450f, 60.64863586f, + 100.06098938f, 53.23743057f, 33.58250046f, 37.12489319f, 62.11270142f, + 84.95267487f, 81.70674133f, 68.56751251f, 46.94418335f, 42.31033325f, + 48.46044159f, 65.21463013f, 22.11164856f, 21.07112503f, 43.68747711f, + 88.50624084f, 56.67428589f, 29.03699112f, 41.90959167f, 82.10002136f, + 96.46846008f, 59.01469421f, 40.22736740f, 48.11627579f, 64.54234314f, + 60.91376114f, 57.00017166f, 61.02260208f, 27.76537514f, 26.16415215f, + 37.93569183f, 55.13633728f, 97.57464600f, 59.98986435f, 41.12758636f, + 45.35464478f, 52.20872116f, 63.01165390f, 47.57964325f, 40.53738022f, + 53.50274277f, 76.44663239f, 74.97815704f, 69.62757111f, 24.59967995f, + 22.23286629f, 31.82554245f, 62.27807999f, 87.92049408f, 53.21877289f, + 44.85179901f, 44.66452789f, 58.01993942f, 65.59706116f, 63.20540237f, + 69.99266815f, 66.43755341f, 60.34387207f, 60.76932526f, 63.49954987f, + 25.11368752f, 23.57916832f, 35.81934738f, 68.99372101f, 98.37869263f, + 63.63158417f, 47.53970337f, 44.60314178f, 58.33650970f, 69.50181580f, + 60.72591400f, 56.39746094f, 55.29515839f, 57.86849594f, 59.38237381f, + 61.77172852f, 27.29609680f, 25.83432579f, 35.38584900f, 41.58143234f, + 89.87036896f, 76.51296997f, 51.89628601f, 58.59866333f, 50.15446854f, + 65.43125916f, 71.60181427f, 59.29849625f, 51.27042007f, 47.59590912f, + 49.10307312f, 57.76146698f, 18.98057365f, 20.81531715f, 53.56282425f, + 88.80827332f, 75.38246155f, 63.70977783f, 62.73327637f, 60.79899597f, + 58.66080475f, 57.47954178f, 57.26865768f, 57.35509872f, 56.67100525f, + 55.51200104f, 54.66986465f, 59.18122482f, 25.32238770f, 20.68062973f, + 28.36009407f, 40.33654785f, 86.68951416f, 86.51828003f, 64.46145630f, + 55.06295013f, 42.86376572f, 52.33369064f, 68.57237244f, 70.92263794f, + 61.17023849f, 56.09333801f, 58.05968094f, 62.57154846f, 18.67280960f, + 27.20020294f, 79.32300568f, 80.76397705f, 62.05303955f, 60.97631073f, + 58.87064362f, 58.27484131f, 56.96005630f, 56.76728439f, 56.64775848f, + 56.52514267f, 55.55430984f, 55.01075745f, 53.68558121f, 58.74045563f, + 29.54671860f, 28.61027908f, 37.17855453f, 39.57009888f, 86.27275085f, + 79.13014221f, 47.02121735f, 57.23653030f, 49.52788925f, 44.78738022f, + 53.71403122f, 62.91474533f, 64.79869843f, 62.62981415f, 58.24869919f, + 60.06638336f, 28.12161827f, 34.00690842f, 60.39837265f, 74.62567139f, + 82.97061157f, 76.43457794f, 63.76325607f, 53.43813324f, 50.59312820f, + 47.57706833f, 45.96542740f, 48.54483795f, 51.67103577f, 55.42654800f, + 58.54445267f, 64.89894867f, 42.93475342f, 39.43522263f, 55.95222473f, + 65.88129425f, 60.98608780f, 58.98157883f, 59.11711502f, 54.85660934f, + 57.57508087f, 58.85480881f, 56.67377472f, 56.79773331f, 56.28233719f, + 53.88801956f, 52.54358292f, 59.64854050f, 49.53974915f, 60.80837631f, + 61.29835510f, 53.16458893f, 62.77450562f, 62.31079102f, 57.79144669f, + 51.27103043f, 46.25718307f, 45.45421600f, 48.86591721f, 53.39314651f, + 55.54738998f, 56.92560196f, 59.08743286f, 64.09606171f, 60.72393799f, + 65.90709686f, 63.53307343f, 55.44069672f, 60.31943512f, 62.19502640f, + 58.11647034f, 52.52097702f, 48.90110397f, 45.15906525f, 44.96876526f, + 47.84098053f, 50.57266617f, 53.61349487f, 55.55693817f, 61.47087479f, + 72.06310272f, 69.39316559f, 59.08422089f, 57.24771881f, 65.71746826f, + 64.69672394f, 60.91994858f, 53.24753189f, 46.86304092f, 42.66559601f, + 42.41964722f, 43.76725769f, 45.80307007f, 49.87761688f, 52.68863678f, + 57.46463776f, 81.77955627f, 74.57749939f, 66.83322144f, 69.54669189f, + 68.09569550f, 55.31027985f, 48.12663269f, 45.37993622f, 41.38604736f, + 39.97538757f, 43.81065750f, 47.01694870f, 48.50960159f, 50.49465561f, + 50.52083588f, 54.24332047f, 71.85914612f, 64.69673157f, 59.39583969f, + 52.52187347f, 57.25660706f, 62.27436066f, 62.15499878f, 61.26008987f, + 59.19638824f, 53.50318146f, 51.65423584f, 49.85649490f, 45.82172775f, + 44.06589127f, 43.89001846f, 47.53118896f, 60.04483795f, 59.83569336f, + 52.16779709f, 45.41381073f, 52.64526367f, 59.17994690f, 58.35621262f, + 56.55029297f, 57.65917587f, 58.24497604f, 57.56445694f, 56.27445221f, + 54.76704788f, 54.01100922f, 53.06089401f, 57.64678574f, 22.93865967f, + 25.94177818f, 61.82679749f, 64.59768677f, 49.33342743f, 49.56757736f, + 42.11018372f, 67.27801514f, 67.62043762f, 40.15002441f, 57.48740387f, + 72.15245819f, 67.54809570f, 58.87646484f, 55.09449387f, 64.78334808f, + 28.06971550f, 27.15646935f, 36.75730133f, 38.62354660f, 74.91754913f, + 63.33176422f, 55.39395523f, 63.07621384f, 41.87721634f, 43.57663345f, + 44.85655212f, 60.18329239f, 86.15392303f, 78.47897339f, 63.33504105f, + 57.56226349f, 33.45854568f, 29.11658096f, 31.20649147f, 50.92073822f, + 74.30931091f, 47.03403854f, 47.06088638f, 38.65474701f, 38.06953812f, + 50.29759979f, 50.87401581f, 54.85138702f, 81.64796448f, 92.17088318f, + 70.48130798f, 66.96426392f, 50.08899689f, 32.78342438f, 36.86429214f, + 37.18173981f, 37.63923264f, 56.18009567f, 53.51729965f, 46.61832809f, + 56.68966293f, 59.36262894f, 56.39588547f, 54.88195801f, 75.07868195f, + 96.45698547f, 73.98442078f, 55.66107559f, 34.46772385f, 30.14305305f, + 39.08222961f, 36.71318436f, 54.31451035f, 57.31208801f, 52.00975800f, + 46.47596359f, 42.75908661f, 62.08021545f, 65.85154724f, 73.32521057f, + 84.24238586f, 70.64961243f, 63.17792511f, 63.65686035f, 30.61931992f, + 32.57714462f, 40.81238174f, 36.43671799f, 39.14760971f, 47.02568436f, + 90.90510559f, 72.71091461f, 43.31842422f, 53.96344757f, 90.27839661f, + 90.96269989f, 52.36705017f, 43.89374924f, 41.77083206f, 49.92410660f, + 27.70341110f, 26.10897827f, 31.22848892f, 46.22554398f, 69.79851532f, + 47.68115997f, 48.10245514f, 40.53551483f, 60.89052200f, 87.37016296f, + 57.35636902f, 58.40283966f, 52.99349594f, 54.04876328f, 71.69735718f, + 71.21662140f, 40.84841156f, 27.98457909f, 29.06910324f, 27.22127151f, + 53.72144699f, 75.32254028f, 47.50754929f, 54.42188263f, 46.35825348f, + 53.99143600f, 75.61268616f, 49.48343658f, 54.25512695f, 77.55857849f, + 74.04908752f, 64.17858887f, 40.82606125f, 31.73655510f, 32.05362320f, + 30.15248871f, 60.30594254f, 89.29907990f, 49.42378998f, 37.45138931f, + 33.05088806f, 41.86178207f, 65.35848999f, 62.83221054f, 75.23628998f, + 87.04959106f, 70.58181763f, 62.44256210f, 25.31159019f, 24.34242249f, + 35.23166275f, 50.78132629f, 73.45314789f, 60.42639923f, 61.95764160f, + 66.26519012f, 62.89816666f, 65.06851196f, 63.74531937f, 63.67735291f, + 60.35585785f, 60.06472778f, 61.07849884f, 61.91757584f, 22.89045906f, + 27.24340439f, 57.14545441f, 74.94773102f, 72.12722015f, 44.62713242f, + 28.65854263f, 49.80601883f, 87.02990723f, 66.92189789f, 64.33074188f, + 64.27783203f, 44.78753662f, 48.63618469f, 60.93623352f, 65.29827118f, + 34.30735779f, 51.58544922f, 61.40118408f, 43.44897842f, 50.59210968f, + 58.85723114f, 62.16580200f, 61.32621002f, 61.16173553f, 62.79653549f, + 60.40631866f, 59.08562088f, 57.58434677f, 56.30934143f, 53.98606873f, + 58.90121841f, 26.64968491f, 26.58556175f, 67.80798340f, 54.54604721f, + 43.02314377f, 52.29839325f, 40.75535202f, 55.25498962f, 56.23502731f, + 40.95955658f, 64.31992340f, 85.76444244f, 58.62097931f, 51.81830978f, + 59.07057190f, 68.81068420f, 31.51725388f, 29.64301109f, 68.15830231f, + 48.88651657f, 37.57243729f, 60.42789459f, 43.16152191f, 56.62898254f, + 78.21684265f, 45.43099594f, 43.33174515f, 61.73524475f, 66.17499542f, + 57.58115005f, 54.73582077f, 63.47382736f, 27.46224022f, 35.62995911f, + 57.48218155f, 37.94735718f, 42.28582764f, 46.42540359f, 46.43659210f, + 41.99361038f, 36.43420029f, 58.86711884f, 101.85854340f, 90.39488220f, + 62.49348831f, 61.48776245f, 63.98002625f, 58.75501251f, 24.02379799f, + 37.92109680f, 76.27156067f, 45.02413940f, 40.16073990f, 44.08317947f, + 48.63985825f, 41.63816833f, 36.26319122f, 55.71387100f, 101.28601074f, + 84.31336975f, 48.91724014f, 53.55353928f, 58.58589172f, 59.65835571f, + 33.85987091f, 25.47232056f, 60.31459808f, 71.40914154f, 34.16411591f, + 31.44390678f, 37.29024506f, 44.07047272f, 74.50944519f, 60.76315689f, + 40.13964081f, 56.93555832f, 58.82191467f, 50.52367020f, 77.00817871f, + 88.56400299f, 26.23241997f, 34.07615280f, 53.72222137f, 47.81643295f, + 54.98140717f, 50.64495087f, 47.93675995f, 52.46852112f, 66.16542053f, + 77.76923370f, 78.78589630f, 73.08940887f, 57.74690247f, 50.11543274f, + 51.78378677f, 64.16659546f, 40.04499435f, 32.83197021f, 44.03527069f, + 38.04254913f, 52.99823761f, 71.75680542f, 52.67618179f, 63.61703873f, + 61.32105255f, 52.41450882f, 67.00193024f, 70.13252258f, 58.31614304f, + 54.17544937f, 51.04999924f, 58.02515030f, 29.39674950f, 33.54152679f, + 44.07868195f, 32.80142975f, 36.75119400f, 54.29905701f, 60.05080795f, + 63.10977173f, 80.95140076f, 87.48461151f, 84.08176422f, 64.65602112f, + 51.11909866f, 50.55273438f, 51.63026428f, 55.92106628f, 32.43203354f, + 35.19086838f, 52.48605728f, 38.87727737f, 43.43602371f, 47.74624252f, + 57.89318848f, 56.59716034f, 37.67229462f, 54.36892319f, 104.13726044f, + 77.87561035f, 45.27653503f, 42.70982742f, 50.00558090f, 72.11049652f, + 23.15091705f, 29.68937683f, 84.29270172f, 56.97257996f, 36.93620682f, + 45.76895523f, 50.98108292f, 50.25860214f, 48.30105591f, 63.42514801f, + 72.01637268f, 63.89733505f, 58.89476013f, 63.55104828f, 63.29576492f, + 62.64519501f, 26.40411758f, 33.88385391f, 73.38534546f, 41.93790817f, + 29.54182053f, 35.14719391f, 55.53915787f, 62.32246399f, 55.53688049f, + 67.71183014f, 67.73328400f, 66.71433258f, 62.51498413f, 62.21415329f, + 61.18598557f, 65.40946198f, 23.36671257f, 29.05081749f, 70.07810211f, + 58.88187408f, 40.48395920f, 42.10813141f, 62.00427246f, 80.31524658f, + 58.20276642f, 59.09466553f, 64.51416016f, 59.56649017f, 59.24276352f, + 60.31189728f, 57.44777679f, 59.64531326f, 21.39454269f, 25.19507599f, + 62.11148453f, 92.40872955f, 53.02559662f, 34.33268356f, 54.66912460f, + 75.52672577f, 65.54019928f, 59.27623749f, 58.03553391f, 56.06007767f, + 53.49679947f, 52.66230774f, 55.80004883f, 66.00994873f, 26.49234772f, + 28.06620979f, 71.84543610f, 50.06892014f, 42.60673523f, 53.48630524f, + 41.20733261f, 66.57645416f, 54.34481049f, 50.21356964f, 81.29329681f, + 69.27972412f, 51.25036621f, 50.18910599f, 49.81430435f, 54.67628098f, + 25.25213432f, 26.27217484f, 63.17989349f, 89.34584808f, 55.40425110f, + 50.19643021f, 59.20699692f, 52.45797729f, 67.72447205f, 74.88394928f, + 52.19100952f, 45.75650024f, 50.78663635f, 51.88641357f, 53.43647003f, + 61.86102676f, 26.62268448f, 51.35712433f, 81.43214417f, 60.82180023f, + 59.03229904f, 59.15783310f, 58.40338898f, 55.67206192f, 55.50912857f, + 55.69218826f, 55.51039505f, 55.25974274f, 54.70522308f, 54.32756805f, + 53.57998276f, 58.04686737f, 26.99984360f, 34.32979584f, 55.27625275f, + 47.05793762f, 56.66270447f, 51.78815842f, 62.71406555f, 53.01352692f, + 60.77756500f, 73.74706268f, 45.40955734f, 43.94420242f, 44.93154144f, + 48.44590759f, 64.26975250f, 78.60430145f, 39.68233109f, 30.48469543f, + 48.00776672f, 45.96604156f, 39.44678116f, 61.35329819f, 58.51391983f, + 51.03633499f, 67.84073639f, 51.40700531f, 42.05585098f, 57.82880783f, + 53.51763916f, 43.56558990f, 68.20864868f, 95.94857025f, 54.09636307f, + 68.45973969f, 67.88989258f, 46.89349747f, 42.97753525f, 48.63239288f, + 53.96750259f, 54.89427567f, 57.18038559f, 56.57381821f, 55.22798157f, + 56.07190323f, 56.59679794f, 55.91986847f, 54.94155121f, 60.33355713f, + 72.14902496f, 80.18998718f, 70.16993713f, 60.36406708f, 54.06077194f, + 43.46662903f, 38.57094193f, 39.10970306f, 44.32598495f, 49.24937820f, + 53.25442505f, 56.15134430f, 55.72174454f, 55.06374359f, 55.40906143f, + 60.11138535f, 63.44208908f, 78.67465973f, 67.96295929f, 47.46451569f, + 41.62522507f, 39.47309494f, 42.87333298f, 47.63717270f, 53.18756866f, + 55.23044968f, 56.02836227f, 57.74340820f, 57.22745514f, 56.75315094f, + 57.80585480f, 62.67353058f, 47.66206741f, 42.05881882f, 39.75352859f, + 35.88562775f, 56.59163284f, 72.49357605f, 58.53800583f, 66.28578949f, + 68.44763184f, 50.70192337f, 44.83471298f, 44.17079926f, 48.10833740f, + 59.88060760f, 70.23044586f, 72.72976685f, 31.83942413f, 31.00273323f, + 62.84654236f, 42.52922821f, 45.04764557f, 68.73088074f, 44.12630463f, + 55.82215881f, 60.64304733f, 39.67309189f, 40.97443008f, 46.15904236f, + 51.13856506f, 77.50988007f, 91.96014404f, 66.76219940f, 24.87833977f, + 24.48041534f, 84.98556519f, 78.79760742f, 35.44894791f, 36.24985123f, + 39.40999222f, 46.73764420f, 45.47512436f, 34.56911469f, 37.47670746f, + 46.34072113f, 59.32683563f, 97.60725403f, 89.46193695f, 60.29697800f, + 26.50839996f, 32.23742294f, 60.97684479f, 82.84976959f, 64.65290833f, + 35.75301743f, 29.20633698f, 49.02716064f, 82.37818909f, 52.69860840f, + 40.97535324f, 47.71611786f, 45.36249924f, 49.57620239f, 77.53877258f, + 92.26754761f, 35.64341736f, 31.00637817f, 32.70653152f, 36.61704636f, + 78.32850647f, 58.38439178f, 50.15953064f, 51.64757538f, 31.45488358f, + 32.53406906f, 70.45175171f, 95.83827209f, 55.77313614f, 52.13791275f, + 53.08223343f, 60.95632553f, 48.49149704f, 36.81194305f, 40.89573669f, + 63.74932861f, 56.87507248f, 43.46606064f, 53.26033783f, 46.30524826f, + 47.92121887f, 70.16265869f, 68.21533966f, 54.02314377f, 53.99431229f, + 57.06119919f, 54.64419937f, 68.16999054f, 25.64371872f, 24.45460892f, + 50.87102509f, 82.50071716f, 55.51737976f, 43.91300201f, 62.40633392f, + 50.28652573f, 43.43270874f, 76.00059509f, 63.61797333f, 32.75575638f, + 39.15626526f, 64.85440826f, 75.91765594f, 71.19286346f, 24.05227470f, + 25.63839912f, 62.18745422f, 66.20637512f, 44.97000122f, 55.09886551f, + 51.85337830f, 42.12100601f, 71.82875824f, 75.90416718f, 45.78887939f, + 53.78314590f, 68.78794861f, 64.08832550f, 61.43847275f, 62.34527588f, + 40.28961945f, 31.29172707f, 52.52343750f, 42.86972046f, 34.05217361f, + 64.05602264f, 60.71221542f, 38.49654388f, 62.62505341f, 63.44993973f, + 35.85233307f, 30.82952881f, 55.26118851f, 90.10671234f, 73.23900604f, + 65.04768372f, 25.42248154f, 29.15345764f, 60.32111740f, 58.00751877f, + 63.52694702f, 54.05160141f, 37.57971191f, 36.38301468f, 56.08333588f, + 81.28800201f, 51.21339035f, 43.08742142f, 63.39225388f, 80.68672180f, + 68.30161285f, 64.31939697f, 25.08824348f, 31.97578621f, 62.30278397f, + 64.77771759f, 46.62558746f, 29.43172455f, 33.39860153f, 69.36865234f, + 87.11560822f, 74.09555054f, 60.52772141f, 61.69064331f, 61.31235123f, + 62.69378281f, 59.57194138f, 54.95983887f, 31.77939606f, 24.52310181f, + 66.91590881f, 87.38681793f, 38.01080704f, 32.13548279f, 42.10402679f, + 40.00331116f, 55.64583969f, 70.36904907f, 46.01465225f, 39.05214691f, + 51.01358414f, 75.73467255f, 89.46847534f, 67.09191895f, 23.85073662f, + 23.40214920f, 81.03526306f, 74.39035797f, 32.08067322f, 33.65716171f, + 39.26899719f, 53.91749191f, 53.91583252f, 49.25065613f, 73.15007019f, + 73.78266144f, 53.83327484f, 48.50161743f, 55.10165787f, 69.67100525f, + 27.85416794f, 37.11641693f, 58.47553253f, 38.89407349f, 55.67539597f, + 46.16933441f, 50.34129715f, 65.48024750f, 33.90142822f, 39.54533005f, + 75.70198822f, 81.68888855f, 59.27466583f, 49.28007126f, 50.05373001f, + 64.65666962f, 36.43780136f, 31.76765823f, 58.14712524f, 37.10118866f, + 37.97302628f, 55.99253082f, 45.96212387f, 61.74487305f, 52.35879898f, + 38.01057816f, 64.10728455f, 93.47910309f, 68.85859680f, 51.53124237f, + 49.20208359f, 60.44374084f, 36.27912140f, 28.61949539f, 35.11944962f, + 28.25377083f, 47.16120529f, 67.15929413f, 50.14215851f, 60.74728775f, + 55.00474167f, 61.08347321f, 73.02226257f, 73.34864807f, 82.29946899f, + 66.90367126f, 52.82141113f, 50.24045181f, 30.33128738f, 29.83868027f, + 48.98286438f, 44.07889175f, 53.02743149f, 68.58934784f, 58.47387314f, + 74.61608124f, 71.30519104f, 46.92713547f, 44.54153442f, 47.53027344f, + 49.54763031f, 61.84693527f, 76.80824280f, 74.72835541f, 30.68704414f, + 33.75550079f, 54.49449539f, 34.38837051f, 32.02235794f, 38.75023651f, + 69.81581116f, 67.80587769f, 35.19872665f, 41.11143875f, 46.83567047f, + 57.45496750f, 87.16669464f, 89.70450592f, 72.88046265f, 62.92624283f, + 25.88317871f, 32.00049210f, 63.66804123f, 45.31368256f, 44.64995575f, + 53.55807114f, 49.34097672f, 48.64500046f, 55.97005844f, 53.48418427f, + 60.72993469f, 84.73365784f, 72.60200500f, 65.07049561f, 62.67537689f, + 62.98127747f, 41.71213913f, 32.50508118f, 52.03067017f, 46.15842438f, + 37.55257034f, 46.54631805f, 47.84952164f, 52.91853714f, 52.09297562f, + 42.96075439f, 50.51084518f, 57.35768890f, 65.56761932f, 88.42894745f, + 89.21614838f, 72.57400513f, 28.85829735f, 29.02394867f, 67.85389709f, + 47.40405273f, 38.05905533f, 47.58603668f, 47.27703094f, 53.40644455f, + 42.10163116f, 53.89140320f, 59.49587250f, 47.21412277f, 72.10668182f, + 87.97994995f, 72.60945129f, 66.37307739f, 38.71412659f, 28.24537659f, + 48.75971222f, 70.90471649f, 37.74874496f, 35.92568588f, 68.88765717f, + 50.13407898f, 42.39151001f, 67.38808441f, 55.08102036f, 40.90394974f, + 56.17565536f, 74.78722382f, 72.37669373f, 70.07965851f, 29.43914413f, + 27.64601707f, 65.63799286f, 52.87505341f, 37.65579987f, 56.94130325f, + 45.13871384f, 53.37010193f, 62.69499588f, 46.24171448f, 54.58054352f, + 83.49011230f, 84.91969299f, 59.13919830f, 47.59422684f, 49.57666779f, + 25.31308937f, 28.12471771f, 59.06542587f, 47.85390472f, 50.11564636f, + 56.14247894f, 56.69361877f, 61.49286270f, 45.35743713f, 56.13601685f, + 65.42692566f, 67.17038727f, 70.89638519f, 65.09598541f, 62.22166824f, + 62.09773254f, 27.86618805f, 33.66560745f, 58.54564285f, 46.03859711f, + 60.97461700f, 62.42464447f, 50.46584320f, 58.19345856f, 49.84050369f, + 56.09535980f, 58.70023727f, 56.75710678f, 64.45565796f, 68.68337250f, + 62.83724976f, 62.15460968f, 27.98069763f, 28.12239647f, 73.64580536f, + 53.64321899f, 41.57968903f, 56.11806107f, 41.83660507f, 52.42901611f, + 55.75767517f, 40.98953629f, 43.80265808f, 49.33514023f, 71.48557281f, + 96.82264709f, 69.97777557f, 54.90660858f, 26.00374031f, 29.38063622f, + 88.02574158f, 56.13308334f, 34.13850021f, 44.49108505f, 42.94824219f, + 60.48073578f, 61.72525024f, 40.94783020f, 38.54808807f, 41.31735611f, + 57.69098282f, 77.83142090f, 71.16756439f, 73.88340759f, 42.04106140f, + 29.33940315f, 46.77529526f, 75.90257263f, 49.26646805f, 37.13816071f, + 52.37572861f, 47.95476913f, 42.74429703f, 56.84862137f, 55.28556061f, + 50.77186966f, 62.24879837f, 57.00417709f, 57.74382782f, 86.80639648f, + 40.93001556f, 30.12081528f, 36.18900681f, 30.52259254f, 37.25543213f, + 83.96064758f, 86.67710114f, 53.48010254f, 46.48635101f, 40.51612473f, + 37.21931458f, 50.81362152f, 69.11064148f, 70.85220337f, 76.62476349f, + 77.50777435f, 43.84403992f, 35.34262466f, 41.53487778f, 32.88284683f, + 51.00677490f, 73.34737396f, 46.15427399f, 43.91883087f, 37.78704834f, + 33.87147903f, 49.63688278f, 56.28442001f, 72.40470123f, 102.90767670f, + 81.28096771f, 63.06505966f, 30.32354355f, 26.06576347f, 32.33953476f, + 34.05029297f, 71.36428833f, 66.01895142f, 44.89619064f, 47.41546631f, + 45.04423523f, 63.33537674f, 80.34857941f, 80.64633942f, 69.65506744f, + 59.56158829f, 55.70967102f, 59.13024139f, 49.87876129f, 32.02300644f, + 31.95695877f, 29.96616554f, 31.71495819f, 63.89558411f, 81.99237823f, + 48.16778946f, 49.59616089f, 56.84108353f, 43.18778610f, 56.67759705f, + 83.08076477f, 63.70401382f, 55.50138855f, 72.05219269f, 43.29176331f, + 31.75572586f, 44.29584503f, 37.05521011f, 33.32308960f, 51.52458954f, + 51.83518600f, 59.65685272f, 64.09313965f, 55.29719162f, 63.49596786f, + 80.18101501f, 87.86631012f, 62.67739105f, 46.96037292f, 54.00913239f, + 33.05537033f, 33.52505112f, 39.44873810f, 30.25352669f, 33.82030869f, + 68.30262756f, 71.50759888f, 37.81459808f, 45.00791168f, 53.27256775f, + 65.01938629f, 83.22824860f, 76.78502655f, 67.26903534f, 62.30852127f, + 62.56160355f, 26.68041611f, 29.35152435f, 52.81324768f, 37.36683273f, + 33.63171387f, 43.50512695f, 61.99557495f, 55.16758728f, 60.60149002f, + 74.62538910f, 71.04770660f, 78.17013550f, 70.27218628f, 64.35273743f, + 57.04582214f, 58.27642822f, 27.22444916f, 40.25427246f, 85.34473419f, + 65.68736267f, 61.74830246f, 70.05519867f, 67.59353638f, 66.44824219f, + 57.99704742f, 52.12969589f, 48.11986160f, 47.41305923f, 47.12488174f, + 48.54206467f, 49.59511185f, 55.78128815f, 33.40121078f, 58.24025726f, + 67.21931458f, 40.01454163f, 43.46700668f, 49.53392410f, 54.13881683f, + 49.82066727f, 51.45339966f, 57.58335495f, 63.94172668f, 66.31728363f, + 59.40647888f, 57.90964508f, 59.12393951f, 64.02872467f, 22.45939827f, + 24.09759521f, 86.19745636f, 89.98487854f, 36.69483185f, 33.11008453f, + 36.89076996f, 44.10708618f, 45.22092438f, 37.95475388f, 41.34347534f, + 62.74864578f, 98.06116486f, 75.13717651f, 54.60420227f, 60.10364914f, + 21.77506447f, 42.97178268f, 93.36532593f, 43.16156006f, 37.07690430f, + 40.44392395f, 38.06811523f, 31.15335083f, 35.34060669f, 73.39562225f, + 88.76380157f, 73.44093323f, 56.12755585f, 57.37850189f, 64.17596436f, + 57.66079712f, 28.35590744f, 40.32005310f, 63.64964676f, 58.80429459f, + 47.87990952f, 46.03519821f, 62.35939026f, 37.32320404f, 28.36582756f, + 39.22389221f, 45.41779709f, 75.22049713f, 120.09323120f, 67.16011810f, + 41.66241455f, 52.26153946f, 30.68520927f, 48.99335861f, 62.54696655f, + 48.14344406f, 57.25169754f, 59.29005814f, 65.54375458f, 52.66086578f, + 45.11617279f, 53.95734787f, 55.46360397f, 59.44460297f, 59.69741440f, + 56.98567200f, 60.16737747f, 68.18187714f, 31.64274979f, 39.94817734f, + 57.17124176f, 39.78912735f, 51.29457474f, 60.69633865f, 56.79949188f, + 43.48522568f, 46.53956985f, 68.30560303f, 65.82494354f, 50.49483109f, + 47.13283539f, 52.68176270f, 64.01728821f, 85.40366364f, 33.67242050f, + 30.30710793f, 59.03366089f, 47.52296448f, 35.79129791f, 46.42206192f, + 50.84357452f, 49.82937622f, 50.42001724f, 60.66556168f, 59.06491852f, + 72.13677979f, 105.84234619f, 79.97609711f, 50.45109558f, 46.40296555f, + 43.56876373f, 29.16429901f, 36.02735519f, 35.79633713f, 45.38971710f, + 52.08420944f, 45.85276794f, 57.32064438f, 47.30744171f, 47.82405472f, + 90.70173645f, 84.54063416f, 48.98644257f, 40.15388870f, 57.78521347f, + 84.83719635f, 42.70676041f, 34.33568954f, 54.60139847f, 44.82980347f, + 38.44404602f, 50.84912872f, 52.22068405f, 55.78813934f, 56.04770660f, + 44.55458832f, 41.00638199f, 50.70363998f, 54.99309921f, 54.14403534f, + 81.80480194f, 101.17221069f, 39.33768463f, 33.15550995f, 63.93803787f, + 63.12727356f, 42.71297836f, 47.74219894f, 58.45108795f, 50.70246887f, + 47.15308380f, 53.15393829f, 46.32630539f, 39.19215012f, 41.36018753f, + 47.03018188f, 61.14070129f, 101.71155548f, 33.28364944f, 29.34801674f, + 30.92674446f, 43.59842300f, 81.65496826f, 59.48735809f, 45.84857178f, + 38.03454971f, 59.14472961f, 73.20796967f, 49.86552429f, 51.43836975f, + 48.01525879f, 47.34091187f, 64.95159149f, 87.08312988f, 35.67461395f, + 31.63343811f, 40.92625427f, 36.06115341f, 41.63019943f, 46.37862778f, + 72.24681854f, 73.10201263f, 58.17958832f, 62.42228699f, 45.93933487f, + 38.71157074f, 47.26561356f, 76.48676300f, 89.55551910f, 70.80134583f, + 36.70552826f, 32.41079712f, 38.39546585f, 35.12812805f, 72.25511169f, + 71.24157715f, 42.94526672f, 53.67319107f, 45.78990173f, 35.59971237f, + 39.35116196f, 47.44698715f, 55.44371033f, 55.80371857f, 78.27950287f, + 99.56220245f, 35.75726700f, 35.43749237f, 80.10720062f, 71.09939575f, + 38.09885406f, 43.53698349f, 48.39539337f, 47.14159775f, 59.57736588f, + 56.05052948f, 46.88885498f, 50.65227890f, 55.45956039f, 55.27238083f, + 59.95415497f, 76.67358398f, 30.48989677f, 31.09431267f, 41.20455170f, + 39.70792770f, 77.44073486f, 65.52349091f, 46.26779175f, 76.19163513f, + 54.80591583f, 33.82253647f, 32.12807846f, 35.31846619f, 41.42735672f, + 52.59740448f, 86.43671417f, 97.89361572f, 35.33759689f, 26.95825195f, + 56.00233459f, 82.72183990f, 46.27759933f, 42.16004562f, 63.31395721f, + 47.65197372f, 41.25454712f, 62.51292038f, 55.10221481f, 41.08710861f, + 47.76231384f, 53.30332184f, 52.42124176f, 79.32273102f, 25.67922020f, + 25.40534401f, 87.19135284f, 87.31198120f, 40.65235138f, 38.92859650f, + 36.11894226f, 40.76044083f, 47.92928314f, 40.23088837f, 35.55156326f, + 37.77005768f, 45.02421951f, 60.78223801f, 96.27216339f, 95.95360565f, + 25.95465088f, 21.57634163f, 49.31441498f, 113.67279816f, 96.14002228f, + 42.05511856f, 31.98275948f, 36.16901016f, 40.25297546f, 51.04194260f, + 48.74641418f, 41.97515106f, 51.07022095f, 67.85249329f, 78.34592438f, + 75.15943909f, 31.28936195f, 57.42531967f, 90.53761292f, 52.06074905f, + 45.04249191f, 46.44200134f, 48.43907166f, 50.42742920f, 49.98683548f, + 53.54566574f, 55.87023163f, 59.19391632f, 59.93918991f, 58.82572937f, + 58.34109497f, 63.10987473f, 28.05487251f, 23.63316727f, 61.24803543f, + 115.18739319f, 75.26832581f, 37.97168350f, 35.13646317f, 37.70814896f, + 41.76129913f, 55.20713425f, 50.08812714f, 37.92100906f, 38.71198654f, + 46.64434814f, 58.08201981f, 92.72935486f, 38.96191025f, 63.71978760f, + 63.97180939f, 44.39167023f, 52.72070313f, 58.57560349f, 59.19809723f, + 58.14528275f, 57.01485443f, 58.30971527f, 57.85213852f, 57.11650848f, + 56.12951279f, 55.68547058f, 55.10100555f, 59.07358932f, 71.56976318f, + 57.39773560f, 41.59987640f, 38.37985611f, 44.64391708f, 52.75336838f, + 56.14191437f, 54.65293121f, 55.89964294f, 58.27516556f, 61.53528214f, + 63.28555679f, 59.81817627f, 56.56216049f, 54.88045502f, 58.54565430f, + 69.10721588f, 63.11733627f, 57.60437775f, 52.38751221f, 55.26897812f, + 58.35265732f, 58.65968704f, 57.27175140f, 58.71163559f, 56.23760223f, + 53.37927246f, 52.83778000f, 50.42839432f, 48.27567673f, 47.26873016f, + 50.61319351f, 59.33306503f, 48.39329910f, 38.40591049f, 40.55169296f, + 55.44321060f, 61.37379837f, 55.88480377f, 50.66183090f, 51.41033173f, + 54.27007294f, 61.07071304f, 67.98171234f, 65.11176300f, 59.76893997f, + 56.42860031f, 61.40325928f, 26.27382278f, 29.93502998f, 87.15231323f, + 48.43775558f, 30.41054726f, 38.70485306f, 44.48966599f, 65.87891388f, + 48.31138229f, 36.65853882f, 58.95906067f, 91.48318481f, 67.75254822f, + 50.97986984f, 53.25600433f, 60.32897186f, 26.33623314f, 31.90271187f, + 90.31379700f, 58.17583084f, 35.16676712f, 39.55157471f, 39.83322144f, + 49.49237442f, 46.30712509f, 35.65680313f, 34.48379517f, 43.58718872f, + 87.21034241f, 109.36755371f, 68.02302551f, 58.08772278f, 30.97780418f, + 25.11987686f, 61.43051529f, 59.76992035f, 32.69781494f, 33.63170624f, + 37.10293579f, 58.25488663f, 65.58847046f, 43.49975204f, 59.01026535f, + 69.00422668f, 59.61562729f, 73.37989807f, 74.23587799f, 69.86299896f, + 28.78158379f, 37.98389816f, 71.62084198f, 42.80751419f, 39.70916367f, + 42.45513535f, 48.77637100f, 51.15852737f, 36.13694763f, 38.23048401f, + 44.31620026f, 50.16409302f, 86.18952942f, 108.49091339f, 74.16990662f, + 61.91885757f, 30.11363411f, 43.68441010f, 56.11302948f, 53.20962906f, + 61.57991409f, 53.31562042f, 51.47801590f, 46.02001190f, 57.74351501f, + 70.87924957f, 64.74682617f, 62.95172882f, 59.53381348f, 58.65623856f, + 57.47818375f, 60.74559021f, 23.98161125f, 34.12941360f, 91.76512146f, + 56.41880417f, 38.00878906f, 45.25758362f, 51.63621902f, 63.12136841f, + 58.11164093f, 59.19710541f, 58.18413925f, 57.55535126f, 59.65021133f, + 59.94812775f, 57.72056961f, 60.05414200f, 31.69394875f, 34.15394592f, + 50.30434418f, 45.78476715f, 69.70542145f, 77.27056885f, 65.18736267f, + 70.87966919f, 56.40662384f, 44.83968353f, 37.92598343f, 43.25963211f, + 65.49037933f, 80.08726501f, 61.06654739f, 50.73454285f, 52.48049164f, + 37.74885559f, 32.84705734f, 42.24605179f, 68.03234100f, 74.63986969f, + 65.60765839f, 53.66085052f, 46.20950317f, 44.68785858f, 55.51148605f, + 73.06719971f, 68.56088257f, 57.57872009f, 52.38343811f, 57.28626633f, + 59.02671432f, 46.61535263f, 37.13630676f, 47.64561462f, 70.52297211f, + 70.05669403f, 64.37633514f, 58.29954147f, 55.28224564f, 53.41539383f, + 52.18756485f, 53.02276230f, 53.36929703f, 53.66748810f, 53.23779678f, + 58.79326630f, 62.93693924f, 43.00690842f, 37.63240051f, 50.69776535f, + 67.49617004f, 59.53757858f, 51.48891068f, 47.10806656f, 47.89420319f, + 52.12152863f, 56.32263565f, 59.45511246f, 58.18305206f, 56.71432877f, + 57.66085815f, 65.01094055f, 63.92367935f, 67.33415985f, 62.15634918f, + 57.49787903f, 59.58540726f, 53.46123886f, 46.31530380f, 41.40219879f, + 42.75317383f, 46.59084702f, 50.92510605f, 55.31436157f, 57.31076050f, + 57.92418671f, 58.75542831f, 63.97220612f, 55.70299911f, 60.43587875f, + 64.76921844f, 56.78495026f, 53.76028061f, 48.36291504f, 45.38504028f, + 43.34703445f, 44.20055771f, 48.13724899f, 52.75143814f, 57.73850632f, + 60.82793427f, 61.78697968f, 63.24287796f, 67.91735840f, 59.04277420f, + 51.33352280f, 46.29484940f, 37.30976105f, 42.38951111f, 51.73043442f, + 57.26016235f, 54.58428574f, 52.99783707f, 51.50612640f, 49.28882599f, + 54.87439346f, 64.07160187f, 66.49423218f, 66.31239319f, 69.17700195f, + 60.97944641f, 48.85638046f, 37.94224930f, 33.13868713f, 45.31595612f, + 63.26202774f, 69.20629120f, 65.14806366f, 62.51951218f, 57.16036606f, + 53.12342072f, 52.30583572f, 52.54816055f, 55.59687042f, 59.05779648f, + 63.91780853f, 38.16660690f, 32.63441467f, 42.31219101f, 31.02834320f, + 49.01750183f, 92.74621582f, 49.04926300f, 44.73206711f, 67.08958435f, + 44.29878616f, 31.71022797f, 37.31089020f, 71.03110504f, 96.27531433f, + 67.00743103f, 55.51771927f, 41.41088867f, 32.63044357f, 44.90244293f, + 39.71800232f, 37.27100754f, 73.68880463f, 89.44371033f, 49.77977753f, + 45.84424210f, 52.67778778f, 41.79865646f, 43.40632248f, 55.25019073f, + 53.00514984f, 53.15204620f, 83.17504120f, 33.90364838f, 29.31626701f, + 63.80526733f, 62.59220123f, 35.53377533f, 58.65224457f, 63.65067291f, + 42.49652863f, 63.17875290f, 68.20914459f, 47.87530899f, 54.95333481f, + 56.04679108f, 42.44972229f, 45.74412537f, 69.62164307f, 32.33472824f, + 32.36685944f, 71.27500153f, 58.83824921f, 52.89490891f, 57.05721283f, + 44.75731659f, 66.49700928f, 53.30723953f, 41.02497482f, 44.74613571f, + 42.72458267f, 41.67597580f, 50.91527176f, 76.18853760f, 84.17784119f, + 33.91438293f, 24.74755478f, 34.48404312f, 31.74764633f, 36.77778625f, + 84.48294830f, 105.86836243f, 50.84911728f, 42.26078796f, 51.22866058f, + 44.80072403f, 57.39357758f, 70.37298584f, 65.45933533f, 64.70481110f, + 65.07164764f, 54.81047440f, 64.19705963f, 61.01438904f, 58.33678055f, + 57.41178894f, 56.80622101f, 56.18848038f, 55.27061844f, 55.63972855f, + 54.96983337f, 55.08586502f, 54.55832672f, 54.42483521f, 53.81105042f, + 52.72660065f, 58.03502655f, 43.11587524f, 62.92795563f, 65.00118256f, + 61.56204224f, 59.74514008f, 58.35398483f, 57.48186493f, 56.64671326f, + 56.21909332f, 55.75438690f, 55.41420746f, 55.22217178f, 54.35841370f, + 53.21385193f, 51.11892700f, 58.70683670f, 30.71430588f, 29.96514320f, + 76.60626221f, 60.13325500f, 39.29867554f, 46.79974747f, 41.00794601f, + 49.70497513f, 59.34734726f, 42.31467056f, 35.41555786f, 42.09702682f, + 49.67417145f, 56.61996460f, 88.86426544f, 101.60348511f, 51.64251709f, + 37.48175812f, 41.70228577f, 40.68749237f, 34.71246338f, 54.51747131f, + 84.52162170f, 53.79661560f, 41.88551331f, 48.06188202f, 39.60204697f, + 39.98397827f, 61.51813126f, 67.10542297f, 62.49188614f, 87.32495880f, + 38.52933121f, 30.04664230f, 38.80035400f, 36.65904236f, 61.74727631f, + 94.43470764f, 55.52663803f, 45.95931244f, 41.82407379f, 39.92137527f, + 65.12637329f, 70.52561188f, 47.80123901f, 46.39950943f, 54.24890137f, + 76.12986755f, 31.66247940f, 31.64093399f, 40.27448654f, 37.82950974f, + 55.67258453f, 63.15267181f, 53.08364487f, 43.62401962f, 47.98174286f, + 90.01052094f, 102.53605652f, 53.96711349f, 37.07308960f, 44.45272064f, + 62.66236877f, 69.50439453f, 24.18644333f, 28.45671272f, 77.17498016f, + 65.37176514f, 29.84308052f, 28.47002983f, 54.98761368f, 64.72391510f, + 41.17515182f, 45.48504257f, 66.77935028f, 96.41430664f, 77.21109009f, + 55.44864655f, 51.22275925f, 53.08966064f, 29.07206917f, 28.41476440f, + 56.13959503f, 36.53352356f, 29.27622604f, 32.17654037f, 56.98409653f, + 71.59062958f, 45.24163818f, 62.93268585f, 56.08460236f, 58.77624512f, + 83.24846649f, 77.55653381f, 67.72992706f, 56.03655624f, 26.93898010f, + 24.48547745f, 32.31073380f, 62.12464905f, 95.42501068f, 50.29490280f, + 44.81559372f, 39.43442535f, 34.77753448f, 45.90629196f, 80.09409332f, + 83.13093567f, 48.40743637f, 48.72597885f, 60.92992783f, 67.21363831f, + 31.60326195f, 28.92547798f, 37.78547287f, 39.16407013f, 55.79271317f, + 65.47225189f, 69.30518341f, 58.04764175f, 57.82527161f, 55.20221710f, + 47.90188980f, 62.40616226f, 69.62246704f, 70.67929077f, 69.63761139f, + 66.63272095f, 29.59915161f, 27.48261261f, 35.14276886f, 39.17920303f, + 90.62158203f, 67.90657043f, 38.77464294f, 42.96372223f, 35.70911789f, + 36.67858124f, 43.03745651f, 56.11576843f, 88.13270569f, 89.82960510f, + 64.29818726f, 62.52038956f, 41.88219452f, 33.49052429f, 44.98608780f, + 36.17403793f, 41.16875076f, 56.70652771f, 48.73784256f, 71.57128143f, + 69.24300385f, 48.56510544f, 67.38247681f, 68.62966919f, 51.11661911f, + 45.62579346f, 46.49620056f, 70.30479431f, 28.50153351f, 41.65053177f, + 74.93982697f, 41.58124542f, 37.32712555f, 40.98759079f, 59.76941681f, + 63.07977295f, 44.12331009f, 56.90774918f, 55.65740967f, 48.48997498f, + 58.76491928f, 69.81462860f, 72.95185852f, 69.19013214f, 30.06960487f, + 26.09254837f, 59.50636292f, 66.71000671f, 42.29006958f, 58.85589218f, + 64.21626282f, 45.71190643f, 60.08098221f, 62.70387268f, 38.91758728f, + 32.85036469f, 37.27833176f, 58.38954163f, 91.48894501f, 86.27506256f, + 24.46445274f, 33.46820831f, 65.66596985f, 72.74819183f, 45.64891052f, + 33.25068283f, 62.67976761f, 65.43602753f, 45.98501587f, 48.36267853f, + 36.38481903f, 47.69902420f, 92.42938995f, 82.47864532f, 58.19116974f, + 58.74897003f, 31.08081245f, 23.18120003f, 51.17359161f, 101.16779327f, + 65.10298920f, 38.00490952f, 41.60630798f, 41.16596603f, 42.74139023f, + 54.11957169f, 51.80855942f, 45.24751282f, 47.37712860f, 55.24230957f, + 78.66986084f, 93.59764099f, 26.22109222f, 43.31058502f, 71.12840271f, + 39.33586121f, 41.00408554f, 47.24116898f, 57.11434174f, 47.18526077f, + 36.09568405f, 41.26922226f, 62.45367813f, 81.44187927f, 69.89323425f, + 61.88053894f, 61.97871017f, 69.51184082f, 23.57955742f, 23.88466072f, + 81.55332947f, 69.46887970f, 34.53810883f, 35.39361954f, 37.68282318f, + 43.16726685f, 41.51604462f, 36.21642303f, 50.22421646f, 98.07154083f, + 79.60334778f, 49.96912384f, 61.44383240f, 71.57108307f, 52.62379074f, + 34.04034042f, 39.85871124f, 50.32118225f, 37.48392868f, 37.08398056f, + 57.30740356f, 52.34113312f, 48.11880875f, 65.17064667f, 59.22914124f, + 52.78776550f, 65.37060547f, 62.33963776f, 63.87888718f, 82.38067627f, + 34.59612274f, 34.49519348f, 41.94660568f, 35.91946793f, 49.33207321f, + 52.03366470f, 56.57223129f, 43.96832275f, 35.52185440f, 48.36158752f, + 50.62252426f, 66.76281738f, 97.41931152f, 80.74346161f, 69.20502472f, + 68.50171661f, 28.37327385f, 33.89537048f, 59.31214905f, 44.07299423f, + 51.99851990f, 54.78195190f, 55.98205948f, 47.41673279f, 37.20127106f, + 43.55690002f, 48.23084641f, 80.54396057f, 84.69123077f, 50.28728867f, + 57.10305023f, 76.65652466f, 28.21533585f, 32.52445221f, 86.66576385f, + 86.09087372f, 43.16950226f, 46.15630722f, 57.47613144f, 48.09718323f, + 59.58281708f, 70.17431641f, 52.33071136f, 53.06081390f, 57.05317307f, + 48.81638336f, 45.59243774f, 55.13225555f, 46.21962738f, 66.56465912f, + 72.56446838f, 56.91426086f, 56.43696594f, 58.91387558f, 60.05456543f, + 58.88148880f, 59.75614548f, 57.46108246f, 54.28297806f, 53.08645630f, + 50.65118027f, 48.99625778f, 48.34797287f, 52.37127686f, 35.75634384f, + 63.81522751f, 85.60957336f, 67.98733521f, 72.45655060f, 66.58245850f, + 54.62078476f, 46.85538483f, 43.41488266f, 41.68208313f, 44.34422684f, + 49.20368958f, 50.78888702f, 52.99479675f, 55.61487961f, 60.11945343f, + 21.97690582f, 24.60343552f, 89.33682251f, 86.11702728f, 33.86256790f, + 31.32287407f, 39.93796158f, 53.70496368f, 49.88062668f, 45.86664963f, + 68.58612823f, 82.87562561f, 63.69519424f, 50.66447830f, 51.70297623f, + 56.78165817f, 21.67534256f, 40.34953308f, 99.62911987f, 43.56707001f, + 33.17560577f, 38.71137238f, 42.87627792f, 37.20338821f, 30.02617645f, + 33.78417587f, 45.37812042f, 99.21356201f, 101.36063385f, 58.21515274f, + 59.44672775f, 56.71328735f, 29.49651146f, 24.55385780f, 49.14814377f, + 89.08448792f, 66.54791260f, 47.46413422f, 47.81396866f, 39.32986832f, + 36.96180725f, 62.31585312f, 65.87332916f, 41.30357361f, 50.98836899f, + 82.09771729f, 78.23535156f, 61.49948883f, 27.37726212f, 31.65637589f, + 69.43057251f, 42.97422409f, 49.50066376f, 64.19516754f, 43.38182449f, + 59.92191696f, 48.06811523f, 36.99844360f, 59.22207260f, 80.73378754f, + 65.57009888f, 56.09910583f, 55.02647400f, 58.67771149f, 36.78656387f, + 29.96942520f, 39.47150803f, 33.00797653f, 54.62816238f, 70.02225494f, + 48.32385635f, 50.30700302f, 46.13695145f, 43.43633652f, 62.87342834f, + 91.06671906f, 69.28872681f, 48.51445770f, 56.97172165f, 73.30443573f, + 38.13494873f, 32.24038696f, 41.02093887f, 36.30622101f, 57.12064362f, + 71.10481262f, 49.63396454f, 50.20743561f, 51.43164825f, 51.57761765f, + 53.56945801f, 49.98236084f, 48.39651489f, 71.63349915f, 95.46888733f, + 74.99383545f, 35.17610931f, 31.45412064f, 64.53784943f, 55.69260406f, + 41.86282730f, 50.88761902f, 48.60056305f, 50.77645111f, 51.11251831f, + 43.16846848f, 44.47324753f, 47.32735825f, 49.34292603f, 83.79014587f, + 103.07089233f, 66.52885437f, 34.91808319f, 28.19522858f, 49.81605530f, + 52.10576248f, 35.89753342f, 35.38637543f, 35.23908615f, 61.95359421f, + 113.69660950f, 66.97486115f, 42.81861496f, 52.64135361f, 50.28179169f, + 41.25332642f, 62.54451370f, 87.57741547f, 36.11969757f, 26.53855896f, + 50.27358246f, 51.92799377f, 33.02027130f, 34.57915497f, 34.29354477f, + 48.55658722f, 94.36264801f, 55.36539459f, 40.45243835f, 67.74715424f, + 63.65488434f, 60.88786316f, 77.15895081f, 74.78061676f, 33.33308029f, + 29.09128571f, 61.67295837f, 47.37999344f, 31.65302658f, 35.21455002f, + 37.29717255f, 69.56938934f, 86.32746124f, 43.20579147f, 36.14655685f, + 46.24681854f, 45.82084656f, 64.79587555f, 98.21845245f, 80.80149841f, + 27.14248276f, 28.80326462f, 40.52916336f, 34.56164169f, 40.12372589f, + 65.32350159f, 79.31365967f, 68.50655365f, 71.76698303f, 68.20982361f, + 61.45349503f, 61.85831451f, 62.45957947f, 61.27304459f, 59.87812805f, + 61.21359253f, 36.54257202f, 32.30891800f, 59.97655487f, 49.97169876f, + 36.86036301f, 52.59625626f, 48.59771729f, 52.43449020f, 63.96591949f, + 52.74033356f, 48.84372330f, 52.91386795f, 84.34142303f, 91.18651581f, + 56.71543121f, 51.45142746f, 26.78902435f, 25.13040924f, 73.48807526f, + 70.56851959f, 37.37528610f, 39.61826324f, 41.60355377f, 48.74739075f, + 50.14381409f, 43.74727249f, 52.19654083f, 58.06746292f, 63.68207932f, + 81.95114899f, 82.07016754f, 70.03555298f, 26.55171204f, 30.35668945f, + 66.99411774f, 37.16141891f, 28.50297356f, 34.57562637f, 53.09408951f, + 55.35205841f, 39.21624374f, 52.82180786f, 61.94337845f, 81.44139099f, + 88.24986267f, 67.79347229f, 65.54416656f, 65.74330139f, 25.64266777f, + 28.94634819f, 60.90471649f, 71.56941223f, 56.19982529f, 43.69511414f, + 34.02218628f, 32.31221008f, 55.36420822f, 87.13250732f, 73.97786713f, + 71.22916412f, 65.30374908f, 58.61976242f, 63.82756042f, 62.22309875f, + 29.42667389f, 29.18475533f, 60.52156448f, 60.53834534f, 59.30995178f, + 68.47309113f, 49.47060776f, 59.00800705f, 59.03788757f, 52.27059937f, + 54.26659775f, 50.33647156f, 49.21657562f, 53.90012741f, 67.93323517f, + 72.64030457f, 52.70161819f, 39.99518585f, 43.94145203f, 44.90818405f, + 42.22129822f, 47.93509293f, 51.81373978f, 48.15493774f, 61.45544815f, + 70.51400757f, 58.27124405f, 62.90043640f, 70.44403076f, 67.03193665f, + 59.98938751f, 59.49853897f, 31.87010193f, 26.31987190f, 54.47800827f, + 43.22328186f, 31.45675278f, 35.08499146f, 38.76694489f, 66.19170380f, + 61.14185333f, 57.77470779f, 77.22586060f, 66.21171570f, 69.75552368f, + 76.36651611f, 67.52690125f, 61.88909149f, 30.44549942f, 32.31820679f, + 45.57734680f, 38.14467239f, 51.88415527f, 48.25827026f, 55.28089142f, + 47.30094147f, 52.80366516f, 92.02010345f, 59.57464218f, 46.85560608f, + 48.76711273f, 43.70464706f, 59.03880310f, 86.42306519f, 29.08301926f, + 22.57310104f, 34.33633804f, 35.00811768f, 54.06639099f, 103.70252228f, + 66.43305969f, 49.89102554f, 71.02000427f, 49.13789749f, 34.29194641f, + 43.82691193f, 61.71987915f, 78.80532837f, 73.96313477f, 61.74487305f, + 27.73894501f, 28.70202065f, 45.61611938f, 32.97626495f, 31.28823280f, + 37.26791763f, 71.78433228f, 79.15342712f, 59.47504425f, 69.53830719f, + 66.82013702f, 64.95858765f, 65.01549530f, 63.24348450f, 60.97856140f, + 62.80610657f, 27.57221794f, 24.39394760f, 33.77619171f, 33.13829041f, + 71.12453461f, 82.77764893f, 51.30236435f, 52.40961838f, 49.01937485f, + 59.80195236f, 77.56819153f, 86.10384369f, 68.75656891f, 52.21301270f, + 45.78854752f, 48.21636963f, 24.06404305f, 27.07773781f, 69.14982605f, + 56.84390640f, 47.25941849f, 54.36014175f, 58.30286026f, 67.57962799f, + 41.16304398f, 29.33624077f, 37.65505219f, 71.09774017f, 86.70954895f, + 70.26335907f, 65.02716827f, 63.02545547f, 33.37455750f, 26.72333336f, + 35.18984222f, 31.04051208f, 64.39746094f, 99.43074799f, 48.59360504f, + 45.98094559f, 44.35056305f, 38.26673508f, 48.61328125f, 48.73290253f, + 49.29114532f, 79.37200928f, 93.23593903f, 63.16757965f, 21.59132957f, + 25.49298668f, 71.01719666f, 84.42379761f, 53.44499969f, 52.94273376f, + 72.89039612f, 68.64645386f, 46.97680283f, 38.79965210f, 42.73474121f, + 52.71775818f, 60.41701889f, 63.08420181f, 64.22211456f, 67.28025055f, + 21.89855576f, 27.83234024f, 68.68400574f, 61.83190155f, 57.32409668f, + 65.99078369f, 57.21675110f, 62.40436935f, 61.00146103f, 59.13877869f, + 59.00645828f, 58.52240372f, 58.46230316f, 58.43955612f, 56.01047134f, + 58.15670395f, 30.96079826f, 28.86873436f, 37.56067276f, 38.71757507f, + 79.31478119f, 78.18986511f, 50.61719894f, 63.17142487f, 70.36816406f, + 60.94702530f, 47.13932037f, 48.31149673f, 46.21164703f, 43.35731506f, + 47.09792709f, 70.39653015f, 23.77980423f, 28.24261856f, 48.67664337f, + 76.31697083f, 67.86864471f, 43.46442413f, 59.16133881f, 74.37849426f, + 48.08635330f, 33.94245529f, 46.92239761f, 81.53016663f, 81.53174591f, + 60.97972107f, 54.23860168f, 55.46714401f, 26.28499794f, 29.91284180f, + 46.31903839f, 43.75836945f, 75.23796844f, 59.59530640f, 55.86365509f, + 55.63940048f, 31.57254410f, 34.93405914f, 62.86548996f, 97.04029846f, + 67.28402710f, 49.97871399f, 51.12545013f, 58.50247574f, 25.86953545f, + 25.67130661f, 36.89023590f, 65.07382965f, 85.44828796f, 54.66888046f, + 44.56608200f, 44.56648636f, 72.82321930f, 70.15782166f, 48.38794708f, + 48.31065750f, 46.63700104f, 48.24217987f, 60.40505219f, 80.37291718f, + 29.64596558f, 27.92177200f, 33.96648407f, 55.24999619f, 71.02349091f, + 49.56125259f, 51.49148560f, 45.18648911f, 49.42793274f, 48.21702576f, + 48.70598602f, 83.63790894f, 84.38695526f, 57.71953583f, 60.53441620f, + 67.29040527f, 29.55237579f, 33.49652100f, 56.31692123f, 40.10456848f, + 57.33588028f, 62.43098831f, 45.69797134f, 55.42858505f, 46.18419647f, + 39.69566727f, 40.85213852f, 46.84600830f, 78.06649017f, 99.77924347f, + 72.71241760f, 60.43941879f, 30.89263916f, 33.95299911f, 60.34748077f, + 78.54538727f, 63.12105179f, 54.42975616f, 53.94228363f, 41.31426620f, + 43.81251907f, 48.22406387f, 50.74752808f, 67.54508209f, 70.06299591f, + 56.05704880f, 60.18289948f, 72.14845276f, 27.40541267f, 23.21533012f, + 31.33833885f, 36.89186478f, 94.03147888f, 92.18949890f, 41.53026581f, + 38.83160019f, 36.70827484f, 41.26368713f, 52.58258438f, 54.43003845f, + 68.39715576f, 82.05222321f, 68.04830933f, 60.02172089f, 37.43375778f, + 67.53905487f, 84.03999329f, 62.07997131f, 66.22523499f, 68.93660736f, + 65.38884735f, 59.50014877f, 54.52999878f, 48.62021637f, 46.25228882f, + 45.71772385f, 44.52745819f, 45.32447433f, 46.65079498f, 52.15478897f, + 76.12829590f, 69.90707397f, 60.88018417f, 59.67306519f, 69.79356384f, + 68.00685883f, 59.25265121f, 54.78600311f, 51.42123413f, 46.81361771f, + 44.72520065f, 43.54372406f, 43.40436554f, 44.30783463f, 44.60446167f, + 49.75890350f, 78.58826447f, 67.18058014f, 54.08536530f, 48.41952133f, + 50.25127411f, 51.25906372f, 51.50946045f, 51.11488342f, 53.01088333f, + 53.32189178f, 54.00339890f, 55.81242752f, 53.92714691f, 52.62067413f, + 51.96416473f, 56.06571198f, 24.74991989f, 29.11821938f, 91.61383057f, + 69.48088074f, 37.06432724f, 42.15169525f, 45.90179443f, 63.15735626f, + 61.88145828f, 51.93773270f, 49.75987625f, 47.64082336f, 50.82057571f, + 55.14278030f, 58.39253998f, 70.08444214f, 28.16965485f, 29.31967163f, + 32.71649933f, 57.83382034f, 69.27395630f, 53.38219833f, 59.67870331f, + 33.72189331f, 28.52124786f, 34.58098602f, 43.50675964f, 73.86998749f, + 109.15721130f, 74.96228027f, 50.93960190f, 58.17417145f, 29.14766312f, + 24.02442360f, 32.21295166f, 32.49707794f, 69.84065247f, 90.56945038f, + 48.73727036f, 44.94636917f, 43.75082397f, 59.32031631f, 68.06079865f, + 53.07934189f, 62.79975891f, 72.22282410f, 67.47800446f, 62.26689529f, + 24.22199821f, 24.30853844f, 57.83673859f, 97.65560150f, 58.07064056f, + 34.08103561f, 33.33621597f, 53.74912643f, 68.01794434f, 48.17714691f, + 49.81681824f, 63.22098541f, 70.75649261f, 72.17205048f, 65.89617157f, + 59.56274033f, 27.69730377f, 24.43465614f, 32.55577087f, 35.62110901f, + 83.35758209f, 75.03337860f, 44.08871078f, 43.26962280f, 38.11668015f, + 41.34130096f, 63.63392639f, 91.22867584f, 68.86619568f, 54.75460052f, + 58.76897430f, 66.21032715f, 37.35518646f, 31.99437332f, 42.38615799f, + 34.22846985f, 51.48179245f, 76.71948242f, 53.30300522f, 51.89649963f, + 47.13976669f, 40.48551559f, 46.38737106f, 76.64321136f, 103.93244171f, + 71.85894775f, 50.41750336f, 51.54095078f, 28.85683060f, 30.88228226f, + 53.69935608f, 37.09889221f, 31.00023842f, 34.82223511f, 74.04431915f, + 62.77407455f, 32.02605438f, 40.63477707f, 69.22469330f, 100.53865814f, + 73.51525879f, 57.67640305f, 49.90647125f, 54.14498520f, 29.61500931f, + 30.87433434f, 37.06995773f, 50.76168060f, 69.29536438f, 52.55547333f, + 53.13591003f, 36.13773727f, 29.73791695f, 41.21875000f, 79.24547577f, + 106.57115936f, 56.77584076f, 39.86819077f, 61.37645340f, 75.19174957f, + 28.30440140f, 38.89139938f, 66.74124908f, 37.46420670f, 42.79446411f, + 47.74041748f, 53.14031601f, 53.99964905f, 37.16692734f, 37.94214630f, + 55.01705933f, 98.37632751f, 82.15518951f, 60.47322845f, 59.07986069f, + 55.52326965f, 34.24888611f, 34.06593704f, 36.45554352f, 44.36808395f, + 73.18087769f, 51.21831131f, 58.24463654f, 53.04191208f, 34.35956573f, + 60.25250244f, 96.49848175f, 68.12080383f, 47.24505234f, 47.19258118f, + 49.34179688f, 62.62845230f, 30.19637871f, 32.96672440f, 44.05630493f, + 34.17293167f, 40.46246719f, 49.17797089f, 50.53604507f, 40.10102463f, + 50.14830780f, 95.34430695f, 84.24397278f, 60.41412735f, 55.20934677f, + 55.36225128f, 70.56622314f, 69.67316437f, 35.14830780f, 32.30957794f, + 55.72906876f, 42.05350494f, 35.95722961f, 45.69368744f, 55.22116470f, + 74.65226746f, 54.14055634f, 52.08957672f, 66.35743713f, 47.25928879f, + 47.88355637f, 74.31385803f, 81.42047882f, 70.09598541f, 30.62301254f, + 27.24707031f, 53.35401154f, 39.12836456f, 30.26208305f, 31.85187721f, + 40.98994827f, 91.76765442f, 74.72691345f, 50.20461273f, 68.43885803f, + 67.97496796f, 60.76320267f, 60.42381287f, 60.18946075f, 66.94487000f, + 22.73421860f, 27.39487839f, 52.47588348f, 49.92472458f, 60.75211334f, + 78.33421326f, 68.94541931f, 63.79943848f, 61.94213867f, 61.49895096f, + 59.60924149f, 59.09317398f, 58.65007019f, 57.68883133f, 56.06912613f, + 60.42691040f, 21.75316048f, 20.77889061f, 39.23469543f, 75.50487518f, + 76.20504761f, 60.15762329f, 63.76489639f, 64.21314240f, 61.56743622f, + 57.45051575f, 59.25061035f, 59.76544952f, 59.35617447f, 58.87415695f, + 57.96597290f, 60.81930161f, 22.21710587f, 25.30570602f, 57.19749069f, + 64.90682220f, 67.63256073f, 57.77220917f, 43.37454224f, 66.96671295f, + 65.91177368f, 51.56299591f, 70.96542358f, 85.82904053f, 64.62564087f, + 49.31163406f, 38.47437286f, 44.94469070f, 36.07413101f, 29.92312622f, + 40.66774368f, 36.15398788f, 44.95003510f, 101.12895966f, 86.96417999f, + 43.18052673f, 50.16093063f, 61.23469162f, 48.31414413f, 58.88009262f, + 62.18779755f, 47.51422501f, 47.66326904f, 62.00125504f, 32.11720276f, + 33.41061401f, 36.28831100f, 45.99550247f, 73.34411621f, 56.46103668f, + 61.42068863f, 54.61499405f, 54.93304443f, 62.93020630f, 55.84457397f, + 61.80632019f, 59.61034775f, 55.79121017f, 55.16328049f, 67.91851807f, + 27.20767021f, 37.00852966f, 57.18434143f, 43.52794647f, 63.39742279f, + 57.88319778f, 59.86457062f, 65.88842010f, 44.95322418f, 59.17788315f, + 67.63705444f, 59.36702347f, 53.74018478f, 49.94276047f, 52.20279312f, + 62.82994843f, 29.02539825f, 26.63498878f, 57.90202332f, 85.36663055f, + 42.73936081f, 43.63980484f, 66.81975555f, 42.92092514f, 48.27086639f, + 72.59160614f, 54.35919952f, 51.75491333f, 67.39468384f, 64.49733734f, + 56.79810715f, 58.08383560f, 28.58060646f, 22.74833488f, 54.07825089f, + 111.31721497f, 66.03354645f, 35.38137436f, 36.51008987f, 36.88007736f, + 45.99224472f, 67.57579041f, 56.96130371f, 46.03073883f, 55.14943314f, + 66.87574768f, 68.81295776f, 67.44326019f, 23.47033501f, 29.47317886f, + 102.57007599f, 68.41741180f, 30.67175674f, 34.38528824f, 41.43571091f, + 58.23853302f, 55.66437531f, 46.08085251f, 44.12660599f, 41.67513275f, + 56.00514603f, 74.56895447f, 68.68479156f, 67.67321014f, 24.88741493f, + 43.82337570f, 95.62670135f, 49.02528381f, 39.62008286f, 47.32071304f, + 49.80189514f, 43.83912659f, 37.29087448f, 45.93240738f, 59.59160995f, + 67.09440613f, 70.97201538f, 70.89601898f, 63.09349442f, 63.39022827f, + 102.22576904f, 75.45988464f, 53.77607727f, 47.50698471f, 40.41980743f, + 37.76411438f, 38.27172089f, 42.70124054f, 51.29972458f, 54.99493408f, + 54.58897018f, 54.10474396f, 52.00009537f, 51.14828873f, 51.67758179f, + 59.54081345f, 24.84206390f, 23.40861702f, 71.38685608f, 92.77749634f, + 41.97495270f, 33.94096756f, 37.41461563f, 51.38677979f, 55.38788223f, + 42.29495621f, 50.45867538f, 86.82837677f, 89.91969299f, 55.11670685f, + 47.34526443f, 51.68705368f, 24.91025543f, 37.88228226f, 66.81151581f, + 38.04747391f, 39.49282455f, 43.21199036f, 47.52063751f, 36.89085388f, + 34.37616348f, 79.67692566f, 81.96594238f, 56.52114105f, 53.27249146f, + 44.01078033f, 67.97731781f, 81.57801819f, 29.63401604f, 34.02974319f, + 45.98505020f, 59.92497253f, 65.54274750f, 45.05346298f, 48.13533401f, + 42.83655548f, 40.98011398f, 59.71934891f, 74.14730072f, 82.86124420f, + 81.31180573f, 63.14473724f, 50.12644196f, 52.50730133f, 35.76043701f, + 32.11127090f, 46.82095337f, 37.35770798f, 44.94866562f, 73.62842560f, + 58.67256165f, 61.36848831f, 58.88263321f, 52.95913315f, 58.93379211f, + 61.88537979f, 83.97660065f, 76.26807404f, 49.11487579f, 47.00580978f, + 26.98147011f, 36.55282974f, 69.19075012f, 62.18497467f, 64.29322052f, + 67.54309845f, 63.32001495f, 65.42429352f, 63.58644867f, 61.17696762f, + 57.99259949f, 58.00358200f, 53.90764236f, 49.32493973f, 46.58947754f, + 52.76522064f, 31.00034142f, 38.92043686f, 79.35646057f, 48.59160995f, + 47.72912598f, 58.66611862f, 55.26951981f, 55.72875595f, 41.78349304f, + 43.65134048f, 48.62068558f, 52.36624527f, 64.23863220f, 74.26587677f, + 64.54032898f, 62.47298813f, 43.43863678f, 48.34838867f, 61.46944809f, + 38.23884201f, 37.26012039f, 43.96838760f, 51.73004150f, 66.47560883f, + 59.89195633f, 63.15715408f, 73.52404022f, 68.43296814f, 57.99526596f, + 53.37960052f, 52.53592300f, 58.50771713f, 31.44836807f, 37.54881668f, + 50.96245575f, 35.10600662f, 36.63582611f, 54.37725830f, 63.53458786f, + 56.28988266f, 64.99540710f, 50.55338669f, 63.97557831f, 107.88322449f, + 68.96430206f, 46.70220947f, 42.79805756f, 49.48856735f, 24.39008331f, + 37.63390732f, 75.63178253f, 39.89515305f, 35.02666092f, 41.01152039f, + 48.38898087f, 38.79004669f, 31.43542290f, 41.38462830f, 66.17842102f, + 102.32599640f, 84.91678619f, 64.59684753f, 65.25298309f, 64.47338104f, + 29.48563957f, 27.78212166f, 73.72246552f, 67.35079956f, 33.26398849f, + 42.70332718f, 49.36284637f, 44.77936554f, 69.30042267f, 68.03928375f, + 41.34254074f, 41.16074371f, 65.35512543f, 78.48603821f, 62.71489716f, + 60.93986130f, 37.14540482f, 67.46842194f, 93.93869019f, 64.33036804f, + 52.85181046f, 46.39006042f, 44.03501511f, 44.49140930f, 48.88271713f, + 52.02955246f, 53.33543015f, 56.13254547f, 56.21807098f, 55.10010529f, + 55.17017746f, 60.21377182f, 76.23497009f, 69.92237091f, 62.97297287f, + 66.73405457f, 68.03582001f, 55.66715622f, 45.41874695f, 40.62066269f, + 38.72326279f, 40.44689560f, 46.92369461f, 52.79742432f, 53.86170578f, + 54.69544601f, 54.99558258f, 57.94821930f, 89.85523987f, 84.22457886f, + 69.22385406f, 59.71983719f, 51.88126373f, 42.39007568f, 37.81760406f, + 39.07238007f, 43.24521255f, 47.43628693f, 52.17528152f, 54.82188034f, + 52.81221771f, 50.87530518f, 50.12046432f, 55.67862320f, 96.67877197f, + 67.81649780f, 46.17552567f, 39.40610123f, 38.46431732f, 40.53482056f, + 43.52210999f, 48.92483902f, 55.39977264f, 57.51078415f, 55.75929260f, + 54.66993713f, 52.35992432f, 52.74879074f, 54.34913254f, 62.35863113f, + 68.98082733f, 63.03712082f, 53.79784393f, 51.12783432f, 54.01675797f, + 54.89172363f, 53.94263458f, 53.26175308f, 55.46403503f, 55.97488785f, + 56.30199432f, 56.04262543f, 54.17489624f, 53.18113708f, 52.33756256f, + 55.29016876f, 28.75065422f, 44.35783386f, 66.28974915f, 61.66216660f, + 66.98233795f, 62.13458252f, 59.73792648f, 54.33398056f, 53.89686966f, + 55.61928940f, 55.51991272f, 56.46464539f, 55.46454239f, 57.31410980f, + 57.58850098f, 61.00199509f, 27.25502205f, 24.55155945f, 66.80747223f, + 124.76464844f, 60.31520462f, 32.28490067f, 35.59736633f, 36.04310989f, + 47.63801193f, 72.28716278f, 54.79343033f, 47.74478912f, 55.85177612f, + 46.97123718f, 45.37574387f, 66.26371765f, 24.34076118f, 33.39995193f, + 91.47109985f, 87.90158081f, 68.10491943f, 60.05513000f, 50.07935333f, + 47.85038757f, 41.90112305f, 42.53277206f, 48.71320343f, 53.20432281f, + 55.66915894f, 58.04410172f, 58.44812393f, 63.16614914f, 22.15181923f, + 30.43225861f, 88.97502136f, 81.30101776f, 58.48758316f, 58.84383392f, + 45.22598267f, 38.66847992f, 43.58890152f, 51.26040268f, 59.37908936f, + 64.50835419f, 60.89634705f, 59.20288849f, 61.58885574f, 62.35607910f, + 30.21978951f, 25.56132126f, 53.77295685f, 61.58668900f, 41.43342590f, + 61.70607758f, 60.53200912f, 44.01621246f, 61.36420822f, 52.45355606f, + 41.65804291f, 60.24726486f, 64.97768402f, 61.98981094f, 73.40084076f, + 72.28564453f, + +}; \ No newline at end of file diff --git a/decoder/ixheaacd_basic_funcs.c b/decoder/ixheaacd_basic_funcs.c new file mode 100644 index 0000000..d684368 --- /dev/null +++ b/decoder/ixheaacd_basic_funcs.c @@ -0,0 +1,191 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" + +#define sat16_m(a) ixheaacd_sat16(a) + +VOID ixheaacd_fix_mant_exp_add(WORD16 op1_mant, WORD16 op1_exp, WORD16 op2_mant, + WORD16 op2_exp, WORD16 *ptr_result_mant, + WORD16 *ptr_result_exp) { + WORD32 new_mant; + WORD32 new_exp; + new_exp = op1_exp - op2_exp; + if (new_exp < 0) { + op1_mant = op1_mant >> (-new_exp); + new_exp = op2_exp; + } else { + op2_mant = op2_mant >> new_exp; + new_exp = op1_exp; + } + + new_mant = op1_mant + op2_mant; + + if (ixheaacd_abs32(new_mant) >= 0x8000) { + new_mant = new_mant >> 1; + new_exp++; + } + + *ptr_result_mant = new_mant; + *ptr_result_exp = (WORD16)(new_exp); +} + +WORD32 ixheaacd_fix_mant_div(WORD16 op1_mant, WORD16 op2_mant, + WORD16 *ptr_result_mant, + ixheaacd_misc_tables *pstr_common_tables) + +{ + WORD32 pre_shift_val, post_shift_val; + WORD32 index; + WORD16 one_by_op2_mant; + + pre_shift_val = ixheaacd_norm32(op2_mant) - 16; + + index = (op2_mant << pre_shift_val) >> (SHORT_BITS - 3 - 8); + + index &= (1 << (8 + 1)) - 1; + + if (index == 0) { + post_shift_val = ixheaacd_norm32(op1_mant) - 16; + + *ptr_result_mant = (op1_mant << post_shift_val); + } else { + WORD32 ratio_m; + + index = ((index - 1) >> 1); + + one_by_op2_mant = pstr_common_tables->inv_table[index]; + + ratio_m = ixheaacd_mult16x16in32(one_by_op2_mant, op1_mant); + + post_shift_val = ixheaacd_norm32(ratio_m) - 1; + + *ptr_result_mant = (WORD16)((ratio_m << post_shift_val) >> 15); + } + return (pre_shift_val - post_shift_val); +} + +VOID ixheaacd_fix_mant_exp_sqrt(WORD16 *ptr_in_out, WORD16 *sqrt_table) { + WORD32 index; + WORD32 pre_shift_val; + WORD32 op_mant = *ptr_in_out; + WORD32 op_exp = *(ptr_in_out + 1); + WORD32 result_m; + WORD32 result_e; + + if (op_mant > 0) { + pre_shift_val = (ixheaacd_norm32((WORD16)op_mant) - 16); + op_exp = (op_exp - pre_shift_val); + index = (op_mant << pre_shift_val) >> (SHORT_BITS - 3 - 8); + index &= (1 << (8 + 1)) - 1; + result_m = sqrt_table[index >> 1]; + if ((op_exp & 1) != 0) { + result_m = (result_m * 0x5a82) >> 16; + op_exp += 3; + } + result_e = (op_exp >> 1); + + } else { + result_m = 0; + result_e = -SHORT_BITS; + } + + *ptr_in_out++ = (WORD16)result_m; + *ptr_in_out = (WORD16)result_e; +} + +WORD32 ixheaacd_fix_div_dec(WORD32 op1, WORD32 op2) { + WORD32 quotient = 0; + UWORD32 abs_num, abs_den; + WORD32 k; + WORD32 sign; + + abs_num = ixheaacd_abs32(op1 >> 1); + abs_den = ixheaacd_abs32(op2 >> 1); + sign = op1 ^ op2; + + if (abs_num != 0) { + for (k = 15; k > 0; k--) { + quotient = (quotient << 1); + abs_num = (abs_num << 1); + if (abs_num >= abs_den) { + abs_num -= abs_den; + quotient++; + } + } + } + if (sign < 0) quotient = -(quotient); + + return quotient; +} + +#define ONE_IN_Q30 0x40000000 + +static PLATFORM_INLINE WORD32 ixheaacd_one_by_sqrt_calc(WORD32 op) { + WORD32 a = ixheaacd_add32_sat(0x900ebee0, + ixheaacd_mult32x16in32_shl_sat(op, 0x39d9)); + WORD32 iy = + ixheaacd_add32_sat(0x573b645a, ixheaacd_mult32x16h_in32_shl_sat(op, a)); + + iy = ixheaacd_shl32_dir_sat_limit(iy, 1); + + a = ixheaacd_mult32_shl_sat(op, iy); + a = ixheaacd_sub32_sat(ONE_IN_Q30, ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32_shl_sat(a, iy), 1)); + iy = ixheaacd_add32_sat(iy, ixheaacd_mult32_shl_sat(a, iy)); + + a = ixheaacd_mult32_shl_sat(op, iy); + a = ixheaacd_sub32_sat(ONE_IN_Q30, ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32_shl_sat(a, iy), 1)); + iy = ixheaacd_add32_sat(iy, ixheaacd_mult32_shl_sat(a, iy)); + + a = ixheaacd_mult32_shl_sat(op, iy); + a = ixheaacd_sub32_sat(ONE_IN_Q30, ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32_shl_sat(a, iy), 1)); + iy = ixheaacd_add32_sat(iy, ixheaacd_mult32_shl_sat(a, iy)); + + return iy; +} + +WORD32 ixheaacd_sqrt(WORD32 op) { + WORD32 result = 0; + WORD16 shift; + + if (op != 0) { + shift = (WORD16)(ixheaacd_norm32(op) & ~1); + op = ixheaacd_shl32_dir_sat_limit(op, shift); + shift = ixheaacd_shr32_dir_sat_limit(shift, 1); + op = ixheaacd_mult32_shl_sat(ixheaacd_one_by_sqrt_calc(op), op); + result = ixheaacd_shr32_dir_sat_limit(op, ixheaacd_sat16(shift - 1)); + } + + return result; +} diff --git a/decoder/ixheaacd_basic_funcs.h b/decoder/ixheaacd_basic_funcs.h new file mode 100644 index 0000000..7a078b7 --- /dev/null +++ b/decoder/ixheaacd_basic_funcs.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_FUNCS_H +#define IXHEAACD_BASIC_FUNCS_H + +#define LOG_2_TABLE_SIZE 65 +#define INV_TABLE_SIZE 256 +#define SQRT_TABLE_SIZE 256 + +WORD32 ixheaacd_sqrt(WORD32 op); + +VOID ixheaacd_fix_mant_exp_add(WORD16 a_m, WORD16 a_e, WORD16 b_m, WORD16 b_e, + WORD16 *ptr_sum_mant, WORD16 *ptr_sum_exp); + +WORD32 ixheaacd_fix_mant_div(WORD16 a_m, WORD16 b_m, WORD16 *ptr_result, + ixheaacd_misc_tables *pstr_common_tables); + +VOID ixheaacd_fix_mant_exp_sqrt(WORD16 *mant, WORD16 *sqrt_table); + +WORD32 ixheaacd_fix_div_dec(WORD32 divident, WORD32 divisor); + +WORD32 ixheaacd_fix_div_armv7(WORD32 divident, WORD32 divisor); + +VOID ixheaacd_mantisa_mod(WORD32 b_m, WORD32 b_e, WORD32 *ptr_sum_mant, + WORD32 *ptr_sum_exp); + +extern VOID ixheaacd_scale_short_vec_left(WORD16 *word16_arr, WORD32 n, + WORD16 shift); + +extern VOID ixheaacd_scale_int_vec_left(WORD32 *word32_arr, WORD32 n, + WORD16 shift); + +extern VOID ixheaacd_scale_int_vec_right(WORD32 *word32_arr, WORD32 n, + WORD16 shift); + +extern VOID ixheaacd_scale_short_vec_right(WORD16 *word16_arr, WORD32 n, + WORD16 shift); + +#endif /* IXHEAACD_BASIC_FUNCS_H */ diff --git a/decoder/ixheaacd_basic_ops.c b/decoder/ixheaacd_basic_ops.c new file mode 100644 index 0000000..f36a1ae --- /dev/null +++ b/decoder/ixheaacd_basic_ops.c @@ -0,0 +1,607 @@ +/****************************************************************************** + * * + * 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 +#include + +#include "ixheaacd_constants.h" + +#include +#include "ixheaacd_windows.h" + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_sh1(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 31); + + return (result); +} + +VOID ixheaacd_memset(FLOAT32 *x, WORD32 n) { + memset(x, 0, n * sizeof(FLOAT32)); + return; +} + +VOID ixheaacd_mem_cpy(const FLOAT32 x[], FLOAT32 y[], WORD32 n) { + memcpy(y, x, n * sizeof(FLOAT32)); + return; +} + +VOID ixheaacd_vec_cnst_mul(FLOAT32 a, FLOAT32 x[], FLOAT32 z[], WORD32 n) { + WORD32 i; + for (i = 0; i < n; i++) { + z[i] = (FLOAT32)a * x[i]; + } + return; +} + +VOID ixheaacd_combine_fac(WORD32 *src1, WORD32 *src2, WORD32 *dest, WORD32 len, + WORD8 output_q, WORD8 fac_q) { + WORD32 i; + if (fac_q > output_q) { + for (i = 0; i < len; i++) { + *dest = ixheaacd_add32_sat(*src1, ((*src2) >> (fac_q - output_q))); + dest++; + src1++; + src2++; + } + } else { + for (i = 0; i < len; i++) { + *dest = ixheaacd_add32_sat(*src1, ((*src2) << (output_q - fac_q))); + dest++; + src1++; + src2++; + } + } +} + +WORD8 ixheaacd_windowing_long1(WORD32 *src1, WORD32 *src2, + const WORD32 *win_fwd, const WORD32 *win_rev, + WORD32 *dest, WORD32 vlen, WORD8 shift1, + WORD8 shift2) { + WORD32 i; + WORD32 *rsrc2 = src2 + vlen - 1; + + if (shift1 > shift2) { + for (i = 0; i < vlen / 2; i++) { + *dest = ixheaacd_add32_sat( + ((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(*rsrc2, *win_fwd)); + + src1++; + src2++; + win_fwd++; + win_rev--; + rsrc2--; + dest++; + } + return (shift2); + } else { + for (i = 0; i < vlen / 2; i++) { + *dest = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(*src1, *win_fwd), + ((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(*rsrc2, *win_fwd)) >> (shift2 - shift1))); + src1++; + src2++; + win_fwd++; + win_rev--; + rsrc2--; + dest++; + } + return (shift1); + } +} + +WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, + WORD32 *fac_data_out, WORD32 *over_lap, + WORD32 *p_out_buffer, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap, WORD8 fac_q) { + WORD32 i; + WORD32 *dest = p_out_buffer; + + win_fwd += ixheaacd_drc_offset->lfac; + + if (shiftp > fac_q) { + if (shift_olap > fac_q) { + for (i = 0; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = over_lap[i] >> (shift_olap - fac_q); + } + + for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + 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) >> + (shiftp - fac_q)), + (*fac_data_out)); + win_fwd++; + fac_data_out++; + } + + 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)); + 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); + } + return (fac_q); + } else { + memcpy(dest, over_lap, sizeof(WORD32) * (ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac)); + + for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + 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) >> + (shiftp - shift_olap)), + (*fac_data_out) >> (fac_q - shift_olap)); + win_fwd++; + fac_data_out++; + } + + 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)); + 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); + } + return (shift_olap); + } + } else { + if (shift_olap > shiftp) { + for (i = 0; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = over_lap[i] >> (shift_olap - shiftp); + } + + for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + 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), + (*fac_data_out) >> (fac_q - shiftp)); + win_fwd++; + fac_data_out++; + } + + 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)); + 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]; + } + return (shiftp); + } else { + memcpy(dest, over_lap, sizeof(WORD32) * (ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac)); + + for (i = ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + 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) >> + (shiftp - shift_olap)), + (*fac_data_out) >> (fac_q - shift_olap)); + win_fwd++; + fac_data_out++; + } + + 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)); + 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); + } + return (shift_olap); + } + } +} + +WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd, + WORD32 *over_lap, WORD32 *p_out_buffer, + const WORD32 *win_rev, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap) { + WORD32 i; + WORD32 *dest = p_out_buffer; + + if (shiftp > shift_olap) { + memcpy(dest, over_lap, sizeof(FLOAT32) * ixheaacd_drc_offset->n_flat_ls); + + for (i = ixheaacd_drc_offset->n_flat_ls; + i < ixheaacd_drc_offset->n_long / 2; i++) { + dest[i] = ixheaacd_add32_sat( + (ixheaacd_mult32_sh1(src1[i], *win_fwd) >> (shiftp - shift_olap)), + ixheaacd_mult32_sh1(over_lap[i], *win_rev)); + win_fwd++; + win_rev--; + } + + for (i = ixheaacd_drc_offset->n_long / 2; + 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) >> + (shiftp - shift_olap)), + ixheaacd_mult32_sh1(over_lap[i], *win_rev)); + win_fwd++; + win_rev--; + } + + for (; i < ixheaacd_drc_offset->n_long; i++) { + dest[i] = + -src1[ixheaacd_drc_offset->n_long - i - 1] >> (shiftp - shift_olap); + } + + return (shift_olap); + } else { + for (i = 0; i < ixheaacd_drc_offset->n_flat_ls; i++) { + dest[i] = over_lap[i] >> (shift_olap - shiftp); + } + + for (i = ixheaacd_drc_offset->n_flat_ls; + i < ixheaacd_drc_offset->n_long / 2; i++) { + dest[i] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(src1[i], *win_fwd), + ixheaacd_mult32_sh1(over_lap[i], *win_rev) >> (shift_olap - shiftp)); + win_fwd++; + win_rev--; + } + + for (i = ixheaacd_drc_offset->n_long / 2; + 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(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]; + } + + return (shiftp); + } +} + +VOID ixheaacd_windowing_short1(WORD32 *src1, WORD32 *src2, WORD32 *fp, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap) { + WORD32 i; + WORD32 *dest = fp; + + if (shift_olap > shiftp) { + if (ixheaacd_drc_offset->n_short > ixheaacd_drc_offset->lfac) { + for (i = 0; i < ixheaacd_drc_offset->lfac; i++) { + dest[i] = dest[i] >> (shift_olap - shiftp); + } + 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]); + } + + for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = 0; + } + } else { + for (i = 0; i < ixheaacd_drc_offset->lfac; i++) { + dest[i] = dest[i] >> (shift_olap - shiftp); + } + for (i = ixheaacd_drc_offset->lfac; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = 0; + } + } + } else { + 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); + } + + for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = 0; + } + } else { + for (i = ixheaacd_drc_offset->lfac; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; + i++) { + dest[i] = 0; + } + } + } +} + +VOID ixheaacd_windowing_short2(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap) { + WORD32 i; + + WORD32 *win_rev = win_fwd + ixheaacd_drc_offset->n_short - 1; + + if (shift_olap > shiftp) { + for (i = 0; i < ixheaacd_drc_offset->n_short / 2; i++) { + fp[i] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(src1[i], *win_fwd), + (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(fp[ixheaacd_drc_offset->n_short - i - 1], + *win_fwd) >> + (shift_olap - shiftp))); + win_fwd++; + win_rev--; + } + + for (i = ixheaacd_drc_offset->n_short; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_short; + i++) { + fp[i] = 0; + } + } else { + for (i = 0; i < ixheaacd_drc_offset->n_short / 2; i++) { + fp[i] = ixheaacd_add32_sat( + (ixheaacd_mult32_sh1(src1[i], *win_fwd) >> (shiftp - shift_olap)), + 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(fp[ixheaacd_drc_offset->n_short - i - 1], + *win_fwd)); + + win_fwd++; + win_rev--; + } + + for (i = ixheaacd_drc_offset->n_short; + i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_short; + i++) { + fp[i] = 0; + } + } +} + +WORD8 ixheaacd_windowing_short3(WORD32 *src1, WORD32 *win_rev, WORD32 *fp, + WORD32 n_short, WORD8 shiftp, + WORD8 shift_olap) { + WORD32 i; + const WORD32 *win_fwd = win_rev - n_short + 1; + 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), + (fp[i] >> (shift_olap - shiftp))); + + fp[n_short - i - 1] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd), + (fp[n_short - i - 1] >> (shift_olap - shiftp))); + win_rev--; + win_fwd++; + } + return (shiftp); + } 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) >> + (shiftp - shift_olap)), + fp[i]); + + fp[n_short - i - 1] = ixheaacd_add32_sat( + (ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd) >> + (shiftp - shift_olap)), + fp[n_short - i - 1]); + + win_rev--; + win_fwd++; + } + return (shift_olap); + } +} + +WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, + WORD32 *win_fwd1, WORD32 n_short, WORD32 flag, + WORD8 shiftp, WORD8 shift_olap, + WORD8 output_q) { + WORD32 i; + const WORD32 *win_rev = win_fwd + n_short - 1; + const WORD32 *win_rev1 = win_fwd1 - n_short + 1; + if (shift_olap > output_q) { + for (i = 0; i < n_short / 2; i++) { + fp[i] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(src1[n_short / 2 + i], *win_fwd) >> + (shiftp - output_q), + fp[i]); + + fp[n_short - i - 1] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >> + (shiftp - output_q), + fp[n_short - i - 1]); + + win_fwd++; + win_rev--; + } + 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) >> + (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) >> + (shiftp - output_q), + (fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q))); + + win_fwd1--; + win_rev1++; + } + } 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[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat( + -src1[n_short - i - 1] >> (shiftp - output_q), + fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q)); + } + } + return (output_q); + } else { + for (i = 0; i < n_short / 2; i++) { + fp[i] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(src1[n_short / 2 + i], *win_fwd) >> + (shiftp - shift_olap), + fp[i] >> (output_q - shift_olap)); + + fp[n_short - i - 1] = ixheaacd_add32_sat( + ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >> + (shiftp - shift_olap), + fp[n_short - i - 1]); + + win_fwd++; + win_rev--; + } + 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) >> + (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) >> + (shiftp - shift_olap), + fp[3 * n_short - n_short / 2 - i - 1]); + + win_fwd1--; + win_rev1++; + } + } else { + for (; i < n_short; i++) { + fp[i + n_short / 2] = + ixheaacd_add32_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), + fp[3 * n_short - n_short / 2 - i - 1]); + } + } + return (shift_olap); + } +} + +VOID ixheaacd_scale_down(WORD32 *dest, WORD32 *src, WORD32 len, WORD8 shift1, + WORD8 shift2) { + WORD32 i; + if (shift1 > shift2) { + for (i = 0; i < len; i++) { + *dest = *src >> (shift1 - shift2); + src++; + dest++; + } + } else { + for (i = 0; i < len; i++) { + *dest = *src << (shift2 - shift1); + src++; + dest++; + } + } +} diff --git a/decoder/ixheaacd_basic_ops.h b/decoder/ixheaacd_basic_ops.h new file mode 100644 index 0000000..602ddd5 --- /dev/null +++ b/decoder/ixheaacd_basic_ops.h @@ -0,0 +1,137 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS_H +#define IXHEAACD_BASIC_OPS_H + +static PLATFORM_INLINE WORD16 ixheaacd_extract16h(WORD32 var) { + WORD16 var_out; + + var_out = (WORD16)(var >> 16); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_extract16l(WORD32 var) { + WORD16 var_out; + + var_out = (WORD16)var; + return (var_out); +} + +static PLATFORM_INLINE WORD32 ixheaacd_deposit16h_in32(WORD16 var) { + WORD32 var_out; + + var_out = (WORD32)var << 16; + return (var_out); +} + +static PLATFORM_INLINE WORD32 ixheaacd_deposit16l_in32(WORD16 var) { + WORD32 var_out; + + var_out = (WORD32)var; + return (var_out); +} + +static PLATFORM_INLINE UWORD32 ixheaacd_extu(UWORD32 a, WORD32 shift_left, + WORD32 shift_right) { + UWORD32 x; + x = (UWORD32)a << shift_left; + x = (UWORD32)x >> shift_right; + + return x; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16h_in32_shl_sat(WORD32 a, + WORD32 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD16)0x8000) { + result = (WORD32)0x7fffffff; + } else { + result = ixheaacd_mult32x16in32_shl(a, ixheaacd_extract16h(b)); + } + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_div32_pos_normb(WORD32 a, WORD32 b) { + WORD32 quotient; + UWORD32 mantissa_nr = a; + UWORD32 mantissa_dr = b; + + LOOPINDEX i; + + if (a == b) { + quotient = MAX_32; + } else { + quotient = 0; + + for (i = 0; i < 32; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + } + + return quotient; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shr32_dir_sat_limit(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32_sat(a, -b); + } else { + b = ixheaacd_min32(b, 31); + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir_sat_limit(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + b = -b; + b = ixheaacd_min32(b, 31); + out_val = ixheaacd_shr32(a, b); + } else { + out_val = ixheaacd_shl32_sat(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD64 ixheaacd_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); +} + +#endif /* IXHEAACD_BASIC_OPS_H */ diff --git a/decoder/ixheaacd_basic_ops16.h b/decoder/ixheaacd_basic_ops16.h new file mode 100644 index 0000000..4ccc336 --- /dev/null +++ b/decoder/ixheaacd_basic_ops16.h @@ -0,0 +1,331 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS16_H +#define IXHEAACD_BASIC_OPS16_H + +static PLATFORM_INLINE WORD16 ixheaacd_sat16(WORD32 op1) { + WORD16 var_out; + + if (op1 > 0X00007fffL) { + var_out = MAX_16; + } else if (op1 < (WORD32)0xffff8000L) { + var_out = (WORD16)(-32768); + } else { + var_out = (WORD16)(op1); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_add16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 + op2)); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_add16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 sum; + + sum = (WORD32)op1 + (WORD32)op2; + var_out = ixheaacd_sat16(sum); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_sub16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(op1 - op2)); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_sub16_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 diff; + + diff = (WORD32)op1 - op2; + var_out = ixheaacd_sat16(diff); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_mult16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 16)); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ((WORD16)(((WORD32)op1 * (WORD32)op2) >> 15)); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_mult16_shl_sat(WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 temp; + + temp = ((WORD32)(((WORD32)op1 * (WORD32)op2) >> 15)); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_shl16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = (WORD16)(op1 << shift); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_shl16_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + WORD32 temp; + + if (shift > 15) { + shift = 15; + } + temp = (WORD32)(op1 << shift); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_shr16(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + var_out = ((WORD16)(op1 >> shift)); + return (var_out); +} + +static PLATFORM_INLINE WORD16 shl16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 shr16_dir(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 shl16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + if (shift > 0) { + var_out = ixheaacd_shl16_sat(op1, shift); + } else { + var_out = ixheaacd_shr16(op1, (WORD16)(-shift)); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_shr16_dir_sat(WORD16 op1, WORD16 shift) { + WORD16 var_out; + + if (shift < 0) { + var_out = ixheaacd_shl16_sat(op1, (WORD16)(-shift)); + } else { + var_out = ixheaacd_shr16(op1, shift); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 norm16(WORD16 op1) { + WORD16 var_out; + + if (0 == op1) { + var_out = 0; + } else { + if ((WORD16)0xffff == op1) { + var_out = 15; + } else { + if (op1 < 0) { + op1 = (WORD16)(~op1); + } + for (var_out = 0; op1 < 0x4000; var_out++) { + op1 <<= 1; + } + } + } + + return (var_out); +} + +static PLATFORM_INLINE WORD16 bin_expo16(WORD16 op1) { + WORD16 var_out; + + var_out = ((WORD16)(15 - norm16(op1))); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_abs16(WORD16 op1) { + WORD16 var_out; + + if (op1 < 0) { + var_out = (WORD16)(-op1); + } else { + var_out = op1; + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_abs16_sat(WORD16 op1) { + WORD16 var_out; + + if (-32768 == op1) { + var_out = MAX_16; + } else { + if (op1 < 0) { + var_out = (WORD16)(-op1); + } else { + var_out = op1; + } + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_negate16(WORD16 op1) { + WORD16 var_out; + + if (-32768 == op1) { + var_out = MAX_16; + } else { + var_out = (WORD16)(-op1); + } + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_min16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 < op2 ? op1 : op2; + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_max16(WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = op1 > op2 ? op1 : op2; + return (var_out); +} + +static PLATFORM_INLINE WORD16 div16(WORD16 op1, WORD16 op2, WORD16 *q_format) { + WORD32 quotient; + UWORD16 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPIDX i; + WORD16 q_nr, q_dr; + + mantissa_nr = op1; + mantissa_dr = op2; + quotient = 0; + + if (op1 < 0 && op2 != 0) { + op1 = -op1; + sign = (WORD16)(sign ^ -1); + } + + if (op2 < 0) { + op2 = -op2; + sign = (WORD16)(sign ^ -1); + } + + if (op2 == 0) { + *q_format = 0; + return (op1); + } + + quotient = 0; + + q_nr = norm16(op1); + mantissa_nr = (UWORD16)op1 << (q_nr); + q_dr = norm16(op2); + mantissa_dr = (UWORD16)op2 << (q_dr); + *q_format = (WORD16)(14 + q_nr - q_dr); + + for (i = 0; i < 15; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return (WORD16)quotient; +} + +static PLATFORM_INLINE WORD16 mac16(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +static PLATFORM_INLINE WORD16 mac16_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16(op1, op2); + var_out = ixheaacd_add16_sat(c, var_out); + return (var_out); +} + +static PLATFORM_INLINE WORD16 mac16_shl(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + + var_out = ixheaacd_mult16_shl(op1, op2); + var_out = ixheaacd_add16(c, var_out); + return (var_out); +} + +static PLATFORM_INLINE WORD16 mac16_shl_sat(WORD16 c, WORD16 op1, WORD16 op2) { + WORD16 var_out; + WORD32 temp; + + temp = ((WORD32)op1 * (WORD32)op2) >> 15; + temp += c; + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +static PLATFORM_INLINE WORD16 ixheaacd_round16(WORD32 op1) { + WORD16 var_out; + + var_out = (WORD16)(ixheaacd_add32_sat(op1, 0x8000) >> 16); + return (var_out); +} +#endif diff --git a/decoder/ixheaacd_basic_ops32.h b/decoder/ixheaacd_basic_ops32.h new file mode 100644 index 0000000..6784ae4 --- /dev/null +++ b/decoder/ixheaacd_basic_ops32.h @@ -0,0 +1,478 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS32_H +#define IXHEAACD_BASIC_OPS32_H + +static PLATFORM_INLINE WORD32 ixheaacd_min32(WORD32 a, WORD32 b) { + WORD32 min_val; + + min_val = (a < b) ? a : b; + + return min_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_max32(WORD32 a, WORD32 b) { + WORD32 max_val; + + max_val = (a > b) ? a : b; + + return max_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shl32(WORD32 a, WORD b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); + if (b > 31) + out_val = 0; + else + out_val = (WORD32)a << b; + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shr32(WORD32 a, WORD b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); + if (b >= 31) { + if (a < 0) + out_val = -1; + else + out_val = 0; + } else { + out_val = (WORD32)a >> b; + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_sat(WORD32 a, WORD b) { + WORD32 out_val = a; + for (; b > 0; b--) { + if (a > (WORD32)0X3fffffffL) { + out_val = MAX_32; + break; + } else if (a < (WORD32)0xc0000000L) { + out_val = MIN_32; + break; + } + + a = ixheaacd_shl32(a, 1); + out_val = a; + } + return (out_val); +} + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shr32(a, -b); + } else { + out_val = ixheaacd_shl32(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shl32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shr32(a, -b); + } else { + out_val = ixheaacd_shl32_sat(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_shr32_dir(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32(a, -b); + } else { + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 shr32_dir_sat(WORD32 a, WORD b) { + WORD32 out_val; + + if (b < 0) { + out_val = ixheaacd_shl32_sat(a, -b); + } else { + out_val = ixheaacd_shr32(a, b); + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32(WORD16 a, WORD16 b) { + WORD32 product; + + product = (WORD32)a * (WORD32)b; + + return product; +} + +static PLATFORM_INLINE WORD32 mult16x16in32_32(WORD32 a, WORD32 b) { + WORD32 product; + + product = (WORD32)a * (WORD32)b; + + return product; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl(WORD16 a, WORD16 b) { + WORD32 product; + + product = ixheaacd_shl32(ixheaacd_mult16x16in32(a, b), 1); + + return product; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult16x16in32_shl_sat(WORD16 a, + WORD16 b) { + WORD32 product; + product = (WORD32)a * (WORD32)b; + if (product != (WORD32)0x40000000L) { + product = ixheaacd_shl32(product, 1); + } else { + product = MAX_32; + } + return product; +} + +static PLATFORM_INLINE WORD32 ixheaacd_add32(WORD32 a, WORD32 b) { + WORD32 sum; + + sum = (WORD32)a + (WORD32)b; + + return sum; +} + +static PLATFORM_INLINE WORD32 ixheaacd_sub32(WORD32 a, WORD32 b) { + WORD32 diff; + + diff = (WORD32)a - (WORD32)b; + + return diff; +} + +static PLATFORM_INLINE WORD32 ixheaacd_add32_sat(WORD32 a, WORD32 b) { + WORD64 sum; + + 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; + } + } + + return (WORD32)sum; +} + +static PLATFORM_INLINE WORD32 ixheaacd_add32_sat3(WORD32 a, WORD32 b, + WORD32 c) { + WORD64 sum; + + sum = (WORD64)a + (WORD64)b; + + sum = (WORD64)sum + (WORD64)c; + + if (sum > MAX_32) { + sum = MAX_32; + } + if (sum < MIN_32) { + sum = MIN_32; + } + + return (WORD32)sum; +} + +static PLATFORM_INLINE WORD32 ixheaacd_sub32_sat(WORD32 a, WORD32 b) { + WORD64 diff; + + 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; + } + } + + return (WORD32)diff; +} + +static PLATFORM_INLINE WORD ixheaacd_norm32(WORD32 a) { + WORD norm_val; + + if (a == 0) { + norm_val = 31; + } else { + if (a == (WORD32)0xffffffffL) { + norm_val = 31; + } else { + if (a < 0) { + a = ~a; + } + for (norm_val = 0; a < (WORD32)0x40000000L; norm_val++) { + a <<= 1; + } + } + } + + return norm_val; +} + +static PLATFORM_INLINE WORD ixheaacd_pnorm32(WORD32 a) { + WORD norm_val; + + if (a == 0) { + norm_val = 31; + } else { + for (norm_val = 0; a < (WORD32)0x40000000L; norm_val++) { + a <<= 1; + } + } + + return norm_val; +} + +static PLATFORM_INLINE WORD bin_expo32(WORD32 a) { + WORD bin_expo_val; + + bin_expo_val = 31 - ixheaacd_norm32(a); + + return bin_expo_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_abs32(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a < 0) { + abs_val = -a; + } + + return abs_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_abs32_nrm(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a < 0) { + abs_val = ~a; + } + + return abs_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_abs32_sat(WORD32 a) { + WORD32 abs_val; + + abs_val = a; + + if (a == MIN_32) { + abs_val = MAX_32; + } else if (a < 0) { + abs_val = -a; + } + + return abs_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_negate32(WORD32 a) { + WORD32 neg_val; + + neg_val = -a; + + return neg_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_negate32_sat(WORD32 a) { + WORD32 neg_val; + + neg_val = -a; + if (a == MIN_32) { + neg_val = MAX_32; + } + + return neg_val; +} + +static PLATFORM_INLINE WORD32 div32(WORD32 a, WORD32 b, WORD *q_format) { + WORD32 quotient; + UWORD32 mantissa_nr, mantissa_dr; + WORD16 sign = 0; + + LOOPINDEX i; + WORD q_nr, q_dr; + + mantissa_nr = a; + mantissa_dr = b; + quotient = 0; + + if ((a < 0) && (0 != b)) { + a = -a; + sign = (WORD16)(sign ^ -1); + } + + if (b < 0) { + b = -b; + sign = (WORD16)(sign ^ -1); + } + + if (0 == b) { + *q_format = 0; + return (a); + } + + quotient = 0; + + q_nr = ixheaacd_norm32(a); + mantissa_nr = (UWORD32)a << (q_nr); + q_dr = ixheaacd_norm32(b); + mantissa_dr = (UWORD32)b << (q_dr); + *q_format = (WORD)(30 + q_nr - q_dr); + + for (i = 0; i < 31; i++) { + quotient = quotient << 1; + + if (mantissa_nr >= mantissa_dr) { + mantissa_nr = mantissa_nr - mantissa_dr; + quotient += 1; + } + + mantissa_nr = (UWORD32)mantissa_nr << 1; + } + + if (sign < 0) { + quotient = -quotient; + } + + return quotient; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32(b, c); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 mac16x16hin32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32((WORD16)b, (WORD16)(c >> 16)); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_add32(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_add32_sat(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 msu16x16in32(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 msu16x16in32_shl(WORD32 a, WORD16 b, WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl(b, c); + + acc = ixheaacd_sub32(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 msu16x16in32_shl_sat(WORD32 a, WORD16 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult16x16in32_shl_sat(b, c); + + acc = ixheaacd_sub32_sat(a, acc); + + return acc; +} + +static PLATFORM_INLINE WORD32 add32_shr(WORD32 a, WORD32 b) { + WORD32 sum; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + sum = ixheaacd_add32(a, b); + + return sum; +} + +static PLATFORM_INLINE WORD32 sub32_shr(WORD32 a, WORD32 b) { + WORD32 diff; + + a = ixheaacd_shr32(a, 1); + b = ixheaacd_shr32(b, 1); + + diff = ixheaacd_sub32(a, b); + + return diff; +} +#endif diff --git a/decoder/ixheaacd_basic_ops40.h b/decoder/ixheaacd_basic_ops40.h new file mode 100644 index 0000000..028b96b --- /dev/null +++ b/decoder/ixheaacd_basic_ops40.h @@ -0,0 +1,366 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS40_H +#define IXHEAACD_BASIC_OPS40_H +#define lo64(a) (((unsigned *)&a)[0]) +#define hi64(a) (((WORD32 *)&a)[1]) + +static PLATFORM_INLINE WORD16 norm40(WORD40 *in) { + WORD16 expo; + WORD32 tempo; + + if (0 == (*in)) return 31; + + if (((*in) <= 0x7fffffff) && ((WORD40)(*in) >= (WORD40)0xFFFFFFFF80000000)) { + tempo = (WORD32)(*in); + expo = ixheaacd_norm32(tempo); + *in = tempo << expo; + + return (expo); + } + + tempo = (WORD32)((*in) >> 31); + expo = 31 - (ixheaacd_norm32(tempo)); + *in = (*in) >> expo; + + return (-expo); +} + +static PLATFORM_INLINE WORD32 add32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a + (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +static PLATFORM_INLINE WORD32 sub32_shr40(WORD32 a, WORD32 b) { + WORD40 sum; + + sum = (WORD40)a - (WORD40)b; + sum = sum >> 1; + + return ((WORD32)sum); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 16); + + return (result << 1); +} + +static PLATFORM_INLINE WORD32 mult32x16hin32_shl(WORD32 a, WORD32 b) { + WORD32 product; + WORD64 temp_product; + + temp_product = (WORD64)a * (WORD64)(b >> 16); + product = (WORD32)(temp_product >> 16); + + return (product << 1); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 16); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shl_sat(WORD32 a, + WORD16 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD16)0x8000) { + result = (WORD32)0x7fffffff; + } else { + result = ixheaacd_mult32x16in32_shl(a, b); + } + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + + return (result << 1); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl_sat(WORD32 a, WORD32 b) { + WORD32 result; + + if (a == (WORD32)0x80000000 && b == (WORD32)0x80000000) { + result = 0x7fffffff; + } else { + result = ixheaacd_mult32_shl(a, b); + } + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32_shl(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 mac32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 mac32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32_shl(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 mac32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_add32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +static PLATFORM_INLINE WORD32 msu32x16in32(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 msu32x16in32_shl(WORD32 a, WORD32 b, WORD16 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16in32_shl(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 msu32x16in32_shl_sat(WORD32 a, WORD32 b, + WORD16 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32x16in32_shl_sat(b, c))); +} + +static PLATFORM_INLINE WORD32 msu32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 msu32_shl(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32_shl(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 msu32_shl_sat(WORD32 a, WORD32 b, WORD32 c) { + return (ixheaacd_sub32_sat(a, ixheaacd_mult32_shl_sat(b, c))); +} + +static PLATFORM_INLINE WORD32 mac3216_arr40(WORD32 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32x16in32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return (WORD32)sum; +} + +static PLATFORM_INLINE WORD32 mac32_arr40(WORD32 *x, WORD32 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)(ixheaacd_mult32(x[i], y[i])); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +static PLATFORM_INLINE WORD32 mac16_arr40(WORD16 *x, WORD16 *y, + LOOPINDEX length, WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)((WORD32)x[i] * (WORD32)y[i]); + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +static PLATFORM_INLINE WORD32 add32_arr40(WORD32 *in_arr, LOOPINDEX length, + WORD16 *q_val) { + LOOPINDEX i; + WORD40 sum = 0; + + for (i = 0; i < length; i++) { + sum += (WORD40)in_arr[i]; + } + + *q_val = norm40(&sum); + + return ((WORD32)sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mult32x32in64(WORD32 a, WORD32 b) { + WORD64 result; + + result = (WORD64)a * (WORD64)b; + + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64(WORD64 sum, WORD32 a, + WORD32 b) { + sum += (WORD64)a * (WORD64)b; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_7(WORD64 sum, + const WORD32 *a, + const WORD16 *b) { + sum = (WORD64)a[0] * (WORD64)b[0]; + sum += (WORD64)a[1] * (WORD64)b[1]; + sum += (WORD64)a[2] * (WORD64)b[2]; + sum += (WORD64)a[3] * (WORD64)b[3]; + sum += (WORD64)a[4] * (WORD64)b[4]; + sum += (WORD64)a[5] * (WORD64)b[5]; + sum += (WORD64)a[6] * (WORD64)b[6]; + + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_n(WORD64 sum, + const WORD32 *a, + const WORD16 *b, + WORD32 n) { + WORD32 k; + + sum += (WORD64)a[0] * (WORD64)b[0]; + for (k = 1; k < n; k++) sum += (WORD64)a[k] * (WORD64)b[k]; + return (sum); +} + +static PLATFORM_INLINE WORD64 ixheaacd_mult64(WORD32 a, WORD32 b) { + WORD64 result; + result = (WORD64)a * (WORD64)b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_add64(WORD64 a, WORD64 b) { + WORD64 result; + result = a + b; + return (result); +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = (WORD64)a - (WORD64)b; + + return diff; +} + +static PLATFORM_INLINE WORD64 ixheaacd_sub64_sat(WORD64 a, WORD64 b) { + WORD64 diff; + + diff = ixheaacd_sub64(a, b); + + if ((((WORD64)a ^ (WORD64)b) & (WORD64)MIN_64) != 0) { + if (((WORD64)diff ^ (WORD64)a) & (WORD64)MIN_64) { + diff = (a < 0L) ? MIN_64 : MAX_64; + } + } + + return (diff); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mul32_sh(WORD32 a, WORD32 b, + WORD8 shift) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> shift); + + return (result); +} + +#endif diff --git a/decoder/ixheaacd_basic_ops_arr.h b/decoder/ixheaacd_basic_ops_arr.h new file mode 100644 index 0000000..2002501 --- /dev/null +++ b/decoder/ixheaacd_basic_ops_arr.h @@ -0,0 +1,425 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OPS_ARR_H +#define IXHEAACD_BASIC_OPS_ARR_H + +static PLATFORM_INLINE WORD16 norm32_arr(WORD32 *word32_arr, WORD32 n) { + WORD32 i; + WORD32 max_bits = 0; + + for (i = 0; i < n; i++) { + max_bits = max_bits | ixheaacd_abs32_sat(word32_arr[i]); + } + + return (ixheaacd_norm32(max_bits)); +} + +static PLATFORM_INLINE WORD16 norm16_arr(WORD16 *word16_arr, WORD32 n) { + WORD32 i; + WORD16 max_bits = 0; + + for (i = 0; i < n; i++) { + max_bits = max_bits | ixheaacd_abs16_sat(word16_arr[i]); + } + + return (norm16(max_bits)); +} + +static PLATFORM_INLINE VOID shl32_arr(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = ixheaacd_shl32(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_shr32_arr(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + *word32_arr = ixheaacd_shr32(*word32_arr, shift); + word32_arr++; + } + + return; +} + +static PLATFORM_INLINE VOID shl32_arr_dir(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = ixheaacd_shl32_dir(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shr32_arr_dir(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = ixheaacd_shr32_dir(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shl32_arr_dir_sat(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = ixheaacd_shl32_dir_sat(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shr32_arr_dir_sat(WORD32 *word32_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = shr32_dir_sat(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_shl32_arr_sat(WORD32 *word32_arr, + WORD16 shift, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + *word32_arr = ixheaacd_shl32_sat(*word32_arr, shift); + word32_arr++; + } + + return; +} + +static PLATFORM_INLINE VOID shl16_arr(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = ixheaacd_shl16(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_shr16_arr(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + *word16_arr = ixheaacd_shr16(*word16_arr, shift); + word16_arr++; + } + + return; +} + +static PLATFORM_INLINE VOID shl16_arr_dir(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = shl16_dir(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shr16_arr_dir(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = shr16_dir(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shl16_arr_dir_sat(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = shl16_dir_sat(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shr16_arr_dir_sat(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = ixheaacd_shr16_dir_sat(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shl16_arr_sat(WORD16 *word16_arr, WORD16 shift, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = ixheaacd_shl16_sat(word16_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE VOID shl3216_arr(WORD32 *word32_arr, WORD16 *word16_arr, + WORD16 shift, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = (WORD16)ixheaacd_shl32_dir(word32_arr[i], shift); + } + + return; +} + +static PLATFORM_INLINE WORD32 max32_arr(WORD32 *word32_arr, WORD32 n) { + WORD32 i; + + WORD32 max_value; + + max_value = word32_arr[0]; + + for (i = 1; i < n; i++) { + max_value = ixheaacd_max32(max_value, word32_arr[i]); + } + + return max_value; +} + +static PLATFORM_INLINE WORD32 min32_arr(WORD32 *word32_arr, WORD32 n) { + WORD32 i; + + WORD32 min_value; + + min_value = word32_arr[0]; + + for (i = 1; i < n; i++) { + min_value = ixheaacd_min32(min_value, word32_arr[i]); + } + + return min_value; +} + +static PLATFORM_INLINE WORD16 max16_arr(WORD16 *word16_arr, WORD32 n) { + WORD32 i; + + WORD16 max_value; + + max_value = word16_arr[0]; + + for (i = 1; i < n; i++) { + max_value = ixheaacd_max16(max_value, word16_arr[i]); + } + + return max_value; +} + +static PLATFORM_INLINE WORD16 min16_arr(WORD16 *word16_arr, WORD32 n) { + WORD32 i; + + WORD16 min_value; + + min_value = word16_arr[0]; + + for (i = 1; i < n; i++) { + min_value = ixheaacd_min16(min_value, word16_arr[i]); + } + + return min_value; +} + +static PLATFORM_INLINE VOID copy8(WORD8 *src, WORD8 *dst, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + dst[i] = src[i]; + } + + return; +} + +static PLATFORM_INLINE VOID copy16(WORD16 *src, WORD16 *dst, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + dst[i] = src[i]; + } + + return; +} + +static PLATFORM_INLINE VOID copy32(WORD32 *src, WORD32 *dst, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + dst[i] = src[i]; + } + + return; +} + +static PLATFORM_INLINE VOID delay8(WORD8 *word8_arr, WORD32 delay, WORD32 n) { + WORD32 source_index; + WORD32 destination_index; + + source_index = (n - 1) - delay; + destination_index = n - 1; + + for (; source_index >= 0; source_index--, destination_index--) { + word8_arr[destination_index] = word8_arr[source_index]; + } + + return; +} + +static PLATFORM_INLINE VOID delay16(WORD16 *word16_arr, WORD32 delay, + WORD32 n) { + WORD32 source_index; + WORD32 destination_index; + + source_index = (n - 1) - delay; + destination_index = n - 1; + + for (; source_index >= 0; source_index--, destination_index--) { + word16_arr[destination_index] = word16_arr[source_index]; + } + + return; +} + +static PLATFORM_INLINE VOID delay32(WORD32 *word32_arr, WORD32 delay, + WORD32 n) { + WORD32 source_index; + WORD32 destination_index; + + source_index = (n - 1) - delay; + destination_index = n - 1; + + for (; source_index >= 0; source_index--, destination_index--) { + word32_arr[destination_index] = word32_arr[source_index]; + } + + return; +} + +static PLATFORM_INLINE VOID copy_reverse16(WORD16 *src, WORD16 *dst, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + *dst++ = *src--; + } + + return; +} + +static PLATFORM_INLINE VOID copy_reverse32(WORD32 *src, WORD32 *dst, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + *dst++ = *src--; + } + + return; +} + +static PLATFORM_INLINE VOID set_val8(WORD8 *word8_arr, WORD8 set_val, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word8_arr[i] = set_val; + } + + return; +} + +static PLATFORM_INLINE VOID set_val16(WORD16 *word16_arr, WORD16 set_val, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = set_val; + } + + return; +} + +static PLATFORM_INLINE VOID set_val32(WORD32 *word32_arr, WORD32 set_val, + WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = set_val; + } + + return; +} + +static PLATFORM_INLINE VOID set_zero8(WORD8 *word8_arr, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word8_arr[i] = 0; + } + + return; +} + +static PLATFORM_INLINE VOID set_zero16(WORD16 *word16_arr, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word16_arr[i] = 0; + } + + return; +} + +static PLATFORM_INLINE VOID set_zero32(WORD32 *word32_arr, WORD32 n) { + WORD32 i; + + for (i = 0; i < n; i++) { + word32_arr[i] = 0; + } + + return; +} +#endif diff --git a/decoder/ixheaacd_bit_extract.h b/decoder/ixheaacd_bit_extract.h new file mode 100644 index 0000000..9ed8f7b --- /dev/null +++ b/decoder/ixheaacd_bit_extract.h @@ -0,0 +1,89 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BIT_EXTRACT_H +#define IXHEAACD_BIT_EXTRACT_H + +typedef struct { + WORD32 core_mode[2]; + WORD32 common_tw; + WORD32 common_window; + WORD32 tns_data_present[2]; + WORD32 tns_active; + WORD32 common_tns; + WORD32 tns_on_lr; + WORD32 tns_present_both; + WORD32 common_max_sfb; + UWORD8 max_sfb[2]; + WORD32 max_sfb_ste; + WORD32 pred_dir; + WORD32 complex_coef; + WORD32 use_prev_frame; + UWORD8 ms_mask_present[2]; + +} ia_usac_tmp_core_coder_struct; + +WORD32 ixheaacd_ics_info(ia_usac_data_struct *usac_data, WORD32 widx, + UWORD8 *max_sfb, ia_bit_buf_struct *it_bit_buff, + WORD32 window_sequence_last); + +VOID ixheaacd_calc_grp_offset(ia_sfb_info_struct *pstr_sfb_info, UWORD8 *group); + +VOID ixheaacd_read_tns_u(ia_sfb_info_struct *pstr_sfb_info, + ia_tns_frame_info_struct *pstr_tns_frame_info, + ia_bit_buf_struct *it_bit_buff); + +WORD32 ixheaacd_core_coder_data(WORD32 id, ia_usac_data_struct *usac_data, + WORD32 elem_idx, WORD32 *chan_offset, + ia_bit_buf_struct *it_bit_buff, + WORD32 nr_core_coder_channels); + +VOID usac_past_tw(ia_usac_data_struct *usac_data, WORD32 mod0, WORD32 i, + ia_usac_lpd_decoder_handle st); + +VOID usac_td2buffer(FLOAT32 p_in_data[], ia_usac_data_struct *usac_data, + WORD32 k, WORD32 mod0); + +WORD32 ixheaacd_lpd_channel_stream(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff, + FLOAT32 *synth); + +VOID ixheaacd_acelp_decoding(WORD32 k, ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff, WORD32 chan); + +VOID ixheaacd_tcx_coding(ia_usac_data_struct *usac_data, WORD32 *quant, + WORD32 k, WORD32 first_tcx_flag, + ia_td_frame_data_struct *pstr_td_frame_data, + ia_bit_buf_struct *it_bit_buff); + +WORD32 ixheaacd_win_seq_select(WORD32 window_sequence_curr, + WORD32 window_sequence_last); + +WORD32 ixheaacd_fd_channel_stream( + ia_usac_data_struct *usac_data, + ia_usac_tmp_core_coder_struct *pstr_core_coder, UWORD8 *max_sfb, + WORD32 window_sequence_last, WORD32 chn, WORD32 noise_filling_config, + WORD32 ch, ia_bit_buf_struct *it_bit_buff); + +VOID ixheaacd_read_fac_data(WORD32 lfac, WORD32 *fac_data, + ia_bit_buf_struct *it_bit_buff); + +#endif /* IXHEAACD_BIT_EXTRACT_H */ diff --git a/decoder/ixheaacd_bitbuffer.c b/decoder/ixheaacd_bitbuffer.c new file mode 100644 index 0000000..847815f --- /dev/null +++ b/decoder/ixheaacd_bitbuffer.c @@ -0,0 +1,281 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_adts_crc_check.h" + +VOID ixheaacd_byte_align(ia_bit_buf_struct *it_bit_buff, + WORD32 *align_bits_cnt) { + WORD alignment; + alignment = (WORD)((*align_bits_cnt - it_bit_buff->cnt_bits) & 0x07); + + if (alignment) { + ixheaacd_read_bits_buf(it_bit_buff, (8 - alignment)); + } + + *align_bits_cnt = it_bit_buff->cnt_bits; +} + +WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { + UWORD32 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + + ret_val = (UWORD32)*ptr_read_next; + + bit_pos -= no_of_bits; + while (bit_pos < 0) { + bit_pos += 8; + ptr_read_next++; + + if (ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + + ret_val <<= 8; + + ret_val |= (UWORD32)*ptr_read_next; + } + + ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); + + return ret_val; +} + +WORD32 ixheaacd_read_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { + UWORD32 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + + if (no_of_bits == 0) { + return 0; + } + + it_bit_buff->cnt_bits -= no_of_bits; + ret_val = (UWORD32)*ptr_read_next; + + bit_pos -= no_of_bits; + while (bit_pos < 0) { + bit_pos += 8; + ptr_read_next++; + + if (ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + + ret_val <<= 8; + + ret_val |= (UWORD32)*ptr_read_next; + } + + ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); + it_bit_buff->ptr_read_next = ptr_read_next; + it_bit_buff->bit_pos = (WORD16)bit_pos; + return ret_val; +} + +UWORD32 ixheaacd_aac_read_byte(UWORD8 **ptr_read_next, WORD32 *bit_pos, + WORD32 *readword) { + UWORD8 *v = *ptr_read_next; + WORD32 bits_consumed = *bit_pos; + + if ((bits_consumed -= 8) >= 0) { + *readword = (*readword << 8) | *v; + v++; + } else { + bits_consumed += 8; + } + *bit_pos = bits_consumed; + *ptr_read_next = v; + return 1; +} + +UWORD32 ixheaacd_aac_read_2bytes(UWORD8 **ptr_read_next, WORD32 *bit_pos, + WORD32 *readword) { + UWORD8 *v = *ptr_read_next; + WORD32 bits_consumed = *bit_pos; + + if ((bits_consumed - 16) >= 0) { + *readword = (*readword << 8) | *v; + v++; + *readword = (*readword << 8) | *v; + v++; + bits_consumed -= 16; + + } else if ((bits_consumed - 8) >= 0) { + *readword = (*readword << 8) | *v; + v++; + bits_consumed -= 8; + } + + *bit_pos = bits_consumed; + *ptr_read_next = v; + return 1; +} + +UWORD32 ixheaacd_aac_read_byte_corr1(UWORD8 **ptr_read_next, + WORD16 *ptr_bit_pos, WORD32 *readword) { + UWORD8 *v = *ptr_read_next; + WORD16 bits_consumed = *ptr_bit_pos; + + while (bits_consumed >= 8) { + if ((bits_consumed -= 8) >= 0) { + { + *readword = (*readword << 8) | *v; + v++; + } + } else { + bits_consumed += 8; + } + } + *ptr_bit_pos = bits_consumed; + *ptr_read_next = v; + return 1; +} + +UWORD32 ixheaacd_aac_read_byte_corr(UWORD8 **ptr_read_next, WORD32 *ptr_bit_pos, + WORD32 *readword, UWORD8 *p_bit_buf_end) { + UWORD8 *v = *ptr_read_next; + WORD32 bits_consumed = *ptr_bit_pos; + + if ((bits_consumed -= 8) >= 0) { + if (p_bit_buf_end < v) + bits_consumed += 8; + else { + *readword = (*readword << 8) | *v; + v++; + } + } else { + bits_consumed += 8; + } + *ptr_bit_pos = bits_consumed; + *ptr_read_next = v; + return 1; +} + +WORD32 ixheaacd_aac_read_bit(ia_bit_buf_struct *it_bit_buff) { + UWORD8 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + UWORD32 temp; + WORD no_of_bits = 1; + + if (bit_pos < 0) { + bit_pos = 7; + ptr_read_next--; + } + + it_bit_buff->cnt_bits += no_of_bits; + ret_val = *ptr_read_next; + bit_pos -= no_of_bits; + + temp = (ret_val << 24) << (bit_pos + no_of_bits); + it_bit_buff->ptr_read_next = ptr_read_next; + it_bit_buff->bit_pos = (WORD16)bit_pos; + + return temp >> (32 - no_of_bits); +} + +WORD32 ixheaacd_aac_read_bit_rev(ia_bit_buf_struct *it_bit_buff) { + UWORD8 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + UWORD32 temp; + WORD no_of_bits = 1; + + if (bit_pos >= 8) { + bit_pos -= 8; + ptr_read_next++; + } + + it_bit_buff->cnt_bits -= no_of_bits; + ret_val = *ptr_read_next; + bit_pos += no_of_bits; + + temp = (ret_val << 24) << (bit_pos - no_of_bits); + it_bit_buff->ptr_read_next = ptr_read_next; + it_bit_buff->bit_pos = (WORD16)bit_pos; + + return temp >> (32 - no_of_bits); +} + +VOID ixheaacd_write_bit(ia_bit_buf_struct *it_bit_buff, WORD32 value, + WORD32 no_of_bits) + +{ + WORD32 mask; + + if (no_of_bits == 0) return; + + mask = 0x1; + mask <<= no_of_bits - 1; + + it_bit_buff->bit_count += no_of_bits; + + while (no_of_bits > 0) { + while (no_of_bits > 0 && it_bit_buff->valid_bits < 8) { + it_bit_buff->byte <<= 1; + if (value & mask) it_bit_buff->byte |= 0x1; + value <<= 1; + no_of_bits--; + it_bit_buff->valid_bits++; + } + if (it_bit_buff->valid_bits == 8) { + *it_bit_buff->byte_ptr++ = it_bit_buff->byte; + it_bit_buff->byte = 0; + it_bit_buff->valid_bits = 0; + } + } +} + +WORD32 ixheaacd_read_bit(ia_bit_buf_struct *it_bit_buff, WORD32 no_of_bits) { + UWORD32 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->byte_ptr; + + if (no_of_bits == 0) { + return 0; + } + + ret_val = ixheaacd_aac_showbits_32(ptr_read_next); + it_bit_buff->byte_ptr += (no_of_bits >> 3); + + if (it_bit_buff->valid_bits != 8) { + UWORD8 *v = it_bit_buff->byte_ptr; + ret_val = (ret_val << (8 - it_bit_buff->valid_bits)) | + (*v >> it_bit_buff->valid_bits); + } + + it_bit_buff->valid_bits -= (no_of_bits % 8); + + ret_val = ret_val >> (32 - no_of_bits); + + return ret_val; +} diff --git a/decoder/ixheaacd_bitbuffer.h b/decoder/ixheaacd_bitbuffer.h new file mode 100644 index 0000000..0b82926 --- /dev/null +++ b/decoder/ixheaacd_bitbuffer.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BITBUFFER_H +#define IXHEAACD_BITBUFFER_H + +#define CRC_ADTS_HEADER_LEN 56 +#define CRC_ADTS_RAW_DATA_BLK_LEN 192 +#define CRC_ADTS_RAW_IIND_ICS 128 +#define CRC_ADTS_LEN_ALL -1 + +#define MAX_REG_SIZE 192 +#define MAX_CRC_REGS 7 + +struct ia_crc_bit_buf_struct { + UWORD8 *ptr_bit_buf_base; + UWORD8 *ptr_bit_buf_end; + + UWORD8 *ptr_read_next; + WORD16 bit_pos; + WORD32 cnt_bits; + + WORD32 size; +}; + +typedef struct { + UWORD8 active; + WORD32 buf_size; + WORD32 max_bits; + UWORD32 bit_cnt; + WORD32 bit_buf_cnt; + struct ia_crc_bit_buf_struct str_bit_buf; +} ia_crc_reg_data_struct; + +typedef struct { + UWORD8 crc_active; + UWORD16 no_reg; + UWORD16 file_value; + UWORD16 crc_lookup[256]; + ia_crc_reg_data_struct str_crc_reg_data[MAX_CRC_REGS]; +} ia_adts_crc_info_struct; + +typedef struct ia_bit_buf_struct { + UWORD8 *ptr_bit_buf_base; + UWORD8 *ptr_bit_buf_end; + + UWORD8 *ptr_read_next; + + WORD32 bit_pos; + WORD32 cnt_bits; + + WORD32 size; + + WORD32 adts_header_present; + WORD32 crc_check; + WORD8 protection_absent; + WORD8 no_raw_data_blocks; + ia_adts_crc_info_struct str_adts_crc_info; + ia_adts_crc_info_struct *pstr_adts_crc_info; + + WORD32 initial_cnt_bits; + WORD32 audio_mux_align; + WORD32 bit_count; + WORD32 valid_bits; + UWORD8 byte; + UWORD8 *byte_ptr; + UWORD8 *ptr_start; + WORD32 write_bit_count; + +} ia_bit_buf_struct; + +typedef struct ia_bit_buf_struct *ia_handle_bit_buf_struct; + +typedef struct ia_crc_bit_buf_struct *ia_crc_bit_buf_struct_handle; + +VOID ixheaacd_byte_align(ia_bit_buf_struct *it_bit_buff, + WORD32 *ptr_byte_align_bits); + +ia_bit_buf_struct *ixheaacd_create_bit_buf(ia_bit_buf_struct *it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); + +ia_bit_buf_struct *ixheaacd_create_init_bit_buf(ia_bit_buf_struct *it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); + +WORD32 ixheaacd_read_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits); + +WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits); + +VOID ixheaacd_read_bidirection(ia_bit_buf_struct *it_bit_buff, + WORD32 ixheaacd_drc_offset); + +UWORD32 ixheaacd_aac_showbits_32(UWORD8 *ptr_read_next); + +UWORD32 ixheaacd_aac_read_byte(UWORD8 **ptr_read_next, WORD32 *bit_pos, + WORD32 *readword); + +UWORD32 ixheaacd_aac_read_2bytes(UWORD8 **ptr_read_next, WORD32 *bit_pos, + WORD32 *readword); + +UWORD32 ixheaacd_aac_read_byte_corr(UWORD8 **ptr_read_next, WORD32 *ptr_bit_pos, + WORD32 *readword, UWORD8 *p_bit_buf_end); + +UWORD32 ixheaacd_aac_read_byte_corr1(UWORD8 **ptr_read_next, + WORD16 *ptr_bit_pos, WORD32 *readword); + +#define get_no_bits_available(it_bit_buff) ((it_bit_buff)->cnt_bits) +#define ixheaacd_no_bits_read(it_bit_buff) \ + ((it_bit_buff)->size - (it_bit_buff)->cnt_bits) + +WORD32 ixheaacd_aac_read_bit_rev(ia_bit_buf_struct *it_bit_buff); +WORD32 ixheaacd_aac_read_bit(ia_bit_buf_struct *it_bit_buff); + +VOID ixheaacd_write_bit(ia_bit_buf_struct *it_bit_buff, WORD32 value, + WORD32 no_of_bits); + +WORD32 ixheaacd_read_bit(ia_bit_buf_struct *data, WORD32 no_of_bits); + +#endif /* IXHEAACD_BITBUFFER_H */ diff --git a/decoder/ixheaacd_block.c b/decoder/ixheaacd_block.c new file mode 100644 index 0000000..1385922 --- /dev/null +++ b/decoder/ixheaacd_block.c @@ -0,0 +1,1310 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include + +#include "ixheaacd_tns.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" + +static PLATFORM_INLINE WORD32 ixheaacd_shr32_drc(WORD32 a, WORD32 b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); + if (b >= 31) { + if (a < 0) + out_val = -1; + else + out_val = 0; + } else { + a += (1 << (b - 1)); + out_val = (WORD32)a >> b; + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_drc(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + if (temp_result < (WORD64)MIN_32) + result = MIN_32; + + else if (temp_result > (WORD64)MAX_32) + result = MAX_32; + + else + result = (WORD32)(temp_result); + + return (result); +} +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16in32_drc(WORD32 a, WORD32 b, + WORD16 c) { + WORD32 acc; + + acc = ixheaacd_mult32x16in32_drc(b, c); + + acc = ixheaacd_add32_sat(a, acc); + + return acc; +} + +WORD32 ixheaacd_cnt_leading_ones(WORD32 a); + +VOID ixheaacd_huff_sfb_table(WORD32 it_bit_buff, WORD16 *huff_index, + WORD16 *len, const UWORD16 *code_book_tbl, + const UWORD32 *idx_table) { + UWORD32 temp = 0; + UWORD32 temp1 = 0; + WORD32 found = 0; + UWORD32 mask = 0x80000000; + + WORD32 leading_ones; + WORD32 max_len; + WORD32 ixheaacd_drc_offset = 0; + WORD32 length; + UWORD32 code_word; + WORD32 len_end; + + max_len = code_book_tbl[0]; + mask = mask - (1 << (31 - max_len)); + mask = mask << 1; + + temp = (UWORD32)((it_bit_buff & mask)); + + len_end = code_book_tbl[0]; + leading_ones = ixheaacd_cnt_leading_ones(temp); + do { + ixheaacd_drc_offset = (idx_table[leading_ones] >> 20) & 0x1ff; + length = code_book_tbl[ixheaacd_drc_offset + 1] & 0x1f; + code_word = idx_table[leading_ones] & 0xfffff; + temp1 = temp >> (32 - length); + if (temp1 <= code_word) { + ixheaacd_drc_offset = ixheaacd_drc_offset - (code_word - temp1); + found = 1; + } else { + len_end = len_end + ((idx_table[leading_ones] >> 29) & 0x7); + leading_ones = len_end; + } + } while (!found); + *huff_index = code_book_tbl[ixheaacd_drc_offset + 1] >> 5; + *len = length; +} + +VOID ixheaacd_inverse_quantize(WORD32 *x_invquant, WORD no_band, + WORD32 *ixheaacd_pow_table_Q13, + WORD8 *scratch_in) { + WORD32 j; + WORD32 temp; + WORD32 q_abs; + + for (j = no_band - 1; j >= 0; j--) { + q_abs = *scratch_in++; + temp = (ixheaacd_pow_table_Q13[q_abs]); + *x_invquant++ = -temp; + } +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_word1( + ia_bit_buf_struct *it_bit_buff, WORD32 *spec_coef, WORD16 *offsets, + WORD no_bands, WORD group_len, const UWORD16 *code_book_tbl, + WORD32 *ixheaacd_pow_table_Q13, const UWORD32 *idx_table) { + WORD32 sp1, sp2; + WORD32 flush_cw; + WORD32 i, value, norm_val, off; + WORD idx, grp_idx; + WORD32 out1, out2; + WORD32 err_code = 0; + WORD len_idx = 0; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + WORD16 index, length; + ptr_read_next += 4; + + do { + len_idx = offsets[1] - offsets[0]; + grp_idx = group_len; + + do { + spec_coef = spec_coef + offsets[0]; + idx = len_idx; + do { + { + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + ixheaacd_huff_sfb_table(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + } + + out1 = index / 17; + out2 = index - out1 * 17; + flush_cw = read_word << bit_pos; + + sp1 = out1; + sp2 = out2; + + if (out1) { + if (flush_cw & 0x80000000) { + out1 = -out1; + } + bit_pos++; + flush_cw = (WORD32)flush_cw << 1; + } + + if (out2) { + bit_pos++; + if (flush_cw & 0x80000000) { + out2 = -out2; + } + } + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + if (sp1 == 16) { + i = 4; + value = ixheaacd_extu(read_word, bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + bit_pos += (norm_val - 21); + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(read_word, bit_pos, 32 - i); + + bit_pos += i; + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + i = off + ((WORD32)1 << i); + + if (i <= IQ_TABLE_SIZE_HALF) + i = ixheaacd_pow_table_Q13[i]; + else { + err_code |= ixheaacd_inv_quant(&i, ixheaacd_pow_table_Q13); + } + + if (out1 < 0) { + out1 = -i; + } else { + out1 = i; + } + *spec_coef++ = out1; + } else { + if (out1 <= 0) { + out1 = -out1; + out1 = ixheaacd_pow_table_Q13[out1]; + *spec_coef++ = -out1; + } else { + out1 = ixheaacd_pow_table_Q13[out1]; + *spec_coef++ = out1; + } + } + + if (sp2 == 16) { + i = 4; + value = ixheaacd_extu(read_word, bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + + bit_pos += (norm_val - 21); + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(read_word, bit_pos, 32 - i); + + bit_pos += i; + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + i = off + ((WORD32)1 << i); + + if (i <= IQ_TABLE_SIZE_HALF) + i = ixheaacd_pow_table_Q13[i]; + else { + err_code |= ixheaacd_inv_quant(&i, ixheaacd_pow_table_Q13); + } + + if (out2 < 0) { + out2 = -i; + } else { + out2 = i; + } + *spec_coef++ = out2; + } else { + if (out2 <= 0) { + out2 = -out2; + out2 = ixheaacd_pow_table_Q13[out2]; + *spec_coef++ = -out2; + } else { + out2 = ixheaacd_pow_table_Q13[out2]; + *spec_coef++ = out2; + } + } + + idx -= 2; + } while (idx != 0); + + spec_coef += (MAX_BINS_SHORT - offsets[1]); + grp_idx--; + } while (grp_idx != 0); + + offsets++; + spec_coef -= (MAX_BINS_SHORT * group_len); + no_bands--; + } while (no_bands >= 0); + + it_bit_buff->bit_pos = bit_pos; + it_bit_buff->ptr_read_next = ptr_read_next - 4; + + return err_code; +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_word2_11( + ia_bit_buf_struct *it_bit_buff, WORD32 width, const UWORD16 *code_book_tbl, + WORD32 *x_invquant, WORD32 *ixheaacd_pow_table_Q13, WORD8 *ptr_scratch, + const UWORD32 *idx_table) { + WORD32 sp1, sp2; + WORD32 flush_cw; + WORD32 i, value, norm_val, off; + WORD idx; + WORD32 out1, out2; + WORD32 err_code = 0; + WORD16 index, length; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next += 4; + + for (idx = width; idx != 0; idx -= 2) { + { + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + ixheaacd_huff_sfb_table(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + } + + flush_cw = read_word << bit_pos; + out1 = index / 17; + out2 = index - out1 * 17; + sp1 = out1; + + if (out1) { + if (flush_cw & 0x80000000) { + out1 = -out1; + } + + bit_pos++; + flush_cw = (WORD32)flush_cw << 1; + } + + sp2 = out2; + if (out2) { + bit_pos++; + if (flush_cw & 0x80000000) { + out2 = -out2; + } + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + if (sp1 == 16) { + i = 4; + value = ixheaacd_extu(read_word, bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + i += (norm_val - 22); + bit_pos += (norm_val - 21); + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(read_word, bit_pos, 32 - i); + + bit_pos += i; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + value = *ptr_scratch++; + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + i = off + ((WORD32)1 << i); + i += value; + + if (i <= IQ_TABLE_SIZE_HALF) + i = ixheaacd_pow_table_Q13[i]; + else { + err_code |= ixheaacd_inv_quant(&i, ixheaacd_pow_table_Q13); + } + if (out1 < 0) { + i = -i; + } + *x_invquant++ = i; + } else { + WORD8 temp = *ptr_scratch++; + if (out1 <= 0) { + out1 = temp - out1; + out1 = ixheaacd_pow_table_Q13[out1]; + *x_invquant++ = -out1; + } else { + out1 += temp; + out1 = ixheaacd_pow_table_Q13[out1]; + *x_invquant++ = out1; + } + } + + if (sp2 == 16) { + i = 4; + value = ixheaacd_extu(read_word, bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + + bit_pos += (norm_val - 21); + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(read_word, bit_pos, 32 - i); + + bit_pos += i; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + value = *ptr_scratch++; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + + i = off + ((WORD32)1 << i); + i += value; + if (i <= IQ_TABLE_SIZE_HALF) + i = ixheaacd_pow_table_Q13[i]; + else { + err_code |= ixheaacd_inv_quant(&i, ixheaacd_pow_table_Q13); + } + + if (out2 < 0) { + i = -i; + } + *x_invquant++ = i; + + } else { + WORD8 temp = *ptr_scratch++; + if (out2 <= 0) { + out2 = temp - out2; + out2 = ixheaacd_pow_table_Q13[out2]; + *x_invquant++ = -out2; + } else { + out2 += temp; + out2 = ixheaacd_pow_table_Q13[out2]; + *x_invquant++ = out2; + } + } + } + + it_bit_buff->ptr_read_next = ptr_read_next - 4; + it_bit_buff->bit_pos = bit_pos; + + return err_code; +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_quad( + ia_bit_buf_struct *it_bit_buff, WORD32 *spec_coef, WORD16 *offsets, + WORD no_bands, WORD group_len, const UWORD16 *code_book_tbl, + WORD32 *ixheaacd_pow_table_Q13, WORD32 tbl_sign, const UWORD32 *idx_table) { + WORD idx, grp_idx; + WORD idx_len; + WORD32 *spec_orig; + WORD16 index, length; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next += 4; + spec_orig = spec_coef; + do { + idx_len = offsets[1] - offsets[0]; + grp_idx = group_len; + + do { + spec_coef = spec_coef + offsets[0]; + idx = idx_len; + do { + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + if (tbl_sign) { + WORD32 temp_word; + WORD32 w, x, y, z; + temp_word = read_word << bit_pos; + w = index / 27; + index = index - w * 27; + x = index / 9; + index = index - x * 9; + y = index / 3; + z = index - y * 3; + if (w) { + w = ixheaacd_pow_table_Q13[w]; + if (temp_word & 0x80000000) w = -w; + temp_word <<= 1; + bit_pos++; + } + *spec_coef++ = w; + + if (x) { + x = ixheaacd_pow_table_Q13[x]; + if (temp_word & 0x80000000) x = -x; + temp_word <<= 1; + bit_pos++; + } + *spec_coef++ = x; + if (y) { + y = ixheaacd_pow_table_Q13[y]; + if (temp_word & 0x80000000) y = -y; + temp_word <<= 1; + bit_pos++; + } + *spec_coef++ = y; + if (z) { + z = ixheaacd_pow_table_Q13[z]; + if (temp_word & 0x80000000) z = -z; + temp_word <<= 1; + bit_pos++; + } + *spec_coef++ = z; + + } + + else { + WORD32 w, x, y, z; + + w = index / 27 - 1; + index = index - (w + 1) * 27; + x = index / 9 - 1; + index = index - (x + 1) * 9; + y = index / 3 - 1; + z = index - ((y + 1) * 3) - 1; + if (w < 0) { + w = -w; + w = ixheaacd_pow_table_Q13[w]; + w = -w; + } else + w = ixheaacd_pow_table_Q13[w]; + + *spec_coef++ = w; + + if (x < 0) { + x = -x; + x = ixheaacd_pow_table_Q13[x]; + x = -x; + } else + x = ixheaacd_pow_table_Q13[x]; + + *spec_coef++ = x; + + if (y < 0) { + y = -y; + y = ixheaacd_pow_table_Q13[y]; + y = -y; + } else + y = ixheaacd_pow_table_Q13[y]; + + *spec_coef++ = y; + + if (z < 0) { + z = -z; + z = ixheaacd_pow_table_Q13[z]; + z = -z; + } else + z = ixheaacd_pow_table_Q13[z]; + + *spec_coef++ = z; + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + idx -= 4; + } while (idx != 0); + + spec_coef += (MAX_BINS_SHORT - offsets[1]); + grp_idx--; + } while (grp_idx != 0); + offsets++; + spec_coef = spec_orig; + no_bands--; + } while (no_bands >= 0); + + it_bit_buff->ptr_read_next = ptr_read_next - 4; + it_bit_buff->bit_pos = bit_pos; + + return 0; +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_word2_quad( + ia_bit_buf_struct *it_bit_buff, WORD32 width, const UWORD16 *code_book_tbl, + WORD32 *x_invquant, WORD32 *ixheaacd_pow_table_Q13, WORD8 *ptr_scratch, + WORD32 tbl_sign, const UWORD32 *idx_table) { + WORD idx; + WORD16 index, length; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next += 4; + + for (idx = width; idx != 0; idx -= 4) { + WORD32 ampres, ampres1; + WORD32 ampres2, ampres3; + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + if (tbl_sign) { + WORD32 w, x, y, z; + WORD32 ampout0, ampout1, ampout2, ampout3; + WORD32 temp_word; + temp_word = read_word << bit_pos; + + w = index / 27; + index = index - w * 27; + x = index / 9; + index = index - x * 9; + y = index / 3; + z = index - y * 3; + + ampout0 = w + *ptr_scratch++; + ampout0 = ixheaacd_pow_table_Q13[ampout0]; + + if (w) { + if (temp_word & 0x80000000) { + ampout0 = -ampout0; + } + temp_word = temp_word << 1; + bit_pos++; + } else { + ampout0 = -ampout0; + } + + ampout1 = x + *ptr_scratch++; + ampout1 = ixheaacd_pow_table_Q13[ampout1]; + + if (x) { + if (temp_word & 0x80000000) { + ampout1 = -ampout1; + } + temp_word = temp_word << 1; + bit_pos++; + } else { + ampout1 = -ampout1; + } + + ampout2 = y + *ptr_scratch++; + ampout2 = ixheaacd_pow_table_Q13[ampout2]; + + if (y) { + if (temp_word & 0x80000000) { + ampout2 = -ampout2; + } + temp_word = temp_word << 1; + bit_pos++; + } else { + ampout2 = -ampout2; + } + + ampout3 = z + *ptr_scratch++; + ampout3 = ixheaacd_pow_table_Q13[ampout3]; + + if (z) { + if (temp_word & 0x80000000) { + ampout3 = -ampout3; + } + temp_word = temp_word << 1; + bit_pos++; + } else { + ampout3 = -ampout3; + } + *x_invquant++ = ampout0; + *x_invquant++ = ampout1; + *x_invquant++ = ampout2; + *x_invquant++ = ampout3; + } else { + WORD32 w, x, y, z; + ampres = *ptr_scratch++; + ampres1 = *ptr_scratch++; + ampres2 = *ptr_scratch++; + ampres3 = *ptr_scratch++; + + w = index / 27 - 1; + index = index - (w + 1) * 27; + x = index / 9 - 1; + index = index - (x + 1) * 9; + y = index / 3 - 1; + z = index - ((y + 1) * 3) - 1; + if (w <= 0) { + ampres = ampres - w; + ampres = ixheaacd_pow_table_Q13[ampres]; + ampres = -ampres; + } else { + ampres += w; + ampres = ixheaacd_pow_table_Q13[ampres]; + } + + if (x <= 0) { + ampres1 = ampres1 - x; + ampres1 = ixheaacd_pow_table_Q13[ampres1]; + ampres1 = -ampres1; + } else { + ampres1 += x; + ampres1 = ixheaacd_pow_table_Q13[ampres1]; + } + + if (y <= 0) { + ampres2 = ampres2 - y; + ampres2 = ixheaacd_pow_table_Q13[ampres2]; + ampres2 = -ampres2; + } else { + ampres2 += y; + ampres2 = ixheaacd_pow_table_Q13[ampres2]; + } + + if (z <= 0) { + ampres3 = ampres3 - z; + ampres3 = ixheaacd_pow_table_Q13[ampres3]; + ampres3 = -ampres3; + } else { + ampres3 += z; + ampres3 = ixheaacd_pow_table_Q13[ampres3]; + } + + *x_invquant++ = ampres; + *x_invquant++ = ampres1; + *x_invquant++ = ampres2; + *x_invquant++ = ampres3; + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + } + + it_bit_buff->ptr_read_next = ptr_read_next - 4; + it_bit_buff->bit_pos = bit_pos; + + return 0; +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_pair( + ia_bit_buf_struct *it_bit_buff, WORD32 *spec_coef, WORD16 *offsets, + WORD no_bands, WORD group_len, const UWORD16 *code_book_tbl, + WORD32 *ixheaacd_pow_table_Q13, WORD32 tbl_sign, const UWORD32 *idx_table, + WORD32 huff_mode) + +{ + WORD idx, grp_idx; + WORD len_idx; + WORD16 index, length; + WORD32 y, z; + WORD32 *spec_orig = spec_coef; + + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next += 4; + + do { + len_idx = offsets[1] - offsets[0]; + grp_idx = group_len; + do { + spec_coef += offsets[0]; + idx = len_idx; + do { + UWORD32 read_word1; + read_word1 = read_word << bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + if (tbl_sign) { + WORD32 temp_word; + temp_word = read_word << bit_pos; + y = index / huff_mode; + z = index - huff_mode * y; + if (y) { + y = ixheaacd_pow_table_Q13[y]; + if (temp_word & 0x80000000) y = -y; + + temp_word = temp_word << 1; + bit_pos++; + } + *spec_coef++ = y; + + if (z) { + z = ixheaacd_pow_table_Q13[z]; + if (temp_word & 0x80000000) { + z = -z; + } + temp_word <<= 1; + bit_pos++; + } + *spec_coef++ = z; + } else { + y = (index / huff_mode) - 4; + z = index - ((y + 4) * huff_mode) - 4; + if (y < 0) { + y = -y; + y = ixheaacd_pow_table_Q13[y]; + y = -y; + } else + y = ixheaacd_pow_table_Q13[y]; + + if (z < 0) { + z = -z; + z = ixheaacd_pow_table_Q13[z]; + z = -z; + } else + z = ixheaacd_pow_table_Q13[z]; + + *spec_coef++ = y; + *spec_coef++ = z; + } + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + idx -= 2; + } while (idx != 0); + + spec_coef += (MAX_BINS_SHORT - offsets[1]); + grp_idx--; + } while (grp_idx != 0); + + offsets++; + spec_coef = spec_orig; + no_bands--; + } while (no_bands >= 0); + + it_bit_buff->ptr_read_next = ptr_read_next - 4; + it_bit_buff->bit_pos = bit_pos; + + return 0; +} + +static PLATFORM_INLINE WORD ixheaacd_huffman_dec_word2_pair( + ia_bit_buf_struct *it_bit_buff, WORD32 width, const UWORD16 *code_book_tbl, + WORD32 *x_invquant, WORD32 *ixheaacd_pow_table_Q13, WORD8 *ptr_scratch, + WORD32 tbl_sign, const UWORD32 *idx_table, WORD32 huff_mode) + +{ + WORD32 ampres; + WORD idx; + WORD16 index, length; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = it_bit_buff->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next += 4; + + for (idx = width; idx != 0; idx -= 2) { + { + UWORD32 read_word1; + read_word1 = read_word << bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + } + + if (tbl_sign) { + WORD32 out0, out1, temp_word; + WORD32 ampout0, ampout1; + + ampout0 = *ptr_scratch++; + ampout1 = *ptr_scratch++; + out0 = index / huff_mode; + out1 = index - huff_mode * out0; + ampout0 += out0; + ampout0 = ixheaacd_pow_table_Q13[ampout0]; + + ampout1 += out1; + ampout1 = ixheaacd_pow_table_Q13[ampout1]; + temp_word = read_word << bit_pos; + if (out0) { + if (temp_word & 0x80000000) { + ampout0 = -(ampout0); + } + + bit_pos++; + temp_word = temp_word << 1; + } else { + ampout0 = -(ampout0); + } + + if (out1) { + if (temp_word & 0x80000000) { + ampout1 = -(ampout1); + } + bit_pos++; + } else { + ampout1 = -(ampout1); + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + *x_invquant++ = ampout0; + *x_invquant++ = ampout1; + } else { + WORD32 y, z; + y = (index / huff_mode) - 4; + z = index - ((y + 4) * huff_mode) - 4; + + ampres = *ptr_scratch++; + if (y <= 0) { + ampres = ampres - y; + ampres = ixheaacd_pow_table_Q13[ampres]; + *x_invquant++ = -ampres; + } else { + ampres += y; + *x_invquant++ = ixheaacd_pow_table_Q13[ampres]; + } + ampres = *ptr_scratch++; + if (z <= 0) { + ampres = ampres - z; + ampres = ixheaacd_pow_table_Q13[ampres]; + *x_invquant++ = -ampres; + } else { + ampres += z; + *x_invquant++ = ixheaacd_pow_table_Q13[ampres]; + } + } + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + } + + it_bit_buff->ptr_read_next = ptr_read_next - 4; + it_bit_buff->bit_pos = bit_pos; + + return 0; +} + +WORD ixheaacd_decode_huffman(ia_bit_buf_struct *it_bit_buff, WORD32 cb_no, + WORD32 *spec_coef, WORD16 *sfb_offset, WORD start, + WORD sfb, WORD group_len, + ia_aac_dec_tables_struct *ptr_aac_tables) { + WORD ret_val = 0; + WORD start_bit_pos = it_bit_buff->bit_pos; + UWORD8 *start_read_pos = it_bit_buff->ptr_read_next; + const UWORD16 *cb_table = (UWORD16 *)(ptr_aac_tables->code_book[cb_no]); + WORD32 huff_mode; + const UWORD32 *idx_table = (UWORD32 *)(ptr_aac_tables->index_table[cb_no]); + WORD32 *pow_table = + (WORD32 *)ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13; + WORD32 no_bands = sfb - start - 1; + WORD16 *band_offset = sfb_offset + start; + + if (cb_no == 11) { + const UWORD32 *idx_table = + ptr_aac_tables->pstr_huffmann_tables->idx_table_hf11; + const UWORD16 *cb_table = + ptr_aac_tables->pstr_huffmann_tables->input_table_cb11; + + ret_val = ixheaacd_huffman_dec_word1(it_bit_buff, spec_coef, band_offset, + no_bands, group_len, cb_table, + pow_table, idx_table); + + } else if (cb_no <= 4) { + WORD32 tbl_sign = 0; + + if (cb_no > 2) { + tbl_sign = 1; + } + ret_val = ixheaacd_huffman_dec_quad(it_bit_buff, spec_coef, band_offset, + no_bands, group_len, cb_table, + pow_table, tbl_sign, idx_table); + } + + else if (cb_no <= 10) { + WORD32 tbl_sign = 0; + huff_mode = 9; + if (cb_no > 6) { + if (cb_no > 8) + huff_mode = 13; + else + huff_mode = 8; + tbl_sign = 1; + } + ret_val = ixheaacd_huffman_dec_pair( + it_bit_buff, spec_coef, band_offset, no_bands, group_len, cb_table, + pow_table, tbl_sign, idx_table, huff_mode); + } + + { + WORD bits_cons; + bits_cons = ((it_bit_buff->ptr_read_next - start_read_pos) << 3) + + (it_bit_buff->bit_pos - start_bit_pos); + it_bit_buff->cnt_bits -= bits_cons; + } + return ret_val; +} + +WORD ixheaacd_huffman_dec_word2(ia_bit_buf_struct *it_bit_buff, WORD32 cb_no, + WORD32 width, + ia_aac_dec_tables_struct *ptr_aac_tables, + WORD32 *x_invquant, WORD8 *scratch_ptr) { + WORD ret_val = 0; + WORD32 huff_mode; + WORD start_bit_pos = it_bit_buff->bit_pos; + WORD32 *pow_table = + (WORD32 *)ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13; + UWORD8 *start_read_pos = it_bit_buff->ptr_read_next; + + const UWORD16 *cb_table = (UWORD16 *)(ptr_aac_tables->code_book[cb_no]); + const UWORD32 *idx_table = (UWORD32 *)(ptr_aac_tables->index_table[cb_no]); + + if (cb_no == 11) { + const UWORD16 *cb_table = + ptr_aac_tables->pstr_huffmann_tables->input_table_cb11; + + ret_val = ixheaacd_huffman_dec_word2_11( + it_bit_buff, width, cb_table, x_invquant, pow_table, scratch_ptr, + ptr_aac_tables->pstr_huffmann_tables->idx_table_hf11); + } else if (cb_no <= 4) { + WORD32 tbl_sign = 0; + if (cb_no > 2) tbl_sign = 1; + ret_val = ixheaacd_huffman_dec_word2_quad(it_bit_buff, width, cb_table, + x_invquant, pow_table, + scratch_ptr, tbl_sign, idx_table); + } else if (cb_no <= 10) { + WORD32 tbl_sign = 0; + huff_mode = 9; + if (cb_no > 6) { + if (cb_no > 8) { + huff_mode = 13; + } else { + huff_mode = 8; + } + + tbl_sign = 1; + } + ret_val = ixheaacd_huffman_dec_word2_pair( + it_bit_buff, width, cb_table, x_invquant, pow_table, scratch_ptr, + tbl_sign, idx_table, huff_mode); + } + + { + WORD bits_cons; + if (it_bit_buff->bit_pos <= 7) { + bits_cons = ((it_bit_buff->ptr_read_next - start_read_pos) << 3) + + (it_bit_buff->bit_pos - start_bit_pos); + it_bit_buff->cnt_bits -= bits_cons; + } else { + it_bit_buff->ptr_read_next += (it_bit_buff->bit_pos) >> 3; + it_bit_buff->bit_pos = it_bit_buff->bit_pos & 0x7; + + bits_cons = ((it_bit_buff->ptr_read_next - start_read_pos) << 3) + + ((it_bit_buff->bit_pos - start_bit_pos)); + it_bit_buff->cnt_bits -= bits_cons; + } + } + return ret_val; +} + +void ixheaacd_lap1_512_480(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, WORD16 size, + WORD16 stride) { + WORD32 accu; + WORD32 i; + WORD16 rounding_fac = -0x2000; + + WORD32 *window_i = (WORD32 *)window; + + WORD16 *ptr_out1, *ptr_out2; + + WORD32 *pwin1, *pwin2; + WORD32 *pCoef = &coef[size * 2 - 1 - 0]; + + pwin1 = &window_i[size - 1 - 0]; + pwin2 = &window_i[size + 0]; + + ptr_out1 = &out[stride * (size - 1 - 0)]; + ptr_out2 = &out[stride * (size + 0)]; + + for (i = 0; i < size; i++) { + WORD32 win1, win2, coeff; + WORD32 prev_data = *prev++; + + win1 = *pwin1--; + coeff = *pCoef--; + win2 = *pwin2++; + + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_dir_sat_limit(ixheaacd_mult32_shl(coeff, win1), q_shift), + ixheaacd_mac32x16in32_shl(rounding_fac, win2, (WORD16)(prev_data))); + + accu = ixheaacd_add32_sat(accu, accu); + accu = ixheaacd_add32_sat(accu, accu); + + *ptr_out1 = ixheaacd_shr32(accu, 16); + ptr_out1 -= stride; + + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32_shl(ixheaacd_negate32(coeff), win2), q_shift), + ixheaacd_mac32x16in32_shl(rounding_fac, win1, (WORD16)(prev_data))); + + accu = ixheaacd_add32_sat(accu, accu); + accu = ixheaacd_add32_sat(accu, accu); + + *ptr_out2 = ixheaacd_shr32(accu, 16); + ptr_out2 += stride; + } +} + +VOID ixheaacd_over_lap_add1_dec(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac) { + WORD32 accu; + WORD32 i; + WORD16 rounding_fac = -0x2000; + + for (i = 0; i < size; i++) { + WORD16 window1, window2; + + window1 = window[2 * size - 2 * i - 1]; + window2 = window[2 * size - 2 * i - 2]; + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(coef[size * 2 - 1 - i], window2), q_shift), + ixheaacd_mac32x16in32_drc(rounding_fac, prev[i], window1)); + out[ch_fac * (size - i - 1)] = + ixheaacd_shr32(ixheaacd_shl32_dir_sat_limit(accu, 2), 16); + accu = ixheaacd_sub32_sat( + ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(ixheaacd_negate32(coef[size * 2 - 1 - i]), + window1), + q_shift), + ixheaacd_mac32x16in32_drc(rounding_fac, prev[i], window2)); + out[ch_fac * (size + i)] = + ixheaacd_shr32(ixheaacd_shl32_dir_sat_limit(accu, 2), 16); + } +} + +VOID ixheaacd_over_lap_add2_dec(WORD32 *coef, WORD32 *prev, WORD32 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac) { + WORD32 accu; + WORD32 i; + + for (i = 0; i < size; i++) { + accu = ixheaacd_sub32_sat( + ixheaacd_mult32x16in32(coef[size + i], window[2 * i]), + ixheaacd_mult32x16in32(prev[size - 1 - i], window[2 * i + 1])); + out[ch_fac * i] = ixheaacd_shr32_drc(accu, 16 - (q_shift + 1)); + } + + for (i = 0; i < size; i++) { + accu = ixheaacd_sub32_sat( + ixheaacd_mult32x16in32(ixheaacd_negate32_sat(coef[size * 2 - 1 - i]), + window[2 * size - 2 * i - 1]), + ixheaacd_mult32x16in32(prev[i], window[2 * size - 2 * i - 2])); + out[ch_fac * (i + size)] = ixheaacd_shr32_drc(accu, 16 - (q_shift + 1)); + } +} + +VOID ixheaacd_process_single_scf(WORD32 scale_factor, WORD32 *x_invquant, + WORD32 width, WORD32 *ptr_scale_table, + WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) { + WORD32 j; + + WORD32 temp1; + WORD32 q_factor; + WORD32 buffer1; + WORD16 scale_short; + + object_type = 0; + aac_sf_data_resil_flag = 0; + + + if (scale_factor < 24) { + for (j = width; j > 0; j--) { + *x_invquant++ = 0; + } + } else { + WORD32 shift; + + if (total_channels > 2) + q_factor = 34 - (scale_factor >> 2); + else + q_factor = 37 - (scale_factor >> 2); + + scale_short = ptr_scale_table[(scale_factor & 0x0003)]; + shift = q_factor; + if (shift > 0) { + if (scale_short == (WORD16)0x8000) { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + buffer1 = ixheaacd_mult32x16in32_shl_sat(temp1, scale_short); + buffer1 = ixheaacd_shr32(buffer1, shift); + *x_invquant++ = buffer1; + } + } else { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + buffer1 = ixheaacd_mult32x16in32_shl(temp1, scale_short); + buffer1 = ixheaacd_shr32(buffer1, shift); + *x_invquant++ = buffer1; + } + } + } else { + shift = -shift; + if (shift > 0) { + if (scale_short == (WORD16)0x8000) { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + temp1 = ixheaacd_shl32(temp1, shift - 1); + buffer1 = ixheaacd_mult32x16in32_shl_sat(temp1, scale_short); + buffer1 = ixheaacd_shl32(buffer1, 1); + *x_invquant++ = buffer1; + } + } else { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + temp1 = ixheaacd_shl32(temp1, shift - 1); + buffer1 = ixheaacd_mult32x16in32_shl(temp1, scale_short); + buffer1 = ixheaacd_shl32(buffer1, 1); + *x_invquant++ = buffer1; + } + } + + } else { + if (scale_short == (WORD16)0x8000) { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + buffer1 = ixheaacd_mult32x16in32_shl_sat(temp1, scale_short); + *x_invquant++ = buffer1; + } + } else { + for (j = width; j > 0; j--) { + temp1 = *x_invquant; + buffer1 = ixheaacd_mult32x16in32_shl(temp1, scale_short); + *x_invquant++ = buffer1; + } + } + } + } + } +} + +VOID ixheaacd_scale_factor_process_dec(WORD32 *x_invquant, WORD16 *scale_fact, + WORD no_band, WORD8 *width, + WORD32 *ptr_scale_table, + WORD32 total_channels, + WORD32 object_type, + WORD32 aac_sf_data_resil_flag) { + WORD32 i; + WORD16 scale_factor; + + for (i = no_band - 1; i >= 0; i--) { + scale_factor = *scale_fact++; + ixheaacd_process_single_scf(scale_factor, x_invquant, *width, + ptr_scale_table, total_channels, object_type, + aac_sf_data_resil_flag); + + x_invquant += *width; + width++; + } +} + +void ixheaacd_right_shift_block(WORD32 *p_spectrum, WORD32 length, + WORD32 shift_val) { + WORD32 i; + WORD32 temp1, temp2; + WORD32 *temp_ptr = &p_spectrum[0]; + length = length >> 2; + + for (i = length - 1; i >= 0; i--) { + temp1 = *temp_ptr; + temp2 = *(temp_ptr + 1); + *temp_ptr++ = temp1 >> shift_val; + temp1 = *(temp_ptr + 1); + *temp_ptr++ = temp2 >> shift_val; + temp2 = *(temp_ptr + 1); + *temp_ptr++ = temp1 >> shift_val; + *temp_ptr++ = temp2 >> shift_val; + } +} diff --git a/decoder/ixheaacd_block.h b/decoder/ixheaacd_block.h new file mode 100644 index 0000000..52f9484 --- /dev/null +++ b/decoder/ixheaacd_block.h @@ -0,0 +1,189 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BLOCK_H +#define IXHEAACD_BLOCK_H + +#define IQ_TABLE_SIZE_HALF 128 + +VOID ixheaacd_inverse_quantize(WORD32 *x_invquant, WORD no_band, + WORD32 *ixheaacd_pow_table_Q13, + WORD8 *scratch_in); + +VOID ixheaacd_scale_factor_process_dec(WORD32 *x_invquant, WORD16 *scale_fact, + WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, + WORD32 total_channels, + WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +VOID ixheaacd_scale_factor_process_armv7(WORD32 *x_invquant, WORD16 *scale_fact, + WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, + WORD32 total_channels, + WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +VOID ixheaacd_scale_factor_process_armv8(WORD32 *x_invquant, WORD16 *scale_fact, + WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, + WORD32 total_channels, + WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +void ixheaacd_right_shift_block(WORD32 *p_spectrum, WORD length, + WORD shift_val); + +WORD ixheaacd_decode_huffman(ia_bit_buf_struct *it_bit_buff, WORD32 cb_no, + WORD32 *spec_coef, WORD16 *sfb_offset, WORD start, + WORD sfb, WORD group_len, + ia_aac_dec_tables_struct *ptr_aac_tables); + +WORD ixheaacd_huffman_dec_word2(ia_bit_buf_struct *it_bit_buff, WORD32 cb_no, + WORD32 width, + ia_aac_dec_tables_struct *ptr_aac_tables, + WORD32 *x_invquant, WORD8 *scratch_ptr); + +VOID ixheaacd_read_scale_factor_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 object_type); + +WORD16 ixheaacd_read_spectral_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 frame_size, WORD32 object_type, WORD32 aac_spect_data_resil_flag, + WORD32 aac_sf_data_resil_flag); + +WORD16 ixheaacd_read_section_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + WORD32 aac_spect_data_resil_flag, WORD32 aac_sect_data_resil_flag, + ia_aac_dec_tables_struct *ptr_aac_tables); + +VOID ixheaacd_over_lap_add1_dec(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_over_lap_add1_armv7(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_over_lap_add1_armv8(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_over_lap_add2_dec(WORD32 *coef, WORD32 *prev, WORD32 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_over_lap_add2_armv7(WORD32 *coef, WORD32 *prev, WORD32 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_over_lap_add2_armv8(WORD32 *coef, WORD32 *prev, WORD32 *out, + const WORD16 *window, WORD16 q_shift, + WORD16 size, WORD16 ch_fac); + +VOID ixheaacd_set_corr_info( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD16 pns_band); + +VOID ixheaacd_gen_rand_vec(WORD32 scale, WORD shift, WORD32 *spec, + WORD32 sfb_width, WORD32 *random_vec); + +VOID ixheaacd_pns_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], WORD32 channel, + ia_aac_dec_tables_struct *ptr_aac_tables); + +VOID ixheaacd_spec_to_overlapbuf_dec(WORD32 *ptr_overlap_buf, + WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size); + +VOID ixheaacd_spec_to_overlapbuf_armv7(WORD32 *ptr_overlap_buf, + WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size); + +VOID ixheaacd_overlap_buf_out_dec(WORD16 *out_samples, WORD32 *ptr_overlap_buf, + WORD32 size, const WORD16 ch_fac); + +VOID ixheaacd_overlap_buf_out_armv7(WORD16 *out_samples, + WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac); + +WORD32 ixheaacd_inv_quant(WORD32 *x_quant, WORD32 *ixheaacd_pow_table_Q13); + +VOID ixheaacd_imdct_process(ia_aac_dec_overlap_info *ptr_aac_dec_overlap_info, + WORD32 *ptr_spec_coeff, + ia_ics_info_struct *ptr_ics_info, + WORD16 out_samples[], const WORD16 ch_fac, + WORD32 *scratch, + ia_aac_dec_tables_struct *ptr_aac_tables, + WORD32 object_type); + +VOID ixheaacd_neg_shift_spec_dec(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac); + +VOID ixheaacd_neg_shift_spec_armv7(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac); + +VOID ixheaacd_neg_shift_spec_armv8(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac); + +VOID ixheaacd_nolap1_32(WORD32 *coef, WORD32 *out, WORD16 cu_scale, + WORD16 stride); + +VOID ixheaacd_overlap_out_copy_dec(WORD16 *out_samples, WORD32 *ptr_overlap_buf, + WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac); + +VOID ixheaacd_overlap_out_copy_armv7(WORD16 *out_samples, + WORD32 *ptr_overlap_buf, + WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac); + +VOID ixheaacd_long_short_win_seq(WORD32 *current, WORD32 *prev, WORD16 *out, + const WORD16 *short_window, + const WORD16 *short_window_prev, + const WORD16 *long_window_prev, WORD16 q_shift, + WORD16 ch_fac); + +WORD32 ixheaacd_cnt_leading_ones(WORD32 a); + +VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *huff_index, + WORD16 *len, const UWORD16 *input_table, + const UWORD32 *idx_table); + +void ixheaacd_eld_dec_windowing(WORD32 *ptr_spect_coeff, const WORD16 *ptr_win, + WORD32 framesize, WORD16 q_shift, + WORD32 *ptr_overlap_buf, const WORD16 stride, + WORD16 *out_samples); + +WORD32 ixheaacd_extension_payload(ia_bit_buf_struct *it_bit_buff, WORD32 cnt); + +VOID ixheaacd_process_single_scf(WORD32 scale_factor, WORD32 *x_invquant, + WORD32 width, WORD32 *ptr_scale_table, + WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +void ixheaacd_lap1_512_480(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window, WORD16 q_shift, WORD16 size, + WORD16 stride); + +#endif /* #ifndef IXHEAACD_BLOCK_H */ diff --git a/decoder/ixheaacd_channel.c b/decoder/ixheaacd_channel.c new file mode 100644 index 0000000..9cf7e8d --- /dev/null +++ b/decoder/ixheaacd_channel.c @@ -0,0 +1,1153 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_error_codes.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_stereo.h" + +#include "ixheaacd_tns.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_adts_crc_check.h" +#include "ixheaacd_rvlc.h" +#include "ixheaacd_hcr.h" +#include "ixheaacd_function_selector.h" + +#define SPEC(ptr, w, gl) ((ptr) + ((w) * (gl))) + +#define _SWAP(a, b) \ + (b = (((WORD32)a[0] << 24) | ((WORD32)a[1] << 16) | ((WORD32)a[2] << 8) | \ + ((WORD32)a[3]))) + +UWORD32 ixheaacd_aac_showbits_32(UWORD8 *ptr_read_next) { + UWORD8 *v = ptr_read_next; + UWORD32 b = 0; + + _SWAP(v, b); + return b; +} + +WORD16 *ixheaacd_getscalefactorbandoffsets( + ia_ics_info_struct *ptr_ics_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { + return ptr_aac_tables->sfb_long_table; + } else { + return ptr_aac_tables->sfb_short_table; + } +} + +WORD8 *ixheaacd_getscalefactorbandwidth( + ia_ics_info_struct *ptr_ics_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + if (ptr_ics_info->frame_length == 512) { + return ( + WORD8 *)(&ptr_aac_tables + ->scale_fac_bands_512[ptr_ics_info->sampling_rate_index] + [0]); + } else { + return ( + WORD8 *)(&ptr_aac_tables + ->scale_fac_bands_480[ptr_ics_info->sampling_rate_index] + [0]); + } +} + +WORD32 ixheaacd_cblock_inv_quant_spect_data( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables); + +void ixheaacd_cblock_scale_spect_data( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 object_type, WORD32 aac_sf_data_resil_flag) { + int grp_win, group = 0; + WORD32 *ptr_spect_coeff = ptr_aac_dec_channel_info->ptr_spec_coeff; + WORD8 *ptr_sfb_width = (WORD8 *)(ixheaacd_getscalefactorbandwidth( + &(ptr_aac_dec_channel_info->str_ics_info), ptr_aac_tables)); + int max_band; + WORD16 *ptr_scale_fac = ptr_aac_dec_channel_info->ptr_scale_factor; + WORD tot_bands = ptr_aac_dec_channel_info->str_ics_info.max_sfb; + WORD tot_groups = ptr_aac_dec_channel_info->str_ics_info.num_window_groups; + WORD32 *scale_table_ptr = ptr_aac_tables->pstr_block_tables->scale_table; + + max_band = ptr_aac_dec_channel_info->str_ics_info.max_sfb; + + do { + grp_win = + ptr_aac_dec_channel_info->str_ics_info.window_group_length[group++]; + do { + (*ixheaacd_scale_factor_process)(&ptr_spect_coeff[0], &ptr_scale_fac[0], + tot_bands, (WORD8 *)ptr_sfb_width, + scale_table_ptr, total_channels, + object_type, aac_sf_data_resil_flag); + ptr_spect_coeff += 128; + grp_win--; + } while (grp_win != 0); + + ptr_scale_fac += 16; + tot_groups--; + } while (tot_groups != 0); +} + +WORD32 ixheaacd_read_pulse_data(ia_bit_buf_struct *it_bit_buff, + ia_pulse_info_struct *ptr_pulse_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + WORD32 i, total_offset; + WORD32 error_code = 0; + + WORD32 value = ixheaacd_read_bits_buf(it_bit_buff, 8); + ptr_pulse_info->number_pulse = value >> 6; + ptr_pulse_info->pulse_start_band = value & 0x3F; + + if (ptr_pulse_info->pulse_start_band >= 52) { + return (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PULSEDATA_ERROR; + } + + total_offset = ptr_aac_tables->str_aac_sfb_info[0] + .sfb_index[ptr_pulse_info->pulse_start_band]; + + for (i = 0; i < ptr_pulse_info->number_pulse + 1; i++) { + WORD32 value = ixheaacd_read_bits_buf(it_bit_buff, 9); + ptr_pulse_info->pulse_offset[i] = value >> 4; + ptr_pulse_info->pulse_amp[i] = value & 0xF; + total_offset += ptr_pulse_info->pulse_offset[i]; + + if (total_offset >= 1024) { + error_code = (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PULSEDATA_ERROR; + } + } + + return error_code; +} + +static WORD16 ixheaacd_read_block_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 frame_size, WORD32 object_type, WORD32 aac_spect_data_resil_flag, + WORD32 aac_sect_data_resil_flag, WORD32 aac_sf_data_resil_flag, + WORD32 ele_type, ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) + +{ + FLAG gain_control_data_present; + WORD16 error_code = AAC_DEC_OK; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + memset(ptr_aac_dec_channel_info->ptr_scale_factor, 0, + MAX_WINDOWS * MAX_SCALE_FACTOR_BANDS_SHORT * 3); + } + + error_code = ixheaacd_read_section_data( + it_bit_buff, ptr_aac_dec_channel_info, aac_spect_data_resil_flag, + aac_sect_data_resil_flag, ptr_aac_tables); + + if (error_code) { + return error_code; + } + if (aac_sf_data_resil_flag && ((object_type == AOT_ER_AAC_ELD) + || (object_type == AOT_ER_AAC_LD))) + ixheaacd_rvlc_read(it_bit_buff, ptr_aac_dec_channel_info); + else + ixheaacd_read_scale_factor_data(it_bit_buff, ptr_aac_dec_channel_info, + ptr_aac_tables, object_type); + + error_code = 0; + if (object_type != AOT_ER_AAC_ELD) { + ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present = + ixheaacd_read_bits_buf(it_bit_buff, 1); + if (ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present) { + error_code = ixheaacd_read_pulse_data( + it_bit_buff, &ptr_aac_dec_channel_info->str_pulse_info, + ptr_aac_tables); + } + + if (error_code) { + return error_code; + } + } + + ptr_aac_dec_channel_info->str_tns_info.tns_data_present = + (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (object_type < ER_OBJECT_START) { + error_code = 0; + if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) { + error_code = + ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); + } + + if (error_code) { + return error_code; + } + } + + if (object_type != AOT_ER_AAC_ELD) { + gain_control_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (gain_control_data_present) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_GAIN_CONTROL_DATA_PRESENT); + } + } + + if (object_type == AOT_ER_AAC_ELD) { + if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) + error_code = + ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); + } + + if (aac_spect_data_resil_flag && + ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD))) + ixheaacd_hcr_read(it_bit_buff, ptr_aac_dec_channel_info, ele_type); + + if (aac_sf_data_resil_flag && + ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD))) { + ixheaacd_rvlc_dec(ptr_aac_dec_channel_info, ptr_aac_dec_static_channel_info, + it_bit_buff); + + it_bit_buff->bit_pos = 7 - it_bit_buff->bit_pos; + } + + if (object_type == AOT_ER_AAC_LD) { + if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) + error_code = + ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); + } + + { it_bit_buff->bit_pos = 7 - it_bit_buff->bit_pos; } + + error_code |= ixheaacd_read_spectral_data( + it_bit_buff, ptr_aac_dec_channel_info, ptr_aac_tables, total_channels, + frame_size, object_type, aac_spect_data_resil_flag, + aac_sf_data_resil_flag); + + it_bit_buff->bit_pos = (7 - it_bit_buff->bit_pos); + + return error_code; +} + +WORD16 ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff, + ia_ics_info_struct *ptr_ics_info, + WORD32 object_type, + WORD32 frame_size, WORD32 ch) { + WORD32 retval = AAC_DEC_OK; + + if (ptr_ics_info->predictor_data_present) { + if (ch == 0) { + ixheaacd_init_ltp_object(&(ptr_ics_info->ltp)); + ptr_ics_info->ltp.data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (ptr_ics_info->ltp.data_present) { + if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, + &(ptr_ics_info->ltp), it_bit_buff, + frame_size)) > 0) { + return retval; + } + } + } else { + ixheaacd_init_ltp_object(&(ptr_ics_info->ltp2)); + ptr_ics_info->ltp2.data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (ptr_ics_info->ltp2.data_present) { + if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, + &(ptr_ics_info->ltp2), it_bit_buff, + frame_size)) > 0) { + return retval; + } + } + } + } + return retval; +} +WORD16 ixheaacd_ics_read(ia_bit_buf_struct *it_bit_buff, + ia_ics_info_struct *ptr_ics_info, + WORD8 num_swb_window[2], WORD32 object_type, + WORD32 common_window, + WORD32 frame_size) { + WORD i; + WORD mask; + WORD value = 0; + + if (object_type == AOT_ER_AAC_ELD) { + ptr_ics_info->window_sequence = 0; + ptr_ics_info->window_shape = 1; + } else { + if (object_type != AOT_ER_AAC_LD) { + ptr_ics_info->frame_length = 1024; + } + value = ixheaacd_read_bits_buf(it_bit_buff, 4); + ptr_ics_info->window_sequence = (WORD16)((value & 0x6) >> 1); + ptr_ics_info->window_shape = (WORD16)((value & 0x1)); + } + + if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { + ptr_ics_info->num_swb_window = num_swb_window[0]; + + ptr_ics_info->num_window_groups = 1; + ptr_ics_info->window_group_length[0] = 1; + + if (object_type == AOT_ER_AAC_ELD) { + ptr_ics_info->max_sfb = ixheaacd_read_bits_buf(it_bit_buff, 6); + if (ptr_ics_info->max_sfb == 0) ptr_ics_info->num_swb_window = 0; + } else { + value = ixheaacd_read_bits_buf(it_bit_buff, 7); + ptr_ics_info->max_sfb = (value & 0x7E) >> 1; + } + + if ((object_type != AOT_ER_AAC_LD) && (object_type != AOT_AAC_LTP)) { + if (value & 1) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PREDICTION_DATA_PRESENT); + } + + } else { + ptr_ics_info->predictor_data_present = value & 1; + + if (ptr_ics_info->predictor_data_present) { + WORD32 retval = AAC_DEC_OK; + + ixheaacd_init_ltp_object(&(ptr_ics_info->ltp)); + if (object_type < ER_OBJECT_START) { + if ((ptr_ics_info->ltp.data_present = + ixheaacd_read_bits_buf(it_bit_buff, 1)) & + 1) { + if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, + &(ptr_ics_info->ltp), it_bit_buff, + frame_size)) > 0) { + return retval; + } + } + if (common_window) { + ixheaacd_init_ltp_object(&(ptr_ics_info->ltp2)); + if ((ptr_ics_info->ltp2.data_present = + ixheaacd_read_bits_buf(it_bit_buff, 1)) & + 1) { + if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, + &(ptr_ics_info->ltp2), + it_bit_buff, frame_size)) > 0) { + return retval; + } + } + } + } + if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { + if (!common_window && (object_type >= ER_OBJECT_START)) { + if ((ptr_ics_info->ltp.data_present = + ixheaacd_read_bits_buf(it_bit_buff, 1)) & + 1) { + if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, + &(ptr_ics_info->ltp), it_bit_buff, + frame_size)) < 0) { + return retval; + } + } + } + } + } + } + + } else { + WORD32 num_groups = 0, scale_factor_grouping; + ptr_ics_info->num_swb_window = num_swb_window[1]; + + value = ixheaacd_read_bits_buf(it_bit_buff, 11); + ptr_ics_info->max_sfb = (value & 0x780) >> 7; + + scale_factor_grouping = (value & 0x7F); + + mask = 0x40; + for (i = 0; i < 7; i++) { + ptr_ics_info->window_group_length[i] = 1; + + if (scale_factor_grouping & mask) { + ptr_ics_info->window_group_length[num_groups] = + ptr_ics_info->window_group_length[num_groups] + 1; + + } else { + num_groups = num_groups + 1; + } + + mask = mask >> 1; + } + + ptr_ics_info->window_group_length[7] = 1; + ptr_ics_info->num_window_groups = num_groups + 1; + } + + if (ptr_ics_info->max_sfb > ptr_ics_info->num_swb_window) { + return (WORD16)IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_SFB_TRANSMITTED; + } + + return AAC_DEC_OK; +} + +WORD16 ixheaacd_individual_ch_stream( + ia_bit_buf_struct *it_bit_buff, ia_aac_decoder_struct *aac_dec_handle, + WORD32 num_ch, WORD32 frame_size, WORD32 total_channels, WORD32 object_type, + ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type) { + WORD16 error_code = AAC_DEC_OK; + WORD32 ch; + WORD32 crc_reg = 0; + + for (ch = 0; ch < num_ch; ch++) { + ia_aac_dec_channel_info_struct *ptr_aac_dec_ch_info = + aac_dec_handle->pstr_aac_dec_ch_info[ch]; + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_ch_info->str_ics_info; + + if (ch == 1) { + if (it_bit_buff->pstr_adts_crc_info->crc_active == 1) { + crc_reg = + ixheaacd_adts_crc_start_reg(it_bit_buff->pstr_adts_crc_info, + it_bit_buff, CRC_ADTS_RAW_IIND_ICS); + } + } + ptr_aac_dec_ch_info->global_gain = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (!(aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window)) { + error_code = ixheaacd_ics_read( + it_bit_buff, ptr_ics_info, aac_dec_handle->num_swb_window, + object_type, + aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window, + aac_dec_handle->samples_per_frame); + if (ch == 1) + aac_dec_handle->pstr_aac_dec_ch_info[ch - 1]->str_ics_info.ltp2.lag = + ptr_ics_info->ltp.lag; + + if (error_code) { + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + return error_code; + } + } + + error_code = ixheaacd_read_block_data( + it_bit_buff, ptr_aac_dec_ch_info, aac_dec_handle->pstr_aac_tables, + total_channels, frame_size, object_type, + eld_specific_config.aac_spect_data_resil_flag, + eld_specific_config.aac_sect_data_resil_flag, + eld_specific_config.aac_sf_data_resil_flag, ele_type, + aac_dec_handle->pstr_aac_dec_overlap_info[ch]); + if (error_code) { + if (it_bit_buff->cnt_bits < 0) { + error_code = (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + return error_code; + } + + if (ch == 0) { + if ((object_type == AOT_ER_AAC_LD) && + (aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window) && + (ele_type == ID_CPE)) { + WORD16 temp = ixheaacd_ltp_decode( + it_bit_buff, ptr_ics_info, object_type, + aac_dec_handle->samples_per_frame, 1); + + if(temp!=0) + { + return temp; + } + aac_dec_handle->pstr_aac_dec_ch_info[ch + 1]->str_ics_info.ltp.lag = + ptr_ics_info->ltp2.lag; + } + } + if (ch == 1) { + if (it_bit_buff->pstr_adts_crc_info->crc_active == 1) { + ixheaacd_adts_crc_end_reg(it_bit_buff->pstr_adts_crc_info, it_bit_buff, + crc_reg); + } + } + } + + return error_code; +} + +VOID ixheaacd_read_ms_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_ch_info) { + WORD32 num_win_group, sfb; + WORD32 ms_mask_present; + UWORD8 *ptr_ms_used = &ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[0][0]; + WORD32 num_window_groups = + ptr_aac_dec_ch_info->str_ics_info.num_window_groups; + WORD16 max_sfb = ptr_aac_dec_ch_info->str_ics_info.max_sfb; + + ms_mask_present = ixheaacd_read_bits_buf(it_bit_buff, 2); + + if (ms_mask_present < 1) { + memset(ptr_ms_used, 0, + sizeof(UWORD8) * JOINT_STEREO_MAX_BANDS * JOINT_STEREO_MAX_GROUPS); + } + + else if (ms_mask_present == 1) { + for (num_win_group = 0; num_win_group < num_window_groups; + num_win_group++) { + for (sfb = 0; sfb < max_sfb; sfb++) { + ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[num_win_group][sfb] = + (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, 1); + } + } + + } else { + for (num_win_group = 0; num_win_group < num_window_groups; + num_win_group++) { + ptr_ms_used = + &ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[num_win_group][0]; + memset(ptr_ms_used, 1, (max_sfb) * sizeof(UWORD8)); + } + } +} + +VOID ixheaacd_channel_pair_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], WORD32 num_ch, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 object_type, WORD32 aac_spect_data_resil_flag, + WORD32 aac_sf_data_resil_flag, WORD32 *in_data, WORD32 *out_data, + void *self_ptr) { + WORD32 channel; + ia_aac_decoder_struct *self = self_ptr; + if (aac_spect_data_resil_flag) { + for (channel = 0; channel < num_ch; channel++) { + ixheaacd_cblock_inv_quant_spect_data(ptr_aac_dec_channel_info[channel], + ptr_aac_tables); + ixheaacd_cblock_scale_spect_data(ptr_aac_dec_channel_info[channel], + ptr_aac_tables, num_ch, object_type, + aac_sf_data_resil_flag); + } + } + + if (num_ch > 1) { + if (ptr_aac_dec_channel_info[LEFT]->common_window) { + if (ptr_aac_dec_channel_info[LEFT]->str_pns_info.pns_active || + ptr_aac_dec_channel_info[RIGHT]->str_pns_info.pns_active) { + ixheaacd_map_ms_mask_pns(ptr_aac_dec_channel_info); + } + + ixheaacd_ms_stereo_process(ptr_aac_dec_channel_info, ptr_aac_tables); + } + + ixheaacd_intensity_stereo_process(ptr_aac_dec_channel_info, ptr_aac_tables, + object_type, aac_sf_data_resil_flag); + } + + for (channel = 0; channel < num_ch; channel++) { + WORD32 *p_spectrum = ptr_aac_dec_channel_info[channel]->ptr_spec_coeff; + + if (total_channels > 2) { + if (ptr_aac_dec_channel_info[channel]->str_ics_info.window_sequence != + EIGHT_SHORT_SEQUENCE) { + WORD16 *band_offsets = ptr_aac_tables->sfb_long_table; + WORD32 no_spec_coeff = band_offsets[ptr_aac_dec_channel_info[channel] + ->str_ics_info.max_sfb]; + ixheaacd_right_shift_block(p_spectrum, no_spec_coeff, 3); + } else { + ixheaacd_right_shift_block(p_spectrum, 1024, 3); + } + } + + ixheaacd_pns_process(ptr_aac_dec_channel_info, channel, ptr_aac_tables); + + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP)) { + { + if (channel == 0) { + ltp_info *ltp1 = + &(ptr_aac_dec_channel_info[channel]->str_ics_info.ltp); + ixheaacd_lt_prediction(ptr_aac_dec_channel_info[channel], ltp1, + p_spectrum, ptr_aac_tables, + self->ptr_aac_dec_static_channel_info[LEFT] + ->overlap_add_data.win_shape, + self->sampling_rate_index, object_type, + self->samples_per_frame, in_data, out_data); + + } else { + ltp_info *ltp2 = + (self->pstr_aac_dec_ch_info[0]->common_window) + ? &(ptr_aac_dec_channel_info[0]->str_ics_info.ltp2) + : + + &(ptr_aac_dec_channel_info[1]->str_ics_info.ltp); + ixheaacd_lt_prediction(ptr_aac_dec_channel_info[channel], ltp2, + p_spectrum, ptr_aac_tables, + self->ptr_aac_dec_static_channel_info[RIGHT] + ->overlap_add_data.win_shape, + self->sampling_rate_index, object_type, + self->samples_per_frame, in_data, out_data); + } + } + } + + if (ptr_aac_dec_channel_info[channel]->str_tns_info.tns_data_present) { + ixheaacd_aac_tns_process(ptr_aac_dec_channel_info[channel], + total_channels, ptr_aac_tables, object_type, 1, + NULL); + } + } +} + +VOID ixheaacd_set_corr_info( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD16 pns_band) { + ia_pns_correlation_info_struct *ptr_corr_info = + ptr_aac_dec_channel_info->pstr_pns_corr_info; + ptr_corr_info->correlated[(pns_band >> PNS_BAND_FLAGS_SHIFT)] |= + (1 << (pns_band & PNS_BAND_FLAGS_MASK)); +} + +VOID ixheaacd_map_ms_mask_pns( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[CHANNELS]) { + WORD32 num_win_group, sfb; + + for (num_win_group = 0; + num_win_group < + ptr_aac_dec_channel_info[LEFT]->str_ics_info.num_window_groups; + num_win_group++) { + for (sfb = 0; sfb < ptr_aac_dec_channel_info[LEFT]->str_ics_info.max_sfb; + sfb++) { + if (ptr_aac_dec_channel_info[LEFT] + ->pstr_stereo_info->ms_used[num_win_group][sfb]) { + WORD16 pns_band = (num_win_group << 4) + sfb; + ixheaacd_set_corr_info(ptr_aac_dec_channel_info[LEFT], pns_band); + + if (ptr_aac_dec_channel_info[LEFT]->str_pns_info.pns_used[pns_band] && + ptr_aac_dec_channel_info[RIGHT]->str_pns_info.pns_used[pns_band]) { + ptr_aac_dec_channel_info[LEFT] + ->pstr_stereo_info->ms_used[num_win_group][sfb] ^= 1; + } + } + } + } +} + +VOID ixheaacd_pulse_data_apply(ia_pulse_info_struct *ptr_pulse_info, + WORD8 *pulse_scratch, + const WORD16 *ptr_swb_offset, WORD object_type) { + WORD i; + WORD32 k; + + memset(pulse_scratch, 0, sizeof(WORD32) * 256); + + if (object_type != AOT_ER_AAC_ELD) { + if (ptr_pulse_info->pulse_data_present) { + k = ptr_swb_offset[ptr_pulse_info->pulse_start_band]; + + for (i = 0; i <= ptr_pulse_info->number_pulse; i++) { + k = k + ptr_pulse_info->pulse_offset[i]; + pulse_scratch[k] = ptr_pulse_info->pulse_amp[i]; + } + } + } else { + ptr_pulse_info->pulse_data_present = 0; + } +} + +WORD16 ixheaacd_read_spectral_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 frame_size, WORD32 object_type, WORD32 aac_spect_data_resil_flag, + WORD32 aac_sf_data_resil_flag) { + WORD sfb, max_sfb; + WORD num_win_grp, group_len, grp_offset; + + WORD index; + WORD8 *ptr_code_book, *ptr_code_book_no; + WORD16 *ptr_scale_factor; + WORD32 *ptr_spec_coef; + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + WORD16 *swb_offset; + + WORD32 *ptr_spec_coef_out; + + ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; + ptr_scale_factor = ptr_aac_dec_channel_info->ptr_scale_factor; + ptr_spec_coef = ptr_aac_dec_channel_info->ptr_spec_coeff; + max_sfb = ptr_ics_info->max_sfb; + + swb_offset = + ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence].sfb_index; + + if (!aac_spect_data_resil_flag) { + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence != + EIGHT_SHORT_SEQUENCE) { + WORD8 *ptr_scratch; + + if (object_type == AOT_ER_AAC_ELD) + ptr_scratch = (WORD8 *)ptr_aac_dec_channel_info->pulse_scratch; + else + ptr_scratch = (WORD8 *)ptr_aac_dec_channel_info->scratch_buf_ptr; + + memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); + + ixheaacd_pulse_data_apply(&ptr_aac_dec_channel_info->str_pulse_info, + ptr_scratch, swb_offset, object_type); + + ptr_spec_coef_out = &ptr_spec_coef[0]; + for (sfb = 0; sfb < max_sfb;) { + WORD ret_val; + WORD32 sfb_width; + WORD32 sect_cb = ptr_code_book[sfb]; + WORD start = sfb; + if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { + if ((sect_cb >= 16) && (sect_cb <= 31)) { + ptr_code_book[sfb] = sect_cb = 11; + } + } + for (; sfb < max_sfb && (ptr_code_book[sfb] == sect_cb); sfb++) + ; + + sfb_width = swb_offset[sfb] - swb_offset[start]; + + if (sect_cb > ZERO_HCB && (sect_cb < NOISE_HCB)) { + ret_val = ixheaacd_huffman_dec_word2(it_bit_buff, sect_cb, sfb_width, + ptr_aac_tables, + ptr_spec_coef_out, ptr_scratch); + + if (ret_val != 0) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL); + } + } + + else { + if (ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present) { + ixheaacd_inverse_quantize( + ptr_spec_coef_out, sfb_width, + (WORD32 *) + ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13, + ptr_scratch); + } + + else { + memset(ptr_spec_coef_out, 0, sizeof(WORD32) * sfb_width); + } + } + ptr_scratch += sfb_width; + ptr_spec_coef_out += sfb_width; + } + + if ((object_type != AOT_ER_AAC_ELD) && (object_type != AOT_ER_AAC_LD)) + index = 1024 - swb_offset[max_sfb]; + else + index = frame_size - swb_offset[max_sfb]; + + memset(ptr_spec_coef_out, 0, sizeof(WORD32) * index); + + } else { + memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); + + grp_offset = 0; + + for (num_win_grp = 0; num_win_grp < ptr_ics_info->num_window_groups; + num_win_grp++) { + WORD grp_len = ptr_ics_info->window_group_length[num_win_grp]; + ptr_code_book_no = + &ptr_code_book[num_win_grp * MAX_SCALE_FACTOR_BANDS_SHORT]; + ptr_spec_coef_out = &ptr_spec_coef[grp_offset * MAX_BINS_SHORT]; + + for (sfb = 0; sfb < max_sfb;) { + WORD sect_cb = *ptr_code_book_no; + WORD start = sfb; + WORD ret_val; + + for (; sfb < max_sfb && (*ptr_code_book_no == sect_cb); + sfb++, ptr_code_book_no++) + ; + + if (sect_cb > ZERO_HCB && (sect_cb < NOISE_HCB)) { + ret_val = ixheaacd_decode_huffman( + it_bit_buff, sect_cb, ptr_spec_coef_out, (WORD16 *)swb_offset, + start, sfb, grp_len, ptr_aac_tables); + + if (ret_val != 0) { + return (WORD16)( + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL); + } + } + } + grp_offset = (grp_offset + grp_len); + } + } + { + WORD32 *ptr_scale_table = ptr_aac_tables->pstr_block_tables->scale_table; + WORD8 *ptr_sfb_width = + ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence] + .sfb_width; + + for (num_win_grp = 0; num_win_grp < ptr_ics_info->num_window_groups; + num_win_grp++) { + for (group_len = 0; + group_len < ptr_ics_info->window_group_length[num_win_grp]; + group_len++) { + (*ixheaacd_scale_factor_process)( + &ptr_spec_coef[0], &ptr_scale_factor[0], max_sfb, + (WORD8 *)ptr_sfb_width, ptr_scale_table, total_channels, + object_type, aac_sf_data_resil_flag); + + ptr_spec_coef += MAX_BINS_SHORT; + } + + ptr_scale_factor += MAX_SCALE_FACTOR_BANDS_SHORT; + } + } + } else { + ia_hcr_info_struct *pstr_hcr_info = &ptr_aac_dec_channel_info->str_hcr_info; + WORD32 error = 0; + + memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); + + if (ptr_aac_dec_channel_info->reorder_spect_data_len != 0) { + error = ixheaacd_huff_code_reorder_init( + pstr_hcr_info, ptr_aac_dec_channel_info, ptr_aac_tables, it_bit_buff); + + if (error != 0) { + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + error = ixheaacd_hcr_decoder(pstr_hcr_info, ptr_aac_dec_channel_info, + ptr_aac_tables, it_bit_buff); + + if (error != 0) { + ixheaacd_huff_mute_erroneous_lines(pstr_hcr_info); + } + + it_bit_buff->cnt_bits += + -ptr_aac_dec_channel_info->reorder_spect_data_len; + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = (it_bit_buff->size - it_bit_buff->cnt_bits) & 7; + + } else { + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = (it_bit_buff->size - it_bit_buff->cnt_bits) & 7; + } + } + + return AAC_DEC_OK; +} + +WORD16 ixheaacd_read_tns_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + WORD win_size, window_per_frame; + WORD n_filt_bits, start_band_bits, order_bits; + WORD32 bottom; + + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + ia_tns_info_aac_struct *ptr_tns_info = + &ptr_aac_dec_channel_info->str_tns_info; + + if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { + n_filt_bits = 2; + start_band_bits = 6; + order_bits = 5; + window_per_frame = 1; + + } else { + n_filt_bits = 1; + start_band_bits = 4; + order_bits = 3; + window_per_frame = 8; + } + + bottom = ptr_ics_info->num_swb_window; + + for (win_size = 0; win_size < window_per_frame; win_size++) { + WORD n_filt; + WORD start_band, coef_res; + ptr_tns_info->n_filt[win_size] = n_filt = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, n_filt_bits); + + if (n_filt) { + WORD filt; + WORD top; + + coef_res = ixheaacd_read_bits_buf(it_bit_buff, 1); + + top = bottom; + for (filt = 0; filt < n_filt; filt++) { + WORD order; + ia_filter_info_struct *filter = + &ptr_tns_info->str_filter[win_size][filt]; + + start_band = ixheaacd_read_bits_buf(it_bit_buff, start_band_bits); + + if (top < start_band) { + top = start_band; + } + filter->start_band = top - start_band; + filter->stop_band = top; + + top = filter->start_band; + + if (filter->start_band < 0) { + filter->order = -1; + return (WORD16)((WORD32)IA_ENHAACPLUS_DEC_EXE_FATAL_TNS_RANGE_ERROR); + } + + filter->order = order = ixheaacd_read_bits_buf(it_bit_buff, order_bits); + + if ((order - MAX_ORDER_LONG) > 0) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_TNS_ORDER_ERROR); + } + + if (order) { + WORD i; + WORD32 coef, coef_compress; + WORD resolution, shift; + + filter->direction = + (WORD8)(ixheaacd_read_bits_buf(it_bit_buff, 1) ? -1 : 1); + + coef_compress = ixheaacd_read_bits_buf(it_bit_buff, 1); + + filter->resolution = coef_res; + + resolution = coef_res + 3 - coef_compress; + + shift = 32 - resolution; + + for (i = 0; i < order; i++) { + coef = ixheaacd_read_bits_buf(it_bit_buff, resolution); + coef = coef << shift; + filter->coef[i] = (WORD8)(coef >> shift); + } + } + } + } + } + return AAC_DEC_OK; +} + +WORD32 ixheaacd_inv_quant(WORD32 *px_quant, WORD32 *ixheaacd_pow_table_Q13) + +{ + WORD32 q1; + WORD32 temp; + WORD32 q_abs; + WORD16 interp; + WORD32 shift; + + q_abs = *px_quant; + + if (q_abs > (8191 + 32)) + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL; + + if (q_abs < 1024) { + shift = 3; + } else { + shift = 6; + } + + q1 = (q_abs) >> shift; + + interp = q_abs - (q1 << shift); + + temp = ixheaacd_pow_table_Q13[q1 + 1] - ixheaacd_pow_table_Q13[q1]; + + temp = (WORD32)(temp * (WORD32)interp); + + temp = temp + (ixheaacd_pow_table_Q13[q1] << shift); + + if (shift == 3) + temp = temp << 1; + else + temp = temp << 2; + + *px_quant = temp; + + return 0; +} + +void ixheaacd_scale_value_in_place(WORD32 *value, WORD32 scalefactor) { + WORD32 newscale; + + if ((newscale = (scalefactor)) >= 0) { + *(value) <<= newscale; + } else { + *(value) >>= -newscale; + } +} + +WORD32 ixheaacd_cblock_inv_quant_spect_data( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + int window, group, grp_win, band; + int sf_bands_transmitted = ptr_aac_dec_channel_info->str_ics_info.max_sfb; + WORD8 *ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; + const WORD16 *band_offsets = (WORD16 *)ixheaacd_getscalefactorbandoffsets( + &(ptr_aac_dec_channel_info->str_ics_info), ptr_aac_tables); + WORD32 *ptr_pow_table_Q13 = + (WORD32 *)ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13; + + for (window = 0, group = 0; + group < ptr_aac_dec_channel_info->str_ics_info.num_window_groups; + group++) { + for (grp_win = 0; + grp_win < + ptr_aac_dec_channel_info->str_ics_info.window_group_length[group]; + grp_win++, window++) { + for (band = 0; band < sf_bands_transmitted; band++) { + WORD32 *ptr_spec_coef = + SPEC(ptr_aac_dec_channel_info->ptr_spec_coeff, window, + ptr_aac_dec_channel_info->granule_len) + + band_offsets[band]; + int num_lines = band_offsets[band + 1] - band_offsets[band]; + int bnds = group * 16 + band; + int i; + + if ((ptr_code_book[bnds] == ZERO_HCB) || + (ptr_code_book[bnds] == INTENSITY_HCB) || + (ptr_code_book[bnds] == INTENSITY_HCB2)) + continue; + + if (ptr_code_book[bnds] == NOISE_HCB) { + continue; + } + + for (i = 0; i < num_lines; i++) { + WORD8 temp = 0; + WORD32 out1 = ptr_spec_coef[i]; + if (out1 <= 0) { + out1 = sub_d(temp, out1); + if (out1 > 127) { + ixheaacd_inv_quant(&out1, ptr_pow_table_Q13); + } else + out1 = ptr_pow_table_Q13[out1]; + ptr_spec_coef[i] = -out1; + + } else { + if (out1 > 127) { + ixheaacd_inv_quant(&out1, ptr_pow_table_Q13); + } else + out1 = ptr_pow_table_Q13[out1]; + + ptr_spec_coef[i] = out1; + } + } + } + } + } + + return AAC_DEC_OK; +} + +void ixheaacd_init_ltp_object(ltp_info *ltp) { + ltp->data_present = 0; + ltp->last_band = 0; + + ltp->lag_update = 0; + ltp->coef = 0; +} + +WORD32 ixheaacd_ltp_data(WORD32 object_type, ia_ics_info_struct *ics, + ltp_info *ltp, ia_handle_bit_buf_struct bs, + WORD32 frame_len) { + UWORD8 sfb, w; + + if (object_type == AOT_ER_AAC_LD) { + ltp->lag_update = ixheaacd_read_bits_buf(bs, 1); + + if (ltp->lag_update) { + ltp->lag = (UWORD16)ixheaacd_read_bits_buf(bs, 10); + } + } else { + ltp->lag = (UWORD16)ixheaacd_read_bits_buf(bs, 11); + } + + if (ltp->lag > (frame_len << 1)) return -1; + + ltp->coef = (UWORD8)ixheaacd_read_bits_buf(bs, 3); + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { + for (w = 0; w < 8; w++) { + if ((ltp->short_used[w] = ixheaacd_read_bits_buf(bs, 1)) & 1) { + ltp->short_lag_present[w] = ixheaacd_read_bits_buf(bs, 1); + if (ltp->short_lag_present[w]) { + ltp->short_lag[w] = (UWORD8)ixheaacd_read_bits_buf(bs, 4); + } + } + } + } else { + ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB); + + for (sfb = 0; sfb < ltp->last_band; sfb++) { + ltp->long_used[sfb] = ixheaacd_read_bits_buf(bs, 1); + } + } + + return 0; +} diff --git a/decoder/ixheaacd_channel.h b/decoder/ixheaacd_channel.h new file mode 100644 index 0000000..0bf1b5e --- /dev/null +++ b/decoder/ixheaacd_channel.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CHANNEL_H +#define IXHEAACD_CHANNEL_H + +enum { + + ID_SCE = 0, + ID_CPE, + ID_CCE, + ID_LFE, + ID_DSE, + ID_PCE, + ID_FIL, + ID_END, + ID_HDR, + ID_NULL, + ID_IIND_ICS, + CRC_LEVEL_FIN, + END_HDR, +}; + +#define LEFT 0 +#define RIGHT 1 + +VOID ixheaacd_channel_pair_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], WORD32 num_ch, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, + WORD32 object_type, WORD32 aac_spect_data_resil_flag, + WORD32 aac_sf_data_resil_flag, WORD32 *in_data, WORD32 *out_data, + void *self_ptr); + +VOID ixheaacd_map_ms_mask_pns( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[CHANNELS]); + +VOID ixheaacd_read_fill_element(ia_bit_buf_struct *it_bit_buff, + ia_drc_dec_struct *drc_dummy, + ia_drc_dec_struct *pstr_drc_dec); + +VOID ixheaacd_read_data_stream_element(ia_bit_buf_struct *it_bit_buff, + WORD32 *byte_align_bits, + ia_drc_dec_struct *drc_handle); + +WORD16 *ixheaacd_getscalefactorbandoffsets( + ia_ics_info_struct *ptr_ics_info, ia_aac_dec_tables_struct *ptr_aac_tables); +#endif /* #ifndef IXHEAACD_CHANNEL_H */ diff --git a/decoder/ixheaacd_channelinfo.h b/decoder/ixheaacd_channelinfo.h new file mode 100644 index 0000000..1d8c3de --- /dev/null +++ b/decoder/ixheaacd_channelinfo.h @@ -0,0 +1,341 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CHANNELINFO_H +#define IXHEAACD_CHANNELINFO_H + +#include "ixheaacd_lt_predict.h" + +#define MAX_SFB_SHORT 16 +#define MAX_QUANTIZED_VALUE 8191 + +#define OVERLAP_BUFFER_SIZE 512 + +#define JOINT_STEREO_MAX_GROUPS 8 +#define JOINT_STEREO_MAX_BANDS 64 + +typedef struct { + WORD16 window_shape; + WORD16 window_sequence; + WORD16 max_sfb; + WORD16 num_swb_window; + WORD16 sampling_rate_index; + WORD16 num_window_groups; + WORD8 window_group_length[8]; + WORD16 frame_length; + WORD32 frame_size; + WORD16 predictor_data_present; + ltp_info ltp; + ltp_info ltp2; +} ia_ics_info_struct; + +typedef struct { + WORD32 aac_sect_data_resil_flag; + WORD32 aac_sf_data_resil_flag; + WORD32 aac_spect_data_resil_flag; + WORD32 ep_config; +} ia_aac_err_config_struct; + +typedef struct { + WORD32 ld_sbr_flag_present; + WORD32 ld_sbr_samp_rate; + WORD32 ld_sbr_crc_flag; + WORD32 ldSbrHeaderPresent; + + WORD32 aac_sect_data_resil_flag; + WORD32 aac_sf_data_resil_flag; + WORD32 aac_spect_data_resil_flag; + WORD32 ep_config; + +} ia_eld_specific_config_struct; + +typedef struct { + UWORD8 ms_used[JOINT_STEREO_MAX_GROUPS][JOINT_STEREO_MAX_BANDS]; +} ia_stereo_info_struct; + +typedef struct { + WORD16 start_band; + WORD16 stop_band; + WORD8 direction; + WORD8 resolution; + WORD8 order; + WORD8 coef[MAX_ORDER]; +} ia_filter_info_struct; + +typedef struct { + FLAG tns_data_present; + WORD8 n_filt[MAX_WINDOWS]; + ia_filter_info_struct str_filter[MAX_WINDOWS][MAX_FILTERS]; +} ia_tns_info_aac_struct; + +typedef struct { + const WORD16 *ptr_long_window[2]; + const WORD16 *ptr_short_window[2]; + WORD16 window_shape; + WORD16 window_sequence; + WORD32 *ptr_overlap_buf; + + WORD16 rvlc_prev_sf[128]; + WORD16 rvlc_prev_cb[128]; + WORD8 rvlc_prev_blk_type; + WORD8 rvlc_prev_sf_ok; + +} ia_aac_dec_overlap_info; + +typedef struct { + WORD32 sf_concealment; + WORD32 rev_global_gain; + WORD16 rvlc_sf_len; + WORD32 dpcm_noise_nrg; + WORD32 sf_esc_present; + WORD16 rvlc_esc_len; + WORD32 dpcm_noise_last_pos; + + WORD32 dpcm_is_last_pos; + + WORD16 rvlc_sf_fwd_len; + WORD16 rvlc_sf_bwd_len; + + WORD16 *ptr_rvl_bit_cnt; + UWORD16 *ptr_rvl_bit_str_idx; + + WORD16 num_wind_grps; + WORD16 max_sfb_transmitted; + UWORD8 first_noise_group; + UWORD8 first_noise_band; + UWORD8 direction; + + UWORD16 rvl_fwd_bit_str_idx; + UWORD16 rvl_bwd_bit_str_idx; + UWORD16 esc_bit_str_idx; + + const UWORD32 *ptr_huff_tree_rvl_cw; + const UWORD32 *ptr_huff_tree_rvl_esc; + + UWORD8 num_fwd_esc_words_decoded; + UWORD8 num_bwd_esc_words_decoded; + UWORD8 num_esc_words_decoded; + + WORD8 noise_used; + WORD8 intensity_used; + WORD8 sf_used; + + WORD16 firt_scale_fac; + WORD16 last_scale_fac; + WORD16 first_nrg; + WORD16 last_nrg; + WORD16 is_first; + WORD16 is_last; + + UWORD32 rvlc_err_log; + WORD16 conceal_min; + WORD16 conceal_max; + WORD16 conceal_min_esc; + WORD16 conceal_max_esc; +} ia_rvlc_info_struct; + +#define LINES_PER_UNIT 4 + +#define MAX_SFB_HCR (((1024 / 8) / LINES_PER_UNIT) * 8) +#define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8) +#define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS) + +#define FROM_LEFT_TO_RIGHT 0 +#define FROM_RIGHT_TO_LEFT 1 + +#define MAX_CB_PAIRS 23 +#define MAX_HCR_SETS 14 + +#define ESCAPE_VALUE 16 +#define POSITION_OF_FLAG_A 21 +#define POSITION_OF_FLAG_B 20 + +#define MAX_CB 32 + +#define MAX_CB_CHECK 32 +#define WORD_BITS 32 + +#define THIRTYTWO_LOG_DIV_TWO_LOG 5 +#define EIGHT_LOG_DIV_TWO_LOG 3 +#define FOUR_LOG_DIV_TWO_LOG 2 + +#define CPE_TOP_LENGTH 12288 +#define SCE_TOP_LENGTH 6144 +#define LEN_OF_LONGEST_CW_TOP_LENGTH 49 +#define Q_VALUE_INVALID 8192 +#define NODE_MASK 0x400 + +#define ERROR_POS 0x00000001 +#define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC + +typedef enum { PCW, PCW_SIGN, PCW_ESC_SIGN } ia_pcw_type_struct; + +typedef struct { + UWORD32 err_log; + WORD32 *ptr_quant_spec_coeff_base; + WORD32 quant_spec_coeff_idx; + WORD16 reordered_spec_data_len; + WORD16 num_sect; + WORD16 *ptr_num_line_in_sect; + UWORD16 bit_str_idx; + WORD8 longest_cw_len; + UWORD8 *ptr_cb; +} ia_huff_code_reorder_io_struct; + +typedef struct { + const UWORD8 *ptr_min_cb_pair_tbl; + const UWORD8 *ptr_max_cb_pair_tbl; +} ia_huff_code_reorder_cb_pairs_struct; + +typedef struct { + const UWORD16 *ptr_lav_tbl; + const UWORD8 *ptr_max_cw_len_tbl; + const UWORD8 *ptr_cb_dimension_tbl; + const UWORD8 *ptr_cb_dim_shift_tbl; + const UWORD8 *ptr_cb_sign_tbl; + const UWORD8 *ptr_cb_priority; +} ia_huff_code_reorder_tbl_struct; + +typedef struct { + WORD32 num_segment; + UWORD32 segment_offset; + WORD32 arr_temp_values[1024]; + UWORD16 arr_seg_start_l[1024 >> 1]; + UWORD16 arr_seg_start_r[1024 >> 1]; + WORD8 p_remaining_bits_in_seg[1024 >> 1]; + WORD32 code[512]; + WORD32 code_extra[512]; + WORD8 p_num_bits[512]; + UWORD8 read_direction; + WORD32 is_decoded[512]; +} ia_huff_code_reord_seg_info_struct; + +typedef struct { + UWORD32 num_code_word; + UWORD32 current_codeword; + UWORD32 num_sorted_section; + UWORD16 ptr_num_cw_in_sect[MAX_SFB_HCR]; + UWORD16 ptr_num_sorted_cw_in_sect[MAX_SFB_HCR]; + UWORD16 ptr_num_ext_sorted_cw_in_sect[MAX_SFB_HCR + MAX_HCR_SETS]; + WORD32 num_ext_sorted_cw_in_sect_idx; + UWORD16 ptr_num_ext_sorted_sect_in_sets[MAX_HCR_SETS]; + WORD32 num_ext_sorted_sect_in_sets_idx; + UWORD16 ptr_reorder_offset[MAX_SFB_HCR]; + UWORD8 ptr_sorted_cb[MAX_SFB_HCR]; + + UWORD8 ptr_ext_sorted_cw[MAX_SFB_HCR + MAX_HCR_SETS]; + WORD32 ext_sorted_cw_idx; + UWORD8 ptr_ext_sorted_sect_max_cb_len[MAX_SFB_HCR + MAX_HCR_SETS]; + WORD32 ext_sorted_sect_max_cb_len_idx; + UWORD8 ptr_cb_switch[MAX_SFB_HCR]; +} ia_huff_code_reord_sect_info_struct; + +typedef UWORD32 (*ixheaacd_ptr_state_func)(ia_bit_buf_struct *, pVOID); + +typedef struct { + WORD32 *ptr_result_base; + UWORD16 res_ptr_idx[1024 >> 2]; + UWORD32 cw_offset; + UWORD8 ptr_cb[1024 >> 2]; +} ia_hcr_non_pcw_sideinfo_struct; + +typedef struct { + ia_huff_code_reorder_io_struct str_dec_io; + ia_huff_code_reorder_cb_pairs_struct codebook_pairs; + ia_huff_code_reorder_tbl_struct table_info; + ia_huff_code_reord_seg_info_struct str_segment_info; + ia_huff_code_reord_sect_info_struct sect_info; + ia_hcr_non_pcw_sideinfo_struct str_non_pcw_side_info; + + WORD32 global_hcr_type; +} ia_hcr_info_struct; + +typedef struct { + WORD16 scale_factor[MAX_WINDOWS * MAX_SFB_SHORT]; + WORD8 code_book[MAX_WINDOWS * MAX_SFB_SHORT]; +} ia_aac_sfb_code_book_struct; + +typedef struct { + ia_stereo_info_struct str_stereo_info; + ia_pns_correlation_info_struct str_pns_corr_info; +} ia_pns_stereo_data_struct; + +typedef struct { + WORD16 win_shape; + WORD16 win_seq; + + WORD32 *ptr_overlap_buf; + +} ia_aac_dec_ola_data; + +typedef struct { + const WORD16 *ptr_long_window[2]; + const WORD16 *ptr_short_window[2]; + + ia_aac_dec_ola_data overlap_add_data; + + WORD16 *ltp_buf; + UWORD16 ltp_lag; + +} ia_aac_dec_channel_info; + +typedef struct { + WORD16 *ptr_scale_factor; + WORD8 *ptr_code_book; + WORD32 *ptr_spec_coeff; + ia_stereo_info_struct *pstr_stereo_info; + ia_pns_correlation_info_struct *pstr_pns_corr_info; + ia_pns_rand_vec_struct *pstr_pns_rand_vec_data; + ia_ics_info_struct str_ics_info; + ia_tns_info_aac_struct str_tns_info; + ia_pulse_info_struct str_pulse_info; + ia_pns_info_struct str_pns_info; + WORD16 common_window; + WORD16 element_instance_tag; + WORD16 global_gain; + WORD32 *scratch_buf_ptr; + WORD32 *pulse_scratch; + ia_rvlc_info_struct ptr_rvlc_info; + ia_hcr_info_struct str_hcr_info; + WORD16 reorder_spect_data_len; + WORD8 longest_cw_len; + WORD16 rvlc_scf_esc_arr[128]; + WORD16 rvlc_scf_fwd_arr[128]; + WORD16 rvlc_scf_bwd_arr[128]; + WORD8 rvlc_intensity_used; + WORD16 num_line_in_sec4_hcr_arr[32 * 8]; + UWORD8 cb4_hcr_arr[32 * 8]; + WORD32 number_sect; + WORD32 granule_len; + WORD16 rvlc_curr_sf_flag; + WORD16 *ltp_buf; + UWORD16 ltp_lag; +} ia_aac_dec_channel_info_struct; +WORD16 ixheaacd_ics_read(ia_bit_buf_struct *it_bit_buff, + ia_ics_info_struct *ptr_ics_info, + WORD8 num_swb_window[2], WORD32 object_type, + WORD32 common_window, + WORD32 frame_size); + +WORD16 ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff, + ia_ics_info_struct *ptr_ics_info, + WORD32 object_type, + WORD32 frame_size, WORD32 ch); + +#endif /* #ifndef IXHEAACD_CHANNELINFO_H */ diff --git a/decoder/ixheaacd_cnst.h b/decoder/ixheaacd_cnst.h new file mode 100644 index 0000000..b96422b --- /dev/null +++ b/decoder/ixheaacd_cnst.h @@ -0,0 +1,120 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CNST_H +#define IXHEAACD_CNST_H + +#define MAX_ELEMENTS 68 + +#define LEN_SUPERFRAME 1024 +#define LEN_FRAME 256 +#define NUM_FRAMES 4 +#define MAX_NUM_SUBFR 4 + +#define ORDER 16 +#define ORDER_BY_2 (ORDER / 2) + +#define FAC_LENGTH 128 + +#define NUM_SUBFR_SUPERFRAME 16 +#define NUM_SUBFR_SUPERFRAME_BY2 (NUM_SUBFR_SUPERFRAME / 2) +#define SYNTH_DELAY_LMAX ((NUM_SUBFR_SUPERFRAME_BY2 - 1) * LEN_SUBFR) + +#define FSCALE_DENOM 12800 +#define FAC_FSCALE_MAX 24000 +#define FAC_FSCALE_MIN 6000 + +#define FILTER_DELAY 12 + +#define TMIN 34 +#define TFR2 (162 - TMIN) +#define TFR1 160 +#define TMAX (27 + 6 * TMIN) + +#define UP_SAMP 4 +#define INTER_LP_FIL_ORDER 16 +#define INTER_LP_FIL_LEN (UP_SAMP * INTER_LP_FIL_ORDER + 1) + +#define MAX_PITCH \ + (TMAX + \ + (6 * \ + ((((FAC_FSCALE_MAX * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN))) + +#define PI 3.14159265358979323846264338327950288 + +#define PREEMPH_FILT_FAC 0.68f +#define PREEMPH_FAC_FIX 44564 + +#define IGAMMA1 1975684956 + +#define TILT_CODE 0.3f + +#define BLOCK_LEN_LONG 1024 +#define BLOCK_LEN_SHORT 128 +#define BLOCK_LEN_LONG_S 960 +#define BLOCK_LEN_SHORT_S 120 + +#define WIN_LEN_1024 1024 +#define WIN_LEN_768 768 +#define WIN_LEN_512 512 +#define WIN_LEN_192 192 +#define WIN_LEN_128 128 +#define WIN_LEN_960 960 +#define WIN_LEN_480 480 +#define WIN_LEN_256 256 +#define WIN_LEN_120 120 +#define WIN_LEN_96 96 +#define WIN_LEN_64 64 +#define WIN_LEN_48 48 +#define WIN_LEN_16 16 +#define WIN_LEN_4 4 + +#define TW_IPLEN2S 12 +#define TW_OS_FACTOR_WIN 16 + +#define WIN_SEL_0 0 +#define WIN_SEL_1 1 +#define WIN_SEL_2 2 + +#define NUM_TW_NODES 16 + +#define CORE_MODE_FD 0 + +#define ONLY_LONG_SEQUENCE 0 +#define LONG_START_SEQUENCE 1 +#define EIGHT_SHORT_SEQUENCE 2 +#define LONG_STOP_SEQUENCE 3 +#define STOP_START_SEQUENCE 4 +#define NUM_WIN_SEQ 5 + +#define NSFB_SHORT 16 +#define MAX_SHORT_IN_LONG_BLOCK 8 +#define MAX_SHORT_WINDOWS 8 + +#define MAX_NUM_CHANNELS 6 + +#define SFB_NUM_MAX ((NSFB_SHORT + 1) * MAX_SHORT_IN_LONG_BLOCK) + +#define MAX_31 (WORD32)0x3FFFFFFF +#define MIN_31 (WORD32)0xC0000000 +#define LEN_SUBFR 64 + +#define SFB_PER_PRED_BAND 2 + +#endif /* IXHEAACD_CNST_H */ diff --git a/decoder/ixheaacd_common_initfuncs.c b/decoder/ixheaacd_common_initfuncs.c new file mode 100644 index 0000000..4da4b79 --- /dev/null +++ b/decoder/ixheaacd_common_initfuncs.c @@ -0,0 +1,186 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_defines.h" + +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_headerdecode.h" + +#include "ixheaacd_multichannel.h" + +#include +#include "ixheaacd_adts_crc_check.h" +#include "ixheaacd_function_selector.h" + +VOID ixheaacd_allocate_mem_persistent( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, + ia_aac_dec_state_struct *p_state_enhaacplus_dec, WORD channels, + WORD *persistent_used_total, WORD *sbr_persistent_start, WORD ps_enable) { + WORD persistent_used; + WORD8 **temp_persistent = + (WORD8 **)&(p_state_enhaacplus_dec->aac_persistent_mem_v); + *temp_persistent += *persistent_used_total; + + persistent_used = ixheaacd_set_aac_persistent_buffers( + p_state_enhaacplus_dec->aac_persistent_mem_v, channels); + + *persistent_used_total += persistent_used; + + *sbr_persistent_start = *persistent_used_total; + + p_state_enhaacplus_dec->sbr_persistent_mem_v = + (pVOID)((SIZE_T)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + + persistent_used + sizeof(SIZE_T) - 1) & + (SIZE_T)(~(sizeof(SIZE_T) - 1))); + + persistent_used = ixheaacd_getsize_sbr_persistent(); + + ixheaacd_set_sbr_persistent_buffers( + p_state_enhaacplus_dec->sbr_persistent_mem_v, &persistent_used, channels, + ps_enable); + + *persistent_used_total += persistent_used; + + { + struct ia_aac_persistent_struct *aac_persistent_mem = + (struct ia_aac_persistent_struct *) + p_obj_enhaacplus_dec->p_state_aac->aac_persistent_mem_v; + aac_persistent_mem->str_aac_decoder.pstr_aac_tables = + &p_obj_enhaacplus_dec->aac_tables; + aac_persistent_mem->str_aac_decoder.pstr_common_tables = + p_obj_enhaacplus_dec->common_tables; + } + + ixheaacd_set_sbr_persistent_table_pointer( + p_obj_enhaacplus_dec->p_state_aac->sbr_persistent_mem_v, + &p_obj_enhaacplus_dec->str_sbr_tables, + p_obj_enhaacplus_dec->common_tables); +} + +ia_bit_buf_struct *ixheaacd_create_bit_buf(ia_bit_buf_struct *it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) { + it_bit_buff->ptr_bit_buf_base = ptr_bit_buf_base; + it_bit_buff->ptr_bit_buf_end = ptr_bit_buf_base + bit_buf_size - 1; + + it_bit_buff->ptr_read_next = ptr_bit_buf_base; + it_bit_buff->bit_pos = 7; + + it_bit_buff->cnt_bits = 0; + it_bit_buff->size = bit_buf_size << 3; + + it_bit_buff->adts_header_present = 0; + it_bit_buff->protection_absent = 0; + it_bit_buff->pstr_adts_crc_info = &it_bit_buff->str_adts_crc_info; + ixheaacd_adts_crc_open(it_bit_buff->pstr_adts_crc_info); + + return it_bit_buff; +} + +ia_bit_buf_struct *ixheaacd_create_init_bit_buf(ia_bit_buf_struct *it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) { + ixheaacd_create_bit_buf(it_bit_buff, ptr_bit_buf_base, bit_buf_size); + it_bit_buff->cnt_bits = (bit_buf_size << 3); + return (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; + + 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); + + if (bit_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; + } + + it_bit_buff->ptr_read_next = ptr_read_next; + } + } +} diff --git a/decoder/ixheaacd_common_lpfuncs.c b/decoder/ixheaacd_common_lpfuncs.c new file mode 100644 index 0000000..ff43237 --- /dev/null +++ b/decoder/ixheaacd_common_lpfuncs.c @@ -0,0 +1,368 @@ +/****************************************************************************** + * * + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************** + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ +#include "string.h" +#include "ixheaacd_sbr_common.h" +#include + +#include +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_defines.h" + +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" + +#include "ixheaacd_channelinfo.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_headerdecode.h" + +#include "ixheaacd_multichannel.h" + +#include +#include "ixheaacd_intrinsics.h" + +static PLATFORM_INLINE UWORD32 +ixheaacd_aac_showbits_7(ia_bit_buf_struct *it_bit_buff) { + UWORD8 *v = it_bit_buff->ptr_read_next; + UWORD32 b = 0; + UWORD32 x; + b = (((WORD32)v[0] << 8) | (WORD32)(v[1])); + x = (UWORD32)b << (15 + 8 - it_bit_buff->bit_pos); + x = (UWORD32)x >> (25); + return x; +} + +WORD ixheaacd_get_channel_mask( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec) { + WORD ixheaacd_drc_offset = 0, channel_mask = 0; + WORD flag1 = 0, flag2 = 0; + WORD ch_idx; + WORD *ptr_slot_element = p_obj_enhaacplus_dec->aac_config.slot_element; + WORD *ptr_element_type = p_obj_enhaacplus_dec->aac_config.element_type; + + memset(ptr_slot_element, 0, sizeof(WORD) * MAX_BS_ELEMENT); + + for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 1) { + channel_mask += 0x3; + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 2; + flag1 = ch_idx + 1; + break; + } + } + + for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 0) { + channel_mask += 0x4; + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 1; + flag2 = ch_idx + 1; + break; + } + } + for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 3) { + channel_mask += 0x8; + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 1; + break; + } + } + for (ch_idx = flag1; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 1) { + channel_mask += 0x30; + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 2; + flag1 = ch_idx + 1; + break; + } + } + for (ch_idx = flag2; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 0) { + channel_mask += 0x100; + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 1; + break; + } + } + for (ch_idx = flag1; ch_idx < MAX_BS_ELEMENT; ch_idx++) { + if (ptr_element_type[ch_idx] == 1) { + { + channel_mask += (0x40 + 0x80); + ptr_slot_element[ch_idx] = ixheaacd_drc_offset; + ixheaacd_drc_offset += 2; + break; + } + } + } + + return channel_mask; +} + +VOID ixheaacd_read_data_stream_element(ia_bit_buf_struct *it_bit_buff, + WORD32 *byte_align_bits, + ia_drc_dec_struct *drc_handle) { + ia_bit_buf_struct temp_bs; + WORD32 count = ixheaacd_read_bits_buf(it_bit_buff, 13); + WORD32 cnt = (count & 0xff); + WORD32 start_pos = 0; + + if (cnt == 255) { + cnt += ixheaacd_read_bits_buf(it_bit_buff, 8); + } + + if ((count & 0x0100) >> 8) { + ixheaacd_byte_align(it_bit_buff, byte_align_bits); + } + + { + memcpy(&temp_bs, it_bit_buff, sizeof(ia_bit_buf_struct)); + start_pos = temp_bs.cnt_bits; + + if (ixheaacd_read_bits_buf(&temp_bs, 8) == DVB_ANC_DATA_SYNC_BYTE) { + int dmx_level_present, compression_present; + int coarse_gain_present, fine_grain_present; + + ixheaacd_read_bits_buf(&temp_bs, 8); + + ixheaacd_read_bits_buf(&temp_bs, 3); + dmx_level_present = ixheaacd_read_bits_buf(&temp_bs, 1); + ixheaacd_read_bits_buf(&temp_bs, 1); + compression_present = ixheaacd_read_bits_buf(&temp_bs, 1); + coarse_gain_present = ixheaacd_read_bits_buf(&temp_bs, 1); + fine_grain_present = ixheaacd_read_bits_buf(&temp_bs, 1); + + if (dmx_level_present) ixheaacd_read_bits_buf(&temp_bs, 8); + + if (compression_present) ixheaacd_read_bits_buf(&temp_bs, 16); + + if (coarse_gain_present) ixheaacd_read_bits_buf(&temp_bs, 16); + + if (fine_grain_present) ixheaacd_read_bits_buf(&temp_bs, 16); + + if (!drc_handle->dvb_anc_data_present && temp_bs.cnt_bits >= 0) { + drc_handle->dvb_anc_data_pos = start_pos; + drc_handle->dvb_anc_data_present = 1; + } + } + } + + it_bit_buff->ptr_read_next += cnt; + it_bit_buff->cnt_bits -= ((cnt) << 3); + + if (it_bit_buff->ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + it_bit_buff->ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } +} + +VOID ixheaacd_read_fill_element(ia_bit_buf_struct *it_bit_buff, + ia_drc_dec_struct *drc_dummy, + ia_drc_dec_struct *ptr_drc_dec) { + WORD32 count; + count = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if ((count - 15) == 0) { + count = ixheaacd_read_bits_buf(it_bit_buff, 8); + count = (count + 14); + } + + if (count > 0) { + WORD32 extension_type; + + extension_type = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if (extension_type == EXT_DYNAMIC_RANGE) { + ptr_drc_dec->drc_element_found = 1; + count -= + ixheaacd_dec_drc_read_element(ptr_drc_dec, drc_dummy, it_bit_buff); + + } else { + ixheaacd_read_bits_buf(it_bit_buff, 4); + + it_bit_buff->ptr_read_next += count - 1; + it_bit_buff->cnt_bits -= ((count - 1) << 3); + + if (it_bit_buff->ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + it_bit_buff->ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + } + } +} + +WORD32 ixheaacd_get_element_index_tag( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, WORD ch_idx1, + WORD *ch_idx, WORD *channel, WORD *ele_idx_order, WORD total_elements, + WORD8 *element_used, WORD total_channels, ia_drc_dec_struct *pstr_drc_dec, + ia_drc_dec_struct *drc_dummy) { + WORD element_tag, j; + ia_aac_dec_state_struct *p_state_enhaacplus_dec = + p_obj_enhaacplus_dec->p_state_aac; + + ia_bit_buf_struct *it_bit_buff = p_state_enhaacplus_dec->ptr_bit_stream; + WORD element_idx; + WORD element_type; + + ia_aac_decoder_struct *aac_dec_handle = + p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx1]; + + *ch_idx = ch_idx1; + + if (p_state_enhaacplus_dec->bs_format != LOAS_BSFORMAT) { + if (ch_idx1 == 0) { + ixheaacd_byte_align(it_bit_buff, &aac_dec_handle->byte_align_bits); + } + } + { + if (ch_idx1 == 0) { + aac_dec_handle->byte_align_bits = it_bit_buff->cnt_bits; + } + } + + if (it_bit_buff->cnt_bits < 3) { + it_bit_buff->cnt_bits = -1; + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + element_tag = (WORD)ixheaacd_read_bits_buf(it_bit_buff, 7); + ixheaacd_read_bidirection(it_bit_buff, -7); + + element_idx = (element_tag & 0xF); + element_type = (element_tag >> 4) & 0x7; + + p_obj_enhaacplus_dec->aac_config.str_prog_config.alignment_bits = + it_bit_buff->bit_pos; + + while (element_type == 4 || element_type == 5 || element_type == 6) { + WORD type = (WORD)ixheaacd_read_bits_buf(it_bit_buff, 3); + + if (it_bit_buff->cnt_bits < 3) { + it_bit_buff->cnt_bits = -1; + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + if (type == 4) { + ixheaacd_read_data_stream_element( + it_bit_buff, &aac_dec_handle->byte_align_bits, pstr_drc_dec); + } + if (type == 5) { + WORD32 error_code = 0; + error_code = ixheaacd_decode_pce( + it_bit_buff, &p_obj_enhaacplus_dec->aac_config.ui_pce_found_in_hdr, + &p_obj_enhaacplus_dec->aac_config.str_prog_config); + if (error_code != 0) { + if (it_bit_buff->cnt_bits < 0) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + } + if (type == 6) { + ixheaacd_read_fill_element(it_bit_buff, drc_dummy, pstr_drc_dec); + } + + if (it_bit_buff->cnt_bits < 7) { + it_bit_buff->cnt_bits = -1; + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + element_tag = (WORD)ixheaacd_aac_showbits_7(it_bit_buff); + element_idx = (element_tag & 0xF); + element_type = (element_tag >> 4) & 0x7; + } + + if (total_elements == 2 && total_channels == 2 && + p_state_enhaacplus_dec->p_config->ui_pce_found_in_hdr == 2 && + ch_idx1 == 0) { + ixheaacd_fill_prog_config_slots(p_state_enhaacplus_dec); + } + + *channel = 1; + if (element_type == 1) { + *channel = 2; + } + + for (j = 0; j < total_elements; j++) { + if (p_obj_enhaacplus_dec->aac_config.element_type[j] == element_type && + (element_idx == ele_idx_order[j]) && (element_used[j] == 0)) { + *ch_idx = j; + element_used[j] = 1; + break; + } + } + + if (j == total_elements) { + if (it_bit_buff->cnt_bits < 0) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + ixheaacd_read_bidirection( + it_bit_buff, (WORD16)(it_bit_buff->cnt_bits - it_bit_buff->size)); + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_ELE_INSTANCE_TAG_NOT_FOUND; + } else + return 0; +} diff --git a/decoder/ixheaacd_common_rom.c b/decoder/ixheaacd_common_rom.c new file mode 100644 index 0000000..5622e12 --- /dev/null +++ b/decoder/ixheaacd_common_rom.c @@ -0,0 +1,351 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" + +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" + +/* const - has been removed to verify table relocatability */ +const ixheaacd_misc_tables ixheaacd_str_fft_n_transcendent_tables = { + + // const WORD16 cos_sin_lookup_tab[513] = + {0x0000, 0x0065, 0x00c9, 0x012e, 0x0192, 0x01f7, 0x025b, 0x02c0, 0x0324, + 0x0389, 0x03ed, 0x0452, 0x04b6, 0x051b, 0x057f, 0x05e3, 0x0648, 0x06ac, + 0x0711, 0x0775, 0x07d9, 0x083e, 0x08a2, 0x0906, 0x096b, 0x09cf, 0x0a33, + 0x0a97, 0x0afb, 0x0b60, 0x0bc4, 0x0c28, 0x0c8c, 0x0cf0, 0x0d54, 0x0db8, + 0x0e1c, 0x0e80, 0x0ee4, 0x0f47, 0x0fab, 0x100f, 0x1073, 0x10d6, 0x113a, + 0x119e, 0x1201, 0x1265, 0x12c8, 0x132b, 0x138f, 0x13f2, 0x1455, 0x14b9, + 0x151c, 0x157f, 0x15e2, 0x1645, 0x16a8, 0x170b, 0x176e, 0x17d1, 0x1833, + 0x1896, 0x18f9, 0x195b, 0x19be, 0x1a20, 0x1a83, 0x1ae5, 0x1b47, 0x1ba9, + 0x1c0c, 0x1c6e, 0x1cd0, 0x1d31, 0x1d93, 0x1df5, 0x1e57, 0x1eb8, 0x1f1a, + 0x1f7b, 0x1fdd, 0x203e, 0x209f, 0x2101, 0x2162, 0x21c3, 0x2224, 0x2284, + 0x22e5, 0x2346, 0x23a7, 0x2407, 0x2467, 0x24c8, 0x2528, 0x2588, 0x25e8, + 0x2648, 0x26a8, 0x2708, 0x2768, 0x27c7, 0x2827, 0x2886, 0x28e5, 0x2945, + 0x29a4, 0x2a03, 0x2a62, 0x2ac1, 0x2b1f, 0x2b7e, 0x2bdc, 0x2c3b, 0x2c99, + 0x2cf7, 0x2d55, 0x2db3, 0x2e11, 0x2e6f, 0x2ecc, 0x2f2a, 0x2f87, 0x2fe5, + 0x3042, 0x309f, 0x30fc, 0x3159, 0x31b5, 0x3212, 0x326e, 0x32cb, 0x3327, + 0x3383, 0x33df, 0x343b, 0x3497, 0x34f2, 0x354e, 0x35a9, 0x3604, 0x365f, + 0x36ba, 0x3715, 0x3770, 0x37ca, 0x3825, 0x387f, 0x38d9, 0x3933, 0x398d, + 0x39e7, 0x3a40, 0x3a9a, 0x3af3, 0x3b4c, 0x3ba5, 0x3bfe, 0x3c57, 0x3caf, + 0x3d08, 0x3d60, 0x3db8, 0x3e10, 0x3e68, 0x3ec0, 0x3f17, 0x3f6f, 0x3fc6, + 0x401d, 0x4074, 0x40cb, 0x4121, 0x4178, 0x41ce, 0x4224, 0x427a, 0x42d0, + 0x4326, 0x437b, 0x43d1, 0x4426, 0x447b, 0x44d0, 0x4524, 0x4579, 0x45cd, + 0x4621, 0x4675, 0x46c9, 0x471d, 0x4770, 0x47c4, 0x4817, 0x486a, 0x48bd, + 0x490f, 0x4962, 0x49b4, 0x4a06, 0x4a58, 0x4aaa, 0x4afb, 0x4b4d, 0x4b9e, + 0x4bef, 0x4c40, 0x4c91, 0x4ce1, 0x4d31, 0x4d81, 0x4dd1, 0x4e21, 0x4e71, + 0x4ec0, 0x4f0f, 0x4f5e, 0x4fad, 0x4ffb, 0x504a, 0x5098, 0x50e6, 0x5134, + 0x5181, 0x51cf, 0x521c, 0x5269, 0x52b6, 0x5303, 0x534f, 0x539b, 0x53e7, + 0x5433, 0x547f, 0x54ca, 0x5515, 0x5560, 0x55ab, 0x55f6, 0x5640, 0x568a, + 0x56d4, 0x571e, 0x5767, 0x57b1, 0x57fa, 0x5843, 0x588c, 0x58d4, 0x591c, + 0x5964, 0x59ac, 0x59f4, 0x5a3b, 0x5a82, 0x5ac9, 0x5b10, 0x5b57, 0x5b9d, + 0x5be3, 0x5c29, 0x5c6f, 0x5cb4, 0x5cf9, 0x5d3e, 0x5d83, 0x5dc8, 0x5e0c, + 0x5e50, 0x5e94, 0x5ed7, 0x5f1b, 0x5f5e, 0x5fa1, 0x5fe4, 0x6026, 0x6068, + 0x60aa, 0x60ec, 0x612e, 0x616f, 0x61b0, 0x61f1, 0x6232, 0x6272, 0x62b2, + 0x62f2, 0x6332, 0x6371, 0x63b0, 0x63ef, 0x642e, 0x646c, 0x64ab, 0x64e9, + 0x6526, 0x6564, 0x65a1, 0x65de, 0x661b, 0x6657, 0x6693, 0x66d0, 0x670b, + 0x6747, 0x6782, 0x67bd, 0x67f8, 0x6832, 0x686d, 0x68a7, 0x68e0, 0x691a, + 0x6953, 0x698c, 0x69c5, 0x69fd, 0x6a36, 0x6a6e, 0x6aa5, 0x6add, 0x6b14, + 0x6b4b, 0x6b82, 0x6bb8, 0x6bee, 0x6c24, 0x6c5a, 0x6c8f, 0x6cc4, 0x6cf9, + 0x6d2e, 0x6d62, 0x6d96, 0x6dca, 0x6dfe, 0x6e31, 0x6e64, 0x6e97, 0x6ec9, + 0x6efb, 0x6f2d, 0x6f5f, 0x6f90, 0x6fc2, 0x6ff2, 0x7023, 0x7053, 0x7083, + 0x70b3, 0x70e3, 0x7112, 0x7141, 0x7170, 0x719e, 0x71cc, 0x71fa, 0x7228, + 0x7255, 0x7282, 0x72af, 0x72dc, 0x7308, 0x7334, 0x735f, 0x738b, 0x73b6, + 0x73e1, 0x740b, 0x7436, 0x7460, 0x7489, 0x74b3, 0x74dc, 0x7505, 0x752d, + 0x7556, 0x757e, 0x75a6, 0x75cd, 0x75f4, 0x761b, 0x7642, 0x7668, 0x768e, + 0x76b4, 0x76d9, 0x76fe, 0x7723, 0x7748, 0x776c, 0x7790, 0x77b4, 0x77d8, + 0x77fb, 0x781e, 0x7840, 0x7863, 0x7885, 0x78a6, 0x78c8, 0x78e9, 0x790a, + 0x792a, 0x794a, 0x796a, 0x798a, 0x79aa, 0x79c9, 0x79e7, 0x7a06, 0x7a24, + 0x7a42, 0x7a60, 0x7a7d, 0x7a9a, 0x7ab7, 0x7ad3, 0x7aef, 0x7b0b, 0x7b27, + 0x7b42, 0x7b5d, 0x7b78, 0x7b92, 0x7bac, 0x7bc6, 0x7bdf, 0x7bf9, 0x7c11, + 0x7c2a, 0x7c42, 0x7c5a, 0x7c72, 0x7c89, 0x7ca0, 0x7cb7, 0x7cce, 0x7ce4, + 0x7cfa, 0x7d0f, 0x7d25, 0x7d3a, 0x7d4e, 0x7d63, 0x7d77, 0x7d8a, 0x7d9e, + 0x7db1, 0x7dc4, 0x7dd6, 0x7de9, 0x7dfb, 0x7e0c, 0x7e1e, 0x7e2f, 0x7e3f, + 0x7e50, 0x7e60, 0x7e70, 0x7e7f, 0x7e8e, 0x7e9d, 0x7eac, 0x7eba, 0x7ec8, + 0x7ed6, 0x7ee3, 0x7ef0, 0x7efd, 0x7f0a, 0x7f16, 0x7f22, 0x7f2d, 0x7f38, + 0x7f43, 0x7f4e, 0x7f58, 0x7f62, 0x7f6c, 0x7f75, 0x7f7e, 0x7f87, 0x7f90, + 0x7f98, 0x7fa0, 0x7fa7, 0x7fae, 0x7fb5, 0x7fbc, 0x7fc2, 0x7fc8, 0x7fce, + 0x7fd3, 0x7fd9, 0x7fdd, 0x7fe2, 0x7fe6, 0x7fea, 0x7fed, 0x7ff1, 0x7ff4, + 0x7ff6, 0x7ff8, 0x7ffa, 0x7ffc, 0x7ffe, 0x7fff, 0x7fff, 0x7fff, 0x7fff}, + + // const WORD16 sine_table8_16[8] = + { + -0x0000, -0x18f9, -0x30fc, -0x471d, -0x5a82, -0x6a6e, -0x7642, -0x7d8a, + }, + + // const WORD16 log_dual_is_table[LOG_2_TABLE_SIZE] = + {(WORD16)(-0x8000), + 0x0000, + 0x1000, + 0x195c, + 0x2000, + 0x2527, + 0x295c, + 0x2ceb, + 0x3000, + 0x32b8, + 0x3527, + 0x375a, + 0x395c, + 0x3b35, + 0x3ceb, + 0x3e83, + 0x4000, + 0x4166, + 0x42b8, + 0x43f8, + 0x4527, + 0x4647, + 0x475a, + 0x4861, + 0x495c, + 0x4a4d, + 0x4b35, + 0x4c14, + 0x4ceb, + 0x4dba, + 0x4e83, + 0x4f44, + 0x5000, + 0x50b6, + 0x5166, + 0x5212, + 0x52b8, + 0x535a, + 0x53f8, + 0x5491, + 0x5527, + 0x55b9, + 0x5647, + 0x56d2, + 0x575a, + 0x57df, + 0x5861, + 0x58e0, + 0x595c, + 0x59d6, + 0x5a4d, + 0x5ac2, + 0x5b35, + 0x5ba6, + 0x5c14, + 0x5c80, + 0x5ceb, + 0x5d54, + 0x5dba, + 0x5e1f, + 0x5e83, + 0x5ee4, + 0x5f44, + 0x5fa3, + 0x6000}, + + /*WORD32 down_mix_martix[4][2][8] = */ + { + {/* Q30 */ /* 5.0 Channel to Stereo */ + {405185594, 0, 315041546, 315041546, 0, 0, 0, 0}, + {0, 405185594, 315041546, 0, 315041546, 0, 0, 0}}, + {/* Q30 */ /* 5.1 Channel to Stereo */ + {405185594, 0, 286509481, 95503160, 286509481, 0, 0, 0}, + {0, 405185594, 286509481, 95503160, 0, 286509481, 0, 0}}, + {/* Q30 */ /* 7.0 Channel to Stereo */ + {405185594, 0, 244131873, 244131873, 0, 244131873, 0, 0}, + {0, 405185594, 244131873, 0, 244131873, 0, 244131873, 0}}, + {/* Q30 */ /* 7.1 Channel to Stereo */ + {405185594, 0, 226641828, 75547276, 226641828, 0, 226641828, 0}, + {0, 405185594, 75547276, 226641828, 0, 226641828, 0, 226641828}}, + + } + + /* Q29 */ + /*const WORD32 cc_gain_scale[4] = */, + {585461881, 638450708, 759250125, 1073741824}, + + // const WORD16 inv_table[INV_TABLE_SIZE ] = + { + + 0x7f80, 0x7f02, 0x7e84, 0x7e08, 0x7d8c, 0x7d12, 0x7c98, 0x7c1f, 0x7ba7, + 0x7b30, 0x7aba, 0x7a45, 0x79d0, 0x795d, 0x78ea, 0x7878, 0x7808, 0x7797, + 0x7728, 0x76ba, 0x764c, 0x75df, 0x7573, 0x7507, 0x749d, 0x7433, 0x73ca, + 0x7361, 0x72fa, 0x7293, 0x722d, 0x71c7, 0x7162, 0x70fe, 0x709b, 0x7038, + 0x6fd6, 0x6f75, 0x6f14, 0x6eb4, 0x6e54, 0x6df6, 0x6d98, 0x6d3a, 0x6cdd, + 0x6c81, 0x6c25, 0x6bca, 0x6b70, 0x6b16, 0x6abc, 0x6a64, 0x6a0c, 0x69b4, + 0x695d, 0x6907, 0x68b1, 0x685b, 0x6807, 0x67b2, 0x675e, 0x670b, 0x66b9, + 0x6666, 0x6615, 0x65c4, 0x6573, 0x6523, 0x64d3, 0x6484, 0x6435, 0x63e7, + 0x6399, 0x634c, 0x62ff, 0x62b3, 0x6267, 0x621c, 0x61d1, 0x6186, 0x613c, + 0x60f2, 0x60a9, 0x6060, 0x6018, 0x5fd0, 0x5f89, 0x5f41, 0x5efb, 0x5eb5, + 0x5e6f, 0x5e29, 0x5de4, 0x5d9f, 0x5d5b, 0x5d17, 0x5cd4, 0x5c91, 0x5c4e, + 0x5c0c, 0x5bca, 0x5b88, 0x5b47, 0x5b06, 0x5ac5, 0x5a85, 0x5a45, 0x5a06, + 0x59c6, 0x5988, 0x5949, 0x590b, 0x58cd, 0x5890, 0x5853, 0x5816, 0x57da, + 0x579d, 0x5762, 0x5726, 0x56eb, 0x56b0, 0x5676, 0x563b, 0x5601, 0x55c8, + 0x558e, 0x5555, 0x551d, 0x54e4, 0x54ac, 0x5474, 0x543d, 0x5405, 0x53ce, + 0x5398, 0x5361, 0x532b, 0x52f5, 0x52bf, 0x528a, 0x5255, 0x5220, 0x51ec, + 0x51b7, 0x5183, 0x514f, 0x511c, 0x50e9, 0x50b6, 0x5083, 0x5050, 0x501e, + 0x4fec, 0x4fba, 0x4f89, 0x4f57, 0x4f26, 0x4ef6, 0x4ec5, 0x4e95, 0x4e64, + 0x4e35, 0x4e05, 0x4dd5, 0x4da6, 0x4d77, 0x4d48, 0x4d1a, 0x4cec, 0x4cbd, + 0x4c90, 0x4c62, 0x4c34, 0x4c07, 0x4bda, 0x4bad, 0x4b81, 0x4b54, 0x4b28, + 0x4afc, 0x4ad0, 0x4aa4, 0x4a79, 0x4a4e, 0x4a23, 0x49f8, 0x49cd, 0x49a3, + 0x4979, 0x494e, 0x4925, 0x48fb, 0x48d1, 0x48a8, 0x487f, 0x4856, 0x482d, + 0x4805, 0x47dc, 0x47b4, 0x478c, 0x4764, 0x473c, 0x4715, 0x46ed, 0x46c6, + 0x469f, 0x4678, 0x4651, 0x462b, 0x4604, 0x45de, 0x45b8, 0x4592, 0x456c, + 0x4547, 0x4521, 0x44fc, 0x44d7, 0x44b2, 0x448d, 0x4469, 0x4444, 0x4420, + 0x43fc, 0x43d8, 0x43b4, 0x4390, 0x436d, 0x4349, 0x4326, 0x4303, 0x42e0, + 0x42bd, 0x429a, 0x4277, 0x4255, 0x4233, 0x4211, 0x41ee, 0x41cd, 0x41ab, + 0x4189, 0x4168, 0x4146, 0x4125, 0x4104, 0x40e3, 0x40c2, 0x40a2, 0x4081, + 0x4061, 0x4040, 0x4020, 0x4000 + + }, + // const WORD16 sqrt_table[SQRT_TABLE_SIZE] = + {0x5a82, 0x5ab0, 0x5add, 0x5b0a, 0x5b37, 0x5b64, 0x5b90, 0x5bbd, 0x5bea, + 0x5c16, 0x5c43, 0x5c6f, 0x5c9b, 0x5cc8, 0x5cf4, 0x5d20, 0x5d4c, 0x5d77, + 0x5da3, 0x5dcf, 0x5dfb, 0x5e26, 0x5e52, 0x5e7d, 0x5ea8, 0x5ed3, 0x5eff, + 0x5f2a, 0x5f55, 0x5f80, 0x5fab, 0x5fd5, 0x6000, 0x602b, 0x6055, 0x6080, + 0x60aa, 0x60d4, 0x60ff, 0x6129, 0x6153, 0x617d, 0x61a7, 0x61d1, 0x61fb, + 0x6225, 0x624e, 0x6278, 0x62a1, 0x62cb, 0x62f4, 0x631e, 0x6347, 0x6370, + 0x6399, 0x63c2, 0x63ec, 0x6414, 0x643d, 0x6466, 0x648f, 0x64b8, 0x64e0, + 0x6509, 0x6531, 0x655a, 0x6582, 0x65ab, 0x65d3, 0x65fb, 0x6623, 0x664b, + 0x6673, 0x669b, 0x66c3, 0x66eb, 0x6713, 0x673a, 0x6762, 0x678a, 0x67b1, + 0x67d9, 0x6800, 0x6827, 0x684f, 0x6876, 0x689d, 0x68c4, 0x68eb, 0x6912, + 0x6939, 0x6960, 0x6987, 0x69ae, 0x69d4, 0x69fb, 0x6a22, 0x6a48, 0x6a6f, + 0x6a95, 0x6abc, 0x6ae2, 0x6b08, 0x6b2f, 0x6b55, 0x6b7b, 0x6ba1, 0x6bc7, + 0x6bed, 0x6c13, 0x6c39, 0x6c5f, 0x6c84, 0x6caa, 0x6cd0, 0x6cf5, 0x6d1b, + 0x6d41, 0x6d66, 0x6d8b, 0x6db1, 0x6dd6, 0x6dfb, 0x6e21, 0x6e46, 0x6e6b, + 0x6e90, 0x6eb5, 0x6eda, 0x6eff, 0x6f24, 0x6f49, 0x6f6d, 0x6f92, 0x6fb7, + 0x6fdb, 0x7000, 0x7025, 0x7049, 0x706e, 0x7092, 0x70b6, 0x70db, 0x70ff, + 0x7123, 0x7147, 0x716b, 0x7190, 0x71b4, 0x71d8, 0x71fc, 0x721f, 0x7243, + 0x7267, 0x728b, 0x72af, 0x72d2, 0x72f6, 0x731a, 0x733d, 0x7361, 0x7384, + 0x73a8, 0x73cb, 0x73ee, 0x7412, 0x7435, 0x7458, 0x747b, 0x749e, 0x74c2, + 0x74e5, 0x7508, 0x752b, 0x754e, 0x7570, 0x7593, 0x75b6, 0x75d9, 0x75fc, + 0x761e, 0x7641, 0x7664, 0x7686, 0x76a9, 0x76cb, 0x76ee, 0x7710, 0x7733, + 0x7755, 0x7777, 0x7799, 0x77bc, 0x77de, 0x7800, 0x7822, 0x7844, 0x7866, + 0x7888, 0x78aa, 0x78cc, 0x78ee, 0x7910, 0x7932, 0x7953, 0x7975, 0x7997, + 0x79b9, 0x79da, 0x79fc, 0x7a1d, 0x7a3f, 0x7a60, 0x7a82, 0x7aa3, 0x7ac5, + 0x7ae6, 0x7b07, 0x7b29, 0x7b4a, 0x7b6b, 0x7b8c, 0x7bad, 0x7bce, 0x7bef, + 0x7c11, 0x7c32, 0x7c52, 0x7c73, 0x7c94, 0x7cb5, 0x7cd6, 0x7cf7, 0x7d18, + 0x7d38, 0x7d59, 0x7d7a, 0x7d9a, 0x7dbb, 0x7ddb, 0x7dfc, 0x7e1c, 0x7e3d, + 0x7e5d, 0x7e7e, 0x7e9e, 0x7ebe, 0x7edf, 0x7eff, 0x7f1f, 0x7f3f, 0x7f60, + 0x7f80, 0x7fa0, 0x7fc0, 0x7fe0, 0x7fff}, + 0, + + /*WORD32 start_band[10][16] =*/ + {/*sampling frequency = 96000*/ + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 19, 23, 27}, + + /*sampling Frequency = 88200*/ + {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 20, 24, 28}, + + /*sampling Frequency = 64000*/ + {1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 21, 25}, + + /*sampling Frequency = 48000*/ + {1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 21, 25}, + + /*sampling Frequency = 44100*/ + {2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 22, 26}, + + /*sampling Frequency = 40000*/ + {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 23, 25}, + + /*sampling Frequency = 32000*/ + {2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 24}, + + /*sampling Frequency = 24000*/ + {3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 24}, + + /*sampling Frequency = 22050*/ + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22}, + + /*sampling Frequency = 16000*/ + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}}, + + /*WORD32 stop_band[10][16] = */ + {/*sampling Frequency = 96000*/ + {7, 8, 10, 12, 14, 16, 19, 23, 27, 32, 38, 46, 54, 64, 78, 86}, + + /*sampling Frequency = 88200*/ + {7, 8, 10, 12, 14, 16, 19, 23, 27, 32, 38, 46, 54, 64, 78, 86}, + + /*sampling Frequency = 64000*/ + {10, 11, 13, 15, 17, 20, 23, 27, 31, 36, 42, 48, 55, 64, 78, 89}, + + /*sampling Frequency = 48000*/ + {11, 12, 14, 16, 19, 22, 25, 28, 32, 37, 43, 49, 56, 64, 78, 90}, + + /*sampling Frequency = 44100*/ + {12, 14, 16, 18, 20, 23, 26, 30, 34, 38, 43, 49, 56, 64, 78, 91}, + + /*sampling Frequency = 40000*/ + {13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64, 78, 92}, + + /*sampling Frequency = 32000*/ + {16, 18, 20, 22, 24, 27, 30, 34, 38, 42, 46, 52, 58, 64, 78, 95}, + + /*sampling Frequency = 24000*/ + {16, 18, 20, 22, 24, 27, 30, 34, 38, 42, 46, 52, 58, 64, 78, 95}, + + /*sampling Frequency = 22050*/ + {17, 19, 21, 23, 25, 28, 31, 34, 38, 42, 47, 52, 58, 64, 78, 96}, + + /*sampling Frequency = 16000*/ + {24, 26, 28, 30, 32, 35, 38, 41, 44, 47, 51, 55, 59, 64, 78, 10}}, + /*WORD32 stop_freq_table_fs40k_2[13] = */ + {26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 52, 56, 60, 0}, + /*WORD32 stop_freq_table_fs40k_4[13] = */ + {19, 21, 23, 25, 27, 30, 33, 36, 40, 44, 48, 53, 58, 0} + +}; diff --git a/decoder/ixheaacd_common_rom.h b/decoder/ixheaacd_common_rom.h new file mode 100644 index 0000000..5209e0f --- /dev/null +++ b/decoder/ixheaacd_common_rom.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_COMMON_ROM_H +#define IXHEAACD_COMMON_ROM_H + +#define LOG_2_TABLE_SIZE 65 +#define INV_TABLE_SIZE 256 +#define SQRT_TABLE_SIZE 256 + +typedef struct { + const WORD16 trig_data[513]; + const WORD16 sine_table8_16[8]; + const WORD16 log_dual_is_table[LOG_2_TABLE_SIZE]; + + const WORD32 down_mix_martix[4][2][8]; + const WORD32 cc_gain_scale[4]; + + WORD16 inv_table[INV_TABLE_SIZE]; + const WORD16 sqrt_table[SQRT_TABLE_SIZE + 1]; + + WORD32 dummy; + WORD32 start_band[10][16]; + WORD32 stop_band[10][16]; + WORD32 stop_freq_table_fs40k_2[14]; + WORD32 stop_freq_table_fs40k_4[14]; +} ixheaacd_misc_tables; + +extern const ixheaacd_misc_tables ixheaacd_str_fft_n_transcendent_tables; + +#endif diff --git a/decoder/ixheaacd_config.h b/decoder/ixheaacd_config.h new file mode 100644 index 0000000..2d80563 --- /dev/null +++ b/decoder/ixheaacd_config.h @@ -0,0 +1,662 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CONFIG_H +#define IXHEAACD_CONFIG_H + +#define USAC_MAX_ELEMENTS (16) + +#define USAC_MAX_CONFIG_EXTENSIONS (16) + +#define ID_USAC_SCE 0 +#define ID_USAC_CPE 1 +#define ID_USAC_LFE 2 +#define ID_USAC_EXT 3 +#define ID_USAC_INVALID 0xFF + +#define USAC_SBR_RATIO_NO_SBR 0 +#define USAC_SBR_RATIO_INDEX_2_1 1 +#define USAC_SBR_RATIO_INDEX_8_3 2 +#define USAC_SBR_RATIO_INDEX_4_1 3 + +#define USAC_OUT_FRAMELENGTH_768 768 +#define USAC_OUT_FRAMELENGTH_1024 1024 +#define USAC_OUT_FRAMELENGTH_2048 2048 +#define USAC_OUT_FRAMELENGTH_4096 4096 + +#define ID_EXT_ELE_FILL 0 +#define ID_EXT_ELE_MPEGS 1 +#define ID_EXT_ELE_SAOC 2 +#ifdef ENABLE_DRC +#define ID_EXT_ELE_AUDIOPREROLL 3 +#define ID_EXT_ELE_UNI_DRC 4 +#endif + +#define ID_CONFIG_EXT_FILL 0 +#ifdef ENABLE_DRC +#define ID_CONFIG_EXT_LOUDNESS_INFO (2) +#endif + +typedef UWORD8 UINT8; +typedef UWORD32 UINT32; + +typedef struct { + UINT32 harmonic_sbr; + UINT32 bs_inter_tes; + UINT32 bs_pvc; + WORD16 dflt_start_freq; + WORD16 dflt_stop_freq; + WORD16 dflt_header_extra1; + WORD16 dflt_header_extra2; + WORD16 dflt_freq_scale; + WORD16 dflt_alter_scale; + WORD16 dflt_noise_bands; + WORD16 dflt_limiter_bands; + WORD16 dflt_limiter_gains; + WORD16 dflt_interpol_freq; + WORD16 dflt_smoothing_mode; +} ia_usac_dec_sbr_config_struct; + +typedef struct { + UINT32 bs_freq_res; + UINT32 bs_fixed_gain_dmx; + UINT32 bs_temp_shape_config; + UINT32 bs_decorr_config; + UINT32 bs_high_rate_mode; + UINT32 bs_phase_coding; + UINT32 bs_ott_bands_phase_present; + UINT32 bs_ott_bands_phase; + UINT32 bs_residual_bands; + UINT32 bs_pseudo_lr; + UINT32 bs_env_quant_mode; +} ia_usac_dec_mps_config_struct; + +#define BS_OUTPUT_CHANNEL_POS_NA -1 /* n/a */ +#define BS_OUTPUT_CHANNEL_POS_L 0 /* Left Front */ +#define BS_OUTPUT_CHANNEL_POS_R 1 /* Right Front */ +#define BS_OUTPUT_CHANNEL_POS_C 2 /* Center Front */ +#define BS_OUTPUT_CHANNEL_POS_LFE 3 /* Low Frequency Enhancement */ +#define BS_OUTPUT_CHANNEL_POS_LS 4 /* Left Surround */ +#define BS_OUTPUT_CHANNEL_POS_RS 5 /* Right Surround */ +#define BS_OUTPUT_CHANNEL_POS_LC 6 /* Left Front Center */ +#define BS_OUTPUT_CHANNEL_POS_RC 7 /* Right Front Center */ +#define BS_OUTPUT_CHANNEL_POS_LSR 8 /* Rear Surround Left */ +#define BS_OUTPUT_CHANNEL_POS_RSR 9 /* Rear Surround Right */ +#define BS_OUTPUT_CHANNEL_POS_CS 10 /* Rear Center */ +#define BS_OUTPUT_CHANNEL_POS_LSD 11 /* Left Surround Direct */ +#define BS_OUTPUT_CHANNEL_POS_RSD 12 /* Right Surround Direct */ +#define BS_OUTPUT_CHANNEL_POS_LSS 13 /* Left Side Surround */ +#define BS_OUTPUT_CHANNEL_POS_RSS 14 /* Right Side Surround */ +#define BS_OUTPUT_CHANNEL_POS_LW 15 /* Left Wide Front */ +#define BS_OUTPUT_CHANNEL_POS_RW 16 /* Right Wide Front */ +#define BS_OUTPUT_CHANNEL_POS_LV 17 /* Left Front Vertical Height */ +#define BS_OUTPUT_CHANNEL_POS_RV 18 /* Right Front Vertical Height */ +#define BS_OUTPUT_CHANNEL_POS_CV 19 /* Center Front Vertical Height */ +#define BS_OUTPUT_CHANNEL_POS_LVR 20 /* Left Surround Vertical Height Rear */ +#define BS_OUTPUT_CHANNEL_POS_RVR 21 /* Right Surround Vertical Height Rear */ +#define BS_OUTPUT_CHANNEL_POS_CVR 22 /* Center Vertical Height Rear */ +#define BS_OUTPUT_CHANNEL_POS_LVSS 23 /* Left Vertical Height Side Surround */ +#define BS_OUTPUT_CHANNEL_POS_RVSS \ + 24 /* Right Vertical Height Side Surround \ \ \ + */ +#define BS_OUTPUT_CHANNEL_POS_TS 25 /* Top Center Surround */ +#define BS_OUTPUT_CHANNEL_POS_LFE2 26 /* Low Frequency Enhancement 2 */ +#define BS_OUTPUT_CHANNEL_POS_LB 27 /* Left Front Vertical Bottom */ +#define BS_OUTPUT_CHANNEL_POS_RB 28 /* Right Front Vertical Bottom */ +#define BS_OUTPUT_CHANNEL_POS_CB 29 /* Center Front Vertical Bottom */ +#define BS_OUTPUT_CHANNEL_POS_LVS 30 /* Left Vertical Height Surround */ +#define BS_OUTPUT_CHANNEL_POS_RVS 31 /* Right Vertical Height Surround */ + +#define BS_MAX_NUM_OUT_CHANNELS (255) + +#ifdef ENABLE_DRC +#define EXT_COUNT_MAX (2) +#define MAX_CHANNEL_COUNT (128) +#define SEQUENCE_COUNT_MAX (24) +#define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX (9) +#define PARAM_DRC_INSTRUCTIONS_COUNT_MAX (8) +#define DOWNMIX_ID_COUNT_MAX (8) +#define DRC_SET_ID_COUNT_MAX (16) +#define EQ_SET_ID_COUNT_MAX (8) +#define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX (4) +#define LOUD_EQ_INSTRUCTIONS_COUNT_MAX (8) +#define FILTER_ELEMENT_COUNT_MAX (16) +#define FILTER_BLOCK_COUNT_MAX (16) +#define REAL_ZERO_RADIUS_ONE_COUNT_MAX (14) +#define REAL_ZERO_COUNT_MAX (64) +#define COMPLEX_ZERO_COUNT_MAX (64) +#define REAL_POLE_COUNT_MAX (16) +#define COMPLEX_POLE_COUNT_MAX (16) +#define FIR_ORDER_MAX (128) +#define EQ_NODE_COUNT_MAX (33) +#define UNIQUE_SUBBAND_GAIN_COUNT_MAX (16) +#define EQ_SUBBAND_GAIN_COUNT_MAX (135) +#define EQ_CHANNEL_GROUP_COUNT_MAX (4) +#define EQ_FILTER_BLOCK_COUNT_MAX (4) +#define EQ_INSTRUCTIONS_COUNT_MAX (8) +#define DRC_COEFF_COUNT_MAX (8) +#define DOWNMIX_INSTRUCTION_COUNT_MAX (16) +#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) +#define BAND_COUNT_MAX (8) + +#define N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX (512 + 14) +#define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX +#define SPLIT_CHARACTERISTIC_NODE_COUNT_MAX (4) +#define SPLIT_CHARACTERISTIC_COUNT_MAX (8) +#define SHAPE_FILTER_COUNT_MAX (8) +#define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX +#define DRC_BAND_COUNT_MAX BAND_COUNT_MAX +#define SPEAKER_POS_COUNT_MAX (128) +#define DOWNMIX_COEFF_COUNT_MAX (32 * 32) +#endif + +typedef struct { + UINT32 tw_mdct; + UINT32 noise_filling; + UINT32 stereo_config_index; + + UINT32 usac_ext_eleme_def_len; + UINT32 usac_ext_elem_pld_frag; + + ia_usac_dec_sbr_config_struct str_usac_sbr_config; + ia_usac_dec_mps_config_struct str_usac_mps212_config; + +} ia_usac_dec_element_config_struct; + +typedef struct { + UWORD32 num_elements; +#ifdef ENABLE_DRC + UWORD32 num_config_extensions; +#endif + UWORD32 usac_element_type[USAC_MAX_ELEMENTS]; + ia_usac_dec_element_config_struct str_usac_element_config[USAC_MAX_ELEMENTS]; + +#ifdef ENABLE_DRC + WORD32 usac_cfg_ext_info_present[USAC_MAX_CONFIG_EXTENSIONS]; + 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; + 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]; +#endif + +} ia_usac_decoder_config_struct; + +typedef struct { + UINT32 usac_sampling_frequency_index; + UINT32 usac_sampling_frequency; + UINT32 core_sbr_framelength_index; + UINT32 channel_configuration_index; + + UINT32 num_out_channels; + UINT32 output_channel_pos[BS_MAX_NUM_OUT_CHANNELS]; + ia_usac_decoder_config_struct str_usac_dec_config; + +} ia_usac_config_struct; + +#ifdef ENABLE_DRC +#ifdef AMMENDMENT1 +typedef struct { + WORD32 parametric_lim_threshold_present; + FLOAT32 parametric_lim_threshold; + WORD32 parametric_lim_attack; + WORD32 parametric_lim_release_present; + WORD32 parametric_lim_release; + WORD32 drc_characteristic; + + WORD32 disable_paramteric_drc; +} ia_parametric_drc_lim_struct; +typedef struct { + WORD32 level_estim_k_weighting_type; + WORD32 level_estim_integration_time_present; + WORD32 level_estim_integration_time; + WORD32 drc_curve_definition_type; + WORD32 drc_characteristic; + WORD32 node_count; + WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; + WORD32 drc_gain_smooth_parameters_present; + WORD32 gain_smooth_attack_time_slow; + WORD32 gain_smooth_release_time_slow; + WORD32 gain_smooth_time_fast_present; + WORD32 gain_smooth_attack_time_fast; + WORD32 gain_smooth_release_time_fast; + WORD32 gain_smooth_threshold_present; + WORD32 gain_smooth_attack_threshold; + WORD32 gain_smooth_rel_threshold; + WORD32 gain_smooth_hold_off_count_present; + WORD32 gain_smooth_hold_off; + + WORD32 disable_paramteric_drc; +} ia_parametric_drc_type_feed_forward_struct; +typedef struct { + WORD32 parametric_drc_id; + WORD32 parametric_drc_look_ahead_flag; + WORD32 parametric_drc_look_ahead; + WORD32 parametric_drc_preset_id_present; + WORD32 parametric_drc_preset_id; + WORD32 parametric_drc_type; + WORD32 len_bit_size; + ia_parametric_drc_type_feed_forward_struct + str_parametric_drc_type_feed_forward; +#ifdef AMMENDMENT1 + ia_parametric_drc_lim_struct parametric_drc_lim; +#endif + + WORD32 drc_characteristic; + WORD32 disable_paramteric_drc; +} ia_parametric_drc_instructions_struct; + +typedef struct { + WORD32 parametric_drc_id; + WORD32 side_chain_config_type; + WORD32 downmix_id; + WORD32 level_estim_channel_weight_format; + FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; + WORD32 drc_input_loudness_present; + FLOAT32 drc_input_loudness; + + WORD32 ch_count_from_dwnmix_id; +} ia_parametric_drc_gain_set_params_struct; + +typedef struct { + WORD32 drc_location; + WORD32 parametric_drc_frame_size_format; + WORD32 parametric_drc_frame_size; + WORD32 parametric_drc_delay_max_present; + WORD32 parametric_drc_delay_max; + WORD32 reset_parametric_drc; + WORD32 parametric_drc_gain_set_count; + ia_parametric_drc_gain_set_params_struct + str_parametric_drc_gain_set_params[SEQUENCE_COUNT_MAX]; +} ia_drc_coeff_parametric_drc_struct; + +typedef struct { + WORD32 loud_eq_set_id; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 drc_set_id_count; + WORD32 drc_set_id[DRC_SET_ID_COUNT_MAX]; + WORD32 eq_set_id_count; + WORD32 eq_set_id[EQ_SET_ID_COUNT_MAX]; + WORD32 loudness_after_drc; + WORD32 loudness_after_eq; + WORD32 loud_eq_gain_sequence_count; + WORD32 gain_seq_idx[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_format_is_cicp[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_left_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 drc_characteristic_right_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + WORD32 frequency_range_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + FLOAT32 loud_eq_scaling[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; + FLOAT32 loud_eq_offset[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; +} ia_loud_eq_instructions_struct; + +#endif +typedef struct { + WORD32 filt_ele_idx; + WORD32 filt_ele_gain_flag; + FLOAT32 filt_ele_gain; +} ia_filt_ele_struct; + +typedef struct { + WORD32 filter_element_count; + ia_filt_ele_struct str_filter_element[FILTER_ELEMENT_COUNT_MAX]; +} ia_filt_block_struct; + +typedef struct { + WORD32 eq_filter_format; + WORD32 bs_real_zero_radius_one_count; + WORD32 real_zero_count; + WORD32 generic_zero_count; + WORD32 real_pole_count; + WORD32 cmplx_pole_count; + WORD32 zero_sign[REAL_ZERO_RADIUS_ONE_COUNT_MAX]; + FLOAT32 real_zero_radius[REAL_ZERO_COUNT_MAX]; + FLOAT32 generic_zero_radius[COMPLEX_ZERO_COUNT_MAX]; + FLOAT32 generic_zero_angle[COMPLEX_ZERO_COUNT_MAX]; + FLOAT32 real_pole_radius[REAL_POLE_COUNT_MAX]; + FLOAT32 complex_pole_radius[COMPLEX_POLE_COUNT_MAX]; + FLOAT32 complex_pole_angle[COMPLEX_POLE_COUNT_MAX]; + WORD32 fir_filt_order; + WORD32 fir_symmetry; + FLOAT32 fir_coeff[FIR_ORDER_MAX / 2]; +} ia_unique_td_filt_element; +typedef struct { + WORD32 num_eq_nodes; + FLOAT32 eq_slope[EQ_NODE_COUNT_MAX]; + WORD32 eq_freq_delta[EQ_NODE_COUNT_MAX]; + FLOAT32 eq_gain_initial; + FLOAT32 eq_gain_delta[EQ_NODE_COUNT_MAX]; +} ia_eq_subband_gain_spline_struct; +typedef struct { + FLOAT32 eq_subband_gain[EQ_SUBBAND_GAIN_COUNT_MAX]; +} ia_eq_subband_gain_vector; +typedef struct { + WORD32 eq_delay_max_present; + WORD32 eq_delay_max; + WORD32 unique_filter_block_count; + ia_filt_block_struct str_filter_block[FILTER_BLOCK_COUNT_MAX]; + WORD32 unique_td_filter_element_count; + ia_unique_td_filt_element unique_td_filt_ele[FILTER_ELEMENT_COUNT_MAX]; + WORD32 unique_eq_subband_gains_count; + WORD32 eq_subband_gain_representation; + WORD32 eq_subband_gain_format; + WORD32 eq_subband_gain_count; + ia_eq_subband_gain_spline_struct + str_eq_subband_gain_spline[UNIQUE_SUBBAND_GAIN_COUNT_MAX]; + ia_eq_subband_gain_vector + str_eq_subband_gain_vector[UNIQUE_SUBBAND_GAIN_COUNT_MAX]; +} ia_eq_coeff_struct; +typedef struct { + WORD32 filter_block_count; + WORD32 filter_block_index[EQ_FILTER_BLOCK_COUNT_MAX]; +} ia_filter_block_refs_struct; +typedef struct { + WORD32 eq_cascade_gain_present[EQ_CHANNEL_GROUP_COUNT_MAX]; + FLOAT32 eq_cascade_gain[EQ_CHANNEL_GROUP_COUNT_MAX]; + ia_filter_block_refs_struct str_filter_block_refs[EQ_CHANNEL_GROUP_COUNT_MAX]; + WORD32 eq_phase_alignment_present; + WORD32 eq_phase_alignment[EQ_CHANNEL_GROUP_COUNT_MAX] + [EQ_CHANNEL_GROUP_COUNT_MAX]; +} ia_td_filter_cascade_struct; + +typedef struct { + WORD32 eq_set_id; + WORD32 eq_set_complexity_level; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 eq_apply_to_downmix; + WORD32 drc_set_id_count; + WORD32 drc_set_id[DRC_SET_ID_COUNT_MAX]; + WORD32 eq_set_purpose; + WORD32 depends_on_eq_set_present; + WORD32 depends_on_eq_set; + WORD32 no_independent_eq_use; + WORD32 eq_channel_count; + WORD32 eq_ch_group_count; + WORD32 eq_ch_group_of_channel[MAX_CHANNEL_COUNT]; + WORD32 td_filter_cascade_present; + ia_td_filter_cascade_struct str_td_filter_cascade; + WORD32 subband_gains_present; + WORD32 subband_gains_index[EQ_CHANNEL_GROUP_COUNT_MAX]; + WORD32 eq_transition_duration_present; + WORD32 eq_transition_duration; +} ia_eq_instructions_struct; + +typedef struct { + WORD32 drc_config_ext_type[EXT_COUNT_MAX]; + WORD32 ext_bit_size[EXT_COUNT_MAX - 1]; + +#ifdef AMMENDMENT1 + WORD32 parametric_drc_present; + ia_drc_coeff_parametric_drc_struct str_drc_coeff_param_drc; + WORD32 parametric_drc_instructions_count; + ia_parametric_drc_instructions_struct + str_parametric_drc_instructions[PARAM_DRC_INSTRUCTIONS_COUNT_MAX]; +#endif +#ifdef AMMENDMENT1 + WORD32 drc_extension_v1_present; + WORD32 loud_eq_instructions_flag; + WORD32 loud_eq_instructions_count; + ia_loud_eq_instructions_struct + loud_eq_instructions[LOUD_EQ_INSTRUCTIONS_COUNT_MAX]; + WORD32 eq_flag; + ia_eq_coeff_struct str_eq_coeff; + WORD32 eq_instructions_count; + ia_eq_instructions_struct str_eq_instructions[EQ_INSTRUCTIONS_COUNT_MAX]; +#endif +} ia_drc_config_ext; + +typedef struct { + WORD32 drc_location; + WORD32 drc_characteristic; +} ia_drc_coefficients_basic_struct; + +typedef struct { + WORD32 drc_set_id; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 drc_set_effect; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + WORD32 drc_set_target_loudness_present; + WORD32 drc_set_target_loudness_value_upper; + WORD32 drc_set_target_loudness_value_lower_present; + WORD32 drc_set_target_loudness_value_lower; +} ia_drc_instructions_basic_struct; + +typedef struct { + WORD32 gain_seq_idx; + WORD32 drc_characteristic; +#ifdef AMMENDMENT1 + WORD32 drc_characteristic_present; + WORD32 drc_characteristic_format_is_cicp; + WORD32 drc_characteristic_left_index; + WORD32 drc_characteristic_right_index; +#endif + WORD32 crossover_freq_idx; + WORD32 start_subband_index; +} ia_gain_params_struct; +typedef struct { + WORD32 size; + WORD32 code; + WORD32 value; +} ia_delta_time_code_table_entry_struct; +typedef struct { + ia_delta_time_code_table_entry_struct + delta_time_code_table[N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX]; +} ia_tables_struct; + +typedef struct { + WORD32 gain_coding_profile; + WORD32 gain_interpolation_type; + WORD32 full_frame; + WORD32 time_alignment; + WORD32 time_delt_min_flag; + WORD32 time_delt_min_val; + WORD32 band_count; + WORD32 drc_band_type; + ia_gain_params_struct gain_params[BAND_COUNT_MAX]; + + WORD32 num_gain_max_values; + ia_tables_struct str_tables; +} ia_gain_set_params_struct; + +typedef struct { + WORD32 characteristic_format; + FLOAT32 in_out_ratio; + FLOAT32 gain; + FLOAT32 exp; + WORD32 flip_sign; + WORD32 characteristic_node_count; + FLOAT32 node_level[SPLIT_CHARACTERISTIC_NODE_COUNT_MAX + 1]; + FLOAT32 node_gain[SPLIT_CHARACTERISTIC_NODE_COUNT_MAX + 1]; +} ia_split_drc_characteristic_struct; + +typedef struct { + WORD32 corner_freq_index; + WORD32 filter_strength_index; +} ia_shape_filter_params_struct; + +typedef struct { + WORD32 lf_cut_filter_present; + ia_shape_filter_params_struct str_lf_cut_params; + WORD32 lf_boost_filter_present; + ia_shape_filter_params_struct str_lf_boost_params; + WORD32 hf_cut_filter_present; + ia_shape_filter_params_struct str_hf_cut_params; + WORD32 hf_boost_filter_present; + ia_shape_filter_params_struct str_hf_boost_params; +} ia_shape_filter_block_params_struct; + +typedef struct { + WORD32 version; + WORD32 drc_location; + WORD32 drc_frame_size_present; + WORD32 drc_frame_size; + WORD32 gain_set_count; + ia_gain_set_params_struct gain_set_params[GAIN_SET_COUNT_MAX]; +#ifdef AMMENDMENT1 + WORD32 drc_characteristic_left_present; + WORD32 characteristic_left_count; + ia_split_drc_characteristic_struct + str_split_characteristic_left[SPLIT_CHARACTERISTIC_COUNT_MAX]; + WORD32 drc_characteristic_right_present; + WORD32 characteristic_right_count; + ia_split_drc_characteristic_struct + str_split_characteristic_right[SPLIT_CHARACTERISTIC_COUNT_MAX]; + WORD32 shape_filters_present; + WORD32 shape_num_filter; + ia_shape_filter_block_params_struct + str_shape_filter_block_params[SHAPE_FILTER_COUNT_MAX + 1]; + WORD32 gain_sequence_count; + WORD32 gain_set_params_index_for_gain_sequence[SEQUENCE_COUNT_MAX]; +#endif +#ifdef AMMENDMENT1 + WORD32 gain_set_count_plus; + +#endif +} ia_uni_drc_coeffs_struct; + +typedef struct { +#ifdef AMMENDMENT1 + WORD32 target_characteristic_left_present[DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_left_index[DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_right_present[DRC_BAND_COUNT_MAX]; + WORD32 target_characteristic_right_index[DRC_BAND_COUNT_MAX]; + WORD32 shape_filter_flag; + WORD32 shape_filter_idx; +#endif + WORD32 gain_scaling_flag[BAND_COUNT_MAX]; + FLOAT32 attn_scaling[BAND_COUNT_MAX]; + FLOAT32 ampl_scaling[BAND_COUNT_MAX]; + WORD32 gain_offset_flag[BAND_COUNT_MAX]; + FLOAT32 gain_offset[BAND_COUNT_MAX]; +} ia_gain_modifiers_struct; + +typedef struct { + WORD32 ducking_scaling_flag; + FLOAT32 ducking_scaling; + FLOAT32 ducking_scaling_quantized; +} ia_ducking_modifiers_struct; + +typedef struct { + WORD32 drc_set_id; +#ifdef AMMENDMENT1 + WORD32 drc_set_complexity_level; + WORD32 requires_eq; +#endif + WORD32 drc_apply_to_dwnmix; + WORD32 drc_location; + WORD32 dwnmix_id_count; + WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX]; + WORD32 depends_on_drc_set_present; + WORD32 depends_on_drc_set; + WORD32 no_independent_use; + WORD32 drc_set_effect; + WORD32 gain_set_index[MAX_CHANNEL_COUNT]; + ia_gain_modifiers_struct + str_gain_modifiers_of_ch_group[CHANNEL_GROUP_COUNT_MAX]; + ia_ducking_modifiers_struct + str_ducking_modifiers_for_channel[MAX_CHANNEL_COUNT]; + WORD32 limiter_peak_target_present; + FLOAT32 limiter_peak_target; + WORD32 drc_set_target_loudness_present; + WORD32 drc_set_target_loudness_value_upper; + WORD32 drc_set_target_loudness_value_lower_present; + WORD32 drc_set_target_loudness_value_lower; + + WORD32 audio_num_chan; + WORD32 num_drc_ch_groups; + WORD32 gain_set_index_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 band_count_of_ch_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_interpolation_type_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 time_delta_min_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 time_alignment_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + ia_ducking_modifiers_struct + str_ducking_modifiers_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 channel_group_of_ch[MAX_CHANNEL_COUNT]; + WORD32 num_chan_per_ch_group[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_element_count; + WORD32 multiband_audio_sig_count; +#ifdef AMMENDMENT1 + WORD32 ch_group_parametric_drc_flag[CHANNEL_GROUP_COUNT_MAX]; + WORD32 gain_set_idx_of_ch_group_parametric_drc[CHANNEL_GROUP_COUNT_MAX]; + WORD32 parametric_drc_look_ahead_samples[CHANNEL_GROUP_COUNT_MAX]; + WORD32 parametric_drc_look_ahead_samples_max; +#endif +} ia_drc_instructions_struct; + +typedef struct { + WORD32 base_channel_count; + WORD32 layout_signaling_present; + WORD32 defined_layout; + WORD32 speaker_position[SPEAKER_POS_COUNT_MAX]; +} ia_channel_layout_struct; +typedef struct { + WORD32 downmix_id; + WORD32 target_channel_count; + WORD32 target_layout; + WORD32 downmix_coefficients_present; + FLOAT32 downmix_coefficient[DOWNMIX_COEFF_COUNT_MAX]; +} ia_downmix_instructions_struct; +typedef struct ia_drc_config { + WORD32 sample_rate_present; + WORD32 sampling_rate; + WORD32 dwnmix_instructions_count; + WORD32 drc_coefficients_drc_count; + WORD32 drc_instructions_uni_drc_count; + WORD32 drc_instructions_count_plus; + WORD32 drc_description_basic_present; + WORD32 drc_coefficients_basic_count; + WORD32 drc_instructions_basic_count; + WORD32 drc_config_ext_present; + WORD32 apply_drc; + ia_drc_config_ext str_drc_config_ext; + ia_drc_coefficients_basic_struct + str_drc_coefficients_basic[DRC_COEFF_COUNT_MAX]; + ia_drc_instructions_basic_struct + str_drc_instructions_basic[DRC_INSTRUCTIONS_COUNT_MAX]; + ia_uni_drc_coeffs_struct + str_p_loc_drc_coefficients_uni_drc[DRC_COEFF_COUNT_MAX]; + ia_drc_instructions_struct + str_drc_instruction_str[DRC_INSTRUCTIONS_COUNT_MAX]; + ia_channel_layout_struct channel_layout; + ia_downmix_instructions_struct + dwnmix_instructions[DOWNMIX_INSTRUCTION_COUNT_MAX]; +} ia_drc_config; +#endif + +VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf); + +UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_frame_len_idx); + +UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_frame_len_idx, + WORD32 *output_frame_length, WORD32 *block_size, + WORD32 *output_samples); + +WORD32 ixheaacd_config(ia_bit_buf_struct *bit_buff, + ia_usac_config_struct *pstr_usac_conf); + +#endif /* IXHEAACD_CONFIG_H */ diff --git a/decoder/ixheaacd_constants.h b/decoder/ixheaacd_constants.h new file mode 100644 index 0000000..9c8d6d8 --- /dev/null +++ b/decoder/ixheaacd_constants.h @@ -0,0 +1,75 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CONSTANTS_H +#define IXHEAACD_CONSTANTS_H + +/*****************************************************************************/ +/* constant macros */ +/*****************************************************************************/ +#define Q0 1 +#define Q1 2 +#define Q2 4 +#define Q3 8 +#define Q4 16 +#define Q5 32 +#define Q6 64 +#define Q7 128 +#define Q8 256 +#define Q9 512 +#define Q10 1024 +#define Q11 2048 +#define Q14 16384 +#define Q15 32768 +#define Q16 65536 +#define Q18 262144 +#define Q19 524288 +#define Q20 1048576 +#define Q24 16777216 +#define Q25 33554432 +#define Q26 67108864 +#define Q28 268435456 +#define Q29 536870912 +#define Q30 1073741824 +#define Q31 2147483647 +#define Q32 4294967296 +#define Q35 34359738368 +#define Q38 274877906944 +#define Q39 549755813887 +#define Q40 Q39 + +#define MAX_64 (WORD64)0x7fffffffffffffff +#define MIN_64 (WORD64)0x8000000000000000 + +#define MAX_32 (WORD32)0x7fffffffL +#define MIN_32 (WORD32)0x80000000L + +#define MAX_16 (WORD16)0x7fff +#define MIN_16 (WORD16)0x8000 + +#define NULLPTR ((VOID *)0) + +#define IT_NULL ((VOID *)0) +/*****************************************************************************/ +/* function macros */ +/*****************************************************************************/ +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) + +#endif /* IXHEAACD_CONSTANTS_H */ diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c new file mode 100644 index 0000000..c8a75b8 --- /dev/null +++ b/decoder/ixheaacd_create.c @@ -0,0 +1,697 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include + +#include + +#include "ixheaacd_cnst.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_struct.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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 +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_common_rom.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_audioobjtypes.h" +#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_create.h" + +#include "ixheaacd_process.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_bit_extract.h" +#include "ixheaacd_func_def.h" +#include "ixheaacd_interface.h" + +extern ia_huff_code_word_struct ixheaacd_huff_book_scl[]; + +extern WORD32 ixheaacd_book_scl_index[]; +extern WORD16 ixheaacd_book_scl_code_book[]; + +extern 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, + WORD32 block_size_samples, + ia_sfb_info_struct *pstr_sfb_info_long, + ia_sfb_info_struct *pstr_sfb_info_short, + WORD16 *sfb_width_short, + WORD16 *sfb_width_long) { + WORD32 i, j, k, n, ws; + const WORD16 *sfbands; + ia_sfb_info_struct *pstr_sfb_info_ip; + + pstr_sfb_info_long->islong = 1; + pstr_sfb_info_long->max_win_len = 1; + pstr_sfb_info_long->samp_per_bk = block_size_samples; + + switch (block_size_samples) { + case 480: + pstr_sfb_info_long->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_480; + pstr_sfb_info_long->sfb_per_sbk = ptr_samp_info->num_sfb_480; + break; + case 512: + pstr_sfb_info_long->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_512; + pstr_sfb_info_long->sfb_per_sbk = ptr_samp_info->num_sfb_512; + break; + case 768: + pstr_sfb_info_long->sfb_per_sbk = ptr_samp_info->num_sfb_768; + pstr_sfb_info_long->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_768; + break; + case 960: + pstr_sfb_info_long->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_960; + pstr_sfb_info_long->sfb_per_sbk = ptr_samp_info->num_sfb_960; + break; + case 1024: + pstr_sfb_info_long->sfb_per_sbk = ptr_samp_info->num_sfb_1024; + pstr_sfb_info_long->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_1024; + break; + default: + assert(0); + break; + } + + pstr_sfb_info_long->sfb_width = sfb_width_long; + pstr_sfb_info_long->num_groups = 1; + pstr_sfb_info_long->group_len[0] = 1; + + for (i = 0, j = 0, n = pstr_sfb_info_long->sfb_per_sbk; i < n; i++) { + k = pstr_sfb_info_long->ptr_sfb_tbl[i]; + pstr_sfb_info_long->sfb_width[i] = k - j; + j = k; + } + + pstr_sfb_info_short->islong = 0; + pstr_sfb_info_short->max_win_len = NSHORT; + pstr_sfb_info_short->samp_per_bk = block_size_samples; + + for (i = 0; i < pstr_sfb_info_short->max_win_len; i++) { + switch (block_size_samples) { + case 768: + pstr_sfb_info_short->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_96; + pstr_sfb_info_short->sfb_per_sbk = ptr_samp_info->num_sfb_96; + break; + case 960: + pstr_sfb_info_short->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_120; + pstr_sfb_info_short->sfb_per_sbk = ptr_samp_info->num_sfb_120; + break; + case 1024: + pstr_sfb_info_short->ptr_sfb_tbl = ptr_samp_info->ptr_sfb_128; + pstr_sfb_info_short->sfb_per_sbk = ptr_samp_info->num_sfb_128; + break; + default: + assert(0); + break; + } + } + + pstr_sfb_info_short->sfb_width = sfb_width_short; + for (i = 0, j = 0, n = pstr_sfb_info_short->sfb_per_sbk; i < n; i++) { + k = pstr_sfb_info_short->ptr_sfb_tbl[i]; + pstr_sfb_info_short->sfb_width[i] = k - j; + j = k; + } + + pstr_sfb_info_ip = pstr_sfb_info_long; + for (ws = 0; ws < 2; ws++) { + pstr_sfb_info_ip->sfb_per_bk = 0; + k = 0; + n = 0; + for (i = 0; i < pstr_sfb_info_ip->max_win_len; i++) { + pstr_sfb_info_ip->bins_per_sbk = + pstr_sfb_info_ip->samp_per_bk / pstr_sfb_info_ip->max_win_len; + + pstr_sfb_info_ip->sfb_per_bk += pstr_sfb_info_ip->sfb_per_sbk; + + sfbands = pstr_sfb_info_ip->ptr_sfb_tbl; + for (j = 0; j < pstr_sfb_info_ip->sfb_per_sbk; j++) + pstr_sfb_info_ip->sfb_idx_tbl[j + k] = sfbands[j] + n; + + n += pstr_sfb_info_ip->bins_per_sbk; + k += pstr_sfb_info_ip->sfb_per_sbk; + } + pstr_sfb_info_ip = pstr_sfb_info_short; + } +} + +WORD32 ixheaacd_decode_init( + VOID *handle, WORD32 sample_rate, ia_usac_data_struct *usac_data, + ia_audio_specific_config_struct *pstr_stream_config) { + WORD32 i; + ia_exhaacplus_dec_api_struct *codec_handle = + (ia_exhaacplus_dec_api_struct *)handle; + ia_aac_dec_state_struct *aac_dec_handle = codec_handle->p_state_aac; + WORD32 fscale; + + WORD32 ele_id = 0; + + ia_usac_config_struct *ptr_usac_config = + &(pstr_stream_config->str_usac_config); + ia_usac_decoder_config_struct *ptr_usac_dec_config = + &(pstr_stream_config->str_usac_config.str_usac_dec_config); + WORD32 num_elements = ptr_usac_dec_config->num_elements; + WORD32 chan = 0; + + usac_data->huffman_code_book_scl = aac_dec_handle->huffman_code_book_scl; + usac_data->huffman_code_book_scl_index = + aac_dec_handle->huffman_code_book_scl_index; + + usac_data->tns_coeff3_32 = + aac_dec_handle->pstr_aac_tables->pstr_block_tables->tns_coeff3_32; + usac_data->tns_coeff4_32 = + aac_dec_handle->pstr_aac_tables->pstr_block_tables->tns_coeff4_32; + usac_data->tns_max_bands_tbl_usac = + &aac_dec_handle->pstr_aac_tables->pstr_block_tables + ->tns_max_bands_tbl_usac; + + for (i = 0; i < (1 << LEN_SAMP_IDX); i++) { + if (ixheaacd_sampling_boundaries[i] <= sample_rate) break; + } + + if (i == (1 << LEN_SAMP_IDX)) return -1; + usac_data->sampling_rate_idx = i; + + fscale = (WORD32)((double)sample_rate * (double)FSCALE_DENOM / 12800.0f); + + for (i = 0; i < MAX_NUM_CHANNELS; i++) { + usac_data->window_shape_prev[i] = 0; + usac_data->window_shape[i] = 0; + } + + ixheaacd_hufftab(&ixheaacd_book, ixheaacd_huff_book_scl, + ixheaacd_book_scl_code_book, ixheaacd_book_scl_index, 1, 60, + 60, 1, 19); + + usac_data->pstr_usac_winmap[0] = &usac_data->str_only_long_info; + usac_data->pstr_usac_winmap[1] = &usac_data->str_only_long_info; + usac_data->pstr_usac_winmap[2] = &usac_data->str_eight_short_info; + usac_data->pstr_usac_winmap[3] = &usac_data->str_only_long_info; + usac_data->pstr_usac_winmap[4] = &usac_data->str_only_long_info; + ixheaacd_info_init(&ixheaacd_samp_rate_info[usac_data->sampling_rate_idx], + usac_data->ccfl, usac_data->pstr_usac_winmap[0], + usac_data->pstr_usac_winmap[2], usac_data->sfb_width_short, + usac_data->sfb_width_long); + + 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; + usac_data->len_subfrm = usac_data->ccfl / 4; + usac_data->num_subfrm = (MAX_NUM_SUBFR * usac_data->ccfl) / LEN_SUPERFRAME; + + ixheaacd_init_acelp_data(usac_data, usac_data->str_tddec[i]); + + usac_data->str_tddec[i]->fd_synth = + &usac_data->str_tddec[i]->fd_synth_buf[LEN_FRAME]; + } + + for (ele_id = 0; ele_id < num_elements; ele_id++) { + UWORD32 ele_type; + WORD32 stereo_config_index; + + ia_usac_dec_element_config_struct *ptr_usac_ele_config = + &ptr_usac_config->str_usac_dec_config.str_usac_element_config[ele_id]; + + if (ptr_usac_ele_config) { + if (usac_data->tw_mdct[ele_id]) { + return -1; + } + + usac_data->noise_filling_config[ele_id] = + ptr_usac_ele_config->noise_filling; + } + + ele_type = ptr_usac_config->str_usac_dec_config.usac_element_type[ele_id]; + + stereo_config_index = ptr_usac_ele_config->stereo_config_index; + + switch (ele_type) { + case ID_USAC_SCE: + case ID_USAC_LFE: + + usac_data->seed_value[chan] = 0x3039; + + break; + + case ID_USAC_CPE: { + WORD32 frame_len_tbl[] = {-1, -1, 32, 32, 64}; + + usac_data->seed_value[chan] = 0x3039; + chan++; + + usac_data->seed_value[chan] = 0x10932; + + if (stereo_config_index > 0) { + WORD32 bs_frame_length = + frame_len_tbl[ptr_usac_config->core_sbr_framelength_index] - 1; + WORD32 bs_residual_coding = (stereo_config_index > 1) ? 1 : 0; + + ia_usac_dec_mps_config_struct *ptr_usac_mps212_config = + &(ptr_usac_config->str_usac_dec_config + .str_usac_element_config[ele_id] + .str_usac_mps212_config); + + if (aac_dec_handle->mps_dec_handle[ele_id]) { + aac_dec_handle->mps_dec_handle[ele_id] = NULL; + } + + aac_dec_handle->mps_dec_handle[ele_id] = ixheaacd_mps_create( + bs_frame_length, bs_residual_coding, ptr_usac_mps212_config); + + if (aac_dec_handle->mps_dec_handle[ele_id] == 0) return -1; + } + break; + } + + break; + case ID_USAC_EXT: + break; + default: + return -1; + break; + } + } + + return 0; +} + +WORD32 ixheaacd_dec_data_init(VOID *handle, + ia_frame_data_struct *pstr_frame_data, + ia_usac_data_struct *usac_data) { + ia_audio_specific_config_struct *pstr_stream_config, *layer_config; + WORD32 err_code = 0; + + WORD32 num_out_chan = 0; + + WORD32 i_ch, i, ele_id; + WORD32 num_elements; + + WORD32 out_frame_len, sbr_ratio_idx; + + ia_usac_config_struct *ptr_usac_config = + &(pstr_frame_data->str_audio_specific_config.str_usac_config); + + usac_data->window_shape_prev[0] = WIN_SEL_0; + usac_data->window_shape_prev[1] = WIN_SEL_0; + + pstr_frame_data->str_layer.bit_rate = + pstr_frame_data->str_audio_specific_config.avg_bit_rate; + pstr_stream_config = &pstr_frame_data->str_audio_specific_config; + layer_config = &pstr_frame_data->str_audio_specific_config; + + sbr_ratio_idx = ixheaacd_sbr_params( + ptr_usac_config->core_sbr_framelength_index, &out_frame_len, + &usac_data->ccfl, &usac_data->output_samples); + + num_elements = ptr_usac_config->str_usac_dec_config.num_elements; + + for (ele_id = 0; ele_id < num_elements; ele_id++) { + ia_usac_dec_element_config_struct *ptr_usac_ele_config = + &(ptr_usac_config->str_usac_dec_config.str_usac_element_config[ele_id]); + + if (ptr_usac_ele_config) { + usac_data->tw_mdct[ele_id] = ptr_usac_ele_config->tw_mdct; + } + + { + ia_usac_dec_mps_config_struct *ptr_usac_mps212_config = + &ptr_usac_ele_config->str_usac_mps212_config; + WORD32 stereo_config_index = ptr_usac_ele_config->stereo_config_index; + + usac_data->mps_pseudo_lr[ele_id] = + (stereo_config_index > 1) ? ptr_usac_mps212_config->bs_pseudo_lr : 0; + } + } + + usac_data->sbr_ratio_idx = sbr_ratio_idx; + usac_data->esbr_bit_str[0].no_elements = 0; + usac_data->esbr_bit_str[1].no_elements = 0; + + num_out_chan = ptr_usac_config->num_out_channels; + + if (layer_config->samp_frequency_index != 0xf) + pstr_frame_data->str_layer.sample_rate_layer = + ixheaacd_sampl_freq_idx_table[layer_config->samp_frequency_index]; + else + pstr_frame_data->str_layer.sample_rate_layer = + layer_config->sampling_frequency; + + if (out_frame_len == 768) + pstr_frame_data->str_layer.sample_rate_layer = + 4 * pstr_frame_data->str_layer.sample_rate_layer / 3; + + for (i = 0; i < MAX_NUM_CHANNELS; i++) { + usac_data->coef_fix[i] = &usac_data->arr_coef_fix[i][0]; + usac_data->coef[i] = &usac_data->arr_coef[i][0]; + usac_data->coef_save[i] = &usac_data->arr_coef_save[i][0]; + usac_data->factors[i] = &usac_data->arr_factors[i][0]; + usac_data->group_dis[i] = &usac_data->arr_group_dis[i][0]; + usac_data->pstr_tns[i] = &usac_data->arr_str_tns[i]; + usac_data->tw_ratio[i] = &usac_data->arr_tw_ratio[i][0]; + usac_data->ms_used[i] = &usac_data->arr_ms_used[i][0]; + usac_data->window_shape_prev[i] = WIN_SEL_0; + + usac_data->seed_value[i] = 0x0; + + usac_data->fac_data_present[i] = 0; + } + + err_code = + ixheaacd_decode_init(handle, pstr_frame_data->str_layer.sample_rate_layer, + usac_data, pstr_stream_config); + if (err_code == -1) return -1; + + for (i_ch = 0; i_ch < MAX_NUM_CHANNELS; i_ch++) { + if (usac_data->tw_mdct[0] == 1) { + WORD32 i; + for (i = 0; i < 2 * usac_data->ccfl; i++) { + usac_data->warp_cont_mem[i_ch][i] = 1.0; + } + usac_data->warp_sum[i_ch][0] = usac_data->warp_sum[i_ch][1] = + (FLOAT32)usac_data->ccfl; + } + } + return err_code; +} + +static VOID ixheaacd_count_tracks_per_layer(int *max_layer, int *stream_count, + int *tracks_in_layer) { + WORD32 stream; + WORD32 num_layer; + WORD32 num_streams; + WORD32 layer = 0; + + if (stream_count == NULL) + num_streams = 0; + else + num_streams = *stream_count; + if (max_layer == NULL) + num_layer = num_streams; + else + num_layer = *max_layer; + if (num_layer < 0) num_layer = num_streams; + + for (stream = 0; (layer <= num_layer) && (stream < num_streams);) { + *tracks_in_layer = 1; + stream += 1; + layer++; + if (layer <= num_layer) *tracks_in_layer = 0; + } + + if (max_layer) *max_layer = (layer - 1); + if (stream_count) *stream_count = stream; +} + +WORD32 ixheaacd_frm_data_init(ia_audio_specific_config_struct *pstr_audio_conf, + ia_dec_data_struct *pstr_dec_data) + +{ + WORD32 layer; + WORD32 track; + WORD32 num_dec_streams; + ia_frame_data_struct *pstr_frame_data; + + WORD32 stream_count = 1; + WORD32 max_layer = -1; + + memset(pstr_dec_data, 0, sizeof(ia_dec_data_struct)); + pstr_dec_data->pstr_frame_data = &pstr_dec_data->str_frame_data; + memset(pstr_dec_data->pstr_frame_data, 1, + sizeof(pstr_dec_data->str_frame_data)); + + pstr_frame_data = pstr_dec_data->pstr_frame_data; + + if (max_layer < 0) max_layer = stream_count - 1; + + ixheaacd_count_tracks_per_layer(&max_layer, &stream_count, + &pstr_frame_data->tracks_in_layer); + + pstr_frame_data->scal_out_select = max_layer; + + pstr_frame_data->stream_count = 0; + + num_dec_streams = track = 0; + for (layer = 0; layer < (signed)pstr_frame_data->scal_out_select + 1; + layer++) { + WORD32 j; + for (j = 0; j < 1; j++, num_dec_streams++) { + pstr_frame_data->str_audio_specific_config = *pstr_audio_conf; + pstr_frame_data->str_layer.sample_rate_layer = + pstr_frame_data->str_audio_specific_config.sampling_frequency; + pstr_frame_data->str_layer.bit_rate = + pstr_frame_data->str_audio_specific_config.avg_bit_rate; + } + + track += pstr_frame_data->tracks_in_layer; + } + + pstr_frame_data->stream_count = num_dec_streams; + + return num_dec_streams; +} + +WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, + ia_dec_data_struct *pstr_dec_data, + WORD32 tracks_for_decoder) { + WORD32 stream; + + WORD32 num_delay_samp = 0; + WORD32 err = 0; + ia_frame_data_struct *pstr_frame_data; + WORD32 stream_count; + ia_aac_dec_state_struct *aac_dec_handle = handle->p_state_aac; + pstr_frame_data = pstr_dec_data->pstr_frame_data; + stream_count = pstr_frame_data->stream_count; + pstr_frame_data->stream_count = tracks_for_decoder; + + for (stream = 0; stream < stream_count; stream++) { + UWORD32 aot = pstr_frame_data->str_audio_specific_config.audio_object_type; + + switch (aot) { + case AOT_USAC: + if (pstr_dec_data->pstr_usac_data == NULL) { + pstr_dec_data->pstr_usac_data = &pstr_dec_data->str_usac_data; + err = ixheaacd_dec_data_init(handle, pstr_frame_data, + pstr_dec_data->pstr_usac_data); + + switch (pstr_dec_data->pstr_usac_data->sbr_ratio_idx) { + case 0: + handle->aac_config.ui_sbr_mode = 0; + break; + case 1: + handle->aac_config.ui_sbr_mode = 1; + break; + case 2: + handle->aac_config.ui_sbr_mode = 1; + break; + case 3: + handle->aac_config.ui_sbr_mode = 3; + break; + + default: + handle->aac_config.ui_sbr_mode = 0; + } + + if (err == -1) return -1; + } + break; + + default: + + break; + } + } + + pstr_frame_data->scal_out_object_type = + pstr_frame_data->str_audio_specific_config.audio_object_type; + pstr_frame_data->scal_out_num_channels = + pstr_frame_data->str_audio_specific_config.channel_configuration; + pstr_frame_data->scal_out_sampling_frequency = + pstr_frame_data->str_audio_specific_config.sampling_frequency; + + if (pstr_dec_data->pstr_usac_data != NULL) { + ia_audio_specific_config_struct *pstr_aud_spec_config = + &pstr_frame_data->str_audio_specific_config; + ia_usac_config_struct *ptr_usac_config = + &(pstr_frame_data->str_audio_specific_config.str_usac_config); + + WORD32 inter_tes[MAX_NUM_ELEMENTS] = {0}; + WORD32 bs_pvc[MAX_NUM_ELEMENTS] = {0}; + WORD32 harmonic_sbr[MAX_NUM_ELEMENTS] = {0}; + + ia_usac_decoder_config_struct *ptr_usac_dec_config = + &ptr_usac_config->str_usac_dec_config; + WORD32 const num_ele = ptr_usac_dec_config->num_elements; + WORD32 elem_idx = 0; + + for (elem_idx = 0; elem_idx < num_ele; elem_idx++) { + ia_usac_dec_sbr_config_struct *ptr_usac_sbr_config = + &(ptr_usac_dec_config->str_usac_element_config[elem_idx] + .str_usac_sbr_config); + inter_tes[elem_idx] = + (ptr_usac_sbr_config != NULL) ? ptr_usac_sbr_config->bs_inter_tes : 0; + bs_pvc[elem_idx] = + (ptr_usac_sbr_config != NULL) ? ptr_usac_sbr_config->bs_pvc : 0; + harmonic_sbr[elem_idx] = + (ptr_usac_sbr_config != NULL) ? ptr_usac_sbr_config->harmonic_sbr : 0; + } + + pstr_dec_data->pstr_usac_data->down_samp_sbr = 0; + + if (pstr_dec_data->pstr_usac_data->sbr_ratio_idx > 0) { + if (pstr_aud_spec_config->ext_sampling_frequency == + pstr_aud_spec_config->sampling_frequency) { + pstr_dec_data->pstr_usac_data->down_samp_sbr = 1; + } + if (pstr_dec_data->pstr_usac_data->down_samp_sbr == 0) { + if (pstr_dec_data->pstr_usac_data->sbr_ratio_idx == 3) { + pstr_frame_data->scal_out_sampling_frequency = + 4 * pstr_frame_data->scal_out_sampling_frequency; + } else { + pstr_frame_data->scal_out_sampling_frequency = + 2 * pstr_frame_data->scal_out_sampling_frequency; + } + } + + { + UWORD32 usac_ele_type = + ptr_usac_config->str_usac_dec_config.usac_element_type[0]; + ia_usac_dec_element_config_struct *ptr_usac_ele_config = + &ptr_usac_config->str_usac_dec_config.str_usac_element_config[0]; + ia_sbr_header_data_struct usac_def_header; + void *sbr_persistent_mem_v = aac_dec_handle->sbr_persistent_mem_u; + + if ((usac_ele_type != ID_USAC_LFE) && (usac_ele_type != ID_USAC_EXT)) { + ia_usac_dec_sbr_config_struct *ptr_usac_sbr_config = + &(ptr_usac_ele_config->str_usac_sbr_config); + + memset(&usac_def_header, 0, sizeof(ia_sbr_header_data_struct)); + + usac_def_header.start_freq = ptr_usac_sbr_config->dflt_start_freq; + usac_def_header.stop_freq = ptr_usac_sbr_config->dflt_stop_freq; + usac_def_header.header_extra_1 = + ptr_usac_sbr_config->dflt_header_extra1; + usac_def_header.header_extra_2 = + ptr_usac_sbr_config->dflt_header_extra2; + usac_def_header.freq_scale = ptr_usac_sbr_config->dflt_freq_scale; + usac_def_header.alter_scale = ptr_usac_sbr_config->dflt_alter_scale; + usac_def_header.noise_bands = ptr_usac_sbr_config->dflt_noise_bands; + usac_def_header.limiter_bands = + ptr_usac_sbr_config->dflt_limiter_bands; + usac_def_header.limiter_gains = + ptr_usac_sbr_config->dflt_limiter_gains; + usac_def_header.interpol_freq = + ptr_usac_sbr_config->dflt_interpol_freq; + usac_def_header.smoothing_mode = + ptr_usac_sbr_config->dflt_smoothing_mode; + } + pstr_dec_data->pstr_usac_data->pstr_esbr_dec = ixheaacd_init_sbr( + pstr_frame_data->str_layer.sample_rate_layer, + pstr_dec_data->pstr_usac_data->ccfl, + &pstr_dec_data->pstr_usac_data->down_samp_sbr, sbr_persistent_mem_v, + NULL, pstr_frame_data->scal_out_num_channels, 0, + pstr_dec_data->pstr_usac_data->sbr_ratio_idx, + pstr_dec_data->pstr_usac_data->output_samples, harmonic_sbr, + (void *)&usac_def_header, aac_dec_handle->str_sbr_config, + pstr_dec_data->pstr_usac_data->audio_object_type); + pstr_dec_data->pstr_usac_data->sbr_scratch_mem_base = + aac_dec_handle->sbr_scratch_mem_u; + if (num_ele) + ixheaacd_setesbr_flags(sbr_persistent_mem_v, bs_pvc[0], + harmonic_sbr[0], inter_tes[0]); + } + + if (pstr_dec_data->pstr_usac_data->pstr_esbr_dec == NULL) { + return -1; + } + } + } + + return (num_delay_samp); +} + +WORD32 ixheaacd_decode_free(VOID *codec_handle) { + UWORD32 i; + ia_exhaacplus_dec_api_struct *handle = + (ia_exhaacplus_dec_api_struct *)codec_handle; + ia_aac_dec_state_struct *p_state_aac_dec = handle->p_state_aac; + ia_dec_data_struct *pstr_dec_data = + (ia_dec_data_struct *)(p_state_aac_dec->pstr_dec_data); + if (pstr_dec_data->pstr_usac_data) { + for (i = 0; i < MAX_NUM_ELEMENTS; i++) { + if (p_state_aac_dec->mps_dec_handle[i]) { + p_state_aac_dec->mps_dec_handle[i] = NULL; + } + } + } + + return (0); +} diff --git a/decoder/ixheaacd_create.h b/decoder/ixheaacd_create.h new file mode 100644 index 0000000..9b8402a --- /dev/null +++ b/decoder/ixheaacd_create.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_CREATE_H +#define IXHEAACD_CREATE_H + +typedef struct { + ia_frame_data_struct *pstr_frame_data; + ia_usac_data_struct *pstr_usac_data; + struct ia_bit_buf_struct dec_bit_buf; + ia_frame_data_struct str_frame_data; + ia_usac_data_struct str_usac_data; +} ia_dec_data_struct; + +WORD32 ixheaacd_frm_data_init(ia_audio_specific_config_struct *pstr_audio_conf, + ia_dec_data_struct *pstr_dec_data); + +WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *dec_handle, + ia_dec_data_struct *pstr_dec_data, + WORD32 tracks_for_decoder); + +WORD32 ixheaacd_decode_free(pVOID codec_handle); +ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( + WORD32 sample_rate_dec, WORD32 samp_per_frame, FLAG *down_sample_flag, + VOID *sbr_persistent_mem_v, WORD32 *ptr_overlap_buf, WORD channel, + WORD ps_enable, WORD sbr_ratio_idx, WORD output_frame_size, WORD *use_hbe, + VOID *p_usac_dflt_header, ia_sbr_header_data_struct str_sbr_config, + WORD audio_object_type); + +VOID ixheaacd_setesbr_flags(VOID *sbr_persistent_mem_v, FLAG pvc_flag, + FLAG hbe_flag, FLAG inter_tes_flag); + +#endif diff --git a/decoder/ixheaacd_dec_main.h b/decoder/ixheaacd_dec_main.h new file mode 100644 index 0000000..d800212 --- /dev/null +++ b/decoder/ixheaacd_dec_main.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DEC_MAIN_H +#define IXHEAACD_DEC_MAIN_H + +WORD32 ixheaacd_decode_init( + VOID *dec_handle, WORD32 sampling_rate_decoded, + ia_usac_data_struct *usac_data, WORD32 profile, + ia_audio_specific_config_struct *pstr_stream_config); + +WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, + WORD32 *num_out_channels, VOID *dec_handle); + +#endif diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c new file mode 100644 index 0000000..7ae8676 --- /dev/null +++ b/decoder/ixheaacd_decode_main.c @@ -0,0 +1,211 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_common_rom.h" +#include +#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" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_audioobjtypes.h" +#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 +#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" + +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; + + WORD16 *out_buf = (WORD16 *)outbuffer; + + num = num_channel_out * 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])); + + if (write_local > 32767) { + write_local = 32767; + } + if (write_local < -32768) { + write_local = -32768; + } + out_buf[i] = (WORD16)write_local; + } + + *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)); + + if (write_local > 8388607) { + write_local = 8388607; + } + if (write_local < -8388608) { + write_local = -8388608; + } + *out_24bit++ = (WORD32)write_local & 0xff; + *out_24bit++ = ((WORD32)write_local >> 8) & 0xff; + *out_24bit++ = ((WORD32)write_local >> 16) & 0xff; + } + + *out_bytes = num * 3 * sizeof(WORD8); + } +} + +WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, + WORD32 *out_bytes, WORD32 frames_done, WORD32 pcmsize, + WORD32 *num_channel_out) { + WORD32 err = 0; + ia_exhaacplus_dec_api_struct *handle = + (ia_exhaacplus_dec_api_struct *)temp_handle; + ia_aac_dec_state_struct *aac_dec_handle = handle->p_state_aac; + + WORD32 tmp; + ia_audio_specific_config_struct *pstr_audio_specific_config = + (ia_audio_specific_config_struct *) + aac_dec_handle->ia_audio_specific_config; + WORD32 suitable_tracks = 1; + WORD32 num_samples_out; + ia_dec_data_struct *pstr_dec_data; + + if (frames_done == 0) { + if ((pstr_audio_specific_config->channel_configuration > 2) || + (pstr_audio_specific_config->channel_configuration == 0)) { + return -1; + } + + pstr_dec_data = (ia_dec_data_struct *)aac_dec_handle->pstr_dec_data; + + tmp = pstr_audio_specific_config->channel_configuration; + + suitable_tracks = + ixheaacd_frm_data_init(pstr_audio_specific_config, pstr_dec_data); + + pstr_audio_specific_config->channel_configuration = tmp; + + if (suitable_tracks <= 0) { + return -1; + } + } + + { + pstr_dec_data = (ia_dec_data_struct *)aac_dec_handle->pstr_dec_data; + + if (frames_done == 0) { + WORD32 delay; + delay = ixheaacd_decode_create( + handle, pstr_dec_data, + pstr_dec_data->pstr_frame_data->scal_out_select + 1); + if (delay == -1) return -1; + *num_channel_out = pstr_dec_data->pstr_frame_data->scal_out_num_channels; + return 0; + } + + pstr_dec_data->dec_bit_buf.ptr_bit_buf_base = (UWORD8 *)inbuffer; + pstr_dec_data->dec_bit_buf.size = aac_dec_handle->ui_in_bytes << 3; + pstr_dec_data->dec_bit_buf.ptr_bit_buf_end = + (UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes; + pstr_dec_data->dec_bit_buf.ptr_read_next = (UWORD8 *)inbuffer; + pstr_dec_data->dec_bit_buf.bit_pos = 7; + pstr_dec_data->dec_bit_buf.cnt_bits = pstr_dec_data->dec_bit_buf.size; + + pstr_dec_data->pstr_usac_data->usac_flag = aac_dec_handle->usac_flag; + + err = ixheaacd_usac_process(pstr_dec_data, num_channel_out, aac_dec_handle); + if (err == -1) return err; + + num_samples_out = pstr_dec_data->pstr_usac_data->output_samples; + + ixheaacd_samples_sat(outbuffer, num_samples_out, pcmsize, + pstr_dec_data->pstr_usac_data->time_sample_vector, + out_bytes, *num_channel_out); +#ifdef ENABLE_DRC + pstr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len = + pstr_dec_data->pstr_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->pstr_frame_data->str_audio_specific_config + .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_buf, + pstr_dec_data->pstr_frame_data->str_audio_specific_config + .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_len * + sizeof(WORD8)); +#endif + } + + return err; +} diff --git a/decoder/ixheaacd_defines.h b/decoder/ixheaacd_defines.h new file mode 100644 index 0000000..3ff42dd --- /dev/null +++ b/decoder/ixheaacd_defines.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DEFINES_H +#define IXHEAACD_DEFINES_H + +#define MAX_WINDOWS 8 +#define MAX_ORDER 31 +#define MAX_ORDER_LONG 12 +#define MAX_FILTERS 3 + +#define MAX_BINS_LONG 1024 +#define MAX_BINS_SHORT 128 +#define MAX_SCALE_FACTOR_BANDS_SHORT 16 + +#define ZERO_HCB 0 + +#define NOISE_OFFSET 90 + +#define ESC_HCB 11 +#define NOISE_HCB 13 +#define INTENSITY_HCB2 14 +#define INTENSITY_HCB 15 + +#define CHANNELS 2 + +#define SIZE01 (MAX_BINS_LONG / 16) +#define SIZE02 2 * SIZE01 +#define SIZE03 3 * SIZE01 +#define SIZE04 4 * SIZE01 +#define SIZE05 5 * SIZE01 +#define SIZE06 6 * SIZE01 +#define SIZE07 7 * SIZE01 +#define SIZE08 8 * SIZE01 +#define SIZE09 9 * SIZE01 +#define SIZE10 10 * SIZE01 +#define SIZE11 11 * SIZE01 +#define SIZE12 12 * SIZE01 +#define SIZE13 13 * SIZE01 +#define SIZE14 14 * SIZE01 +#define SIZE15 15 * SIZE01 +#define SIZE16 16 * SIZE01 + +typedef struct { WORD32 sampling_frequency; } ia_sampling_rate_info_struct; + +#endif diff --git a/decoder/ixheaacd_definitions.h b/decoder/ixheaacd_definitions.h new file mode 100644 index 0000000..8762096 --- /dev/null +++ b/decoder/ixheaacd_definitions.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DEFINITIONS_H +#define IXHEAACD_DEFINITIONS_H + +#define LIBNAME "IA_XHEAAC_DEC" +#define LIBVERSION "1.0" + +#define LIB_APIVERSION_MAJOR 1 +#define LIB_APIVERSION_MINOR 10 + +#define LIB_APIVERSION \ + IA_MAKE_VERSION_STR(LIB_APIVERSION_MAJOR, LIB_APIVERSION_MINOR) + +#define IA_ENHAACPLUS_DEC_PERSIST_IDX (0) +#define IA_ENHAACPLUS_DEC_SCRATCH_IDX (1) +#define IA_ENHAACPLUS_DEC_INPUT_IDX (2) +#define IA_ENHAACPLUS_DEC_OUTPUT_IDX (3) + +#define IA_MPS_DEC_PERSIST_IDX (0) +#define IA_MPS_DEC_SCRATCH_IDX (1) +#define IA_MPS_DEC_INPUT_IDX (2) +#define IA_MPS_DEC_MPS_INPUT_IDX (3) +#define IA_MPS_DEC_OUTPUT_IDX (4) + +#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_MPS_DEC_INP_BUF_SIZE (0) +#define IA_MPS_DEC_OUT_BUF_SIZE (0) + +#define IA_ENHAACPLUS_DEC_MAX_CHANNEL (2) +#define IA_ENHAACPLUS_DEC_FRAME_LENGTH (1024) + +#endif /* __DEFINITIONS_H__ */ diff --git a/decoder/ixheaacd_drc_data_struct.h b/decoder/ixheaacd_drc_data_struct.h new file mode 100644 index 0000000..9e1980b --- /dev/null +++ b/decoder/ixheaacd_drc_data_struct.h @@ -0,0 +1,93 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DRC_DATA_STRUCT_H + +#define IXHEAACD_DRC_DATA_STRUCT_H + +#define MAX_DRC_BANDS 16 + +#define MAX_AUDIO_CHANNELS 8 + +#define SBR_QMF_SUB_SAMPLES 64 +#define SBR_QMF_SUB_BANDS 64 + +typedef enum { + UNKNOWN_PAYLOAD = 0, + MPEG_DRC_EXT_DATA = 1, + DVB_DRC_ANC_DATA = 2 + +} AACDEC_DRC_PAYLOAD_TYPE; + +#define DVB_ANC_DATA_SYNC_BYTE (0xBC) +typedef struct { + WORD32 prog_ref_level; + WORD16 n_mdct_bands[MAX_DRC_BANDS]; + WORD16 drc_fac[MAX_DRC_BANDS]; + WORD16 drc_fac_dvb[MAX_DRC_BANDS]; + WORD8 drc_exp; + UWORD8 short_block; + UWORD8 drc_interp_scheme; + UWORD8 n_drc_bands; + UWORD8 new_prog_ref_level; + UWORD8 new_drc_fac; + UWORD8 prev_interp_scheme; + WORD32 drc_factors_sbr[SBR_QMF_SUB_SAMPLES][SBR_QMF_SUB_BANDS]; +} ixheaac_drc_data_struct; + +typedef struct { + UWORD8 b_channel_on[MAX_AUDIO_CHANNELS]; + UWORD8 prog_ref_level_present; + UWORD8 prog_ref_level; + UWORD8 drc_num_bands; + UWORD8 drc_band_top[MAX_DRC_BANDS]; + WORD8 dyn_rng_dlbl[MAX_DRC_BANDS]; + WORD8 dyn_rng_dlbl_dvb[MAX_DRC_BANDS]; + WORD8 max_dyn_rng_dlbl; + UWORD8 drc_interpolation_scheme; + WORD8 drc_data_type; +} ixheaac_drc_bs_data_struct; + +typedef struct { + ixheaac_drc_bs_data_struct str_drc_bs_data[MAX_BS_ELEMENT]; + ixheaac_drc_data_struct str_drc_channel_data[MAX_BS_ELEMENT]; + WORD16 drc_ref_level; + WORD16 drc_def_level; + UWORD8 drc_channel_next_index[MAX_BS_ELEMENT]; + UWORD8 sbr_allowed; + UWORD8 sbr_found; + UWORD8 drc_element_found; + UWORD8 max_audio_channels; + UWORD8 length_history; + UWORD8 num_drc_elements; + WORD32 is_longblock[MAX_BS_ELEMENT]; + WORD32 state; + WORD32 target_ref_level; + WORD32 prog_ref_level; + WORD32 cut_factor; + WORD32 boost_factor; + FLAG drc_dig_norm; + FLAG drc_on; + FLAG dvb_anc_data_present; + WORD32 dvb_anc_data_pos; + WORD32 pres_mode; + WORD32 heavy_mode; +} ia_drc_dec_struct; + +#endif diff --git a/decoder/ixheaacd_drc_dec.h b/decoder/ixheaacd_drc_dec.h new file mode 100644 index 0000000..9990f3a --- /dev/null +++ b/decoder/ixheaacd_drc_dec.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DRC_DEC_H + +#define IXHEAACD_DRC_DEC_H + +#define DD_BLOCKSIZE (256) + +#define ININTERBUF_SIZE 256 + +#define MAX_METADATA_SETS (32) + +VOID ixheaacd_drc_dec_create(ia_drc_dec_struct *pstr_hdrc_dec, + WORD16 drc_ref_level, WORD16 drc_def_level); + +WORD32 ixheaacd_dec_drc_read_element(ia_drc_dec_struct *pstr_drc_dec, + ia_drc_dec_struct *drc_dummy, + ia_handle_bit_buf_struct bs); + +WORD32 ixheaacd_drc_map_channels(ia_drc_dec_struct *drc_dec, WORD32 num_ch, + WORD32 frame_size); + +VOID ixheaacd_drc_apply(ia_drc_dec_struct *pstr_drc_dec, + WORD32 *ptr_spectral_coef, WORD32 win_seq, + WORD32 channel, WORD32 frame_size); +#endif diff --git a/decoder/ixheaacd_drc_freq_dec.c b/decoder/ixheaacd_drc_freq_dec.c new file mode 100644 index 0000000..7b13dac --- /dev/null +++ b/decoder/ixheaacd_drc_freq_dec.c @@ -0,0 +1,1082 @@ +/****************************************************************************** + * * + * 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 +#include "stdio.h" +#include "math.h" +#include +#include "ixheaacd_sbr_common.h" + +#include "ixheaacd_cnst.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_bitbuffer.h" +#include "ixheaacd_error_standards.h" +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_aac_rom.h" + +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_common_rom.h" + +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_stereo.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" + +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" + +#define DRC_SBR_ONE_Q25 (1 << 25) + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shift29(WORD32 a, + WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 29); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shift25(WORD32 a, + WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + temp_result = temp_result >> 25; + + if (temp_result >= MAX_32) + result = MAX_32; + else if (temp_result < MIN_32) + result = MIN_32; + else + result = (WORD32)temp_result; + + return (result); +} + +static 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, + 543611091, 543987817, 544365523, 544742772, 545120282, 545498775, + 545876810, 546255106, 546633664, 547013208, 547392292, 547771638, + 548151972, 548531845, 548911981, 549293107, 549673770, 550054698, + 550435889, 550818073, 551199794, 551581779, 551964758, 552347273, + 552730053, 553113099, 553497142, 553880719, 554264562, 554649404, + 555033779, 555418421, 555803330, 556189241, 556574683, 556960393, + 557347107, 557733352, 558119865, 558506646, 558894433, 559281751, + 559669337, 560057931, 560446055, 560834448, 561223110, 561612784, + 562001985, 562391456, 562781941, 563171952, 563562234, 563952786, + 564344355, 564735450, 565126815, 565519199, 565911108, 566303288, + 566695739, 567089213, 567482209, 567875478, 568269771, 568663586, + 569057673, 569452034, 569847421, 570242329, 570637511, 571033721, + 571429451, 571825455, 572221734, 572619044, 573015873, 573412977, + 573811114, 574208769, 574606699, 575005666, 575404148, 575802907, + 576201942, 576602016, 577001605, 577401471, 577802378, 578202799, + 578603497, 579004473, 579406493, 579808025, 580209836, 580612693, + 581015061, 581417708, 581820634, 582224610, 582628095, 583031860, + 583436676, 583841002, 584245607, 584650493, 585056433, 585461881, + 585867610, 586274395, 586680687, 587087260, 587494116, 587902030, + 588309450, 588717152, 589125916, 589534184, 589942735, 590351569, + 590761467, 591170869, 591580554, 591991306, 592401560, 592812098, + 593222920, 593634813, 594046205, 594457883, 594870633, 595282882, + 595695417, 596108238, 596522133, 596935527, 597349207, 597763964, + 598178218, 598592760, 599008380, 599423497, 599838901, 600254594, + 600671368, 601087637, 601504195, 601921837, 602338973, 602756397, + 603174111, 603592913, 604011207, 604429790, 604849464, 605268628, + 605688083, 606107829, 606528668, 606948996, 607369615, 607791330, + 608212533, 608634029, 609055816, 609478701, 609901074, 610323739, + 610747505, 611170757, 611594302, 612018141, 612443083, 612867510, + 613292231, 613718058, 614143369, 614568974, 614994874, 615421883, + 615848375, 616275162, 616703060, 617130439, 617558114, 617986086, + 618415172, 618843738, 619272600, 619702579, 620132037, 620561793, + 620991846, 621423019, 621853669, 622284618, 622716688, 623148235, + 623580081, 624012226, 624445496, 624878241, 625311285, 625745457, + 626179103, 626613049, 627048125, 627482673, 627917523, 628352674, + 628788957, 629224712, 629660769, 630097961, 630534623, 630971588, + 631408855, 631847261, 632285135, 632723313, 633162631, 633601417, + 634040507, 634479901, 634920439, 635360443, 635800752, 636242207, + 636683127, 637124352, 637565884, 638008564, 638450708, 638893159, + 639336761, 639779826, 640223197, 640666876, 641111710, 641556004, + 642000607, 642446367, 642891586, 643337114, 643782951, 644229948, + 644676404, 645123169, 645571097, 646018482, 646466177, 646914182, + 647363354, 647811981, 648260918, 648711025, 649160586, 649610458, + 650060643, 650511999, 650962808, 651413929, 651866225, 652317973, + 652770033, 653223271, 653675959, 654128960, 654582276, 655036772, + 655490716, 655944976, 656400417, 656855307, 657310512, 657766033, + 658222739, 658678891, 659135360, 659593017, 660050119, 660507538, + 660965274, 661424202, 661882573, 662341262, 662801145, 663260471, + 663720114, 664180077, 664641237, 665101837, 665562757, 666024877, + 666486436, 666948316, 667410515, 667873918, 668336759, 668799921, + 669264288, 669728093, 670192218, 670656666, 671122323, 671587415, + 672052829, 672519455, 672985516, 673451899, 673918605, 674386527, + 674853881, 675321559, 675790455, 676258782, 676727434, 677196410, + 677666608, 678136235, 678606188, 679077364, 679547969, 680018900, + 680490157, 680962642, 681434553, 681906792, 682380260, 682853154, + 683326375, 683800829, 684274707, 684748914, 685223450, 685699220, + 686174414, 686649938, 687126699, 687602882, 688079395, 688556239, + 689034324, 689511829, 689989665, 690468745, 690947244, 691426075, + 691905238, 692385648, 692865476, 693345636, 693827046, 694307873, + 694789033, 695270526, 695753273, 696235434, 696717930, 697201682, + 697684847, 698168347, 698652182, 699137277, 699621784, 700106626, + 700592731, 701078246, 701564098, 702050286, 702537740, 703024604, + 703511804, 704000273, 704488150, 704976365, 705464918, 705954743, + 706443974, 706933544, 707424389, 707914639, 708405228, 708896158, + 709388365, 709879976, 710371927, 710865159, 711357793, 711850769, + 712345028, 712838688, 713332689, 713827033, 714322665, 714817695, + 715313068, 715809731, 716305792, 716802196, 717298945, 717796987, + 718294425, 718792207, 719291286, 719789759, 720288578, 720787743, + 721288207, 721788064, 722288268, 722789774, 723290672, 723791917, + 724293510, 724796408, 725298697, 725801333, 726305278, 726808613, + 727312296, 727816328, 728321672, 728826404, 729331485, 729837881, + 730343664, 730849797, 731356280, 731864082, 732371269, 732878807, + 733387666, 733895909, 734404503, 734913450, 735423722, 735933376, + 736443382, 736954717, 737465431, 737976499, 738487922, 739000676, + 739512808, 740025295, 740539116, 741052315, 741565869, 742079779, + 742595027, 743109650, 743624629, 744140950, 744656644, 745172696, + 745690092, 746206860, 746723986, 747241470, 747760302, 748278505, + 748797067, 749316978, 749836260, 750355901, 750875903, 751397258, + 751917981, 752439065, 752961506, 753483313, 754005482, 754528012, + 755051903, 755575159, 756098778, 756623759, 757148104, 757672813, + 758197885, 758724324, 759250125, 759776290, 760303825, 760830721, + 761357981, 761885607, 762414607, 762942965, 763471690, 764001790, + 764531249, 765061074, 765591266, 766122838, 766653766, 767185062, + 767717742, 768249775, 768782177, 769314948, 769849106, 770382616, + 770916497, 771451767, 771986388, 772521379, 773057763, 773593497, + 774129603, 774666080, 775203953, 775741174, 776278768, 776817761, + 777356101, 777894814, 778433900, 778974389, 779514224, 780054432, + 780596047, 781137005, 781678338, 782220046, 782763164, 783305624, + 783848460, 784392709, 784936298, 785480264, 786024607, 786570367, + 787115466, 787660942, 788207838, 788754071, 789300683, 789847673, + 790396087, 790943837, 791491966, 792041522, 792590412, 793139683, + 793689333, 794240415, 794790829, 795341624, 795893853, 796445413, + 796997355, 797549679, 798103441, 798656532, 799210006, 799764921, + 800319163, 800873790, 801428800, 801985256, 802541037, 803097203, + 803654817, 804211755, 804769079, 805326789, 805885951, 806444435, + 807003307, 807563633, 808123280, 808683314, 809243737, 809805619, + 810366819, 810928409, 811491460, 812053829, 812616587, 813179736, + 813744351, 814308281, 814872602, 815438392, 816003496, 816568991, + 817135959, 817702240, 818268913, 818835978, 819404520, 819972373, + 820540619, 821110344, 821679379, 822248808, 822818632, 823389939, + 823960554, 824531564, 825104060, 825675863, 826248061, 826820657, + 827394742, 827968132, 828541920, 829117201, 829691784, 830266766, + 830842146, 831419024, 831995203, 832571781, 833149860, 833727238, + 834305017, 834883195, 835462879, 836041861, 836621243, 837202134, + 837782320, 838362909, 838943900, 839526403, 840108200, 840690401, + 841274117, 841857125, 842440538, 843025469, 843609691, 844194318, + 844779350, 845365905, 845951749, 846537999, 847125775, 847712839, + 848300310, 848888187, 849477595, 850066289, 850655390, 851246025, + 851835944, 852426272, 853017009, 853609284, 854200840, 854792807, + 855386315, 855979103, 856572302, 857165912, 857761068, 858355502, + 858950348, 859546742, 860142413, 860738498, 861334995, 861933045, + 862530370, 863128110, 863727405, 864325973, 864924957, 865524355, + 866125314, 866725545, 867326191, 867928401, 868529881, 869131778, + 869734092, 870337974, 870941124, 871544692, 872149831, 872754236, + 873359061, 873964304, 874571123, 875177207, 875783710, 876391792, + 876999138, 877606904, 878215091, 878824861, 879433893, 880043346, + 880654386, 881264685, 881875407, 882486553, 883099289, 883711283, + 884323700, 884937712, 885550980, 886164672, 886778790, 887394507, + 888009477, 888624873, 889241872, 889858122, 890474799, 891093082, + 891710615, 892328577, 892946966, 893566965, 894186213, 894805890, + 895427180, 896047717, 896668684, 897290081, 897913096, 898535355, + 899158046, 899782358, 900405913, 901029900, 901654319, 902280365, + 902905651, 903531370, 904158719, 904785306, 905412328, 906039785, + 906668875, 907297202, 907925965, 908556365, 909186000, 909816072, + 910446581, 911078730, 911710114, 912341935, 912975401, 913608099, + 914241235, 914874810, 915510034, 916144489, 916779383, 917415930, + 918051705, 918687921, 919325793, 919962891, 920600432, 921238414, + 921878057, 922516924, 923156234, 923797209, 924437406, 925078047, + 925719132, 926361886, 927003861, 927646281, 928290373, 928933684, + 929577441, 930221644, 930867524, 931512622, 932158166, 932805391, + 933451831, 934098719, 934746055, 935395077, 936043312, 936691996, + 937342369, 937991953, 938641988, 939292472, 939944651, 940596039, + 941247878, 941901414, 942554158, 943207354, 943861002, 944516353, + 945170909, 945825918, 946482633, 947138552, 947794925, 948451753, + 949110291, 949768030, 950426226, 951086135, 951745243, 952404809, + 953064832, 953726573, 954387511, 955048908, 955712027, 956374341, + 957037115, 957700348, 958365307, 959029460, 959694074, 960360418, + 961025954, 961691951, 962358410, 963026603, 963693987, 964361833, + 965031418, 965700191, 966369428, 967039128, 967710571, 968381201, + 969052296, 969725137, 970397163, 971069654, 971743897, 972417321, + 973091213, 973765571, 974441685, 975116980, 975792742, 976470264, + 977146964, 977824133, 978501771, 979181174, 979859753, 980538802, + 981219619, 981899611, 982580073, 983261008, 983943715, 984625594, + 985307946, 985992074, 986675373, 987359145, 988043392, 988729419, + 989414615, 990100286, 990787742, 991474364, 992161462, 992849036, + 993538401, 994226929, 994915935, 995606734, 996296696, 996987136, + 997678055, 998370772, 999062649, 999755006, 1000449165, 1001142483, + 1001836281, 1002531886, 1003226647, 1003921889, 1004617614, 1005315149, + 1006011839, 1006709012, 1007407999, 1008106140, 1008804764, 1009503872, + 1010204800, 1010904879, 1011605442, 1012307830, 1013009365, 1013711388, + 1014413896, 1015118233, 1015821717, 1016525688, 1017231492, 1017936440, + 1018641876, 1019347801, 1020055565, 1020762470, 1021469865, 1022179101, + 1022887478, 1023596346, 1024305704, 1025016910, 1025727253, 1026438089, + 1027150775, 1027862597, 1028574913, 1029287722, 1030002386, 1030716185, + 1031430478, 1032146630, 1032861915, 1033577694, 1034293970, 1035012111, + 1035729381, 1036447148, 1037166784, 1037885547, 1038604809, 1039324569, + 1040046202, 1040766961, 1041488219, 1042211355, 1042933614, 1043656374, + 1044379635, 1045104778, 1045829042, 1046553809, 1047280462, 1048006234, + 1048732509, 1049459287, 1050187958, 1050915745, 1051644036, 1052374224, + 1053103526, 1053833333, 1054563647, 1055295861, 1056027188, 1056759022, + 1057492761, 1058225610, 1058958967, 1059694233, 1060428608, 1061163492, + 1061898885, 1062636193, 1063372607, 1064109531, 1064848373, 1065586320, + 1066324778, 1067063748, 1067804642, 1068544637, 1069285146, 1070027582, + 1070769118, 1071511168, 1072253732, 1072998229}; + +static 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, + 529112805, 528746380, 528379511, 528013594, 527647931, 527282520, 526916667, + 526551763, 526187112, 525822018, 525457872, 525093979, 524729644, 524366255, + 524003117, 523640231, 523276904, 522914521, 522552389, 522189817, 521828187, + 521466807, 521105678, 520744110, 520383480, 520023101, 519662284, 519302404, + 518942774, 518583392, 518223574, 517864691, 517506056, 517146985, 516788847, + 516430957, 516073315, 515715239, 515358092, 515001193, 514643861, 514287456, + 513931299, 513575388, 513219044, 512863627, 512508455, 512152852, 511798173, + 511443739, 511089551, 510734932, 510381235, 510027782, 509673901, 509320938, + 508968220, 508615746, 508262844, 507910858, 507559117, 507206948, 506855694, + 506504683, 506153915, 505802721, 505452439, 505102400, 504751936, 504402382, + 504053070, 503704000, 503354506, 503005920, 502657575, 502308807, 501960945, + 501613323, 501265280, 500918141, 500571242, 500224583, 499877503, 499531325, + 499185386, 498839027, 498493568, 498148348, 497803367, 497457967, 497113465, + 496769200, 496424518, 496080731, 495737182, 495393871, 495050143, 494707308, + 494364710, 494021696, 493679573, 493337687, 492996037, 492653973, 492312797, + 491971857, 491630504, 491290037, 490949805, 490609809, 490269401, 489929876, + 489590587, 489250886, 488912067, 488573482, 488235132, 487896371, 487558490, + 487220843, 486882786, 486545606, 486208661, 485871948, 485534827, 485198581, + 484862569, 484526148, 484190601, 483855286, 483520203, 483184714, 482850096, + 482515709, 482180917, 481846994, 481513302, 481179205, 480845976, 480512977, + 480180209, 479847037, 479514730, 479182654, 478850174, 478518557, 478187171, + 477856013, 477524454, 477193756, 476863286, 476532416, 476202404, 475872622, + 475543067, 475213113, 474884015, 474555145, 474225876, 473897462, 473569276, + 473241317, 472912959, 472585454, 472258176, 471930501, 471603677, 471277079, + 470950707, 470623939, 470298019, 469972325, 469646236, 469320994, 468995977, + 468671184, 468345998, 468021656, 467697539, 467373028, 467049359, 466725915, + 466402695, 466079083, 465756311, 465433762, 465110822, 464788720, 464466842, + 464145186, 463823140, 463501930, 463180943, 462859566, 462539024, 462218703, + 461898604, 461578117, 461258462, 460939028, 460619207, 460300216, 459981446, + 459662289, 459343960, 459025852, 458707965, 458389691, 458072244, 457755017, + 457437405, 457120617, 456804049, 456487700, 456170967, 455855057, 455539365, + 455223290, 454908036, 454593000, 454278182, 453962983, 453648601, 453334438, + 453019893, 452706164, 452392653, 452079359, 451765685, 451452825, 451140182, + 450827160, 450514950, 450202956, 449891179, 449579023, 449267678, 448956548, + 448645040, 448334342, 448023858, 447713590, 447402945, 447093107, 446783483, + 446473483, 446164288, 445855308, 445546541, 445237400, 444929061, 444620936, + 444312437, 444004738, 443697253, 443389981, 443082336, 442775490, 442468856, + 442161850, 441855641, 441549645, 441243276, 440937704, 440632343, 440327193, + 440021673, 439716946, 439412431, 439107545, 438803452, 438499569, 438195896, + 437891855, 437588603, 437285562, 436982152, 436679530, 436377118, 436074915, + 435772346, 435470562, 435168987, 434867046, 434565889, 434264941, 433964201, + 433663096, 433362772, 433062657, 432762178, 432462478, 432162987, 431863702, + 431564055, 431265185, 430966523, 430667498, 430369249, 430071207, 429773371, + 429475174, 429177751, 428880534, 428582956, 428286151, 427989552, 427693157, + 427396403, 427100420, 426804642, 426508504, 426213136, 425917972, 425623013, + 425327695, 425033144, 424738798, 424444094, 424150155, 423856420, 423562888, + 423269000, 422975875, 422682953, 422389675, 422097159, 421804845, 421512177, + 421220269, 420928563, 420637058, 420345200, 420054100, 419763202, 419471950, + 419181454, 418891160, 418601067, 418310622, 418020930, 417731440, 417441598, + 417152508, 416863619, 416574930, 416285891, 415997602, 415709512, 415421073, + 415133383, 414845892, 414558600, 414270960, 413984066, 413697371, 413410328, + 413124031, 412837931, 412552030, 412265782, 411980277, 411694970, 411409316, + 411124404, 410839690, 410555172, 410270309, 409986186, 409702260, 409417989, + 409134456, 408851120, 408567980, 408284496, 408001748, 407719196, 407436301, + 407154140, 406872175, 406590406, 406308294, 406026914, 405745730, 405464204, + 405183410, 404902809, 404621868, 404341657, 404061640, 403781816, 403501653, + 403222218, 402942976, 402663395, 402384540, 402105878, 401827409, 401548602, + 401270518, 400992628, 400714400, 400436895, 400159582, 399882461, 399605003, + 399328266, 399051721, 398774839, 398498677, 398222706, 397946927, 397670812, + 397395415, 397120208, 396844667, 396569841, 396295206, 396020761, 395745983, + 395471919, 395198044, 394923836, 394650341, 394377035, 394103919, 393830471, + 393557733, 393285184, 393012304, 392740132, 392468149, 392196355, 391924230, + 391652812, 391381582, 391110023, 390839169, 390568502, 390298023, 390027216, + 389757112, 389487195, 389216950, 388947407, 388678050, 388408881, 388139384, + 387870587, 387601977, 387333040, 387064801, 386796749, 386528371, 386260690, + 385993194, 385725883, 385458248, 385191308, 384924553, 384657474, 384391089, + 384124887, 383858871, 383592531, 383326883, 383061419, 382795633, 382530537, + 382265624, 382000895, 381735845, 381471483, 381207303, 380942804, 380678991, + 380415360, 380151913, 379888145, 379625062, 379362162, 379098943, 378836406, + 378574052, 378311880, 378049389, 377787580, 377525952, 377264006, 377002741, + 376741656, 376480753, 376219533, 375958991, 375698629, 375437951, 375177951, + 374918130, 374658489, 374398533, 374139252, 373880151, 373620735, 373361993, + 373103430, 372844553, 372586348, 372328322, 372070475, 371812315, 371554825, + 371297513, 371039889, 370782934, 370526157, 370269558, 370012648, 369756404, + 369500338, 369243961, 368988250, 368732715, 368477358, 368221691, 367966688, + 367711861, 367456725, 367202252, 366947954, 366693833, 366439403, 366185634, + 365932041, 365678140, 365424898, 365171832, 364918941, 364665743, 364413202, + 364160836, 363908164, 363656148, 363404306, 363152639, 362900667, 362649348, + 362398204, 362146755, 361895959, 361645336, 361394887, 361144134, 360894032, + 360644103, 360393871, 360144289, 359894880, 359645643, 359396104, 359147212, + 358898493, 358649472, 358401098, 358152896, 357904865, 357656534, 357408847, + 357161332, 356913517, 356666345, 356419344, 356172514, 355925384, 355678897, + 355432580, 355185964, 354939988, 354694182, 354448547, 354202614, 353957319, + 353712195, 353466772, 353221987, 352977371, 352732459, 352488182, 352244075, + 352000137, 351755902, 351512302, 351268870, 351025143, 350782049, 350539123, + 350296365, 350053313, 349810892, 349568639, 349326091, 349084174, 348842424, + 348600841, 348358965, 348117717, 347876636, 347635263, 347394516, 347153937, + 346913523, 346672818, 346432738, 346192824, 345952619, 345713038, 345473622, + 345234373, 344994832, 344755914, 344517162, 344278119, 344039698, 343801441, + 343563349, 343324969, 343087207, 342849610, 342611725, 342374457, 342137354, + 341899962, 341663188, 341426577, 341190130, 340953396, 340717277, 340481321, + 340245079, 340009450, 339773984, 339538682, 339303094, 339068117, 338833304, + 338598205, 338363717, 338129391, 337895227, 337660780, 337426941, 337193263, + 336959303, 336725949, 336492758, 336259728, 336026415, 335793707, 335561161, + 335328333, 335096109, 334864046, 334632144, 334399960, 334168380, 333936959, + 333705258, 333474158, 333243218, 333012438, 332781379, 332550919, 332320618, + 332090038, 331860057, 331630235, 331400573, 331170631, 330941287, 330712101, + 330482637, 330253769, 330025060, 329796509, 329567680, 329339446, 329111369, + 328883016, 328655256, 328427654, 328200209, 327972488, 327745358, 327518386, + 327291138, 327064480, 326837979, 326611635, 326385017, 326158986, 325933113, + 325706965, 325481404, 325255999, 325030751, 324805229, 324580293, 324355513, + 324130459, 323905990, 323681677, 323457091, 323233088, 323009241, 322785548, + 322561584, 322338202, 322114974, 321891476, 321668557, 321445793, 321223183, + 321000303, 320778002, 320555855, 320333438, 320111599, 319889913, 319668381, + 319446579, 319225354, 319004282, 318782942, 318562176, 318341563, 318121103, + 317900376, 317680221, 317460219, 317239950, 317020253, 316800708, 316581315, + 316361656, 316142567, 315923630, 315704427, 315485794, 315267311, 315048981, + 314830385, 314612356, 314394479, 314176337, 313958761, 313741337, 313523648, + 313306525, 313089551, 312872729, 312655643, 312439120, 312222748, 312006113, + 311790040, 311574117, 311358344, 311142309, 310926835, 310711510, 310495923, + 310280896, 310066019, 309851290, 309636300, 309421869, 309207586, 308993043, + 308779057, 308565219, 308351530, 308137581, 307924187, 307710942, 307497437, + 307284487, 307071684, 306859029, 306646116, 306433755, 306221542, 306009071, + 305797151, 305585378, 305373753, 305161870, 304950537, 304739351, 304527908, + 304317014, 304106267, 303895665, 303684808, 303474498, 303264334, 303053915, + 302844042, 302634314, 302424732, 302214895, 302005603, 301796456, 301587056, + 301378199, 301169486, 300960918, 300752097, 300543819, 300335684, 300127297, + 299919451, 299711748, 299504190, 299296380, 299089109, 298881982, 298674603, + 298467763, 298261067, 298054513, 297847708, 297641441, 297435316, 297228942, + 297023103, 296817406, 296611460, 296406049, 296200780, 295995653, 295790277, + 295585435, 295380734, 295175785, 294971367, 294767092, 294562958, 294358576, + 294154725, 293951015, 293747058, 293543630, 293340343, 293137197, 292933805, + 292730940, 292528217, 292325247, 292122804, 291920501, 291718338, 291515930, + 291314047, 291112305, 290910317, 290708854, 290507530, 290306346, 290104918, + 289904013, 289703246, 289502236, 289301748, 289101399, 288901189, 288700736, + 288500803, 288301008, 288100971, 287901454, 287702074, 287502453, 287303350, + 287104385, 286905557, 286706488, 286507937, 286309522, 286110867, 285912728, + 285714725, 285516860, 285318755, 285121164, 284923710, 284726017, 284528837, + 284331793, 284134885, 283937739, 283741105, 283544606, 283347870, 283151644, + 282955554, 282759600, 282563407, 282367725, 282172178, 281976393, 281781117, + 281585976, 281390970, 281195728, 281000992, 280806392, 280611555, 280417224, + 280223028, 280028966, 279834668, 279640875, 279447217, 279253323, 279059933, + 278866676, 278673554, 278480197, 278287342, 278094620, 277901665, 277709211, + 277516890, 277324702, 277132281, 276940359, 276748571, 276556549, 276365027, + 276173637, 275982379, 275790889, 275599897, 275409037, 275217945, 275027349, + 274836885, 274646553, 274455990, 274265922, 274075986, 273885819, 273696146, + 273506604, 273317193, 273127553, 272938405, 272749388, 272560141, 272371386, + 272182762, 271993908, 271805545, 271617313, 271429211, 271240880, 271053039, + 270865327, 270677388, 270489937, 270302615, 270115423, 269928004, 269741072, + 269554269, 269367240, 269180696, 268994281, 268807995, 268621484}; + +#define MUL_DRC_BAND 4 + +static PLATFORM_INLINE WORD32 ixheaacd_div_by_30(WORD32 op) { + WORD32 ret; + WORD64 temp; + + temp = (WORD64)op * 35791394; + + ret = (WORD32)((temp + 17895697) >> 30); + + return ret; +} + +static PLATFORM_INLINE WORD32 ixheaacd_div_by_15(WORD64 op) { + WORD32 ret; + WORD64 temp; + + temp = (WORD64)op * 71582788; + + ret = (WORD32)((temp + 134217728) >> 30); + + return ret; +} + +static VOID ixheaacd_copy_drc_data(ixheaac_drc_data_struct *ch_data, + ixheaac_drc_bs_data_struct *ptr_bs_data, + WORD32 frame_size) { + WORD32 band_num; + + ch_data->n_drc_bands = ptr_bs_data->drc_num_bands; + + if (ch_data->n_drc_bands == 1) { + ch_data->n_mdct_bands[0] = frame_size; + ch_data->drc_fac[0] = ptr_bs_data->dyn_rng_dlbl[0]; + ch_data->drc_fac_dvb[0] = ptr_bs_data->dyn_rng_dlbl_dvb[0]; + + } else { + for (band_num = 0; band_num < ptr_bs_data->drc_num_bands; band_num++) { + ch_data->n_mdct_bands[band_num] = + (ptr_bs_data->drc_band_top[band_num] + 1) * MUL_DRC_BAND; + ch_data->drc_fac[band_num] = ptr_bs_data->dyn_rng_dlbl[band_num]; + ch_data->drc_fac_dvb[band_num] = ptr_bs_data->dyn_rng_dlbl_dvb[band_num]; + } + } + + ch_data->drc_interp_scheme = ptr_bs_data->drc_interpolation_scheme; +} + +WORD32 ixheaacd_drc_map_channels(ia_drc_dec_struct *pstr_drc_dec, + WORD32 num_channels, WORD32 frame_size) { + WORD32 i, element; + WORD32 num_drc_elements; + ixheaac_drc_bs_data_struct *ptr_bs_data; + + num_drc_elements = pstr_drc_dec->num_drc_elements; + + if (num_drc_elements == 0) { + return IA_NO_ERROR; + } + + if (num_drc_elements == 1) { + } + + if (num_drc_elements > 1) { + for (i = 0; i < num_channels; i++) { + WORD32 drc_on = 0; + + for (element = 0; element < num_drc_elements; element++) { + ptr_bs_data = &pstr_drc_dec->str_drc_bs_data[element]; + if (ptr_bs_data->b_channel_on[i]) drc_on++; + } + + if (drc_on > 1) { + return IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_DRC_DATA; + } + } + } + + for (element = 0; element < num_drc_elements; element++) { + ptr_bs_data = &pstr_drc_dec->str_drc_bs_data[element]; + if (ptr_bs_data->prog_ref_level_present) + pstr_drc_dec->prog_ref_level = ptr_bs_data->prog_ref_level; + + for (i = 0; i < num_channels; i++) { + if (!ptr_bs_data->b_channel_on[i]) continue; + + ixheaacd_copy_drc_data(&pstr_drc_dec->str_drc_channel_data[i], + &pstr_drc_dec->str_drc_bs_data[element], + frame_size); + } + } + return IA_NO_ERROR; +} + +VOID ixheaacd_drc_dec_create(ia_drc_dec_struct *pstr_drc_dec, + WORD16 drc_ref_level, WORD16 drc_def_level) { + WORD32 j, k; + WORD32 ch; + + pstr_drc_dec->sbr_allowed = 1; + pstr_drc_dec->sbr_found = 0; + + pstr_drc_dec->drc_element_found = 0; + + pstr_drc_dec->max_audio_channels = MAX_BS_ELEMENT; + pstr_drc_dec->drc_ref_level = drc_ref_level; + pstr_drc_dec->drc_def_level = drc_def_level; + + pstr_drc_dec->num_drc_elements = 0; + pstr_drc_dec->target_ref_level = 108; + pstr_drc_dec->prog_ref_level = 108; + pstr_drc_dec->cut_factor = 0; + pstr_drc_dec->boost_factor = 0; + pstr_drc_dec->drc_on = 0; + pstr_drc_dec->drc_dig_norm = 1; + pstr_drc_dec->pres_mode = -1; + + pstr_drc_dec->length_history = 2; + if (pstr_drc_dec->sbr_allowed) pstr_drc_dec->length_history++; + + for (ch = 0; ch < MAX_BS_ELEMENT; ch++) { + ixheaac_drc_data_struct *pstr_drc_data = + (ixheaac_drc_data_struct *)&pstr_drc_dec->str_drc_channel_data[ch]; + pstr_drc_dec->drc_channel_next_index[ch] = 0; + pstr_drc_dec->state = 0; + + for (j = 0; j < 64; j++) + for (k = 0; k < 64; k++) + pstr_drc_data->drc_factors_sbr[j][k] = DRC_SBR_ONE_Q25; + for (j = 0; j < MAX_DRC_BANDS; j++) pstr_drc_data->drc_fac[j] = 0; + + pstr_drc_data->n_mdct_bands[0] = FRAME_SIZE; + pstr_drc_data->drc_exp = 1; + pstr_drc_data->short_block = 0; + pstr_drc_data->drc_interp_scheme = 0; + pstr_drc_data->n_drc_bands = 1; + pstr_drc_data->new_prog_ref_level = 0; + pstr_drc_data->new_drc_fac = 0; + } +} + +static WORD32 ixheaacd_drc_excluded_channels(ia_handle_bit_buf_struct bs, + WORD32 nch, UWORD8 *b_channel_on) { + WORD32 ich, nbyte = 0; + WORD32 num_excl_chan; + UWORD8 exclude_mask; + + num_excl_chan = 7; + for (ich = 0; ich < 7; ich++) { + exclude_mask = ixheaacd_read_bits_buf(bs, 1); + if (ich < nch) { + b_channel_on[ich] = !exclude_mask; + } + } + nbyte++; + + while (ixheaacd_read_bits_buf(bs, 1)) { + for (ich = num_excl_chan; ich < num_excl_chan + 7; ich++) { + exclude_mask = ixheaacd_read_bits_buf(bs, 1); + if (ich < nch) { + b_channel_on[ich] = !exclude_mask; + } + } + nbyte++; + num_excl_chan += 7; + } + + return nbyte; +} + +static WORD32 ixheaacd_drc_element_read( + ia_handle_bit_buf_struct bs, ixheaac_drc_bs_data_struct *pstr_bs_data) { + WORD32 ich, idrc, nbyte = 1; + WORD32 pce_tag_present, drc_bands_present; + WORD32 pce_instance_tag, drc_tag_reserved_bits; + WORD32 prog_ref_level_reserved_bits; + WORD32 excluded_chns_present; + UWORD8 drc_band_incr; + WORD8 max_dyn_rng_dlbl = -128; + + pstr_bs_data->drc_num_bands = 1; + + pce_tag_present = ixheaacd_read_bits_buf(bs, 1); + if (pce_tag_present) { + pce_instance_tag = ixheaacd_read_bits_buf(bs, 4); + drc_tag_reserved_bits = ixheaacd_read_bits_buf(bs, 4); + nbyte++; + } + + for (ich = 0; ich < MAX_AUDIO_CHANNELS; ich++) { + pstr_bs_data->b_channel_on[ich] = 1; + } + + excluded_chns_present = ixheaacd_read_bits_buf(bs, 1); + if (excluded_chns_present) { + nbyte += ixheaacd_drc_excluded_channels(bs, MAX_AUDIO_CHANNELS, + pstr_bs_data->b_channel_on); + } + + drc_bands_present = ixheaacd_read_bits_buf(bs, 1); + if (drc_bands_present) { + drc_band_incr = ixheaacd_read_bits_buf(bs, 4); + pstr_bs_data->drc_interpolation_scheme = ixheaacd_read_bits_buf(bs, 4); + nbyte++; + + pstr_bs_data->drc_num_bands += drc_band_incr; + for (idrc = 0; idrc < pstr_bs_data->drc_num_bands; idrc++) { + pstr_bs_data->drc_band_top[idrc] = ixheaacd_read_bits_buf(bs, 8); + nbyte++; + } + } else { + pstr_bs_data->drc_band_top[0] = FRAME_SIZE / 4 - 1; + pstr_bs_data->drc_interpolation_scheme = 0; + } + + pstr_bs_data->prog_ref_level_present = ixheaacd_read_bits_buf(bs, 1); + if (pstr_bs_data->prog_ref_level_present) { + pstr_bs_data->prog_ref_level = ixheaacd_read_bits_buf(bs, 7); + + prog_ref_level_reserved_bits = ixheaacd_read_bits_buf(bs, 1); + nbyte++; + } + + for (idrc = 0; idrc < pstr_bs_data->drc_num_bands; idrc++) { + WORD32 sign = ixheaacd_read_bits_buf(bs, 1); + pstr_bs_data->dyn_rng_dlbl[idrc] = ixheaacd_read_bits_buf(bs, 7); + if (sign) + pstr_bs_data->dyn_rng_dlbl[idrc] = -pstr_bs_data->dyn_rng_dlbl[idrc]; + max_dyn_rng_dlbl = max(max_dyn_rng_dlbl, pstr_bs_data->dyn_rng_dlbl[idrc]); + + nbyte++; + } + pstr_bs_data->max_dyn_rng_dlbl = max_dyn_rng_dlbl; + + return nbyte; +} + +static int ixheaacd_drc_read_compression(ia_handle_bit_buf_struct bs, + ia_drc_dec_struct *pstr_drc_dec, + WORD32 bs_pos) { + int bit_count = 0; + int dmx_lvl_present, ext_present, compression_present; + int coarse_gain_present, fine_grain_present; + ia_bit_buf_struct local_bs; + WORD32 bytes = 0, bits = 0; + + memcpy(&local_bs, bs, sizeof(ia_bit_buf_struct)); + + bytes = (local_bs.size - bs_pos) >> 3; + bits = (local_bs.size - bs_pos) % 8; + + local_bs.cnt_bits = bs_pos; + local_bs.ptr_read_next = local_bs.ptr_bit_buf_base; + local_bs.ptr_read_next += bytes; + local_bs.bit_pos = 7 - bits; + + if (ixheaacd_read_bits_buf(&local_bs, 8) != DVB_ANC_DATA_SYNC_BYTE) { + return 0; + } + + if (ixheaacd_read_bits_buf(&local_bs, 2) != 3) return 0; + + ixheaacd_read_bits_buf(&local_bs, 2); + pstr_drc_dec->pres_mode = ixheaacd_read_bits_buf(&local_bs, 2); + ixheaacd_read_bits_buf(&local_bs, 1); + if (ixheaacd_read_bits_buf(&local_bs, 1) != 0) return 0; + + if (ixheaacd_read_bits_buf(&local_bs, 3) != 0) return 0; + + dmx_lvl_present = ixheaacd_read_bits_buf(&local_bs, 1); + ext_present = ixheaacd_read_bits_buf(&local_bs, 1); + compression_present = ixheaacd_read_bits_buf(&local_bs, 1); + coarse_gain_present = ixheaacd_read_bits_buf(&local_bs, 1); + fine_grain_present = ixheaacd_read_bits_buf(&local_bs, 1); + bit_count += 24; + + if (dmx_lvl_present) { + ixheaacd_read_bits_buf(&local_bs, 8); + bit_count += 8; + } + + if (compression_present) { + UWORD8 compression_on, compression_val; + + if (ixheaacd_read_bits_buf(&local_bs, 7) != 0) return 0; + + compression_on = (UWORD8)ixheaacd_read_bits_buf(&local_bs, 1); + compression_val = (UWORD8)ixheaacd_read_bits_buf(&local_bs, 8); + bit_count += 16; + + if (compression_on) { + pstr_drc_dec->str_drc_bs_data[0].drc_num_bands = 1; + pstr_drc_dec->str_drc_bs_data[0].dyn_rng_dlbl_dvb[0] = compression_val; + pstr_drc_dec->str_drc_bs_data[0].drc_band_top[0] = (1024 >> 2) - 1; + pstr_drc_dec->drc_ref_level = -1; + pstr_drc_dec->str_drc_bs_data[0].drc_data_type = DVB_DRC_ANC_DATA; + } else { + pstr_drc_dec->str_drc_bs_data[0].drc_num_bands = 1; + pstr_drc_dec->str_drc_bs_data[0].dyn_rng_dlbl_dvb[0] = (WORD8)0x80; + pstr_drc_dec->str_drc_bs_data[0].drc_band_top[0] = (1024 >> 2) - 1; + pstr_drc_dec->str_drc_bs_data[0].drc_data_type = DVB_DRC_ANC_DATA; + + if (compression_val != 0) return 0; + } + } + + if (coarse_gain_present) { + ixheaacd_read_bits_buf(&local_bs, 16); + bit_count += 16; + } + if (fine_grain_present) { + ixheaacd_read_bits_buf(&local_bs, 16); + bit_count += 16; + } + + if (ext_present) { + int ext_bits = 8; + + ixheaacd_read_bits_buf(&local_bs, 1); + if (ixheaacd_read_bits_buf(&local_bs, 1)) ext_bits += 8; + if (ixheaacd_read_bits_buf(&local_bs, 1)) ext_bits += 16; + if (ixheaacd_read_bits_buf(&local_bs, 1)) ext_bits += 8; + + ixheaacd_read_bits_buf(&local_bs, ext_bits - 4); + bit_count += ext_bits; + } + + return (bit_count); +} + +WORD32 ixheaacd_dec_drc_read_element(ia_drc_dec_struct *pstr_drc_dec, + ia_drc_dec_struct *drc_dummy, + ia_handle_bit_buf_struct bs) { + WORD32 bits_read = 0; + WORD32 bits_parse = 0; + if (pstr_drc_dec->num_drc_elements < pstr_drc_dec->max_audio_channels) { + bits_read = ixheaacd_drc_element_read( + bs, &pstr_drc_dec->str_drc_bs_data[pstr_drc_dec->num_drc_elements]); + + if (pstr_drc_dec->dvb_anc_data_present) { + bits_parse = ixheaacd_drc_read_compression( + bs, pstr_drc_dec, pstr_drc_dec->dvb_anc_data_pos); + } + pstr_drc_dec->num_drc_elements++; + + } else { + ixheaac_drc_bs_data_struct drc_ele_dummy; + + bits_read = ixheaacd_drc_element_read(bs, &drc_ele_dummy); + if (pstr_drc_dec->dvb_anc_data_present) { + bits_parse = ixheaacd_drc_read_compression( + bs, drc_dummy, pstr_drc_dec->dvb_anc_data_pos); + } + } + + pstr_drc_dec->dvb_anc_data_present = 0; + + return bits_read; +} + +static const WORD32 ixheaacd_drc_offset[2][16] = { + {0, 4, 8, 12, 16, 20, 24, 28, 0, 0, 0, 0, 0, 0, 0, 0}, + + {0, 4, 8, 12, 16, 19, 22, 26, 0, 0, 0, 0, 0, 0, 0, 0}}; + +WORD32 ixheaacd_get_div_value_24(WORD32 value) { + WORD32 ret; + WORD64 temp; + + temp = (WORD64)value * 44739243; + + ret = (WORD32)((temp + 22369621) >> 30); + + return ret; +} + +WORD32 ixheaacd_get_div_value_2400(WORD32 value) { + WORD32 ret; + WORD64 temp; + + temp = (WORD64)value * 447392; + + ret = (WORD32)((temp + 223696) >> 30); + + return ret; +} + +static WORD32 ixheaacd_drc_div_120_floor(WORD32 value) { + WORD32 ret_val; + WORD64 temp; + + temp = (WORD64)value * 8947849; + + ret_val = (WORD32)(temp >> 30); + + return ret_val; +} + +static WORD32 ixheaacd_drc_floor(WORD32 bottom, WORD32 frame_size) { + WORD32 ret_val; + if (960 == frame_size) { + ret_val = ixheaacd_drc_div_120_floor(bottom); + ret_val *= 30; + ret_val = ret_val >> 3; + } else { + ret_val = bottom >> 7; + ret_val = ret_val << 2; + } + return ret_val; +} + +static WORD32 ixheaacd_drc_ceil(WORD32 top, WORD32 frame_size) { + WORD32 ret_val; + if (960 == frame_size) { + top += 119; + ret_val = ixheaacd_drc_div_120_floor(top); + ret_val *= 30; + ret_val = ret_val >> 3; + } else { + top += 127; + ret_val = top >> 7; + ret_val = ret_val << 2; + } + return ret_val; +} + +static WORD32 ixheaacd_drc_get_bottom_qmf(WORD32 bottom, WORD32 frame_size) { + WORD32 ret_val; + if (960 == frame_size) { + ret_val = bottom % 120; + ret_val = ret_val << 5; + ret_val = ixheaacd_drc_div_120_floor(ret_val); + } else { + ret_val = bottom & 0x7F; + ret_val = ret_val >> 2; + } + return ret_val; +}; + +VOID ixheaacd_drc_apply(ia_drc_dec_struct *pstr_drc_dec, + WORD32 *ptr_spectral_coef, WORD32 win_seq, + WORD32 channel, WORD32 frame_size) { + 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; + 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); + WORD32 diff_ref_level; + + WORD32 *drc_sbr_factors[64]; + WORD32 qmf_start_pos, qmf_stop_pos, qmf_start, i, j; + WORD32 prev_frame_drc_sbr_factors[64]; + WORD32 *ptr_drc_fac; + ptr_drc_fac = + &pstr_drc_dec->str_drc_channel_data[channel].drc_factors_sbr[0][0]; + + for (i = 0; i < 64; i++) { + drc_sbr_factors[i] = ptr_drc_fac; + ptr_drc_fac += 64; + } + + memcpy(prev_frame_drc_sbr_factors, + drc_sbr_factors[2 * num_qmf_sub_sample - 1], 64 * sizeof(WORD32)); + + pstr_drc_data = &pstr_drc_dec->str_drc_channel_data[channel]; + if (!pstr_drc_dec->drc_on) return; + + if (pstr_drc_dec->drc_dig_norm) { + diff_ref_level = + pstr_drc_dec->target_ref_level - pstr_drc_dec->prog_ref_level; + + if (diff_ref_level < 0) { + diff_ref_level = -diff_ref_level; + table = ixheaacd_drc_pow_tbl_2_q29; + div_val = ixheaacd_get_div_value_24(diff_ref_level); + drc_norm = 1 << (25 + div_val); + mod_val = diff_ref_level - (div_val * 24); + diff_ref_level = mod_val * 1000; + + } else { + table = ixheaacd_drc_pow_tbl_1_2_q29; + div_val = ixheaacd_get_div_value_24(diff_ref_level); + drc_norm = 1 << (25 - div_val); + mod_val = diff_ref_level - (div_val * 24); + diff_ref_level = mod_val * 1000; + } + ret_val = ixheaacd_get_div_value_24(diff_ref_level); + drc_norm = ixheaacd_mult32x16in32_shift29(drc_norm, table[ret_val]); + + } else { + drc_norm = (1 << 25); + } + + start_pos = 0; + for (drc_band = 0; drc_band < pstr_drc_data->n_drc_bands; drc_band++) { + if ((pstr_drc_dec->str_drc_bs_data[0].drc_data_type == DVB_DRC_ANC_DATA) && + (pstr_drc_dec->heavy_mode)) { + int val_x, val_y; + float compression_factor; + float temp; + val_x = ((UWORD8)pstr_drc_data->drc_fac_dvb[drc_band]) >> 4; + val_y = ((UWORD8)pstr_drc_data->drc_fac_dvb[drc_band]) & 0x0F; + + compression_factor = (FLOAT32)(48.164 - 6.0206 * val_x - 0.4014 * val_y); + + temp = (FLOAT32)(pow(10, (float)compression_factor / 20.0)); + drc_freq_fac = (WORD32)(temp * 33554431); + + } else { + if (pstr_drc_data->drc_fac[drc_band] < 0) { + low_hi = pstr_drc_dec->cut_factor; + } else { + low_hi = pstr_drc_dec->boost_factor; + } + + { + drc_fac = + pstr_drc_dec->str_drc_channel_data[channel].drc_fac[drc_band] * + low_hi; + if (drc_fac < 0) { + drc_fac *= -1; + table = ixheaacd_drc_pow_tbl_1_2_q29; + + div_val = ixheaacd_get_div_value_2400(drc_fac); + drc_freq_fac = 1 << (25 - div_val); + + mod_val = drc_fac - (div_val * 2400); + drc_fac = mod_val * 10; + } else { + table = ixheaacd_drc_pow_tbl_2_q29; + + div_val = ixheaacd_get_div_value_2400(drc_fac); + drc_freq_fac = 1 << (25 + div_val); + + mod_val = drc_fac - (div_val * 2400); + drc_fac = mod_val * 10; + } + + ret_val = ixheaacd_get_div_value_24(drc_fac); + + drc_freq_fac = + ixheaacd_mult32x16in32_shift29(drc_freq_fac, table[ret_val]); + + drc_freq_fac = ixheaacd_mult32x16in32_shift25(drc_freq_fac, drc_norm); + } + } + + end_pos = pstr_drc_data->n_mdct_bands[drc_band]; + + if (!pstr_drc_dec->sbr_found) { + for (spec_pos = start_pos; spec_pos < end_pos; spec_pos++) { + ptr_spectral_coef[spec_pos] = ixheaacd_mult32x16in32_shift25( + ptr_spectral_coef[spec_pos], drc_freq_fac); + } + } + + if (pstr_drc_dec->sbr_found) { + if (win_seq != EIGHT_SHORT_SEQUENCE) { + if (960 == frame_size) { + qmf_start = ixheaacd_div_by_30(start_pos); + offset_value = 1; + } else { + qmf_start = start_pos >> 5; + offset_value = 0; + } + + for (j = -num_qmf_sub_sample_by_2; j < num_qmf_sub_sample; j++) { + WORD32 alpha_val = 0; + + if (j + num_qmf_sub_sample_by_2 < num_qmf_sub_sample) { + if (pstr_drc_data->drc_interp_scheme == 0) { + alpha_val = (j + num_qmf_sub_sample_by_2); + for (i = qmf_start; i < 64; i++) { + WORD64 temp_drc = (WORD64)alpha_val * drc_freq_fac + + (num_qmf_sub_sample - alpha_val) * + (WORD64)prev_frame_drc_sbr_factors[i]; + + if (frame_size == 512) + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + (WORD32)(temp_drc >> 4); + } + else if (frame_size == 480) + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + ixheaacd_div_by_15(temp_drc); + } + else + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + (WORD32)(temp_drc >> 5); + } + + if (960 == frame_size) { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + ixheaacd_div_by_30( + drc_sbr_factors[num_qmf_sub_sample + j][i]); + } + } + + } else { + if (j + num_qmf_sub_sample_by_2 >= + ixheaacd_drc_offset[offset_value] + [pstr_drc_data->drc_interp_scheme - 1]) { + alpha_val = 1; + for (i = qmf_start; i < 64; i++) { + drc_sbr_factors[num_qmf_sub_sample + j][i] = drc_freq_fac; + } + } else { + alpha_val = 0; + for (i = qmf_start; i < 64; i++) { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + prev_frame_drc_sbr_factors[i]; + } + } + } + } else { + alpha_val = 1; + for (i = qmf_start; i < 64; i++) { + drc_sbr_factors[num_qmf_sub_sample + j][i] = drc_freq_fac; + } + } + } + } else { + qmf_start_pos = ixheaacd_drc_floor(start_pos, frame_size); + + qmf_stop_pos = ixheaacd_drc_ceil(end_pos, frame_size); + + qmf_start = ixheaacd_drc_get_bottom_qmf(start_pos, frame_size); + for (j = qmf_start_pos; j < qmf_stop_pos; j++) { + if (j > qmf_start_pos && ((j & 0x03) == 0)) { + qmf_start = 0; + } + for (i = qmf_start; i < 64; i++) { + drc_sbr_factors[num_qmf_sub_sample + j][i] = drc_freq_fac; + } + } + } + } + + start_pos = end_pos; + } + + if (win_seq != EIGHT_SHORT_SEQUENCE) { + pstr_drc_data->prev_interp_scheme = pstr_drc_data->drc_interp_scheme; + } else { + pstr_drc_data->prev_interp_scheme = 8; + } +} diff --git a/decoder/ixheaacd_dsp_fft32x32s.c b/decoder/ixheaacd_dsp_fft32x32s.c new file mode 100644 index 0000000..0e6a89f --- /dev/null +++ b/decoder/ixheaacd_dsp_fft32x32s.c @@ -0,0 +1,117 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_dsp_fft32x32s.h" +#include "ixheaacd_intrinsics.h" + +#include + +VOID ixheaacd_inv_dit_fft_8pt_dec(WORD32 *y, WORD32 *real, WORD32 *imag) { + WORD32 a0, a1, a2, a3, a00, a10, a20, a30; + WORD32 vr, vi; + + WORD32 x[16]; + + a00 = ixheaacd_add32_sat(y[0], y[8]); + a0 = ixheaacd_sub32_sat(y[0], y[8]); + + a20 = ixheaacd_add32_sat(y[1], y[9]); + a3 = ixheaacd_sub32_sat(y[1], y[9]); + + a10 = ixheaacd_add32_sat(y[4], y[12]); + a2 = ixheaacd_sub32_sat(y[4], y[12]); + + a30 = ixheaacd_add32_sat(y[5], y[13]); + a1 = ixheaacd_sub32_sat(y[5], y[13]); + + x[0] = ixheaacd_add32_sat(a00, a10); + x[4] = ixheaacd_sub32_sat(a00, a10); + x[1] = ixheaacd_add32_sat(a20, a30); + x[5] = ixheaacd_sub32_sat(a20, a30); + + x[2] = ixheaacd_sub32_sat(a0, a1); + x[6] = ixheaacd_add32_sat(a0, a1); + x[3] = ixheaacd_add32_sat(a3, a2); + x[7] = ixheaacd_sub32_sat(a3, a2); + + a00 = ixheaacd_add32_sat(y[2], y[10]); + a0 = ixheaacd_sub32_sat(y[2], y[10]); + + a20 = ixheaacd_add32_sat(y[3], y[11]); + a3 = ixheaacd_sub32_sat(y[3], y[11]); + + a10 = ixheaacd_add32_sat(y[6], y[14]); + a2 = ixheaacd_sub32_sat(y[6], y[14]); + + a30 = ixheaacd_add32_sat(y[7], y[15]); + a1 = ixheaacd_sub32_sat(y[7], y[15]); + + x[8] = ixheaacd_add32_sat(a00, a10); + x[12] = ixheaacd_sub32_sat(a00, a10); + x[9] = ixheaacd_add32_sat(a20, a30); + x[13] = ixheaacd_sub32_sat(a20, a30); + + x[10] = ixheaacd_sub32_sat(a0, a1); + x[14] = ixheaacd_add32_sat(a0, a1); + x[11] = ixheaacd_add32_sat(a3, a2); + x[15] = ixheaacd_sub32_sat(a3, a2); + + real[0] = ixheaacd_add32_sat(x[0], x[8]); + imag[0] = ixheaacd_add32_sat(x[1], x[9]); + a00 = ixheaacd_sub32_sat(x[0], x[8]); + a10 = ixheaacd_sub32_sat(x[1], x[9]); + + a0 = ixheaacd_sub32_sat(x[4], x[13]); + a1 = ixheaacd_add32_sat(x[5], x[12]); + + real[4] = ixheaacd_add32_sat(x[4], x[13]); + imag[4] = ixheaacd_sub32_sat(x[5], x[12]); + + vr = ixheaacd_mult32x16in32_shl_sat(ixheaacd_sub32_sat(x[10], x[11]), 0x5A82); + vi = ixheaacd_mult32x16in32_shl_sat(ixheaacd_add32_sat(x[10], x[11]), 0x5A82); + + real[1] = ixheaacd_add32_sat(x[2], vr); + imag[1] = ixheaacd_add32_sat(x[3], vi); + + a2 = ixheaacd_sub32_sat(x[2], vr); + a3 = ixheaacd_sub32_sat(x[3], vi); + + real[2] = ixheaacd_add32_sat(a0, a2); + imag[2] = ixheaacd_add32_sat(a1, a3); + vr = ixheaacd_mult32x16in32_shl_sat(ixheaacd_add32_sat(x[14], x[15]), 0x5A82); + vi = ixheaacd_mult32x16in32_shl_sat(ixheaacd_sub32_sat(x[14], x[15]), 0x5A82); + + a20 = ixheaacd_sub32_sat(x[6], vr); + a30 = ixheaacd_add32_sat(x[7], vi); + + real[3] = ixheaacd_add32_sat(a00, a20); + imag[3] = ixheaacd_add32_sat(a10, a30); + + real[5] = ixheaacd_add32_sat(x[6], vr); + imag[5] = ixheaacd_sub32_sat(x[7], vi); +} diff --git a/decoder/ixheaacd_dsp_fft32x32s.h b/decoder/ixheaacd_dsp_fft32x32s.h new file mode 100644 index 0000000..7e6fdc3 --- /dev/null +++ b/decoder/ixheaacd_dsp_fft32x32s.h @@ -0,0 +1,29 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_DSP_FFT32X32S_H +#define IXHEAACD_DSP_FFT32X32S_H + +VOID ixheaacd_inv_dit_fft_8pt_dec(WORD32 *x, WORD32 *real, WORD32 *imag); + +VOID ixheaacd_inv_dit_fft_8pt_armv7(WORD32 *x, WORD32 *real, WORD32 *imag); + +VOID ixheaacd_inv_dit_fft_8pt_armv8(WORD32 *x, WORD32 *real, WORD32 *imag); + +#endif diff --git a/decoder/ixheaacd_env_calc.c b/decoder/ixheaacd_env_calc.c new file mode 100644 index 0000000..652e810 --- /dev/null +++ b/decoder/ixheaacd_env_calc.c @@ -0,0 +1,1829 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" + +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_freq_sca.h" + +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_env_calc.h" +#include + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_function_selector.h" + +#include "ixheaacd_audioobjtypes.h" + +#define FACTOR 0x010b0000 * 2 + +static VOID ixheaacd_alias_reduction(WORD16 *deg_patched, WORD16 *nrg_gain, + WORD16 *nrg_est, WORD8 *alias_red_buf, + WORD32 num_sub_bands, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 group, grouping, i, num_groups, k; + WORD16 f_group_vec[MAX_FREQ_COEFFS], *ptr_f_group_vec; + + grouping = 0; + i = 0; + + for (k = 0; k < num_sub_bands - 1; k++) { + if ((deg_patched[k + 1] != 0) && alias_red_buf[k]) { + if (grouping == 0) { + f_group_vec[i] = k; + grouping = 1; + i++; + } else { + if ((f_group_vec[i - 1] + 3) == k) { + f_group_vec[i] = (k + 1); + grouping = 0; + i++; + } + } + } else { + if (grouping) { + grouping = 0; + f_group_vec[i] = k; + + if (alias_red_buf[k]) f_group_vec[i] = k + 1; + + i++; + } + } + } + + if (grouping) { + f_group_vec[i] = num_sub_bands; + i++; + } + num_groups = (i >> 1); + + ptr_f_group_vec = f_group_vec; + + for (group = num_groups; group != 0; group--) { + WORD16 nrg_amp_mant; + WORD16 nrg_amp_exp; + WORD16 nrgMod_m; + WORD16 nrgMod_e; + WORD16 grp_gain_mant; + WORD16 grp_gain_exp; + WORD16 compensation_m; + WORD16 compensation_e; + WORD32 nrg_mod_mant; + WORD32 nrg_mod_exp; + + WORD32 start_grp = *ptr_f_group_vec++; + WORD32 stop_grp = *ptr_f_group_vec++; + + ixheaacd_avggain_calc(nrg_est, nrg_gain, start_grp, stop_grp, &nrg_amp_mant, + &nrg_amp_exp, &grp_gain_mant, &grp_gain_exp, + pstr_common_tables, 1); + + nrg_mod_mant = 0; + nrg_mod_exp = 0; + { + WORD16 *ptr_nrg_gain_mant = &nrg_gain[2 * start_grp]; + + for (k = start_grp; k < stop_grp; k++) { + WORD32 tmp_mant, tmp_gain_mant, gain_m; + WORD32 tmp_e, tmp_gain_exp; + WORD16 one_minus_alpha, alpha = deg_patched[k]; + + if (k < (num_sub_bands - 1)) { + alpha = ixheaacd_max16(deg_patched[k + 1], alpha); + } + gain_m = (alpha * grp_gain_mant); + one_minus_alpha = 0x7fff - alpha; + + tmp_gain_mant = *ptr_nrg_gain_mant; + tmp_gain_exp = *(ptr_nrg_gain_mant + 1); + + { + WORD32 exp_diff; + + tmp_gain_mant = (one_minus_alpha * tmp_gain_mant) >> 15; + + exp_diff = (grp_gain_exp - tmp_gain_exp); + + if (exp_diff >= 0) { + tmp_gain_exp = grp_gain_exp; + tmp_gain_mant = ixheaacd_shr32(tmp_gain_mant, exp_diff); + + tmp_gain_mant = (gain_m >> 15) + tmp_gain_mant; + + } else { + tmp_gain_mant = + (ixheaacd_shr32(gain_m, (15 - exp_diff))) + tmp_gain_mant; + } + } + *ptr_nrg_gain_mant++ = tmp_gain_mant; + *ptr_nrg_gain_mant++ = tmp_gain_exp; + + tmp_mant = (tmp_gain_mant * (nrg_est[2 * k])) >> 16; + tmp_e = (tmp_gain_exp + (nrg_est[2 * k + 1]) + 1); + + { + WORD32 exp_diff; + exp_diff = tmp_e - nrg_mod_exp; + if (exp_diff >= 0) { + nrg_mod_mant = tmp_mant + (ixheaacd_shr32(nrg_mod_mant, exp_diff)); + nrg_mod_exp = tmp_e; + } else { + exp_diff = -exp_diff; + nrg_mod_mant = (ixheaacd_shr32(tmp_mant, exp_diff)) + nrg_mod_mant; + } + } + } + } + + { + WORD32 norm_val; + norm_val = 16 - ixheaacd_pnorm32(nrg_mod_mant); + if (norm_val > 0) { + nrg_mod_mant >>= norm_val; + nrg_mod_exp += norm_val; + } + } + + nrgMod_m = (WORD16)nrg_mod_mant; + nrgMod_e = (WORD16)nrg_mod_exp; + + compensation_e = ixheaacd_fix_mant_div(nrg_amp_mant, nrgMod_m, + &compensation_m, pstr_common_tables); + compensation_e += nrg_amp_exp - nrgMod_e + 1 + 1; + + { + WORD16 *ptr_nrg_gain_mant = &nrg_gain[2 * start_grp]; + + for (k = stop_grp - start_grp; k != 0; k--) { + WORD16 temp1, temp2; + temp1 = *ptr_nrg_gain_mant; + temp2 = *(ptr_nrg_gain_mant + 1); + temp1 = (temp1 * compensation_m) >> 16; + temp2 = (temp2 + compensation_e); + *ptr_nrg_gain_mant++ = temp1; + *ptr_nrg_gain_mant++ = temp2; + } + } + } +} + +VOID ixheaacd_noiselimiting(ia_freq_band_data_struct *pstr_freq_band_data, + WORD32 skip_bands, WORD16 *ptr_enrg_orig, + WORD16 *nrg_est, WORD16 *nrg_gain, + WORD16 *noise_level_mant, WORD16 *nrg_sine, + WORD16 *ptr_limit_gain_table, FLAG noise_absc_flag, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 c, k; + WORD32 temp_val; + WORD16 limit_gain_mant = *ptr_limit_gain_table++; + WORD16 limit_gain_exp = *ptr_limit_gain_table; + for (c = 0; c < pstr_freq_band_data->num_lf_bands; c++) { + WORD16 max_gain_mant; + WORD16 sum_orig_mant, sum_orig_exp; + WORD16 max_gain_exp; + WORD32 max_temp; + WORD32 start_band = 0; + WORD32 stop_band = 0; + + if ((pstr_freq_band_data->freq_band_tbl_lim[c] > skip_bands)) { + start_band = (pstr_freq_band_data->freq_band_tbl_lim[c] - skip_bands); + } + + if ((pstr_freq_band_data->freq_band_tbl_lim[c + 1] > skip_bands)) { + stop_band = (pstr_freq_band_data->freq_band_tbl_lim[c + 1] - skip_bands); + } + + if ((start_band < stop_band)) { + ixheaacd_avggain_calc(ptr_enrg_orig, nrg_est, start_band, stop_band, + &sum_orig_mant, &sum_orig_exp, &max_gain_mant, + &max_gain_exp, pstr_common_tables, 0); + + max_temp = ixheaacd_mult16x16in32_shl(max_gain_mant, limit_gain_mant); + max_gain_exp = (max_gain_exp + limit_gain_exp); + + temp_val = ixheaacd_norm32(max_temp); + + max_gain_exp = (WORD16)(max_gain_exp - temp_val); + max_gain_mant = (WORD16)((max_temp << temp_val) >> 16); + + if ((max_gain_exp >= MAX_GAIN_EXP)) { + max_gain_mant = 0x3000; + max_gain_exp = MAX_GAIN_EXP; + } + + { + WORD16 *ptr_nrg_gain = &nrg_gain[2 * start_band]; + WORD16 *p_noise_level = &noise_level_mant[2 * start_band]; + + for (k = stop_band - start_band; k != 0; k--) { + WORD16 noise_amp_mant; + WORD16 noise_amp_exp; + + WORD16 t_gain_mant = *(ptr_nrg_gain); + WORD16 t_gain_exp = *(ptr_nrg_gain + 1); + + if (((t_gain_exp > max_gain_exp)) || + ((t_gain_exp == max_gain_exp) && (t_gain_mant > max_gain_mant))) { + noise_amp_exp = + ixheaacd_fix_mant_div(max_gain_mant, t_gain_mant, + &noise_amp_mant, pstr_common_tables); + noise_amp_exp += (max_gain_exp - t_gain_exp) + 1; + + *p_noise_level = ixheaacd_extract16h(ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult16x16in32_shl(*p_noise_level, noise_amp_mant), + noise_amp_exp)); + + *ptr_nrg_gain = max_gain_mant; + *(ptr_nrg_gain + 1) = max_gain_exp; + } + ptr_nrg_gain += 2; + p_noise_level += 2; + } + } + + { + WORD16 boost_gain_mant; + WORD16 boost_gain_exp; + WORD16 accu_m; + WORD16 accu_e; + WORD32 accu_m_t; + WORD32 accu_e_t; + WORD16 *ptr_nrg_gain = &nrg_gain[2 * start_band]; + WORD16 *ptr_enrg_est_buf = &nrg_est[2 * start_band]; + WORD16 *p_noise_level = &noise_level_mant[2 * start_band]; + WORD16 *p_nrg_sine = &nrg_sine[2 * start_band]; + + accu_m_t = 0; + accu_e_t = 0; + + for (k = stop_band - start_band; k != 0; k--) { + WORD32 tmp_mant, tmp_e; + + tmp_mant = *ptr_nrg_gain++; + tmp_e = *ptr_nrg_gain++; + tmp_mant = (tmp_mant * (*ptr_enrg_est_buf++)); + tmp_e = (tmp_e + (*ptr_enrg_est_buf++)); + tmp_mant = tmp_mant >> 15; + { + WORD32 exp_diff; + exp_diff = tmp_e - accu_e_t; + if (exp_diff >= 0) { + accu_m_t = tmp_mant + ixheaacd_shr32(accu_m_t, exp_diff); + accu_e_t = tmp_e; + } else { + exp_diff = -exp_diff; + accu_m_t = ixheaacd_shr32(tmp_mant, exp_diff) + accu_m_t; + } + } + + if (p_nrg_sine[0] != 0) { + WORD32 exp_diff = p_nrg_sine[1] - accu_e_t; + if (exp_diff >= 0) { + accu_m_t = p_nrg_sine[0] + ixheaacd_shr32(accu_m_t, exp_diff); + accu_e_t = p_nrg_sine[1]; + } else { + exp_diff = -exp_diff; + accu_m_t = accu_m_t + ixheaacd_shr32(p_nrg_sine[0], exp_diff); + } + + } else { + if (noise_absc_flag == 0) { + WORD32 exp_diff = p_noise_level[1] - accu_e_t; + if (exp_diff >= 0) { + accu_m_t = + p_noise_level[0] + ixheaacd_shr32(accu_m_t, exp_diff); + accu_e_t = p_noise_level[1]; + } else { + exp_diff = -exp_diff; + accu_m_t = + accu_m_t + ixheaacd_shr32(p_noise_level[0], exp_diff); + } + } + } + p_noise_level += 2; + p_nrg_sine += 2; + } + + { + WORD32 norm_val; + norm_val = 16 - ixheaacd_norm32(accu_m_t); + if (norm_val > 0) { + accu_m_t >>= norm_val; + accu_e_t += norm_val; + } + } + + accu_m = (WORD16)accu_m_t; + accu_e = (WORD16)accu_e_t; + + boost_gain_exp = ixheaacd_fix_mant_div( + sum_orig_mant, accu_m, &boost_gain_mant, pstr_common_tables); + + boost_gain_exp += (sum_orig_exp - accu_e) + 1; + + if ((boost_gain_exp > 2) || + ((boost_gain_exp == 2) && (boost_gain_mant > 0x5061))) { + boost_gain_mant = 0x5061; + boost_gain_exp = 2; + } + + ptr_nrg_gain = &nrg_gain[2 * start_band]; + p_noise_level = &noise_level_mant[2 * start_band]; + p_nrg_sine = &nrg_sine[2 * start_band]; + + for (k = stop_band - start_band; k != 0; k--) { + WORD16 temp1, temp2, temp3; + + temp1 = *ptr_nrg_gain; + temp2 = *p_nrg_sine; + temp3 = *p_noise_level; + + temp1 = ixheaacd_mult16_shl(temp1, boost_gain_mant); + temp2 = ixheaacd_mult16_shl(temp2, boost_gain_mant); + temp3 = ixheaacd_mult16_shl(temp3, boost_gain_mant); + *ptr_nrg_gain++ = temp1; + *p_nrg_sine++ = temp2; + *p_noise_level++ = temp3; + + temp1 = *ptr_nrg_gain; + temp2 = *p_nrg_sine; + temp3 = *p_noise_level; + + temp1 = (temp1 + boost_gain_exp); + temp2 = (temp2 + boost_gain_exp); + temp3 = (temp3 + boost_gain_exp); + *ptr_nrg_gain++ = (temp1); + *p_nrg_sine++ = (temp2); + *p_noise_level++ = (temp3); + } + } + } + } +} + +VOID ixheaacd_conv_ergtoamplitudelp_dec(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) { + WORD32 k; + for (k = 0; k < bands; k++) { + WORD32 shift; + ixheaacd_fix_mant_exp_sqrt(&nrg_sine[2 * k], sqrt_table); + ixheaacd_fix_mant_exp_sqrt(&nrg_gain[2 * k], sqrt_table); + ixheaacd_fix_mant_exp_sqrt(&noise_level_mant[2 * k], sqrt_table); + + shift = (noise_e - noise_level_mant[2 * k + 1]); + + shift = (shift - 4); + if (shift > 0) + noise_level_mant[2 * k] = (noise_level_mant[2 * k] >> shift); + else + noise_level_mant[2 * k] = (noise_level_mant[2 * k] << -shift); + + shift = (nrg_sine[2 * k + 1] - noise_e); + if (shift > 0) + nrg_sine[2 * k] = ixheaacd_shl16_sat(nrg_sine[2 * k], (WORD16)shift); + else + nrg_sine[2 * k] = ixheaacd_shr16(nrg_sine[2 * k], (WORD16)-shift); + } +} + +VOID ixheaacd_conv_ergtoamplitude_dec(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) { + WORD32 k; + for (k = 0; k < bands; k++) { + WORD32 shift; + + ixheaacd_fix_mant_exp_sqrt(&nrg_sine[2 * k], sqrt_table); + ixheaacd_fix_mant_exp_sqrt(&nrg_gain[2 * k], sqrt_table); + ixheaacd_fix_mant_exp_sqrt(&noise_level_mant[2 * k], sqrt_table); + + shift = (noise_e - noise_level_mant[2 * k + 1]); + + shift = (shift - 4); + if (shift > 0) + noise_level_mant[2 * k] = (noise_level_mant[2 * k] >> shift); + else + noise_level_mant[2 * k] = (noise_level_mant[2 * k] << -shift); + } +} + +static PLATFORM_INLINE VOID ixheaacd_adapt_noise_gain_calc( + ia_sbr_calc_env_struct *ptr_sbr_calc_env, WORD32 noise_e, + WORD32 num_sub_bands, WORD32 skip_bands, WORD16 *nrg_gain, + WORD16 *noise_level_mant, WORD16 *nrg_sine, WORD32 start_pos, + WORD32 end_pos, WORD32 input_e, WORD32 adj_e, WORD32 final_e, + WORD32 sub_band_start, WORD32 lb_scale, FLAG noise_absc_flag, + WORD32 smooth_length, WORD32 **anal_buf_real_mant, + WORD32 **anal_buf_imag_mant, WORD32 low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables) { + WORD32 l, k; + WORD32 scale_change; + WORD32 bands = num_sub_bands - skip_bands; + WORD16 *ptr_filt_buf; + WORD16 *ptr_filt_buf_noise; + WORD16 *ptr_gain = &nrg_gain[0]; + + if (ptr_sbr_calc_env->start_up) { + WORD16 *ptr_noise = noise_level_mant; + ptr_sbr_calc_env->start_up = 0; + + ptr_sbr_calc_env->filt_buf_noise_e = noise_e; + ptr_filt_buf = &ptr_sbr_calc_env->filt_buf_me[skip_bands * 2]; + ptr_filt_buf_noise = &ptr_sbr_calc_env->filt_buf_noise_m[skip_bands]; + + for (k = bands; k != 0; k--) { + WORD16 temp1 = *ptr_gain++; + WORD16 temp2 = *ptr_gain++; + WORD16 temp3 = *ptr_noise; + ptr_noise += 2; + + *ptr_filt_buf++ = temp1; + *ptr_filt_buf++ = temp2; + *ptr_filt_buf_noise++ = temp3; + } + } else { + ixheaacd_equalize_filt_buff_exp( + &ptr_sbr_calc_env->filt_buf_me[2 * skip_bands], nrg_gain, bands); + } + + for (l = start_pos; l < end_pos; l++) { + if ((l < MAX_COLS)) { + scale_change = (adj_e - input_e); + } else { + scale_change = (final_e - input_e); + + if (((l == MAX_COLS)) && ((start_pos < MAX_COLS))) { + WORD32 diff = final_e - noise_e; + noise_e = final_e; + ixheaacd_noise_level_rescaling(noise_level_mant, diff, bands, 2); + } + } + + ixheaacd_noise_level_rescaling(ptr_sbr_calc_env->filt_buf_noise_m, + ptr_sbr_calc_env->filt_buf_noise_e - noise_e, + num_sub_bands, 1); + + ptr_sbr_calc_env->filt_buf_noise_e = noise_e; + + { + WORD32 *anal_buf_real_m_l; + anal_buf_real_m_l = anal_buf_real_mant[l]; + + if (low_pow_flag) { + WORD32 index = ptr_sbr_calc_env->ph_index; + WORD32 harm_index = ptr_sbr_calc_env->harm_index; + WORD32 freq_inv_flag = (sub_band_start & 1); + WORD32 *ptr_real_buf = &anal_buf_real_m_l[sub_band_start]; + + const WORD32 *ptr_rand_ph = &ptr_sbr_tables->sbr_rand_ph[index + 1]; + + ptr_sbr_calc_env->ph_index = + (WORD16)((index + num_sub_bands) & (SBR_NF_NO_RANDOM_VAL - 1)); + ptr_sbr_calc_env->harm_index = (WORD16)(((harm_index + 1)) & 3); + + if (!(harm_index & 0x1)) { + (*ixheaacd_harm_idx_zerotwolp)( + ptr_real_buf, nrg_gain, scale_change, nrg_sine, ptr_rand_ph, + noise_level_mant, num_sub_bands, noise_absc_flag, harm_index); + } else { + WORD32 noise = (noise_e - 16) - lb_scale; + + freq_inv_flag = (!freq_inv_flag); + freq_inv_flag = (freq_inv_flag << 1) - 1; + + if (harm_index == 3) freq_inv_flag = -freq_inv_flag; + + ixheaacd_harm_idx_onethreelp(ptr_real_buf, nrg_gain, scale_change, + nrg_sine, ptr_rand_ph, noise_level_mant, + num_sub_bands, noise_absc_flag, + freq_inv_flag, noise, sub_band_start); + } + + } else { + WORD16 smooth_ratio; + WORD32 *anal_buf_imag_m_l; + anal_buf_imag_m_l = anal_buf_imag_mant[l]; + + if (((l - start_pos) < smooth_length)) { + smooth_ratio = ptr_sbr_tables->env_calc_tables_ptr + ->sbr_smooth_filter[(l - start_pos)]; + } else { + smooth_ratio = 0; + } + + ixheaacd_adj_timeslot( + &anal_buf_real_m_l[sub_band_start], + &anal_buf_imag_m_l[sub_band_start], + &ptr_sbr_calc_env->filt_buf_me[2 * skip_bands], + &ptr_sbr_calc_env->filt_buf_noise_m[skip_bands], nrg_gain, + noise_level_mant, nrg_sine, (WORD16)(noise_e - 16), + &ptr_sbr_calc_env->harm_index, (WORD16)sub_band_start, + (WORD16)(bands), (WORD16)scale_change, smooth_ratio, + noise_absc_flag, &ptr_sbr_calc_env->ph_index, ptr_sbr_tables); + } + } + } + + ixheaacd_filt_buf_update(ptr_sbr_calc_env->filt_buf_me + 2 * skip_bands, + ptr_sbr_calc_env->filt_buf_noise_m + skip_bands, + nrg_gain, noise_level_mant, bands); +} + +VOID ixheaacd_calc_subband_gains(ia_freq_band_data_struct *pstr_freq_band_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + WORD32 freq_res, WORD16 *ptr_noise_floor, + WORD32 num_sf_bands, WORD32 mvalue, WORD32 env, + WORD8 *sine_mapped_matrix, + WORD8 *alias_red_buf, WORD16 *ptr_enrg_orig, + WORD16 *nrg_sine, WORD16 *nrg_est, + WORD16 *nrg_gain, WORD16 *noise_level_mant, + FLAG noise_absc_flag, + ixheaacd_misc_tables *pstr_common_tables) { + WORD16 *ptr_freq_band_tbl = pstr_freq_band_data->freq_band_table[freq_res]; + WORD32 ui_noise = pstr_freq_band_data->freq_band_tbl_noise[1]; + WORD32 nb_idx = 0; + WORD16 tmp_noise_mant; + WORD16 tmp_noise_exp; + WORD8 *ptr_sine_mapped = sine_mapped_matrix; + WORD32 sub_band_start = pstr_freq_band_data->sub_band_start; + WORD32 skip_bands = (ptr_frame_data->max_qmf_subband_aac - sub_band_start); + WORD8 *ptr_sine_mapped_1 = &sine_mapped_matrix[skip_bands]; + WORD32 k, c = 0, j; + + WORD16 *ptr_env_sf_arr = &ptr_frame_data->int_env_sf_arr[mvalue]; + WORD8 *ptr_alias_red_buf = + &alias_red_buf[ptr_freq_band_tbl[0] - sub_band_start]; + + tmp_noise_mant = (WORD16)(ptr_noise_floor[nb_idx] & MASK_M); + tmp_noise_exp = + (WORD16)(ptr_noise_floor[nb_idx] & MASK_FOR_EXP) - NOISE_EXP_OFFSET; + + for (j = 0; j < num_sf_bands; j++) { + WORD8 sine_present_flag; + WORD16 tmp_nrg_ref_exp, tmp_nrg_ref_mant; + WORD16 li = *ptr_freq_band_tbl++; + WORD16 ui = *ptr_freq_band_tbl; + WORD16 env_sf_val = *ptr_env_sf_arr++; + + tmp_nrg_ref_exp = + (WORD16)((env_sf_val & (WORD16)MASK_FOR_EXP) - NRG_EXP_OFFSET); + tmp_nrg_ref_mant = (WORD16)(env_sf_val & MASK_M); + + sine_present_flag = 0; + for (k = li; k < ui; k++) { + if ((env >= *ptr_sine_mapped++)) sine_present_flag = 1; + } + for (k = li; k < ui; k++) { + *ptr_alias_red_buf++ = !sine_present_flag; + + if ((k >= ui_noise)) { + nb_idx++; + ui_noise = pstr_freq_band_data->freq_band_tbl_noise[nb_idx + 1]; + tmp_noise_mant = (WORD16)(ptr_noise_floor[nb_idx] & MASK_M); + tmp_noise_exp = + (WORD16)(ptr_noise_floor[nb_idx] & MASK_FOR_EXP) - NOISE_EXP_OFFSET; + } + + if ((k >= ptr_frame_data->max_qmf_subband_aac)) { + ptr_enrg_orig[2 * c] = tmp_nrg_ref_mant; + ptr_enrg_orig[2 * c + 1] = tmp_nrg_ref_exp; + nrg_sine[2 * c] = 0; + nrg_sine[2 * c + 1] = 0; + + ixheaacd_subbandgain_calc( + tmp_nrg_ref_mant, tmp_noise_mant, nrg_est[2 * c], + nrg_est[2 * c + 1], tmp_noise_exp, tmp_nrg_ref_exp, + sine_present_flag, + (env >= ptr_sine_mapped_1[c]) ? (FLAG)1 : (FLAG)0, noise_absc_flag, + &nrg_gain[2 * c], &noise_level_mant[2 * c], &nrg_sine[2 * c], + pstr_common_tables); + c++; + } + } + } +} + +#define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) + +VOID 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, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, + WORD32 **anal_buf_real_mant, WORD32 **anal_buf_imag_mant, + WORD16 *deg_patched, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables, WORD32 *ptr_qmf_matrix, + WORD32 audio_object_type) { + WORD32 i, j, m; + WORD32 noise_floor_idx; + WORD32 start_pos, end_pos; + 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; + + WORD16 *ptr_noise_floor; + ia_freq_band_data_struct *pstr_freq_band_data = + ptr_header_data->pstr_freq_band_data; + + FLAG noise_absc_flag; + WORD32 smooth_length; + + const WORD16 *num_sf_bands = pstr_freq_band_data->num_sf_bands; + const WORD32 num_nf_bands = pstr_freq_band_data->num_nf_bands; + + WORD32 sub_band_start = pstr_freq_band_data->sub_band_start; + WORD32 sub_band_end = pstr_freq_band_data->sub_band_end; + WORD32 num_sub_bands; + WORD32 skip_bands; + WORD32 bands; + + WORD num_cols; + WORD32 first_start; + + WORD16 *ptr_sbr_lim_gain; + WORD32 max_sfb_nrg_exp; + + WORD16 *ptr_enrg_orig; + + WORD32 input_e; + WORD32 ov_adj_e; + WORD32 adj_e; + WORD32 output_e; + WORD32 final_e; + WORD16 noise_e; + WORD16 lb_scale; + + WORD16 nrg_est[2 * MAX_FREQ_COEFFS]; + + WORD16 nrg_gain[2 * MAX_FREQ_COEFFS]; + WORD16 noise_level_mant[2 * MAX_FREQ_COEFFS]; + WORD16 nrg_sine[2 * MAX_FREQ_COEFFS]; + + WORD8 sine_mapped_matrix[MAX_FREQ_COEFFS]; + WORD8 alias_red_buf[64]; + + ptr_noise_floor = ptr_frame_data->int_noise_floor; + + ptr_enrg_orig = + (WORD16 *)((WORD8 *)ptr_frame_data + + ALIGN_SIZE64(sizeof(ia_sbr_frame_info_data_struct))); + + num_env = ptr_frame_data->str_frame_info_details.num_env; + ptr_border_vec = ptr_frame_data->str_frame_info_details.border_vec; + num_sub_bands = (sub_band_end - sub_band_start); + skip_bands = (ptr_frame_data->max_qmf_subband_aac - sub_band_start); + + ixheaacd_map_sineflags( + pstr_freq_band_data->freq_band_table[HIGH], + pstr_freq_band_data->num_sf_bands[HIGH], ptr_frame_data->add_harmonics, + ptr_sbr_calc_env->harm_flags_prev, + ptr_frame_data->str_frame_info_details.transient_env, sine_mapped_matrix); + + adj_e = 0; + { + WORD16 max_noise; + WORD32 first_band; + + if (ptr_frame_data_prev->max_qmf_subband_aac > + ptr_frame_data->max_qmf_subband_aac) + first_band = (ptr_frame_data_prev->max_qmf_subband_aac - sub_band_start); + else + first_band = (ptr_frame_data->max_qmf_subband_aac - sub_band_start); + + max_noise = 0; + for (i = first_band; i < num_sub_bands; i++) { + if (ptr_sbr_calc_env->filt_buf_noise_m[i] > max_noise) { + max_noise = ptr_sbr_calc_env->filt_buf_noise_m[i]; + } + } + adj_e = ((ptr_sbr_calc_env->filt_buf_noise_e - ixheaacd_norm32(max_noise)) - + 16); + } + + final_e = 0; + { + WORD16 *ptr_env_sf_buf = ptr_frame_data->int_env_sf_arr; + for (i = 0; i < num_env; i++) { + WORD32 temp_val; + + max_sfb_nrg_exp = NRG_EXP_OFFSET - SHORT_BITS; + + freq_res = ptr_frame_data->str_frame_info_details.freq_res[i]; + + for (j = 0; j < num_sf_bands[freq_res]; j++) { + temp_val = ((*ptr_env_sf_buf++ & MASK_FOR_EXP)); + + if ((temp_val > max_sfb_nrg_exp)) { + max_sfb_nrg_exp = temp_val; + } + } + + max_sfb_nrg_exp = (max_sfb_nrg_exp - NRG_EXP_OFFSET); + + temp_val = ((max_sfb_nrg_exp + 13) >> 1); + + if ((ptr_border_vec[i] < SBR_TIME_SLOTS)) { + if ((temp_val > adj_e)) { + adj_e = (WORD16)temp_val; + } + } + + if ((ptr_border_vec[i + 1] > SBR_TIME_SLOTS)) { + if ((temp_val > final_e)) { + final_e = (WORD16)temp_val; + } + } + } + } + + m = 0; + noise_floor_idx = 0; + + for (i = 0; i < num_env; i++) { + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + start_pos = ptr_border_vec[i]; + end_pos = ptr_border_vec[i + 1]; + } else { + start_pos = SBR_TIME_STEP * ptr_border_vec[i]; + end_pos = SBR_TIME_STEP * ptr_border_vec[i + 1]; + } + freq_res = ptr_frame_data->str_frame_info_details.freq_res[i]; + + if (ptr_border_vec[i] == + ptr_frame_data->str_frame_info_details + .noise_border_vec[noise_floor_idx + 1]) { + ptr_noise_floor += num_nf_bands; + noise_floor_idx++; + } + + if ((i == ptr_frame_data->str_frame_info_details.transient_env) || + (i == ptr_sbr_calc_env->tansient_env_prev)) { + noise_absc_flag = 1; + smooth_length = 0; + } else { + noise_absc_flag = 0; + smooth_length = ((1 - ptr_header_data->smoothing_mode) << 2); + } + + input_e = 15 - ptr_sbr_scale_fac->hb_scale; + + if (ptr_header_data->interpol_freq) { + (*ixheaacd_enery_calc_per_subband)( + start_pos, end_pos, ptr_frame_data->max_qmf_subband_aac, sub_band_end, + input_e, nrg_est, low_pow_flag, ptr_sbr_tables, ptr_qmf_matrix); + } else { + ixheaacd_enery_calc_persfb( + anal_buf_real_mant, anal_buf_imag_mant, num_sf_bands[freq_res], + pstr_freq_band_data->freq_band_table[freq_res], start_pos, end_pos, + ptr_frame_data->max_qmf_subband_aac, input_e, nrg_est, low_pow_flag, + ptr_sbr_tables); + } + + ixheaacd_calc_subband_gains( + pstr_freq_band_data, ptr_frame_data, freq_res, ptr_noise_floor, + num_sf_bands[freq_res], m, i, sine_mapped_matrix, alias_red_buf, + ptr_enrg_orig, nrg_sine, nrg_est, nrg_gain, noise_level_mant, + noise_absc_flag, pstr_common_tables); + + m += num_sf_bands[freq_res]; + + ptr_sbr_lim_gain = + &ptr_sbr_tables->env_calc_tables_ptr + ->sbr_lim_gains_m[2 * ptr_header_data->limiter_gains]; + ixheaacd_noiselimiting(pstr_freq_band_data, skip_bands, ptr_enrg_orig, + nrg_est, nrg_gain, noise_level_mant, nrg_sine, + ptr_sbr_lim_gain, noise_absc_flag, + pstr_common_tables); + + if (low_pow_flag) { + ixheaacd_alias_reduction(deg_patched + sub_band_start, nrg_gain, nrg_est, + alias_red_buf, num_sub_bands, + pstr_common_tables); + } + + if ((start_pos < MAX_COLS)) { + noise_e = adj_e; + } else { + noise_e = final_e; + } + + bands = num_sub_bands - skip_bands; + + if (low_pow_flag) { + (*ixheaacd_conv_ergtoamplitudelp)( + bands, noise_e, nrg_sine, nrg_gain, noise_level_mant, + (WORD16 *)pstr_common_tables->sqrt_table); + } else + + { + (*ixheaacd_conv_ergtoamplitude)(bands, noise_e, nrg_sine, nrg_gain, + noise_level_mant, + (WORD16 *)pstr_common_tables->sqrt_table); + } + + lb_scale = ixheaacd_sub16(15, ptr_sbr_scale_fac->lb_scale); + + ixheaacd_adapt_noise_gain_calc( + ptr_sbr_calc_env, noise_e, num_sub_bands, skip_bands, nrg_gain, + noise_level_mant, nrg_sine, start_pos, end_pos, input_e, adj_e, final_e, + ptr_frame_data->max_qmf_subband_aac, lb_scale, noise_absc_flag, + smooth_length, anal_buf_real_mant, anal_buf_imag_mant, low_pow_flag, + ptr_sbr_tables); + } + + first_start = ptr_border_vec[0] * SBR_TIME_STEP; + { + WORD32 ov_reserve, reserve; + + ov_reserve = reserve = 0; + + if (audio_object_type != AOT_ER_AAC_ELD) { + if (ptr_header_data->channel_mode == PS_STEREO) { + ov_reserve = (*ixheaacd_ixheaacd_expsubbandsamples)( + anal_buf_real_mant, anal_buf_imag_mant, + ptr_frame_data->max_qmf_subband_aac, sub_band_end, 0, first_start, + low_pow_flag); + + reserve = (*ixheaacd_ixheaacd_expsubbandsamples)( + anal_buf_real_mant, anal_buf_imag_mant, + ptr_frame_data->max_qmf_subband_aac, sub_band_end, first_start, + MAX_COLS, low_pow_flag); + } + } + + output_e = 0; + + ov_adj_e = 15 - ptr_sbr_scale_fac->ov_hb_scale; + + if (((ov_adj_e - ov_reserve) > (adj_e - reserve))) + output_e = (ov_adj_e - ov_reserve); + else + output_e = (adj_e - reserve); + + (*ixheaacd_adjust_scale)(anal_buf_real_mant, anal_buf_imag_mant, + ptr_frame_data->max_qmf_subband_aac, sub_band_end, + 0, first_start, (ov_adj_e - output_e), + low_pow_flag); + + num_cols = (ptr_header_data->num_time_slots * ptr_header_data->time_step); + + (*ixheaacd_adjust_scale)(anal_buf_real_mant, anal_buf_imag_mant, + ptr_frame_data->max_qmf_subband_aac, sub_band_end, + first_start, num_cols, (adj_e - output_e), + low_pow_flag); + } + + ptr_sbr_scale_fac->hb_scale = (WORD16)(15 - output_e); + + ptr_sbr_scale_fac->ov_hb_scale = (WORD16)(15 - final_e); + + if (ptr_frame_data->str_frame_info_details.transient_env == num_env) { + ptr_sbr_calc_env->tansient_env_prev = 0; + } else { + ptr_sbr_calc_env->tansient_env_prev = -1; + } +} + +VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, WORD16 *nrg_gain, + WORD32 subbands) { + WORD32 band; + WORD32 diff; + WORD32 gain_m, gain_e; + WORD32 filt_buf_mant, filt_buf_exp; + + for (band = subbands - 1; band >= 0; band--) { + filt_buf_exp = *(ptr_filt_buf + 1); + gain_e = *(nrg_gain + 1); + filt_buf_mant = *ptr_filt_buf; + gain_m = *nrg_gain; + diff = (gain_e - filt_buf_exp); + + if (diff >= 0) { + *(ptr_filt_buf + 1) = (WORD16)(gain_e); + + *ptr_filt_buf = (WORD16)(*ptr_filt_buf >> diff); + } else { + WORD32 reserve; + reserve = (ixheaacd_norm32(filt_buf_mant) - 16); + + if ((diff + reserve) >= 0) { + *ptr_filt_buf = (WORD16)(filt_buf_mant << -diff); + *(ptr_filt_buf + 1) = (WORD16)(filt_buf_exp + diff); + } else { + WORD32 shift; + + *ptr_filt_buf = (WORD16)(filt_buf_mant << reserve); + + *(ptr_filt_buf + 1) = (WORD16)(filt_buf_exp - reserve); + + shift = -(reserve + diff); + + *nrg_gain = (WORD16)(gain_m >> shift); + *(nrg_gain + 1) = (WORD16)(*(nrg_gain + 1) + shift); + } + } + nrg_gain += 2; + ptr_filt_buf += 2; + } +} + +PLATFORM_INLINE VOID ixheaacd_filt_buf_update(WORD16 *ptr_filt_buf, + WORD16 *ptr_filt_buf_noise, + WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD32 num_sub_bands) { + WORD32 k; + WORD32 temp1, temp2; + + for (k = num_sub_bands - 1; k >= 0; k--) { + temp1 = *nrg_gain; + nrg_gain += 2; + temp2 = *noise_level_mant; + noise_level_mant += 2; + + *ptr_filt_buf = temp1; + ptr_filt_buf += 2; + *ptr_filt_buf_noise++ = temp2; + } +} + +VOID ixheaacd_noise_level_rescaling(WORD16 *noise_level_mant, WORD32 diff, + WORD32 num_sub_bands, + WORD32 ixheaacd_drc_offset) { + WORD32 k; + + if (diff > 0) { + for (k = num_sub_bands - 1; k >= 0; k--) { + *noise_level_mant = *noise_level_mant >> diff; + noise_level_mant += ixheaacd_drc_offset; + } + } else if (diff < 0) { + diff = -diff; + for (k = num_sub_bands - 1; k >= 0; k--) { + *noise_level_mant = *noise_level_mant << diff; + noise_level_mant += ixheaacd_drc_offset; + } + } +} + +VOID ixheaacd_adjust_scale_dec(WORD32 **re, WORD32 **im, WORD32 sub_band_start, + WORD32 sub_band_end, WORD32 start_pos, + WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) { + WORD32 k, l; + + if (shift != 0) { + WORD32 num_sub_bands = (sub_band_end - sub_band_start); + + shift = ixheaacd_min32(shift, 31); + shift = ixheaacd_max32(shift, -31); + + if (low_pow_flag) { + if (shift > 0) { + for (l = start_pos; l < next_pos; l++) { + WORD32 *ptr = re[l] + sub_band_start; + for (k = num_sub_bands - 1; k >= 0; k--) { + *ptr = (*ptr << shift); + ptr++; + } + } + } else { + shift = -shift; + for (l = start_pos; l < next_pos; l++) { + WORD32 *ptr = re[l] + sub_band_start; + for (k = num_sub_bands - 1; k >= 0; k--) { + *ptr = (*ptr >> shift); + ptr++; + } + } + } + } else { + if (shift > 0) { + for (l = start_pos; l < next_pos; l++) { + WORD32 *ptr = re[l] + sub_band_start; + WORD32 *pti = im[l] + sub_band_start; + for (k = num_sub_bands; k > 0; k--) { + *ptr = (*ptr << shift); + *pti = (*pti << shift); + pti++; + ptr++; + } + } + } else { + shift = -shift; + for (l = start_pos; l < next_pos; l++) { + WORD32 *ptr = re[l] + sub_band_start; + WORD32 *pti = im[l] + sub_band_start; + for (k = num_sub_bands; k > 0; k--) { + *ptr = (*ptr >> shift); + *pti = (*pti >> shift); + ptr++; + pti++; + } + } + } + } + } +} + +WORD16 ixheaacd_expsubbandsamples_dec(WORD32 **re, WORD32 **im, + WORD32 sub_band_start, + WORD32 sub_band_end, WORD32 start_pos, + WORD32 next_pos, FLAG low_pow_flag) { + WORD32 l, k; + WORD16 max_shift; + + WORD32 value; + WORD32 max_abs; + WORD32 num_sub_bands; + + WORD32 *ptr_real; + WORD32 *ptr_imag; + + max_abs = 1; + num_sub_bands = (sub_band_end - sub_band_start); + + if (low_pow_flag) { + for (l = start_pos; l < next_pos; l++) { + WORD32 temp_real; + ptr_real = re[l] + sub_band_start; + temp_real = *ptr_real++; + for (k = num_sub_bands; k > 0; k--) { + value = ixheaacd_abs32_nrm(temp_real); + max_abs |= value; + temp_real = *ptr_real++; + } + } + max_shift = ixheaacd_pnorm32(max_abs); + } else { + for (l = start_pos; l < next_pos; l++) { + ptr_real = re[l] + sub_band_start; + ptr_imag = im[l] + sub_band_start; + + for (k = num_sub_bands; k > 0; k--) { + WORD32 temp_real = *ptr_real++; + WORD32 tempIm = *ptr_imag++; + + temp_real = ixheaacd_abs32_nrm(temp_real); + max_abs |= temp_real; + tempIm = ixheaacd_abs32_nrm(tempIm); + max_abs |= tempIm; + } + } + max_shift = ixheaacd_pnorm32(max_abs); + } + + return max_shift; +} + +#define SHIFT_BEFORE_SQUARE 4 + +VOID ixheaacd_enery_calc_per_subband_dec(WORD32 start_pos, WORD32 next_pos, + WORD32 sub_band_start, + WORD32 sub_band_end, WORD32 frame_exp, + WORD16 *nrg_est, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) { + WORD16 temp; + WORD16 inv_width; + WORD16 sum_m; + WORD32 accu; + WORD32 k, l; + WORD32 pre_shift_val; + WORD32 shift; + WORD32 *p_real; + WORD32 max_shift_gap = SHIFT_BEFORE_SQUARE; + WORD32 extra_shift = 0; + WORD32 num_cols = next_pos - start_pos; + + if (low_pow_flag) { + max_shift_gap -= 1; + p_real = ptr_qmf_matrix + sub_band_start + (start_pos << 6); + extra_shift++; + } else { + p_real = ptr_qmf_matrix + sub_band_start + (start_pos << 7); + num_cols = num_cols << 1; + } + inv_width = ptr_sbr_tables->env_calc_tables_ptr + ->sbr_inv_int_table[(next_pos - start_pos)]; + frame_exp = (frame_exp << 1); + + { + WORD32 *ptr; + for (k = sub_band_start; k < sub_band_end; k++) { + WORD32 max_val = 1; + + ptr = p_real; + + for (l = num_cols; l != 0; l -= 2) { + WORD32 value = ixheaacd_abs32_nrm(*ptr); + ptr += 64; + max_val = ixheaacd_max32(value, max_val); + value = ixheaacd_abs32_nrm(*ptr); + ptr += 64; + max_val = ixheaacd_max32(value, max_val); + } + pre_shift_val = (ixheaacd_pnorm32(max_val) - max_shift_gap); + + accu = 0L; + shift = 16 - pre_shift_val; + ptr = p_real; + + if (shift > 0) + for (l = num_cols; l != 0; l -= 2) { + temp = (WORD16)((*(ptr) >> shift)); + ptr += 64; + accu += (temp * temp); + temp = (WORD16)((*(ptr) >> shift)); + ptr += 64; + accu += (temp * temp); + } + else + for (l = num_cols; l != 0; l -= 2) { + temp = (WORD16)((*(ptr) << (-shift))); + ptr += 64; + accu += (temp * temp); + temp = (WORD16)((*(ptr) << (-shift))); + ptr += 64; + accu += (temp * temp); + } + + if (accu != 0L) { + shift = -(ixheaacd_pnorm32(accu)); + sum_m = (WORD16)(ixheaacd_shr32_dir_sat_limit(accu, (16 + shift))); + *nrg_est++ = ixheaacd_mult16_shl_sat(sum_m, inv_width); + shift = (shift - (pre_shift_val << 1)); + shift += extra_shift; + *nrg_est++ = (WORD16)(frame_exp + shift + 1); + } else { + *nrg_est++ = 0; + *nrg_est++ = 0; + } + + p_real++; + } + } +} + +VOID ixheaacd_enery_calc_persfb(WORD32 **anal_buf_real, WORD32 **anal_buf_imag, + WORD32 num_sf_bands, WORD16 *freq_band_table, + WORD32 start_pos, WORD32 next_pos, + WORD32 max_qmf_subband_aac, WORD32 frame_exp, + WORD16 *nrg_est, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables) { + WORD16 inv_width; + WORD32 pre_shift_val; + WORD32 shift; + WORD32 sum_e; + WORD16 sum_m; + + WORD32 j, k, l; + WORD32 li, ui; + WORD32 accu_line; + WORD32 accumulate; + WORD32 extra_shift = 10; + + inv_width = ptr_sbr_tables->env_calc_tables_ptr + ->sbr_inv_int_table[(next_pos - start_pos)]; + + frame_exp = (frame_exp << 1); + + if (low_pow_flag) extra_shift++; + + for (j = 0; j < num_sf_bands; j++) { + li = freq_band_table[j]; + + if ((li >= max_qmf_subband_aac)) { + ui = freq_band_table[j + 1]; + + pre_shift_val = (*ixheaacd_ixheaacd_expsubbandsamples)( + anal_buf_real, anal_buf_imag, li, ui, start_pos, next_pos, + low_pow_flag); + + pre_shift_val = (pre_shift_val - SHIFT_BEFORE_SQUARE); + + accumulate = 0; + + for (k = li; k < ui; k++) { + WORD32 pre_shift1 = (16 - pre_shift_val); + accu_line = 0L; + pre_shift1 = min(pre_shift1, 31); + { + WORD32 *ptr = &anal_buf_real[start_pos][k]; + WORD32 inc = !low_pow_flag; + for (l = (next_pos - start_pos) << inc; l != 0; l--) { + WORD16 temp; + temp = ixheaacd_extract16l(ixheaacd_shr32_dir(*ptr, pre_shift1)); + ptr += 64; + accu_line = ixheaacd_mac16x16in32(accu_line, temp, temp); + } + } + accumulate = + ixheaacd_add32_sat(accumulate, ixheaacd_shr32(accu_line, 9)); + } + + shift = ixheaacd_pnorm32(accumulate); + + sum_m = ixheaacd_extract16l( + ixheaacd_shr32_dir_sat_limit(accumulate, (16 - shift))); + + if (sum_m == 0) { + sum_e = 0; + } else { + sum_m = ixheaacd_mult16_shl_sat(sum_m, inv_width); + + sum_m = ixheaacd_mult16_shl_sat( + sum_m, + ptr_sbr_tables->env_calc_tables_ptr->sbr_inv_int_table[ui - li]); + + sum_e = ((frame_exp + extra_shift) - shift); + + sum_e = (sum_e - (pre_shift_val << 1)); + } + + for (k = li; k < ui; k++) { + *nrg_est++ = sum_m; + *nrg_est++ = (WORD16)sum_e; + } + } + } +} + +VOID ixheaacd_subbandgain_calc( + WORD16 e_orig_mant_matrix, WORD16 tmp_noise_mant, WORD16 nrg_est_mant, + WORD16 nrg_est_exp, WORD16 tmp_noise_exp, WORD16 nrg_ref_exp, + FLAG sine_present_flag, FLAG sine_mapped_matrix, FLAG noise_absc_flag, + WORD16 *ptr_nrg_gain_mant, WORD16 *ptr_noise_floor_mant, + WORD16 *ptr_nrg_sine_m, ixheaacd_misc_tables *pstr_common_tables) { + WORD16 var1_mant; + WORD16 var1_exp; + WORD16 var2_mant; + WORD16 var2_exp; + WORD16 var3_mant; + WORD16 var3_exp; + WORD32 temp; + + if (nrg_est_mant == 0) { + nrg_est_mant = 0x4000; + nrg_est_exp = 1; + } + + var1_mant = ixheaacd_mult16_shl_sat(e_orig_mant_matrix, tmp_noise_mant); + var1_exp = (nrg_ref_exp + tmp_noise_exp); + + { + WORD32 accu, exp_diff; + + exp_diff = tmp_noise_exp - 1; + + if (exp_diff >= 0) { + accu = tmp_noise_mant + ixheaacd_shr32(0x4000, exp_diff); + var2_exp = tmp_noise_exp; + } else { + exp_diff = -exp_diff; + accu = ixheaacd_shr32((WORD32)tmp_noise_mant, exp_diff) + 0x4000; + var2_exp = 1; + } + if (ixheaacd_abs32(accu) >= 0x8000) { + accu = accu >> 1; + var2_exp++; + } + var2_mant = (WORD16)(accu); + } + + temp = ixheaacd_fix_mant_div(var1_mant, var2_mant, ptr_noise_floor_mant, + pstr_common_tables); + *(ptr_noise_floor_mant + 1) = temp + (var1_exp - var2_exp) + 1; + + if (sine_present_flag || !noise_absc_flag) { + var3_mant = ixheaacd_mult16_shl_sat(var2_mant, nrg_est_mant); + var3_exp = (var2_exp + nrg_est_exp); + } else { + var3_mant = nrg_est_mant; + var3_exp = nrg_est_exp; + } + + if (sine_present_flag == 0) { + var1_mant = e_orig_mant_matrix; + var1_exp = nrg_ref_exp; + } + + temp = ixheaacd_fix_mant_div(var1_mant, var3_mant, ptr_nrg_gain_mant, + pstr_common_tables); + *(ptr_nrg_gain_mant + 1) = temp + (var1_exp - var3_exp) + 1; + + if (sine_present_flag && sine_mapped_matrix) { + temp = ixheaacd_fix_mant_div(e_orig_mant_matrix, var2_mant, ptr_nrg_sine_m, + pstr_common_tables); + *(ptr_nrg_sine_m + 1) = temp + (nrg_ref_exp - var2_exp) + 1; + } +} + +VOID ixheaacd_avggain_calc(WORD16 *ptr_enrg_orig, WORD16 *nrg_est, + WORD32 sub_band_start, WORD32 sub_band_end, + WORD16 *ptr_enrg_orig_mant, WORD16 *ptr_sum_ref_exp, + WORD16 *ptr_avg_gain_mant, WORD16 *ptr_avg_gain_exp, + ixheaacd_misc_tables *pstr_common_tables, + WORD32 flag) { + WORD16 sum_orig_mant; + WORD16 sum_orig_exp; + WORD16 sum_est_mant; + WORD16 sum_est_exp; + + WORD32 accu_sum_orig_mant; + WORD32 accu_sum_orig_exp; + WORD32 accu_sum_est_mant; + WORD32 accu_sum_est_exp; + + WORD32 k, temp; + WORD16 *ptr_enrg_orig_buf; + WORD16 *ptr_enrg_est_buf; + + { + accu_sum_orig_mant = 0; + accu_sum_orig_exp = 0; + + accu_sum_est_mant = 0; + accu_sum_est_exp = 0; + } + + ptr_enrg_orig_buf = &ptr_enrg_orig[sub_band_start << 1]; + ptr_enrg_est_buf = &nrg_est[sub_band_start << 1]; + + for (k = sub_band_end - sub_band_start; k != 0; k--) { + WORD16 tmp_mant, tmp_e; + WORD16 tmp2_m, tmp2_e; + + tmp_mant = *ptr_enrg_orig_buf++; + tmp_e = *ptr_enrg_orig_buf++; + tmp2_m = *ptr_enrg_est_buf++; + tmp2_e = *ptr_enrg_est_buf++; + { + WORD32 exp_diff; + exp_diff = tmp_e - accu_sum_orig_exp; + if (exp_diff >= 0) { + accu_sum_orig_mant = + tmp_mant + ixheaacd_shr32(accu_sum_orig_mant, exp_diff); + accu_sum_orig_exp = tmp_e; + } else { + exp_diff = -exp_diff; + accu_sum_orig_mant = + ixheaacd_shr32(tmp_mant, exp_diff) + accu_sum_orig_mant; + } + } + if (flag) { + tmp_mant = (tmp_mant * tmp2_m) >> 16; + tmp_e = (tmp_e + tmp2_e + 1); + + } else { + tmp_mant = tmp2_m; + tmp_e = tmp2_e; + } + + { + WORD32 exp_diff; + exp_diff = tmp_e - accu_sum_est_exp; + if (exp_diff >= 0) { + accu_sum_est_mant = + tmp_mant + ixheaacd_shr32(accu_sum_est_mant, exp_diff); + accu_sum_est_exp = tmp_e; + } else { + exp_diff = -exp_diff; + accu_sum_est_mant = + ixheaacd_shr32(tmp_mant, exp_diff) + accu_sum_est_mant; + } + } + } + { + WORD32 norm_val; + norm_val = 16 - ixheaacd_pnorm32(accu_sum_orig_mant); + if (norm_val > 0) { + accu_sum_orig_mant >>= norm_val; + accu_sum_orig_exp += norm_val; + } + norm_val = 16 - ixheaacd_pnorm32(accu_sum_est_mant); + if (norm_val > 0) { + accu_sum_est_mant >>= norm_val; + accu_sum_est_exp += norm_val; + } + } + + if (!flag) { + sum_orig_mant = (WORD16)accu_sum_orig_mant; + sum_orig_exp = (WORD16)accu_sum_orig_exp; + sum_est_mant = (WORD16)accu_sum_est_mant; + sum_est_exp = (WORD16)accu_sum_est_exp; + } else { + sum_est_mant = (WORD16)accu_sum_orig_mant; + sum_est_exp = (WORD16)accu_sum_orig_exp; + sum_orig_mant = (WORD16)accu_sum_est_mant; + sum_orig_exp = (WORD16)accu_sum_est_exp; + } + + { + temp = ixheaacd_fix_mant_div(sum_orig_mant, sum_est_mant, ptr_avg_gain_mant, + pstr_common_tables); + *ptr_avg_gain_exp = temp + (sum_orig_exp - sum_est_exp) + 1; + *ptr_enrg_orig_mant = sum_orig_mant; + *ptr_sum_ref_exp = sum_orig_exp; + } +} + +VOID ixheaacd_harm_idx_zerotwolp_dec(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, + WORD32 scale_change, + WORD16 *ptr_sine_level_buf, + const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, + WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) { + WORD32 shift, k; + WORD32 signal_real; + WORD32 sine_level; + + scale_change = scale_change - 1; + if (!noise_absc_flag) { + for (k = 0; k < num_sub_bands; k++) { + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, *ptr_gain_buf++); + shift = (*ptr_gain_buf++ - scale_change); + + if (shift > 0) + signal_real = (signal_real << shift); + else + signal_real = (signal_real >> -(shift)); + + sine_level = (ptr_sine_level_buf[2 * k] << 16); + + if (sine_level == 0) { + *ptr_real_buf++ = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(ptr_rand_ph[k]), + noise_level_mant[2 * k]); + } else if (harm_index == 0) + *ptr_real_buf++ = ixheaacd_add32_sat(signal_real, sine_level); + else + *ptr_real_buf++ = ixheaacd_sub32_sat(signal_real, sine_level); + } + } else { + for (k = 0; k < num_sub_bands; k++) { + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, *ptr_gain_buf++); + shift = (*ptr_gain_buf++ - scale_change); + + if (shift > 0) + signal_real = (signal_real << shift); + else + signal_real = (signal_real >> -(shift)); + + sine_level = (ptr_sine_level_buf[2 * k] << 16); + + if (harm_index == 0) + *ptr_real_buf++ = ixheaacd_add32_sat(signal_real, sine_level); + else + *ptr_real_buf++ = ixheaacd_sub32_sat(signal_real, sine_level); + } + } +} + +VOID ixheaacd_harm_idx_onethreelp( + WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 freq_inv_flag, WORD32 noise_e, WORD32 sub_band_start) { + WORD32 shift, k = 0; + WORD32 signal_real, temp_mult, temp_mult2; + WORD16 sine_level, sine_level_prev, sine_level_next; + WORD32 tone_count = 0; + WORD16 tmp; + + scale_change = scale_change - 1; + + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, *ptr_gain_buf++); + shift = (*ptr_gain_buf++ - scale_change); + + if (shift > 0) + signal_real = (signal_real << shift); + else + signal_real = (signal_real >> -(shift)); + + sine_level = ((ptr_sine_level_buf[2 * 0])); + + if (num_sub_bands > 1) { + sine_level_next = ((ptr_sine_level_buf[2 * 1])); + } else { + sine_level_next = 0; + } + + if (ptr_sine_level_buf[2 * 0] != 0) { + tone_count++; + } else { + if (!noise_absc_flag) { + signal_real = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(ptr_rand_ph[k]), *noise_level_mant); + } + } + + noise_level_mant += 2; + temp_mult2 = ixheaacd_mult32x16in32(FACTOR, sine_level_next); + temp_mult = ixheaacd_mult32x16in32(FACTOR, sine_level); + tmp = noise_e; + + if (tmp > 0) { + temp_mult = ixheaacd_shl32(temp_mult, tmp); + } else { + temp_mult = ixheaacd_shr32(temp_mult, -tmp); + } + + if (freq_inv_flag < 0) { + *(ptr_real_buf - 1) = ixheaacd_add32_sat(*(ptr_real_buf - 1), temp_mult); + signal_real = ixheaacd_sub32_sat(signal_real, temp_mult2); + } else { + *(ptr_real_buf - 1) = ixheaacd_sub32_sat(*(ptr_real_buf - 1), temp_mult); + signal_real = ixheaacd_add32_sat(signal_real, temp_mult2); + } + *ptr_real_buf++ = signal_real; + + num_sub_bands = num_sub_bands - 1; + for (k = 1; k < num_sub_bands; k++) { + WORD16 gain_m = *ptr_gain_buf++; + WORD16 gain_e = *ptr_gain_buf++; + WORD32 q_real = *ptr_real_buf; + + signal_real = ixheaacd_mult32x16in32(q_real, gain_m); + + if ((shift = (gain_e - scale_change)) >= 0) + signal_real = (signal_real << shift); + else + signal_real = (signal_real >> -(shift)); + + sine_level_prev = sine_level; + sine_level = sine_level_next; + if (sine_level != 0) { + tone_count++; + } + sine_level_next = (ptr_sine_level_buf[2 * (k + 1)]); + + if ((!noise_absc_flag) && (sine_level == 0)) { + signal_real = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(ptr_rand_ph[k]), *noise_level_mant); + } + noise_level_mant += 2; + + if (tone_count <= 16) { + WORD32 temp_mult; + WORD32 add_sine = ixheaacd_mult32x16in32( + FACTOR, ixheaacd_sub16(sine_level_prev, sine_level_next)); + temp_mult = add_sine * freq_inv_flag; + signal_real = ixheaacd_add32_sat(signal_real, temp_mult); + } + *ptr_real_buf++ = signal_real; + freq_inv_flag = -(freq_inv_flag); + } + + freq_inv_flag = (freq_inv_flag + 1) >> 1; + + if (num_sub_bands > 0) { + WORD32 temp_mult_sine; + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, *ptr_gain_buf++); + shift = (*ptr_gain_buf - scale_change); + + if (shift > 0) + signal_real = (signal_real << shift); + else + signal_real = (signal_real >> -(shift)); + + temp_mult_sine = ixheaacd_mult32x16in32(FACTOR, sine_level); + sine_level = sine_level_next; + + if (sine_level != 0) { + tone_count++; + } else { + if (!noise_absc_flag) { + signal_real = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(ptr_rand_ph[k]), + *noise_level_mant); + } + } + + if (tone_count <= 16) { + temp_mult2 = ixheaacd_mult32x16in32(FACTOR, sine_level); + + if (freq_inv_flag) { + *ptr_real_buf++ = ixheaacd_add32_sat(signal_real, temp_mult_sine); + + if ((k + sub_band_start) < 62) { + *ptr_real_buf = ixheaacd_sub32_sat(*ptr_real_buf, temp_mult2); + } + } else { + *ptr_real_buf++ = ixheaacd_sub32_sat(signal_real, temp_mult_sine); + + if ((k + sub_band_start) < 62) { + *ptr_real_buf = ixheaacd_add32_sat(*ptr_real_buf, temp_mult2); + } + } + } else { + *ptr_real_buf = signal_real; + } + } +} + +VOID ixheaacd_harm_idx_zerotwo(FLAG noise_absc_flag, WORD16 num_sub_bands, + WORD32 *ptr_real_buf, WORD32 *ptr_imag, + WORD16 *smoothed_gain, WORD16 *smoothed_noise, + WORD32 factor, WORD16 *ptr_gain_buf, + WORD16 scale_change, const WORD32 *ptr_rand_ph, + WORD16 *ptr_sine_level_buf, WORD16 noise_e, + WORD32 harm_index) { + WORD32 k; + WORD32 signal_real, sig_imag; + WORD32 shift; + WORD32 sine_level; + ptr_gain_buf++; + + for (k = 0; k < num_sub_bands; k++) { + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, smoothed_gain[0]); + sig_imag = ixheaacd_mult32x16in32(*ptr_imag, smoothed_gain[0]); + + shift = ixheaacd_sub16(*ptr_gain_buf, scale_change); + ptr_gain_buf += 2; + + if (shift > 0) { + signal_real = ixheaacd_shl32(signal_real, shift); + sig_imag = ixheaacd_shl32(sig_imag, shift); + } else { + shift = -shift; + signal_real = ixheaacd_shr32(signal_real, shift); + sig_imag = ixheaacd_shr32(sig_imag, shift); + } + + ptr_rand_ph++; + + if (*ptr_sine_level_buf != 0) { + WORD32 tmp = ixheaacd_sub16(ptr_sine_level_buf[1], noise_e); + + if (tmp > 0) + sine_level = ixheaacd_shl32(ptr_sine_level_buf[0], tmp); + else + sine_level = ixheaacd_shr32(ptr_sine_level_buf[0], tmp); + + if (harm_index == 0) + *ptr_real_buf = ixheaacd_add32_sat(signal_real, sine_level); + else + *ptr_real_buf = ixheaacd_sub32_sat(signal_real, sine_level); + + *ptr_imag = sig_imag; + } else { + if (!noise_absc_flag) { + WORD32 random = *ptr_rand_ph; + WORD16 noise = smoothed_noise[0]; + + *ptr_real_buf = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(random), noise); + *ptr_imag = ixheaacd_mac16x16in32_shl( + sig_imag, ixheaacd_extract16l(random), noise); + } else { + *ptr_real_buf = signal_real; + *ptr_imag = sig_imag; + } + } + + smoothed_noise += factor; + smoothed_gain += 2; + ptr_sine_level_buf += 2; + ptr_real_buf++; + ptr_imag++; + } +} + +VOID ixheaacd_harm_idx_onethree(FLAG noise_absc_flag, WORD16 num_sub_bands, + WORD32 *ptr_real_buf, WORD32 *ptr_imag, + WORD16 *smoothed_gain, WORD16 *smoothed_noise, + WORD32 factor, WORD16 *ptr_gain_buf, + WORD16 scale_change, const WORD32 *ptr_rand_ph, + WORD16 *ptr_sine_level_buf, WORD16 noise_e, + WORD32 freq_inv_flag, WORD32 harm_index) { + WORD32 k; + WORD32 signal_real, sig_imag; + WORD32 shift; + WORD32 sine_level; + + ptr_gain_buf++; + + if (harm_index == 1) freq_inv_flag = !freq_inv_flag; + + for (k = 0; k < num_sub_bands; k++) { + signal_real = ixheaacd_mult32x16in32(*ptr_real_buf, smoothed_gain[0]); + sig_imag = ixheaacd_mult32x16in32(*ptr_imag, smoothed_gain[0]); + + shift = ixheaacd_sub16(*ptr_gain_buf, scale_change); + ptr_gain_buf += 2; + + if (shift > 0) { + signal_real = ixheaacd_shl32(signal_real, shift); + sig_imag = ixheaacd_shl32(sig_imag, shift); + } else { + shift = -shift; + signal_real = ixheaacd_shr32(signal_real, shift); + sig_imag = ixheaacd_shr32(sig_imag, shift); + } + + ptr_rand_ph++; + + if (*ptr_sine_level_buf != 0) { + WORD32 tmp = ixheaacd_sub16(ptr_sine_level_buf[1], noise_e); + + if (tmp > 0) + sine_level = ixheaacd_shl32(ptr_sine_level_buf[0], tmp); + else + sine_level = ixheaacd_shr32(ptr_sine_level_buf[0], -tmp); + + *ptr_real_buf = signal_real; + + if (freq_inv_flag) { + *ptr_imag = ixheaacd_add32_sat(sig_imag, sine_level); + } else { + *ptr_imag = ixheaacd_sub32_sat(sig_imag, sine_level); + } + + } else { + if (!noise_absc_flag) { + WORD32 random = *ptr_rand_ph; + WORD16 noise = smoothed_noise[0]; + + *ptr_real_buf = ixheaacd_mac16x16in32_shl( + signal_real, ixheaacd_extract16h(random), noise); + *ptr_imag = ixheaacd_mac16x16in32_shl( + sig_imag, ixheaacd_extract16l(random), noise); + } else { + *ptr_real_buf = signal_real; + *ptr_imag = sig_imag; + } + } + + freq_inv_flag = (!freq_inv_flag); + smoothed_gain += 2; + smoothed_noise += factor; + ptr_sine_level_buf += 2; + ptr_real_buf++; + ptr_imag++; + } +} diff --git a/decoder/ixheaacd_env_calc.h b/decoder/ixheaacd_env_calc.h new file mode 100644 index 0000000..8b03ade --- /dev/null +++ b/decoder/ixheaacd_env_calc.h @@ -0,0 +1,191 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ENV_CALC_H +#define IXHEAACD_ENV_CALC_H + +typedef struct { + WORD16 *filt_buf_me; + WORD16 *filt_buf_noise_m; + WORD32 filt_buf_noise_e; + FLAG start_up; + WORD16 ph_index; + WORD16 tansient_env_prev; + WORD8 harm_flags_prev[MAX_FREQ_COEFFS]; + WORD16 harm_index; +} ia_sbr_calc_env_struct; + +VOID 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, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_prev_frame_data, + WORD32 **anal_buf_real_mant, WORD32 **anal_buf_imag_mant, + WORD16 *degree_alias, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables, WORD32 *ptr_qmf_matrix, + WORD32 audio_object_type); + +VOID ixheaacd_reset_sbrenvelope_calc(ia_sbr_calc_env_struct *ptr_calc_env); + +WORD32 ixheaacd_derive_lim_band_tbl( + ia_sbr_header_data_struct *ptr_header_data, + const ia_patch_param_struct *p_str_patch_param, WORD16 num_patches, + ixheaacd_misc_tables *pstr_common_tables); + +PLATFORM_INLINE VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, + WORD16 *nrg_gain_mant, + WORD32 subbands); + +PLATFORM_INLINE VOID ixheaacd_filt_buf_update(WORD16 *filt_buf_mant, + WORD16 *ptr_filt_buf_noise, + WORD16 *nrg_gain_mant, + WORD16 *noise_level_mant, + WORD32 num_sub_bands); + +VOID ixheaacd_noise_level_rescaling(WORD16 *noise_level_mant, WORD32 diff, + WORD32 num_sub_bands, + WORD32 ixheaacd_drc_offset); + +VOID ixheaacd_enery_calc_persfb(WORD32 **anal_buf_real, WORD32 **anal_buf_imag, + WORD32 num_sf_bands, WORD16 *freq_band_table, + WORD32 start_pos, WORD32 next_pos, + WORD32 max_qmf_subband_aac, WORD32 frame_exp, + WORD16 *nrg_est_m, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables); + + +VOID ixheaacd_avggain_calc(WORD16 *ptr_enrg_orig, WORD16 *nrg_est, + WORD32 sub_band_start, WORD32 sub_band_end, + WORD16 *sum_orig_mant, WORD16 *sum_orig_exp, + WORD16 *ptr_avg_gain_mant, WORD16 *ptr_avg_gain_exp, + ixheaacd_misc_tables *pstr_common_tables, + WORD32 flag); + +VOID ixheaacd_adj_timeslot(WORD32 *ptr_buf_real, WORD32 *ptr_buf_imag, + WORD16 *ptr_filt_buf, WORD16 *ptr_filt_buf_noise, + WORD16 *ptr_gain_buf, WORD16 *ptr_noise_floor, + WORD16 *ptr_sine_lvl_buf, WORD16 noise_floor_exp, + WORD16 *ptr_harm_index, WORD16 sub_band_start, + WORD16 num_sub_bands, WORD16 scale_change, + WORD16 smooth_ratio, FLAG num_noise_flg, + WORD16 *ptr_phase_index, + ia_sbr_tables_struct *ptr_sbr_tables); + +VOID ixheaacd_map_sineflags(WORD16 *freq_band_table, WORD16 num_sf_bands, + FLAG *add_harmonics, WORD8 *harm_flags_prev, + WORD16 transient_env, WORD8 *sine_mapped_matrix); + +VOID ixheaacd_adjust_scale_dec(WORD32 **re, WORD32 **im, WORD sub_band_start, + WORD num_sub_bands, WORD start_pos, + WORD next_pos, WORD shift, FLAG low_pow_flag); + +VOID ixheaacd_adjust_scale_armv7(WORD32 **re, WORD32 **im, WORD sub_band_start, + WORD num_sub_bands, WORD start_pos, + WORD next_pos, WORD shift, FLAG low_pow_flag); + +WORD16 ixheaacd_expsubbandsamples_dec(WORD32 **anal_buf_real_mant, + WORD32 **anal_buf_imag_mant, + WORD sub_band_start, WORD sub_band_end, + WORD start_pos, WORD end_pos, + FLAG low_pow_flag); + +WORD16 ixheaacd_expsubbandsamples_armv7(WORD32 **anal_buf_real_mant, + WORD32 **anal_buf_imag_mant, + WORD sub_band_start, WORD sub_band_end, + WORD start_pos, WORD end_pos, + FLAG low_pow_flag); + +VOID ixheaacd_enery_calc_per_subband_dec(WORD32 start_pos, WORD32 next_pos, + WORD32 sub_band_start, + WORD32 sub_band_end, WORD32 frame_exp, + WORD16 *nrg_est_mant, + FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix); + +VOID ixheaacd_enery_calc_per_subband_armv7( + WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, + WORD32 sub_band_end, WORD32 frame_exp, WORD16 *nrg_est_mant, + FLAG low_pow_flag, ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix); + +WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *hf_generator, + ia_sbr_header_data_struct *ptr_header_data, + WORD audio_obj_type); + +VOID ixheaacd_harm_idx_zerotwolp_dec(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, + WORD scale_change, + WORD16 *ptr_sine_level_buf, + const WORD32 *ptr_rand_ph, + WORD16 *noise_lvl_me, WORD num_sub_bands, + FLAG noise_absc_flag, WORD32 harm_index); + +VOID ixheaacd_harm_idx_zerotwolp_armv7(WORD32 *ptr_real_buf, + WORD16 *ptr_gain_buf, WORD scale_change, + WORD16 *ptr_sine_level_buf, + const WORD32 *ptr_rand_ph, + WORD16 *noise_lvl_me, WORD num_sub_bands, + FLAG noise_absc_flag, WORD32 harm_index); + +VOID ixheaacd_harm_idx_onethreelp(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, + WORD scale_change, WORD16 *ptr_sine_level_buf, + const WORD32 *ptr_rand_ph, + WORD16 *noise_lvl_me, WORD num_sub_bands, + FLAG noise_absc_flag, WORD freq_inv_flag, + WORD noise_e, WORD sub_band_start); + +VOID ixheaacd_conv_ergtoamplitudelp_dec(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table); + +VOID ixheaacd_conv_ergtoamplitudelp_armv7(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table); + +VOID ixheaacd_conv_ergtoamplitude_dec(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table); + +VOID ixheaacd_conv_ergtoamplitude_armv7(WORD32 bands, WORD16 noise_e, + WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table); + + VOID ixheaacd_subbandgain_calc( + WORD16 e_orig_mant_matrix, WORD16 tmp_noise_mant, WORD16 nrg_est_mant, + WORD16 nrg_est_exp, WORD16 tmp_noise_exp, WORD16 nrg_ref_exp, + FLAG sine_present_flag, FLAG sine_mapped_matrix, FLAG noise_absc_flag, + WORD16 *ptr_nrg_gain_mant, WORD16 *ptr_noise_floor_mant, + WORD16 *ptr_nrg_sine_m, ixheaacd_misc_tables *pstr_common_tables); +PLATFORM_INLINE VOID ixheaacd_filt_buf_update(WORD16 *ptr_filt_buf, + WORD16 *ptr_filt_buf_noise, + WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD32 num_sub_bands); + +PLATFORM_INLINE VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, + WORD16 *nrg_gain, + WORD32 subbands); + +#endif diff --git a/decoder/ixheaacd_env_dec.c b/decoder/ixheaacd_env_dec.c new file mode 100644 index 0000000..ae39456 --- /dev/null +++ b/decoder/ixheaacd_env_dec.c @@ -0,0 +1,799 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#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 +#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)) + +#define mult16x16_16(a, b) ixheaacd_mult16((a), (b)) + +static VOID ixheaacd_dequant_esbr_env_data(FLOAT32 *ptr_env_sf, + WORD32 num_env_sf, + WORD32 num_noise_fac, WORD32 amp_res, + FLOAT32 *ptr_noise_floor) { + WORD32 i; + FLOAT32 array[2] = {0.5f, 1.0f}; + FLOAT32 a_flt = array[amp_res]; + + for (i = 0; i < num_env_sf; i++) { + ptr_env_sf[i] = (FLOAT32)(pow(2, ptr_env_sf[i] * a_flt) * 64); + } + + for (i = 0; i < num_noise_fac; i++) { + FLOAT32 temp = ptr_noise_floor[i]; + + temp = NOISE_FLOOR_OFFSET - temp; + temp = (FLOAT32)pow(2.0f, temp); + + ptr_noise_floor[i] = temp; + } +} + +static VOID ixheaacd_dequant_pvc_env_data(WORD32 num_noise_fac, + FLOAT32 *ptr_noise_floor) { + WORD32 i; + + for (i = 0; i < num_noise_fac; i++) { + FLOAT32 temp = ptr_noise_floor[i]; + + temp = NOISE_FLOOR_OFFSET - temp; + temp = (FLOAT32)pow(2.0f, temp); + + ptr_noise_floor[i] = temp; + } +} + +VOID ixheaacd_map_res_energy(WORD16 curr_val, WORD16 *prev_data, + WORD32 ixheaacd_drc_offset, WORD32 index, + WORD32 res) { + if (res == LOW) { + if (ixheaacd_drc_offset >= 0) { + if (index < ixheaacd_drc_offset) { + prev_data[index] = curr_val; + } else { + WORD32 index_2; + index_2 = ((index + index) - ixheaacd_drc_offset); + prev_data[index_2] = curr_val; + prev_data[index_2 + 1] = curr_val; + } + } else { + ixheaacd_drc_offset = -(ixheaacd_drc_offset); + + if (index < ixheaacd_drc_offset) { + WORD32 index_3; + index_3 = ((index + index) + index); + prev_data[index_3] = curr_val; + prev_data[index_3 + 1] = curr_val; + prev_data[index_3 + 2] = curr_val; + } else { + WORD32 index_2; + index_2 = ((index + index) + ixheaacd_drc_offset); + prev_data[index_2] = curr_val; + prev_data[index_2 + 1] = curr_val; + } + } + } else { + prev_data[index] = curr_val; + } +} + +VOID ixheaacd_process_del_cod_env_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data) { + WORD32 i, dtdf_dir, num_sf_bands, band, freq_res; + WORD16 temp_val; + WORD16 *ptr_prev_env_sf = ptr_prev_data->sfb_nrg_prev; + WORD16 *ptr_env_sf = ptr_sbr_data->int_env_sf_arr; + + FLOAT32 *ptr_env_sf_float = ptr_sbr_data->flt_env_sf_arr; + + WORD32 ixheaacd_drc_offset; + band = 0; + + ixheaacd_drc_offset = + ((ptr_header_data->pstr_freq_band_data->num_sf_bands[LOW] << 1) - + ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]); + + for (i = 0; i < ptr_sbr_data->str_frame_info_details.num_env; i++) { + dtdf_dir = ptr_sbr_data->del_cod_dir_arr[i]; + freq_res = ptr_sbr_data->str_frame_info_details.freq_res[i]; + + num_sf_bands = ptr_header_data->pstr_freq_band_data->num_sf_bands[freq_res]; + + if (dtdf_dir == DTDF_DIR_FREQ) { + ixheaacd_map_res_energy(*ptr_env_sf, ptr_prev_env_sf, ixheaacd_drc_offset, + 0, freq_res); + ptr_env_sf++; + + ptr_env_sf_float++; + + for (band = 1; band < num_sf_bands; band++) { + *ptr_env_sf = *ptr_env_sf + *(ptr_env_sf - 1); + ixheaacd_map_res_energy(*ptr_env_sf, ptr_prev_env_sf, + ixheaacd_drc_offset, band, freq_res); + + *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf); + ptr_env_sf_float++; + + ptr_env_sf++; + } + + } else { + if (freq_res == LOW) { + if (ixheaacd_drc_offset < 0) { + WORD32 tar, index_3; + ixheaacd_drc_offset = -ixheaacd_drc_offset; + tar = ixheaacd_min32(ixheaacd_drc_offset, band); + + for (band = 0; band < tar; band++) { + index_3 = ((band + band) + band); + temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_3]); + + ptr_prev_env_sf[index_3] = temp_val; + ptr_prev_env_sf[index_3 + 1] = temp_val; + ptr_prev_env_sf[index_3 + 2] = temp_val; + *ptr_env_sf++ = temp_val; + + *ptr_env_sf_float = (FLOAT32)temp_val; + ptr_env_sf_float++; + } + + for (; band < num_sf_bands; band++) { + index_3 = (band << 1) + ixheaacd_drc_offset; + temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_3]); + ptr_prev_env_sf[index_3] = temp_val; + ptr_prev_env_sf[index_3 + 1] = temp_val; + *ptr_env_sf++ = temp_val; + *ptr_env_sf_float = (FLOAT32)temp_val; + ptr_env_sf_float++; + } + } else { + WORD32 tar, index_2; + WORD16 *ptr2 = ptr_prev_env_sf; + tar = ixheaacd_min32(ixheaacd_drc_offset, band); + for (band = 0; band < tar; band++) { + *ptr_env_sf = add16_m(*ptr_env_sf, *ptr2); + *ptr2 = *ptr_env_sf; + + *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf); + ptr_env_sf_float++; + + ptr2++; + ptr_env_sf++; + } + + for (; band < num_sf_bands; band++) { + index_2 = (band < ixheaacd_drc_offset) + ? band + : ((band << 1) - ixheaacd_drc_offset); + temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_2]); + ptr_prev_env_sf[index_2] = temp_val; + ptr_prev_env_sf[index_2 + 1] = temp_val; + *ptr_env_sf++ = temp_val; + + *ptr_env_sf_float = (FLOAT32)temp_val; + ptr_env_sf_float++; + } + } + + } else { + WORD16 *ptr2 = ptr_prev_env_sf; + for (band = num_sf_bands - 1; band >= 0; band--) { + *ptr_env_sf = add16_m(*ptr_env_sf, *ptr2); + *ptr2 = *ptr_env_sf; + *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf); + ptr_env_sf_float++; + ptr2++; + ptr_env_sf++; + } + band = num_sf_bands; + } + } + } +} + +static PLATFORM_INLINE VOID +ixheaacd_wrong_timing_compensate(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 i, num_env_sf; + ia_frame_info_struct *p_frame_info = &ptr_sbr_data->str_frame_info_details; + WORD16 *num_sf_bands = ptr_header_data->pstr_freq_band_data->num_sf_bands; + WORD32 start_pos_est; + WORD32 ref_len, new_len, shift; + WORD16 delta_exp; + + start_pos_est = + (ptr_prev_data->end_position - ptr_header_data->num_time_slots); + + ref_len = (p_frame_info->border_vec[1] - p_frame_info->border_vec[0]); + + new_len = (p_frame_info->border_vec[1] - start_pos_est); + + if (new_len <= 0) { + new_len = ref_len; + start_pos_est = p_frame_info->border_vec[0]; + } + + delta_exp = pstr_common_tables->log_dual_is_table[ref_len]; + delta_exp -= pstr_common_tables->log_dual_is_table[new_len]; + + shift = (SHORT_BITS - ENV_EXP_FRACT - 3 - ptr_sbr_data->amp_res); + delta_exp = ixheaacd_shr16(delta_exp, (WORD16)shift); + p_frame_info->border_vec[0] = start_pos_est; + p_frame_info->noise_border_vec[0] = start_pos_est; + + if (ptr_sbr_data->coupling_mode != COUPLING_BAL) { + num_env_sf = + ((p_frame_info->freq_res[0]) ? num_sf_bands[HIGH] : num_sf_bands[LOW]); + + for (i = 0; i < num_env_sf; i++) { + ptr_sbr_data->int_env_sf_arr[i] = + add16_m(ptr_sbr_data->int_env_sf_arr[i], delta_exp); + } + } +} + +WORD16 ixheaacd_check_env_data(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data) { + WORD16 *ptr_evn_sf = ptr_sbr_data->int_env_sf_arr; + WORD16 *ptr_prev_evn_sf = ptr_prev_data->sfb_nrg_prev; + WORD32 i; + FLAG error_code = 0; + WORD16 sbr_max_env_sf; + WORD32 amp_res = ptr_sbr_data->amp_res; + + sbr_max_env_sf = (SBR_ENV_SF_MAX_VAL_1_5 >> amp_res); + + for (i = 0; i < ptr_sbr_data->num_env_sfac; i++) { + if (ptr_evn_sf[i] > sbr_max_env_sf) { + error_code = 1; + } + if (ptr_evn_sf[i] < 0) { + ptr_evn_sf[i] = 0; + } + } + + for (i = 0; i < ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]; + i++) { + if (ptr_prev_evn_sf[i] < 0) { + ptr_prev_evn_sf[i] = 0; + } else { + if (ptr_prev_evn_sf[i] > sbr_max_env_sf) + ptr_prev_evn_sf[i] = sbr_max_env_sf; + } + } + return (WORD16)(error_code); +} + +VOID ixheaacd_dequant_env_data(ia_sbr_frame_info_data_struct *ptr_sbr_data, + WORD32 amp_res) { + WORD32 i; + WORD32 num_env_sf = ptr_sbr_data->num_env_sfac; + WORD32 mantissa; + WORD32 amp_res_1; + 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}; + + amp_res_1 = (1 - amp_res); + + for (i = num_env_sf - 1; i >= 0; i--) { + exponent = *ptr_env_sf; + mantissa = mant_arr[(exponent & amp_res_1)]; + exponent = (exponent >> amp_res_1); + exponent = (exponent + exp_add); + *ptr_env_sf++ = (WORD16)(mantissa | (exponent & MASK_FOR_EXP)); + } +} + +static PLATFORM_INLINE VOID +ixheaacd_limit_noise_floor_fac(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data) { + WORD32 i, tot_nf_bands; + WORD32 value; + WORD32 num_nf_bands; + WORD16 *ptr_noise_floor; + + num_nf_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands; + + tot_nf_bands = + ptr_sbr_data->str_frame_info_details.num_noise_env * num_nf_bands; + + ptr_noise_floor = ptr_sbr_data->int_noise_floor; + + for (i = tot_nf_bands - 1; i >= 0; i--) { + value = *ptr_noise_floor; + if (value > MAX_NOISE_FLOOR_FAC_VAL) { + *ptr_noise_floor = MAX_NOISE_FLOOR_FAC_VAL; + } else { + if (value < MIN_NOISE_FLOOR_FAC_VAL) { + *ptr_noise_floor = MIN_NOISE_FLOOR_FAC_VAL; + } + } + ptr_noise_floor++; + } +} + +VOID ixheaacd_add_arr(WORD16 *ptr1, WORD16 *ptr2, WORD32 num) { + WORD32 i; + for (i = num - 1; i >= 0; i--) { + *ptr2 = (*ptr2 + *ptr1); + ptr2++; + ptr1++; + } +} + +VOID ixheaacd_calc_noise_floor(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data) { + WORD32 i; + WORD32 num_nf_bands; + WORD32 num_noise_env; + WORD32 ixheaacd_drc_offset; + WORD16 *ptr_noise_floor = ptr_sbr_data->int_noise_floor; + + WORD16 *ptr_prev_noise_floor = ptr_prev_data->prev_noise_level; + WORD16 *ptr1, *ptr2; + WORD32 num; + FLOAT32 *ptr_noise_floor_float = ptr_sbr_data->flt_noise_floor; + + num_nf_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands; + num_noise_env = ptr_sbr_data->str_frame_info_details.num_noise_env; + + if (ptr_sbr_data->del_cod_dir_noise_arr[0] == DTDF_DIR_FREQ) { + ptr1 = ptr_noise_floor++; + ptr2 = ptr_noise_floor; + num = num_nf_bands - 1; + } else { + ptr1 = ptr_prev_noise_floor; + ptr2 = ptr_sbr_data->int_noise_floor; + num = num_nf_bands; + } + + ixheaacd_add_arr(ptr1, ptr2, num); + + if (num_noise_env > 1) { + if (ptr_sbr_data->del_cod_dir_noise_arr[1] == DTDF_DIR_FREQ) { + ptr1 = &ptr_sbr_data->int_noise_floor[num_nf_bands]; + ptr2 = &ptr_sbr_data->int_noise_floor[(num_nf_bands + 1)]; + + num = num_nf_bands - 1; + } else { + ptr1 = &ptr_sbr_data->int_noise_floor[0]; + ptr2 = &ptr_sbr_data->int_noise_floor[num_nf_bands]; + + num = num_nf_bands; + } + ixheaacd_add_arr(ptr1, ptr2, num); + } + + ixheaacd_limit_noise_floor_fac(ptr_header_data, ptr_sbr_data); + + ixheaacd_drc_offset = num_nf_bands * (num_noise_env - 1); + ptr1 = &ptr_sbr_data->int_noise_floor[ixheaacd_drc_offset]; + ptr2 = ptr_prev_noise_floor; + + memcpy(ptr2, ptr1, sizeof(WORD16) * (num_nf_bands)); + + if (ptr_sbr_data->coupling_mode != COUPLING_BAL) { + WORD32 noise_floor_exp, tot_nf_bands; + + tot_nf_bands = (num_nf_bands * num_noise_env); + ptr_noise_floor = &ptr_sbr_data->int_noise_floor[0]; + + for (i = 0; i < tot_nf_bands; i++) { + noise_floor_exp = + (NOISE_FLOOR_OFFSET_INT + 1 + NOISE_EXP_OFFSET - *ptr_noise_floor); + + *ptr_noise_floor_float++ = *ptr_noise_floor; + *ptr_noise_floor++ = (WORD16)(0x4000 + (noise_floor_exp & MASK_FOR_EXP)); + } + } +} + +VOID ixheaacd_dec_sbrdata_for_pvc( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data) { + ixheaacd_calc_noise_floor(ptr_header_data, ptr_sbr_data, ptr_prev_data); + + if (!ptr_sbr_data->coupling_mode) { + ptr_sbr_data->num_noise_sfac = + ptr_header_data->pstr_freq_band_data->num_nf_bands * + ptr_sbr_data->str_frame_info_details.num_noise_env; + ixheaacd_dequant_pvc_env_data(ptr_sbr_data->num_noise_sfac, + ptr_sbr_data->flt_noise_floor); + } +} + +VOID ixheaacd_sbr_env_dequant_coup_fix( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_data_left, + ia_sbr_frame_info_data_struct *ptr_data_right, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 i; + WORD32 num_env_sf = ptr_data_left->num_env_sfac; + WORD16 temp_left_mant, temp_right_mant, temp_right_plus1_mant, new_left_mant, + new_right_mant; + WORD16 temp_left_exp, temp_right_exp, temp_rightplus1_exp, new_left_exp, + new_right_exp; + WORD32 i_end; + WORD16 *r_data = ptr_data_right->int_env_sf_arr; + WORD16 *l_data = ptr_data_left->int_env_sf_arr; + + for (i = 0; i < num_env_sf; i++) { + temp_right_mant = (WORD16)(*r_data & MASK_M); + temp_right_exp = (WORD16)(*r_data & MASK_FOR_EXP); + + temp_right_exp = sub16_m(temp_right_exp, add16_m(18, NRG_EXP_OFFSET)); + temp_left_mant = (WORD16)(*l_data & MASK_M); + temp_left_exp = (WORD16)(*l_data & MASK_FOR_EXP); + + temp_left_exp = sub16_m(temp_left_exp, NRG_EXP_OFFSET); + + ixheaacd_fix_mant_exp_add(temp_right_mant, temp_right_exp, 0x4000, 1, + &temp_right_plus1_mant, &temp_rightplus1_exp); + + new_right_exp = ixheaacd_fix_mant_div(temp_left_mant, temp_right_plus1_mant, + &new_right_mant, pstr_common_tables); + + new_right_exp += temp_left_exp - temp_rightplus1_exp + 2; + + new_left_mant = ixheaacd_mult16_shl(temp_right_mant, new_right_mant); + + new_left_exp = add16_m(temp_right_exp, new_right_exp); + + *r_data++ = (WORD16)(((new_right_mant + ROUNDING) & MASK_M) + + ((new_right_exp + NRG_EXP_OFFSET) & MASK_FOR_EXP)); + *l_data++ = (WORD16)(((new_left_mant + ROUNDING) & MASK_M) + + ((new_left_exp + NRG_EXP_OFFSET) & MASK_FOR_EXP)); + } + + i_end = ptr_header_data->pstr_freq_band_data->num_nf_bands * + ptr_data_left->str_frame_info_details.num_noise_env; + r_data = ptr_data_right->int_noise_floor; + l_data = ptr_data_left->int_noise_floor; + + for (i = i_end - 1; i >= 0; i--) { + temp_left_exp = + sub16_m((WORD16)(*l_data & (WORD16)MASK_FOR_EXP), NOISE_EXP_OFFSET); + temp_right_exp = sub16_m(*r_data, 12); + + ixheaacd_fix_mant_exp_add(0x4000, ixheaacd_add16(1, temp_right_exp), 0x4000, + 1, &temp_right_plus1_mant, &temp_rightplus1_exp); + + new_right_exp = ixheaacd_fix_mant_div(0x4000, temp_right_plus1_mant, + &new_right_mant, pstr_common_tables); + + new_right_exp += temp_left_exp - temp_rightplus1_exp + 2; + + new_left_mant = new_right_mant; + new_left_exp = add16_m(new_right_exp, temp_right_exp); + *r_data++ = (WORD16)(((new_right_mant + ROUNDING) & MASK_M) + + ((new_right_exp + NOISE_EXP_OFFSET) & MASK_FOR_EXP)); + *l_data++ = (WORD16)(((new_left_mant + ROUNDING) & MASK_M) + + ((new_left_exp + NOISE_EXP_OFFSET) & MASK_FOR_EXP)); + } +} + +VOID ixheaacd_sbr_env_dequant_coup( + ia_sbr_frame_info_data_struct *ptr_data_ch_0, + ia_sbr_frame_info_data_struct *ptr_data_ch_1) { + FLOAT32 *ptr_env_sf_left = ptr_data_ch_0->flt_env_sf_arr; + FLOAT32 *ptr_env_sf_right = ptr_data_ch_1->flt_env_sf_arr; + FLOAT32 *ptr_noise_floor_left = ptr_data_ch_0->flt_noise_floor; + FLOAT32 *ptr_noise_floor_right = ptr_data_ch_1->flt_noise_floor; + WORD32 num_env_sf = ptr_data_ch_0->num_env_sfac; + WORD32 num_noise_fac = ptr_data_ch_0->num_noise_sfac; + WORD32 amp_res = ptr_data_ch_0->amp_res; + + WORD32 i; + FLOAT32 temp_l, temp_r; + FLOAT32 pan_offset[2] = {24.0f, 12.0f}; + FLOAT32 a_arr[2] = {0.5f, 1.0f}; + + FLOAT32 a = a_arr[amp_res]; + + for (i = 0; i < num_env_sf; i++) { + temp_l = ptr_env_sf_left[i]; + temp_r = ptr_env_sf_right[i]; + + ptr_env_sf_left[i] = + (FLOAT32)(64 * (pow(2, temp_l * a + 1) / + (1 + pow(2, (pan_offset[amp_res] - temp_r) * a)))); + ptr_env_sf_right[i] = + (FLOAT32)(64 * (pow(2, temp_l * a + 1) / + (1 + pow(2, (temp_r - pan_offset[amp_res]) * a)))); + } + + for (i = 0; i < num_noise_fac; i++) { + temp_l = ptr_noise_floor_left[i]; + temp_r = ptr_noise_floor_right[i]; + + ptr_noise_floor_left[i] = + (FLOAT32)(pow(2, NOISE_FLOOR_OFFSET - temp_l + 1) / + (1 + pow(2, pan_offset[1] - temp_r))); + ptr_noise_floor_right[i] = + (FLOAT32)(pow(2, NOISE_FLOOR_OFFSET - temp_l + 1) / + (1 + pow(2, temp_r - pan_offset[1]))); + } +} +VOID ixheaacd_dec_sbrdata(ia_sbr_header_data_struct *ptr_header_data_ch_0, + ia_sbr_header_data_struct *ptr_header_data_ch_1, + ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_0, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_0, + ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_1, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1, + ixheaacd_misc_tables *ptr_common_tables) { + FLAG error_code; + WORD32 usac_flag = ptr_header_data_ch_0->usac_flag; + + ixheaacd_dec_envelope(ptr_header_data_ch_0, ptr_sbr_data_ch_0, + ptr_prev_data_ch_0, ptr_prev_data_ch_1, + ptr_common_tables); + + ixheaacd_calc_noise_floor(ptr_header_data_ch_0, ptr_sbr_data_ch_0, + ptr_prev_data_ch_0); + + if (!ptr_sbr_data_ch_0->coupling_mode && usac_flag) { + ptr_sbr_data_ch_0->num_noise_sfac = + ptr_header_data_ch_0->pstr_freq_band_data->num_nf_bands * + ptr_sbr_data_ch_0->str_frame_info_details.num_noise_env; + + ixheaacd_dequant_esbr_env_data( + ptr_sbr_data_ch_0->flt_env_sf_arr, ptr_sbr_data_ch_0->num_env_sfac, + ptr_sbr_data_ch_0->num_noise_sfac, ptr_sbr_data_ch_0->amp_res, + ptr_sbr_data_ch_0->flt_noise_floor); + } + + if (ptr_sbr_data_ch_1 != NULL) { + error_code = ptr_header_data_ch_0->err_flag; + ixheaacd_dec_envelope(ptr_header_data_ch_1, ptr_sbr_data_ch_1, + ptr_prev_data_ch_1, ptr_prev_data_ch_0, + ptr_common_tables); + + ixheaacd_calc_noise_floor(ptr_header_data_ch_1, ptr_sbr_data_ch_1, + ptr_prev_data_ch_1); + + if (!ptr_sbr_data_ch_1->coupling_mode && usac_flag) { + ptr_sbr_data_ch_1->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_dequant_esbr_env_data( + ptr_sbr_data_ch_1->flt_env_sf_arr, ptr_sbr_data_ch_1->num_env_sfac, + ptr_sbr_data_ch_1->num_noise_sfac, ptr_sbr_data_ch_1->amp_res, + ptr_sbr_data_ch_1->flt_noise_floor); + } + + if (!usac_flag) { + if (!error_code && ptr_header_data_ch_0->err_flag) { + ixheaacd_dec_envelope(ptr_header_data_ch_0, ptr_sbr_data_ch_0, + ptr_prev_data_ch_0, ptr_prev_data_ch_1, + ptr_common_tables); + } + } + + if (ptr_sbr_data_ch_0->coupling_mode) { + ixheaacd_sbr_env_dequant_coup_fix(ptr_header_data_ch_0, ptr_sbr_data_ch_0, + ptr_sbr_data_ch_1, ptr_common_tables); + + ixheaacd_sbr_env_dequant_coup(ptr_sbr_data_ch_0, ptr_sbr_data_ch_1); + } + } +} +VOID ixheaacd_dec_envelope(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_0, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1, + ixheaacd_misc_tables *pstr_common_tables) { + FLAG error_code; + WORD16 env_sf_local_arr[MAX_FREQ_COEFFS]; + WORD32 usac_flag = ptr_header_data->usac_flag; + WORD32 temp_1 = + ptr_prev_data_ch_0->end_position - ptr_header_data->num_time_slots; + temp_1 = ptr_sbr_data->str_frame_info_details.border_vec[0] - temp_1; + + if ((!ptr_header_data->err_flag_prev) && (!ptr_header_data->err_flag) && + (temp_1 != 0)) { + if (ptr_sbr_data->del_cod_dir_arr[0] == DTDF_DIR_TIME) { + ptr_header_data->err_flag = 1; + } else { + ptr_header_data->err_flag_prev = 1; + } + } + + if (ptr_header_data->err_flag && !usac_flag) { + ixheaacd_lean_sbrconcealment(ptr_header_data, ptr_sbr_data, + ptr_prev_data_ch_0); + + ixheaacd_process_del_cod_env_data(ptr_header_data, ptr_sbr_data, + ptr_prev_data_ch_0); + } else { + WORD32 num = ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]; + if (ptr_header_data->err_flag_prev && !usac_flag) { + WORD16 *ptr1, *ptr2; + WORD32 i; + ixheaacd_wrong_timing_compensate(ptr_header_data, ptr_sbr_data, + ptr_prev_data_ch_0, pstr_common_tables); + + if (ptr_sbr_data->coupling_mode != + (WORD16)ptr_prev_data_ch_0->coupling_mode) { + if (ptr_prev_data_ch_0->coupling_mode == COUPLING_BAL) { + memcpy(ptr_prev_data_ch_0->sfb_nrg_prev, + ptr_prev_data_ch_1->sfb_nrg_prev, sizeof(WORD16) * num); + } else { + if (ptr_sbr_data->coupling_mode == COUPLING_LEVEL) { + ptr1 = ptr_prev_data_ch_0->sfb_nrg_prev; + ptr2 = ptr_prev_data_ch_1->sfb_nrg_prev; + + for (i = 0; i < num; i++) { + *ptr1 = (add16_m(*ptr1, *ptr2) >> 1); + ptr2++; + ptr1++; + } + } else { + if (ptr_sbr_data->coupling_mode == COUPLING_BAL) { + memset(ptr_prev_data_ch_0->sfb_nrg_prev, SBR_ENERGY_PAN_OFFSET, + sizeof(WORD16) * num); + } + } + } + } + } + + memcpy(env_sf_local_arr, ptr_prev_data_ch_0->sfb_nrg_prev, + sizeof(WORD16) * MAX_FREQ_COEFFS); + + ixheaacd_process_del_cod_env_data(ptr_header_data, ptr_sbr_data, + ptr_prev_data_ch_0); + + if (!usac_flag) { + error_code = ixheaacd_check_env_data(ptr_header_data, ptr_sbr_data, + ptr_prev_data_ch_0); + + if (error_code) { + ptr_header_data->err_flag = 1; + + memcpy(ptr_prev_data_ch_0->sfb_nrg_prev, env_sf_local_arr, + sizeof(WORD16) * MAX_FREQ_COEFFS); + + ixheaacd_dec_envelope(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0, + ptr_prev_data_ch_1, pstr_common_tables); + return; + } + } + } + if (!usac_flag) + ixheaacd_dequant_env_data(ptr_sbr_data, ptr_sbr_data->amp_res); +} + +VOID ixheaacd_adj_timeslot(WORD32 *ptr_buf_real, WORD32 *ptr_buf_imag, + WORD16 *ptr_filt_buf, WORD16 *ptr_filt_buf_noise, + WORD16 *ptr_gain_buf, WORD16 *ptr_noise_floor, + WORD16 *ptr_sine_lvl_buf, WORD16 noise_floor_exp, + WORD16 *ptr_harm_index, WORD16 sub_band_start, + WORD16 num_sub_bands, WORD16 scale_change, + WORD16 smooth_ratio, FLAG num_noise_flg, + WORD16 *ptr_phase_index, + ia_sbr_tables_struct *ptr_sbr_tables) { + WORD16 k; + WORD16 *ptr_smoothed_gain, *ptr_smoothed_noise; + WORD16 direct_ratio; + WORD32 index = *ptr_phase_index; + WORD32 harm_idx = *ptr_harm_index; + WORD32 freq_inv_flag; + const WORD32 *ptr_rand_ph_buf; + WORD32 factor = 0; + + direct_ratio = ixheaacd_sub16_sat(0x7fff, smooth_ratio); + freq_inv_flag = (sub_band_start & 1); + + scale_change = scale_change - 1; + + ptr_rand_ph_buf = &ptr_sbr_tables->sbr_rand_ph[index]; + *ptr_phase_index = + (WORD16)((index + num_sub_bands) & (SBR_NF_NO_RANDOM_VAL - 1)); + + if (smooth_ratio) { + WORD16 *ptr_filt_buf_local = &ptr_filt_buf[0]; + WORD16 *ptr_gain_buf_local = &ptr_gain_buf[0]; + WORD16 *ptr_filt_noise_local = &ptr_filt_buf_noise[0]; + WORD16 *ptr_noise_floor_local = &ptr_noise_floor[0]; + + WORD16 tmp, tmp1; + + for (k = 0; k < num_sub_bands; k++) { + tmp = add16_m(mult16x16_16(smooth_ratio, *ptr_filt_buf_local), + mult16x16_16(direct_ratio, *ptr_gain_buf_local++)); + + ptr_gain_buf_local++; + + tmp1 = add16_m(mult16x16_16(smooth_ratio, *ptr_filt_noise_local), + mult16x16_16(direct_ratio, *ptr_noise_floor_local++)); + + ptr_noise_floor_local++; + + *ptr_filt_buf_local++ = tmp << 1; + ptr_filt_buf_local++; + *ptr_filt_noise_local++ = tmp1 << 1; + } + ptr_smoothed_gain = ptr_filt_buf; + ptr_smoothed_noise = ptr_filt_buf_noise; + factor = 1; + } else { + ptr_smoothed_gain = ptr_gain_buf; + ptr_smoothed_noise = ptr_noise_floor; + factor = 2; + } + + switch (harm_idx) { + case 0: + case 2: + ixheaacd_harm_idx_zerotwo(num_noise_flg, num_sub_bands, ptr_buf_real, + ptr_buf_imag, ptr_smoothed_gain, + ptr_smoothed_noise, factor, ptr_gain_buf, + scale_change, ptr_rand_ph_buf, ptr_sine_lvl_buf, + noise_floor_exp, harm_idx); + break; + case 1: + case 3: + ixheaacd_harm_idx_onethree( + num_noise_flg, num_sub_bands, ptr_buf_real, ptr_buf_imag, + ptr_smoothed_gain, ptr_smoothed_noise, factor, ptr_gain_buf, + scale_change, ptr_rand_ph_buf, ptr_sine_lvl_buf, noise_floor_exp, + freq_inv_flag, harm_idx); + break; + } + *ptr_harm_index = (WORD16)((harm_idx + 1) & 3); +} diff --git a/decoder/ixheaacd_env_dec.h b/decoder/ixheaacd_env_dec.h new file mode 100644 index 0000000..3f4556a --- /dev/null +++ b/decoder/ixheaacd_env_dec.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ENV_DEC_H +#define IXHEAACD_ENV_DEC_H + +VOID ixheaacd_dec_sbrdata(ia_sbr_header_data_struct *ptr_header_data_ch_0, + ia_sbr_header_data_struct *ptr_header_data_ch_1, + ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_0, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_0, + ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_1, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1, + ixheaacd_misc_tables *ptr_common_tables); + +VOID ixheaacd_dec_sbrdata_for_pvc(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data); + +VOID ixheaacd_harm_idx_onethreelp(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, + WORD scale_change, WORD16 *ptr_sine_level_buf, + const WORD32 *ptr_rand_ph, + WORD16 *noise_lvl_me, WORD num_subband, + FLAG noise_absc_flag, WORD freq_inv_flag, + WORD noise_e, WORD sub_band_start); + +VOID ixheaacd_harm_idx_zerotwo(FLAG noise_absc_flag, WORD16 num_subband, + WORD32 *ptr_real_buf, WORD32 *ptr_im, + WORD16 *smoothed_gain, WORD16 *smoothed_noise, + WORD factor, WORD16 *ptr_gain_buf, + WORD16 scale_change, const WORD32 *ptr_rand_ph, + WORD16 *ptr_sine_level_buf, WORD16 noise_e, + WORD32 harm_index); + +VOID ixheaacd_harm_idx_onethree(FLAG noise_absc_flag, WORD16 num_subband, + WORD32 *ptr_real_buf, WORD32 *ptr_im, + WORD16 *smoothed_gain, WORD16 *smoothed_noise, + WORD factor, WORD16 *ptr_gain_buf, + WORD16 scale_change, const WORD32 *ptr_rand_ph, + WORD16 *ptr_sine_level_buf, WORD16 noise_e, + WORD freq_inv_flag, WORD32 harm_index); + +VOID ixheaacd_dec_envelope(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1, + ixheaacd_misc_tables *pstr_common_tables); + +VOID ixheaacd_lean_sbrconcealment(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data); + +#endif diff --git a/decoder/ixheaacd_env_extr.c b/decoder/ixheaacd_env_extr.c new file mode 100644 index 0000000..cca3ed3 --- /dev/null +++ b/decoder/ixheaacd_env_extr.c @@ -0,0 +1,1724 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include + +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_pvc_dec.h" + +#include "ixheaacd_ps_bitdec.h" + +#include "ixheaacd_audioobjtypes.h" + +WORD32 ixheaacd_cnt_leading_ones(WORD32 a) { + WORD32 count = 0; + + while (a) { + if (a & 0x80000000) + count++; + else + break; + a = a << 1; + } + return count; +} +VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len, + const UWORD16 *input_table, + const UWORD32 *idx_table) { + UWORD32 temp = 0; + UWORD32 temp1 = 0; + WORD32 found = 0; + UWORD32 mask = 0x80000000; + + WORD32 clo; + WORD32 MAX_LEN; + WORD32 ixheaacd_drc_offset = 0; + WORD32 length; + UWORD32 cwrd; + WORD32 len_end; + + MAX_LEN = input_table[0]; + mask = mask - (1 << (31 - MAX_LEN)); + mask = mask << 1; + temp = (UWORD32)(it_bit_buff & mask); + + len_end = input_table[0]; + clo = ixheaacd_cnt_leading_ones(temp); + do { + ixheaacd_drc_offset = (idx_table[clo] >> 20) & 0xff; + length = input_table[ixheaacd_drc_offset + 1] & 0x1f; + cwrd = idx_table[clo] & 0xfffff; + temp1 = temp >> (32 - length); + if (temp1 <= cwrd) { + ixheaacd_drc_offset = ixheaacd_drc_offset - (cwrd - temp1); + found = 1; + } else { + len_end = len_end + ((idx_table[clo] >> 28) & 0xf); + clo = len_end; + } + } while (!found); + *h_index = input_table[ixheaacd_drc_offset + 1] >> 5; + *len = length; +} + +static VOID ixheaacd_read_esbr_pvc_envelope(ia_pvc_data_struct *ptr_pvc_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 indepFlag) { + WORD32 i, j, k; + WORD32 fixed_length = 0, num_grid_info = 0, grid_info; + UWORD8 div_mode, ns_mode; + UWORD16 pvc_id[PVC_NUM_TIME_SLOTS + 1]; + UWORD8 num_length; + UWORD8 length; + UWORD8 reuse_pvc_id; + WORD32 sum_length = 0; + WORD32 length_bits = 4; + UWORD8 pvc_id_bits = PVC_ID_BITS; + + div_mode = (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, PVC_DIV_MODE_BITS); + ns_mode = (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, PVC_NS_MODE_BITS); + + if (ptr_pvc_data->pvc_mode == 3) { + pvc_id_bits = 0; + } + + if (div_mode <= 3) { + num_length = div_mode; + if (indepFlag) { + reuse_pvc_id = 0; + } else { + reuse_pvc_id = + (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, PVC_REUSE_PVC_ID_BITS); + } + if (reuse_pvc_id == 1) { + pvc_id[0] = ptr_pvc_data->prev_pvc_id; + } else { + pvc_id[0] = (UWORD16)ixheaacd_read_bits_buf(it_bit_buff, pvc_id_bits); + } + + k = 1; + if (num_length) { + sum_length = 0; + for (i = 0; i < num_length; i++) { + if (sum_length >= 13) { + length_bits = 1; + } else if (sum_length >= 11) { + length_bits = 2; + } else if (sum_length >= 7) { + length_bits = 3; + } else { + length_bits = 4; + } + length = (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, length_bits); + length += 1; + sum_length += length; + for (j = 1; j < length; j++, k++) { + pvc_id[k] = pvc_id[k - 1]; + } + pvc_id[k++] = (UWORD16)ixheaacd_read_bits_buf(it_bit_buff, pvc_id_bits); + } + } + + for (; k < 16; k++) { + pvc_id[k] = pvc_id[k - 1]; + } + + } else { + switch (div_mode) { + case 4: + num_grid_info = 2; + fixed_length = 8; + break; + case 5: + num_grid_info = 4; + fixed_length = 4; + break; + case 6: + num_grid_info = 8; + fixed_length = 2; + break; + case 7: + num_grid_info = 16; + fixed_length = 1; + break; + default:; + } + if (indepFlag) { + grid_info = 1; + } else { + grid_info = ixheaacd_read_bits_buf(it_bit_buff, PVC_GRID_INFO_BITS); + } + if (grid_info) { + pvc_id[0] = (UWORD16)ixheaacd_read_bits_buf(it_bit_buff, pvc_id_bits); + } else { + pvc_id[0] = ptr_pvc_data->prev_pvc_id; + } + for (j = 1, k = 1; j < fixed_length; j++, k++) { + pvc_id[k] = pvc_id[k - 1]; + } + + for (i = 1; i < num_grid_info; i++) { + grid_info = ixheaacd_read_bits_buf(it_bit_buff, PVC_GRID_INFO_BITS); + if (grid_info == 1) { + pvc_id[k++] = (UWORD16)ixheaacd_read_bits_buf(it_bit_buff, pvc_id_bits); + } else { + pvc_id[k] = pvc_id[k - 1]; + k++; + } + for (j = 1; j < fixed_length; j++, k++) { + pvc_id[k] = pvc_id[k - 1]; + } + } + } + ptr_pvc_data->div_mode = div_mode; + ptr_pvc_data->ns_mode = ns_mode; + for (i = 0; i < PVC_NUM_TIME_SLOTS; i++) { + ptr_pvc_data->pvc_id[i] = pvc_id[i]; + } +} + +static VOID ixheaacd_pvc_env_dtdf_data( + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff) { + WORD32 i; + WORD32 usac_independency_flag = ptr_frame_data->usac_independency_flag; + WORD32 bs_num_noise = ptr_frame_data->str_frame_info_details.num_noise_env; + + if (usac_independency_flag) { + ptr_frame_data->del_cod_dir_noise_arr[0] = 0; + } else { + ptr_frame_data->del_cod_dir_noise_arr[0] = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_DOMAIN_BITS); + } + + for (i = 1; i < bs_num_noise; i++) { + ptr_frame_data->del_cod_dir_noise_arr[i] = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_DOMAIN_BITS); + } +} + +static VOID ixheaacd_read_sbr_addi_data( + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_header_data_struct *ptr_header_data, + ia_bit_buf_struct *it_bit_buff) { + WORD32 i; + + WORD32 flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + + ptr_frame_data->sin_start_for_cur_top = + ptr_frame_data->sin_start_for_next_top; + ptr_frame_data->sin_len_for_cur_top = ptr_frame_data->sin_len_for_next_top; + ptr_frame_data->sin_start_for_next_top = 0; + ptr_frame_data->sin_len_for_next_top = 0; + + if (flag) { + for (i = 0; i < ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]; + i++) { + ptr_frame_data->add_harmonics[i] = ixheaacd_read_bits_buf(it_bit_buff, 1); + } + if (ptr_frame_data->pvc_mode != 0) { + ptr_frame_data->sine_position = ESC_SIN_POS; + + ptr_frame_data->bs_sin_pos_present = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (ptr_frame_data->bs_sin_pos_present == 1) { + ptr_frame_data->sine_position = ixheaacd_read_bits_buf(it_bit_buff, 5); + } + if (ptr_frame_data->var_len > 0) { + if (ptr_frame_data->sine_position > 16) { + if (ptr_frame_data->sine_position == 31) { + ptr_frame_data->sin_start_for_next_top = 0; + ptr_frame_data->sin_len_for_next_top = ptr_frame_data->var_len; + } else { + if ((ptr_frame_data->var_len + 16) == + ptr_frame_data->sine_position) { + ptr_frame_data->sin_start_for_next_top = 0; + ptr_frame_data->sin_len_for_next_top = ptr_frame_data->var_len; + } else { + ptr_frame_data->sin_start_for_next_top = + ptr_frame_data->sine_position - 16; + ptr_frame_data->sin_len_for_next_top = ptr_frame_data->var_len; + } + } + } else { + ptr_frame_data->sin_start_for_next_top = 0; + ptr_frame_data->sin_len_for_next_top = ptr_frame_data->var_len; + } + } else { + ptr_frame_data->sin_start_for_next_top = 0; + ptr_frame_data->sin_len_for_next_top = 0; + } + } + } + return; +} + +WORD32 ixheaacd_ssc_huff_dec(ia_huffman_data_type t_huff, + ia_handle_bit_buf_struct it_bit_buff) { + WORD32 index; + WORD32 value, bit; + WORD16 cw; + index = 0; + + while (index >= 0) { + cw = t_huff[index]; + + bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (bit) { + WORD sign = (cw & 0x0080); + if (sign) { + index = (cw | 0xffffff80); + } else { + index = (cw & 0x007f); + } + } else { + index = (cw >> 8); + } + } + + value = (index + 64); + + return (value); +} + +WORD32 ixheaacd_sbr_read_header_data( + ia_sbr_header_data_struct *pstr_sbr_header, ia_bit_buf_struct *it_bit_buff, + FLAG stereo_flag, ia_sbr_header_data_struct *pstr_sbr_dflt_header) { + ia_sbr_header_data_struct prev_header_info; + FLAG header_extra_1 = 0, header_extra_2 = 0; + WORD32 tmp; + WORD32 usac_independency_flag = pstr_sbr_header->usac_independency_flag; + WORD32 use_dflt_hdr = 0; + WORD32 header_present = 1; + WORD32 usac_flag = pstr_sbr_header->usac_flag; + + if (!usac_flag) { + memcpy(&prev_header_info, pstr_sbr_header, + sizeof(ia_sbr_header_data_struct)); + + tmp = ixheaacd_read_bits_buf( + it_bit_buff, SBR_AMPLITUDE_RESOLUTION_BITS + SBR_BEGIN_SAMP_FREQ_BITS + + SBR_END_SAMP_FREQ_BITS + SBR_CROSS_OVER_BND_BITS); + + pstr_sbr_header->amp_res = (WORD16)( + (tmp & 0x0800) >> (SBR_BEGIN_SAMP_FREQ_BITS + SBR_END_SAMP_FREQ_BITS + + SBR_CROSS_OVER_BND_BITS)); + + pstr_sbr_header->start_freq = (WORD16)( + (tmp & 0x0780) >> (SBR_END_SAMP_FREQ_BITS + SBR_CROSS_OVER_BND_BITS)); + + pstr_sbr_header->stop_freq = + (WORD16)((tmp & 0x078) >> (SBR_CROSS_OVER_BND_BITS)); + + pstr_sbr_header->xover_band = (WORD16)((tmp & 0x07)); + + tmp = ixheaacd_read_bits_buf( + it_bit_buff, + SBR_HDR_RESERV_BITS + SBR_HDR_EXTR_1_BITS + SBR_HDR_EXTR_2_BITS); + header_extra_1 = (FLAG)((tmp & 0x02) >> (SBR_HDR_EXTR_2_BITS)); + header_extra_2 = (FLAG)((tmp & 0x01)); + if (stereo_flag) { + pstr_sbr_header->channel_mode = SBR_STEREO; + } else { + pstr_sbr_header->channel_mode = SBR_MONO; + } + } else { + WORD32 info_present = 0; + if (pstr_sbr_header->sync_state == SBR_ACTIVE) { + memcpy(&prev_header_info, pstr_sbr_header, + sizeof(ia_sbr_header_data_struct)); + } + if (usac_independency_flag) { + header_present = 1; + info_present = 1; + } else { + info_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (info_present) { + header_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + } else { + header_present = 0; + } + } + + if (info_present) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, SBR_AMPLITUDE_RESOLUTION_BITS + + ESBR_CROSS_OVER_BND_BITS + + ESBR_PRE_FLAT_BITS); + pstr_sbr_header->amp_res = (WORD16)( + (tmp & 0x0020) >> (ESBR_CROSS_OVER_BND_BITS + ESBR_PRE_FLAT_BITS)); + pstr_sbr_header->xover_band = + (WORD16)((tmp & 0x001E) >> (ESBR_PRE_FLAT_BITS)); + pstr_sbr_header->pre_proc_flag = (WORD16)((tmp & 0x001)); + if (pstr_sbr_header->pvc_flag) { + pstr_sbr_header->pvc_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PVC_MODE_BITS); + } else { + pstr_sbr_header->pvc_mode = 0; + } + } + + if (header_present) { + use_dflt_hdr = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (use_dflt_hdr) { + pstr_sbr_header->start_freq = pstr_sbr_dflt_header->start_freq; + pstr_sbr_header->stop_freq = pstr_sbr_dflt_header->stop_freq; + pstr_sbr_header->header_extra_1 = pstr_sbr_dflt_header->header_extra_1; + pstr_sbr_header->header_extra_2 = pstr_sbr_dflt_header->header_extra_2; + pstr_sbr_header->freq_scale = pstr_sbr_dflt_header->freq_scale; + pstr_sbr_header->alter_scale = pstr_sbr_dflt_header->alter_scale; + pstr_sbr_header->noise_bands = pstr_sbr_dflt_header->noise_bands; + pstr_sbr_header->limiter_bands = pstr_sbr_dflt_header->limiter_bands; + pstr_sbr_header->limiter_gains = pstr_sbr_dflt_header->limiter_gains; + pstr_sbr_header->interpol_freq = pstr_sbr_dflt_header->interpol_freq; + pstr_sbr_header->smoothing_mode = pstr_sbr_dflt_header->smoothing_mode; + } else { + tmp = ixheaacd_read_bits_buf( + it_bit_buff, SBR_BEGIN_SAMP_FREQ_BITS + SBR_END_SAMP_FREQ_BITS + + SBR_HDR_EXTR_1_BITS + SBR_HDR_EXTR_2_BITS); + pstr_sbr_header->start_freq = + (tmp & 0x03C0) >> (SBR_END_SAMP_FREQ_BITS + SBR_HDR_EXTR_1_BITS + + SBR_HDR_EXTR_2_BITS); + pstr_sbr_header->stop_freq = + (tmp & 0x003C) >> (SBR_HDR_EXTR_1_BITS + SBR_HDR_EXTR_2_BITS); + pstr_sbr_header->header_extra_1 = + (tmp & 0x0002) >> (SBR_HDR_EXTR_2_BITS); + pstr_sbr_header->header_extra_2 = (tmp & 0x0001); + header_extra_1 = pstr_sbr_header->header_extra_1; + header_extra_2 = pstr_sbr_header->header_extra_2; + } + } + } + + if (!use_dflt_hdr && header_present) { + if (header_extra_1) { + tmp = ixheaacd_read_bits_buf( + it_bit_buff, + SBR_SAMP_FREQ_LVL_BITS + SBR_CHANGE_LVL_BITS + SBR_NOISE_BND_BITS); + pstr_sbr_header->freq_scale = + (WORD16)((tmp & 0x018) >> (SBR_CHANGE_LVL_BITS + SBR_NOISE_BND_BITS)); + pstr_sbr_header->alter_scale = + (WORD16)((tmp & 0x04) >> (SBR_NOISE_BND_BITS)); + pstr_sbr_header->noise_bands = (WORD16)((tmp & 0x03)); + } else { + pstr_sbr_header->freq_scale = SBR_SAMP_FEQ_LVL_DEF; + pstr_sbr_header->alter_scale = SBR_CHANGE_LVL_DEF; + pstr_sbr_header->noise_bands = SBR_NOISE_BND_DEF; + } + + if (header_extra_2) { + tmp = ixheaacd_read_bits_buf( + it_bit_buff, SBR_BND_LIMIT_BITS + SBR_GAIN_LIMIT_BITS + + SBR_INTERPOL_SAMP_FREQ_BITS + SBR_SMOOTH_LEN_BITS); + pstr_sbr_header->limiter_bands = (WORD16)( + (tmp & 0x030) >> (SBR_GAIN_LIMIT_BITS + SBR_INTERPOL_SAMP_FREQ_BITS + + SBR_SMOOTH_LEN_BITS)); + pstr_sbr_header->limiter_gains = (WORD16)( + (tmp & 0x0c) >> (SBR_INTERPOL_SAMP_FREQ_BITS + SBR_SMOOTH_LEN_BITS)); + pstr_sbr_header->interpol_freq = + (WORD16)((tmp & 0x02) >> (SBR_SMOOTH_LEN_BITS)); + pstr_sbr_header->smoothing_mode = (WORD16)((tmp & 0x01)); + } else { + pstr_sbr_header->limiter_bands = SBR_BND_LIMIT_DEF; + pstr_sbr_header->limiter_gains = SBR_GAIN_LIMIT_DEF; + pstr_sbr_header->interpol_freq = SBR_INTERPOL_SAMP_FEQ_DEF; + pstr_sbr_header->smoothing_mode = SBR_SMOOTH_LEN_DEF; + } + } + + if ((pstr_sbr_header->sync_state != SBR_ACTIVE) || + (prev_header_info.start_freq != pstr_sbr_header->start_freq) || + (prev_header_info.stop_freq != pstr_sbr_header->stop_freq) || + (prev_header_info.xover_band != pstr_sbr_header->xover_band) || + (prev_header_info.freq_scale != pstr_sbr_header->freq_scale) || + (prev_header_info.alter_scale != pstr_sbr_header->alter_scale) || + (prev_header_info.noise_bands != pstr_sbr_header->noise_bands)) { + return SBR_RESET; + } + + return 0; +} + +static VOID ixheaacd_sbr_sin_coding_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff) { + FLAG *p_add_harmonic = ptr_frame_data->add_harmonics; + WORD32 i; + + i = ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]; + do { + *p_add_harmonic++ = + (FLAG)ixheaacd_read_bits_buf(it_bit_buff, SBR_ADD_SINE_FLAG_BITS); + i--; + } while (i != 0); + + return; +} + +static WORD16 ixheaacd_validate_frame_info( + ia_frame_info_struct *pstr_frame_info, WORD16 num_time_slots, + WORD audio_object_type) { + WORD32 i, j; + + WORD32 start_pos, end_pos, transient_env, start_pos_noise, end_pos_noise, + num_env_sf, num_noise_env; + + num_env_sf = pstr_frame_info->num_env; + num_noise_env = pstr_frame_info->num_noise_env; + + if ((num_env_sf < 1) || (num_env_sf > MAX_ENVELOPES)) return 0; + + if (num_noise_env > MAX_NOISE_ENVELOPES) return 0; + + start_pos = pstr_frame_info->border_vec[0]; + end_pos = pstr_frame_info->border_vec[num_env_sf]; + transient_env = pstr_frame_info->transient_env; + + if (transient_env > num_env_sf) return 0; + + start_pos_noise = pstr_frame_info->noise_border_vec[0]; + end_pos_noise = pstr_frame_info->noise_border_vec[num_noise_env]; + + if ((start_pos < 0) || (start_pos >= end_pos)) return 0; + + if (start_pos > SBR_OV_SLOTS) return 0; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + if (end_pos < SBR_TIME_SLOTS) return 0; + } else { + if (end_pos < num_time_slots) return 0; + } + + if (end_pos > add_d(SBR_TIME_SLOTS, SBR_OV_SLOTS)) return 0; + + for (i = 0; i < num_env_sf; i++) { + if (pstr_frame_info->border_vec[i] > pstr_frame_info->border_vec[i + 1]) + return 0; + } + + if ((num_env_sf == 1) && (num_noise_env > 1)) return 0; + + if ((start_pos != start_pos_noise) || (end_pos != end_pos_noise)) return 0; + + for (i = 0; i < num_noise_env; i++) { + start_pos_noise = pstr_frame_info->noise_border_vec[i]; + + for (j = 0; j < num_env_sf; j++) { + if (pstr_frame_info->border_vec[j] == start_pos_noise) break; + } + if (j == num_env_sf) return 0; + } + + return 1; +} + + +static WORD16 ixheaacd_read_extn_data( + ia_sbr_header_data_struct *ptr_header_data, ia_ps_dec_struct *ptr_ps_dec, + ia_bit_buf_struct *it_bit_buff, ia_ps_tables_struct *ps_tables_ptr) { + WORD i; + WORD extended_data; + WORD no_bits_left; + + extended_data = ixheaacd_read_bits_buf(it_bit_buff, SBR_ENLARGED_DATA_BITS); + + if (extended_data) { + WORD cnt; + FLAG ps_read; + + ps_read = 0; + + cnt = ixheaacd_read_bits_buf(it_bit_buff, SBR_CONT_SIZE_BITS); + + if (cnt == ((1 << SBR_CONT_SIZE_BITS) - 1)) { + cnt = (cnt + ixheaacd_read_bits_buf(it_bit_buff, SBR_CONT_ESC_CNT_BITS)); + } + + no_bits_left = (cnt << 3); + + while (no_bits_left > 7) { + WORD extension_id = ixheaacd_read_bits_buf(it_bit_buff, SBR_CONT_ID_BITS); + + no_bits_left = (no_bits_left - SBR_CONT_ID_BITS); + + switch (extension_id) { + case EXTENSION_ID_PS_CODING: + + if (ptr_ps_dec == NULL) { + return 0; + } + + if (!(ptr_ps_dec->force_mono || ps_read)) { + no_bits_left = + (no_bits_left - ixheaacd_read_ps_data(ptr_ps_dec, it_bit_buff, + (WORD16)no_bits_left, + ps_tables_ptr)); + + if (no_bits_left < 0) return 0; + + ptr_header_data->channel_mode = PS_STEREO; + ps_read = 1; + break; + } + + default: + cnt = (no_bits_left >> 3); + for (i = cnt - 1; i >= 0; i--) ixheaacd_read_bits_buf(it_bit_buff, 8); + no_bits_left = (no_bits_left - (cnt << 3)); + break; + } + } + + if (no_bits_left < 0) return 0; + + ixheaacd_read_bits_buf(it_bit_buff, no_bits_left); + } + return 1; +} + +VOID ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, WORD32 hbe_flag, + ia_pvc_data_struct *ptr_pvc_data, + ia_sbr_tables_struct *ptr_sbr_tables, + ia_sbr_header_data_struct *ptr_header_data) { + WORD32 i; + ia_env_extr_tables_struct *env_extr_tables_ptr = + ptr_sbr_tables->env_extr_tables_ptr; + WORD32 usac_independency_flag = ptr_frame_data->usac_independency_flag; + + if (hbe_flag) { + ptr_frame_data->sbr_patching_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PATCHING_MODE_BITS); + + if (ptr_frame_data->sbr_patching_mode == 0) { + ptr_frame_data->over_sampling_flag = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_OVERSAMPLING_FLAG_BITS); + if (ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_FLAG_BITS)) + ptr_frame_data->pitch_in_bins = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_BINS_BITS); + else + ptr_frame_data->pitch_in_bins = 0; + } else { + ptr_frame_data->over_sampling_flag = ptr_frame_data->pitch_in_bins = 0; + } + } + + ixheaacd_pvc_time_freq_grid_info(it_bit_buff, ptr_frame_data); + + ptr_pvc_data->prev_sbr_mode = PVC_SBR; + + ixheaacd_pvc_env_dtdf_data(ptr_frame_data, it_bit_buff); + + for (i = 0; i < ptr_header_data->pstr_freq_band_data->num_nf_bands; i++) { + ptr_frame_data->sbr_invf_mode_prev[i] = ptr_frame_data->sbr_invf_mode[i]; + ptr_frame_data->sbr_invf_mode[i] = + (WORD32)ixheaacd_read_bits_buf(it_bit_buff, ESBR_INVF_MODE_BITS); + } + + ptr_pvc_data->pvc_mode = ptr_header_data->pvc_mode; + + ixheaacd_read_esbr_pvc_envelope(ptr_pvc_data, it_bit_buff, + usac_independency_flag); + + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data, + it_bit_buff, env_extr_tables_ptr); + + memset(ptr_frame_data->add_harmonics, 0, + ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH] * + sizeof(WORD32)); + ptr_frame_data->pvc_mode = ptr_header_data->pvc_mode; + + ixheaacd_read_sbr_addi_data(ptr_frame_data, ptr_header_data, it_bit_buff); + + ptr_frame_data->coupling_mode = COUPLING_OFF; +} + +WORD8 ixheaacd_sbr_read_sce(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_ps_dec_struct *ptr_ps_dec, + ia_bit_buf_struct *it_bit_buff, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD audio_object_type) { + WORD32 bit; + WORD32 i; + WORD32 hbe_flag = ptr_header_data->hbe_flag; + WORD32 num_if_bands = ptr_header_data->pstr_freq_band_data->num_if_bands; + WORD32 usac_flag = ptr_header_data->usac_flag; + ia_env_extr_tables_struct *env_extr_tables_ptr = + ptr_sbr_tables->env_extr_tables_ptr; + + ptr_frame_data->coupling_mode = COUPLING_OFF; + + if (!usac_flag) { + bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (bit) ixheaacd_read_bits_buf(it_bit_buff, SBR_SCE_RESERV_BITS); + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + if (ptr_frame_data->eld_sbr_flag == 1) { + if (!ixheaacd_extract_frame_info_ld(it_bit_buff, ptr_frame_data)) + return 0; + } + } else { + if (!ixheaacd_sbr_time_freq_grid_info(it_bit_buff, ptr_frame_data, + env_extr_tables_ptr)) + + return 0; + } + if (!ixheaacd_validate_frame_info(&ptr_frame_data->str_frame_info_details, + ptr_header_data->num_time_slots, + audio_object_type)) + return 0; + + } else { + if (hbe_flag) { + ptr_frame_data->sbr_patching_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PATCHING_MODE_BITS); + if (ptr_frame_data->sbr_patching_mode == 0) { + ptr_frame_data->over_sampling_flag = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_OVERSAMPLING_FLAG_BITS); + if (ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_FLAG_BITS)) + ptr_frame_data->pitch_in_bins = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_BINS_BITS); + else + ptr_frame_data->pitch_in_bins = 0; + } else { + ptr_frame_data->over_sampling_flag = ptr_frame_data->pitch_in_bins = 0; + } + } + ptr_frame_data->num_time_slots = ptr_header_data->num_time_slots; + if (!ixheaacd_sbr_time_freq_grid_info(it_bit_buff, ptr_frame_data, + env_extr_tables_ptr)) + return 0; + + if (!ixheaacd_validate_frame_info(&ptr_frame_data->str_frame_info_details, + ptr_header_data->num_time_slots, + audio_object_type)) + return 0; + + ptr_frame_data->prev_sbr_mode = ORIG_SBR; + } + + ixheaacd_sbr_env_dtdf_data(ptr_frame_data, it_bit_buff, + ptr_header_data->usac_flag); + + if (ptr_frame_data->del_cod_dir_arr[0] == DTDF_DIR_FREQ) { + ptr_header_data->err_flag = 0; + } + + for (i = 0; i < num_if_bands; i++) { + ptr_frame_data->sbr_invf_mode_prev[i] = ptr_frame_data->sbr_invf_mode[i]; + ptr_frame_data->sbr_invf_mode[i] = + (WORD32)ixheaacd_read_bits_buf(it_bit_buff, SBR_INVERSE_FILT_MODE_BITS); + } + + if (!ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data, it_bit_buff, + env_extr_tables_ptr, audio_object_type)) + return 0; + + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data, + it_bit_buff, env_extr_tables_ptr); + + if (usac_flag) { + memset( + ptr_frame_data->add_harmonics, 0, + ptr_header_data->pstr_freq_band_data->num_sf_bands[1] * sizeof(WORD32)); + ptr_frame_data->coupling_mode = COUPLING_OFF; + } + + bit = (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + if (bit) { + ixheaacd_sbr_sin_coding_data(ptr_header_data, ptr_frame_data, it_bit_buff); + } else { + memset(ptr_frame_data->add_harmonics, 0, sizeof(FLAG) * MAX_FREQ_COEFFS); + } + + if (!usac_flag) { + ixheaacd_read_extn_data(ptr_header_data, ptr_ps_dec, it_bit_buff, + ptr_sbr_tables->ps_tables_ptr); + } + + return 1; +} + +WORD8 ixheaacd_sbr_read_cpe(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct **ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD audio_object_type) { + WORD32 i, k, bit, num_ch = 2; + WORD32 num_if_bands = ptr_header_data->pstr_freq_band_data->num_if_bands; + WORD32 hbe_flag = ptr_header_data->hbe_flag; + WORD32 usac_flag = ptr_header_data->usac_flag; + + ia_env_extr_tables_struct *env_extr_tables_ptr = + ptr_sbr_tables->env_extr_tables_ptr; + bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (usac_flag) { + if (bit) { + if (hbe_flag) { + ptr_frame_data[0]->sbr_patching_mode = + ptr_frame_data[1]->sbr_patching_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PATCHING_MODE_BITS); + if (ptr_frame_data[0]->sbr_patching_mode == 0) { + ptr_frame_data[0]->over_sampling_flag = + ptr_frame_data[1]->over_sampling_flag = ixheaacd_read_bits_buf( + it_bit_buff, ESBR_OVERSAMPLING_FLAG_BITS); + if (ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_FLAG_BITS)) + ptr_frame_data[0]->pitch_in_bins = + ptr_frame_data[1]->pitch_in_bins = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_BINS_BITS); + else + ptr_frame_data[0]->pitch_in_bins = + ptr_frame_data[1]->pitch_in_bins = 0; + } else { + ptr_frame_data[0]->over_sampling_flag = 0; + ptr_frame_data[1]->over_sampling_flag = 0; + ptr_frame_data[0]->pitch_in_bins = 0; + ptr_frame_data[1]->pitch_in_bins = 0; + } + } + ptr_frame_data[0]->coupling_mode = COUPLING_LEVEL; + ptr_frame_data[1]->coupling_mode = COUPLING_BAL; + } else { + if (hbe_flag) { + ptr_frame_data[0]->sbr_patching_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PATCHING_MODE_BITS); + if (ptr_frame_data[0]->sbr_patching_mode == 0) { + ptr_frame_data[0]->over_sampling_flag = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_OVERSAMPLING_FLAG_BITS); + if (ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_FLAG_BITS)) + ptr_frame_data[0]->pitch_in_bins = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_BINS_BITS); + else + ptr_frame_data[0]->pitch_in_bins = 0; + } else { + ptr_frame_data[0]->over_sampling_flag = 0; + ptr_frame_data[0]->pitch_in_bins = 0; + } + ptr_frame_data[1]->sbr_patching_mode = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PATCHING_MODE_BITS); + if (ptr_frame_data[1]->sbr_patching_mode == 0) { + ptr_frame_data[1]->over_sampling_flag = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_OVERSAMPLING_FLAG_BITS); + if (ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_FLAG_BITS)) + ptr_frame_data[1]->pitch_in_bins = + ixheaacd_read_bits_buf(it_bit_buff, ESBR_PITCHIN_BINS_BITS); + else + ptr_frame_data[1]->pitch_in_bins = 0; + } else { + ptr_frame_data[1]->over_sampling_flag = + ptr_frame_data[1]->pitch_in_bins = 0; + } + } + + ptr_frame_data[0]->coupling_mode = COUPLING_OFF; + ptr_frame_data[1]->coupling_mode = COUPLING_OFF; + } + } else { + if (bit) { + ixheaacd_read_bits_buf(it_bit_buff, + SBR_SCE_RESERV_BITS + SBR_SCE_RESERV_BITS); + } + if ((audio_object_type != AOT_ER_AAC_ELD) && + (ptr_header_data->channel_mode != SBR_STEREO)) { + ptr_header_data->sync_state = UPSAMPLING; + return 0; + } + + bit = ixheaacd_read_bits_buf(it_bit_buff, SBR_COUPLNG_MODE_BITS); + + if (bit) { + ptr_frame_data[0]->coupling_mode = COUPLING_LEVEL; + ptr_frame_data[1]->coupling_mode = COUPLING_BAL; + } else { + ptr_frame_data[0]->coupling_mode = COUPLING_OFF; + ptr_frame_data[1]->coupling_mode = COUPLING_OFF; + } + } + + for (i = 0; i < num_ch; i++) { + ptr_frame_data[i]->num_time_slots = ptr_header_data->num_time_slots; + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + if (ptr_frame_data[i]->eld_sbr_flag == 1) { + if (!ixheaacd_extract_frame_info_ld(it_bit_buff, ptr_frame_data[i])) + return 0; + } + } else { + if (!ixheaacd_sbr_time_freq_grid_info(it_bit_buff, ptr_frame_data[i], + env_extr_tables_ptr)) + return 0; + } + + if (!ixheaacd_validate_frame_info( + &ptr_frame_data[i]->str_frame_info_details, + ptr_header_data->num_time_slots, audio_object_type)) + return 0; + + if (ptr_frame_data[0]->coupling_mode) { + memcpy(&ptr_frame_data[1]->str_frame_info_details, + &ptr_frame_data[0]->str_frame_info_details, + sizeof(ia_frame_info_struct)); + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + ptr_frame_data[1]->amp_res = ptr_frame_data[0]->amp_res; + } + num_ch = 1; + } + } + + if (ptr_frame_data[0]->coupling_mode && usac_flag) { + ixheaacd_sbr_env_dtdf_data(ptr_frame_data[0], it_bit_buff, + ptr_header_data->usac_flag); + ixheaacd_sbr_env_dtdf_data(ptr_frame_data[1], it_bit_buff, + ptr_header_data->usac_flag); + + for (i = 0; i < ptr_header_data->noise_bands; i++) { + ptr_frame_data[0]->sbr_invf_mode_prev[i] = + ptr_frame_data[0]->sbr_invf_mode[i]; + ptr_frame_data[1]->sbr_invf_mode_prev[i] = + ptr_frame_data[1]->sbr_invf_mode[i]; + + ptr_frame_data[0]->sbr_invf_mode[i] = + (WORD32)ixheaacd_read_bits_buf(it_bit_buff, ESBR_INVF_MODE_BITS); + ptr_frame_data[1]->sbr_invf_mode[i] = ptr_frame_data[0]->sbr_invf_mode[i]; + } + + ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[0], it_bit_buff, + env_extr_tables_ptr, audio_object_type); + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff, env_extr_tables_ptr); + + ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[1], it_bit_buff, + env_extr_tables_ptr, audio_object_type); + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data[1], + it_bit_buff, env_extr_tables_ptr); + + memset( + ptr_frame_data[0]->add_harmonics, 0, + ptr_header_data->pstr_freq_band_data->num_sf_bands[1] * sizeof(WORD32)); + memset( + ptr_frame_data[1]->add_harmonics, 0, + ptr_header_data->pstr_freq_band_data->num_sf_bands[1] * sizeof(WORD32)); + + } else { + ixheaacd_sbr_env_dtdf_data(ptr_frame_data[0], it_bit_buff, + ptr_header_data->usac_flag); + ixheaacd_sbr_env_dtdf_data(ptr_frame_data[1], it_bit_buff, + ptr_header_data->usac_flag); + + if ((ptr_frame_data[0]->del_cod_dir_arr[0] == DTDF_DIR_FREQ) && + (ptr_frame_data[1]->del_cod_dir_arr[0] == DTDF_DIR_FREQ)) { + ptr_header_data->err_flag = 0; + } + + for (k = 0; k < num_ch; k++) { + for (i = 0; i < num_if_bands; i++) { + ptr_frame_data[k]->sbr_invf_mode_prev[i] = + ptr_frame_data[k]->sbr_invf_mode[i]; + ptr_frame_data[k]->sbr_invf_mode[i] = (WORD32)ixheaacd_read_bits_buf( + it_bit_buff, SBR_INVERSE_FILT_MODE_BITS); + } + } + + if (ptr_frame_data[0]->coupling_mode) { + memcpy(ptr_frame_data[1]->sbr_invf_mode, ptr_frame_data[0]->sbr_invf_mode, + sizeof(WORD32) * num_if_bands); + + if (!ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff, env_extr_tables_ptr, + audio_object_type)) { + return 0; + } + + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff, env_extr_tables_ptr); + + if (!ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[1], + it_bit_buff, env_extr_tables_ptr, + audio_object_type)) { + return 0; + } + } else { + if (!ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff, env_extr_tables_ptr, + audio_object_type)) + return 0; + + if (!ixheaacd_read_sbr_env_data(ptr_header_data, ptr_frame_data[1], + it_bit_buff, env_extr_tables_ptr, + audio_object_type)) + return 0; + + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff, env_extr_tables_ptr); + } + ixheaacd_read_sbr_noise_floor_data(ptr_header_data, ptr_frame_data[1], + it_bit_buff, env_extr_tables_ptr); + } + + bit = (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + if (bit) { + ixheaacd_sbr_sin_coding_data(ptr_header_data, ptr_frame_data[0], + it_bit_buff); + } else { + memset(ptr_frame_data[0]->add_harmonics, 0, sizeof(FLAG) * MAX_FREQ_COEFFS); + } + + bit = (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + if (bit) { + ixheaacd_sbr_sin_coding_data(ptr_header_data, ptr_frame_data[1], + it_bit_buff); + } else { + memset(ptr_frame_data[1]->add_harmonics, 0, sizeof(FLAG) * MAX_FREQ_COEFFS); + } + + if (!usac_flag) { + ixheaacd_read_extn_data(ptr_header_data, NULL, it_bit_buff, + ptr_sbr_tables->ps_tables_ptr); + } + return 1; +} + +VOID ixheaacd_sbr_env_dtdf_data(ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 usac_flag) { + WORD32 i; + WORD32 num_env = ptr_frame_data->str_frame_info_details.num_env; + WORD32 num_noise_env = ptr_frame_data->str_frame_info_details.num_noise_env; + WORD16 *p_coding_dir_vec = ptr_frame_data->del_cod_dir_arr; + WORD16 *p_coding_dir_noise_vec = ptr_frame_data->del_cod_dir_noise_arr; + WORD32 usac_independency_flag = ptr_frame_data->usac_independency_flag; + + if (usac_flag) { + if (usac_independency_flag) { + *p_coding_dir_vec = 0; + p_coding_dir_vec++; + } else { + *p_coding_dir_vec = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + p_coding_dir_vec++; + } + for (i = num_env - 1; i >= 1; i--) { + *p_coding_dir_vec++ = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + } + if (usac_independency_flag) { + *p_coding_dir_noise_vec = 0; + p_coding_dir_noise_vec++; + } else { + *p_coding_dir_noise_vec = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + p_coding_dir_noise_vec++; + } + for (i = num_noise_env - 1; i >= 1; i--) { + *p_coding_dir_noise_vec++ = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + } + } else { + for (i = num_env - 1; i >= 0; i--) { + *p_coding_dir_vec++ = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + } + + for (i = num_noise_env - 1; i >= 0; i--) { + *p_coding_dir_noise_vec++ = + (WORD16)ixheaacd_read_bits_buf(it_bit_buff, SBR_DEL_COD_DIR_BITS); + } + } +} + +VOID ixheaacd_read_env_data(ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_huffman_data_type hcb_t, + ia_huffman_data_type hcb_f, WORD32 *idx_t, + WORD32 *idx_f, WORD16 *no_band, WORD32 num_env, + WORD32 env_data_tbl_comp_factor, WORD32 start_bits, + WORD32 start_bits_balance, WORD32 num_noise_env, + WORD32 lav, WORD32 usac_flag) { + WORD32 j, i, ixheaacd_drc_offset = 0, + coupling_mode = ptr_frame_data->coupling_mode, delta, bits, + shift; + WORD16 *p_coding_dir_vec, *p_sbr_sf; + WORD16 index, length; + WORD32 readword; + FLOAT32 *p_sbr_sf_float; + + if (num_noise_env) { + p_coding_dir_vec = ptr_frame_data->del_cod_dir_noise_arr; + p_sbr_sf = ptr_frame_data->int_noise_floor; + p_sbr_sf_float = ptr_frame_data->flt_noise_floor; + } else { + p_coding_dir_vec = ptr_frame_data->del_cod_dir_arr; + p_sbr_sf = ptr_frame_data->int_env_sf_arr; + p_sbr_sf_float = ptr_frame_data->flt_env_sf_arr; + } + + if (coupling_mode == COUPLING_BAL) { + bits = start_bits_balance; + shift = env_data_tbl_comp_factor; + + } else { + bits = start_bits; + shift = 0; + } + + for (j = 0; j < num_env; j++) { + ia_huffman_data_type h; + const WORD32 *idx_tab; + WORD32 dtdf_dir_flag = p_coding_dir_vec[j]; + + if (dtdf_dir_flag == DTDF_DIR_FREQ) { + p_sbr_sf[ixheaacd_drc_offset] = + (WORD16)(ixheaacd_read_bits_buf(it_bit_buff, bits) << shift); + p_sbr_sf_float[ixheaacd_drc_offset] = p_sbr_sf[ixheaacd_drc_offset]; + h = hcb_f; + idx_tab = idx_f; + } else { + h = hcb_t; + idx_tab = idx_t; + } + + for (i = (1 - dtdf_dir_flag); i < no_band[j]; i++) { + readword = ixheaacd_show_bits_buf(it_bit_buff, 20); + ixheaacd_huffman_decode(readword << 12, &index, &length, + (const UWORD16 *)h, (const UWORD32 *)idx_tab); + delta = index - lav; + ixheaacd_read_bits_buf(it_bit_buff, length); + p_sbr_sf[ixheaacd_drc_offset + i] = + (WORD16)(delta << env_data_tbl_comp_factor); + p_sbr_sf_float[ixheaacd_drc_offset + i] = + p_sbr_sf[ixheaacd_drc_offset + i]; + } + if (usac_flag && (num_noise_env == 0)) { + ptr_frame_data->inter_temp_shape_mode[j] = 0; + if (ptr_frame_data->inter_tes_flag) { + WORD32 flag = (WORD32)ixheaacd_read_bits_buf(it_bit_buff, 1); + if (flag) { + ptr_frame_data->inter_temp_shape_mode[j] = + (WORD32)ixheaacd_read_bits_buf(it_bit_buff, 2); + } + } + } + ixheaacd_drc_offset += (no_band[j]); + } +} + +VOID ixheaacd_read_sbr_noise_floor_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_env_extr_tables_struct *env_extr_tables_ptr) { + WORD32 i; + WORD32 coupling_mode; + WORD16 num_noise_bands[MAX_NOISE_ENVELOPES]; + ia_huffman_data_type hcb_noise_env; + ia_huffman_data_type hcb_noise; + WORD32 *idx_noise_env; + WORD32 *idx_noise; + WORD32 lav; + WORD32 env_data_tbl_comp_factor; + + WORD32 start_bits; + WORD32 start_bits_balance; + WORD32 num_noise_env = ptr_frame_data->str_frame_info_details.num_noise_env; + + for (i = 0; i < num_noise_env; i++) + num_noise_bands[i] = ptr_header_data->pstr_freq_band_data->num_nf_bands; + + start_bits = SBR_BEGIN_NOISE_BITS_AMPLITUDE_RESOLUTION_3_0; + start_bits_balance = SBR_BEGIN_NOISE_BITS_BALNCE_AMPLITUDE_RESOLUTION_3_0; + + coupling_mode = ptr_frame_data->coupling_mode; + + if (coupling_mode == COUPLING_BAL) { + lav = 12; + hcb_noise = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_noise_bal_3_0db_inp_table; + idx_noise = + env_extr_tables_ptr->ixheaacd_t_huffman_noise_bal_3_0db_idx_table; + hcb_noise_env = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_bal_3_0db_inp_table; + idx_noise_env = + env_extr_tables_ptr->ixheaacd_f_huffman_env_bal_3_0db_idx_table; + env_data_tbl_comp_factor = 1; + } else { + lav = 31; + hcb_noise = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_noise_3_0db_inp_table; + idx_noise = env_extr_tables_ptr->ixheaacd_t_huffman_noise_3_0db_idx_table; + hcb_noise_env = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_3_0db_inp_table; + idx_noise_env = env_extr_tables_ptr->ixheaacd_f_huffman_env_3_0db_idx_table; + env_data_tbl_comp_factor = 0; + } + + ixheaacd_read_env_data(ptr_frame_data, it_bit_buff, hcb_noise, hcb_noise_env, + idx_noise, idx_noise_env, &num_noise_bands[0], + num_noise_env, env_data_tbl_comp_factor, start_bits, + start_bits_balance, 1, lav, + ptr_header_data->usac_flag); +} + +WORD16 ixheaacd_read_sbr_env_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_env_extr_tables_struct *env_extr_tables_ptr, WORD audio_object_type) { + WORD32 coupling_mode = ptr_frame_data->coupling_mode; + WORD32 *idx_t, *idx_f; + WORD32 lav; + WORD32 i; + WORD16 no_band[MAX_ENVELOPES]; + WORD32 delta; + WORD32 amp_res, num_env, env_data_tbl_comp_factor, start_bits, + start_bits_balance; + WORD16 *p_freq_res = ptr_frame_data->str_frame_info_details.freq_res; + WORD16 *p_num_sf_bands = ptr_header_data->pstr_freq_band_data->num_sf_bands; + ia_huffman_data_type hcb_t, hcb_f; + + delta = 0; + amp_res = ptr_header_data->amp_res; + num_env = ptr_frame_data->str_frame_info_details.num_env; + + ptr_frame_data->num_env_sfac = 0; + + if ((ptr_frame_data->str_frame_info_details.frame_class == FIXFIX) && + (num_env == 1)) { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + amp_res = SBR_AMPLITUDE_RESOLUTION_1_5; + } else { + amp_res = ptr_frame_data->amp_res; + } + } + ptr_frame_data->amp_res = amp_res; + + if (amp_res == SBR_AMPLITUDE_RESOLUTION_3_0) { + start_bits = SBR_BEGIN_ENVN_BITS_AMPLITUDE_RESOLUTION_3_0; + start_bits_balance = SBR_BEGIN_ENVN_BITS_BALNCE_AMPLITUDE_RESOLUTION_3_0; + } else { + start_bits = SBR_BEGIN_ENVN_BITS_AMPLITUDE_RESOLUTION_1_5; + start_bits_balance = SBR_BEGIN_ENVN_BITS_BALNCE_AMPLITUDE_RESOLUTION_1_5; + } + + for (i = 0; i < num_env; i++) { + no_band[i] = p_num_sf_bands[*p_freq_res++]; + ptr_frame_data->num_env_sfac = + ixheaacd_add16(ptr_frame_data->num_env_sfac, no_band[i]); + } + + if (ptr_frame_data->num_env_sfac > MAX_NUM_ENVELOPE_VALUES) return 0; + + if (coupling_mode == COUPLING_BAL) { + env_data_tbl_comp_factor = 1; + + if (amp_res == SBR_AMPLITUDE_RESOLUTION_1_5) { + lav = 24; + hcb_t = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_env_bal_1_5db_inp_table; + idx_t = env_extr_tables_ptr->ixheaacd_t_huffman_env_bal_1_5db_idx_table; + hcb_f = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_bal_1_5db_inp_table; + idx_f = env_extr_tables_ptr->ixheaacd_f_huffman_env_bal_1_5db_idx_table; + } else { + lav = 12; + hcb_t = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_env_bal_3_0db_inp_table; + idx_t = env_extr_tables_ptr->ixheaacd_t_huffman_env_bal_3_0db_idx_table; + hcb_f = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_bal_3_0db_inp_table; + idx_f = env_extr_tables_ptr->ixheaacd_f_huffman_env_bal_3_0db_idx_table; + } + } else { + env_data_tbl_comp_factor = 0; + + if (amp_res == SBR_AMPLITUDE_RESOLUTION_1_5) { + lav = 60; + hcb_t = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_env_1_5db_inp_table; + idx_t = env_extr_tables_ptr->ixheaacd_t_huffman_env_1_5db_idx_table; + hcb_f = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_1_5db_inp_table; + idx_f = env_extr_tables_ptr->ixheaacd_f_huffman_env_1_5db_idx_table; + } else { + lav = 31; + hcb_t = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_t_huffman_env_3_0db_inp_table; + idx_t = env_extr_tables_ptr->ixheaacd_t_huffman_env_3_0db_idx_table; + hcb_f = (ia_huffman_data_type)&env_extr_tables_ptr + ->ixheaacd_f_huffman_env_3_0db_inp_table; + idx_f = env_extr_tables_ptr->ixheaacd_f_huffman_env_3_0db_idx_table; + } + } + + ixheaacd_read_env_data(ptr_frame_data, it_bit_buff, hcb_t, hcb_f, idx_t, + idx_f, &no_band[0], num_env, env_data_tbl_comp_factor, + start_bits, start_bits_balance, 0, lav, + ptr_header_data->usac_flag); + + return 1; +} + +int ixheaacd_extract_frame_info_ld( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *h_frame_data) { + int abs_bord_lead = 0, num_rel_lead = 0, num_rel_trail = 0, bs_num_env = 0, + frame_class, temp, env, k, abs_bord_trail = 0, middle_bord = 0, + bs_num_noise, transient_env_temp = 0, bs_transient_position = 0; + + WORD16 time_border[MAX_ENVELOPES + 1]; + WORD16 time_border_noise[2 + 1]; + WORD16 f[MAX_ENVELOPES + 1]; + int rel_bord_lead[3]; + int rel_bord_trail[3] = {0}; + + ia_frame_info_struct *v_frame_info = &h_frame_data->str_frame_info_details; + + int numTimeSlots = h_frame_data->num_time_slots; + + v_frame_info->frame_class = frame_class = + ixheaacd_read_bits_buf(it_bit_buff, SBRLD_CLA_BITS); + + switch (frame_class) { + case FIXFIX: + temp = ixheaacd_read_bits_buf(it_bit_buff, SBR_ENV_BITS); + bs_num_env = 1 << temp; + + if (bs_num_env == 1) + h_frame_data->amp_res = + ixheaacd_read_bits_buf(it_bit_buff, SBR_AMPLITUDE_RESOLUTION_BITS); + + f[0] = ixheaacd_read_bits_buf(it_bit_buff, SBR_RES_BITS); + + for (env = 1; env < bs_num_env; env++) f[env] = f[0]; + break; + case LD_TRAN: + bs_transient_position = + ixheaacd_read_bits_buf(it_bit_buff, SBR_TRAN_BITS); + v_frame_info->frame_class = 0; + bs_num_env = (numTimeSlots == 16) + ? ixheaacd_ld_env_table_512[bs_transient_position] + [SBR_ENVT_NUMENV] + : ixheaacd_ld_env_table_480[bs_transient_position] + [SBR_ENVT_NUMENV]; + for (env = 0; env < bs_num_env; env++) + f[env] = ixheaacd_read_bits_buf(it_bit_buff, SBR_RES_BITS); + break; + } + + switch (frame_class) { + case FIXFIX: + abs_bord_lead = 0; + abs_bord_trail = numTimeSlots; + num_rel_lead = bs_num_env - 1; + num_rel_trail = 0; + + for (k = 0; k < num_rel_lead; k++) { + rel_bord_lead[k] = ixheaacd_ld_env_table_time_slot[num_rel_lead - 1]; + } + + time_border[0] = abs_bord_lead; + time_border[bs_num_env] = abs_bord_trail; + for (env = 1; env <= num_rel_lead; env++) { + time_border[env] = abs_bord_lead; + for (k = 0; k <= env - 1; k++) time_border[env] += rel_bord_lead[k]; + } + for (env = num_rel_lead + 1; env < bs_num_env; env++) { + time_border[env] = abs_bord_trail; + for (k = 0; k <= bs_num_env - env - 1; k++) + time_border[env] -= rel_bord_trail[k]; + } + break; + + case LD_TRAN: + time_border[0] = 0; + time_border[bs_num_env] = numTimeSlots; + for (k = 1; k < bs_num_env; k++) + time_border[k] = + (numTimeSlots == 16) + ? ixheaacd_ld_env_table_512[bs_transient_position][k] + : ixheaacd_ld_env_table_480[bs_transient_position][k]; + break; + + default: + time_border[0] = 0; + + break; + }; + + switch (frame_class) { + case FIXFIX: + middle_bord = bs_num_env / 2; + break; + case LD_TRAN: + middle_bord = 1; + break; + }; + + time_border_noise[0] = time_border[0]; + if (bs_num_env > 1) { + time_border_noise[1] = time_border[middle_bord]; + time_border_noise[2] = time_border[bs_num_env]; + bs_num_noise = 2; + } else { + time_border_noise[1] = time_border[bs_num_env]; + bs_num_noise = 1; + } + + switch (frame_class) { + case FIXFIX: + transient_env_temp = -1; + break; + case LD_TRAN: + transient_env_temp = + (numTimeSlots == 16) + ? ixheaacd_ld_env_table_512[bs_transient_position] + [SBR_ENVT_TRANIDX] + : ixheaacd_ld_env_table_480[bs_transient_position] + [SBR_ENVT_TRANIDX]; + break; + }; + + v_frame_info->num_env = bs_num_env; + memcpy(v_frame_info->border_vec, time_border, + (bs_num_env + 1) * sizeof(WORD16)); + memcpy(v_frame_info->freq_res, f, bs_num_env * sizeof(WORD16)); + v_frame_info->transient_env = transient_env_temp; + v_frame_info->num_noise_env = bs_num_noise; + memcpy(v_frame_info->noise_border_vec, time_border_noise, + (bs_num_noise + 1) * sizeof(WORD16)); + + return 1; +} + +VOID ixheaacd_pvc_time_freq_grid_info( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *ptr_frame_data) { + WORD32 bs_num_env = 0, bs_num_noise = 0; + WORD32 time_border[MAX_ENVELOPES + 1]; + WORD32 time_border_noise[2 + 1]; + WORD32 pvc_time_border[MAX_ENVELOPES + 1]; + WORD32 pvc_time_border_noise[2 + 1]; + WORD32 bs_freq_res[MAX_ENVELOPES + 1]; + WORD32 var_len; + ia_frame_info_struct *p_frame_info = &ptr_frame_data->str_frame_info_details; + ia_frame_info_struct *pvc_frame_info = &ptr_frame_data->str_pvc_frame_info; + WORD32 i; + WORD32 prev_sbr_mode = ptr_frame_data->prev_sbr_mode; + + WORD32 tmp; + WORD32 bs_noise_pos; + bs_noise_pos = ixheaacd_read_bits_buf(it_bit_buff, 4); + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (tmp == 0) { + ptr_frame_data->var_len = 0; + } else { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 2); + ptr_frame_data->var_len = tmp + 1; + } + var_len = ptr_frame_data->var_len; + + if (p_frame_info->num_env > 0) { + time_border[0] = p_frame_info->border_vec[p_frame_info->num_env] - 16; + } else { + time_border[0] = 0; + } + + pvc_time_border[0] = 0; + bs_freq_res[0] = 0; + + if (bs_noise_pos == 0) { + time_border[1] = 16 + var_len; + pvc_time_border[1] = 16; + bs_num_noise = 1; + bs_num_env = 1; + } else { + time_border[1] = bs_noise_pos; + pvc_time_border[1] = bs_noise_pos; + time_border[2] = 16 + var_len; + pvc_time_border[2] = 16; + bs_freq_res[1] = 0; + bs_num_noise = 2; + bs_num_env = 2; + } + + for (i = 0; i < 3; i++) { + time_border_noise[i] = time_border[i]; + pvc_time_border_noise[i] = pvc_time_border[i]; + } + + if (prev_sbr_mode == ORIG_SBR) { + pvc_time_border[0] = time_border[0]; + pvc_time_border_noise[0] = time_border[0]; + } + + pvc_frame_info->num_env = bs_num_env; + for (i = 0; i < (bs_num_env + 1); i++) { + pvc_frame_info->border_vec[i] = pvc_time_border[i]; + } + for (i = 0; i < (bs_num_env); i++) { + pvc_frame_info->freq_res[i] = bs_freq_res[i]; + } + pvc_frame_info->transient_env = -1; + pvc_frame_info->num_noise_env = bs_num_noise; + for (i = 0; i < (bs_num_noise + 1); i++) { + pvc_frame_info->noise_border_vec[i] = pvc_time_border_noise[i]; + } + p_frame_info->num_env = bs_num_env; + for (i = 0; i < (bs_num_env + 1); i++) { + p_frame_info->border_vec[i] = time_border[i]; + } + for (i = 0; i < (bs_num_env); i++) { + p_frame_info->freq_res[i] = bs_freq_res[i]; + } + p_frame_info->transient_env = -1; + p_frame_info->num_noise_env = bs_num_noise; + for (i = 0; i < (bs_num_noise + 1); i++) { + p_frame_info->noise_border_vec[i] = time_border_noise[i]; + } +} + +WORD16 ixheaacd_sbr_time_freq_grid_info( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_env_extr_tables_struct *env_extr_tables_ptr) { + WORD32 i, k, bs_num_rel = 0; + WORD32 bs_pointer_bits = 0, bs_num_env = 0, border, bs_pointer, + 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}; + ia_frame_info_struct *p_fixfix_tab; + ia_frame_info_struct *p_frame_info = &ptr_frame_data->str_frame_info_details; + + frame_class = ixheaacd_read_bits_buf(it_bit_buff, SBR_FRAME_CLASS_BITS); + p_frame_info->frame_class = frame_class; + + switch (frame_class) { + case FIXFIX: + temp = + ixheaacd_read_bits_buf(it_bit_buff, SBR_ENV_BITS + SBR_FRQ_RES_BITS); + bs_num_env = (temp & 0x6) >> SBR_FRQ_RES_BITS; + p_fixfix_tab = &env_extr_tables_ptr->sbr_frame_info1_2_4_16[bs_num_env]; + memcpy(p_frame_info, p_fixfix_tab, sizeof(ia_frame_info_struct)); + bs_num_env = (1 << bs_num_env); + freq_res_0 = temp & 0x1; + + if (!freq_res_0) { + memset(&p_frame_info->freq_res[0], 0, sizeof(WORD16) * bs_num_env); + } + break; + case FIXVAR: + bs_var_bord = + ixheaacd_read_bits_buf(it_bit_buff, SBR_VAR_BORD_BITS + SBR_NUM_BITS); + bs_num_rel = bs_var_bord & 3; + bs_var_bord = bs_var_bord >> SBR_NUM_BITS; + bs_num_env = bs_num_rel + 1; + p_frame_info->border_vec[0] = 0; + border = bs_var_bord + SBR_TIME_SLOTS; + p_frame_info->border_vec[bs_num_env] = border; + for (k = bs_num_rel; k > 0; k--) { + temp = ixheaacd_read_bits_buf(it_bit_buff, SBR_REL_BITS); + border = border - ((temp << 1) + 2); + if (border < 0) border = 0; + p_frame_info->border_vec[k] = border; + } + + bs_pointer_bits = pointer_bits_array[bs_num_rel]; + bs_pointer = ixheaacd_read_bits_buf(it_bit_buff, bs_pointer_bits); + + if ((bs_pointer - (bs_num_rel + 1)) > 0) return 0; + + for (k = bs_num_rel; k >= 0; k--) { + p_frame_info->freq_res[k] = + ixheaacd_read_bits_buf(it_bit_buff, SBR_FRQ_RES_BITS); + } + if (bs_pointer) { + p_frame_info->transient_env = bs_num_env + 1 - bs_pointer; + } else { + p_frame_info->transient_env = -1; + } + if ((bs_pointer == 0) || (bs_pointer == 1)) + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[bs_num_rel]; + else + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[p_frame_info->transient_env]; + + break; + + case VARFIX: + bs_var_bord = + ixheaacd_read_bits_buf(it_bit_buff, SBR_VAR_BORD_BITS + SBR_NUM_BITS); + bs_num_rel = bs_var_bord & 3; + bs_var_bord = bs_var_bord >> SBR_NUM_BITS; + bs_num_env = bs_num_rel + 1; + + border = bs_var_bord; + p_frame_info->border_vec[0] = border; + for (k = 1; k <= bs_num_rel; k++) { + temp = ixheaacd_read_bits_buf(it_bit_buff, SBR_REL_BITS); + border = border + ((temp << 1) + 2); + if (border > SBR_TIME_SLOTS) border = SBR_TIME_SLOTS; + p_frame_info->border_vec[k] = border; + } + p_frame_info->border_vec[k] = SBR_TIME_SLOTS; + + bs_pointer_bits = pointer_bits_array[bs_num_rel]; + + bs_pointer = ixheaacd_read_bits_buf(it_bit_buff, bs_pointer_bits); + + if ((bs_pointer - (bs_num_rel + 1)) > 0) return 0; + + if (bs_pointer == 0 || (bs_pointer - 1) == 0) { + p_frame_info->transient_env = -1; + } else { + p_frame_info->transient_env = bs_pointer - 1; + } + + for (k = 0; k <= bs_num_rel; k++) { + p_frame_info->freq_res[k] = + ixheaacd_read_bits_buf(it_bit_buff, SBR_FRQ_RES_BITS); + } + + switch (bs_pointer) { + case 0: + p_frame_info->noise_border_vec[1] = p_frame_info->border_vec[1]; + break; + case 1: + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[bs_num_rel]; + break; + default: + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[(WORD32)p_frame_info->transient_env]; + break; + } + + break; + + case VARVAR: + abs_bord_lead = ixheaacd_read_bits_buf( + it_bit_buff, 2 * SBR_VAR_BORD_BITS + 2 * SBR_NUM_BITS); + abs_bord_trail = + (((abs_bord_lead & 0x30) >> (2 * SBR_NUM_BITS)) + SBR_TIME_SLOTS); + num_rel_trail = ((abs_bord_lead & 0xc) >> SBR_NUM_BITS); + num_rel_lead = (abs_bord_lead & 0x3); + abs_bord_lead = abs_bord_lead >> (SBR_VAR_BORD_BITS + 2 * SBR_NUM_BITS); + bs_num_env = ((num_rel_trail + num_rel_lead) + 1); + border = abs_bord_lead; + p_frame_info->border_vec[0] = border; + + for (k = 1; k <= num_rel_trail; k++) { + temp = ixheaacd_read_bits_buf(it_bit_buff, SBR_REL_BITS); + border = border + ((temp << 1) + 2); + p_frame_info->border_vec[k] = border; + } + + border = abs_bord_trail; + i = bs_num_env; + + p_frame_info->border_vec[i] = border; + + for (k = 0; k < num_rel_lead; k++) { + temp = ixheaacd_read_bits_buf(it_bit_buff, SBR_REL_BITS); + border = border - ((temp << 1) + 2); + i--; + p_frame_info->border_vec[i] = border; + } + bs_pointer_bits = pointer_bits_array[num_rel_trail + num_rel_lead]; + + bs_pointer = ixheaacd_read_bits_buf(it_bit_buff, bs_pointer_bits); + if ((bs_pointer - ((num_rel_trail + num_rel_lead) + 1)) > 0) return 0; + + if (bs_pointer) { + p_frame_info->transient_env = bs_num_env + 1 - bs_pointer; + } else { + p_frame_info->transient_env = -1; + } + + for (k = 0; k < bs_num_env; k++) { + p_frame_info->freq_res[k] = + ixheaacd_read_bits_buf(it_bit_buff, SBR_FRQ_RES_BITS); + } + p_frame_info->noise_border_vec[0] = abs_bord_lead; + if (bs_num_env == 1) { + p_frame_info->noise_border_vec[1] = abs_bord_trail; + } else { + if (bs_pointer == 0 || (bs_pointer - 1) == 0) + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[bs_num_env - 1]; + else + p_frame_info->noise_border_vec[1] = + p_frame_info->border_vec[(WORD32)p_frame_info->transient_env]; + + p_frame_info->noise_border_vec[2] = abs_bord_trail; + } + break; + } + p_frame_info->num_env = bs_num_env; + + if (bs_num_env == 1) + p_frame_info->num_noise_env = 1; + else + p_frame_info->num_noise_env = 2; + + if (frame_class == VARFIX || frame_class == FIXVAR) { + p_frame_info->noise_border_vec[0] = p_frame_info->border_vec[0]; + p_frame_info->noise_border_vec[p_frame_info->num_noise_env] = + p_frame_info->border_vec[bs_num_env]; + } + return 1; +} diff --git a/decoder/ixheaacd_env_extr.h b/decoder/ixheaacd_env_extr.h new file mode 100644 index 0000000..9535217 --- /dev/null +++ b/decoder/ixheaacd_env_extr.h @@ -0,0 +1,185 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ENV_EXTR_H +#define IXHEAACD_ENV_EXTR_H + +#define ENV_EXP_FRACT 0 + +#define EXP_BITS 6 + +#define MASK_M (((1 << (SHORT_BITS - EXP_BITS)) - 1) << EXP_BITS) +#define MASK_FOR_EXP ((1 << EXP_BITS) - 1) + +#define SIGN_EXT (((WORD8)-1) ^ MASK_FOR_EXP) +#define ROUNDING (1 << (EXP_BITS - 1)) +#define NRG_EXP_OFFSET 16 +#define NOISE_EXP_OFFSET 38 + +typedef const UWORD16 *ia_huffman_data_type; + +#define COUPLING_OFF 0 +#define COUPLING_LEVEL 1 +#define COUPLING_BAL 2 + +#define MAX_INVF_BANDS MAX_NOISE_COEFFS + +typedef struct { + WORD16 sfb_nrg_prev[MAX_FREQ_COEFFS]; + WORD16 prev_noise_level[MAX_NOISE_COEFFS]; + WORD16 amp_res; + WORD16 end_position; + WORD32 max_qmf_subband_aac; + WORD32 coupling_mode; + WORD32 sbr_invf_mode[MAX_NUM_NOISE_VALUES]; +} ia_sbr_prev_frame_data_struct; + +typedef struct { + WORD16 num_env_sfac; + ia_frame_info_struct str_frame_info_details; + WORD16 del_cod_dir_arr[MAX_ENVELOPES]; + WORD16 del_cod_dir_noise_arr[MAX_NOISE_ENVELOPES]; + WORD32 sbr_invf_mode[MAX_NUM_NOISE_VALUES]; + WORD32 coupling_mode; + WORD16 amp_res; + WORD32 max_qmf_subband_aac; + FLAG add_harmonics[MAX_FREQ_COEFFS]; + WORD16 int_env_sf_arr[MAX_NUM_ENVELOPE_VALUES]; + WORD16 int_noise_floor[MAX_NUM_NOISE_VALUES]; + WORD32 num_noise_sfac; + ia_frame_info_struct str_pvc_frame_info; + WORD32 env_short_flag_prev; + ia_sbr_header_data_struct *pstr_sbr_header; + WORD32 num_time_slots; + WORD32 rate; + WORD32 sbr_patching_mode; + WORD32 prev_sbr_patching_mode; + WORD32 over_sampling_flag; + WORD32 pitch_in_bins; + WORD32 pvc_mode; + + WORD32 sbr_invf_mode_prev[MAX_NUM_NOISE_VALUES]; + FLOAT32 flt_env_sf_arr[MAX_NUM_ENVELOPE_VALUES]; + FLOAT32 flt_noise_floor[MAX_NUM_NOISE_VALUES]; + FLOAT32 sfb_nrg_prev[MAX_FREQ_COEFFS]; + FLOAT32 prev_noise_level[MAX_NUM_NOISE_VALUES]; + WORD32 inter_temp_shape_mode[MAX_ENVELOPES]; + WORD32 var_len; + WORD32 bs_sin_pos_present; + WORD32 sine_position; + WORD32 sin_start_for_next_top; + WORD32 sin_len_for_next_top; + WORD32 sin_start_for_cur_top; + WORD32 sin_len_for_cur_top; + WORD32 var_len_id_prev; + ia_frame_info_struct str_frame_info_prev; + FLOAT32 bw_array_prev[MAX_NUM_PATCHES]; + struct ixheaacd_lpp_trans_patch patch_param; + WORD32 harm_index; + WORD32 phase_index; + WORD8 harm_flag_prev[64]; + FLOAT32 e_gain[5][64]; + FLOAT32 noise_buf[5][64]; + WORD32 lim_table[4][12 + 1]; + 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]; + WORD32 stereo_config_idx; + FLAG reset_flag; + FLAG mps_sbr_flag; + FLAG usac_independency_flag; + FLAG inter_tes_flag; + FLAG sbr_mode; + FLAG prev_sbr_mode; + WORD32 eld_sbr_flag; + +} ia_sbr_frame_info_data_struct; + +WORD8 ixheaacd_sbr_read_sce(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_ps_dec_struct *ptr_ps_dec, + ia_bit_buf_struct *it_bit_buff, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD audio_object_type); + +WORD8 ixheaacd_sbr_read_cpe(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct **ptr_frame_data, + ia_bit_buf_struct *itt_bit_buf, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD audio_object_type); + +WORD32 ixheaacd_sbr_read_header_data( + ia_sbr_header_data_struct *ptr_sbr_header, ia_bit_buf_struct *it_bit_buf, + FLAG stereo_flag, ia_sbr_header_data_struct *ptr_sbr_dflt_header); + +WORD32 ixheaacd_ssc_huff_dec(ia_huffman_data_type h, + ia_bit_buf_struct *it_bit_buff); + +int ixheaacd_extract_frame_info_ld(ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *h_frame_data); + +VOID ixheaacd_pvc_time_freq_grid_info( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *ptr_frame_data); + +WORD16 ixheaacd_sbr_time_freq_grid_info( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_env_extr_tables_struct *env_extr_tables_ptr); + +WORD16 ixheaacd_read_sbr_env_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_env_extr_tables_struct *env_extr_tables_ptr, WORD audio_object_type); + +VOID ixheaacd_sbr_env_dtdf_data(ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 usac_flag); + +VOID ixheaacd_read_sbr_noise_floor_data( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + ia_env_extr_tables_struct *env_extr_tables_ptr); + +VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len, + const UWORD16 *input_table, + const UWORD32 *idx_table); + +VOID ixheaacd_createlimiterbands(WORD32 lim_table[4][12 + 1], + WORD32 gate_mode[4], WORD16 *freq_band_tbl, + WORD32 ixheaacd_num_bands, + WORD32 x_over_qmf[MAX_NUM_PATCHES], + WORD32 b_patching_mode, WORD32 upsamp_4_flag, + struct ixheaacd_lpp_trans_patch *patch_param); + +VOID ixheaacd_apply_inter_tes(FLOAT32 *qmf_real1, FLOAT32 *qmf_imag1, + FLOAT32 *qmf_real, FLOAT32 *qmf_imag, + WORD32 num_sample, WORD32 sub_band_start, + WORD32 num_subband, WORD32 gamma_idx); + +#endif diff --git a/decoder/ixheaacd_env_extr_part.h b/decoder/ixheaacd_env_extr_part.h new file mode 100644 index 0000000..fc38546 --- /dev/null +++ b/decoder/ixheaacd_env_extr_part.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ENV_EXTR_PART_H +#define IXHEAACD_ENV_EXTR_PART_H + +#define SBR_NOT_INITIALIZED 0 +#define UPSAMPLING 1 +#define SBR_ACTIVE 2 + +#define SBR_MONO 1 +#define SBR_STEREO 2 +#define PS_STEREO 3 + +#define SBR_RESET 1 + +typedef struct { + WORD16 num_sf_bands[2]; + WORD16 num_nf_bands; + WORD16 num_mf_bands; + WORD16 sub_band_start; + WORD16 sub_band_end; + WORD16 freq_band_tbl_lim[MAX_NUM_LIMITERS + 1]; + WORD16 num_lf_bands; + WORD16 num_if_bands; + WORD16 *freq_band_table[2]; + WORD16 freq_band_tbl_lo[MAX_FREQ_COEFFS / 2 + 1]; + WORD16 freq_band_tbl_hi[MAX_FREQ_COEFFS + 1]; + WORD16 freq_band_tbl_noise[MAX_NOISE_COEFFS + 1]; + WORD16 f_master_tbl[MAX_FREQ_COEFFS + 1]; + + WORD16 qmf_sb_prev; +} ia_freq_band_data_struct; + +typedef struct { + WORD32 sync_state; + FLAG err_flag; + FLAG err_flag_prev; + WORD16 num_time_slots; + WORD16 time_step; + WORD16 core_frame_size; + WORD32 out_sampling_freq; + + WORD32 channel_mode; + WORD16 amp_res; + + WORD16 start_freq; + WORD16 stop_freq; + WORD16 xover_band; + WORD16 freq_scale; + WORD16 alter_scale; + WORD16 noise_bands; + + WORD16 limiter_bands; + WORD16 limiter_gains; + WORD16 interpol_freq; + WORD16 smoothing_mode; + ia_freq_band_data_struct *pstr_freq_band_data; + + WORD16 header_extra_1; + WORD16 header_extra_2; + WORD16 pre_proc_flag; + + WORD32 status; + + WORD32 sbr_ratio_idx; + WORD32 upsamp_fac; + WORD32 is_usf_4; + WORD32 output_framesize; + WORD32 usac_independency_flag; + FLAG pvc_flag; + FLAG hbe_flag; + + WORD32 esbr_start_up; + WORD32 esbr_start_up_pvc; + WORD32 usac_flag; + UWORD8 pvc_mode; + +} ia_sbr_header_data_struct; + +typedef struct { + WORD16 frame_class; + WORD16 num_env; + WORD16 transient_env; + WORD16 num_noise_env; + WORD16 border_vec[MAX_ENVELOPES + 1]; + WORD16 freq_res[MAX_ENVELOPES]; + WORD16 noise_border_vec[MAX_NOISE_ENVELOPES + 1]; +} ia_frame_info_struct; + +#endif diff --git a/decoder/ixheaacd_error_codes.h b/decoder/ixheaacd_error_codes.h new file mode 100644 index 0000000..3476657 --- /dev/null +++ b/decoder/ixheaacd_error_codes.h @@ -0,0 +1,114 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ERROR_CODES_H +#define IXHEAACD_ERROR_CODES_H + +/*****************************************************************************/ +/* Class 0: API Errors */ +/*****************************************************************************/ +/* Non Fatal Errors */ +#define IA_ENHAACPLUS_DEC_API_NONFATAL_NO_ERROR 0x00000000 +#define IA_ENHAACPLUS_DEC_API_NONFATAL_CMD_NOT_SUPPORTED 0x00000001 +#define IA_ENHAACPLUS_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED 0x00000002 +/* Fatal Errors */ +#define IA_ENHAACPLUS_DEC_API_FATAL_INVALID_MEMTAB_INDEX 0xFFFF8000 +#define IA_ENHAACPLUS_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX 0xFFFF8001 +#define IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALLOC 0xFFFF8002 +#define IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM 0xFFFF8003 +#define IA_ENHAACPLUS_DEC_API_FATAL_INVALID_EXECUTE_TYPE 0xFFFF8004 +#define IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CMD 0xFFFF8005 +#define IA_ENHAACPLUS_DEC_API_FATAL_MEM_ALIGN 0xFFFF8006 +/*****************************************************************************/ +/* Class 1: Configuration Errors */ +/*****************************************************************************/ +/* Non Fatal Errors */ +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_PCM_WDSZ 0x00000800 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DOWNMIX 0x00000801 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_OUT08KHZ 0x00000802 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_OUT16KHZ 0x00000803 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_TOSTEREO 0x00000804 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DSAMPLE 0x00000805 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_FRAMEOK 0x00000806 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MP4FLAG 0x00000807 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL 0x00000808 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_COUP_CHANNEL 0x00000809 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_FEATURE_NOT_SUPPORTED 0x0000080A +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_SYNCFLAG 0x0000080B +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_SBRUPFLAG 0x0000080C + +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_LOASFLAG 0x0000080D + +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRCFLAG 0x0000080E +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_CUT 0x0000080F +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_BOOST 0x00000810 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_TARGET 0x00000811 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_FRAMSZ 0x00000812 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_ELDSBR 0x00000813 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE 0x00000804 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000805 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG 0x00000806 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX 0x00000807 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY 0x00000808 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CONST_DELAY_MODE 0x00000809 + +// Fatal Errors +#define IA_ENHAACPLUS_DEC_CONFIG_FATAL_INVALID_SAMPLE_RATE 0xFFFF8800 + +// Class 2: Initialization Errors + +// Non Fatal Errors +#define IA_ENHAACPLUS_DEC_INIT_NONFATAL_BOTH_16AND08OUT 0x00001000 +#define IA_ENHAACPLUS_DEC_INIT_NONFATAL_NO_UPSAMPLING 0x00001001 +#define IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START 0x00001002 + +// Fatal Errors +#define IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL 0xFFFF9000 +#define IA_ENHAACPLUS_DEC_INIT_FATAL_EO_INPUT_REACHED 0xFFFF9001 +#define IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX 0xFFFF9002 +#define IA_ENHAACPLUS_DEC_INIT_FATAL_AUDIOOBJECTTYPE_NOT_SUPPORTED 0xFFFF9003 + +// Class 3: Execution Errors + +// Non Fatal Errors +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_ADTS_SYNC_LOST 0x00001800 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_SBR_TURNED_OFF 0x00001801 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_SBR_TURNED_ON 0x00001802 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_ADTS_HDR_CRC_FAIL 0x00001803 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES 0x00001804 + +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_ELE_INSTANCE_TAG_NOT_FOUND 0x00001805 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL 0x00001806 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR 0x00001807 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_SFB_TRANSMITTED 0x00001808 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_GAIN_CONTROL_DATA_PRESENT 0x00001809 +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_TNS_ORDER_ERROR 0x0000180A +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_PREDICTION_DATA_PRESENT 0x0000180B +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_CHANGED_ADTS_SF 0x0000180C +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_PULSEDATA_ERROR 0x0000180D +#define IA_ENHAACPLUS_DEC_EXE_NONFATAL_INVALID_CODE_BOOK 0x0000180E + +// Fatal Errors +#define IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE 0xFFFF9800 +#define IA_ENHAACPLUS_DEC_EXE_FATAL_TNS_RANGE_ERROR 0xFFFF9801 +#define IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER 0xFFFF9802 +#define IA_AACLD_DEC_EXE_FATAL_ER_PROFILE_UNSUPPORTED 0xFFFF9803 +#define IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_DRC_DATA 0xFFFF9804 + +#endif /* IXHEAACD_ERROR_CODES_H */ diff --git a/decoder/ixheaacd_error_handler.h b/decoder/ixheaacd_error_handler.h new file mode 100644 index 0000000..83cbdc1 --- /dev/null +++ b/decoder/ixheaacd_error_handler.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ERROR_HANDLER_H +#define IXHEAACD_ERROR_HANDLER_H + +#define IA_ERROR_NON_FATAL_IDX 0x0 +#define IA_ERROR_FATAL_IDX 0x1 + +#define IA_ERROR_CLASS_0 0x0 +#define IA_ERROR_CLASS_1 0x1 +#define IA_ERROR_CLASS_2 0x2 +#define IA_ERROR_CLASS_3 0x3 +#define IA_ERROR_CLASS_4 0x4 +#define IA_ERROR_CLASS_5 0x5 +#define IA_ERROR_CLASS_6 0x6 +#define IA_ERROR_CLASS_7 0x7 +#define IA_ERROR_CLASS_8 0x8 +#define IA_ERROR_CLASS_9 0x9 +#define IA_ERROR_CLASS_A 0xA +#define IA_ERROR_CLASS_B 0xB +#define IA_ERROR_CLASS_C 0xC +#define IA_ERROR_CLASS_D 0xD +#define IA_ERROR_CLASS_E 0xE +#define IA_ERROR_CLASS_F 0xF + +typedef struct { + pWORD8 pb_module_name; + pWORD8 ppb_class_names[16]; + WORD8 **ppppb_error_msg_pointers[2][16]; +} ia_error_info_struct; + +IA_ERRORCODE ixheaacd_error_handler(ia_error_info_struct *p_mod_err_info, + WORD8 *pb_context, IA_ERRORCODE code); + +#define _IA_HANDLE_ERROR(p_mod_err_info, context, e) \ + if ((e) != IA_NO_ERROR) { \ + ixheaacd_error_handler((p_mod_err_info), (context), (e)); \ + if ((e)&IA_FATAL_ERROR) return (e); \ + } + +#endif /* IXHEAACD_ERROR_HANDLER_H */ diff --git a/decoder/ixheaacd_error_standards.h b/decoder/ixheaacd_error_standards.h new file mode 100644 index 0000000..736a659 --- /dev/null +++ b/decoder/ixheaacd_error_standards.h @@ -0,0 +1,29 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ERROR_STANDARDS_H +#define IXHEAACD_ERROR_STANDARDS_H + +typedef WORD32 IA_ERRORCODE; + +#define IA_NO_ERROR 0x00000000 + +#define IA_FATAL_ERROR 0x80000000 + +#endif /* IXHEAACD_ERROR_STANDARDS_H */ diff --git a/decoder/ixheaacd_esbr_envcal.c b/decoder/ixheaacd_esbr_envcal.c new file mode 100644 index 0000000..53aacef --- /dev/null +++ b/decoder/ixheaacd_esbr_envcal.c @@ -0,0 +1,960 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include + +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbr_common.h" +#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 +#include "ixheaacd_common_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_freq_sca.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_esbr_rom.h" + +VOID ixheaacd_shellsort(WORD32 *in, WORD32 n) { + WORD32 i, j, v; + WORD32 inc = 1; + + do + inc = 3 * inc + 1; + while (inc <= n); + + do { + inc = inc / 3; + for (i = inc + 1; i <= n; i++) { + v = in[i - 1]; + j = i; + while (in[j - inc - 1] > v) { + in[j - 1] = in[j - inc - 1]; + j -= inc; + if (j <= inc) break; + } + in[j - 1] = v; + } + } while (inc > 1); +} + +VOID ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, + FLOAT32 input_real[][64], FLOAT32 input_imag[][64], + FLOAT32 input_real1[][64], FLOAT32 input_imag1[][64], + WORD32 x_over_qmf[MAX_NUM_PATCHES], + FLOAT32 *scratch_buff, FLOAT32 *env_out) { + WORD8 harmonics[64]; + FLOAT32(*env_tmp)[48]; + FLOAT32(*noise_level_pvc)[48]; + FLOAT32(*nrg_est_pvc)[48]; + FLOAT32(*nrg_ref_pvc)[48]; + FLOAT32(*nrg_gain_pvc)[48]; + FLOAT32(*nrg_tone_pvc)[48]; + + WORD32 n, c, li, ui, i, j, k = 0, l, m = 0, kk = 0, o, next = -1, ui2, flag, + tmp, noise_absc_flag, smooth_length; + WORD32 upsamp_4_flag = frame_data->pstr_sbr_header->is_usf_4; + + FLOAT32 *ptr_real_buf, *ptr_imag_buf, nrg = 0, p_ref, p_est, avg_gain, g_max, + p_adj, boost_gain, sb_gain, sb_noise, + temp[64]; + + WORD32 t; + WORD32 start_pos = 0; + WORD32 end_pos = 0; + + WORD32 slot_idx; + + FLOAT32 *prev_env_noise_level = frame_data->prev_noise_level; + FLOAT32 *nrg_tone = scratch_buff; + FLOAT32 *noise_level = scratch_buff + 64; + FLOAT32 *nrg_est = scratch_buff + 128; + FLOAT32 *nrg_ref = scratch_buff + 192; + FLOAT32 *nrg_gain = scratch_buff + 256; + + const FLOAT32 *smooth_filt; + + FLOAT32 *sfb_nrg = frame_data->flt_env_sf_arr; + FLOAT32 *noise_floor = frame_data->flt_noise_floor; + ia_frame_info_struct *p_frame_info = &frame_data->str_frame_info_details; + + ia_frame_info_struct *pvc_frame_info = &frame_data->str_pvc_frame_info; + WORD32 smoothing_length = frame_data->pstr_sbr_header->smoothing_mode ? 0 : 4; + WORD32 int_mode = frame_data->pstr_sbr_header->interpol_freq; + WORD32 limiter_band = frame_data->pstr_sbr_header->limiter_bands; + WORD32 limiter_gains = frame_data->pstr_sbr_header->limiter_gains; + WORD32 *add_harmonics = frame_data->add_harmonics; + WORD32 sub_band_start = + frame_data->pstr_sbr_header->pstr_freq_band_data->sub_band_start; + WORD32 sub_band_end = + frame_data->pstr_sbr_header->pstr_freq_band_data->sub_band_end; + WORD32 reset = frame_data->reset_flag; + WORD32 num_subbands = sub_band_end - sub_band_start; + WORD32 bs_num_env = p_frame_info->num_env; + WORD32 trans_env = p_frame_info->transient_env; + WORD32 sbr_mode = frame_data->sbr_mode; + WORD32 prev_sbr_mode = frame_data->prev_sbr_mode; + + WORD16 *freq_band_table[2]; + const WORD16 *num_sf_bands = + frame_data->pstr_sbr_header->pstr_freq_band_data->num_sf_bands; + WORD16 *freq_band_table_noise = + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_tbl_noise; + WORD32 num_nf_bands = + frame_data->pstr_sbr_header->pstr_freq_band_data->num_nf_bands; + + WORD32 harm_index = frame_data->harm_index; + WORD32 phase_index = frame_data->phase_index; + WORD32 esbr_start_up = frame_data->pstr_sbr_header->esbr_start_up; + WORD32 esbr_start_up_pvc = frame_data->pstr_sbr_header->esbr_start_up_pvc; + WORD8(*harm_flag_prev)[64] = &frame_data->harm_flag_prev; + FLOAT32(*e_gain)[5][64] = &frame_data->e_gain; + FLOAT32(*noise_buf)[5][64] = &frame_data->noise_buf; + WORD32(*lim_table)[4][12 + 1] = &frame_data->lim_table; + WORD32(*gate_mode)[4] = &frame_data->gate_mode; + WORD32 freq_inv = 1; + + WORD8(*harm_flag_varlen_prev)[64] = &frame_data->harm_flag_varlen_prev; + WORD8(*harm_flag_varlen)[64] = &frame_data->harm_flag_varlen; + WORD32 band_loop_end; + + WORD32 rate = upsamp_4_flag ? 4 : 2; + + env_tmp = frame_data->env_tmp; + noise_level_pvc = frame_data->noise_level_pvc; + nrg_est_pvc = frame_data->nrg_est_pvc; + nrg_ref_pvc = frame_data->nrg_ref_pvc; + nrg_gain_pvc = frame_data->nrg_gain_pvc; + nrg_tone_pvc = frame_data->nrg_tone_pvc; + + freq_band_table[0] = + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_table[0]; + freq_band_table[1] = + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_table[1]; + + if (reset) { + esbr_start_up = 1; + esbr_start_up_pvc = 1; + phase_index = 0; + ixheaacd_createlimiterbands( + (*lim_table), (*gate_mode), + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_tbl_lo, + num_sf_bands[LOW], x_over_qmf, frame_data->sbr_patching_mode, + upsamp_4_flag, &frame_data->patch_param); + } + + if (frame_data->sbr_patching_mode != frame_data->prev_sbr_patching_mode) { + ixheaacd_createlimiterbands( + (*lim_table), (*gate_mode), + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_tbl_lo, + num_sf_bands[LOW], x_over_qmf, frame_data->sbr_patching_mode, + upsamp_4_flag, &frame_data->patch_param); + + frame_data->prev_sbr_patching_mode = frame_data->sbr_patching_mode; + } + + memset(harmonics, 0, 64 * sizeof(WORD8)); + + if (sbr_mode == PVC_SBR) { + for (i = 0; i < num_sf_bands[HIGH]; i++) { + li = + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_tbl_hi[i]; + ui = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_hi[i + 1]; + tmp = ((ui + li) - (sub_band_start << 1)) >> 1; + + harmonics[tmp] = add_harmonics[i]; + } + + for (t = 0; t < p_frame_info->border_vec[0]; t++) { + for (c = 0; c < 64; c++) { + frame_data->qmapped_pvc[c][t] = frame_data->qmapped_pvc[c][t + 16]; + } + } + + for (i = 0; i < bs_num_env; i++) { + 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]; + + for (t = start_pos; t < end_pos; t++) { + band_loop_end = num_sf_bands[p_frame_info->freq_res[i]]; + + for (c = 0, o = 0, j = 0; j < band_loop_end; j++) { + li = freq_band_table[p_frame_info->freq_res[i]][j]; + ui = freq_band_table[p_frame_info->freq_res[i]][j + 1]; + ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_noise[o + 1]; + + for (k = 0; k < ui - li; k++) { + o = (k + li >= ui2) ? o + 1 : o; + ui2 = freq_band_table_noise[o + 1]; + + frame_data->qmapped_pvc[c][t] = + noise_floor[next * num_nf_bands + o]; + c++; + } + } + } + } + + kk = 0; + next = -1; + + for (i = 0; i < bs_num_env; i++) { + 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]; + + for (t = start_pos; t < end_pos; t++) { + for (c = 0; c < 64; c++) { + env_tmp[c][t] = env_out[64 * t + c]; + } + } + + noise_absc_flag = + (i == trans_env || i == frame_data->env_short_flag_prev) ? 1 : 0; + + if (prev_sbr_mode == ORIG_SBR) noise_absc_flag = 0; + + smooth_length = (noise_absc_flag ? 0 : smoothing_length); + smooth_filt = *ixheaacd_fir_table[smooth_length]; + + for (t = start_pos; t < frame_data->sin_len_for_cur_top; t++) { + band_loop_end = + num_sf_bands[frame_data->str_frame_info_prev + .freq_res[frame_data->var_len_id_prev]]; + + for (c = 0, o = 0, j = 0; j < band_loop_end; j++) { + double tmp; + + li = freq_band_table[frame_data->str_frame_info_prev + .freq_res[frame_data->var_len_id_prev]][j]; + ui = freq_band_table[frame_data->str_frame_info_prev + .freq_res[frame_data->var_len_id_prev]] + [j + 1]; + ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_noise[o + 1]; + + for (flag = 0, k = li; k < ui; k++) { + flag = ((*harm_flag_varlen)[c] && + (t >= frame_data->sin_start_for_cur_top || + (*harm_flag_varlen_prev)[c + sub_band_start])) + ? 1 + : flag; + + nrg_ref_pvc[c][t] = env_tmp[k][t]; + for (nrg = 0, l = 0; l < rate; l++) { + nrg += + (input_real[rate * t + l][k] * input_real[rate * t + l][k]) + + (input_imag[rate * t + l][k] * input_imag[rate * t + l][k]); + } + nrg_est_pvc[c][t] = nrg / rate; + c++; + } + + if (!int_mode) { + for (nrg = 0, k = c - (ui - li); k < c; k++) { + nrg += nrg_est_pvc[k][t]; + } + nrg /= (ui - li); + } + c -= (ui - li); + + for (k = 0; k < ui - li; k++) { + o = (k + li >= ui2) ? o + 1 : o; + 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; + + tmp = frame_data->qmapped_pvc[c][t] / + (1 + frame_data->qmapped_pvc[c][t]); + + if (flag) { + nrg_gain_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp / + (nrg_est_pvc[c][t] + 1)); + + nrg_tone_pvc[c][t] = (FLOAT32)( + (harmonics[c] && (t >= frame_data->sine_position || + (*harm_flag_prev)[c + sub_band_start])) + ? sqrt(nrg_ref_pvc[c][t] * tmp / + frame_data->qmapped_pvc[c][t]) + : nrg_tone_pvc[c][t]); + + nrg_tone_pvc[c][t] = (FLOAT32)( + ((*harm_flag_varlen)[c] && + (t >= frame_data->sin_start_for_cur_top || + (*harm_flag_varlen_prev)[c + sub_band_start])) + ? sqrt(nrg_ref_pvc[c][t] * tmp / prev_env_noise_level[o]) + : nrg_tone_pvc[c][t]); + + } else { + if (noise_absc_flag) { + nrg_gain_pvc[c][t] = + (FLOAT32)sqrt(nrg_ref_pvc[c][t] / (nrg_est_pvc[c][t] + 1)); + } else { + nrg_gain_pvc[c][t] = (FLOAT32)sqrt( + nrg_ref_pvc[c][t] * tmp / + ((nrg_est_pvc[c][t] + 1) * frame_data->qmapped_pvc[c][t])); + } + } + + noise_level_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp); + c++; + } + } + + for (c = 0; c < (*gate_mode)[limiter_band]; c++) { + p_ref = p_est = 0.0f; + p_adj = 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + p_ref += nrg_ref_pvc[k][t]; + p_est += nrg_est_pvc[k][t]; + } + avg_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_est + EPS)); + g_max = avg_gain * ixheaacd_g_lim_gains[limiter_gains]; + g_max > 1.0e5f ? g_max = 1.0e5f : 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + if (g_max <= nrg_gain_pvc[k][t]) { + noise_level_pvc[k][t] = + noise_level_pvc[k][t] * (g_max / nrg_gain_pvc[k][t]); + nrg_gain_pvc[k][t] = g_max; + } + + p_adj += + nrg_gain_pvc[k][t] * nrg_gain_pvc[k][t] * nrg_est_pvc[k][t]; + + if (nrg_tone_pvc[k][t]) { + p_adj += nrg_tone_pvc[k][t] * nrg_tone_pvc[k][t]; + } else if (!noise_absc_flag) { + p_adj += noise_level_pvc[k][t] * noise_level_pvc[k][t]; + } + } + boost_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_adj + EPS)); + boost_gain = boost_gain > 1.584893192f ? 1.584893192f : boost_gain; + + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + nrg_gain_pvc[k][t] *= boost_gain; + noise_level_pvc[k][t] *= boost_gain; + nrg_tone_pvc[k][t] *= boost_gain; + } + } + } + + for (; t < end_pos; t++) { + band_loop_end = num_sf_bands[pvc_frame_info->freq_res[i]]; + + for (c = 0, o = 0, j = 0; j < band_loop_end; j++) { + double tmp; + + li = freq_band_table[pvc_frame_info->freq_res[i]][j]; + ui = freq_band_table[pvc_frame_info->freq_res[i]][j + 1]; + ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_noise[o + 1]; + + for (flag = 0, k = li; k < ui; k++) { + flag = (harmonics[c] && (t >= frame_data->sine_position || + (*harm_flag_prev)[c + sub_band_start])) + ? 1 + : flag; + + nrg_ref_pvc[c][t] = env_tmp[k][t]; + for (nrg = 0, l = 0; l < rate; l++) { + nrg += + (input_real[rate * t + l][k] * input_real[rate * t + l][k]) + + (input_imag[rate * t + l][k] * input_imag[rate * t + l][k]); + } + nrg_est_pvc[c][t] = nrg / rate; + c++; + } + + if (!int_mode) { + for (nrg = 0, k = c - (ui - li); k < c; k++) { + nrg += nrg_est_pvc[k][t]; + } + nrg /= (ui - li); + } + c -= (ui - li); + + for (k = 0; k < ui - li; k++) { + o = (k + li >= ui2) ? o + 1 : o; + 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; + + tmp = frame_data->qmapped_pvc[c][t] / + (1 + frame_data->qmapped_pvc[c][t]); + + if (flag) { + nrg_gain_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp / + (nrg_est_pvc[c][t] + 1)); + + nrg_tone_pvc[c][t] = (FLOAT32)( + (harmonics[c] && (t >= frame_data->sine_position || + (*harm_flag_prev)[c + sub_band_start])) + ? sqrt(nrg_ref_pvc[c][t] * tmp / + frame_data->qmapped_pvc[c][t]) + : nrg_tone_pvc[c][t]); + } else { + if (noise_absc_flag) { + nrg_gain_pvc[c][t] = + (FLOAT32)sqrt(nrg_ref_pvc[c][t] / (nrg_est_pvc[c][t] + 1)); + } else { + nrg_gain_pvc[c][t] = (FLOAT32)sqrt( + nrg_ref_pvc[c][t] * tmp / + ((nrg_est_pvc[c][t] + 1) * frame_data->qmapped_pvc[c][t])); + } + } + + noise_level_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp); + c++; + } + } + + for (c = 0; c < (*gate_mode)[limiter_band]; c++) { + p_ref = p_est = 0.0f; + p_adj = 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + p_ref += nrg_ref_pvc[k][t]; + p_est += nrg_est_pvc[k][t]; + } + avg_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_est + EPS)); + g_max = avg_gain * ixheaacd_g_lim_gains[limiter_gains]; + g_max > 1.0e5f ? g_max = 1.0e5f : 0; + + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + if (g_max <= nrg_gain_pvc[k][t]) { + noise_level_pvc[k][t] = + noise_level_pvc[k][t] * (g_max / nrg_gain_pvc[k][t]); + nrg_gain_pvc[k][t] = g_max; + } + + p_adj += + nrg_gain_pvc[k][t] * nrg_gain_pvc[k][t] * nrg_est_pvc[k][t]; + + if (nrg_tone_pvc[k][t]) { + p_adj += nrg_tone_pvc[k][t] * nrg_tone_pvc[k][t]; + } else if (!noise_absc_flag) { + p_adj += noise_level_pvc[k][t] * noise_level_pvc[k][t]; + } + } + + boost_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_adj + EPS)); + boost_gain = boost_gain > 1.584893192f ? 1.584893192f : boost_gain; + + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + nrg_gain_pvc[k][t] *= boost_gain; + noise_level_pvc[k][t] *= boost_gain; + nrg_tone_pvc[k][t] *= boost_gain; + } + } + } + + if (esbr_start_up_pvc) { + for (n = 0; n < 4; n++) { + for (c = 0; c < num_subbands; c++) { + (*e_gain)[n][c] = nrg_gain_pvc[c][start_pos]; + (*noise_buf)[n][c] = noise_level_pvc[c][start_pos]; + } + } + esbr_start_up_pvc = 0; + esbr_start_up = 0; + } + for (l = rate * pvc_frame_info->border_vec[i]; + l < rate * pvc_frame_info->border_vec[1 + i]; l++) { + ptr_real_buf = *(input_real + l) + sub_band_start; + ptr_imag_buf = *(input_imag + l) + sub_band_start; + + slot_idx = (WORD32)l / rate; + if (sub_band_start & 1) { + freq_inv = -1; + } + + for (k = 0; k < num_subbands; k++) { + (*e_gain)[4][k] = nrg_gain_pvc[k][slot_idx]; + (*noise_buf)[4][k] = noise_level_pvc[k][slot_idx]; + c = 0, sb_gain = 0, sb_noise = 0; + for (n = 4 - smooth_length; n <= 4; n++) { + sb_gain += (*e_gain)[n][k] * smooth_filt[c]; + sb_noise += (*noise_buf)[n][k] * smooth_filt[c++]; + } + phase_index = (phase_index + 1) & 511; + sb_noise = (nrg_tone_pvc[k][slot_idx] != 0 || noise_absc_flag) + ? 0 + : sb_noise; + + *ptr_real_buf = + *ptr_real_buf * sb_gain + + sb_noise * ixheaacd_random_phase[phase_index][0] + + nrg_tone_pvc[k][slot_idx] * ixheaacd_hphase_tbl[0][harm_index]; + *ptr_imag_buf = *ptr_imag_buf * sb_gain + + sb_noise * ixheaacd_random_phase[phase_index][1] + + nrg_tone_pvc[k][slot_idx] * freq_inv * + ixheaacd_hphase_tbl[1][harm_index]; + + ptr_real_buf++; + ptr_imag_buf++; + freq_inv = -freq_inv; + } + + harm_index = (harm_index + 1) & 3; + + memcpy(temp, (*e_gain)[0], 64 * sizeof(FLOAT32)); + for (n = 0; n < 4; n++) { + memcpy((*e_gain)[n], (*e_gain)[n + 1], 64 * sizeof(FLOAT32)); + } + memcpy((*e_gain)[4], temp, 64 * sizeof(FLOAT32)); + + memcpy(temp, (*noise_buf)[0], 64 * sizeof(FLOAT32)); + for (n = 0; n < 4; n++) { + memcpy((*noise_buf)[n], (*noise_buf)[n + 1], 64 * sizeof(FLOAT32)); + } + memcpy((*noise_buf)[4], temp, 64 * sizeof(FLOAT32)); + } + } + } else { + for (i = 0; i < num_sf_bands[HIGH]; i++) { + li = + frame_data->pstr_sbr_header->pstr_freq_band_data->freq_band_tbl_hi[i]; + ui = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_hi[i + 1]; + tmp = ((ui + li) - (sub_band_start << 1)) >> 1; + + harmonics[tmp] = add_harmonics[i]; + } + + for (i = 0; i < bs_num_env; i++) { + if (p_frame_info->border_vec[i] == p_frame_info->noise_border_vec[kk]) + kk++, next++; + + noise_absc_flag = + (i == trans_env || i == frame_data->env_short_flag_prev) ? 1 : 0; + + smooth_length = (noise_absc_flag ? 0 : smoothing_length); + smooth_filt = *ixheaacd_fir_table[smooth_length]; + + if (sbr_mode == ORIG_SBR) { + for (c = 0, o = 0, j = 0; j < num_sf_bands[p_frame_info->freq_res[i]]; + j++) { + double tmp; + li = freq_band_table[p_frame_info->freq_res[i]][j]; + ui = freq_band_table[p_frame_info->freq_res[i]][j + 1]; + ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_noise[o + 1]; + for (flag = 0, k = li; k < ui; k++) { + for (nrg = 0, l = rate * p_frame_info->border_vec[i]; + l < rate * p_frame_info->border_vec[i + 1]; l++) { + nrg += (input_real[l][k] * input_real[l][k]) + + (input_imag[l][k] * input_imag[l][k]); + } + flag = (harmonics[c] && + (i >= trans_env || (*harm_flag_prev)[c + sub_band_start])) + ? 1 + : flag; + nrg_est[c++] = nrg / (rate * p_frame_info->border_vec[i + 1] - + rate * p_frame_info->border_vec[i]); + } + if (!int_mode) { + for (nrg = 0, k = c - (ui - li); k < c; k++) { + nrg += nrg_est[k]; + } + nrg /= (ui - li); + } + c -= (ui - li); + + for (k = 0; k < ui - li; k++) { + o = (k + li >= ui2) ? o + 1 : o; + ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data + ->freq_band_tbl_noise[o + 1]; + nrg_ref[c] = sfb_nrg[m]; + nrg_est[c] = (!int_mode) ? nrg : nrg_est[c]; + nrg_tone[c] = 0; + tmp = noise_floor[next * num_nf_bands + o] / + (1 + noise_floor[next * num_nf_bands + o]); + if (flag) { + nrg_gain[c] = (FLOAT32)sqrt(nrg_ref[c] * tmp / (nrg_est[c] + 1)); + nrg_tone[c] = (FLOAT32)( + (harmonics[c] && + (i >= trans_env || (*harm_flag_prev)[c + sub_band_start])) + ? sqrt(nrg_ref[c] * tmp / + noise_floor[next * num_nf_bands + o]) + : 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]))); + } + noise_level[c] = (FLOAT32)sqrt(nrg_ref[c] * tmp); + c++; + } + m++; + } + + for (c = 0; c < (*gate_mode)[limiter_band]; c++) { + p_ref = p_est = 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + p_ref += nrg_ref[k]; + p_est += nrg_est[k]; + } + avg_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_est + EPS)); + g_max = avg_gain * ixheaacd_g_lim_gains[limiter_gains]; + g_max > 1.0e5f ? g_max = 1.0e5f : 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + if (g_max <= nrg_gain[k]) { + noise_level[k] = noise_level[k] * (g_max / nrg_gain[k]); + nrg_gain[k] = g_max; + } + } + p_adj = 0; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + p_adj += nrg_gain[k] * nrg_gain[k] * nrg_est[k]; + if (nrg_tone[k]) + p_adj += nrg_tone[k] * nrg_tone[k]; + else if (!noise_absc_flag) + p_adj += noise_level[k] * noise_level[k]; + } + boost_gain = (FLOAT32)sqrt((p_ref + EPS) / (p_adj + EPS)); + boost_gain = boost_gain > 1.584893192f ? 1.584893192f : boost_gain; + for (k = (*lim_table)[limiter_band][c]; + k < (*lim_table)[limiter_band][c + 1]; k++) { + nrg_gain[k] *= boost_gain; + noise_level[k] *= boost_gain; + nrg_tone[k] *= boost_gain; + } + } + + if (esbr_start_up) { + for (n = 0; n < 4; n++) { + memcpy((*e_gain)[n], nrg_gain, num_subbands * sizeof(FLOAT32)); + memcpy((*noise_buf)[n], noise_level, + num_subbands * sizeof(FLOAT32)); + } + esbr_start_up = 0; + esbr_start_up_pvc = 0; + } + + for (l = rate * p_frame_info->border_vec[i]; + l < rate * p_frame_info->border_vec[i + 1]; l++) { + ptr_real_buf = *(input_real + l) + sub_band_start; + ptr_imag_buf = *(input_imag + l) + sub_band_start; + + for (k = 0; k < num_subbands; k++) { + (*e_gain)[4][k] = nrg_gain[k]; + (*noise_buf)[4][k] = noise_level[k]; + c = 0, sb_gain = 0, sb_noise = 0; + for (n = 4 - smooth_length; n <= 4; n++) { + sb_gain += (*e_gain)[n][k] * smooth_filt[c]; + sb_noise += (*noise_buf)[n][k] * smooth_filt[c++]; + } + + phase_index = (phase_index + 1) & 511; + sb_noise = (nrg_tone[k] != 0 || noise_absc_flag) ? 0 : sb_noise; + + *ptr_real_buf = *ptr_real_buf * sb_gain + + sb_noise * ixheaacd_random_phase[phase_index][0]; + *ptr_imag_buf = *ptr_imag_buf * sb_gain + + sb_noise * ixheaacd_random_phase[phase_index][1]; + + ptr_real_buf++; + ptr_imag_buf++; + } + + memcpy(temp, (*e_gain)[0], 64 * sizeof(FLOAT32)); + for (n = 0; n < 4; n++) + memcpy((*e_gain)[n], (*e_gain)[n + 1], 64 * sizeof(FLOAT32)); + memcpy((*e_gain)[4], temp, 64 * sizeof(FLOAT32)); + memcpy(temp, (*noise_buf)[0], 64 * sizeof(FLOAT32)); + for (n = 0; n < 4; n++) + memcpy((*noise_buf)[n], (*noise_buf)[n + 1], 64 * sizeof(FLOAT32)); + memcpy((*noise_buf)[4], temp, 64 * sizeof(FLOAT32)); + } + + ixheaacd_apply_inter_tes( + *(input_real1 + rate * p_frame_info->border_vec[i]), + *(input_imag1 + rate * p_frame_info->border_vec[i]), + *(input_real + rate * p_frame_info->border_vec[i]), + *(input_imag + rate * p_frame_info->border_vec[i]), + rate * p_frame_info->border_vec[i + 1] - + rate * p_frame_info->border_vec[i], + sub_band_start, num_subbands, frame_data->inter_temp_shape_mode[i]); + + for (l = rate * p_frame_info->border_vec[i]; + l < rate * p_frame_info->border_vec[i + 1]; l++) { + ptr_real_buf = *(input_real + l) + sub_band_start; + ptr_imag_buf = *(input_imag + l) + sub_band_start; + if (sub_band_start & 1) { + freq_inv = -1; + } + for (k = 0; k < num_subbands; k++) { + *ptr_real_buf += nrg_tone[k] * ixheaacd_hphase_tbl[0][harm_index]; + *ptr_imag_buf += + nrg_tone[k] * freq_inv * ixheaacd_hphase_tbl[1][harm_index]; + + ptr_real_buf++; + ptr_imag_buf++; + freq_inv = -freq_inv; + } + harm_index = (harm_index + 1) & 3; + } + } + } + } + + for (i = 0; i < 64; i++) { + (*harm_flag_varlen_prev)[i] = (*harm_flag_prev)[i]; + (*harm_flag_varlen)[i] = harmonics[i]; + } + + memcpy(&((*harm_flag_prev)[0]) + sub_band_start, harmonics, + (64 - sub_band_start) * sizeof(WORD8)); + + if (trans_env == bs_num_env) { + frame_data->env_short_flag_prev = 0; + } else { + frame_data->env_short_flag_prev = -1; + } + + memcpy((VOID *)&frame_data->str_frame_info_prev, + (VOID *)&frame_data->str_frame_info_details, + sizeof(ia_frame_info_struct)); + + if (frame_data->str_frame_info_details.num_env == 1) { + frame_data->var_len_id_prev = 0; + } else if (frame_data->str_frame_info_details.num_env == 2) { + frame_data->var_len_id_prev = 1; + } + + for (i = 0; i < num_nf_bands; i++) { + prev_env_noise_level[i] = + frame_data->flt_noise_floor + [(frame_data->str_frame_info_details.num_noise_env - 1) * + num_nf_bands + + i]; + } + + frame_data->harm_index = harm_index; + frame_data->phase_index = phase_index; + frame_data->pstr_sbr_header->esbr_start_up = esbr_start_up; + frame_data->pstr_sbr_header->esbr_start_up_pvc = esbr_start_up_pvc; +} + +VOID ixheaacd_createlimiterbands(WORD32 lim_table[4][12 + 1], + WORD32 gate_mode[4], WORD16 *freq_band_tbl, + WORD32 ixheaacd_num_bands, + WORD32 x_over_qmf[MAX_NUM_PATCHES], + WORD32 b_patching_mode, WORD32 upsamp_4_flag, + struct ixheaacd_lpp_trans_patch *patch_param) { + WORD32 i, j, k, is_patch_border[2]; + WORD32 patch_borders[MAX_NUM_PATCHES + 1]; + WORD32 temp_limiter_band_calc[32 + MAX_NUM_PATCHES + 1]; + + double num_octave; + WORD32 num_patches; + + WORD32 sub_band_start = freq_band_tbl[0]; + WORD32 sub_band_end = freq_band_tbl[ixheaacd_num_bands]; + + const double log2 = log(2.0); + const double limbnd_per_oct[4] = {0, 1.2, 2.0, 3.0}; + + if (!b_patching_mode && (x_over_qmf != NULL)) { + num_patches = 0; + if (upsamp_4_flag) { + for (i = 1; i < MAX_NUM_PATCHES; i++) + if (x_over_qmf[i] != 0) num_patches++; + } else { + for (i = 1; i < 4; i++) + if (x_over_qmf[i] != 0) num_patches++; + } + for (i = 0; i < num_patches; i++) { + patch_borders[i] = x_over_qmf[i] - sub_band_start; + } + } else { + num_patches = patch_param->num_patches; + for (i = 0; i < num_patches; i++) { + patch_borders[i] = patch_param->start_subband[i] - sub_band_start; + } + } + patch_borders[i] = sub_band_end - sub_band_start; + + lim_table[0][0] = freq_band_tbl[0] - sub_band_start; + lim_table[0][1] = freq_band_tbl[ixheaacd_num_bands] - sub_band_start; + gate_mode[0] = 1; + + for (i = 1; i < 4; i++) { + for (k = 0; k <= ixheaacd_num_bands; k++) { + temp_limiter_band_calc[k] = freq_band_tbl[k] - sub_band_start; + } + + for (k = 1; k < num_patches; k++) { + temp_limiter_band_calc[ixheaacd_num_bands + k] = patch_borders[k]; + } + + gate_mode[i] = ixheaacd_num_bands + num_patches - 1; + ixheaacd_shellsort(temp_limiter_band_calc, gate_mode[i] + 1); + + for (j = 1; j <= gate_mode[i]; j++) { + num_octave = log((double)(temp_limiter_band_calc[j] + sub_band_start) / + (temp_limiter_band_calc[j - 1] + sub_band_start)) / + log2; + + if (num_octave * limbnd_per_oct[i] < 0.49) { + if (temp_limiter_band_calc[j] == temp_limiter_band_calc[j - 1]) { + temp_limiter_band_calc[j] = sub_band_end; + ixheaacd_shellsort(temp_limiter_band_calc, gate_mode[i] + 1); + gate_mode[i]--; + j--; + continue; + } + + is_patch_border[0] = is_patch_border[1] = 0; + + for (k = 0; k <= num_patches; k++) { + if (temp_limiter_band_calc[j - 1] == patch_borders[k]) { + is_patch_border[0] = 1; + break; + } + } + + for (k = 0; k <= num_patches; k++) { + if (temp_limiter_band_calc[j] == patch_borders[k]) { + is_patch_border[1] = 1; + break; + } + } + + if (!is_patch_border[1]) { + temp_limiter_band_calc[j] = sub_band_end; + ixheaacd_shellsort(temp_limiter_band_calc, gate_mode[i] + 1); + gate_mode[i]--; + j--; + } else if (!is_patch_border[0]) { + temp_limiter_band_calc[j - 1] = sub_band_end; + ixheaacd_shellsort(temp_limiter_band_calc, gate_mode[i] + 1); + gate_mode[i]--; + j--; + } + } + } + + for (k = 0; k <= gate_mode[i]; k++) { + lim_table[i][k] = temp_limiter_band_calc[k]; + } + } +} + +VOID ixheaacd_apply_inter_tes(FLOAT32 *qmf_real1, FLOAT32 *qmf_imag1, + FLOAT32 *qmf_real, FLOAT32 *qmf_imag, + WORD32 num_sample, WORD32 sub_band_start, + WORD32 num_subband, WORD32 gamma_idx) { + WORD32 sub_band_end = sub_band_start + num_subband; + FLOAT32 subsample_power_high[TIMESLOT_BUFFER_SIZE], + subsample_power_low[TIMESLOT_BUFFER_SIZE]; + FLOAT32 total_power_high = 0.0f; + FLOAT32 total_power_low = 0.0f, total_power_high_after = 1.0e-6f; + FLOAT32 gain[TIMESLOT_BUFFER_SIZE]; + FLOAT32 gain_adj, gain_adj_2; + FLOAT32 gamma = ixheaacd_q_gamma_table[gamma_idx]; + WORD32 i, j; + + if (gamma > 0) { + for (i = 0; i < num_sample; i++) { + memcpy(&qmf_real[64 * i], &qmf_real1[64 * i], + sub_band_start * sizeof(FLOAT32)); + memcpy(&qmf_imag[64 * i], &qmf_imag1[64 * i], + sub_band_start * sizeof(FLOAT32)); + } + + for (i = 0; i < num_sample; i++) { + subsample_power_low[i] = 0.0f; + for (j = 0; j < sub_band_start; j++) { + subsample_power_low[i] += qmf_real[64 * i + j] * qmf_real[64 * i + j]; + subsample_power_low[i] += qmf_imag[64 * i + j] * qmf_imag[64 * i + j]; + } + subsample_power_high[i] = 0.0f; + for (j = sub_band_start; j < sub_band_end; j++) { + subsample_power_high[i] += qmf_real[64 * i + j] * qmf_real[64 * i + j]; + subsample_power_high[i] += qmf_imag[64 * i + j] * qmf_imag[64 * i + j]; + } + total_power_low += subsample_power_low[i]; + total_power_high += subsample_power_high[i]; + } + + for (i = 0; i < num_sample; i++) { + gain[i] = (FLOAT32)(sqrt(subsample_power_low[i] * num_sample / + (total_power_low + 1.0e-6f))); + } + + for (i = 0; i < num_sample; i++) { + gain[i] = (FLOAT32)(1.0f + gamma * (gain[i] - 1.0f)); + } + + for (i = 0; i < num_sample; i++) { + if (gain[i] < 0.2f) { + gain[i] = 0.2f; + } + + subsample_power_high[i] *= gain[i] * gain[i]; + total_power_high_after += subsample_power_high[i]; + } + + gain_adj_2 = total_power_high / total_power_high_after; + gain_adj = (FLOAT32)(sqrt(gain_adj_2)); + + for (i = 0; i < num_sample; i++) { + gain[i] *= gain_adj; + + for (j = sub_band_start; j < sub_band_end; j++) { + qmf_real[64 * i + j] *= gain[i]; + qmf_imag[64 * i + j] *= gain[i]; + } + } + } +} diff --git a/decoder/ixheaacd_esbr_fft.c b/decoder/ixheaacd_esbr_fft.c new file mode 100644 index 0000000..24916ae --- /dev/null +++ b/decoder/ixheaacd_esbr_fft.c @@ -0,0 +1,1217 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include "ixheaacd_constants.h" +#include + +#define PLATFORM_INLINE __inline + +#define DIG_REV(i, m, j) \ + do { \ + unsigned _ = (i); \ + _ = ((_ & 0x33333333) << 2) | ((_ & ~0x33333333) >> 2); \ + _ = ((_ & 0x0F0F0F0F) << 4) | ((_ & ~0x0F0F0F0F) >> 4); \ + _ = ((_ & 0x00FF00FF) << 8) | ((_ & ~0x00FF00FF) >> 8); \ + (j) = _ >> (m); \ + } while (0) + +extern FLOAT32 ixheaacd_twiddle_table_fft_float[514]; +const FLOAT32 ixheaacd_twidle_tbl_48[64]; +const FLOAT32 ixheaacd_twidle_tbl_24[32]; + +void ixheaacd_real_synth_fft_p2(FLOAT32 *ptr_x, FLOAT32 *ptr_y, + WORD32 npoints) { + WORD32 i, j, k, n_stages, h2; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + WORD32 del, nodespacing, in_loop_cnt; + WORD32 not_power_4; + WORD32 dig_rev_shift; + const FLOAT32 *ptr_w; + + dig_rev_shift = ixheaacd_norm32(npoints) + 1 - 16; + n_stages = 30 - ixheaacd_norm32(npoints); + not_power_4 = n_stages & 1; + + n_stages = n_stages >> 1; + + ptr_w = ixheaacd_twiddle_table_fft_float; + + for (i = 0; i < npoints; i += 4) { + FLOAT32 *inp = ptr_x; + + DIG_REV(i, dig_rev_shift, h2); + if (not_power_4) { + h2 += 1; + h2 &= ~1; + } + inp += (h2 >> 1); + + x0r = *inp; + inp += (npoints >> 2); + + x1r = *inp; + inp += (npoints >> 2); + + x2r = *inp; + inp += (npoints >> 2); + + x3r = *inp; + + x0r = x0r + x2r; + x2r = x0r - (x2r * 2); + x1r = x1r + x3r; + x3r = x1r - (x3r * 2); + x0r = x0r + x1r; + x1r = x0r - (x1r * 2); + + *ptr_y++ = x0r; + *ptr_y++ = 0; + *ptr_y++ = x2r; + *ptr_y++ = x3r; + *ptr_y++ = x1r; + *ptr_y++ = 0; + *ptr_y++ = x2r; + *ptr_y++ = -x3r; + } + ptr_y -= 2 * npoints; + del = 4; + nodespacing = 64; + in_loop_cnt = npoints >> 4; + for (i = n_stages - 1; i > 0; i--) { + const FLOAT32 *twiddles = ptr_w; + FLOAT32 *data = ptr_y; + FLOAT32 W1, W2, W3, W4, W5, W6; + WORD32 sec_loop_cnt; + + for (k = in_loop_cnt; k != 0; k--) { + x0r = (*data); + x0i = (*(data + 1)); + data += (del << 1); + + x1r = (*data); + x1i = (*(data + 1)); + data += (del << 1); + + x2r = (*data); + x2i = (*(data + 1)); + data += (del << 1); + + x3r = (*data); + x3i = (*(data + 1)); + data -= 3 * (del << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - x3i; + x2i = x2i + x3r; + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data = ptr_y + 2; + + sec_loop_cnt = (nodespacing * del); + sec_loop_cnt = (sec_loop_cnt / 4) + (sec_loop_cnt / 8) - + (sec_loop_cnt / 16) + (sec_loop_cnt / 32) - + (sec_loop_cnt / 64) + (sec_loop_cnt / 128) - + (sec_loop_cnt / 256); + j = nodespacing; + + for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1)); + W5 = *(twiddles + (j << 1) + 257); + W3 = *(twiddles + j + (j << 1)); + W6 = *(twiddles + j + (j << 1) + 257); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2i = (FLOAT32)(-((FLOAT32)x2r * W5) + (FLOAT32)x2i * W2); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3i = (FLOAT32)(-((FLOAT32)x3r * W6) + (FLOAT32)x3i * W3); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= (nodespacing * del) >> 1; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1)); + W5 = *(twiddles + (j << 1) + 257); + W3 = *(twiddles + j + (j << 1) - 256); + W6 = *(twiddles + j + (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2i = (FLOAT32)(-((FLOAT32)x2r * W5) + (FLOAT32)x2i * W2); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W6) - ((FLOAT32)x3i * W3)); + x3i = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= sec_loop_cnt * 2; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1) - 256); + W5 = *(twiddles + (j << 1) + 1); + W3 = *(twiddles + j + (j << 1) - 256); + W6 = *(twiddles + j + (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W5) - ((FLOAT32)x2i * W2)); + x2i = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W6) - ((FLOAT32)x3i * W3)); + x3i = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j < nodespacing * del; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1) - 256); + W5 = *(twiddles + (j << 1) + 1); + W3 = *(twiddles + j + (j << 1) - 512); + W6 = *(twiddles + j + (j << 1) - 512 + 257); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W5) - ((FLOAT32)x2i * W2)); + x2i = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2r = tmp; + + tmp = (FLOAT32)(-((FLOAT32)x3r * W3) - ((FLOAT32)x3i * W6)); + x3i = (FLOAT32)(-((FLOAT32)x3r * W6) + (FLOAT32)x3i * W3); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i - x3i; + x3r = x1r - (x3r * 2); + x3i = x1i + (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + nodespacing >>= 2; + del <<= 2; + in_loop_cnt >>= 2; + } + + if (not_power_4) { + const FLOAT32 *twiddles = ptr_w; + nodespacing <<= 1; + + for (j = del / 2; j != 0; j--) { + FLOAT32 W1 = *twiddles; + FLOAT32 W4 = *(twiddles + 257); + FLOAT32 tmp; + twiddles += nodespacing; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + *ptr_y = (x0r) - (x1r); + *(ptr_y + 1) = (x0i) - (x1i); + ptr_y -= (del << 1); + + *ptr_y = (x0r) + (x1r); + *(ptr_y + 1) = (x0i) + (x1i); + ptr_y += 2; + } + twiddles = ptr_w; + for (j = del / 2; j != 0; j--) { + FLOAT32 W1 = *twiddles; + FLOAT32 W4 = *(twiddles + 257); + FLOAT32 tmp; + twiddles += nodespacing; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W4) - ((FLOAT32)x1i * W1)); + x1i = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1r = tmp; + + *ptr_y = (x0r) - (x1r); + *(ptr_y + 1) = (x0i) - (x1i); + ptr_y -= (del << 1); + + *ptr_y = (x0r) + (x1r); + *(ptr_y + 1) = (x0i) + (x1i); + ptr_y += 2; + } + } +} + +void ixheaacd_cmplx_anal_fft_p2(FLOAT32 *ptr_x, FLOAT32 *ptr_y, + WORD32 npoints) { + WORD32 i, j, k, n_stages, h2; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + WORD32 del, nodespacing, in_loop_cnt; + WORD32 not_power_4; + WORD32 dig_rev_shift; + const FLOAT32 *ptr_w; + + dig_rev_shift = ixheaacd_norm32(npoints) + 1 - 16; + n_stages = 30 - ixheaacd_norm32(npoints); + not_power_4 = n_stages & 1; + + n_stages = n_stages >> 1; + + ptr_w = ixheaacd_twiddle_table_fft_float; + + for (i = 0; i < npoints; i += 4) { + FLOAT32 *inp = ptr_x; + + DIG_REV(i, dig_rev_shift, h2); + if (not_power_4) { + h2 += 1; + h2 &= ~1; + } + inp += (h2); + + x0r = *inp; + x0i = *(inp + 1); + inp += (npoints >> 1); + + x1r = *inp; + x1i = *(inp + 1); + inp += (npoints >> 1); + + x2r = *inp; + x2i = *(inp + 1); + inp += (npoints >> 1); + + x3r = *inp; + x3i = *(inp + 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - x3i; + x2i = x2i + x3r; + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *ptr_y++ = x0r; + *ptr_y++ = x0i; + *ptr_y++ = x2r; + *ptr_y++ = x2i; + *ptr_y++ = x1r; + *ptr_y++ = x1i; + *ptr_y++ = x3i; + *ptr_y++ = x3r; + } + ptr_y -= 2 * npoints; + del = 4; + nodespacing = 64; + in_loop_cnt = npoints >> 4; + for (i = n_stages - 1; i > 0; i--) { + const FLOAT32 *twiddles = ptr_w; + FLOAT32 *data = ptr_y; + FLOAT32 W1, W2, W3, W4, W5, W6; + WORD32 sec_loop_cnt; + + for (k = in_loop_cnt; k != 0; k--) { + x0r = (*data); + x0i = (*(data + 1)); + data += (del << 1); + + x1r = (*data); + x1i = (*(data + 1)); + data += (del << 1); + + x2r = (*data); + x2i = (*(data + 1)); + data += (del << 1); + + x3r = (*data); + x3i = (*(data + 1)); + data -= 3 * (del << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - x3i; + x2i = x2i + x3r; + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data = ptr_y + 2; + + sec_loop_cnt = (nodespacing * del); + sec_loop_cnt = (sec_loop_cnt / 4) + (sec_loop_cnt / 8) - + (sec_loop_cnt / 16) + (sec_loop_cnt / 32) - + (sec_loop_cnt / 64) + (sec_loop_cnt / 128) - + (sec_loop_cnt / 256); + j = nodespacing; + + for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1)); + W5 = *(twiddles + (j << 1) + 257); + W3 = *(twiddles + j + (j << 1)); + W6 = *(twiddles + j + (j << 1) + 257); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2i = (FLOAT32)(-((FLOAT32)x2r * W5) + (FLOAT32)x2i * W2); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3i = (FLOAT32)(-((FLOAT32)x3r * W6) + (FLOAT32)x3i * W3); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= (nodespacing * del) >> 1; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1)); + W5 = *(twiddles + (j << 1) + 257); + W3 = *(twiddles + j + (j << 1) - 256); + W6 = *(twiddles + j + (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2i = (FLOAT32)(-((FLOAT32)x2r * W5) + (FLOAT32)x2i * W2); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W6) - ((FLOAT32)x3i * W3)); + x3i = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= sec_loop_cnt * 2; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1) - 256); + W5 = *(twiddles + (j << 1) + 1); + W3 = *(twiddles + j + (j << 1) - 256); + W6 = *(twiddles + j + (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W5) - ((FLOAT32)x2i * W2)); + x2i = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x3r * W6) - ((FLOAT32)x3i * W3)); + x3i = (FLOAT32)(((FLOAT32)x3r * W3) + ((FLOAT32)x3i * W6)); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r * 2); + x3i = x1i - (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j < nodespacing * del; j += nodespacing) { + W1 = *(twiddles + j); + W4 = *(twiddles + j + 257); + W2 = *(twiddles + (j << 1) - 256); + W5 = *(twiddles + (j << 1) + 1); + W3 = *(twiddles + j + (j << 1) - 512); + W6 = *(twiddles + j + (j << 1) - 512 + 257); + + for (k = in_loop_cnt; k != 0; k--) { + FLOAT32 tmp; + FLOAT32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + tmp = (FLOAT32)(((FLOAT32)x2r * W5) - ((FLOAT32)x2i * W2)); + x2i = (FLOAT32)(((FLOAT32)x2r * W2) + ((FLOAT32)x2i * W5)); + x2r = tmp; + + tmp = (FLOAT32)(-((FLOAT32)x3r * W3) - ((FLOAT32)x3i * W6)); + x3i = (FLOAT32)(-((FLOAT32)x3r * W6) + (FLOAT32)x3i * W3); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r * 2); + x2i = x0i - (x2i * 2); + x1r = x1r + x3r; + x1i = x1i - x3i; + x3r = x1r - (x3r * 2); + x3i = x1i + (x3i * 2); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r * 2); + x1i = x0i - (x1i * 2); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i * 2); + x3r = x2i - (x3r * 2); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + nodespacing >>= 2; + del <<= 2; + in_loop_cnt >>= 2; + } + + if (not_power_4) { + const FLOAT32 *twiddles = ptr_w; + nodespacing <<= 1; + + for (j = del / 2; j != 0; j--) { + FLOAT32 W1 = *twiddles; + FLOAT32 W4 = *(twiddles + 257); + FLOAT32 tmp; + twiddles += nodespacing; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1i = (FLOAT32)(-((FLOAT32)x1r * W4) + (FLOAT32)x1i * W1); + x1r = tmp; + + *ptr_y = (x0r) - (x1r); + *(ptr_y + 1) = (x0i) - (x1i); + ptr_y -= (del << 1); + + *ptr_y = (x0r) + (x1r); + *(ptr_y + 1) = (x0i) + (x1i); + ptr_y += 2; + } + twiddles = ptr_w; + for (j = del / 2; j != 0; j--) { + FLOAT32 W1 = *twiddles; + FLOAT32 W4 = *(twiddles + 257); + FLOAT32 tmp; + twiddles += nodespacing; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (FLOAT32)(((FLOAT32)x1r * W4) - ((FLOAT32)x1i * W1)); + x1i = (FLOAT32)(((FLOAT32)x1r * W1) + ((FLOAT32)x1i * W4)); + x1r = tmp; + + *ptr_y = (x0r) - (x1r); + *(ptr_y + 1) = (x0i) - (x1i); + ptr_y -= (del << 1); + + *ptr_y = (x0r) + (x1r); + *(ptr_y + 1) = (x0i) + (x1i); + ptr_y += 2; + } + } +} + +static PLATFORM_INLINE void ixheaacd_aac_ld_dec_fft_3_float(FLOAT32 *inp, + FLOAT32 *op) { + FLOAT32 add_r, sub_r; + FLOAT32 add_i, sub_i; + FLOAT32 temp_real, temp_imag, temp; + + FLOAT32 p1, p2, p3, p4; + + FLOAT32 sinmu; + sinmu = -0.866025403784439f; + + temp_real = inp[0] + inp[2]; + temp_imag = inp[1] + inp[3]; + + add_r = inp[2] + inp[4]; + add_i = inp[3] + inp[5]; + + sub_r = inp[2] - inp[4]; + sub_i = inp[3] - inp[5]; + + p1 = add_r / 2.0f; + p4 = add_i / 2.0f; + p2 = sub_i * sinmu; + p3 = sub_r * sinmu; + + temp = inp[0] - p1; + + op[0] = temp_real + inp[4]; + op[1] = temp_imag + inp[5]; + op[2] = temp + p2; + op[3] = (inp[1] - p3) - p4; + op[4] = temp - p2; + op[5] = (inp[1] + p3) - p4; + + return; +} + +void ixheaacd_real_synth_fft_p3(FLOAT32 *x_in, FLOAT32 *x_out, WORD32 npoints) { + WORD32 i, j; + FLOAT32 x_3[8]; + FLOAT32 y_3[16]; + FLOAT32 y[48]; + FLOAT32 x[48]; + FLOAT32 *ptr_y = y; + FLOAT32 *y_p3 = y; + FLOAT32 *x_p3 = x; + + for (i = 0; i < 3; i += 1) { + for (j = 0; j < (npoints / 3); j++) { + x_3[j] = x_in[3 * j + i]; + } + + ixheaacd_real_synth_fft_p2(x_3, y_3, 8); + + for (j = 0; j < 16; j += 2) { + x[3 * j + 2 * i] = y_3[j]; + x[3 * j + 2 * i + 1] = y_3[j + 1]; + } + } + + { + FLOAT32 *wr; + FLOAT32 tmp; + FLOAT32 *x_tw = x; + wr = (FLOAT32 *)ixheaacd_twidle_tbl_24; + x_tw += 2; + + for (i = 0; i < (npoints / 3); i++) { + tmp = ((*x_tw) * (*wr) + (*(x_tw + 1)) * (*(wr + 1))); + *(x_tw + 1) = (-(*x_tw) * (*(wr + 1)) + (*(x_tw + 1)) * (*wr)); + *x_tw = tmp; + + wr += 2; + x_tw += 2; + + tmp = ((*x_tw) * (*wr) + (*(x_tw + 1)) * (*(wr + 1))); + *(x_tw + 1) = (-(*x_tw) * (*(wr + 1)) + (*(x_tw + 1)) * (*wr)); + *x_tw = tmp; + + wr += 2; + x_tw += 4; + } + } + + for (i = 0; i < (npoints / 3); i++) { + ixheaacd_aac_ld_dec_fft_3_float(x_p3, y_p3); + + x_p3 = x_p3 + 6; + y_p3 = y_p3 + 6; + } + + for (i = 0; i < 16; i += 2) { + x_out[i] = *ptr_y++; + x_out[i + 1] = *ptr_y++; + x_out[16 + i] = *ptr_y++; + x_out[16 + i + 1] = *ptr_y++; + x_out[32 + i] = *ptr_y++; + x_out[32 + i + 1] = *ptr_y++; + } +} + +void ixheaacd_cmplx_anal_fft_p3(FLOAT32 *x_in, FLOAT32 *x_out, WORD32 npoints) { + WORD32 i, j; + FLOAT32 x_3[32]; + FLOAT32 y_3[32]; + FLOAT32 y[96]; + FLOAT32 *ptr_x = x_in; + FLOAT32 *ptr_y = y; + FLOAT32 *y_p3 = y; + + for (i = 0; i < 6; i += 2) { + for (j = 0; j < 32; j += 2) { + x_3[j] = x_in[3 * j + i]; + x_3[j + 1] = x_in[3 * j + i + 1]; + } + + ixheaacd_cmplx_anal_fft_p2(x_3, y_3, 16); + + for (j = 0; j < 32; j += 2) { + x_in[3 * j + i] = y_3[j]; + x_in[3 * j + i + 1] = y_3[j + 1]; + } + } + + { + FLOAT32 *wr; + FLOAT32 tmp; + wr = (FLOAT32 *)ixheaacd_twidle_tbl_48; + x_in += 2; + + for (i = 0; i < (npoints / 3); i++) { + tmp = ((*x_in) * (*wr) + (*(x_in + 1)) * (*(wr + 1))); + *(x_in + 1) = (-(*x_in) * (*(wr + 1)) + (*(x_in + 1)) * (*wr)); + *x_in = tmp; + + wr += 2; + x_in += 2; + + tmp = ((*x_in) * (*wr) + (*(x_in + 1)) * (*(wr + 1))); + *(x_in + 1) = (-(*x_in) * (*(wr + 1)) + (*(x_in + 1)) * (*wr)); + *x_in = tmp; + + wr += 2; + x_in += 4; + } + } + + for (i = 0; i < (npoints / 3); i++) { + ixheaacd_aac_ld_dec_fft_3_float(ptr_x, ptr_y); + + ptr_x = ptr_x + 6; + ptr_y = ptr_y + 6; + } + + for (i = 0; i < 32; i += 2) { + x_out[i] = *y_p3++; + x_out[i + 1] = *y_p3++; + x_out[32 + i] = *y_p3++; + x_out[32 + i + 1] = *y_p3++; + x_out[64 + i] = *y_p3++; + x_out[64 + i + 1] = *y_p3++; + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_esbr_polyphase.c b/decoder/ixheaacd_esbr_polyphase.c new file mode 100644 index 0000000..591cf2d --- /dev/null +++ b/decoder/ixheaacd_esbr_polyphase.c @@ -0,0 +1,246 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_common_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_freq_sca.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_qmf_poly.h" +#include "ixheaacd_esbr_rom.h" + +#include "string.h" + +VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) { + WORD32 idx; + WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size; + WORD32 N = (10 * anal_size); + + for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) { + WORD32 i, j, k, l; + FLOAT32 window_output[640]; + FLOAT32 u[128], u_in[256], u_out[256]; + FLOAT32 accu_r, accu_i; + const FLOAT32 *inp_signal; + FLOAT32 *anal_buf; + + FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab; + const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff; + FLOAT32 *x = ptr_hbe_txposer->analy_buf; + + memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0, + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + + inp_signal = ptr_hbe_txposer->ptr_input_buf + + idx * 2 * ptr_hbe_txposer->synth_size + 1; + anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1] + [4 * ptr_hbe_txposer->k_start]; + + for (i = N - 1; i >= anal_size; i--) { + x[i] = x[i - anal_size]; + } + + for (i = anal_size - 1; i >= 0; i--) { + x[i] = inp_signal[anal_size - 1 - i]; + } + + for (i = 0; i < N; i++) { + window_output[i] = x[i] * interp_window_coeff[i]; + } + + for (i = 0; i < 2 * anal_size; i++) { + accu_r = 0.0; + for (j = 0; j < 5; j++) { + accu_r = accu_r + window_output[i + j * 2 * anal_size]; + } + u[i] = accu_r; + } + + if (anal_size == 40) { + for (i = 1; i < anal_size; i++) { + FLOAT32 temp1 = u[i] + u[2 * anal_size - i]; + FLOAT32 temp2 = u[i] - u[2 * anal_size - i]; + u[i] = temp1; + u[2 * anal_size - i] = temp2; + } + + for (k = 0; k < anal_size; k++) { + accu_r = u[anal_size]; + if (k & 1) + accu_i = u[0]; + else + accu_i = -u[0]; + for (l = 1; l < anal_size; l++) { + accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0]; + accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1]; + } + analy_cos_sin_tab += (2 * anal_size); + *anal_buf++ = (FLOAT32)accu_r; + *anal_buf++ = (FLOAT32)accu_i; + } + } else { + FLOAT32 *ptr_u = u_in; + FLOAT32 *ptr_v = u_out; + for (k = 0; k < anal_size * 2; k++) { + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + } + + (*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2); + + for (k = 0; k < anal_size / 2; k++) { + *(anal_buf + 1) = -*ptr_v++; + *anal_buf = *ptr_v++; + + anal_buf += 2; + + *(anal_buf + 1) = *ptr_v++; + *anal_buf = -*ptr_v++; + + anal_buf += 2; + } + } + } +} + +VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 num_columns, FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64]) { + WORD32 i, j, k, l, idx; + FLOAT32 g[640]; + FLOAT32 w[640]; + FLOAT32 synth_out[128]; + FLOAT32 accu_r; + WORD32 synth_size = ptr_hbe_txposer->synth_size; + FLOAT32 *ptr_cos_tab_trans_qmf = + (FLOAT32 *)&ixheaacd_cos_table_trans_qmf[0][0] + + ptr_hbe_txposer->k_start * 32; + FLOAT32 *buffer = ptr_hbe_txposer->synth_buf; + + for (idx = 0; idx < num_columns; idx++) { + FLOAT32 loc_qmf_buf[64]; + FLOAT32 *synth_buf_r = loc_qmf_buf; + FLOAT32 *out_buf = ptr_hbe_txposer->ptr_input_buf + + (idx + 1) * ptr_hbe_txposer->synth_size; + FLOAT32 *synth_cos_tab = ptr_hbe_txposer->synth_cos_tab; + const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->synth_wind_coeff; + + for (k = 0; k < synth_size; k++) { + WORD32 ki = ptr_hbe_txposer->k_start + k; + synth_buf_r[k] = (FLOAT32)( + ptr_cos_tab_trans_qmf[(k << 1) + 0] * qmf_buf_real[idx][ki] + + ptr_cos_tab_trans_qmf[(k << 1) + 1] * qmf_buf_imag[idx][ki]); + + synth_buf_r[k + ptr_hbe_txposer->synth_size] = 0; + } + + for (l = (20 * synth_size - 1); l >= 2 * synth_size; l--) { + buffer[l] = buffer[l - 2 * synth_size]; + } + + if (synth_size == 20) { + FLOAT32 *psynth_cos_tab = synth_cos_tab; + + for (l = 0; l < (synth_size + 1); l++) { + accu_r = 0.0; + for (k = 0; k < synth_size; k++) { + accu_r += synth_buf_r[k] * psynth_cos_tab[k]; + } + buffer[0 + l] = accu_r; + buffer[synth_size - l] = accu_r; + psynth_cos_tab = psynth_cos_tab + synth_size; + } + for (l = (synth_size + 1); l < (2 * synth_size - synth_size / 2); l++) { + accu_r = 0.0; + for (k = 0; k < synth_size; k++) { + accu_r += synth_buf_r[k] * psynth_cos_tab[k]; + } + buffer[0 + l] = accu_r; + buffer[3 * synth_size - l] = -accu_r; + psynth_cos_tab = psynth_cos_tab + synth_size; + } + accu_r = 0.0; + for (k = 0; k < synth_size; k++) { + accu_r += synth_buf_r[k] * psynth_cos_tab[k]; + } + buffer[3 * synth_size >> 1] = accu_r; + } else { + FLOAT32 tmp; + FLOAT32 *ptr_u = synth_out; + WORD32 kmax = (synth_size >> 1); + FLOAT32 *syn_buf = &buffer[kmax]; + kmax += synth_size; + + (*ixheaacd_real_synth_fft)(synth_buf_r, synth_out, synth_size * 2); + + for (k = 0; k < kmax; k++) { + tmp = ((*ptr_u++) * (*synth_cos_tab++)); + tmp -= ((*ptr_u++) * (*synth_cos_tab++)); + *syn_buf++ = tmp; + } + + syn_buf = &buffer[0]; + kmax -= synth_size; + + for (k = 0; k < kmax; k++) { + tmp = ((*ptr_u++) * (*synth_cos_tab++)); + tmp -= ((*ptr_u++) * (*synth_cos_tab++)); + *syn_buf++ = tmp; + } + } + + for (i = 0; i < 5; i++) { + memcpy(&g[(2 * i + 0) * synth_size], &buffer[(4 * i + 0) * synth_size], + sizeof(FLOAT32) * synth_size); + memcpy(&g[(2 * i + 1) * synth_size], &buffer[(4 * i + 3) * synth_size], + sizeof(FLOAT32) * synth_size); + } + + for (k = 0; k < 10 * synth_size; k++) { + w[k] = g[k] * interp_window_coeff[k]; + } + + for (i = 0; i < synth_size; i++) { + accu_r = 0.0; + for (j = 0; j < 10; j++) { + accu_r = accu_r + w[synth_size * j + i]; + } + out_buf[i] = (FLOAT32)accu_r; + } + } +} diff --git a/decoder/ixheaacd_esbr_rom.c b/decoder/ixheaacd_esbr_rom.c new file mode 100644 index 0000000..095e180 --- /dev/null +++ b/decoder/ixheaacd_esbr_rom.c @@ -0,0 +1,2609 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_const.h" + +const FLOAT32 ixheaacd_sub_samp_qmf_window_coeff[40 + 80 + 120 + 160 + 200 + + 240 + 320 + 400] = { + 0.000000000000f, -0.000715773669f, -0.000665041502f, 0.000402654026f, + 0.002620175947f, 0.005039302167f, 0.005271575879f, 0.000027604519f, + 0.013271821663f, 0.034462094307f, 0.058591566980f, 0.075313732028f, + 0.070353306830f, 0.029082400724f, -0.058370534331f, -0.192396670580f, + 0.361158996820f, 0.541255354881f, 0.702238857746f, 0.813819110394f, + 0.853738546371f, 0.813819110394f, 0.702238857746f, 0.541255354881f, + -0.361158996820f, -0.192396670580f, -0.058370534331f, 0.029082400724f, + 0.070353306830f, 0.075313732028f, 0.058591566980f, 0.034462094307f, + -0.013271821663f, 0.000027604519f, 0.005271575879f, 0.005039302167f, + 0.002620175947f, 0.000402654026f, -0.000665041502f, -0.000715773669f, + + 0.000000000000f, -0.000546656549f, -0.000715773669f, -0.000780366478f, + -0.000665041502f, -0.000289698131f, 0.000402654026f, 0.001390249468f, + 0.002620175947f, 0.003920743242f, 0.005039302167f, 0.005622064229f, + 0.005271575879f, 0.003540124744f, 0.000027604519f, -0.005533721298f, + 0.013271821663f, 0.023068016395f, 0.034462094307f, 0.046684302390f, + 0.058591566980f, 0.068704381585f, 0.075313732028f, 0.076505072415f, + 0.070353306830f, 0.055046003312f, 0.029082400724f, -0.008571174927f, + -0.058370534331f, -0.120007798076f, -0.192396670580f, -0.273663401604f, + 0.361158996820f, 0.451599657536f, 0.541255354881f, 0.626124262810f, + 0.702238857746f, 0.765867471695f, 0.813819110394f, 0.843623816967f, + 0.853738546371f, 0.843623816967f, 0.813819110394f, 0.765867471695f, + 0.702238857746f, 0.626124262810f, 0.541255354881f, 0.451599657536f, + -0.361158996820f, -0.273663401604f, -0.192396670580f, -0.120007798076f, + -0.058370534331f, -0.008571174927f, 0.029082400724f, 0.055046003312f, + 0.070353306830f, 0.076505072415f, 0.075313732028f, 0.068704381585f, + 0.058591566980f, 0.046684302390f, 0.034462094307f, 0.023068016395f, + -0.013271821663f, -0.005533721298f, 0.000027604519f, 0.003540124744f, + 0.005271575879f, 0.005622064229f, 0.005039302167f, 0.003920743242f, + 0.002620175947f, 0.001390249468f, 0.000402654026f, -0.000289698131f, + -0.000665041502f, -0.000780366478f, -0.000715773669f, -0.000546656549f, + + 0.000000000000f, -0.000494276581f, -0.000604547502f, -0.000715773669f, + -0.000776134315f, -0.000767318823f, -0.000665041502f, -0.000443592289f, + -0.000089368223f, 0.000402654026f, 0.001034071436f, 0.001785487286f, + 0.002620175947f, 0.003494867589f, 0.004324191250f, 0.005039302167f, + 0.005507593509f, 0.005630714353f, 0.005271575879f, 0.004295178223f, + 0.002582125831f, 0.000027604519f, -0.003442291170f, -0.007873747498f, + 0.013271821663f, 0.019609235227f, 0.026719830930f, 0.034462094307f, + 0.042579874396f, 0.050749942660f, 0.058591566980f, 0.065628737211f, + 0.071387805045f, 0.075313732028f, 0.076819263399f, 0.075348608196f, + 0.070353306830f, 0.061245717108f, 0.047619495541f, 0.029082400724f, + 0.005301259924f, -0.023842986673f, -0.058370534331f, -0.098213292658f, + -0.143036201596f, -0.192396670580f, -0.245750576258f, -0.302297174931f, + 0.361158996820f, 0.421350568533f, 0.481765538454f, 0.541255354881f, + 0.598601102829f, 0.652643620968f, 0.702238857746f, 0.746226489544f, + 0.783699929714f, 0.813819110394f, 0.835786461830f, 0.849197566509f, + 0.853738546371f, 0.849197506905f, 0.835786342621f, 0.813819110394f, + 0.783699750900f, 0.746226310730f, 0.702238857746f, 0.652643322945f, + 0.598600804806f, 0.541255354881f, 0.481765210629f, 0.421350240707f, + -0.361158996820f, -0.302297025919f, -0.245750263333f, -0.192396670580f, + -0.143036067486f, -0.098213046789f, -0.058370534331f, -0.023842897266f, + 0.005301412195f, 0.029082400724f, 0.047619540244f, 0.061245780438f, + 0.070353306830f, 0.075348615646f, 0.076819263399f, 0.075313732028f, + 0.071387790143f, 0.065628699958f, 0.058591566980f, 0.050749920309f, + 0.042579825968f, 0.034462094307f, 0.026719808578f, 0.019609196112f, + -0.013271821663f, -0.007873705588f, -0.003442274174f, 0.000027604519f, + 0.002582143992f, 0.004295184277f, 0.005271575879f, 0.005630714819f, + 0.005507592112f, 0.005039302167f, 0.004324184265f, 0.003494864097f, + 0.002620175947f, 0.001785481116f, 0.001034068293f, 0.000402654026f, + -0.000089371701f, -0.000443593453f, -0.000665041502f, -0.000767319347f, + -0.000776134082f, -0.000715773669f, -0.000604546454f, -0.000494276290f, + + 0.000000000000f, -0.000487522804f, -0.000546656549f, -0.000631249335f, + -0.000715773669f, -0.000768137164f, -0.000780366478f, -0.000753000146f, + -0.000665041502f, -0.000514557236f, -0.000289698131f, 0.000013494974f, + 0.000402654026f, 0.000860844331f, 0.001390249468f, 0.001984114060f, + 0.002620175947f, 0.003273961367f, 0.003920743242f, 0.004520985298f, + 0.005039302167f, 0.005419677589f, 0.005622064229f, 0.005591712892f, + 0.005271575879f, 0.004603953101f, 0.003540124744f, 0.002027417533f, + 0.000027604519f, -0.002482672455f, -0.005533721298f, -0.009132533334f, + 0.013271821663f, 0.017943337560f, 0.023068016395f, 0.028607217595f, + 0.034462094307f, 0.040534917265f, 0.046684302390f, 0.052763074636f, + 0.058591566980f, 0.063971586525f, 0.068704381585f, 0.072568260133f, + 0.075313732028f, 0.076709352434f, 0.076505072415f, 0.074466437101f, + 0.070353306830f, 0.063944481313f, 0.055046003312f, 0.043476879597f, + 0.029082400724f, 0.011762383394f, -0.008571174927f, -0.031953126192f, + -0.058370534331f, -0.087754756212f, -0.120007798076f, -0.154960706830f, + -0.192396670580f, -0.232069090009f, -0.273663401604f, -0.316827893257f, + 0.361158996820f, 0.406231760979f, 0.451599657536f, 0.496770828962f, + 0.541255354881f, 0.584540307522f, 0.626124262810f, 0.665513992310f, + 0.702238857746f, 0.735821187496f, 0.765867471695f, 0.791973590851f, + 0.813819110394f, 0.831103861332f, 0.843623816967f, 0.851197123528f, + 0.853738546371f, 0.851197123528f, 0.843623816967f, 0.831103861332f, + 0.813819110394f, 0.791973590851f, 0.765867471695f, 0.735821187496f, + 0.702238857746f, 0.665513992310f, 0.626124262810f, 0.584540307522f, + 0.541255354881f, 0.496770828962f, 0.451599657536f, 0.406231760979f, + -0.361158996820f, -0.316827893257f, -0.273663401604f, -0.232069090009f, + -0.192396670580f, -0.154960706830f, -0.120007798076f, -0.087754756212f, + -0.058370534331f, -0.031953126192f, -0.008571174927f, 0.011762383394f, + 0.029082400724f, 0.043476879597f, 0.055046003312f, 0.063944481313f, + 0.070353306830f, 0.074466437101f, 0.076505072415f, 0.076709352434f, + 0.075313732028f, 0.072568260133f, 0.068704381585f, 0.063971586525f, + 0.058591566980f, 0.052763074636f, 0.046684302390f, 0.040534917265f, + 0.034462094307f, 0.028607217595f, 0.023068016395f, 0.017943337560f, + -0.013271821663f, -0.009132533334f, -0.005533721298f, -0.002482672455f, + 0.000027604519f, 0.002027417533f, 0.003540124744f, 0.004603953101f, + 0.005271575879f, 0.005591712892f, 0.005622064229f, 0.005419677589f, + 0.005039302167f, 0.004520985298f, 0.003920743242f, 0.003273961367f, + 0.002620175947f, 0.001984114060f, 0.001390249468f, 0.000860844331f, + 0.000402654026f, 0.000013494974f, -0.000289698131f, -0.000514557236f, + -0.000665041502f, -0.000753000146f, -0.000780366478f, -0.000768137164f, + -0.000715773669f, -0.000631249335f, -0.000546656549f, -0.000487522804f, + + 0.000000000000f, -0.000493306026f, -0.000511505408f, -0.000579367916f, + -0.000649476540f, -0.000715773669f, -0.000752875290f, -0.000781254726f, + -0.000777536596f, -0.000736148562f, -0.000665041502f, -0.000548077514f, + -0.000385754218f, -0.000170716201f, 0.000090249574f, 0.000402654026f, + 0.000768811035f, 0.001178124920f, 0.001629814156f, 0.002113749273f, + 0.002620175947f, 0.003144826740f, 0.003664653283f, 0.004168645944f, + 0.004632714204f, 0.005039302167f, 0.005361670163f, 0.005566063803f, + 0.005641560070f, 0.005550691392f, 0.005271575879f, 0.004769547377f, + 0.004013354424f, 0.002990481444f, 0.001668256707f, 0.000027604519f, + -0.001939695445f, -0.004252972547f, -0.006908639334f, -0.009918526746f, + 0.013271821663f, 0.016974641010f, 0.020970622078f, 0.025238998234f, + 0.029761660844f, 0.034462094307f, 0.039311274886f, 0.044225402176f, + 0.049129784107f, 0.053948841989f, 0.058591566980f, 0.062942937016f, + 0.066905103624f, 0.070362940431f, 0.073203273118f, 0.075313732028f, + 0.076541244984f, 0.076781995595f, 0.075908273458f, 0.073805764318f, + 0.070353306830f, 0.065404154360f, 0.058896079659f, 0.050722457469f, + 0.040812026709f, 0.029082400724f, 0.015448591672f, -0.000097587261f, + -0.017581636086f, -0.037012770772f, -0.058370534331f, -0.081660762429f, + -0.106792926788f, -0.133693277836f, -0.162268877029f, -0.192396670580f, + -0.223985999823f, -0.256831049919f, -0.290771633387f, -0.325614720583f, + 0.361158996820f, 0.397183418274f, 0.433449268341f, 0.469719588757f, + 0.505739748478f, 0.541255354881f, 0.575990140438f, 0.609711349010f, + 0.642155468464f, 0.673076033592f, 0.702238857746f, 0.729360222816f, + 0.754271447659f, 0.776768505573f, 0.796672165394f, 0.813819110394f, + 0.828002870083f, 0.839164674282f, 0.847211718559f, 0.852083206177f, + 0.853738546371f, 0.852083206177f, 0.847211718559f, 0.839164674282f, + 0.828002750874f, 0.813819110394f, 0.796671986580f, 0.776768505573f, + 0.754271447659f, 0.729359984398f, 0.702238857746f, 0.673075735569f, + 0.642155468464f, 0.609711349010f, 0.575989782810f, 0.541255354881f, + 0.505739450455f, 0.469719588757f, 0.433449268341f, 0.397183090448f, + -0.361158996820f, -0.325614541769f, -0.290771633387f, -0.256830900908f, + -0.223985850811f, -0.192396670580f, -0.162268742919f, -0.133693277836f, + -0.106792800128f, -0.081660643220f, -0.058370534331f, -0.037012673914f, + -0.017581636086f, -0.000097508135f, 0.015448661521f, 0.029082400724f, + 0.040812078863f, 0.050722457469f, 0.058896116912f, 0.065404184163f, + 0.070353306830f, 0.073805779219f, 0.075908273458f, 0.076781995595f, + 0.076541237533f, 0.075313732028f, 0.073203265667f, 0.070362940431f, + 0.066905081272f, 0.062942922115f, 0.058591566980f, 0.053948819637f, + 0.049129784107f, 0.044225379825f, 0.039311248809f, 0.034462094307f, + 0.029761638492f, 0.025238998234f, 0.020970601588f, 0.016974622384f, + -0.013271821663f, -0.009918511845f, -0.006908619311f, -0.004252942745f, + -0.001939700567f, 0.000027604519f, 0.001668263576f, 0.002990489826f, + 0.004013365135f, 0.004769545514f, 0.005271575879f, 0.005550692324f, + 0.005641560070f, 0.005566061940f, 0.005361671094f, 0.005039302167f, + 0.004632712342f, 0.004168642685f, 0.003664647229f, 0.003144827904f, + 0.002620175947f, 0.002113747410f, 0.001629810315f, 0.001178119797f, + 0.000768812315f, 0.000402654026f, 0.000090248475f, -0.000170717947f, + -0.000385756488f, -0.000548077049f, -0.000665041502f, -0.000736148853f, + -0.000777536712f, -0.000781254901f, -0.000752875523f, -0.000715773669f, + -0.000649476249f, -0.000579367450f, -0.000511504768f, -0.000493305910f, + + 0.000000000000f, -0.000517090957f, -0.000494276581f, -0.000546656549f, + -0.000604547502f, -0.000661945262f, -0.000715773669f, -0.000747404585f, + -0.000776134315f, -0.000780366478f, -0.000767318823f, -0.000728470215f, + -0.000665041502f, -0.000569175696f, -0.000443592289f, -0.000289698131f, + -0.000089368223f, 0.000141059689f, 0.000402654026f, 0.000705181097f, + 0.001034071436f, 0.001390249468f, 0.001785487286f, 0.002198014408f, + 0.002620175947f, 0.003057343885f, 0.003494867589f, 0.003920743242f, + 0.004324191250f, 0.004704849795f, 0.005039302167f, 0.005313484930f, + 0.005507593509f, 0.005622064229f, 0.005630714353f, 0.005518750288f, + 0.005271575879f, 0.004868620075f, 0.004295178223f, 0.003540124744f, + 0.002582125831f, 0.001415721956f, 0.000027604519f, -0.001588239335f, + -0.003442291170f, -0.005533721298f, -0.007873747498f, -0.010453868657f, + 0.013271821663f, 0.016335172579f, 0.019609235227f, 0.023068016395f, + 0.026719830930f, 0.030534112826f, 0.034462094307f, 0.038497347385f, + 0.042579874396f, 0.046684302390f, 0.050749942660f, 0.054735988379f, + 0.058591566980f, 0.062239032239f, 0.065628737211f, 0.068704381585f, + 0.071387805045f, 0.073608145118f, 0.075313732028f, 0.076399229467f, + 0.076819263399f, 0.076505072415f, 0.075348608196f, 0.073319546878f, + 0.070353306830f, 0.066330201924f, 0.061245717108f, 0.055046003312f, + 0.047619495541f, 0.038977786899f, 0.029082400724f, 0.017846630886f, + 0.005301259924f, -0.008571174927f, -0.023842986673f, -0.040445398539f, + -0.058370534331f, -0.077656343579f, -0.098213292658f, -0.120007798076f, + -0.143036201596f, -0.167190954089f, -0.192396670580f, -0.218634754419f, + -0.245750576258f, -0.273663401604f, -0.302297174931f, -0.331498444080f, + 0.361158996820f, 0.391159355640f, 0.421350568533f, 0.451599657536f, + 0.481765538454f, 0.511695802212f, 0.541255354881f, 0.570261478424f, + 0.598601102829f, 0.626124262810f, 0.652643620968f, 0.678056061268f, + 0.702238857746f, 0.724978864193f, 0.746226489544f, 0.765867471695f, + 0.783699929714f, 0.799714028835f, 0.813819110394f, 0.825832426548f, + 0.835786461830f, 0.843623816967f, 0.849197566509f, 0.852570533752f, + 0.853738546371f, 0.852570474148f, 0.849197506905f, 0.843623816967f, + 0.835786342621f, 0.825832307339f, 0.813819110394f, 0.799713850021f, + 0.783699750900f, 0.765867471695f, 0.746226310730f, 0.724978625774f, + 0.702238857746f, 0.678055822849f, 0.652643322945f, 0.626124262810f, + 0.598600804806f, 0.570261120796f, 0.541255354881f, 0.511695444584f, + 0.481765210629f, 0.451599657536f, 0.421350240707f, 0.391158998013f, + -0.361158996820f, -0.331498116255f, -0.302297025919f, -0.273663401604f, + -0.245750263333f, -0.218634605408f, -0.192396670580f, -0.167190670967f, + -0.143036067486f, -0.120007798076f, -0.098213046789f, -0.077656231821f, + -0.058370534331f, -0.040445201099f, -0.023842897266f, -0.008571174927f, + 0.005301412195f, 0.017846697941f, 0.029082400724f, 0.038977894932f, + 0.047619540244f, 0.055046003312f, 0.061245780438f, 0.066330231726f, + 0.070353306830f, 0.073319576681f, 0.075348615646f, 0.076505072415f, + 0.076819263399f, 0.076399222016f, 0.075313732028f, 0.073608122766f, + 0.071387790143f, 0.068704381585f, 0.065628699958f, 0.062239013612f, + 0.058591566980f, 0.054735943675f, 0.050749920309f, 0.046684302390f, + 0.042579825968f, 0.038497325033f, 0.034462094307f, 0.030534068123f, + 0.026719808578f, 0.023068016395f, 0.019609196112f, 0.016335153952f, + -0.013271821663f, -0.010453845374f, -0.007873705588f, -0.005533721298f, + -0.003442274174f, -0.001588209649f, 0.000027604519f, 0.001415733015f, + 0.002582143992f, 0.003540124744f, 0.004295184277f, 0.004868627992f, + 0.005271575879f, 0.005518751685f, 0.005630714819f, 0.005622064229f, + 0.005507592112f, 0.005313480273f, 0.005039302167f, 0.004704846535f, + 0.004324184265f, 0.003920743242f, 0.003494864097f, 0.003057336202f, + 0.002620175947f, 0.002198010916f, 0.001785481116f, 0.001390249468f, + 0.001034068293f, 0.000705175975f, 0.000402654026f, 0.000141057521f, + -0.000089371701f, -0.000289698131f, -0.000443593453f, -0.000569177268f, + -0.000665041502f, -0.000728470448f, -0.000767319347f, -0.000780366478f, + -0.000776134082f, -0.000747404411f, -0.000715773669f, -0.000661944796f, + -0.000604546454f, -0.000546656549f, -0.000494276290f, -0.000517093693f, + + 0.000000000000f, -0.000561769237f, -0.000487522804f, -0.000504071417f, + -0.000546656549f, -0.000587093062f, -0.000631249335f, -0.000677769072f, + -0.000715773669f, -0.000744094199f, -0.000768137164f, -0.000783433206f, + -0.000780366478f, -0.000775797758f, -0.000753000146f, -0.000721539196f, + -0.000665041502f, -0.000594611920f, -0.000514557236f, -0.000409512140f, + -0.000289698131f, -0.000144638092f, 0.000013494974f, 0.000204301701f, + 0.000402654026f, 0.000623937638f, 0.000860844331f, 0.001125015551f, + 0.001390249468f, 0.001686808304f, 0.001984114060f, 0.002301725559f, + 0.002620175947f, 0.002946944674f, 0.003273961367f, 0.003600826720f, + 0.003920743242f, 0.004226427060f, 0.004520985298f, 0.004793256056f, + 0.005039302167f, 0.005246116780f, 0.005419677589f, 0.005547571462f, + 0.005622064229f, 0.005638919771f, 0.005591712892f, 0.005475378130f, + 0.005271575879f, 0.004983968567f, 0.004603953101f, 0.004125164356f, + 0.003540124744f, 0.002844675677f, 0.002027417533f, 0.001090232865f, + 0.000027604519f, -0.001156813581f, -0.002482672455f, -0.003940112423f, + -0.005533721298f, -0.007261581719f, -0.009132533334f, -0.011131554842f, + 0.013271821663f, 0.015540555120f, 0.017943337560f, 0.020453179255f, + 0.023068016395f, 0.025787584484f, 0.028607217595f, 0.031501762569f, + 0.034462094307f, 0.037481285632f, 0.040534917265f, 0.043609753251f, + 0.046684302390f, 0.049738574773f, 0.052763074636f, 0.055717363954f, + 0.058591566980f, 0.061345517635f, 0.063971586525f, 0.066436752677f, + 0.068704381585f, 0.070762872696f, 0.072568260133f, 0.074100367725f, + 0.075313732028f, 0.076199248433f, 0.076709352434f, 0.076823003590f, + 0.076505072415f, 0.075730577111f, 0.074466437101f, 0.072677463293f, + 0.070353306830f, 0.067452505231f, 0.063944481313f, 0.059816658497f, + 0.055046003312f, 0.049597866833f, 0.043476879597f, 0.036641810089f, + 0.029082400724f, 0.020799707621f, 0.011762383394f, 0.001976560103f, + -0.008571174927f, -0.019883412868f, -0.031953126192f, -0.044780682772f, + -0.058370534331f, -0.072694331408f, -0.087754756212f, -0.103532955050f, + -0.120007798076f, -0.137155175209f, -0.154960706830f, -0.173380821943f, + -0.192396670580f, -0.211973592639f, -0.232069090009f, -0.252648025751f, + -0.273663401604f, -0.295071661472f, -0.316827893257f, -0.338872283697f, + 0.361158996820f, 0.383635014296f, 0.406231760979f, 0.428911983967f, + 0.451599657536f, 0.474245309830f, 0.496770828962f, 0.519123494625f, + 0.541255354881f, 0.563078939915f, 0.584540307522f, 0.605578362942f, + 0.626124262810f, 0.646126985550f, 0.665513992310f, 0.684235334396f, + 0.702238857746f, 0.719446241856f, 0.735821187496f, 0.751313745975f, + 0.765867471695f, 0.779428780079f, 0.791973590851f, 0.803448557854f, + 0.813819110394f, 0.823041975498f, 0.831103861332f, 0.837971746922f, + 0.843623816967f, 0.848031580448f, 0.851197123528f, 0.853102087975f, + 0.853738546371f, 0.853102087975f, 0.851197123528f, 0.848031580448f, + 0.843623816967f, 0.837971746922f, 0.831103861332f, 0.823041975498f, + 0.813819110394f, 0.803448557854f, 0.791973590851f, 0.779428780079f, + 0.765867471695f, 0.751313745975f, 0.735821187496f, 0.719446241856f, + 0.702238857746f, 0.684235334396f, 0.665513992310f, 0.646126985550f, + 0.626124262810f, 0.605578362942f, 0.584540307522f, 0.563078939915f, + 0.541255354881f, 0.519123494625f, 0.496770828962f, 0.474245309830f, + 0.451599657536f, 0.428911983967f, 0.406231760979f, 0.383635014296f, + -0.361158996820f, -0.338872283697f, -0.316827893257f, -0.295071661472f, + -0.273663401604f, -0.252648025751f, -0.232069090009f, -0.211973592639f, + -0.192396670580f, -0.173380821943f, -0.154960706830f, -0.137155175209f, + -0.120007798076f, -0.103532955050f, -0.087754756212f, -0.072694331408f, + -0.058370534331f, -0.044780682772f, -0.031953126192f, -0.019883412868f, + -0.008571174927f, 0.001976560103f, 0.011762383394f, 0.020799707621f, + 0.029082400724f, 0.036641810089f, 0.043476879597f, 0.049597866833f, + 0.055046003312f, 0.059816658497f, 0.063944481313f, 0.067452505231f, + 0.070353306830f, 0.072677463293f, 0.074466437101f, 0.075730577111f, + 0.076505072415f, 0.076823003590f, 0.076709352434f, 0.076199248433f, + 0.075313732028f, 0.074100367725f, 0.072568260133f, 0.070762872696f, + 0.068704381585f, 0.066436752677f, 0.063971586525f, 0.061345517635f, + 0.058591566980f, 0.055717363954f, 0.052763074636f, 0.049738574773f, + 0.046684302390f, 0.043609753251f, 0.040534917265f, 0.037481285632f, + 0.034462094307f, 0.031501762569f, 0.028607217595f, 0.025787584484f, + 0.023068016395f, 0.020453179255f, 0.017943337560f, 0.015540555120f, + -0.013271821663f, -0.011131554842f, -0.009132533334f, -0.007261581719f, + -0.005533721298f, -0.003940112423f, -0.002482672455f, -0.001156813581f, + 0.000027604519f, 0.001090232865f, 0.002027417533f, 0.002844675677f, + 0.003540124744f, 0.004125164356f, 0.004603953101f, 0.004983968567f, + 0.005271575879f, 0.005475378130f, 0.005591712892f, 0.005638919771f, + 0.005622064229f, 0.005547571462f, 0.005419677589f, 0.005246116780f, + 0.005039302167f, 0.004793256056f, 0.004520985298f, 0.004226427060f, + 0.003920743242f, 0.003600826720f, 0.003273961367f, 0.002946944674f, + 0.002620175947f, 0.002301725559f, 0.001984114060f, 0.001686808304f, + 0.001390249468f, 0.001125015551f, 0.000860844331f, 0.000623937638f, + 0.000402654026f, 0.000204301701f, 0.000013494974f, -0.000144638092f, + -0.000289698131f, -0.000409512140f, -0.000514557236f, -0.000594611920f, + -0.000665041502f, -0.000721539196f, -0.000753000146f, -0.000775797758f, + -0.000780366478f, -0.000783433206f, -0.000768137164f, -0.000744094199f, + -0.000715773669f, -0.000677769072f, -0.000631249335f, -0.000587093062f, + -0.000546656549f, -0.000504071417f, -0.000487522804f, -0.000561769237f, + + 0.000000000000f, -0.000558072992f, -0.000493306026f, -0.000489007856f, + -0.000511505408f, -0.000546656549f, -0.000579367916f, -0.000616869656f, + -0.000649476540f, -0.000684326049f, -0.000715773669f, -0.000736658229f, + -0.000752875290f, -0.000771615305f, -0.000781254726f, -0.000780366478f, + -0.000777536596f, -0.000761063478f, -0.000736148562f, -0.000709641026f, + -0.000665041502f, -0.000610430841f, -0.000548077514f, -0.000471417530f, + -0.000385754218f, -0.000289698131f, -0.000170716201f, -0.000046687699f, + 0.000090249574f, 0.000240562411f, 0.000402654026f, 0.000578658364f, + 0.000768811035f, 0.000963047845f, 0.001178124920f, 0.001390249468f, + 0.001629814156f, 0.001864684164f, 0.002113749273f, 0.002366060158f, + 0.002620175947f, 0.002882985165f, 0.003144826740f, 0.003408302786f, + 0.003664653283f, 0.003920743242f, 0.004168645944f, 0.004402655177f, + 0.004632714204f, 0.004841458052f, 0.005039302167f, 0.005203964189f, + 0.005361670163f, 0.005474018864f, 0.005566063803f, 0.005622064229f, + 0.005641560070f, 0.005619631615f, 0.005550691392f, 0.005438786000f, + 0.005271575879f, 0.005045672413f, 0.004769547377f, 0.004424938932f, + 0.004013354424f, 0.003540124744f, 0.002990481444f, 0.002366164699f, + 0.001668256707f, 0.000887429516f, 0.000027604519f, -0.000912658463f, + -0.001939695445f, -0.003051238833f, -0.004252972547f, -0.005533721298f, + -0.006908639334f, -0.008370369673f, -0.009918526746f, -0.011552934535f, + 0.013271821663f, 0.015080526471f, 0.016974641010f, 0.018938465044f, + 0.020970622078f, 0.023068016395f, 0.025238998234f, 0.027470193803f, + 0.029761660844f, 0.032091233879f, 0.034462094307f, 0.036876682192f, + 0.039311274886f, 0.041758917272f, 0.044225402176f, 0.046684302390f, + 0.049129784107f, 0.051557101309f, 0.053948841989f, 0.056295089424f, + 0.058591566980f, 0.060800816864f, 0.062942937016f, 0.064974091947f, + 0.066905103624f, 0.068704381585f, 0.070362940431f, 0.071873866022f, + 0.073203273118f, 0.074358329177f, 0.075313732028f, 0.076039887965f, + 0.076541244984f, 0.076795786619f, 0.076781995595f, 0.076505072415f, + 0.075908273458f, 0.075019389391f, 0.073805764318f, 0.072239525616f, + 0.070353306830f, 0.068058051169f, 0.065404154360f, 0.062357112765f, + 0.058896079659f, 0.055046003312f, 0.050722457469f, 0.045999649912f, + 0.040812026709f, 0.035168409348f, 0.029082400724f, 0.022492101416f, + 0.015448591672f, 0.007923411205f, -0.000097587261f, -0.008571174927f, + -0.017581636086f, -0.027048788965f, -0.037012770772f, -0.047460637987f, + -0.058370534331f, -0.069793038070f, -0.081660762429f, -0.093993641436f, + -0.106792926788f, -0.120007798076f, -0.133693277836f, -0.147773429751f, + -0.162268877029f, -0.177155479789f, -0.192396670580f, -0.208034217358f, + -0.223985999823f, -0.240255206823f, -0.256831049919f, -0.273663401604f, + -0.290771633387f, -0.308093428612f, -0.325614720583f, -0.343320041895f, + 0.361158996820f, 0.379132896662f, 0.397183418274f, 0.415302306414f, + 0.433449268341f, 0.451599657536f, 0.469719588757f, 0.487774550915f, + 0.505739748478f, 0.523563683033f, 0.541255354881f, 0.558729469776f, + 0.575990140438f, 0.592998087406f, 0.609711349010f, 0.626124262810f, + 0.642155468464f, 0.657824218273f, 0.673076033592f, 0.687872409821f, + 0.702238857746f, 0.716044247150f, 0.729360222816f, 0.742110610008f, + 0.754271447659f, 0.765867471695f, 0.776768505573f, 0.787063062191f, + 0.796672165394f, 0.805576920509f, 0.813819110394f, 0.821256279945f, + 0.828002870083f, 0.833975851536f, 0.839164674282f, 0.843623816967f, + 0.847211718559f, 0.850063860416f, 0.852083206177f, 0.853290081024f, + 0.853738546371f, 0.853290081024f, 0.852083206177f, 0.850063800812f, + 0.847211718559f, 0.843623816967f, 0.839164674282f, 0.833975732327f, + 0.828002750874f, 0.821256279945f, 0.813819110394f, 0.805576920509f, + 0.796671986580f, 0.787062883377f, 0.776768505573f, 0.765867471695f, + 0.754271447659f, 0.742110371590f, 0.729359984398f, 0.716044247150f, + 0.702238857746f, 0.687872409821f, 0.673075735569f, 0.657823920250f, + 0.642155468464f, 0.626124262810f, 0.609711349010f, 0.592997789383f, + 0.575989782810f, 0.558729469776f, 0.541255354881f, 0.523563683033f, + 0.505739450455f, 0.487774193287f, 0.469719588757f, 0.451599657536f, + 0.433449268341f, 0.415301978588f, 0.397183090448f, 0.379132896662f, + -0.361158996820f, -0.343319863081f, -0.325614541769f, -0.308093249798f, + -0.290771633387f, -0.273663401604f, -0.256830900908f, -0.240255042911f, + -0.223985850811f, -0.208034217358f, -0.192396670580f, -0.177155330777f, + -0.162268742919f, -0.147773295641f, -0.133693277836f, -0.120007798076f, + -0.106792800128f, -0.093993522227f, -0.081660643220f, -0.069793038070f, + -0.058370534331f, -0.047460533679f, -0.037012673914f, -0.027048695832f, + -0.017581636086f, -0.008571174927f, -0.000097508135f, 0.007923483849f, + 0.015448661521f, 0.022492101416f, 0.029082400724f, 0.035168465227f, + 0.040812078863f, 0.045999698341f, 0.050722457469f, 0.055046003312f, + 0.058896116912f, 0.062357142568f, 0.065404184163f, 0.068058051169f, + 0.070353306830f, 0.072239540517f, 0.073805779219f, 0.075019404292f, + 0.075908273458f, 0.076505072415f, 0.076781995595f, 0.076795786619f, + 0.076541237533f, 0.076039887965f, 0.075313732028f, 0.074358314276f, + 0.073203265667f, 0.071873851120f, 0.070362940431f, 0.068704381585f, + 0.066905081272f, 0.064974069595f, 0.062942922115f, 0.060800816864f, + 0.058591566980f, 0.056295067072f, 0.053948819637f, 0.051557078958f, + 0.049129784107f, 0.046684302390f, 0.044225379825f, 0.041758891195f, + 0.039311248809f, 0.036876682192f, 0.034462094307f, 0.032091211528f, + 0.029761638492f, 0.027470171452f, 0.025238998234f, 0.023068016395f, + 0.020970601588f, 0.018938446417f, 0.016974622384f, 0.015080526471f, + -0.013271821663f, -0.011552894488f, -0.009918511845f, -0.008370377123f, + -0.006908619311f, -0.005533721298f, -0.004252942745f, -0.003051228123f, + -0.001939700567f, -0.000912644493f, 0.000027604519f, 0.000887448899f, + 0.001668263576f, 0.002366161672f, 0.002990489826f, 0.003540124744f, + 0.004013365135f, 0.004424942192f, 0.004769545514f, 0.005045676138f, + 0.005271575879f, 0.005438789260f, 0.005550692324f, 0.005619631149f, + 0.005641560070f, 0.005622064229f, 0.005566061940f, 0.005474017933f, + 0.005361671094f, 0.005203961395f, 0.005039302167f, 0.004841453396f, + 0.004632712342f, 0.004402656574f, 0.004168642685f, 0.003920743242f, + 0.003664647229f, 0.003408300225f, 0.003144827904f, 0.002882981440f, + 0.002620175947f, 0.002366054105f, 0.002113747410f, 0.001864685910f, + 0.001629810315f, 0.001390249468f, 0.001178119797f, 0.000963046390f, + 0.000768812315f, 0.000578655337f, 0.000402654026f, 0.000240558948f, + 0.000090248475f, -0.000046686841f, -0.000170717947f, -0.000289698131f, + -0.000385756488f, -0.000471418141f, -0.000548077049f, -0.000610431889f, + -0.000665041502f, -0.000709642132f, -0.000736148853f, -0.000761063420f, + -0.000777536712f, -0.000780366478f, -0.000781254901f, -0.000771615247f, + -0.000752875523f, -0.000736657763f, -0.000715773669f, -0.000684325409f, + -0.000649476249f, -0.000616869889f, -0.000579367450f, -0.000546656549f, + -0.000511504768f, -0.000489007856f, -0.000493305910f, -0.000558072818f, + +}; + +const FLOAT32 ixheaacd_random_phase[512][2] = { + {-0.99948153278296f, -0.59483417516607f}, + {0.97113454393991f, -0.67528515225647f}, + {0.14130051758487f, -0.95090983575689f}, + {-0.47005496701697f, -0.37340549728647f}, + {0.80705063769351f, 0.29653668284408f}, + {-0.38981478896926f, 0.89572605717087f}, + {-0.01053049862020f, -0.66959058036166f}, + {-0.91266367957293f, -0.11522938140034f}, + {0.54840422910309f, 0.75221367176302f}, + {0.40009252867955f, -0.98929400334421f}, + {-0.99867974711855f, -0.88147068645358f}, + {-0.95531076805040f, 0.90908757154593f}, + {-0.45725933317144f, -0.56716323646760f}, + {-0.72929675029275f, -0.98008272727324f}, + {0.75622801399036f, 0.20950329995549f}, + {0.07069442601050f, -0.78247898470706f}, + {0.74496252926055f, -0.91169004445807f}, + {-0.96440182703856f, -0.94739918296622f}, + {0.30424629369539f, -0.49438267012479f}, + {0.66565033746925f, 0.64652935542491f}, + {0.91697008020594f, 0.17514097332009f}, + {-0.70774918760427f, 0.52548653416543f}, + {-0.70051415345560f, -0.45340028808763f}, + {-0.99496513054797f, -0.90071908066973f}, + {0.98164490790123f, -0.77463155528697f}, + {-0.54671580548181f, -0.02570928536004f}, + {-0.01689629065389f, 0.00287506445732f}, + {-0.86110349531986f, 0.42548583726477f}, + {-0.98892980586032f, -0.87881132267556f}, + {0.51756627678691f, 0.66926784710139f}, + {-0.99635026409640f, -0.58107730574765f}, + {-0.99969370862163f, 0.98369989360250f}, + {0.55266258627194f, 0.59449057465591f}, + {0.34581177741673f, 0.94879421061866f}, + {0.62664209577999f, -0.74402970906471f}, + {-0.77149701404973f, -0.33883658042801f}, + {-0.91592244254432f, 0.03687901376713f}, + {-0.76285492357887f, -0.91371867919124f}, + {0.79788337195331f, -0.93180971199849f}, + {0.54473080610200f, -0.11919206037186f}, + {-0.85639281671058f, 0.42429854760451f}, + {-0.92882402971423f, 0.27871809078609f}, + {-0.11708371046774f, -0.99800843444966f}, + {0.21356749817493f, -0.90716295627033f}, + {-0.76191692573909f, 0.99768118356265f}, + {0.98111043100884f, -0.95854459734407f}, + {-0.85913269895572f, 0.95766566168880f}, + {-0.93307242253692f, 0.49431757696466f}, + {0.30485754879632f, -0.70540034357529f}, + {0.85289650925190f, 0.46766131791044f}, + {0.91328082618125f, -0.99839597361769f}, + {-0.05890199924154f, 0.70741827819497f}, + {0.28398686150148f, 0.34633555702188f}, + {0.95258164539612f, -0.54893416026939f}, + {-0.78566324168507f, -0.75568541079691f}, + {-0.95789495447877f, -0.20423194696966f}, + {0.82411158711197f, 0.96654618432562f}, + {-0.65185446735885f, -0.88734990773289f}, + {-0.93643603134666f, 0.99870790442385f}, + {0.91427159529618f, -0.98290505544444f}, + {-0.70395684036886f, 0.58796798221039f}, + {0.00563771969365f, 0.61768196727244f}, + {0.89065051931895f, 0.52783352697585f}, + {-0.68683707712762f, 0.80806944710339f}, + {0.72165342518718f, -0.69259857349564f}, + {-0.62928247730667f, 0.13627037407335f}, + {0.29938434065514f, -0.46051329682246f}, + {-0.91781958879280f, -0.74012716684186f}, + {0.99298717043688f, 0.40816610075661f}, + {0.82368298622748f, -0.74036047190173f}, + {-0.98512833386833f, -0.99972330709594f}, + {-0.95915368242257f, -0.99237800466040f}, + {-0.21411126572790f, -0.93424819052545f}, + {-0.68821476106884f, -0.26892306315457f}, + {0.91851997982317f, 0.09358228901785f}, + {-0.96062769559127f, 0.36099095133739f}, + {0.51646184922287f, -0.71373332873917f}, + {0.61130721139669f, 0.46950141175917f}, + {0.47336129371299f, -0.27333178296162f}, + {0.90998308703519f, 0.96715662938132f}, + {0.44844799194357f, 0.99211574628306f}, + {0.66614891079092f, 0.96590176169121f}, + {0.74922239129237f, -0.89879858826087f}, + {-0.99571588506485f, 0.52785521494349f}, + {0.97401082477563f, -0.16855870075190f}, + {0.72683747733879f, -0.48060774432251f}, + {0.95432193457128f, 0.68849603408441f}, + {-0.72962208425191f, -0.76608443420917f}, + {-0.85359479233537f, 0.88738125901579f}, + {-0.81412430338535f, -0.97480768049637f}, + {-0.87930772356786f, 0.74748307690436f}, + {-0.71573331064977f, -0.98570608178923f}, + {0.83524300028228f, 0.83702537075163f}, + {-0.48086065601423f, -0.98848504923531f}, + {0.97139128574778f, 0.80093621198236f}, + {0.51992825347895f, 0.80247631400510f}, + {-0.00848591195325f, -0.76670128000486f}, + {-0.70294374303036f, 0.55359910445577f}, + {-0.95894428168140f, -0.43265504344783f}, + {0.97079252950321f, 0.09325857238682f}, + {-0.92404293670797f, 0.85507704027855f}, + {-0.69506469500450f, 0.98633412625459f}, + {0.26559203620024f, 0.73314307966524f}, + {0.28038443336943f, 0.14537913654427f}, + {-0.74138124825523f, 0.99310339807762f}, + {-0.01752795995444f, -0.82616635284178f}, + {-0.55126773094930f, -0.98898543862153f}, + {0.97960898850996f, -0.94021446752851f}, + {-0.99196309146936f, 0.67019017358456f}, + {-0.67684928085260f, 0.12631491649378f}, + {0.09140039465500f, -0.20537731453108f}, + {-0.71658965751996f, -0.97788200391224f}, + {0.81014640078925f, 0.53722648362443f}, + {0.40616991671205f, -0.26469008598449f}, + {-0.67680188682972f, 0.94502052337695f}, + {0.86849774348749f, -0.18333598647899f}, + {-0.99500381284851f, -0.02634122068550f}, + {0.84329189340667f, 0.10406957462213f}, + {-0.09215968531446f, 0.69540012101253f}, + {0.99956173327206f, -0.12358542001404f}, + {-0.79732779473535f, -0.91582524736159f}, + {0.96349973642406f, 0.96640458041000f}, + {-0.79942778496547f, 0.64323902822857f}, + {-0.11566039853896f, 0.28587846253726f}, + {-0.39922954514662f, 0.94129601616966f}, + {0.99089197565987f, -0.92062625581587f}, + {0.28631285179909f, -0.91035047143603f}, + {-0.83302725605608f, -0.67330410892084f}, + {0.95404443402072f, 0.49162765398743f}, + {-0.06449863579434f, 0.03250560813135f}, + {-0.99575054486311f, 0.42389784469507f}, + {-0.65501142790847f, 0.82546114655624f}, + {-0.81254441908887f, -0.51627234660629f}, + {-0.99646369485481f, 0.84490533520752f}, + {0.00287840603348f, 0.64768261158166f}, + {0.70176989408455f, -0.20453028573322f}, + {0.96361882270190f, 0.40706967140989f}, + {-0.68883758192426f, 0.91338958840772f}, + {-0.34875585502238f, 0.71472290693300f}, + {0.91980081243087f, 0.66507455644919f}, + {-0.99009048343881f, 0.85868021604848f}, + {0.68865791458395f, 0.55660316809678f}, + {-0.99484402129368f, -0.20052559254934f}, + {0.94214511408023f, -0.99696425367461f}, + {-0.67414626793544f, 0.49548221180078f}, + {-0.47339353684664f, -0.85904328834047f}, + {0.14323651387360f, -0.94145598222488f}, + {-0.29268293575672f, 0.05759224927952f}, + {0.43793861458754f, -0.78904969892724f}, + {-0.36345126374441f, 0.64874435357162f}, + {-0.08750604656825f, 0.97686944362527f}, + {-0.96495267812511f, -0.53960305946511f}, + {0.55526940659947f, 0.78891523734774f}, + {0.73538215752630f, 0.96452072373404f}, + {-0.30889773919437f, -0.80664389776860f}, + {0.03574995626194f, -0.97325616900959f}, + {0.98720684660488f, 0.48409133691962f}, + {-0.81689296271203f, -0.90827703628298f}, + {0.67866860118215f, 0.81284503870856f}, + {-0.15808569732583f, 0.85279555024382f}, + {0.80723395114371f, -0.24717418514605f}, + {0.47788757329038f, -0.46333147839295f}, + {0.96367554763201f, 0.38486749303242f}, + {-0.99143875716818f, -0.24945277239809f}, + {0.83081876925833f, -0.94780851414763f}, + {-0.58753191905341f, 0.01290772389163f}, + {0.95538108220960f, -0.85557052096538f}, + {-0.96490920476211f, -0.64020970923102f}, + {-0.97327101028521f, 0.12378128133110f}, + {0.91400366022124f, 0.57972471346930f}, + {-0.99925837363824f, 0.71084847864067f}, + {-0.86875903507313f, -0.20291699203564f}, + {-0.26240034795124f, -0.68264554369108f}, + {-0.24664412953388f, -0.87642273115183f}, + {0.02416275806869f, 0.27192914288905f}, + {0.82068619590515f, -0.85087787994476f}, + {0.88547373760759f, -0.89636802901469f}, + {-0.18173078152226f, -0.26152145156800f}, + {0.09355476558534f, 0.54845123045604f}, + {-0.54668414224090f, 0.95980774020221f}, + {0.37050990604091f, -0.59910140383171f}, + {-0.70373594262891f, 0.91227665827081f}, + {-0.34600785879594f, -0.99441426144200f}, + {-0.68774481731008f, -0.30238837956299f}, + {-0.26843291251234f, 0.83115668004362f}, + {0.49072334613242f, -0.45359708737775f}, + {0.38975993093975f, 0.95515358099121f}, + {-0.97757125224150f, 0.05305894580606f}, + {-0.17325552859616f, -0.92770672250494f}, + {0.99948035025744f, 0.58285545563426f}, + {-0.64946246527458f, 0.68645507104960f}, + {-0.12016920576437f, -0.57147322153312f}, + {-0.58947456517751f, -0.34847132454388f}, + {-0.41815140454465f, 0.16276422358861f}, + {0.99885650204884f, 0.11136095490444f}, + {-0.56649614128386f, -0.90494866361587f}, + {0.94138021032330f, 0.35281916733018f}, + {-0.75725076534641f, 0.53650549640587f}, + {0.20541973692630f, -0.94435144369918f}, + {0.99980371023351f, 0.79835913565599f}, + {0.29078277605775f, 0.35393777921520f}, + {-0.62858772103030f, 0.38765693387102f}, + {0.43440904467688f, -0.98546330463232f}, + {-0.98298583762390f, 0.21021524625209f}, + {0.19513029146934f, -0.94239832251867f}, + {-0.95476662400101f, 0.98364554179143f}, + {0.93379635304810f, -0.70881994583682f}, + {-0.85235410573336f, -0.08342347966410f}, + {-0.86425093011245f, -0.45795025029466f}, + {0.38879779059045f, 0.97274429344593f}, + {0.92045124735495f, -0.62433652524220f}, + {0.89162532251878f, 0.54950955570563f}, + {-0.36834336949252f, 0.96458298020975f}, + {0.93891760988045f, -0.89968353740388f}, + {0.99267657565094f, -0.03757034316958f}, + {-0.94063471614176f, 0.41332338538963f}, + {0.99740224117019f, -0.16830494996370f}, + {-0.35899413170555f, -0.46633226649613f}, + {0.05237237274947f, -0.25640361602661f}, + {0.36703583957424f, -0.38653265641875f}, + {0.91653180367913f, -0.30587628726597f}, + {0.69000803499316f, 0.90952171386132f}, + {-0.38658751133527f, 0.99501571208985f}, + {-0.29250814029851f, 0.37444994344615f}, + {-0.60182204677608f, 0.86779651036123f}, + {-0.97418588163217f, 0.96468523666475f}, + {0.88461574003963f, 0.57508405276414f}, + {0.05198933055162f, 0.21269661669964f}, + {-0.53499621979720f, 0.97241553731237f}, + {-0.49429560226497f, 0.98183865291903f}, + {-0.98935142339139f, -0.40249159006933f}, + {-0.98081380091130f, -0.72856895534041f}, + {-0.27338148835532f, 0.99950922447209f}, + {0.06310802338302f, -0.54539587529618f}, + {-0.20461677199539f, -0.14209977628489f}, + {0.66223843141647f, 0.72528579940326f}, + {-0.84764345483665f, 0.02372316801261f}, + {-0.89039863483811f, 0.88866581484602f}, + {0.95903308477986f, 0.76744927173873f}, + {0.73504123909879f, -0.03747203173192f}, + {-0.31744434966056f, -0.36834111883652f}, + {-0.34110827591623f, 0.40211222807691f}, + {0.47803883714199f, -0.39423219786288f}, + {0.98299195879514f, 0.01989791390047f}, + {-0.30963073129751f, -0.18076720599336f}, + {0.99992588229018f, -0.26281872094289f}, + {-0.93149731080767f, -0.98313162570490f}, + {0.99923472302773f, -0.80142993767554f}, + {-0.26024169633417f, -0.75999759855752f}, + {-0.35712514743563f, 0.19298963768574f}, + {-0.99899084509530f, 0.74645156992493f}, + {0.86557171579452f, 0.55593866696299f}, + {0.33408042438752f, 0.86185953874709f}, + {0.99010736374716f, 0.04602397576623f}, + {-0.66694269691195f, -0.91643611810148f}, + {0.64016792079480f, 0.15649530836856f}, + {0.99570534804836f, 0.45844586038111f}, + {-0.63431466947340f, 0.21079116459234f}, + {-0.07706847005931f, -0.89581437101329f}, + {0.98590090577724f, 0.88241721133981f}, + {0.80099335254678f, -0.36851896710853f}, + {0.78368131392666f, 0.45506999802597f}, + {0.08707806671691f, 0.80938994918745f}, + {-0.86811883080712f, 0.39347308654705f}, + {-0.39466529740375f, -0.66809432114456f}, + {0.97875325649683f, -0.72467840967746f}, + {-0.95038560288864f, 0.89563219587625f}, + {0.17005239424212f, 0.54683053962658f}, + {-0.76910792026848f, -0.96226617549298f}, + {0.99743281016846f, 0.42697157037567f}, + {0.95437383549973f, 0.97002324109952f}, + {0.99578905365569f, -0.54106826257356f}, + {0.28058259829990f, -0.85361420634036f}, + {0.85256524470573f, -0.64567607735589f}, + {-0.50608540105128f, -0.65846015480300f}, + {-0.97210735183243f, -0.23095213067791f}, + {0.95424048234441f, -0.99240147091219f}, + {-0.96926570524023f, 0.73775654896574f}, + {0.30872163214726f, 0.41514960556126f}, + {-0.24523839572639f, 0.63206633394807f}, + {-0.33813265086024f, -0.38661779441897f}, + {-0.05826828420146f, -0.06940774188029f}, + {-0.22898461455054f, 0.97054853316316f}, + {-0.18509915019881f, 0.47565762892084f}, + {-0.10488238045009f, -0.87769947402394f}, + {-0.71886586182037f, 0.78030982480538f}, + {0.99793873738654f, 0.90041310491497f}, + {0.57563307626120f, -0.91034337352097f}, + {0.28909646383717f, 0.96307783970534f}, + {0.42188998312520f, 0.48148651230437f}, + {0.93335049681047f, -0.43537023883588f}, + {-0.97087374418267f, 0.86636445711364f}, + {0.36722871286923f, 0.65291654172961f}, + {-0.81093025665696f, 0.08778370229363f}, + {-0.26240603062237f, -0.92774095379098f}, + {0.83996497984604f, 0.55839849139647f}, + {-0.99909615720225f, -0.96024605713970f}, + {0.74649464155061f, 0.12144893606462f}, + {-0.74774595569805f, -0.26898062008959f}, + {0.95781667469567f, -0.79047927052628f}, + {0.95472308713099f, -0.08588776019550f}, + {0.48708332746299f, 0.99999041579432f}, + {0.46332038247497f, 0.10964126185063f}, + {-0.76497004940162f, 0.89210929242238f}, + {0.57397389364339f, 0.35289703373760f}, + {0.75374316974495f, 0.96705214651335f}, + {-0.59174397685714f, -0.89405370422752f}, + {0.75087906691890f, -0.29612672982396f}, + {-0.98607857336230f, 0.25034911730023f}, + {-0.40761056640505f, -0.90045573444695f}, + {0.66929266740477f, 0.98629493401748f}, + {-0.97463695257310f, -0.00190223301301f}, + {0.90145509409859f, 0.99781390365446f}, + {-0.87259289048043f, 0.99233587353666f}, + {-0.91529461447692f, -0.15698707534206f}, + {-0.03305738840705f, -0.37205262859764f}, + {0.07223051368337f, -0.88805001733626f}, + {0.99498012188353f, 0.97094358113387f}, + {-0.74904939500519f, 0.99985483641521f}, + {0.04585228574211f, 0.99812337444082f}, + {-0.89054954257993f, -0.31791913188064f}, + {-0.83782144651251f, 0.97637632547466f}, + {0.33454804933804f, -0.86231516800408f}, + {-0.99707579362824f, 0.93237990079441f}, + {-0.22827527843994f, 0.18874759397997f}, + {0.67248046289143f, -0.03646211390569f}, + {-0.05146538187944f, -0.92599700120679f}, + {0.99947295749905f, 0.93625229707912f}, + {0.66951124390363f, 0.98905825623893f}, + {-0.99602956559179f, -0.44654715757688f}, + {0.82104905483590f, 0.99540741724928f}, + {0.99186510988782f, 0.72023001312947f}, + {-0.65284592392918f, 0.52186723253637f}, + {0.93885443798188f, -0.74895312615259f}, + {0.96735248738388f, 0.90891816978629f}, + {-0.22225968841114f, 0.57124029781228f}, + {-0.44132783753414f, -0.92688840659280f}, + {-0.85694974219574f, 0.88844532719844f}, + {0.91783042091762f, -0.46356892383970f}, + {0.72556974415690f, -0.99899555770747f}, + {-0.99711581834508f, 0.58211560180426f}, + {0.77638976371966f, 0.94321834873819f}, + {0.07717324253925f, 0.58638399856595f}, + {-0.56049829194163f, 0.82522301569036f}, + {0.98398893639988f, 0.39467440420569f}, + {0.47546946844938f, 0.68613044836811f}, + {0.65675089314631f, 0.18331637134880f}, + {0.03273375457980f, -0.74933109564108f}, + {-0.38684144784738f, 0.51337349030406f}, + {-0.97346267944545f, -0.96549364384098f}, + {-0.53282156061942f, -0.91423265091354f}, + {0.99817310731176f, 0.61133572482148f}, + {-0.50254500772635f, -0.88829338134294f}, + {0.01995873238855f, 0.85223515096765f}, + {0.99930381973804f, 0.94578896296649f}, + {0.82907767600783f, -0.06323442598128f}, + {-0.58660709669728f, 0.96840773806582f}, + {-0.17573736667267f, -0.48166920859485f}, + {0.83434292401346f, -0.13023450646997f}, + {0.05946491307025f, 0.20511047074866f}, + {0.81505484574602f, -0.94685947861369f}, + {-0.44976380954860f, 0.40894572671545f}, + {-0.89746474625671f, 0.99846578838537f}, + {0.39677256130792f, -0.74854668609359f}, + {-0.07588948563079f, 0.74096214084170f}, + {0.76343198951445f, 0.41746629422634f}, + {-0.74490104699626f, 0.94725911744610f}, + {0.64880119792759f, 0.41336660830571f}, + {0.62319537462542f, -0.93098313552599f}, + {0.42215817594807f, -0.07712787385208f}, + {0.02704554141885f, -0.05417518053666f}, + {0.80001773566818f, 0.91542195141039f}, + {-0.79351832348816f, -0.36208897989136f}, + {0.63872359151636f, 0.08128252493444f}, + {0.52890520960295f, 0.60048872455592f}, + {0.74238552914587f, 0.04491915291044f}, + {0.99096131449250f, -0.19451182854402f}, + {-0.80412329643109f, -0.88513818199457f}, + {-0.64612616129736f, 0.72198674804544f}, + {0.11657770663191f, -0.83662833815041f}, + {-0.95053182488101f, -0.96939905138082f}, + {-0.62228872928622f, 0.82767262846661f}, + {0.03004475787316f, -0.99738896333384f}, + {-0.97987214341034f, 0.36526129686425f}, + {-0.99986980746200f, -0.36021610299715f}, + {0.89110648599879f, -0.97894250343044f}, + {0.10407960510582f, 0.77357793811619f}, + {0.95964737821728f, -0.35435818285502f}, + {0.50843233159162f, 0.96107691266205f}, + {0.17006334670615f, -0.76854025314829f}, + {0.25872675063360f, 0.99893303933816f}, + {-0.01115998681937f, 0.98496019742444f}, + {-0.79598702973261f, 0.97138411318894f}, + {-0.99264708948101f, -0.99542822402536f}, + {-0.99829663752818f, 0.01877138824311f}, + {-0.70801016548184f, 0.33680685948117f}, + {-0.70467057786826f, 0.93272777501857f}, + {0.99846021905254f, -0.98725746254433f}, + {-0.63364968534650f, -0.16473594423746f}, + {-0.16258217500792f, -0.95939125400802f}, + {-0.43645594360633f, -0.94805030113284f}, + {-0.99848471702976f, 0.96245166923809f}, + {-0.16796458968998f, -0.98987511890470f}, + {-0.87979225745213f, -0.71725725041680f}, + {0.44183099021786f, -0.93568974498761f}, + {0.93310180125532f, -0.99913308068246f}, + {-0.93941931782002f, -0.56409379640356f}, + {-0.88590003188677f, 0.47624600491382f}, + {0.99971463703691f, -0.83889954253462f}, + {-0.75376385639978f, 0.00814643438625f}, + {0.93887685615875f, -0.11284528204636f}, + {0.85126435782309f, 0.52349251543547f}, + {0.39701421446381f, 0.81779634174316f}, + {-0.37024464187437f, -0.87071656222959f}, + {-0.36024828242896f, 0.34655735648287f}, + {-0.93388812549209f, -0.84476541096429f}, + {-0.65298804552119f, -0.18439575450921f}, + {0.11960319006843f, 0.99899346780168f}, + {0.94292565553160f, 0.83163906518293f}, + {0.75081145286948f, -0.35533223142265f}, + {0.56721979748394f, -0.24076836414499f}, + {0.46857766746029f, -0.30140233457198f}, + {0.97312313923635f, -0.99548191630031f}, + {-0.38299976567017f, 0.98516909715427f}, + {0.41025800019463f, 0.02116736935734f}, + {0.09638062008048f, 0.04411984381457f}, + {-0.85283249275397f, 0.91475563922421f}, + {0.88866808958124f, -0.99735267083226f}, + {-0.48202429536989f, -0.96805608884164f}, + {0.27572582416567f, 0.58634753335832f}, + {-0.65889129659168f, 0.58835634138583f}, + {0.98838086953732f, 0.99994349600236f}, + {-0.20651349620689f, 0.54593044066355f}, + {-0.62126416356920f, -0.59893681700392f}, + {0.20320105410437f, -0.86879180355289f}, + {-0.97790548600584f, 0.96290806999242f}, + {0.11112534735126f, 0.21484763313301f}, + {-0.41368337314182f, 0.28216837680365f}, + {0.24133038992960f, 0.51294362630238f}, + {-0.66393410674885f, -0.08249679629081f}, + {-0.53697829178752f, -0.97649903936228f}, + {-0.97224737889348f, 0.22081333579837f}, + {0.87392477144549f, -0.12796173740361f}, + {0.19050361015753f, 0.01602615387195f}, + {-0.46353441212724f, -0.95249041539006f}, + {-0.07064096339021f, -0.94479803205886f}, + {-0.92444085484466f, -0.10457590187436f}, + {-0.83822593578728f, -0.01695043208885f}, + {0.75214681811150f, -0.99955681042665f}, + {-0.42102998829339f, 0.99720941999394f}, + {-0.72094786237696f, -0.35008961934255f}, + {0.78843311019251f, 0.52851398958271f}, + {0.97394027897442f, -0.26695944086561f}, + {0.99206463477946f, -0.57010120849429f}, + {0.76789609461795f, -0.76519356730966f}, + {-0.82002421836409f, -0.73530179553767f}, + {0.81924990025724f, 0.99698425250579f}, + {-0.26719850873357f, 0.68903369776193f}, + {-0.43311260380975f, 0.85321815947490f}, + {0.99194979673836f, 0.91876249766422f}, + {-0.80692001248487f, -0.32627540663214f}, + {0.43080003649976f, -0.21919095636638f}, + {0.67709491937357f, -0.95478075822906f}, + {0.56151770568316f, -0.70693811747778f}, + {0.10831862810749f, -0.08628837174592f}, + {0.91229417540436f, -0.65987351408410f}, + {-0.48972893932274f, 0.56289246362686f}, + {-0.89033658689697f, -0.71656563987082f}, + {0.65269447475094f, 0.65916004833932f}, + {0.67439478141121f, -0.81684380846796f}, + {-0.47770832416973f, -0.16789556203025f}, + {-0.99715979260878f, -0.93565784007648f}, + {-0.90889593602546f, 0.62034397054380f}, + {-0.06618622548177f, -0.23812217221359f}, + {0.99430266919728f, 0.18812555317553f}, + {0.97686402381843f, -0.28664534366620f}, + {0.94813650221268f, -0.97506640027128f}, + {-0.95434497492853f, -0.79607978501983f}, + {-0.49104783137150f, 0.32895214359663f}, + {0.99881175120751f, 0.88993983831354f}, + {0.50449166760303f, -0.85995072408434f}, + {0.47162891065108f, -0.18680204049569f}, + {-0.62081581361840f, 0.75000676218956f}, + {-0.43867015250812f, 0.99998069244322f}, + {0.98630563232075f, -0.53578899600662f}, + {-0.61510362277374f, -0.89515019899997f}, + {-0.03841517601843f, -0.69888815681179f}, + {-0.30102157304644f, -0.07667808922205f}, + {0.41881284182683f, 0.02188098922282f}, + {-0.86135454941237f, 0.98947480909359f}, + {0.67226861393788f, -0.13494389011014f}, + {-0.70737398842068f, -0.76547349325992f}, + {0.94044946687963f, 0.09026201157416f}, + {-0.82386352534327f, 0.08924768823676f}, + {-0.32070666698656f, 0.50143421908753f}, + {0.57593163224487f, -0.98966422921509f}, + {-0.36326018419965f, 0.07440243123228f}, + {0.99979044674350f, -0.14130287347405f}, + {-0.92366023326932f, -0.97979298068180f}, + {-0.44607178518598f, -0.54233252016394f}, + {0.44226800932956f, 0.71326756742752f}, + {0.03671907158312f, 0.63606389366675f}, + {0.52175424682195f, -0.85396826735705f}, + {-0.94701139690956f, -0.01826348194255f}, + {-0.98759606946049f, 0.82288714303073f}, + {0.87434794743625f, 0.89399495655433f}, + {-0.93412041758744f, 0.41374052024363f}, + {0.96063943315511f, 0.93116709541280f}, + {0.97534253457837f, 0.86150930812689f}, + {0.99642466504163f, 0.70190043427512f}, + {-0.94705089665984f, -0.29580042814306f}, + {0.91599807087376f, -0.98147830385781f}}; + +const FLOAT32 ixheaacd_hphase_tbl[2][8] = {{1.0f, 0.0f, -1.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, -1.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 FLOAT32 ixheaacd_q_gamma_table[4] = {0.0f, 1.0f, 2.0f, 4.0f}; + +const WORD32 ixheaacd_start_subband2kL_tbl[33] = { + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, + 6, 8, 8, 8, 8, 8, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12}; + +const FLOAT32 ixheaacd_cos_table_trans_qmf[7][32 * 2] = { + + { + -0.698376249409f, 0.715730825284f, 0.732654271672f, 0.680600997795f, + 0.662415777590f, -0.749136394523f, -0.765167265622f, -0.643831542890f, + -0.624859488142f, 0.780737228572f, 0.795836904609f, 0.605511041404f, + 0.585797857456f, -0.810457198253f, -0.824589302785f, -0.565731810784f, + -0.545324988422f, 0.838224705555f, 0.851355193105f, 0.524589682678f, + 0.503538383726f, -0.863972856122f, -0.876070094195f, -0.482183772079f, + -0.460538710958f, 0.887639620403f, 0.898674465694f, 0.438616238539f, + 0.416429560098f, -0.909167983091f, -0.919113851690f, -0.393992040061f, + -0.371317193952f, 0.928506080473f, 0.937339011913f, 0.348418680249f, + 0.325310292162f, -0.945607325381f, -0.953306040354f, -0.302005949319f, + -0.278519689385f, 0.960430519416f, 0.966976471045f, 0.254865659605f, + 0.231058108281f, -0.972939952206f, -0.978317370720f, -0.207111376192f, + -0.183039887955f, 0.983105487431f, 0.987301418158f, 0.158858143334f, + 0.134580708507f, -0.990902635428f, -0.993906970002f, -0.110222207294f, + -0.085797312344f, 0.996312612183f, 0.998118112900f, 0.061320736302f, + 0.036807222941f, -0.999322384588f, -0.999924701839f, -0.012271538286f, + }, + + { + -0.662415777590f, 0.749136394523f, 0.765167265622f, 0.643831542890f, + 0.624859488142f, -0.780737228572f, -0.795836904609f, -0.605511041404f, + -0.585797857456f, 0.810457198253f, 0.824589302785f, 0.565731810784f, + 0.545324988422f, -0.838224705555f, -0.851355193105f, -0.524589682678f, + -0.503538383726f, 0.863972856122f, 0.876070094195f, 0.482183772079f, + 0.460538710958f, -0.887639620403f, -0.898674465694f, -0.438616238539f, + -0.416429560098f, 0.909167983091f, 0.919113851690f, 0.393992040061f, + 0.371317193952f, -0.928506080473f, -0.937339011913f, -0.348418680249f, + -0.325310292162f, 0.945607325381f, 0.953306040354f, 0.302005949319f, + 0.278519689385f, -0.960430519416f, -0.966976471045f, -0.254865659605f, + -0.231058108281f, 0.972939952206f, 0.978317370720f, 0.207111376192f, + 0.183039887955f, -0.983105487431f, -0.987301418158f, -0.158858143334f, + -0.134580708507f, 0.990902635428f, 0.993906970002f, 0.110222207294f, + 0.085797312344f, -0.996312612183f, -0.998118112900f, -0.061320736302f, + -0.036807222941f, 0.999322384588f, 0.999924701839f, 0.012271538286f, + -0.012271538286f, -0.999924701839f, -0.999322384588f, 0.036807222941f, + + }, + + { + -0.624859488142f, 0.780737228572f, 0.795836904609f, 0.605511041404f, + 0.585797857456f, -0.810457198253f, -0.824589302785f, -0.565731810784f, + -0.545324988422f, 0.838224705555f, 0.851355193105f, 0.524589682678f, + 0.503538383726f, -0.863972856122f, -0.876070094195f, -0.482183772079f, + -0.460538710958f, 0.887639620403f, 0.898674465694f, 0.438616238539f, + 0.416429560098f, -0.909167983091f, -0.919113851690f, -0.393992040061f, + -0.371317193952f, 0.928506080473f, 0.937339011913f, 0.348418680249f, + 0.325310292162f, -0.945607325381f, -0.953306040354f, -0.302005949319f, + -0.278519689385f, 0.960430519416f, 0.966976471045f, 0.254865659605f, + 0.231058108281f, -0.972939952206f, -0.978317370720f, -0.207111376192f, + -0.183039887955f, 0.983105487431f, 0.987301418158f, 0.158858143334f, + 0.134580708507f, -0.990902635428f, -0.993906970002f, -0.110222207294f, + -0.085797312344f, 0.996312612183f, 0.998118112900f, 0.061320736302f, + 0.036807222941f, -0.999322384588f, -0.999924701839f, -0.012271538286f, + 0.012271538286f, 0.999924701839f, 0.999322384588f, -0.036807222941f, + -0.061320736302f, -0.998118112900f, -0.996312612183f, 0.085797312344f, + + }, + + { + -0.585797857456f, 0.810457198253f, 0.824589302785f, 0.565731810784f, + 0.545324988422f, -0.838224705555f, -0.851355193105f, -0.524589682678f, + -0.503538383726f, 0.863972856122f, 0.876070094195f, 0.482183772079f, + 0.460538710958f, -0.887639620403f, -0.898674465694f, -0.438616238539f, + -0.416429560098f, 0.909167983091f, 0.919113851690f, 0.393992040061f, + 0.371317193952f, -0.928506080473f, -0.937339011913f, -0.348418680249f, + -0.325310292162f, 0.945607325381f, 0.953306040354f, 0.302005949319f, + 0.278519689385f, -0.960430519416f, -0.966976471045f, -0.254865659605f, + -0.231058108281f, 0.972939952206f, 0.978317370720f, 0.207111376192f, + 0.183039887955f, -0.983105487431f, -0.987301418158f, -0.158858143334f, + -0.134580708507f, 0.990902635428f, 0.993906970002f, 0.110222207294f, + 0.085797312344f, -0.996312612183f, -0.998118112900f, -0.061320736302f, + -0.036807222941f, 0.999322384588f, 0.999924701839f, 0.012271538286f, + -0.012271538286f, -0.999924701839f, -0.999322384588f, 0.036807222941f, + 0.061320736302f, 0.998118112900f, 0.996312612183f, -0.085797312344f, + -0.110222207294f, -0.993906970002f, -0.990902635428f, 0.134580708507f, + + }, + + { + -0.545324988422f, 0.838224705555f, 0.851355193105f, 0.524589682678f, + 0.503538383726f, -0.863972856122f, -0.876070094195f, -0.482183772079f, + -0.460538710958f, 0.887639620403f, 0.898674465694f, 0.438616238539f, + 0.416429560098f, -0.909167983091f, -0.919113851690f, -0.393992040061f, + -0.371317193952f, 0.928506080473f, 0.937339011913f, 0.348418680249f, + 0.325310292162f, -0.945607325381f, -0.953306040354f, -0.302005949319f, + -0.278519689385f, 0.960430519416f, 0.966976471045f, 0.254865659605f, + 0.231058108281f, -0.972939952206f, -0.978317370720f, -0.207111376192f, + -0.183039887955f, 0.983105487431f, 0.987301418158f, 0.158858143334f, + 0.134580708507f, -0.990902635428f, -0.993906970002f, -0.110222207294f, + -0.085797312344f, 0.996312612183f, 0.998118112900f, 0.061320736302f, + 0.036807222941f, -0.999322384588f, -0.999924701839f, -0.012271538286f, + 0.012271538286f, 0.999924701839f, 0.999322384588f, -0.036807222941f, + -0.061320736302f, -0.998118112900f, -0.996312612183f, 0.085797312344f, + 0.110222207294f, 0.993906970002f, 0.990902635428f, -0.134580708507f, + -0.158858143334f, -0.987301418158f, -0.983105487431f, 0.183039887955f, + + }, + + { + -0.503538383726f, 0.863972856122f, 0.876070094195f, 0.482183772079f, + 0.460538710958f, -0.887639620403f, -0.898674465694f, -0.438616238539f, + -0.416429560098f, 0.909167983091f, 0.919113851690f, 0.393992040061f, + 0.371317193952f, -0.928506080473f, -0.937339011913f, -0.348418680249f, + -0.325310292162f, 0.945607325381f, 0.953306040354f, 0.302005949319f, + 0.278519689385f, -0.960430519416f, -0.966976471045f, -0.254865659605f, + -0.231058108281f, 0.972939952206f, 0.978317370720f, 0.207111376192f, + 0.183039887955f, -0.983105487431f, -0.987301418158f, -0.158858143334f, + -0.134580708507f, 0.990902635428f, 0.993906970002f, 0.110222207294f, + 0.085797312344f, -0.996312612183f, -0.998118112900f, -0.061320736302f, + -0.036807222941f, 0.999322384588f, 0.999924701839f, 0.012271538286f, + -0.012271538286f, -0.999924701839f, -0.999322384588f, 0.036807222941f, + 0.061320736302f, 0.998118112900f, 0.996312612183f, -0.085797312344f, + -0.110222207294f, -0.993906970002f, -0.990902635428f, 0.134580708507f, + 0.158858143334f, 0.987301418158f, 0.983105487431f, -0.183039887955f, + -0.207111376192f, -0.978317370720f, -0.972939952206f, 0.231058108281f, + + }, + + { + -0.460538710958f, 0.887639620403f, 0.898674465694f, 0.438616238539f, + 0.416429560098f, -0.909167983091f, -0.919113851690f, -0.393992040061f, + -0.371317193952f, 0.928506080473f, 0.937339011913f, 0.348418680249f, + 0.325310292162f, -0.945607325381f, -0.953306040354f, -0.302005949319f, + -0.278519689385f, 0.960430519416f, 0.966976471045f, 0.254865659605f, + 0.231058108281f, -0.972939952206f, -0.978317370720f, -0.207111376192f, + -0.183039887955f, 0.983105487431f, 0.987301418158f, 0.158858143334f, + 0.134580708507f, -0.990902635428f, -0.993906970002f, -0.110222207294f, + -0.085797312344f, 0.996312612183f, 0.998118112900f, 0.061320736302f, + 0.036807222941f, -0.999322384588f, -0.999924701839f, -0.012271538286f, + 0.012271538286f, 0.999924701839f, 0.999322384588f, -0.036807222941f, + -0.061320736302f, -0.998118112900f, -0.996312612183f, 0.085797312344f, + 0.110222207294f, 0.993906970002f, 0.990902635428f, -0.134580708507f, + -0.158858143334f, -0.987301418158f, -0.983105487431f, 0.183039887955f, + 0.207111376192f, 0.978317370720f, 0.972939952206f, -0.231058108281f, + -0.254865659605f, -0.966976471045f, -0.960430519416f, 0.278519689385f, + + } + +}; + +const FLOAT32 ixheaacd_phase_vocoder_cos_table[64] = { + 0.012272f, -0.036807f, 0.061321f, -0.085797f, 0.110222f, -0.134581f, + 0.158858f, -0.183040f, 0.207111f, -0.231058f, 0.254866f, -0.278520f, + 0.302006f, -0.325310f, 0.348419f, -0.371317f, 0.393992f, -0.416430f, + 0.438616f, -0.460539f, 0.482184f, -0.503538f, 0.524590f, -0.545325f, + 0.565732f, -0.585798f, 0.605511f, -0.624859f, 0.643832f, -0.662416f, + 0.680601f, -0.698376f, 0.715731f, -0.732654f, 0.749136f, -0.765167f, + 0.780737f, -0.795837f, 0.810457f, -0.824589f, 0.838225f, -0.851355f, + 0.863973f, -0.876070f, 0.887640f, -0.898674f, 0.909168f, -0.919114f, + 0.928506f, -0.937339f, 0.945607f, -0.953306f, 0.960431f, -0.966976f, + 0.972940f, -0.978317f, 0.983105f, -0.987301f, 0.990903f, -0.993907f, + 0.996313f, -0.998118f, 0.999322f, -0.999925f, +}; +const FLOAT32 ixheaacd_phase_vocoder_sin_table[64] = { + 0.999925f, -0.999322f, 0.998118f, -0.996313f, 0.993907f, -0.990903f, + 0.987301f, -0.983105f, 0.978317f, -0.972940f, 0.966976f, -0.960431f, + 0.953306f, -0.945607f, 0.937339f, -0.928506f, 0.919114f, -0.909168f, + 0.898674f, -0.887640f, 0.876070f, -0.863973f, 0.851355f, -0.838225f, + 0.824589f, -0.810457f, 0.795837f, -0.780737f, 0.765167f, -0.749136f, + 0.732654f, -0.715731f, 0.698376f, -0.680601f, 0.662416f, -0.643832f, + 0.624859f, -0.605511f, 0.585798f, -0.565732f, 0.545325f, -0.524590f, + 0.503538f, -0.482184f, 0.460539f, -0.438616f, 0.416430f, -0.393992f, + 0.371317f, -0.348419f, 0.325310f, -0.302006f, 0.278520f, -0.254866f, + 0.231058f, -0.207111f, 0.183040f, -0.158858f, 0.134581f, -0.110222f, + 0.085797f, -0.061321f, 0.036807f, -0.012272f, +}; + +const FLOAT32 ixheaacd_hbe_post_anal_proc_interp_coeff[4][2] = { + + {0.3984033437f, 0.3984033437f}, + {0.3984033437f, -0.3984033437f}, + {-0.3984033437f, -0.3984033437f}, + {-0.3984033437f, 0.3984033437f}, +}; + +const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_2[(128 + 128) * 2] = { + + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923880f, 0.382683f, 0.866025f, 0.500000f, 0.793353f, 0.608761f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866025f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382683f, 0.923880f, -0.500000f, 0.866025f, -0.608761f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866025f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923880f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608761f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866025f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923880f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793353f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866026f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923879f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793354f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130527f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793354f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130527f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707106f, -0.793354f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130527f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707106f, -0.707107f, -0.608761f, -0.793354f, + + 1.000000f, 0.000000f, 0.997859f, 0.065403f, 0.991445f, 0.130526f, + 0.980785f, 0.195090f, 0.965926f, 0.258819f, 0.946930f, 0.321439f, + 0.923880f, 0.382683f, 0.896873f, 0.442289f, 0.866025f, 0.500000f, + 0.831470f, 0.555570f, 0.793353f, 0.608761f, 0.751840f, 0.659346f, + 0.707107f, 0.707107f, 0.659346f, 0.751840f, 0.608761f, 0.793353f, + 0.555570f, 0.831470f, 0.500000f, 0.866025f, 0.442289f, 0.896873f, + 0.382683f, 0.923880f, 0.321439f, 0.946930f, 0.258819f, 0.965926f, + 0.195090f, 0.980785f, 0.130526f, 0.991445f, 0.065403f, 0.997859f, + -0.000000f, 1.000000f, -0.065403f, 0.997859f, -0.130526f, 0.991445f, + -0.195090f, 0.980785f, -0.258819f, 0.965926f, -0.321440f, 0.946930f, + -0.382683f, 0.923880f, -0.442289f, 0.896873f, -0.500000f, 0.866025f, + -0.555570f, 0.831470f, -0.608761f, 0.793353f, -0.659346f, 0.751840f, + -0.707107f, 0.707107f, -0.751840f, 0.659346f, -0.793353f, 0.608761f, + -0.831470f, 0.555570f, -0.866025f, 0.500000f, -0.896873f, 0.442289f, + -0.923880f, 0.382683f, -0.946930f, 0.321439f, -0.965926f, 0.258819f, + -0.980785f, 0.195090f, -0.991445f, 0.130526f, -0.997859f, 0.065403f, + -1.000000f, -0.000000f, -0.997859f, -0.065403f, -0.991445f, -0.130526f, + -0.980785f, -0.195090f, -0.965926f, -0.258819f, -0.946930f, -0.321440f, + -0.923880f, -0.382684f, -0.896873f, -0.442289f, -0.866025f, -0.500000f, + -0.831470f, -0.555570f, -0.793353f, -0.608761f, -0.751840f, -0.659346f, + -0.707107f, -0.707107f, -0.659346f, -0.751840f, -0.608761f, -0.793353f, + -0.555570f, -0.831470f, -0.500000f, -0.866025f, -0.442289f, -0.896873f, + -0.382683f, -0.923880f, -0.321439f, -0.946930f, -0.258819f, -0.965926f, + -0.195090f, -0.980785f, -0.130526f, -0.991445f, -0.065403f, -0.997859f, + 0.000000f, -1.000000f, 0.065403f, -0.997859f, 0.130526f, -0.991445f, + 0.195090f, -0.980785f, 0.258819f, -0.965926f, 0.321440f, -0.946930f, + 0.382684f, -0.923880f, 0.442289f, -0.896873f, 0.500000f, -0.866025f, + 0.555570f, -0.831470f, 0.608762f, -0.793353f, 0.659346f, -0.751840f, + 0.707107f, -0.707107f, 0.751840f, -0.659346f, 0.793353f, -0.608761f, + 0.831470f, -0.555570f, 0.866026f, -0.500000f, 0.896873f, -0.442289f, + 0.923880f, -0.382683f, 0.946930f, -0.321439f, 0.965926f, -0.258819f, + 0.980785f, -0.195090f, 0.991445f, -0.130526f, 0.997859f, -0.065403f, + 1.000000f, 0.000000f, 0.997859f, 0.065403f, 0.991445f, 0.130526f, + 0.980785f, 0.195091f, 0.965926f, 0.258819f, 0.946930f, 0.321440f, + 0.923879f, 0.382684f, 0.896873f, 0.442289f, 0.866025f, 0.500000f, + 0.831470f, 0.555570f, 0.793353f, 0.608762f, 0.751840f, 0.659346f, + 0.707107f, 0.707107f, 0.659346f, 0.751840f, 0.608761f, 0.793353f, + 0.555570f, 0.831470f, 0.500000f, 0.866026f, 0.442289f, 0.896873f, + 0.382683f, 0.923880f, 0.321439f, 0.946930f, 0.258819f, 0.965926f, + 0.195090f, 0.980785f, 0.130526f, 0.991445f, 0.065403f, 0.997859f, + -0.000000f, 1.000000f, -0.065403f, 0.997859f, -0.130526f, 0.991445f, + -0.195091f, 0.980785f, -0.258819f, 0.965926f, -0.321440f, 0.946930f, + -0.382684f, 0.923879f, -0.442289f, 0.896873f, + +}; + +const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_3[(128 + 128) * 2] = { + + 1.000000f, 0.000000f, 0.965926f, 0.258819f, 0.866025f, 0.500000f, + 0.707107f, 0.707107f, 0.500000f, 0.866025f, 0.258819f, 0.965926f, + -0.000000f, 1.000000f, -0.258819f, 0.965926f, -0.500000f, 0.866025f, + -0.707107f, 0.707107f, -0.866025f, 0.500000f, -0.965926f, 0.258819f, + -1.000000f, -0.000000f, -0.965926f, -0.258819f, -0.866025f, -0.500000f, + -0.707107f, -0.707107f, -0.500000f, -0.866025f, -0.258819f, -0.965926f, + 0.000000f, -1.000000f, 0.258819f, -0.965926f, 0.500000f, -0.866025f, + 0.707107f, -0.707107f, 0.866026f, -0.500000f, 0.965926f, -0.258819f, + 1.000000f, 0.000000f, 0.965926f, 0.258819f, 0.866025f, 0.500000f, + 0.707107f, 0.707107f, 0.500000f, 0.866026f, 0.258819f, 0.965926f, + -0.000000f, 1.000000f, -0.258819f, 0.965926f, -0.500000f, 0.866025f, + -0.707107f, 0.707107f, -0.866026f, 0.500000f, -0.965926f, 0.258819f, + -1.000000f, -0.000000f, -0.965926f, -0.258819f, -0.866025f, -0.500000f, + -0.707107f, -0.707107f, -0.500000f, -0.866026f, -0.258819f, -0.965926f, + 0.000000f, -1.000000f, 0.258819f, -0.965926f, 0.500000f, -0.866025f, + 0.707107f, -0.707107f, 0.866026f, -0.500000f, 0.965926f, -0.258819f, + 1.000000f, 0.000000f, 0.965926f, 0.258819f, 0.866025f, 0.500000f, + 0.707107f, 0.707107f, 0.500000f, 0.866026f, 0.258819f, 0.965926f, + -0.000000f, 1.000000f, -0.258819f, 0.965926f, -0.500000f, 0.866025f, + -0.707107f, 0.707106f, -0.866026f, 0.500000f, -0.965926f, 0.258819f, + -1.000000f, -0.000000f, -0.965926f, -0.258819f, -0.866025f, -0.500000f, + -0.707106f, -0.707107f, -0.500000f, -0.866026f, -0.258819f, -0.965926f, + 0.000000f, -1.000000f, 0.258820f, -0.965926f, 0.500000f, -0.866025f, + 0.707107f, -0.707106f, 0.866026f, -0.500000f, 0.965926f, -0.258819f, + 1.000000f, 0.000001f, 0.965926f, 0.258820f, 0.866025f, 0.500000f, + 0.707106f, 0.707107f, 0.500000f, 0.866026f, 0.258819f, 0.965926f, + -0.000001f, 1.000000f, -0.258820f, 0.965926f, -0.500000f, 0.866025f, + -0.707107f, 0.707106f, -0.866026f, 0.499999f, -0.965926f, 0.258818f, + -1.000000f, -0.000001f, -0.965926f, -0.258820f, -0.866025f, -0.500001f, + -0.707106f, -0.707107f, -0.499999f, -0.866026f, -0.258818f, -0.965926f, + 0.000001f, -1.000000f, 0.258820f, -0.965926f, 0.500001f, -0.866025f, + 0.707107f, -0.707106f, 0.866026f, -0.499999f, 0.965926f, -0.258818f, + 1.000000f, 0.000001f, 0.965926f, 0.258820f, 0.866025f, 0.500001f, + 0.707106f, 0.707107f, 0.499999f, 0.866026f, 0.258818f, 0.965926f, + -0.000001f, 1.000000f, -0.258820f, 0.965926f, -0.500001f, 0.866025f, + -0.707107f, 0.707106f, -0.866026f, 0.499999f, -0.965926f, 0.258818f, + -1.000000f, -0.000001f, -0.965926f, -0.258820f, -0.866025f, -0.500001f, + -0.707106f, -0.707107f, -0.499999f, -0.866026f, -0.258818f, -0.965926f, + 0.000001f, -1.000000f, 0.258820f, -0.965926f, 0.500001f, -0.866025f, + 0.707107f, -0.707106f, 0.866026f, -0.499999f, 0.965926f, -0.258818f, + 1.000000f, 0.000001f, 0.965926f, 0.258820f, 0.866025f, 0.500001f, + 0.707106f, 0.707107f, 0.499999f, 0.866026f, 0.258818f, 0.965926f, + -0.000001f, 1.000000f, -0.258820f, 0.965926f, + + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923880f, 0.382683f, 0.866025f, 0.500000f, 0.793353f, 0.608761f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866025f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382683f, 0.923880f, -0.500000f, 0.866025f, -0.608761f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866025f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923880f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608761f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866025f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923880f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793353f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866026f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923879f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793354f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130527f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793354f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130527f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707106f, -0.793354f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130527f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707106f, -0.707107f, -0.608761f, -0.793354f, + +}; + +const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_4[(128 + 128) * 2] = { + + 1.000000f, 0.000000f, 0.923880f, 0.382683f, 0.707107f, 0.707107f, + 0.382683f, 0.923880f, -0.000000f, 1.000000f, -0.382683f, 0.923880f, + -0.707107f, 0.707107f, -0.923880f, 0.382683f, -1.000000f, -0.000000f, + -0.923880f, -0.382684f, -0.707107f, -0.707107f, -0.382683f, -0.923880f, + 0.000000f, -1.000000f, 0.382684f, -0.923880f, 0.707107f, -0.707107f, + 0.923880f, -0.382683f, 1.000000f, 0.000000f, 0.923879f, 0.382684f, + 0.707107f, 0.707107f, 0.382683f, 0.923880f, -0.000000f, 1.000000f, + -0.382684f, 0.923879f, -0.707107f, 0.707107f, -0.923880f, 0.382683f, + -1.000000f, -0.000000f, -0.923879f, -0.382684f, -0.707107f, -0.707107f, + -0.382683f, -0.923880f, 0.000000f, -1.000000f, 0.382684f, -0.923879f, + 0.707107f, -0.707107f, 0.923880f, -0.382683f, 1.000000f, 0.000000f, + 0.923879f, 0.382684f, 0.707107f, 0.707107f, 0.382683f, 0.923880f, + -0.000000f, 1.000000f, -0.382684f, 0.923879f, -0.707107f, 0.707106f, + -0.923880f, 0.382683f, -1.000000f, -0.000000f, -0.923879f, -0.382684f, + -0.707106f, -0.707107f, -0.382683f, -0.923880f, 0.000000f, -1.000000f, + 0.382684f, -0.923879f, 0.707107f, -0.707106f, 0.923880f, -0.382683f, + 1.000000f, 0.000001f, 0.923879f, 0.382684f, 0.707106f, 0.707107f, + 0.382683f, 0.923880f, -0.000001f, 1.000000f, -0.382684f, 0.923879f, + -0.707107f, 0.707106f, -0.923880f, 0.382683f, -1.000000f, -0.000001f, + -0.923879f, -0.382684f, -0.707106f, -0.707107f, -0.382683f, -0.923880f, + 0.000001f, -1.000000f, 0.382684f, -0.923879f, 0.707107f, -0.707106f, + 0.923880f, -0.382683f, 1.000000f, 0.000001f, 0.923879f, 0.382684f, + 0.707106f, 0.707107f, 0.382683f, 0.923880f, -0.000001f, 1.000000f, + -0.382684f, 0.923879f, -0.707107f, 0.707106f, -0.923880f, 0.382683f, + -1.000000f, -0.000001f, -0.923879f, -0.382684f, -0.707106f, -0.707107f, + -0.382683f, -0.923880f, 0.000001f, -1.000000f, 0.382684f, -0.923879f, + 0.707107f, -0.707106f, 0.923880f, -0.382683f, 1.000000f, 0.000001f, + 0.923879f, 0.382684f, 0.707106f, 0.707107f, 0.382683f, 0.923880f, + -0.000001f, 1.000000f, -0.382684f, 0.923879f, -0.707107f, 0.707106f, + -0.923880f, 0.382683f, -1.000000f, -0.000001f, -0.923879f, -0.382684f, + -0.707106f, -0.707107f, -0.382683f, -0.923880f, 0.000001f, -1.000000f, + 0.382684f, -0.923879f, 0.707107f, -0.707106f, 0.923880f, -0.382682f, + 1.000000f, 0.000001f, 0.923879f, 0.382684f, 0.707106f, 0.707108f, + 0.382682f, 0.923880f, -0.000001f, 1.000000f, -0.382684f, 0.923879f, + -0.707108f, 0.707106f, -0.923880f, 0.382682f, -1.000000f, -0.000001f, + -0.923879f, -0.382684f, -0.707106f, -0.707108f, -0.382682f, -0.923880f, + 0.000001f, -1.000000f, 0.382685f, -0.923879f, 0.707108f, -0.707106f, + 0.923880f, -0.382682f, 1.000000f, 0.000001f, 0.923879f, 0.382685f, + 0.707106f, 0.707108f, 0.382682f, 0.923880f, -0.000001f, 1.000000f, + -0.382685f, 0.923879f, -0.707108f, 0.707106f, -0.923880f, 0.382682f, + -1.000000f, -0.000001f, -0.923879f, -0.382685f, -0.707106f, -0.707108f, + -0.382682f, -0.923880f, 0.000001f, -1.000000f, 0.382685f, -0.923879f, + 0.707108f, -0.707106f, 0.923880f, -0.382682f, + + 1.000000f, 0.000000f, 0.980785f, 0.195090f, 0.923880f, 0.382683f, + 0.831470f, 0.555570f, 0.707107f, 0.707107f, 0.555570f, 0.831470f, + 0.382683f, 0.923880f, 0.195090f, 0.980785f, -0.000000f, 1.000000f, + -0.195090f, 0.980785f, -0.382683f, 0.923880f, -0.555570f, 0.831470f, + -0.707107f, 0.707107f, -0.831470f, 0.555570f, -0.923880f, 0.382683f, + -0.980785f, 0.195090f, -1.000000f, -0.000000f, -0.980785f, -0.195090f, + -0.923880f, -0.382684f, -0.831470f, -0.555570f, -0.707107f, -0.707107f, + -0.555570f, -0.831470f, -0.382683f, -0.923880f, -0.195090f, -0.980785f, + 0.000000f, -1.000000f, 0.195090f, -0.980785f, 0.382684f, -0.923880f, + 0.555570f, -0.831470f, 0.707107f, -0.707107f, 0.831470f, -0.555570f, + 0.923880f, -0.382683f, 0.980785f, -0.195090f, 1.000000f, 0.000000f, + 0.980785f, 0.195091f, 0.923879f, 0.382684f, 0.831470f, 0.555570f, + 0.707107f, 0.707107f, 0.555570f, 0.831470f, 0.382683f, 0.923880f, + 0.195090f, 0.980785f, -0.000000f, 1.000000f, -0.195091f, 0.980785f, + -0.382684f, 0.923879f, -0.555570f, 0.831469f, -0.707107f, 0.707107f, + -0.831470f, 0.555570f, -0.923880f, 0.382683f, -0.980785f, 0.195090f, + -1.000000f, -0.000000f, -0.980785f, -0.195091f, -0.923879f, -0.382684f, + -0.831469f, -0.555570f, -0.707107f, -0.707107f, -0.555570f, -0.831470f, + -0.382683f, -0.923880f, -0.195090f, -0.980785f, 0.000000f, -1.000000f, + 0.195091f, -0.980785f, 0.382684f, -0.923879f, 0.555570f, -0.831469f, + 0.707107f, -0.707107f, 0.831470f, -0.555570f, 0.923880f, -0.382683f, + 0.980785f, -0.195090f, 1.000000f, 0.000000f, 0.980785f, 0.195091f, + 0.923879f, 0.382684f, 0.831469f, 0.555571f, 0.707107f, 0.707107f, + 0.555570f, 0.831470f, 0.382683f, 0.923880f, 0.195090f, 0.980785f, + -0.000000f, 1.000000f, -0.195091f, 0.980785f, -0.382684f, 0.923879f, + -0.555571f, 0.831469f, -0.707107f, 0.707106f, -0.831470f, 0.555570f, + -0.923880f, 0.382683f, -0.980785f, 0.195090f, -1.000000f, -0.000000f, + -0.980785f, -0.195091f, -0.923879f, -0.382684f, -0.831469f, -0.555571f, + -0.707106f, -0.707107f, -0.555570f, -0.831470f, -0.382683f, -0.923880f, + -0.195090f, -0.980785f, 0.000000f, -1.000000f, 0.195091f, -0.980785f, + 0.382684f, -0.923879f, 0.555571f, -0.831469f, 0.707107f, -0.707106f, + 0.831470f, -0.555570f, 0.923880f, -0.382683f, 0.980785f, -0.195090f, + 1.000000f, 0.000001f, 0.980785f, 0.195091f, 0.923879f, 0.382684f, + 0.831469f, 0.555571f, 0.707106f, 0.707107f, 0.555570f, 0.831470f, + 0.382683f, 0.923880f, 0.195090f, 0.980785f, -0.000001f, 1.000000f, + -0.195091f, 0.980785f, -0.382684f, 0.923879f, -0.555571f, 0.831469f, + -0.707107f, 0.707106f, -0.831470f, 0.555570f, -0.923880f, 0.382683f, + -0.980785f, 0.195090f, -1.000000f, -0.000001f, -0.980785f, -0.195091f, + -0.923879f, -0.382684f, -0.831469f, -0.555571f, -0.707106f, -0.707107f, + -0.555570f, -0.831470f, -0.382683f, -0.923880f, -0.195090f, -0.980785f, + 0.000001f, -1.000000f, 0.195091f, -0.980785f, 0.382684f, -0.923879f, + 0.555571f, -0.831469f, 0.707107f, -0.707106f, 0.831470f, -0.555570f, + 0.923880f, -0.382683f, 0.980785f, -0.195090f, +}; + +const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_4_1[2 * (128 + 128)] = { + + 1.000000f, 0.000000f, 0.866025f, 0.500000f, 0.500000f, 0.866025f, + -0.000000f, 1.000000f, -0.500000f, 0.866025f, -0.866025f, 0.500000f, + -1.000000f, -0.000000f, -0.866025f, -0.500000f, -0.500000f, -0.866025f, + 0.000000f, -1.000000f, 0.500000f, -0.866025f, 0.866026f, -0.500000f, + 1.000000f, 0.000000f, 0.866025f, 0.500000f, 0.500000f, 0.866026f, + -0.000000f, 1.000000f, -0.500000f, 0.866025f, -0.866026f, 0.500000f, + -1.000000f, -0.000000f, -0.866025f, -0.500000f, -0.500000f, -0.866026f, + 0.000000f, -1.000000f, 0.500000f, -0.866025f, 0.866026f, -0.500000f, + 1.000000f, 0.000000f, 0.866025f, 0.500000f, 0.500000f, 0.866026f, + -0.000000f, 1.000000f, -0.500000f, 0.866025f, -0.866026f, 0.500000f, + -1.000000f, -0.000000f, -0.866025f, -0.500000f, -0.500000f, -0.866026f, + 0.000000f, -1.000000f, 0.500000f, -0.866025f, 0.866026f, -0.500000f, + 1.000000f, 0.000001f, 0.866025f, 0.500000f, 0.500000f, 0.866026f, + -0.000001f, 1.000000f, -0.500000f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000001f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000001f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000001f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000001f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000001f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000001f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000001f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000001f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000001f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000001f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000001f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000001f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000001f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000001f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000001f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000001f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000002f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000002f, 0.866025f, 0.500001f, 0.499999f, 0.866026f, + -0.000002f, 1.000000f, -0.500001f, 0.866025f, -0.866026f, 0.499999f, + -1.000000f, -0.000002f, -0.866025f, -0.500001f, -0.499999f, -0.866026f, + 0.000002f, -1.000000f, 0.500001f, -0.866025f, 0.866026f, -0.499999f, + 1.000000f, 0.000002f, 0.866024f, 0.500002f, 0.499998f, 0.866026f, + -0.000002f, 1.000000f, -0.500002f, 0.866024f, -0.866026f, 0.499998f, + -1.000000f, -0.000002f, -0.866024f, -0.500002f, + + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923880f, 0.382683f, 0.866025f, 0.500000f, 0.793353f, 0.608761f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866025f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382683f, 0.923880f, -0.500000f, 0.866025f, -0.608761f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866025f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923880f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608761f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866025f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923880f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793353f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130526f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793353f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130526f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707107f, -0.793353f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130526f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707107f, -0.707107f, -0.608761f, -0.793353f, -0.500000f, -0.866026f, + -0.382683f, -0.923880f, -0.258819f, -0.965926f, -0.130526f, -0.991445f, + 0.000000f, -1.000000f, 0.130526f, -0.991445f, 0.258819f, -0.965926f, + 0.382684f, -0.923879f, 0.500000f, -0.866025f, 0.608762f, -0.793353f, + 0.707107f, -0.707107f, 0.793354f, -0.608761f, 0.866026f, -0.500000f, + 0.923880f, -0.382683f, 0.965926f, -0.258819f, 0.991445f, -0.130526f, + 1.000000f, 0.000000f, 0.991445f, 0.130527f, 0.965926f, 0.258819f, + 0.923879f, 0.382684f, 0.866025f, 0.500000f, 0.793353f, 0.608762f, + 0.707107f, 0.707107f, 0.608761f, 0.793354f, 0.500000f, 0.866026f, + 0.382683f, 0.923880f, 0.258819f, 0.965926f, 0.130526f, 0.991445f, + -0.000000f, 1.000000f, -0.130527f, 0.991445f, -0.258819f, 0.965926f, + -0.382684f, 0.923879f, -0.500000f, 0.866025f, -0.608762f, 0.793353f, + -0.707107f, 0.707106f, -0.793354f, 0.608761f, -0.866026f, 0.500000f, + -0.923880f, 0.382683f, -0.965926f, 0.258819f, -0.991445f, 0.130526f, + -1.000000f, -0.000000f, -0.991445f, -0.130527f, -0.965926f, -0.258819f, + -0.923879f, -0.382684f, -0.866025f, -0.500000f, -0.793353f, -0.608762f, + -0.707106f, -0.707107f, -0.608761f, -0.793354f, +}; + +const FLOAT32 ixheaacd_synth_cos_table_kl_4[16] = { + 0.250000000000f, 0.000000000000f, 0.230969882082f, 0.095670860615f, + 0.176776691433f, 0.176776699160f, 0.095670850519f, 0.230969886264f, + -0.000000010928f, 0.250000000000f, -0.095670870711f, 0.230969877900f, + 0.176776706887f, -0.176776683706f, 0.230969890446f, -0.095670840423f}; + +const FLOAT32 ixheaacd_synth_cos_table_kl_8[32] = { + 0.125000000000f, 0.000000000000f, 0.122598159917f, 0.024386290922f, + 0.115484941041f, 0.047835430308f, 0.103933700399f, 0.069446280831f, + 0.088388345717f, 0.088388349580f, 0.069446276288f, 0.103933703435f, + 0.047835425260f, 0.115484943132f, 0.024386285563f, 0.122598160983f, + -0.000000005464f, 0.125000000000f, -0.024386296281f, 0.122598158851f, + -0.047835435356f, 0.115484938950f, -0.069446285374f, 0.103933697364f, + 0.088388353444f, -0.088388341853f, 0.103933706471f, -0.069446271745f, + 0.115484945223f, -0.047835420212f, 0.122598162049f, -0.024386280204f}; + +const FLOAT32 ixheaacd_synth_cos_table_kl_12[48] = { + 0.083333333333f, 0.000000000000f, 0.082620405075f, 0.010877182986f, + 0.080493818700f, 0.021568254345f, 0.076989960694f, 0.031890286872f, + 0.072168783042f, 0.041666667718f, 0.066112777434f, 0.050730120288f, + 0.058925563811f, 0.058925566387f, 0.050730117398f, 0.066112779651f, + 0.041666664564f, 0.072168784863f, 0.031890283506f, 0.076989962088f, + 0.021568250826f, 0.080493819643f, 0.010877179375f, 0.082620405550f, + -0.000000003643f, 0.083333333333f, -0.010877186597f, 0.082620404599f, + -0.021568257863f, 0.080493817758f, -0.031890290237f, 0.076989959300f, + -0.041666670873f, 0.072168781220f, -0.050730123178f, 0.066112775216f, + 0.058925568962f, -0.058925561235f, 0.066112781869f, -0.050730114508f, + 0.072168786684f, -0.041666661409f, 0.076989963482f, -0.031890280141f, + 0.080493820586f, -0.021568247308f, 0.082620406026f, -0.010877175763f}; + +const FLOAT32 ixheaacd_synth_cos_table_kl_16[64] = { + 0.062500000000f, 0.000000000000f, 0.062199045400f, 0.006126071441f, + 0.061299079959f, 0.012193145461f, 0.059808770835f, 0.018142792819f, + 0.057742470521f, 0.023917715154f, 0.055120078619f, 0.029462296805f, + 0.051966850200f, 0.034723140416f, 0.048313152577f, 0.039649581184f, + 0.044194172858f, 0.044194174790f, 0.039649579072f, 0.048313154310f, + 0.034723138144f, 0.051966851718f, 0.029462294395f, 0.055120079907f, + 0.023917712630f, 0.057742471566f, 0.018142790204f, 0.059808771628f, + 0.012193142781f, 0.061299080492f, 0.006126068722f, 0.062199045668f, + -0.000000002732f, 0.062500000000f, -0.006126074159f, 0.062199045132f, + -0.012193148140f, 0.061299079426f, -0.018142795433f, 0.059808770042f, + -0.023917717678f, 0.057742469475f, -0.029462299214f, 0.055120077331f, + -0.034723142687f, 0.051966848682f, -0.039649583296f, 0.048313150844f, + 0.044194176722f, -0.044194170926f, 0.048313156043f, -0.039649576960f, + 0.051966853235f, -0.034723135872f, 0.055120081195f, -0.029462291986f, + 0.057742472612f, -0.023917710106f, 0.059808772421f, -0.018142787590f, + 0.061299081025f, -0.012193140102f, 0.062199045936f, -0.006126066003f}; + +const FLOAT32 ixheaacd_synth_cos_table_kl_20[40 * 20] = { + 0.035355f, -0.035355f, -0.035355f, 0.035355f, 0.035355f, -0.035355f, + -0.035355f, 0.035355f, 0.035355f, -0.035355f, -0.035355f, 0.035355f, + 0.035355f, -0.035355f, -0.035355f, 0.035355f, 0.035355f, -0.035355f, + -0.035355f, 0.035355f, 0.038020f, -0.026125f, -0.046194f, 0.011672f, + 0.049846f, 0.003923f, -0.048618f, -0.019134f, 0.042632f, 0.032472f, + -0.032472f, -0.042632f, 0.019134f, 0.048618f, -0.003923f, -0.049846f, + -0.011672f, 0.046194f, 0.026125f, -0.038020f, 0.040451f, -0.015451f, + -0.050000f, -0.015451f, 0.040451f, 0.040451f, -0.015451f, -0.050000f, + -0.015451f, 0.040451f, 0.040451f, -0.015451f, -0.050000f, -0.015451f, + 0.040451f, 0.040451f, -0.015451f, -0.050000f, -0.015451f, 0.040451f, + 0.042632f, -0.003923f, -0.046194f, -0.038020f, 0.011672f, 0.048618f, + 0.032472f, -0.019134f, -0.049846f, -0.026125f, 0.026125f, 0.049846f, + 0.019134f, -0.032472f, -0.048618f, -0.011672f, 0.038020f, 0.046194f, + 0.003923f, -0.042632f, 0.044550f, 0.007822f, -0.035355f, -0.049384f, + -0.022700f, 0.022700f, 0.049384f, 0.035355f, -0.007822f, -0.044550f, + -0.044550f, -0.007822f, 0.035355f, 0.049384f, 0.022700f, -0.022700f, + -0.049384f, -0.035355f, 0.007822f, 0.044550f, 0.046194f, 0.019134f, + -0.019134f, -0.046194f, -0.046194f, -0.019134f, 0.019134f, 0.046194f, + 0.046194f, 0.019134f, -0.019134f, -0.046194f, -0.046194f, -0.019134f, + 0.019134f, 0.046194f, 0.046194f, 0.019134f, -0.019134f, -0.046194f, + 0.047553f, 0.029389f, 0.000000f, -0.029389f, -0.047553f, -0.047553f, + -0.029389f, -0.000000f, 0.029389f, 0.047553f, 0.047553f, 0.029389f, + 0.000000f, -0.029389f, -0.047553f, -0.047553f, -0.029389f, -0.000000f, + 0.029389f, 0.047553f, 0.048618f, 0.038020f, 0.019134f, -0.003923f, + -0.026125f, -0.042632f, -0.049846f, -0.046194f, -0.032472f, -0.011672f, + 0.011672f, 0.032472f, 0.046194f, 0.049846f, 0.042632f, 0.026125f, + 0.003923f, -0.019134f, -0.038020f, -0.048618f, 0.049384f, 0.044550f, + 0.035355f, 0.022700f, 0.007822f, -0.007822f, -0.022700f, -0.035355f, + -0.044550f, -0.049384f, -0.049384f, -0.044550f, -0.035355f, -0.022700f, + -0.007822f, 0.007822f, 0.022700f, 0.035355f, 0.044550f, 0.049384f, + 0.049846f, 0.048618f, 0.046194f, 0.042632f, 0.038020f, 0.032472f, + 0.026125f, 0.019134f, 0.011672f, 0.003923f, -0.003923f, -0.011672f, + -0.019134f, -0.026125f, -0.032472f, -0.038020f, -0.042632f, -0.046194f, + -0.048618f, -0.049846f, 0.050000f, 0.050000f, 0.050000f, 0.050000f, + 0.050000f, 0.050000f, 0.050000f, 0.050000f, 0.050000f, 0.050000f, + 0.050000f, 0.050000f, 0.050000f, 0.050000f, 0.050000f, 0.050000f, + 0.050000f, 0.050000f, 0.050000f, 0.050000f, 0.049846f, 0.048618f, + 0.046194f, 0.042632f, 0.038020f, 0.032472f, 0.026125f, 0.019134f, + 0.011672f, 0.003923f, -0.003923f, -0.011672f, -0.019134f, -0.026125f, + -0.032472f, -0.038020f, -0.042632f, -0.046194f, -0.048618f, -0.049846f, + 0.049384f, 0.044550f, 0.035355f, 0.022700f, 0.007822f, -0.007822f, + -0.022700f, -0.035355f, -0.044550f, -0.049384f, -0.049384f, -0.044550f, + -0.035355f, -0.022700f, -0.007822f, 0.007822f, 0.022700f, 0.035355f, + 0.044550f, 0.049384f, 0.048618f, 0.038020f, 0.019134f, -0.003923f, + -0.026125f, -0.042632f, -0.049846f, -0.046194f, -0.032472f, -0.011672f, + 0.011672f, 0.032472f, 0.046194f, 0.049846f, 0.042632f, 0.026125f, + 0.003923f, -0.019134f, -0.038020f, -0.048618f, 0.047553f, 0.029389f, + 0.000000f, -0.029389f, -0.047553f, -0.047553f, -0.029389f, -0.000000f, + 0.029389f, 0.047553f, 0.047553f, 0.029389f, 0.000000f, -0.029389f, + -0.047553f, -0.047553f, -0.029389f, -0.000000f, 0.029389f, 0.047553f, + 0.046194f, 0.019134f, -0.019134f, -0.046194f, -0.046194f, -0.019134f, + 0.019134f, 0.046194f, 0.046194f, 0.019134f, -0.019134f, -0.046194f, + -0.046194f, -0.019134f, 0.019134f, 0.046194f, 0.046194f, 0.019134f, + -0.019134f, -0.046194f, 0.044550f, 0.007822f, -0.035355f, -0.049384f, + -0.022700f, 0.022700f, 0.049384f, 0.035355f, -0.007822f, -0.044550f, + -0.044550f, -0.007822f, 0.035355f, 0.049384f, 0.022700f, -0.022700f, + -0.049384f, -0.035355f, 0.007822f, 0.044550f, 0.042632f, -0.003923f, + -0.046194f, -0.038020f, 0.011672f, 0.048618f, 0.032472f, -0.019134f, + -0.049846f, -0.026125f, 0.026125f, 0.049846f, 0.019134f, -0.032472f, + -0.048618f, -0.011672f, 0.038020f, 0.046194f, 0.003923f, -0.042632f, + 0.040451f, -0.015451f, -0.050000f, -0.015451f, 0.040451f, 0.040451f, + -0.015451f, -0.050000f, -0.015451f, 0.040451f, 0.040451f, -0.015451f, + -0.050000f, -0.015451f, 0.040451f, 0.040451f, -0.015451f, -0.050000f, + -0.015451f, 0.040451f, 0.038020f, -0.026125f, -0.046194f, 0.011672f, + 0.049846f, 0.003923f, -0.048618f, -0.019134f, 0.042632f, 0.032472f, + -0.032472f, -0.042632f, 0.019134f, 0.048618f, -0.003923f, -0.049846f, + -0.011672f, 0.046194f, 0.026125f, -0.038020f, 0.035355f, -0.035355f, + -0.035355f, 0.035355f, 0.035355f, -0.035355f, -0.035355f, 0.035355f, + 0.035355f, -0.035355f, -0.035355f, 0.035355f, 0.035355f, -0.035355f, + -0.035355f, 0.035355f, 0.035355f, -0.035355f, -0.035355f, 0.035355f, + 0.032472f, -0.042632f, -0.019134f, 0.048618f, 0.003923f, -0.049846f, + 0.011672f, 0.046194f, -0.026125f, -0.038020f, 0.038020f, 0.026125f, + -0.046194f, -0.011672f, 0.049846f, -0.003923f, -0.048618f, 0.019134f, + 0.042632f, -0.032472f, 0.029389f, -0.047553f, -0.000000f, 0.047553f, + -0.029389f, -0.029389f, 0.047553f, 0.000000f, -0.047553f, 0.029389f, + 0.029389f, -0.047553f, -0.000000f, 0.047553f, -0.029389f, -0.029389f, + 0.047553f, -0.000000f, -0.047553f, 0.029389f, 0.026125f, -0.049846f, + 0.019134f, 0.032472f, -0.048618f, 0.011672f, 0.038020f, -0.046194f, + 0.003923f, 0.042632f, -0.042632f, -0.003923f, 0.046194f, -0.038020f, + -0.011672f, 0.048618f, -0.032472f, -0.019134f, 0.049846f, -0.026125f, + 0.022700f, -0.049384f, 0.035355f, 0.007822f, -0.044550f, 0.044550f, + -0.007822f, -0.035355f, 0.049384f, -0.022700f, -0.022700f, 0.049384f, + -0.035355f, -0.007822f, 0.044550f, -0.044550f, 0.007822f, 0.035355f, + -0.049384f, 0.022700f, 0.019134f, -0.046194f, 0.046194f, -0.019134f, + -0.019134f, 0.046194f, -0.046194f, 0.019134f, 0.019134f, -0.046194f, + 0.046194f, -0.019134f, -0.019134f, 0.046194f, -0.046194f, 0.019134f, + 0.019134f, -0.046194f, 0.046194f, -0.019134f, 0.015451f, -0.040451f, + 0.050000f, -0.040451f, 0.015451f, 0.015451f, -0.040451f, 0.050000f, + -0.040451f, 0.015451f, 0.015451f, -0.040451f, 0.050000f, -0.040451f, + 0.015451f, 0.015451f, -0.040451f, 0.050000f, -0.040451f, 0.015451f, + 0.011672f, -0.032472f, 0.046194f, -0.049846f, 0.042632f, -0.026125f, + 0.003923f, 0.019134f, -0.038020f, 0.048618f, -0.048618f, 0.038020f, + -0.019134f, -0.003923f, 0.026125f, -0.042632f, 0.049846f, -0.046194f, + 0.032472f, -0.011672f, 0.007822f, -0.022700f, 0.035355f, -0.044550f, + 0.049384f, -0.049384f, 0.044550f, -0.035355f, 0.022700f, -0.007822f, + -0.007822f, 0.022700f, -0.035355f, 0.044550f, -0.049384f, 0.049384f, + -0.044550f, 0.035355f, -0.022700f, 0.007822f, 0.003923f, -0.011672f, + 0.019134f, -0.026125f, 0.032472f, -0.038020f, 0.042632f, -0.046194f, + 0.048618f, -0.049846f, 0.049846f, -0.048618f, 0.046194f, -0.042632f, + 0.038020f, -0.032472f, 0.026125f, -0.019134f, 0.011672f, -0.003923f, + 0.000000f, -0.000000f, 0.000000f, -0.000000f, 0.000000f, -0.000000f, + -0.000000f, -0.000000f, -0.000000f, -0.000000f, -0.000000f, -0.000000f, + -0.000000f, -0.000000f, -0.000000f, -0.000000f, 0.000000f, -0.000000f, + 0.000000f, -0.000000f, -0.003923f, 0.011672f, -0.019134f, 0.026125f, + -0.032472f, 0.038020f, -0.042632f, 0.046194f, -0.048618f, 0.049846f, + -0.049846f, 0.048618f, -0.046194f, 0.042632f, -0.038020f, 0.032472f, + -0.026125f, 0.019134f, -0.011672f, 0.003923f, -0.007822f, 0.022700f, + -0.035355f, 0.044550f, -0.049384f, 0.049384f, -0.044550f, 0.035355f, + -0.022700f, 0.007822f, 0.007822f, -0.022700f, 0.035355f, -0.044550f, + 0.049384f, -0.049384f, 0.044550f, -0.035355f, 0.022700f, -0.007822f, + -0.011672f, 0.032472f, -0.046194f, 0.049846f, -0.042632f, 0.026125f, + -0.003923f, -0.019134f, 0.038020f, -0.048618f, 0.048618f, -0.038020f, + 0.019134f, 0.003923f, -0.026125f, 0.042632f, -0.049846f, 0.046194f, + -0.032472f, 0.011672f, -0.015451f, 0.040451f, -0.050000f, 0.040451f, + -0.015451f, -0.015451f, 0.040451f, -0.050000f, 0.040451f, -0.015451f, + -0.015451f, 0.040451f, -0.050000f, 0.040451f, -0.015451f, -0.015451f, + 0.040451f, -0.050000f, 0.040451f, -0.015451f, -0.019134f, 0.046194f, + -0.046194f, 0.019134f, 0.019134f, -0.046194f, 0.046194f, -0.019134f, + -0.019134f, 0.046194f, -0.046194f, 0.019134f, 0.019134f, -0.046194f, + 0.046194f, -0.019134f, -0.019134f, 0.046194f, -0.046194f, 0.019134f, + -0.022700f, 0.049384f, -0.035355f, -0.007822f, 0.044550f, -0.044550f, + 0.007822f, 0.035355f, -0.049384f, 0.022700f, 0.022700f, -0.049384f, + 0.035355f, 0.007822f, -0.044550f, 0.044550f, -0.007822f, -0.035355f, + 0.049384f, -0.022700f, -0.026125f, 0.049846f, -0.019134f, -0.032472f, + 0.048618f, -0.011672f, -0.038020f, 0.046194f, -0.003923f, -0.042632f, + 0.042632f, 0.003923f, -0.046194f, 0.038020f, 0.011672f, -0.048618f, + 0.032472f, 0.019134f, -0.049846f, 0.026125f, -0.029389f, 0.047553f, + -0.000000f, -0.047553f, 0.029389f, 0.029389f, -0.047553f, -0.000000f, + 0.047553f, -0.029389f, -0.029389f, 0.047553f, -0.000000f, -0.047553f, + 0.029389f, 0.029389f, -0.047553f, 0.000000f, 0.047553f, -0.029389f, + -0.032472f, 0.042632f, 0.019134f, -0.048618f, -0.003923f, 0.049846f, + -0.011672f, -0.046194f, 0.026125f, 0.038020f, -0.038020f, -0.026125f, + 0.046194f, 0.011672f, -0.049846f, 0.003923f, 0.048618f, -0.019134f, + -0.042632f, 0.032472f, + +}; + +const FLOAT32 ixheaacd_analy_cos_sin_table_kl_8[32] = { + 1.000000000000f, 0.000000000000f, 0.980785279337f, 0.195090327375f, + 0.923879528329f, 0.382683442461f, 0.831469603196f, 0.555570246649f, + 0.707106765732f, 0.707106796641f, 0.555570210304f, 0.831469627481f, + 0.382683402077f, 0.923879545057f, 0.195090284504f, 0.980785287865f, + -0.000000043711f, 1.000000000000f, -0.195090370247f, 0.980785270810f, + -0.382683482845f, 0.923879511602f, -0.555570282994f, 0.831469578911f, + -0.707106827549f, 0.707106734824f, -0.831469651765f, 0.555570173959f, + -0.923879561785f, 0.382683361693f, -0.980785296393f, 0.195090241632f}; + +const FLOAT32 ixheaacd_analy_cos_sin_table_kl_16[64] = { + 1.000000000000f, 0.000000000000f, 0.995184726404f, 0.098017143048f, + 0.980785279337f, 0.195090327375f, 0.956940333353f, 0.290284685097f, + 0.923879528329f, 0.382683442461f, 0.881921257909f, 0.471396748873f, + 0.831469603196f, 0.555570246649f, 0.773010441231f, 0.634393298946f, + 0.707106765732f, 0.707106796641f, 0.634393265157f, 0.773010468961f, + 0.555570210304f, 0.831469627481f, 0.471396710323f, 0.881921278515f, + 0.382683402077f, 0.923879545057f, 0.290284643268f, 0.956940346042f, + 0.195090284504f, 0.980785287865f, 0.098017099547f, 0.995184730689f, + -0.000000043711f, 1.000000000000f, -0.098017186549f, 0.995184722120f, + -0.195090370247f, 0.980785270810f, -0.290284726927f, 0.956940320664f, + -0.382683482845f, 0.923879511602f, -0.471396787423f, 0.881921237304f, + -0.555570282994f, 0.831469578911f, -0.634393332736f, 0.773010413501f, + -0.707106827549f, 0.707106734824f, -0.773010496691f, 0.634393231368f, + -0.831469651765f, 0.555570173959f, -0.881921299120f, 0.471396671773f, + -0.923879561785f, 0.382683361693f, -0.956940358731f, 0.290284601439f, + -0.980785296393f, 0.195090241632f, -0.995184734973f, 0.098017056047f}; + +const FLOAT32 ixheaacd_analy_cos_sin_table_kl_24[96] = { + 1.000000000000f, 0.000000000000f, 0.997858923119f, 0.065403131048f, + 0.991444860898f, 0.130526195832f, 0.980785279337f, 0.195090327375f, + 0.965925824404f, 0.258819052140f, 0.946930126568f, 0.321439473926f, + 0.923879528329f, 0.382683442461f, 0.896872735894f, 0.442288701653f, + 0.866025396499f, 0.500000012618f, 0.831469603196f, 0.555570246649f, + 0.793353329204f, 0.608761443458f, 0.751839794269f, 0.659345830163f, + 0.707106765732f, 0.707106796641f, 0.659345797299f, 0.751839823090f, + 0.608761408780f, 0.793353355814f, 0.555570210304f, 0.831469627481f, + 0.499999974763f, 0.866025418355f, 0.442288662450f, 0.896872755227f, + 0.382683402077f, 0.923879545057f, 0.321439432535f, 0.946930140618f, + 0.258819009918f, 0.965925835717f, 0.195090284504f, 0.980785287865f, + 0.130526152494f, 0.991444866604f, 0.065403087430f, 0.997858925978f, + -0.000000043711f, 1.000000000000f, -0.065403174665f, 0.997858920261f, + -0.130526239169f, 0.991444855193f, -0.195090370247f, 0.980785270810f, + -0.258819094361f, 0.965925813090f, -0.321439515318f, 0.946930112517f, + -0.382683482845f, 0.923879511602f, -0.442288740857f, 0.896872716561f, + -0.500000050474f, 0.866025374644f, -0.555570282994f, 0.831469578911f, + -0.608761478137f, 0.793353302594f, -0.659345863027f, 0.751839765448f, + -0.707106827549f, 0.707106734824f, -0.751839851911f, 0.659345764435f, + -0.793353382423f, 0.608761374101f, -0.831469651765f, 0.555570173959f, + -0.866025440211f, 0.499999936908f, -0.896872774560f, 0.442288623246f, + -0.923879561785f, 0.382683361693f, -0.946930154669f, 0.321439391143f, + -0.965925847030f, 0.258818967696f, -0.980785296393f, 0.195090241632f, + -0.991444872309f, 0.130526109157f, -0.997858941555f, 0.065403044224f}; + +const FLOAT32 ixheaacd_analy_cos_sin_table_kl_32[128] = { + 1.000000000000f, 0.000000000000f, 0.998795456138f, 0.049067675692f, + 0.995184726404f, 0.098017143048f, 0.989176509363f, 0.146730478509f, + 0.980785279337f, 0.195090327375f, 0.970031251535f, 0.242980186528f, + 0.956940333353f, 0.290284685097f, 0.941544061962f, 0.336889862395f, + 0.923879528329f, 0.382683442461f, 0.903989287867f, 0.427555104544f, + 0.881921257909f, 0.471396748873f, 0.857728602275f, 0.514102757081f, + 0.831469603196f, 0.555570246649f, 0.803207520902f, 0.595699318756f, + 0.773010441231f, 0.634393298946f, 0.740951111595f, 0.671558970029f, + 0.707106765732f, 0.707106796641f, 0.671558937641f, 0.740951140950f, + 0.634393265157f, 0.773010468961f, 0.595699283646f, 0.803207546941f, + 0.555570210304f, 0.831469627481f, 0.514102719589f, 0.857728624748f, + 0.471396710323f, 0.881921278515f, 0.427555065029f, 0.903989306556f, + 0.382683402077f, 0.923879545057f, 0.336889821239f, 0.941544076688f, + 0.290284643268f, 0.956940346042f, 0.242980144127f, 0.970031262156f, + 0.195090284504f, 0.980785287865f, 0.146730435271f, 0.989176515777f, + 0.098017099547f, 0.995184730689f, 0.049067632033f, 0.998795458283f, + -0.000000043711f, 1.000000000000f, -0.049067719350f, 0.998795453993f, + -0.098017186549f, 0.995184722120f, -0.146730521747f, 0.989176502950f, + -0.195090370247f, 0.980785270810f, -0.242980228930f, 0.970031240914f, + -0.290284726927f, 0.956940320664f, -0.336889903551f, 0.941544047236f, + -0.382683482845f, 0.923879511602f, -0.427555144058f, 0.903989269178f, + -0.471396787423f, 0.881921237304f, -0.514102794574f, 0.857728579803f, + -0.555570282994f, 0.831469578911f, -0.595699353865f, 0.803207494864f, + -0.634393332736f, 0.773010413501f, -0.671559002417f, 0.740951082240f, + -0.707106827549f, 0.707106734824f, -0.740951170304f, 0.671558905253f, + -0.773010496691f, 0.634393231368f, -0.803207572980f, 0.595699248537f, + -0.831469651765f, 0.555570173959f, -0.857728647220f, 0.514102682096f, + -0.881921299120f, 0.471396671773f, -0.903989325245f, 0.427555025515f, + -0.923879561785f, 0.382683361693f, -0.941544091414f, 0.336889780083f, + -0.956940358731f, 0.290284601439f, -0.970031272777f, 0.242980101726f, + -0.980785296393f, 0.195090241632f, -0.989176522191f, 0.146730392032f, + -0.995184734973f, 0.098017056047f, -0.998795460428f, 0.049067588374f}; + +const FLOAT32 ixheaacd_analy_cos_sin_table_kl_40[40 * 40 * 2] = { + 0.000000f, -1.000000f, 0.039260f, -0.999229f, 0.078459f, -0.996917f, + 0.117537f, -0.993068f, 0.156434f, -0.987688f, 0.195090f, -0.980785f, + 0.233445f, -0.972370f, 0.271440f, -0.962455f, 0.309017f, -0.951057f, + 0.346117f, -0.938191f, 0.382683f, -0.923880f, 0.418660f, -0.908143f, + 0.453990f, -0.891007f, 0.488621f, -0.872496f, 0.522499f, -0.852640f, + 0.555570f, -0.831470f, 0.587785f, -0.809017f, 0.619094f, -0.785317f, + 0.649448f, -0.760406f, 0.678801f, -0.734322f, 0.707107f, -0.707107f, + 0.734322f, -0.678801f, 0.760406f, -0.649448f, 0.785317f, -0.619094f, + 0.809017f, -0.587785f, 0.831470f, -0.555570f, 0.852640f, -0.522499f, + 0.872496f, -0.488621f, 0.891007f, -0.453990f, 0.908143f, -0.418660f, + 0.923880f, -0.382683f, 0.938191f, -0.346117f, 0.951057f, -0.309017f, + 0.962455f, -0.271440f, 0.972370f, -0.233445f, 0.980785f, -0.195090f, + 0.987688f, -0.156434f, 0.993068f, -0.117537f, 0.996917f, -0.078459f, + 0.999229f, -0.039260f, -0.000000f, 1.000000f, -0.117537f, 0.993068f, + -0.233445f, 0.972370f, -0.346117f, 0.938191f, -0.453990f, 0.891007f, + -0.555570f, 0.831470f, -0.649448f, 0.760406f, -0.734322f, 0.678801f, + -0.809017f, 0.587785f, -0.872496f, 0.488621f, -0.923880f, 0.382683f, + -0.962455f, 0.271440f, -0.987688f, 0.156434f, -0.999229f, 0.039260f, + -0.996917f, -0.078459f, -0.980785f, -0.195090f, -0.951057f, -0.309017f, + -0.908143f, -0.418660f, -0.852640f, -0.522499f, -0.785317f, -0.619094f, + -0.707107f, -0.707107f, -0.619094f, -0.785317f, -0.522499f, -0.852640f, + -0.418660f, -0.908143f, -0.309017f, -0.951057f, -0.195090f, -0.980785f, + -0.078459f, -0.996917f, 0.039260f, -0.999229f, 0.156434f, -0.987688f, + 0.271440f, -0.962455f, 0.382683f, -0.923880f, 0.488621f, -0.872496f, + 0.587785f, -0.809017f, 0.678801f, -0.734322f, 0.760406f, -0.649448f, + 0.831470f, -0.555570f, 0.891007f, -0.453990f, 0.938191f, -0.346117f, + 0.972370f, -0.233445f, 0.993068f, -0.117537f, 0.000000f, -1.000000f, + 0.195090f, -0.980785f, 0.382683f, -0.923880f, 0.555570f, -0.831470f, + 0.707107f, -0.707107f, 0.831470f, -0.555570f, 0.923880f, -0.382683f, + 0.980785f, -0.195090f, 1.000000f, 0.000000f, 0.980785f, 0.195090f, + 0.923880f, 0.382683f, 0.831470f, 0.555570f, 0.707107f, 0.707107f, + 0.555570f, 0.831470f, 0.382683f, 0.923880f, 0.195090f, 0.980785f, + -0.000000f, 1.000000f, -0.195090f, 0.980785f, -0.382683f, 0.923880f, + -0.555570f, 0.831470f, -0.707107f, 0.707107f, -0.831470f, 0.555570f, + -0.923880f, 0.382683f, -0.980785f, 0.195090f, -1.000000f, -0.000000f, + -0.980785f, -0.195090f, -0.923880f, -0.382683f, -0.831470f, -0.555570f, + -0.707107f, -0.707107f, -0.555570f, -0.831470f, -0.382683f, -0.923880f, + -0.195090f, -0.980785f, 0.000000f, -1.000000f, 0.195090f, -0.980785f, + 0.382683f, -0.923880f, 0.555570f, -0.831470f, 0.707107f, -0.707107f, + 0.831470f, -0.555570f, 0.923880f, -0.382683f, 0.980785f, -0.195090f, + -0.000000f, 1.000000f, -0.271440f, 0.962455f, -0.522499f, 0.852640f, + -0.734322f, 0.678801f, -0.891007f, 0.453990f, -0.980785f, 0.195090f, + -0.996917f, -0.078459f, -0.938191f, -0.346117f, -0.809017f, -0.587785f, + -0.619094f, -0.785317f, -0.382683f, -0.923880f, -0.117537f, -0.993068f, + 0.156434f, -0.987688f, 0.418660f, -0.908143f, 0.649448f, -0.760406f, + 0.831470f, -0.555570f, 0.951057f, -0.309017f, 0.999229f, -0.039260f, + 0.972370f, 0.233445f, 0.872496f, 0.488621f, 0.707107f, 0.707107f, + 0.488621f, 0.872496f, 0.233445f, 0.972370f, -0.039260f, 0.999229f, + -0.309017f, 0.951057f, -0.555570f, 0.831470f, -0.760406f, 0.649448f, + -0.908143f, 0.418660f, -0.987688f, 0.156434f, -0.993068f, -0.117537f, + -0.923880f, -0.382683f, -0.785317f, -0.619094f, -0.587785f, -0.809017f, + -0.346117f, -0.938191f, -0.078459f, -0.996917f, 0.195090f, -0.980785f, + 0.453990f, -0.891007f, 0.678801f, -0.734322f, 0.852640f, -0.522499f, + 0.962455f, -0.271440f, 0.000000f, -1.000000f, 0.346117f, -0.938191f, + 0.649448f, -0.760406f, 0.872496f, -0.488621f, 0.987688f, -0.156434f, + 0.980785f, 0.195090f, 0.852640f, 0.522499f, 0.619094f, 0.785317f, + 0.309017f, 0.951057f, -0.039260f, 0.999229f, -0.382683f, 0.923880f, + -0.678801f, 0.734322f, -0.891007f, 0.453990f, -0.993068f, 0.117537f, + -0.972370f, -0.233445f, -0.831470f, -0.555570f, -0.587785f, -0.809017f, + -0.271440f, -0.962455f, 0.078459f, -0.996917f, 0.418660f, -0.908143f, + 0.707107f, -0.707107f, 0.908143f, -0.418660f, 0.996917f, -0.078459f, + 0.962455f, 0.271440f, 0.809017f, 0.587785f, 0.555570f, 0.831470f, + 0.233445f, 0.972370f, -0.117537f, 0.993068f, -0.453990f, 0.891007f, + -0.734322f, 0.678801f, -0.923880f, 0.382683f, -0.999229f, 0.039260f, + -0.951057f, -0.309017f, -0.785317f, -0.619094f, -0.522499f, -0.852640f, + -0.195090f, -0.980785f, 0.156434f, -0.987688f, 0.488621f, -0.872496f, + 0.760406f, -0.649448f, 0.938191f, -0.346117f, -0.000000f, 1.000000f, + -0.418660f, 0.908143f, -0.760406f, 0.649448f, -0.962455f, 0.271440f, + -0.987688f, -0.156434f, -0.831470f, -0.555570f, -0.522499f, -0.852640f, + -0.117537f, -0.993068f, 0.309017f, -0.951057f, 0.678801f, -0.734322f, + 0.923880f, -0.382683f, 0.999229f, 0.039260f, 0.891007f, 0.453990f, + 0.619094f, 0.785317f, 0.233445f, 0.972370f, -0.195090f, 0.980785f, + -0.587785f, 0.809017f, -0.872496f, 0.488621f, -0.996917f, 0.078459f, + -0.938191f, -0.346117f, -0.707107f, -0.707107f, -0.346117f, -0.938191f, + 0.078459f, -0.996917f, 0.488621f, -0.872496f, 0.809017f, -0.587785f, + 0.980785f, -0.195090f, 0.972370f, 0.233445f, 0.785317f, 0.619094f, + 0.453990f, 0.891007f, 0.039260f, 0.999229f, -0.382683f, 0.923880f, + -0.734322f, 0.678801f, -0.951057f, 0.309017f, -0.993068f, -0.117537f, + -0.852640f, -0.522499f, -0.555570f, -0.831470f, -0.156434f, -0.987688f, + 0.271440f, -0.962455f, 0.649448f, -0.760406f, 0.908143f, -0.418660f, + -0.000000f, -1.000000f, 0.488621f, -0.872496f, 0.852640f, -0.522499f, + 0.999229f, -0.039260f, 0.891007f, 0.453990f, 0.555570f, 0.831470f, + 0.078459f, 0.996917f, -0.418660f, 0.908143f, -0.809017f, 0.587785f, + -0.993068f, 0.117537f, -0.923880f, -0.382683f, -0.619094f, -0.785317f, + -0.156434f, -0.987688f, 0.346117f, -0.938191f, 0.760406f, -0.649448f, + 0.980785f, -0.195090f, 0.951057f, 0.309017f, 0.678801f, 0.734322f, + 0.233445f, 0.972370f, -0.271440f, 0.962455f, -0.707107f, 0.707107f, + -0.962455f, 0.271440f, -0.972370f, -0.233445f, -0.734322f, -0.678801f, + -0.309017f, -0.951057f, 0.195090f, -0.980785f, 0.649448f, -0.760406f, + 0.938191f, -0.346117f, 0.987688f, 0.156434f, 0.785317f, 0.619094f, + 0.382683f, 0.923880f, -0.117537f, 0.993068f, -0.587785f, 0.809017f, + -0.908143f, 0.418660f, -0.996917f, -0.078459f, -0.831470f, -0.555570f, + -0.453990f, -0.891007f, 0.039260f, -0.999229f, 0.522499f, -0.852640f, + 0.872496f, -0.488621f, -0.000000f, 1.000000f, -0.555570f, 0.831470f, + -0.923880f, 0.382683f, -0.980785f, -0.195090f, -0.707107f, -0.707107f, + -0.195090f, -0.980785f, 0.382683f, -0.923880f, 0.831470f, -0.555570f, + 1.000000f, 0.000000f, 0.831470f, 0.555570f, 0.382683f, 0.923880f, + -0.195090f, 0.980785f, -0.707107f, 0.707107f, -0.980785f, 0.195090f, + -0.923880f, -0.382683f, -0.555570f, -0.831470f, 0.000000f, -1.000000f, + 0.555570f, -0.831470f, 0.923880f, -0.382683f, 0.980785f, 0.195090f, + 0.707107f, 0.707107f, 0.195090f, 0.980785f, -0.382683f, 0.923880f, + -0.831470f, 0.555570f, -1.000000f, -0.000000f, -0.831470f, -0.555570f, + -0.382683f, -0.923880f, 0.195090f, -0.980785f, 0.707107f, -0.707107f, + 0.980785f, -0.195090f, 0.923880f, 0.382683f, 0.555570f, 0.831470f, + -0.000000f, 1.000000f, -0.555570f, 0.831470f, -0.923880f, 0.382683f, + -0.980785f, -0.195090f, -0.707107f, -0.707107f, -0.195090f, -0.980785f, + 0.382683f, -0.923880f, 0.831470f, -0.555570f, -0.000000f, -1.000000f, + 0.619094f, -0.785317f, 0.972370f, -0.233445f, 0.908143f, 0.418660f, + 0.453990f, 0.891007f, -0.195090f, 0.980785f, -0.760406f, 0.649448f, + -0.999229f, 0.039260f, -0.809017f, -0.587785f, -0.271440f, -0.962455f, + 0.382683f, -0.923880f, 0.872496f, -0.488621f, 0.987688f, 0.156434f, + 0.678801f, 0.734322f, 0.078459f, 0.996917f, -0.555570f, 0.831470f, + -0.951057f, 0.309017f, -0.938191f, -0.346117f, -0.522499f, -0.852640f, + 0.117537f, -0.993068f, 0.707107f, -0.707107f, 0.993068f, -0.117537f, + 0.852640f, 0.522499f, 0.346117f, 0.938191f, -0.309017f, 0.951057f, + -0.831470f, 0.555570f, -0.996917f, -0.078459f, -0.734322f, -0.678801f, + -0.156434f, -0.987688f, 0.488621f, -0.872496f, 0.923880f, -0.382683f, + 0.962455f, 0.271440f, 0.587785f, 0.809017f, -0.039260f, 0.999229f, + -0.649448f, 0.760406f, -0.980785f, 0.195090f, -0.891007f, -0.453990f, + -0.418660f, -0.908143f, 0.233445f, -0.972370f, 0.785317f, -0.619094f, + -0.000000f, 1.000000f, -0.678801f, 0.734322f, -0.996917f, 0.078459f, + -0.785317f, -0.619094f, -0.156434f, -0.987688f, 0.555570f, -0.831470f, + 0.972370f, -0.233445f, 0.872496f, 0.488621f, 0.309017f, 0.951057f, + -0.418660f, 0.908143f, -0.923880f, 0.382683f, -0.938191f, -0.346117f, + -0.453990f, -0.891007f, 0.271440f, -0.962455f, 0.852640f, -0.522499f, + 0.980785f, 0.195090f, 0.587785f, 0.809017f, -0.117537f, 0.993068f, + -0.760406f, 0.649448f, -0.999229f, -0.039260f, -0.707107f, -0.707107f, + -0.039260f, -0.999229f, 0.649448f, -0.760406f, 0.993068f, -0.117537f, + 0.809017f, 0.587785f, 0.195090f, 0.980785f, -0.522499f, 0.852640f, + -0.962455f, 0.271440f, -0.891007f, -0.453990f, -0.346117f, -0.938191f, + 0.382683f, -0.923880f, 0.908143f, -0.418660f, 0.951057f, 0.309017f, + 0.488621f, 0.872496f, -0.233445f, 0.972370f, -0.831470f, 0.555570f, + -0.987688f, -0.156434f, -0.619094f, -0.785317f, 0.078459f, -0.996917f, + 0.734322f, -0.678801f, -0.000000f, -1.000000f, 0.734322f, -0.678801f, + 0.996917f, 0.078459f, 0.619094f, 0.785317f, -0.156434f, 0.987688f, + -0.831470f, 0.555570f, -0.972370f, -0.233445f, -0.488621f, -0.872496f, + 0.309017f, -0.951057f, 0.908143f, -0.418660f, 0.923880f, 0.382683f, + 0.346117f, 0.938191f, -0.453990f, 0.891007f, -0.962455f, 0.271440f, + -0.852640f, -0.522499f, -0.195090f, -0.980785f, 0.587785f, -0.809017f, + 0.993068f, -0.117537f, 0.760406f, 0.649448f, 0.039260f, 0.999229f, + -0.707107f, 0.707107f, -0.999229f, -0.039260f, -0.649448f, -0.760406f, + 0.117537f, -0.993068f, 0.809017f, -0.587785f, 0.980785f, 0.195090f, + 0.522499f, 0.852640f, -0.271440f, 0.962455f, -0.891007f, 0.453990f, + -0.938191f, -0.346117f, -0.382683f, -0.923880f, 0.418660f, -0.908143f, + 0.951057f, -0.309017f, 0.872496f, 0.488621f, 0.233445f, 0.972370f, + -0.555570f, 0.831470f, -0.987688f, 0.156434f, -0.785317f, -0.619094f, + -0.078459f, -0.996917f, 0.678801f, -0.734322f, -0.000000f, 1.000000f, + -0.785317f, 0.619094f, -0.972370f, -0.233445f, -0.418660f, -0.908143f, + 0.453990f, -0.891007f, 0.980785f, -0.195090f, 0.760406f, 0.649448f, + -0.039260f, 0.999229f, -0.809017f, 0.587785f, -0.962455f, -0.271440f, + -0.382683f, -0.923880f, 0.488621f, -0.872496f, 0.987688f, -0.156434f, + 0.734322f, 0.678801f, -0.078459f, 0.996917f, -0.831470f, 0.555570f, + -0.951057f, -0.309017f, -0.346117f, -0.938191f, 0.522499f, -0.852640f, + 0.993068f, -0.117537f, 0.707107f, 0.707107f, -0.117537f, 0.993068f, + -0.852640f, 0.522499f, -0.938191f, -0.346117f, -0.309017f, -0.951057f, + 0.555570f, -0.831470f, 0.996917f, -0.078459f, 0.678801f, 0.734322f, + -0.156434f, 0.987688f, -0.872496f, 0.488621f, -0.923880f, -0.382683f, + -0.271440f, -0.962455f, 0.587785f, -0.809017f, 0.999229f, -0.039260f, + 0.649448f, 0.760406f, -0.195090f, 0.980785f, -0.891007f, 0.453990f, + -0.908143f, -0.418660f, -0.233445f, -0.972370f, 0.619094f, -0.785317f, + -0.000000f, -1.000000f, 0.831470f, -0.555570f, 0.923880f, 0.382683f, + 0.195090f, 0.980785f, -0.707107f, 0.707107f, -0.980785f, -0.195090f, + -0.382683f, -0.923880f, 0.555570f, -0.831470f, 1.000000f, 0.000000f, + 0.555570f, 0.831470f, -0.382683f, 0.923880f, -0.980785f, 0.195090f, + -0.707107f, -0.707107f, 0.195090f, -0.980785f, 0.923880f, -0.382683f, + 0.831470f, 0.555570f, -0.000000f, 1.000000f, -0.831470f, 0.555570f, + -0.923880f, -0.382683f, -0.195090f, -0.980785f, 0.707107f, -0.707107f, + 0.980785f, 0.195090f, 0.382683f, 0.923880f, -0.555570f, 0.831470f, + -1.000000f, -0.000000f, -0.555570f, -0.831470f, 0.382683f, -0.923880f, + 0.980785f, -0.195090f, 0.707107f, 0.707107f, -0.195090f, 0.980785f, + -0.923880f, 0.382683f, -0.831470f, -0.555570f, 0.000000f, -1.000000f, + 0.831470f, -0.555570f, 0.923880f, 0.382683f, 0.195090f, 0.980785f, + -0.707107f, 0.707107f, -0.980785f, -0.195090f, -0.382683f, -0.923880f, + 0.555570f, -0.831470f, -0.000000f, 1.000000f, -0.872496f, 0.488621f, + -0.852640f, -0.522499f, 0.039260f, -0.999229f, 0.891007f, -0.453990f, + 0.831470f, 0.555570f, -0.078459f, 0.996917f, -0.908143f, 0.418660f, + -0.809017f, -0.587785f, 0.117537f, -0.993068f, 0.923880f, -0.382683f, + 0.785317f, 0.619094f, -0.156434f, 0.987688f, -0.938191f, 0.346117f, + -0.760406f, -0.649448f, 0.195090f, -0.980785f, 0.951057f, -0.309017f, + 0.734322f, 0.678801f, -0.233445f, 0.972370f, -0.962455f, 0.271440f, + -0.707107f, -0.707107f, 0.271440f, -0.962455f, 0.972370f, -0.233445f, + 0.678801f, 0.734322f, -0.309017f, 0.951057f, -0.980785f, 0.195090f, + -0.649448f, -0.760406f, 0.346117f, -0.938191f, 0.987688f, -0.156434f, + 0.619094f, 0.785317f, -0.382683f, 0.923880f, -0.993068f, 0.117537f, + -0.587785f, -0.809017f, 0.418660f, -0.908143f, 0.996917f, -0.078459f, + 0.555570f, 0.831470f, -0.453990f, 0.891007f, -0.999229f, 0.039260f, + -0.522499f, -0.852640f, 0.488621f, -0.872496f, -0.000000f, -1.000000f, + 0.908143f, -0.418660f, 0.760406f, 0.649448f, -0.271440f, 0.962455f, + -0.987688f, 0.156434f, -0.555570f, -0.831470f, 0.522499f, -0.852640f, + 0.993068f, 0.117537f, 0.309017f, 0.951057f, -0.734322f, 0.678801f, + -0.923880f, -0.382683f, -0.039260f, -0.999229f, 0.891007f, -0.453990f, + 0.785317f, 0.619094f, -0.233445f, 0.972370f, -0.980785f, 0.195090f, + -0.587785f, -0.809017f, 0.488621f, -0.872496f, 0.996917f, 0.078459f, + 0.346117f, 0.938191f, -0.707107f, 0.707107f, -0.938191f, -0.346117f, + -0.078459f, -0.996917f, 0.872496f, -0.488621f, 0.809017f, 0.587785f, + -0.195090f, 0.980785f, -0.972370f, 0.233445f, -0.619094f, -0.785317f, + 0.453990f, -0.891007f, 0.999229f, 0.039260f, 0.382683f, 0.923880f, + -0.678801f, 0.734322f, -0.951057f, -0.309017f, -0.117537f, -0.993068f, + 0.852640f, -0.522499f, 0.831470f, 0.555570f, -0.156434f, 0.987688f, + -0.962455f, 0.271440f, -0.649448f, -0.760406f, 0.418660f, -0.908143f, + -0.000000f, 1.000000f, -0.938191f, 0.346117f, -0.649448f, -0.760406f, + 0.488621f, -0.872496f, 0.987688f, 0.156434f, 0.195090f, 0.980785f, + -0.852640f, 0.522499f, -0.785317f, -0.619094f, 0.309017f, -0.951057f, + 0.999229f, -0.039260f, 0.382683f, 0.923880f, -0.734322f, 0.678801f, + -0.891007f, -0.453990f, 0.117537f, -0.993068f, 0.972370f, -0.233445f, + 0.555570f, 0.831470f, -0.587785f, 0.809017f, -0.962455f, -0.271440f, + -0.078459f, -0.996917f, 0.908143f, -0.418660f, 0.707107f, 0.707107f, + -0.418660f, 0.908143f, -0.996917f, -0.078459f, -0.271440f, -0.962455f, + 0.809017f, -0.587785f, 0.831470f, 0.555570f, -0.233445f, 0.972370f, + -0.993068f, 0.117537f, -0.453990f, -0.891007f, 0.678801f, -0.734322f, + 0.923880f, 0.382683f, -0.039260f, 0.999229f, -0.951057f, 0.309017f, + -0.619094f, -0.785317f, 0.522499f, -0.852640f, 0.980785f, 0.195090f, + 0.156434f, 0.987688f, -0.872496f, 0.488621f, -0.760406f, -0.649448f, + 0.346117f, -0.938191f, 0.000000f, -1.000000f, 0.962455f, -0.271440f, + 0.522499f, 0.852640f, -0.678801f, 0.734322f, -0.891007f, -0.453990f, + 0.195090f, -0.980785f, 0.996917f, -0.078459f, 0.346117f, 0.938191f, + -0.809017f, 0.587785f, -0.785317f, -0.619094f, 0.382683f, -0.923880f, + 0.993068f, 0.117537f, 0.156434f, 0.987688f, -0.908143f, 0.418660f, + -0.649448f, -0.760406f, 0.555570f, -0.831470f, 0.951057f, 0.309017f, + -0.039260f, 0.999229f, -0.972370f, 0.233445f, -0.488621f, -0.872496f, + 0.707107f, -0.707107f, 0.872496f, 0.488621f, -0.233445f, 0.972370f, + -0.999229f, 0.039260f, -0.309017f, -0.951057f, 0.831470f, -0.555570f, + 0.760406f, 0.649448f, -0.418660f, 0.908143f, -0.987688f, -0.156434f, + -0.117537f, -0.993068f, 0.923880f, -0.382683f, 0.619094f, 0.785317f, + -0.587785f, 0.809017f, -0.938191f, -0.346117f, 0.078459f, -0.996917f, + 0.980785f, -0.195090f, 0.453990f, 0.891007f, -0.734322f, 0.678801f, + -0.852640f, -0.522499f, 0.271440f, -0.962455f, -0.000000f, 1.000000f, + -0.980785f, 0.195090f, -0.382683f, -0.923880f, 0.831470f, -0.555570f, + 0.707107f, 0.707107f, -0.555570f, 0.831470f, -0.923880f, -0.382683f, + 0.195090f, -0.980785f, 1.000000f, 0.000000f, 0.195090f, 0.980785f, + -0.923880f, 0.382683f, -0.555570f, -0.831470f, 0.707107f, -0.707107f, + 0.831470f, 0.555570f, -0.382683f, 0.923880f, -0.980785f, -0.195090f, + -0.000000f, -1.000000f, 0.980785f, -0.195090f, 0.382683f, 0.923880f, + -0.831470f, 0.555570f, -0.707107f, -0.707107f, 0.555570f, -0.831470f, + 0.923880f, 0.382683f, -0.195090f, 0.980785f, -1.000000f, -0.000000f, + -0.195090f, -0.980785f, 0.923880f, -0.382683f, 0.555570f, 0.831470f, + -0.707107f, 0.707107f, -0.831470f, -0.555570f, 0.382683f, -0.923880f, + 0.980785f, 0.195090f, -0.000000f, 1.000000f, -0.980785f, 0.195090f, + -0.382683f, -0.923880f, 0.831470f, -0.555570f, 0.707107f, 0.707107f, + -0.555570f, 0.831470f, -0.923880f, -0.382683f, 0.195090f, -0.980785f, + 0.000000f, -1.000000f, 0.993068f, -0.117537f, 0.233445f, 0.972370f, + -0.938191f, 0.346117f, -0.453990f, -0.891007f, 0.831470f, -0.555570f, + 0.649448f, 0.760406f, -0.678801f, 0.734322f, -0.809017f, -0.587785f, + 0.488621f, -0.872496f, 0.923880f, 0.382683f, -0.271440f, 0.962455f, + -0.987688f, -0.156434f, 0.039260f, -0.999229f, 0.996917f, -0.078459f, + 0.195090f, 0.980785f, -0.951057f, 0.309017f, -0.418660f, -0.908143f, + 0.852640f, -0.522499f, 0.619094f, 0.785317f, -0.707107f, 0.707107f, + -0.785317f, -0.619094f, 0.522499f, -0.852640f, 0.908143f, 0.418660f, + -0.309017f, 0.951057f, -0.980785f, -0.195090f, 0.078459f, -0.996917f, + 0.999229f, -0.039260f, 0.156434f, 0.987688f, -0.962455f, 0.271440f, + -0.382683f, -0.923880f, 0.872496f, -0.488621f, 0.587785f, 0.809017f, + -0.734322f, 0.678801f, -0.760406f, -0.649448f, 0.555570f, -0.831470f, + 0.891007f, 0.453990f, -0.346117f, 0.938191f, -0.972370f, -0.233445f, + 0.117537f, -0.993068f, -0.000000f, 1.000000f, -0.999229f, 0.039260f, + -0.078459f, -0.996917f, 0.993068f, -0.117537f, 0.156434f, 0.987688f, + -0.980785f, 0.195090f, -0.233445f, -0.972370f, 0.962455f, -0.271440f, + 0.309017f, 0.951057f, -0.938191f, 0.346117f, -0.382683f, -0.923880f, + 0.908143f, -0.418660f, 0.453990f, 0.891007f, -0.872496f, 0.488621f, + -0.522499f, -0.852640f, 0.831470f, -0.555570f, 0.587785f, 0.809017f, + -0.785317f, 0.619094f, -0.649448f, -0.760406f, 0.734322f, -0.678801f, + 0.707107f, 0.707107f, -0.678801f, 0.734322f, -0.760406f, -0.649448f, + 0.619094f, -0.785317f, 0.809017f, 0.587785f, -0.555570f, 0.831470f, + -0.852640f, -0.522499f, 0.488621f, -0.872496f, 0.891007f, 0.453990f, + -0.418660f, 0.908143f, -0.923880f, -0.382683f, 0.346117f, -0.938191f, + 0.951057f, 0.309017f, -0.271440f, 0.962455f, -0.972370f, -0.233445f, + 0.195090f, -0.980785f, 0.987688f, 0.156434f, -0.117537f, 0.993068f, + -0.996917f, -0.078459f, 0.039260f, -0.999229f, 0.000000f, -1.000000f, + 0.999229f, 0.039260f, -0.078459f, 0.996917f, -0.993068f, -0.117537f, + 0.156434f, -0.987688f, 0.980785f, 0.195090f, -0.233445f, 0.972370f, + -0.962455f, -0.271440f, 0.309017f, -0.951057f, 0.938191f, 0.346117f, + -0.382683f, 0.923880f, -0.908143f, -0.418660f, 0.453990f, -0.891007f, + 0.872496f, 0.488621f, -0.522499f, 0.852640f, -0.831470f, -0.555570f, + 0.587785f, -0.809017f, 0.785317f, 0.619094f, -0.649448f, 0.760406f, + -0.734322f, -0.678801f, 0.707107f, -0.707107f, 0.678801f, 0.734322f, + -0.760406f, 0.649448f, -0.619094f, -0.785317f, 0.809017f, -0.587785f, + 0.555570f, 0.831470f, -0.852640f, 0.522499f, -0.488621f, -0.872496f, + 0.891007f, -0.453990f, 0.418660f, 0.908143f, -0.923880f, 0.382683f, + -0.346117f, -0.938191f, 0.951057f, -0.309017f, 0.271440f, 0.962455f, + -0.972370f, 0.233445f, -0.195090f, -0.980785f, 0.987688f, -0.156434f, + 0.117537f, 0.993068f, -0.996917f, 0.078459f, -0.039260f, -0.999229f, + -0.000000f, 1.000000f, -0.993068f, -0.117537f, 0.233445f, -0.972370f, + 0.938191f, 0.346117f, -0.453990f, 0.891007f, -0.831470f, -0.555570f, + 0.649448f, -0.760406f, 0.678801f, 0.734322f, -0.809017f, 0.587785f, + -0.488621f, -0.872496f, 0.923880f, -0.382683f, 0.271440f, 0.962455f, + -0.987688f, 0.156434f, -0.039260f, -0.999229f, 0.996917f, 0.078459f, + -0.195090f, 0.980785f, -0.951057f, -0.309017f, 0.418660f, -0.908143f, + 0.852640f, 0.522499f, -0.619094f, 0.785317f, -0.707107f, -0.707107f, + 0.785317f, -0.619094f, 0.522499f, 0.852640f, -0.908143f, 0.418660f, + -0.309017f, -0.951057f, 0.980785f, -0.195090f, 0.078459f, 0.996917f, + -0.999229f, -0.039260f, 0.156434f, -0.987688f, 0.962455f, 0.271440f, + -0.382683f, 0.923880f, -0.872496f, -0.488621f, 0.587785f, -0.809017f, + 0.734322f, 0.678801f, -0.760406f, 0.649448f, -0.555570f, -0.831470f, + 0.891007f, -0.453990f, 0.346117f, 0.938191f, -0.972370f, 0.233445f, + -0.117537f, -0.993068f, 0.000000f, -1.000000f, 0.980785f, 0.195090f, + -0.382683f, 0.923880f, -0.831470f, -0.555570f, 0.707107f, -0.707107f, + 0.555570f, 0.831470f, -0.923880f, 0.382683f, -0.195090f, -0.980785f, + 1.000000f, 0.000000f, -0.195090f, 0.980785f, -0.923880f, -0.382683f, + 0.555570f, -0.831470f, 0.707107f, 0.707107f, -0.831470f, 0.555570f, + -0.382683f, -0.923880f, 0.980785f, -0.195090f, -0.000000f, 1.000000f, + -0.980785f, -0.195090f, 0.382683f, -0.923880f, 0.831470f, 0.555570f, + -0.707107f, 0.707107f, -0.555570f, -0.831470f, 0.923880f, -0.382683f, + 0.195090f, 0.980785f, -1.000000f, -0.000000f, 0.195090f, -0.980785f, + 0.923880f, 0.382683f, -0.555570f, 0.831470f, -0.707107f, -0.707107f, + 0.831470f, -0.555570f, 0.382683f, 0.923880f, -0.980785f, 0.195090f, + 0.000000f, -1.000000f, 0.980785f, 0.195090f, -0.382683f, 0.923880f, + -0.831470f, -0.555570f, 0.707107f, -0.707107f, 0.555570f, 0.831470f, + -0.923880f, 0.382683f, -0.195090f, -0.980785f, 0.000000f, 1.000000f, + -0.962455f, -0.271440f, 0.522499f, -0.852640f, 0.678801f, 0.734322f, + -0.891007f, 0.453990f, -0.195090f, -0.980785f, 0.996917f, 0.078459f, + -0.346117f, 0.938191f, -0.809017f, -0.587785f, 0.785317f, -0.619094f, + 0.382683f, 0.923880f, -0.993068f, 0.117537f, 0.156434f, -0.987688f, + 0.908143f, 0.418660f, -0.649448f, 0.760406f, -0.555570f, -0.831470f, + 0.951057f, -0.309017f, 0.039260f, 0.999229f, -0.972370f, -0.233445f, + 0.488621f, -0.872496f, 0.707107f, 0.707107f, -0.872496f, 0.488621f, + -0.233445f, -0.972370f, 0.999229f, 0.039260f, -0.309017f, 0.951057f, + -0.831470f, -0.555570f, 0.760406f, -0.649448f, 0.418660f, 0.908143f, + -0.987688f, 0.156434f, 0.117537f, -0.993068f, 0.923880f, 0.382683f, + -0.619094f, 0.785317f, -0.587785f, -0.809017f, 0.938191f, -0.346117f, + 0.078459f, 0.996917f, -0.980785f, -0.195090f, 0.453990f, -0.891007f, + 0.734322f, 0.678801f, -0.852640f, 0.522499f, -0.271440f, -0.962455f, + 0.000000f, -1.000000f, 0.938191f, 0.346117f, -0.649448f, 0.760406f, + -0.488621f, -0.872496f, 0.987688f, -0.156434f, -0.195090f, 0.980785f, + -0.852640f, -0.522499f, 0.785317f, -0.619094f, 0.309017f, 0.951057f, + -0.999229f, -0.039260f, 0.382683f, -0.923880f, 0.734322f, 0.678801f, + -0.891007f, 0.453990f, -0.117537f, -0.993068f, 0.972370f, 0.233445f, + -0.555570f, 0.831470f, -0.587785f, -0.809017f, 0.962455f, -0.271440f, + -0.078459f, 0.996917f, -0.908143f, -0.418660f, 0.707107f, -0.707107f, + 0.418660f, 0.908143f, -0.996917f, 0.078459f, 0.271440f, -0.962455f, + 0.809017f, 0.587785f, -0.831470f, 0.555570f, -0.233445f, -0.972370f, + 0.993068f, 0.117537f, -0.453990f, 0.891007f, -0.678801f, -0.734322f, + 0.923880f, -0.382683f, 0.039260f, 0.999229f, -0.951057f, -0.309017f, + 0.619094f, -0.785317f, 0.522499f, 0.852640f, -0.980785f, 0.195090f, + 0.156434f, -0.987688f, 0.872496f, 0.488621f, -0.760406f, 0.649448f, + -0.346117f, -0.938191f, -0.000000f, 1.000000f, -0.908143f, -0.418660f, + 0.760406f, -0.649448f, 0.271440f, 0.962455f, -0.987688f, -0.156434f, + 0.555570f, -0.831470f, 0.522499f, 0.852640f, -0.993068f, 0.117537f, + 0.309017f, -0.951057f, 0.734322f, 0.678801f, -0.923880f, 0.382683f, + 0.039260f, -0.999229f, 0.891007f, 0.453990f, -0.785317f, 0.619094f, + -0.233445f, -0.972370f, 0.980785f, 0.195090f, -0.587785f, 0.809017f, + -0.488621f, -0.872496f, 0.996917f, -0.078459f, -0.346117f, 0.938191f, + -0.707107f, -0.707107f, 0.938191f, -0.346117f, -0.078459f, 0.996917f, + -0.872496f, -0.488621f, 0.809017f, -0.587785f, 0.195090f, 0.980785f, + -0.972370f, -0.233445f, 0.619094f, -0.785317f, 0.453990f, 0.891007f, + -0.999229f, 0.039260f, 0.382683f, -0.923880f, 0.678801f, 0.734322f, + -0.951057f, 0.309017f, 0.117537f, -0.993068f, 0.852640f, 0.522499f, + -0.831470f, 0.555570f, -0.156434f, -0.987688f, 0.962455f, 0.271440f, + -0.649448f, 0.760406f, -0.418660f, -0.908143f, 0.000000f, -1.000000f, + 0.872496f, 0.488621f, -0.852640f, 0.522499f, -0.039260f, -0.999229f, + 0.891007f, 0.453990f, -0.831470f, 0.555570f, -0.078459f, -0.996917f, + 0.908143f, 0.418660f, -0.809017f, 0.587785f, -0.117537f, -0.993068f, + 0.923880f, 0.382683f, -0.785317f, 0.619094f, -0.156434f, -0.987688f, + 0.938191f, 0.346117f, -0.760406f, 0.649448f, -0.195090f, -0.980785f, + 0.951057f, 0.309017f, -0.734322f, 0.678801f, -0.233445f, -0.972370f, + 0.962455f, 0.271440f, -0.707107f, 0.707107f, -0.271440f, -0.962455f, + 0.972370f, 0.233445f, -0.678801f, 0.734322f, -0.309017f, -0.951057f, + 0.980785f, 0.195090f, -0.649448f, 0.760406f, -0.346117f, -0.938191f, + 0.987688f, 0.156434f, -0.619094f, 0.785317f, -0.382683f, -0.923880f, + 0.993068f, 0.117537f, -0.587785f, 0.809017f, -0.418660f, -0.908143f, + 0.996917f, 0.078459f, -0.555570f, 0.831470f, -0.453990f, -0.891007f, + 0.999229f, 0.039260f, -0.522499f, 0.852640f, -0.488621f, -0.872496f, + -0.000000f, 1.000000f, -0.831470f, -0.555570f, 0.923880f, -0.382683f, + -0.195090f, 0.980785f, -0.707107f, -0.707107f, 0.980785f, -0.195090f, + -0.382683f, 0.923880f, -0.555570f, -0.831470f, 1.000000f, 0.000000f, + -0.555570f, 0.831470f, -0.382683f, -0.923880f, 0.980785f, 0.195090f, + -0.707107f, 0.707107f, -0.195090f, -0.980785f, 0.923880f, 0.382683f, + -0.831470f, 0.555570f, 0.000000f, -1.000000f, 0.831470f, 0.555570f, + -0.923880f, 0.382683f, 0.195090f, -0.980785f, 0.707107f, 0.707107f, + -0.980785f, 0.195090f, 0.382683f, -0.923880f, 0.555570f, 0.831470f, + -1.000000f, -0.000000f, 0.555570f, -0.831470f, 0.382683f, 0.923880f, + -0.980785f, -0.195090f, 0.707107f, -0.707107f, 0.195090f, 0.980785f, + -0.923880f, -0.382683f, 0.831470f, -0.555570f, -0.000000f, 1.000000f, + -0.831470f, -0.555570f, 0.923880f, -0.382683f, -0.195090f, 0.980785f, + -0.707107f, -0.707107f, 0.980785f, -0.195090f, -0.382683f, 0.923880f, + -0.555570f, -0.831470f, -0.000000f, -1.000000f, 0.785317f, 0.619094f, + -0.972370f, 0.233445f, 0.418660f, -0.908143f, 0.453990f, 0.891007f, + -0.980785f, -0.195090f, 0.760406f, -0.649448f, 0.039260f, 0.999229f, + -0.809017f, -0.587785f, 0.962455f, -0.271440f, -0.382683f, 0.923880f, + -0.488621f, -0.872496f, 0.987688f, 0.156434f, -0.734322f, 0.678801f, + -0.078459f, -0.996917f, 0.831470f, 0.555570f, -0.951057f, 0.309017f, + 0.346117f, -0.938191f, 0.522499f, 0.852640f, -0.993068f, -0.117537f, + 0.707107f, -0.707107f, 0.117537f, 0.993068f, -0.852640f, -0.522499f, + 0.938191f, -0.346117f, -0.309017f, 0.951057f, -0.555570f, -0.831470f, + 0.996917f, 0.078459f, -0.678801f, 0.734322f, -0.156434f, -0.987688f, + 0.872496f, 0.488621f, -0.923880f, 0.382683f, 0.271440f, -0.962455f, + 0.587785f, 0.809017f, -0.999229f, -0.039260f, 0.649448f, -0.760406f, + 0.195090f, 0.980785f, -0.891007f, -0.453990f, 0.908143f, -0.418660f, + -0.233445f, 0.972370f, -0.619094f, -0.785317f, -0.000000f, 1.000000f, + -0.734322f, -0.678801f, 0.996917f, -0.078459f, -0.619094f, 0.785317f, + -0.156434f, -0.987688f, 0.831470f, 0.555570f, -0.972370f, 0.233445f, + 0.488621f, -0.872496f, 0.309017f, 0.951057f, -0.908143f, -0.418660f, + 0.923880f, -0.382683f, -0.346117f, 0.938191f, -0.453990f, -0.891007f, + 0.962455f, 0.271440f, -0.852640f, 0.522499f, 0.195090f, -0.980785f, + 0.587785f, 0.809017f, -0.993068f, -0.117537f, 0.760406f, -0.649448f, + -0.039260f, 0.999229f, -0.707107f, -0.707107f, 0.999229f, -0.039260f, + -0.649448f, 0.760406f, -0.117537f, -0.993068f, 0.809017f, 0.587785f, + -0.980785f, 0.195090f, 0.522499f, -0.852640f, 0.271440f, 0.962455f, + -0.891007f, -0.453990f, 0.938191f, -0.346117f, -0.382683f, 0.923880f, + -0.418660f, -0.908143f, 0.951057f, 0.309017f, -0.872496f, 0.488621f, + 0.233445f, -0.972370f, 0.555570f, 0.831470f, -0.987688f, -0.156434f, + 0.785317f, -0.619094f, -0.078459f, 0.996917f, -0.678801f, -0.734322f, + -0.000000f, -1.000000f, 0.678801f, 0.734322f, -0.996917f, -0.078459f, + 0.785317f, -0.619094f, -0.156434f, 0.987688f, -0.555570f, -0.831470f, + 0.972370f, 0.233445f, -0.872496f, 0.488621f, 0.309017f, -0.951057f, + 0.418660f, 0.908143f, -0.923880f, -0.382683f, 0.938191f, -0.346117f, + -0.453990f, 0.891007f, -0.271440f, -0.962455f, 0.852640f, 0.522499f, + -0.980785f, 0.195090f, 0.587785f, -0.809017f, 0.117537f, 0.993068f, + -0.760406f, -0.649448f, 0.999229f, -0.039260f, -0.707107f, 0.707107f, + 0.039260f, -0.999229f, 0.649448f, 0.760406f, -0.993068f, -0.117537f, + 0.809017f, -0.587785f, -0.195090f, 0.980785f, -0.522499f, -0.852640f, + 0.962455f, 0.271440f, -0.891007f, 0.453990f, 0.346117f, -0.938191f, + 0.382683f, 0.923880f, -0.908143f, -0.418660f, 0.951057f, -0.309017f, + -0.488621f, 0.872496f, -0.233445f, -0.972370f, 0.831470f, 0.555570f, + -0.987688f, 0.156434f, 0.619094f, -0.785317f, 0.078459f, 0.996917f, + -0.734322f, -0.678801f, -0.000000f, 1.000000f, -0.619094f, -0.785317f, + 0.972370f, 0.233445f, -0.908143f, 0.418660f, 0.453990f, -0.891007f, + 0.195090f, 0.980785f, -0.760406f, -0.649448f, 0.999229f, 0.039260f, + -0.809017f, 0.587785f, 0.271440f, -0.962455f, 0.382683f, 0.923880f, + -0.872496f, -0.488621f, 0.987688f, -0.156434f, -0.678801f, 0.734322f, + 0.078459f, -0.996917f, 0.555570f, 0.831470f, -0.951057f, -0.309017f, + 0.938191f, -0.346117f, -0.522499f, 0.852640f, -0.117537f, -0.993068f, + 0.707107f, 0.707107f, -0.993068f, -0.117537f, 0.852640f, -0.522499f, + -0.346117f, 0.938191f, -0.309017f, -0.951057f, 0.831470f, 0.555570f, + -0.996917f, 0.078459f, 0.734322f, -0.678801f, -0.156434f, 0.987688f, + -0.488621f, -0.872496f, 0.923880f, 0.382683f, -0.962455f, 0.271440f, + 0.587785f, -0.809017f, 0.039260f, 0.999229f, -0.649448f, -0.760406f, + 0.980785f, 0.195090f, -0.891007f, 0.453990f, 0.418660f, -0.908143f, + 0.233445f, 0.972370f, -0.785317f, -0.619094f, -0.000000f, -1.000000f, + 0.555570f, 0.831470f, -0.923880f, -0.382683f, 0.980785f, -0.195090f, + -0.707107f, 0.707107f, 0.195090f, -0.980785f, 0.382683f, 0.923880f, + -0.831470f, -0.555570f, 1.000000f, -0.000000f, -0.831470f, 0.555570f, + 0.382683f, -0.923880f, 0.195090f, 0.980785f, -0.707107f, -0.707107f, + 0.980785f, 0.195090f, -0.923880f, 0.382683f, 0.555570f, -0.831470f, + 0.000000f, 1.000000f, -0.555570f, -0.831470f, 0.923880f, 0.382683f, + -0.980785f, 0.195090f, 0.707107f, -0.707107f, -0.195090f, 0.980785f, + -0.382683f, -0.923880f, 0.831470f, 0.555570f, -1.000000f, 0.000000f, + 0.831470f, -0.555570f, -0.382683f, 0.923880f, -0.195090f, -0.980785f, + 0.707107f, 0.707107f, -0.980785f, -0.195090f, 0.923880f, -0.382683f, + -0.555570f, 0.831470f, -0.000000f, -1.000000f, 0.555570f, 0.831470f, + -0.923880f, -0.382683f, 0.980785f, -0.195090f, -0.707107f, 0.707107f, + 0.195090f, -0.980785f, 0.382683f, 0.923880f, -0.831470f, -0.555570f, + -0.000000f, 1.000000f, -0.488621f, -0.872496f, 0.852640f, 0.522499f, + -0.999229f, -0.039260f, 0.891007f, -0.453990f, -0.555570f, 0.831470f, + 0.078459f, -0.996917f, 0.418660f, 0.908143f, -0.809017f, -0.587785f, + 0.993068f, 0.117537f, -0.923880f, 0.382683f, 0.619094f, -0.785317f, + -0.156434f, 0.987688f, -0.346117f, -0.938191f, 0.760406f, 0.649448f, + -0.980785f, -0.195090f, 0.951057f, -0.309017f, -0.678801f, 0.734322f, + 0.233445f, -0.972370f, 0.271440f, 0.962455f, -0.707107f, -0.707107f, + 0.962455f, 0.271440f, -0.972370f, 0.233445f, 0.734322f, -0.678801f, + -0.309017f, 0.951057f, -0.195090f, -0.980785f, 0.649448f, 0.760406f, + -0.938191f, -0.346117f, 0.987688f, -0.156434f, -0.785317f, 0.619094f, + 0.382683f, -0.923880f, 0.117537f, 0.993068f, -0.587785f, -0.809017f, + 0.908143f, 0.418660f, -0.996917f, 0.078459f, 0.831470f, -0.555570f, + -0.453990f, 0.891007f, -0.039260f, -0.999229f, 0.522499f, 0.852640f, + -0.872496f, -0.488621f, 0.000000f, -1.000000f, 0.418660f, 0.908143f, + -0.760406f, -0.649448f, 0.962455f, 0.271440f, -0.987688f, 0.156434f, + 0.831470f, -0.555570f, -0.522499f, 0.852640f, 0.117537f, -0.993068f, + 0.309017f, 0.951057f, -0.678801f, -0.734322f, 0.923880f, 0.382683f, + -0.999229f, 0.039260f, 0.891007f, -0.453990f, -0.619094f, 0.785317f, + 0.233445f, -0.972370f, 0.195090f, 0.980785f, -0.587785f, -0.809017f, + 0.872496f, 0.488621f, -0.996917f, -0.078459f, 0.938191f, -0.346117f, + -0.707107f, 0.707107f, 0.346117f, -0.938191f, 0.078459f, 0.996917f, + -0.488621f, -0.872496f, 0.809017f, 0.587785f, -0.980785f, -0.195090f, + 0.972370f, -0.233445f, -0.785317f, 0.619094f, 0.453990f, -0.891007f, + -0.039260f, 0.999229f, -0.382683f, -0.923880f, 0.734322f, 0.678801f, + -0.951057f, -0.309017f, 0.993068f, -0.117537f, -0.852640f, 0.522499f, + 0.555570f, -0.831470f, -0.156434f, 0.987688f, -0.271440f, -0.962455f, + 0.649448f, 0.760406f, -0.908143f, -0.418660f, -0.000000f, 1.000000f, + -0.346117f, -0.938191f, 0.649448f, 0.760406f, -0.872496f, -0.488621f, + 0.987688f, 0.156434f, -0.980785f, 0.195090f, 0.852640f, -0.522499f, + -0.619094f, 0.785317f, 0.309017f, -0.951057f, 0.039260f, 0.999229f, + -0.382683f, -0.923880f, 0.678801f, 0.734322f, -0.891007f, -0.453990f, + 0.993068f, 0.117537f, -0.972370f, 0.233445f, 0.831470f, -0.555570f, + -0.587785f, 0.809017f, 0.271440f, -0.962455f, 0.078459f, 0.996917f, + -0.418660f, -0.908143f, 0.707107f, 0.707107f, -0.908143f, -0.418660f, + 0.996917f, 0.078459f, -0.962455f, 0.271440f, 0.809017f, -0.587785f, + -0.555570f, 0.831470f, 0.233445f, -0.972370f, 0.117537f, 0.993068f, + -0.453990f, -0.891007f, 0.734322f, 0.678801f, -0.923880f, -0.382683f, + 0.999229f, 0.039260f, -0.951057f, 0.309017f, 0.785317f, -0.619094f, + -0.522499f, 0.852640f, 0.195090f, -0.980785f, 0.156434f, 0.987688f, + -0.488621f, -0.872496f, 0.760406f, 0.649448f, -0.938191f, -0.346117f, + -0.000000f, -1.000000f, 0.271440f, 0.962455f, -0.522499f, -0.852640f, + 0.734322f, 0.678801f, -0.891007f, -0.453990f, 0.980785f, 0.195090f, + -0.996917f, 0.078459f, 0.938191f, -0.346117f, -0.809017f, 0.587785f, + 0.619094f, -0.785317f, -0.382683f, 0.923880f, 0.117537f, -0.993068f, + 0.156434f, 0.987688f, -0.418660f, -0.908143f, 0.649448f, 0.760406f, + -0.831470f, -0.555570f, 0.951057f, 0.309017f, -0.999229f, -0.039260f, + 0.972370f, -0.233445f, -0.872496f, 0.488621f, 0.707107f, -0.707107f, + -0.488621f, 0.872496f, 0.233445f, -0.972370f, 0.039260f, 0.999229f, + -0.309017f, -0.951057f, 0.555570f, 0.831470f, -0.760406f, -0.649448f, + 0.908143f, 0.418660f, -0.987688f, -0.156434f, 0.993068f, -0.117537f, + -0.923880f, 0.382683f, 0.785317f, -0.619094f, -0.587785f, 0.809017f, + 0.346117f, -0.938191f, -0.078459f, 0.996917f, -0.195090f, -0.980785f, + 0.453990f, 0.891007f, -0.678801f, -0.734322f, 0.852640f, 0.522499f, + -0.962455f, -0.271440f, -0.000000f, 1.000000f, -0.195090f, -0.980785f, + 0.382683f, 0.923880f, -0.555570f, -0.831470f, 0.707107f, 0.707107f, + -0.831470f, -0.555570f, 0.923880f, 0.382683f, -0.980785f, -0.195090f, + 1.000000f, 0.000000f, -0.980785f, 0.195090f, 0.923880f, -0.382683f, + -0.831470f, 0.555570f, 0.707107f, -0.707107f, -0.555570f, 0.831470f, + 0.382683f, -0.923880f, -0.195090f, 0.980785f, 0.000000f, -1.000000f, + 0.195090f, 0.980785f, -0.382683f, -0.923880f, 0.555570f, 0.831470f, + -0.707107f, -0.707107f, 0.831470f, 0.555570f, -0.923880f, -0.382683f, + 0.980785f, 0.195090f, -1.000000f, -0.000000f, 0.980785f, -0.195090f, + -0.923880f, 0.382683f, 0.831470f, -0.555570f, -0.707107f, 0.707107f, + 0.555570f, -0.831470f, -0.382683f, 0.923880f, 0.195090f, -0.980785f, + -0.000000f, 1.000000f, -0.195090f, -0.980785f, 0.382683f, 0.923880f, + -0.555570f, -0.831470f, 0.707107f, 0.707107f, -0.831470f, -0.555570f, + 0.923880f, 0.382683f, -0.980785f, -0.195090f, -0.000000f, -1.000000f, + 0.117537f, 0.993068f, -0.233445f, -0.972370f, 0.346117f, 0.938191f, + -0.453990f, -0.891007f, 0.555570f, 0.831470f, -0.649448f, -0.760406f, + 0.734322f, 0.678801f, -0.809017f, -0.587785f, 0.872496f, 0.488621f, + -0.923880f, -0.382683f, 0.962455f, 0.271440f, -0.987688f, -0.156434f, + 0.999229f, 0.039260f, -0.996917f, 0.078459f, 0.980785f, -0.195090f, + -0.951057f, 0.309017f, 0.908143f, -0.418660f, -0.852640f, 0.522499f, + 0.785317f, -0.619094f, -0.707107f, 0.707107f, 0.619094f, -0.785317f, + -0.522499f, 0.852640f, 0.418660f, -0.908143f, -0.309017f, 0.951057f, + 0.195090f, -0.980785f, -0.078459f, 0.996917f, -0.039260f, -0.999229f, + 0.156434f, 0.987688f, -0.271440f, -0.962455f, 0.382683f, 0.923880f, + -0.488621f, -0.872496f, 0.587785f, 0.809017f, -0.678801f, -0.734322f, + 0.760406f, 0.649448f, -0.831470f, -0.555570f, 0.891007f, 0.453990f, + -0.938191f, -0.346117f, 0.972370f, 0.233445f, -0.993068f, -0.117537f, + -0.000000f, 1.000000f, -0.039260f, -0.999229f, 0.078459f, 0.996917f, + -0.117537f, -0.993068f, 0.156434f, 0.987688f, -0.195090f, -0.980785f, + 0.233445f, 0.972370f, -0.271440f, -0.962455f, 0.309017f, 0.951057f, + -0.346117f, -0.938191f, 0.382683f, 0.923880f, -0.418660f, -0.908143f, + 0.453990f, 0.891007f, -0.488621f, -0.872496f, 0.522499f, 0.852640f, + -0.555570f, -0.831470f, 0.587785f, 0.809017f, -0.619094f, -0.785317f, + 0.649448f, 0.760406f, -0.678801f, -0.734322f, 0.707107f, 0.707107f, + -0.734322f, -0.678801f, 0.760406f, 0.649448f, -0.785317f, -0.619094f, + 0.809017f, 0.587785f, -0.831470f, -0.555570f, 0.852640f, 0.522499f, + -0.872496f, -0.488621f, 0.891007f, 0.453990f, -0.908143f, -0.418660f, + 0.923880f, 0.382683f, -0.938191f, -0.346117f, 0.951057f, 0.309017f, + -0.962455f, -0.271440f, 0.972370f, 0.233445f, -0.980785f, -0.195090f, + 0.987688f, 0.156434f, -0.993068f, -0.117537f, 0.996917f, 0.078459f, + -0.999229f, -0.039260f, +}; + +const FLOAT32 ixheaacd_twiddle_table_fft_float[514] = { + 1.00000000000000000000f, 0.99998117528260111000f, + 0.99992470183914450000f, 0.99983058179582340000f, + 0.99969881869620425000f, 0.99952941750109314000f, + 0.99932238458834954000f, 0.99907772775264536000f, + 0.99879545620517241000f, 0.99847558057329477000f, + 0.99811811290014918000f, 0.99772306664419164000f, + 0.99729045667869021000f, 0.99682029929116567000f, + 0.99631261218277800000f, 0.99576741446765982000f, + 0.99518472667219693000f, 0.99456457073425542000f, + 0.99390697000235606000f, 0.99321194923479450000f, + 0.99247953459870997000f, 0.99170975366909953000f, + 0.99090263542778001000f, 0.99005821026229712000f, + 0.98917650996478101000f, 0.98825756773074946000f, + 0.98730141815785843000f, 0.98630809724459867000f, + 0.98527764238894122000f, 0.98421009238692903000f, + 0.98310548743121629000f, 0.98196386910955524000f, + 0.98078528040323043000f, 0.97956976568544052000f, + 0.97831737071962765000f, 0.97702814265775439000f, + 0.97570213003852857000f, 0.97433938278557586000f, + 0.97293995220556018000f, 0.97150389098625178000f, + 0.97003125319454397000f, 0.96852209427441738000f, + 0.96697647104485207000f, 0.96539444169768940000f, + 0.96377606579543984000f, 0.96212140426904158000f, + 0.96043051941556579000f, 0.95870347489587160000f, + 0.95694033573220882000f, 0.95514116830577078000f, + 0.95330604035419386000f, 0.95143502096900834000f, + 0.94952818059303667000f, 0.94758559101774109000f, + 0.94560732538052128000f, 0.94359345816196039000f, + 0.94154406518302081000f, 0.93945922360218992000f, + 0.93733901191257496000f, 0.93518350993894761000f, + 0.93299279883473896000f, 0.93076696107898371000f, + 0.92850608047321559000f, 0.92621024213831138000f, + 0.92387953251128674000f, 0.92151403934204201000f, + 0.91911385169005777000f, 0.91667905992104270000f, + 0.91420975570353069000f, 0.91170603200542988000f, + 0.90916798309052238000f, 0.90659570451491533000f, + 0.90398929312344334000f, 0.90134884704602203000f, + 0.89867446569395382000f, 0.89596624975618522000f, + 0.89322430119551532000f, 0.89044872324475788000f, + 0.88763962040285393000f, 0.88479709843093779000f, + 0.88192126434835505000f, 0.87901222642863353000f, + 0.87607009419540660000f, 0.87309497841829009000f, + 0.87008699110871146000f, 0.86704624551569265000f, + 0.86397285612158681000f, 0.86086693863776731000f, + 0.85772861000027212000f, 0.85455798836540053000f, + 0.85135519310526520000f, 0.84812034480329723000f, + 0.84485356524970712000f, 0.84155497743689844000f, + 0.83822470555483808000f, 0.83486287498638001000f, + 0.83146961230254524000f, 0.82804504525775580000f, + 0.82458930278502529000f, 0.82110251499110465000f, + 0.81758481315158371000f, 0.81403632970594841000f, + 0.81045719825259477000f, 0.80684755354379933000f, + 0.80320753148064494000f, 0.79953726910790501000f, + 0.79583690460888357000f, 0.79210657730021239000f, + 0.78834642762660634000f, 0.78455659715557524000f, + 0.78073722857209449000f, 0.77688846567323244000f, + 0.77301045336273699000f, 0.76910333764557970000f, + 0.76516726562245896000f, 0.76120238548426178000f, + 0.75720884650648457000f, 0.75318679904361252000f, + 0.74913639452345937000f, 0.74505778544146606000f, + 0.74095112535495911000f, 0.73681656887736990000f, + 0.73265427167241282000f, 0.72846439044822520000f, + 0.72424708295146700000f, 0.72000250796138165000f, + 0.71573082528381859000f, 0.71143219574521643000f, + 0.70710678118654757000f, 0.70275474445722530000f, + 0.69837624940897292000f, 0.69397146088965400000f, + 0.68954054473706694000f, 0.68508366777270036000f, + 0.68060099779545313000f, 0.67609270357531603000f, + 0.67155895484701833000f, 0.66699992230363747000f, + 0.66241577759017178000f, 0.65780669329707864000f, + 0.65317284295377676000f, 0.64851440102211255000f, + 0.64383154288979150000f, 0.63912444486377573000f, + 0.63439328416364549000f, 0.62963823891492710000f, + 0.62485948814238645000f, 0.62005721176328921000f, + 0.61523159058062682000f, 0.61038280627630948000f, + 0.60551104140432555000f, 0.60061647938386897000f, + 0.59569930449243347000f, 0.59075970185887428000f, + 0.58579785745643886000f, 0.58081395809576453000f, + 0.57580819141784534000f, 0.57078074588696737000f, + 0.56573181078361323000f, 0.56066157619733603000f, + 0.55557023301960229000f, 0.55045797293660481000f, + 0.54532498842204646000f, 0.54017147272989297000f, + 0.53499761988709726000f, 0.52980362468629483000f, + 0.52458968267846884000f, 0.51935599016558953000f, + 0.51410274419322166000f, 0.50883014254310699000f, + 0.50353838372571758000f, 0.49822766697278187000f, + 0.49289819222978409000f, 0.48755016014843605000f, + 0.48218377207912283000f, 0.47679923006332225000f, + 0.47139673682599781000f, 0.46597649576796613000f, + 0.46053871095824001000f, 0.45508358712634384000f, + 0.44961132965460660000f, 0.44412214457042926000f, + 0.43861623853852771000f, 0.43309381885315201000f, + 0.42755509343028220000f, 0.42200027079979979000f, + 0.41642956009763732000f, 0.41084317105790391000f, + 0.40524131400498986000f, 0.39962419984564679000f, + 0.39399204006104810000f, 0.38834504669882630000f, + 0.38268343236508984000f, 0.37700741021641831000f, + 0.37131719395183760000f, 0.36561299780477396000f, + 0.35989503653498828000f, 0.35416352542049051000f, + 0.34841868024943451000f, 0.34266071731199438000f, + 0.33688985339222005000f, 0.33110630575987643000f, + 0.32531029216226298000f, 0.31950203081601575000f, + 0.31368174039889157000f, 0.30784964004153498000f, + 0.30200594931922820000f, 0.29615088824362396000f, + 0.29028467725446233000f, 0.28440753721127182000f, + 0.27851968938505306000f, 0.27262135544994898000f, + 0.26671275747489842000f, 0.26079411791527557000f, + 0.25486565960451463000f, 0.24892760574572026000f, + 0.24298017990326398000f, 0.23702360599436734000f, + 0.23105810828067128000f, 0.22508391135979278000f, + 0.21910124015686977000f, 0.21311031991609136000f, + 0.20711137619221856000f, 0.20110463484209196000f, + 0.19509032201612833000f, 0.18906866414980628000f, + 0.18303988795514106000f, 0.17700422041214886000f, + 0.17096188876030136000f, 0.16491312048997009000f, + 0.15885814333386139000f, 0.15279718525844341000f, + 0.14673047445536175000f, 0.14065823933284924000f, + 0.13458070850712622000f, 0.12849811079379322000f, + 0.12241067519921628000f, 0.11631863091190488000f, + 0.11022220729388318000f, 0.10412163387205473000f, + 0.09801714032956077000f, 0.09190895649713269600f, + 0.08579731234443988000f, 0.07968243797143012600f, + 0.07356456359966745400f, 0.06744391956366410600f, + 0.06132073630220864800f, 0.05519524434969003100f, + 0.04906767432741812600f, 0.04293825693494095900f, + 0.03680722294135899100f, 0.03067480317663658100f, + 0.02454122852291226400f, 0.01840672990580482000f, + 0.01227153828571994400f, 0.00613588464915451520f, + 0.00000000000000006123f, 0.00000000000000000000f, + -0.00613588464915447530f, -0.01227153828571992500f, + -0.01840672990580482000f, -0.02454122852291228800f, + -0.03067480317663662600f, -0.03680722294135883200f, + -0.04293825693494082000f, -0.04906767432741801500f, + -0.05519524434968993400f, -0.06132073630220857800f, + -0.06744391956366405100f, -0.07356456359966742600f, + -0.07968243797143012600f, -0.08579731234443989400f, + -0.09190895649713272400f, -0.09801714032956060400f, + -0.10412163387205459000f, -0.11022220729388306000f, + -0.11631863091190475000f, -0.12241067519921620000f, + -0.12849811079379317000f, -0.13458070850712617000f, + -0.14065823933284921000f, -0.14673047445536175000f, + -0.15279718525844344000f, -0.15885814333386145000f, + -0.16491312048996989000f, -0.17096188876030122000f, + -0.17700422041214875000f, -0.18303988795514095000f, + -0.18906866414980619000f, -0.19509032201612825000f, + -0.20110463484209190000f, -0.20711137619221856000f, + -0.21311031991609136000f, -0.21910124015686980000f, + -0.22508391135979283000f, -0.23105810828067111000f, + -0.23702360599436720000f, -0.24298017990326387000f, + -0.24892760574572015000f, -0.25486565960451457000f, + -0.26079411791527551000f, -0.26671275747489837000f, + -0.27262135544994898000f, -0.27851968938505306000f, + -0.28440753721127188000f, -0.29028467725446233000f, + -0.29615088824362379000f, -0.30200594931922808000f, + -0.30784964004153487000f, -0.31368174039889152000f, + -0.31950203081601569000f, -0.32531029216226293000f, + -0.33110630575987643000f, -0.33688985339222005000f, + -0.34266071731199438000f, -0.34841868024943456000f, + -0.35416352542049034000f, -0.35989503653498811000f, + -0.36561299780477385000f, -0.37131719395183754000f, + -0.37700741021641826000f, -0.38268343236508978000f, + -0.38834504669882625000f, -0.39399204006104810000f, + -0.39962419984564679000f, -0.40524131400498986000f, + -0.41084317105790391000f, -0.41642956009763715000f, + -0.42200027079979968000f, -0.42755509343028208000f, + -0.43309381885315196000f, -0.43861623853852766000f, + -0.44412214457042920000f, -0.44961132965460654000f, + -0.45508358712634384000f, -0.46053871095824001000f, + -0.46597649576796618000f, -0.47139673682599764000f, + -0.47679923006332209000f, -0.48218377207912272000f, + -0.48755016014843600000f, -0.49289819222978404000f, + -0.49822766697278187000f, -0.50353838372571758000f, + -0.50883014254310699000f, -0.51410274419322166000f, + -0.51935599016558964000f, -0.52458968267846895000f, + -0.52980362468629461000f, -0.53499761988709715000f, + -0.54017147272989285000f, -0.54532498842204646000f, + -0.55045797293660481000f, -0.55557023301960218000f, + -0.56066157619733603000f, -0.56573181078361312000f, + -0.57078074588696726000f, -0.57580819141784534000f, + -0.58081395809576453000f, -0.58579785745643886000f, + -0.59075970185887416000f, -0.59569930449243336000f, + -0.60061647938386897000f, -0.60551104140432555000f, + -0.61038280627630948000f, -0.61523159058062682000f, + -0.62005721176328910000f, -0.62485948814238634000f, + -0.62963823891492698000f, -0.63439328416364549000f, + -0.63912444486377573000f, -0.64383154288979139000f, + -0.64851440102211244000f, -0.65317284295377676000f, + -0.65780669329707864000f, -0.66241577759017178000f, + -0.66699992230363747000f, -0.67155895484701833000f, + -0.67609270357531592000f, -0.68060099779545302000f, + -0.68508366777270036000f, -0.68954054473706683000f, + -0.69397146088965400000f, -0.69837624940897292000f, + -0.70275474445722530000f, -0.70710678118654746000f, + -0.71143219574521643000f, -0.71573082528381859000f, + -0.72000250796138165000f, -0.72424708295146689000f, + -0.72846439044822520000f, -0.73265427167241282000f, + -0.73681656887736979000f, -0.74095112535495911000f, + -0.74505778544146595000f, -0.74913639452345926000f, + -0.75318679904361241000f, -0.75720884650648446000f, + -0.76120238548426178000f, -0.76516726562245896000f, + -0.76910333764557959000f, -0.77301045336273699000f, + -0.77688846567323244000f, -0.78073722857209438000f, + -0.78455659715557524000f, -0.78834642762660623000f, + -0.79210657730021239000f, -0.79583690460888346000f, + -0.79953726910790501000f, -0.80320753148064483000f, + -0.80684755354379922000f, -0.81045719825259477000f, + -0.81403632970594830000f, -0.81758481315158371000f, + -0.82110251499110465000f, -0.82458930278502529000f, + -0.82804504525775580000f, -0.83146961230254524000f, + -0.83486287498638001000f, -0.83822470555483797000f, + -0.84155497743689833000f, -0.84485356524970701000f, + -0.84812034480329712000f, -0.85135519310526520000f, + -0.85455798836540053000f, -0.85772861000027212000f, + -0.86086693863776731000f, -0.86397285612158670000f, + -0.86704624551569265000f, -0.87008699110871135000f, + -0.87309497841829009000f, -0.87607009419540660000f, + -0.87901222642863341000f, -0.88192126434835494000f, + -0.88479709843093779000f, -0.88763962040285393000f, + -0.89044872324475788000f, -0.89322430119551532000f, + -0.89596624975618511000f, -0.89867446569395382000f, + -0.90134884704602203000f, -0.90398929312344334000f, + -0.90659570451491533000f, -0.90916798309052227000f, + -0.91170603200542988000f, -0.91420975570353069000f, + -0.91667905992104270000f, -0.91911385169005777000f, + -0.92151403934204190000f, -0.92387953251128674000f, + -0.92621024213831127000f, -0.92850608047321548000f, + -0.93076696107898371000f, -0.93299279883473885000f, + -0.93518350993894750000f, -0.93733901191257496000f, + -0.93945922360218992000f, -0.94154406518302081000f, + -0.94359345816196039000f, -0.94560732538052128000f, + -0.94758559101774109000f, -0.94952818059303667000f, + -0.95143502096900834000f, -0.95330604035419375000f, + -0.95514116830577067000f, -0.95694033573220894000f, + -0.95870347489587160000f, -0.96043051941556579000f, + -0.96212140426904158000f, -0.96377606579543984000f, + -0.96539444169768940000f, -0.96697647104485207000f, + -0.96852209427441727000f, -0.97003125319454397000f, + -0.97150389098625178000f, -0.97293995220556007000f, + -0.97433938278557586000f, -0.97570213003852857000f, + -0.97702814265775439000f, -0.97831737071962765000f, + -0.97956976568544052000f, -0.98078528040323043000f, + -0.98196386910955524000f, -0.98310548743121629000f, + -0.98421009238692903000f, -0.98527764238894122000f, + -0.98630809724459867000f, -0.98730141815785843000f, + -0.98825756773074946000f, -0.98917650996478101000f, + -0.99005821026229712000f, -0.99090263542778001000f, + -0.99170975366909953000f, -0.99247953459870997000f, + -0.99321194923479450000f, -0.99390697000235606000f, + -0.99456457073425542000f, -0.99518472667219682000f, + -0.99576741446765982000f, -0.99631261218277800000f, + -0.99682029929116567000f, -0.99729045667869021000f, + -0.99772306664419164000f, -0.99811811290014918000f, + -0.99847558057329477000f, -0.99879545620517241000f, + -0.99907772775264536000f, -0.99932238458834954000f, + -0.99952941750109314000f, -0.99969881869620425000f, + -0.99983058179582340000f, -0.99992470183914450000f, + -0.99998117528260111000f, -1.00000000000000000000f}; + +const FLOAT32 ixheaacd_twidle_tbl_48[64] = { + 1.000000000000f, 0.000000000000f, 1.000000000000f, 0.000000000000f, + 0.991444885731f, -0.130526185036f, 0.965925812721f, -0.258819043636f, + 0.965925812721f, -0.258819043636f, 0.866025388241f, -0.500000000000f, + 0.923879504204f, -0.382683426142f, 0.707106769085f, -0.707106769085f, + 0.866025388241f, -0.500000000000f, 0.500000000000f, -0.866025388241f, + 0.793353319168f, -0.608761429787f, 0.258819043636f, -0.965925812721f, + 0.707106769085f, -0.707106769085f, 0.000000000000f, -1.000000000000f, + 0.608761429787f, -0.793353319168f, -0.258819043636f, -0.965925812721f, + 0.500000000000f, -0.866025388241f, -0.500000000000f, -0.866025388241f, + 0.382683426142f, -0.923879504204f, -0.707106769085f, -0.707106769085f, + 0.258819043636f, -0.965925812721f, -0.866025388241f, -0.500000000000f, + 0.130526185036f, -0.991444885731f, -0.965925812721f, -0.258819043636f, + 0.000000000000f, -1.000000000000f, -1.000000000000f, -0.000000000000f, + -0.130526185036f, -0.991444885731f, -0.965925812721f, 0.258819043636f, + -0.258819043636f, -0.965925812721f, -0.866025388241f, 0.500000000000f, + -0.382683426142f, -0.923879504204f, -0.707106769085f, 0.707106769085f}; + +const FLOAT32 ixheaacd_twidle_tbl_24[32] = { + 1.000000000000f, 0.000000000000f, 1.000000000000f, 0.000000000000f, + 0.965925812721f, -0.258819043636f, 0.866025388241f, -0.500000000000f, + 0.866025388241f, -0.500000000000f, 0.500000000000f, -0.866025388241f, + 0.707106769085f, -0.707106769085f, 0.000000000000f, -1.000000000000f, + 0.500000000000f, -0.866025388241f, -0.500000000000f, -0.866025388241f, + 0.258819043636f, -0.965925812721f, -0.866025388241f, -0.500000000000f, + 0.000000000000f, -1.000000000000f, -1.000000000000f, -0.000000000000f, + -0.258819043636f, -0.965925812721f, -0.866025388241f, 0.500000000000f}; + +const FLOAT32 ixheaacd_sel_case[5][8] = {{1, -1, 1, 1, 1, 1, -1, 1}, + {1, 1, -1, 1, 1, -1, 1, 1}, + {-1, 1, -1, -1, -1, -1, 1, -1}, + {-1, -1, 1, -1, -1, 1, -1, -1}, + {1, -1, 1, 1, 1, 1, -1, 1}}; \ No newline at end of file diff --git a/decoder/ixheaacd_esbr_rom.h b/decoder/ixheaacd_esbr_rom.h new file mode 100644 index 0000000..de93bab --- /dev/null +++ b/decoder/ixheaacd_esbr_rom.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_ESBR_ROM_H +#define IXHEAACD_ESBR_ROM_H + +extern const FLOAT32 ixheaacd_sub_samp_qmf_window_coeff[40 + 80 + 120 + 160 + + 200 + 240 + 320 + 400]; +extern const FLOAT32 ixheaacd_random_phase[512][2]; +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]; +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]; + +extern const FLOAT32 ixheaacd_phase_vocoder_cos_table[64]; +extern const FLOAT32 ixheaacd_phase_vocoder_sin_table[64]; +extern const FLOAT32 ixheaacd_hbe_post_anal_proc_interp_coeff[4][2]; + +extern const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_2[2 * (128 + 128)]; +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_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_sel_case[4][8]; +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_ext_ch_ele.c b/decoder/ixheaacd_ext_ch_ele.c new file mode 100644 index 0000000..b403456 --- /dev/null +++ b/decoder/ixheaacd_ext_ch_ele.c @@ -0,0 +1,911 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include + +#include "ixheaacd_cnst.h" + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_interface.h" +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_tns_usac.h" + +#include "ixheaacd_bit_extract.h" + +#include "ixheaacd_constants.h" +#include +#include +#include + +#include "ixheaacd_func_def.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_windows.h" + +#include "ixheaacd_vec_baisc_ops.h" +#include "ixheaacd_config.h" + +const WORD16 ixheaacd_mdst_fcoeff_long_sin[] = {0, 0, -16384, 0, 16384, 0, 0}; +const WORD16 ixheaacd_mdst_fcoeff_long_kbd[] = {-2998, 0, -19052, 0, + 19052, 0, 2998}; +const WORD16 ixheaacd_mdst_fcoeff_long_sin_kbd[] = {-1499, -1876, -17718, 0, + 17718, 1876, 1499}; +const WORD16 ixheaacd_mdst_fcoeff_long_kbd_sin[] = {-1499, 1876, -17718, 0, + 17718, -1876, 1499}; + +const WORD16 *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}}; + +const WORD16 ixheaacd_mdst_fcoeff_start_sin[] = {-3364, -3401, -18584, 0, + 18584, 3401, 3364}; +const WORD16 ixheaacd_mdst_fcoeff_start_kbd[] = {-4932, -1572, -19942, 0, + 19942, 1572, 4932}; +const WORD16 ixheaacd_mdst_fcoeff_start_sin_kbd[] = {-3433, -3447, -18608, 0, + 18608, 3447, 3433}; +const WORD16 ixheaacd_mdst_fcoeff_start_kbd_sin[] = {-4863, -1525, -19918, 0, + 19918, 1525, 4863}; + +const WORD16 *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}}; + +const WORD16 ixheaacd_mdst_fcoeff_stop_sin[] = {-3364, 3401, -18584, 0, + 18584, -3401, 3364}; +const WORD16 ixheaacd_mdst_fcoeff_stop_kbd[] = {-4932, 1572, -19942, 0, + 19942, -1572, 4932}; +const WORD16 ixheaacd_mdst_fcoeff_stop_sin_kbd[] = {-4863, 1525, -19918, 0, + 19918, -1525, 4863}; +const WORD16 ixheaacd_mdst_fcoeff_stop_kbd_sin[] = {-3433, 3447, -18608, 0, + 18608, -3447, 3433}; + +const WORD16 *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}}; + +const WORD16 ixheaacd_mdst_fcoeff_stopstart_sin[] = {-6728, 0, -20785, 0, + 20785, 0, 6728}; +const WORD16 ixheaacd_mdst_fcoeff_stopstart_kbd[] = {-6866, -0, -20831, 0, + 20831, 0, 6866}; +const WORD16 ixheaacd_mdst_fcoeff_stopstart_sin_kbd[] = {-6797, -46, -20808, 0, + 20808, 46, 6797}; +const WORD16 ixheaacd_mdst_fcoeff_stopstart_kbd_sin[] = {-6797, 46, -20808, 0, + 20808, 46, 6797}; + +const WORD16 *ixheaacd_mdst_fcoeff_stopstart_cur[2][2] = { + {ixheaacd_mdst_fcoeff_stopstart_sin, + ixheaacd_mdst_fcoeff_stopstart_sin_kbd}, + {ixheaacd_mdst_fcoeff_stopstart_kbd_sin, + ixheaacd_mdst_fcoeff_stopstart_kbd}}; + +const WORD16 ixheaacd_mdst_fcoeff_l_s_start_left_sin[] = { + -0, 3477, 8192, 10430, 8192, 3477, -0}; +const WORD16 ixheaacd_mdst_fcoeff_l_s_start_left_kbd[] = { + 1950, 4054, 6114, 6982, 6114, 4054, 1950}; + +const WORD16 ixheaacd_mdst_fcoeff_stop_stopstart_left_sin[] = { + 1262, 1285, 1299, 1304, 1299, 1285, 1262}; +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] = { + 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] = { + ixheaacd_mdst_fcoeff_stop_stopstart_left_sin, + ixheaacd_mdst_fcoeff_stop_stopstart_left_kbd}; + +#define ONE_BY_TWO_POW_14 0.00006103515625 +#define ONE_BY_TWO_POW_15 0.000030517578125 + +void ixheaacd_usac_cplx_save_prev(ia_sfb_info_struct *info, WORD32 *l_spec, + WORD32 *r_spec, WORD32 *l_spec_prev, + WORD32 *r_spec_prev) { + WORD32 ixheaacd_drc_offset; + + ixheaacd_drc_offset = info->samp_per_bk - info->bins_per_sbk; + + memcpy(l_spec_prev + ixheaacd_drc_offset, l_spec + ixheaacd_drc_offset, + sizeof(WORD32) * info->bins_per_sbk); + memcpy(r_spec_prev + ixheaacd_drc_offset, r_spec + ixheaacd_drc_offset, + sizeof(WORD32) * info->bins_per_sbk); +} + +static WORD32 ixheaacd_cplx_pred_data( + ia_usac_data_struct *usac_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 = + ptr_huff_code_book->pstr_huff_code_word; + WORD32 cplx_pred_all; + WORD32 delta_code_time; + WORD32 g, sfb; + WORD32 dpcm_alpha, last_alpha_q_re, last_alpha_q_im; + UWORD8 max_sfb_ste = pstr_core_coder->max_sfb_ste; + + WORD32(*alpha_q_re)[SFB_NUM_MAX] = usac_data->alpha_q_re; + WORD32(*alpha_q_im)[SFB_NUM_MAX] = usac_data->alpha_q_im; + WORD32 *alpha_q_re_prev = usac_data->alpha_q_re_prev; + WORD32 *alpha_q_im_prev = usac_data->alpha_q_im_prev; + UWORD8(*cplx_pred_used)[SFB_NUM_MAX] = usac_data->cplx_pred_used; + + cplx_pred_all = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (cplx_pred_all == 0) { + for (g = 0; g < num_window_groups; g++) { + for (sfb = 0; sfb < max_sfb_ste; sfb += SFB_PER_PRED_BAND) { + cplx_pred_used[g][sfb] = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (sfb + 1 < max_sfb_ste) + cplx_pred_used[g][sfb + 1] = cplx_pred_used[g][sfb]; + } + for (sfb = max_sfb_ste; sfb < SFB_NUM_MAX; sfb++) + cplx_pred_used[g][sfb] = 0; + } + } else { + for (g = 0; g < num_window_groups; g++) { + for (sfb = 0; sfb < max_sfb_ste; sfb++) cplx_pred_used[g][sfb] = 1; + + for (sfb = max_sfb_ste; sfb < SFB_NUM_MAX; sfb++) + cplx_pred_used[g][sfb] = 0; + } + } + + pstr_core_coder->pred_dir = ixheaacd_read_bits_buf(it_bit_buff, 1); + + pstr_core_coder->complex_coef = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->complex_coef) { + if (usac_data->usac_independency_flg) + pstr_core_coder->use_prev_frame = 0; + else + pstr_core_coder->use_prev_frame = ixheaacd_read_bits_buf(it_bit_buff, 1); + } + + if (usac_data->usac_independency_flg) + delta_code_time = 0; + else + delta_code_time = ixheaacd_read_bits_buf(it_bit_buff, 1); + + for (g = 0; g < num_window_groups; g++) { + for (sfb = 0; sfb < max_sfb_ste; sfb += SFB_PER_PRED_BAND) { + if (delta_code_time == 1) { + last_alpha_q_re = alpha_q_re_prev[sfb]; + last_alpha_q_im = alpha_q_im_prev[sfb]; + } else { + if (sfb > 0) { + last_alpha_q_re = alpha_q_re[g][sfb - 1]; + last_alpha_q_im = alpha_q_im[g][sfb - 1]; + } else { + last_alpha_q_re = last_alpha_q_im = 0; + } + } + + if (cplx_pred_used[g][sfb] == 1) { + dpcm_alpha = + -ixheaacd_huff_codeword(ptr_huff_code_word, 0, it_bit_buff) + 60; + alpha_q_re[g][sfb] = dpcm_alpha + last_alpha_q_re; + + if (pstr_core_coder->complex_coef) { + dpcm_alpha = + -ixheaacd_huff_codeword(ptr_huff_code_word, 0, it_bit_buff) + 60; + alpha_q_im[g][sfb] = dpcm_alpha + last_alpha_q_im; + } else { + alpha_q_im[g][sfb] = 0; + } + } else { + alpha_q_re[g][sfb] = 0; + alpha_q_im[g][sfb] = 0; + } + + if ((sfb + 1) < max_sfb_ste) { + alpha_q_re[g][sfb + 1] = alpha_q_re[g][sfb]; + alpha_q_im[g][sfb + 1] = alpha_q_im[g][sfb]; + } + + alpha_q_re_prev[sfb] = alpha_q_re[g][sfb]; + alpha_q_im_prev[sfb] = alpha_q_im[g][sfb]; + } + for (sfb = max_sfb_ste; sfb < SFB_NUM_MAX; sfb++) { + alpha_q_re[g][sfb] = 0; + alpha_q_im[g][sfb] = 0; + alpha_q_re_prev[sfb] = 0; + alpha_q_im_prev[sfb] = 0; + } + } + + return 1; +} + +static WORD32 ixheaacd_read_ms_mask( + ia_usac_data_struct *usac_data, + ia_usac_tmp_core_coder_struct *pstr_core_coder, + ia_bit_buf_struct *it_bit_buff, WORD32 chn) { + WORD32 g, sfb; + WORD32 ms_mask_present; + + UWORD8 *sfb_group = usac_data->group_dis[chn]; + UWORD8 max_sfb = pstr_core_coder->max_sfb_ste; + UWORD8 *ms_used = usac_data->ms_used[chn]; + ia_sfb_info_struct *info = usac_data->pstr_sfb_info[chn]; + + ms_mask_present = ixheaacd_read_bits_buf(it_bit_buff, 2); + + switch (ms_mask_present) { + case 0: + + break; + + case 1: + for (g = 0; g < info->max_win_len; g = *sfb_group++) { + for (sfb = 0; sfb < max_sfb; sfb++) { + *ms_used = ixheaacd_read_bits_buf(it_bit_buff, 1); + ms_used++; + } + for (; sfb < info->sfb_per_sbk; sfb++) { + *ms_used = 0; + ms_used++; + } + } + + break; + case 2: + for (g = 0; g < info->max_win_len; g = *sfb_group++) + for (sfb = 0; sfb < info->sfb_per_sbk; sfb++) *ms_used++ = 1; + break; + + case 3: + + ixheaacd_cplx_pred_data(usac_data, pstr_core_coder, info->num_groups, + it_bit_buff); + return 3; + } + + for (sfb = 0; sfb < SFB_NUM_MAX; sfb++) { + usac_data->alpha_q_re_prev[sfb] = 0; + usac_data->alpha_q_im_prev[sfb] = 0; + } + return ms_mask_present; +} + +VOID ixheaacd_ms_stereo(ia_usac_data_struct *usac_data, WORD32 *r_spec, + WORD32 *l_spec, WORD32 chn, WORD32 nband) { + WORD32 temp_r, temp_l; + WORD32 sfb, k, grp, grp_len; + ia_sfb_info_struct *ptr_sfb_info = usac_data->pstr_sfb_info[chn]; + UWORD8 *ms_used = usac_data->ms_used[chn]; + WORD32 ixheaacd_drc_offset = 0; + + for (grp = 0; grp < ptr_sfb_info->num_groups; grp++) { + for (grp_len = 0; grp_len < ptr_sfb_info->group_len[grp]; grp_len++) { + ixheaacd_drc_offset = 0; + for (sfb = 0; sfb < nband; sfb++) { + ixheaacd_drc_offset += ptr_sfb_info->sfb_width[sfb]; + if (ms_used[sfb]) { + for (k = 0; k < ptr_sfb_info->sfb_width[sfb]; k++) { + temp_r = *r_spec; + temp_l = *l_spec; + *l_spec = temp_r + temp_l; + *r_spec = temp_l - temp_r; + r_spec++; + l_spec++; + } + } else { + r_spec += ptr_sfb_info->sfb_width[sfb]; + l_spec += ptr_sfb_info->sfb_width[sfb]; + } + } + + l_spec = l_spec + ptr_sfb_info->bins_per_sbk - ixheaacd_drc_offset; + r_spec = r_spec + ptr_sfb_info->bins_per_sbk - ixheaacd_drc_offset; + } + + ms_used += ptr_sfb_info->sfb_per_sbk; + } +} + +static VOID ixheaacd_filter_and_add(const WORD32 *in, const WORD32 length, + const WORD16 *filter, WORD32 *out, + const WORD32 factor_even, + const WORD32 factor_odd) { + WORD32 i; + WORD64 sum; + + sum = ixheaacd_mult32x32in64(in[2], filter[0]); + sum = ixheaacd_mac32x32in64(sum, in[1], filter[1]); + sum = ixheaacd_mac32x32in64(sum, in[0], filter[2]); + sum = ixheaacd_mac32x32in64_n(sum, &in[0], &filter[3], 4); + *out += (WORD32)((sum * factor_even) >> 15); + out++; + + sum = ixheaacd_mult32x32in64(in[1], filter[0]); + sum = ixheaacd_mac32x32in64(sum, in[0], filter[1]); + sum = ixheaacd_mac32x32in64_n(sum, &in[0], &filter[2], 5); + *out += (WORD32)((sum * factor_odd) >> 15); + out++; + + sum = ixheaacd_mult32x32in64(in[0], filter[0]); + sum = ixheaacd_mac32x32in64_n(sum, &in[0], &filter[1], 6); + *out += (WORD32)((sum * factor_even) >> 15); + out++; + + for (i = 3; i < length - 4; i += 2) { + sum = 0; + sum = ixheaacd_mac32x32in64_7(sum, &in[i - 3], filter); + *out += (WORD32)((sum * factor_odd) >> 15); + out++; + + sum = 0; + sum = ixheaacd_mac32x32in64_7(sum, &in[i - 2], filter); + *out += (WORD32)((sum * factor_even) >> 15); + out++; + } + i = length - 3; + sum = 0; + sum = ixheaacd_mac32x32in64_n(sum, &in[i - 3], filter, 6); + sum = ixheaacd_mac32x32in64(sum, in[i + 2], filter[6]); + *out += (WORD32)((sum * factor_odd) >> 15); + + out++; + i = length - 2; + sum = 0; + sum = ixheaacd_mac32x32in64_n(sum, &in[i - 3], filter, 5); + sum = ixheaacd_mac32x32in64(sum, in[i + 1], filter[5]); + sum = ixheaacd_mac32x32in64(sum, in[i], filter[6]); + + *out += (WORD32)((sum * factor_even) >> 15); + out++; + + i = length - 1; + sum = 0; + sum = ixheaacd_mac32x32in64_n(sum, &in[i - 3], filter, 4); + sum = ixheaacd_mac32x32in64(sum, in[i], filter[4]); + sum = ixheaacd_mac32x32in64(sum, in[i - 1], filter[5]); + sum = ixheaacd_mac32x32in64(sum, in[i - 2], filter[6]); + + *out += (WORD32)((sum * factor_odd) >> 15); +} + +static WORD32 ixheaacd_estimate_dmx_im(const WORD32 *dmx_re, + const WORD32 *dmx_re_prev, + WORD32 *dmx_im, + ia_sfb_info_struct *pstr_sfb_info, + WORD32 window, const WORD32 w_shape, + const WORD32 prev_w_shape) { + WORD32 i; + const WORD16 *mdst_fcoeff_curr, *mdst_fcoeff_prev; + WORD32 err = 0; + + switch (window) { + case ONLY_LONG_SEQUENCE: + case EIGHT_SHORT_SEQUENCE: + mdst_fcoeff_curr = + ixheaacd_mdst_fcoeff_longshort_curr[prev_w_shape][w_shape]; + mdst_fcoeff_prev = ixheaacd_mdst_fcoeff_l_s_start_left_prev[prev_w_shape]; + break; + case LONG_START_SEQUENCE: + mdst_fcoeff_curr = ixheaacd_mdst_fcoeff_start_curr[prev_w_shape][w_shape]; + mdst_fcoeff_prev = ixheaacd_mdst_fcoeff_l_s_start_left_prev[prev_w_shape]; + break; + case LONG_STOP_SEQUENCE: + mdst_fcoeff_curr = ixheaacd_mdst_fcoeff_stop_cur[prev_w_shape][w_shape]; + mdst_fcoeff_prev = + ixheaacd_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape]; + break; + case STOP_START_SEQUENCE: + mdst_fcoeff_curr = + ixheaacd_mdst_fcoeff_stopstart_cur[prev_w_shape][w_shape]; + mdst_fcoeff_prev = + ixheaacd_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape]; + break; + default: + mdst_fcoeff_curr = + ixheaacd_mdst_fcoeff_stopstart_cur[prev_w_shape][w_shape]; + mdst_fcoeff_prev = + ixheaacd_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape]; + break; + } + + for (i = 0; i < pstr_sfb_info->max_win_len; i++) { + ixheaacd_filter_and_add(dmx_re, pstr_sfb_info->bins_per_sbk, + mdst_fcoeff_curr, dmx_im, 1, 1); + + if (dmx_re_prev) + ixheaacd_filter_and_add(dmx_re_prev, pstr_sfb_info->bins_per_sbk, + mdst_fcoeff_prev, dmx_im, -1, 1); + + dmx_re_prev = dmx_re; + dmx_re += pstr_sfb_info->bins_per_sbk; + dmx_im += pstr_sfb_info->bins_per_sbk; + } + return err; +} + +static WORD32 ixheaacd_cplx_pred_upmixing( + ia_usac_data_struct *usac_data, WORD32 *l_spec, WORD32 *r_spec, + ia_usac_tmp_core_coder_struct *pstr_core_coder, WORD32 chn) { + ia_sfb_info_struct *pstr_sfb_info = usac_data->pstr_sfb_info[chn]; + WORD32 *dmx_re = &usac_data->scratch_buffer[0]; + WORD32 *dmx_im = &usac_data->x_ac_dec[0]; + + WORD32 grp, sfb, grp_len, i = 0, k; + WORD32 *dmx_re_prev = usac_data->dmx_re_prev; + const WORD32(*alpha_q_re)[SFB_NUM_MAX] = usac_data->alpha_q_re; + const WORD32(*alpha_q_im)[SFB_NUM_MAX] = usac_data->alpha_q_im; + WORD32 err = 0; + + UWORD8(*cplx_pred_used)[SFB_NUM_MAX] = usac_data->cplx_pred_used; + + WORD32 alpha_q_re_temp; + WORD32 alpha_q_im_temp; + WORD32 factor = 1; + + if (pstr_core_coder->pred_dir) factor = -1; + + for (grp = 0; grp < pstr_sfb_info->num_groups; grp++) { + for (grp_len = 0; grp_len < pstr_sfb_info->group_len[grp]; grp_len++) { + for (sfb = 0; sfb < pstr_sfb_info->sfb_per_sbk; sfb++) { + if (cplx_pred_used[grp][sfb] == 1) { + memcpy(&dmx_re[i], &l_spec[i], + pstr_sfb_info->sfb_width[sfb] * sizeof(WORD32)); + i += pstr_sfb_info->sfb_width[sfb]; + } + + else { + for (k = 0; k < pstr_sfb_info->sfb_width[sfb]; k++, i++) { + dmx_re[i] = (l_spec[i] + (factor * r_spec[i])) >> 1; + } + } + } + } + } + + memset(dmx_im, 0, sizeof(WORD32) * BLOCK_LEN_LONG); + + if (pstr_core_coder->complex_coef) { + WORD32 *p_dmx_re_prev = + pstr_core_coder->use_prev_frame ? dmx_re_prev : NULL; + err = ixheaacd_estimate_dmx_im(dmx_re, p_dmx_re_prev, dmx_im, pstr_sfb_info, + usac_data->window_sequence[chn], + usac_data->window_shape[chn], + usac_data->window_shape_prev[chn]); + if (err == -1) return err; + + for (grp = 0, i = 0; grp < pstr_sfb_info->num_groups; grp++) { + for (grp_len = 0; grp_len < pstr_sfb_info->group_len[grp]; grp_len++) { + for (sfb = 0; sfb < pstr_sfb_info->sfb_per_sbk; sfb++) { + alpha_q_re_temp = alpha_q_re[grp][sfb] * 1677722; + alpha_q_im_temp = alpha_q_im[grp][sfb] * 1677722; + if (cplx_pred_used[grp][sfb]) { + for (k = 0; k < pstr_sfb_info->sfb_width[sfb]; k++, i++) { + WORD32 mid_side = r_spec[i] - + (WORD32)((WORD64)ixheaacd_mult32x32in64( + alpha_q_re_temp, l_spec[i]) >> + 24) - + (WORD32)((WORD64)ixheaacd_mult32x32in64( + alpha_q_im_temp, dmx_im[i]) >> + 24); + r_spec[i] = (factor) * (l_spec[i] - mid_side); + l_spec[i] = l_spec[i] + mid_side; + } + + } else { + i += pstr_sfb_info->sfb_width[sfb]; + } + } + } + } + } else { + for (grp = 0, i = 0; grp < pstr_sfb_info->num_groups; grp++) { + for (grp_len = 0; grp_len < pstr_sfb_info->group_len[grp]; grp_len++) { + for (sfb = 0; sfb < pstr_sfb_info->sfb_per_sbk; sfb++) { + alpha_q_re_temp = alpha_q_re[grp][sfb] * 1677722; + if (cplx_pred_used[grp][sfb]) { + for (k = 0; k < pstr_sfb_info->sfb_width[sfb]; k++, i++) { + WORD32 mid_side = + r_spec[i] - (WORD32)((WORD64)ixheaacd_mult32x32in64( + alpha_q_re_temp, l_spec[i]) >> + 24); + + r_spec[i] = (factor) * (l_spec[i] - mid_side); + l_spec[i] = l_spec[i] + mid_side; + } + + } else { + i += pstr_sfb_info->sfb_width[sfb]; + } + } + } + } + } + + return err; +} + +static VOID ixheaacd_cplx_prev_mdct_dmx(ia_sfb_info_struct *pstr_sfb_info, + WORD32 *l_spec, WORD32 *r_spec, + WORD32 *dmx_re_prev, WORD32 pred_dir) { + WORD32 offs, i; + WORD32 factor = 1; + if (pred_dir) factor = -1; + + offs = pstr_sfb_info->samp_per_bk - pstr_sfb_info->bins_per_sbk; + + for (i = 0; i < pstr_sfb_info->bins_per_sbk; i++) + dmx_re_prev[i] = (WORD32)(((WORD64)l_spec[i + offs] + + ((WORD64)factor * (WORD64)r_spec[i + offs])) >> + 1); +} + +WORD32 ixheaacd_ics_info(ia_usac_data_struct *usac_data, WORD32 chn, + UWORD8 *max_sfb, ia_bit_buf_struct *it_bit_buff, + WORD32 window_sequence_last + + ) + +{ + WORD32 win; + WORD32 mask = 0x40; + + UWORD8 *scf_group_ptr = usac_data->group_dis[chn]; + + win = ixheaacd_read_bits_buf(it_bit_buff, 2); + + win = usac_data->window_sequence[chn] = + ixheaacd_win_seq_select(win, window_sequence_last); + if (win == -1) return -1; + + usac_data->pstr_sfb_info[chn] = + usac_data->pstr_usac_winmap[usac_data->window_sequence[chn]]; + + usac_data->window_shape[chn] = (WORD32)ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (usac_data->pstr_usac_winmap[win]->islong) { + *max_sfb = ixheaacd_read_bits_buf(it_bit_buff, 6); + *scf_group_ptr = 1; + + } else { + WORD32 i, scale_factor_grouping; + + *max_sfb = ixheaacd_read_bits_buf(it_bit_buff, 4); + + scale_factor_grouping = ixheaacd_read_bits_buf(it_bit_buff, 7); + + for (i = 1; i < 8; i++) { + if (!(scale_factor_grouping & mask)) *scf_group_ptr++ = i; + + mask = mask >> 1; + } + *scf_group_ptr++ = i; + + ixheaacd_calc_grp_offset(usac_data->pstr_usac_winmap[win], + &usac_data->group_dis[chn][0]); + } + + if (*max_sfb > usac_data->pstr_sfb_info[chn]->sfb_per_sbk) { + *max_sfb = usac_data->pstr_sfb_info[chn]->sfb_per_sbk; + return 0; + } + + return 0; +} + +WORD32 ixheaacd_core_coder_data(WORD32 id, ia_usac_data_struct *usac_data, + WORD32 elem_idx, WORD32 *chan_offset, + ia_bit_buf_struct *it_bit_buff, + WORD32 nr_core_coder_channels) { + WORD32 err_code = 0; + WORD32 k = 0, ch = 0, chn, left = 0, right = 0; + + ia_usac_tmp_core_coder_struct str_tmp_core_coder; + ia_usac_tmp_core_coder_struct *pstr_core_coder = &str_tmp_core_coder; + ia_td_frame_data_struct td_frame; + + memset(&td_frame, 0, sizeof(td_frame)); + pstr_core_coder->tns_on_lr = 0; + pstr_core_coder->pred_dir = 0; + if (id != ID_USAC_LFE) { + for (ch = 0; ch < nr_core_coder_channels; ch++) + pstr_core_coder->core_mode[ch] = ixheaacd_read_bits_buf(it_bit_buff, 1); + } else { + for (ch = 0; ch < nr_core_coder_channels; ch++) + pstr_core_coder->core_mode[ch] = 0; + } + + if (nr_core_coder_channels == 2 && pstr_core_coder->core_mode[0] == 0 && + pstr_core_coder->core_mode[1] == 0) { + pstr_core_coder->tns_active = ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_core_coder->common_window = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->common_window) { + left = *chan_offset; + right = *chan_offset + 1; + + err_code = + ixheaacd_ics_info(usac_data, left, &pstr_core_coder->max_sfb[left], + it_bit_buff, usac_data->window_sequence_last[left]); + + if (err_code == -1) return err_code; + + pstr_core_coder->common_max_sfb = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->common_max_sfb == 0) { + if (usac_data->window_sequence[left] == EIGHT_SHORT_SEQUENCE) + pstr_core_coder->max_sfb[right] = + ixheaacd_read_bits_buf(it_bit_buff, 4); + else + pstr_core_coder->max_sfb[right] = + ixheaacd_read_bits_buf(it_bit_buff, 6); + } else { + pstr_core_coder->max_sfb[right] = pstr_core_coder->max_sfb[left]; + } + + pstr_core_coder->max_sfb_ste = + max(pstr_core_coder->max_sfb[left], pstr_core_coder->max_sfb[right]); + + usac_data->window_sequence[right] = usac_data->window_sequence[left]; + usac_data->window_shape[right] = usac_data->window_shape[left]; + memcpy(&usac_data->group_dis[right][0], &usac_data->group_dis[left][0], + 8); + usac_data->pstr_sfb_info[right] = usac_data->pstr_sfb_info[left]; + if (pstr_core_coder->max_sfb[right] > + usac_data->pstr_sfb_info[right]->sfb_per_sbk) + pstr_core_coder->max_sfb[right] = + usac_data->pstr_sfb_info[right]->sfb_per_sbk; + + pstr_core_coder->ms_mask_present[0] = + ixheaacd_read_ms_mask(usac_data, pstr_core_coder, it_bit_buff, left); + } else { + left = *chan_offset; + right = *chan_offset + 1; + + pstr_core_coder->ms_mask_present[0] = 0; + pstr_core_coder->ms_mask_present[1] = 0; + + for (k = 0; k < SFB_NUM_MAX; k++) { + usac_data->alpha_q_re_prev[k] = 0; + usac_data->alpha_q_im_prev[k] = 0; + } + } + + if (usac_data->tw_mdct[elem_idx] == 1) { + pstr_core_coder->common_tw = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->common_tw == 1) { + usac_data->tw_data_present[left] = + ixheaacd_read_bits_buf(it_bit_buff, 1); + usac_data->tw_data_present[right] = usac_data->tw_data_present[left]; + if (usac_data->tw_data_present[left]) { + for (k = 0; k < NUM_TW_NODES; k++) { + usac_data->tw_ratio[left][k] = + ixheaacd_read_bits_buf(it_bit_buff, 3); + usac_data->tw_ratio[right][k] = usac_data->tw_ratio[left][k]; + } + } + } + } + + if (pstr_core_coder->tns_active) { + if (pstr_core_coder->common_window) { + pstr_core_coder->common_tns = ixheaacd_read_bits_buf(it_bit_buff, 1); + + } else { + pstr_core_coder->common_tns = 0; + } + + pstr_core_coder->tns_on_lr = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->common_tns) { + ixheaacd_read_tns_u(usac_data->pstr_sfb_info[0], + &usac_data->pstr_tns[left][0], it_bit_buff); + memcpy(&usac_data->pstr_tns[right][0], &usac_data->pstr_tns[left][0], + sizeof(ia_tns_frame_info_struct)); + + pstr_core_coder->tns_data_present[0] = 2; + pstr_core_coder->tns_data_present[1] = 2; + } else { + pstr_core_coder->tns_present_both = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_core_coder->tns_present_both) { + pstr_core_coder->tns_data_present[0] = 1; + pstr_core_coder->tns_data_present[1] = 1; + } else { + pstr_core_coder->tns_data_present[1] = + ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_core_coder->tns_data_present[0] = + 1 - pstr_core_coder->tns_data_present[1]; + } + } + } else { + pstr_core_coder->common_tns = 0; + pstr_core_coder->tns_data_present[0] = 0; + pstr_core_coder->tns_data_present[1] = 0; + } + + } else { + pstr_core_coder->common_window = 0; + pstr_core_coder->common_tw = 0; + left = *chan_offset; + right = *chan_offset; + if (nr_core_coder_channels == 2) right = *chan_offset + 1; + } + + for (ch = 0, chn = *chan_offset; ch < nr_core_coder_channels; ch++, chn++) { + if (pstr_core_coder->core_mode[ch] == 1) { + err_code = + ixheaacd_tw_buff_update(usac_data, chn, usac_data->str_tddec[chn]); + if (err_code == -1) return err_code; + + if (!usac_data->td_frame_prev[chn]) { + ixheaacd_fix2flt_data(usac_data, usac_data->str_tddec[chn], chn); + } + + for (k = 0; k < usac_data->ccfl; k++) { + usac_data->time_sample_vector[chn][k] = + (FLOAT32)((FLOAT32)usac_data->output_data_ptr[chn][k] * + (FLOAT32)(ONE_BY_TWO_POW_15)); + } + usac_data->present_chan = chn; + err_code = + ixheaacd_lpd_channel_stream(usac_data, &td_frame, it_bit_buff, + usac_data->time_sample_vector[chn]); + if (err_code == -1) return err_code; + + for (k = 0; k < usac_data->ccfl; k++) { + usac_data->output_data_ptr[chn][k] = (WORD32)( + usac_data->time_sample_vector[chn][k] * (FLOAT32)((WORD64)1 << 15)); + } + + usac_data->window_shape[chn] = WIN_SEL_0; + + ixheaacd_td_frm_dec(usac_data, chn, td_frame.mod[0]); + + for (k = 0; k < usac_data->ccfl; k++) { + usac_data->time_sample_vector[chn][k] = + (FLOAT32)((FLOAT32)usac_data->output_data_ptr[chn][k] * + (FLOAT32)(ONE_BY_TWO_POW_15)); + } + + usac_data->window_shape_prev[chn] = usac_data->window_shape[chn]; + usac_data->window_sequence_last[chn] = EIGHT_SHORT_SEQUENCE; + + } else { + memset(usac_data->coef_fix[chn], 0, + LN2 * sizeof(*usac_data->coef_fix[0])); + + if (usac_data->str_tddec[chn] && usac_data->td_frame_prev[chn]) { + ixheaacd_lpd_dec_update(usac_data->str_tddec[chn], usac_data, chn); + } + + if (id != ID_USAC_LFE) { + if ((nr_core_coder_channels == 1) || + (pstr_core_coder->core_mode[0] != pstr_core_coder->core_mode[1])) + pstr_core_coder->tns_data_present[ch] = + ixheaacd_read_bits_buf(it_bit_buff, 1); + } + + err_code = ixheaacd_fd_channel_stream( + usac_data, pstr_core_coder, &pstr_core_coder->max_sfb[ch], + usac_data->window_sequence_last[chn], chn, + usac_data->noise_filling_config[elem_idx], ch, it_bit_buff); + if (err_code == -1) return err_code; + } + } + + if (pstr_core_coder->core_mode[0] == CORE_MODE_FD && + pstr_core_coder->core_mode[1] == CORE_MODE_FD && + nr_core_coder_channels == 2) { + ixheaacd_cplx_prev_mdct_dmx( + usac_data->pstr_sfb_info[left], usac_data->coef_save[left], + usac_data->coef_save[right], usac_data->dmx_re_prev, + pstr_core_coder->pred_dir); + } + + if (pstr_core_coder->tns_on_lr == 0 && (id != ID_USAC_LFE)) { + for (ch = 0, chn = left; chn <= right; ch++, chn++) { + if (pstr_core_coder->core_mode[ch] == CORE_MODE_FD) { + ixheaacd_tns_apply( + usac_data, usac_data->coef_fix[chn], pstr_core_coder->max_sfb[ch], + usac_data->pstr_sfb_info[chn], usac_data->pstr_tns[chn]); + } + } + } + + if (nr_core_coder_channels == 2 && pstr_core_coder->core_mode[0] == 0 && + pstr_core_coder->core_mode[1] == 0) { + if (pstr_core_coder->ms_mask_present[0] == 3) { + err_code = ixheaacd_cplx_pred_upmixing( + usac_data, usac_data->coef_fix[left], usac_data->coef_fix[right], + pstr_core_coder, left); + if (err_code == -1) return err_code; + + } else if (pstr_core_coder->ms_mask_present[0] > 0) { + ixheaacd_ms_stereo( + usac_data, usac_data->coef_fix[right], usac_data->coef_fix[left], + left, pstr_core_coder->max_sfb[right] > pstr_core_coder->max_sfb[left] + ? pstr_core_coder->max_sfb[right] + : pstr_core_coder->max_sfb[left]); + } + + if (pstr_core_coder->tns_on_lr) { + for (ch = 0, chn = left; chn <= right; ch++, chn++) { + if (pstr_core_coder->core_mode[ch] == CORE_MODE_FD) { + ixheaacd_tns_apply( + usac_data, usac_data->coef_fix[chn], pstr_core_coder->max_sfb[ch], + usac_data->pstr_sfb_info[chn], usac_data->pstr_tns[chn]); + } + } + } + + ixheaacd_usac_cplx_save_prev( + usac_data->pstr_sfb_info[left], usac_data->coef_fix[left], + usac_data->coef_fix[right], usac_data->coef_save[left], + usac_data->coef_save[right]); + } + + for (ch = left; ch <= right; ch++) { + if (pstr_core_coder->core_mode[ch] == CORE_MODE_FD) { + if (usac_data->tw_mdct[elem_idx]) { + err_code = -1; + return err_code; + + } else { + err_code = ixheaacd_fd_frm_dec(usac_data, ch); + if (err_code == -1) return err_code; + + for (k = 0; k < usac_data->ccfl; k++) { + usac_data->time_sample_vector[ch][k] = + (FLOAT32)((FLOAT32)usac_data->output_data_ptr[ch][k] * + (FLOAT32)(ONE_BY_TWO_POW_15)); + } + } + + usac_data->window_shape_prev[ch] = usac_data->window_shape[ch]; + usac_data->window_sequence_last[ch] = usac_data->window_sequence[ch]; + } + } + + for (ch = 0, chn = left; chn <= right; chn++, ch++) + usac_data->td_frame_prev[chn] = pstr_core_coder->core_mode[ch]; + + return 0; +} diff --git a/decoder/ixheaacd_fft.c b/decoder/ixheaacd_fft.c new file mode 100644 index 0000000..677bcb0 --- /dev/null +++ b/decoder/ixheaacd_fft.c @@ -0,0 +1,1776 @@ +/****************************************************************************** + * * + * 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 +#include + +#include +#include "ixheaacd_interface.h" +#include "ixheaacd_constants.h" +#include +#include "ixheaacd_function_selector.h" + +extern const WORD32 ixheaacd_twiddle_table_fft_32x32[514]; +extern const WORD32 ixheaacd_twiddle_table_3pr[1155]; +extern const WORD32 ixheaacd_twiddle_table_3pi[1155]; +extern const WORD8 ixheaacd_mps_dig_rev[16]; + +#define PLATFORM_INLINE __inline + +#define DIG_REV(i, m, j) \ + do { \ + unsigned _ = (i); \ + _ = ((_ & 0x33333333) << 2) | ((_ & ~0x33333333) >> 2); \ + _ = ((_ & 0x0F0F0F0F) << 4) | ((_ & ~0x0F0F0F0F) >> 4); \ + _ = ((_ & 0x00FF00FF) << 8) | ((_ & ~0x00FF00FF) >> 8); \ + (j) = _ >> (m); \ + } while (0) + +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 31); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32(WORD32 a, WORD32 b, WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 32); + + return (result << 1); +} + +VOID ixheaacd_mps_complex_fft_64_dec(WORD32 *ptr_x, WORD32 *fin_re, + WORD32 *fin_im, WORD32 nlength) { + WORD32 i, j, k, n_stages; + WORD32 h2, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + WORD32 del, nodespacing, in_loop_cnt; + WORD32 y[128]; + WORD32 npoints = nlength; + WORD32 *ptr_y = y; + const WORD32 *ptr_w; + n_stages = 30 - ixheaacd_norm32(npoints); + + n_stages = n_stages >> 1; + + ptr_w = ixheaacd_twiddle_table_fft_32x32; + + for (i = 0; i < npoints; i += 4) { + WORD32 *inp = ptr_x; + h2 = ixheaacd_mps_dig_rev[i >> 2]; + inp += (h2); + + x0r = *inp; + x0i = *(inp + 1); + inp += (npoints >> 1); + + x1r = *inp; + x1i = *(inp + 1); + inp += (npoints >> 1); + + x2r = *inp; + x2i = *(inp + 1); + inp += (npoints >> 1); + + x3r = *inp; + x3i = *(inp + 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + x3i; + x2i = x2i - x3r; + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *ptr_y++ = x0r; + *ptr_y++ = x0i; + *ptr_y++ = x2r; + *ptr_y++ = x2i; + *ptr_y++ = x1r; + *ptr_y++ = x1i; + *ptr_y++ = x3i; + *ptr_y++ = x3r; + } + ptr_y -= 2 * npoints; + del = 4; + nodespacing = 64; + in_loop_cnt = npoints >> 4; + for (i = n_stages - 1; i > 0; i--) { + const WORD32 *twiddles = ptr_w; + WORD32 *data = ptr_y; + WORD32 w1h, w2h, w3h, w1l, w2l, w3l; + WORD32 sec_loop_cnt; + + for (k = in_loop_cnt; k != 0; k--) { + x0r = (*data); + x0i = (*(data + 1)); + data += (del << 1); + + x1r = (*data); + x1i = (*(data + 1)); + data += (del << 1); + + x2r = (*data); + x2i = (*(data + 1)); + data += (del << 1); + + x3r = (*data); + x3i = (*(data + 1)); + data -= 3 * (del << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + x3i; + x2i = x2i - x3r; + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data = ptr_y + 2; + + sec_loop_cnt = (nodespacing * del); + sec_loop_cnt = (sec_loop_cnt / 4) + (sec_loop_cnt / 8) - + (sec_loop_cnt / 16) + (sec_loop_cnt / 32) - + (sec_loop_cnt / 64) + (sec_loop_cnt / 128) - + (sec_loop_cnt / 256); + j = nodespacing; + + for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w1l = *(twiddles + 2 * j + 1); + w2h = *(twiddles + 2 * (j << 1)); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3h = *(twiddles + 2 * j + 2 * (j << 1)); + w3l = *(twiddles + 2 * j + 2 * (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) - ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3l) - ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= (nodespacing * del) >> 1; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1)); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) - ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) + ixheaacd_mult32(x3i, w3l)); + x3i = -ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= sec_loop_cnt * 2; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) + ixheaacd_mult32(x2i, w2l)); + x2i = -ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) + ixheaacd_mult32(x3i, w3l)); + x3i = -ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j < nodespacing * del; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 1024); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 1023); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) + ixheaacd_mult32(x2i, w2l)); + x2i = -ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (-ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i - x3i; + x3r = x1r - (x3r << 1); + x3i = x1i + (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + nodespacing >>= 2; + del <<= 2; + in_loop_cnt >>= 2; + } + + for (i = 0; i < 2 * nlength; i += 2) { + fin_re[i] = y[i]; + fin_im[i] = y[i + 1]; + } + + return; +} + +VOID ixheaacd_complex_fft_p2_dec(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift) { + WORD32 i, j, k, n_stages; + WORD32 h2, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + WORD32 del, nodespacing, in_loop_cnt; + WORD32 not_power_4; + WORD32 npts, shift; + WORD32 dig_rev_shift; + WORD32 ptr_x[1024]; + WORD32 y[1024]; + WORD32 npoints = nlength; + WORD32 n = 0; + WORD32 *ptr_y = y; + const WORD32 *ptr_w; + dig_rev_shift = ixheaacd_norm32(npoints) + 1 - 16; + n_stages = 30 - ixheaacd_norm32(npoints); + not_power_4 = n_stages & 1; + + n_stages = n_stages >> 1; + + npts = npoints; + while (npts >> 1) { + n++; + npts = npts >> 1; + } + + if (n % 2 == 0) + shift = ((n + 4)) / 2; + else + shift = ((n + 3) / 2); + + for (i = 0; i < nlength; i++) { + ptr_x[2 * i] = (xr[i] / (1 << (shift))); + ptr_x[2 * i + 1] = (xi[i] / (1 << (shift))); + } + + if (fft_mode == -1) { + ptr_w = ixheaacd_twiddle_table_fft_32x32; + + for (i = 0; i < npoints; i += 4) { + WORD32 *inp = ptr_x; + + DIG_REV(i, dig_rev_shift, h2); + if (not_power_4) { + h2 += 1; + h2 &= ~1; + } + inp += (h2); + + x0r = *inp; + x0i = *(inp + 1); + inp += (npoints >> 1); + + x1r = *inp; + x1i = *(inp + 1); + inp += (npoints >> 1); + + x2r = *inp; + x2i = *(inp + 1); + inp += (npoints >> 1); + + x3r = *inp; + x3i = *(inp + 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + x3i; + x2i = x2i - x3r; + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *ptr_y++ = x0r; + *ptr_y++ = x0i; + *ptr_y++ = x2r; + *ptr_y++ = x2i; + *ptr_y++ = x1r; + *ptr_y++ = x1i; + *ptr_y++ = x3i; + *ptr_y++ = x3r; + } + ptr_y -= 2 * npoints; + del = 4; + nodespacing = 64; + in_loop_cnt = npoints >> 4; + for (i = n_stages - 1; i > 0; i--) { + const WORD32 *twiddles = ptr_w; + WORD32 *data = ptr_y; + WORD32 w1h, w2h, w3h, w1l, w2l, w3l; + WORD32 sec_loop_cnt; + + for (k = in_loop_cnt; k != 0; k--) { + x0r = (*data); + x0i = (*(data + 1)); + data += (del << 1); + + x1r = (*data); + x1i = (*(data + 1)); + data += (del << 1); + + x2r = (*data); + x2i = (*(data + 1)); + data += (del << 1); + + x3r = (*data); + x3i = (*(data + 1)); + data -= 3 * (del << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + x3i; + x2i = x2i - x3r; + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data = ptr_y + 2; + + sec_loop_cnt = (nodespacing * del); + sec_loop_cnt = (sec_loop_cnt / 4) + (sec_loop_cnt / 8) - + (sec_loop_cnt / 16) + (sec_loop_cnt / 32) - + (sec_loop_cnt / 64) + (sec_loop_cnt / 128) - + (sec_loop_cnt / 256); + j = nodespacing; + + for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w1l = *(twiddles + 2 * j + 1); + w2h = *(twiddles + 2 * (j << 1)); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3h = *(twiddles + 2 * j + 2 * (j << 1)); + w3l = *(twiddles + 2 * j + 2 * (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) - ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3l) - ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= (nodespacing * del) >> 1; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1)); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) - ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) + ixheaacd_mult32(x3i, w3l)); + x3i = -ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= sec_loop_cnt * 2; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) + ixheaacd_mult32(x2i, w2l)); + x2i = -ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) + ixheaacd_mult32(x3i, w3l)); + x3i = -ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j < nodespacing * del; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 1024); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 1023); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) + ixheaacd_mult32(x2i, w2l)); + x2i = -ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (-ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i - x3i; + x3r = x1r - (x3r << 1); + x3i = x1i + (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r + (x3i); + x2i = x2i - (x3r); + x3i = x2r - (x3i << 1); + x3r = x2i + (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + nodespacing >>= 2; + del <<= 2; + in_loop_cnt >>= 2; + } + if (not_power_4) { + const WORD32 *twiddles = ptr_w; + nodespacing <<= 1; + shift += 1; + + for (j = del / 2; j != 0; j--) { + WORD32 w1h = *twiddles; + WORD32 w1l = *(twiddles + 1); + WORD32 tmp; + twiddles += nodespacing * 2; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (ixheaacd_mult32(x1r, w1l) - ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + *ptr_y = (x0r) / 2 - (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 - (x1i) / 2; + ptr_y -= (del << 1); + + *ptr_y = (x0r) / 2 + (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 + (x1i) / 2; + ptr_y += 2; + } + twiddles = ptr_w; + for (j = del / 2; j != 0; j--) { + WORD32 w1h = *twiddles; + WORD32 w1l = *(twiddles + 1); + WORD32 tmp; + twiddles += nodespacing * 2; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (ixheaacd_mult32(x1r, w1h) + ixheaacd_mult32(x1i, w1l)); + x1i = -ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h); + x1r = tmp; + + *ptr_y = (x0r) / 2 - (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 - (x1i) / 2; + ptr_y -= (del << 1); + + *ptr_y = (x0r) / 2 + (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 + (x1i) / 2; + ptr_y += 2; + } + } + + } + + else { + ptr_w = ixheaacd_twiddle_table_fft_32x32; + + for (i = 0; i < npoints; i += 4) { + WORD32 *inp = ptr_x; + + DIG_REV(i, dig_rev_shift, h2); + if (not_power_4) { + h2 += 1; + h2 &= ~1; + } + inp += (h2); + + x0r = *inp; + x0i = *(inp + 1); + inp += (npoints >> 1); + + x1r = *inp; + x1i = *(inp + 1); + inp += (npoints >> 1); + + x2r = *inp; + x2i = *(inp + 1); + inp += (npoints >> 1); + + x3r = *inp; + x3i = *(inp + 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - x3i; + x2i = x2i + x3r; + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *ptr_y++ = x0r; + *ptr_y++ = x0i; + *ptr_y++ = x2r; + *ptr_y++ = x2i; + *ptr_y++ = x1r; + *ptr_y++ = x1i; + *ptr_y++ = x3i; + *ptr_y++ = x3r; + } + ptr_y -= 2 * npoints; + del = 4; + nodespacing = 64; + in_loop_cnt = npoints >> 4; + for (i = n_stages - 1; i > 0; i--) { + const WORD32 *twiddles = ptr_w; + WORD32 *data = ptr_y; + WORD32 w1h, w2h, w3h, w1l, w2l, w3l; + WORD32 sec_loop_cnt; + + for (k = in_loop_cnt; k != 0; k--) { + x0r = (*data); + x0i = (*(data + 1)); + data += (del << 1); + + x1r = (*data); + x1i = (*(data + 1)); + data += (del << 1); + + x2r = (*data); + x2i = (*(data + 1)); + data += (del << 1); + + x3r = (*data); + x3i = (*(data + 1)); + data -= 3 * (del << 1); + + x0r = x0r + x2r; + x0i = x0i + x2i; + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + x1r; + x0i = x0i + x1i; + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - x3i; + x2i = x2i + x3r; + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data = ptr_y + 2; + + sec_loop_cnt = (nodespacing * del); + sec_loop_cnt = (sec_loop_cnt / 4) + (sec_loop_cnt / 8) - + (sec_loop_cnt / 16) + (sec_loop_cnt / 32) - + (sec_loop_cnt / 64) + (sec_loop_cnt / 128) - + (sec_loop_cnt / 256); + j = nodespacing; + + for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1)); + w3h = *(twiddles + 2 * j + 2 * (j << 1)); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3l = *(twiddles + 2 * j + 2 * (j << 1) + 1); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(-ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(-ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(-ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= (nodespacing * del) >> 1; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1)); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) + 1); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(-ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h)); + x2i = ixheaacd_mac32(-ixheaacd_mult32(x2r, w2h), x2i, w2l); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) - ixheaacd_mult32(x3i, w3l)); + x3i = ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j <= sec_loop_cnt * 2; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 512); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 511); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(-ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) - ixheaacd_mult32(x2i, w2l)); + x2i = ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (ixheaacd_mult32(x3r, w3h) - ixheaacd_mult32(x3i, w3l)); + x3i = ixheaacd_mult32(x3r, w3l) + ixheaacd_mult32(x3i, w3h); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i + x3i; + x3r = x1r - (x3r << 1); + x3i = x1i - (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + for (; j < nodespacing * del; j += nodespacing) { + w1h = *(twiddles + 2 * j); + w2h = *(twiddles + 2 * (j << 1) - 512); + w3h = *(twiddles + 2 * j + 2 * (j << 1) - 1024); + w1l = *(twiddles + 2 * j + 1); + w2l = *(twiddles + 2 * (j << 1) - 511); + w3l = *(twiddles + 2 * j + 2 * (j << 1) - 1023); + + for (k = in_loop_cnt; k != 0; k--) { + WORD32 tmp; + WORD32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + data += (del << 1); + + x1r = *data; + x1i = *(data + 1); + data += (del << 1); + + x2r = *data; + x2i = *(data + 1); + data += (del << 1); + + x3r = *data; + x3i = *(data + 1); + data -= 3 * (del << 1); + + tmp = (ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(-ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + tmp = (ixheaacd_mult32(x2r, w2h) - ixheaacd_mult32(x2i, w2l)); + x2i = ixheaacd_mult32(x2r, w2l) + ixheaacd_mult32(x2i, w2h); + x2r = tmp; + + tmp = (-ixheaacd_mult32(x3r, w3l) - ixheaacd_mult32(x3i, w3h)); + x3i = ixheaacd_mac32(-ixheaacd_mult32(x3r, w3h), x3i, w3l); + x3r = tmp; + + x0r = (*data); + x0i = (*(data + 1)); + + x0r = x0r + (x2r); + x0i = x0i + (x2i); + x2r = x0r - (x2r << 1); + x2i = x0i - (x2i << 1); + x1r = x1r + x3r; + x1i = x1i - x3i; + x3r = x1r - (x3r << 1); + x3i = x1i + (x3i << 1); + + x0r = x0r + (x1r); + x0i = x0i + (x1i); + x1r = x0r - (x1r << 1); + x1i = x0i - (x1i << 1); + x2r = x2r - (x3i); + x2i = x2i + (x3r); + x3i = x2r + (x3i << 1); + x3r = x2i - (x3r << 1); + + *data = x0r; + *(data + 1) = x0i; + data += (del << 1); + + *data = x2r; + *(data + 1) = x2i; + data += (del << 1); + + *data = x1r; + *(data + 1) = x1i; + data += (del << 1); + + *data = x3i; + *(data + 1) = x3r; + data += (del << 1); + } + data -= 2 * npoints; + data += 2; + } + nodespacing >>= 2; + del <<= 2; + in_loop_cnt >>= 2; + } + if (not_power_4) { + const WORD32 *twiddles = ptr_w; + nodespacing <<= 1; + shift += 1; + for (j = del / 2; j != 0; j--) { + WORD32 w1h = *twiddles; + WORD32 w1l = *(twiddles + 1); + + WORD32 tmp; + twiddles += nodespacing * 2; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h)); + x1i = ixheaacd_mac32(-ixheaacd_mult32(x1r, w1h), x1i, w1l); + x1r = tmp; + + *ptr_y = (x0r) / 2 - (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 - (x1i) / 2; + ptr_y -= (del << 1); + + *ptr_y = (x0r) / 2 + (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 + (x1i) / 2; + ptr_y += 2; + } + twiddles = ptr_w; + for (j = del / 2; j != 0; j--) { + WORD32 w1h = *twiddles; + WORD32 w1l = *(twiddles + 1); + WORD32 tmp; + twiddles += nodespacing * 2; + + x0r = *ptr_y; + x0i = *(ptr_y + 1); + ptr_y += (del << 1); + + x1r = *ptr_y; + x1i = *(ptr_y + 1); + + tmp = (ixheaacd_mult32(x1r, w1h) - ixheaacd_mult32(x1i, w1l)); + x1i = ixheaacd_mult32(x1r, w1l) + ixheaacd_mult32(x1i, w1h); + x1r = tmp; + + *ptr_y = (x0r) / 2 - (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 - (x1i) / 2; + ptr_y -= (del << 1); + + *ptr_y = (x0r) / 2 + (x1r) / 2; + *(ptr_y + 1) = (x0i) / 2 + (x1i) / 2; + ptr_y += 2; + } + } + } + + for (i = 0; i < nlength; i++) { + xr[i] = y[2 * i]; + xi[i] = y[2 * i + 1]; + } + + *preshift = shift - *preshift; + return; +} + +static PLATFORM_INLINE void ixheaacd_complex_3point_fft(WORD32 *inp, WORD32 *op, + WORD32 sign_dir) { + WORD32 add_r, sub_r; + WORD32 add_i, sub_i; + WORD32 temp_real, temp_imag, temp; + + WORD32 p1, p2, p3, p4; + + WORD32 sinmu; + sinmu = -1859775393 * sign_dir; + + temp_real = ixheaacd_add32_sat(inp[0], inp[2]); + temp_imag = ixheaacd_add32_sat(inp[1], inp[3]); + + add_r = ixheaacd_add32_sat(inp[2], inp[4]); + add_i = ixheaacd_add32_sat(inp[3], inp[5]); + + sub_r = ixheaacd_sub32_sat(inp[2], inp[4]); + sub_i = ixheaacd_sub32_sat(inp[3], inp[5]); + + p1 = add_r >> 1; + p4 = add_i >> 1; + p2 = ixheaacd_mult32_shl(sub_i, sinmu); + p3 = ixheaacd_mult32_shl(sub_r, sinmu); + + temp = ixheaacd_sub32(inp[0], p1); + + op[0] = ixheaacd_add32_sat(temp_real, inp[4]); + op[1] = ixheaacd_add32_sat(temp_imag, inp[5]); + op[2] = ixheaacd_add32_sat(temp, p2); + op[3] = ixheaacd_sub32_sat(ixheaacd_sub32_sat(inp[1], p3), p4); + op[4] = ixheaacd_sub32_sat(temp, p2); + op[5] = ixheaacd_sub32_sat(ixheaacd_add32_sat(inp[1], p3), p4); + + return; +} + +VOID ixheaacd_complex_fft_p3(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift) { + WORD32 i, j; + WORD32 shift = 0; + WORD32 xr_3[384]; + WORD32 xi_3[384]; + WORD32 x[1024]; + WORD32 y[1024]; + WORD32 cnfac, npts; + WORD32 mpass = nlength; + WORD32 n = 0; + WORD32 *ptr_x = x; + WORD32 *ptr_y = y; + + cnfac = 0; + while (mpass % 3 == 0) { + mpass /= 3; + cnfac++; + } + npts = mpass; + + for (i = 0; i < 3 * cnfac; i++) { + for (j = 0; j < mpass; j++) { + xr_3[j] = xr[3 * j + i]; + xi_3[j] = xi[3 * j + i]; + } + + (*ixheaacd_complex_fft_p2)(xr_3, xi_3, mpass, fft_mode, &shift); + + for (j = 0; j < mpass; j++) { + xr[3 * j + i] = xr_3[j]; + xi[3 * j + i] = xi_3[j]; + } + } + + while (npts >> 1) { + n++; + npts = npts >> 1; + } + + if (n % 2 == 0) + shift = ((n + 4)) / 2; + else + shift = ((n + 5) / 2); + + *preshift = shift - *preshift + 1; + + for (i = 0; i < nlength; i++) { + ptr_x[2 * i] = (xr[i] >> 1); + ptr_x[2 * i + 1] = (xi[i] >> 1); + } + + { + const WORD32 *w1r, *w1i; + WORD32 tmp; + w1r = ixheaacd_twiddle_table_3pr; + w1i = ixheaacd_twiddle_table_3pi; + + if (fft_mode < 0) { + for (i = 0; i < nlength; i += 3) { + tmp = ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 1], (*w1i))); + ptr_x[2 * i + 1] = + ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i], (*w1i)), + ixheaacd_mult32(ptr_x[2 * i + 1], (*w1r))); + ptr_x[2 * i] = tmp; + + w1r++; + w1i++; + + tmp = ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i + 2], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 3], (*w1i))); + ptr_x[2 * i + 3] = + ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i + 2], (*w1i)), + ixheaacd_mult32(ptr_x[2 * i + 3], (*w1r))); + ptr_x[2 * i + 2] = tmp; + + w1r++; + w1i++; + + tmp = ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i + 4], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 5], (*w1i))); + ptr_x[2 * i + 5] = + ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i + 4], (*w1i)), + ixheaacd_mult32(ptr_x[2 * i + 5], (*w1r))); + ptr_x[2 * i + 4] = tmp; + + w1r += 3 * (128 / mpass - 1) + 1; + w1i += 3 * (128 / mpass - 1) + 1; + } + } + + else { + for (i = 0; i < nlength; i += 3) { + tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 1], (*w1i))); + ptr_x[2 * i + 1] = + ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i + 1], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i], (*w1i))); + ptr_x[2 * i] = tmp; + + w1r++; + w1i++; + + tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i + 2], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 3], (*w1i))); + ptr_x[2 * i + 3] = + ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i + 3], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 2], (*w1i))); + ptr_x[2 * i + 2] = tmp; + + w1r++; + w1i++; + + tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_x[2 * i + 4], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 5], (*w1i))); + ptr_x[2 * i + 5] = + ixheaacd_sub32_sat(ixheaacd_mult32(ptr_x[2 * i + 5], (*w1r)), + ixheaacd_mult32(ptr_x[2 * i + 4], (*w1i))); + ptr_x[2 * i + 4] = tmp; + + w1r += 3 * (128 / mpass - 1) + 1; + w1i += 3 * (128 / mpass - 1) + 1; + } + } + } + + for (i = 0; i < mpass; i++) { + ixheaacd_complex_3point_fft(ptr_x, ptr_y, fft_mode); + + ptr_x = ptr_x + 6; + ptr_y = ptr_y + 6; + } + + for (i = 0; i < mpass; i++) { + xr[i] = y[6 * i]; + xi[i] = y[6 * i + 1]; + } + + for (i = 0; i < mpass; i++) { + xr[mpass + i] = y[6 * i + 2]; + xi[mpass + i] = y[6 * i + 3]; + } + + for (i = 0; i < mpass; i++) { + xr[2 * mpass + i] = y[6 * i + 4]; + xi[2 * mpass + i] = y[6 * i + 5]; + } + return; +} + +VOID ixheaacd_complex_fft(WORD32 *data_r, WORD32 *data_i, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift) { + if (nlength & (nlength - 1)) { + if ((nlength != 24) && (nlength != 48) && (nlength != 96) && + (nlength != 192) && (nlength != 384)) { + printf("%d point FFT not supported", nlength); + exit(0); + } + ixheaacd_complex_fft_p3(data_r, data_i, nlength, fft_mode, preshift); + } else + (*ixheaacd_complex_fft_p2)(data_r, data_i, nlength, fft_mode, preshift); + + return; +} diff --git a/decoder/ixheaacd_freq_sca.c b/decoder/ixheaacd_freq_sca.c new file mode 100644 index 0000000..15db6fc --- /dev/null +++ b/decoder/ixheaacd_freq_sca.c @@ -0,0 +1,592 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.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 +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_env_extr.h" +#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}; + +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_get_sr_idx_2(WORD32 samplerate) { + WORD32 i; + for (i = 0; i < 12; i++) { + if (ixheaacd_samp_rate_table[i] <= samplerate) break; + } + return i; +} + +static WORD32 ixheaacd_get_sr_idx_4(WORD32 fs) { + if (92017 <= fs) return 0; + if (75132 <= fs) return 1; + if (55426 <= fs) return 2; + if (46009 <= fs) return 3; + if (42000 <= fs) return 4; + if (35777 <= fs) return 5; + if (27713 <= fs) return 6; + if (23004 <= fs) return 7; + if (18783 <= fs) return 8; + if (00000 <= fs) return 9; + return 0; +} + +static PLATFORM_INLINE WORD16 ixheaacd_get_k0( + WORD32 sr_idx, WORD16 start_freq, ia_sbr_tables_struct *ptr_sbr_tables) { + WORD32 start_min = ptr_sbr_tables->env_extr_tables_ptr->start_min[sr_idx]; + WORD32 ixheaacd_drc_offset = + ptr_sbr_tables->env_extr_tables_ptr->offset_idx[sr_idx]; + return start_min + + ptr_sbr_tables->env_extr_tables_ptr + ->ixheaacd_drc_offset[ixheaacd_drc_offset][start_freq]; +} + +WORD16 ixheaacd_calc_master_frq_bnd_tbl( + ia_freq_band_data_struct *pstr_freq_band_data, + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 k; + WORD32 fs = ptr_header_data->out_sampling_freq; + WORD16 bands; + WORD16 k0, k2, k1; + WORD32 k2_achived; + WORD32 k2_diff; + WORD32 incr; + WORD32 dk, sr_idx; + WORD16 vec_dk[MAX_OCTAVE + MAX_SECOND_REGION]; + WORD16 *vec_dk0 = &vec_dk[0]; + WORD16 *vec_dk1 = &vec_dk[MAX_OCTAVE]; + WORD16 upsamp_fac = ptr_header_data->upsamp_fac; + WORD16 *f_master_tbl = pstr_freq_band_data->f_master_tbl; + WORD16 num_mf_bands; + WORD32 usac_flag = ptr_header_data->usac_flag; + + k1 = 0; + incr = 0; + dk = 0; + + if (upsamp_fac == 4) { + fs = fs / 2; + sr_idx = ixheaacd_get_sr_idx_4(fs); + k0 = pstr_common_tables->start_band[sr_idx][ptr_header_data->start_freq]; + } else { + sr_idx = ixheaacd_get_sr_idx_2(fs); + k0 = ixheaacd_get_k0(sr_idx, ptr_header_data->start_freq, ptr_sbr_tables); + if (usac_flag && fs == 40000) { + k0 = k0 + ixheaacd_v_offset_40[ptr_header_data->start_freq]; + } + } + + if (ptr_header_data->stop_freq < 14) { + if (upsamp_fac == 4) { + k2 = pstr_common_tables->stop_band[sr_idx][ptr_header_data->stop_freq]; + k2 = (WORD16)ixheaacd_min32(64, k2); + if (fs == 20000) { + k2 = pstr_common_tables + ->stop_freq_table_fs40k_4[ptr_header_data->stop_freq]; + } + } else { + WORD32 stop_minv = ptr_sbr_tables->env_extr_tables_ptr->stop_min[sr_idx]; + k2 = (WORD16)ixheaacd_min32( + 64, stop_minv + + ptr_sbr_tables->env_extr_tables_ptr + ->stop_off[sr_idx][ptr_header_data->stop_freq]); + if (usac_flag && fs == 40000) { + k2 = pstr_common_tables + ->stop_freq_table_fs40k_2[ptr_header_data->stop_freq]; + } + } + + } else { + if (ptr_header_data->stop_freq == 14) + k2 = ixheaacd_shl16(k0, 1); + else + k2 = add_d(ixheaacd_shl16(k0, 1), k0); + } + if (k2 > NO_SYNTHESIS_CHANNELS) { + k2 = NO_SYNTHESIS_CHANNELS; + } + if (upsamp_fac == 4) { + if ((sub_d(k2, k0) > MAX_FREQ_COEFFS) || (k2 <= k0)) { + return -1; + } + if ((2 * fs == 44100) && (sub_d(k2, k0) > MAX_FREQ_COEFFS)) { + return -1; + } + if ((2 * fs >= 48000) && (sub_d(k2, k0) > MAX_FREQ_COEFFS)) { + return -1; + } + } else { + if ((sub_d(k2, k0) > MAX_FREQ_COEFFS_SBR) || (k2 <= k0)) { + return -1; + } + if ((fs == 44100) && (sub_d(k2, k0) > MAX_FREQ_COEFFS_FS44100)) { + return -1; + } + if ((fs >= 48000) && (sub_d(k2, k0) > MAX_FREQ_COEFFS_FS48000)) { + return -1; + } + } + + if (ptr_header_data->freq_scale == 0) { + WORD16 num_bands; + if (ptr_header_data->alter_scale == 0) { + dk = 1; + num_bands = (WORD16)(k2 - k0); + num_bands = num_bands - (num_bands & 0x1); + } else { + dk = 2; + num_bands = (WORD16)((k2 - k0) + 2) >> 2; + num_bands = num_bands << 1; + } + if (num_bands < 1) { + return -1; + } + k2_achived = k0 + (num_bands << (dk - 1)); + + k2_diff = k2 - k2_achived; + + for (k = 0; k < num_bands; k++) { + vec_dk[k] = dk; + } + + if (k2_diff < 0) { + incr = 1; + k = 0; + } + if (k2_diff > 0) { + incr = -1; + k = sub_d(num_bands, 1); + } + while (k2_diff != 0) { + vec_dk[k] = vec_dk[k] - incr; + k = (WORD16)(k + incr); + k2_diff = k2_diff + incr; + } + f_master_tbl[0] = k0; + for (k = 1; k <= num_bands; k++) + f_master_tbl[k] = f_master_tbl[k - 1] + vec_dk[k - 1]; + num_mf_bands = num_bands; + } else { + WORD32 num_bands0; + WORD32 num_bands1; + + switch (ptr_header_data->freq_scale) { + case 1: + bands = 12; + break; + case 2: + bands = 10; + break; + case 3: + bands = 8; + break; + default: + bands = 8; + }; + + if ((upsamp_fac == 4) && (k0 < bands)) { + bands = ((WORD32)(k0 - (k0 & 1))); + } + + if ((WORD32)(10000 * k2) > (WORD32)(22449 * k0)) { + k1 = k0 << 1; + + num_bands0 = bands; + + num_bands1 = pstr_common_tables->log_dual_is_table[k2] - + pstr_common_tables->log_dual_is_table[k1]; + num_bands1 = bands * num_bands1; + + if (ptr_header_data->alter_scale) { + num_bands1 = num_bands1 * (0x6276); + num_bands1 = num_bands1 >> 15; + } + num_bands1 = num_bands1 + 0x1000; + + num_bands1 = num_bands1 >> 13; + num_bands1 = num_bands1 << 1; + + if (num_bands0 < 1) { + return -1; + } + + if (num_bands1 < 1) { + return -1; + } + + ixheaacd_calc_bands(vec_dk0, k0, k1, (WORD16)num_bands0); + + 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++) + f_master_tbl[k] = f_master_tbl[k - 1] + vec_dk0[k - 1]; + + ixheaacd_calc_bands(vec_dk1, k1, k2, (WORD16)num_bands1); + ixheaacd_aac_shellsort(vec_dk1, num_bands1); + + if (vec_dk1[0] < vec_dk0[num_bands0 - 1]) { + WORD16 change = vec_dk0[num_bands0 - 1] - vec_dk1[0]; + WORD16 temp = vec_dk1[num_bands1 - 1] - vec_dk1[0]; + temp = temp >> 1; + if (change > temp) { + change = temp; + } + vec_dk1[0] = vec_dk1[0] + change; + vec_dk1[num_bands1 - 1] = vec_dk1[num_bands1 - 1] - change; + ixheaacd_aac_shellsort(vec_dk1, num_bands1); + } + + f_master_tbl[num_bands0] = k1; + for (k = 1; k <= num_bands1; k++) + f_master_tbl[num_bands0 + k] = + f_master_tbl[num_bands0 + k - 1] + vec_dk1[k - 1]; + num_mf_bands = add_d(num_bands0, num_bands1); + + } else { + k1 = k2; + + num_bands0 = pstr_common_tables->log_dual_is_table[k1] - + pstr_common_tables->log_dual_is_table[k0]; + + num_bands0 = bands * num_bands0; + + num_bands0 = num_bands0 + 0x1000; + + num_bands0 = num_bands0 >> 13; + num_bands0 = num_bands0 << 1; + + if (num_bands0 < 1) { + return -1; + } + ixheaacd_calc_bands(vec_dk0, k0, k1, (WORD16)num_bands0); + 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++) + f_master_tbl[k] = f_master_tbl[k - 1] + vec_dk0[k - 1]; + + num_mf_bands = num_bands0; + } + } + if (num_mf_bands < 1) { + return -1; + } + pstr_freq_band_data->num_mf_bands = num_mf_bands; + return 0; +} + +static WORD16 ixheaacd_calc_freq_ratio(WORD16 k_start, WORD16 k_stop, + WORD16 num_bands) { + WORD32 bandfactor; + WORD32 step; + WORD32 direction; + WORD32 start; + WORD32 stop; + WORD32 temp; + WORD32 j, i; + + bandfactor = 0x3f000000L; + step = 0x20000000L; + direction = 1; + start = ixheaacd_shl32(ixheaacd_deposit16l_in32(k_start), INT_BITS - 8); + stop = ixheaacd_shl32(ixheaacd_deposit16l_in32(k_stop), INT_BITS - 8); + + i = 0; + + do { + i = i + 1; + temp = stop; + + for (j = 0; j < num_bands; j++) + temp = ixheaacd_mult16x16in32_shl(ixheaacd_extract16h(temp), + ixheaacd_extract16h(bandfactor)); + + if (temp < start) { + if (direction == 0) step = ixheaacd_shr32(step, 1); + direction = 1; + bandfactor = ixheaacd_add32_sat(bandfactor, step); + + } else { + if (direction == 1) step = ixheaacd_shr32(step, 1); + direction = 0; + bandfactor = ixheaacd_sub32_sat(bandfactor, step); + } + + if (i > 100) { + step = 0; + } + } while (step > 0); + + return ixheaacd_extract16h(bandfactor); +} + +VOID ixheaacd_calc_bands(WORD16 *diff, WORD16 start, WORD16 stop, + WORD16 num_bands) { + WORD32 i; + WORD32 previous; + WORD32 current; + WORD32 temp, exact; + WORD16 bandfactor = ixheaacd_calc_freq_ratio(start, stop, num_bands); + + previous = stop; + exact = ixheaacd_shl32_sat(ixheaacd_deposit16l_in32(stop), INT_BITS - 8); + + for (i = num_bands - 1; i >= 0; i--) { + exact = ixheaacd_mult16x16in32(ixheaacd_extract16h(exact), bandfactor); + + temp = ixheaacd_add32_sat(exact, 0x00400000); + exact = exact << 1; + + current = ixheaacd_extract16l(ixheaacd_shr32(temp, (INT_BITS - 9))); + + diff[i] = sub_d(previous, current); + previous = current; + } +} + +static VOID ixheaacd_derive_hi_lo_freq_bnd_tbls( + ia_freq_band_data_struct *pstr_freq_band_data, + ia_sbr_header_data_struct *ptr_header_data) { + WORD16 k; + WORD16 xover_band = ptr_header_data->xover_band; + WORD16 *f_master_tbl = pstr_freq_band_data->f_master_tbl + xover_band; + WORD16 *f_low_tbl = pstr_freq_band_data->freq_band_table[LOW]; + WORD16 *f_high_tbl = pstr_freq_band_data->freq_band_table[HIGH]; + WORD16 num_mf_bands = pstr_freq_band_data->num_mf_bands; + WORD16 num_lf_bands, num_hf_bands; + num_hf_bands = num_mf_bands - xover_band; + k = 0; + *f_low_tbl = *f_high_tbl = *f_master_tbl; + f_low_tbl++; + f_high_tbl++; + f_master_tbl++; + k++; + if ((num_hf_bands & 1)) { + *f_low_tbl = *f_high_tbl = *f_master_tbl; + f_high_tbl++; + f_master_tbl++; + f_low_tbl++; + k++; + } + for (; k <= num_hf_bands; k++) { + *f_high_tbl = *f_master_tbl; + f_high_tbl++; + f_master_tbl++; + k++; + + *f_low_tbl = *f_high_tbl = *f_master_tbl; + f_high_tbl++; + f_master_tbl++; + f_low_tbl++; + } + num_lf_bands = ((num_hf_bands + 1) >> 1); + + pstr_freq_band_data->num_sf_bands[LOW] = num_lf_bands; + pstr_freq_band_data->num_sf_bands[HIGH] = num_hf_bands; +} + +static WORD32 ixheaacd_int_div(WORD32 num, WORD32 den) { + if (den != 0) { + WORD32 result = 0; + WORD32 temp = 0; + while (den <= num) { + temp = 0; + while (num >= (den << (temp + 1))) { + temp++; + } + result = result + (1 << temp); + num = num - (den * (1 << temp)); + } + return result; + } else { + return 0; + } +} + +VOID ixheaacd_aac_shellsort(WORD16 *in, WORD32 n) { + WORD32 i, j; + WORD32 inc; + WORD32 v, w; + + inc = 1; + + do { + inc = (((inc << 1) + inc) + 1); + } while (inc <= n); + + do { + inc = (ixheaacd_int_div(inc, 3)); + for (i = inc; i < n; i++) { + v = in[i]; + j = i; + + while ((w = in[(j - inc)]) > v) { + in[j] = w; + j = (j - inc); + + if (j < inc) break; + } + in[j] = v; + } + + } while (inc > 1); +} + +WORD32 ixheaacd_derive_noise_freq_bnd_tbl( + ia_sbr_header_data_struct *ptr_header_data, + ixheaacd_misc_tables *pstr_common_tables, + ia_freq_band_data_struct *pstr_freq_band_data) { + WORD16 k2, kx; + WORD32 temp; + WORD32 num_lf_bands = pstr_freq_band_data->num_sf_bands[LOW]; + WORD32 num_hf_bands = pstr_freq_band_data->num_sf_bands[HIGH]; + k2 = pstr_freq_band_data->freq_band_table[HIGH][num_hf_bands]; + 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; + } else { + temp = pstr_common_tables->log_dual_is_table[k2] - + pstr_common_tables->log_dual_is_table[kx]; + temp = temp * ptr_header_data->noise_bands; + temp = temp + 0x800; + temp = temp >> 12; + 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) { + return -1; + } + { + WORD16 i_k, k; + WORD16 num, den; + WORD16 *f_noise_tbl = pstr_freq_band_data->freq_band_tbl_noise; + WORD16 *f_low_tbl = pstr_freq_band_data->freq_band_table[LOW]; + WORD32 num_nf_bands = pstr_freq_band_data->num_nf_bands; + + num = num_lf_bands; + den = num_nf_bands; + + k = 0; + *f_noise_tbl = f_low_tbl[0]; + f_noise_tbl++; + k++; + i_k = 0; + + for (; k <= num_nf_bands; k++) { + i_k = i_k + (WORD16)ixheaacd_int_div(num, den); + *f_noise_tbl = f_low_tbl[i_k]; + num = num_lf_bands - i_k; + den = den - 1; + f_noise_tbl++; + } + } + return 0; +} + +WORD32 ixheaacd_calc_frq_bnd_tbls(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 err; + WORD16 num_lf_bands, num_hf_bands, lsb, usb; + ia_freq_band_data_struct *pstr_freq_band_data = + ptr_header_data->pstr_freq_band_data; + + err = ixheaacd_calc_master_frq_bnd_tbl(pstr_freq_band_data, ptr_header_data, + ptr_sbr_tables, pstr_common_tables); + + if (err || + (ptr_header_data->xover_band > pstr_freq_band_data->num_mf_bands)) { + return -1; + } + + ixheaacd_derive_hi_lo_freq_bnd_tbls(pstr_freq_band_data, ptr_header_data); + + num_lf_bands = pstr_freq_band_data->num_sf_bands[LOW]; + num_hf_bands = pstr_freq_band_data->num_sf_bands[HIGH]; + + if ((num_lf_bands <= 0) || + (num_lf_bands > ixheaacd_shr16(MAX_FREQ_COEFFS, 1))) { + return -1; + } + + lsb = pstr_freq_band_data->freq_band_table[LOW][0]; + usb = pstr_freq_band_data->freq_band_table[LOW][num_lf_bands]; + + pstr_freq_band_data->sub_band_start = lsb; + + ptr_header_data->status = 1; + + if ((lsb > NO_ANALYSIS_CHANNELS) || (lsb >= usb)) { + return -1; + } + + if (ixheaacd_derive_noise_freq_bnd_tbl(ptr_header_data, pstr_common_tables, + pstr_freq_band_data)) { + return -1; + } + + pstr_freq_band_data->sub_band_start = lsb; + pstr_freq_band_data->sub_band_end = usb; + + return 0; +} diff --git a/decoder/ixheaacd_freq_sca.h b/decoder/ixheaacd_freq_sca.h new file mode 100644 index 0000000..a396555 --- /dev/null +++ b/decoder/ixheaacd_freq_sca.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_FREQ_SCA_H +#define IXHEAACD_FREQ_SCA_H + +VOID ixheaacd_aac_shellsort(WORD16 *in, WORD32 n); + +WORD32 ixheaacd_calc_frq_bnd_tbls(ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables); + +VOID ixheaacd_calc_bands(WORD16 *diff, WORD16 start, WORD16 stop, + WORD16 ixheaacd_num_bands); + +#endif diff --git a/decoder/ixheaacd_func_def.h b/decoder/ixheaacd_func_def.h new file mode 100644 index 0000000..d914cb1 --- /dev/null +++ b/decoder/ixheaacd_func_def.h @@ -0,0 +1,98 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_FUNC_DEF_H +#define IXHEAACD_FUNC_DEF_H + +#define restrict + +WORD32 ixheaacd_calc_idx_offset(WORD32 qn1, WORD32 qn2); + +VOID ixheaacd_qn_data(WORD32 nk_mode, WORD32 *qn, + ia_bit_buf_struct *it_bit_buff); + +VOID ixheaacd_memset(FLOAT32 *x, WORD32 n); + +VOID ixheaacd_mem_cpy(const FLOAT32 x[], FLOAT32 y[], WORD32 n); + +VOID ixheaacd_vec_add(FLOAT32 x[], FLOAT32 y[], FLOAT32 z[], WORD32 n); + +VOID ixheaacd_vec_cnst_mul(FLOAT32 a, FLOAT32 x[], FLOAT32 z[], WORD32 n); + +WORD32 ixheaacd_lpd_dec(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, + ia_td_frame_data_struct *pstr_td_frame_data, + FLOAT32 fsynth[], WORD32 first_lpd_flag, + WORD32 short_fac_flag, WORD32 bpf_control_info); + +WORD32 ixheaacd_lpd_dec_update(ia_usac_lpd_decoder_handle tddec, + ia_usac_data_struct *usac_data, WORD32 i_ch); + +VOID ixheaacd_acelp_update(ia_usac_data_struct *usac_data, FLOAT32 signal_out[], + ia_usac_lpd_decoder_handle st); + +VOID ixheaacd_init_acelp_data(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st); + +VOID ixheaacd_reset_acelp_data(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, + FLOAT32 *ptr_ola_buffer, WORD32 last_was_short, + WORD32 tw_mdct); + +WORD32 ixheaacd_acelp_alias_cnx(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 k, FLOAT32 A[], FLOAT32 stab_fac, + ia_usac_lpd_decoder_handle st); + +WORD32 ixheaacd_tcx_mdct(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 frame_index, FLOAT32 A[], WORD32 long_frame, + ia_usac_lpd_decoder_handle st); + +VOID ixheaacd_alg_vec_dequant(ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 first_lpd_flag, FLOAT32 *lsf, + WORD32 mod[]); + +VOID ixheaacd_fac_decoding(WORD32 fac_len, WORD32 k, WORD32 *fac_prm, + ia_bit_buf_struct *it_bit_buff); + +VOID ixheaacd_lpc_to_td(FLOAT32 *lpc_coeffs, WORD32 lpc_order, + FLOAT32 *mdct_gains, WORD32 lg); + +VOID ixheaacd_noise_shaping(FLOAT32 x[], WORD32 lg, WORD32 fdns_npts, + FLOAT32 old_gains[], FLOAT32 new_gains[]); +VOID ixheaacd_interpolation_lsp_params(FLOAT32 lsp_old[], FLOAT32 lsp_new[], + FLOAT32 lp_flt_coff_a[], + WORD32 nb_subfr); + +VOID ixheaacd_lpc_coef_gen(FLOAT32 lsf_old[], FLOAT32 lsf_new[], FLOAT32 a[], + WORD32 nb_subfr, WORD32 m); + +VOID ixheaacd_tw_create(VOID); + +WORD32 ixheaacd_reset_acelp_tw_data(ia_usac_data_struct *usac_data, WORD32 i, + ia_usac_lpd_decoder_handle st); + +WORD32 ixheaacd_tw_frame_process(ia_usac_data_struct *usac_data, WORD32 ch); + +VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len, + const UWORD16 *input_table, + const UWORD32 *idx_table); + +#endif diff --git a/decoder/ixheaacd_function_selector.h b/decoder/ixheaacd_function_selector.h new file mode 100644 index 0000000..99fc367 --- /dev/null +++ b/decoder/ixheaacd_function_selector.h @@ -0,0 +1,199 @@ +/****************************************************************************** + * * + * 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 _IXHEAACD_FUNCTION_SELECTOR_H_ +#define _IXHEAACD_FUNCTION_SELECTOR_H_ + +#include +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_basic_funcs.h" + +extern WORD32 (*ixheaacd_fix_div)(WORD32, WORD32); +extern VOID (*ixheaacd_covariance_matrix_calc)(WORD32 *, + ixheaacd_lpp_trans_cov_matrix *, + WORD32); +extern VOID (*ixheaacd_covariance_matrix_calc_2)( + ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, WORD16); +extern VOID (*ixheaacd_over_lap_add1)(WORD32 *, WORD32 *, WORD16 *, + const WORD16 *, WORD16, WORD16, WORD16); +extern VOID (*ixheaacd_over_lap_add2)(WORD32 *, WORD32 *, WORD32 *, + const WORD16 *, WORD16, WORD16, WORD16); + +extern VOID (*ixheaacd_decorr_filter1)(ia_ps_dec_struct *, + ia_ps_tables_struct *, WORD16 *); + +extern VOID (*ixheaacd_decorr_filter2)(ia_ps_dec_struct *, WORD32 *, WORD32 *, + WORD32 *, WORD32 *, + ia_ps_tables_struct *, WORD16 *); + +extern WORD32 (*ixheaacd_divide16_pos)(WORD32, WORD32); + +extern VOID (*ixheaacd_decorrelation)(ia_ps_dec_struct *, WORD32 *, WORD32 *, + WORD32 *, WORD32 *, + ia_ps_tables_struct *); + +extern VOID (*ixheaacd_apply_rot)(ia_ps_dec_struct *, WORD32 *, WORD32 *, + WORD32 *, WORD32 *, ia_sbr_tables_struct *, + const WORD16 *); + +extern VOID (*ixheaacd_conv_ergtoamplitudelp)(WORD32, WORD16, WORD16 *, + WORD16 *, WORD16 *, WORD16 *); + +extern VOID (*ixheaacd_conv_ergtoamplitude)(WORD32, WORD16, WORD16 *, WORD16 *, + WORD16 *, WORD16 *); + +extern VOID (*ixheaacd_adjust_scale)(WORD32 **, WORD32 **, WORD32, WORD32, + WORD32, WORD32, WORD32, FLAG); + +extern WORD16 (*ixheaacd_ixheaacd_expsubbandsamples)(WORD32 **, WORD32 **, + WORD32, WORD32, WORD32, + WORD32, FLAG); + +extern VOID (*ixheaacd_enery_calc_per_subband)(WORD32, WORD32, WORD32, WORD32, + WORD32, WORD16 *, FLAG, + ia_sbr_tables_struct *, + WORD32 *); + +extern VOID (*ixheaacd_harm_idx_zerotwolp)(WORD32 *, WORD16 *, WORD, WORD16 *, + const WORD32 *, WORD16 *, WORD, FLAG, + WORD32); + +extern VOID (*ixheaacd_tns_ar_filter_fixed)(WORD32 *, WORD32, WORD32, WORD32 *, + WORD32, WORD32, WORD); + +extern VOID (*ixheaacd_tns_ar_filter)(WORD32 *, WORD32, WORD32, WORD16 *, + WORD32, WORD32, WORD, WORD32 *); + +extern VOID (*ixheaacd_tns_parcor_lpc_convert)(WORD16 *, WORD16 *, WORD16 *, + WORD); + +extern WORD32 (*ixheaacd_calc_max_spectral_line)(WORD32 *, WORD32); + +extern VOID (*ixheaacd_post_twiddle)(WORD32[], WORD32[], + ia_aac_dec_imdct_tables_struct *, WORD); + +extern VOID (*ixheaacd_post_twid_overlap_add)(WORD16[], WORD32[], + ia_aac_dec_imdct_tables_struct *, + WORD, WORD32 *, WORD16, + const WORD16 *, WORD16); + +extern VOID (*ixheaacd_neg_shift_spec)(WORD32 *, WORD16 *, WORD16, WORD16); + +extern VOID (*ixheaacd_spec_to_overlapbuf)(WORD32 *, WORD32 *, WORD32, WORD32); + +extern VOID (*ixheaacd_overlap_buf_out)(WORD16 *, WORD32 *, WORD32, + const WORD16); + +extern VOID (*ixheaacd_overlap_out_copy)(WORD16 *, WORD32 *, WORD32 *, + const WORD16); + +extern VOID (*ixheaacd_pretwiddle_compute)(WORD32 *, WORD32 *, WORD32 *, + ia_aac_dec_imdct_tables_struct *, + WORD, WORD32); + +extern VOID (*ixheaacd_imdct_using_fft)(ia_aac_dec_imdct_tables_struct *, + WORD32, WORD32 *, WORD32 *); + +extern VOID (*ixheaacd_complex_fft_p2)(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift); + +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, + WORD32 resolution); + +extern VOID (*ixheaacd_mps_synt_post_twiddle)(WORD32 *ptr_in, WORD32 *table_re, + WORD32 *table_im, + WORD32 resolution); + +extern VOID (*ixheaacd_calc_pre_twid)(WORD32 *ptr_x, WORD32 *r_ptr, + WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_ptr, + const WORD32 *sin_ptr); + +extern VOID (*ixheaacd_calc_post_twid)(WORD32 *ptr_x, WORD32 *r_ptr, + WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_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); +extern VOID (*ixheaacd_mps_synt_out_calc)(WORD32 resolution, WORD32 *out, + WORD32 *state, + const WORD32 *filter_coeff); + +extern VOID (*ixheaacd_fft_15_ld)(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr); + +extern VOID (*ixheaacd_aac_ld_dec_rearrange)(WORD32 *ip, WORD32 *op, + WORD32 mdct_len_2, + UWORD8 *re_arr_tab); + +extern VOID (*ixheaacd_fft32x32_ld)( + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +extern VOID (*ixheaacd_fft32x32_ld2)( + ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y); + +extern WORD16 (*ixheaacd_neg_expo_inc)(WORD16 neg_expo); + +extern VOID (*ixheaacd_inv_dit_fft_8pt)(WORD32 *x, WORD32 *real, WORD32 *imag); + +extern VOID (*ixheaacd_scale_factor_process)( + WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +#endif /* _IXHEAACD_FUNCTION_SELECTOR_H_ */ diff --git a/decoder/ixheaacd_fwd_alias_cnx.c b/decoder/ixheaacd_fwd_alias_cnx.c new file mode 100644 index 0000000..749770d --- /dev/null +++ b/decoder/ixheaacd_fwd_alias_cnx.c @@ -0,0 +1,200 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_acelp_info.h" +#include "ixheaacd_td_mdct.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_windows.h" +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_func_def.h" +#include "ixheaacd_acelp_com.h" + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_m(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 31); + + return (result); +} + +static VOID ixheaacd_weighted_synthesis_filter(WORD32 *a, WORD32 *ap) { + WORD32 f; + WORD32 i; + ap[0] = a[0]; + f = IGAMMA1; + for (i = 1; i <= ORDER; i++) { + ap[i] = ixheaacd_mult32_m(f, a[i]); + f = ixheaacd_mult32_m(f, IGAMMA1); + } + return; +} + +static VOID ixheaacd_synthesis_tool(WORD32 a[], WORD32 x[], WORD32 l, + WORD32 qshift, WORD32 *preshift) { + WORD32 s; + WORD32 i, j; + + for (i = 0; i < l; i++) { + s = x[i]; + for (j = 1; j <= ORDER; j += 4) { + s -= ixheaacd_mul32_sh(a[j], x[i - j], (WORD8)(qshift)); + s -= ixheaacd_mul32_sh(a[j + 1], x[i - (j + 1)], (WORD8)(qshift)); + s -= ixheaacd_mul32_sh(a[j + 2], x[i - (j + 2)], (WORD8)(qshift)); + s -= ixheaacd_mul32_sh(a[j + 3], x[i - (j + 3)], (WORD8)(qshift)); + } + x[i] = s; + } + + (*preshift)++; + return; +} + +WORD32 ixheaacd_fwd_alias_cancel_tool( + ia_usac_data_struct *usac_data, ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 fac_length, FLOAT32 *lp_filt_coeff, WORD32 gain) { + WORD32 i; + FLOAT32 lp_filt_coeff_a[ORDER + 1]; + WORD32 qshift = 0; + WORD32 err = 0; + + WORD32 *x_in = pstr_td_frame_data->fac_data; + WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; + WORD32 *fac_signal = &usac_data->x_ac_dec[16]; + FLOAT32 fac_signal_flt[128 + 16]; + FLOAT32 *ptr_fac_signal_flt = &fac_signal_flt[16]; + WORD32 *ptr_overlap_buf = + &(usac_data->overlap_data_ptr[usac_data->present_chan] + [(usac_data->ccfl / 2) - fac_length]); + + memset(fac_signal - 16, 0, ORDER * sizeof(WORD32)); + + err = ixheaacd_acelp_mdct(x_in, fac_signal, &qshift, fac_length, ptr_scratch); + if (err == -1) return err; + + ixheaacd_lpc_coeff_wt_apply(lp_filt_coeff, lp_filt_coeff_a); + + for (i = 0; i < fac_length; i++) + ptr_fac_signal_flt[i] = + (FLOAT32)((FLOAT32)fac_signal[i] / (1 << (16 - qshift))); + + memset(ptr_fac_signal_flt - 16, 0, 16 * sizeof(FLOAT32)); + + ixheaacd_synthesis_tool_float1(lp_filt_coeff_a, ptr_fac_signal_flt, + fac_length); + + for (i = 0; i < fac_length; i++) + fac_signal[i] = (WORD32)(ptr_fac_signal_flt[i] * (1 << (16 - qshift))); + + for (i = 0; i < fac_length; i++) + ptr_overlap_buf[i] += + (WORD32)ixheaacd_mul32_sh(fac_signal[i], gain, (WORD8)(16 - qshift)); + + return err; +} + +WORD32 ixheaacd_fr_alias_cnx_fix(WORD32 *x_in, WORD32 len, WORD32 fac_length, + WORD32 *lp_filt_coeff, WORD32 *izir, + WORD32 *fac_data_out, WORD8 *qshift1, + WORD8 qshift2, WORD8 qshift3, WORD32 *preshift, + WORD32 *ptr_scratch) { + WORD32 i; + const WORD32 *sine_window; + WORD32 fac_window[2 * FAC_LENGTH]; + WORD32 lp_filt_coeff_a[ORDER + 1]; + WORD32 err = 0; + + if (fac_length == 48) { + sine_window = ixheaacd_sine_win_96; + } else if (fac_length == 64) { + sine_window = ixheaacd_sine_win_128; + } else if (fac_length == 96) { + sine_window = ixheaacd_sine_win_192; + } else { + sine_window = ixheaacd_sine_win_256; + } + if (FAC_LENGTH < fac_length) { + return -1; + } + + if (lp_filt_coeff != NULL && fac_data_out != NULL) { + memset(fac_data_out - 16, 0, ORDER * sizeof(WORD32)); + err = ixheaacd_acelp_mdct(x_in, fac_data_out, preshift, fac_length, + ptr_scratch); + if (err == -1) return err; + + ixheaacd_weighted_synthesis_filter(lp_filt_coeff, lp_filt_coeff_a); + + memset(fac_data_out + fac_length, 0, fac_length * sizeof(WORD32)); + + ixheaacd_synthesis_tool(lp_filt_coeff_a, fac_data_out, 2 * fac_length, + qshift2, preshift); + + if (izir != NULL) { + for (i = 0; i < fac_length; i++) { + fac_window[i] = ixheaacd_mult32_m( + sine_window[i], sine_window[(2 * fac_length) - 1 - i]); + fac_window[fac_length + i] = + 2147483647 - ixheaacd_mult32_m(sine_window[fac_length + i], + sine_window[fac_length + i]); + } + for (i = 0; i < fac_length; i++) { + WORD32 temp1; + WORD32 temp2; + + temp1 = ixheaacd_mul32_sh( + izir[1 + (len / 2) + i], fac_window[fac_length + i], + (char)((qshift3 - *qshift1 + 31 + (WORD8)(*preshift)))); + + temp2 = ixheaacd_mul32_sh( + izir[1 + (len / 2) - 1 - i], fac_window[fac_length - 1 - i], + (char)((qshift3 - *qshift1 + 31 + (WORD8)(*preshift)))); + + fac_data_out[i] = + ixheaacd_add32_sat3((fac_data_out[i] / 2), temp1, temp2); + + fac_data_out[fac_length + i] = (fac_data_out[fac_length + i] / 2); + } + } + } + + return err; +} diff --git a/decoder/ixheaacd_hbe_trans.c b/decoder/ixheaacd_hbe_trans.c new file mode 100644 index 0000000..656f3dd --- /dev/null +++ b/decoder/ixheaacd_hbe_trans.c @@ -0,0 +1,1580 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include + +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_common_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_freq_sca.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_pvc_dec.h" + +#include "ixheaacd_sbr_dec.h" + +#include "ixheaacd_sbrqmftrans.h" +#include "ixheaacd_qmf_poly.h" + +#include "ixheaacd_constants.h" +#include +#include + +#include "ixheaacd_esbr_rom.h" + +#define SBR_CONST_PMIN 1.0f + +static FLOAT32 *ixheaacd_map_prot_filter(WORD32 filt_length) { + switch (filt_length) { + case 4: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[0]; + break; + case 8: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[40]; + break; + case 12: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[120]; + break; + case 16: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[240]; + break; + case 20: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[400]; + break; + case 24: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[600]; + break; + case 32: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[840]; + break; + case 40: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[1160]; + break; + default: + return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[0]; + } +} + +VOID ixheaacd_qmf_hbe_data_reinit(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD16 *p_freq_band_tab[2], WORD16 *p_num_sfb, + WORD32 upsamp_4_flag) { + WORD32 synth_size, sfb, patch, stop_patch; + + if (ptr_hbe_txposer != NULL) { + ptr_hbe_txposer->start_band = p_freq_band_tab[LOW][0]; + ptr_hbe_txposer->end_band = p_freq_band_tab[LOW][p_num_sfb[LOW]]; + + ptr_hbe_txposer->synth_size = + 4 * ((ptr_hbe_txposer->start_band + 4) / 8 + 1); + ptr_hbe_txposer->k_start = + ixheaacd_start_subband2kL_tbl[ptr_hbe_txposer->start_band]; + + ptr_hbe_txposer->upsamp_4_flag = upsamp_4_flag; + + if (upsamp_4_flag) { + if (ptr_hbe_txposer->k_start + ptr_hbe_txposer->synth_size > 16) + ptr_hbe_txposer->k_start = 16 - ptr_hbe_txposer->synth_size; + } else if (ptr_hbe_txposer->core_frame_length == 768) { + if (ptr_hbe_txposer->k_start + ptr_hbe_txposer->synth_size > 24) + ptr_hbe_txposer->k_start = 24 - ptr_hbe_txposer->synth_size; + } + + memset(ptr_hbe_txposer->synth_buf, 0, 1280 * sizeof(FLOAT32)); + synth_size = ptr_hbe_txposer->synth_size; + ptr_hbe_txposer->synth_buf_offset = 18 * synth_size; + switch (synth_size) { + case 4: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_4; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_8; + ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; + ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; + break; + case 8: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_8; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_16; + ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; + ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; + break; + case 12: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_12; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_24; + ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p3; + ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p3; + break; + case 16: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_16; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_32; + ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; + ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; + break; + case 20: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_20; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_40; + break; + default: + ptr_hbe_txposer->synth_cos_tab = + (FLOAT32 *)ixheaacd_synth_cos_table_kl_4; + ptr_hbe_txposer->analy_cos_sin_tab = + (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_8; + ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; + ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; + } + + ptr_hbe_txposer->synth_wind_coeff = ixheaacd_map_prot_filter(synth_size); + + memset(ptr_hbe_txposer->analy_buf, 0, 640 * sizeof(FLOAT32)); + synth_size = 2 * ptr_hbe_txposer->synth_size; + ptr_hbe_txposer->analy_wind_coeff = ixheaacd_map_prot_filter(synth_size); + + memset(ptr_hbe_txposer->x_over_qmf, 0, MAX_NUM_PATCHES * sizeof(WORD32)); + sfb = 0; + if (upsamp_4_flag) { + stop_patch = MAX_NUM_PATCHES; + ptr_hbe_txposer->max_stretch = MAX_STRETCH; + } else { + stop_patch = MAX_STRETCH; + } + + for (patch = 1; patch <= stop_patch; patch++) { + while (sfb <= p_num_sfb[LOW] && + p_freq_band_tab[LOW][sfb] <= patch * ptr_hbe_txposer->start_band) + sfb++; + if (sfb <= p_num_sfb[LOW]) { + if ((patch * ptr_hbe_txposer->start_band - + p_freq_band_tab[LOW][sfb - 1]) <= 3) { + ptr_hbe_txposer->x_over_qmf[patch - 1] = + p_freq_band_tab[LOW][sfb - 1]; + } else { + WORD32 sfb = 0; + while (sfb <= p_num_sfb[HIGH] && + p_freq_band_tab[HIGH][sfb] <= + patch * ptr_hbe_txposer->start_band) + sfb++; + ptr_hbe_txposer->x_over_qmf[patch - 1] = + p_freq_band_tab[HIGH][sfb - 1]; + } + } else { + ptr_hbe_txposer->x_over_qmf[patch - 1] = ptr_hbe_txposer->end_band; + ptr_hbe_txposer->max_stretch = min(patch, MAX_STRETCH); + break; + } + } + } +} + +VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 num_columns, + FLOAT32 pv_qmf_buf_real[][64], + FLOAT32 pv_qmf_buf_imag[][64], + WORD32 pitch_in_bins) { + WORD32 i, qmf_band_idx; + WORD32 qmf_voc_columns = ptr_hbe_txposer->no_bins / 2; + + memcpy(ptr_hbe_txposer->ptr_input_buf, + ptr_hbe_txposer->ptr_input_buf + + ptr_hbe_txposer->no_bins * ptr_hbe_txposer->synth_size, + ptr_hbe_txposer->synth_size * sizeof(FLOAT32)); + + ixheaacd_real_synth_filt(ptr_hbe_txposer, num_columns, qmf_buf_real, + qmf_buf_imag); + + for (i = 0; i < HBE_OPER_WIN_LEN - 1; i++) { + memcpy(ptr_hbe_txposer->qmf_in_buf[i], + ptr_hbe_txposer->qmf_in_buf[i + qmf_voc_columns], + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + } + + ixheaacd_complex_anal_filt(ptr_hbe_txposer); + + for (i = 0; i < (ptr_hbe_txposer->hbe_qmf_out_len - ptr_hbe_txposer->no_bins); + i++) { + memcpy(ptr_hbe_txposer->qmf_out_buf[i], + ptr_hbe_txposer->qmf_out_buf[i + ptr_hbe_txposer->no_bins], + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + } + + for (; i < ptr_hbe_txposer->hbe_qmf_out_len; i++) { + memset(ptr_hbe_txposer->qmf_out_buf[i], 0, + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + } + + ixheaacd_hbe_post_anal_process(ptr_hbe_txposer, pitch_in_bins, + ptr_hbe_txposer->upsamp_4_flag); + + for (i = 0; i < ptr_hbe_txposer->no_bins; i++) { + for (qmf_band_idx = ptr_hbe_txposer->start_band; + qmf_band_idx < ptr_hbe_txposer->end_band; qmf_band_idx++) { + pv_qmf_buf_real[i][qmf_band_idx] = + (FLOAT32)(ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx] * + ixheaacd_phase_vocoder_cos_table[qmf_band_idx] - + ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx + 1] * + ixheaacd_phase_vocoder_sin_table[qmf_band_idx]); + + pv_qmf_buf_imag[i][qmf_band_idx] = + (FLOAT32)(ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx] * + ixheaacd_phase_vocoder_sin_table[qmf_band_idx] + + ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx + 1] * + ixheaacd_phase_vocoder_cos_table[qmf_band_idx]); + } + } +} + +VOID ixheaacd_norm_qmf_in_buf_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_band_idx) { + WORD32 i; + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * qmf_band_idx]; + FLOAT32 *norm_buf = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * qmf_band_idx]; + + for (; qmf_band_idx <= ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { + for (i = 0; i < ptr_hbe_txposer->hbe_qmf_in_len; i++) { + FLOAT32 mag_scaling_fac = 0.0f; + FLOAT32 x_r, x_i, temp; + FLOAT64 base = 1e-17; + x_r = in_buf[0]; + x_i = in_buf[1]; + + temp = x_r * x_r; + base = base + temp; + temp = x_i * x_i; + base = base + temp; + + temp = (FLOAT32)sqrt(sqrt(base)); + mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); + + mag_scaling_fac = 1 / mag_scaling_fac; + + x_r *= mag_scaling_fac; + x_i *= mag_scaling_fac; + + norm_buf[0] = x_r; + norm_buf[1] = x_i; + + in_buf += 128; + norm_buf += 128; + } + + in_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); + norm_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); + } +} + +VOID ixheaacd_norm_qmf_in_buf_2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_band_idx) { + WORD32 i; + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * qmf_band_idx]; + FLOAT32 *norm_buf = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * qmf_band_idx]; + + for (; qmf_band_idx <= ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { + for (i = 0; i < ptr_hbe_txposer->hbe_qmf_in_len; i++) { + FLOAT32 mag_scaling_fac = 0.0f; + FLOAT32 x_r, x_i, temp; + FLOAT64 base = 1e-17; + x_r = in_buf[0]; + x_i = in_buf[1]; + + temp = x_r * x_r; + base = base + temp; + temp = x_i * x_i; + base = base + x_i * x_i; + + mag_scaling_fac = (FLOAT32)(1.0f / base); + mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); + + x_r *= mag_scaling_fac; + x_i *= mag_scaling_fac; + + norm_buf[0] = x_r; + norm_buf[1] = x_i; + + in_buf += 128; + norm_buf += 128; + } + + in_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); + norm_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); + } +} + +VOID ixheaacd_hbe_xprod_proc_3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_band_idx, WORD32 qmf_col_idx, + FLOAT32 p, WORD32 pitch_in_bins_idx) { + WORD32 tr, n1, n2, max_trans_fac, max_n1, max_n2; + WORD32 k, addrshift; + WORD32 inp_band_idx = 2 * qmf_band_idx / 3; + + FLOAT64 temp_fac; + FLOAT32 max_mag_value; + FLOAT32 mag_zero_band, mag_n1_band, mag_n2_band, temp; + FLOAT32 temp_r, temp_i; + FLOAT32 mag_cmplx_gain = 1.8856f; + + FLOAT32 *qmf_in_buf_ri = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX]; + + mag_zero_band = + qmf_in_buf_ri[2 * inp_band_idx] * qmf_in_buf_ri[2 * inp_band_idx] + + qmf_in_buf_ri[2 * inp_band_idx + 1] * qmf_in_buf_ri[2 * inp_band_idx + 1]; + max_mag_value = 0; + max_n1 = max_n2 = max_trans_fac = 0; + + for (tr = 1; tr < 3; tr++) { + temp_fac = (2.0f * qmf_band_idx + 1 - tr * p) * 0.3333334; + + n1 = (WORD32)(temp_fac); + n2 = (WORD32)(temp_fac + p); + + mag_n1_band = qmf_in_buf_ri[2 * n1] * qmf_in_buf_ri[2 * n1] + + qmf_in_buf_ri[2 * n1 + 1] * qmf_in_buf_ri[2 * n1 + 1]; + mag_n2_band = qmf_in_buf_ri[2 * n2] * qmf_in_buf_ri[2 * n2] + + qmf_in_buf_ri[2 * n2 + 1] * qmf_in_buf_ri[2 * n2 + 1]; + temp = min(mag_n1_band, mag_n2_band); + + if (temp > max_mag_value) { + max_mag_value = temp; + max_trans_fac = tr; + max_n1 = n1; + max_n2 = n2; + } + } + + if (max_mag_value > mag_zero_band && max_n1 >= 0 && + max_n2 < NO_QMF_SYNTH_CHANNELS) { + FLOAT32 vec_y_r[2], vec_y_i[2], vec_o_r[2], vec_o_i[2]; + FLOAT32 coeff_real[2], coeff_imag[2]; + FLOAT32 d1, d2; + WORD32 mid_trans_fac, idx; + FLOAT64 base = 1e-17; + FLOAT32 mag_scaling_fac = 0; + FLOAT32 x_zero_band_r; + FLOAT32 x_zero_band_i; + + x_zero_band_r = 0; + x_zero_band_i = 0; + mid_trans_fac = 3 - max_trans_fac; + if (max_trans_fac == 1) { + WORD32 idx; + d1 = 0; + d2 = 1.5; + x_zero_band_r = qmf_in_buf_ri[2 * max_n1]; + x_zero_band_i = qmf_in_buf_ri[2 * max_n1 + 1]; + + idx = max_n2 & 3; + idx = (idx + 1) & 3; + coeff_real[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][0]; + coeff_imag[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][1]; + + coeff_real[1] = coeff_real[0]; + coeff_imag[1] = -coeff_imag[0]; + + vec_y_r[1] = qmf_in_buf_ri[2 * max_n2]; + vec_y_i[1] = qmf_in_buf_ri[2 * max_n2 + 1]; + + addrshift = -2; + temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + + HBE_ZERO_BAND_IDX][2 * max_n2]; + temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + + HBE_ZERO_BAND_IDX][2 * max_n2 + 1]; + + vec_y_r[0] = coeff_real[1] * temp_r - coeff_imag[1] * temp_i; + vec_y_i[0] = coeff_imag[1] * temp_r + coeff_real[1] * temp_i; + + temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + + HBE_ZERO_BAND_IDX][2 * max_n2]; + temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + + HBE_ZERO_BAND_IDX][2 * max_n2 + 1]; + + vec_y_r[0] += coeff_real[0] * temp_r - coeff_imag[0] * temp_i; + vec_y_i[0] += coeff_imag[0] * temp_r + coeff_real[0] * temp_i; + + } else { + WORD32 idx; + d1 = 1.5; + d2 = 0; + mid_trans_fac = max_trans_fac; + max_trans_fac = 3 - max_trans_fac; + + x_zero_band_r = qmf_in_buf_ri[2 * max_n2]; + x_zero_band_i = qmf_in_buf_ri[2 * max_n2 + 1]; + + idx = (max_n1 & 3); + idx = (idx + 1) & 3; + coeff_real[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][0]; + coeff_imag[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][1]; + + coeff_real[1] = coeff_real[0]; + coeff_imag[1] = -coeff_imag[0]; + + vec_y_r[1] = qmf_in_buf_ri[2 * max_n1]; + vec_y_i[1] = qmf_in_buf_ri[2 * max_n1 + 1]; + + addrshift = -2; + + temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + + HBE_ZERO_BAND_IDX][2 * max_n1]; + temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + + HBE_ZERO_BAND_IDX][2 * max_n1 + 1]; + + vec_y_r[0] = coeff_real[1] * temp_r - coeff_imag[1] * temp_i; + vec_y_i[0] = coeff_imag[1] * temp_r + coeff_real[1] * temp_i; + + temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + + HBE_ZERO_BAND_IDX][2 * max_n1]; + temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + + HBE_ZERO_BAND_IDX][2 * max_n1 + 1]; + + vec_y_r[0] += coeff_real[0] * temp_r - coeff_imag[0] * temp_i; + vec_y_i[0] += coeff_imag[0] * temp_r + coeff_real[0] * temp_i; + } + + base = 1e-17; + base = base + x_zero_band_r * x_zero_band_r; + base = base + x_zero_band_i * x_zero_band_i; + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base)); + x_zero_band_r *= mag_scaling_fac; + x_zero_band_i *= mag_scaling_fac; + for (k = 0; k < 2; k++) { + base = 1e-17; + base = base + vec_y_r[k] * vec_y_r[k]; + base = base + vec_y_i[k] * vec_y_i[k]; + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base)); + vec_y_r[k] *= mag_scaling_fac; + vec_y_i[k] *= mag_scaling_fac; + } + + temp_r = x_zero_band_r; + temp_i = x_zero_band_i; + for (idx = 0; idx < mid_trans_fac - 1; idx++) { + FLOAT32 tmp = x_zero_band_r; + x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; + x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; + } + + for (k = 0; k < 2; k++) { + temp_r = vec_y_r[k]; + temp_i = vec_y_i[k]; + for (idx = 0; idx < max_trans_fac - 1; idx++) { + FLOAT32 tmp = vec_y_r[k]; + vec_y_r[k] = vec_y_r[k] * temp_r - vec_y_i[k] * temp_i; + vec_y_i[k] = tmp * temp_i + vec_y_i[k] * temp_r; + } + } + + for (k = 0; k < 2; k++) { + vec_o_r[k] = vec_y_r[k] * x_zero_band_r - vec_y_i[k] * x_zero_band_i; + vec_o_i[k] = vec_y_r[k] * x_zero_band_i + vec_y_i[k] * x_zero_band_r; + } + + { + FLOAT32 cos_theta = + ixheaacd_hbe_x_prod_cos_table_trans_3[(pitch_in_bins_idx << 1) + 0]; + FLOAT32 sin_theta = + ixheaacd_hbe_x_prod_cos_table_trans_3[(pitch_in_bins_idx << 1) + 1]; + if (d2 < d1) { + sin_theta = -sin_theta; + } + temp_r = vec_o_r[0]; + temp_i = vec_o_i[0]; + vec_o_r[0] = (FLOAT32)(cos_theta * temp_r - sin_theta * temp_i); + vec_o_i[0] = (FLOAT32)(cos_theta * temp_i + sin_theta * temp_r); + } + + for (k = 0; k < 2; k++) { + ptr_hbe_txposer->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - + 1)][2 * qmf_band_idx] += + (FLOAT32)(mag_cmplx_gain * vec_o_r[k]); + ptr_hbe_txposer + ->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx + 1] += + (FLOAT32)(mag_cmplx_gain * vec_o_i[k]); + } + } +} + +VOID ixheaacd_hbe_xprod_proc_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_band_idx, WORD32 qmf_col_idx, + FLOAT32 p, WORD32 pitch_in_bins_idx) { + WORD32 k; + WORD32 inp_band_idx = qmf_band_idx >> 1; + WORD32 tr, n1, n2, max_trans_fac, max_n1, max_n2; + + FLOAT64 temp_fac; + FLOAT32 max_mag_value, mag_zero_band, mag_n1_band, mag_n2_band, temp; + FLOAT32 temp_r, temp_i; + FLOAT32 mag_cmplx_gain = 2.0f; + + FLOAT32 *qmf_in_buf_ri = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX]; + + mag_zero_band = + qmf_in_buf_ri[2 * inp_band_idx] * qmf_in_buf_ri[2 * inp_band_idx] + + qmf_in_buf_ri[2 * inp_band_idx + 1] * qmf_in_buf_ri[2 * inp_band_idx + 1]; + + max_mag_value = 0; + 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; + n1 = ((WORD32)(temp_fac)) << 1; + n2 = ((WORD32)(temp_fac + p)) << 1; + + mag_n1_band = qmf_in_buf_ri[n1] * qmf_in_buf_ri[n1] + + qmf_in_buf_ri[n1 + 1] * qmf_in_buf_ri[n1 + 1]; + mag_n2_band = qmf_in_buf_ri[n2] * qmf_in_buf_ri[n2] + + qmf_in_buf_ri[n2 + 1] * qmf_in_buf_ri[n2 + 1]; + + temp = min(mag_n1_band, mag_n2_band); + + if (temp > max_mag_value) { + max_mag_value = temp; + max_trans_fac = tr; + max_n1 = n1; + max_n2 = n2; + } + } + if (max_mag_value > mag_zero_band && max_n1 >= 0 && + max_n2 < TWICE_QMF_SYNTH_CHANNELS_NUM) { + FLOAT32 vec_y_r[2], vec_y_i[2], vec_o_r[2], vec_o_i[2]; + FLOAT32 d1, d2; + WORD32 mid_trans_fac, idx; + FLOAT32 x_zero_band_r; + FLOAT32 x_zero_band_i; + FLOAT64 base = 1e-17; + FLOAT32 mag_scaling_fac = 0.0f; + + x_zero_band_r = 0; + x_zero_band_i = 0; + mid_trans_fac = 4 - max_trans_fac; + + if (max_trans_fac == 1) { + d1 = 0; + d2 = 2; + x_zero_band_r = qmf_in_buf_ri[max_n1]; + x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; + for (k = 0; k < 2; k++) { + vec_y_r[k] = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + + 2 * (k - 1)][max_n2]; + vec_y_i[k] = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + + 2 * (k - 1)][max_n2 + 1]; + } + } else if (max_trans_fac == 2) { + d1 = 0; + d2 = 1; + x_zero_band_r = qmf_in_buf_ri[max_n1]; + x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; + for (k = 0; k < 2; k++) { + vec_y_r[k] = + ptr_hbe_txposer + ->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + (k - 1)][max_n2]; + vec_y_i[k] = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + + (k - 1)][max_n2 + 1]; + } + } else { + d1 = 2; + d2 = 0; + mid_trans_fac = max_trans_fac; + max_trans_fac = 4 - max_trans_fac; + x_zero_band_r = qmf_in_buf_ri[max_n2]; + x_zero_band_i = qmf_in_buf_ri[max_n2 + 1]; + for (k = 0; k < 2; k++) { + vec_y_r[k] = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + + 2 * (k - 1)][max_n1]; + vec_y_i[k] = + ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + + 2 * (k - 1)][max_n1 + 1]; + } + } + + base = 1e-17; + base = base + x_zero_band_r * x_zero_band_r; + base = base + x_zero_band_i * x_zero_band_i; + { + temp = (FLOAT32)sqrt(sqrt(base)); + mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); + mag_scaling_fac = 1 / mag_scaling_fac; + } + + x_zero_band_r *= mag_scaling_fac; + x_zero_band_i *= mag_scaling_fac; + for (k = 0; k < 2; k++) { + base = 1e-17; + base = base + vec_y_r[k] * vec_y_r[k]; + base = base + vec_y_i[k] * vec_y_i[k]; + { + temp = (FLOAT32)sqrt(sqrt(base)); + mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); + + mag_scaling_fac = 1 / mag_scaling_fac; + } + vec_y_r[k] *= mag_scaling_fac; + vec_y_i[k] *= mag_scaling_fac; + } + + temp_r = x_zero_band_r; + temp_i = x_zero_band_i; + for (idx = 0; idx < mid_trans_fac - 1; idx++) { + FLOAT32 tmp = x_zero_band_r; + x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; + x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; + } + + for (k = 0; k < 2; k++) { + temp_r = vec_y_r[k]; + temp_i = vec_y_i[k]; + for (idx = 0; idx < max_trans_fac - 1; idx++) { + FLOAT32 tmp = vec_y_r[k]; + vec_y_r[k] = vec_y_r[k] * temp_r - vec_y_i[k] * temp_i; + vec_y_i[k] = tmp * temp_i + vec_y_i[k] * temp_r; + } + } + + for (k = 0; k < 2; k++) { + vec_o_r[k] = vec_y_r[k] * x_zero_band_r - vec_y_i[k] * x_zero_band_i; + vec_o_i[k] = vec_y_r[k] * x_zero_band_i + vec_y_i[k] * x_zero_band_r; + } + + { + FLOAT32 cos_theta; + FLOAT32 sin_theta; + + if (d2 == 1) { + cos_theta = + ixheaacd_hbe_x_prod_cos_table_trans_4_1[(pitch_in_bins_idx << 1) + + 0]; + sin_theta = + ixheaacd_hbe_x_prod_cos_table_trans_4_1[(pitch_in_bins_idx << 1) + + 1]; + } else { + cos_theta = + ixheaacd_hbe_x_prod_cos_table_trans_4[(pitch_in_bins_idx << 1) + 0]; + sin_theta = + ixheaacd_hbe_x_prod_cos_table_trans_4[(pitch_in_bins_idx << 1) + 1]; + if (d2 < d1) { + sin_theta = -sin_theta; + } + } + temp_r = vec_o_r[0]; + temp_i = vec_o_i[0]; + vec_o_r[0] = (FLOAT32)(cos_theta * temp_r - sin_theta * temp_i); + vec_o_i[0] = (FLOAT32)(cos_theta * temp_i + sin_theta * temp_r); + } + + for (k = 0; k < 2; k++) { + ptr_hbe_txposer->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - + 1)][2 * qmf_band_idx] += + (FLOAT32)(mag_cmplx_gain * vec_o_r[k]); + ptr_hbe_txposer + ->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx + 1] += + (FLOAT32)(mag_cmplx_gain * vec_o_i[k]); + } + } +} + +VOID ixheaacd_hbe_post_anal_prod2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { + WORD32 i; + FLOAT32 *norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[1][2 * qmf_band_idx]; + FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[1][2 * qmf_band_idx]; + FLOAT32 *x_norm_ptr = + &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * qmf_band_idx]; + + ixheaacd_norm_qmf_in_buf_2(ptr_hbe_txposer, qmf_band_idx); + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 x_zero_band_r, x_zero_band_i; + + x_zero_band_r = *x_norm_ptr++; + x_zero_band_i = *x_norm_ptr++; + + for (k = 0; k < HBE_OPER_BLK_LEN_2; k++) { + register FLOAT32 tmp_r, tmp_i; + tmp_r = *norm_ptr++; + tmp_i = *norm_ptr++; + + *out_ptr++ += + ((tmp_r * x_zero_band_r - tmp_i * x_zero_band_i) * 0.3333333f); + + *out_ptr++ += + ((tmp_r * x_zero_band_i + tmp_i * x_zero_band_r) * 0.3333333f); + + norm_ptr += 126; + out_ptr += 126; + } + + norm_ptr -= 128 * 9; + out_ptr -= 128 * 8; + x_norm_ptr += 126; + } + out_ptr -= (128 * 2 * qmf_voc_columns) - 2; + norm_ptr -= (128 * qmf_voc_columns) - 2; + x_norm_ptr -= (128 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_prod3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { + WORD32 i, inp_band_idx, rem; + + FLOAT32 *out_buf = &ptr_hbe_txposer->qmf_out_buf[2][2 * qmf_band_idx]; + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[2]; qmf_band_idx++) { + FLOAT32 temp_r, temp_i; + FLOAT32 temp_r1, temp_i1; + const FLOAT32 *ptr_sel, *ptr_sel1; + + inp_band_idx = (2 * qmf_band_idx) / 3; + ptr_sel = &ixheaacd_sel_case[(inp_band_idx + 1) & 3][0]; + ptr_sel1 = &ixheaacd_sel_case[((inp_band_idx + 1) & 3) + 1][0]; + rem = 2 * qmf_band_idx - 3 * inp_band_idx; + + if (rem == 0 || rem == 1) { + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; + + for (i = 0; i < qmf_voc_columns; i += 1) { + WORD32 k; + FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; + FLOAT32 *ptr_vec_x = &vec_x[0]; + FLOAT32 x_zero_band_r, x_zero_band_i; + + FLOAT32 mag_scaling_fac; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { + FLOAT64 base1; + FLOAT64 base = 1e-17; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + in_buf += 256; + + base1 = base + temp_r * temp_r; + base1 = base1 + temp_i * temp_i; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[0] = temp_r * mag_scaling_fac; + ptr_vec_x[1] = temp_i * mag_scaling_fac; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + in_buf -= 128; + + temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; + temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + temp_r1 += ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; + temp_i1 += ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; + + temp_r1 *= 0.3984033437f; + temp_i1 *= 0.3984033437f; + + base1 = base + temp_r1 * temp_r1; + base1 = base1 + temp_i1 * temp_i1; + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[2] = temp_r1 * mag_scaling_fac; + ptr_vec_x[3] = temp_i1 * mag_scaling_fac; + + ptr_vec_x += 4; + in_buf += 256; + } + ptr_vec_x = &vec_x[0]; + temp_r = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i = vec_x[(2 * (HBE_ZERO_BAND_IDX - 2)) + 1]; + + x_zero_band_r = temp_r * temp_r - temp_i * temp_i; + x_zero_band_i = temp_r * temp_i + temp_i * temp_r; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { + temp_r = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; + temp_i = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; + + out_buf[0] += (temp_r * 0.4714045f); + out_buf[1] += (temp_i * 0.4714045f); + + ptr_vec_x += 2; + out_buf += 128; + } + + in_buf -= 128 * 11; + out_buf -= 128 * 6; + } + } else { + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; + FLOAT32 *in_buf1 = + &ptr_hbe_txposer->qmf_in_buf[0][2 * (inp_band_idx + 1)]; + + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; + FLOAT32 vec_x_cap[2 * HBE_OPER_WIN_LEN]; + + FLOAT32 x_zero_band_r, x_zero_band_i; + FLOAT32 *ptr_vec_x = &vec_x[0]; + FLOAT32 *ptr_vec_x_cap = &vec_x_cap[0]; + + FLOAT32 mag_scaling_fac; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { + FLOAT32 tmp_vr, tmp_vi; + FLOAT32 tmp_cr, tmp_ci; + FLOAT64 base1; + FLOAT64 base = 1e-17; + + temp_r1 = in_buf[0]; + temp_i1 = in_buf[1]; + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + base1 = base + temp_r * temp_r; + base1 = base1 + temp_i * temp_i; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[0] = temp_r * mag_scaling_fac; + ptr_vec_x[1] = temp_i * mag_scaling_fac; + + base1 = base + temp_r1 * temp_r1; + base1 = base1 + temp_i1 * temp_i1; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x_cap[0] = temp_r1 * mag_scaling_fac; + ptr_vec_x_cap[1] = temp_i1 * mag_scaling_fac; + + in_buf += 256; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; + temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; + + in_buf -= 128; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + tmp_cr = temp_r1 + ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; + tmp_ci = temp_i1 + ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; + + in_buf1 += 256; + + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + temp_r1 = ptr_sel1[0] * temp_r + ptr_sel1[1] * temp_i; + temp_i1 = ptr_sel1[2] * temp_r + ptr_sel1[3] * temp_i; + + in_buf1 -= 128; + + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + tmp_vr = temp_r1 + ptr_sel1[4] * temp_r + ptr_sel1[5] * temp_i; + tmp_vi = temp_i1 + ptr_sel1[6] * temp_r + ptr_sel1[7] * temp_i; + + tmp_cr *= 0.3984033437f; + tmp_ci *= 0.3984033437f; + + tmp_vr *= 0.3984033437f; + tmp_vi *= 0.3984033437f; + + base1 = base + tmp_vr * tmp_vr; + base1 = base1 + tmp_vi * tmp_vi; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[2] = tmp_vr * mag_scaling_fac; + ptr_vec_x[3] = tmp_vi * mag_scaling_fac; + + base1 = base + tmp_cr * tmp_cr; + base1 = base1 + tmp_ci * tmp_ci; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x_cap[2] = tmp_cr * mag_scaling_fac; + ptr_vec_x_cap[3] = tmp_ci * mag_scaling_fac; + + in_buf += 256; + in_buf1 += 256; + ptr_vec_x += 4; + ptr_vec_x_cap += 4; + } + ptr_vec_x = &vec_x[0]; + ptr_vec_x_cap = &vec_x_cap[0]; + + temp_r = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; + temp_r1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; + + x_zero_band_r = temp_r * temp_r - temp_i * temp_i; + x_zero_band_i = temp_r * temp_i + temp_i * temp_r; + + temp_r = temp_r1 * temp_r1 - temp_i1 * temp_i1; + temp_i = temp_r1 * temp_i1 + temp_i1 * temp_r1; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { + temp_r1 = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; + temp_i1 = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; + + temp_r1 += ptr_vec_x_cap[0] * temp_r - ptr_vec_x_cap[1] * temp_i; + temp_i1 += ptr_vec_x_cap[0] * temp_i + ptr_vec_x_cap[1] * temp_r; + + out_buf[0] += (temp_r1 * 0.23570225f); + out_buf[1] += (temp_i1 * 0.23570225f); + + out_buf += 128; + ptr_vec_x += 2; + ptr_vec_x_cap += 2; + } + + in_buf -= 128 * 11; + in_buf1 -= 128 * 11; + out_buf -= 128 * 6; + } + } + + out_buf -= (256 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_prod4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { + WORD32 i, inp_band_idx; + FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[3][2 * qmf_band_idx]; + + ixheaacd_norm_qmf_in_buf_4(ptr_hbe_txposer, ((qmf_band_idx >> 1) - 1)); + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { + WORD32 ip_idx; + FLOAT32 temp, temp_r, temp_i; + FLOAT32 *norm_ptr, *x_norm_ptr; + inp_band_idx = qmf_band_idx >> 1; + ip_idx = (qmf_band_idx & 1) ? (inp_band_idx + 1) : (inp_band_idx - 1); + + norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * ip_idx]; + x_norm_ptr = + &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * inp_band_idx]; + + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 x_zero_band_r, x_zero_band_i; + + temp_r = x_zero_band_r = *x_norm_ptr++; + temp_i = x_zero_band_i = *x_norm_ptr++; + + temp = x_zero_band_r * x_zero_band_r - x_zero_band_i * x_zero_band_i; + x_zero_band_i = + x_zero_band_r * x_zero_band_i + x_zero_band_i * x_zero_band_r; + + x_zero_band_r = temp_r * temp - temp_i * x_zero_band_i; + x_zero_band_i = temp_r * x_zero_band_i + temp_i * temp; + + for (k = 0; k < HBE_OPER_BLK_LEN_4; k++) { + temp = *norm_ptr++; + temp_i = *norm_ptr++; + + temp_r = temp * x_zero_band_r - temp_i * x_zero_band_i; + temp_i = temp * x_zero_band_i + temp_i * x_zero_band_r; + + *out_ptr++ += (temp_r * 0.6666667f); + *out_ptr++ += (temp_i * 0.6666667f); + + norm_ptr += 254; + out_ptr += 126; + } + + norm_ptr -= 128 * 11; + out_ptr -= 128 * 4; + x_norm_ptr += 126; + } + + out_ptr -= (128 * 2 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_xprod2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx, + FLOAT32 p, FLOAT32 *cos_sin_theta) { + WORD32 i; + FLOAT32 *norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[1][2 * qmf_band_idx]; + FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[1][2 * qmf_band_idx]; + FLOAT32 *x_norm_ptr = + &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * qmf_band_idx]; + + ixheaacd_norm_qmf_in_buf_2(ptr_hbe_txposer, qmf_band_idx); + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { + WORD32 n1, n2; + FLOAT64 temp_fac; + FLOAT32 mag_cmplx_gain = 1.666666667f; + temp_fac = (2.0f * qmf_band_idx + 1 - p) * 0.5; + n1 = ((WORD32)(temp_fac)) << 1; + n2 = ((WORD32)(temp_fac + p)) << 1; + + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 x_zero_band_r, x_zero_band_i; + + x_zero_band_r = *x_norm_ptr++; + x_zero_band_i = *x_norm_ptr++; + + for (k = 1; k < (HBE_OPER_BLK_LEN_2 + 1); k++) { + register FLOAT32 tmp_r, tmp_i; + tmp_r = *norm_ptr++; + tmp_i = *norm_ptr++; + + *out_ptr++ += + ((tmp_r * x_zero_band_r - tmp_i * x_zero_band_i) * 0.3333333f); + + *out_ptr++ += + ((tmp_r * x_zero_band_i + tmp_i * x_zero_band_r) * 0.3333333f); + + norm_ptr += 126; + out_ptr += 126; + } + norm_ptr -= 128 * 9; + out_ptr -= 128 * 8; + x_norm_ptr += 126; + + { + WORD32 max_trans_fac, max_n1, max_n2; + FLOAT32 max_mag_value; + FLOAT32 mag_zero_band, mag_n1_band, mag_n2_band, temp; + + FLOAT32 *qmf_in_buf_ri = + ptr_hbe_txposer->qmf_in_buf[i + HBE_ZERO_BAND_IDX]; + + mag_zero_band = + qmf_in_buf_ri[2 * qmf_band_idx] * qmf_in_buf_ri[2 * qmf_band_idx] + + qmf_in_buf_ri[2 * qmf_band_idx + 1] * + qmf_in_buf_ri[2 * qmf_band_idx + 1]; + + mag_n1_band = qmf_in_buf_ri[n1] * qmf_in_buf_ri[n1] + + qmf_in_buf_ri[n1 + 1] * qmf_in_buf_ri[n1 + 1]; + mag_n2_band = qmf_in_buf_ri[n2] * qmf_in_buf_ri[n2] + + qmf_in_buf_ri[n2 + 1] * qmf_in_buf_ri[n2 + 1]; + + temp = min(mag_n1_band, mag_n2_band); + + max_mag_value = 0; + max_trans_fac = 0; + max_n1 = 0; + max_n2 = 0; + + if (temp > 0) { + max_mag_value = temp; + max_trans_fac = 1; + max_n1 = n1; + max_n2 = n2; + } + + if (max_mag_value > mag_zero_band && max_n1 >= 0 && + max_n2 < TWICE_QMF_SYNTH_CHANNELS_NUM) { + FLOAT32 vec_y_r[2], vec_y_i[2]; + FLOAT32 temp_r, temp_i, tmp_r1; + WORD32 mid_trans_fac, idx; + FLOAT64 base; + WORD32 k; + FLOAT32 mag_scaling_fac = 0.0f; + FLOAT32 x_zero_band_r = 0; + FLOAT32 x_zero_band_i = 0; + + mid_trans_fac = 2 - max_trans_fac; + + x_zero_band_r = qmf_in_buf_ri[max_n1]; + x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; + base = 1e-17; + base = base + x_zero_band_r * x_zero_band_r; + base = base + x_zero_band_i * x_zero_band_i; + + mag_scaling_fac = (FLOAT32)(1.0f / base); + mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); + + x_zero_band_r *= mag_scaling_fac; + x_zero_band_i *= mag_scaling_fac; + + temp_r = x_zero_band_r; + temp_i = x_zero_band_i; + for (idx = 0; idx < mid_trans_fac - 1; idx++) { + FLOAT32 tmp = x_zero_band_r; + x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; + x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; + } + + for (k = 0; k < 2; k++) { + temp_r = ptr_hbe_txposer + ->qmf_in_buf[i + HBE_ZERO_BAND_IDX - 1 + k][max_n2]; + temp_i = + ptr_hbe_txposer + ->qmf_in_buf[i + HBE_ZERO_BAND_IDX - 1 + k][max_n2 + 1]; + + base = 1e-17; + base = base + temp_r * temp_r; + base = base + temp_i * temp_i; + + mag_scaling_fac = (FLOAT32)(1.0f / base); + mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); + + temp_r *= mag_scaling_fac; + temp_i *= mag_scaling_fac; + + vec_y_r[k] = temp_r; + vec_y_i[k] = temp_i; + } + + temp_r = vec_y_r[0] * x_zero_band_r - vec_y_i[0] * x_zero_band_i; + temp_i = vec_y_r[0] * x_zero_band_i + vec_y_i[0] * x_zero_band_r; + + tmp_r1 = + (FLOAT32)(cos_sin_theta[0] * temp_r - cos_sin_theta[1] * temp_i); + temp_i = + (FLOAT32)(cos_sin_theta[0] * temp_i + cos_sin_theta[1] * temp_r); + + ptr_hbe_txposer->qmf_out_buf[i * 2 + (HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx] += + (FLOAT32)(mag_cmplx_gain * tmp_r1); + + ptr_hbe_txposer->qmf_out_buf[i * 2 + (HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx + 1] += + (FLOAT32)(mag_cmplx_gain * temp_i); + + temp_r = vec_y_r[1] * x_zero_band_r - vec_y_i[1] * x_zero_band_i; + temp_i = vec_y_r[1] * x_zero_band_i + vec_y_i[1] * x_zero_band_r; + + ptr_hbe_txposer->qmf_out_buf[i * 2 + (1 + HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx] += + (FLOAT32)(mag_cmplx_gain * temp_r); + + ptr_hbe_txposer->qmf_out_buf[i * 2 + (1 + HBE_ZERO_BAND_IDX - 1)] + [2 * qmf_band_idx + 1] += + (FLOAT32)(mag_cmplx_gain * temp_i); + } + } + } + + out_ptr -= (128 * 2 * qmf_voc_columns) - 2; + norm_ptr -= (128 * qmf_voc_columns) - 2; + x_norm_ptr -= (128 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_xprod3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx, + FLOAT32 p, WORD32 pitch_in_bins_idx) { + WORD32 i, inp_band_idx, rem; + + FLOAT32 *out_buf = &ptr_hbe_txposer->qmf_out_buf[2][2 * qmf_band_idx]; + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[2]; qmf_band_idx++) { + FLOAT32 temp_r, temp_i; + FLOAT32 temp_r1, temp_i1; + const FLOAT32 *ptr_sel, *ptr_sel1; + + inp_band_idx = (2 * qmf_band_idx) / 3; + ptr_sel = &ixheaacd_sel_case[(inp_band_idx + 1) & 3][0]; + ptr_sel1 = &ixheaacd_sel_case[((inp_band_idx + 1) & 3) + 1][0]; + rem = 2 * qmf_band_idx - 3 * inp_band_idx; + + if (rem == 0 || rem == 1) { + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; + + for (i = 0; i < qmf_voc_columns; i += 1) { + WORD32 k; + FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; + FLOAT32 *ptr_vec_x = &vec_x[0]; + FLOAT32 x_zero_band_r, x_zero_band_i; + + FLOAT32 mag_scaling_fac; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { + FLOAT64 base1; + FLOAT64 base = 1e-17; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + in_buf += 256; + + base1 = base + temp_r * temp_r; + base1 = base1 + temp_i * temp_i; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[0] = temp_r * mag_scaling_fac; + ptr_vec_x[1] = temp_i * mag_scaling_fac; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + in_buf -= 128; + + temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; + temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + temp_r1 += ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; + temp_i1 += ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; + + temp_r1 *= 0.3984033437f; + temp_i1 *= 0.3984033437f; + + base1 = base + temp_r1 * temp_r1; + base1 = base1 + temp_i1 * temp_i1; + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[2] = temp_r1 * mag_scaling_fac; + ptr_vec_x[3] = temp_i1 * mag_scaling_fac; + + ptr_vec_x += 4; + in_buf += 256; + } + ptr_vec_x = &vec_x[0]; + temp_r = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i = vec_x[(2 * (HBE_ZERO_BAND_IDX - 2)) + 1]; + + x_zero_band_r = temp_r * temp_r - temp_i * temp_i; + x_zero_band_i = temp_r * temp_i + temp_i * temp_r; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { + temp_r = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; + temp_i = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; + + out_buf[0] += (temp_r * 0.4714045f); + out_buf[1] += (temp_i * 0.4714045f); + + ptr_vec_x += 2; + out_buf += 128; + } + + ixheaacd_hbe_xprod_proc_3(ptr_hbe_txposer, qmf_band_idx, i, p, + pitch_in_bins_idx); + + in_buf -= 128 * 11; + out_buf -= 128 * 6; + } + } else { + FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; + FLOAT32 *in_buf1 = + &ptr_hbe_txposer->qmf_in_buf[0][2 * (inp_band_idx + 1)]; + + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; + FLOAT32 vec_x_cap[2 * HBE_OPER_WIN_LEN]; + + FLOAT32 x_zero_band_r, x_zero_band_i; + FLOAT32 *ptr_vec_x = &vec_x[0]; + FLOAT32 *ptr_vec_x_cap = &vec_x_cap[0]; + + FLOAT32 mag_scaling_fac; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { + FLOAT32 tmp_vr, tmp_vi; + FLOAT32 tmp_cr, tmp_ci; + FLOAT64 base1; + FLOAT64 base = 1e-17; + + temp_r1 = in_buf[0]; + temp_i1 = in_buf[1]; + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + base1 = base + temp_r * temp_r; + base1 = base1 + temp_i * temp_i; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[0] = temp_r * mag_scaling_fac; + ptr_vec_x[1] = temp_i * mag_scaling_fac; + + base1 = base + temp_r1 * temp_r1; + base1 = base1 + temp_i1 * temp_i1; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x_cap[0] = temp_r1 * mag_scaling_fac; + ptr_vec_x_cap[1] = temp_i1 * mag_scaling_fac; + + in_buf += 256; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; + temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; + + in_buf -= 128; + + temp_r = in_buf[0]; + temp_i = in_buf[1]; + + tmp_cr = temp_r1 + ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; + tmp_ci = temp_i1 + ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; + + in_buf1 += 256; + + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + temp_r1 = ptr_sel1[0] * temp_r + ptr_sel1[1] * temp_i; + temp_i1 = ptr_sel1[2] * temp_r + ptr_sel1[3] * temp_i; + + in_buf1 -= 128; + + temp_r = in_buf1[0]; + temp_i = in_buf1[1]; + + tmp_vr = temp_r1 + ptr_sel1[4] * temp_r + ptr_sel1[5] * temp_i; + tmp_vi = temp_i1 + ptr_sel1[6] * temp_r + ptr_sel1[7] * temp_i; + + tmp_cr *= 0.3984033437f; + tmp_ci *= 0.3984033437f; + + tmp_vr *= 0.3984033437f; + tmp_vi *= 0.3984033437f; + + base1 = base + tmp_vr * tmp_vr; + base1 = base1 + tmp_vi * tmp_vi; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x[2] = tmp_vr * mag_scaling_fac; + ptr_vec_x[3] = tmp_vi * mag_scaling_fac; + + base1 = base + tmp_cr * tmp_cr; + base1 = base1 + tmp_ci * tmp_ci; + + mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); + + ptr_vec_x_cap[2] = tmp_cr * mag_scaling_fac; + ptr_vec_x_cap[3] = tmp_ci * mag_scaling_fac; + + in_buf += 256; + in_buf1 += 256; + ptr_vec_x += 4; + ptr_vec_x_cap += 4; + } + ptr_vec_x = &vec_x[0]; + ptr_vec_x_cap = &vec_x_cap[0]; + + temp_r = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; + temp_r1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; + temp_i1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; + + x_zero_band_r = temp_r * temp_r - temp_i * temp_i; + x_zero_band_i = temp_r * temp_i + temp_i * temp_r; + + temp_r = temp_r1 * temp_r1 - temp_i1 * temp_i1; + temp_i = temp_r1 * temp_i1 + temp_i1 * temp_r1; + + for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { + temp_r1 = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; + temp_i1 = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; + + temp_r1 += ptr_vec_x_cap[0] * temp_r - ptr_vec_x_cap[1] * temp_i; + temp_i1 += ptr_vec_x_cap[0] * temp_i + ptr_vec_x_cap[1] * temp_r; + + out_buf[0] += (temp_r1 * 0.23570225f); + out_buf[1] += (temp_i1 * 0.23570225f); + + out_buf += 128; + ptr_vec_x += 2; + ptr_vec_x_cap += 2; + } + + ixheaacd_hbe_xprod_proc_3(ptr_hbe_txposer, qmf_band_idx, i, p, + pitch_in_bins_idx); + + in_buf -= 128 * 11; + in_buf1 -= 128 * 11; + out_buf -= 128 * 6; + } + } + + out_buf -= (256 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_xprod4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 qmf_voc_columns, WORD32 qmf_band_idx, + FLOAT32 p, WORD32 pitch_in_bins_idx) { + WORD32 i, inp_band_idx; + FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[3][2 * qmf_band_idx]; + + ixheaacd_norm_qmf_in_buf_4(ptr_hbe_txposer, ((qmf_band_idx >> 1) - 1)); + + for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { + WORD32 ip_idx; + FLOAT32 temp, temp_r, temp_i; + FLOAT32 *norm_ptr, *x_norm_ptr; + inp_band_idx = qmf_band_idx >> 1; + ip_idx = (qmf_band_idx & 1) ? (inp_band_idx + 1) : (inp_band_idx - 1); + + norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * ip_idx]; + x_norm_ptr = + &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * inp_band_idx]; + + for (i = 0; i < qmf_voc_columns; i++) { + WORD32 k; + FLOAT32 x_zero_band_r, x_zero_band_i; + + temp_r = x_zero_band_r = *x_norm_ptr++; + temp_i = x_zero_band_i = *x_norm_ptr++; + + temp = x_zero_band_r * x_zero_band_r - x_zero_band_i * x_zero_band_i; + x_zero_band_i = + x_zero_band_r * x_zero_band_i + x_zero_band_i * x_zero_band_r; + + x_zero_band_r = temp_r * temp - temp_i * x_zero_band_i; + x_zero_band_i = temp_r * x_zero_band_i + temp_i * temp; + + for (k = 0; k < HBE_OPER_BLK_LEN_4; k++) { + temp = *norm_ptr++; + temp_i = *norm_ptr++; + + temp_r = temp * x_zero_band_r - temp_i * x_zero_band_i; + temp_i = temp * x_zero_band_i + temp_i * x_zero_band_r; + + *out_ptr++ += (temp_r * 0.6666667f); + *out_ptr++ += (temp_i * 0.6666667f); + + norm_ptr += 254; + out_ptr += 126; + } + + norm_ptr -= 128 * 11; + out_ptr -= 128 * 4; + x_norm_ptr += 126; + + ixheaacd_hbe_xprod_proc_4(ptr_hbe_txposer, qmf_band_idx, i, p, + pitch_in_bins_idx); + } + + out_ptr -= (128 * 2 * qmf_voc_columns) - 2; + } +} + +VOID ixheaacd_hbe_post_anal_process(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 pitch_in_bins, + WORD32 sbr_upsamp_4_flg) { + FLOAT32 p; + WORD32 trans_fac; + WORD32 qmf_voc_columns = ptr_hbe_txposer->no_bins / 2; + FLOAT32 cos_sin_theta[2]; + + p = (sbr_upsamp_4_flg) ? (FLOAT32)(pitch_in_bins * 0.04166666666666) + : (FLOAT32)(pitch_in_bins * 0.08333333333333); + + if (p < SBR_CONST_PMIN) { + trans_fac = 2; + if (trans_fac <= ptr_hbe_txposer->max_stretch) + ixheaacd_hbe_post_anal_prod2(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[0]); + + trans_fac = 3; + if (trans_fac <= ptr_hbe_txposer->max_stretch) + ixheaacd_hbe_post_anal_prod3(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[1]); + + trans_fac = 4; + if (trans_fac <= ptr_hbe_txposer->max_stretch) + ixheaacd_hbe_post_anal_prod4(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[2]); + + } else { + trans_fac = 2; + if (trans_fac <= ptr_hbe_txposer->max_stretch) { + cos_sin_theta[0] = ixheaacd_hbe_x_prod_cos_table_trans_2 + [((pitch_in_bins + sbr_upsamp_4_flg * 128) << 1) + 0]; + cos_sin_theta[1] = ixheaacd_hbe_x_prod_cos_table_trans_2 + [((pitch_in_bins + sbr_upsamp_4_flg * 128) << 1) + 1]; + + ixheaacd_hbe_post_anal_xprod2(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[0], p, + cos_sin_theta); + } + + trans_fac = 3; + if (trans_fac <= ptr_hbe_txposer->max_stretch) + ixheaacd_hbe_post_anal_xprod3(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[1], p, + (pitch_in_bins + sbr_upsamp_4_flg * 128)); + + trans_fac = 4; + if (trans_fac <= ptr_hbe_txposer->max_stretch) + ixheaacd_hbe_post_anal_xprod4(ptr_hbe_txposer, qmf_voc_columns, + ptr_hbe_txposer->x_over_qmf[2], p, + (pitch_in_bins + sbr_upsamp_4_flg * 128)); + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_hcr.h b/decoder/ixheaacd_hcr.h new file mode 100644 index 0000000..827867b --- /dev/null +++ b/decoder/ixheaacd_hcr.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_HCR_H +#define IXHEAACD_HCR_H +void ixheaacd_huff_code_reorder_tbl_init(ia_hcr_info_struct* ptr_hcr_info); +UWORD32 ixheaacd_huff_code_reorder_init( + ia_hcr_info_struct* ptr_hcr_info, + ia_aac_dec_channel_info_struct* ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct* ptr_aac_tables, ia_bit_buf_struct* itt_bit_buff); +UWORD32 ixheaacd_hcr_decoder( + ia_hcr_info_struct* ptr_hcr_info, + ia_aac_dec_channel_info_struct* ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct* ptr_aac_tables, ia_bit_buf_struct* itt_bit_buff); +VOID ixheaacd_huff_mute_erroneous_lines(ia_hcr_info_struct* ptr_hcr_info); + +void ixheaacd_lt_prediction( + ia_aac_dec_channel_info_struct* ptr_aac_dec_channel_info, ltp_info* ltp, + WORD32* spec, ia_aac_dec_tables_struct* aac_tables_ptr, + UWORD16 win_shape_prev, UWORD32 sr_index, UWORD32 object_type, + UWORD32 frame_len, WORD32* in_data, WORD32* out_data); + +WORD32 ixheaacd_ltp_data(WORD32 object_type, ia_ics_info_struct* ics, + ltp_info* ltp, ia_handle_bit_buf_struct bs, + WORD32 frame_len); + +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_headerdecode.c b/decoder/ixheaacd_headerdecode.c new file mode 100644 index 0000000..bdcb3d5 --- /dev/null +++ b/decoder/ixheaacd_headerdecode.c @@ -0,0 +1,1129 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" + +#include "ixheaacd_struct_def.h" +#include "ixheaacd_error_codes.h" +#include "ixheaacd_definitions.h" +#include "ixheaacd_adts_crc_check.h" + +#include "ixheaacd_headerdecode.h" + +#include "ixheaacd_interface.h" +#include "ixheaacd_info.h" + +#include "ixheaacd_config.h" + +#include "ixheaacd_struct.h" +#include "ixheaacd_function_selector.h" + +#undef ALLOW_SMALL_FRAMELENGTH + +#define ALLOW_SMALL_FRAMELENGTH +#ifdef ALLOW_SMALL_FRAMELENGTH +#undef FRAME_SIZE_SMALL +#define FRAME_SIZE_SMALL 960 +#endif + +extern const WORD32 ixheaacd_sampl_freq_idx_table[17]; + +#define AAC_LC_PROFILE (2) + +#define ADTS_HEADER_LENGTH 7 + +#undef ALLOW_SMALL_FRAMELENGTH + +#define ALLOW_SMALL_FRAMELENGTH + +static PLATFORM_INLINE VOID +ixheaacd_aac_bytealign(struct ia_bit_buf_struct *it_bit_buff) { + WORD16 num_bit; + num_bit = (it_bit_buff->bit_pos + 1); + if (num_bit != 8) { + it_bit_buff->bit_pos = 7; + it_bit_buff->cnt_bits -= num_bit; + it_bit_buff->ptr_read_next += 1; + } +} + +WORD32 ixheaacd_read_pce_channel_info(WORD32 ch, WORD8 *ptr_is_cpe, + WORD8 *ptr_tag_select, + struct ia_bit_buf_struct *it_bit_buff) { + WORD32 num_ch = 0, i, tmp; + for (i = 0; i < ch; i++) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 5); + ptr_is_cpe[i] = (tmp & 0x10) >> 4; + + if (ptr_is_cpe[i]) { + num_ch += 2; + } else { + num_ch++; + } + + ptr_tag_select[i] = (tmp & 0xF); + } + return num_ch; +} + +VOID ixheaacd_read_pce_mixdown_data(struct ia_bit_buf_struct *it_bit_buff, + WORD32 mix_down_present, + WORD32 mix_down_element_no) { + WORD32 mix_down_flag = ixheaacd_read_bits_buf(it_bit_buff, mix_down_present); + if (mix_down_flag == 1) { + ixheaacd_read_bits_buf(it_bit_buff, mix_down_element_no); + } +} + +VOID ixheaacd_skip_bits(struct ia_bit_buf_struct *it_bit_buff, WORD32 bits, + WORD32 num_element) { + WORD32 i; + for (i = 0; i < num_element; i++) { + ixheaacd_read_bits_buf(it_bit_buff, bits); + } +} + +WORD32 ixheaacd_read_prog_config_element( + ia_program_config_struct *ptr_config_element, + struct ia_bit_buf_struct *it_bit_buff) { + WORD32 i, tmp; + WORD count = 0, num_ch = 0; + WORD32 object_type; + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 6); + + ptr_config_element->element_instance_tag = (tmp >> 2); + ptr_config_element->object_type = tmp & 0x3; + + object_type = 0; + + if ((ptr_config_element->object_type + 1) != 2 + + && (ptr_config_element->object_type + 1) != 4 + + ) { + object_type = IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + + ptr_config_element->samp_freq_index = ixheaacd_read_bits_buf(it_bit_buff, 4); + if (ptr_config_element->samp_freq_index > 11) { + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; + } + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 21); + + count += ptr_config_element->num_front_channel_elements = (tmp >> 17); + count += ptr_config_element->num_side_channel_elements = + (tmp & 0x1E000) >> 13; + count += ptr_config_element->num_back_channel_elements = (tmp & 0x1E00) >> 9; + count += ptr_config_element->num_lfe_channel_elements = (tmp & 0x180) >> 7; + ptr_config_element->num_assoc_data_elements = (tmp & 0x70) >> 4; + count += ptr_config_element->num_valid_cc_elements = tmp & 0xF; + + if (count > MAX_BS_ELEMENT) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX; + } + + ixheaacd_read_pce_mixdown_data(it_bit_buff, 1, 4); + ixheaacd_read_pce_mixdown_data(it_bit_buff, 1, 4); + ixheaacd_read_pce_mixdown_data(it_bit_buff, 1, 3); + + num_ch += ixheaacd_read_pce_channel_info( + ptr_config_element->num_front_channel_elements, + ptr_config_element->front_element_is_cpe, + ptr_config_element->front_element_tag_select, it_bit_buff); + + num_ch += ixheaacd_read_pce_channel_info( + ptr_config_element->num_side_channel_elements, + ptr_config_element->side_element_is_cpe, + ptr_config_element->side_element_tag_select, it_bit_buff); + + num_ch += ixheaacd_read_pce_channel_info( + ptr_config_element->num_back_channel_elements, + ptr_config_element->back_element_is_cpe, + ptr_config_element->back_element_tag_select, it_bit_buff); + + num_ch += ptr_config_element->num_lfe_channel_elements; + + for (i = 0; i < (ptr_config_element->num_lfe_channel_elements); i++) { + ptr_config_element->lfe_element_tag_select[i] = + ixheaacd_read_bits_buf(it_bit_buff, 4); + } + + ptr_config_element->channels = num_ch; + + for (i = 0; i < (ptr_config_element->num_assoc_data_elements); i++) { + ixheaacd_read_bits_buf(it_bit_buff, 4); + } + + ixheaacd_skip_bits(it_bit_buff, 5, ptr_config_element->num_valid_cc_elements); + + { + WORD32 bits_to_read = ptr_config_element->alignment_bits; + if (bits_to_read <= it_bit_buff->bit_pos) { + bits_to_read = it_bit_buff->bit_pos - bits_to_read; + } else { + bits_to_read = 8 - (bits_to_read) + it_bit_buff->bit_pos; + } + tmp = ixheaacd_read_bits_buf(it_bit_buff, bits_to_read); + } + tmp = ixheaacd_read_bits_buf(it_bit_buff, 8); + + ixheaacd_skip_bits(it_bit_buff, 8, tmp); + + return object_type; +} + +WORD ixheaacd_decode_pce(struct ia_bit_buf_struct *it_bit_buff, + UWORD32 *ui_pce_found_in_hdr, + ia_program_config_struct *ptr_prog_config) { + WORD32 error_code = 0; + + if (*ui_pce_found_in_hdr == 1 || *ui_pce_found_in_hdr == 3) { + ia_program_config_struct ptr_config_element; + ptr_config_element.alignment_bits = ptr_prog_config->alignment_bits; + ixheaacd_read_prog_config_element(&ptr_config_element, it_bit_buff); + *ui_pce_found_in_hdr = 3; + } else { + error_code = + ixheaacd_read_prog_config_element(ptr_prog_config, it_bit_buff); + *ui_pce_found_in_hdr = 2; + } + return error_code; +} + +static PLATFORM_INLINE WORD32 ixheaacd_get_adif_header( + ia_adif_header_struct *adif, struct ia_bit_buf_struct *it_bit_buff) { + WORD32 i; + WORD32 ret_val = 0, tmp; + + ixheaacd_read_bits_buf(it_bit_buff, 16); + tmp = ixheaacd_read_bits_buf(it_bit_buff, 17); + + if (tmp & 0x1) { + ixheaacd_skip_bits(it_bit_buff, 8, 9); + } + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 3); + + adif->bit_stream_type = (tmp & 0x1); + + ixheaacd_read_bits_buf(it_bit_buff, 23); + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 4); + + for (i = 0; i <= tmp; i++) { + if (adif->bit_stream_type == 0) { + ixheaacd_read_bits_buf(it_bit_buff, 20); + } + + adif->prog_config_present = 1; + adif->str_prog_config.alignment_bits = 7; + ret_val = + ixheaacd_read_prog_config_element(&adif->str_prog_config, it_bit_buff); + if (ret_val) { + return ret_val; + } + } + + return 0; +} + +WORD32 ixheaacd_find_syncword(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff) { + adts->sync_word = (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 12); + if (adts->sync_word == 0xFFF) { + return 0; + } + + while (1) { + ixheaacd_read_bidirection(it_bit_buff, -4); + if (it_bit_buff->cnt_bits < 12) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + adts->sync_word = (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 12); + if (adts->sync_word == 0xFFF) { + ixheaacd_read_bidirection(it_bit_buff, -12); + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + } +} + +WORD32 ixheaacd_adtsframe(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff) { + WORD32 tmp; + + WORD32 crc_reg; + ia_adts_crc_info_struct *ptr_adts_crc_info = it_bit_buff->pstr_adts_crc_info; + ptr_adts_crc_info->crc_active = 1; + ptr_adts_crc_info->no_reg = 0; + ixheaacd_read_bidirection(it_bit_buff, -12); + crc_reg = ixheaacd_adts_crc_start_reg(ptr_adts_crc_info, it_bit_buff, + CRC_ADTS_HEADER_LEN); + ixheaacd_find_syncword(adts, it_bit_buff); + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 10); + + adts->id = (tmp & 0x200) >> 9; + adts->layer = (tmp & 0x180) >> 7; + adts->protection_absent = (tmp & 0x40) >> 6; + adts->profile = (tmp & 0x30) >> 4; + { adts->profile++; } + adts->samp_freq_index = (tmp & 0xF); + + if (((adts->profile != AAC_LC_PROFILE)) || (adts->samp_freq_index > 11)) + + { + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 21); + + adts->channel_configuration = (WORD32)(tmp & 0xE0000) >> 17; + + adts->aac_frame_length = (tmp & 0x1FFF); + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 13); + + adts->no_raw_data_blocks = (tmp & 0x3); + + ixheaacd_adts_crc_end_reg(ptr_adts_crc_info, it_bit_buff, crc_reg); + + if (adts->protection_absent == 0) { + ixheaacd_skip_bits(it_bit_buff, 16, adts->no_raw_data_blocks); + adts->crc_check = ixheaacd_read_bits_buf(it_bit_buff, 16); + + ptr_adts_crc_info->crc_active = 1; + ptr_adts_crc_info->file_value = adts->crc_check; + } else + ptr_adts_crc_info->crc_active = 0; + + ixheaacd_aac_bytealign(it_bit_buff); + return 0; +} + +WORD32 ixheaacd_get_samp_rate( + struct ia_bit_buf_struct *it_bit_buff, + ia_sampling_rate_info_struct *pstr_samp_rate_info, + ia_audio_specific_config_struct *pstr_audio_specific_config) { + WORD32 index; + WORD32 sampling_rate; + index = ixheaacd_read_bits_buf(it_bit_buff, 4); + pstr_audio_specific_config->samp_frequency_index = index; + + if (index == 0x0F) { + sampling_rate = ixheaacd_read_bits_buf(it_bit_buff, 24); + + if (pstr_audio_specific_config->audio_object_type != AOT_USAC) { + if (sampling_rate < 9391) + sampling_rate = 8000; + else if ((sampling_rate >= 9391) && (sampling_rate < 11502)) + sampling_rate = 11025; + else if ((sampling_rate >= 11502) && (sampling_rate < 13856)) + sampling_rate = 12000; + else if ((sampling_rate >= 13856) && (sampling_rate < 18783)) + sampling_rate = 16000; + else if ((sampling_rate >= 18783) && (sampling_rate < 23004)) + sampling_rate = 22050; + else if ((sampling_rate >= 23004) && (sampling_rate < 27713)) + sampling_rate = 24000; + else if ((sampling_rate >= 27713) && (sampling_rate < 37566)) + sampling_rate = 32000; + else if ((sampling_rate >= 37566) && (sampling_rate < 46009)) + sampling_rate = 44100; + else if ((sampling_rate >= 46009) && (sampling_rate < 55426)) + sampling_rate = 48000; + else if ((sampling_rate >= 55426) && (sampling_rate < 75132)) + sampling_rate = 64000; + else if ((sampling_rate >= 75132) && (sampling_rate < 92017)) + sampling_rate = 88200; + else if (sampling_rate >= 92017) + sampling_rate = 96000; + } + return sampling_rate; + } else if ((index > 12) && (index < 15)) { + return -1; + } else { + return ((pstr_samp_rate_info[index].sampling_frequency)); + } +} +static int ixheaacd_get_ld_sbr_header( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_header_data_struct *sbr_header_data) { + WORD32 header_extra_1, header_extra_2; + UWORD32 tmp, bit_cnt = 0; + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 16); + bit_cnt += 16; + + sbr_header_data->amp_res = (tmp & 0x8000) >> 15; + sbr_header_data->start_freq = (tmp & 0x7800) >> 11; + sbr_header_data->stop_freq = (tmp & 0x780) >> 7; + sbr_header_data->xover_band = (tmp & 0x70) >> 4; + header_extra_1 = (tmp & 0x0002) >> 1; + header_extra_2 = (tmp & 0x0001); + + if (header_extra_1) { + sbr_header_data->freq_scale = ixheaacd_read_bits_buf(it_bit_buff, 2); + sbr_header_data->alter_scale = ixheaacd_read_bits_buf(it_bit_buff, 1); + sbr_header_data->noise_bands = ixheaacd_read_bits_buf(it_bit_buff, 2); + } else { + sbr_header_data->freq_scale = 2; + sbr_header_data->alter_scale = 1; + sbr_header_data->noise_bands = 2; + } + + if (header_extra_2) { + sbr_header_data->limiter_bands = ixheaacd_read_bits_buf(it_bit_buff, 2); + sbr_header_data->limiter_gains = ixheaacd_read_bits_buf(it_bit_buff, 2); + sbr_header_data->interpol_freq = ixheaacd_read_bits_buf(it_bit_buff, 1); + sbr_header_data->smoothing_mode = ixheaacd_read_bits_buf(it_bit_buff, 1); + } else { + sbr_header_data->limiter_bands = 2; + sbr_header_data->limiter_gains = 2; + sbr_header_data->interpol_freq = 1; + sbr_header_data->smoothing_mode = 1; + } + + return (bit_cnt); +} + +WORD32 ixheaacd_eld_sbr_header(ia_bit_buf_struct *it_bit_buff, WORD32 channels, + ia_sbr_header_data_struct *pstr_sbr_config) { + int num_sbr_header, el, bit_cnt = 0; + switch (channels) { + default: + num_sbr_header = 0; + break; + case 1: + case 2: + num_sbr_header = 1; + break; + case 3: + num_sbr_header = 2; + break; + case 4: + case 5: + case 6: + num_sbr_header = 3; + break; + case 7: + num_sbr_header = 4; + break; + } + for (el = 0; el < num_sbr_header; el++) { + bit_cnt = ixheaacd_get_ld_sbr_header(it_bit_buff, pstr_sbr_config); + } + return (bit_cnt); +} + +WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct, + WORD32 header_len, WORD32 *bytes_consumed, + ia_sampling_rate_info_struct *pstr_samp_rate_info, + struct ia_bit_buf_struct *it_bit_buff) { + WORD32 tmp; + WORD32 cnt_bits = it_bit_buff->cnt_bits; + WORD32 dummy = 0; + ia_audio_specific_config_struct *pstr_audio_specific_config; + + memset(aac_state_struct->ia_audio_specific_config, 0, + sizeof(ia_audio_specific_config_struct)); + + pstr_audio_specific_config = aac_state_struct->ia_audio_specific_config; + + aac_state_struct->p_config->str_prog_config.alignment_bits = + it_bit_buff->bit_pos; + + aac_state_struct->audio_object_type = ixheaacd_read_bits_buf(it_bit_buff, 5); + + if (aac_state_struct->audio_object_type == 31) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 6); + aac_state_struct->audio_object_type = 32 + tmp; + } + pstr_audio_specific_config->audio_object_type = + aac_state_struct->audio_object_type; + + tmp = ixheaacd_get_samp_rate(it_bit_buff, pstr_samp_rate_info, + pstr_audio_specific_config); + pstr_audio_specific_config->sampling_frequency = tmp; + + if (tmp == -1) { + *bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } else + aac_state_struct->sampling_rate = tmp; + aac_state_struct->p_config->ui_samp_freq = tmp; + + aac_state_struct->ch_config = ixheaacd_read_bits_buf(it_bit_buff, 4); + + pstr_audio_specific_config->channel_configuration = + aac_state_struct->ch_config; + + if (aac_state_struct->audio_object_type == AOT_SBR || + aac_state_struct->audio_object_type == AOT_PS) { + tmp = ixheaacd_get_samp_rate(it_bit_buff, pstr_samp_rate_info, + pstr_audio_specific_config); + aac_state_struct->sbr_present_flag = 1; + if (tmp == -1) { + *bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } else + aac_state_struct->extension_samp_rate = tmp; + + aac_state_struct->audio_object_type = + ixheaacd_read_bits_buf(it_bit_buff, 5); + } + + 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 || + aac_state_struct->audio_object_type == AOT_TWIN_VQ || + aac_state_struct->audio_object_type == AOT_ER_AAC_LD || + aac_state_struct->audio_object_type == AOT_ER_AAC_LC) && + aac_state_struct->audio_object_type != AOT_USAC) + + { + aac_state_struct->usac_flag = 0; + + aac_state_struct->frame_len_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (aac_state_struct->audio_object_type != AOT_ER_AAC_ELD) { + aac_state_struct->depends_on_core_coder = + ixheaacd_read_bits_buf(it_bit_buff, 1); + aac_state_struct->extension_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (aac_state_struct->ch_config == 0) { + WORD32 error_code; + error_code = ixheaacd_read_prog_config_element( + &aac_state_struct->p_config->str_prog_config, it_bit_buff); + if (error_code != 0) { + *bytes_consumed = 1; + return error_code; + } + aac_state_struct->p_config->ui_pce_found_in_hdr = 1; + } + } + if (aac_state_struct->audio_object_type == AOT_ER_AAC_ELD || + aac_state_struct->audio_object_type == AOT_ER_AAC_LD) { + aac_state_struct->eld_specific_config.aac_sect_data_resil_flag = 0; + aac_state_struct->eld_specific_config.aac_sf_data_resil_flag = 0; + aac_state_struct->eld_specific_config.aac_spect_data_resil_flag = 0; + aac_state_struct->eld_specific_config.ep_config = 0; + if ((aac_state_struct->extension_flag == 1) || + aac_state_struct->audio_object_type == AOT_ER_AAC_ELD) { + if (aac_state_struct->audio_object_type >= ER_OBJECT_START) { + aac_state_struct->eld_specific_config.aac_sect_data_resil_flag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + aac_state_struct->eld_specific_config.aac_sf_data_resil_flag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + aac_state_struct->eld_specific_config.aac_spect_data_resil_flag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + if (aac_state_struct->audio_object_type != AOT_ER_AAC_ELD) + aac_state_struct->eld_specific_config.ep_config = + ixheaacd_read_bits_buf(it_bit_buff, 2); + else + aac_state_struct->eld_specific_config.ld_sbr_flag_present = + ixheaacd_read_bits_buf(it_bit_buff, 1); + } + } + } + } + if (pstr_audio_specific_config->audio_object_type == AOT_USAC) { + { + pstr_audio_specific_config->sbr_present_flag = 0; + pstr_audio_specific_config->ext_audio_object_type = 0; + } + + {{size_t tmp = 0xf; + UWORD32 i; + WORD32 err = 0; + + aac_state_struct->usac_flag = 1; + + ixheaacd_conf_default(&(pstr_audio_specific_config->str_usac_config)); + err = ixheaacd_config(it_bit_buff, + &(pstr_audio_specific_config->str_usac_config)); + if (err != 0) return -1; + + if (pstr_audio_specific_config->audio_object_type == AOT_USAC) { + pstr_audio_specific_config->sbr_present_flag = 1; + pstr_audio_specific_config->ext_audio_object_type = AOT_SBR; + pstr_audio_specific_config->ext_sampling_frequency = + pstr_audio_specific_config->sampling_frequency; + pstr_audio_specific_config->ext_samp_frequency_index = + pstr_audio_specific_config->samp_frequency_index; + if (pstr_audio_specific_config->str_usac_config + .core_sbr_framelength_index == 4) { + pstr_audio_specific_config->sampling_frequency = + pstr_audio_specific_config->ext_sampling_frequency / 4; + } else if ((pstr_audio_specific_config->str_usac_config + .core_sbr_framelength_index == 2) || + (pstr_audio_specific_config->str_usac_config + .core_sbr_framelength_index == 3)) { + pstr_audio_specific_config->sampling_frequency = + pstr_audio_specific_config->ext_sampling_frequency / 2; + } + for (i = 0; i < sizeof(ixheaacd_sampl_freq_idx_table) / + sizeof(ixheaacd_sampl_freq_idx_table[0]); + i++) { + if (ixheaacd_sampl_freq_idx_table[i] == + (int)(pstr_audio_specific_config->sampling_frequency)) { + tmp = i; + break; + } + } + pstr_audio_specific_config->samp_frequency_index = (UINT32)tmp; + } else { + pstr_audio_specific_config->sbr_present_flag = 0; + } + } +} + +{ + WORD32 write_flag = 0; + WORD32 system_flag = 1; + WORD32 len; + + if (system_flag) { + if (write_flag == 0) { + if ((SIZE_T)it_bit_buff->ptr_read_next == + (SIZE_T)it_bit_buff->ptr_bit_buf_base) { + len = ((((SIZE_T)it_bit_buff->ptr_bit_buf_end - + (SIZE_T)it_bit_buff->ptr_bit_buf_base) + + 1) + << 3) - + (SIZE_T)it_bit_buff->size; + } else { + len = ((((SIZE_T)it_bit_buff->ptr_bit_buf_end - + (SIZE_T)it_bit_buff->ptr_bit_buf_base) + + 1) + << 3) - + (((((SIZE_T)it_bit_buff->ptr_read_next - + (SIZE_T)it_bit_buff->ptr_bit_buf_base)) + << 3) + + 7 - it_bit_buff->bit_pos); + } + if (len > 0) { + if ((SIZE_T)it_bit_buff->ptr_read_next == + (SIZE_T)it_bit_buff->ptr_bit_buf_base) { + len = ((((SIZE_T)it_bit_buff->ptr_bit_buf_end - + (SIZE_T)it_bit_buff->ptr_bit_buf_base) + + 1) + << 3) - + (SIZE_T)it_bit_buff->size - 0; + } else { + len = ((((SIZE_T)it_bit_buff->ptr_bit_buf_end - + (SIZE_T)it_bit_buff->ptr_bit_buf_base) + + 1) + << 3) - + ((((((SIZE_T)it_bit_buff->ptr_read_next - + (SIZE_T)it_bit_buff->ptr_bit_buf_base)) + << 3) + + 7 - it_bit_buff->bit_pos) - + 0); + } + if (len > 0) { + dummy = ixheaacd_read_bits_buf(it_bit_buff, len); + } + } + } + } + + if ((SIZE_T)it_bit_buff->ptr_read_next == + (SIZE_T)it_bit_buff->ptr_bit_buf_base) { + *bytes_consumed = ((WORD32)it_bit_buff->size) >> 3; + } else { + *bytes_consumed = (((((SIZE_T)it_bit_buff->ptr_read_next - + (SIZE_T)it_bit_buff->ptr_bit_buf_base)) + << 3) + + 7 - it_bit_buff->bit_pos + 7) >> + 3; + } +} +return 0; +} + +aac_state_struct->frame_length = FRAME_SIZE; +if (aac_state_struct->frame_len_flag) +#ifdef ALLOW_SMALL_FRAMELENGTH + aac_state_struct->frame_length = FRAME_SIZE_SMALL; +#else + return -1; +#endif + +if (aac_state_struct->extension_flag) + aac_state_struct->extension_flag_3 = ixheaacd_read_bits_buf(it_bit_buff, 1); + +if (aac_state_struct->audio_object_type == AOT_ER_AAC_LD) + aac_state_struct->frame_length >>= 1; + +if (aac_state_struct->audio_object_type == AOT_ER_AAC_ELD) { + aac_state_struct->frame_length >>= 1; + if (aac_state_struct->eld_specific_config.ld_sbr_flag_present) { + aac_state_struct->eld_specific_config.ld_sbr_samp_rate = + ixheaacd_read_bits_buf(it_bit_buff, 1); + aac_state_struct->eld_specific_config.ld_sbr_crc_flag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + ixheaacd_eld_sbr_header(it_bit_buff, aac_state_struct->ch_config, + &aac_state_struct->str_sbr_config); + + aac_state_struct->dwnsmp_signal = + !aac_state_struct->eld_specific_config.ld_sbr_samp_rate; + } + + ixheaacd_read_bits_buf(it_bit_buff, 1); +} +if (aac_state_struct->audio_object_type == AOT_ER_AAC_ELD) { + int ep_config = ixheaacd_read_bits_buf(it_bit_buff, 2); + if (ep_config == 2 || ep_config == 3) { + } + if (ep_config == 3) { + int direct_map = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (!direct_map) { + } + } +} + +tmp = (header_len * 8) - it_bit_buff->cnt_bits; + +if (aac_state_struct->audio_object_type != AOT_SBR && + (it_bit_buff->cnt_bits >= 16)) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 11); + + if (tmp == 0x2b7) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 5); + + if (tmp == AOT_SBR) { + WORD32 sbr_present_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (sbr_present_flag) { + tmp = ixheaacd_get_samp_rate(it_bit_buff, pstr_samp_rate_info, + pstr_audio_specific_config); + if (tmp == -1) { + *bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } else + aac_state_struct->extension_samp_rate = tmp; + + if (it_bit_buff->cnt_bits >= 12) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 11); + if (tmp == 0x548) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, 1); + } + } + } + } + } else if (aac_state_struct->bs_format == LOAS_BSFORMAT) { + ixheaacd_read_bidirection(it_bit_buff, -11); + } +} + +if (aac_state_struct->audio_object_type != AOT_AAC_LC && + aac_state_struct->audio_object_type != AOT_SBR && + aac_state_struct->audio_object_type != AOT_PS && + aac_state_struct->audio_object_type != AOT_ER_AAC_LC && + aac_state_struct->audio_object_type != AOT_ER_AAC_LD && + aac_state_struct->audio_object_type != AOT_ER_AAC_ELD && + aac_state_struct->audio_object_type != AOT_AAC_LTP) { + *bytes_consumed = 1; + return IA_ENHAACPLUS_DEC_INIT_FATAL_AUDIOOBJECTTYPE_NOT_SUPPORTED; +} else { + if (aac_state_struct->bs_format == LOAS_BSFORMAT) { + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) >> 3; + if (it_bit_buff->bit_pos < 7) *bytes_consumed += 1; + + } else + *bytes_consumed = header_len; + + return 0; +} +} + +WORD32 ixheaacd_check_if_adts(ia_adts_header_struct *adts, + struct ia_bit_buf_struct *it_bit_buff, + WORD32 usr_max_ch) { + WORD32 max_frm_len_per_ch, result = 0; + + result = ixheaacd_adtsframe(adts, it_bit_buff); + + max_frm_len_per_ch = 768 * (adts->no_raw_data_blocks + 1); + + if (adts->channel_configuration != 0) + max_frm_len_per_ch = max_frm_len_per_ch * adts->channel_configuration; + else + max_frm_len_per_ch = max_frm_len_per_ch * usr_max_ch; + + return ((result != 0) || (adts->aac_frame_length < 8) || (adts->layer != 0) || + (adts->profile != AAC_LC_PROFILE)); +} + +WORD32 ixheaacd_latm_header_decode( + ia_aac_dec_state_struct *aac_state_struct, + struct ia_bit_buf_struct *it_bit_buff, WORD32 *bytes_consumed, + ia_sampling_rate_info_struct *pstr_samp_rate_info) { + WORD32 sync, result; + WORD32 next_sync, audio_mux_len_bytes_last; + WORD32 audio_mux_len_bits_last; + WORD32 sync_status = aac_state_struct->sync_status; + WORD32 bit_count = aac_state_struct->bit_count; + WORD32 cnt_bits = it_bit_buff->cnt_bits; + + *bytes_consumed = 0; + + aac_state_struct->bs_format = LOAS_BSFORMAT; + + if (sync_status == 0) { + do { + sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + bit_count += 11; + while (sync != 0x2B7) { + sync = ((sync & 0x3ff) << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); + bit_count += 1; + if (it_bit_buff->cnt_bits < 13) { + ixheaacd_read_bidirection(it_bit_buff, -11); + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; + return (IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START); + } + } + + audio_mux_len_bytes_last = ixheaacd_read_bits_buf(it_bit_buff, 13); + bit_count += 13; + audio_mux_len_bits_last = audio_mux_len_bytes_last << 3; + if (it_bit_buff->cnt_bits >= (audio_mux_len_bits_last + 11)) { + ixheaacd_read_bidirection(it_bit_buff, audio_mux_len_bits_last); + bit_count += audio_mux_len_bits_last; + + next_sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + bit_count += 11; + + if (next_sync == 0x2B7) { + ixheaacd_read_bidirection(it_bit_buff, + -(11 + audio_mux_len_bits_last + 13 + 11)); + bit_count -= 11 + audio_mux_len_bits_last + 13 + 11; + break; + } else { + ixheaacd_read_bidirection(it_bit_buff, + -(audio_mux_len_bits_last + 24 + 11 - 1)); + bit_count -= audio_mux_len_bits_last + 24 + 11 - 1; + } + + } else { + ixheaacd_read_bidirection(it_bit_buff, -(13 + 11)); + bit_count -= (13 + 11); + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; + } + } while (1); + + do { + WORD32 audio_mux_len_bytes_last; + WORD32 use_same_stream_mux; + + sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + bit_count += 11; + + if (sync != 0x2b7) { + ixheaacd_read_bidirection(it_bit_buff, -25); + bit_count -= 11; + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; + return IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START; + } + + audio_mux_len_bytes_last = ixheaacd_read_bits_buf(it_bit_buff, 13); + bit_count += 13; + + use_same_stream_mux = ixheaacd_read_bits_buf(it_bit_buff, 1); + bit_count += 1; + + if (it_bit_buff->cnt_bits - (audio_mux_len_bytes_last * 8 - 1 + 11) < 0) { + ixheaacd_read_bidirection(it_bit_buff, -25); + bit_count -= 25; + aac_state_struct->bit_count = bit_count; + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; + return IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START; + } + + if (!use_same_stream_mux) { + ixheaacd_read_bidirection(it_bit_buff, -25); + bit_count -= 25; + sync_status = 1; + aac_state_struct->sync_status = sync_status; + break; + } + + ixheaacd_read_bidirection(it_bit_buff, audio_mux_len_bytes_last * 8 - 1); + bit_count += audio_mux_len_bytes_last * 8 - 1; + + } while (sync_status == 0); + + *bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; + { + ixheaacd_latm_struct latm_struct_element; + WORD32 sync; + memset(&latm_struct_element, 0, sizeof(ixheaacd_latm_struct)); + + sync = ixheaacd_read_bits_buf(it_bit_buff, 11); + if (sync == 0x2b7) { + result = ixheaacd_latm_audio_mux_element( + it_bit_buff, &latm_struct_element, aac_state_struct, + pstr_samp_rate_info); + if (result < 0) { + sync_status = 0; + aac_state_struct->sync_status = sync_status; + + *bytes_consumed += 1; + return result; + } + } + } + } + return 0; +} + +WORD32 ixheaacd_aac_headerdecode( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, UWORD8 *buffer, + WORD32 *bytes_consumed, + const ia_aac_dec_huffman_tables_struct *pstr_huffmann_tables) { + struct ia_bit_buf_struct it_bit_buff, *handle_bit_buff; + ia_adif_header_struct adif; + ia_adts_header_struct adts; + WORD32 result; + WORD32 header_len; + WORD32 sync = 0; + + WORD32 disable_sync = p_obj_exhaacplus_dec->aac_config.ui_disable_sync; + WORD32 is_ga_header = p_obj_exhaacplus_dec->aac_config.ui_mp4_flag; + + WORD32 loas_present = p_obj_exhaacplus_dec->aac_config.loas_present; + + ia_aac_dec_state_struct *aac_state_struct = + p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; + WORD32 usr_max_ch = aac_state_struct->p_config->ui_max_channels; + + ia_sampling_rate_info_struct *pstr_samp_rate_info = + (ia_sampling_rate_info_struct *)&pstr_huffmann_tables + ->str_sample_rate_info[0]; + + if (buffer == 0) { + return IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + } + + header_len = aac_state_struct->ui_in_bytes; + + handle_bit_buff = ixheaacd_create_bit_buf(&it_bit_buff, (UWORD8 *)buffer, + (WORD16)header_len); + handle_bit_buff->cnt_bits += (header_len << 3); + + if (is_ga_header == 1) { + return ixheaacd_ga_hdr_dec(aac_state_struct, header_len, bytes_consumed, + pstr_samp_rate_info, handle_bit_buff); + } else if (loas_present) { + return ixheaacd_latm_header_decode(aac_state_struct, &it_bit_buff, + bytes_consumed, pstr_samp_rate_info); + } + + else { + WORD32 header_found = 0; + WORD32 bytes_taken = -1; + WORD32 prev_offset = 0; + WORD32 run_once = 1; + if (disable_sync == 0) run_once = 0; + + do { + bytes_taken++; + buffer += (bytes_taken - prev_offset); + + prev_offset = bytes_taken; + + handle_bit_buff = ixheaacd_create_bit_buf( + &it_bit_buff, (UWORD8 *)buffer, (WORD16)(header_len - bytes_taken)); + handle_bit_buff->cnt_bits += (8 * (header_len - bytes_taken)); + + handle_bit_buff->pstr_adts_crc_info = &handle_bit_buff->str_adts_crc_info; + ixheaacd_adts_crc_open(handle_bit_buff->pstr_adts_crc_info); + + if ((buffer[0] == 'A') && (buffer[1] == 'D') && (buffer[2] == 'I') && + (buffer[3] == 'F')) { + adif.prog_config_present = 0; + result = ixheaacd_get_adif_header(&adif, handle_bit_buff); + if (result == 0) { + if (adif.prog_config_present == 1) { + aac_state_struct->p_config->ui_pce_found_in_hdr = 1; + aac_state_struct->p_config->str_prog_config = adif.str_prog_config; + } + aac_state_struct->s_adif_hdr_present = 1; + aac_state_struct->audio_object_type = + adif.str_prog_config.object_type; + aac_state_struct->sampling_rate = + pstr_samp_rate_info[adif.str_prog_config.samp_freq_index] + .sampling_frequency; + aac_state_struct->ch_config = adif.str_prog_config.channels; + bytes_taken += + ((handle_bit_buff->size - handle_bit_buff->cnt_bits) >> 3); + + header_found = 1; + aac_state_struct->frame_length = FRAME_SIZE; + if (aac_state_struct->audio_object_type == AOT_ER_AAC_LD) + aac_state_struct->frame_length >>= 1; + } + } + + else if ((sync = ixheaacd_read_bits_buf(&it_bit_buff, 12)) == 0xfff) { + result = ixheaacd_check_if_adts(&adts, handle_bit_buff, usr_max_ch); + if (result != 0) { + continue; + } + + if ((adts.aac_frame_length + ADTS_HEADER_LENGTH) < + (header_len - bytes_taken)) { + ia_adts_header_struct adts_loc; + + handle_bit_buff = ixheaacd_create_init_bit_buf( + &it_bit_buff, (UWORD8 *)(buffer + adts.aac_frame_length), + (WORD16)(header_len - adts.aac_frame_length)); + + adts_loc.sync_word = + (WORD16)ixheaacd_read_bits_buf(handle_bit_buff, 12); + + if (adts_loc.sync_word != 0xFFF) { + continue; + } + + result = + ixheaacd_check_if_adts(&adts_loc, handle_bit_buff, usr_max_ch); + if ((result != 0) || + (adts.samp_freq_index != adts_loc.samp_freq_index) || + (adts.channel_configuration != adts_loc.channel_configuration)) { + continue; + } + } + + { + WORD32 obj_type; + obj_type = adts.profile; + + aac_state_struct->audio_object_type = obj_type; + aac_state_struct->sampling_rate = + ((pstr_samp_rate_info[adts.samp_freq_index].sampling_frequency)); + aac_state_struct->ch_config = adts.channel_configuration; + aac_state_struct->s_adts_hdr_present = 1; + header_found = 1; + aac_state_struct->bs_format = ADTS_BSFORMAT; + aac_state_struct->frame_length = FRAME_SIZE; + if (aac_state_struct->audio_object_type == AOT_ER_AAC_LD) + aac_state_struct->frame_length >>= 1; + } + } else if (0x2b7 == (sync >> 1)) { + ixheaacd_read_bidirection(&it_bit_buff, -12); + result = + ixheaacd_latm_header_decode(aac_state_struct, &it_bit_buff, + bytes_consumed, pstr_samp_rate_info); + if (result != 0) { + if ((result == + (WORD32) + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES) || + (result == + (WORD32)IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX)) { + bytes_taken += *bytes_consumed; + *bytes_consumed = bytes_taken; + return result; + } else + bytes_taken += *bytes_consumed - 1; + continue; + } + header_found = 1; + aac_state_struct->bs_format = LOAS_BSFORMAT; + bytes_taken += *bytes_consumed; + } + + } while ((header_found == 0 && ((bytes_taken + 1) < (header_len - 68))) && + run_once != 1); + + if (header_found == 0 && disable_sync == 1) { + WORD32 err_code; + ixheaacd_read_bidirection(&it_bit_buff, -12); + err_code = + ixheaacd_ga_hdr_dec(aac_state_struct, header_len, bytes_consumed, + pstr_samp_rate_info, handle_bit_buff); + + if (err_code == 0) p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 1; + return err_code; + } + + if (aac_state_struct->audio_object_type != AOT_USAC) + aac_state_struct->usac_flag = 0; + *bytes_consumed = bytes_taken; + + if ((handle_bit_buff->cnt_bits < 0) && + (handle_bit_buff->size < + (usr_max_ch * (IA_ENHAACPLUS_DEC_INP_BUF_SIZE << 3)))) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + + if (header_found == 0) { + *bytes_consumed = bytes_taken + 1; + return IA_ENHAACPLUS_DEC_INIT_NONFATAL_HEADER_NOT_AT_START; + } else { + return 0; + } + } +} diff --git a/decoder/ixheaacd_headerdecode.h b/decoder/ixheaacd_headerdecode.h new file mode 100644 index 0000000..f813de6 --- /dev/null +++ b/decoder/ixheaacd_headerdecode.h @@ -0,0 +1,71 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_HEADERDECODE_H +#define IXHEAACD_HEADERDECODE_H + +typedef struct { + WORD32 bit_stream_type; + WORD32 prog_config_present; + ia_program_config_struct str_prog_config; +} ia_adif_header_struct; + +WORD32 ixheaacd_aac_headerdecode( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, UWORD8 *buffer, + WORD32 *bytes_consumed, + const ia_aac_dec_huffman_tables_struct *ptr_huffmann_tables); + +ia_aac_decoder_struct *ixheaacd_aac_decoder_init( + ia_aac_dec_state_struct *p_state_enhaacplus_dec, + ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream, WORD channels, + VOID *aac_persistent_mem_v, WORD32 frame_length); + +VOID ixheaacd_fill_prog_config_slots( + ia_aac_dec_state_struct *p_state_enhaacplus_dec); + +WORD ixheaacd_decode_pce(struct ia_bit_buf_struct *it_bit_buff, + UWORD32 *ui_pce_found_in_hdr, + ia_program_config_struct *pce_t); + +WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *pstate_aac_dec, + WORD32 header_len, WORD32 *bytes_consumed, + ia_sampling_rate_info_struct *pstr_samp_rate_info, + struct ia_bit_buf_struct *it_bit_buff); + +WORD32 ixheaacd_latm_audio_mux_element( + struct ia_bit_buf_struct *it_bit_buff, ixheaacd_latm_struct *latm_element, + ia_aac_dec_state_struct *aac_state_struct, + ia_sampling_rate_info_struct *sample_rate_info); + +WORD32 ixheaacd_get_element_index_tag( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD ch_idx1, + WORD *ch_idx, WORD *channel, WORD *element_index_order, WORD total_elements, + WORD8 *element_used, WORD total_channels, ia_drc_dec_struct *pstr_drc_dec, + ia_drc_dec_struct *drc_dummy); + +WORD32 ixheaacd_latm_audio_mux_element( + struct ia_bit_buf_struct *it_bit_buff, ixheaacd_latm_struct *latm_element, + ia_aac_dec_state_struct *aac_state_struct, + ia_sampling_rate_info_struct *ptr_samp_rate_info); + +VOID ixheaacd_set_sbr_persistent_table_pointer( + VOID *sbr_persistent_mem_v, ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *ptr_common_tables); + +#endif /* IXHEAACD_HEADERDECODE_H */ diff --git a/decoder/ixheaacd_huff_code_reorder.c b/decoder/ixheaacd_huff_code_reorder.c new file mode 100644 index 0000000..bc74d6a --- /dev/null +++ b/decoder/ixheaacd_huff_code_reorder.c @@ -0,0 +1,1872 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" +#include "ixheaacd_aac_rom.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_common_rom.h" + +#include "ixheaacd_aacdec.h" + +#include "ixheaacd_sbrdecsettings.h" + +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_cnst.h" +#include "ixheaacd_rvlc.h" + +const UWORD8 ixheaacd_min_huff_cb_pair_tbl[MAX_CB_PAIRS] = { + 0, 1, 3, 5, 7, 9, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 11}; +const UWORD8 ixheaacd_max_huff_cb_pair_table[MAX_CB_PAIRS] = { + 0, 2, 4, 6, 8, 10, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 11}; +const UWORD8 ixheaacd_max_huff_cw_len_table[MAX_CB] = { + 0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49, 0, 0, 0, 0, + 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41}; +const UWORD8 ixheaacd_huff_cb_dim_table[MAX_CB] = { + 2, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; +const UWORD8 ixheaacd_huff_cb_dim_shift_table[MAX_CB] = { + 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +const UWORD8 ixheaacd_huff_cb_sign_table[MAX_CB] = { + 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +const UWORD8 ixheaacd_huff_cb_priority_table[MAX_CB] = { + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 22, 0, 0, 0, 0, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}; +const UWORD16 ixheaacd_huff_reord_lav_table[MAX_CB] = { + 0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, + 8191, 0, 0, 0, 0, 15, 31, 47, 63, 95, 127, + 159, 191, 223, 255, 319, 383, 511, 767, 1023, 2047}; + +VOID ixheaacd_huff_code_reorder_tbl_init(ia_hcr_info_struct *ptr_hcr_info) { + ptr_hcr_info->codebook_pairs.ptr_min_cb_pair_tbl = + ixheaacd_min_huff_cb_pair_tbl; + ptr_hcr_info->codebook_pairs.ptr_max_cb_pair_tbl = + ixheaacd_max_huff_cb_pair_table; + ptr_hcr_info->table_info.ptr_max_cw_len_tbl = ixheaacd_max_huff_cw_len_table; + ptr_hcr_info->table_info.ptr_cb_dimension_tbl = ixheaacd_huff_cb_dim_table; + ptr_hcr_info->table_info.ptr_cb_dim_shift_tbl = + ixheaacd_huff_cb_dim_shift_table; + ptr_hcr_info->table_info.ptr_cb_sign_tbl = ixheaacd_huff_cb_sign_table; + ptr_hcr_info->table_info.ptr_cb_priority = ixheaacd_huff_cb_priority_table; + ptr_hcr_info->table_info.ptr_lav_tbl = ixheaacd_huff_reord_lav_table; +} + +VOID ixheaacd_huff_mute_erroneous_lines(ia_hcr_info_struct *ptr_hcr_info) { + WORD32 c; + WORD32 *ptr_long = ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base; + + for (c = 0; c < 1024; c++) { + if (ptr_long[c] == (WORD32)8192) { + ptr_long[c] = 0; + } + } +} + +static UWORD8 ixheaacd_err_detect_pcw_segment(WORD8 remaining_bits_in_segment, + ia_hcr_info_struct *ptr_hcr_info, + ia_pcw_type_struct kind, + WORD32 *qsc_base_of_cw, + UWORD8 dimension) { + WORD8 i; + if (remaining_bits_in_segment < 0) { + switch (kind) { + case PCW: + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 31); + break; + case PCW_SIGN: + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 30); + break; + case PCW_ESC_SIGN: + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 29); + break; + } + for (i = dimension; i != 0; i--) { + *qsc_base_of_cw++ = (WORD32)8192; + } + return 1; + } + return 0; +} + +static VOID ixheaacd_nonpcw_sideinfo_init( + ia_hcr_info_struct *ptr_hcr_info) { + UWORD16 i, k; + UWORD8 cb_dim; + UWORD8 *ptr_cb = ptr_hcr_info->str_non_pcw_side_info.ptr_cb; + UWORD16 *res_ptr_idx = ptr_hcr_info->str_non_pcw_side_info.res_ptr_idx; + UWORD16 *ptr_num_ext_sorted_cw_in_sect = + ptr_hcr_info->sect_info.ptr_num_ext_sorted_cw_in_sect; + WORD32 num_ext_sorted_cw_in_sect_idx = + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx; + UWORD8 *ptr_ext_sorted_cw = ptr_hcr_info->sect_info.ptr_ext_sorted_cw; + WORD32 ext_sorted_cw_idx = ptr_hcr_info->sect_info.ext_sorted_cw_idx; + UWORD16 *ptr_num_ext_sorted_sect_in_sets = + ptr_hcr_info->sect_info.ptr_num_ext_sorted_sect_in_sets; + WORD32 num_ext_sorted_sect_in_sets_idx = + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx; + WORD32 quant_spec_coeff_idx = ptr_hcr_info->str_dec_io.quant_spec_coeff_idx; + const UWORD8 *ptr_cb_dimension_tbl = + ptr_hcr_info->table_info.ptr_cb_dimension_tbl; + WORD32 loop_idx = 0; + + for (i = ptr_num_ext_sorted_sect_in_sets[num_ext_sorted_sect_in_sets_idx]; + i != 0; i--) { + cb_dim = ptr_cb_dimension_tbl[ptr_ext_sorted_cw[ext_sorted_cw_idx]]; + + for (k = ptr_num_ext_sorted_cw_in_sect[num_ext_sorted_cw_in_sect_idx]; + k != 0; k--) { + loop_idx++; + if (loop_idx > 256) { + return; + } + *ptr_cb++ = ptr_ext_sorted_cw[ext_sorted_cw_idx]; + *res_ptr_idx++ = quant_spec_coeff_idx; + quant_spec_coeff_idx += cb_dim; + if (quant_spec_coeff_idx >= 1024) { + return; + } + } + num_ext_sorted_cw_in_sect_idx++; + ext_sorted_cw_idx++; + if (num_ext_sorted_cw_in_sect_idx >= (MAX_SFB_HCR + MAX_HCR_SETS) || + ext_sorted_cw_idx >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + return; + } + } + num_ext_sorted_sect_in_sets_idx++; + if (num_ext_sorted_cw_in_sect_idx >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + return; + } + + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx = + num_ext_sorted_cw_in_sect_idx; + ptr_hcr_info->sect_info.ext_sorted_cw_idx = ext_sorted_cw_idx; + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx = + num_ext_sorted_sect_in_sets_idx; + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx = + num_ext_sorted_cw_in_sect_idx; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = quant_spec_coeff_idx; +} + +static VOID ixheaacd_calc_num_ext_sorted_sect_sets( + UWORD32 num_segment, UWORD16 *ptr_num_ext_sorted_cw_in_sect, + WORD32 num_ext_sorted_cw_in_sect_idx, + UWORD16 *ptr_num_ext_sorted_sect_in_sets, + WORD32 num_ext_sorted_sect_in_sets_idx) { + UWORD16 counter = 0; + UWORD32 cw_sum = 0; + UWORD16 *ptr_num_ext_sort_cw_in_sect = ptr_num_ext_sorted_cw_in_sect; + UWORD16 *ptr_num_ext_sort_sect_in_sets = ptr_num_ext_sorted_sect_in_sets; + + while (ptr_num_ext_sort_cw_in_sect[num_ext_sorted_cw_in_sect_idx] != 0) { + cw_sum += ptr_num_ext_sort_cw_in_sect[num_ext_sorted_cw_in_sect_idx]; + num_ext_sorted_cw_in_sect_idx++; + if (num_ext_sorted_cw_in_sect_idx >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + return; + } + if (cw_sum > num_segment) { + return; + } + counter++; + if (counter > 256) { + return; + } + if (cw_sum == num_segment) { + ptr_num_ext_sort_sect_in_sets[num_ext_sorted_sect_in_sets_idx] = counter; + num_ext_sorted_sect_in_sets_idx++; + if (num_ext_sorted_sect_in_sets_idx >= MAX_HCR_SETS) { + return; + } + counter = 0; + cw_sum = 0; + } + } + ptr_num_ext_sort_sect_in_sets[num_ext_sorted_sect_in_sets_idx] = counter; +} + +static VOID ixheaacd_validate_hcr_sideinfo(WORD8 cb, WORD32 num_line, + UWORD32 *error_word) { + if (cb < ZERO_HCB || cb >= MAX_CB_CHECK || cb == (ESC_HCB + 1)) { + *error_word |= (ERROR_POS << 4); + } + if (num_line < 0 || num_line > 1024) { + *error_word |= (ERROR_POS << 5); + } +} + +static VOID ixheaacd_validate_hcr_lengths(WORD8 longest_cw_len, + WORD16 reordered_spec_data_len, + UWORD32 *error_word) { + if (reordered_spec_data_len < longest_cw_len) { + *error_word |= (ERROR_POS << 8); + } +} + +UWORD32 ixheaacd_huff_code_reorder_init( + ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, ia_bit_buf_struct *itt_bit_buff) { + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + WORD16 *ptr_num_sect_lines; + UWORD8 *ptr_cb; + WORD16 num_sect; + WORD8 cb; + WORD32 num_line; + WORD32 i; + + ptr_hcr_info->str_dec_io.reordered_spec_data_len = + ptr_aac_dec_channel_info->reorder_spect_data_len; + ptr_hcr_info->str_dec_io.longest_cw_len = + ptr_aac_dec_channel_info->longest_cw_len; + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base = + ptr_aac_dec_channel_info->ptr_spec_coeff; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = 0; + ptr_hcr_info->str_dec_io.ptr_cb = ptr_aac_dec_channel_info->cb4_hcr_arr; + ptr_hcr_info->str_dec_io.ptr_num_line_in_sect = + ptr_aac_dec_channel_info->num_line_in_sec4_hcr_arr; + ptr_hcr_info->str_dec_io.num_sect = ptr_aac_dec_channel_info->number_sect; + ptr_hcr_info->str_dec_io.err_log = 0; + ptr_hcr_info->str_non_pcw_side_info.ptr_result_base = + ptr_aac_dec_channel_info->ptr_spec_coeff; + + ptr_hcr_info->str_dec_io.bit_str_idx = + itt_bit_buff->size - itt_bit_buff->cnt_bits; + itt_bit_buff->byte_ptr = (UWORD8 *)ptr_aac_dec_channel_info->scratch_buf_ptr; + itt_bit_buff->ptr_start = (UWORD8 *)ptr_aac_dec_channel_info->scratch_buf_ptr; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + WORD16 band; + WORD16 max_band; + WORD8 group; + WORD8 win_group_len; + WORD8 window; + WORD8 num_unit_in_band; + WORD8 cnt_unit_in_band; + WORD8 grp_win; + WORD8 cb_prev; + + WORD8 *ptr_code_book; + const WORD16 *band_offsets; + WORD16 num_groups; + + ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; + ptr_num_sect_lines = ptr_hcr_info->str_dec_io.ptr_num_line_in_sect; + ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + band_offsets = (WORD16 *)ixheaacd_getscalefactorbandoffsets(ptr_ics_info, + ptr_aac_tables); + num_groups = ptr_ics_info->num_window_groups; + + num_line = 0; + num_sect = 0; + cb = ptr_code_book[0]; + cb_prev = ptr_code_book[0]; + + *ptr_cb++ = cb_prev; + + max_band = ptr_ics_info->max_sfb; + for (band = 0; band < max_band; band++) { + num_unit_in_band = ((band_offsets[band + 1] - band_offsets[band]) >> 2); + for (cnt_unit_in_band = num_unit_in_band; cnt_unit_in_band != 0; + cnt_unit_in_band--) { + for (window = 0, group = 0; group < num_groups; group++) { + win_group_len = ptr_ics_info->window_group_length[group]; + for (grp_win = win_group_len; grp_win != 0; grp_win--, window++) { + cb = ptr_code_book[group * 16 + band]; + if (cb != cb_prev) { + ixheaacd_validate_hcr_sideinfo(cb, num_line, + &ptr_hcr_info->str_dec_io.err_log); + if (ptr_hcr_info->str_dec_io.err_log != 0) { + return (ptr_hcr_info->str_dec_io.err_log); + } + *ptr_cb++ = cb; + *ptr_num_sect_lines++ = num_line; + num_sect++; + + cb_prev = cb; + num_line = LINES_PER_UNIT; + } else { + num_line += LINES_PER_UNIT; + } + } + } + } + } + + num_sect++; + + ixheaacd_validate_hcr_sideinfo(cb, num_line, + &ptr_hcr_info->str_dec_io.err_log); + if (num_sect <= 0 || num_sect > 1024 / 2) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 7); + } + ixheaacd_validate_hcr_lengths( + ptr_hcr_info->str_dec_io.longest_cw_len, + ptr_hcr_info->str_dec_io.reordered_spec_data_len, + &ptr_hcr_info->str_dec_io.err_log); + if (ptr_hcr_info->str_dec_io.err_log != 0) { + return (ptr_hcr_info->str_dec_io.err_log); + } + + *ptr_cb = cb; + *ptr_num_sect_lines = num_line; + ptr_hcr_info->str_dec_io.num_sect = num_sect; + + } else { + ixheaacd_validate_hcr_lengths( + ptr_hcr_info->str_dec_io.longest_cw_len, + ptr_hcr_info->str_dec_io.reordered_spec_data_len, + &ptr_hcr_info->str_dec_io.err_log); + num_sect = ptr_hcr_info->str_dec_io.num_sect; + ptr_num_sect_lines = ptr_hcr_info->str_dec_io.ptr_num_line_in_sect; + ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + if (num_sect <= 0 || num_sect > 64) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 6); + num_sect = 0; + } + + for (i = num_sect; i != 0; i--) { + cb = *ptr_cb++; + + if (cb < ZERO_HCB || cb >= MAX_CB_CHECK || cb == (ESC_HCB + 1)) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 2); + } + + num_line = *ptr_num_sect_lines++; + + if ((num_line <= 0) || (num_line > 1024)) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 3); + } + } + if (ptr_hcr_info->str_dec_io.err_log != 0) { + return (ptr_hcr_info->str_dec_io.err_log); + } + } + + ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + for (i = 0; i < num_sect; i++) { + if ((*ptr_cb == NOISE_HCB) || (*ptr_cb == INTENSITY_HCB2) || + (*ptr_cb == INTENSITY_HCB)) { + *ptr_cb = 0; + } + ptr_cb++; + } + + return (ptr_hcr_info->str_dec_io.err_log); +} + +static VOID ixheaacd_huff_calc_num_cwd(ia_hcr_info_struct *ptr_hcr_info) { + WORD32 sect_idx; + UWORD32 num_code_word; + + UWORD32 num_sect = ptr_hcr_info->str_dec_io.num_sect; + UWORD8 *ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + WORD16 *ptr_num_line_in_sect = ptr_hcr_info->str_dec_io.ptr_num_line_in_sect; + const UWORD8 *ptr_cb_dim_shift_tbl = + ptr_hcr_info->table_info.ptr_cb_dim_shift_tbl; + UWORD16 *ptr_num_cw_in_sect = ptr_hcr_info->sect_info.ptr_num_cw_in_sect; + + num_code_word = 0; + for (sect_idx = num_sect; sect_idx != 0; sect_idx--) { + *ptr_num_cw_in_sect = + *ptr_num_line_in_sect++ >> ptr_cb_dim_shift_tbl[*ptr_cb]; + if (*ptr_cb != 0) { + num_code_word += *ptr_num_cw_in_sect; + } + ptr_num_cw_in_sect++; + ptr_cb++; + } + ptr_hcr_info->sect_info.num_code_word = num_code_word; +} + +static VOID ixheaacd_huff_sort_sect_cb_cwd(ia_hcr_info_struct *ptr_hcr_info) { + UWORD32 i, j, k; + UWORD8 temp; + UWORD32 counter; + UWORD32 start_offset; + UWORD32 num_zero_sect; + UWORD8 *ptr_dest; + UWORD32 num_sect_dec; + + UWORD32 num_sect = ptr_hcr_info->str_dec_io.num_sect; + UWORD8 *ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + UWORD8 *ptr_sorted_cb = ptr_hcr_info->sect_info.ptr_sorted_cb; + UWORD16 *ptr_num_cw_in_sect = ptr_hcr_info->sect_info.ptr_num_cw_in_sect; + UWORD16 *ptr_num_sorted_cw_in_sect = + ptr_hcr_info->sect_info.ptr_num_sorted_cw_in_sect; + UWORD8 *ptr_cb_switch = ptr_hcr_info->sect_info.ptr_cb_switch; + UWORD16 *ptr_reorder_offset = ptr_hcr_info->sect_info.ptr_reorder_offset; + const UWORD8 *ptr_cb_priority = ptr_hcr_info->table_info.ptr_cb_priority; + const UWORD8 *ptr_min_cb_pair_tbl = + ptr_hcr_info->codebook_pairs.ptr_min_cb_pair_tbl; + const UWORD8 *ptr_max_cb_pair_tbl = + ptr_hcr_info->codebook_pairs.ptr_max_cb_pair_tbl; + const UWORD8 *ptr_cb_dim_shift_tbl = + ptr_hcr_info->table_info.ptr_cb_dim_shift_tbl; + + UWORD32 search_start_idx = 0; + + ptr_dest = ptr_sorted_cb; + num_zero_sect = 0; + for (i = num_sect; i != 0; i--) { + if (ptr_cb_priority[*ptr_cb] == 0) { + num_zero_sect += 1; + } + *ptr_dest++ = ptr_cb_priority[*ptr_cb++]; + } + ptr_hcr_info->sect_info.num_sorted_section = num_sect - num_zero_sect; + ptr_cb = ptr_hcr_info->str_dec_io.ptr_cb; + + num_sect_dec = num_sect - 1; + if (num_sect_dec > 0) { + counter = num_sect_dec; + for (j = num_sect_dec; j != 0; j--) { + for (i = 0; i < counter; i++) { + if (ptr_sorted_cb[i + 1] > ptr_sorted_cb[i]) { + temp = ptr_sorted_cb[i]; + ptr_sorted_cb[i] = ptr_sorted_cb[i + 1]; + ptr_sorted_cb[i + 1] = temp; + } + } + counter -= 1; + } + } + + for (i = num_sect; i != 0; i--) { + *ptr_cb_switch++ = 0; + } + ptr_cb_switch = ptr_hcr_info->sect_info.ptr_cb_switch; + + for (j = 0; j < num_sect; j++) { + for (i = search_start_idx; i < num_sect; i++) { + if (ptr_cb_switch[i] == 0 && + (ptr_min_cb_pair_tbl[ptr_sorted_cb[j]] == ptr_cb[i] || + ptr_max_cb_pair_tbl[ptr_sorted_cb[j]] == ptr_cb[i])) { + ptr_cb_switch[i] = 1; + ptr_sorted_cb[j] = ptr_cb[i]; + ptr_num_sorted_cw_in_sect[j] = ptr_num_cw_in_sect[i]; + + start_offset = 0; + for (k = 0; k < i; k++) { + start_offset += ptr_num_cw_in_sect[k] + << ptr_cb_dim_shift_tbl[ptr_cb[k]]; + } + ptr_reorder_offset[j] = start_offset; + + if (i == search_start_idx) { + UWORD32 k = i; + while (ptr_cb_switch[k++] == 1) search_start_idx++; + } + break; + } + } + } +} + +static VOID ixheaacd_huff_ext_sect_info(ia_hcr_info_struct *ptr_hcr_info) { + UWORD32 srt_sec_cnt = 0; + UWORD32 x_srt_sc_cnt = 0; + UWORD32 remain_num_cw_sort_sec; + UWORD32 in_segment_remain_num_cw; + + UWORD32 num_sorted_section = ptr_hcr_info->sect_info.num_sorted_section; + UWORD8 *ptr_sorted_cb = ptr_hcr_info->sect_info.ptr_sorted_cb; + UWORD16 *ptr_num_sorted_cw_in_sect = + ptr_hcr_info->sect_info.ptr_num_sorted_cw_in_sect; + UWORD8 *ptr_extended_sorted_code_book = + ptr_hcr_info->sect_info.ptr_ext_sorted_cw; + UWORD16 *ptr_num_ext_sort_cw_sect = + ptr_hcr_info->sect_info.ptr_num_ext_sorted_cw_in_sect; + UWORD32 num_segment = ptr_hcr_info->str_segment_info.num_segment; + UWORD8 *ptr_ext_sorted_sect_max_cb_len = + ptr_hcr_info->sect_info.ptr_ext_sorted_sect_max_cb_len; + WORD8 longest_cw_len = ptr_hcr_info->str_dec_io.longest_cw_len; + const UWORD8 *ptr_max_cw_len_tbl = + ptr_hcr_info->table_info.ptr_max_cw_len_tbl; + + remain_num_cw_sort_sec = ptr_num_sorted_cw_in_sect[srt_sec_cnt]; + in_segment_remain_num_cw = num_segment; + + while (srt_sec_cnt < num_sorted_section) { + if (in_segment_remain_num_cw < remain_num_cw_sort_sec) { + ptr_num_ext_sort_cw_sect[x_srt_sc_cnt] = in_segment_remain_num_cw; + ptr_extended_sorted_code_book[x_srt_sc_cnt] = ptr_sorted_cb[srt_sec_cnt]; + + remain_num_cw_sort_sec -= in_segment_remain_num_cw; + in_segment_remain_num_cw = num_segment; + } else if (in_segment_remain_num_cw == remain_num_cw_sort_sec) { + ptr_num_ext_sort_cw_sect[x_srt_sc_cnt] = in_segment_remain_num_cw; + ptr_extended_sorted_code_book[x_srt_sc_cnt] = ptr_sorted_cb[srt_sec_cnt]; + + srt_sec_cnt++; + remain_num_cw_sort_sec = ptr_num_sorted_cw_in_sect[srt_sec_cnt]; + in_segment_remain_num_cw = num_segment; + } else { + ptr_num_ext_sort_cw_sect[x_srt_sc_cnt] = remain_num_cw_sort_sec; + ptr_extended_sorted_code_book[x_srt_sc_cnt] = ptr_sorted_cb[srt_sec_cnt]; + + in_segment_remain_num_cw -= remain_num_cw_sort_sec; + srt_sec_cnt++; + remain_num_cw_sort_sec = ptr_num_sorted_cw_in_sect[srt_sec_cnt]; + } + ptr_ext_sorted_sect_max_cb_len[x_srt_sc_cnt] = + min(ptr_max_cw_len_tbl[ptr_extended_sorted_code_book[x_srt_sc_cnt]], + longest_cw_len); + + x_srt_sc_cnt += 1; + + if (x_srt_sc_cnt >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 28); + return; + } + } + ptr_num_ext_sort_cw_sect[x_srt_sc_cnt] = 0; +} + +static VOID ixheaacd_hcr_prepare_segmentation_grid( + ia_hcr_info_struct *ptr_hcr_info) { + UWORD16 i, j; + UWORD16 num_segment = 0; + UWORD16 segment_start = 0; + UWORD8 segment_width; + UWORD8 last_segment_width; + UWORD8 sorted_code_book; + UWORD8 end_flag = 0; + UWORD16 intermediate_result; + + WORD8 longest_cw_len = ptr_hcr_info->str_dec_io.longest_cw_len; + WORD16 reordered_spec_data_len = + ptr_hcr_info->str_dec_io.reordered_spec_data_len; + UWORD32 num_sorted_section = ptr_hcr_info->sect_info.num_sorted_section; + UWORD8 *ptr_sorted_cb = ptr_hcr_info->sect_info.ptr_sorted_cb; + UWORD16 *ptr_num_sorted_cw_in_sect = + ptr_hcr_info->sect_info.ptr_num_sorted_cw_in_sect; + UWORD16 *arr_seg_start_l = ptr_hcr_info->str_segment_info.arr_seg_start_l; + UWORD16 *arr_seg_start_r = ptr_hcr_info->str_segment_info.arr_seg_start_r; + WORD8 *p_remaining_bits_in_seg = + ptr_hcr_info->str_segment_info.p_remaining_bits_in_seg; + UWORD16 bit_str_idx = ptr_hcr_info->str_dec_io.bit_str_idx; + const UWORD8 *ptr_max_cw_len_tbl = + ptr_hcr_info->table_info.ptr_max_cw_len_tbl; + + for (i = num_sorted_section; i != 0; i--) { + sorted_code_book = *ptr_sorted_cb++; + segment_width = min(ptr_max_cw_len_tbl[sorted_code_book], longest_cw_len); + + for (j = *ptr_num_sorted_cw_in_sect; j != 0; j--) { + intermediate_result = bit_str_idx + segment_start; + if ((segment_start + segment_width) <= reordered_spec_data_len) { + *arr_seg_start_l++ = intermediate_result; + *arr_seg_start_r++ = intermediate_result + segment_width - 1; + *p_remaining_bits_in_seg++ = segment_width; + segment_start += segment_width; + num_segment += 1; + } else { + arr_seg_start_l--; + arr_seg_start_r--; + p_remaining_bits_in_seg--; + segment_start = *arr_seg_start_l - bit_str_idx; + + last_segment_width = reordered_spec_data_len - segment_start; + *p_remaining_bits_in_seg = last_segment_width; + *arr_seg_start_r = bit_str_idx + segment_start + last_segment_width - 1; + end_flag = 1; + break; + } + } + ptr_num_sorted_cw_in_sect++; + if (end_flag != 0) { + break; + } + } + ptr_hcr_info->str_segment_info.num_segment = num_segment; +} + +static PLATFORM_INLINE UWORD16 *ixheaacd_huff_dec_pair_hcr_pcw( + ia_hcr_info_struct *ptr_hcr_info, ia_bit_buf_struct *it_bit_buff, + WORD no_bands, const UWORD16 *code_book_tbl, WORD32 *read_word, + WORD32 tbl_sign, const UWORD32 *idx_table, UWORD16 *arr_seg_start_l, + WORD32 *read_bits, WORD32 huff_mode, WORD8 *p_remaining_bits_in_seg, + WORD32 *ptr_num_decoded_bits) + +{ + WORD32 spec_index = ptr_hcr_info->str_dec_io.quant_spec_coeff_idx; + WORD32 *spec_coef = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base + spec_index; + WORD16 index, length; + WORD32 y, z; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 *bit_pos = &it_bit_buff->bit_pos; + + do { + UWORD32 read_word1; + + WORD32 read_bit_offset = + *arr_seg_start_l - (it_bit_buff->size - *read_bits); + + if (read_bit_offset) { + *read_bits -= read_bit_offset; + *bit_pos += read_bit_offset; + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + } + + read_word1 = *read_word << *bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + *bit_pos += length; + *ptr_num_decoded_bits += length; + *p_remaining_bits_in_seg -= length; + *arr_seg_start_l += length; + *read_bits -= length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + if (tbl_sign) { + WORD32 temp_word; + temp_word = *read_word << *bit_pos; + y = index / huff_mode; + z = index - huff_mode * y; + + if (y) { + if (temp_word & 0x80000000) y = -y; + + temp_word = temp_word << 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + *read_bits -= 1; + } + *spec_coef++ = y; + spec_index++; + + if (z) { + if (temp_word & 0x80000000) { + z = -z; + } + temp_word <<= 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + *read_bits -= 1; + } + *spec_coef++ = z; + spec_index++; + } else { + y = (index / huff_mode) - 4; + z = index - ((y + 4) * huff_mode) - 4; + + *spec_coef++ = y; + *spec_coef++ = z; + spec_index += 2; + } + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + no_bands--; + arr_seg_start_l++; + p_remaining_bits_in_seg++; + } while (no_bands != 0); + + it_bit_buff->ptr_read_next = ptr_read_next; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = spec_index; + + return arr_seg_start_l; +} + +static PLATFORM_INLINE WORD16 ixheaacd_huff_dec_pair_hcr_non_pcw( + ia_bit_buf_struct *itt_bit_buff, WORD32 *spec_coef, + const UWORD16 *code_book_tbl, WORD32 tbl_sign, const UWORD32 *idx_table, + WORD32 huff_mode) + +{ + WORD16 index, length; + WORD32 y, z; + WORD32 read_word1; + WORD32 read_word = ixheaacd_aac_showbits_32(itt_bit_buff->byte_ptr); + + ixheaacd_huffman_decode(read_word, &index, &length, code_book_tbl, idx_table); + read_word1 = read_word << length; + if (tbl_sign) { + WORD32 temp_word; + temp_word = read_word1; + y = index / huff_mode; + z = index - huff_mode * y; + + if (y) { + if (temp_word & 0x80000000) y = -y; + + temp_word = temp_word << 1; + length++; + } + *spec_coef++ = y; + + if (z) { + if (temp_word & 0x80000000) { + z = -z; + } + temp_word <<= 1; + length++; + } + *spec_coef++ = z; + } else { + y = (index / huff_mode) - 4; + z = index - ((y + 4) * huff_mode) - 4; + + *spec_coef++ = y; + *spec_coef++ = z; + } + + return length; +} + +static PLATFORM_INLINE UWORD16 *ixheaacd_huff_dec_quad_hcr_pcw( + ia_hcr_info_struct *ptr_hcr_info, ia_bit_buf_struct *it_bit_buff, + WORD no_bands, const UWORD16 *code_book_tbl, WORD32 tbl_sign, + const UWORD32 *idx_table, WORD32 *read_word, WORD32 *read_bits, + UWORD16 *arr_seg_start_l, WORD8 *p_remaining_bits_in_seg, + WORD32 *ptr_num_decoded_bits) { + WORD16 index, length; + + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 spec_index = ptr_hcr_info->str_dec_io.quant_spec_coeff_idx; + WORD32 *spec_coef = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base + spec_index; + WORD32 *bit_pos = &it_bit_buff->bit_pos; + + do { + UWORD32 read_word1; + + WORD32 read_bit_offset = + *arr_seg_start_l - (it_bit_buff->size - *read_bits); + + if (read_bit_offset) { + *read_bits -= read_bit_offset; + *bit_pos += read_bit_offset; + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + } + + read_word1 = *read_word << *bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, code_book_tbl, + idx_table); + *bit_pos += length; + *p_remaining_bits_in_seg -= length; + *read_bits -= length; + *ptr_num_decoded_bits += length; + *arr_seg_start_l += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + if (tbl_sign) { + WORD32 temp_word; + WORD32 w, x, y, z; + temp_word = *read_word << *bit_pos; + w = index / 27; + index = index - w * 27; + x = index / 9; + index = index - x * 9; + y = index / 3; + z = index - y * 3; + if (w) { + if (temp_word & 0x80000000) w = -w; + temp_word <<= 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *read_bits -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + } + *spec_coef++ = w; + spec_index++; + + if (x) { + if (temp_word & 0x80000000) x = -x; + temp_word <<= 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *read_bits -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + } + *spec_coef++ = x; + spec_index++; + if (y) { + if (temp_word & 0x80000000) y = -y; + temp_word <<= 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *read_bits -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + } + *spec_coef++ = y; + spec_index++; + if (z) { + if (temp_word & 0x80000000) z = -z; + temp_word <<= 1; + *bit_pos += 1; + *p_remaining_bits_in_seg -= 1; + *read_bits -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + } + *spec_coef++ = z; + spec_index++; + + } + + else { + WORD32 w, x, y, z; + + w = index / 27 - 1; + index = index - (w + 1) * 27; + x = index / 9 - 1; + index = index - (x + 1) * 9; + y = index / 3 - 1; + z = index - ((y + 1) * 3) - 1; + *spec_coef++ = w; + + *spec_coef++ = x; + + *spec_coef++ = y; + + *spec_coef++ = z; + spec_index += 4; + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + arr_seg_start_l++; + p_remaining_bits_in_seg++; + no_bands--; + } while (no_bands != 0); + + it_bit_buff->ptr_read_next = ptr_read_next; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = spec_index; + + return arr_seg_start_l; +} + +static UWORD16 *ixheaacd_huff_dec_word_hcr_pcw( + ia_hcr_info_struct *ptr_hcr_info, ia_bit_buf_struct *it_bit_buff, + WORD no_bands, const UWORD16 *code_book_tbl, WORD32 *read_word, + const UWORD32 *idx_table, UWORD16 *arr_seg_start_l, WORD32 *read_bits, + WORD8 *p_remaining_bits_in_seg, WORD32 *ptr_num_decoded_bits) { + WORD32 sp1, sp2; + WORD32 flush_cw; + WORD32 i, value, norm_val, off; + WORD32 out1, out2; + WORD16 index, length; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 spec_index = ptr_hcr_info->str_dec_io.quant_spec_coeff_idx; + WORD32 *spec_coef = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base + spec_index; + WORD32 *bit_pos = &it_bit_buff->bit_pos; + + do { + UWORD32 read_word1; + + WORD32 read_bit_offset = + *arr_seg_start_l - (it_bit_buff->size - *read_bits); + + if (read_bit_offset) { + *read_bits -= read_bit_offset; + *bit_pos += read_bit_offset; + ixheaacd_aac_read_byte_corr1(&ptr_read_next, (WORD16 *)bit_pos, + read_word); + } + + read_word1 = *read_word << *bit_pos; + ixheaacd_huff_sfb_table(read_word1, &index, &length, code_book_tbl, + idx_table); + *bit_pos += length; + *read_bits -= length; + *arr_seg_start_l += length; + *p_remaining_bits_in_seg -= length; + *ptr_num_decoded_bits += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + out1 = index / 17; + out2 = index - out1 * 17; + flush_cw = *read_word << *bit_pos; + + sp1 = out1; + sp2 = out2; + + if (out1) { + if (flush_cw & 0x80000000) { + out1 = -out1; + } + *bit_pos += 1; + *read_bits -= 1; + *p_remaining_bits_in_seg -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + flush_cw = (WORD32)flush_cw << 1; + } + + if (out2) { + *bit_pos += 1; + *read_bits -= 1; + *p_remaining_bits_in_seg -= 1; + *ptr_num_decoded_bits += 1; + *arr_seg_start_l += 1; + if (flush_cw & 0x80000000) { + out2 = -out2; + } + } + + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + if (sp1 == 16) { + i = 4; + value = ixheaacd_extu(*read_word, *bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + *bit_pos += (norm_val - 21); + *p_remaining_bits_in_seg -= (norm_val - 21); + *ptr_num_decoded_bits += (norm_val - 21); + *read_bits -= (norm_val - 21); + *arr_seg_start_l += (norm_val - 21); + + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(*read_word, *bit_pos, 32 - i); + + *bit_pos += i; + *p_remaining_bits_in_seg -= i; + *ptr_num_decoded_bits += i; + *read_bits -= i; + *arr_seg_start_l += i; + + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + i = off + ((WORD32)1 << i); + + if (out1 < 0) + *spec_coef++ = -i; + else + *spec_coef++ = i; + spec_index++; + } else { + *spec_coef++ = out1; + spec_index++; + } + + if (sp2 == 16) { + i = 4; + value = ixheaacd_extu(*read_word, *bit_pos, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + + *bit_pos += (norm_val - 21); + *read_bits -= (norm_val - 21); + *p_remaining_bits_in_seg -= (norm_val - 21); + *ptr_num_decoded_bits += (norm_val - 21); + *arr_seg_start_l += (norm_val - 21); + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + off = ixheaacd_extu(*read_word, *bit_pos, 32 - i); + + *bit_pos += i; + *p_remaining_bits_in_seg -= i; + *ptr_num_decoded_bits += i; + *read_bits -= i; + *arr_seg_start_l += i; + + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + ixheaacd_aac_read_byte_corr(&ptr_read_next, bit_pos, read_word, + it_bit_buff->ptr_bit_buf_end); + + i = off + ((WORD32)1 << i); + + if (out2 < 0) + *spec_coef++ = -i; + else + *spec_coef++ = i; + spec_index++; + } else { + *spec_coef++ = out2; + spec_index++; + } + + arr_seg_start_l++; + p_remaining_bits_in_seg++; + + no_bands--; + } while (no_bands != 0); + + it_bit_buff->ptr_read_next = ptr_read_next; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = spec_index; + + return arr_seg_start_l; +} + +static VOID ixheaacd_decode_pcw( + ia_bit_buf_struct *itt_bit_buff, ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + UWORD16 ext_sort_sec; + UWORD16 cur_ext_sort_cw_sec; + UWORD8 codebook; + UWORD8 dimension; + + + WORD32 num_ext_sorted_cw_in_sect_idx = + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx; + UWORD8 *ptr_ext_sorted_cw = ptr_hcr_info->sect_info.ptr_ext_sorted_cw; + WORD32 ext_sorted_cw_idx = ptr_hcr_info->sect_info.ext_sorted_cw_idx; + UWORD16 *ptr_num_ext_sorted_sect_in_sets = + ptr_hcr_info->sect_info.ptr_num_ext_sorted_sect_in_sets; + WORD32 num_ext_sorted_sect_in_sets_idx = + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx; + WORD32 *ptr_quant_spec_coeff = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base; + UWORD16 *arr_seg_start_l = ptr_hcr_info->str_segment_info.arr_seg_start_l; + WORD8 *p_remaining_bits_in_seg = + ptr_hcr_info->str_segment_info.p_remaining_bits_in_seg; + UWORD8 *ptr_ext_sorted_sect_max_cb_len = + ptr_hcr_info->sect_info.ptr_ext_sorted_sect_max_cb_len; + WORD32 ext_sorted_sect_max_cb_len_idx = + ptr_hcr_info->sect_info.ext_sorted_sect_max_cb_len_idx; + UWORD8 max_allowed_cw_len; + WORD32 num_decoded_bits; + const UWORD8 *ptr_cb_dimension_tbl = + ptr_hcr_info->table_info.ptr_cb_dimension_tbl; + const UWORD16 *cb_table; + const UWORD32 *idx_table; + + WORD32 read_word = ixheaacd_aac_showbits_32(itt_bit_buff->ptr_read_next); + WORD32 read_bits = itt_bit_buff->cnt_bits; + + + itt_bit_buff->ptr_read_next += 4; + + for (ext_sort_sec = + ptr_num_ext_sorted_sect_in_sets[num_ext_sorted_sect_in_sets_idx]; + ext_sort_sec != 0; ext_sort_sec--) { + codebook = ptr_ext_sorted_cw[ext_sorted_cw_idx]; + cb_table = (UWORD16 *)(ptr_aac_tables->code_book[codebook]); + idx_table = (UWORD32 *)(ptr_aac_tables->index_table[codebook]); + ext_sorted_cw_idx++; + if (ext_sorted_cw_idx >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + return; + } + dimension = ptr_cb_dimension_tbl[codebook]; + max_allowed_cw_len = + ptr_ext_sorted_sect_max_cb_len[ext_sorted_sect_max_cb_len_idx]; + ext_sorted_sect_max_cb_len_idx++; + if (ext_sorted_sect_max_cb_len_idx >= (MAX_SFB_HCR + MAX_HCR_SETS)) { + return; + } + + if (codebook <= 4) { + WORD32 tbl_sign = 0; + + if (codebook > 2) { + tbl_sign = 1; + } + + { + num_decoded_bits = 0; + cur_ext_sort_cw_sec = + ptr_hcr_info->sect_info + .ptr_num_ext_sorted_cw_in_sect[num_ext_sorted_cw_in_sect_idx]; + + arr_seg_start_l = ixheaacd_huff_dec_quad_hcr_pcw( + ptr_hcr_info, itt_bit_buff, cur_ext_sort_cw_sec, cb_table, tbl_sign, + idx_table, &read_word, &read_bits, arr_seg_start_l, + p_remaining_bits_in_seg, &num_decoded_bits); + + p_remaining_bits_in_seg += cur_ext_sort_cw_sec; + + if (cur_ext_sort_cw_sec * max_allowed_cw_len < num_decoded_bits) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 19); + } + + if (1 == + ixheaacd_err_detect_pcw_segment( + *p_remaining_bits_in_seg, ptr_hcr_info, PCW, + ptr_quant_spec_coeff + + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx - dimension, + dimension)) { + return; + } + } + } else if (codebook < 11) { + { + WORD32 tbl_sign = 0; + WORD32 huff_mode = 9; + num_decoded_bits = 0; + + if (codebook > 6) { + if (codebook > 8) + huff_mode = 13; + else + huff_mode = 8; + tbl_sign = 1; + } + + cur_ext_sort_cw_sec = + ptr_hcr_info->sect_info + .ptr_num_ext_sorted_cw_in_sect[num_ext_sorted_cw_in_sect_idx]; + + arr_seg_start_l = ixheaacd_huff_dec_pair_hcr_pcw( + ptr_hcr_info, itt_bit_buff, cur_ext_sort_cw_sec, cb_table, + &read_word, tbl_sign, idx_table, arr_seg_start_l, &read_bits, + huff_mode, p_remaining_bits_in_seg, &num_decoded_bits); + + p_remaining_bits_in_seg += cur_ext_sort_cw_sec; + + if (cur_ext_sort_cw_sec * max_allowed_cw_len < num_decoded_bits) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 18); + } + + if (1 == + ixheaacd_err_detect_pcw_segment( + *p_remaining_bits_in_seg, ptr_hcr_info, PCW_SIGN, + ptr_quant_spec_coeff + + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx - dimension, + dimension)) { + return; + } + } + } else if ((codebook >= 11)) { + const UWORD32 *idx_table = + ptr_aac_tables->pstr_huffmann_tables->idx_table_hf11; + const UWORD16 *cb_table = + ptr_aac_tables->pstr_huffmann_tables->input_table_cb11; + num_decoded_bits = 0; + + cur_ext_sort_cw_sec = + ptr_hcr_info->sect_info + .ptr_num_ext_sorted_cw_in_sect[num_ext_sorted_cw_in_sect_idx]; + + arr_seg_start_l = ixheaacd_huff_dec_word_hcr_pcw( + ptr_hcr_info, itt_bit_buff, cur_ext_sort_cw_sec, cb_table, &read_word, + idx_table, arr_seg_start_l, &read_bits, p_remaining_bits_in_seg, + &num_decoded_bits); + + p_remaining_bits_in_seg += cur_ext_sort_cw_sec; + + if (cur_ext_sort_cw_sec * max_allowed_cw_len < num_decoded_bits) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 17); + } + + if (1 == ixheaacd_err_detect_pcw_segment( + *p_remaining_bits_in_seg, ptr_hcr_info, PCW_ESC_SIGN, + ptr_quant_spec_coeff + + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx - 2, + 2)) { + return; + } + } + + num_ext_sorted_cw_in_sect_idx++; + if (num_ext_sorted_cw_in_sect_idx >= MAX_SFB_HCR + MAX_HCR_SETS) { + return; + } + } + + num_ext_sorted_sect_in_sets_idx++; + if (num_ext_sorted_sect_in_sets_idx >= MAX_HCR_SETS) { + return; + } + + itt_bit_buff->cnt_bits = read_bits; + + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx = + num_ext_sorted_cw_in_sect_idx; + ptr_hcr_info->sect_info.ext_sorted_cw_idx = ext_sorted_cw_idx; + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx = + num_ext_sorted_sect_in_sets_idx; + ptr_hcr_info->sect_info.ext_sorted_sect_max_cb_len_idx = + ext_sorted_sect_max_cb_len_idx; +} + +static UWORD32 ixheaacd_init_segment_bit_field(WORD32 num_segment, + WORD8 *p_remaining_bits_in_seg) { + WORD16 i; + WORD16 num_valid_segment = 0; + + for (i = 0; i < num_segment; i++) { + if (p_remaining_bits_in_seg[i] != 0) { + num_valid_segment += 1; + } + } + + return num_valid_segment; +} + +UWORD8 ixheaacd_toggle_read_dir(UWORD8 read_direction) { + if (read_direction == FROM_LEFT_TO_RIGHT) { + return FROM_RIGHT_TO_LEFT; + } else { + return FROM_LEFT_TO_RIGHT; + } +} + +static PLATFORM_INLINE UWORD16 ixheaacd_huff_dec_quad_hcr_non_pcw( + ia_bit_buf_struct *itt_bit_buff, WORD32 *spec_coef, + const UWORD16 *code_book_tbl, WORD32 tbl_sign, const UWORD32 *idx_table) { + WORD16 index, length; + WORD16 cw_len; + WORD32 read_word = ixheaacd_aac_showbits_32(itt_bit_buff->byte_ptr); + ixheaacd_huffman_decode(read_word, &index, &length, code_book_tbl, idx_table); + cw_len = length; + if (tbl_sign) { + WORD32 temp_word; + WORD32 w, x, y, z; + temp_word = read_word << length; + w = index / 27; + index = index - w * 27; + x = index / 9; + index = index - x * 9; + y = index / 3; + z = index - y * 3; + if (w) { + if (temp_word & 0x80000000) w = -w; + temp_word <<= 1; + cw_len++; + } + *spec_coef++ = w; + + if (x) { + if (temp_word & 0x80000000) x = -x; + temp_word <<= 1; + cw_len++; + } + *spec_coef++ = x; + if (y) { + if (temp_word & 0x80000000) y = -y; + temp_word <<= 1; + cw_len++; + } + *spec_coef++ = y; + if (z) { + if (temp_word & 0x80000000) z = -z; + temp_word <<= 1; + cw_len++; + } + *spec_coef++ = z; + + } + + else { + WORD32 w, x, y, z; + + w = index / 27 - 1; + index = index - (w + 1) * 27; + x = index / 9 - 1; + index = index - (x + 1) * 9; + y = index / 3 - 1; + z = index - ((y + 1) * 3) - 1; + *spec_coef++ = w; + *spec_coef++ = x; + *spec_coef++ = y; + *spec_coef++ = z; + } + + return cw_len; +} + +static PLATFORM_INLINE UWORD16 ixheaacd_huff_dec_word_hcr_non_pcw( + ia_bit_buf_struct *itt_bit_buff, WORD32 *spec_coef, + const UWORD16 *code_book_tbl, const UWORD32 *idx_table) { + WORD32 sp1, sp2; + WORD32 flush_cw; + WORD32 i, value, norm_val, off; + WORD32 out1, out2; + UWORD16 cw_len; + + + WORD16 index, length; + + + WORD32 read_word = ixheaacd_aac_showbits_32(itt_bit_buff->byte_ptr); + UWORD8 *ptr_read_next = itt_bit_buff->byte_ptr; + ptr_read_next += 4; + + ixheaacd_huff_sfb_table(read_word, &index, &length, code_book_tbl, idx_table); + cw_len = length; + + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + + out1 = index / 17; + out2 = index - out1 * 17; + flush_cw = read_word << length; + + sp1 = out1; + sp2 = out2; + + + if (out1) { + if (flush_cw & 0x80000000) { + out1 = -out1; + } + flush_cw = (WORD32)flush_cw << 1; + length++; + cw_len++; + } + + if (out2) { + if (flush_cw & 0x80000000) { + out2 = -out2; + } + length++; + cw_len++; + } + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + + if (sp1 == 16) { + + i = 4; + value = ixheaacd_extu(read_word, length, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + length += (norm_val - 21); + cw_len += (norm_val - 21); + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + + off = ixheaacd_extu(read_word, length, 32 - i); + length += i; + cw_len += i; + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + + i = off + ((WORD32)1 << i); + + if (out1 < 0) + *spec_coef++ = -i; + else + *spec_coef++ = i; + } else { + *spec_coef++ = out1; + } + + if (sp2 == 16) { + i = 4; + value = ixheaacd_extu(read_word, length, 23); + value = value | 0xfffffe00; + norm_val = ixheaacd_norm32(value); + + i += (norm_val - 22); + length += (norm_val - 21); + cw_len += (norm_val - 21); + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + + off = ixheaacd_extu(read_word, length, 32 - i); + length += i; + cw_len += i; + + ixheaacd_aac_read_byte_corr1(&ptr_read_next, &length, &read_word); + i = off + ((WORD32)1 << i); + + if (out2 < 0) + *spec_coef++ = -i; + else + *spec_coef++ = i; + } else { + *spec_coef++ = out2; + } + + return cw_len; +} + +static VOID ixheaacd_decode_hcr_non_pcw( + ia_bit_buf_struct *itt_bit_buff, ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 *cw_offset, WORD32 trial, + WORD32 start) { + UWORD16 *cb_table; + UWORD32 *idx_table; + WORD16 codeword_len = 0; + WORD8 seg_bits_left; + UWORD8 tot_bits_to_save, code_bits_to_save, extra_code_bits; + WORD32 segment_offset = 0; + WORD8 *p_remaining_bits_in_seg = + ptr_hcr_info->str_segment_info.p_remaining_bits_in_seg; + WORD32 num_segment = ptr_hcr_info->str_segment_info.num_segment; + + for (segment_offset = start; segment_offset < trial; + segment_offset++, *cw_offset += 1) { + if (p_remaining_bits_in_seg[segment_offset] && + !ptr_hcr_info->str_segment_info.is_decoded[*cw_offset]) { + cb_table = + (UWORD16 *)(ptr_aac_tables + ->code_book[ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment]]); + idx_table = + (UWORD32 *)(ptr_aac_tables + ->index_table[ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment]]); + { + UWORD32 i_qsc; + WORD8 current_seg_bits = p_remaining_bits_in_seg[segment_offset]; + + itt_bit_buff->byte_ptr = itt_bit_buff->ptr_start; + itt_bit_buff->valid_bits = 0; + itt_bit_buff->byte = 0; + itt_bit_buff->bit_count = 0; + itt_bit_buff->write_bit_count = 0; + + if (ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]) { + extra_code_bits = max( + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset] - 32, 0); + code_bits_to_save = + min(ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset], 32); + + ixheaacd_write_bit( + itt_bit_buff, + ptr_hcr_info->str_segment_info.code_extra[*cw_offset], + extra_code_bits); + ixheaacd_write_bit(itt_bit_buff, + ptr_hcr_info->str_segment_info.code[*cw_offset], + code_bits_to_save); + } + { + UWORD32 bit; + WORD32 read_bit_offset; + + if (ptr_hcr_info->str_segment_info.read_direction == + FROM_LEFT_TO_RIGHT) { + read_bit_offset = + ptr_hcr_info->str_segment_info.arr_seg_start_l[segment_offset] - + (itt_bit_buff->size - itt_bit_buff->cnt_bits); + if (read_bit_offset) { + itt_bit_buff->cnt_bits += -read_bit_offset; + } + itt_bit_buff->ptr_read_next = + itt_bit_buff->ptr_bit_buf_base + + ((itt_bit_buff->size - itt_bit_buff->cnt_bits) >> 3); + itt_bit_buff->bit_pos = + ((itt_bit_buff->size - itt_bit_buff->cnt_bits) & 7); + + for (; p_remaining_bits_in_seg[segment_offset] > 0; + p_remaining_bits_in_seg[segment_offset] -= 1) { + bit = ixheaacd_aac_read_bit_rev(itt_bit_buff); + ptr_hcr_info->str_segment_info.arr_seg_start_l[segment_offset] += + 1; + + ixheaacd_write_bit(itt_bit_buff, bit, 1); + } + + } else { + read_bit_offset = + ptr_hcr_info->str_segment_info.arr_seg_start_r[segment_offset] - + (itt_bit_buff->size - itt_bit_buff->cnt_bits); + if (read_bit_offset) { + itt_bit_buff->cnt_bits += -read_bit_offset; + } + itt_bit_buff->ptr_read_next = + itt_bit_buff->ptr_bit_buf_base + + ((itt_bit_buff->size - itt_bit_buff->cnt_bits) >> 3); + itt_bit_buff->bit_pos = + ((itt_bit_buff->size - itt_bit_buff->cnt_bits) & 7); + + for (; p_remaining_bits_in_seg[segment_offset] > 0; + p_remaining_bits_in_seg[segment_offset] -= 1) { + bit = ixheaacd_aac_read_bit(itt_bit_buff); + ptr_hcr_info->str_segment_info.arr_seg_start_r[segment_offset] -= + 1; + ixheaacd_write_bit(itt_bit_buff, bit, 1); + } + } + } + + ixheaacd_write_bit(itt_bit_buff, 0, 32 - itt_bit_buff->bit_count % 32); + itt_bit_buff->valid_bits = 8; + itt_bit_buff->byte_ptr = itt_bit_buff->ptr_start; + itt_bit_buff->byte = *itt_bit_buff->ptr_start; + + if (current_seg_bits) { + i_qsc = ptr_hcr_info->str_non_pcw_side_info + .res_ptr_idx[*cw_offset % num_segment]; + + if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] <= 4) { + WORD32 tbl_sign = 0; + + if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] > 2) { + tbl_sign = 1; + } + + codeword_len = ixheaacd_huff_dec_quad_hcr_non_pcw( + itt_bit_buff, + &ptr_hcr_info->str_non_pcw_side_info.ptr_result_base[i_qsc], + cb_table, tbl_sign, idx_table); + + seg_bits_left = + current_seg_bits - codeword_len + + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]; + + } + + else if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] < 11) { + WORD32 tbl_sign = 0; + WORD32 huff_mode = 9; + if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] > 6) { + if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] > 8) + huff_mode = 13; + else + huff_mode = 8; + tbl_sign = 1; + } + codeword_len = ixheaacd_huff_dec_pair_hcr_non_pcw( + itt_bit_buff, + &ptr_hcr_info->str_non_pcw_side_info.ptr_result_base[i_qsc], + cb_table, tbl_sign, idx_table, huff_mode); + + seg_bits_left = + current_seg_bits - codeword_len + + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]; + } + if (ptr_hcr_info->str_non_pcw_side_info + .ptr_cb[*cw_offset % num_segment] >= 11) { + const UWORD32 *idx_table = + ptr_aac_tables->pstr_huffmann_tables->idx_table_hf11; + const UWORD16 *cb_table = + ptr_aac_tables->pstr_huffmann_tables->input_table_cb11; + + codeword_len = ixheaacd_huff_dec_word_hcr_non_pcw( + itt_bit_buff, + &ptr_hcr_info->str_non_pcw_side_info.ptr_result_base[i_qsc], + cb_table, idx_table); + + seg_bits_left = + current_seg_bits - codeword_len + + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]; + } + if (seg_bits_left < 0) { + tot_bits_to_save = + current_seg_bits + + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]; + extra_code_bits = max(tot_bits_to_save - 32, 0); + code_bits_to_save = min(tot_bits_to_save, 32); + + + + ptr_hcr_info->str_segment_info.code_extra[*cw_offset] = + ixheaacd_read_bit(itt_bit_buff, extra_code_bits); + ptr_hcr_info->str_segment_info.code[*cw_offset] = + ixheaacd_read_bit(itt_bit_buff, code_bits_to_save); + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset] = + tot_bits_to_save; + + p_remaining_bits_in_seg[segment_offset] = 0; + if (p_remaining_bits_in_seg[segment_offset] < 0) + p_remaining_bits_in_seg[segment_offset] = 0; + } else { + p_remaining_bits_in_seg[segment_offset] = + current_seg_bits - + (codeword_len - + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset]); + ptr_hcr_info->str_segment_info.p_num_bits[*cw_offset] = 0; + ptr_hcr_info->str_segment_info.is_decoded[*cw_offset] = 1; + if (p_remaining_bits_in_seg[segment_offset] < 0) + p_remaining_bits_in_seg[segment_offset] = 0; + } + + if (p_remaining_bits_in_seg[segment_offset] > 0) { + if (ptr_hcr_info->str_segment_info.read_direction == + FROM_LEFT_TO_RIGHT) + ptr_hcr_info->str_segment_info.arr_seg_start_l[segment_offset] -= + (p_remaining_bits_in_seg[segment_offset]); + else + ptr_hcr_info->str_segment_info.arr_seg_start_r[segment_offset] += + (p_remaining_bits_in_seg[segment_offset]); + } + } + } + } + } +} + +VOID ixheaacd_decode_non_pcw( + ia_bit_buf_struct *itt_bit_buff, ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_tables_struct *ptr_aac_tables) { + UWORD32 num_valid_segment; + WORD32 cw_offset; + WORD32 trial; + WORD32 num_segment; + WORD32 num_code_word; + UWORD8 num_set; + UWORD8 current_set; + WORD32 code_word_set; + WORD32 loop1, loop2; + + num_segment = ptr_hcr_info->str_segment_info.num_segment; + + num_valid_segment = ixheaacd_init_segment_bit_field( + num_segment, ptr_hcr_info->str_segment_info.p_remaining_bits_in_seg); + + if (num_valid_segment != 0) { + num_code_word = ptr_hcr_info->sect_info.num_code_word; + num_set = ((num_code_word - 1) / num_segment) + 1; + + ptr_hcr_info->str_segment_info.read_direction = FROM_RIGHT_TO_LEFT; + + for (current_set = 1; current_set < num_set; current_set++) { + num_code_word -= num_segment; + if (num_code_word < num_segment) { + code_word_set = num_code_word; + } else { + code_word_set = num_segment; + } + + ixheaacd_nonpcw_sideinfo_init(ptr_hcr_info); + + cw_offset = num_segment * current_set; + + ixheaacd_decode_hcr_non_pcw(itt_bit_buff, ptr_hcr_info, ptr_aac_tables, + &cw_offset, code_word_set, 0); + + for (trial = 1; trial < num_segment; trial++) { + cw_offset = num_segment * current_set; + + loop1 = min(num_segment, trial + code_word_set); + loop2 = max(0, trial + code_word_set - num_segment); + + ixheaacd_decode_hcr_non_pcw(itt_bit_buff, ptr_hcr_info, ptr_aac_tables, + &cw_offset, loop1, trial); + + ixheaacd_decode_hcr_non_pcw(itt_bit_buff, ptr_hcr_info, ptr_aac_tables, + &cw_offset, loop2, 0); + } + + ptr_hcr_info->str_segment_info.read_direction = ixheaacd_toggle_read_dir( + ptr_hcr_info->str_segment_info.read_direction); + } + } +} + +static VOID ixheaacd_hcr_reorder_quantized_spec_coeff( + ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + WORD32 qsc; + UWORD32 abs_qsc; + UWORD32 i, j; + UWORD16 num_spec_val_sect; + WORD32 *ptr_teva; + UWORD16 lav_err_cnt = 0; + + UWORD32 num_sect = ptr_hcr_info->str_dec_io.num_sect; + WORD32 *ptr_quant_spec_coeff_base = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base; + WORD32 *ptr_quant_spec_coeff = + ptr_hcr_info->str_dec_io.ptr_quant_spec_coeff_base; + const UWORD8 *ptr_cb_dim_shift_tbl = + ptr_hcr_info->table_info.ptr_cb_dim_shift_tbl; + const UWORD16 *ptr_lav_tbl = ptr_hcr_info->table_info.ptr_lav_tbl; + UWORD8 *ptr_sorted_cb = ptr_hcr_info->sect_info.ptr_sorted_cb; + UWORD16 *ptr_num_sorted_cw_in_sect = + ptr_hcr_info->sect_info.ptr_num_sorted_cw_in_sect; + UWORD16 *ptr_reorder_offset = ptr_hcr_info->sect_info.ptr_reorder_offset; + WORD32 *arr_temp_values = ptr_hcr_info->str_segment_info.arr_temp_values; + WORD32 *ptr_bak = ptr_hcr_info->str_segment_info.arr_temp_values; + + WORD32 cnt = 0; + + for (i = num_sect; i != 0; i--) { + num_spec_val_sect = *ptr_num_sorted_cw_in_sect++ + << ptr_cb_dim_shift_tbl[*ptr_sorted_cb]; + ptr_teva = &arr_temp_values[*ptr_reorder_offset++]; + for (j = num_spec_val_sect; j != 0; j--) { + cnt++; + qsc = *ptr_quant_spec_coeff++; + abs_qsc = ixheaacd_abs32(qsc); + if (abs_qsc <= ptr_lav_tbl[*ptr_sorted_cb]) { + *ptr_teva++ = (WORD32)qsc; + } else { + if (abs_qsc == 8192) { + *ptr_teva++ = (WORD32)qsc; + } else { + *ptr_teva++ = (WORD32)8192; + lav_err_cnt += 1; + } + } + } + ptr_sorted_cb++; + } + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + WORD32 *ptr_out; + WORD8 window; + + ptr_bak = ptr_hcr_info->str_segment_info.arr_temp_values; + for (window = 0; window < 8; window++) { + ptr_out = ptr_quant_spec_coeff_base + + (window * ptr_aac_dec_channel_info->granule_len); + for (i = 0; i < (LINES_PER_UNIT_GROUP); i++) { + ptr_teva = ptr_bak + (window << 2) + i * 32; + for (j = (LINES_PER_UNIT); j != 0; j--) { + *ptr_out++ = *ptr_teva++; + } + } + } + } else { + ptr_quant_spec_coeff = ptr_quant_spec_coeff_base; + for (i = 1024; i != 0; i--) { + *ptr_quant_spec_coeff++ = *ptr_bak++; + } + } + + if (lav_err_cnt != 0) { + ptr_hcr_info->str_dec_io.err_log |= (ERROR_POS << 1); + } +} + +static VOID ixheaacd_err_detect_segmentation_final( + ia_hcr_info_struct *ptr_hcr_info) { + UWORD8 segmentation_err_flag = 0; + UWORD16 i; + WORD8 *p_remaining_bits_in_seg = + ptr_hcr_info->str_segment_info.p_remaining_bits_in_seg; + UWORD32 num_segment = ptr_hcr_info->str_segment_info.num_segment; + + for (i = num_segment; i != 0; i--) { + if (*p_remaining_bits_in_seg++ != 0) { + segmentation_err_flag = 1; + } + } + if (segmentation_err_flag == 1) { + ptr_hcr_info->str_dec_io.err_log |= ERROR_POS; + } +} + +UWORD32 ixheaacd_hcr_decoder( + ia_hcr_info_struct *ptr_hcr_info, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, ia_bit_buf_struct *itt_bit_buff) { + WORD32 ptr_tmp1, ptr_tmp2, ptr_tmp3, ptr_tmp4; + WORD32 ptr_tmp5; + + WORD32 bit_cnt_offset; + UWORD32 save_bit_cnt = itt_bit_buff->cnt_bits; + + ixheaacd_huff_calc_num_cwd(ptr_hcr_info); + + ixheaacd_huff_sort_sect_cb_cwd(ptr_hcr_info); + + ixheaacd_hcr_prepare_segmentation_grid(ptr_hcr_info); + + ixheaacd_huff_ext_sect_info(ptr_hcr_info); + + if ((ptr_hcr_info->str_dec_io.err_log & HCR_FATAL_PCW_ERROR_MASK) != 0) { + return (ptr_hcr_info->str_dec_io.err_log); + } + + ixheaacd_calc_num_ext_sorted_sect_sets( + ptr_hcr_info->str_segment_info.num_segment, + ptr_hcr_info->sect_info.ptr_num_ext_sorted_cw_in_sect, + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx, + ptr_hcr_info->sect_info.ptr_num_ext_sorted_sect_in_sets, + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx); + + ptr_tmp1 = ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx; + ptr_tmp2 = ptr_hcr_info->sect_info.ext_sorted_cw_idx; + ptr_tmp3 = ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx; + ptr_tmp4 = ptr_hcr_info->str_dec_io.quant_spec_coeff_idx; + ptr_tmp5 = ptr_hcr_info->sect_info.ext_sorted_sect_max_cb_len_idx; + + ixheaacd_decode_pcw(itt_bit_buff, ptr_hcr_info, ptr_aac_tables); + + if ((ptr_hcr_info->str_dec_io.err_log & HCR_FATAL_PCW_ERROR_MASK) == 0) { + ixheaacd_decode_non_pcw(itt_bit_buff, ptr_hcr_info, ptr_aac_tables); + } + + ixheaacd_err_detect_segmentation_final(ptr_hcr_info); + + ptr_hcr_info->sect_info.num_ext_sorted_cw_in_sect_idx = ptr_tmp1; + ptr_hcr_info->sect_info.ext_sorted_cw_idx = ptr_tmp2; + ptr_hcr_info->sect_info.num_ext_sorted_sect_in_sets_idx = ptr_tmp3; + ptr_hcr_info->str_dec_io.quant_spec_coeff_idx = ptr_tmp4; + ptr_hcr_info->sect_info.ext_sorted_sect_max_cb_len_idx = ptr_tmp5; + + ixheaacd_hcr_reorder_quantized_spec_coeff( + ptr_hcr_info, ptr_aac_dec_channel_info); + + bit_cnt_offset = (WORD32)itt_bit_buff->cnt_bits - (WORD32)save_bit_cnt; + if (bit_cnt_offset) { + itt_bit_buff->cnt_bits += -bit_cnt_offset; + itt_bit_buff->ptr_read_next = + itt_bit_buff->ptr_bit_buf_base + + ((itt_bit_buff->size - itt_bit_buff->cnt_bits) >> 3); + itt_bit_buff->bit_pos = (itt_bit_buff->size - itt_bit_buff->cnt_bits) & 7; + } + + return (ptr_hcr_info->str_dec_io.err_log); +} diff --git a/decoder/ixheaacd_huff_tools.c b/decoder/ixheaacd_huff_tools.c new file mode 100644 index 0000000..5b0d39b --- /dev/null +++ b/decoder/ixheaacd_huff_tools.c @@ -0,0 +1,110 @@ +/****************************************************************************** + * * + * 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 +#include + +#include +#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) { + WORD32 i, num; + + if (!sign_code_book) { + ptr_huff_code_book->huff_mode = lav + 1; + ptr_huff_code_book->off = 0; + } else { + ptr_huff_code_book->huff_mode = 2 * lav + 1; + ptr_huff_code_book->off = lav; + } + num = 1; + for (i = 0; i < dim; i++) num *= ptr_huff_code_book->huff_mode; + + ptr_huff_code_book->num = num; + ptr_huff_code_book->dim = dim; + ptr_huff_code_book->lav = lav; + ptr_huff_code_book->lav_incr_esc = lav_incr_esc; + ptr_huff_code_book->sign_code_book = sign_code_book; + ptr_huff_code_book->pstr_huff_code_word = ptr_huff_code_word; + 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 i, j; + UWORD32 code_word = 0; + UWORD32 tmp = 0; + + i = ptr_huff_code_word->len; + if (data_present == 0) { + code_word = ixheaacd_read_bits_buf(it_bit_buff, i); + } + + if (data_present == 1) { + code_word = ixheaacd_read_bits_buf(it_bit_buff, i); + } + while (code_word != ptr_huff_code_word->code_word) { + ptr_huff_code_word++; + j = ptr_huff_code_word->len - i; + if (j < 0) { + return ptr_huff_code_word->index; + } + + i += j; + code_word <<= j; + + if (data_present == 0) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, j); + } + + if (data_present == 1) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, j); + } + + code_word |= tmp; + } + return (ptr_huff_code_word->index); +} diff --git a/decoder/ixheaacd_hufftables.c b/decoder/ixheaacd_hufftables.c new file mode 100644 index 0000000..c9c9232 --- /dev/null +++ b/decoder/ixheaacd_hufftables.c @@ -0,0 +1,81 @@ +/****************************************************************************** + * * + * 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 + +#include +#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] = { + 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] = { + 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, + 0x05ea, 0x094a, 0x05ca, 0x098b, 0x096b, 0x09ab, 0x09cb, 0x05ab, 0x056b, + 0x058c, 0x09ec, 0x054c, 0x052c, 0x0a0c, 0x050c, 0x0a2d, 0x04ed, 0x0a4d, + 0x04cd, 0x0a6d, 0x04ae, 0x046e, 0x0aae, 0x042e, 0x048e, 0x044e, 0x0a8e, + 0x040e, 0x0aef, 0x0b2f, 0x03cf, 0x03ef, 0x0ad0, 0x03b0, 0x0350, 0x0370, + 0x0390, 0x0310, 0x0b10, 0x0331, 0x02d1, 0x02f1, 0x0b52, 0x02b2, 0x0272, + 0x0072, 0x0032, 0x0052, 0x0012, 0x0c53, 0x0c73, 0x0c93, 0x0cb3, 0x0cd3, + 0x0eb3, 0x0c33, 0x0b73, 0x0b93, 0x0bb3, 0x0bd3, 0x0bf3, 0x0c13, 0x0d13, + 0x0df3, 0x0e13, 0x0e33, 0x0e53, 0x0e73, 0x0e93, 0x0dd3, 0x0d33, 0x0d53, + 0x0d73, 0x0d93, 0x0db3, 0x0ed3, 0x00d3, 0x0113, 0x0133, 0x0153, 0x00b3, + 0x0cf3, 0x0f13, 0x0ef3, 0x0093, 0x00f3, 0x01f3, 0x0213, 0x0253, 0x0293, + 0x0233, 0x0173, 0x0193, 0x01d3, 0x01b3}; diff --git a/decoder/ixheaacd_hybrid.c b/decoder/ixheaacd_hybrid.c new file mode 100644 index 0000000..3dcaa92 --- /dev/null +++ b/decoder/ixheaacd_hybrid.c @@ -0,0 +1,285 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.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 +#include "ixheaacd_hybrid.h" + +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_dsp_fft32x32s.h" + +#include "ixheaacd_function_selector.h" + +static VOID ixheaacd_filt_2_ch(const WORD32 *ptr_qmf, WORD32 *ptr_hybrid, + ia_sbr_tables_struct *ptr_sbr_tables) { + WORD32 cum0, cum1, cum00, cum11; + WORD16 *p2_6 = ptr_sbr_tables->ps_tables_ptr->p2_6; + + cum0 = ptr_qmf[HYBRID_FILTER_DELAY] >> 1; + cum00 = ptr_qmf[HYBRID_FILTER_DELAY + 16] >> 1; + cum1 = 0L; + cum11 = 0L; + + { + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[1], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[17], *p2_6++)); + + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[3], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[19], *p2_6++)); + + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[5], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[21], *p2_6++)); + + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[7], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[23], *p2_6++)); + + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[9], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[25], *p2_6++)); + + cum1 = ixheaacd_add32_sat(cum1, ixheaacd_mult32x16in32(ptr_qmf[11], *p2_6)); + cum11 = + ixheaacd_add32_sat(cum11, ixheaacd_mult32x16in32(ptr_qmf[27], *p2_6++)); + } + cum1 = ixheaacd_shl32(cum1, 1); + cum11 = ixheaacd_shl32(cum11, 1); + + ptr_hybrid[0] = ixheaacd_add32_sat(cum0, cum1); + ptr_hybrid[1] = ixheaacd_sub32_sat(cum0, cum1); + + ptr_hybrid[16] = ixheaacd_add32_sat(cum00, cum11); + ptr_hybrid[17] = ixheaacd_sub32_sat(cum00, cum11); +} + +static VOID ixheaacd_filt_8_ch(const WORD32 *ptr_qmf_real, + const WORD32 *ptr_qmf_imag, WORD32 *ptr_hyb_real, + WORD32 *ptr_hyb_imag, + ia_sbr_tables_struct *ptr_sbr_tables) { + const WORD16 tcos = 0x7642; + const WORD16 tsin = 0x30fc; + const WORD16 tcom = 0x5a82; + WORD32 real, imag; + WORD32 cum[16]; + const WORD16 *p8_13 = ptr_sbr_tables->ps_tables_ptr->p8_13; + const WORD16 *p8_13_8 = ptr_sbr_tables->ps_tables_ptr->p8_13 + 8; + + real = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_real[0], *p8_13), + ixheaacd_mult32x16in32(ptr_qmf_real[8], *p8_13_8)), + 1); + imag = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_imag[0], *p8_13++), + ixheaacd_mult32x16in32(ptr_qmf_imag[8], *p8_13_8++)), + 1); + + cum[12] = ixheaacd_shl32( + ixheaacd_mult32x16in32(ixheaacd_add32_sat(imag, real), tcom), 1); + cum[13] = ixheaacd_shl32( + ixheaacd_mult32x16in32(ixheaacd_sub32_sat(imag, real), tcom), 1); + + real = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_real[1], *p8_13), + ixheaacd_mult32x16in32(ptr_qmf_real[9], *p8_13_8)), + 1); + imag = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_imag[1], *p8_13++), + ixheaacd_mult32x16in32(ptr_qmf_imag[9], *p8_13_8++)), + 1); + + cum[10] = + ixheaacd_shl32(ixheaacd_add32_sat(ixheaacd_mult32x16in32(imag, tcos), + ixheaacd_mult32x16in32(real, tsin)), + 1); + cum[11] = + ixheaacd_shl32(ixheaacd_sub32_sat(ixheaacd_mult32x16in32(imag, tsin), + ixheaacd_mult32x16in32(real, tcos)), + 1); + cum[9] = ixheaacd_shl32( + ixheaacd_mult32x16in32( + ixheaacd_sub32_sat(ptr_qmf_real[2], ptr_qmf_real[10]), *p8_13_8++), + 1); + cum[8] = ixheaacd_shl32( + ixheaacd_mult32x16in32( + ixheaacd_sub32_sat(ptr_qmf_imag[2], ptr_qmf_imag[10]), *p8_13++), + 1); + + real = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_real[3], *p8_13), + ixheaacd_mult32x16in32(ptr_qmf_real[11], *p8_13_8)), + 1); + imag = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_imag[3], *p8_13++), + ixheaacd_mult32x16in32(ptr_qmf_imag[11], *p8_13_8++)), + 1); + + cum[6] = + ixheaacd_shl32(ixheaacd_sub32_sat(ixheaacd_mult32x16in32(imag, tcos), + ixheaacd_mult32x16in32(real, tsin)), + 1); + cum[7] = ixheaacd_shl32(ixheaacd_negate32_sat(ixheaacd_add32_sat( + ixheaacd_mult32x16in32(imag, tsin), + ixheaacd_mult32x16in32(real, tcos))), + 1); + + real = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_real[4], *p8_13), + ixheaacd_mult32x16in32(ptr_qmf_real[12], *p8_13_8)), + 1); + imag = ixheaacd_shl32( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(ptr_qmf_imag[4], *p8_13++), + ixheaacd_mult32x16in32(ptr_qmf_imag[12], *p8_13_8++)), + 1); + + cum[4] = ixheaacd_shl32( + ixheaacd_mult32x16in32(ixheaacd_sub32_sat(imag, real), tcom), 1); + cum[5] = ixheaacd_shl32( + ixheaacd_mult32x16in32( + ixheaacd_negate32_sat(ixheaacd_add32_sat(imag, real)), tcom), + 1); + + real = ixheaacd_shl32(ixheaacd_mult32x16in32(ptr_qmf_real[5], *p8_13), 1); + imag = ixheaacd_shl32(ixheaacd_mult32x16in32(ptr_qmf_imag[5], *p8_13++), 1); + + cum[2] = + ixheaacd_shl32(ixheaacd_sub32_sat(ixheaacd_mult32x16in32(real, tcos), + ixheaacd_mult32x16in32(imag, tsin)), + 1); + cum[3] = + ixheaacd_shl32(ixheaacd_add32_sat(ixheaacd_mult32x16in32(real, tsin), + ixheaacd_mult32x16in32(imag, tcos)), + 1); + + cum[0] = ixheaacd_shl32( + ixheaacd_mult32x16in32(ptr_qmf_real[HYBRID_FILTER_DELAY], *p8_13), 1); + cum[1] = ixheaacd_shl32( + ixheaacd_mult32x16in32(ptr_qmf_imag[HYBRID_FILTER_DELAY], *p8_13++), 1); + + real = ixheaacd_shl32(ixheaacd_mult32x16in32(ptr_qmf_real[7], *p8_13), 1); + imag = ixheaacd_shl32(ixheaacd_mult32x16in32(ptr_qmf_imag[7], *p8_13++), 1); + + cum[14] = + ixheaacd_shl32(ixheaacd_add32_sat(ixheaacd_mult32x16in32(imag, tsin), + ixheaacd_mult32x16in32(real, tcos)), + 1); + cum[15] = + ixheaacd_shl32(ixheaacd_sub32_sat(ixheaacd_mult32x16in32(imag, tcos), + ixheaacd_mult32x16in32(real, tsin)), + 1); + + (*ixheaacd_inv_dit_fft_8pt)(cum, ptr_hyb_real, ptr_hyb_imag); +} + +VOID ixheaacd_hybrid_analysis(const WORD32 *ptr_qmf_real, WORD32 *ptr_hyb_real, + WORD32 *ptr_hyb_imag, + ia_hybrid_struct *ptr_hybrid, WORD16 scale, + ia_sbr_tables_struct *ptr_sbr_tables) + +{ + WORD band, j; + WORD chn_offset = 0; + WORD32 *ptr_re, *ptr_im; + WORD32 *ptr_temp_real, *ptr_temp_imag; + + for (band = 0; band < NO_QMF_CHANNELS_IN_HYBRID; band++) { + ptr_re = ptr_hybrid->ptr_qmf_buf_re[band]; + ptr_im = ptr_hybrid->ptr_qmf_buf_im[band]; + + ptr_temp_real = &ptr_hybrid->ptr_work_re[0]; + ptr_temp_imag = &ptr_hybrid->ptr_work_im[0]; + + *ptr_temp_real = *ptr_re; + *ptr_temp_imag = *ptr_im; + + ptr_temp_real++; + ptr_re++; + ptr_temp_imag++; + ptr_im++; + + for (j = ptr_hybrid->ptr_qmf_buf - 2; j >= 0; j--) { + *ptr_temp_real++ = *ptr_re; + *(ptr_re - 1) = *ptr_re; + ptr_re++; + *ptr_temp_imag++ = *ptr_im; + *(ptr_im - 1) = *ptr_im; + ptr_im++; + } + + { + WORD32 temp_re = ptr_qmf_real[band]; + WORD32 temp_im = ptr_qmf_real[band + 0x40]; + + if (scale < 0) { + temp_re = ixheaacd_shl32(temp_re, -scale); + temp_im = ixheaacd_shl32(temp_im, -scale); + } else { + temp_re = ixheaacd_shr32(temp_re, scale); + temp_im = ixheaacd_shr32(temp_im, scale); + } + *ptr_temp_real = temp_re; + *--ptr_re = temp_re; + + *ptr_temp_imag = temp_im; + *--ptr_im = temp_im; + } + + switch (ptr_hybrid->ptr_resol[band]) { + case NO_HYBRID_CHANNELS_LOW: + + ixheaacd_filt_2_ch(ptr_hybrid->ptr_work_re, &ptr_hyb_real[chn_offset], + ptr_sbr_tables); + + chn_offset += 2; + + break; + case NO_HYBRID_CHANNELS_HIGH: + + ixheaacd_filt_8_ch(ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_work_im, + &ptr_hyb_real[chn_offset], &ptr_hyb_imag[chn_offset], + ptr_sbr_tables); + + chn_offset += 6; + } + } +} diff --git a/decoder/ixheaacd_hybrid.h b/decoder/ixheaacd_hybrid.h new file mode 100644 index 0000000..3fb080f --- /dev/null +++ b/decoder/ixheaacd_hybrid.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_HYBRID_H +#define IXHEAACD_HYBRID_H + +#define HYBRID_FILTER_LENGTH 13 +#define HYBRID_FILTER_DELAY 6 +#define NO_QMF_CHANNELS_IN_HYBRID 3 +#define NO_HYBRID_CHANNELS_LOW 2 +#define NO_HYBRID_CHANNELS_HIGH 8 + +typedef struct { + const WORD16 *ptr_resol; + WORD8 ptr_qmf_buf; + WORD32 *ptr_work_re; + WORD32 *ptr_work_im; + WORD32 *ptr_qmf_buf_re[NO_QMF_CHANNELS_IN_HYBRID]; + WORD32 *ptr_qmf_buf_im[NO_QMF_CHANNELS_IN_HYBRID]; + WORD32 *ptr_temp_re; + WORD32 *ptr_temp_im; +} ia_hybrid_struct; + +VOID ixheaacd_hybrid_analysis(const WORD32 *ptr_qmf_real, WORD32 *ptr_hyb_real, + WORD32 *ptr_hyb_imag, + ia_hybrid_struct *ptr_hybrid, WORD16 scale, + ia_sbr_tables_struct *sbr_tables_ptr); + +#endif /* IXHEAACD_HYBRID_H */ diff --git a/decoder/ixheaacd_imdct.c b/decoder/ixheaacd_imdct.c new file mode 100644 index 0000000..9bf4117 --- /dev/null +++ b/decoder/ixheaacd_imdct.c @@ -0,0 +1,549 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include + +#include +#include + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_td_mdct.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_windows.h" + +#include "ixheaacd_vec_baisc_ops.h" +#include "ixheaacd_constants.h" +#include "ixheaacd_function_selector.h" +#include +#include +#include + +#include "ixheaacd_func_def.h" + +#include "ixheaacd_windows.h" + +extern const WORD32 ixheaacd_pre_post_twid_cos_512[512]; +extern const WORD32 ixheaacd_pre_post_twid_sin_512[512]; +extern const WORD32 ixheaacd_pre_post_twid_cos_384[384]; +extern const WORD32 ixheaacd_pre_post_twid_sin_384[384]; +extern const WORD32 ixheaacd_pre_post_twid_cos_64[64]; +extern const WORD32 ixheaacd_pre_post_twid_sin_64[64]; +extern const WORD32 ixheaacd_pre_post_twid_cos_48[48]; +extern const WORD32 ixheaacd_pre_post_twid_sin_48[48]; +extern const FLOAT64 ixheaacd_power_10_table[28]; + +#define ABS(A) ((A) < 0 ? (-A) : (A)) + +static WORD32 ixheaacd_calc_max_spectralline(WORD32 *p_in_ibuffer, WORD32 n) { + WORD32 k, shiftp, itemp = 0; + for (k = 0; k < n; k++) { + if (ABS(p_in_ibuffer[k]) > itemp) itemp = ABS(p_in_ibuffer[k]); + } + + shiftp = ixheaacd_norm32(itemp); + + return (shiftp); +} + +static void ixheaacd_normalize(WORD32 *buff, WORD32 shift, WORD len) { + WORD32 i; + + for (i = 0; i < len; i++) { + buff[i] = buff[i] << shift; + } +} + +static FLOAT32 ixheaacd_pow10(WORD32 input) { + FLOAT32 output = 1; + while (input > 0) { + output *= 10; + input--; + } + return (output); +} + +void ixheaacd_calc_pre_twid_dec(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *cos_ptr, + const WORD32 *sin_ptr) { + WORD32 i; + WORD32 *ptr_y; + + ptr_y = &ptr_x[2 * nlength - 1]; + + for (i = 0; i < nlength; i++) { + *r_ptr++ = ((ixheaacd_mult32(-(*ptr_x), (*cos_ptr)) - + ixheaacd_mult32((*ptr_y), (*sin_ptr)))); + *i_ptr++ = ((ixheaacd_mult32((*ptr_y), (*cos_ptr++)) - + ixheaacd_mult32((*ptr_x), (*sin_ptr++)))); + ptr_x += 2; + ptr_y -= 2; + } +} + +void ixheaacd_calc_post_twid_dec(WORD32 *xptr, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *cos_ptr, + const WORD32 *sin_ptr + + ) { + WORD32 i; + WORD32 *yptr; + + yptr = &xptr[2 * nlength - 1]; + + for (i = 0; i < nlength; i++) { + *xptr = (-(ixheaacd_mult32((r_ptr[i]), (*cos_ptr)) - + ixheaacd_mult32((i_ptr[i]), (*sin_ptr)))); + *yptr = (-(ixheaacd_mult32((i_ptr[i]), (*cos_ptr++)) + + ixheaacd_mult32((r_ptr[i]), (*sin_ptr++)))); + xptr += 2; + yptr -= 2; + } +} + +static void ixheaacd_fft_based_imdct(WORD32 *data, WORD32 npoints, + WORD32 *preshift, WORD32 *tmp_data) { + WORD32 *data_r; + WORD32 *data_i; + WORD32 nlength = npoints >> 1; + const WORD32 *cos_ptr; + const WORD32 *sin_ptr; + + data_r = tmp_data; + data_i = tmp_data + 512; + + if (nlength == 512) { + cos_ptr = ixheaacd_pre_post_twid_cos_512; + sin_ptr = ixheaacd_pre_post_twid_sin_512; + } else if (nlength == 384) { + cos_ptr = ixheaacd_pre_post_twid_cos_384; + sin_ptr = ixheaacd_pre_post_twid_sin_384; + } else if (nlength == 64) { + cos_ptr = ixheaacd_pre_post_twid_cos_64; + sin_ptr = ixheaacd_pre_post_twid_sin_64; + } else if (nlength == 48) { + cos_ptr = ixheaacd_pre_post_twid_cos_48; + sin_ptr = ixheaacd_pre_post_twid_sin_48; + } else { + cos_ptr = ixheaacd_pre_post_twid_cos_48; + sin_ptr = ixheaacd_pre_post_twid_sin_48; + } + + (*ixheaacd_calc_pre_twid)(data, data_r, data_i, nlength, cos_ptr, sin_ptr); + ixheaacd_complex_fft(data_r, data_i, nlength, 1, preshift); + (*ixheaacd_calc_post_twid)(data, data_r, data_i, nlength, cos_ptr, sin_ptr); +} + +#define N_LONG_LEN_MAX 1024 + +void ixheaacd_acelp_imdct(WORD32 *imdct_in, WORD32 npoints, WORD8 *qshift, + WORD32 *tmp_data) { + WORD32 preshift = 0; + WORD32 i; + WORD32 k = (npoints / 2); + + while (((k & 1) == 0) & (k != 1)) { + k = k >> 1; + preshift++; + } + + if ((k != 1)) { + for (i = 0; i < (npoints / 2); i++) { + imdct_in[i] = (imdct_in[i] / 3) << 1; + } + preshift++; + } + + ixheaacd_fft_based_imdct(imdct_in, npoints / 2, &preshift, tmp_data); + preshift += 2; + *qshift -= preshift; +} + +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]; + FLOAT32 gain, ztemp, ftemp, pow10, rem10; + FLOAT32 qfac1; + WORD8 qshift1, qshift2 = 0, qshift3 = 0; + WORD32 quo, rem, 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; + pow10 = ixheaacd_pow10(quo); + rem10 = (FLOAT32)ixheaacd_power_10_table[rem]; + + gain = pow10 * rem10; + scale = (WORD32)(ixheaacd_norm32((WORD32)((ABS(gain) + 1)))); + gain_fac = (WORD32)(gain * (FLOAT32)((WORD64)1 << scale)); + scale += 4; + qfac1 = 1.0f / (gain); + + if (acelp_in != NULL) { + izir = intzir; + ftemp = 0.0; + for (k = 0; k < n_long / 4; k++) { + ztemp = acelp_in[k] * (qfac1); + if (ABS(ztemp) > ftemp) ftemp = ABS(ztemp); + } + + itemp = (WORD32)(ftemp); + qshift3 = ixheaacd_norm32(itemp); + + for (k = 0; k < n_long / 4; k++) { + izir[k] = + (WORD32)((acelp_in[k] * (qfac1)) * (FLOAT32)((WORD64)1 << qshift3)); + } + } else + izir = NULL; + + if (last_lpc != NULL) { + ftemp = 0.0; + i_aq = int_aq; + for (k = 0; k < ORDER + 1; k++) { + if (ABS(last_lpc[k]) > ftemp) ftemp = ABS(last_lpc[k]); + } + + itemp = (WORD32)(ftemp); + qshift2 = ixheaacd_norm32(itemp); + + for (k = 0; k < ORDER + 1; k++) { + i_aq[k] = (WORD32)(last_lpc[k] * (FLOAT32)((WORD64)1 << qshift2)); + } + } else + i_aq = NULL; + + for (k = 0; k < lfac; k++) { + if (ABS(fac_data[k + 1]) > itemp) itemp = ABS(fac_data[k + 1]); + } + + qshift1 = ixheaacd_norm32(itemp); + + for (k = 0; k < lfac; k++) { + fac_data[k + 1] = + (WORD32)(fac_data[k + 1] * (FLOAT32)((WORD64)1 << qshift1)); + } + + for (k = 0; k < lfac / 2; k++) { + x_in[k] = fac_data[2 * k + 1]; + x_in[lfac / 2 + k] = fac_data[lfac - 2 * k]; + } + + ixheaacd_fr_alias_cnx_fix(x_in, n_long / 4, lfac, i_aq, izir, fac_idata + 16, + &qshift1, qshift2, qshift3, &preshift, ptr_scratch); + preshift += 4; + + if (acelp_in != NULL) { + for (k = 0; k < 2 * lfac; k++) { + fac_idata[k] = + ixheaacd_mul32_sh(fac_idata[k + 16], gain_fac, (WORD8)(scale)); + } + } + return (qshift1 - preshift); +} + +static WORD32 ixheaacd_fd_imdct_short(ia_usac_data_struct *usac_data, + WORD32 i_ch, WORD32 *fac_data_out, + offset_lengths *ixheaacd_drc_offset, + WORD8 fac_q) { + FLOAT32 qfac; + WORD32 overlap_data_buf[2 * N_LONG_LEN_MAX] = {0}; + WORD32 *window_short, k, *window_short_prev_ptr; + WORD32 *overlap_data, *fp; + + WORD32 *p_overlap_ibuffer = usac_data->overlap_data_ptr[i_ch]; + WORD32 *p_in_ibuffer = usac_data->coef_fix[i_ch]; + FLOAT32 *p_out_buffer = usac_data->time_sample_vector[i_ch]; + WORD32 *p_out_ibuffer = usac_data->output_data_ptr[i_ch]; + WORD32 *scratch_mem = usac_data->scratch_buffer; + WORD32 td_frame_prev = usac_data->td_frame_prev[i_ch]; + WORD32 fac_apply = usac_data->fac_data_present[i_ch]; + WORD8 shiftp, input_q, output_q, shift_olap = 14; + WORD32 max_shift; + + WORD32 window_select = usac_data->window_shape[i_ch]; + WORD32 window_select_prev = usac_data->window_shape_prev[i_ch]; + ia_usac_lpd_decoder_handle st = usac_data->str_tddec[i_ch]; + WORD32 err_code = 0; + + max_shift = + ixheaacd_calc_max_spectralline(p_in_ibuffer, ixheaacd_drc_offset->n_long); + ixheaacd_normalize(p_in_ibuffer, max_shift, ixheaacd_drc_offset->n_long); + shiftp = max_shift + 6; + input_q = shiftp; + + memcpy(overlap_data_buf, p_overlap_ibuffer, + sizeof(WORD32) * ixheaacd_drc_offset->n_long); + overlap_data = overlap_data_buf; + + fp = overlap_data + ixheaacd_drc_offset->n_flat_ls; + + for (k = 0; k < 8; k++) { + shiftp = input_q; + ixheaacd_acelp_imdct(p_in_ibuffer + (k * ixheaacd_drc_offset->n_short), + 2 * ixheaacd_drc_offset->n_short, &shiftp, + scratch_mem); + } + + max_shift = + ixheaacd_calc_max_spectralline(p_in_ibuffer, ixheaacd_drc_offset->n_long); + ixheaacd_normalize(p_in_ibuffer, max_shift - 1, ixheaacd_drc_offset->n_long); + shiftp += max_shift - 1; + + err_code = ixheaacd_calc_window(&window_short, ixheaacd_drc_offset->n_short, + window_select); + if (err_code == -1) return err_code; + err_code = + ixheaacd_calc_window(&window_short_prev_ptr, + ixheaacd_drc_offset->n_trans_ls, window_select_prev); + if (err_code == -1) return err_code; + + if (fac_apply) + ixheaacd_windowing_short1(p_in_ibuffer + ixheaacd_drc_offset->n_short / 2, + window_short_prev_ptr, fp, ixheaacd_drc_offset, + shiftp, shift_olap); + + else + ixheaacd_windowing_short2(p_in_ibuffer + ixheaacd_drc_offset->n_short / 2, + window_short_prev_ptr, fp, ixheaacd_drc_offset, + shiftp, shift_olap); + + output_q = ixheaacd_windowing_short3( + p_in_ibuffer, window_short + ixheaacd_drc_offset->n_short - 1, + fp + ixheaacd_drc_offset->n_short, ixheaacd_drc_offset->n_short, shiftp, + shift_olap); + p_in_ibuffer += ixheaacd_drc_offset->n_short; + fp += ixheaacd_drc_offset->n_short; + window_short_prev_ptr = window_short; + + for (k = 1; k < 7; k++) { + output_q = ixheaacd_windowing_short4( + p_in_ibuffer, window_short_prev_ptr, fp, + window_short_prev_ptr + ixheaacd_drc_offset->n_short - 1, + ixheaacd_drc_offset->n_short, 1, shiftp, shift_olap, output_q); + p_in_ibuffer += ixheaacd_drc_offset->n_short; + fp += ixheaacd_drc_offset->n_short; + window_short_prev_ptr = window_short; + } + + output_q = ixheaacd_windowing_short4( + p_in_ibuffer, window_short_prev_ptr, fp, + window_short_prev_ptr + ixheaacd_drc_offset->n_short - 1, + ixheaacd_drc_offset->n_short, 0, shiftp, shift_olap, output_q); + p_in_ibuffer += ixheaacd_drc_offset->n_short; + fp += ixheaacd_drc_offset->n_short; + + if (fac_apply) { + ixheaacd_combine_fac(overlap_data + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac, + fac_data_out, + overlap_data + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac, + 2 * ixheaacd_drc_offset->lfac, output_q, fac_q); + } + memset(overlap_data + 2 * ixheaacd_drc_offset->n_long - + ixheaacd_drc_offset->n_flat_ls, + 0, sizeof(WORD32) * ixheaacd_drc_offset->n_flat_ls); + ixheaacd_scale_down(overlap_data, overlap_data, + ixheaacd_drc_offset->n_flat_ls, shift_olap, output_q); + + ixheaacd_scale_down(p_overlap_ibuffer, + overlap_data + ixheaacd_drc_offset->n_long, + ixheaacd_drc_offset->n_long, output_q, shift_olap); + ixheaacd_scale_down(p_out_ibuffer, overlap_data, ixheaacd_drc_offset->n_long, + output_q, 15); + + if (td_frame_prev) { + qfac = 1.0f / (FLOAT32)(1 << 15); + + for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { + p_out_buffer[k] = ((FLOAT32)p_out_ibuffer[k]) * qfac; + } + ixheaacd_lpd_bpf_fix(usac_data, 1, p_out_buffer, st); + + for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { + p_out_ibuffer[k] = (WORD32)(p_out_buffer[k] * (1 << 15)); + } + } + + return 0; +} + +static WORD32 ixheaacd_fd_imdct_long(ia_usac_data_struct *usac_data, + WORD32 i_ch, WORD32 *fac_idata, + offset_lengths *ixheaacd_drc_offset, + WORD8 fac_q) { + FLOAT32 qfac; + WORD32 *window_long_prev, k, i, *window_short_prev_ptr; + + WORD32 *p_in_ibuffer = usac_data->coef_fix[i_ch]; + WORD32 *p_overlap_ibuffer = usac_data->overlap_data_ptr[i_ch]; + WORD32 *p_out_ibuffer = usac_data->output_data_ptr[i_ch]; + FLOAT32 *p_out_buffer = usac_data->time_sample_vector[i_ch]; + WORD32 *scratch_mem = usac_data->scratch_buffer; + WORD32 n_long = usac_data->ccfl; + WORD32 td_frame_prev = usac_data->td_frame_prev[i_ch]; + WORD32 fac_apply = usac_data->fac_data_present[i_ch]; + WORD8 shiftp, output_q = 0, shift_olap = 14; + WORD32 max_shift; + + WORD32 window_sequence = usac_data->window_sequence[i_ch]; + WORD32 window_select_prev = usac_data->window_shape_prev[i_ch]; + ia_usac_lpd_decoder_handle st = usac_data->str_tddec[i_ch]; + + WORD32 err_code = 0; + + max_shift = + ixheaacd_calc_max_spectralline(p_in_ibuffer, ixheaacd_drc_offset->n_long); + ixheaacd_normalize(p_in_ibuffer, max_shift, ixheaacd_drc_offset->n_long); + shiftp = max_shift + 6; + + ixheaacd_acelp_imdct(p_in_ibuffer, 2 * ixheaacd_drc_offset->n_long, &shiftp, + scratch_mem); + + max_shift = + ixheaacd_calc_max_spectralline(p_in_ibuffer, ixheaacd_drc_offset->n_long); + ixheaacd_normalize(p_in_ibuffer, max_shift - 1, ixheaacd_drc_offset->n_long); + shiftp += max_shift - 1; + + switch (window_sequence) { + case ONLY_LONG_SEQUENCE: + case LONG_START_SEQUENCE: + err_code = ixheaacd_calc_window( + &window_long_prev, ixheaacd_drc_offset->n_long, window_select_prev); + if (err_code == -1) return err_code; + output_q = ixheaacd_windowing_long1( + p_in_ibuffer + n_long / 2, p_overlap_ibuffer, window_long_prev, + window_long_prev + ixheaacd_drc_offset->n_long - 1, p_out_ibuffer, + ixheaacd_drc_offset->n_long, shiftp, shift_olap); + break; + + case STOP_START_SEQUENCE: + case LONG_STOP_SEQUENCE: + err_code = ixheaacd_calc_window(&window_short_prev_ptr, + ixheaacd_drc_offset->n_trans_ls, + window_select_prev); + if (err_code == -1) return err_code; + if (fac_apply) { + output_q = ixheaacd_windowing_long2( + p_in_ibuffer + n_long / 2, window_short_prev_ptr, fac_idata, + p_overlap_ibuffer, p_out_ibuffer, ixheaacd_drc_offset, shiftp, + shift_olap, fac_q); + } else { + output_q = ixheaacd_windowing_long3( + p_in_ibuffer + n_long / 2, window_short_prev_ptr, p_overlap_ibuffer, + p_out_ibuffer, + window_short_prev_ptr + ixheaacd_drc_offset->n_trans_ls - 1, + ixheaacd_drc_offset, shiftp, shift_olap); + } + break; + } + + 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); + p_overlap_ibuffer[ixheaacd_drc_offset->n_long / 2 - i - 1] = + -p_in_ibuffer[i] >> (shiftp - shift_olap); + } + + ixheaacd_scale_down(p_out_ibuffer, p_out_ibuffer, ixheaacd_drc_offset->n_long, + output_q, 15); + + if (td_frame_prev) { + qfac = 1.0f / (FLOAT32)(1 << 15); + + for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { + p_out_buffer[k] = ((FLOAT32)p_out_ibuffer[k]) * qfac; + } + ixheaacd_lpd_bpf_fix(usac_data, 0, p_out_buffer, st); + + for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { + p_out_ibuffer[k] = (WORD32)(p_out_buffer[k] * (1 << 15)); + } + } + + return 0; +} + +WORD32 ixheaacd_fd_frm_dec(ia_usac_data_struct *usac_data, WORD32 i_ch) { + WORD32 fac_idata[2 * FAC_LENGTH + 16]; + offset_lengths ixheaacd_drc_offset; + WORD8 fac_q = 0; + WORD32 td_frame_prev = usac_data->td_frame_prev[i_ch]; + WORD32 fac_apply = usac_data->fac_data_present[i_ch]; + WORD32 window_sequence = usac_data->window_sequence[i_ch]; + ixheaacd_drc_offset.n_long = usac_data->ccfl; + ixheaacd_drc_offset.n_short = ixheaacd_drc_offset.n_long >> 3; + + memset(fac_idata, 0, sizeof(fac_idata)); + + if (td_frame_prev) { + if (window_sequence == EIGHT_SHORT_SEQUENCE) { + ixheaacd_drc_offset.lfac = ixheaacd_drc_offset.n_long >> 4; + } else { + ixheaacd_drc_offset.lfac = ixheaacd_drc_offset.n_long >> 3; + } + ixheaacd_drc_offset.n_flat_ls = + (ixheaacd_drc_offset.n_long - (ixheaacd_drc_offset.lfac) * 2) >> 1; + + ixheaacd_drc_offset.n_trans_ls = (ixheaacd_drc_offset.lfac) << 1; + } else { + ixheaacd_drc_offset.lfac = FAC_LENGTH; + ixheaacd_drc_offset.n_flat_ls = + (ixheaacd_drc_offset.n_long - ixheaacd_drc_offset.n_short) >> 1; + ixheaacd_drc_offset.n_trans_ls = ixheaacd_drc_offset.n_short; + } + + if (fac_apply) + fac_q = ixheaacd_cal_fac_data(usac_data, i_ch, ixheaacd_drc_offset.n_long, + ixheaacd_drc_offset.lfac, fac_idata); + + if (window_sequence != EIGHT_SHORT_SEQUENCE) + ixheaacd_fd_imdct_long(usac_data, i_ch, fac_idata, &ixheaacd_drc_offset, + fac_q); + + else + ixheaacd_fd_imdct_short(usac_data, i_ch, fac_idata, &ixheaacd_drc_offset, + fac_q); + + return 0; +} \ No newline at end of file diff --git a/decoder/ixheaacd_info.h b/decoder/ixheaacd_info.h new file mode 100644 index 0000000..d6de7eb --- /dev/null +++ b/decoder/ixheaacd_info.h @@ -0,0 +1,109 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_INFO_H +#define IXHEAACD_INFO_H + +#define chans 51 + +#define EXT_SBR_DATA 13 + +typedef struct { + WORD32 samp_rate; + WORD32 num_sfb_1024; + const WORD16 *ptr_sfb_1024; + WORD32 num_sfb_128; + const WORD16 *ptr_sfb_128; + WORD32 num_sfb_960; + const WORD16 *ptr_sfb_960; + WORD32 num_sfb_120; + const WORD16 *ptr_sfb_120; + WORD32 num_sfb_768; + const WORD16 *ptr_sfb_768; + WORD32 num_sfb_96; + const WORD16 *ptr_sfb_96; + WORD32 short_fss_width; + WORD32 long_fss_groups; + WORD32 num_sfb_480; + const WORD16 *ptr_sfb_480; + WORD32 num_sfb_512; + const WORD16 *ptr_sfb_512; +} ia_usac_samp_rate_info; + +typedef struct { + WORD32 index; + WORD32 len; + UWORD32 code_word; +} ia_huff_code_word_struct; + +typedef struct { + WORD32 num; + WORD32 dim; + WORD32 lav; + WORD32 lav_incr_esc; + WORD32 huff_mode; + 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; +} ia_huff_code_book_struct; + +typedef struct { + WORD32 num_ele; + WORD32 ele_is_cpe[(1 << LEN_TAG)]; + WORD32 ele_tag[(1 << LEN_TAG)]; +} ia_ele_list_struct; + +typedef struct { + WORD32 present; + WORD32 ele_tag; + WORD32 pseudo_enab; +} ia_mix_dwn_struct; + +typedef struct { + WORD32 tag; + WORD32 profile; + WORD32 sampling_rate_idx; + ia_ele_list_struct front; + ia_ele_list_struct side; + ia_ele_list_struct back; + ia_ele_list_struct lfe; + ia_ele_list_struct data; + ia_ele_list_struct coupling; + ia_mix_dwn_struct mono_mix; + ia_mix_dwn_struct stereo_mix; + ia_mix_dwn_struct matrix_mix; + WORD8 comments[(1 << LEN_PC_COMM) + 1]; + WORD32 buffer_fullness; +} ia_prog_config_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); + +WORD32 ixheaacd_huff_codeword(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 new file mode 100644 index 0000000..e776a65 --- /dev/null +++ b/decoder/ixheaacd_init_config.c @@ -0,0 +1,559 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include + +#include + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_aac_rom.h" +#include "ixheaacd_common_rom.h" +#include +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" + +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_audioobjtypes.h" +#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_config.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_info.h" +#include "ixheaacd_struct.h" +#include "ixheaacd_constants.h" + +UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx) { + UWORD32 sbr_ratio_index = 0x0FF; + + switch (core_sbr_framelength_idx) { + case 0: + case 1: + sbr_ratio_index = USAC_SBR_RATIO_NO_SBR; + break; + case 2: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_8_3; + break; + case 3: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_2_1; + break; + case 4: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_4_1; + break; + } + + return sbr_ratio_index; +} + +UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx, + WORD32 *output_framelength, WORD32 *block_size, + WORD32 *output_samples) { + UWORD32 sbr_ratio_index = 0x0FF; + + *output_framelength = -1; + + switch (core_sbr_framelength_idx) { + case 0: + sbr_ratio_index = USAC_SBR_RATIO_NO_SBR; + *output_framelength = USAC_OUT_FRAMELENGTH_768; + *block_size = 768; + *output_samples = *block_size; + break; + case 1: + sbr_ratio_index = USAC_SBR_RATIO_NO_SBR; + *output_framelength = USAC_OUT_FRAMELENGTH_1024; + *block_size = 1024; + *output_samples = *block_size; + break; + case 2: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_8_3; + *output_framelength = USAC_OUT_FRAMELENGTH_2048; + *block_size = 768; + *output_samples = (*block_size * 8) / 3; + break; + case 3: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_2_1; + *output_framelength = USAC_OUT_FRAMELENGTH_2048; + *block_size = 1024; + *output_samples = *block_size * 2; + break; + case 4: + sbr_ratio_index = USAC_SBR_RATIO_INDEX_4_1; + *output_framelength = USAC_OUT_FRAMELENGTH_4096; + *block_size = 1024; + *output_samples = *block_size * 4; + break; + } + + return sbr_ratio_index; +} + +VOID ixheaacd_read_escape_value(ia_bit_buf_struct *it_bit_buff, + UWORD32 *ext_ele_value, UWORD32 no_bits1, + UWORD32 no_bits2, UWORD32 no_bits3) { + UWORD32 value = 0; + UWORD32 val_add = 0; + UWORD32 max_val1 = (1 << no_bits1) - 1; + UWORD32 max_val2 = (1 << no_bits2) - 1; + + value = ixheaacd_read_bits_buf(it_bit_buff, no_bits1); + + if (value == max_val1) { + val_add = ixheaacd_read_bits_buf(it_bit_buff, no_bits2); + + value += val_add; + + if (val_add == max_val2) { + val_add = ixheaacd_read_bits_buf(it_bit_buff, no_bits3); + + value += val_add; + } + } + + *ext_ele_value = value; +} + +static VOID ixheaacd_get_usac_chan_conf(ia_usac_config_struct *pstr_usac_config, + UWORD32 ch_config_index) { + switch (ch_config_index) { + case 1: + pstr_usac_config->num_out_channels = 1; + pstr_usac_config->output_channel_pos[0] = BS_OUTPUT_CHANNEL_POS_C; + break; + case 2: + pstr_usac_config->num_out_channels = 2; + 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; + + default: + assert(0); + break; + } +} + +VOID ixheaacd_sbr_config(ia_bit_buf_struct *it_bit_buff, + ia_usac_dec_sbr_config_struct *pstr_usac_sbr_config) { + pstr_usac_sbr_config->harmonic_sbr = ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->bs_inter_tes = ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->bs_pvc = ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->dflt_start_freq = + ixheaacd_read_bits_buf(it_bit_buff, 4); + + pstr_usac_sbr_config->dflt_stop_freq = ixheaacd_read_bits_buf(it_bit_buff, 4); + pstr_usac_sbr_config->dflt_header_extra1 = + ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->dflt_header_extra2 = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (pstr_usac_sbr_config->dflt_header_extra1) { + pstr_usac_sbr_config->dflt_freq_scale = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_usac_sbr_config->dflt_alter_scale = + ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->dflt_noise_bands = + ixheaacd_read_bits_buf(it_bit_buff, 2); + } + + if (pstr_usac_sbr_config->dflt_header_extra2) { + pstr_usac_sbr_config->dflt_limiter_bands = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_usac_sbr_config->dflt_limiter_gains = + ixheaacd_read_bits_buf(it_bit_buff, 2); + pstr_usac_sbr_config->dflt_interpol_freq = + ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_sbr_config->dflt_smoothing_mode = + ixheaacd_read_bits_buf(it_bit_buff, 1); + } +} + +WORD32 ixheaacd_ext_element_config( + ia_bit_buf_struct *it_bit_buff, + ia_usac_dec_element_config_struct *pstr_usac_element_config +#ifdef ENABLE_DRC + , + UWORD8 *ptr_usac_ext_ele_payload, WORD32 *ptr_usac_ext_ele_payload_len +#endif + ) { + UWORD32 usac_ext_element_type, usac_ext_element_config_length, flag; + +#ifdef ENABLE_DRC + UWORD32 i; +#endif + + ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_type), 4, 8, 16); + + ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_config_length), 4, + 8, 16); + + flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + +#ifdef ENABLE_DRC + *ptr_usac_ext_ele_payload_len = 0; +#endif + + if (flag) { + ixheaacd_read_escape_value( + it_bit_buff, + (UWORD32 *)(&(pstr_usac_element_config->usac_ext_eleme_def_len)), 8, 16, + 0); + pstr_usac_element_config->usac_ext_eleme_def_len += 1; + + } else { + pstr_usac_element_config->usac_ext_eleme_def_len = 0; + } + + pstr_usac_element_config->usac_ext_elem_pld_frag = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + switch (usac_ext_element_type) { + case ID_EXT_ELE_FILL: + break; +#ifdef ENABLE_DRC + case ID_EXT_ELE_AUDIOPREROLL: + break; + case ID_EXT_ELE_UNI_DRC: + for (i = 0; i < usac_ext_element_config_length; i++) { + ptr_usac_ext_ele_payload[i] = ixheaacd_read_bits_buf(it_bit_buff, 8); + } + *ptr_usac_ext_ele_payload_len = usac_ext_element_config_length; + break; +#endif + + default: + if ((it_bit_buff->cnt_bits >> 3) < (WORD32)usac_ext_element_config_length) + return -1; + it_bit_buff->ptr_read_next += usac_ext_element_config_length; + it_bit_buff->cnt_bits -= (usac_ext_element_config_length << 3); + + break; + } + + return 0; +} + +VOID ixheaacd_mps212_config( + ia_bit_buf_struct *it_bit_buff, + ia_usac_dec_mps_config_struct *pstr_usac_mps212_config, + WORD32 stereo_config_index) { + pstr_usac_mps212_config->bs_freq_res = ixheaacd_read_bits_buf(it_bit_buff, 3); + + pstr_usac_mps212_config->bs_fixed_gain_dmx = + ixheaacd_read_bits_buf(it_bit_buff, 3); + + pstr_usac_mps212_config->bs_temp_shape_config = + ixheaacd_read_bits_buf(it_bit_buff, 2); + + pstr_usac_mps212_config->bs_decorr_config = + ixheaacd_read_bits_buf(it_bit_buff, 2); + + pstr_usac_mps212_config->bs_high_rate_mode = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + pstr_usac_mps212_config->bs_phase_coding = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + pstr_usac_mps212_config->bs_ott_bands_phase_present = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + 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 (stereo_config_index > 1) { + pstr_usac_mps212_config->bs_residual_bands = + ixheaacd_read_bits_buf(it_bit_buff, 5); + + pstr_usac_mps212_config->bs_ott_bands_phase = + max(pstr_usac_mps212_config->bs_ott_bands_phase, + pstr_usac_mps212_config->bs_residual_bands); + + pstr_usac_mps212_config->bs_pseudo_lr = + ixheaacd_read_bits_buf(it_bit_buff, 1); + } + + 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); +} + +VOID ixheaacd_cpe_config( + ia_bit_buf_struct *it_bit_buff, + ia_usac_dec_element_config_struct *pstr_usac_element_config, + WORD32 sbr_ratio_index) { + pstr_usac_element_config->tw_mdct = ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_element_config->noise_filling = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (sbr_ratio_index > 0) { + ixheaacd_sbr_config(it_bit_buff, + &(pstr_usac_element_config->str_usac_sbr_config)); + pstr_usac_element_config->stereo_config_index = + ixheaacd_read_bits_buf(it_bit_buff, 2); + + } else { + pstr_usac_element_config->stereo_config_index = 0; + } + + 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); +} + +WORD32 ixheaacd_decoder_config( + ia_bit_buf_struct *it_bit_buff, + ia_usac_decoder_config_struct *pstr_usac_decoder_config, + WORD32 sbr_ratio_index) { + UWORD32 elem_idx = 0; + UWORD32 err = 0; + + ixheaacd_read_escape_value( + it_bit_buff, &(pstr_usac_decoder_config->num_elements), 4, 8, 16); + pstr_usac_decoder_config->num_elements += 1; + + if (pstr_usac_decoder_config->num_elements > USAC_MAX_ELEMENTS) { + return -1; + } + + for (elem_idx = 0; elem_idx < pstr_usac_decoder_config->num_elements; + elem_idx++) { + ia_usac_dec_element_config_struct *pstr_usac_element_config = + &(pstr_usac_decoder_config->str_usac_element_config[elem_idx]); + + pstr_usac_decoder_config->usac_element_type[elem_idx] = + ixheaacd_read_bits_buf(it_bit_buff, 2); + + switch (pstr_usac_decoder_config->usac_element_type[elem_idx]) { + case ID_USAC_SCE: + + pstr_usac_element_config->tw_mdct = + ixheaacd_read_bits_buf(it_bit_buff, 1); + pstr_usac_element_config->noise_filling = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (sbr_ratio_index > 0) + ixheaacd_sbr_config(it_bit_buff, + &(pstr_usac_element_config->str_usac_sbr_config)); + + break; + + case ID_USAC_CPE: + ixheaacd_cpe_config(it_bit_buff, pstr_usac_element_config, + sbr_ratio_index); + break; + + case ID_USAC_LFE: + + pstr_usac_element_config->tw_mdct = 0; + pstr_usac_element_config->noise_filling = 0; + break; + + case ID_USAC_EXT: + err = ixheaacd_ext_element_config( + it_bit_buff, pstr_usac_element_config +#ifdef ENABLE_DRC + , + &pstr_usac_decoder_config->usac_ext_ele_payload_buf[elem_idx][0], + &pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx] +#endif + ); + +#ifdef ENABLE_DRC + if (pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx] > 0) { + pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 1; + } else { + pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 0; + } +#endif + if (err != 0) return -1; + break; + default: + return -1; + break; + } + } + return err; +} + +WORD32 ixheaacd_config_extension( + ia_bit_buf_struct *it_bit_buff +#ifdef ENABLE_DRC + , + ia_usac_decoder_config_struct *pstr_usac_decoder_config +#endif + ) { + UWORD32 i, j; + UWORD32 num_config_extensions; + UWORD32 usac_config_ext_type, usac_config_ext_len; + + ixheaacd_read_escape_value(it_bit_buff, &(num_config_extensions), 2, 4, 8); + num_config_extensions += 1; + if (USAC_MAX_CONFIG_EXTENSIONS < num_config_extensions) { + return -1; + } + +#ifdef ENABLE_DRC + pstr_usac_decoder_config->num_config_extensions = num_config_extensions; + memset(pstr_usac_decoder_config->usac_cfg_ext_info_len, 0, + USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32)); + memset(pstr_usac_decoder_config->usac_cfg_ext_info_present, 0, + USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32)); +#endif + + for (j = 0; j < num_config_extensions; j++) { + UWORD32 tmp; + UWORD32 fill_byte_val = 0xa5; + + 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); + + switch (usac_config_ext_type) { + case ID_CONFIG_EXT_FILL: + for (i = 0; i < usac_config_ext_len; i++) { + fill_byte_val = ixheaacd_read_bits_buf(it_bit_buff, 8); + if (fill_byte_val != 0xa5) return -1; + } + break; + default: + if ((WORD32)usac_config_ext_len > (it_bit_buff->cnt_bits >> 3)) { + return -1; + } +#ifdef ENABLE_DRC + if (ID_CONFIG_EXT_LOUDNESS_INFO == usac_config_ext_type) { + for (i = 0; i < usac_config_ext_len; i++) { + UWORD8 byte_val = ixheaacd_read_bits_buf(it_bit_buff, 8); + pstr_usac_decoder_config->usac_cfg_ext_info_buf[j][i] = byte_val; + } + pstr_usac_decoder_config->usac_cfg_ext_info_len[j] = + usac_config_ext_len; + pstr_usac_decoder_config->usac_cfg_ext_info_present[j] = 1; + } else { +#endif + for (i = 0; i < usac_config_ext_len; i++) + tmp = ixheaacd_read_bits_buf(it_bit_buff, 8); +#ifdef ENABLE_DRC + } +#endif + break; + } + } + + return 0; +} + +WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff, + ia_usac_config_struct *pstr_usac_conf) { + WORD32 tmp, err; + err = 0; + + pstr_usac_conf->usac_sampling_frequency_index = + ixheaacd_read_bits_buf(it_bit_buff, 5); + + if (pstr_usac_conf->usac_sampling_frequency_index == 0x1f) + pstr_usac_conf->usac_sampling_frequency = + ixheaacd_read_bits_buf(it_bit_buff, 24); + + pstr_usac_conf->core_sbr_framelength_index = + ixheaacd_read_bits_buf(it_bit_buff, 3); + + if (pstr_usac_conf->core_sbr_framelength_index > 4) return -1; + + 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 == 0) { + UWORD32 i; + + ixheaacd_read_escape_value(it_bit_buff, + (UWORD32 *)(&(pstr_usac_conf->num_out_channels)), + 5, 8, 16); + if (BS_MAX_NUM_OUT_CHANNELS < pstr_usac_conf->num_out_channels) { + return -1; + } + for (i = 0; i < pstr_usac_conf->num_out_channels; i++) + pstr_usac_conf->output_channel_pos[i] = + ixheaacd_read_bits_buf(it_bit_buff, 5); + + } else { + ixheaacd_get_usac_chan_conf(pstr_usac_conf, + pstr_usac_conf->channel_configuration_index); + } + + err = ixheaacd_decoder_config( + it_bit_buff, &(pstr_usac_conf->str_usac_dec_config), + ixheaacd_sbr_ratio(pstr_usac_conf->core_sbr_framelength_index)); + if (err != 0) return -1; + + tmp = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (tmp) { + err = ixheaacd_config_extension(it_bit_buff +#ifdef ENABLE_DRC + , + &pstr_usac_conf->str_usac_dec_config +#endif + ); + if (err != 0) return -1; + } + + return err; +} + +VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf) { + WORD32 i; + + pstr_usac_conf->num_out_channels = 0; + + for (i = 0; i < BS_MAX_NUM_OUT_CHANNELS; i++) + pstr_usac_conf->output_channel_pos[i] = BS_OUTPUT_CHANNEL_POS_NA; + + pstr_usac_conf->str_usac_dec_config.num_elements = 0; + + for (i = 0; i < USAC_MAX_ELEMENTS; i++) + pstr_usac_conf->str_usac_dec_config.usac_element_type[i] = ID_USAC_INVALID; + + return; +} \ No newline at end of file diff --git a/decoder/ixheaacd_initfuncs.c b/decoder/ixheaacd_initfuncs.c new file mode 100644 index 0000000..b8f1eae --- /dev/null +++ b/decoder/ixheaacd_initfuncs.c @@ -0,0 +1,492 @@ +/****************************************************************************** + * * + * 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 +#include + +#include "ixheaacd_sbr_common.h" + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_bitbuffer.h" + +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_defines.h" + +#include + +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_common_rom.h" + +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" + +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_multichannel.h" + +#define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) + +WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v, + WORD32 num_channel) { + WORD32 persistent_used; + + struct ia_aac_persistent_struct *aac_persistent_mem = + (struct ia_aac_persistent_struct *)aac_persistent_mem_v; + + persistent_used = sizeof(struct ia_aac_persistent_struct); + + memset(aac_persistent_mem, 0, sizeof(struct ia_aac_persistent_struct)); + aac_persistent_mem->overlap_buffer = + (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used); + + memset((WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, + 4 * 512 * num_channel * sizeof(WORD32)); + + persistent_used += 4 * 512 * num_channel * sizeof(WORD32); + + aac_persistent_mem->sbr_payload_buffer = + (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used); + + memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, + ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8)); + + persistent_used += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8); + + { + WORD32 i; + + for (i = 0; i < num_channel; i++) { + aac_persistent_mem->ltp_buf[i] = + (WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used); + + memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, + ltp_buffer_size * sizeof(WORD16)); + + persistent_used += (ltp_buffer_size * sizeof(WORD16)); + + aac_persistent_mem->ptr_aac_dec_static_channel_info[i] = + (ia_aac_dec_channel_info *)((WORD8 *)aac_persistent_mem_v + + persistent_used); + persistent_used += sizeof(ia_aac_dec_channel_info); + + aac_persistent_mem->ptr_aac_dec_static_channel_info[i] + ->overlap_add_data.win_shape = 0; + aac_persistent_mem->ptr_aac_dec_static_channel_info[i] + ->overlap_add_data.win_seq = 0; + + aac_persistent_mem->ptr_aac_dec_static_channel_info[i] + ->overlap_add_data.ptr_overlap_buf = + &aac_persistent_mem->overlap_buffer[i * OVERLAP_BUFFER_SIZE]; + } + } + + return persistent_used; +} + +VOID ixheaacd_huff_tables_create(ia_aac_dec_tables_struct *ptr_aac_tables) { + ptr_aac_tables->code_book[0] = 0; + ptr_aac_tables->code_book[1] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb1; + ptr_aac_tables->code_book[2] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb2; + ptr_aac_tables->code_book[3] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb3; + ptr_aac_tables->code_book[4] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb4; + ptr_aac_tables->code_book[5] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb5; + ptr_aac_tables->code_book[6] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb6; + ptr_aac_tables->code_book[7] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb7; + ptr_aac_tables->code_book[8] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb8; + ptr_aac_tables->code_book[9] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb9; + ptr_aac_tables->code_book[10] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; + ptr_aac_tables->code_book[11] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; + ptr_aac_tables->code_book[12] = + (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; + + ptr_aac_tables->index_table[1] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf1; + ptr_aac_tables->index_table[2] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf2; + ptr_aac_tables->index_table[3] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf3; + ptr_aac_tables->index_table[4] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf4; + ptr_aac_tables->index_table[5] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf5; + ptr_aac_tables->index_table[6] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf6; + ptr_aac_tables->index_table[7] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf7; + ptr_aac_tables->index_table[8] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf8; + ptr_aac_tables->index_table[9] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf9; + ptr_aac_tables->index_table[10] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; + ptr_aac_tables->index_table[11] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; + ptr_aac_tables->index_table[12] = + (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; + + ptr_aac_tables->scale_factor_bands_short[0] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; + ptr_aac_tables->scale_factor_bands_short[1] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; + ptr_aac_tables->scale_factor_bands_short[2] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; + ptr_aac_tables->scale_factor_bands_short[3] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; + ptr_aac_tables->scale_factor_bands_short[4] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; + ptr_aac_tables->scale_factor_bands_short[5] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; + ptr_aac_tables->scale_factor_bands_short[6] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128; + ptr_aac_tables->scale_factor_bands_short[7] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128; + ptr_aac_tables->scale_factor_bands_short[8] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; + ptr_aac_tables->scale_factor_bands_short[9] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; + ptr_aac_tables->scale_factor_bands_short[10] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; + ptr_aac_tables->scale_factor_bands_short[11] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_128; + + ptr_aac_tables->scale_factor_bands_long[0] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024; + ptr_aac_tables->scale_factor_bands_long[1] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024; + ptr_aac_tables->scale_factor_bands_long[2] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_64_1024; + ptr_aac_tables->scale_factor_bands_long[3] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024; + ptr_aac_tables->scale_factor_bands_long[4] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024; + ptr_aac_tables->scale_factor_bands_long[5] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_1024; + ptr_aac_tables->scale_factor_bands_long[6] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024; + ptr_aac_tables->scale_factor_bands_long[7] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024; + ptr_aac_tables->scale_factor_bands_long[8] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; + ptr_aac_tables->scale_factor_bands_long[9] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; + ptr_aac_tables->scale_factor_bands_long[10] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; + ptr_aac_tables->scale_factor_bands_long[11] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_1024; + + ptr_aac_tables->scale_fac_bands_512[0] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; + ptr_aac_tables->scale_fac_bands_512[1] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; + ptr_aac_tables->scale_fac_bands_512[2] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; + ptr_aac_tables->scale_fac_bands_512[3] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; + ptr_aac_tables->scale_fac_bands_512[4] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; + ptr_aac_tables->scale_fac_bands_512[5] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_512; + ptr_aac_tables->scale_fac_bands_512[6] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[7] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[8] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[9] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[10] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[11] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[12] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[13] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[14] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + ptr_aac_tables->scale_fac_bands_512[15] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; + + ptr_aac_tables->scale_fac_bands_480[0] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; + ptr_aac_tables->scale_fac_bands_480[1] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; + ptr_aac_tables->scale_fac_bands_480[2] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; + ptr_aac_tables->scale_fac_bands_480[3] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; + ptr_aac_tables->scale_fac_bands_480[4] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; + ptr_aac_tables->scale_fac_bands_480[5] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_480; + ptr_aac_tables->scale_fac_bands_480[6] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[7] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[8] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[9] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[10] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[11] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[12] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[13] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[14] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; + ptr_aac_tables->scale_fac_bands_480[15] = + ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; +} + +ia_aac_decoder_struct *ixheaacd_aac_decoder_init( + ia_aac_dec_state_struct *p_state_enhaacplus_dec, + ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream, WORD channels, + VOID *aac_persistent_mem_v, WORD32 frame_length) { + WORD i, ch; + struct ia_aac_persistent_struct *aac_persistent_mem; + aac_persistent_mem = (struct ia_aac_persistent_struct *)aac_persistent_mem_v; + + aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream = ptr_sbr_bitstream; + + for (ch = 0; ch < channels; ch++) { + ia_aac_decoder_struct *aac_dec_handle = + &aac_persistent_mem->str_aac_decoder; + aac_dec_handle->pstr_aac_dec_overlap_info[ch] = + &aac_persistent_mem->str_aac_dec_overlap_info[ch]; + aac_dec_handle->pstr_pns_rand_vec_data = + &aac_persistent_mem->str_pns_rand_vec_data; + + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_shape = 0; + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_sequence = 0; + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf = + &aac_persistent_mem->overlap_buffer[ch * 4 * OVERLAP_BUFFER_SIZE]; + else + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf = + &aac_persistent_mem->overlap_buffer[ch * OVERLAP_BUFFER_SIZE]; + + { + WORD32 *ptr_overlap_buf = + aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf; + memset(ptr_overlap_buf, 0, sizeof(WORD32) * 4 * 512); + } + aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] = + aac_persistent_mem->ptr_aac_dec_static_channel_info[ch]; + aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] + ->ltp_buf = aac_persistent_mem->ltp_buf[ch]; + } + + for (i = 0; i < 1; i++) { + ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream = + &aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream[i]; + + ptr_sbr_bitstream->no_elements = 0; + ptr_sbr_bitstream->str_sbr_ele[0].ptr_sbr_data = + &aac_persistent_mem->sbr_payload_buffer[ALIGN_SIZE64(MAXSBRBYTES) * i]; + ptr_sbr_bitstream->str_sbr_ele[0].sbr_ele_id = ID_SCE; + ptr_sbr_bitstream->str_sbr_ele[0].size_payload = 0; + } + + { + ia_aac_dec_tables_struct *ptr_aac_tables = + aac_persistent_mem->str_aac_decoder.pstr_aac_tables; + ia_aac_dec_huffman_tables_struct *pstr_huffmann_tables = + ptr_aac_tables->pstr_huffmann_tables; + + WORD num_entries = sizeof(pstr_huffmann_tables->str_sample_rate_info) / + sizeof(ia_sampling_rate_info_struct); + + WORD32 sampling_rate = p_state_enhaacplus_dec->sampling_rate; + + i = 0; + while (sampling_rate != ((pstr_huffmann_tables->str_sample_rate_info[i] + .sampling_frequency)) && + (i < num_entries)) { + i++; + } + if (i == 12) { + i = i - 1; + } + + if (i == num_entries) { + return NULL; + } + + if (frame_length == 1024) { + WORD16 *psfb_table_idx[2]; + const WORD8 *psfb_width[2]; + WORD width_idx; + WORD32 j; + + psfb_table_idx[0] = ptr_aac_tables->sfb_long_table; + psfb_table_idx[1] = ptr_aac_tables->sfb_short_table; + + psfb_width[0] = ptr_aac_tables->scale_factor_bands_long[i]; + psfb_width[1] = ptr_aac_tables->scale_factor_bands_short[i]; + + for (j = 1; j >= 0; j--) { + const WORD8 *ptr_width = psfb_width[j]; + WORD16 *ptable_idx = psfb_table_idx[j]; + width_idx = 0; + *ptable_idx++ = width_idx; + do { + width_idx += (*ptr_width++); + *ptable_idx++ = width_idx; + } while (*ptr_width != -1); + + aac_persistent_mem->str_aac_decoder.num_swb_window[j] = + (WORD8)(ptr_width - psfb_width[j]); + } + + { + ptr_aac_tables->str_aac_sfb_info[0].sfb_index = + ptr_aac_tables->sfb_long_table; + ptr_aac_tables->str_aac_sfb_info[1].sfb_index = + ptr_aac_tables->sfb_long_table; + ptr_aac_tables->str_aac_sfb_info[3].sfb_index = + ptr_aac_tables->sfb_long_table; + + ptr_aac_tables->str_aac_sfb_info[2].sfb_index = + ptr_aac_tables->sfb_short_table; + + ptr_aac_tables->str_aac_sfb_info[0].sfb_width = (WORD8 *)psfb_width[0]; + ptr_aac_tables->str_aac_sfb_info[1].sfb_width = (WORD8 *)psfb_width[0]; + ptr_aac_tables->str_aac_sfb_info[3].sfb_width = (WORD8 *)psfb_width[0]; + + ptr_aac_tables->str_aac_sfb_info[2].sfb_width = (WORD8 *)psfb_width[1]; + } + } else { + WORD16 *ptr_sfb_idx[2]; + const WORD8 *ptr_sfb_width[2]; + WORD width_idx; + WORD32 j; + + ptr_sfb_idx[0] = ptr_aac_tables->sfb_long_table; + ptr_sfb_idx[1] = ptr_aac_tables->sfb_short_table; + + if (frame_length == 512) + ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_512[i]; + else + ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_480[i]; + + for (j = 0; j >= 0; j--) { + const WORD8 *ptr_width = ptr_sfb_width[j]; + WORD16 *ptr_idx = ptr_sfb_idx[j]; + width_idx = 0; + *ptr_idx++ = width_idx; + do { + width_idx += (*ptr_width++); + *ptr_idx++ = width_idx; + } while (*ptr_width != -1); + + aac_persistent_mem->str_aac_decoder.num_swb_window[j] = + (WORD8)(ptr_width - ptr_sfb_width[j]); + } + + { + ptr_aac_tables->str_aac_sfb_info[0].sfb_index = + ptr_aac_tables->sfb_long_table; + ptr_aac_tables->str_aac_sfb_info[1].sfb_index = + ptr_aac_tables->sfb_long_table; + ptr_aac_tables->str_aac_sfb_info[3].sfb_index = + ptr_aac_tables->sfb_long_table; + ptr_aac_tables->str_aac_sfb_info[2].sfb_index = + ptr_aac_tables->sfb_short_table; + + ptr_aac_tables->str_aac_sfb_info[0].sfb_width = + (WORD8 *)ptr_sfb_width[0]; + ptr_aac_tables->str_aac_sfb_info[1].sfb_width = + (WORD8 *)ptr_sfb_width[0]; + ptr_aac_tables->str_aac_sfb_info[3].sfb_width = + (WORD8 *)ptr_sfb_width[0]; + ptr_aac_tables->str_aac_sfb_info[2].sfb_width = + (WORD8 *)ptr_sfb_width[1]; + } + } + { + ia_aac_decoder_struct *aac_dec_handle = + &aac_persistent_mem->str_aac_decoder; + aac_dec_handle->sampling_rate_index = (WORD16)i; + aac_dec_handle->sampling_rate = sampling_rate; + aac_dec_handle->channels = 1; + aac_dec_handle->block_number = 0; + aac_dec_handle->samples_per_frame = frame_length; + } + } + + return &(aac_persistent_mem->str_aac_decoder); +} diff --git a/decoder/ixheaacd_interface.h b/decoder/ixheaacd_interface.h new file mode 100644 index 0000000..07f7963 --- /dev/null +++ b/decoder/ixheaacd_interface.h @@ -0,0 +1,116 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_INTERFACE_H +#define IXHEAACD_INTERFACE_H + +enum { + LN = 2048, + SN = 256, + LN2 = LN / 2, + SN2 = SN / 2, + LN4 = LN / 4, + SN4 = SN / 4, + NSHORT = LN / SN, + MAX_SBK = NSHORT, + + MAXBANDS = 16 * NSHORT, + MAXFAC = 121, + MIDFAC = (MAXFAC - 1) / 2, + SF_OFFSET = 100, + + LEN_TAG = 4, + LEN_MAX_SFBS = 4, + LEN_MAX_SFBL = 6, + LEN_SAMP_IDX = 4, + LEN_PC_COMM = 8, +}; + +WORD32 ixheaacd_dec_main(VOID *handle, WORD8 *inbuffer, WORD8 *outbuffer, + WORD32 *out_bytes, WORD32 frames_done, WORD32 pcmsize, + WORD32 *num_channel_out); + +VOID ixheaacd_complex_fft_p3(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift); + +VOID ixheaacd_complex_fft_p2_dec(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift); + +VOID ixheaacd_complex_fft_p2_armv7(WORD32 *xr, WORD32 *xi, WORD32 nlength, + WORD32 fft_mode, WORD32 *preshift); + +VOID ixheaacd_mps_complex_fft_64_dec(WORD32 *ptr_x, WORD32 *fin_re, + WORD32 *fin_im, WORD32 nlength); + +VOID ixheaacd_mps_complex_fft_64_armv7(WORD32 *ptr_x, WORD32 *fin_re, + WORD32 *fin_im, WORD32 nlength); + +VOID ixheaacd_mps_complex_fft_64_asm(const WORD32 *table, WORD32 nlength, + WORD32 *ptr_x, WORD32 *ptr_y, + const WORD8 *table2); + +VOID ixheaacd_complex_ifft_p2_asm(const WORD32 *table, WORD32 nlength, + WORD32 *ptr_x, WORD32 *ptr_y); + +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_armv7(WORD32 *ptr_in, WORD32 *table_re, + 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_armv7(WORD32 *ptr_in, WORD32 *table_re, + 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, + const WORD32 *sin_ptr); + +VOID ixheaacd_calc_pre_twid_armv7(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *cos_ptr, + const WORD32 *sin_ptr); + +VOID ixheaacd_calc_post_twid_dec(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *cos_ptr, + const WORD32 *sin_ptr); + +VOID ixheaacd_calc_post_twid_armv7(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, + WORD32 nlength, const WORD32 *cos_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); + +VOID ixheaacd_mps_synt_post_fft_twiddle_armv7(WORD32 resolution, WORD32 *fin_re, + WORD32 *fin_im, WORD32 *table_re, + WORD32 *table_im, WORD32 *state); + +VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out, + WORD32 *state, const WORD32 *filter_coeff); + +VOID ixheaacd_mps_synt_out_calc_armv7(WORD32 resolution, WORD32 *out, + WORD32 *state, + const WORD32 *filter_coeff); +#endif /* #ifndef IXHEAACD_INTERFACE_H */ diff --git a/decoder/ixheaacd_intrinsics.h b/decoder/ixheaacd_intrinsics.h new file mode 100644 index 0000000..ec78e19 --- /dev/null +++ b/decoder/ixheaacd_intrinsics.h @@ -0,0 +1,26 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_INTRINSICS_H +#define IXHEAACD_INTRINSICS_H + +#define SHORT_BITS 16 +#define INT_BITS 32 + +#endif diff --git a/decoder/ixheaacd_latmdemux.c b/decoder/ixheaacd_latmdemux.c new file mode 100644 index 0000000..d800c88 --- /dev/null +++ b/decoder/ixheaacd_latmdemux.c @@ -0,0 +1,313 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include +#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_bitbuffer.h" + +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_defines.h" + +#include "ixheaacd_aac_rom.h" + +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_common_rom.h" + +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_stereo.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_multichannel.h" +#include "ixheaacd_headerdecode.h" + +WORD32 ixheaacd_latm_au_chunk_length_info( + struct ia_bit_buf_struct *it_bit_buff) { + UWORD8 reading_done; + WORD32 len = 0; + + do { + UWORD32 tmp = ixheaacd_read_bits_buf(it_bit_buff, 8); + reading_done = (tmp < 255); + + len += tmp; + + } while (reading_done == 0); + + len <<= 3; + + return len; +} + +WORD32 ixheaacd_latm_payload_length_info(struct ia_bit_buf_struct *it_bit_buff, + ixheaacd_latm_struct *latm_element) { + WORD32 error_code = AAC_DEC_OK; + UWORD32 prog, lay; + + if (latm_element->all_streams_same_time_framing == 1) { + for (prog = 0; prog < latm_element->num_program; prog++) { + for (lay = 0; lay < latm_element->num_layer; lay++) { + ixheaacd_latm_layer_info *layer_info = + &latm_element->layer_info[prog][lay]; + + switch (layer_info->frame_len_type) { + case 0: + layer_info->frame_len_bits = + ixheaacd_latm_au_chunk_length_info(it_bit_buff); + if (layer_info->frame_len_bits % 8 != 0) { + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + return error_code; + } + + latm_element->frame_length = layer_info->frame_len_bits >> 3; + latm_element->frame_length += + (it_bit_buff->size - it_bit_buff->cnt_bits) >> 3; + break; + + default: + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + return error_code; + } + } + } + } else { + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + return error_code; + } + + return (error_code); +} + +static UWORD32 ixheaacd_latm_get_value(ia_bit_buf_struct *it_bit_buff) { + UWORD32 bytes_read; + + bytes_read = ixheaacd_read_bits_buf(it_bit_buff, 2) + 1; + + if (bytes_read <= 3) + return ixheaacd_read_bits_buf(it_bit_buff, 8 * bytes_read); + else + return (ixheaacd_read_bits_buf(it_bit_buff, 24) << 24) + + ixheaacd_read_bits_buf(it_bit_buff, 8); +} + +WORD32 ixheaacd_latm_stream_mux_config( + struct ia_bit_buf_struct *it_bit_buff, ixheaacd_latm_struct *latm_element, + ia_aac_dec_state_struct *aac_state_struct, + ia_sampling_rate_info_struct *sample_rate_info) { + UWORD32 prog; + UWORD32 lay; + WORD32 bytes_consumed; + WORD32 audio_mux_version_a; + UWORD32 tara_buf_fullness; + WORD32 error_code = AAC_DEC_OK; + ixheaacd_latm_layer_info *layer_info = 0; + + latm_element->audio_mux_version = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (latm_element->audio_mux_version == 1) + audio_mux_version_a = ixheaacd_read_bits_buf(it_bit_buff, 1); + else + audio_mux_version_a = 0; + + if (audio_mux_version_a == 0) { + if (latm_element->audio_mux_version == 1) { + tara_buf_fullness = ixheaacd_latm_get_value(it_bit_buff); + } + latm_element->all_streams_same_time_framing = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + latm_element->num_sub_frames = ixheaacd_read_bits_buf(it_bit_buff, 6) + 1; + + if (latm_element->num_sub_frames != 1) { + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + return error_code; + } + + latm_element->num_program = ixheaacd_read_bits_buf(it_bit_buff, 4) + 1; + + for (prog = 0; prog < latm_element->num_program; prog++) { + latm_element->num_layer = ixheaacd_read_bits_buf(it_bit_buff, 3) + 1; + + for (lay = 0; lay < latm_element->num_layer; lay++) { + layer_info = &latm_element->layer_info[prog][lay]; + layer_info->frame_len_bits = 0; + + if ((prog == 0) && (lay == 0)) { + WORD32 asc_len, pos; + + latm_element->use_same_config = 0; + + asc_len = (latm_element->audio_mux_version == 1) + ? ixheaacd_latm_get_value(it_bit_buff) + : 0; + pos = it_bit_buff->size - it_bit_buff->cnt_bits; + + if (asc_len > it_bit_buff->size - 106 || asc_len > 2592) { + error_code = IA_ENHAACPLUS_DEC_INIT_FATAL_DEC_INIT_FAIL; + return (error_code); + } + + if ((error_code = ixheaacd_ga_hdr_dec( + aac_state_struct, it_bit_buff->cnt_bits, &bytes_consumed, + sample_rate_info, it_bit_buff))) + return (error_code); + + if (asc_len) { + asc_len -= (it_bit_buff->size - it_bit_buff->cnt_bits) - pos; + ixheaacd_read_bidirection(it_bit_buff, asc_len); + } + + layer_info->asc.aot = aac_state_struct->audio_object_type; + layer_info->asc.channel_config = aac_state_struct->ch_config; + layer_info->asc.samples_per_frame = aac_state_struct->frame_len_flag; + layer_info->asc.sampling_freq = aac_state_struct->sampling_rate; + layer_info->asc.samples_per_frame = aac_state_struct->frame_length; + } else { + latm_element->use_same_config = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (latm_element->use_same_config && (lay > 0)) { + layer_info->asc = latm_element->layer_info[prog][lay - 1].asc; + } else { + if ((error_code = ixheaacd_ga_hdr_dec( + aac_state_struct, it_bit_buff->cnt_bits, &bytes_consumed, + sample_rate_info, it_bit_buff))) + return (error_code); + } + } + + layer_info->frame_len_type = ixheaacd_read_bits_buf(it_bit_buff, 3); + + switch (layer_info->frame_len_type) { + case 0: + layer_info->buffer_fullness = + ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (!latm_element->all_streams_same_time_framing) { + if ((lay > 0) && layer_info->asc.aot == AOT_AAC_SCAL) { + } + } + break; + + default: + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + return error_code; + } + } + } + + latm_element->other_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (latm_element->other_data_present) { + if (latm_element->audio_mux_version == 1) { + latm_element->other_data_length = ixheaacd_latm_get_value(it_bit_buff); + } else { + UWORD32 other_data_len; + latm_element->other_data_length = 0; + do { + other_data_len = ixheaacd_read_bits_buf(it_bit_buff, 1); + latm_element->other_data_length <<= 8; + latm_element->other_data_length += + ixheaacd_read_bits_buf(it_bit_buff, 8); + } while (other_data_len); + } + } + + latm_element->crc_check_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (latm_element->crc_check_present) { + latm_element->crc_check_sum = ixheaacd_read_bits_buf(it_bit_buff, 8); + } + } else { + error_code = IA_ENHAACPLUS_DEC_EXE_FATAL_INVALID_LOAS_HEADER; + } + return (error_code); +} + +WORD32 ixheaacd_latm_audio_mux_element( + struct ia_bit_buf_struct *it_bit_buff, ixheaacd_latm_struct *latm_element, + ia_aac_dec_state_struct *aac_state_struct, + ia_sampling_rate_info_struct *sample_rate_info) { + UWORD32 i; + WORD32 error_code = AAC_DEC_OK; + + ixheaacd_read_bits_buf(it_bit_buff, 13); + + latm_element->use_same_stream_mux = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (!latm_element->use_same_stream_mux) { + if ((error_code = ixheaacd_latm_stream_mux_config( + it_bit_buff, latm_element, aac_state_struct, sample_rate_info))) { + return (error_code); + } + } + + for (i = 0; i < latm_element->num_sub_frames; i++) { + if ((error_code = + ixheaacd_latm_payload_length_info(it_bit_buff, latm_element))) { + if (error_code != 0) return (error_code); + } + } + + return (error_code); +} diff --git a/decoder/ixheaacd_latmdemux.h b/decoder/ixheaacd_latmdemux.h new file mode 100644 index 0000000..d085f1f --- /dev/null +++ b/decoder/ixheaacd_latmdemux.h @@ -0,0 +1,65 @@ +/****************************************************************************** + * * + * 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 LATM_DEMUX_H +#define LATM_DEMUX_H + +#define LATM_MAX_PROG 8 +#define LATM_MAX_LAYER 8 +#define LATM_MAX_VAR_CHUNKS 16 +#define LATM_MAX_ID 16 + +typedef struct { + AUDIO_OBJECT_TYPE aot; + UWORD32 sampling_freq_index; + UWORD32 sampling_freq; + WORD32 channel_config; + UWORD32 samples_per_frame; +} ixheaacd_latm_specs; + +typedef struct { + UWORD32 frame_len_type; + UWORD32 buffer_fullness; + UWORD32 frame_len_bits; + ixheaacd_latm_specs asc; +} ixheaacd_latm_layer_info; + +typedef struct { + UWORD32 use_same_stream_mux; + UWORD32 audio_mux_version; + UWORD32 all_streams_same_time_framing; + UWORD32 num_sub_frames; + UWORD32 num_program; + UWORD32 num_layer; + UWORD32 use_same_config; + + UWORD32 other_data_present; + UWORD32 other_data_length; + UWORD32 crc_check_present; + UWORD32 crc_check_sum; + UWORD32 frame_length; + ixheaacd_latm_layer_info layer_info[LATM_MAX_PROG][LATM_MAX_LAYER]; +} ixheaacd_latm_struct; + +WORD32 ixheaacd_latm_au_chunk_length_info(ia_bit_buf_struct* it_bit_buff); + +WORD32 ixheaacd_latm_payload_length_info(ia_bit_buf_struct* it_bit_buff, + ixheaacd_latm_struct* latm_element); + +#endif diff --git a/decoder/ixheaacd_longblock.c b/decoder/ixheaacd_longblock.c new file mode 100644 index 0000000..6f00ca8 --- /dev/null +++ b/decoder/ixheaacd_longblock.c @@ -0,0 +1,314 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_bitbuffer.h" +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_error_codes.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" + +#define LONG_BLOCK_SECT_LEN 5 +#define SHORT_BLOCK_SECT_LEN 3 + +WORD16 ixheaacd_read_section_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + WORD32 aac_spect_data_resil_flag, WORD32 aac_sect_data_resil_flag, + ia_aac_dec_tables_struct *ptr_aac_tables) { + WORD sfb; + WORD sect_cb; + WORD sect_len; + WORD sect_len_incr; + WORD sect_esc_val; + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + WORD max_sfb = ptr_ics_info->max_sfb; + WORD num_win_group; + + WORD8 *ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; + WORD8 *ptr_code_book_temp = ptr_code_book; + WORD32 sect_bitlen = LONG_BLOCK_SECT_LEN; + int num_lines_sec_idx = 0, top; + short *ptr_num_sect_lines = + ptr_aac_dec_channel_info->num_line_in_sec4_hcr_arr; + UWORD8 *ptr_hcr_code_book = ptr_aac_dec_channel_info->cb4_hcr_arr; + const short *band_offsets = (WORD16 *)ixheaacd_getscalefactorbandoffsets( + &(ptr_aac_dec_channel_info->str_ics_info), ptr_aac_tables); + ptr_aac_dec_channel_info->number_sect = 0; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + sect_bitlen = SHORT_BLOCK_SECT_LEN; + } + + sect_esc_val = (1 << sect_bitlen) - 1; + + for (num_win_group = 0; num_win_group < ptr_ics_info->num_window_groups; + num_win_group++) { + sfb = 0; + + while (sfb < max_sfb) { + sect_len = 0; + if (aac_sect_data_resil_flag) { + sect_cb = ixheaacd_read_bits_buf(it_bit_buff, 5); + } else { + sect_cb = ixheaacd_read_bits_buf(it_bit_buff, 4); + } + + if ((aac_sect_data_resil_flag == 0) || + ((sect_cb < 11) || ((sect_cb > 11) && (sect_cb < 16)))) { + sect_len_incr = ixheaacd_read_bits_buf(it_bit_buff, sect_bitlen); + while (sect_len_incr == sect_esc_val) { + sect_len = (sect_len + sect_esc_val); + sect_len_incr = ixheaacd_read_bits_buf(it_bit_buff, sect_bitlen); + } + } else + sect_len_incr = 1; + + sect_len = (sect_len + sect_len_incr); + top = (sfb + sect_len); + + if (aac_spect_data_resil_flag) { + if (num_lines_sec_idx >= MAX_SFB_HCR) { + return -1; + } + ptr_num_sect_lines[num_lines_sec_idx] = + band_offsets[top] - band_offsets[sfb]; + num_lines_sec_idx++; + if (sect_cb == (ESC_HCB + 1)) { + return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INVALID_CODE_BOOK; + } else { + *ptr_hcr_code_book++ = sect_cb; + } + ptr_aac_dec_channel_info->number_sect++; + } + + sfb = (sfb + sect_len); + if (sfb > max_sfb) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_SFB_TRANSMITTED); + } + if (sect_cb == (ESC_HCB + 1)) { + return (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INVALID_CODE_BOOK); + } + + while (sect_len--) { + *ptr_code_book_temp++ = sect_cb; + } + } + ptr_code_book += MAX_SCALE_FACTOR_BANDS_SHORT; + ptr_code_book_temp = ptr_code_book; + } + + return AAC_DEC_OK; +} + +VOID ixheaacd_read_scale_factor_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 object_type) { + WORD sfb; + WORD16 position = 0; + WORD num_win_group; + WORD16 factor = ptr_aac_dec_channel_info->global_gain; + WORD8 *ptr_code_book, *ptr_code_book_short; + WORD16 *ptr_scale_fact, *ptr_scale_fact_short; + WORD16 norm_value; + WORD16 index, length; + const UWORD16 *hcod_sf = + ptr_aac_tables->pstr_huffmann_tables->huffman_code_book_scl; + const UWORD32 *table_idx = + ptr_aac_tables->pstr_huffmann_tables->huffman_code_book_scl_index; + + WORD start_bit_pos = it_bit_buff->bit_pos; + UWORD8 *start_read_pos = it_bit_buff->ptr_read_next; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD32 bit_pos = 7 - it_bit_buff->bit_pos; + WORD32 read_word; + WORD32 diffbytes; + + diffbytes = it_bit_buff->ptr_bit_buf_end - ptr_read_next; + diffbytes++; + if (diffbytes >= 4) { + read_word = ixheaacd_aac_showbits_32(ptr_read_next); + diffbytes = 4; + ptr_read_next = it_bit_buff->ptr_read_next + 4; + } else { + WORD32 ii; + read_word = 0; + for (ii = 0; ii < diffbytes; ii++) { + read_word = (read_word << 8) | (*ptr_read_next); + ptr_read_next++; + } + read_word <<= ((4 - diffbytes) << 3); + } + + ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; + + ptr_scale_fact = ptr_aac_dec_channel_info->ptr_scale_factor; + + for (num_win_group = 0; + num_win_group < ptr_aac_dec_channel_info->str_ics_info.num_window_groups; + num_win_group++) { + ptr_code_book_short = + &ptr_code_book[num_win_group * MAX_SCALE_FACTOR_BANDS_SHORT]; + ptr_scale_fact_short = + &ptr_scale_fact[num_win_group * MAX_SCALE_FACTOR_BANDS_SHORT]; + for (sfb = ptr_aac_dec_channel_info->str_ics_info.max_sfb - 1; sfb >= 0; + sfb--) { + WORD32 sfb_cb = *ptr_code_book_short++; + if (sfb_cb == ZERO_HCB) + *ptr_scale_fact_short++ = 0; + else { + { + WORD32 pns_present = 0; + WORD pns_band; + + ia_pns_info_struct *ptr_pns_info = + &ptr_aac_dec_channel_info->str_pns_info; + + if (sfb_cb == NOISE_HCB && (ptr_pns_info->pns_active != 1)) { + pns_present = 1; + } + + if (!pns_present) { + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + + ixheaacd_huffman_decode(read_word1, &index, &length, hcod_sf, + table_idx); + + bit_pos += length; + ixheaacd_aac_read_byte_corr(&ptr_read_next, &bit_pos, &read_word, + it_bit_buff->ptr_bit_buf_end); + while (bit_pos > 8) + ixheaacd_aac_read_byte(&ptr_read_next, &bit_pos, &read_word); + + norm_value = index - 60; + } + + else { + WORD32 noise_start_value; + UWORD32 temp; + + temp = (read_word << bit_pos); + temp = ((UWORD32)temp >> (32 - 9)); + noise_start_value = temp; + bit_pos += 9; + + ixheaacd_aac_read_2bytes(&ptr_read_next, &bit_pos, &read_word); + + norm_value = noise_start_value - 256; + ptr_pns_info->pns_active = 1; + + ptr_pns_info->noise_energy = + ptr_aac_dec_channel_info->global_gain - NOISE_OFFSET; + } + + if ((object_type != AOT_ER_AAC_ELD) && + (object_type != AOT_ER_AAC_LD)) { + if (sfb_cb > NOISE_HCB) { + position = position + norm_value; + *ptr_scale_fact_short++ = -position; + } else if (sfb_cb < NOISE_HCB) { + factor = factor + norm_value; + *ptr_scale_fact_short++ = factor; + } else { + ptr_pns_info->noise_energy = + ixheaacd_add16_sat(ptr_pns_info->noise_energy, norm_value); + + pns_band = (num_win_group << 4) + + ptr_aac_dec_channel_info->str_ics_info.max_sfb - sfb - + 1; + ptr_aac_dec_channel_info->ptr_scale_factor[pns_band] = + ptr_pns_info->noise_energy; + + ptr_pns_info->pns_used[pns_band] = 1; + ptr_scale_fact_short++; + } + } else { + if ((sfb_cb == INTENSITY_HCB) || (sfb_cb == INTENSITY_HCB2)) { + position = position + norm_value; + *ptr_scale_fact_short++ = -position; + } else if (sfb_cb == NOISE_HCB) { + ptr_pns_info->noise_energy = + ixheaacd_add16_sat(ptr_pns_info->noise_energy, norm_value); + + pns_band = (num_win_group << 4) + + ptr_aac_dec_channel_info->str_ics_info.max_sfb - sfb - + 1; + ptr_aac_dec_channel_info->ptr_scale_factor[pns_band] = + ptr_pns_info->noise_energy; + + ptr_pns_info->pns_used[pns_band] = 1; + ptr_scale_fact_short++; + + } else { + factor = factor + norm_value; + *ptr_scale_fact_short++ = factor; + } + } + } + } + } + } + + it_bit_buff->ptr_read_next = ptr_read_next - diffbytes; + + it_bit_buff->bit_pos = 7 - bit_pos; + { + WORD bits_consumed; + bits_consumed = ((it_bit_buff->ptr_read_next - start_read_pos) << 3) + + (start_bit_pos - it_bit_buff->bit_pos); + it_bit_buff->cnt_bits -= bits_consumed; + } +} diff --git a/decoder/ixheaacd_lpc.c b/decoder/ixheaacd_lpc.c new file mode 100644 index 0000000..82b1a74 --- /dev/null +++ b/decoder/ixheaacd_lpc.c @@ -0,0 +1,720 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include + +#include +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_func_def.h" +#include "ixheaacd_windows.h" +#include "ixheaacd_acelp_com.h" +#include "ixheaacd_constants.h" +#include +#include + +#define LSF_GAP_F 50.0f +#define FREQ_MAX_F 6400.0f +#define FREQ_DIV_F 400.0f + +extern const FLOAT32 lsf_init[ORDER]; + +extern const FLOAT32 ixheaacd_fir_lp_filt[1 + FILTER_DELAY]; + +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, + 92134, 100030, 108604, 117913, 128019, 138992, 150905, + 163840, 177882, 193129, 209682, 227654, 247167, 268352, + 291353, 316325, 343438, 372874, 404834, 439532, 477205, + 518107, 562515, 610728, 663075, 719908, 781612, 848605, + 921340, 1000309, 1086046, 1179133, 1280197, 1389925, 1509057, + 1638400, 1778829, 1931294, 2096827, 2276549, 2471675, 2683525, + 2913532, 3163255, 3434381, 3728745, 4048340, 4395328, 4772057, + 5181075, 5625151, 6107289, 6630752, 7199081, 7816122, 8486051, + 9213400, 10003091, 10860467, 11791330, 12801978, 13899250, 15090570, + 16384000, 17788290, 19312945, 20968279, 22765494, 24716750, 26835250, + 29135329, 31632551, 34343813, 37287459, 40483409, 43953287, 47720573, + 51810757, 56251515, 61072895, 66307521, 71990813, 78161226, 84860513, + 92134002, 100030911, 108604672, 117913300, 128019781, 138992500, 150905703, + 163840000, 177882909, 193129453, 209682794, 227654941, 247167501, 268352504, + 291353298, 316325515, 343438130, 372874596, 404834095, 439532879, 477205734, + 518107571, 562515151}; + +VOID ixheaacd_lsf_weight_2st_flt(float *lsfq, float *w, WORD32 mode); + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_m(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 31); + + return (result); +} + +void ixheaacd_reset_acelp_data_fix(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, + WORD32 *ptr_overlap_buf, + WORD32 was_last_short, WORD32 tw_mdct) { + WORD32 i; + + if (was_last_short == 1) { + st->mode_prev = -2; + } else { + st->mode_prev = -1; + } + + for (i = 0; i < NUM_SUBFR_SUPERFRAME_BY2 - 1; i++) { + st->pitch_prev[i] = 64; + st->gain_prev[i] = 0; + } + + st->bpf_active_prev = 0; + + if (ptr_overlap_buf != NULL && !tw_mdct) { + const WORD32 *ptr_window_coeff; + WORD32 fac_length; + if (was_last_short) { + fac_length = (usac_data->ccfl) / 16; + } else { + fac_length = (usac_data->len_subfrm) / 2; + } + + if (fac_length == 48) { + ptr_window_coeff = ixheaacd_sine_win_96; + } else if (fac_length == 64) { + ptr_window_coeff = ixheaacd_sine_win_128; + } else if (fac_length == 96) { + ptr_window_coeff = ixheaacd_sine_win_192; + } else { + ptr_window_coeff = ixheaacd_sine_win_256; + } + + for (i = 0; i < 2 * fac_length; i++) { + ptr_overlap_buf[(usac_data->ccfl) / 2 - fac_length + i] = + ixheaacd_mult32_m( + ptr_overlap_buf[(usac_data->ccfl) / 2 - fac_length + i], + ptr_window_coeff[2 * fac_length - 1 - i]); + } + for (i = 0; i < (usac_data->ccfl) / 2 - fac_length; i++) { + ptr_overlap_buf[(usac_data->ccfl) / 2 + fac_length + i] = 0; + } + } + + return; +} + +VOID ixheaacd_fix2flt_data(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, WORD32 k) { + WORD32 i; + WORD32 fac_length; + WORD32 window_sequence_last = usac_data->window_sequence_last[k]; + WORD32 *p_ola_buffer = usac_data->overlap_data_ptr[k]; + if (window_sequence_last == EIGHT_SHORT_SEQUENCE) { + fac_length = (usac_data->ccfl) / 16; + } else { + fac_length = (usac_data->len_subfrm) / 2; + } + + 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); + + st->gain_threshold = 0.0f; + + if (p_ola_buffer != NULL) { + for (i = 0; i < (usac_data->len_subfrm) / 2 - fac_length; i++) { + st->exc_prev[i] = 0; + } + for (i = 0; i < 2 * fac_length + 1; i++) { + st->exc_prev[(usac_data->len_subfrm) / 2 - fac_length + i] = (FLOAT32)( + p_ola_buffer[i + usac_data->ccfl / 2 - fac_length - 1] / 16384.0); + } + } else { + ixheaacd_memset(st->exc_prev, 1 + (2 * FAC_LENGTH)); + } + + return; +} + +void ixheaacd_init_acelp_data(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st) { + ixheaacd_reset_acelp_data_fix(usac_data, st, NULL, 0, 0); +} + +#define PI_BY_6400 (PI / 6400.0) +#define SCALE1 (6400.0 / PI) + +void ixheaacd_lsp_2_lsf_conversion(float lsp[], float lsf[], WORD32 m) { + short i; + for (i = 0; i < m; i++) { + lsf[i] = (float)(acos(lsp[i]) * SCALE1); + } + return; +} + +static VOID ixheaacd_lsf_2_lsp_conversion_float(FLOAT32 lsf[], FLOAT32 lsp[], + WORD32 m) { + WORD32 i; + for (i = 0; i < m; i++) + lsp[i] = (FLOAT32)cos((double)lsf[i] * (double)PI_BY_6400); + + return; +} + +static VOID ixheaacd_bass_post_filter(FLOAT32 *synth_sig, WORD32 *pitch, + FLOAT32 *pitch_gain, FLOAT32 *synth_out, + WORD32 len_fr, WORD32 len2, + FLOAT32 bpf_prev[]) { + WORD32 i, j, sf, num_subfr, pitch_lag, lg; + FLOAT32 x_energy, xy_corr, y_energy, norm_corr, energy, gain, tmp, alpha; + FLOAT32 noise_buf[FILTER_DELAY + (2 * LEN_SUBFR)], *noise_tmp1, *noise_tmp2, + *x, *y; + + noise_tmp1 = noise_buf + FILTER_DELAY; + noise_tmp2 = noise_buf + FILTER_DELAY + LEN_SUBFR; + + memcpy(synth_out, synth_sig - LEN_SUBFR, len_fr * sizeof(FLOAT32)); + + if (len_fr % 64) + memset(synth_out + len_fr, 0, (LEN_SUBFR - len_fr % 64) * sizeof(FLOAT32)); + + sf = 0; + for (num_subfr = 0; num_subfr < len_fr; num_subfr += LEN_SUBFR, sf++) { + pitch_lag = pitch[sf]; + gain = pitch_gain[sf]; + + if (gain > 1.0f) gain = 1.0f; + if (gain < 0.0f) gain = 0.0f; + + x = &synth_sig[num_subfr - 96]; + y = &synth_sig[num_subfr - pitch_lag / 2 - 96]; + + x_energy = 0.01f; + xy_corr = 0.01f; + y_energy = 0.01f; + for (i = 0; i < LEN_SUBFR + 96; i++) { + x_energy += x[i] * x[i]; + xy_corr += x[i] * y[i]; + y_energy += y[i] * y[i]; + } + + norm_corr = xy_corr / (FLOAT32)sqrt(x_energy * y_energy); + + if (norm_corr > 0.95f) pitch_lag >>= 1; + + lg = len_fr + len2 - pitch_lag - num_subfr; + if (lg < 0) lg = 0; + if (lg > LEN_SUBFR) lg = LEN_SUBFR; + + if (gain > 0) { + if (lg > 0) { + tmp = 0.01f; + for (i = 0; i < lg; i++) { + tmp += synth_sig[i + num_subfr] * synth_sig[i + num_subfr]; + } + energy = 0.01f; + for (i = 0; i < lg; i++) { + energy += synth_sig[i + num_subfr + pitch_lag] * + synth_sig[i + num_subfr + pitch_lag]; + } + tmp = (FLOAT32)sqrt(tmp / energy); + if (tmp < gain) gain = tmp; + } + + alpha = 0.5f * gain; + for (i = 0; i < lg; i++) { + noise_tmp2[i] = alpha * (synth_sig[i + num_subfr] - + 0.5f * synth_sig[i + num_subfr - pitch_lag] - + 0.5f * synth_sig[i + num_subfr + pitch_lag]); + } + for (i = lg; i < LEN_SUBFR; i++) { + noise_tmp2[i] = alpha * (synth_sig[i + num_subfr] - + synth_sig[i + num_subfr - pitch_lag]); + } + } else { + memset(noise_tmp2, 0, LEN_SUBFR * sizeof(FLOAT32)); + } + + memcpy(noise_buf, bpf_prev, (FILTER_DELAY + LEN_SUBFR) * sizeof(FLOAT32)); + memcpy(bpf_prev, noise_buf + LEN_SUBFR, + (FILTER_DELAY + LEN_SUBFR) * sizeof(FLOAT32)); + + for (i = 0; i < LEN_SUBFR; i++) { + tmp = ixheaacd_fir_lp_filt[0] * noise_tmp1[i]; + for (j = 1; j <= FILTER_DELAY; j++) { + tmp += + ixheaacd_fir_lp_filt[j] * (noise_tmp1[i - j] + noise_tmp1[i + j]); + } + synth_out[i + num_subfr] -= tmp; + } + } + + return; +} + +void ixheaacd_reorder_lsf(float *lsf, float min_dist, int n) { + int i; + float lsf_min; + + lsf_min = min_dist; + for (i = 0; i < n; i++) { + if (lsf[i] < lsf_min) lsf[i] = lsf_min; + + lsf_min = lsf[i] + min_dist; + } + + lsf_min = FREQ_MAX_F - min_dist; + for (i = n - 1; i >= 0; i--) { + if (lsf[i] > lsf_min) lsf[i] = lsf_min; + + lsf_min = lsf[i] - min_dist; + } + + return; +} + +WORD32 ixheaacd_lpd_dec(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, + ia_td_frame_data_struct *pstr_td_frame_data, + FLOAT32 fsynth[], WORD32 first_lpd_flag, + WORD32 short_fac_flag, WORD32 bpf_control_info) { + FLOAT32 *synth_buf = usac_data->synth_buf; + FLOAT32 *xcitation_buff = usac_data->exc_buf; + FLOAT32 lsp_curr[ORDER]; + FLOAT32 lsf_curr[ORDER]; + FLOAT32 *lp_flt_coff_a = usac_data->lp_flt_coff; + FLOAT32 *synth, *xcitation_curr; + WORD32 *pitch = usac_data->pitch; + FLOAT32 *pitch_gain = usac_data->pitch_gain; + FLOAT32 lsf_flt[(2 * NUM_FRAMES + 1) * ORDER]; + + WORD32 i, k, tp, mode; + WORD32 *mod; + FLOAT32 gain, stability_factor; + FLOAT32 tmp, synth_corr, synth_energy; + + WORD32 len_fr; + WORD32 len_subfrm; + WORD32 num_subfr; + WORD32 num_subfr_in_superfr; + WORD32 num_subfr_by2; + WORD32 synth_delay; + WORD32 num_samples = 0; + + WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; + + WORD32 subfr_len, n_subfr; + WORD32 err = 0; + + len_fr = usac_data->ccfl; + len_subfrm = usac_data->len_subfrm; + num_subfr = usac_data->num_subfrm; + num_subfr_in_superfr = NUM_FRAMES * num_subfr; + num_subfr_by2 = (num_subfr_in_superfr / 2) - 1; + synth_delay = num_subfr_by2 * LEN_SUBFR; + + synth = synth_buf + MAX_PITCH + synth_delay; + ixheaacd_mem_cpy(st->synth_prev, synth_buf, MAX_PITCH + synth_delay); + ixheaacd_memset(synth, SYNTH_DELAY_LMAX + LEN_SUPERFRAME - synth_delay); + + xcitation_curr = xcitation_buff + MAX_PITCH + INTER_LP_FIL_ORDER + 1; + ixheaacd_mem_cpy(st->xcitation_prev, xcitation_buff, + MAX_PITCH + INTER_LP_FIL_ORDER + 1); + memset(xcitation_curr, 0, sizeof(FLOAT32) * (LEN_SUPERFRAME + 1)); + + mod = pstr_td_frame_data->mod; + + for (i = 0; i < num_subfr_by2; i++) { + pitch[i] = st->pitch_prev[i]; + pitch_gain[i] = st->gain_prev[i]; + } + for (i = 0; i < num_subfr_in_superfr; i++) { + pitch[i + num_subfr_by2] = 64; + pitch_gain[i + num_subfr_by2] = 0.0f; + } + if (!first_lpd_flag) { + ixheaacd_lsp_2_lsf_conversion(st->lspold, lsf_flt, ORDER); + } + + ixheaacd_alg_vec_dequant(pstr_td_frame_data, first_lpd_flag, lsf_flt, + pstr_td_frame_data->mod); + + if (first_lpd_flag) { + ixheaacd_mem_cpy(&lsf_flt[0], st->lsf_prev, ORDER); + ixheaacd_lsf_2_lsp_conversion_float(st->lsf_prev, st->lspold, ORDER); + } + + if ((first_lpd_flag && mod[0] == 0) || (first_lpd_flag && mod[1] == 0) || + ((first_lpd_flag && mod[2] == 0 && len_subfrm != LEN_FRAME))) { + FLOAT32 lp_flt_coeff_a[9 * (ORDER + 1)]; + FLOAT32 tmp_buf[3 * LEN_FRAME + ORDER]; + FLOAT32 tmp_res_buf[3 * LEN_FRAME]; + FLOAT32 *tmp = &(tmp_buf[LEN_FRAME]); + FLOAT32 *ptr_tmp = &(tmp_res_buf[LEN_FRAME]); + WORD32 tmp_start; + FLOAT32 mem = 0; + WORD32 gain; + WORD32 length; + + ixheaacd_interpolation_lsp_params(st->lspold, st->lspold, lp_flt_coeff_a, + 8); + + memcpy(st->lp_flt_coeff_a_prev, lp_flt_coeff_a, + (ORDER + 1) * sizeof(FLOAT32)); + memcpy(st->lp_flt_coeff_a_prev + ORDER + 1, lp_flt_coeff_a, + (ORDER + 1) * sizeof(FLOAT32)); + + if (mod[0] == 0) { + WORD32 fac_length; + if (short_fac_flag) { + fac_length = (len_subfrm * NUM_FRAMES) / 16; + } else { + fac_length = len_subfrm / 2; + } + + gain = ixheaacd_pow_10_i_by_128[pstr_td_frame_data->fac_data[0]]; + + memcpy(ptr_scratch, &pstr_td_frame_data->fac_data[0], + 129 * sizeof(WORD32)); + + for (i = 0; i < 64; 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; + } + + err = ixheaacd_fwd_alias_cancel_tool(usac_data, pstr_td_frame_data, + fac_length, lp_flt_coeff_a, gain); + if (err == -1) return err; + + memset( + &usac_data->overlap_data_ptr[usac_data->present_chan][(len_fr / 2)], + 0, fac_length * sizeof(WORD32)); + } + + if (mod[0] == 0 && len_subfrm != LEN_FRAME) { + for (i = 0; i < 3 * len_subfrm; i++) + st->fd_synth[ORDER - len_subfrm + i] = (FLOAT32)( + (FLOAT32)usac_data + ->overlap_data_ptr[usac_data->present_chan][i - len_subfrm] / + 16384.0); + num_samples = min(3 * len_subfrm, MAX_PITCH + synth_delay); + } else { + for (i = 0; i < 2 * len_subfrm; i++) + st->fd_synth[ORDER + i] = (FLOAT32)( + (FLOAT32)usac_data->overlap_data_ptr[usac_data->present_chan][i] / + 16384.0); + num_samples = min(2 * len_subfrm, MAX_PITCH + synth_delay); + } + ixheaacd_mem_cpy(st->fd_synth + ORDER, synth - 2 * len_subfrm, + 2 * len_subfrm); + if (mod[0] == 0 && len_subfrm != LEN_FRAME) { + ixheaacd_preemphsis_tool_float(st->fd_synth + ORDER - len_subfrm, + PREEMPH_FILT_FAC, 3 * len_subfrm, mem); + } else { + ixheaacd_preemphsis_tool_float(st->fd_synth + ORDER, PREEMPH_FILT_FAC, + 2 * len_subfrm, mem); + } + + if (mod[0] == 0 && len_subfrm != LEN_FRAME) { + ixheaacd_memset(tmp - len_subfrm, ORDER); + ixheaacd_mem_cpy(st->fd_synth + ORDER - len_subfrm, + tmp - len_subfrm + ORDER, 3 * len_subfrm); + tmp_start = -len_subfrm; + } else { + ixheaacd_memset(tmp, ORDER); + ixheaacd_mem_cpy(st->fd_synth + ORDER, tmp + ORDER, 2 * len_subfrm); + tmp_start = 0; + } + ixheaacd_memset(ptr_tmp - len_subfrm, 3 * len_subfrm); + memset(st->fd_synth, 0, ORDER * sizeof(WORD32)); + length = (2 * len_subfrm - tmp_start) / LEN_SUBFR; + + ixheaacd_residual_tool_float1(lp_flt_coeff_a, + &st->fd_synth[ORDER + tmp_start], + &ptr_tmp[tmp_start], LEN_SUBFR, length); + + if (mod[0] != 0 && (len_subfrm == LEN_FRAME || mod[1] != 0)) { + num_samples = min(len_subfrm, MAX_PITCH + INTER_LP_FIL_ORDER + 1); + } else if (mod[0] == 0 && len_subfrm != LEN_FRAME) { + num_samples = min(3 * len_subfrm, MAX_PITCH + INTER_LP_FIL_ORDER + 1); + } else { + num_samples = min(2 * len_subfrm, MAX_PITCH + INTER_LP_FIL_ORDER + 1); + } + ixheaacd_mem_cpy(ptr_tmp + 2 * len_subfrm - num_samples, + xcitation_curr - num_samples, num_samples); + } + + k = 0; + + while (k < 4) { + mode = mod[k]; + if ((st->mode_prev == 0) && (mode > 0) && + (k != 0 || st->bpf_active_prev == 1)) { + i = (k * num_subfr) + num_subfr_by2; + pitch[i + 1] = pitch[i] = pitch[i - 1]; + pitch_gain[i + 1] = pitch_gain[i] = pitch_gain[i - 1]; + } + + if ((mode == 0) || (mode == 1)) + memcpy(lsf_curr, &lsf_flt[(k + 1) * ORDER], ORDER * sizeof(FLOAT32)); + else if (mode == 2) + memcpy(lsf_curr, &lsf_flt[(k + 2) * ORDER], ORDER * sizeof(FLOAT32)); + else + memcpy(lsf_curr, &lsf_flt[(k + 4) * ORDER], ORDER * sizeof(FLOAT32)); + + ixheaacd_lsf_2_lsp_conversion_float(lsf_curr, lsp_curr, ORDER); + + tmp = 0.0f; + for (i = 0; i < ORDER; i++) { + tmp += (lsf_curr[i] - st->lsf_prev[i]) * (lsf_curr[i] - st->lsf_prev[i]); + } + stability_factor = (FLOAT32)(1.25f - (tmp / 400000.0f)); + if (stability_factor > 1.0f) { + stability_factor = 1.0f; + } + if (stability_factor < 0.0f) { + stability_factor = 0.0f; + } + + if (mode == 0) { + ixheaacd_interpolation_lsp_params(st->lspold, lsp_curr, lp_flt_coff_a, + num_subfr); + + ixheaacd_acelp_alias_cnx(usac_data, pstr_td_frame_data, k, lp_flt_coff_a, + stability_factor, st); + + if ((st->mode_prev != 0) && bpf_control_info) { + i = (k * num_subfr) + num_subfr_by2; + pitch[i - 1] = pitch[i]; + pitch_gain[i - 1] = pitch_gain[i]; + if (st->mode_prev != -2) { + pitch[i - 2] = pitch[i]; + pitch_gain[i - 2] = pitch_gain[i]; + } + } + k++; + } else { + if (mode == 1) { + subfr_len = len_subfrm; + n_subfr = num_subfr; + } else if (mode == 2) { + subfr_len = len_subfrm << 1; + n_subfr = num_subfr_in_superfr / 2; + } else if (mode == 3) { + subfr_len = len_subfrm << 2; + n_subfr = num_subfr_in_superfr; + } + + ixheaacd_lpc_coef_gen(st->lspold, lsp_curr, lp_flt_coff_a, n_subfr, + ORDER); + + ixheaacd_tcx_mdct(usac_data, pstr_td_frame_data, k, lp_flt_coff_a, + subfr_len, st); + k += (1 << (mode - 1)); + } + + st->mode_prev = mode; + + ixheaacd_mem_cpy(lsp_curr, st->lspold, ORDER); + ixheaacd_mem_cpy(lsf_curr, st->lsf_prev, ORDER); + } + + ixheaacd_mem_cpy(xcitation_buff + len_fr, st->xcitation_prev, + MAX_PITCH + INTER_LP_FIL_ORDER + 1); + + ixheaacd_mem_cpy(synth_buf + len_fr, st->synth_prev, MAX_PITCH + synth_delay); + + if (!bpf_control_info) { + if (mod[0] != 0 && st->bpf_active_prev) { + for (i = 2; i < num_subfr_in_superfr; i++) + pitch_gain[num_subfr_by2 + i] = 0.0; + } else { + for (i = 0; i < num_subfr_in_superfr; i++) + pitch_gain[num_subfr_by2 + i] = 0.0; + } + } + st->bpf_active_prev = bpf_control_info; + + for (i = 0; i < num_subfr_by2; i++) { + st->pitch_prev[i] = pitch[num_subfr_in_superfr + i]; + st->gain_prev[i] = pitch_gain[num_subfr_in_superfr + i]; + } + + synth = synth_buf + MAX_PITCH; + + for (i = 0; i < num_subfr_in_superfr; i++) { + tp = pitch[i]; + gain = pitch_gain[i]; + if (gain > 0.0f) { + synth_corr = 0.0f, synth_energy = 1e-6f; + for (k = 0; k < LEN_SUBFR; k++) { + synth_corr += + synth[i * LEN_SUBFR + k] * synth[(i * LEN_SUBFR) - tp + k]; + synth_energy += + synth[(i * LEN_SUBFR) - tp + k] * synth[(i * LEN_SUBFR) - tp + k]; + } + pitch_gain[i] = synth_corr / synth_energy; + } + } + + if (mod[3] == 0) { + ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, + synth_delay, st->bpf_prev); + } else { + ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, + synth_delay - (len_subfrm / 2), st->bpf_prev); + } + return err; +} + +WORD32 ixheaacd_lpd_dec_update(ia_usac_lpd_decoder_handle tddec, + ia_usac_data_struct *usac_data, WORD32 i_ch) { + WORD32 err = 0, i, k; + + WORD32 *ptr_overlap = &usac_data->overlap_data_ptr[i_ch][0]; + WORD32 len_fr, lpd_sbf_len, lpd_delay, num_subfr_by2, synth_delay, fac_length; + + if (usac_data->tw_mdct[0]) + ptr_overlap = &usac_data->overlap_data_ptr[i_ch][usac_data->ccfl / 2]; + + len_fr = usac_data->ccfl; + lpd_sbf_len = (NUM_FRAMES * usac_data->num_subfrm) / 2; + lpd_delay = lpd_sbf_len * LEN_SUBFR; + num_subfr_by2 = lpd_sbf_len - 1; + synth_delay = num_subfr_by2 * LEN_SUBFR; + fac_length = (usac_data->len_subfrm) / 2; + + for (i = 0; i < LEN_SUBFR + synth_delay; i++) + ptr_overlap[i] = (WORD32)( + (FLOAT32)tddec->synth_prev[MAX_PITCH - (LEN_SUBFR) + i] * 16384.0); + + ptr_overlap += LEN_SUBFR + synth_delay - fac_length; + + for (k = 0; k < 2 * fac_length; k++) + ptr_overlap[k] = (WORD32)((FLOAT32)tddec->exc_prev[k + 1] * 16384.0); + + ptr_overlap = &usac_data->overlap_data_ptr[i_ch][lpd_delay + fac_length]; + + for (i = 0; i < len_fr - lpd_delay - fac_length; i++) ptr_overlap[i] = 0; + + usac_data->window_shape[i_ch] = WIN_SEL_0; + usac_data->window_sequence_last[i_ch] = EIGHT_SHORT_SEQUENCE; + usac_data->td_frame_prev[i_ch] = 1; + + if (tddec->mode_prev == 0) { + memmove(usac_data->lpc_prev[i_ch], &tddec->lp_flt_coeff_a_prev[ORDER + 1], + (ORDER + 1) * sizeof(FLOAT32)); + memmove(usac_data->acelp_in[i_ch], tddec->exc_prev, + (1 + (2 * FAC_LENGTH)) * sizeof(FLOAT32)); + } + + return err; +} + +void ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag, + FLOAT32 out_buffer[], ia_usac_lpd_decoder_handle st) { + WORD32 i, tp, k; + float synth_buf[MAX_PITCH + SYNTH_DELAY_LMAX + LEN_SUPERFRAME]; + float signal_out[LEN_SUPERFRAME]; + float *synth, synth_corr, synth_energy; + WORD32 pitch[NUM_SUBFR_SUPERFRAME_BY2 + 3]; + float pitch_gain[NUM_SUBFR_SUPERFRAME_BY2 + 3]; + WORD32 len_fr, lpd_sbf_len, lpd_delay, num_subfr_by2, synth_delay, fac_length; + + len_fr = usac_data->ccfl; + lpd_sbf_len = (NUM_FRAMES * usac_data->num_subfrm) / 2; + lpd_delay = lpd_sbf_len * LEN_SUBFR; + num_subfr_by2 = lpd_sbf_len - 1; + synth_delay = num_subfr_by2 * LEN_SUBFR; + fac_length = (usac_data->len_subfrm) / 2; + + ixheaacd_memset(synth_buf, MAX_PITCH + synth_delay + len_fr); + synth = synth_buf + MAX_PITCH + synth_delay; + ixheaacd_mem_cpy(st->synth_prev, synth_buf, MAX_PITCH + synth_delay); + ixheaacd_mem_cpy(out_buffer, synth_buf + MAX_PITCH - (LEN_SUBFR), + synth_delay + len_fr + (LEN_SUBFR)); + + for (i = 0; i < num_subfr_by2; i++) { + pitch[i] = st->pitch_prev[i]; + pitch_gain[i] = st->gain_prev[i]; + } + for (i = num_subfr_by2; i < lpd_sbf_len + 3; i++) { + pitch[i] = 64; + pitch_gain[i] = 0.0f; + } + if (st->mode_prev == 0) { + pitch[num_subfr_by2] = pitch[num_subfr_by2 - 1]; + pitch_gain[num_subfr_by2] = pitch_gain[num_subfr_by2 - 1]; + if (!is_short_flag) { + pitch[num_subfr_by2 + 1] = pitch[num_subfr_by2]; + pitch_gain[num_subfr_by2 + 1] = pitch_gain[num_subfr_by2]; + } + } + + synth = synth_buf + MAX_PITCH; + + for (i = 0; i < num_subfr_by2 + 2; i++) { + tp = pitch[i]; + if (pitch_gain[i] > 0.0f) { + synth_corr = 0.0f, synth_energy = 1e-6f; + for (k = 0; k < LEN_SUBFR; k++) { + synth_corr += + synth[i * LEN_SUBFR + k] * synth[(i * LEN_SUBFR) - tp + k]; + synth_energy += + synth[(i * LEN_SUBFR) - tp + k] * synth[(i * LEN_SUBFR) - tp + k]; + } + pitch_gain[i] = synth_corr / synth_energy; + } + } + + 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, + st->bpf_prev); + + ixheaacd_mem_cpy(signal_out, out_buffer, + (lpd_sbf_len + 2) * LEN_SUBFR + LEN_SUBFR); + return; +} diff --git a/decoder/ixheaacd_lpc_dec.c b/decoder/ixheaacd_lpc_dec.c new file mode 100644 index 0000000..f7c8892 --- /dev/null +++ b/decoder/ixheaacd_lpc_dec.c @@ -0,0 +1,244 @@ +/****************************************************************************** + * * + * 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 +*/ +#define DEBUG + +#include +#include +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_main.h" +#include "ixheaacd_arith_dec.h" +#include "ixheaacd_func_def.h" +#include "ixheaacd_acelp_com.h" + +#include +#include "ixheaacd_constants.h" +#include +#include + +#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}; + +VOID ixheaacd_lsf_weight_2st_flt(FLOAT32 *lsfq, FLOAT32 *w, WORD32 mode) { + WORD32 i; + FLOAT32 d[ORDER + 1]; + + d[0] = lsfq[0]; + d[ORDER] = FREQ_MAX - lsfq[ORDER - 1]; + for (i = 1; i < ORDER; i++) { + d[i] = lsfq[i] - lsfq[i - 1]; + } + + for (i = 0; i < ORDER; i++) { + w[i] = (FLOAT32)(factor_table[mode] / (FREQ_DIV / sqrt(d[i] * d[i + 1]))); + } + + return; +} + +static WORD32 ixheaacd_decoding_avq_tool(WORD32 *read_arr, WORD32 *nvecq) { + WORD32 i, k, n, qn, nk, kv[8] = {0}; + WORD32 code_book_idx; + WORD32 *ptr_kv = &kv[0]; + + WORD32 position = 2; + + for (k = 0; k < 2; k++) { + qn = read_arr[k]; + + nk = 0; + n = qn; + if (qn > 4) { + nk = (qn - 3) >> 1; + n = qn - nk * 2; + } + + if (qn > 0) { + code_book_idx = read_arr[position++]; + + ptr_kv = &read_arr[position]; + position += 8; + + } else { + code_book_idx = 0; + for (i = 0; i < 8; i++) ptr_kv = &kv[0]; + } + + ixheaacd_rotated_gosset_mtx_dec(qn, code_book_idx, ptr_kv, &nvecq[k * 8]); + } + + return position; +} + +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[]; + WORD32 position = 0; + WORD32 avq[ORDER]; + FLOAT32 d[ORDER + 1], lsf_min; + FLOAT32 *ptr_w; + + ptr_w = &ixheaacd_weight_table_avq[(indx[0] * ORDER)]; + + position++; + + for (i = 0; i < ORDER; i++) { + lsf[i] = ixheaacd_dico_lsf_abs_8b_flt[indx[0] * ORDER + i]; + } + + position += ixheaacd_decoding_avq_tool(&indx[position], avq); + + d[0] = lsf[0]; + d[ORDER] = FREQ_MAX - lsf[ORDER - 1]; + for (i = 1; i < ORDER; i++) { + d[i] = lsf[i] - lsf[i - 1]; + } + + lsf_min = LSF_GAP; + for (i = 0; i < ORDER; i++) { + lsf[i] += (ptr_w[i] * avq[i]); + + if (lsf[i] < lsf_min) lsf[i] = lsf_min; + + lsf_min = lsf[i] + LSF_GAP; + } + + return position; +} + +WORD32 ixheaacd_avq_first_approx_rel(FLOAT32 *lsf, WORD32 *indx, WORD32 mode) { + WORD32 i; + FLOAT32 w[ORDER]; + WORD32 avq[ORDER]; + WORD32 position = 0; + FLOAT32 lsf_min; + + ixheaacd_lsf_weight_2st_flt(lsf, w, mode); + + position = ixheaacd_decoding_avq_tool(indx, avq); + + lsf_min = LSF_GAP; + + for (i = 0; i < ORDER; i++) { + lsf[i] += (w[i] * avq[i]); + + if (lsf[i] < lsf_min) lsf[i] = lsf_min; + + lsf_min = lsf[i] + LSF_GAP; + } + + return position; +} + +VOID ixheaacd_alg_vec_dequant(ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 first_lpd_flag, FLOAT32 *lsf, + WORD32 mod[]) { + WORD32 i; + WORD32 *lpc_index, mode_lpc, pos = 0; + + lpc_index = pstr_td_frame_data->lpc_first_approx_idx; + + pos = ixheaacd_avq_first_approx_abs(&lsf[4 * ORDER], &lpc_index[0]); + + lpc_index += pos; + + if (first_lpd_flag) { + mode_lpc = lpc_index[0]; + lpc_index++; + + if (mode_lpc == 0) { + pos = ixheaacd_avq_first_approx_abs(&lsf[0], &lpc_index[0]); + + } else if (mode_lpc == 1) { + for (i = 0; i < ORDER; i++) lsf[i] = lsf[4 * ORDER + i]; + pos = ixheaacd_avq_first_approx_rel(&lsf[0], &lpc_index[0], 3); + } + + lpc_index += pos; + } + + if (mod[0] < 3) { + mode_lpc = lpc_index[0]; + lpc_index++; + + if (mode_lpc == 0) { + pos = ixheaacd_avq_first_approx_abs(&lsf[2 * ORDER], &lpc_index[0]); + } else if (mode_lpc == 1) { + for (i = 0; i < ORDER; i++) lsf[2 * ORDER + i] = lsf[4 * ORDER + i]; + pos = ixheaacd_avq_first_approx_rel(&lsf[2 * ORDER], &lpc_index[0], 3); + } + + lpc_index += pos; + } + + if (mod[0] < 2) { + mode_lpc = lpc_index[0]; + lpc_index++; + + if (mode_lpc == 1) { + for (i = 0; i < ORDER; i++) + lsf[ORDER + i] = 0.5f * (lsf[i] + lsf[2 * ORDER + i]); + } else { + if (mode_lpc == 0) { + pos = ixheaacd_avq_first_approx_abs(&lsf[ORDER], &lpc_index[0]); + } else if (mode_lpc == 2) { + for (i = 0; i < ORDER; i++) lsf[ORDER + i] = lsf[2 * ORDER + i]; + pos = ixheaacd_avq_first_approx_rel(&lsf[ORDER], &lpc_index[0], 2); + } + + lpc_index += pos; + } + } + + if (mod[2] < 2) { + mode_lpc = lpc_index[0]; + lpc_index++; + + if (mode_lpc == 0) { + pos = ixheaacd_avq_first_approx_abs(&lsf[3 * ORDER], &lpc_index[0]); + } else if (mode_lpc == 1) { + for (i = 0; i < ORDER; i++) + lsf[3 * ORDER + i] = 0.5f * (lsf[2 * ORDER + i] + lsf[4 * ORDER + i]); + pos = ixheaacd_avq_first_approx_rel(&lsf[3 * ORDER], &lpc_index[0], 1); + } else if (mode_lpc == 2) { + for (i = 0; i < ORDER; i++) lsf[3 * ORDER + i] = lsf[2 * ORDER + i]; + pos = ixheaacd_avq_first_approx_rel(&lsf[3 * ORDER], &lpc_index[0], 2); + } else if (mode_lpc == 3) { + for (i = 0; i < ORDER; i++) lsf[3 * ORDER + i] = lsf[4 * ORDER + i]; + pos = ixheaacd_avq_first_approx_rel(&lsf[3 * ORDER], &lpc_index[0], 2); + } + + lpc_index += pos; + } +} diff --git a/decoder/ixheaacd_lpfuncs.c b/decoder/ixheaacd_lpfuncs.c new file mode 100644 index 0000000..5f30eb9 --- /dev/null +++ b/decoder/ixheaacd_lpfuncs.c @@ -0,0 +1,829 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_bitbuffer.h" + +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_defines.h" + +#include + +#include "ixheaacd_definitions.h" + +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_sbr_payload.h" +#include "ixheaacd_common_rom.h" + +#include + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_adts.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_memory_standards.h" + +#include "ixheaacd_latmdemux.h" + +#include "ixheaacd_aacdec.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" + +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_tns.h" +#include "ixheaacd_aac_imdct.h" + +#include "ixheaacd_multichannel.h" +#include "ixheaacd_function_selector.h" + +static PLATFORM_INLINE WORD32 ixheaacd_shr32_drc(WORD32 a, WORD32 b) { + WORD32 out_val; + + b = ((UWORD32)(b << 24) >> 24); + if (b >= 31) { + if (a < 0) + out_val = -1; + else + out_val = 0; + } else { + a += (1 << (b - 1)); + out_val = (WORD32)a >> b; + } + + return out_val; +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_drc(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + if (temp_result < (WORD64)MIN_32) + result = MIN_32; + + else if (temp_result > (WORD64)MAX_32) + result = MAX_32; + + else + result = (WORD32)(temp_result); + + return (result); +} + +VOID ixheaacd_process_win_seq(WORD32 *coef, WORD32 *prev, WORD16 *out, + const WORD16 *window_long, + const WORD16 *window_short, WORD16 q_shift, + WORD16 ch_fac, WORD16 flag) { + WORD32 i, accu; + WORD32 *coef_1; + const WORD16 *temp_win_sh, *temp_win_long; + WORD16 *out1, *out2; + WORD32 *temp_prev; + + if (flag == 1) { + for (i = 0; i < SIZE07; i++) { + WORD32 temp1 = ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(coef[SIZE08 + i], window_long[2 * i]), + (q_shift + 1)); + + accu = temp1 + ((WORD32)prev[i] << 16); + out[ch_fac * i] = ixheaacd_round16(accu << 1); + + accu = ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(-(coef[SIZE15 - 1 - i]), + window_long[2 * (SIZE07 - i) - 1]), + q_shift); + out[ch_fac * (i + SIZE09)] = ixheaacd_round16(accu << 2); + } + + temp_win_sh = &(window_short[0]); + coef_1 = &(coef[SIZE15]); + temp_win_long = &(window_long[SIZE14]); + temp_prev = &(prev[SIZE08 - 1]); + out1 = &(out[ch_fac * (SIZE07)]); + out2 = &(out[ch_fac * (SIZE09 - 1)]); + + } else { + for (i = 0; i < SIZE07; i++) { + accu = ixheaacd_mult32x16in32_drc( + prev[SIZE08 - 1 - i], ixheaacd_negate16(window_long[2 * i + 1])); + + out[ch_fac * i] = ixheaacd_round16(accu << 2); + + accu = (ixheaacd_shl32_dir_sat_limit(-(coef[SIZE15 - 1 - i]), + (q_shift - 1)) - + ixheaacd_mult32x16in32_drc(prev[i + SIZE01], + window_long[2 * SIZE07 - 2 - 2 * i])); + + out[ch_fac * (SIZE09 + i)] = ixheaacd_round16(accu << 2); + } + + temp_win_sh = &(window_long[SIZE14]); + coef_1 = &(coef[SIZE15]); + temp_win_long = &(window_short[0]); + temp_prev = &(prev[SIZE01 - 1]); + out1 = &(out[ch_fac * (SIZE07)]); + out2 = &(out[ch_fac * (SIZE09 - 1)]); + } + + for (i = SIZE01 - 1; i >= 0; i--) { + WORD32 temp_coef = *coef_1++; + WORD16 win1 = *temp_win_long++; + WORD16 win2 = *temp_win_long++; + WORD32 prev1 = *temp_prev--; + WORD16 win4 = *temp_win_sh++; + WORD16 win3 = *temp_win_sh++; + accu = ixheaacd_shl32_dir_sat_limit(ixheaacd_mult32x16in32(temp_coef, win1), + q_shift) - + ixheaacd_mult32x16in32_drc(prev1, win3); + *out1 = ixheaacd_round16(accu << 2); + out1 += ch_fac; + + accu = (ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(ixheaacd_negate32_sat(temp_coef), win2), + q_shift) - + ixheaacd_mult32x16in32_drc(prev1, win4)); + *out2 = ixheaacd_round16(accu << 2); + out2 -= ch_fac; + } +} + +static PLATFORM_INLINE VOID ixheaacd_long_short_win_process( + WORD32 *current, WORD32 *prev, WORD16 *out, const WORD16 *short_window, + const WORD16 *long_window_prev, WORD16 q_shift, WORD16 ch_fac, + WORD32 flag) { + WORD i; + WORD32 accu; + WORD32 *current_tmp1 = &(current[(SIZE03 - 1)]); + WORD32 *current_tmp2 = &(current[-SIZE01]); + const WORD16 *short_ptr = &(short_window[SIZE02 - 1]); + + for (i = SIZE01 - 1; i >= 0; i--) { + WORD32 tmp1_cur = *current_tmp1--; + WORD32 tmp2_cur = *current_tmp2++; + WORD16 short1 = *short_ptr--; + WORD16 short2 = *short_ptr--; + accu = + (ixheaacd_shl32_dir_sat_limit( + (ixheaacd_mult32x16in32(tmp1_cur, short2) - + ixheaacd_mult32x16in32(tmp2_cur, short1)), + q_shift) - + ixheaacd_mult32x16in32_drc(prev[i], long_window_prev[0 - 2 - 2 * i])); + out[ch_fac * (0 + i)] = ixheaacd_round16(accu << 2); + + if (flag) { + accu = (ixheaacd_shl32_dir_sat_limit( + (ixheaacd_mult32x16in32(-(tmp1_cur), short1) - + ixheaacd_mult32x16in32(tmp2_cur, short2)), + q_shift) - + ixheaacd_mult32x16in32_drc( + prev[SIZE02 - 1 - i], long_window_prev[-2 * SIZE02 + 2 * i])); + out[ch_fac * (SIZE02 - 1 - i)] = ixheaacd_round16(accu << 2); + } + } +} + +VOID ixheaacd_long_short_win_seq(WORD32 *current, WORD32 *prev, WORD16 *out, + const WORD16 *short_window, + const WORD16 *short_window_prev, + const WORD16 *long_window_prev, WORD16 q_shift, + WORD16 ch_fac) { + WORD32 i, flag; + WORD32 accu; + for (i = 0; i < SIZE07; i++) { + accu = ixheaacd_mult32x16in32_drc( + prev[SIZE08 - 1 - i], ixheaacd_negate16(long_window_prev[2 * i + 1])); + out[ch_fac * i] = ixheaacd_round16(accu << 2); + } + + for (i = 0; i < SIZE01; i++) { + accu = + (ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(current[SIZE01 + i], + short_window_prev[2 * i]), + q_shift) - + ixheaacd_mult32x16in32_drc(prev[SIZE01 - 1 - i], + long_window_prev[2 * SIZE07 + 1 + 2 * i])); + out[ch_fac * (SIZE07 + i)] = ixheaacd_round16(accu << 2); + } + + for (i = 0; i < SIZE01; i++) { + accu = (ixheaacd_shl32_dir_sat_limit( + ixheaacd_mult32x16in32(-(current[SIZE02 - 1 - i]), + short_window_prev[SIZE02 - 2 * i - 1]), + q_shift) - + ixheaacd_mult32x16in32_drc(prev[i], + long_window_prev[SIZE16 - 2 - (2 * i)])); + out[ch_fac * (SIZE08 + i)] = ixheaacd_round16(accu << 2); + } + + flag = 1; + for (i = 0; i < 4; i++) { + WORD32 inc = i * SIZE02; + + if (i == 3) { + flag = 0; + } + + ixheaacd_long_short_win_process(¤t[SIZE01 + inc], &prev[SIZE01 + inc], + &out[ch_fac * (SIZE09 + inc)], short_window, + &long_window_prev[2 * (SIZE07 - inc)], + q_shift, ch_fac, flag); + } + + for (i = 0; i < SIZE01; i++) { + accu = (ixheaacd_mult32x16in32(-(current[SIZE10 - 1 - i]), + short_window[SIZE02 - 2 * i - 1]) - + ixheaacd_mult32x16in32(current[SIZE06 + i], + short_window[SIZE02 - 2 * i - 2])); + prev[i] = + ixheaacd_round16(ixheaacd_shl32_dir_sat_limit(accu, (q_shift + 1))); + } +} + +VOID ixheaacd_nolap1_32(WORD32 *coef, + + WORD32 *out, + + WORD16 q_shift, WORD16 ch_fac) { + WORD32 i; + + for (i = 0; i < SIZE07; i++) { + out[ch_fac * i] = ixheaacd_shr32_drc( + ixheaacd_negate32_sat(coef[SIZE07 - 1 - i]), 16 - q_shift); + } +} + +VOID ixheaacd_neg_shift_spec_dec(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) { + WORD32 i; + + for (i = 0; i < SIZE07; i++) { + out[ch_fac * i] = ixheaacd_round16(ixheaacd_shl32_dir_sat_limit( + ixheaacd_negate32_sat(coef[SIZE07 - 1 - i]), q_shift)); + } +} + +VOID ixheaacd_spec_to_overlapbuf_dec(WORD32 *ptr_overlap_buf, + WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) { + WORD32 i; + for (i = 0; i < size; i++) { + ptr_overlap_buf[i] = ixheaacd_shr32_drc(ptr_spec_coeff[i], 16 - q_shift); + } +} + +VOID ixheaacd_overlap_buf_out_dec(WORD16 *out_samples, WORD32 *ptr_overlap_buf, + WORD32 size, const WORD16 ch_fac) { + WORD32 i; + + for (i = 0; i < size; i++) { + out_samples[ch_fac * i] = ixheaacd_shl16_sat((WORD16)ptr_overlap_buf[i], 1); + } +} + +VOID ixheaacd_overlap_out_copy_dec(WORD16 *out_samples, WORD32 *ptr_overlap_buf, + WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) { + WORD32 i; + + for (i = 0; i < SIZE01; i++) { + out_samples[ch_fac * i] = ixheaacd_shl16_sat((WORD16)ptr_overlap_buf[i], 1); + ptr_overlap_buf[i] = ptr_overlap_buf1[i]; + } +} + +VOID ixheaacd_imdct_process(ia_aac_dec_overlap_info *ptr_aac_dec_overlap_info, + WORD32 *ptr_spec_coeff, + ia_ics_info_struct *ptr_ics_info, + WORD16 out_samples[], const WORD16 ch_fac, + WORD32 *scratch, + ia_aac_dec_tables_struct *ptr_aac_tables, + WORD32 object_type) { + WORD32 *ptr_overlap_buf; + const WORD16 *ptr_long_window; + const WORD16 *ptr_short_window; + + ptr_overlap_buf = ptr_aac_dec_overlap_info->ptr_overlap_buf; + ptr_long_window = + ptr_aac_dec_overlap_info + ->ptr_long_window[(WORD32)ptr_aac_dec_overlap_info->window_shape]; + ptr_short_window = + ptr_aac_dec_overlap_info + ->ptr_short_window[(WORD32)ptr_aac_dec_overlap_info->window_shape]; + + if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { + WORD16 q_shift; + WORD32 expo, imdct_scale; + + if ((512 == ptr_ics_info->frame_length) || + (480 == ptr_ics_info->frame_length)) { + if (512 == ptr_ics_info->frame_length) { + WORD32 *ld_cos_sin_ptr = + (WORD32 *)ptr_aac_tables->pstr_imdct_tables->cosine_array_1024; + + ixheaacd_inverse_transform_512( + ptr_spec_coeff, scratch, &imdct_scale, ld_cos_sin_ptr, + ptr_aac_tables->pstr_imdct_tables, object_type); + + } else { + ixheaacd_mdct_480_ld(ptr_spec_coeff, scratch, &imdct_scale, 0, + ptr_aac_tables->pstr_imdct_tables, object_type); + } + + if (object_type == AOT_ER_AAC_ELD) { + int i, N = (ptr_ics_info->frame_length << 1); + + for (i = 0; i < N / 2; i++) { + ptr_spec_coeff[i] = -ptr_spec_coeff[i + N]; + ptr_spec_coeff[i + N + N / 2] = -ptr_spec_coeff[i + N / 2]; + } + } + } else + + { + expo = (*ixheaacd_calc_max_spectral_line)(ptr_spec_coeff, 1024) - 1; + + expo = 8 - expo; + + imdct_scale = ixheaacd_inverse_transform( + ptr_spec_coeff, scratch, ptr_aac_tables->pstr_imdct_tables, expo, + 1024); + } + + q_shift = (31 + imdct_scale) + (-1 - 16 - 9); + + switch (ptr_ics_info->window_sequence) { + case ONLY_LONG_SEQUENCE: + + switch (ptr_aac_dec_overlap_info->window_sequence) { + case ONLY_LONG_SEQUENCE: + case LONG_STOP_SEQUENCE: + + if (1024 == ptr_ics_info->frame_length) { + (*ixheaacd_post_twid_overlap_add)( + out_samples, ptr_spec_coeff, + ptr_aac_tables->pstr_imdct_tables, 1024, ptr_overlap_buf, + q_shift, ptr_long_window, ch_fac); + } + if ((512 == ptr_ics_info->frame_length) || + (480 == ptr_ics_info->frame_length)) { + if (object_type != AOT_ER_AAC_ELD) { + if (512 == ptr_ics_info->frame_length) { + ixheaacd_lap1_512_480(ptr_spec_coeff, ptr_overlap_buf, + out_samples, ptr_long_window, q_shift, + SIZE04, ch_fac); + ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff, + q_shift, SIZE04); + } else if (480 == ptr_ics_info->frame_length) { + ixheaacd_lap1_512_480(ptr_spec_coeff, ptr_overlap_buf, + out_samples, ptr_long_window, q_shift, + 240, ch_fac); + ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff, + q_shift, 240); + } + } else { + ixheaacd_eld_dec_windowing( + ptr_spec_coeff, ptr_long_window, ptr_ics_info->frame_length, + q_shift, ptr_overlap_buf, ch_fac, out_samples); + } + } + break; + + case LONG_START_SEQUENCE: + case EIGHT_SHORT_SEQUENCE: + if (1024 == ptr_ics_info->frame_length) { + (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff, + ptr_aac_tables->pstr_imdct_tables, 1024); + } + + ixheaacd_process_win_seq(scratch, ptr_overlap_buf, out_samples, + ptr_long_window, ptr_short_window, q_shift, + ch_fac, 1); + + if (512 == ptr_ics_info->frame_length) { + ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff, + q_shift, SIZE04); + } else if (480 == ptr_ics_info->frame_length) { + ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff, + q_shift, 240); + } else { + (*ixheaacd_spec_to_overlapbuf)(ptr_overlap_buf, scratch, q_shift, + SIZE08); + } + break; + } + + break; + + case LONG_START_SEQUENCE: + if (1024 == ptr_ics_info->frame_length) { + (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff, + ptr_aac_tables->pstr_imdct_tables, 1024); + } + switch (ptr_aac_dec_overlap_info->window_sequence) { + case ONLY_LONG_SEQUENCE: + case LONG_STOP_SEQUENCE: + + (*ixheaacd_over_lap_add1)(scratch, ptr_overlap_buf, out_samples, + ptr_long_window, q_shift, SIZE08, ch_fac); + + break; + + case LONG_START_SEQUENCE: + case EIGHT_SHORT_SEQUENCE: + + ixheaacd_process_win_seq(scratch, ptr_overlap_buf, out_samples, + ptr_long_window, ptr_short_window, q_shift, + ch_fac, 1); + + break; + } + + ixheaacd_nolap1_32(&scratch[SIZE01], ptr_overlap_buf, q_shift, 1); + + (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[SIZE07], scratch, + q_shift, SIZE01); + + break; + + case LONG_STOP_SEQUENCE: + if (1024 == ptr_ics_info->frame_length) { + (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff, + ptr_aac_tables->pstr_imdct_tables, 1024); + } + + switch (ptr_aac_dec_overlap_info->window_sequence) { + case EIGHT_SHORT_SEQUENCE: + case LONG_START_SEQUENCE: + + (*ixheaacd_overlap_buf_out)(out_samples, ptr_overlap_buf, SIZE07, + ch_fac); + + (*ixheaacd_over_lap_add1)( + &scratch[SIZE14], &ptr_overlap_buf[SIZE07], + &out_samples[ch_fac * (SIZE07)], ptr_short_window, q_shift, + SIZE01, ch_fac); + + { + WORD16 q_shift1 = q_shift + 1; + (*ixheaacd_neg_shift_spec)(&scratch[SIZE08], + &out_samples[ch_fac * SIZE09], + q_shift1, ch_fac); + } + + break; + case ONLY_LONG_SEQUENCE: + case LONG_STOP_SEQUENCE: + + ixheaacd_process_win_seq(scratch, ptr_overlap_buf, out_samples, + ptr_long_window, ptr_short_window, q_shift, + ch_fac, 0); + break; + } + + (*ixheaacd_spec_to_overlapbuf)(ptr_overlap_buf, scratch, q_shift, + SIZE08); + + break; + } + + } else { + WORD16 q_shift, max_scale; + WORD32 imdct_scale[8], i; + const WORD16 *short_window; + + short_window = ptr_aac_dec_overlap_info + ->ptr_short_window[(WORD32)ptr_ics_info->window_shape]; + + { + WORD32 expo; + + expo = (*ixheaacd_calc_max_spectral_line)(ptr_spec_coeff, 1024) - 1; + + expo = 5 - expo; + + for (i = 0; i < MAX_WINDOWS; i++) { + imdct_scale[i] = ixheaacd_inverse_transform( + &ptr_spec_coeff[i * SIZE02], &scratch[i * SIZE02], + ptr_aac_tables->pstr_imdct_tables, expo, 128); + + (*ixheaacd_post_twiddle)(&scratch[i * SIZE02], + &ptr_spec_coeff[i * SIZE02], + ptr_aac_tables->pstr_imdct_tables, 128); + } + } + + max_scale = 31 + imdct_scale[0]; + + q_shift = max_scale + (-16 - 6 - 1); + + switch (ptr_aac_dec_overlap_info->window_sequence) { + WORD32 overlap_buf_loc[SIZE01]; + + case EIGHT_SHORT_SEQUENCE: + case LONG_START_SEQUENCE: + + (*ixheaacd_overlap_buf_out)(out_samples, ptr_overlap_buf, SIZE07, + ch_fac); + + (*ixheaacd_over_lap_add1)(&scratch[0], &ptr_overlap_buf[SIZE07], + &out_samples[ch_fac * SIZE07], + ptr_short_window, q_shift, SIZE01, ch_fac); + + for (i = 0; i < 3; i++) { + WORD32 inc = (i * SIZE02); + (*ixheaacd_spec_to_overlapbuf)(overlap_buf_loc, &scratch[inc], + q_shift, SIZE01); + + (*ixheaacd_over_lap_add1)(&scratch[SIZE02 + inc], overlap_buf_loc, + &out_samples[ch_fac * (SIZE09 + inc)], + short_window, q_shift, SIZE01, ch_fac); + } + + (*ixheaacd_over_lap_add2)(&scratch[SIZE08], &scratch[SIZE06], + ptr_overlap_buf, short_window, q_shift, + SIZE01, 1); + + (*ixheaacd_overlap_out_copy)(&out_samples[ch_fac * SIZE15], + ptr_overlap_buf, &ptr_overlap_buf[SIZE01], + ch_fac); + + break; + + case ONLY_LONG_SEQUENCE: + case LONG_STOP_SEQUENCE: + + ixheaacd_long_short_win_seq(scratch, ptr_overlap_buf, out_samples, + short_window, ptr_short_window, + ptr_long_window, q_shift, ch_fac); + + break; + } + + for (i = 0; i < 3; i++) { + WORD32 inc = (i * SIZE02); + (*ixheaacd_over_lap_add2)(&scratch[SIZE10 + inc], &scratch[SIZE08 + inc], + &ptr_overlap_buf[SIZE01 + inc], short_window, + q_shift, SIZE01, 1); + } + + (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[SIZE07], &scratch[SIZE14], + q_shift, SIZE01); + } + + ptr_aac_dec_overlap_info->window_shape = ptr_ics_info->window_shape; + ptr_aac_dec_overlap_info->window_sequence = ptr_ics_info->window_sequence; +} +void ixheaacd_eld_dec_windowing(WORD32 *ptr_spect_coeff, const WORD16 *p_win, + WORD32 framesize, WORD16 q_shift, + WORD32 *p_overlap_buffer, const WORD16 stride, + WORD16 *out_samples) + +{ + int i = 0; + int loop_size; + WORD32 *ptr_z = ptr_spect_coeff; + + WORD32 *ptr_out, *p_out2; + WORD32 *p_overlap_buffer32 = (WORD32 *)p_overlap_buffer; + WORD32 delay = framesize >> 2; + + ptr_z = ptr_spect_coeff + delay; + p_win += delay; + ptr_out = p_overlap_buffer32; + + q_shift = q_shift + 2; + + if (q_shift >= 0) { + for (i = (delay)-1; i >= 0; i--) { + WORD32 win_op; + WORD32 win_ovadd_op; + WORD16 win_val; + + win_val = *p_win++; + + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32_sat(win_ovadd_op, 1)); + out_samples += stride; + + win_val = *p_win++; + + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32_sat(win_ovadd_op, 1)); + out_samples += stride; + win_val = *p_win++; + + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32_sat(win_ovadd_op, 1)); + out_samples += stride; + + win_val = *p_win++; + + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32_sat(win_ovadd_op, 1)); + out_samples += stride; + } + + p_out2 = p_overlap_buffer32; + loop_size = (((framesize * 3) - framesize) >> 2) - 1; + + for (i = loop_size; i >= 0; i--) { + WORD32 win_op; + WORD16 win_val; + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shl32(win_op, q_shift), *ptr_out++); + } + + loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1; + for (i = loop_size; i >= 0; i--) { + WORD32 win_op; + WORD16 win_val; + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shl32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shl32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shl32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shl32(win_op, q_shift); + } + } else { + q_shift = -q_shift; + + for (i = (delay)-1; i >= 0; i--) { + WORD32 win_op; + WORD32 win_ovadd_op; + WORD16 win_val; + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32(win_ovadd_op, 1)); + out_samples += stride; + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32(win_ovadd_op, 1)); + out_samples += stride; + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32(win_ovadd_op, 1)); + out_samples += stride; + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + + win_ovadd_op = + ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + *out_samples = ixheaacd_round16(ixheaacd_shl32(win_ovadd_op, 1)); + out_samples += stride; + } + + p_out2 = p_overlap_buffer32; + loop_size = (((framesize * 3) - framesize) >> 2) - 1; + + for (i = loop_size; i >= 0; i--) { + WORD32 win_op; + WORD16 win_val; + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_add32(ixheaacd_shr32(win_op, q_shift), *ptr_out++); + } + loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1; + for (i = loop_size; i >= 0; i--) { + WORD32 win_op; + WORD16 win_val; + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shr32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shr32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shr32(win_op, q_shift); + + win_val = *p_win++; + win_op = ixheaacd_mult32x16in32(*ptr_z++, (win_val)); + *p_out2++ = ixheaacd_shr32(win_op, q_shift); + } + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_lpp_tran.c b/decoder/ixheaacd_lpp_tran.c new file mode 100644 index 0000000..e1631c2 --- /dev/null +++ b/decoder/ixheaacd_lpp_tran.c @@ -0,0 +1,1131 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_basic_funcs.h" + +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_function_selector.h" + +#include "ixheaacd_audioobjtypes.h" + +#define LPC_SCALE_FACTOR 2 + +#define SHIFT 5 + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16hin32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)(a) * (WORD64)(b >> 16); + result = (WORD32)(temp_result >> 16); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_mac32x16hin32(WORD32 a, WORD32 b, + WORD32 c) { + WORD32 result; + + result = a + ixheaacd_mult32x16hin32(b, c); + + return (result); +} + +static PLATFORM_INLINE WORD32 ixheaacd_macn32x16hin32(WORD32 a, WORD32 b, + WORD32 c) { + WORD32 result; + + result = a - ixheaacd_mult32x16hin32(b, c); + + return (result); +} + +VOID ixheaacd_filterstep3(WORD16 a0r, WORD16 a0i, WORD16 a1r, WORD16 a1i, + WORD32 start_indx, WORD32 stop_idx, WORD32 low_band, + WORD32 high_band, WORD32 *qmf_buffer) { + WORD32 i; + WORD32 prev1r, prev1i; + WORD32 prev2r, prev2i; + WORD16 coef1r = (a0r); + WORD16 coef1i = (a0i); + WORD16 coef2r = (a1r); + WORD16 coef2i = (a1i); + WORD32 *p_src, *p_dst; + WORD32 qmf_real, qmf_imag; + + WORD32 curr, curi; + p_src = qmf_buffer + low_band + ((start_indx) << 7); + prev2r = *p_src; + p_src += 64; + + prev2i = *p_src; + p_src += 64; + + prev1r = *p_src; + p_src += 64; + + prev1i = *p_src; + p_src += 64; + + p_dst = qmf_buffer + high_band + ((start_indx + 2) << 7); + + for (i = stop_idx - start_indx; i != 0; i--) { + WORD32 accu; + + curr = *p_src; + p_src += 64; + + curi = *p_src; + p_src += 64; + + qmf_real = (curr >> LPC_SCALE_FACTOR); + qmf_imag = (curi >> LPC_SCALE_FACTOR); + + accu = ixheaacd_sub32( + ixheaacd_add32(ixheaacd_sub32(ixheaacd_mult32x16in32(prev1r, coef1r), + ixheaacd_mult32x16in32(prev1i, coef1i)), + ixheaacd_mult32x16in32(prev2r, coef2r)), + ixheaacd_mult32x16in32(prev2i, coef2i)); + + *p_dst = ixheaacd_add32(qmf_real, (accu << 1)); + p_dst += 64; + + accu = ixheaacd_add32( + ixheaacd_add32_sat( + ixheaacd_add32_sat(ixheaacd_mult32x16in32(prev1r, coef1i), + ixheaacd_mult32x16in32(prev1i, coef1r)), + ixheaacd_mult32x16in32(prev2r, coef2i)), + ixheaacd_mult32x16in32(prev2i, coef2r)); + + *p_dst = ixheaacd_add32(qmf_imag, (accu << 1)); + p_dst += 64; + + prev2r = prev1r; + prev1r = curr; + prev2i = prev1i; + prev1i = curi; + } +} + +VOID ixheaacd_covariance_matrix_calc_dec( + WORD32 *sub_sign_xlow, ixheaacd_lpp_trans_cov_matrix *cov_matrix, + WORD32 count) { + WORD32 j, k; + WORD32 ixheaacd_drc_offset = 2; + WORD32 len = 38; + WORD32 factor; + WORD32 max_val, q_factor; + WORD32 temp1, temp2, temp3, temp4; + WORD32 *temp_buf_ptr = sub_sign_xlow; + + for (k = count; k > 0; k--) { + WORD32 t_phi_01 = 0, t_phi_02 = 0, t_phi_11 = 0; + WORD32 t_phi_12 = 0, t_phi_22 = 0; + + factor = -3; + j = ixheaacd_drc_offset; + sub_sign_xlow = temp_buf_ptr; + + temp1 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + temp2 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + for (; (j = j + 3) < ixheaacd_drc_offset + len;) { + temp3 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + t_phi_01 += ixheaacd_mult32x16hin32(temp3, temp2); + t_phi_02 += ixheaacd_mult32x16hin32(temp3, temp1); + t_phi_11 += ixheaacd_mult32x16hin32(temp2, temp2); + + temp1 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + t_phi_01 += ixheaacd_mult32x16hin32(temp1, temp3); + t_phi_02 += ixheaacd_mult32x16hin32(temp1, temp2); + t_phi_11 += ixheaacd_mult32x16hin32(temp3, temp3); + + temp2 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + t_phi_01 += ixheaacd_mult32x16hin32(temp2, temp1); + t_phi_02 += ixheaacd_mult32x16hin32(temp2, temp3); + t_phi_11 += ixheaacd_mult32x16hin32(temp1, temp1); + } + + temp3 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + t_phi_01 += ixheaacd_mult32x16hin32(temp3, temp2); + t_phi_02 += ixheaacd_mult32x16hin32(temp3, temp1); + t_phi_11 += ixheaacd_mult32x16hin32(temp2, temp2); + + temp1 = ixheaacd_shl32_dir(*sub_sign_xlow, factor); + sub_sign_xlow += 64; + + t_phi_01 += ixheaacd_mult32x16hin32(temp1, temp3); + t_phi_02 += ixheaacd_mult32x16hin32(temp1, temp2); + t_phi_11 += ixheaacd_mult32x16hin32(temp3, temp3); + + temp2 = ixheaacd_shl32_dir(*temp_buf_ptr, factor); + temp4 = ixheaacd_shl32_dir(*(temp_buf_ptr + 64), factor); + + t_phi_12 = (t_phi_01 - ixheaacd_mult32x16hin32(temp1, temp3) + + ixheaacd_mult32x16hin32(temp4, temp2)); + + t_phi_22 = (t_phi_11 - ixheaacd_mult32x16hin32(temp3, temp3) + + ixheaacd_mult32x16hin32(temp2, temp2)); + + max_val = ixheaacd_abs32_nrm(t_phi_01); + max_val = max_val | ixheaacd_abs32_nrm(t_phi_02); + max_val = max_val | ixheaacd_abs32_nrm(t_phi_12); + max_val = max_val | (t_phi_11); + max_val = max_val | (t_phi_22); + + q_factor = ixheaacd_pnorm32(max_val); + + cov_matrix->phi_11 = (t_phi_11 << q_factor); + cov_matrix->phi_22 = (t_phi_22 << q_factor); + cov_matrix->phi_01 = (t_phi_01 << q_factor); + cov_matrix->phi_02 = (t_phi_02 << q_factor); + cov_matrix->phi_12 = (t_phi_12 << q_factor); + + cov_matrix->d = ixheaacd_sub32_sat( + ixheaacd_mult32(cov_matrix->phi_22, cov_matrix->phi_11), + ixheaacd_mult32(cov_matrix->phi_12, cov_matrix->phi_12)); + + cov_matrix++; + temp_buf_ptr++; + } + + return; +} + +VOID ixheaacd_covariance_matrix_calc_2_dec( + ixheaacd_lpp_trans_cov_matrix *cov_matrix, + + WORD32 *real_buffer, WORD32 num_bands, WORD16 slots) { + WORD32 k; + WORD32 *img_buffer; + WORD32 *ptr_real = real_buffer; + ixheaacd_lpp_trans_cov_matrix *pac_arr = cov_matrix; + + for (k = 0; k < num_bands; k++) { + WORD32 t_phi_11 = 0, t_phi_01 = 0, t_phi_01_i = 0; + WORD32 prev_real, prev_imag, curr_real, curr_imag; + + real_buffer = ptr_real; + img_buffer = real_buffer + 64; + cov_matrix = pac_arr; + + prev_real = real_buffer[-128]; + prev_imag = img_buffer[-128]; + + curr_real = real_buffer[0]; + curr_imag = img_buffer[0]; + + curr_real = ixheaacd_shr32(curr_real, 3); + curr_imag = ixheaacd_shr32(curr_imag, 3); + prev_real = ixheaacd_shr32(prev_real, 3); + prev_imag = ixheaacd_shr32(prev_imag, 3); + + t_phi_01 = ixheaacd_mult32x16hin32(curr_real, prev_real); + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, curr_imag, prev_imag); + + t_phi_01_i = ixheaacd_mult32x16hin32(curr_imag, prev_real); + t_phi_01_i = ixheaacd_macn32x16hin32(t_phi_01_i, curr_real, prev_imag); + + t_phi_11 = ixheaacd_mult32x16hin32(prev_real, prev_real); + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, prev_imag, prev_imag); + + { + WORD n; + WORD32 *real1 = &real_buffer[128]; + WORD32 *imag1 = &img_buffer[128]; + + prev_real = curr_real; + prev_imag = curr_imag; + + for (n = ((slots - 2) >> 1); n; n--) { + curr_real = *real1; + real1 += 128; + curr_imag = *imag1; + imag1 += 128; + + curr_real = ixheaacd_shr32(curr_real, 3); + curr_imag = ixheaacd_shr32(curr_imag, 3); + + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, curr_real, prev_real); + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, curr_imag, prev_imag); + + t_phi_01_i = ixheaacd_mac32x16hin32(t_phi_01_i, curr_imag, prev_real); + t_phi_01_i = ixheaacd_macn32x16hin32(t_phi_01_i, curr_real, prev_imag); + + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, prev_real, prev_real); + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, prev_imag, prev_imag); + + prev_real = *real1; + real1 += 128; + prev_imag = *imag1; + imag1 += 128; + + prev_real = ixheaacd_shr32(prev_real, 3); + prev_imag = ixheaacd_shr32(prev_imag, 3); + + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, prev_real, curr_real); + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, prev_imag, curr_imag); + + t_phi_01_i = ixheaacd_mac32x16hin32(t_phi_01_i, prev_imag, curr_real); + t_phi_01_i = ixheaacd_macn32x16hin32(t_phi_01_i, prev_real, curr_imag); + + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, curr_real, curr_real); + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, curr_imag, curr_imag); + } + + if (slots & 0x01) { + curr_real = *real1; + curr_imag = *imag1; + + curr_real = ixheaacd_shr32(curr_real, 3); + curr_imag = ixheaacd_shr32(curr_imag, 3); + + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, curr_real, prev_real); + t_phi_01 = ixheaacd_mac32x16hin32(t_phi_01, curr_imag, prev_imag); + + t_phi_01_i = ixheaacd_mac32x16hin32(t_phi_01_i, curr_imag, prev_real); + t_phi_01_i = ixheaacd_macn32x16hin32(t_phi_01_i, curr_real, prev_imag); + + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, prev_real, prev_real); + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, prev_imag, prev_imag); + } + } + + { + WORD32 t_phi_22 = t_phi_11; + WORD32 curr_real = real_buffer[-2 * 128]; + WORD32 curr_imag = img_buffer[-2 * 128]; + + curr_real = ixheaacd_shr32(curr_real, 3); + curr_imag = ixheaacd_shr32(curr_imag, 3); + + t_phi_22 = ixheaacd_mac32x16hin32(t_phi_22, curr_real, curr_real); + t_phi_22 = ixheaacd_mac32x16hin32(t_phi_22, curr_imag, curr_imag); + + curr_real = real_buffer[(slots - 2) * 128]; + curr_imag = img_buffer[(slots - 2) * 128]; + + curr_real = ixheaacd_shr32(curr_real, 3); + curr_imag = ixheaacd_shr32(curr_imag, 3); + + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, curr_real, curr_real); + t_phi_11 = ixheaacd_mac32x16hin32(t_phi_11, curr_imag, curr_imag); + + cov_matrix->phi_11 = t_phi_11; + cov_matrix->phi_22 = t_phi_22; + } + + { + WORD32 t_phi_12 = t_phi_01; + + t_phi_12 = ixheaacd_mac32x16hin32(t_phi_12, real_buffer[-128] >> 3, + real_buffer[-2 * 128] >> 3); + t_phi_12 = ixheaacd_mac32x16hin32(t_phi_12, img_buffer[-128] >> 3, + img_buffer[-2 * 128] >> 3); + t_phi_01 = + ixheaacd_mac32x16hin32(t_phi_01, real_buffer[(slots - 1) * 128] >> 3, + real_buffer[(slots - 2) * 128] >> 3); + t_phi_01 = + ixheaacd_mac32x16hin32(t_phi_01, img_buffer[(slots - 1) * 128] >> 3, + img_buffer[(slots - 2) * 128] >> 3); + + cov_matrix->phi_01 = t_phi_01; + cov_matrix->phi_12 = t_phi_12; + } + + { + WORD32 t_phi_12_i = t_phi_01_i; + + t_phi_12_i = ixheaacd_mac32x16hin32(t_phi_12_i, img_buffer[-128] >> 3, + real_buffer[-2 * 128] >> 3); + t_phi_12_i = ixheaacd_macn32x16hin32(t_phi_12_i, real_buffer[-128] >> 3, + img_buffer[-2 * 128] >> 3); + t_phi_01_i = + ixheaacd_mac32x16hin32(t_phi_01_i, img_buffer[(slots - 1) * 128] >> 3, + real_buffer[(slots - 2) * 128] >> 3); + t_phi_01_i = ixheaacd_macn32x16hin32(t_phi_01_i, + real_buffer[(slots - 1) * 128] >> 3, + img_buffer[(slots - 2) * 128] >> 3); + + cov_matrix->phi_01_im = t_phi_01_i; + cov_matrix->phi_12_im = t_phi_12_i; + } + + { + WORD16 n, len_by_4, p; + WORD32 t_phi_02 = 0x00, t_phi_02_i = 0x00; + + len_by_4 = (slots >> 2); + p = 0; + for (n = 0; n < len_by_4; n++) { + WORD32 real1, real2, imag1, imag2; + real1 = real_buffer[p * 128]; + real2 = real_buffer[(p - 2) * 128]; + imag1 = img_buffer[p * 128]; + imag2 = img_buffer[(p - 2) * 128]; + + real1 = ixheaacd_shr32(real1, 3); + real2 = ixheaacd_shr32(real2, 3); + imag1 = ixheaacd_shr32(imag1, 3); + imag2 = ixheaacd_shr32(imag2, 3); + + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, real1, real2); + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, imag1, imag2); + t_phi_02_i = ixheaacd_mac32x16hin32(t_phi_02_i, imag1, real2); + t_phi_02_i = ixheaacd_macn32x16hin32(t_phi_02_i, real1, imag2); + + real1 = real_buffer[(p + 1) * 128]; + real2 = real_buffer[(p - 1) * 128]; + imag1 = img_buffer[(p + 1) * 128]; + imag2 = img_buffer[(p - 1) * 128]; + + real1 = ixheaacd_shr32(real1, 3); + real2 = ixheaacd_shr32(real2, 3); + imag1 = ixheaacd_shr32(imag1, 3); + imag2 = ixheaacd_shr32(imag2, 3); + + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, real1, real2); + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, imag1, imag2); + t_phi_02_i = ixheaacd_mac32x16hin32(t_phi_02_i, imag1, real2); + t_phi_02_i = ixheaacd_macn32x16hin32(t_phi_02_i, real1, imag2); + + real1 = real_buffer[(p + 2) * 128]; + real2 = real_buffer[p * 128]; + imag1 = img_buffer[(p + 2) * 128]; + imag2 = img_buffer[p * 128]; + + real1 = ixheaacd_shr32(real1, 3); + real2 = ixheaacd_shr32(real2, 3); + imag1 = ixheaacd_shr32(imag1, 3); + imag2 = ixheaacd_shr32(imag2, 3); + + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, real1, real2); + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, imag1, imag2); + t_phi_02_i = ixheaacd_mac32x16hin32(t_phi_02_i, imag1, real2); + t_phi_02_i = ixheaacd_macn32x16hin32(t_phi_02_i, real1, imag2); + + real1 = real_buffer[(p + 3) * 128]; + real2 = real_buffer[(p + 1) * 128]; + imag1 = img_buffer[(p + 3) * 128]; + imag2 = img_buffer[(p + 1) * 128]; + + real1 = ixheaacd_shr32(real1, 3); + real2 = ixheaacd_shr32(real2, 3); + imag1 = ixheaacd_shr32(imag1, 3); + imag2 = ixheaacd_shr32(imag2, 3); + + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, real1, real2); + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, imag1, imag2); + t_phi_02_i = ixheaacd_mac32x16hin32(t_phi_02_i, imag1, real2); + t_phi_02_i = ixheaacd_macn32x16hin32(t_phi_02_i, real1, imag2); + p += 4; + } + n = ixheaacd_shl16(len_by_4, 2); + for (; n < slots; n++) { + WORD32 real1, real2, imag1, imag2; + real1 = real_buffer[(n * 128)]; + real2 = real_buffer[(n - 2) * 128]; + imag1 = img_buffer[n * 128]; + imag2 = img_buffer[(n - 2) * 128]; + + real1 = ixheaacd_shr32(real1, 3); + real2 = ixheaacd_shr32(real2, 3); + imag1 = ixheaacd_shr32(imag1, 3); + imag2 = ixheaacd_shr32(imag2, 3); + + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, real1, real2); + t_phi_02 = ixheaacd_mac32x16hin32(t_phi_02, imag1, imag2); + t_phi_02_i = ixheaacd_mac32x16hin32(t_phi_02_i, imag1, real2); + t_phi_02_i = ixheaacd_macn32x16hin32(t_phi_02_i, real1, imag2); + } + + cov_matrix->phi_02 = t_phi_02; + cov_matrix->phi_02_im = t_phi_02_i; + } + ptr_real++; + pac_arr++; + } +} + +static PLATFORM_INLINE VOID ixheaacd_filt_step3_lp(WORD len, WORD32 coef1, + WORD32 coef2, + WORD32 *pqmf_real_low, + WORD32 *pqmf_real_high) { + WORD32 prev1; + WORD32 prev2; + WORD32 i; + + prev2 = *pqmf_real_low; + pqmf_real_low += 64; + + prev1 = *pqmf_real_low; + pqmf_real_low += 64; + + for (i = len; i >= 0; i -= 2) { + WORD32 curr = *pqmf_real_low; + 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 += 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 += 64; + + prev1 = prev2; + prev2 = curr; + } +} + +VOID ixheaacd_filter1_lp(ia_sbr_hf_generator_struct *hf_generator, + ixheaacd_lpp_trans_cov_matrix *cov_matrix_seq, + WORD32 *bw_array, WORD16 *degree_alias, + WORD32 start_idx, WORD32 stop_idx, + WORD32 max_qmf_subband, WORD32 start_patch, + WORD32 stop_patch, WORD32 *sub_sig_x) { + WORD16 k1, k1_below = 0, k1_below2 = 0; + WORD32 i; + WORD16 alpha_real[LPC_ORDER]; + WORD32 low_band, high_band; + WORD32 patch; + WORD16 bw = 0; + WORD32 a0r, a1r; + + WORD num_patches = hf_generator->pstr_settings->num_patches; + ia_patch_param_struct *patch_param = + hf_generator->pstr_settings->str_patch_param; + WORD32 bw_index[MAX_NUM_PATCHES]; + + memset(bw_index, 0, sizeof(WORD32) * num_patches); + + for (low_band = start_patch; low_band < stop_patch; low_band++) { + ixheaacd_lpp_trans_cov_matrix *p_cov_matrix = &cov_matrix_seq[low_band]; + + alpha_real[1] = 0; + alpha_real[0] = 0; + + if (p_cov_matrix->d != 0) { + WORD32 tmp_r, temp_real, modulus_d; + WORD16 inverse_d; + WORD32 norm_d; + + norm_d = ixheaacd_norm32(p_cov_matrix->d); + + inverse_d = + (WORD16)(*ixheaacd_fix_div)(0x40000000, (p_cov_matrix->d << norm_d)); + modulus_d = ixheaacd_abs32(p_cov_matrix->d); + + tmp_r = + (ixheaacd_sub32_sat( + ixheaacd_mult32(p_cov_matrix->phi_01, p_cov_matrix->phi_12), + ixheaacd_mult32(p_cov_matrix->phi_02, p_cov_matrix->phi_11)) >> + LPC_SCALE_FACTOR); + temp_real = ixheaacd_abs32(tmp_r); + + if (temp_real < modulus_d) { + alpha_real[1] = (WORD16)( + (ixheaacd_mult32x16in32_shl_sat(tmp_r, inverse_d) << norm_d) >> 15); + } + + tmp_r = + (ixheaacd_sub32_sat( + ixheaacd_mult32(p_cov_matrix->phi_02, p_cov_matrix->phi_12), + ixheaacd_mult32(p_cov_matrix->phi_01, p_cov_matrix->phi_22)) >> + LPC_SCALE_FACTOR); + temp_real = ixheaacd_abs32(tmp_r); + + if (temp_real < modulus_d) { + alpha_real[0] = (WORD16)( + (ixheaacd_mult32x16in32_shl_sat(tmp_r, inverse_d) << norm_d) >> 15); + } + } + + if (p_cov_matrix->phi_11 == 0) { + k1 = 0; + } else { + if (ixheaacd_abs32_sat(p_cov_matrix->phi_01) >= p_cov_matrix->phi_11) { + if (p_cov_matrix->phi_01 < 0) { + k1 = 0x7fff; + } else { + k1 = (WORD16)-0x8000; + } + } else { + k1 = -((WORD16)( + (*ixheaacd_fix_div)(p_cov_matrix->phi_01, p_cov_matrix->phi_11))); + } + } + + if (low_band > 1) { + WORD16 deg = ixheaacd_sub16_sat( + 0x7fff, ixheaacd_mult16_shl_sat(k1_below, k1_below)); + degree_alias[low_band] = 0; + + if (((low_band & 1) == 0) && (k1 < 0)) { + if (k1_below < 0) { + degree_alias[low_band] = 0x7fff; + + if (k1_below2 > 0) { + degree_alias[low_band - 1] = deg; + } + } else { + if (k1_below2 > 0) { + degree_alias[low_band] = deg; + } + } + } + + if (((low_band & 1) != 0) && (k1 > 0)) { + if (k1_below > 0) { + degree_alias[low_band] = 0x7fff; + + if (k1_below2 < 0) { + degree_alias[low_band - 1] = deg; + } + } else { + if (k1_below2 < 0) { + degree_alias[low_band] = deg; + } + } + } + } + + k1_below2 = k1_below; + k1_below = k1; + + patch = 0; + while (patch < num_patches) { + ia_patch_param_struct *p_loc_patch_param = &patch_param[patch]; + WORD32 bw_vec, bw_idx; + WORD16 alpha1, alpha2; + + high_band = (((low_band + p_loc_patch_param->dst_end_band) << 8) >> 8); + + if ((low_band < p_loc_patch_param->src_start_band) || + (low_band >= p_loc_patch_param->src_end_band) || + (high_band < max_qmf_subband)) { + patch++; + continue; + } + + bw_idx = bw_index[patch]; + while (high_band >= hf_generator->pstr_settings->bw_borders[bw_idx]) { + bw_idx++; + bw_index[patch] = bw_idx; + } + + bw_vec = bw_array[bw_idx]; + alpha1 = alpha_real[0]; + alpha2 = alpha_real[1]; + + bw = ixheaacd_extract16h(bw_vec); + a0r = ixheaacd_mult16x16in32_shl(bw, alpha1); + bw = ixheaacd_mult16_shl_sat(bw, bw); + a1r = ixheaacd_mult16x16in32_shl(bw, alpha2); + + { + WORD32 *p_sub_signal_xlow = sub_sig_x + low_band + ((start_idx) << 6); + WORD32 *p_sub_signal_xhigh = + sub_sig_x + high_band + ((start_idx + 2) << 6); + WORD32 len = stop_idx - start_idx - 1; + + if (bw > 0) { + ixheaacd_filt_step3_lp(len, a0r, a1r, p_sub_signal_xlow, + p_sub_signal_xhigh); + + } else { + p_sub_signal_xlow += 128; + for (i = len; i >= 0; i--) { + *p_sub_signal_xhigh = *p_sub_signal_xlow >> LPC_SCALE_FACTOR; + p_sub_signal_xlow += 64; + p_sub_signal_xhigh += 64; + } + } + } + + patch++; + } + } +} + +VOID ixheaacd_clr_subsamples(WORD32 *ptr_qmf_buf, WORD32 num, WORD32 size) { + WORD32 i; + for (i = num; i >= 0; i--) { + memset(ptr_qmf_buf, 0, sizeof(WORD32) * (size)); + ptr_qmf_buf += 64; + } +} + +VOID ixheaacd_low_pow_hf_generator(ia_sbr_hf_generator_struct *hf_generator, + WORD32 **qmf_real, WORD16 *degree_alias, + WORD32 start_idx, WORD32 stop_idx, + WORD32 num_if_bands, WORD32 max_qmf_subband, + WORD32 *sbr_invf_mode, + WORD32 *sbr_invf_mode_prev, WORD32 norm_max, + WORD32 *sub_sig_x) { + WORD32 bw_array[MAX_NUM_PATCHES]; + WORD32 i; + WORD32 start_patch, stop_patch, low_band, high_band; + ia_patch_param_struct *patch_param = + hf_generator->pstr_settings->str_patch_param; + WORD32 patch; + ixheaacd_lpp_trans_cov_matrix cov_matrix_seq[MAX_COLS]; + + WORD32 actual_stop_band; + WORD32 num_patches = hf_generator->pstr_settings->num_patches; + + stop_idx = (hf_generator->pstr_settings->num_columns + stop_idx); + + ixheaacd_invfilt_level_emphasis(hf_generator, num_if_bands, sbr_invf_mode, + sbr_invf_mode_prev, bw_array); + + actual_stop_band = + ixheaacd_add16(patch_param[num_patches - 1].dst_start_band, + patch_param[num_patches - 1].num_bands_in_patch); + + { + WORD32 *p_qmf_real; + WORD32 len = 6, num; + + if (len > stop_idx) len = stop_idx; + + p_qmf_real = &qmf_real[start_idx][actual_stop_band]; + num = (len - start_idx - 1); + ixheaacd_clr_subsamples(p_qmf_real, num, + (NO_SYNTHESIS_CHANNELS - actual_stop_band)); + + if (actual_stop_band < 32) { + num = (stop_idx - len - 1); + p_qmf_real = &qmf_real[len][actual_stop_band]; + ixheaacd_clr_subsamples(p_qmf_real, num, + (NO_ANALYSIS_CHANNELS - actual_stop_band)); + } + } + + start_patch = ixheaacd_max16( + 1, ixheaacd_sub16(hf_generator->pstr_settings->start_patch, 2)); + stop_patch = patch_param[0].dst_start_band; + + { + WORD32 *ptr = &sub_sig_x[0]; + WORD32 *plpc_filt_states_real = &hf_generator->lpc_filt_states_real[0][0]; + for (i = LPC_ORDER; i != 0; i--) { + memcpy(ptr, plpc_filt_states_real, sizeof(WORD32) * (stop_patch)); + ptr += NO_SYNTHESIS_CHANNELS; + plpc_filt_states_real += 32; + } + } + if (norm_max != 30) { + (*ixheaacd_covariance_matrix_calc)(sub_sig_x + start_patch, + &cov_matrix_seq[start_patch], + (stop_patch - start_patch)); + + } else { + memset(&cov_matrix_seq[0], 0, + sizeof(ixheaacd_lpp_trans_cov_matrix) * stop_patch); + } + + ixheaacd_filter1_lp(hf_generator, cov_matrix_seq, bw_array, degree_alias, + start_idx, stop_idx, max_qmf_subband, start_patch, + stop_patch, sub_sig_x); + + start_patch = hf_generator->pstr_settings->start_patch; + stop_patch = hf_generator->pstr_settings->stop_patch; + + for (low_band = start_patch; low_band < stop_patch; low_band++) { + WORD32 src_start_band, src_end_band, dst_start_band, dst_end_band; + patch = 0; + + while (patch < num_patches) { + ia_patch_param_struct *ptr_loc_patch_param = &patch_param[patch]; + + src_start_band = ptr_loc_patch_param->src_start_band; + src_end_band = ptr_loc_patch_param->src_end_band; + dst_start_band = ptr_loc_patch_param->dst_start_band; + dst_end_band = ptr_loc_patch_param->dst_end_band; + + high_band = (low_band + ptr_loc_patch_param->dst_end_band); + + if ((low_band < src_start_band) || (low_band >= src_end_band) || + (high_band >= NO_SYNTHESIS_CHANNELS)) { + patch++; + continue; + } + + if ((high_band != dst_start_band)) { + degree_alias[high_band] = degree_alias[low_band]; + } + + patch++; + } + } + + memcpy(hf_generator->bw_array_prev, bw_array, sizeof(WORD32) * num_if_bands); +} + +VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, + ia_sbr_scale_fact_struct *scale_factor, + WORD32 **qmf_real, WORD32 **qmf_imag, WORD32 factor, + WORD32 start_idx, WORD32 stop_idx, + WORD32 num_if_bands, WORD32 max_qmf_subband, + WORD32 *sbr_invf_mode, WORD32 *sbr_invf_mode_prev, + WORD32 *sub_sig_x, WORD audio_object_type) { + WORD32 bw_index[MAX_NUM_PATCHES]; + WORD32 bw_array[MAX_NUM_PATCHES]; + + WORD32 i, j; + WORD32 start_patch, stop_patch, low_band, high_band; + ia_patch_param_struct *patch_param = + hf_generator->pstr_settings->str_patch_param; + WORD32 patch; + + WORD16 alpha_real[LPC_ORDER]; + WORD16 a0r, a1r; + WORD16 alpha_imag[LPC_ORDER]; + WORD16 a0i = 0, a1i = 0; + + WORD16 bw = 0; + + ixheaacd_lpp_trans_cov_matrix cov_matrix; + ixheaacd_lpp_trans_cov_matrix cov_matrix_seq[MAX_COLS]; + + WORD32 common_scale; + WORD32 actual_stop_band; + WORD32 num_patches = hf_generator->pstr_settings->num_patches; + + start_idx = (start_idx * factor); + + stop_idx = (hf_generator->pstr_settings->num_columns + (stop_idx * factor)); + + ixheaacd_invfilt_level_emphasis(hf_generator, num_if_bands, sbr_invf_mode, + sbr_invf_mode_prev, bw_array); + + actual_stop_band = + ixheaacd_add16(patch_param[num_patches - 1].dst_start_band, + patch_param[num_patches - 1].num_bands_in_patch); + + for (i = start_idx; i < stop_idx; i++) { + WORD32 *p_qmf_real = &qmf_real[i][actual_stop_band]; + WORD32 *p_qmf_imag = &qmf_imag[i][actual_stop_band]; + + for (j = NO_SYNTHESIS_CHANNELS - actual_stop_band; j != 0; j--) { + *p_qmf_real++ = 0; + *p_qmf_imag++ = 0; + } + } + + memset(bw_index, 0, sizeof(WORD32) * num_patches); + + common_scale = + ixheaacd_min32(scale_factor->ov_lb_scale, scale_factor->lb_scale); + + start_patch = hf_generator->pstr_settings->start_patch; + stop_patch = hf_generator->pstr_settings->stop_patch; + + { + WORD32 *ptr; + for (i = 0; i < LPC_ORDER; i++) { + ptr = sub_sig_x + (start_patch) + i * 128; + memcpy(ptr, &hf_generator->lpc_filt_states_real[i][start_patch], + sizeof(WORD32) * (stop_patch - start_patch)); + memcpy(ptr + 64, &hf_generator->lpc_filt_states_imag[i][start_patch], + sizeof(WORD32) * (stop_patch - start_patch)); + } + } + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + (*ixheaacd_covariance_matrix_calc_2)( + &cov_matrix_seq[start_patch], + (sub_sig_x + start_patch + LPC_ORDER * 128), (stop_patch - start_patch), + 38); + } else { + (*ixheaacd_covariance_matrix_calc_2)( + &cov_matrix_seq[start_patch], + (sub_sig_x + start_patch + LPC_ORDER * 128), (stop_patch - start_patch), + 16); + } + + for (low_band = start_patch; low_band < stop_patch; low_band++) { + FLAG reset_lpc_coeff = 0; + WORD32 max_val; + WORD32 q_shift; + WORD32 v; + max_val = ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_01); + max_val = max_val | ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_02); + max_val = max_val | ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_12); + + max_val = max_val | (cov_matrix_seq[low_band].phi_11); + max_val = max_val | (cov_matrix_seq[low_band].phi_22); + max_val = max_val | ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_01_im); + max_val = max_val | ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_02_im); + max_val = max_val | ixheaacd_abs32_nrm(cov_matrix_seq[low_band].phi_12_im); + + q_shift = ixheaacd_pnorm32(max_val); + + cov_matrix.phi_11 = (cov_matrix_seq[low_band].phi_11 << q_shift); + cov_matrix.phi_22 = (cov_matrix_seq[low_band].phi_22 << q_shift); + cov_matrix.phi_01 = (cov_matrix_seq[low_band].phi_01 << q_shift); + cov_matrix.phi_02 = (cov_matrix_seq[low_band].phi_02 << q_shift); + cov_matrix.phi_12 = (cov_matrix_seq[low_band].phi_12 << q_shift); + cov_matrix.phi_01_im = (cov_matrix_seq[low_band].phi_01_im << q_shift); + cov_matrix.phi_02_im = (cov_matrix_seq[low_band].phi_02_im << q_shift); + cov_matrix.phi_12_im = (cov_matrix_seq[low_band].phi_12_im << q_shift); + + max_val = ixheaacd_mult32(cov_matrix.phi_12, cov_matrix.phi_12); + 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) + << 1; + cov_matrix.d = v; + + alpha_real[1] = 0; + alpha_imag[1] = 0; + + if (cov_matrix.d != 0) { + WORD32 tmp_r, temp_real, modulus_d; + WORD32 tmp_i, temp_imag; + WORD16 inverse_d; + WORD32 norm_d; + + norm_d = ixheaacd_norm32(cov_matrix.d); + + inverse_d = + (WORD16)(*ixheaacd_fix_div)(0x40000000, (cov_matrix.d << norm_d)); + + modulus_d = ixheaacd_abs32_sat(cov_matrix.d); + tmp_r = + (ixheaacd_sub32( + ixheaacd_sub32( + 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))) >> + (LPC_SCALE_FACTOR - 1); + tmp_i = (ixheaacd_sub32_sat( + ixheaacd_add32( + ixheaacd_mult32(cov_matrix.phi_01_im, cov_matrix.phi_12), + ixheaacd_mult32(cov_matrix.phi_01, cov_matrix.phi_12_im)), + ixheaacd_mult32(cov_matrix.phi_02_im, cov_matrix.phi_11))) >> + (LPC_SCALE_FACTOR - 1); + temp_imag = ixheaacd_abs32(tmp_i); + temp_real = ixheaacd_abs32(tmp_r); + + if (temp_real >= modulus_d) { + reset_lpc_coeff = 1; + } else { + alpha_real[1] = (WORD16)( + (ixheaacd_mult32x16in32(tmp_r, inverse_d) << (norm_d + 1)) >> 15); + } + + if (temp_imag >= modulus_d) { + reset_lpc_coeff = 1; + } else { + alpha_imag[1] = (WORD16)( + (ixheaacd_mult32x16in32(tmp_i, inverse_d) << (norm_d + 1)) >> 15); + } + } + + alpha_real[0] = 0; + alpha_imag[0] = 0; + + if (cov_matrix.phi_11 != 0) { + WORD32 tmp_r, temp_real; + WORD32 tmp_i = 0, temp_imag = 0; + WORD16 inverse_r11; + WORD32 norm_r11; + + norm_r11 = ixheaacd_norm32(cov_matrix.phi_11); + + inverse_r11 = (WORD16)(*ixheaacd_fix_div)( + 0x40000000, (cov_matrix.phi_11 << norm_r11)); + + tmp_r = ixheaacd_add32( + 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( + ixheaacd_add32( + (cov_matrix.phi_01_im >> (LPC_SCALE_FACTOR + 1)), + ixheaacd_mult32x16in32(cov_matrix.phi_12, alpha_imag[1])), + ixheaacd_mult32x16in32(cov_matrix.phi_12_im, alpha_real[1])); + + tmp_r = tmp_r << 1; + tmp_i = tmp_i << 1; + + temp_imag = ixheaacd_abs32(tmp_i); + temp_real = ixheaacd_abs32(tmp_r); + + if (temp_real >= cov_matrix.phi_11) { + reset_lpc_coeff = 1; + } else { + alpha_real[0] = (WORD16)( + (ixheaacd_mult32x16in32(ixheaacd_sub32_sat(0, tmp_r), inverse_r11) + << (norm_r11 + 1)) >> + 15); + } + + if (temp_imag >= cov_matrix.phi_11) { + reset_lpc_coeff = 1; + } else { + alpha_imag[0] = (WORD16)( + (ixheaacd_mult32x16in32(ixheaacd_sub32_sat(0, tmp_i), inverse_r11) + << (norm_r11 + 1)) >> + 15); + } + } + + if (ixheaacd_add32((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) { + reset_lpc_coeff = 1; + } + + if (reset_lpc_coeff) { + alpha_real[0] = 0; + alpha_real[1] = 0; + alpha_imag[0] = 0; + alpha_imag[1] = 0; + } + + patch = 0; + + while (patch < num_patches) { + high_band = (low_band + patch_param[patch].dst_end_band); + + if ((low_band < patch_param[patch].src_start_band) || + (low_band >= patch_param[patch].src_end_band)) { + patch++; + continue; + } + + if (high_band < max_qmf_subband) { + patch++; + continue; + } + + while (high_band >= + hf_generator->pstr_settings->bw_borders[bw_index[patch]]) { + bw_index[patch] = (bw_index[patch] + 1); + } + + bw = ixheaacd_extract16h(bw_array[bw_index[patch]]); + a0r = ixheaacd_mult16_shl_sat(bw, alpha_real[0]); + a0i = ixheaacd_mult16_shl_sat(bw, alpha_imag[0]); + bw = ixheaacd_mult16_shl_sat(bw, bw); + a1r = ixheaacd_mult16_shl_sat(bw, alpha_real[1]); + a1i = ixheaacd_mult16_shl_sat(bw, alpha_imag[1]); + + if (bw > 0) { + ixheaacd_filterstep3(a0r, a0i, a1r, a1i, start_idx, stop_idx, low_band, + high_band, sub_sig_x); + + } else { + WORD32 *p_src = sub_sig_x + low_band + ((start_idx + 2) << 7); + WORD32 *p_dst = sub_sig_x + high_band + ((start_idx + 2) << 7); + + for (i = stop_idx - start_idx; i != 0; i--) { + *(p_dst) = *(p_src) >> LPC_SCALE_FACTOR; + p_src += 64; + p_dst += 64; + *(p_dst) = *(p_src) >> LPC_SCALE_FACTOR; + p_src += 64; + p_dst += 64; + } + } + + patch++; + } + } + + memcpy(hf_generator->bw_array_prev, bw_array, sizeof(WORD32) * num_if_bands); + + scale_factor->hb_scale = (WORD16)(common_scale - LPC_SCALE_FACTOR); +} diff --git a/decoder/ixheaacd_lpp_tran.h b/decoder/ixheaacd_lpp_tran.h new file mode 100644 index 0000000..e741412 --- /dev/null +++ b/decoder/ixheaacd_lpp_tran.h @@ -0,0 +1,106 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_LPP_TRAN_H +#define IXHEAACD_LPP_TRAN_H + +#define MAX_NUM_PATCHES 6 +#define GUARDBANDS 0 +#define SHIFT_START_SB 1 + +typedef struct { + WORD32 phi_11; + WORD32 phi_22; + WORD32 phi_01; + WORD32 phi_02; + WORD32 phi_12; + WORD32 phi_01_im; + WORD32 phi_02_im; + WORD32 phi_12_im; + WORD32 d; +} ixheaacd_lpp_trans_cov_matrix; + +typedef struct { + WORD16 src_start_band; + WORD16 src_end_band; + WORD16 guard_start_band; + + WORD16 dst_start_band; + WORD16 dst_end_band; + WORD16 num_bands_in_patch; +} ia_patch_param_struct; + +typedef struct { + WORD16 num_columns; + WORD16 num_patches; + WORD16 start_patch; + WORD16 stop_patch; + WORD16 bw_borders[MAX_NUM_NOISE_VALUES]; + ia_patch_param_struct str_patch_param[MAX_NUM_PATCHES]; +} ia_transposer_settings_struct; + +typedef struct { + ia_transposer_settings_struct *pstr_settings; + WORD32 bw_array_prev[MAX_NUM_PATCHES]; + WORD32 *lpc_filt_states_real[LPC_ORDER]; + WORD32 *lpc_filt_states_imag[LPC_ORDER]; +} ia_sbr_hf_generator_struct; + +VOID ixheaacd_low_pow_hf_generator( + ia_sbr_hf_generator_struct *hf_generator, WORD32 **qmf_buff_re, + WORD16 *degree_alias, WORD first_slot_offset, WORD last_slot_offset, + WORD num_if_bands, WORD max_qmf_subband_aac, WORD32 *sbr_invf_mode, + WORD32 *sbr_invf_mode_prev, WORD32 norm_max, WORD32 *ptr_qmf_matrix); + +VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, + ia_sbr_scale_fact_struct *sbr_scale_factor, + WORD32 **qmf_buff_re, WORD32 **qmf_buff_im, + WORD time_step, WORD first_slot_offset, + WORD last_slot_offset, WORD num_if_bands, + WORD max_qmf_subband_aac, WORD32 *sbr_invf_mode, + WORD32 *sbr_invf_mode_prev, WORD32 *ptr_qmf_matrix, + WORD audio_object_type); + +VOID ixheaacd_invfilt_level_emphasis(ia_sbr_hf_generator_struct *hf_generator, + WORD32 num_if_bands, WORD32 *sbr_invf_mode, + WORD32 *sbr_invf_mode_prev, + WORD32 *bw_array); + +struct ixheaacd_lpp_trans_patch { + WORD32 num_patches; + WORD32 start_subband[MAX_NUM_PATCHES + 1]; +}; + +VOID ixheaacd_covariance_matrix_calc_dec( + WORD32 *sub_sign_xlow, ixheaacd_lpp_trans_cov_matrix *cov_matrix, + WORD32 count); + +VOID ixheaacd_covariance_matrix_calc_armv7( + WORD32 *sub_sign_xlow, ixheaacd_lpp_trans_cov_matrix *cov_matrix, + WORD32 count); + +VOID ixheaacd_covariance_matrix_calc_2_dec( + ixheaacd_lpp_trans_cov_matrix *cov_matrix, WORD32 *real_buffer, + WORD32 ixheaacd_num_bands, WORD16 slots); + +VOID ixheaacd_covariance_matrix_calc_2_armv7( + ixheaacd_lpp_trans_cov_matrix *cov_matrix, WORD32 *real_buffer, + WORD32 ixheaacd_num_bands, WORD16 slots); + +#endif /* IXHEAACD_LPP_TRAN_H */ diff --git a/decoder/ixheaacd_lt_predict.c b/decoder/ixheaacd_lt_predict.c new file mode 100644 index 0000000..4e004f5 --- /dev/null +++ b/decoder/ixheaacd_lt_predict.c @@ -0,0 +1,523 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include +#include "ixheaacd_constants.h" +#include +#include +#include + +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_audioobjtypes.h" + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_aac_imdct.h" + +static const WORD32 ixheaacd_codebook_Q30[8] = { + 612922971, 747985734, 872956397, 978505219, + 1057528322, 1146642451, 1282693056, 1470524861}; + +#define SHIFT_VAL 8 +#define SHIFT_VAL1 (15 - SHIFT_VAL) + +VOID ixheaacd_lt_prediction( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, ltp_info *ltp, + WORD32 *spec, ia_aac_dec_tables_struct *aac_tables_ptr, + UWORD16 win_shape_prev, UWORD32 sr_index, UWORD32 object_type, + UWORD32 frame_len, WORD32 *in_data, WORD32 *out_data) { + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + WORD16 *lt_pred_stat = ptr_aac_dec_channel_info->ltp_buf; + UWORD16 win_shape = ptr_aac_dec_channel_info->str_ics_info.window_shape; + WORD16 sfb; + WORD16 bin, i, num_samples; + const WORD8 *swb_offset = aac_tables_ptr->scale_factor_bands_long[sr_index]; + WORD32 *ptr_spec = &spec[0]; + WORD32 *ptr_x_est = &out_data[0]; + + if (512 == ptr_ics_info->frame_length) { + swb_offset = aac_tables_ptr->scale_fac_bands_512[sr_index]; + } else if (480 == ptr_ics_info->frame_length) { + swb_offset = aac_tables_ptr->scale_fac_bands_480[sr_index]; + } + + if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { + if (ltp->data_present) { + num_samples = frame_len << 1; + + for (i = 0; i < num_samples; i++) { + in_data[i] = + ixheaacd_shr32(ixheaacd_mult32x16in32_shl( + ixheaacd_codebook_Q30[ltp->coef], + lt_pred_stat[num_samples + i - ltp->lag]), + SHIFT_VAL); + } + + ixheaacd_filter_bank_ltp(aac_tables_ptr, ptr_ics_info->window_sequence, + win_shape, win_shape_prev, in_data, out_data, + object_type, frame_len); + + if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present == 1) + ixheaacd_aac_tns_process(ptr_aac_dec_channel_info, 1, aac_tables_ptr, + object_type, 0, out_data); + + for (sfb = 0; sfb < ltp->last_band; sfb++) { + WORD8 sfb_width = swb_offset[sfb]; + if (ltp->long_used[sfb]) { + for (bin = sfb_width - 1; bin >= 0; bin--) { + WORD32 temp = *ptr_spec; + temp += ixheaacd_shr32(*ptr_x_est++, SHIFT_VAL1); + + *ptr_spec++ = temp; + } + } else { + ptr_spec += sfb_width; + ptr_x_est += sfb_width; + } + } + } + } +} + +VOID ixheaacd_filter_bank_ltp(ia_aac_dec_tables_struct *aac_tables_ptr, + WORD16 window_sequence, WORD16 window_shape, + WORD16 window_shape_prev, WORD32 *in_data, + WORD32 *out_mdct, UWORD32 object_type, + UWORD32 frame_len) { + WORD32 i; + + const WORD16 *window_long = NULL; + const WORD16 *window_long_prev = NULL; + const WORD16 *window_short = NULL; + const WORD16 *window_short_prev = NULL; + + UWORD16 nlong = frame_len; + UWORD16 nlong2 = frame_len << 1; + UWORD16 nshort = frame_len / 8; + UWORD16 nflat_ls = (nlong - nshort) / 2; + WORD32 imdct_scale = 0; + WORD32 expo = 0; + + if (object_type == AOT_ER_AAC_LD) { + if (!window_shape) { + if (512 == frame_len) { + window_long = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->window_sine_512; + } else { + window_long = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->window_sine_480; + } + } else { + if (512 == frame_len) { + window_long = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->low_overlap_win; + } else { + window_long = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->low_overlap_win_480; + } + } + + if (!window_shape_prev) { + if (512 == frame_len) { + window_long_prev = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->window_sine_512; + } else { + window_long_prev = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->window_sine_480; + } + } else { + if (512 == frame_len) { + window_long_prev = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->low_overlap_win; + } else { + window_long_prev = + (WORD16 *)aac_tables_ptr->pstr_imdct_tables->low_overlap_win_480; + } + } + + if (!window_shape) + window_short = aac_tables_ptr->pstr_imdct_tables->only_short_window_sine; + else + window_short = aac_tables_ptr->pstr_imdct_tables->only_short_window_kbd; + if (!window_shape_prev) + window_short_prev = + aac_tables_ptr->pstr_imdct_tables->only_short_window_sine; + else + window_short_prev = + aac_tables_ptr->pstr_imdct_tables->only_short_window_kbd; + + } else { + if (!window_shape) + window_long = aac_tables_ptr->pstr_imdct_tables->only_long_window_sine; + else + window_long = aac_tables_ptr->pstr_imdct_tables->only_long_window_kbd; + if (!window_shape_prev) + window_long_prev = + aac_tables_ptr->pstr_imdct_tables->only_long_window_sine; + else + window_long_prev = + aac_tables_ptr->pstr_imdct_tables->only_long_window_kbd; + + if (!window_shape) + window_short = aac_tables_ptr->pstr_imdct_tables->only_short_window_sine; + else + window_short = aac_tables_ptr->pstr_imdct_tables->only_short_window_kbd; + if (!window_shape_prev) + window_short_prev = + aac_tables_ptr->pstr_imdct_tables->only_short_window_sine; + else + window_short_prev = + aac_tables_ptr->pstr_imdct_tables->only_short_window_kbd; + } + + switch (window_sequence) { + case ONLY_LONG_SEQUENCE: + + if ((512 != nlong) && (480 != nlong)) { + for (i = 0; i> 1; i++) { + in_data[i] = + ixheaacd_mult32x16in32_shl(in_data[i], window_long_prev[2 * i]); + + in_data[i + nlong] = ixheaacd_mult32x16in32_shl( + in_data[i + nlong], window_long[2 * i + 1]); + } + for (i = 0; i> 1; i++) { + in_data[i + (nlong >> 1)] = ixheaacd_mult32x16in32_shl( + in_data[i + (nlong >> 1)], window_long_prev[nlong - 1 - 2 * i]); + + in_data[i + nlong + (nlong >> 1)] = + ixheaacd_mult32x16in32_shl(in_data[i + nlong + (nlong >> 1)], + window_long[nlong - 1 - 2 * i - 1]); + } + + } else { + WORD32 *win1, *win2, *win3; + WORD32 *ptr_in1, *ptr_in2; + win1 = (WORD32 *)window_long_prev; + win2 = (WORD32 *)window_long; + ptr_in1 = &in_data[0]; + ptr_in2 = &in_data[nlong]; + win3 = win2 + nlong - 1; + + for (i = nlong - 1; i >= 0; i--) { + WORD32 temp1 = ixheaacd_mult32_shl(*ptr_in1, *win1++); + WORD32 temp2 = ixheaacd_mult32_shl(*ptr_in2, win2[i]); + + *ptr_in1++ = temp1; + *ptr_in2++ = temp2; + } + } + + for (i = 0; i < nlong / 2; i++) { + out_mdct[nlong / 2 + i] = + ixheaacd_sub32(in_data[i], in_data[nlong - 1 - i]); + out_mdct[i] = (-ixheaacd_add32(in_data[nlong + i + nlong / 2], + in_data[nlong2 - nlong / 2 - 1 - i])); + } + + if (512 == nlong || (480 == nlong)) { + if (512 == nlong) + ixheaacd_inverse_transform_512( + out_mdct, in_data, &imdct_scale, + aac_tables_ptr->pstr_imdct_tables->cosine_array_1024, + aac_tables_ptr->pstr_imdct_tables, object_type); + + else + ixheaacd_mdct_480_ld(out_mdct, in_data, &imdct_scale, 1, + aac_tables_ptr->pstr_imdct_tables, object_type); + + imdct_scale += 1; + + if (imdct_scale > 0) { + WORD32 *ptr_out_mdct = &out_mdct[0]; + + for (i = nlong - 1; i >= 0; i -= 4) { + *ptr_out_mdct = ixheaacd_shl32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shl32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shl32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shl32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + } + } else if (imdct_scale < 0) { + WORD32 *ptr_out_mdct = &out_mdct[0]; + imdct_scale = -imdct_scale; + for (i = nlong - 1; i >= 0; i -= 4) { + *ptr_out_mdct = ixheaacd_shr32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shr32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shr32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + *ptr_out_mdct = ixheaacd_shr32(*ptr_out_mdct, imdct_scale); + ptr_out_mdct++; + } + } + } + + else if (1024 == nlong) { + expo = ixheaacd_calc_max_spectral_line_dec(out_mdct, 1024) - 1; + + expo = 8 - expo; + + imdct_scale = ixheaacd_inverse_transform( + out_mdct, in_data, aac_tables_ptr->pstr_imdct_tables, expo, 1024); + + ixheaacd_post_twiddle_dec(in_data, out_mdct, + aac_tables_ptr->pstr_imdct_tables, 1024); + + imdct_scale += 1; + + for (i = 0; i < nlong; i++) { + out_mdct[i] = ixheaacd_shl32_dir(in_data[i], imdct_scale); + } + } + + break; + + case LONG_START_SEQUENCE: + + for (i = 0; i> 1; i++) + in_data[i] = + ixheaacd_mult32x16in32_shl(in_data[i], window_long_prev[2 * i]); + + for (i = 0; i> 1; i++) + in_data[i + (nlong >> 1)] = ixheaacd_mult32x16in32_shl( + in_data[i + (nlong >> 1)], window_long_prev[nlong - 1 - 2 * i - 1]); + + for (i = 0; i> 1; i++) + in_data[i + nlong + nflat_ls + (nshort >> 1)] = + ixheaacd_mult32x16in32_shl( + in_data[i + nlong + nflat_ls + (nshort >> 1)], + window_short[nshort - 1 - 2 * i - 1]); + + for (i = 0; i < nflat_ls; i++) in_data[i + nlong + nflat_ls + nshort] = 0; + + for (i = 0; i < nlong / 2; i++) { + out_mdct[nlong / 2 + i] = + ixheaacd_sub32(in_data[i], in_data[nlong - 1 - i]); + out_mdct[nlong / 2 - 1 - i] = + -ixheaacd_add32(in_data[nlong + i], in_data[nlong2 - 1 - i]); + } + + { + expo = ixheaacd_calc_max_spectral_line_dec(out_mdct, 1024) - 1; + + expo = 8 - expo; + imdct_scale = ixheaacd_inverse_transform( + out_mdct, in_data, aac_tables_ptr->pstr_imdct_tables, expo, 1024); + + ixheaacd_post_twiddle_dec(in_data, out_mdct, + aac_tables_ptr->pstr_imdct_tables, 1024); + } + + imdct_scale += 1; + + for (i = 0; i < nlong; i++) { + out_mdct[i] = ixheaacd_shl32_dir(in_data[i], imdct_scale); + } + break; + + case LONG_STOP_SEQUENCE: + for (i = 0; i < nflat_ls; i++) in_data[i] = 0; + + for (i = 0; i> 1; i++) + in_data[i + nflat_ls] = ixheaacd_mult32x16in32_shl( + in_data[i + nflat_ls], window_short_prev[2 * i]); + + for (i = 0; i> 1; i++) + in_data[i + nflat_ls + (nshort >> 1)] = + ixheaacd_mult32x16in32_shl(in_data[i + nflat_ls + (nshort >> 1)], + window_short_prev[127 - 2 * i]); + + for (i = 0; i> 1; i++) + in_data[i + nlong] = ixheaacd_mult32x16in32_shl(in_data[i + nlong], + window_long[2 * i + 1]); + + for (i = 0; i> 1; i++) + in_data[i + nlong + (nlong >> 1)] = + ixheaacd_mult32x16in32_shl(in_data[i + nlong + (nlong >> 1)], + window_long[nlong - 1 - 2 * i - 1]); + + for (i = 0; i < nlong / 2; i++) { + out_mdct[nlong / 2 + i] = + ixheaacd_sub32(in_data[i], in_data[nlong - 1 - i]); + out_mdct[nlong / 2 - 1 - i] = + -ixheaacd_add32(in_data[nlong + i], in_data[nlong2 - 1 - i]); + } + + { + expo = ixheaacd_calc_max_spectral_line_dec(out_mdct, 1024) - 1; + + expo = 8 - expo; + imdct_scale = ixheaacd_inverse_transform( + out_mdct, in_data, aac_tables_ptr->pstr_imdct_tables, expo, 1024); + + ixheaacd_post_twiddle_dec(in_data, out_mdct, + aac_tables_ptr->pstr_imdct_tables, 1024); + } + + imdct_scale += 1; + + for (i = 0; i < nlong; i++) { + out_mdct[i] = ixheaacd_shl32_dir(in_data[i], imdct_scale); + } + + break; + } +} + +VOID ixheaacd_lt_update_state(WORD16 *lt_pred_stat, WORD16 *time, + WORD32 *overlap, WORD32 frame_len, + WORD32 object_type, WORD32 stride, + WORD16 window_sequence, WORD16 *p_window_next) { + WORD32 i; + if (object_type == AOT_ER_AAC_LD) { + WORD16 *ptr_ltp_state0 = <_pred_stat[0]; + WORD16 *ptr_ltp_state_fl = <_pred_stat[frame_len + 0]; + WORD16 *ptr_ltp_state_2fl = <_pred_stat[(frame_len * 2) + 0]; + WORD16 *ptr_time_in = &time[0 * stride]; + + for (i = 0; i < frame_len; i++) { + *ptr_ltp_state0++ = *ptr_ltp_state_fl; + *ptr_ltp_state_fl++ = *ptr_ltp_state_2fl; + *ptr_ltp_state_2fl++ = *ptr_time_in; + ptr_time_in += stride; + } + + } else { + WORD16 *ptr_ltp_state0 = <_pred_stat[0]; + WORD16 *ptr_ltp_state_fl = <_pred_stat[frame_len + 0]; + WORD16 *ptr_time_in = &time[0 * stride]; + + for (i = 0; i < frame_len; i++) { + *ptr_ltp_state0++ = *ptr_ltp_state_fl; + *ptr_ltp_state_fl++ = *ptr_time_in; + ptr_time_in += stride; + } + } + + if ((window_sequence == ONLY_LONG_SEQUENCE) || + (window_sequence == LONG_STOP_SEQUENCE)) { + if (512 == frame_len) { + WORD32 *window = (WORD32 *)p_window_next; + + for (i = 0; i < 256; i++) { + lt_pred_stat[(frame_len * 3) + i] = + ixheaacd_round16(ixheaacd_mult16x16in32_shl( + (WORD16)ixheaacd_shl16( + (WORD16)-ixheaacd_sat16(overlap[255 - i]), 1), + (WORD16)ixheaacd_shr32(window[511 - i], 15))); + + lt_pred_stat[(frame_len * 3) + 256 + i] = + ixheaacd_round16(ixheaacd_mult16x16in32_shl( + (WORD16)ixheaacd_shl16((WORD16)-ixheaacd_sat16(overlap[i]), 1), + (WORD16)ixheaacd_shr32(window[255 - i], 15))); + } + } else if (480 == frame_len) { + WORD32 *window = (WORD32 *)p_window_next; + + for (i = 0; i < 240; i++) { + lt_pred_stat[(frame_len * 3) + i] = + ixheaacd_round16(ixheaacd_mult16x16in32_shl( + (WORD16)ixheaacd_shl16( + (WORD16)-ixheaacd_sat16(overlap[239 - i]), 1), + (WORD16)ixheaacd_shr32(window[479 - i], 15))); + + lt_pred_stat[(frame_len * 3) + 240 + i] = + ixheaacd_round16(ixheaacd_mult16x16in32_shl( + (WORD16)ixheaacd_shl16((WORD16)-ixheaacd_sat16(overlap[i]), 1), + (WORD16)ixheaacd_shr32(window[239 - i], 15))); + } + } else { + for (i = 0; i < 512; i++) { + lt_pred_stat[(frame_len * 2) + i] = ixheaacd_round16( + ixheaacd_shl32_sat(ixheaacd_mult16x16in32_shl( + (WORD16)-ixheaacd_sat16(overlap[511 - i]), + p_window_next[2 * i + 1]), + 1)); + + lt_pred_stat[(frame_len * 2) + 512 + i] = + ixheaacd_round16(ixheaacd_shl32_sat( + ixheaacd_mult16x16in32_shl((WORD16)-ixheaacd_sat16(overlap[i]), + p_window_next[1023 - 2 * i - 1]), + 1)); + } + } + + } else if (window_sequence == LONG_START_SEQUENCE) { + for (i = 0; i < 448; i++) { + lt_pred_stat[(frame_len * 2) + i] = + ixheaacd_shl16((WORD16)-ixheaacd_sat16(overlap[511 - i]), 1); + } + for (i = 0; i < 64; i++) { + lt_pred_stat[(frame_len * 2) + 448 + i] = + ixheaacd_round16(ixheaacd_shl32_sat( + ixheaacd_mult16x16in32_shl( + (WORD16)-ixheaacd_sat16(overlap[511 - 448 - i]), + p_window_next[2 * i + 1]), + 1)); + } + for (i = 0; i < 64; i++) { + lt_pred_stat[(frame_len * 2) + 512 + i] = + ixheaacd_round16(ixheaacd_shl32_sat( + ixheaacd_mult16x16in32_shl((WORD16)-ixheaacd_sat16(overlap[i]), + p_window_next[127 - 2 * i - 1]), + 1)); + } + for (i = 576; i < 1024; i++) { + lt_pred_stat[(frame_len * 2) + i] = 0; + } + } else { + for (i = 0; i < 448; i++) { + lt_pred_stat[(frame_len * 2) + i] = + ixheaacd_shl16(ixheaacd_sat16(overlap[i]), 1); + } + for (i = 0; i < 64; i++) { + lt_pred_stat[(frame_len * 2) + 448 + i] = ixheaacd_round16( + ixheaacd_shl32_sat(ixheaacd_mult16x16in32_shl( + (WORD16)-ixheaacd_sat16(overlap[511 - i]), + p_window_next[2 * i + 1]), + 1)); + } + for (i = 0; i < 64; i++) { + lt_pred_stat[(frame_len * 2) + 512 + i] = ixheaacd_round16( + ixheaacd_shl32_sat(ixheaacd_mult16x16in32_shl( + (WORD16)-ixheaacd_sat16(overlap[448 + i]), + p_window_next[127 - 2 * i - 1]), + 1)); + } + for (i = 576; i < 1024; i++) { + lt_pred_stat[(frame_len * 2) + i] = 0; + } + } +} diff --git a/decoder/ixheaacd_lt_predict.h b/decoder/ixheaacd_lt_predict.h new file mode 100644 index 0000000..1600421 --- /dev/null +++ b/decoder/ixheaacd_lt_predict.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * * + * 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 _LT_PREDICT_ +#define _LT_PREDICT_ + +#define MAX_SFB 51 +#define MAX_LTP_SFB 40 + +enum { ltp_buffer_size = (4 * 1024) }; + +typedef struct { + UWORD8 last_band; + UWORD8 data_present; + UWORD16 lag; + UWORD8 lag_update; + UWORD8 coef; + UWORD8 long_used[MAX_SFB]; + UWORD8 short_used[8]; + UWORD8 short_lag_present[8]; + UWORD8 short_lag[8]; +} ltp_info; + +VOID ixheaacd_init_ltp_object(ltp_info *ltp); + +VOID ixheaacd_lt_update_state(WORD16 *lt_pred_stat, WORD16 *time, + WORD32 *overlap, WORD32 frame_len, + WORD32 object_type, WORD32 stride, + WORD16 window_sequence, WORD16 *p_window_next); + +VOID ixheaacd_filter_bank_ltp(ia_aac_dec_tables_struct *aac_tables_ptr, + WORD16 window_sequence, WORD16 win_shape, + WORD16 win_shape_prev, WORD32 *in_data, + WORD32 *out_mdct, UWORD32 object_type, + UWORD32 frame_len); + +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_main.h b/decoder/ixheaacd_main.h new file mode 100644 index 0000000..76a3b31 --- /dev/null +++ b/decoder/ixheaacd_main.h @@ -0,0 +1,230 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MAIN_H +#define IXHEAACD_MAIN_H + +VOID ixheaacd_imdct_flt(FLOAT32 in_data[], FLOAT32 out_data[], WORD32 len); + +VOID usac_tw_imdct(FLOAT32 in_data[], FLOAT32 out_data[], WORD32 len); + +WORD32 ixheaacd_window_calc(FLOAT32 window[], WORD32 len, WORD32 wfun_select); + +VOID calc_window_ratio(FLOAT32 window[], WORD32 len, WORD32 prev_len, + WORD32 wfun_select, WORD32 prev_wfun_select); + +WORD32 ixheaacd_tw_window_calc(FLOAT32 window[], WORD32 len, + WORD32 wfun_select); + +typedef struct ia_usac_lpd_decoder { + WORD32 mode_prev; + float synth_prev[MAX_PITCH + SYNTH_DELAY_LMAX]; + float xcitation_prev[MAX_PITCH + INTER_LP_FIL_ORDER + 1]; + int pitch_prev[NUM_SUBFR_SUPERFRAME_BY2 - 1]; + float gain_prev[NUM_SUBFR_SUPERFRAME_BY2 - 1]; + + float lp_flt_coeff_a_prev[2 * (ORDER + 1)]; + + FLOAT32 exc_prev[1 + (2 * FAC_LENGTH)]; + + FLOAT32 bpf_prev[FILTER_DELAY + LEN_SUBFR]; + + WORD32 ilspold[ORDER]; + + FLOAT32 fac_gain; + FLOAT32 fac_fd_data[FAC_LENGTH / 4]; + + FLOAT32 lsf_prev[ORDER]; + FLOAT32 lspold[ORDER]; + WORD32 lsfold_first[ORDER]; + + FLOAT32 gain_threshold; + + WORD32 fscale; + + FLOAT32 fd_synth_buf[3 * LEN_FRAME + 1 + ORDER]; + FLOAT32 *fd_synth; + WORD32 bpf_active_prev; + +} ia_usac_lpd_decoder, *ia_usac_lpd_decoder_handle; + +typedef struct ia_usac_data_main_struct { + FLOAT32 time_sample_vector[MAX_NUM_CHANNELS][4096]; + WORD32 input_data_ptr[MAX_NUM_CHANNELS][4096]; + WORD32 overlap_data_ptr[MAX_NUM_CHANNELS][4096]; + WORD32 output_data_ptr[MAX_NUM_CHANNELS][4096]; + + WORD32 window_shape[MAX_NUM_CHANNELS]; + WORD32 window_shape_prev[MAX_NUM_CHANNELS]; + WORD32 window_sequence[MAX_NUM_CHANNELS]; + WORD32 window_sequence_last[MAX_NUM_CHANNELS]; + + WORD32 output_samples; + WORD32 sbr_ratio_idx; + WORD32 usac_independency_flg; + + WORD32 sampling_rate_idx; + WORD32 audio_object_type; + + WORD32 down_samp_sbr; + WORD32 sbr_mode; + + WORD32 tw_mdct[MAX_ELEMENTS]; + WORD32 mps_pseudo_lr[MAX_ELEMENTS]; + WORD32 td_frame_prev[MAX_NUM_CHANNELS]; + + FLOAT32 warp_sum[MAX_NUM_CHANNELS][2]; + FLOAT32 warp_cont_mem[MAX_NUM_CHANNELS][3 * 1024]; + FLOAT32 prev_sample_pos[MAX_NUM_CHANNELS][3 * 1024]; + FLOAT32 prev_tw_trans_len[MAX_NUM_CHANNELS][2]; + WORD32 prev_tw_start_stop[MAX_NUM_CHANNELS][2]; + FLOAT32 prev_warped_time_sample_vector[MAX_NUM_CHANNELS][3 * 1024]; + + FLOAT32 lpc_prev[MAX_NUM_CHANNELS][ORDER + 1]; + FLOAT32 acelp_in[MAX_NUM_CHANNELS][1 + (2 * FAC_LENGTH)]; + + WORD32 alpha_q_re[MAX_SHORT_WINDOWS][SFB_NUM_MAX]; + WORD32 alpha_q_im[MAX_SHORT_WINDOWS][SFB_NUM_MAX]; + UWORD8 cplx_pred_used[MAX_SHORT_WINDOWS][SFB_NUM_MAX]; + + WORD32 alpha_q_re_prev[SFB_NUM_MAX]; + WORD32 alpha_q_im_prev[SFB_NUM_MAX]; + WORD32 dmx_re_prev[BLOCK_LEN_LONG]; + + VOID *sbr_scratch_mem_base; + + WORD32 *coef_fix[MAX_NUM_CHANNELS]; + FLOAT32 *coef[MAX_NUM_CHANNELS]; + UWORD8 *ms_used[MAX_NUM_CHANNELS]; + WORD32 *coef_save[chans]; + + WORD16 *factors[MAX_NUM_CHANNELS]; + UWORD8 *group_dis[MAX_NUM_CHANNELS]; + + WORD32 tw_data_present[MAX_NUM_CHANNELS]; + WORD32 *tw_ratio[MAX_NUM_CHANNELS]; + ia_tns_frame_info_struct *pstr_tns[MAX_NUM_CHANNELS]; + + ia_usac_lpd_decoder_handle str_tddec[MAX_NUM_CHANNELS]; + + WORD32 arith_prev_n[MAX_NUM_CHANNELS]; + WORD8 c_prev[MAX_NUM_CHANNELS][1024 / 2 + 4]; + WORD8 c[MAX_NUM_CHANNELS][1024 / 2 + 4]; + + WORD32 noise_filling_config[MAX_NUM_ELEMENTS]; + UWORD32 seed_value[MAX_NUM_CHANNELS]; + WORD32 present_chan; + + WORD32 fac_data_present[MAX_NUM_CHANNELS]; + WORD32 fac_data[MAX_NUM_CHANNELS][FAC_LENGTH + 1]; + + ia_sfb_info_struct *pstr_sfb_info[MAX_NUM_CHANNELS]; + ia_sfb_info_struct str_only_long_info; + ia_sfb_info_struct str_eight_short_info; + ia_sfb_info_struct *pstr_usac_winmap[NUM_WIN_SEQ]; + WORD16 sfb_width_short[(1 << LEN_MAX_SFBS)]; + + WORD32 ccfl; + WORD32 len_subfrm; + WORD32 num_subfrm; + + ia_handle_sbr_dec_inst_struct pstr_esbr_dec; + ia_aac_dec_sbr_bitstream_struct esbr_bit_str[2]; + + WORD32 x_ac_dec[1024]; + WORD32 scratch_buffer[1024]; + + FLOAT32 synth_buf[1883]; + FLOAT32 exc_buf[1453]; + FLOAT32 lp_flt_coff[290]; + WORD32 pitch[25]; + FLOAT32 pitch_gain[25]; + + UWORD16 *huffman_code_book_scl; + UWORD32 *huffman_code_book_scl_index; + + WORD32 *tns_coeff3_32; + + WORD32 *tns_coeff4_32; + + WORD32 (*tns_max_bands_tbl_usac)[16][2]; + + WORD16 sfb_width_long[(1 << LEN_MAX_SFBL)]; + WORD32 usac_flag; + + WORD32 arr_coef_fix[MAX_NUM_CHANNELS][(LN2 + LN2 / 8)]; + FLOAT32 arr_coef[MAX_NUM_CHANNELS][(LN2 + LN2 / 8)]; + WORD32 arr_coef_save[chans][(LN2 + LN2 / 8)]; + WORD16 arr_factors[MAX_NUM_CHANNELS][MAXBANDS]; + UWORD8 arr_group_dis[MAX_NUM_CHANNELS][NSHORT]; + WORD32 arr_tw_ratio[MAX_NUM_CHANNELS][NUM_TW_NODES]; + UWORD8 arr_ms_used[MAX_NUM_CHANNELS][MAXBANDS]; + ia_usac_lpd_decoder arr_str_tddec[MAX_NUM_CHANNELS]; + ia_tns_frame_info_struct arr_str_tns[MAX_NUM_CHANNELS]; + +} ia_usac_data_struct; + +VOID ixheaacd_tns_apply(ia_usac_data_struct *usac_data, WORD32 *spec, + WORD32 nbands, ia_sfb_info_struct *pstr_sfb_info, + ia_tns_frame_info_struct *pstr_tns); + +WORD32 ixheaacd_calc_max_spectral_line_dec(WORD32 *ptr_tmp, WORD32 size); + +WORD32 ixheaacd_calc_max_spectral_line_armv7(WORD32 *ptr_tmp, WORD32 size); + +WORD32 ixheaacd_calc_max_spectral_line_armv8(WORD32 *ptr_tmp, WORD32 size); + +WORD32 ixheaacd_tw_buff_update(ia_usac_data_struct *usac_data, WORD32 i, + ia_usac_lpd_decoder_handle st); + +VOID ixheaacd_fix2flt_data(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, WORD32 k); + +VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k, WORD32 mod0); + +WORD32 ixheaacd_tw_frame_dec(ia_usac_data_struct *usac_data, WORD32 i_ch, + FLOAT32 sample_pos[], FLOAT32 tw_trans_len[], + WORD32 tw_start_stop[]); + +WORD32 ixheaacd_fd_frm_dec(ia_usac_data_struct *usac_data, WORD32 i_ch); + +WORD32 ixheaacd_acelp_mdct(WORD32 *ptr_in, WORD32 *ptr_out, WORD32 *preshift, + WORD32 length, WORD32 *ptr_scratch); + +WORD32 ixheaacd_acelp_mdct_main(ia_usac_data_struct *usac_data, WORD32 *x, + WORD32 *y, WORD32 l, WORD32 m, + WORD32 *preshift); + +WORD32 ixheaacd_fr_alias_cnx_fix(WORD32 *x_in, WORD32 len_subfr, WORD32 lfac, + WORD32 *iaq, WORD32 *izir, WORD32 *ifacdec, + WORD8 *qshift1, WORD8 qshift2, WORD8 qshift3, + WORD32 *preshift, WORD32 *ptr_scratch); + +WORD32 ixheaacd_fwd_alias_cancel_tool( + ia_usac_data_struct *usac_data, ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 fac_length, FLOAT32 *iaq, WORD32 gain); + +VOID ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short, + FLOAT32 out_buffer[], ia_usac_lpd_decoder_handle st); + +VOID ixheaacd_reset_acelp_data_fix(ia_usac_data_struct *usac_data, + ia_usac_lpd_decoder_handle st, + WORD32 *ptr_ola_buff, WORD32 last_was_short, + WORD32 tw_mdct); +#endif diff --git a/decoder/ixheaacd_memory_standards.h b/decoder/ixheaacd_memory_standards.h new file mode 100644 index 0000000..b733e9d --- /dev/null +++ b/decoder/ixheaacd_memory_standards.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MEMORY_STANDARDS_H +#define IXHEAACD_MEMORY_STANDARDS_H + +/*****************************************************************************/ +/* type definitions */ +/*****************************************************************************/ +/* standard memory table descriptor for libraries */ +typedef struct { + UWORD32 ui_size; /* size of the memory in bytes */ + UWORD32 ui_alignment; /* alignment in bytes */ + UWORD32 ui_type; /* type of memory */ + UWORD32 ui_placement[2]; /* 64 bit placement info */ + UWORD32 ui_priority; /* the importance for placement */ + UWORD32 ui_placed[2]; /* the o_red location for placement */ +} ia_mem_info_struct; + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +/* when you don't need alignment, pass this to memory library */ +#define IA_MEM_NO_ALIGN 0x01 + +/* ittiam standard memory types */ +/* to be used inter frames */ +#define IA_MEMTYPE_PERSIST 0x00 +/* read write, to be used intra frames */ +#define IA_MEMTYPE_SCRATCH 0x01 +/* read only memory, intra frame */ +#define IA_MEMTYPE_INPUT 0x02 +/* read-write memory, for usable output, intra frame */ +#define IA_MEMTYPE_OUTPUT 0x03 +/* readonly memory, inter frame */ +#define IA_MEMTYPE_TABLE 0x04 +/* input buffer before mem tabs allocation */ +#define IA_MEMTYPE_PRE_FRAME_INPUT 0x05 +/* input buffer before mem tabs allocation */ +#define IA_MEMTYPE_PRE_FRAME_SCRATCH 0x06 +/* for local variables */ +#define IA_MEMTYPE_AUTO_VAR 0x80 + +/* ittiam standard memory priorities */ +#define IA_MEMPRIORITY_ANYWHERE 0x00 +#define IA_MEMPRIORITY_LOWEST 0x01 +#define IA_MEMPRIORITY_LOW 0x02 +#define IA_MEMPRIORITY_NORM 0x03 +#define IA_MEMPRIORITY_ABOVE_NORM 0x04 +#define IA_MEMPRIORITY_HIGH 0x05 +#define IA_MEMPRIORITY_HIGHER 0x06 +#define IA_MEMPRIORITY_CRITICAL 0x07 + +/* ittiam standard memory placements */ +/* placement is defined by 64 bits */ + +#define IA_MEMPLACE_FAST_RAM_0 0x000001 +#define IA_MEMPLACE_FAST_RAM_1 0x000002 +#define IA_MEMPLACE_FAST_RAM_2 0x000004 +#define IA_MEMPLACE_FAST_RAM_3 0x000008 +#define IA_MEMPLACE_FAST_RAM_4 0x000010 +#define IA_MEMPLACE_FAST_RAM_5 0x000020 +#define IA_MEMPLACE_FAST_RAM_6 0x000040 +#define IA_MEMPLACE_FAST_RAM_7 0x000080 + +#define IA_MEMPLACE_INT_RAM_0 0x000100 +#define IA_MEMPLACE_INT_RAM_1 0x000200 +#define IA_MEMPLACE_INT_RAM_2 0x000400 +#define IA_MEMPLACE_INT_RAM_3 0x000800 +#define IA_MEMPLACE_INT_RAM_4 0x001000 +#define IA_MEMPLACE_INT_RAM_5 0x002000 +#define IA_MEMPLACE_INT_RAM_6 0x004000 +#define IA_MEMPLACE_INT_RAM_7 0x008000 + +#define IA_MEMPLACE_EXT_RAM_0 0x010000 +#define IA_MEMPLACE_EXT_RAM_1 0x020000 +#define IA_MEMPLACE_EXT_RAM_2 0x040000 +#define IA_MEMPLACE_EXT_RAM_3 0x080000 +#define IA_MEMPLACE_EXT_RAM_4 0x100000 +#define IA_MEMPLACE_EXT_RAM_5 0x200000 +#define IA_MEMPLACE_EXT_RAM_6 0x400000 +#define IA_MEMPLACE_EXT_RAM_7 0x800000 + +#define IA_MEMPLACE_DONTCARE_H 0xFFFFFFFF +#define IA_MEMPLACE_DONTCARE_L 0xFFFFFFFF + +/* the simple common PC RAM */ +#define IA_PC_RAM_H 0x00000000 +#define IA_PC_RAM_L IA_MEMPLACE_EXT_RAM_0 + +#endif /* IXHEAACD_MEMORY_STANDARDS_H */ diff --git a/decoder/ixheaacd_mps_dec.c b/decoder/ixheaacd_mps_dec.c new file mode 100644 index 0000000..8ef7458 --- /dev/null +++ b/decoder/ixheaacd_mps_dec.c @@ -0,0 +1,1522 @@ +/****************************************************************************** + * * + * 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 +#include + +#include + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_common_rom.h" +#include +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" + +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_audioobjtypes.h" +#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_mps_interface.h" +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_config.h" +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_process.h" +#include "ixheaacd_mps_decor.h" +#include "ixheaacd_mps_hybfilter.h" +#include "ixheaacd_mps_nlc_dec.h" +#include "ixheaacd_mps_huff_tab.h" + +#include "math.h" + +#include +#include + +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; + +ia_mps_dec_state_struct* ixheaacd_mps_create( + WORD32 bs_frame_len, WORD32 residual_coding, + ia_usac_dec_mps_config_struct* mps212_config) { + WORD32 num_ch; + WORD32 err_code = 0; + + ia_mps_dec_state_struct* self = NULL; + ia_mps_bs_frame bs_frame; + + self = (ia_mps_dec_state_struct*)calloc(1, sizeof(ia_mps_dec_state_struct)); + if (self == NULL) return 0; + + self->num_parameter_sets = 1; + self->qmf_band_count = 64; + + if (mps212_config) { + self->config = mps212_config; + self->frame_length = bs_frame_len; + self->in_ch_count = 1; + self->out_ch_count = 2; + self->residual_coding = residual_coding; + if (self->residual_coding) { + self->bs_residual_present = 1; + self->bs_residual_bands = mps212_config->bs_residual_bands; + if (self->config->bs_phase_coding) { + self->config->bs_phase_coding = 2; + } + } + } + + err_code = ixheaacd_mps_header_decode(self); + + if (err_code == -1) { + free(self); + return 0; + } + + if ((self->residual_coding) && (self->res_bands > 0)) self->res_ch_count++; + + ixheaacd_mps_env_init(self); + + ixheaacd_mps_synt_create(&self->poly_phase_filt_kernel, self->qmf_band_count); + + for (num_ch = 0; num_ch < self->out_ch_count; num_ch++) { + ixheaacd_mps_synt_init(&self->qmf_filt_state[num_ch]); + } + + ixheaacd_mps_qmf_hybrid_analysis_init(&self->hyb_filt_state[0]); + + 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); + + ixheaacd_mps_init_pre_and_post_matrix(self); + + self->parse_nxt_frame = 1; + + bs_frame = self->bs_frame; + memset(bs_frame.cld_idx_pre, 0, MAX_PARAMETER_BANDS * sizeof(WORD32)); + memset(bs_frame.icc_idx_pre, 0, MAX_PARAMETER_BANDS * sizeof(WORD32)); + memset(bs_frame.cmp_cld_idx_prev, 0, MAX_PARAMETER_BANDS * sizeof(WORD32)); + memset(bs_frame.cmp_icc_idx_prev, 0, MAX_PARAMETER_BANDS * sizeof(WORD32)); + + self->subband_var.init_flag = 0; + self->subband_var.update_old_ener = 0; + self->subband_var.nrg_dir = 0; + memset(self->subband_var.nrg_diff, 0, 2 * sizeof(FLOAT32)); + + memset(self->opd_smooth.smooth_l_phase, 0, + MAX_PARAMETER_BANDS * sizeof(WORD32)); + memset(self->opd_smooth.smooth_r_phase, 0, + MAX_PARAMETER_BANDS * sizeof(WORD32)); + + return self; +} + +static 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[] = { + 0.0f, 0.707106781186548f, 1.0f, 0.707106781186548f, + 0.0f, -0.707106781186548f, -1.0f, -0.707106781186548f}; + +VOID ixheaacd_mps_qmf_hyb_analysis(ia_mps_dec_state_struct* self) { + ixheaacd_mps_qmf_hybrid_analysis(&self->hyb_filt_state[0], self->qmf_in[0], + self->qmf_band_count, self->time_slots, + self->hyb_in[0]); + + if ((self->residual_coding) && (self->res_bands > 0)) { + ixheaacd_mps_qmf_hybrid_analysis(&self->hyb_filt_state[self->in_ch_count], + self->qmf_in[1], self->qmf_band_count, + self->time_slots, self->hyb_res); + } +} + +VOID ixheaacd_mps_qmf_hyb_synthesis(ia_mps_dec_state_struct* self) { + WORD32 ch; + + for (ch = 0; ch < self->out_ch_count; ch++) { + ixheaacd_mps_qmf_hybrid_synthesis(self->hyb_dir_out[ch], + self->qmf_band_count, self->time_slots, + self->qmf_out_dir[ch]); + } +} + +VOID ixheaacd_mps_decor(ia_mps_dec_state_struct* self) { + WORD32 k, sb_sample, idx; + + ia_cmplx_flt_struct(*scratch)[MAX_HYBRID_BANDS_MPS]; + + ia_cmplx_flt_struct coeff; + WORD32 band_start = 7; + + scratch = self->scratch; + + for (k = self->dir_sig_count; k < self->dir_sig_count + self->decor_sig_count; + k++) { + if (self->bs_tsd_enable) { + for (sb_sample = 0; sb_sample < self->time_slots; sb_sample++) { + if (self->bs_tsd_sep_data[sb_sample]) { + for (idx = band_start; idx < self->mps_decor.num_bins; idx++) { + scratch[sb_sample][idx].re = self->v[k][sb_sample][idx].re; + scratch[sb_sample][idx].im = self->v[k][sb_sample][idx].im; + self->v[k][sb_sample][idx].re = 0.0f; + self->v[k][sb_sample][idx].im = 0.0f; + } + } + } + } + + ixheaacd_mps_decor_apply(&self->mps_decor, self->v[k], self->w_diff[k], + self->time_slots); + + if (self->bs_tsd_enable) { + for (sb_sample = 0; sb_sample < self->time_slots; sb_sample++) { + if (self->bs_tsd_sep_data[sb_sample]) { + coeff.re = ixheaacd_tsd_mul_re[self->bs_tsd_tr_phase_data[sb_sample]]; + coeff.im = ixheaacd_tsd_mul_im[self->bs_tsd_tr_phase_data[sb_sample]]; + + for (idx = band_start; idx < self->mps_decor.num_bins; idx++) { + self->w_diff[k][sb_sample][idx].re += + coeff.re * scratch[sb_sample][idx].re - + coeff.im * scratch[sb_sample][idx].im; + self->w_diff[k][sb_sample][idx].im += + coeff.im * scratch[sb_sample][idx].re + + coeff.re * scratch[sb_sample][idx].im; + } + } + } + } + } +} + +VOID ixheaacd_mps_mix_res_decor(ia_mps_dec_state_struct* self) { + WORD32 ts, qs, row, indx; + + for (ts = 0; ts < self->time_slots; ts++) { + for (qs = 0; qs < self->hyb_band_count; qs++) { + indx = self->hyb_band_to_processing_band_table[qs]; + + for (row = 0; row < self->dir_sig_count; row++) { + self->w_dir[row][ts][qs].re = self->v[row][ts][qs].re; + self->w_dir[row][ts][qs].im = self->v[row][ts][qs].im; + } + + for (row = self->dir_sig_count; + row < (self->dir_sig_count + self->decor_sig_count); row++) { + if (indx < self->res_bands) { + self->w_dir[row][ts][qs].re = self->hyb_res[ts][qs].re; + self->w_dir[row][ts][qs].im = self->hyb_res[ts][qs].im; + } else { + self->w_dir[row][ts][qs].re = 0.0f; + self->w_dir[row][ts][qs].im = 0.0f; + } + } + + for (row = 0; row < self->dir_sig_count; row++) { + self->w_diff[row][ts][qs].re = 0.0f; + self->w_diff[row][ts][qs].im = 0.0f; + } + + for (row = self->dir_sig_count; + row < (self->dir_sig_count + self->decor_sig_count); row++) { + if (indx < self->res_bands) { + self->w_diff[row][ts][qs].re = 0.0f; + self->w_diff[row][ts][qs].im = 0.0f; + } + } + } + } +} + +VOID ixheaacd_mps_create_w(ia_mps_dec_state_struct* self) { + ixheaacd_mps_decor(self); + ixheaacd_mps_mix_res_decor(self); +} +VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, + FLOAT32** input_buffer[4], + FLOAT32 (*output_buffer)[4096]) { + WORD32 ch, ts, qs; + WORD32 time_slots = self->time_slots; + WORD32 in_ch_count = self->in_ch_count + self->res_ch_count; + + self->output_buffer = output_buffer; + + assert(self->present_time_slot + time_slots <= self->time_slots); + + for (ts = 0; ts < time_slots; ts++) { + for (ch = 0; ch < in_ch_count; ch++) { + for (qs = 0; qs < self->qmf_band_count; qs++) { + self->qmf_in[ch][self->present_time_slot + ts][qs].re = + self->input_gain * input_buffer[2 * ch][ts][qs]; + self->qmf_in[ch][self->present_time_slot + ts][qs].im = + self->input_gain * input_buffer[2 * ch + 1][ts][qs]; + } + } + } + + self->present_time_slot += time_slots; + + if (self->present_time_slot < self->time_slots) return; + + self->present_time_slot = 0; + + ixheaacd_mps_frame_decode(self); + + ixheaacd_mps_qmf_hyb_analysis(self); + + ixheaacd_pre_and_mix_matrix_calculation(self); + + ixheaacd_mps_pre_matrix_mix_matrix_smoothing(self); + + ixheaacd_mps_apply_pre_matrix(self); + + ixheaacd_mps_create_w(self); + + ixheaacd_mps_apply_mix_matrix(self); + + if (self->config->bs_temp_shape_config == 2) { + ixheaacd_mps_time_env_shaping(self); + } + + ixheaacd_mps_temp_process(self); + + self->parse_nxt_frame = 1; +} + +#define min(a, b) (((a) < (b)) ? (a) : (b)) + +static WORD32 ixheaacd_mps_pcm_decode(ia_handle_bit_buf_struct it_bit_buff, + WORD32* out_data_1, WORD32* out_data_2, + WORD32 ixheaacd_drc_offset, + WORD32 num_val, WORD32 num_levels) { + WORD32 i = 0, j = 0, idx = 0; + WORD32 max_grp_len = 0, grp_len = 0, next_val = 0, grp_val = 0; + UWORD32 data = 0; + + FLOAT32 ld_nlev = 0.f; + + WORD32 pcm_chunk_size[7] = {0}; + + switch (num_levels) { + case 3: + max_grp_len = 5; + break; + case 7: + max_grp_len = 6; + break; + case 11: + max_grp_len = 2; + break; + case 13: + max_grp_len = 4; + break; + case 19: + max_grp_len = 4; + break; + case 25: + max_grp_len = 3; + break; + case 51: + max_grp_len = 4; + break; + case 4: + case 8: + case 15: + case 16: + case 26: + case 31: + max_grp_len = 1; + break; + default: + assert(0); + } + + ld_nlev = (FLOAT32)(log((FLOAT32)num_levels) / log(2.f)); + + for (i = 1; i <= max_grp_len; i++) { + pcm_chunk_size[i] = (WORD32)ceil((FLOAT32)(i)*ld_nlev); + } + + for (i = 0; i < num_val; i += max_grp_len) { + grp_len = min(max_grp_len, num_val - i); + data = ixheaacd_read_bits_buf(it_bit_buff, pcm_chunk_size[grp_len]); + + grp_val = data; + + for (j = 0; j < grp_len; j++) { + idx = i + (grp_len - j - 1); + next_val = grp_val % num_levels; + + if (out_data_2 == NULL) { + out_data_1[idx] = next_val - ixheaacd_drc_offset; + } else if (out_data_1 == NULL) { + out_data_2[idx] = next_val - ixheaacd_drc_offset; + } else { + if (idx % 2) { + out_data_2[idx / 2] = next_val - ixheaacd_drc_offset; + } else { + out_data_1[idx / 2] = next_val - ixheaacd_drc_offset; + } + } + + grp_val = (grp_val - next_val) / num_levels; + } + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_read(ia_handle_bit_buf_struct it_bit_buff, + const WORD32 (*node_tab)[][2], + WORD32* out_data) { + WORD32 node = 0; + UWORD32 next_bit = 0; + + do { + next_bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + node = (*node_tab)[node][next_bit]; + } while (node > 0); + + *out_data = node; + + return 1; +} + +static WORD32 ixheaacd_mps_huff_read_2d(ia_handle_bit_buf_struct it_bit_buff, + const WORD32 (*node_tab)[][2], + WORD32 out_data[2], WORD32* escape) + +{ + WORD32 huff_2d_8bit = 0; + WORD32 node = 0; + + if (!ixheaacd_mps_huff_read(it_bit_buff, node_tab, &node)) return 0; + *escape = (node == 0); + + if (*escape) { + out_data[0] = 0; + out_data[1] = 1; + } else { + huff_2d_8bit = -(node + 1); + out_data[0] = huff_2d_8bit >> 4; + out_data[1] = huff_2d_8bit & 0xf; + } + + return 1; +} + +static WORD32 ixheaacd_mps_sym_restore(ia_handle_bit_buf_struct it_bit_buff, + WORD32 lav, WORD32 data[2]) { + WORD32 tmp = 0; + UWORD32 sym_bit = 0; + + WORD32 sum_val = data[0] + data[1]; + WORD32 diff_val = data[0] - data[1]; + + if (sum_val > lav) { + data[0] = -sum_val + (2 * lav + 1); + data[1] = -diff_val; + } else { + data[0] = sum_val; + data[1] = diff_val; + } + + if (data[0] + data[1] != 0) { + sym_bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (sym_bit) { + data[0] = -data[0]; + data[1] = -data[1]; + } + } + + if (data[0] - data[1] != 0) { + sym_bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (sym_bit) { + tmp = data[0]; + data[0] = data[1]; + data[1] = tmp; + } + } + + return 1; +} + +static WORD32 ixheaacd_mps_sym_restoreipd(ia_handle_bit_buf_struct it_bit_buff, + WORD32 lav, WORD32 data[2]) { + WORD32 tmp = 0; + UWORD32 sym_bit = 0; + + WORD32 sum_val = data[0] + data[1]; + WORD32 diff_val = data[0] - data[1]; + + if (sum_val > lav) { + data[0] = -sum_val + (2 * lav + 1); + data[1] = -diff_val; + } else { + data[0] = sum_val; + data[1] = diff_val; + } + + if (data[0] - data[1] != 0) { + sym_bit = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (sym_bit) { + tmp = data[0]; + data[0] = data[1]; + data[1] = tmp; + } + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_pilot(ia_handle_bit_buf_struct it_bit_buff, + const WORD32 (*node_tab)[][2], + WORD32* pilot_data) { + WORD32 node = 0; + + if (!ixheaacd_mps_huff_read(it_bit_buff, node_tab, &node)) return 0; + *pilot_data = -(node + 1); + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_cld_1d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_cld_node_1d_struct* huff_nodes, WORD32* out_data, + WORD32 num_val, WORD32 p0_flag) { + WORD32 i = 0, node = 0, ixheaacd_drc_offset = 0; + WORD32 od = 0, od_sign = 0; + UWORD32 data = 0; + + if (p0_flag) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.cld, + &node)) + return 0; + out_data[0] = -(node + 1); + ixheaacd_drc_offset = 1; + } + + for (i = ixheaacd_drc_offset; i < num_val; i++) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&huff_nodes->node_tab, &node)) + return 0; + od = -(node + 1); + + if (od != 0) { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + od_sign = data; + + if (od_sign) od = -od; + } + + out_data[i] = od; + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_ipd_1d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_ipd_node_1d_struct* huff_nodes, WORD32* out_data, + WORD32 num_val, WORD32 p0_flag) { + WORD32 i = 0, node = 0, ixheaacd_drc_offset = 0; + WORD32 od = 0; + + if (p0_flag) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_ipd_nodes.hp0.node_tab, &node)) + return 0; + out_data[0] = -(node + 1); + ixheaacd_drc_offset = 1; + } + + for (i = ixheaacd_drc_offset; i < num_val; i++) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&huff_nodes->node_tab, &node)) + return 0; + od = -(node + 1); + out_data[i] = od; + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_icc_1d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_icc_node_1d_struct* huff_nodes, WORD32* out_data, + WORD32 num_val, WORD32 p0_flag) { + WORD32 i = 0, node = 0, ixheaacd_drc_offset = 0; + WORD32 od = 0, od_sign = 0; + UWORD32 data = 0; + + if (p0_flag) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.icc, + &node)) + return 0; + out_data[0] = -(node + 1); + ixheaacd_drc_offset = 1; + } + + for (i = ixheaacd_drc_offset; i < num_val; i++) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&huff_nodes->node_tab, &node)) + return 0; + od = -(node + 1); + + if (od != 0) { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + od_sign = data; + + if (od_sign) od = -od; + } + + out_data[i] = od; + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_cld_2d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_cld_node_2d_struct* huff_nodes, WORD32 out_data[][2], + WORD32 num_val, WORD32 ch_fac, WORD32* p0_data[2]) { + WORD32 i = 0, lav = 0, escape = 0, esc_contrl = 0; + WORD32 node = 0; + UWORD32 data = 0; + + WORD32 esc_data[MAXBANDS][2] = {{0}}; + WORD32 esc_idx[MAXBANDS] = {0}; + + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_lav_idx_nodes.node_tab, &node)) + return 0; + data = -(node + 1); + + lav = 2 * data + 3; + + if (p0_data[0] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.cld, + &node)) + return 0; + *p0_data[0] = -(node + 1); + } + if (p0_data[1] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.cld, + &node)) + return 0; + *p0_data[1] = -(node + 1); + } + + for (i = 0; i < num_val; i += ch_fac) { + switch (lav) { + case 3: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav3, + out_data[i], &escape)) + return 0; + break; + case 5: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav5, + out_data[i], &escape)) + return 0; + break; + case 7: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav7, + out_data[i], &escape)) + return 0; + break; + case 9: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav9, + out_data[i], &escape)) + return 0; + break; + default: + break; + } + + if (escape) { + esc_idx[esc_contrl++] = i; + } else { + if (!ixheaacd_mps_sym_restore(it_bit_buff, lav, out_data[i])) return 0; + } + } + + if (esc_contrl > 0) { + if (!ixheaacd_mps_pcm_decode(it_bit_buff, esc_data[0], esc_data[1], 0, + 2 * esc_contrl, (2 * lav + 1))) + return 0; + + for (i = 0; i < esc_contrl; i++) { + out_data[esc_idx[i]][0] = esc_data[0][i] - lav; + out_data[esc_idx[i]][1] = esc_data[1][i] - lav; + } + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_icc_2d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_icc_node_2d_struct* huff_nodes, WORD32 out_data[][2], + WORD32 num_val, WORD32 ch_fac, WORD32* p0_data[2]) { + WORD32 i = 0, lav = 0, escape = 0, esc_contrl = 0; + WORD32 node = 0; + UWORD32 data = 0; + + WORD32 esc_data[2][MAXBANDS] = {{0}}; + WORD32 esc_idx[MAXBANDS] = {0}; + + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_lav_idx_nodes.node_tab, &node)) + return 0; + data = -(node + 1); + + lav = 2 * data + 1; + + if (p0_data[0] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.icc, + &node)) + return 0; + *p0_data[0] = -(node + 1); + } + if (p0_data[1] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_part0_nodes.icc, + &node)) + return 0; + *p0_data[1] = -(node + 1); + } + + for (i = 0; i < num_val; i += ch_fac) { + switch (lav) { + case 1: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav1, + out_data[i], &escape)) + return 0; + break; + case 3: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav3, + out_data[i], &escape)) + return 0; + break; + case 5: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav5, + out_data[i], &escape)) + return 0; + break; + case 7: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav7, + out_data[i], &escape)) + return 0; + break; + } + + if (escape) { + esc_idx[esc_contrl++] = i; + } else { + if (!ixheaacd_mps_sym_restore(it_bit_buff, lav, out_data[i])) return 0; + } + } + + if (esc_contrl > 0) { + if (!ixheaacd_mps_pcm_decode(it_bit_buff, esc_data[0], esc_data[1], 0, + 2 * esc_contrl, (2 * lav + 1))) + return 0; + + for (i = 0; i < esc_contrl; i++) { + out_data[esc_idx[i]][0] = esc_data[0][i] - lav; + out_data[esc_idx[i]][1] = esc_data[1][i] - lav; + } + } + + return 1; +} + +static WORD32 ixheaacd_mps_huff_dec_ipd_2d( + ia_handle_bit_buf_struct it_bit_buff, + const ia_huff_ipd_node_2d_struct* huff_nodes, WORD32 out_data[][2], + WORD32 num_val, WORD32 ch_fac, WORD32* p0_data[2]) { + WORD32 i = 0, lav = 0, escape = 0, esc_contrl = 0; + WORD32 node = 0; + UWORD32 data = 0; + + WORD32 esc_data[2][MAXBANDS] = {{0}}; + WORD32 esc_idx[MAXBANDS] = {0}; + + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_lav_idx_nodes.node_tab, &node)) + return 0; + + data = -(node + 1); + if (data == 0) + data = 3; + else + data--; + + lav = 2 * data + 1; + + if (p0_data[0] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_ipd_nodes.hp0.node_tab, &node)) + return 0; + *p0_data[0] = -(node + 1); + } + if (p0_data[1] != NULL) { + if (!ixheaacd_mps_huff_read( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_ipd_nodes.hp0.node_tab, &node)) + return 0; + *p0_data[1] = -(node + 1); + } + + for (i = 0; i < num_val; i += ch_fac) { + switch (lav) { + case 1: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav1, + out_data[i], &escape)) + return 0; + break; + case 3: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav3, + out_data[i], &escape)) + return 0; + break; + case 5: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav5, + out_data[i], &escape)) + return 0; + break; + case 7: + if (!ixheaacd_mps_huff_read_2d(it_bit_buff, + (ia_huff_node_struct)&huff_nodes->lav7, + out_data[i], &escape)) + return 0; + break; + } + + if (escape) { + esc_idx[esc_contrl++] = i; + } else { + if (!ixheaacd_mps_sym_restoreipd(it_bit_buff, lav, out_data[i])) return 0; + } + } + + if (esc_contrl > 0) { + if (!ixheaacd_mps_pcm_decode(it_bit_buff, esc_data[0], esc_data[1], 0, + 2 * esc_contrl, (2 * lav + 1))) + return 0; + + for (i = 0; i < esc_contrl; i++) { + out_data[esc_idx[i]][0] = esc_data[0][i] - lav; + out_data[esc_idx[i]][1] = esc_data[1][i] - lav; + } + } + + return 1; +} + +static WORD32 ixheaacd_huff_decode(ia_handle_bit_buf_struct it_bit_buff, + WORD32* out_data_1, WORD32* out_data_2, + WORD32 data_type, WORD32 diff_type_1, + WORD32 diff_type_2, WORD32 pilot_coding_flag, + WORD32* pilot_data, WORD32 num_val, + WORD32* cdg_scheme) { + WORD32 diff_type; + + WORD32 i = 0; + UWORD32 data = 0; + + WORD32 pair_vec[MAXBANDS][2]; + + WORD32* p0_data_1[2] = {NULL, NULL}; + WORD32* p0_data_2[2] = {NULL, NULL}; + + WORD32 p0_flag[2]; + + WORD32 num_val_1_int = num_val; + WORD32 num_val_2_int = num_val; + + WORD32* out_data_1_int = out_data_1; + WORD32* out_data_2_int = out_data_2; + + WORD32 df_rest_flag_1 = 0; + WORD32 df_rest_flag_2 = 0; + + WORD32 huff_yy_1; + WORD32 huff_yy_2; + WORD32 huff_yy; + + if (pilot_coding_flag) { + switch (data_type) { + case CLD: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_pilot( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_pilot_nodes.cld, + pilot_data)) + return 0; + } + break; + + case ICC: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_pilot( + it_bit_buff, + (ia_huff_node_struct)&ixheaacd_huff_pilot_nodes.icc, + pilot_data)) + return 0; + } + break; + + default: + if (out_data_1 != NULL) { + return 0; + } + break; + } + } + + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + *cdg_scheme = data << PAIR_SHIFT; + + if (*cdg_scheme >> PAIR_SHIFT == HUFF_2D) { + if ((out_data_1 != NULL) && (out_data_2 != NULL)) { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + *cdg_scheme |= data; + } else { + *cdg_scheme |= FREQ_PAIR; + } + } + + if (pilot_coding_flag) { + huff_yy_1 = PCM_PLT; + huff_yy_2 = PCM_PLT; + } else { + huff_yy_1 = diff_type_1; + huff_yy_2 = diff_type_2; + } + + switch (*cdg_scheme >> PAIR_SHIFT) { + case HUFF_1D: + + p0_flag[0] = (diff_type_1 == DIFF_FREQ) && !pilot_coding_flag; + p0_flag[1] = (diff_type_2 == DIFF_FREQ) && !pilot_coding_flag; + + switch (data_type) { + case CLD: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_cld_1d( + it_bit_buff, &ixheaacd_huff_cld_nodes.h_1_dim[huff_yy_1], + out_data_1, num_val_1_int, p0_flag[0])) + return 0; + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_cld_1d( + it_bit_buff, &ixheaacd_huff_cld_nodes.h_1_dim[huff_yy_2], + out_data_2, num_val_2_int, p0_flag[1])) + return 0; + } + + break; + + case ICC: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_icc_1d( + it_bit_buff, &ixheaacd_huff_icc_nodes.h_1_dim[huff_yy_1], + out_data_1, num_val_1_int, p0_flag[0])) + return 0; + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_icc_1d( + it_bit_buff, &ixheaacd_huff_icc_nodes.h_1_dim[huff_yy_2], + out_data_2, num_val_2_int, p0_flag[1])) + return 0; + } + + break; + + case IPD: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_ipd_1d( + it_bit_buff, &ixheaacd_huff_ipd_nodes.h_1_dim[huff_yy_1], + out_data_1, num_val_1_int, p0_flag[0])) + return 0; + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_ipd_1d( + it_bit_buff, &ixheaacd_huff_ipd_nodes.h_1_dim[huff_yy_2], + out_data_2, num_val_2_int, p0_flag[1])) + return 0; + } + + break; + + default: + break; + } + + break; + + case HUFF_2D: + + switch (*cdg_scheme & PAIR_MASK) { + case FREQ_PAIR: + + if (out_data_1 != NULL) { + if (!pilot_coding_flag && diff_type_1 == DIFF_FREQ) { + p0_data_1[0] = &out_data_1[0]; + p0_data_1[1] = NULL; + + num_val_1_int -= 1; + out_data_1_int += 1; + } + df_rest_flag_1 = num_val_1_int % 2; + if (df_rest_flag_1) num_val_1_int -= 1; + } + if (out_data_2 != NULL) { + if (!pilot_coding_flag && diff_type_2 == DIFF_FREQ) { + p0_data_2[0] = NULL; + p0_data_2[1] = &out_data_2[0]; + + num_val_2_int -= 1; + out_data_2_int += 1; + } + df_rest_flag_2 = num_val_2_int % 2; + if (df_rest_flag_2) num_val_2_int -= 1; + } + + switch (data_type) { + case CLD: + + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_cld_2d( + it_bit_buff, + &ixheaacd_huff_cld_nodes.h_2_dim[huff_yy_1][FREQ_PAIR], + pair_vec, num_val_1_int, 2, p0_data_1)) + return 0; + if (df_rest_flag_1) { + if (!ixheaacd_mps_huff_dec_cld_1d( + it_bit_buff, + &ixheaacd_huff_cld_nodes.h_1_dim[huff_yy_1], + out_data_1_int + num_val_1_int, 1, 0)) + return 0; + } + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_cld_2d( + it_bit_buff, + &ixheaacd_huff_cld_nodes.h_2_dim[huff_yy_2][FREQ_PAIR], + pair_vec + 1, num_val_2_int, 2, p0_data_2)) + return 0; + if (df_rest_flag_2) { + if (!ixheaacd_mps_huff_dec_cld_1d( + it_bit_buff, + &ixheaacd_huff_cld_nodes.h_1_dim[huff_yy_2], + out_data_2_int + num_val_2_int, 1, 0)) + return 0; + } + } + break; + + case ICC: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_icc_2d( + it_bit_buff, + &ixheaacd_huff_icc_nodes.h_2_dim[huff_yy_1][FREQ_PAIR], + pair_vec, num_val_1_int, 2, p0_data_1)) + return 0; + if (df_rest_flag_1) { + if (!ixheaacd_mps_huff_dec_icc_1d( + it_bit_buff, + &ixheaacd_huff_icc_nodes.h_1_dim[huff_yy_1], + out_data_1_int + num_val_1_int, 1, 0)) + return 0; + } + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_icc_2d( + it_bit_buff, + &ixheaacd_huff_icc_nodes.h_2_dim[huff_yy_2][FREQ_PAIR], + pair_vec + 1, num_val_2_int, 2, p0_data_2)) + return 0; + if (df_rest_flag_2) { + if (!ixheaacd_mps_huff_dec_icc_1d( + it_bit_buff, + &ixheaacd_huff_icc_nodes.h_1_dim[huff_yy_2], + out_data_2_int + num_val_2_int, 1, 0)) + return 0; + } + } + break; + + case IPD: + if (out_data_1 != NULL) { + if (!ixheaacd_mps_huff_dec_ipd_2d( + it_bit_buff, + &ixheaacd_huff_ipd_nodes.h_2_dim[huff_yy_1][FREQ_PAIR], + pair_vec, num_val_1_int, 2, p0_data_1)) + return 0; + if (df_rest_flag_1) { + if (!ixheaacd_mps_huff_dec_ipd_1d( + it_bit_buff, + &ixheaacd_huff_ipd_nodes.h_1_dim[huff_yy_1], + out_data_1_int + num_val_1_int, 1, 0)) + return 0; + } + } + if (out_data_2 != NULL) { + if (!ixheaacd_mps_huff_dec_ipd_2d( + it_bit_buff, + &ixheaacd_huff_ipd_nodes.h_2_dim[huff_yy_2][FREQ_PAIR], + pair_vec + 1, num_val_2_int, 2, p0_data_2)) + return 0; + if (df_rest_flag_2) { + if (!ixheaacd_mps_huff_dec_ipd_1d( + it_bit_buff, + &ixheaacd_huff_ipd_nodes.h_1_dim[huff_yy_2], + out_data_2_int + num_val_2_int, 1, 0)) + return 0; + } + } + break; + + default: + break; + } + + if (out_data_1 != NULL) { + for (i = 0; i < num_val_1_int - 1; i += 2) { + out_data_1_int[i] = pair_vec[i][0]; + out_data_1_int[i + 1] = pair_vec[i][1]; + } + } + if (out_data_2 != NULL) { + for (i = 0; i < num_val_2_int - 1; i += 2) { + out_data_2_int[i] = pair_vec[i + 1][0]; + out_data_2_int[i + 1] = pair_vec[i + 1][1]; + } + } + + break; + + case TIME_PAIR: + + if (!pilot_coding_flag && + ((diff_type_1 == DIFF_FREQ) || (diff_type_2 == DIFF_FREQ))) { + p0_data_1[0] = &out_data_1[0]; + p0_data_1[1] = &out_data_2[0]; + + out_data_1_int += 1; + out_data_2_int += 1; + + num_val_1_int -= 1; + } + + if ((diff_type_1 == DIFF_TIME) || (diff_type_2 == DIFF_TIME)) { + diff_type = DIFF_TIME; + } else { + diff_type = DIFF_FREQ; + } + if (pilot_coding_flag) { + huff_yy = PCM_PLT; + } else { + huff_yy = diff_type; + } + + switch (data_type) { + case CLD: + if (!ixheaacd_mps_huff_dec_cld_2d( + it_bit_buff, + &ixheaacd_huff_cld_nodes.h_2_dim[huff_yy][TIME_PAIR], + pair_vec, num_val_1_int, 1, p0_data_1)) + return 0; + break; + + case ICC: + if (!ixheaacd_mps_huff_dec_icc_2d( + it_bit_buff, + &ixheaacd_huff_icc_nodes.h_2_dim[huff_yy][TIME_PAIR], + pair_vec, num_val_1_int, 1, p0_data_1)) + return 0; + break; + + case IPD: + if (!ixheaacd_mps_huff_dec_ipd_2d( + it_bit_buff, + &ixheaacd_huff_ipd_nodes.h_2_dim[huff_yy][TIME_PAIR], + pair_vec, num_val_1_int, 1, p0_data_1)) + return 0; + break; + + default: + break; + } + + for (i = 0; i < num_val_1_int; i++) { + out_data_1_int[i] = pair_vec[i][0]; + out_data_2_int[i] = pair_vec[i][1]; + } + + break; + + default: + break; + } + + break; + + default: + break; + } + + return 1; +} + +static VOID ixheaacd_diff_freq_decode(WORD32* diff_data, WORD32* out_data, + WORD32 num_val) { + WORD32 i = 0; + + out_data[0] = diff_data[0]; + + for (i = 1; i < num_val; i++) { + out_data[i] = out_data[i - 1] + diff_data[i]; + } +} + +static VOID ixheaacd_mps_diff_time_dec_bwd(WORD32* prev_data, WORD32* diff_data, + WORD32* out_data, + WORD32 mixed_diff_type, + WORD32 num_val) { + WORD32 i = 0; + + if (mixed_diff_type) { + out_data[0] = diff_data[0]; + for (i = 1; i < num_val; i++) { + out_data[i] = prev_data[i] + diff_data[i]; + } + } else { + for (i = 0; i < num_val; i++) { + out_data[i] = prev_data[i] + diff_data[i]; + } + } +} + +static VOID ixheaacd_mps_diff_time_dec_fwd(WORD32* prev_data, WORD32* diff_data, + WORD32* out_data, + WORD32 mixed_diff_type, + WORD32 num_val) { + WORD32 i = 0; + + if (mixed_diff_type) { + out_data[0] = diff_data[0]; + for (i = 1; i < num_val; i++) { + out_data[i] = prev_data[i] - diff_data[i]; + } + } else { + for (i = 0; i < num_val; i++) { + out_data[i] = prev_data[i] - diff_data[i]; + } + } +} + +static WORD32 ixheaacd_attach_lsb(ia_handle_bit_buf_struct it_bit_buff, + WORD32* in_data_msb, + WORD32 ixheaacd_drc_offset, WORD32 num_lsb, + WORD32 num_val, WORD32* out_data) { + WORD32 i = 0, lsb = 0, msb = 0; + UWORD32 data = 0; + + for (i = 0; i < num_val; i++) { + msb = in_data_msb[i]; + + if (num_lsb > 0) { + data = ixheaacd_read_bits_buf(it_bit_buff, num_lsb); + lsb = data; + + out_data[i] = ((msb << num_lsb) | lsb) - ixheaacd_drc_offset; + } else + out_data[i] = msb - ixheaacd_drc_offset; + } + + return 0; +} + +WORD32 ixheaacd_mps_ecdatapairdec(ia_handle_bit_buf_struct it_bit_buff, + WORD32 outdata[][MAXBANDS], + WORD32 history[MAXBANDS], WORD32 data_type, + WORD32 set_idx, WORD32 data_bands, + WORD32 pair_flag, WORD32 coarse_flag, + WORD32 independency_flag) + +{ + WORD32 diff_time_back_flag = !independency_flag || (set_idx > 0); + WORD32 attach_lsb_flag = 0; + WORD32 pcm_coding_flag = 0; + WORD32 pilot_coding_flag = 0; + WORD32 pilot_data[2] = {0, 0}; + WORD32 mixed_time_pair = 0, pcm_val = 0; + WORD32 quant_levels = 0, quant_offset = 0; + UWORD32 data = 0; + WORD32 band_start = 0; + + WORD32 data_pair[2][MAXBANDS] = {{0}}; + WORD32 data_diff[2][MAXBANDS] = {{0}}; + + WORD32 msb_state[MAXBANDS] = {0}; + + WORD32* data_array[2] = {NULL, NULL}; + + WORD32 diff_type[2] = {DIFF_FREQ, DIFF_FREQ}; + WORD32 cdg_scheme = HUFF_1D; + WORD32 direction = BACKWARDS; + + switch (data_type) { + case CLD: + if (coarse_flag) { + attach_lsb_flag = 0; + quant_levels = 15; + quant_offset = 7; + } else { + attach_lsb_flag = 0; + quant_levels = 31; + quant_offset = 15; + } + + break; + + case ICC: + if (coarse_flag) { + attach_lsb_flag = 0; + quant_levels = 4; + quant_offset = 0; + } else { + attach_lsb_flag = 0; + quant_levels = 8; + quant_offset = 0; + } + + break; + + case IPD: + if (coarse_flag) { + attach_lsb_flag = 0; + quant_levels = 8; + quant_offset = 0; + } else { + attach_lsb_flag = 1; + quant_levels = 16; + quant_offset = 0; + } + break; + + default: + fprintf(stderr, "Unknown type of data!\n"); + return 0; + } + + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + pcm_coding_flag = data; + + pilot_coding_flag = 0; + + if (pcm_coding_flag && !pilot_coding_flag) { + if (pair_flag) { + data_array[0] = data_pair[0]; + data_array[1] = data_pair[1]; + pcm_val = 2 * data_bands; + } else { + data_array[0] = data_pair[0]; + data_array[1] = NULL; + pcm_val = data_bands; + } + + if (!ixheaacd_mps_pcm_decode(it_bit_buff, data_array[0], data_array[1], + quant_offset, pcm_val, quant_levels)) + return 0; + + } else { + if (pair_flag) { + data_array[0] = data_diff[0]; + data_array[1] = data_diff[1]; + } else { + data_array[0] = data_diff[0]; + data_array[1] = NULL; + } + + diff_type[0] = DIFF_FREQ; + diff_type[1] = DIFF_FREQ; + + direction = BACKWARDS; + + if (!pilot_coding_flag) { + if (pair_flag || diff_time_back_flag) { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + diff_type[0] = data; + } + + if (pair_flag && ((diff_type[0] == DIFF_FREQ) || diff_time_back_flag)) { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + diff_type[1] = data; + } + } + + if (!ixheaacd_huff_decode(it_bit_buff, data_array[0], data_array[1], + data_type, diff_type[0], diff_type[1], + pilot_coding_flag, pilot_data, data_bands, + &cdg_scheme)) { + return 0; + } + + if ((diff_type[0] == DIFF_TIME) || (diff_type[1] == DIFF_TIME)) { + if (pair_flag) { + if ((diff_type[0] == DIFF_TIME) && !diff_time_back_flag) { + direction = FORWARDS; + } else if (diff_type[1] == DIFF_TIME) { + direction = BACKWARDS; + } else { + data = ixheaacd_read_bits_buf(it_bit_buff, 1); + direction = data; + } + } else { + direction = BACKWARDS; + } + } + + mixed_time_pair = (diff_type[0] != diff_type[1]) && + ((cdg_scheme & PAIR_MASK) == TIME_PAIR); + + if (direction == BACKWARDS) { + if (diff_type[0] == DIFF_FREQ) { + ixheaacd_diff_freq_decode(data_diff[0], data_pair[0], data_bands); + } else { + WORD32 i; + for (i = 0; i < data_bands; i++) { + msb_state[i] = history[i + band_start] + quant_offset; + if (attach_lsb_flag) { + msb_state[i] >>= 1; + } + } + ixheaacd_mps_diff_time_dec_bwd(msb_state, data_diff[0], data_pair[0], + mixed_time_pair, data_bands); + } + if (diff_type[1] == DIFF_FREQ) { + ixheaacd_diff_freq_decode(data_diff[1], data_pair[1], data_bands); + } else { + ixheaacd_mps_diff_time_dec_bwd(data_pair[0], data_diff[1], data_pair[1], + mixed_time_pair, data_bands); + } + } else { + ixheaacd_diff_freq_decode(data_diff[1], data_pair[1], data_bands); + + if (diff_type[0] == DIFF_FREQ) { + ixheaacd_diff_freq_decode(data_diff[0], data_pair[0], data_bands); + } else { + ixheaacd_mps_diff_time_dec_fwd(data_pair[1], data_diff[0], data_pair[0], + mixed_time_pair, data_bands); + } + } + + ixheaacd_attach_lsb(it_bit_buff, data_pair[0], quant_offset, + attach_lsb_flag ? 1 : 0, data_bands, data_pair[0]); + if (pair_flag) { + ixheaacd_attach_lsb(it_bit_buff, data_pair[1], quant_offset, + attach_lsb_flag ? 1 : 0, data_bands, data_pair[1]); + } + } + + memcpy(outdata[set_idx] + band_start, data_pair[0], + sizeof(WORD32) * data_bands); + if (pair_flag) { + memcpy(outdata[set_idx + 1] + band_start, data_pair[1], + sizeof(WORD32) * data_bands); + } + + return 1; +} + +WORD32 ixheaacd_mps_huff_decode(ia_handle_bit_buf_struct it_bit_buff, + WORD32* out_data, WORD32 num_val) { + WORD32 val_rcvd = 0, dummy = 0, i = 0, val = 0, len = 0; + WORD32 rl_data[2] = {0}; + + while (val_rcvd < num_val) { + if (!ixheaacd_mps_huff_read_2d( + it_bit_buff, (ia_huff_node_struct)&ixheaacd_huff_reshape_nodes, + rl_data, &dummy)) + return 0; + val = rl_data[0]; + len = rl_data[1] + 1; + for (i = val_rcvd; i < val_rcvd + len; i++) { + out_data[i] = val; + } + val_rcvd += len; + } + + return 1; +} diff --git a/decoder/ixheaacd_mps_dec.h b/decoder/ixheaacd_mps_dec.h new file mode 100644 index 0000000..060f6bf --- /dev/null +++ b/decoder/ixheaacd_mps_dec.h @@ -0,0 +1,390 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_DEC_H +#define IXHEAACD_MPS_DEC_H + +#define ABS_THR (1e-9f * 32768 * 32768) + +#define MAX_NUM_QMF_BANDS_MPS (128) +#define MAX_NUM_QMF_BANDS_MPS_NEW (64) + +#define MAX_PARAMETER_SETS_MPS (9) +#define MAX_M2_OUTPUT_MP (MAX_OUTPUT_CHANNELS_MPS) +#define BUFFER_LEN_HF_MPS ((QMF_HYBRID_FILT_ORDER - 1) / 2 + MAX_TIME_SLOTS) +#define MAX_OUTPUT_CHANNELS_MPS_AT (2) +#define HYBRID_BAND_BORDER (12) + +#define DECORR_FILT_0_ORD (10) +#define DECORR_FILT_1_ORD (8) +#define DECORR_FILT_2_ORD (3) +#define DECORR_FILT_3_ORD (2) + +#define MAX_DECORR_FIL_ORDER (DECORR_FILT_0_ORD) + +typedef struct { + FLOAT32 re; + FLOAT32 im; + +} ia_cmplx_flt_struct; + +typedef struct { + WORD32 re; + WORD32 im; +} ia_cmplx_w32_struct; + +typedef struct { + FLOAT32 *re; + FLOAT32 *im; +} ia_cmplx_fltp_struct; + +typedef struct ia_mps_decor_filt_struct { + WORD32 state_len; + WORD32 num_len; + WORD32 den_len; + + ia_cmplx_flt_struct state[MAX_DECORR_FIL_ORDER + 1]; + FLOAT32 *num; + FLOAT32 *den; + +} ia_mps_decor_filt_struct; + +typedef struct ia_mps_decor_struct *ia_mps_decor_struct_handle; + +#define MAX_HYBRID_BANDS_MPS (MAX_NUM_QMF_BANDS_MPS_NEW - 3 + 10) +#define MAX_TIME_SLOTS (72) +#define MAX_PARAMETER_BANDS (28) + +#define MAX_M1_INPUT (2) +#define MAX_M1_OUTPUT (2) +#define MAX_M2_INPUT (2) + +#define MAX_M_INPUT (2) +#define MAX_M_OUTPUT (2) + +#define QMF_BANDS_TO_HYBRID (3) +#define MAX_HYBRID_ONLY_BANDS_PER_QMF (8) +#define QMF_HYBRID_FILT_ORDER (13) +#define BUFFER_LEN_LF_MPS (QMF_HYBRID_FILT_ORDER - 1 + MAX_TIME_SLOTS) +#define MAX_NO_TIME_SLOTS_DELAY (14) + +#define MAXNRSBRCHANNELS 2 + +typedef struct ixheaacd_mps_decor_energy_adjust_filt_struct { + WORD32 num_bins; + FLOAT32 smooth_in_energy[MAX_PARAMETER_BANDS]; + FLOAT32 smooth_out_energy[MAX_PARAMETER_BANDS]; + +} ixheaacd_mps_decor_energy_adjust_filt_struct; + +typedef struct ia_mps_decor_struct { + WORD32 num_bins; + ia_mps_decor_filt_struct filter[MAX_HYBRID_BANDS_MPS]; + ixheaacd_mps_decor_energy_adjust_filt_struct decor_nrg_smooth; + + WORD32 delay_sample_count[MAX_HYBRID_BANDS_MPS]; + + ia_cmplx_flt_struct + decor_delay_buffer[71][MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY]; + +} ia_mps_decor_struct; + +typedef struct ia_mps_hybrid_filt_struct { + ia_cmplx_flt_struct hf_buffer[MAX_NUM_QMF_BANDS_MPS][BUFFER_LEN_HF_MPS]; + ia_cmplx_w32_struct lf_buffer[QMF_BANDS_TO_HYBRID][BUFFER_LEN_LF_MPS]; +} ia_mps_hybrid_filt_struct; + +typedef struct ia_mps_data_struct { + WORD32 bs_xxx_data_mode[MAX_PARAMETER_SETS_MPS]; + WORD32 quant_coarse_xxx_flag[MAX_PARAMETER_SETS_MPS]; + WORD32 bs_freq_res_stride_xxx[MAX_PARAMETER_SETS_MPS]; + WORD8 bs_quant_coarse_xxx[MAX_PARAMETER_SETS_MPS]; + WORD8 bs_quant_coarse_xxx_prev; +} ia_mps_data_struct; + +typedef struct ia_mps_bs_frame { + WORD8 independency_flag; + + WORD32 cld_idx[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + WORD32 icc_idx[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + + WORD32 cld_idx_pre[MAX_PARAMETER_BANDS]; + WORD32 icc_idx_pre[MAX_PARAMETER_BANDS]; + + WORD32 cmp_cld_idx[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + WORD32 cmp_icc_idx[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + + WORD32 cmp_cld_idx_prev[MAX_PARAMETER_BANDS]; + WORD32 cmp_icc_idx_prev[MAX_PARAMETER_BANDS]; + + ia_mps_data_struct cld_data; + ia_mps_data_struct icc_data; + ia_mps_data_struct ipd_data; + + WORD32 ipd_idx_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + WORD32 ipd_idx_data_prev[MAX_PARAMETER_BANDS]; + WORD32 ipd_idx[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + WORD32 ipd_idx_prev[MAX_PARAMETER_BANDS]; + + WORD32 bs_smooth_mode[MAX_PARAMETER_SETS_MPS]; + WORD32 bs_smooth_time[MAX_PARAMETER_SETS_MPS]; + WORD32 bs_freq_res_stride_smg[MAX_PARAMETER_SETS_MPS]; + WORD32 bs_smg_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + +} ia_mps_bs_frame; + +typedef struct ia_mps_smoothing_struct { + WORD32 prev_smg_time; + WORD32 inv_prev_smg_time; + WORD32 prev_smg_data[MAX_PARAMETER_BANDS]; +} ia_mps_smoothing_struct; + +typedef struct ia_mps_env_reshape_struct { + FLOAT32 pb_energy_prev[3][MAX_PARAMETER_BANDS]; + FLOAT32 avg_energy_prev[3]; + FLOAT32 frame_energy_prev[3]; +} ia_mps_env_reshape_struct; + +#define BP_SIZE 25 + +typedef struct ia_mps_stp_struct { + FLOAT32 nrg_dir; + FLOAT32 nrg_diff[2]; + FLOAT32 nrg_dir_prev; + FLOAT32 nrg_diff_prev[2]; + FLOAT32 tp_scale_last[2]; + WORD32 init_flag; + WORD32 update_old_ener; +} ia_mps_stp_struct; + +typedef struct ia_mps_opd_smooth_struct { + WORD32 smooth_l_phase[MAX_PARAMETER_BANDS]; + WORD32 smooth_r_phase[MAX_PARAMETER_BANDS]; +} ia_mps_opd_smooth_struct; + +typedef struct ia_mps_dec_state_struct { + WORD32 in_ch_count; + WORD32 out_ch_count; + + FLOAT32 input_gain; + WORD32 dir_sig_count; + + WORD32 decor_sig_count; + + WORD32 time_slots; + WORD32 present_time_slot; + WORD32 frame_len; + + WORD32 temp_shape_enable_ch_stp[2]; + WORD32 temp_shape_enable_ch_ges[2]; + + FLOAT32 env_shape_data[2][MAX_TIME_SLOTS]; + + WORD8 parse_nxt_frame; + + WORD32 qmf_band_count; + WORD32 hyb_band_count; + WORD32 *hyb_band_to_processing_band_table; + + WORD32 res_ch_count; + + WORD32 res_bands; + WORD32 max_res_bands; + WORD32 bs_param_bands; + + WORD32 ext_frame_flag; + WORD32 num_parameter_sets; + WORD32 num_parameter_sets_prev; + WORD32 param_slots[MAX_PARAMETER_SETS_MPS]; + WORD32 param_slot_diff[MAX_PARAMETER_SETS_MPS]; + FLOAT32 inv_param_slot_diff[MAX_PARAMETER_SETS_MPS]; + WORD32 inv_param_slot_diff_Q30[MAX_PARAMETER_SETS_MPS]; + + WORD32 frame_length; + WORD32 residual_coding; + WORD32 bs_residual_present; + + WORD32 bs_residual_bands; + + ia_usac_dec_mps_config_struct *config; + ia_mps_bs_frame bs_frame; + + WORD32 smoothing_time[MAX_PARAMETER_SETS_MPS]; + WORD32 inv_smoothing_time[MAX_PARAMETER_SETS_MPS]; + WORD32 smoothing_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + + WORD32 bs_tsd_enable; + WORD32 bs_tsd_sep_data[MAX_TIME_SLOTS]; + WORD32 bs_tsd_tr_phase_data[MAX_TIME_SLOTS]; + WORD32 tsd_num_tr_slots; + WORD32 tsd_codeword_len; + + FLOAT32 cld_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + FLOAT32 icc_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + FLOAT32 ipd_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + + WORD32 bs_phase_mode; + WORD32 opd_smoothing_mode; + WORD32 num_bands_ipd; + + FLOAT32 phase_l[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + FLOAT32 phase_r[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + FLOAT32 phase_l_prev[MAX_PARAMETER_BANDS]; + FLOAT32 phase_r_prev[MAX_PARAMETER_BANDS]; + + WORD32 phase_l_fix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + WORD32 phase_r_fix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS]; + + WORD32 m1_param_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 m1_param_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 m2_decor_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 m2_decor_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 m2_resid_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 m2_resid_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + + WORD32 m1_param_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 m1_param_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 m2_decor_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 m2_decor_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 m2_resid_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 m2_resid_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT]; + + ia_cmplx_flt_struct qmf_in[2][MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW]; + ia_cmplx_flt_struct hyb_in[2][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct hyb_res[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct v[MAX_M1_OUTPUT][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct w_diff[MAX_M2_INPUT][MAX_TIME_SLOTS] + [MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct w_dir[MAX_M2_INPUT][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct hyb_dir_out[2][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + ia_cmplx_flt_struct hyb_diff_out[2][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + + ia_cmplx_flt_struct qmf_out_dir[2][MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS]; + ia_cmplx_flt_struct scratch[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]; + + FLOAT32 (*output_buffer)[4096]; + + ia_mps_hybrid_filt_struct hyb_filt_state[2]; + ia_mps_poly_phase_synth_struct qmf_filt_state[2]; + + ia_mps_decor_struct mps_decor; + + ia_mps_smoothing_struct smoothing_filt_state; + + ia_mps_env_reshape_struct guided_env_shaping; + + WORD32 bs_high_rate_mode; + + WORD32 tmp_buf[84 * MAX_NUM_QMF_BANDS_SAC]; + + FLOAT32 r_out_re_in_m1[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + FLOAT32 r_out_im_in_m1[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 r_out_re_scratch_m1[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 r_out_im_scratch_m1[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + + FLOAT32 r_out_re_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + FLOAT32 r_out_im_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + FLOAT32 r_out_diff_re_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + FLOAT32 r_out_diff_im_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + + WORD32 r_out_re_fix_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 r_out_im_fix_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT]; + WORD32 r_diff_out_re_fix_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS] + [MAX_M_OUTPUT][MAX_M_INPUT]; + WORD32 r_diff_out_im_fix_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS] + [MAX_M_OUTPUT][MAX_M_INPUT]; + + FLOAT32 r_out_ph_re_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2]; + FLOAT32 r_out_ph_im_in_m2[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2]; + + ia_mps_stp_struct subband_var; + ia_mps_opd_smooth_struct opd_smooth; + ia_mps_poly_phase_struct poly_phase_filt_kernel; + VOID *p_sbr_dec[MAXNRSBRCHANNELS]; + VOID *p_sbr_frame[MAXNRSBRCHANNELS]; + VOID *p_sbr_header[MAXNRSBRCHANNELS]; +} ia_mps_dec_state_struct; + +VOID ixheaacd_mps_init_pre_and_post_matrix(ia_mps_dec_state_struct *self); +VOID ixheaacd_pre_and_mix_matrix_calculation(ia_mps_dec_state_struct *self); +VOID ixheaacd_mps_apply_pre_matrix(ia_mps_dec_state_struct *self); +VOID ixheaacd_mps_apply_mix_matrix(ia_mps_dec_state_struct *self); + +VOID ixheaacd_mps_config(ia_mps_dec_state_struct *self, WORD32 frame_len, + WORD32 residual_coding, + ia_usac_dec_mps_config_struct *mps212_config); + +VOID ixheaacd_mps_frame_decode(ia_mps_dec_state_struct *self); + +WORD32 ixheaacd_mps_header_decode(ia_mps_dec_state_struct *self); + +VOID ixheaacd_mps_env_init(ia_mps_dec_state_struct *self); +VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self); + +VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing( + ia_mps_dec_state_struct *self); +VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self); +VOID ixheaacd_mps_temp_process(ia_mps_dec_state_struct *self); + +VOID ixheaacd_mps_par2umx_ps(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, WORD32 *h_real, + WORD32 param_set_idx); + +VOID ixheaacd_mps_par2umx_ps_ipd_opd(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, + WORD32 *h_real, WORD32 param_set_idx); + +VOID ixheaacd_mps_par2umx_pred(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, WORD32 *h_imag, + WORD32 *h_real, WORD32 param_set_idx, + WORD32 res_bands); + +VOID ixheaacd_mps_upmix_interp( + WORD32 m_matrix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT], + WORD32 r_matrix[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT], + WORD32 m_matrix_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT], + WORD32 num_rows, WORD32 num_cols, ia_mps_dec_state_struct *self); + +VOID ixheaacd_mps_phase_interpolation( + FLOAT32 pl[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + FLOAT32 pr[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + FLOAT32 pl_prev[MAX_PARAMETER_BANDS], FLOAT32 pr_prev[MAX_PARAMETER_BANDS], + FLOAT32 r_re[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2], + FLOAT32 r_im[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2], + ia_mps_dec_state_struct *self); + +#endif diff --git a/decoder/ixheaacd_mps_decor.h b/decoder/ixheaacd_mps_decor.h new file mode 100644 index 0000000..3d9f6df --- /dev/null +++ b/decoder/ixheaacd_mps_decor.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_DECOR_H +#define IXHEAACD_MPS_DECOR_H + +#define DECOR_ALPHA (0.8f) +#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); + +VOID ixheaacd_mps_decor_apply( + ia_mps_decor_struct_handle self, + ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + WORD32 length); + +#endif diff --git a/decoder/ixheaacd_mps_decorr.c b/decoder/ixheaacd_mps_decorr.c new file mode 100644 index 0000000..0d2622f --- /dev/null +++ b/decoder/ixheaacd_mps_decorr.c @@ -0,0 +1,259 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include + +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" + +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_mps_decor.h" +#include "ixheaacd_mps_hybfilter.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 + ixheaacd_hybrid_band_71_to_processing_band_28_map[MAX_HYBRID_BANDS_MPS]; + +static 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, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; + +static void ixheaacd_mps_decor_filt_init(ia_mps_decor_filt_struct *self, + WORD32 reverb_band) { + switch (reverb_band) { + case 0: + self->num_len = self->den_len = DECORR_FILT_0_ORD + 1; + self->num = ixheaacd_lattice_coeff_0_filt_num_coeff; + self->den = ixheaacd_lattice_coeff_0_filt_den_coeff; + + break; + case 1: + self->num_len = self->den_len = DECORR_FILT_1_ORD + 1; + self->num = ixheaacd_lattice_coeff_1_filt_num_coeff; + self->den = ixheaacd_lattice_coeff_1_filt_den_coeff; + + break; + case 2: + self->num_len = self->den_len = DECORR_FILT_2_ORD + 1; + self->num = ixheaacd_lattice_coeff_2_filt_num_coeff; + self->den = ixheaacd_lattice_coeff_2_filt_den_coeff; + break; + case 3: + self->num_len = self->den_len = DECORR_FILT_3_ORD + 1; + self->num = ixheaacd_lattice_coeff_3_filt_num_coeff; + self->den = ixheaacd_lattice_coeff_3_filt_den_coeff; + break; + } + + self->state_len = self->num_len; + memset(self->state, 0, + sizeof(ia_cmplx_flt_struct) * (MAX_DECORR_FIL_ORDER + 1)); + + return; +} + +static VOID ixheaacd_mps_allpass_apply(ia_mps_decor_filt_struct *self, + ia_cmplx_flt_struct *input, WORD32 len, + ia_cmplx_flt_struct *output) { + WORD32 i, j; + + for (i = 0; i < len; i++) { + output[i].re = self->state[0].re + input[i].re * self->num[0]; + output[i].im = self->state[0].im + input[i].im * self->num[0]; + + for (j = 1; j < self->num_len; j++) { + self->state[j - 1].re = self->state[j].re + self->num[j] * input[i].re - + self->den[j] * output[i].re; + self->state[j - 1].im = self->state[j].im + self->num[j] * input[i].im - + self->den[j] * output[i].im; + } + } +} + +static VOID ixheaacd_mps_decor_energy_adjustment( + ixheaacd_mps_decor_energy_adjust_filt_struct *handle, + ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + WORD32 time_slots) { + ixheaacd_mps_decor_energy_adjust_filt_struct *self = + (ixheaacd_mps_decor_energy_adjust_filt_struct *)handle; + FLOAT32 in_energy[MAX_PARAMETER_BANDS] = {0}; + FLOAT32 out_energy[MAX_PARAMETER_BANDS] = {0}; + FLOAT32 gain[MAX_PARAMETER_BANDS]; + WORD32 i, j, k; + + for (i = 0; i < time_slots; i++) { + memset(in_energy, 0, sizeof(FLOAT32) * MAX_PARAMETER_BANDS); + memset(out_energy, 0, sizeof(FLOAT32) * MAX_PARAMETER_BANDS); + + for (j = 0; j < self->num_bins; j++) { + k = ixheaacd_hybrid_band_71_to_processing_band_28_map[j]; + + in_energy[k] += in[i][j].re * in[i][j].re + in[i][j].im * in[i][j].im; + out_energy[k] += + out[i][j].re * out[i][j].re + out[i][j].im * out[i][j].im; + } + + for (k = 0; k < MAX_PARAMETER_BANDS; k++) { + self->smooth_in_energy[k] = self->smooth_in_energy[k] * DECOR_ALPHA + + in_energy[k] * ONE_MINUS_DECOR_ALPHA; + self->smooth_out_energy[k] = self->smooth_out_energy[k] * DECOR_ALPHA + + out_energy[k] * ONE_MINUS_DECOR_ALPHA; + + gain[k] = 1.0f; + + if (self->smooth_out_energy[k] > + self->smooth_in_energy[k] * DECOR_GAMMA) { + gain[k] = (FLOAT32)sqrt(self->smooth_in_energy[k] * DECOR_GAMMA / + (self->smooth_out_energy[k] + ABS_THR)); + } + + if (self->smooth_in_energy[k] > + self->smooth_out_energy[k] * DECOR_GAMMA) { + gain[k] = + min(2.0f, (FLOAT32)sqrt(self->smooth_in_energy[k] / + (DECOR_GAMMA * self->smooth_out_energy[k] + + ABS_THR))); + } + } + + for (j = 0; j < self->num_bins; j++) { + k = ixheaacd_hybrid_band_71_to_processing_band_28_map[j]; + + out[i][j].re *= gain[k]; + out[i][j].im *= gain[k]; + } + } +} + +void ixheaacd_mps_decor_init(ia_mps_decor_struct_handle self, WORD32 subbands, + WORD32 decor_config) { + WORD32 i, reverb_band; + WORD32 *splitfreq; + + switch (decor_config) { + case 0: + splitfreq = ixheaacd_qmf_split_freq_0; + break; + case 1: + splitfreq = ixheaacd_qmf_split_freq_1; + break; + case 2: + splitfreq = ixheaacd_qmf_split_freq_2; + break; + default: + return; + } + + self->num_bins = subbands; + + for (i = 0; i < self->num_bins; i++) { + reverb_band = 0; + while ((reverb_band < 3) && + (ixheaacd_hybrid_to_qmf_map[i] >= (splitfreq[reverb_band] - 1))) + reverb_band++; + + self->delay_sample_count[i] = ixheaacd_decorr_delay[reverb_band]; + ixheaacd_mps_decor_filt_init(&self->filter[i], reverb_band); + } + + self->decor_nrg_smooth.num_bins = self->num_bins; + + return; +} + +VOID ixheaacd_mps_decor_apply( + ia_mps_decor_struct_handle self, + ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + WORD32 length) { + WORD32 idx, sb_sample; + + ia_cmplx_flt_struct scratch[MAX_TIME_SLOTS]; + + for (idx = 0; idx < self->num_bins; idx++) { + for (sb_sample = 0; sb_sample < length; sb_sample++) { + self->decor_delay_buffer[idx][self->delay_sample_count[idx] + sb_sample] + .re = in[sb_sample][idx].re; + self->decor_delay_buffer[idx][self->delay_sample_count[idx] + sb_sample] + .im = in[sb_sample][idx].im; + } + ixheaacd_mps_allpass_apply(&self->filter[idx], + self->decor_delay_buffer[idx], length, scratch); + + for (sb_sample = 0; sb_sample < length; sb_sample++) { + out[sb_sample][idx].re = scratch[sb_sample].re; + out[sb_sample][idx].im = scratch[sb_sample].im; + } + + for (sb_sample = 0; sb_sample < self->delay_sample_count[idx]; + sb_sample++) { + self->decor_delay_buffer[idx][sb_sample].re = + self->decor_delay_buffer[idx][length + sb_sample].re; + self->decor_delay_buffer[idx][sb_sample].im = + self->decor_delay_buffer[idx][length + sb_sample].im; + } + } + + ixheaacd_mps_decor_energy_adjustment(&self->decor_nrg_smooth, in, out, + length); +} diff --git a/decoder/ixheaacd_mps_huff_tab.h b/decoder/ixheaacd_mps_huff_tab.h new file mode 100644 index 0000000..20ed1e5 --- /dev/null +++ b/decoder/ixheaacd_mps_huff_tab.h @@ -0,0 +1,95 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_HUFF_TAB_H +#define IXHEAACD_MPS_HUFF_TAB_H + +typedef struct { const WORD32 node_tab[39][2]; } ia_huff_res_nodes_struct; + +typedef struct { const WORD32 node_tab[30][2]; } ia_huff_cld_node_1d_struct; + +typedef struct { const WORD32 node_tab[7][2]; } ia_huff_icc_node_1d_struct; + +typedef struct { const WORD32 node_tab[50][2]; } HUFF_CPC_NOD_1D; + +typedef struct { + const WORD32 lav3[15][2]; + const WORD32 lav5[35][2]; + const WORD32 lav7[63][2]; + const WORD32 lav9[99][2]; +} ia_huff_cld_node_2d_struct; + +typedef struct { + const WORD32 lav1[3][2]; + const WORD32 lav3[15][2]; + const WORD32 lav5[35][2]; + const WORD32 lav7[63][2]; +} ia_huff_icc_node_2d_struct; + +typedef struct { + const WORD32 lav3[15][2]; + const WORD32 lav6[48][2]; + const WORD32 lav9[99][2]; + const WORD32 lav12[168][2]; +} HUFF_CPC_NOD_2D; + +typedef struct { + ia_huff_cld_node_1d_struct h_1_dim[3]; + ia_huff_cld_node_2d_struct h_2_dim[3][2]; + +} ia_huff_cld_nodes_struct; + +typedef struct { + ia_huff_icc_node_1d_struct h_1_dim[3]; + ia_huff_icc_node_2d_struct h_2_dim[3][2]; + +} ia_huff_icc_nodes_struct; + +typedef struct { + HUFF_CPC_NOD_1D h_1_dim[3]; + HUFF_CPC_NOD_2D h_2_dim[3][2]; + +} HUFF_CPC_NODES; + +typedef struct { + const WORD32 cld[30][2]; + const WORD32 icc[7][2]; + const WORD32 cpc[25][2]; + +} ia_huff_pt0_nodes_struct; + +typedef struct { const WORD32 node_tab[3][2]; } ia_huff_lav_nodes_struct; + +typedef struct { const WORD32 node_tab[7][2]; } ia_huff_ipd_node_1d_struct; + +typedef struct { + const WORD32 lav1[3][2]; + const WORD32 lav3[15][2]; + const WORD32 lav5[35][2]; + const WORD32 lav7[63][2]; +} ia_huff_ipd_node_2d_struct; + +typedef struct { + ia_huff_ipd_node_1d_struct hp0; + ia_huff_ipd_node_1d_struct h_1_dim[3]; + ia_huff_ipd_node_2d_struct h_2_dim[3][2]; + +} ia_huff_ipd_nodes_struct; + +#endif diff --git a/decoder/ixheaacd_mps_hybfilter.h b/decoder/ixheaacd_mps_hybfilter.h new file mode 100644 index 0000000..b0b8266 --- /dev/null +++ b/decoder/ixheaacd_mps_hybfilter.h @@ -0,0 +1,36 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_HYBFILTER_H +#define IXHEAACD_MPS_HYBFILTER_H + +VOID ixheaacd_mps_qmf_hybrid_analysis_init(ia_mps_hybrid_filt_struct *handle); + +VOID ixheaacd_mps_qmf_hybrid_analysis( + ia_mps_hybrid_filt_struct *handle, + ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW], + WORD32 num_bands, WORD32 num_samples, + ia_cmplx_flt_struct out_hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]); + +VOID ixheaacd_mps_qmf_hybrid_synthesis( + ia_cmplx_flt_struct in_hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + WORD32 num_bands, WORD32 num_samples, + ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS]); + +#endif diff --git a/decoder/ixheaacd_mps_hybrid_filt.c b/decoder/ixheaacd_mps_hybrid_filt.c new file mode 100644 index 0000000..be53625 --- /dev/null +++ b/decoder/ixheaacd_mps_hybrid_filt.c @@ -0,0 +1,293 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" + +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_mps_polyphase.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]; + +static WORD32 ixheaacd_mps_mult32_local(WORD32 a, WORD32 b, WORD16 shift) { + WORD64 temp; + + temp = (WORD64)a * (WORD64)b; + temp = temp >> shift; + return (WORD32)temp; +} + +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 i, n, q; + + WORD32 modulation_fac_re, modulation_fac_im; + WORD32 in_re, in_im; + WORD32 temp; + WORD32 coeff; + WORD64 acc_re, acc_im; + + WORD16 shift = 8; + + for (i = 0; i < num_samples; i++) { + for (q = 0; q < 8; q++) { + acc_re = 0; + acc_im = 0; + for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) { + modulation_fac_re = ixheaacd_cosine[q][n]; + modulation_fac_im = ixheaacd_sine[q][n]; + + in_re = (WORD32)(input[n + i].re); + in_im = (WORD32)(input[n + i].im); + + in_re = in_re << shift; + in_im = 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); + + if (temp >= 1073741823) + temp = 1073741823; + else if (temp <= -1073741824) + temp = -1073741824; + + 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); + + if (temp >= 1073741823) + temp = 1073741823; + else if (temp <= -1073741824) + temp = -1073741824; + + temp = ixheaacd_mps_mult32_local(coeff, temp, 30); + acc_im = acc_im + (WORD64)temp; + } + + output[q][i].re = (WORD32)(acc_re >> shift); + output[q][i].im = (WORD32)(acc_im >> shift); + } + } +} + +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 i, n, q; + + WORD32 modulation_fac_re; + WORD32 in_re, in_im; + WORD32 temp; + WORD32 coeff; + WORD64 acc_re, acc_im; + + WORD16 shift = 8; + + for (i = 0; i < num_samples; i++) { + for (q = 0; q < 2; q++) { + acc_re = 0; + acc_im = 0; + for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) { + modulation_fac_re = ixheaacd_cosine2[q][n]; + + in_re = (WORD32)(input[n + i].re); + in_im = (WORD32)(input[n + i].im); + + in_re = in_re << shift; + in_im = in_im << shift; + + coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n]; + + temp = ixheaacd_mps_mult32_local(in_re, modulation_fac_re, 30); + + if (temp >= 1073741823) + temp = 1073741823; + else if (temp <= -1073741824) + temp = -1073741824; + + 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); + + if (temp >= 1073741823) + temp = 1073741823; + else if (temp <= -1073741824) + temp = -1073741824; + + temp = ixheaacd_mps_mult32_local(coeff, temp, 30); + acc_im = acc_im + (WORD64)temp; + } + + output[q][i].re = (WORD32)(acc_re >> shift); + output[q][i].im = (WORD32)(acc_im >> shift); + } + } +} + +VOID ixheaacd_mps_qmf_hybrid_analysis_init(ia_mps_hybrid_filt_struct *handle) { + memset(handle->lf_buffer, 0, + QMF_BANDS_TO_HYBRID * BUFFER_LEN_LF_MPS * sizeof(ia_cmplx_w32_struct)); + memset(handle->hf_buffer, 0, MAX_NUM_QMF_BANDS_MPS * BUFFER_LEN_HF_MPS * + sizeof(ia_cmplx_flt_struct)); +} + +VOID ixheaacd_mps_qmf_hybrid_analysis( + ia_mps_hybrid_filt_struct *handle, + ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW], + WORD32 num_bands, WORD32 num_samples, + ia_cmplx_flt_struct hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]) { + WORD32 lf_samples_shift; + WORD32 hf_samples_shift; + WORD32 lf_qmf_bands; + WORD32 k, n; + + ia_cmplx_w32_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS]; + + lf_samples_shift = BUFFER_LEN_LF_MPS - num_samples; + hf_samples_shift = BUFFER_LEN_HF_MPS - num_samples; + + lf_qmf_bands = QMF_BANDS_TO_HYBRID; + + for (k = 0; k < lf_qmf_bands; k++) { + for (n = 0; n < lf_samples_shift; n++) { + handle->lf_buffer[k][n].re = handle->lf_buffer[k][n + num_samples].re; + handle->lf_buffer[k][n].im = handle->lf_buffer[k][n + num_samples].im; + } + } + + for (k = 0; k < lf_qmf_bands; k++) { + for (n = 0; n < num_samples; n++) { + handle->lf_buffer[k][n + lf_samples_shift].re = (WORD32)(in_qmf[n][k].re); + handle->lf_buffer[k][n + lf_samples_shift].im = (WORD32)(in_qmf[n][k].im); + } + } + + for (k = 0; k < num_bands - lf_qmf_bands; k++) { + for (n = 0; n < hf_samples_shift; n++) { + handle->hf_buffer[k][n].re = handle->hf_buffer[k][n + num_samples].re; + handle->hf_buffer[k][n].im = handle->hf_buffer[k][n + num_samples].im; + } + } + + for (k = 0; k < num_bands - lf_qmf_bands; k++) { + for (n = 0; n < num_samples; n++) { + handle->hf_buffer[k][n + hf_samples_shift].re = + (in_qmf[n][k + lf_qmf_bands].re); + handle->hf_buffer[k][n + hf_samples_shift].im = + (in_qmf[n][k + lf_qmf_bands].im); + } + } + + ixheaacd_mps_hyb_filt_type1( + &(handle->lf_buffer[0][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), + scratch, num_samples, ixheaacd_ia_mps_hyb_filter_coeff_8); + + for (k = 0; k < 2; k++) { + for (n = 0; n < num_samples; n++) { + hyb[n][k].re = (FLOAT32)scratch[k + 6][n].re; + hyb[n][k + 2].re = (FLOAT32)scratch[k][n].re; + hyb[n][k + 4].re = (FLOAT32)scratch[k + 2][n].re; + hyb[n][k + 4].re += (FLOAT32)scratch[5 - k][n].re; + + hyb[n][k].im = (FLOAT32)scratch[k + 6][n].im; + hyb[n][k + 2].im = (FLOAT32)scratch[k][n].im; + hyb[n][k + 4].im = (FLOAT32)scratch[k + 2][n].im; + hyb[n][k + 4].im += (FLOAT32)scratch[5 - k][n].im; + } + } + + ixheaacd_mps_hyb_filt_type2( + &(handle->lf_buffer[1][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), + scratch, num_samples, ixheaacd_mps_hyb_filter_coeff_2); + + for (k = 0; k < 2; k++) { + for (n = 0; n < num_samples; n++) { + hyb[n][k + 6].re = (FLOAT32)scratch[1 - k][n].re; + hyb[n][k + 6].im = (FLOAT32)scratch[1 - k][n].im; + } + } + + ixheaacd_mps_hyb_filt_type2( + &(handle->lf_buffer[2][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), + scratch, num_samples, ixheaacd_mps_hyb_filter_coeff_2); + + for (k = 0; k < 2; k++) { + for (n = 0; n < num_samples; n++) { + hyb[n][k + 8].re = (FLOAT32)scratch[k][n].re; + hyb[n][k + 8].im = (FLOAT32)scratch[k][n].im; + } + } + + for (k = 0; k < num_bands - lf_qmf_bands; k++) { + for (n = 0; n < num_samples; n++) { + hyb[n][k + 10].re = (handle->hf_buffer[k][n + hf_samples_shift].re); + hyb[n][k + 10].im = (handle->hf_buffer[k][n + hf_samples_shift].im); + } + } +} + +VOID ixheaacd_mps_qmf_hybrid_synthesis( + ia_cmplx_flt_struct hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], + WORD32 num_bands, WORD32 num_samples, + ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS]) { + WORD32 k, n; + + for (n = 0; n < num_samples; n++) { + in_qmf[n][0].re = hyb[n][0].re; + in_qmf[n][0].im = hyb[n][0].im; + + for (k = 1; k < 6; k++) { + in_qmf[n][0].re += hyb[n][k].re; + in_qmf[n][0].im += hyb[n][k].im; + } + + in_qmf[n][1].re = hyb[n][6].re + hyb[n][7].re; + in_qmf[n][1].im = hyb[n][6].im + hyb[n][7].im; + + in_qmf[n][2].re = hyb[n][8].re + hyb[n][9].re; + in_qmf[n][2].im = hyb[n][8].im + hyb[n][9].im; + + for (k = 3; k < num_bands; k++) { + in_qmf[n][k].re = hyb[n][k - 3 + 10].re; + in_qmf[n][k].im = hyb[n][k - 3 + 10].im; + } + } +} diff --git a/decoder/ixheaacd_mps_interface.h b/decoder/ixheaacd_mps_interface.h new file mode 100644 index 0000000..4ed0d4a --- /dev/null +++ b/decoder/ixheaacd_mps_interface.h @@ -0,0 +1,34 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_INTERFACE_H +#define IXHEAACD_MPS_INTERFACE_H + +ia_mps_dec_state_struct* ixheaacd_mps_create( + WORD32 bs_frame_len, WORD32 residual_coding, + ia_usac_dec_mps_config_struct* usac_mps_config); + +VOID ixheaacd_mps_frame_parsing(ia_mps_dec_state_struct* self, + WORD32 independency_flag, + ia_handle_bit_buf_struct it_bit_buff); + +VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, FLOAT32** pointers[4], + FLOAT32 (*out_samples)[4096]); + +#endif diff --git a/decoder/ixheaacd_mps_nlc_dec.h b/decoder/ixheaacd_mps_nlc_dec.h new file mode 100644 index 0000000..bbb2e94 --- /dev/null +++ b/decoder/ixheaacd_mps_nlc_dec.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_NLC_DEC_H +#define IXHEAACD_MPS_NLC_DEC_H + +#define CLD (0) +#define ICC (1) +#define IPD (2) + +#define BACKWARDS (0) +#define FORWARDS (1) + +#define DIFF_FREQ (0) +#define DIFF_TIME (1) + +#define HUFF_1D (0) +#define HUFF_2D (1) + +#define FREQ_PAIR (0) +#define TIME_PAIR (1) + +#define PAIR_SHIFT 4 +#define PAIR_MASK 0xf + +#define PCM_PLT 0x2 + +#define MAXPARAM MAX_NUM_PARAMS +#define MAXSETS MAX_PARAMETER_SETS +#define MAXBANDS MAX_PARAMETER_BANDS + +#define ia_huff_node_struct const WORD32(*)[][2] + +WORD32 ixheaacd_mps_ecdatapairdec(ia_handle_bit_buf_struct strm, + WORD32 aa_out_data[][MAXBANDS], + WORD32 a_history[MAXBANDS], WORD32 data_type, + WORD32 set_idx, WORD32 data_bands, + WORD32 pair_flag, WORD32 coarse_flag, + WORD32 independency_flag); + +WORD32 ixheaacd_mps_huff_decode(ia_handle_bit_buf_struct strm, WORD32 *out_data, + WORD32 num_val); + +#endif diff --git a/decoder/ixheaacd_mps_parse.c b/decoder/ixheaacd_mps_parse.c new file mode 100644 index 0000000..5c8fd4b --- /dev/null +++ b/decoder/ixheaacd_mps_parse.c @@ -0,0 +1,1059 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" + +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" +#include "ixheaacd_mps_nlc_dec.h" +#include "ixheaacd_mps_hybfilter.h" + +#include +#include + +#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 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 + 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 + 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 + 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 + 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}; + +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 int ixheaacd_mps_stride_table[] = {1, 2, 5, 28}; + +static 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[] = { + 1.0000f, 0.9370f, 0.84118f, 0.60092f, 0.36764f, 0.0f, -0.5890f, -0.9900f}; + +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[] = { + 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 int ixheaacd_inverse_smoothing_time_table_q30[] = {16777216, 8388608, + 4194304, 2097152}; + +static VOID ixheaacd_longmult1(unsigned short a[], unsigned short b, + unsigned short d[], int len) { + int k; + UWORD32 tmp; + UWORD32 b0 = (UWORD32)b; + + tmp = ((UWORD32)a[0]) * b0; + d[0] = (unsigned short)tmp; + + for (k = 1; k < len; k++) { + tmp = (tmp >> 16) + ((UWORD32)a[k]) * b0; + d[k] = (unsigned short)tmp; + } +} + +static VOID ixheaacd_longdiv(unsigned short b[], unsigned short a, + unsigned short d[], unsigned short *pr, int len) { + UWORD32 r; + UWORD32 tmp; + UWORD32 temp; + int k; + + assert(a != 0); + + r = 0; + + for (k = len - 1; k >= 0; k--) { + tmp = ((UWORD32)b[k]) + (r << 16); + + if (tmp) { + d[k] = (unsigned short)(tmp / a); + temp = d[k] * a; + r = tmp - temp; + } else { + d[k] = 0; + } + } + *pr = (unsigned short)r; +} + +static VOID ixheaacd_longsub(unsigned short a[], unsigned short b[], int lena, + int lenb) { + int h; + WORD32 carry = 0; + + assert(lena >= lenb); + for (h = 0; h < lenb; h++) { + carry = carry + (WORD32)(a[h] - b[h]); + a[h] = (unsigned short)carry; + carry = carry >> 16; + } + + for (; h < lena; h++) { + carry = ((UWORD32)a[h]) + carry; + a[h] = (unsigned short)carry; + carry = carry >> 16; + } + + assert(carry == 0); + return; +} + +static int ixheaacd_longcompare(unsigned short a[], unsigned short b[], + int len) { + int i; + + for (i = len - 1; i > 0; i--) { + if (a[i] != b[i]) break; + } + return (a[i] >= b[i]) ? 1 : 0; +} + +static VOID ixheaacd_mps_coarse2fine(int *data, WORD32 data_type, + int band_start, int ixheaacd_num_bands) { + int i; + + for (i = band_start; i < band_start + ixheaacd_num_bands; i++) { + data[i] <<= 1; + } + + if (data_type == CLD) { + for (i = band_start; i < band_start + ixheaacd_num_bands; i++) { + if (data[i] == -14) + data[i] = -15; + else if (data[i] == 14) + data[i] = 15; + } + } +} + +static VOID ixheaacd_mps_fine2coarse(int *data, int ixheaacd_num_bands) { + int i; + + for (i = 0; i < ixheaacd_num_bands; i++) { + data[i] /= 2; + } +} + +static int ixheaacd_mps_getstridemap(int freq_res_stride, int band_start, + int band_stop, int *strides) { + int i, pb, ch_fac, data_bands, start_offset; + + ch_fac = ixheaacd_mps_stride_table[freq_res_stride]; + data_bands = (band_stop - band_start - 1) / ch_fac + 1; + + strides[0] = band_start; + for (pb = 1; pb <= data_bands; pb++) { + strides[pb] = strides[pb - 1] + ch_fac; + } + start_offset = 0; + while (strides[data_bands] > band_stop) { + if (start_offset < data_bands) + start_offset++; + else + start_offset = 1; + + for (i = start_offset; i <= data_bands; i++) { + strides[i]--; + } + } + + return data_bands; +} + +static VOID ixheaacd_mps_ecdata_decoding( + ia_mps_dec_state_struct *self, ia_handle_bit_buf_struct bitstream, + int data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], int datatype) { + int i, j, pb, data_set, set_index, bs_data_pair, data_bands, + old_quant_coarse_xxx; + int strides[MAX_PARAMETER_BANDS + 1] = {0}; + int band_stop = 0; + + int *lastdata = NULL; + ia_mps_data_struct *frame_xxx_data = NULL; + int default_val = 0; + + ia_mps_bs_frame *frame = &(self->bs_frame); + + if (datatype == 0) { + frame_xxx_data = &frame->cld_data; + lastdata = frame->cmp_cld_idx_prev; + band_stop = self->bs_param_bands; + } else if (datatype == 1) { + frame_xxx_data = &frame->icc_data; + lastdata = frame->cmp_icc_idx_prev; + band_stop = self->bs_param_bands; + } else if (datatype == 2) { + frame_xxx_data = &frame->ipd_data; + lastdata = frame->ipd_idx_data_prev; + band_stop = self->num_bands_ipd; + } else { + frame_xxx_data = &frame->cld_data; + lastdata = frame->cmp_cld_idx_prev; + band_stop = self->bs_param_bands; + } + + data_set = 0; + for (i = 0; i < self->num_parameter_sets; i++) { + frame_xxx_data->bs_xxx_data_mode[i] = ixheaacd_read_bits_buf(bitstream, 2); + + if (frame_xxx_data->bs_xxx_data_mode[i] == 3) { + data_set++; + } + } + + set_index = 0; + bs_data_pair = 0; + old_quant_coarse_xxx = frame_xxx_data->bs_quant_coarse_xxx_prev; + + for (i = 0; i < self->num_parameter_sets; i++) { + if (frame_xxx_data->bs_xxx_data_mode[i] == 0) { + for (pb = 0; pb < band_stop; pb++) { + lastdata[pb] = default_val; + } + + old_quant_coarse_xxx = 0; + } + + if (frame_xxx_data->bs_xxx_data_mode[i] == 3) { + if (bs_data_pair) { + bs_data_pair = 0; + } else { + bs_data_pair = ixheaacd_read_bits_buf(bitstream, 1); + frame_xxx_data->bs_quant_coarse_xxx[set_index] = + ixheaacd_read_bits_buf(bitstream, 1); + frame_xxx_data->bs_freq_res_stride_xxx[set_index] = + ixheaacd_read_bits_buf(bitstream, 2); + + if (frame_xxx_data->bs_quant_coarse_xxx[set_index] != + old_quant_coarse_xxx) { + if (old_quant_coarse_xxx) { + ixheaacd_mps_coarse2fine(lastdata, datatype, 0, band_stop - 0); + } else { + ixheaacd_mps_fine2coarse(lastdata, band_stop); + } + } + + data_bands = ixheaacd_mps_getstridemap( + frame_xxx_data->bs_freq_res_stride_xxx[set_index], 0, band_stop, + strides); + + for (pb = 0; pb < data_bands; pb++) { + lastdata[pb] = lastdata[strides[pb]]; + } + + ixheaacd_mps_ecdatapairdec( + bitstream, data, lastdata, datatype, set_index, data_bands, + bs_data_pair, frame_xxx_data->bs_quant_coarse_xxx[set_index], + frame->independency_flag && (i == 0)); + + for (pb = 0; pb < data_bands; pb++) { + for (j = strides[pb]; j < strides[pb + 1]; j++) { + if (datatype == IPD) { + if (frame_xxx_data->bs_quant_coarse_xxx[set_index]) { + lastdata[j] = data[set_index + bs_data_pair][pb] & 7; + } else { + lastdata[j] = data[set_index + bs_data_pair][pb] & 15; + } + } else { + lastdata[j] = data[set_index + bs_data_pair][pb]; + } + } + } + + old_quant_coarse_xxx = frame_xxx_data->bs_quant_coarse_xxx[set_index]; + + if (bs_data_pair) { + frame_xxx_data->bs_quant_coarse_xxx[set_index + 1] = + frame_xxx_data->bs_quant_coarse_xxx[set_index]; + frame_xxx_data->bs_freq_res_stride_xxx[set_index + 1] = + frame_xxx_data->bs_freq_res_stride_xxx[set_index]; + } + set_index += bs_data_pair + 1; + } + } + } +} + +VOID ixheaacd_mps_frame_parsing(ia_mps_dec_state_struct *self, + int usac_independency_flag, + ia_handle_bit_buf_struct bitstream) { + int i, bs_frame_type, data_bands, bs_temp_shape_enable, num_of_temp_shape_ch; + int ps, pg, ts, pb; + int env_shape_data[MAX_TIME_SLOTS]; + + int bits_param_slot = 0; + + ia_mps_bs_frame *frame = &(self->bs_frame); + + if (self->parse_nxt_frame == 0) return; + + self->num_parameter_sets_prev = self->num_parameter_sets; + + if (self->bs_high_rate_mode) { + bs_frame_type = ixheaacd_read_bits_buf(bitstream, 1); + self->num_parameter_sets = ixheaacd_read_bits_buf(bitstream, 3) + 1; + } else { + bs_frame_type = 0; + self->num_parameter_sets = 1; + } + + if (self->time_slots == 32) + bits_param_slot = 5; + else if (self->time_slots == 64) + bits_param_slot = 6; + + if (bs_frame_type) { + for (i = 0; i < self->num_parameter_sets; i++) { + self->param_slots[i] = ixheaacd_read_bits_buf(bitstream, bits_param_slot); + } + } else { + self->param_slots[0] = self->time_slots - 1; + } + + if (!usac_independency_flag) { + frame->independency_flag = ixheaacd_read_bits_buf(bitstream, 1); + } else { + frame->independency_flag = 1; + } + + ixheaacd_mps_ecdata_decoding(self, bitstream, frame->cmp_cld_idx, CLD); + ixheaacd_mps_ecdata_decoding(self, bitstream, frame->cmp_icc_idx, ICC); + + if (self->config->bs_phase_coding) { + self->bs_phase_mode = ixheaacd_read_bits_buf(bitstream, 1); + + if (!self->bs_phase_mode) { + for (pb = 0; pb < self->num_bands_ipd; pb++) { + frame->ipd_idx_data_prev[pb] = 0; + for (i = 0; i < self->num_parameter_sets; i++) { + frame->ipd_idx_data[i][pb] = 0; + self->bs_frame.ipd_idx[i][pb] = 0; + } + self->bs_frame.ipd_idx_prev[pb] = 0; + } + self->opd_smoothing_mode = 0; + } else { + self->opd_smoothing_mode = ixheaacd_read_bits_buf(bitstream, 1); + ixheaacd_mps_ecdata_decoding(self, bitstream, frame->ipd_idx_data, IPD); + } + } + + else { + self->bs_phase_mode = 0; + for (pb = 0; pb < self->num_bands_ipd; pb++) { + frame->ipd_idx_data_prev[pb] = 0; + for (i = 0; i < self->num_parameter_sets; i++) { + frame->ipd_idx_data[i][pb] = 0; + self->bs_frame.ipd_idx[i][pb] = 0; + } + self->bs_frame.ipd_idx_prev[pb] = 0; + } + self->opd_smoothing_mode = 0; + } + + if (self->bs_high_rate_mode) { + for (ps = 0; ps < self->num_parameter_sets; ps++) { + frame->bs_smooth_mode[ps] = ixheaacd_read_bits_buf(bitstream, 2); + if (frame->bs_smooth_mode[ps] >= 2) { + frame->bs_smooth_time[ps] = ixheaacd_read_bits_buf(bitstream, 2); + } + if (frame->bs_smooth_mode[ps] == 3) { + frame->bs_freq_res_stride_smg[ps] = + ixheaacd_read_bits_buf(bitstream, 2); + data_bands = + (self->bs_param_bands - 1) / + ixheaacd_mps_stride_table[frame->bs_freq_res_stride_smg[ps]] + + 1; + for (pg = 0; pg < data_bands; pg++) { + frame->bs_smg_data[ps][pg] = ixheaacd_read_bits_buf(bitstream, 1); + } + } + } + } else { + for (ps = 0; ps < self->num_parameter_sets; ps++) { + frame->bs_smooth_mode[ps] = 0; + } + } + + for (i = 0; i < 2; i++) { + self->temp_shape_enable_ch_stp[i] = 0; + self->temp_shape_enable_ch_ges[i] = 0; + } + + self->bs_tsd_enable = 0; + if (self->config->bs_temp_shape_config == 3) { + self->bs_tsd_enable = ixheaacd_read_bits_buf(bitstream, 1); + } else if (self->config->bs_temp_shape_config != 0) { + bs_temp_shape_enable = ixheaacd_read_bits_buf(bitstream, 1); + if (bs_temp_shape_enable) { + num_of_temp_shape_ch = 2; + switch (self->config->bs_temp_shape_config) { + case 1: + for (i = 0; i < num_of_temp_shape_ch; i++) { + self->temp_shape_enable_ch_stp[i] = + ixheaacd_read_bits_buf(bitstream, 1); + } + break; + case 2: + for (i = 0; i < num_of_temp_shape_ch; i++) { + self->temp_shape_enable_ch_ges[i] = + ixheaacd_read_bits_buf(bitstream, 1); + } + for (i = 0; i < num_of_temp_shape_ch; i++) { + if (self->temp_shape_enable_ch_ges[i]) { + ixheaacd_mps_huff_decode(bitstream, env_shape_data, + self->time_slots); + for (ts = 0; ts < self->time_slots; ts++) { + self->env_shape_data[i][ts] = (float)pow( + 2, (float)env_shape_data[ts] / + (self->config->bs_env_quant_mode + 2) - + 1); + } + } + } + break; + default: + assert(0); + } + } + } + + if (self->bs_tsd_enable) { + unsigned short s[4]; + UWORD64 s_64; + unsigned short c[5]; + 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; + int k; + unsigned short h; + WORD32 nbits_tr_slots = 0; + + if (self->time_slots == 32) { + nbits_tr_slots = 4; + tab = table_32; + } else if (self->time_slots == 64) { + nbits_tr_slots = 5; + tab = table_64; + } + + self->tsd_num_tr_slots = ixheaacd_read_bits_buf(bitstream, nbits_tr_slots); + self->tsd_num_tr_slots++; + self->tsd_codeword_len = tab[self->tsd_num_tr_slots - 1]; + + if (self->tsd_codeword_len > 48) { + s[3] = ixheaacd_read_bits_buf(bitstream, self->tsd_codeword_len - 48); + s_64 = s[3]; + s[2] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[2]; + s[1] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[1]; + s[0] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[0]; + } else if (self->tsd_codeword_len > 32) { + s[3] = 0; + s_64 = s[3]; + s[2] = ixheaacd_read_bits_buf(bitstream, self->tsd_codeword_len - 32); + s_64 = (s_64 << 16) | s[2]; + s[1] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[1]; + s[0] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[0]; + } else if (self->tsd_codeword_len > 16) { + s[3] = 0; + s_64 = s[3]; + s[2] = 0; + s_64 = (s_64 << 16) | s[2]; + s[1] = ixheaacd_read_bits_buf(bitstream, self->tsd_codeword_len - 16); + s_64 = (s_64 << 16) | s[1]; + s[0] = ixheaacd_read_bits_buf(bitstream, 16); + s_64 = (s_64 << 16) | s[0]; + } else { + s[3] = 0; + s_64 = s[3]; + s[2] = 0; + s_64 = (s_64 << 16) | s[2]; + s[1] = 0; + s_64 = (s_64 << 16) | s[1]; + s[0] = ixheaacd_read_bits_buf(bitstream, self->tsd_codeword_len); + s_64 = (s_64 << 16) | s[0]; + } + + { + int p = self->tsd_num_tr_slots; + + for (i = 0; i < self->time_slots; i++) self->bs_tsd_sep_data[i] = 0; + + for (k = self->time_slots - 1; k >= 0; k--) { + if (p > k) { + for (; k >= 0; k--) self->bs_tsd_sep_data[k] = 1; + break; + } + + c[0] = k - p + 1; + c_64 = c[0]; + for (i = 1; i < 5; i++) c[i] = 0; + + for (h = 2; h <= p; h++) { + b = k - p + h; + c_64 *= b; + ixheaacd_longmult1(c, b, c, 5); + b = h; + ixheaacd_longdiv(c, b, c, r, 5); + } + + if (ixheaacd_longcompare(s, c, 4)) { + ixheaacd_longsub(s, c, 4, 4); + self->bs_tsd_sep_data[k] = 1; + p--; + if (p == 0) break; + } + } + } + + for (i = 0; i < self->time_slots; i++) { + if (self->bs_tsd_sep_data[i]) + self->bs_tsd_tr_phase_data[i] = ixheaacd_read_bits_buf(bitstream, 3); + } + } + + self->parse_nxt_frame = 0; +} + +static VOID ixheaacd_mps_createmapping(int map[MAX_PARAMETER_BANDS + 1], + int band_start, int band_stop, + int ch_fac) { + int input_bands, out_bands, bands_achived, bands_diff, incr, k, i; + int vdk[MAX_PARAMETER_BANDS + 1]; + input_bands = band_stop - band_start; + out_bands = (input_bands - 1) / ch_fac + 1; + if (out_bands < 1) { + out_bands = 1; + } + + bands_achived = out_bands * ch_fac; + bands_diff = input_bands - bands_achived; + for (i = 0; i < out_bands; i++) { + vdk[i] = ch_fac; + } + + if (bands_diff > 0) { + incr = -1; + k = out_bands - 1; + } else { + incr = 1; + k = 0; + } + + while (bands_diff != 0) { + vdk[k] = vdk[k] - incr; + k = k + incr; + bands_diff = bands_diff + incr; + if (k >= out_bands) { + if (bands_diff > 0) { + k = out_bands - 1; + } else if (bands_diff < 0) { + k = 0; + } + } + } + map[0] = band_start; + for (i = 0; i < out_bands; i++) { + map[i + 1] = map[i] + vdk[i]; + } +} + +static VOID ixheaacd_mps_mapfrequency(int *in, int *out, int *map, + int data_bands) { + int i, j, band_start, band_stop, value; + int start_band_0 = map[0]; + + for (i = 0; i < data_bands; i++) { + value = in[i + start_band_0]; + + band_start = map[i]; + band_stop = map[i + 1]; + for (j = band_start; j < band_stop; j++) { + out[j] = value; + } + } +} + +static float ixheaacd_mps_de_quantize(int value, int param_type) { + switch (param_type) { + case CLD: + return ixheaacd_cld_de_quant_table[value + 15]; + + case ICC: + return ixheaacd_icc_de_quant_table[value]; + + case IPD: + assert((value % 16) < 16); + return ixheaacd_ipd_de_quant_table[(value & 15)]; + + default: + assert(0); + return 0.0; + } +} + +static VOID ixheaacd_mps_mapindexdata( + ia_mps_dec_state_struct *self, ia_mps_data_struct *frame_xxx_data, + float out_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + int out_idx_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + int cmp_idx_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + int idx_prev[MAX_PARAMETER_BANDS], int param_type) { + int interpolate_local[MAX_PARAMETER_SETS_MPS]; + int map[MAX_PARAMETER_BANDS + 1]; + + int set_index, i, band, parm_slot; + int data_bands, ch_fac; + int ps; + + int i1, i2, x1, xi, x2; + int band_start = 0; + int ext_frame_flag = self->ext_frame_flag; + int *param_slots = self->param_slots; + int num_parameter_sets = self->num_parameter_sets; + int band_stop = self->bs_param_bands; + int default_val = 0; + + set_index = 0; + + for (i = 0; i < num_parameter_sets; i++) { + if (frame_xxx_data->bs_xxx_data_mode[i] == 0) { + frame_xxx_data->quant_coarse_xxx_flag[i] = 0; + for (band = band_start; band < band_stop; band++) { + out_idx_data[i][band] = default_val; + } + for (band = band_start; band < band_stop; band++) { + idx_prev[band] = out_idx_data[i][band]; + } + + frame_xxx_data->bs_quant_coarse_xxx_prev = 0; + } + + if (frame_xxx_data->bs_xxx_data_mode[i] == 1) { + for (band = band_start; band < band_stop; band++) { + out_idx_data[i][band] = idx_prev[band]; + } + frame_xxx_data->quant_coarse_xxx_flag[i] = + frame_xxx_data->bs_quant_coarse_xxx_prev; + } + + if (frame_xxx_data->bs_xxx_data_mode[i] == 2) { + for (band = band_start; band < band_stop; band++) { + out_idx_data[i][band] = idx_prev[band]; + } + frame_xxx_data->quant_coarse_xxx_flag[i] = + frame_xxx_data->bs_quant_coarse_xxx_prev; + interpolate_local[i] = 1; + } else { + interpolate_local[i] = 0; + } + + if (frame_xxx_data->bs_xxx_data_mode[i] == 3) { + parm_slot = i; + ch_fac = + ixheaacd_mps_stride_table[frame_xxx_data + ->bs_freq_res_stride_xxx[set_index]]; + data_bands = (band_stop - band_start - 1) / ch_fac + 1; + ixheaacd_mps_createmapping(map, band_start, band_stop, ch_fac); + ixheaacd_mps_mapfrequency(&cmp_idx_data[set_index][0], + &out_idx_data[parm_slot][0], map, data_bands); + + for (band = band_start; band < band_stop; band++) { + idx_prev[band] = out_idx_data[parm_slot][band]; + } + + frame_xxx_data->bs_quant_coarse_xxx_prev = + frame_xxx_data->bs_quant_coarse_xxx[set_index]; + frame_xxx_data->quant_coarse_xxx_flag[i] = + frame_xxx_data->bs_quant_coarse_xxx[set_index]; + + set_index++; + } + } + + for (i = 0; i < num_parameter_sets; i++) { + if (frame_xxx_data->quant_coarse_xxx_flag[i] == 1) { + ixheaacd_mps_coarse2fine(out_idx_data[i], param_type, band_start, + band_stop - band_start); + frame_xxx_data->quant_coarse_xxx_flag[i] = 0; + } + } + + i1 = -1; + x1 = 0; + i2 = 0; + for (i = 0; i < num_parameter_sets; i++) { + if (interpolate_local[i] != 1) { + i1 = i; + } + i2 = i; + while (interpolate_local[i2] == 1) { + i2++; + } + if (i1 == -1) { + x1 = 0; + i1 = 0; + } else { + x1 = param_slots[i1]; + } + xi = param_slots[i]; + x2 = param_slots[i2]; + + if (interpolate_local[i] == 1) { + assert(i2 < num_parameter_sets); + for (band = band_start; band < band_stop; band++) { + int yi, y1, y2; + y1 = out_idx_data[i1][band]; + y2 = out_idx_data[i2][band]; + if (param_type == IPD) { + if (y2 - y1 > 8) y1 += 16; + if (y1 - y2 > 8) y2 += 16; + + yi = (y1 + (xi - x1) * (y2 - y1) / (x2 - x1)) % 16; + } else { + yi = y1 + (xi - x1) * (y2 - y1) / (x2 - x1); + } + out_idx_data[i][band] = yi; + } + } + } + + for (ps = 0; ps < num_parameter_sets; ps++) { + for (band = band_start; band < band_stop; band++) + out_data[ps][band] = + ixheaacd_mps_de_quantize(out_idx_data[ps][band], param_type); + } + + if (ext_frame_flag) { + for (band = band_start; band < band_stop; band++) { + out_data[num_parameter_sets][band] = + out_data[num_parameter_sets - 1][band]; + out_idx_data[num_parameter_sets][band] = + out_idx_data[num_parameter_sets - 1][band]; + } + } +} + +static VOID ixheaacd_mps_dec_and_mapframeott(ia_mps_dec_state_struct *self) { + ia_mps_bs_frame *cur_bit_stream_ptr = &(self->bs_frame); + + ixheaacd_mps_mapindexdata(self, &cur_bit_stream_ptr->cld_data, self->cld_data, + cur_bit_stream_ptr->cld_idx, + cur_bit_stream_ptr->cmp_cld_idx, + cur_bit_stream_ptr->cld_idx_pre, CLD); + + ixheaacd_mps_mapindexdata(self, &cur_bit_stream_ptr->icc_data, self->icc_data, + cur_bit_stream_ptr->icc_idx, + cur_bit_stream_ptr->cmp_icc_idx, + cur_bit_stream_ptr->icc_idx_pre, ICC); + + if ((self->config->bs_phase_coding)) + ixheaacd_mps_mapindexdata(self, &cur_bit_stream_ptr->ipd_data, + self->ipd_data, cur_bit_stream_ptr->ipd_idx, + cur_bit_stream_ptr->ipd_idx_data, + cur_bit_stream_ptr->ipd_idx_prev, IPD); +} + +static VOID ixheaacd_mps_dec_and_mapframesmg(ia_mps_dec_state_struct *self) { + int ps, pb, pg, ch_fac, data_bands, param_band_start, param_band_stop, + group_to_band[MAX_PARAMETER_BANDS + 1]; + ia_mps_bs_frame *frame = &(self->bs_frame); + for (ps = 0; ps < self->num_parameter_sets; ps++) { + switch (frame->bs_smooth_mode[ps]) { + case 0: + self->smoothing_time[ps] = 256; + self->inv_smoothing_time[ps] = 4194304; + + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->smoothing_data[ps][pb] = 0; + } + break; + + case 1: + if (ps > 0) { + self->smoothing_time[ps] = self->smoothing_time[ps - 1]; + self->inv_smoothing_time[ps] = self->inv_smoothing_time[ps - 1]; + } else { + self->smoothing_time[ps] = self->smoothing_filt_state.prev_smg_time; + self->inv_smoothing_time[ps] = + self->smoothing_filt_state.inv_prev_smg_time; + } + + for (pb = 0; pb < self->bs_param_bands; pb++) { + if (ps > 0) + self->smoothing_data[ps][pb] = self->smoothing_data[ps - 1][pb]; + else + self->smoothing_data[ps][pb] = + self->smoothing_filt_state.prev_smg_data[pb]; + } + break; + + case 2: + self->smoothing_time[ps] = + ixheaacd_smoothing_time_table[frame->bs_smooth_time[ps]]; + self->inv_smoothing_time[ps] = + ixheaacd_inverse_smoothing_time_table_q30[frame + ->bs_smooth_time[ps]]; + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->smoothing_data[ps][pb] = 1; + } + break; + + case 3: + self->smoothing_time[ps] = + ixheaacd_smoothing_time_table[frame->bs_smooth_time[ps]]; + self->inv_smoothing_time[ps] = + ixheaacd_inverse_smoothing_time_table_q30[frame + ->bs_smooth_time[ps]]; + + ch_fac = ixheaacd_mps_stride_table[frame->bs_freq_res_stride_smg[ps]]; + data_bands = (self->bs_param_bands - 1) / ch_fac + 1; + ixheaacd_mps_createmapping(group_to_band, 0, self->bs_param_bands, + ch_fac); + for (pg = 0; pg < data_bands; pg++) { + param_band_start = group_to_band[pg]; + param_band_stop = group_to_band[pg + 1]; + for (pb = param_band_start; pb < param_band_stop; pb++) { + self->smoothing_data[ps][pb] = frame->bs_smg_data[ps][pg]; + } + } + break; + } + } + + self->smoothing_filt_state.prev_smg_time = + self->smoothing_time[self->num_parameter_sets - 1]; + self->smoothing_filt_state.inv_prev_smg_time = + self->inv_smoothing_time[self->num_parameter_sets - 1]; + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->smoothing_filt_state.prev_smg_data[pb] = + self->smoothing_data[self->num_parameter_sets - 1][pb]; + } + + if (self->ext_frame_flag) { + self->smoothing_time[self->num_parameter_sets] = + self->smoothing_time[self->num_parameter_sets - 1]; + self->inv_smoothing_time[self->num_parameter_sets] = + self->inv_smoothing_time[self->num_parameter_sets - 1]; + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->smoothing_data[self->num_parameter_sets][pb] = + self->smoothing_data[self->num_parameter_sets - 1][pb]; + } + } +} + +VOID ixheaacd_mps_frame_decode(ia_mps_dec_state_struct *self) { + int i; + if (self->parse_nxt_frame == 1) return; + + self->ext_frame_flag = 0; + if (self->param_slots[self->num_parameter_sets - 1] != self->time_slots - 1) { + self->ext_frame_flag = 1; + } + + ixheaacd_mps_dec_and_mapframeott(self); + + ixheaacd_mps_dec_and_mapframesmg(self); + + if (self->ext_frame_flag) { + self->num_parameter_sets++; + self->param_slots[self->num_parameter_sets - 1] = self->time_slots - 1; + } + self->param_slot_diff[0] = self->param_slots[0] + 1; + self->inv_param_slot_diff[0] = (float)1 / self->param_slot_diff[0]; + self->inv_param_slot_diff_Q30[0] = + (int)floor(self->inv_param_slot_diff[0] * 1073741824 + 0.5); + for (i = 1; i < self->num_parameter_sets; i++) { + self->param_slot_diff[i] = self->param_slots[i] - self->param_slots[i - 1]; + self->inv_param_slot_diff[i] = (float)1 / self->param_slot_diff[i]; + self->inv_param_slot_diff_Q30[i] = + (int)floor(self->inv_param_slot_diff[i] * 1073741824 + 0.5); + } +} + +WORD32 ixheaacd_mps_header_decode(ia_mps_dec_state_struct *self) { + self->time_slots = self->frame_length + 1; + self->frame_len = self->time_slots * self->qmf_band_count; + self->bs_param_bands = ixheaacd_freq_res_table[self->config->bs_freq_res]; + + self->hyb_band_count = self->qmf_band_count - QMF_BANDS_TO_HYBRID + 10; + + switch (self->bs_param_bands) { + case 4: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_4_map; + break; + case 5: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_5_map; + break; + case 7: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_7_map; + break; + case 10: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_10_map; + break; + case 14: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_14_map; + break; + case 20: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_20_map; + break; + case 28: + + self->hyb_band_to_processing_band_table = + ixheaacd_hybrid_band_71_to_processing_band_28_map; + break; + default: + self->hyb_band_to_processing_band_table = NULL; + return -1; + break; + }; + + self->in_ch_count = 1; + self->out_ch_count = 2; + + self->input_gain = + ixheaacd_mps_clip_gain_table[self->config->bs_fixed_gain_dmx]; + + if (self->config->bs_ott_bands_phase_present) { + self->num_bands_ipd = self->config->bs_ott_bands_phase; + } else { + switch (self->bs_param_bands) { + case 4: + case 5: + self->num_bands_ipd = 2; + break; + case 7: + self->num_bands_ipd = 3; + break; + case 10: + self->num_bands_ipd = 5; + break; + case 14: + self->num_bands_ipd = 7; + break; + case 20: + case 28: + self->num_bands_ipd = 10; + break; + default: + assert(0); + break; + } + } + + if (self->residual_coding) { + self->num_bands_ipd = max(self->bs_residual_bands, self->num_bands_ipd); + self->max_res_bands = 0; + if (self->bs_residual_present) { + self->res_bands = self->bs_residual_bands; + if (self->res_bands > self->max_res_bands) { + self->max_res_bands = self->res_bands; + } + } else { + self->res_bands = 0; + } + } + + self->dir_sig_count = 1; + self->decor_sig_count = 1; + + 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 new file mode 100644 index 0000000..71c930f --- /dev/null +++ b/decoder/ixheaacd_mps_poly_filt.c @@ -0,0 +1,192 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include +#include "ixheaacd_mps_polyphase.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" +#include "ixheaacd_constants.h" +#include +#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]; + +static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 31); + + return (result); +} + +VOID ixheaacd_mps_synt_create(ia_mps_poly_phase_struct *kernel, + WORD32 resolution) { + kernel->resolution = resolution; +} + +VOID ixheaacd_mps_synt_init(ia_mps_poly_phase_synth_struct *self) { + memset(self->state, 0, sizeof(WORD32) * 64 * 20); +} + +static VOID ixheaacd_float_to_int32(FLOAT32 *in, WORD32 *out, WORD32 q_factor, + WORD32 sample) { + WORD32 loop; + UWORD32 temp = (1 << 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) { + WORD32 tmp, k; + for (k = 0; k < 2 * resolution; k += 2) { + tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_in[k], table_re[k >> 1]), + ixheaacd_mult32(ptr_in[k + 1], table_im[k >> 1])); + + ptr_in[k + 1] = + ixheaacd_add32_sat(ixheaacd_mult32(-ptr_in[k], table_im[k >> 1]), + ixheaacd_mult32(ptr_in[k + 1], table_re[k >> 1])); + + ptr_in[k] = tmp; + } +} + +VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, + 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] = 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 l; + for (l = 0; l < 2 * resolution; l++) { + state[2 * resolution - l - 1] = + ixheaacd_add32_sat(ixheaacd_mult32(fin_re[l], table_re[l]), + ixheaacd_mult32(fin_im[l], table_im[l])); + } +} + +VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out, + WORD32 *state, const WORD32 *filter_coeff) { + WORD32 l, k; + WORD32 *out1, *out2, *state1, *state2; + out1 = out; + out2 = out + resolution; + state1 = state; + state2 = state + (3 * resolution); + + for (k = 0; k < 5; k++) { + for (l = 0; l < resolution; l++) { + *out1++ = (WORD32)(((WORD64)(*state1++) * (*filter_coeff++)) >> 31); + *out2++ = (WORD32)(((WORD64)(*state2++) * (*filter_coeff++)) >> 31); + } + out1 += resolution; + out2 += resolution; + state1 += (3 * resolution); + state2 += (3 * resolution); + } +} + +VOID ixheaacd_mps_synt_calc(ia_mps_dec_state_struct *self) { + WORD32 k, l, ts, ch; + WORD64 acc; + WORD32 ptr_in[128]; + WORD32 fin_re[128]; + WORD32 fin_im[128]; + FLOAT32 temp; + WORD32 *state, *tmp_state, *out; + const WORD32 *filt_coeff; + WORD32 *tmp_buf = self->tmp_buf; + + ia_mps_poly_phase_struct kernel = self->poly_phase_filt_kernel; + WORD32 resolution = kernel.resolution; + for (ch = 0; ch < self->out_ch_count; ch++) { + tmp_state = (&self->qmf_filt_state[ch])->state; + state = &tmp_buf[self->time_slots * 2 * resolution]; + memcpy(state, tmp_state, sizeof(WORD32) * 20 * resolution); + out = &tmp_buf[74 * MAX_NUM_QMF_BANDS_SAC]; + + for (ts = 0; ts < self->time_slots; ts++) { + ixheaacd_float_to_int32(&self->qmf_out_dir[ch][ts][0].re, ptr_in, 10, + resolution * 2); + + filt_coeff = ixheaacd_mps_polyphase_filter_coeff_fix; + + state -= (2 * resolution); + (*ixheaacd_mps_synt_pre_twiddle)(ptr_in, ixheaacd_mps_pre_re, + ixheaacd_mps_pre_im, resolution); + + (*ixheaacd_mps_complex_fft_64)(ptr_in, fin_re, fin_im, resolution); + + (*ixheaacd_mps_synt_post_twiddle)(ptr_in, ixheaacd_mps_post_re, + ixheaacd_mps_post_im, resolution); + + (*ixheaacd_mps_complex_fft_64)(ptr_in, &fin_re[1], &fin_im[1], + resolution); + + (*ixheaacd_mps_synt_post_fft_twiddle)(resolution, fin_re, fin_im, + ixheaacd_mps_post_re, + ixheaacd_mps_post_im, state); + (*ixheaacd_mps_synt_out_calc)(resolution, out, state, filt_coeff); + + for (k = 0; k < resolution; k++) { + acc = 0; + for (l = 0; l < 10; l++) { + acc = acc + out[resolution * l + k]; + } + if (acc >= 2147483647) + temp = 1.0; + else if (acc <= -2147483647 - 1) + temp = -1.0f; + else + temp = (FLOAT32)((WORD32)acc) / ((FLOAT32)(1 << 10)); + + self->output_buffer[ch][self->qmf_band_count * ts + k] = (FLOAT32)temp; + } + } + + memcpy(tmp_state, state, sizeof(WORD32) * 20 * resolution); + } +} diff --git a/decoder/ixheaacd_mps_polyphase.h b/decoder/ixheaacd_mps_polyphase.h new file mode 100644 index 0000000..dcc6f10 --- /dev/null +++ b/decoder/ixheaacd_mps_polyphase.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_POLYPHASE_H +#define IXHEAACD_MPS_POLYPHASE_H + +#define MAX_NUM_QMF_BANDS_SAC (128) + +typedef struct ia_mps_poly_phase_synth_struct { + WORD32 state[1280]; +} ia_mps_poly_phase_synth_struct; + +typedef struct ia_mps_poly_phase_struct { + int resolution; +} ia_mps_poly_phase_struct; + +VOID ixheaacd_mps_synt_create(ia_mps_poly_phase_struct *kernel, + WORD32 resolution); + +VOID ixheaacd_mps_synt_init(ia_mps_poly_phase_synth_struct *self); + +#endif diff --git a/decoder/ixheaacd_mps_pre_mix.c b/decoder/ixheaacd_mps_pre_mix.c new file mode 100644 index 0000000..3c31a0b --- /dev/null +++ b/decoder/ixheaacd_mps_pre_mix.c @@ -0,0 +1,691 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" + +#include +#include "ixheaacd_constants.h" +#include +#include + +#include +#include + +#include + +#undef ABS_THR +#define ABS_THR 1.0e-9f + +#define ICC_FIX +#define UNSINGULARIZE_FIX +#define QUANTIZE_PARS_FIX + +#define PI 3.14159265358979f + +#define ONE_IN_Q28 (268435456) +#define MINUS_ONE_IN_Q28 (-268435456) +#define PI_Q28 (843314856) +#define PI_Q27 (421657428) +#define PI_BY_8_Q28 (105414352) + +extern const WORD32 ixheaacd_im_weight_Q28[16][8][31]; +extern const WORD32 ixheaacd_re_weight_Q28[16][8][31]; +extern const WORD32 ixheaacd_beta_Q28[16][8][31]; +extern const WORD32 ixheaacd_weight_Q28[16][8][31]; +extern const WORD32 ixheaacd_c_l_table_Q31[31]; +extern const WORD32 ixheaacd_sin_table_Q31[16][31]; +extern const WORD32 ixheaacd_cos_table_Q31[16][31]; +extern const WORD32 ixheaacd_atan_table_Q28[16][8][31]; +extern 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 + +static WORD32 ixheaacd_mps_phase_wraping(WORD32 phase) { + const WORD32 pi_2 = 2 * PI_IN_Q28; + + while (phase < 0) phase += pi_2; + while (phase >= pi_2) phase -= pi_2; + assert((phase >= 0) && (phase < pi_2)); + + return phase; +} + +static VOID ixheaacd_mps_buffer_pre_and_mix_matrix( + ia_mps_dec_state_struct *self) { + WORD32 pb, row, col; + + for (pb = 0; pb < self->bs_param_bands; pb++) { + for (row = 0; row < MAX_M_INPUT; row++) { + for (col = 0; col < MAX_M_OUTPUT; col++) { + self->m1_param_re_prev[pb][row][col] = + self->m1_param_re[self->num_parameter_sets_prev - 1][pb][row][col]; + self->m1_param_im_prev[pb][row][col] = + self->m1_param_im[self->num_parameter_sets_prev - 1][pb][row][col]; + self->m2_decor_re_prev[pb][row][col] = + self->m2_decor_re[self->num_parameter_sets_prev - 1][pb][row][col]; + self->m2_decor_im_prev[pb][row][col] = + self->m2_decor_im[self->num_parameter_sets_prev - 1][pb][row][col]; + self->m2_resid_re_prev[pb][row][col] = + self->m2_resid_re[self->num_parameter_sets_prev - 1][pb][row][col]; + self->m2_resid_im_prev[pb][row][col] = + self->m2_resid_im[self->num_parameter_sets_prev - 1][pb][row][col]; + } + } + } + + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->phase_l_prev[pb] = + self->phase_l[self->num_parameter_sets_prev - 1][pb]; + self->phase_r_prev[pb] = + self->phase_r[self->num_parameter_sets_prev - 1][pb]; + } +} + +VOID ixheaacd_fix_to_float_int(WORD32 *inp, FLOAT32 *out, WORD32 length, + FLOAT32 q_fac) { + WORD32 i; + FLOAT32 m_qfac = 1.0f / q_fac; + + for (i = 0; i < length; i++) out[i] = (FLOAT32)(inp[i]) * m_qfac; +} + +VOID ixheaacd_pre_and_mix_matrix_calculation(ia_mps_dec_state_struct *self) { + WORD32 ps, pb; + ia_mps_bs_frame *curr_bit_stream = &(self->bs_frame); + WORD32 h_imag[2 * MAX_PARAMETER_BANDS]; + WORD32 + h_real[6 * MAX_PARAMETER_BANDS]; + + ixheaacd_mps_buffer_pre_and_mix_matrix(self); + + for (ps = 0; ps < self->num_parameter_sets; ps++) { + WORD32 *h_im = &h_imag[0]; + WORD32 *h_re = &h_real[0]; + memset(h_real, 0, 6 * MAX_PARAMETER_BANDS * sizeof(WORD32)); + memset(h_imag, 0, 2 * MAX_PARAMETER_BANDS * sizeof(WORD32)); + + switch (self->config->bs_phase_coding) { + case 0: + if (self->residual_coding) { + ixheaacd_mps_par2umx_pred(self, curr_bit_stream, h_imag, h_real, ps, + self->res_bands); + } else { + ixheaacd_mps_par2umx_ps(self, curr_bit_stream, h_real, ps); + } + + break; + case 1: + ixheaacd_mps_par2umx_ps_ipd_opd(self, curr_bit_stream, h_real, ps); + break; + case 2: + ixheaacd_mps_par2umx_pred(self, curr_bit_stream, h_imag, h_real, ps, + self->res_bands); + break; + } + + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->m1_param_re[ps][pb][0][0] = 1073741824; + self->m1_param_re[ps][pb][1][0] = 1073741824; + + self->m1_param_im[ps][pb][0][0] = 0; + self->m1_param_im[ps][pb][1][0] = 0; + + self->m2_resid_re[ps][pb][0][0] = *h_re++; + self->m2_resid_im[ps][pb][0][0] = *h_im++; + self->m2_resid_im[ps][pb][0][1] = 0; + + self->m2_resid_re[ps][pb][1][0] = *h_re++; + self->m2_resid_im[ps][pb][1][0] = *h_im++; + self->m2_resid_im[ps][pb][1][1] = 0; + + self->m2_decor_re[ps][pb][0][0] = 0; + self->m2_decor_im[ps][pb][0][0] = 0; + self->m2_decor_re[ps][pb][0][1] = *h_re++; + self->m2_decor_im[ps][pb][0][1] = 0; + + self->m2_decor_re[ps][pb][1][0] = 0; + self->m2_decor_im[ps][pb][1][0] = 0; + self->m2_decor_re[ps][pb][1][1] = *h_re++; + self->m2_decor_im[ps][pb][1][1] = 0; + + self->m2_resid_re[ps][pb][0][1] = *h_re++; + self->m2_resid_re[ps][pb][1][1] = *h_re++; + } + } + ixheaacd_mps_smoothing_opd(self); + + ixheaacd_fix_to_float_int(&self->phase_l_fix[0][0], &self->phase_l[0][0], + MAX_PARAMETER_SETS_MPS * MAX_PARAMETER_BANDS, + 268435456.0f); + ixheaacd_fix_to_float_int(&self->phase_r_fix[0][0], &self->phase_r[0][0], + MAX_PARAMETER_SETS_MPS * MAX_PARAMETER_BANDS, + 268435456.0f); +} + +static VOID ixheaacd_mps_par2umx_ps_core(WORD32 cld[MAX_PARAMETER_BANDS], + WORD32 icc[MAX_PARAMETER_BANDS], + WORD32 ott_band_count, + WORD32 *h_real) { + WORD32 band; + WORD32 c_l_temp, c_r_temp, cld_idx, icc_idx, temp; + + for (band = 0; band < ott_band_count; band++) { + cld_idx = *cld++ + 15; + icc_idx = *icc++; + + c_l_temp = (ixheaacd_c_l_table_Q31[cld_idx]); + c_r_temp = (ixheaacd_c_l_table_Q31[30 - cld_idx]); + + temp = ixheaacd_cos_table_Q31[icc_idx][cld_idx]; + *h_real++ = ixheaacd_mult32(temp, c_l_temp) >> 2; + + temp = ixheaacd_cos_table_Q31[icc_idx][30 - cld_idx]; + *h_real++ = ixheaacd_mult32(temp, c_r_temp) >> 2; + + temp = ixheaacd_sin_table_Q31[icc_idx][cld_idx]; + *h_real++ = ixheaacd_mult32(temp, c_l_temp) >> 2; + + temp = -ixheaacd_sin_table_Q31[icc_idx][30 - cld_idx]; + *h_real++ = ixheaacd_mult32(temp, c_r_temp) >> 2; + + h_real += 2; + } +} + +VOID ixheaacd_mps_par2umx_ps(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, WORD32 *h_real, + WORD32 param_set_idx) { + ixheaacd_mps_par2umx_ps_core(curr_bit_stream->cld_idx[param_set_idx], + curr_bit_stream->icc_idx[param_set_idx], + self->bs_param_bands, h_real); +} + +static VOID ixheaacd_mps_opd_calc(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, + WORD32 param_set_idx, + WORD32 opd[MAX_PARAMETER_BANDS]) { + WORD32 band; + + for (band = 0; band < self->num_bands_ipd; band++) { + WORD32 cld_idx = curr_bit_stream->cld_idx[param_set_idx][band] + 15; + WORD32 ipd_idx = (curr_bit_stream->ipd_idx[param_set_idx][band]) & 15; + WORD32 icc_idx = curr_bit_stream->icc_idx[param_set_idx][band]; + + if ((cld_idx == 15) && (ipd_idx == 8)) + opd[band] = 0; + else + opd[band] = ixheaacd_atan_table_Q28[ipd_idx][icc_idx][cld_idx]; + } +} + +VOID ixheaacd_mps_par2umx_ps_ipd_opd(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, + WORD32 *h_real, WORD32 param_set_idx) { + WORD32 opd[MAX_PARAMETER_BANDS]; + WORD32 ott_band_count = self->bs_param_bands; + WORD32 num_bands_ipd = self->num_bands_ipd; + WORD32 band; + + ixheaacd_mps_par2umx_ps_core(curr_bit_stream->cld_idx[param_set_idx], + curr_bit_stream->icc_idx[param_set_idx], + ott_band_count, h_real); + + if (self->bs_phase_mode) { + ixheaacd_mps_opd_calc(self, curr_bit_stream, param_set_idx, opd); + + for (band = 0; band < num_bands_ipd; band++) { + WORD32 ipd_idx = curr_bit_stream->ipd_idx[param_set_idx][band] & 15; + WORD32 ipd = ixheaacd_ipd_de_quant_table_q28[ipd_idx]; + + self->phase_l_fix[param_set_idx][band] = + ixheaacd_mps_phase_wraping(opd[band]); + self->phase_r_fix[param_set_idx][band] = + ixheaacd_mps_phase_wraping(opd[band] - ipd); + } + } else { + num_bands_ipd = 0; + } + + for (band = num_bands_ipd; band < ott_band_count; band++) { + self->phase_l_fix[param_set_idx][band] = 0; + self->phase_r_fix[param_set_idx][band] = 0; + } +} + +VOID ixheaacd_mps_par2umx_pred(ia_mps_dec_state_struct *self, + ia_mps_bs_frame *curr_bit_stream, WORD32 *h_imag, + WORD32 *h_real, WORD32 param_set_idx, + WORD32 res_bands) { + WORD32 band; + + for (band = 0; band < self->bs_param_bands; band++) { + WORD32 cld_idx = curr_bit_stream->cld_idx[param_set_idx][band] + 15; + WORD32 icc_idx = curr_bit_stream->icc_idx[param_set_idx][band]; + WORD32 ipd_idx = curr_bit_stream->ipd_idx[param_set_idx][band] & 15; + + if ((band < self->num_bands_ipd) && (cld_idx == 15) && (icc_idx == 0) && + (ipd_idx == 8)) { + WORD32 gain = 111848107; + *h_imag++ = 0; + *h_imag++ = 0; + + if (band < res_bands) { + *h_real++ = gain; + *h_real++ = gain; + h_real += 2; + + *h_real++ = gain; + *h_real++ = -gain; + } else { + *h_real++ = gain; + *h_real++ = -gain; + + h_real += 4; + } + } else { + WORD32 weight_fix, re_weight_fix, im_weight_fix; + + weight_fix = ixheaacd_weight_Q28[ipd_idx][icc_idx][cld_idx]; + re_weight_fix = ixheaacd_re_weight_Q28[ipd_idx][icc_idx][cld_idx]; + im_weight_fix = ixheaacd_im_weight_Q28[ipd_idx][icc_idx][cld_idx]; + + if (band < self->num_bands_ipd) { + weight_fix = ixheaacd_weight_Q28[ipd_idx][icc_idx][cld_idx]; + re_weight_fix = ixheaacd_re_weight_Q28[ipd_idx][icc_idx][cld_idx]; + im_weight_fix = ixheaacd_im_weight_Q28[ipd_idx][icc_idx][cld_idx]; + } else { + weight_fix = ixheaacd_weight_Q28[0][icc_idx][cld_idx]; + re_weight_fix = ixheaacd_re_weight_Q28[0][icc_idx][cld_idx]; + im_weight_fix = ixheaacd_im_weight_Q28[0][icc_idx][cld_idx]; + } + + *h_real++ = weight_fix - re_weight_fix; + *h_imag++ = -im_weight_fix; + *h_real++ = weight_fix + re_weight_fix; + *h_imag++ = im_weight_fix; + + if (band < res_bands) { + h_real += 2; + + *h_real++ = weight_fix; + *h_real++ = -weight_fix; + } else { + WORD32 beta = ixheaacd_beta_Q28[ipd_idx][icc_idx][cld_idx]; + + *h_real++ = beta; + *h_real++ = -beta; + h_real += 2; + } + } + } +} + +VOID ixheaacd_mps_apply_pre_matrix(ia_mps_dec_state_struct *self) { + WORD32 ts, qs, row, col = 0; + + ixheaacd_mps_upmix_interp( + self->m1_param_re, self->r_out_re_scratch_m1, self->m1_param_re_prev, + (self->dir_sig_count + self->decor_sig_count), 1, self); + ixheaacd_mps_upmix_interp( + self->m1_param_im, self->r_out_im_scratch_m1, self->m1_param_im_prev, + (self->dir_sig_count + self->decor_sig_count), 1, self); + + ixheaacd_fix_to_float_int( + (WORD32 *)(self->r_out_re_scratch_m1), (FLOAT32 *)(self->r_out_re_in_m1), + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 1073741824); + ixheaacd_fix_to_float_int( + (WORD32 *)self->r_out_im_scratch_m1, (FLOAT32 *)self->r_out_im_in_m1, + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 1073741824); + + for (ts = 0; ts < self->time_slots; ts++) { + for (qs = 0; qs < 2; qs++) { + WORD32 sign = -1; + WORD32 indx = self->hyb_band_to_processing_band_table[qs]; + for (row = 0; row < (self->dir_sig_count + self->decor_sig_count); + row++) { + FLOAT32 sum_real = 0.0f; + FLOAT32 sum_imag = 0.0f; + + { + FLOAT32 real = self->hyb_in[0][ts][qs].re * + self->r_out_re_in_m1[ts][indx][row][col] - + self->hyb_in[0][ts][qs].im * + self->r_out_im_in_m1[ts][indx][row][col] * sign; + FLOAT32 imag = self->hyb_in[0][ts][qs].re * + self->r_out_im_in_m1[ts][indx][row][col] * sign + + self->hyb_in[0][ts][qs].im * + self->r_out_re_in_m1[ts][indx][row][col]; + sum_real += real; + sum_imag += imag; + } + self->v[row][ts][qs].re = sum_real; + self->v[row][ts][qs].im = sum_imag; + } + } + for (qs = 2; qs < self->hyb_band_count; qs++) { + WORD32 sign = 1; + WORD32 indx = self->hyb_band_to_processing_band_table[qs]; + for (row = 0; row < (self->dir_sig_count + self->decor_sig_count); + row++) { + FLOAT32 sum_real = 0.0f; + FLOAT32 sum_imag = 0.0f; + + { + FLOAT32 real = self->hyb_in[0][ts][qs].re * + self->r_out_re_in_m1[ts][indx][row][col] - + self->hyb_in[0][ts][qs].im * + self->r_out_im_in_m1[ts][indx][row][col] * sign; + FLOAT32 imag = self->hyb_in[0][ts][qs].re * + self->r_out_im_in_m1[ts][indx][row][col] * sign + + self->hyb_in[0][ts][qs].im * + self->r_out_re_in_m1[ts][indx][row][col]; + sum_real += real; + sum_imag += imag; + } + self->v[row][ts][qs].re = sum_real; + self->v[row][ts][qs].im = sum_imag; + } + } + } +} + +VOID ixheaacd_mps_apply_mix_matrix(ia_mps_dec_state_struct *self) { + WORD32 ts, qs, row, col; + WORD32 complex_m2 = ((self->config->bs_phase_coding != 0)); + WORD32 phase_interpolation = (self->config->bs_phase_coding == 1); + + ixheaacd_mps_upmix_interp( + self->m2_decor_re, self->r_diff_out_re_fix_in_m2, self->m2_decor_re_prev, + self->out_ch_count, (self->dir_sig_count + self->decor_sig_count), self); + ixheaacd_mps_upmix_interp( + self->m2_resid_re, self->r_out_re_fix_in_m2, self->m2_resid_re_prev, + self->out_ch_count, (self->dir_sig_count + self->decor_sig_count), self); + ixheaacd_fix_to_float_int( + (WORD32 *)self->r_out_re_fix_in_m2, (FLOAT32 *)self->r_out_re_in_m2, + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 268435456); + ixheaacd_fix_to_float_int( + (WORD32 *)self->r_diff_out_re_fix_in_m2, + (FLOAT32 *)self->r_out_diff_re_in_m2, + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 268435456); + + if (complex_m2 && !phase_interpolation) { + ixheaacd_mps_upmix_interp(self->m2_decor_im, self->r_diff_out_im_fix_in_m2, + self->m2_decor_im_prev, self->out_ch_count, + (self->dir_sig_count + self->decor_sig_count), + self); + ixheaacd_mps_upmix_interp(self->m2_resid_im, self->r_out_im_fix_in_m2, + self->m2_resid_im_prev, self->out_ch_count, + (self->dir_sig_count + self->decor_sig_count), + self); + ixheaacd_fix_to_float_int( + (WORD32 *)self->r_diff_out_im_fix_in_m2, + (FLOAT32 *)self->r_out_diff_im_in_m2, + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 268435456); + ixheaacd_fix_to_float_int( + (WORD32 *)self->r_out_im_fix_in_m2, (FLOAT32 *)self->r_out_im_in_m2, + MAX_TIME_SLOTS * MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT, + 268435456); + } + + if (phase_interpolation) { + ixheaacd_mps_phase_interpolation( + self->phase_l, self->phase_r, self->phase_l_prev, self->phase_r_prev, + self->r_out_ph_re_in_m2, self->r_out_ph_im_in_m2, self); + + for (ts = 0; ts < self->time_slots; ts++) { + WORD32 pb; + for (pb = 0; pb < self->bs_param_bands; pb++) { + for (row = 0; row < self->out_ch_count; row++) { + for (col = 0; col < (self->dir_sig_count + self->decor_sig_count); + col++) { + self->r_out_im_in_m2[ts][pb][row][col] = + self->r_out_re_in_m2[ts][pb][row][col] * + self->r_out_ph_im_in_m2[ts][pb][row]; + self->r_out_re_in_m2[ts][pb][row][col] = + self->r_out_re_in_m2[ts][pb][row][col] * + self->r_out_ph_re_in_m2[ts][pb][row]; + + self->r_out_diff_im_in_m2[ts][pb][row][col] = + self->r_out_diff_re_in_m2[ts][pb][row][col] * + self->r_out_ph_im_in_m2[ts][pb][row]; + self->r_out_diff_re_in_m2[ts][pb][row][col] = + self->r_out_diff_re_in_m2[ts][pb][row][col] * + self->r_out_ph_re_in_m2[ts][pb][row]; + } + } + } + } + } + + for (ts = 0; ts < self->time_slots; ts++) { + for (qs = 0; qs < self->hyb_band_count; qs++) { + WORD32 indx = self->hyb_band_to_processing_band_table[qs]; + for (row = 0; row < self->out_ch_count; row++) { + FLOAT32 sum_re_dir = 0; + FLOAT32 sum_re_diff = 0; + FLOAT32 sum_im_dir = 0; + FLOAT32 sum_im_diff = 0; + for (col = 0; col < (self->dir_sig_count + self->decor_sig_count); + col++) { + sum_re_dir += self->w_dir[col][ts][qs].re * + self->r_out_re_in_m2[ts][indx][row][col]; + sum_im_dir += self->w_dir[col][ts][qs].im * + self->r_out_re_in_m2[ts][indx][row][col]; + sum_re_diff += self->w_diff[col][ts][qs].re * + self->r_out_diff_re_in_m2[ts][indx][row][col]; + sum_im_diff += self->w_diff[col][ts][qs].im * + self->r_out_diff_re_in_m2[ts][indx][row][col]; + } + self->hyb_dir_out[row][ts][qs].re = sum_re_dir; + self->hyb_dir_out[row][ts][qs].im = sum_im_dir; + self->hyb_diff_out[row][ts][qs].re = sum_re_diff; + self->hyb_diff_out[row][ts][qs].im = sum_im_diff; + } + } + } + + if (complex_m2) { + for (ts = 0; ts < self->time_slots; ts++) { + for (qs = 0; qs < 2; qs++) { + WORD32 indx = self->hyb_band_to_processing_band_table[qs]; + for (row = 0; row < self->out_ch_count; row++) { + FLOAT32 sum_re_dir = self->hyb_dir_out[row][ts][qs].re; + FLOAT32 sum_im_dir = self->hyb_dir_out[row][ts][qs].im; + FLOAT32 sum_re_diff = self->hyb_diff_out[row][ts][qs].re; + FLOAT32 sum_im_diff = self->hyb_diff_out[row][ts][qs].im; + for (col = 0; col < (self->dir_sig_count + self->decor_sig_count); + col++) { + sum_re_dir += self->w_dir[col][ts][qs].im * + self->r_out_im_in_m2[ts][indx][row][col]; + sum_im_dir -= self->w_dir[col][ts][qs].re * + self->r_out_im_in_m2[ts][indx][row][col]; + sum_re_diff += self->w_diff[col][ts][qs].im * + self->r_out_diff_im_in_m2[ts][indx][row][col]; + sum_im_diff -= self->w_diff[col][ts][qs].re * + self->r_out_diff_im_in_m2[ts][indx][row][col]; + } + self->hyb_dir_out[row][ts][qs].re = sum_re_dir; + self->hyb_dir_out[row][ts][qs].im = sum_im_dir; + self->hyb_diff_out[row][ts][qs].re = sum_re_diff; + self->hyb_diff_out[row][ts][qs].im = sum_im_diff; + } + } + for (qs = 2; qs < self->hyb_band_count; qs++) { + WORD32 indx = self->hyb_band_to_processing_band_table[qs]; + for (row = 0; row < self->out_ch_count; row++) { + FLOAT32 sum_re_dir = self->hyb_dir_out[row][ts][qs].re; + FLOAT32 sum_im_dir = self->hyb_dir_out[row][ts][qs].im; + FLOAT32 sum_re_diff = self->hyb_diff_out[row][ts][qs].re; + FLOAT32 sum_im_diff = self->hyb_diff_out[row][ts][qs].im; + for (col = 0; col < (self->dir_sig_count + self->decor_sig_count); + col++) { + sum_re_dir -= self->w_dir[col][ts][qs].im * + self->r_out_im_in_m2[ts][indx][row][col]; + sum_im_dir += self->w_dir[col][ts][qs].re * + self->r_out_im_in_m2[ts][indx][row][col]; + sum_re_diff -= self->w_diff[col][ts][qs].im * + self->r_out_diff_im_in_m2[ts][indx][row][col]; + sum_im_diff += self->w_diff[col][ts][qs].re * + self->r_out_diff_im_in_m2[ts][indx][row][col]; + } + self->hyb_dir_out[row][ts][qs].re = sum_re_dir; + self->hyb_dir_out[row][ts][qs].im = sum_im_dir; + self->hyb_diff_out[row][ts][qs].re = sum_re_diff; + self->hyb_diff_out[row][ts][qs].im = sum_im_diff; + } + } + } + } +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32_shl2(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + result = (WORD32)(temp_result >> 30); + + return (result); +} + +VOID ixheaacd_mps_upmix_interp( + WORD32 m_matrix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT], + WORD32 r_matrix[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT] + [MAX_M_INPUT], + WORD32 m_matrix_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT], + WORD32 num_rows, WORD32 num_cols, ia_mps_dec_state_struct *self) { + WORD32 ts, ps, pb, row, col, i; + + for (pb = 0; pb < self->bs_param_bands; pb++) { + for (row = 0; row < num_rows; row++) { + for (col = 0; col < num_cols; col++) { + ps = 0; + ts = 0; + for (i = 1; i <= (WORD32)self->param_slot_diff[0]; i++) { + WORD32 alpha = i * self->inv_param_slot_diff_Q30[ps]; + WORD32 one_minus_alpha = 1073741824 - alpha; + r_matrix[ts][pb][row][col] = + ((ixheaacd_mult32_shl2(m_matrix_prev[pb][row][col], + one_minus_alpha) + + ixheaacd_mult32_shl2(alpha, m_matrix[ps][pb][row][col]))); + ts++; + } + + for (ps = 1; ps < self->num_parameter_sets; ps++) { + for (i = 1; i <= (WORD32)self->param_slot_diff[ps]; i++) { + WORD32 alpha = i * self->inv_param_slot_diff_Q30[ps]; + WORD32 one_minus_alpha = 1073741824 - alpha; + r_matrix[ts][pb][row][col] = + ((ixheaacd_mult32_shl2(m_matrix[ps - 1][pb][row][col], + one_minus_alpha) + + ixheaacd_mult32_shl2(alpha, m_matrix[ps][pb][row][col]))); + ts++; + } + } + } + } + } +} + +static FLOAT32 ixheaacd_mps_angle_interpolation(FLOAT32 angle1, FLOAT32 angle2, + FLOAT32 alpha) { + while (angle2 - angle1 > (FLOAT32)P_PI) + angle1 = angle1 + 2.0f * (FLOAT32)P_PI; + while (angle1 - angle2 > (FLOAT32)P_PI) + angle2 = angle2 + 2.0f * (FLOAT32)P_PI; + + return (1 - alpha) * angle1 + alpha * angle2; +} + +VOID ixheaacd_mps_phase_interpolation( + FLOAT32 pl[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + FLOAT32 pr[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS], + FLOAT32 pl_prev[MAX_PARAMETER_BANDS], FLOAT32 pr_prev[MAX_PARAMETER_BANDS], + FLOAT32 r_re[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2], + FLOAT32 r_im[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][2], + ia_mps_dec_state_struct *self) { + WORD32 ts, ps, pb; + WORD32 i; + for (pb = 0; pb < self->bs_param_bands; pb++) { + ps = 0; + ts = 0; + for (i = 1; i <= self->param_slot_diff[ps]; i++) { + FLOAT32 alpha = (FLOAT32)i * self->inv_param_slot_diff[ps]; + FLOAT32 t; + + t = ixheaacd_mps_angle_interpolation(pl_prev[pb], pl[ps][pb], alpha); + r_re[ts][pb][0] = (FLOAT32)cos(t); + r_im[ts][pb][0] = (FLOAT32)sin(t); + + t = ixheaacd_mps_angle_interpolation(pr_prev[pb], pr[ps][pb], alpha); + r_re[ts][pb][1] = (FLOAT32)cos(t); + r_im[ts][pb][1] = (FLOAT32)sin(t); + ts++; + } + + for (ps = 1; ps < self->num_parameter_sets; ps++) { + for (i = 1; i <= self->param_slot_diff[ps]; i++) { + FLOAT32 alpha = (FLOAT32)i * self->inv_param_slot_diff[ps]; + FLOAT32 t; + + t = ixheaacd_mps_angle_interpolation(pl[ps - 1][pb], pl[ps][pb], alpha); + r_re[ts][pb][0] = (FLOAT32)cos(t); + r_im[ts][pb][0] = (FLOAT32)sin(t); + + t = ixheaacd_mps_angle_interpolation(pr[ps - 1][pb], pr[ps][pb], alpha); + r_re[ts][pb][1] = (FLOAT32)cos(t); + r_im[ts][pb][1] = (FLOAT32)sin(t); + ts++; + } + } + } +} + +VOID ixheaacd_mps_init_pre_and_post_matrix(ia_mps_dec_state_struct *self) { + memset(self->m1_param_re_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); + memset(self->m1_param_im_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); + memset(self->m1_param_re_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); + memset(self->m2_decor_re_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); + memset(self->m2_resid_re_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); + memset(self->m2_resid_im_prev, 0, + MAX_PARAMETER_BANDS * MAX_M_OUTPUT * MAX_M_INPUT * sizeof(WORD32)); +} diff --git a/decoder/ixheaacd_mps_process.h b/decoder/ixheaacd_mps_process.h new file mode 100644 index 0000000..97b7090 --- /dev/null +++ b/decoder/ixheaacd_mps_process.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_MPS_PROCESS_H +#define IXHEAACD_MPS_PROCESS_H + +VOID ixheaacd_mps_res_buf_copy(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_qmf_hyb_analysis(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_qmf_hyb_synthesis(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_decor(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_create_w(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_create_x(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_mix_res_decor(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_buffer_update(ia_mps_dec_state_struct* self); +VOID ixheaacd_mps_synt_calc(ia_mps_dec_state_struct* self); + +#endif diff --git a/decoder/ixheaacd_mps_rom.c b/decoder/ixheaacd_mps_rom.c new file mode 100644 index 0000000..680d62a --- /dev/null +++ b/decoder/ixheaacd_mps_rom.c @@ -0,0 +1,5030 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include + +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" + +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_mps_nlc_dec.h" +#include "ixheaacd_mps_huff_tab.h" + +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}, + {-18, 20}, {-19, 21}, {-20, -21}, {-23, 22}, {-22, 23}, {-24, 24}, + {-25, 25}, {27, 26}, {29, 28}, {-30, -31}, {-28, -29}, {-26, -27}}}, + {{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, + {-7, 7}, {9, 8}, {-8, 10}, {-9, 11}, {-10, 12}, {-11, 13}, + {-12, 14}, {-13, 15}, {-14, 16}, {-15, 17}, {-16, 18}, {-17, 19}, + {-18, 20}, {-19, -20}, {-21, 21}, {-22, 22}, {-23, 23}, {25, 24}, + {-24, 26}, {-25, 27}, {29, 28}, {-26, -31}, {-29, -30}, {-27, -28}}}, + {{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, + {-7, 7}, {9, 8}, {-8, 10}, {-9, 11}, {-10, 12}, {-11, 13}, + {-12, 14}, {-13, 15}, {-14, 16}, {-15, 17}, {-16, 18}, {-17, 19}, + {-18, 20}, {-19, -20}, {-21, 21}, {-22, 22}, {-23, 23}, {25, 24}, + {-24, 26}, {-25, 27}, {29, 28}, {-26, -31}, {-29, -30}, {-27, -28}}}}, + {{{{{2, 1}, + {-1, -52}, + {4, 3}, + {-2, 5}, + {-51, 6}, + {-17, -18}, + {8, 7}, + {10, 9}, + {-3, -36}, + {-19, 11}, + {-35, -50}, + {-34, 12}, + {-4, 13}, + {-33, 14}, + {-20, -49}}, + {{2, 1}, {4, 3}, {-86, 5}, {7, 6}, {9, 8}, {-1, -2}, + {-85, 10}, {-18, 11}, {-17, 12}, {14, 13}, {-70, 15}, {17, 16}, + {-19, -69}, {-84, 18}, {-3, 19}, {21, 20}, {-34, -68}, {-20, 22}, + {-35, 23}, {-83, 24}, {-33, 25}, {-4, 26}, {-53, 27}, {-54, -67}, + {-36, 28}, {-21, -52}, {-82, 29}, {-5, -50}, {-51, 30}, {-38, 31}, + {-37, -49}, {-6, 32}, {-66, 33}, {-65, 34}, {-22, -81}}, + {{2, 1}, {4, 3}, {-120, 5}, {7, 6}, {9, 8}, + {11, 10}, {-1, 12}, {-18, -119}, {-2, 13}, {15, 14}, + {-17, 16}, {-104, 17}, {19, 18}, {-19, 20}, {-103, 21}, + {-118, 22}, {24, 23}, {-3, 25}, {27, 26}, {-34, 28}, + {-102, 29}, {-20, 30}, {-35, 31}, {33, 32}, {-117, 34}, + {-33, 35}, {-88, 36}, {-4, 37}, {-87, 38}, {40, 39}, + {-36, -101}, {-86, 41}, {-21, -37}, {-85, -100}, {-52, 42}, + {-22, 43}, {-116, 44}, {-50, 45}, {47, 46}, {-5, -51}, + {-115, 48}, {-70, 49}, {-84, 50}, {-38, -49}, {-72, -99}, + {-53, 51}, {-69, -71}, {-23, 52}, {-6, -67}, {-114, 53}, + {-7, 54}, {-66, -68}, {-55, 55}, {57, 56}, {-54, -65}, + {-8, -56}, {-82, -83}, {59, 58}, {-39, -40}, {-81, 60}, + {-98, 61}, {-97, 62}, {-24, -113}}, + {{2, 1}, {4, 3}, {6, 5}, {-154, 7}, {9, 8}, + {11, 10}, {13, 12}, {15, 14}, {-18, 16}, {-153, 17}, + {-1, -2}, {19, 18}, {-138, 20}, {-17, 21}, {23, 22}, + {25, 24}, {-19, -137}, {27, 26}, {-152, 28}, {30, 29}, + {-3, -34}, {32, 31}, {34, 33}, {36, 35}, {-136, 37}, + {-35, 38}, {-20, 39}, {-122, 40}, {-151, 41}, {-33, 42}, + {-121, 43}, {45, 44}, {47, 46}, {-4, 48}, {-36, -120}, + {-135, 49}, {51, 50}, {-21, 52}, {54, 53}, {56, 55}, + {-50, -150}, {58, 57}, {-51, 59}, {61, 60}, {-119, 62}, + {-52, 63}, {-5, 64}, {-37, 65}, {-117, -134}, {-39, -54}, + {-22, 66}, {-106, 67}, {-69, -102}, {-132, 68}, {-105, 69}, + {-49, 70}, {-149, 71}, {-24, -104}, {73, 72}, {-53, 74}, + {-38, -118}, {-103, 75}, {-6, 76}, {-66, -87}, {-133, -147}, + {-23, 77}, {-67, 78}, {-68, -86}, {-70, -101}, {-40, -148}, + {-116, 79}, {-55, 80}, {-84, -131}, {82, 81}, {-89, -90}, + {-7, -25}, {-85, -88}, {-65, 83}, {-72, -146}, {85, 84}, + {-9, -71}, {-83, 86}, {-82, 87}, {-8, 88}, {-100, 89}, + {-74, -99}, {-73, 90}, {-10, -81}, {-56, 91}, {-57, -98}, + {93, 92}, {-58, -114}, {-97, -115}, {95, 94}, {-41, 96}, + {-42, 97}, {-26, -129}, {-113, 98}, {-130, -145}}}, + {{{-1, 1}, + {-52, 2}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-33, 7}, + {-2, -18}, + {-20, 8}, + {10, 9}, + {-34, -49}, + {-51, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {4, 3}, {-86, 5}, {-1, 6}, {-17, 7}, {-70, 8}, + {10, 9}, {-18, 11}, {-33, 12}, {-54, 13}, {-2, 14}, {-34, 15}, + {-38, 16}, {-49, 17}, {-85, 18}, {-50, 19}, {-69, 20}, {-53, -65}, + {-22, 21}, {-66, 22}, {-19, 23}, {-37, 24}, {-35, -81}, {-3, 25}, + {-51, 26}, {-68, -84}, {-52, 27}, {29, 28}, {-20, 30}, {-4, -36}, + {-83, 31}, {-67, 32}, {-21, 33}, {-5, 34}, {-6, -82}}, + {{2, 1}, {4, 3}, {6, 5}, {-120, 7}, {-17, 8}, + {-1, -104}, {10, 9}, {12, 11}, {-18, 13}, {-33, -88}, + {15, 14}, {17, 16}, {-2, 18}, {-34, 19}, {-72, 20}, + {-49, 21}, {-119, 22}, {-50, 23}, {-103, 24}, {-56, 25}, + {-65, 26}, {28, 27}, {-40, -87}, {-66, 29}, {-82, 30}, + {32, 31}, {-19, -81}, {-71, 33}, {-97, 34}, {-35, -55}, + {-24, 35}, {37, 36}, {-3, -98}, {-51, 38}, {-67, 39}, + {-39, -118}, {-113, 40}, {-102, 41}, {-86, 42}, {-70, -83}, + {44, 43}, {-20, -54}, {-52, 45}, {-36, 46}, {-4, 47}, + {-68, 48}, {-85, 49}, {-101, -117}, {-69, 50}, {52, 51}, + {-21, -37}, {-53, 53}, {55, 54}, {-5, -100}, {-116, 56}, + {-84, 57}, {-38, 58}, {-22, -99}, {-115, 59}, {-6, 60}, + {-23, 61}, {-7, 62}, {-114, 0}}, + {{2, 1}, {4, 3}, {6, 5}, {-154, 7}, {9, 8}, + {-17, 10}, {-138, 11}, {-1, 12}, {14, 13}, {16, 15}, + {-33, -122}, {-18, 17}, {19, 18}, {-34, 20}, {-2, 21}, + {-106, 22}, {-49, 23}, {25, 24}, {-50, 26}, {-153, 27}, + {-90, 28}, {-137, 29}, {-65, 30}, {32, 31}, {-66, 33}, + {-121, 34}, {-74, 35}, {-81, 36}, {38, 37}, {-42, 39}, + {-82, 40}, {-105, 41}, {-19, -114}, {-58, 42}, {-35, 43}, + {-97, 44}, {46, 45}, {-129, 47}, {-26, -89}, {-57, -98}, + {-51, 48}, {-3, 49}, {-113, 50}, {-130, 51}, {-152, 52}, + {-67, -73}, {-99, -136}, {-145, 53}, {-120, 54}, {-41, 55}, + {-83, 56}, {-72, 57}, {-104, 58}, {-115, 59}, {-20, 60}, + {62, 61}, {-36, -88}, {-84, 63}, {-52, -56}, {65, 64}, + {-4, -87}, {-68, 66}, {-151, 67}, {-100, -135}, {69, 68}, + {-69, -119}, {-103, 70}, {-71, 71}, {73, 72}, {-21, 74}, + {-85, 75}, {-37, -53}, {-86, 76}, {78, 77}, {-102, -150}, + {-5, 79}, {-134, 80}, {-118, 81}, {-54, -117}, {83, 82}, + {-38, -70}, {-22, 84}, {-6, 85}, {87, 86}, {-55, 88}, + {-101, 89}, {-133, -149}, {-24, -39}, {91, 90}, {-132, 92}, + {-23, 93}, {-7, 94}, {-147, -148}, {-116, -131}, {-25, 95}, + {-40, 0}, {0, 0}, {0, 0}, {0, 0}}}}, + {{{{-1, 1}, + {-52, 2}, + {-17, 3}, + {5, 4}, + {-2, -36}, + {-18, 6}, + {8, 7}, + {-51, 9}, + {-33, 10}, + {-34, 11}, + {-20, -35}, + {-19, 12}, + {-3, 13}, + {-49, 14}, + {-4, -50}}, + {{2, 1}, {-86, 3}, {-1, 4}, {-17, 5}, {7, 6}, {-70, 8}, + {-2, -18}, {10, 9}, {12, 11}, {-85, 13}, {-33, 14}, {-34, -54}, + {16, 15}, {-69, 17}, {19, 18}, {-50, -53}, {-19, 20}, {-38, 21}, + {-35, -49}, {-3, 22}, {24, 23}, {-68, 25}, {-84, 26}, {-65, 27}, + {-51, -66}, {-22, -37}, {-52, 28}, {-20, 29}, {-36, 30}, {-81, 31}, + {-4, -83}, {-67, 32}, {-21, 33}, {-5, 34}, {-6, -82}}, + {{2, 1}, {-120, 3}, {-1, 4}, {6, 5}, {-17, 7}, + {-104, 8}, {-18, 9}, {-2, 10}, {12, 11}, {14, 13}, + {-119, 15}, {-33, 16}, {-34, -88}, {-103, 17}, {19, 18}, + {21, 20}, {23, 22}, {25, 24}, {-19, -72}, {-50, 26}, + {-49, 27}, {-87, 28}, {30, 29}, {32, 31}, {-3, -35}, + {34, 33}, {-56, 35}, {-65, -66}, {-40, 36}, {-82, -118}, + {-71, 37}, {-55, 38}, {-67, -102}, {-51, 39}, {-70, 40}, + {42, 41}, {-81, 43}, {-86, 44}, {-52, -97}, {-98, 45}, + {-24, -39}, {-20, 46}, {-54, -83}, {-36, 47}, {-85, 48}, + {-68, 49}, {-4, 50}, {-69, -113}, {-117, 51}, {-37, -101}, + {-53, 52}, {-21, 53}, {55, 54}, {-84, -100}, {-5, 56}, + {-116, 57}, {-22, 58}, {-38, -115}, {60, 59}, {-6, -99}, + {-23, 61}, {-114, 62}, {-7, -8}}, + {{2, 1}, {-154, 3}, {5, 4}, {-1, 6}, {8, 7}, + {-17, 9}, {-138, 10}, {-18, 11}, {-2, 12}, {14, 13}, + {16, 15}, {-153, 17}, {-34, 18}, {-33, -122}, {20, 19}, + {22, 21}, {-137, 23}, {25, 24}, {27, 26}, {-106, 28}, + {30, 29}, {-50, 31}, {-19, 32}, {-49, -121}, {34, 33}, + {36, 35}, {-35, 37}, {-90, 38}, {-66, 39}, {-3, 40}, + {42, 41}, {-65, 43}, {-105, 44}, {46, 45}, {-74, 47}, + {-51, 48}, {-82, -152}, {-136, 49}, {-81, 50}, {-42, -89}, + {-114, 51}, {53, 52}, {-57, -58}, {-120, 54}, {-98, 55}, + {-67, 56}, {-97, 57}, {59, 58}, {-99, 60}, {-73, -104}, + {-72, 61}, {-113, 62}, {-20, -83}, {-84, -130}, {-36, 63}, + {-26, 64}, {-41, 65}, {-52, -129}, {-87, -88}, {67, 66}, + {-115, 68}, {-68, 69}, {-56, -69}, {-4, -100}, {-151, 70}, + {-135, 71}, {-103, -119}, {73, 72}, {-71, -145}, {-102, 74}, + {76, 75}, {-53, -85}, {-37, 77}, {-21, -86}, {79, 78}, + {-5, 80}, {-54, -134}, {-150, 81}, {-118, 82}, {-70, 83}, + {-117, 84}, {-22, -38}, {-101, 85}, {-55, 86}, {-149, 87}, + {-39, 88}, {-133, 89}, {-6, 90}, {-116, 91}, {-24, 92}, + {-7, -132}, {-23, 93}, {-40, 94}, {-131, -148}, {-25, 95}, + {-147, 96}, {-146, 97}, {-8, 0}, {0, 0}}}, + {{{-1, 1}, + {-52, 2}, + {4, 3}, + {-2, 5}, + {-17, 6}, + {-18, 7}, + {-36, -51}, + {9, 8}, + {-35, 10}, + {-34, 11}, + {-19, -33}, + {-3, 12}, + {-20, 13}, + {-50, 14}, + {-4, -49}}, + {{2, 1}, {-86, 3}, {5, 4}, {-1, 6}, {8, 7}, {-17, -18}, + {-2, 9}, {-70, 10}, {-85, 11}, {13, 12}, {-69, 14}, {-34, 15}, + {17, 16}, {-19, 18}, {-33, -35}, {-54, 19}, {-53, 20}, {-3, 21}, + {-68, 22}, {-84, 23}, {-50, 24}, {-52, 25}, {-51, 26}, {-20, -36}, + {-49, 27}, {-38, 28}, {-37, 29}, {-4, -83}, {-67, 30}, {-66, 31}, + {-21, 32}, {-22, -65}, {-5, 33}, {-82, 34}, {-6, -81}}, + {{2, 1}, {4, 3}, {-120, 5}, {7, 6}, {9, 8}, + {-1, 10}, {-18, 11}, {-17, 12}, {-2, -104}, {-119, 13}, + {15, 14}, {-103, 16}, {18, 17}, {-34, 19}, {-19, 20}, + {22, 21}, {-35, 23}, {-33, 24}, {-88, 25}, {-87, 26}, + {28, 27}, {-3, -102}, {-86, 29}, {-52, -118}, {31, 30}, + {-50, 32}, {-51, 33}, {-70, 34}, {-36, 35}, {-85, 36}, + {-20, 37}, {39, 38}, {-69, -71}, {-72, 40}, {-49, -67}, + {42, 41}, {-68, 43}, {-4, -101}, {-53, -117}, {-37, 44}, + {-66, 45}, {-55, 46}, {48, 47}, {-54, 49}, {-21, 50}, + {-84, -100}, {-56, -65}, {52, 51}, {-82, -83}, {54, 53}, + {-5, -116}, {-22, 55}, {-38, 56}, {-39, -40}, {58, 57}, + {-81, -115}, {-98, -99}, {-6, 59}, {-23, 60}, {-24, 61}, + {-7, -97}, {-114, 62}, {-8, -113}}, + {{2, 1}, {4, 3}, {-154, 5}, {7, 6}, {9, 8}, + {11, 10}, {-1, 12}, {-18, 13}, {-17, 14}, {-2, -138}, + {16, 15}, {-153, 17}, {-137, 18}, {20, 19}, {22, 21}, + {-34, 23}, {-19, 24}, {-35, 25}, {27, 26}, {29, 28}, + {-121, 30}, {-120, 31}, {-136, 32}, {-33, -122}, {34, 33}, + {-152, 35}, {-3, 36}, {-51, 37}, {-52, 38}, {-69, 39}, + {-36, 40}, {-50, 41}, {43, 42}, {-20, 44}, {-104, 45}, + {-103, 46}, {-87, 47}, {-119, 48}, {-105, 49}, {-86, 50}, + {-102, 51}, {-106, 52}, {-49, -135}, {-68, 53}, {55, 54}, + {-53, 56}, {-67, -151}, {-4, 57}, {-84, 58}, {-85, 59}, + {-66, 60}, {-37, 61}, {-70, 62}, {-54, -88}, {-21, 63}, + {65, 64}, {-89, 66}, {-118, 67}, {-72, 68}, {-90, 69}, + {-71, 70}, {-65, -134}, {-150, 71}, {-83, 72}, {-5, 73}, + {-101, -117}, {-82, 74}, {76, 75}, {-99, 77}, {-38, 78}, + {-100, 79}, {-22, 80}, {-73, 81}, {-39, -74}, {83, 82}, + {-55, -81}, {-57, 84}, {-133, -149}, {-56, 85}, {-6, 86}, + {-98, 87}, {-132, 88}, {-23, 89}, {-114, 90}, {-116, 91}, + {-58, -115}, {-24, 92}, {-97, -148}, {-40, -41}, {-7, -42}, + {-147, 93}, {95, 94}, {-131, 96}, {-8, -130}, {-25, -113}, + {-9, 97}, {-26, -129}, {-146, 98}, {-10, -145}}}}, + {{{{-1, 1}, + {-52, 2}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-33, 7}, + {-2, -18}, + {-20, 8}, + {10, 9}, + {-34, -49}, + {-51, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {4, 3}, {-86, 5}, {-1, 6}, {-17, 7}, {-70, 8}, + {10, 9}, {-18, 11}, {-33, 12}, {-54, 13}, {-2, 14}, {-34, 15}, + {-38, 16}, {-49, 17}, {-85, 18}, {-50, 19}, {-69, 20}, {-53, -65}, + {-22, 21}, {-66, 22}, {-19, 23}, {-37, 24}, {-35, -81}, {-3, 25}, + {-51, 26}, {-68, -84}, {-52, 27}, {29, 28}, {-20, 30}, {-4, -36}, + {-83, 31}, {-67, 32}, {-21, 33}, {-5, 34}, {-6, -82}}, + {{2, 1}, {4, 3}, {6, 5}, {-120, 7}, {-17, 8}, + {-1, -104}, {10, 9}, {12, 11}, {-18, 13}, {-33, -88}, + {15, 14}, {17, 16}, {-2, 18}, {-34, 19}, {-72, 20}, + {-49, 21}, {-119, 22}, {-50, 23}, {-103, 24}, {-56, 25}, + {-65, 26}, {28, 27}, {-40, -87}, {-66, 29}, {-82, 30}, + {32, 31}, {-19, -81}, {-71, 33}, {-97, 34}, {-35, -55}, + {-24, 35}, {37, 36}, {-3, -98}, {-51, 38}, {-67, 39}, + {-39, -118}, {-113, 40}, {-102, 41}, {-86, 42}, {-70, -83}, + {44, 43}, {-20, -54}, {-52, 45}, {-36, 46}, {-4, 47}, + {-68, 48}, {-85, 49}, {-101, -117}, {-69, 50}, {52, 51}, + {-21, -37}, {-53, 53}, {55, 54}, {-5, -100}, {-116, 56}, + {-84, 57}, {-38, 58}, {-22, -99}, {-115, 59}, {-6, 60}, + {-23, 61}, {-7, 62}, {-114, 0}}, + {{2, 1}, {4, 3}, {6, 5}, {-154, 7}, {9, 8}, + {-17, 10}, {-138, 11}, {-1, 12}, {14, 13}, {16, 15}, + {-33, -122}, {-18, 17}, {19, 18}, {-34, 20}, {-2, 21}, + {-106, 22}, {-49, 23}, {25, 24}, {-50, 26}, {-153, 27}, + {-90, 28}, {-137, 29}, {-65, 30}, {32, 31}, {-66, 33}, + {-121, 34}, {-74, 35}, {-81, 36}, {38, 37}, {-42, 39}, + {-82, 40}, {-105, 41}, {-19, -114}, {-58, 42}, {-35, 43}, + {-97, 44}, {46, 45}, {-129, 47}, {-26, -89}, {-57, -98}, + {-51, 48}, {-3, 49}, {-113, 50}, {-130, 51}, {-152, 52}, + {-67, -73}, {-99, -136}, {-145, 53}, {-120, 54}, {-41, 55}, + {-83, 56}, {-72, 57}, {-104, 58}, {-115, 59}, {-20, 60}, + {62, 61}, {-36, -88}, {-84, 63}, {-52, -56}, {65, 64}, + {-4, -87}, {-68, 66}, {-151, 67}, {-100, -135}, {69, 68}, + {-69, -119}, {-103, 70}, {-71, 71}, {73, 72}, {-21, 74}, + {-85, 75}, {-37, -53}, {-86, 76}, {78, 77}, {-102, -150}, + {-5, 79}, {-134, 80}, {-118, 81}, {-54, -117}, {83, 82}, + {-38, -70}, {-22, 84}, {-6, 85}, {87, 86}, {-55, 88}, + {-101, 89}, {-133, -149}, {-24, -39}, {91, 90}, {-132, 92}, + {-23, 93}, {-7, 94}, {-147, -148}, {-116, -131}, {-25, 95}, + {-40, 0}, {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, + {-52, 2}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-33, 7}, + {-2, -18}, + {-20, 8}, + {10, 9}, + {-34, -49}, + {-51, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {4, 3}, {-86, 5}, {-1, 6}, {-17, 7}, {-70, 8}, + {10, 9}, {-18, 11}, {-33, 12}, {-54, 13}, {-2, 14}, {-34, 15}, + {-38, 16}, {-49, 17}, {-85, 18}, {-50, 19}, {-69, 20}, {-53, -65}, + {-22, 21}, {-66, 22}, {-19, 23}, {-37, 24}, {-35, -81}, {-3, 25}, + {-51, 26}, {-68, -84}, {-52, 27}, {29, 28}, {-20, 30}, {-4, -36}, + {-83, 31}, {-67, 32}, {-21, 33}, {-5, 34}, {-6, -82}}, + {{2, 1}, {4, 3}, {6, 5}, {-120, 7}, {-17, 8}, + {-1, -104}, {10, 9}, {12, 11}, {-18, 13}, {-33, -88}, + {15, 14}, {17, 16}, {-2, 18}, {-34, 19}, {-72, 20}, + {-49, 21}, {-119, 22}, {-50, 23}, {-103, 24}, {-56, 25}, + {-65, 26}, {28, 27}, {-40, -87}, {-66, 29}, {-82, 30}, + {32, 31}, {-19, -81}, {-71, 33}, {-97, 34}, {-35, -55}, + {-24, 35}, {37, 36}, {-3, -98}, {-51, 38}, {-67, 39}, + {-39, -118}, {-113, 40}, {-102, 41}, {-86, 42}, {-70, -83}, + {44, 43}, {-20, -54}, {-52, 45}, {-36, 46}, {-4, 47}, + {-68, 48}, {-85, 49}, {-101, -117}, {-69, 50}, {52, 51}, + {-21, -37}, {-53, 53}, {55, 54}, {-5, -100}, {-116, 56}, + {-84, 57}, {-38, 58}, {-22, -99}, {-115, 59}, {-6, 60}, + {-23, 61}, {-7, 62}, {-114, 0}}, + {{2, 1}, {4, 3}, {6, 5}, {-154, 7}, {9, 8}, + {-17, 10}, {-138, 11}, {-1, 12}, {14, 13}, {16, 15}, + {-33, -122}, {-18, 17}, {19, 18}, {-34, 20}, {-2, 21}, + {-106, 22}, {-49, 23}, {25, 24}, {-50, 26}, {-153, 27}, + {-90, 28}, {-137, 29}, {-65, 30}, {32, 31}, {-66, 33}, + {-121, 34}, {-74, 35}, {-81, 36}, {38, 37}, {-42, 39}, + {-82, 40}, {-105, 41}, {-19, -114}, {-58, 42}, {-35, 43}, + {-97, 44}, {46, 45}, {-129, 47}, {-26, -89}, {-57, -98}, + {-51, 48}, {-3, 49}, {-113, 50}, {-130, 51}, {-152, 52}, + {-67, -73}, {-99, -136}, {-145, 53}, {-120, 54}, {-41, 55}, + {-83, 56}, {-72, 57}, {-104, 58}, {-115, 59}, {-20, 60}, + {62, 61}, {-36, -88}, {-84, 63}, {-52, -56}, {65, 64}, + {-4, -87}, {-68, 66}, {-151, 67}, {-100, -135}, {69, 68}, + {-69, -119}, {-103, 70}, {-71, 71}, {73, 72}, {-21, 74}, + {-85, 75}, {-37, -53}, {-86, 76}, {78, 77}, {-102, -150}, + {-5, 79}, {-134, 80}, {-118, 81}, {-54, -117}, {83, 82}, + {-38, -70}, {-22, 84}, {-6, 85}, {87, 86}, {-55, 88}, + {-101, 89}, {-133, -149}, {-24, -39}, {91, 90}, {-132, 92}, + {-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 = { + {{{{-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}}}}, + {{{{{-1, 1}, {-18, 2}, {-2, -17}}, + {{2, 1}, + {-1, -52}, + {-2, 3}, + {5, 4}, + {-51, 6}, + {-18, 7}, + {-17, 8}, + {-3, 9}, + {-36, 10}, + {-19, -50}, + {-35, 11}, + {-4, 12}, + {-34, 13}, + {-33, 14}, + {-20, -49}}, + {{2, 1}, {-86, 3}, {-1, 4}, {6, 5}, {-2, 7}, {-85, 8}, + {-18, 9}, {11, 10}, {-17, 12}, {14, 13}, {-70, 15}, {-3, -19}, + {-69, 16}, {-84, 17}, {-68, 18}, {-20, -35}, {-34, -83}, {20, 19}, + {-4, 21}, {-33, 22}, {-5, 23}, {-53, 24}, {-36, -52}, {-67, 25}, + {-21, -82}, {-54, 26}, {-6, 27}, {-51, 28}, {-50, 29}, {-49, 30}, + {-37, 31}, {-38, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{2, 1}, {4, 3}, {-1, -120}, {6, 5}, {8, 7}, {-18, 9}, + {-2, 10}, {12, 11}, {14, 13}, {-17, -119}, {16, 15}, {-103, 17}, + {-104, 18}, {-52, 19}, {21, 20}, {-69, 22}, {24, 23}, {-3, -35}, + {-19, 25}, {-34, -85}, {27, 26}, {-86, 28}, {-118, 29}, {-37, 30}, + {32, 31}, {-102, 33}, {-20, -22}, {-4, -117}, {-87, 34}, {-100, 35}, + {-33, -36}, {37, 36}, {-70, -88}, {-101, 38}, {-5, 39}, {-51, -53}, + {-50, 40}, {-115, 41}, {-21, 42}, {-116, 43}, {-38, 44}, {-23, -84}, + {-49, -99}, {46, 45}, {-6, -114}, {-7, -72}, {-71, 47}, {-8, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-2, -17}}, + {{2, 1}, + {-1, -52}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-2, 7}, + {-18, -33}, + {9, 8}, + {-20, 10}, + {-34, -51}, + {-49, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {-86, 3}, {-1, 4}, {-17, 5}, {7, 6}, {-70, 8}, + {-33, 9}, {-18, 10}, {-2, 11}, {-54, 12}, {-49, 13}, {-38, 14}, + {-34, -65}, {-85, 15}, {-50, 16}, {-69, 17}, {-22, 18}, {-53, 19}, + {21, 20}, {-19, -81}, {-66, 22}, {-3, -35}, {24, 23}, {-37, 25}, + {-68, -84}, {-51, 26}, {28, 27}, {-20, -52}, {30, 29}, {-4, -36}, + {-83, 31}, {-67, 32}, {-82, 33}, {-21, 34}, {-5, -6}}, + {{2, 1}, {-1, 3}, {-120, 4}, {-17, 5}, {7, 6}, + {-104, 8}, {-33, 9}, {11, 10}, {13, 12}, {-49, 14}, + {-88, 15}, {-18, -97}, {-65, 16}, {-40, 17}, {-2, -72}, + {19, 18}, {-113, 20}, {-34, 21}, {-56, -81}, {23, 22}, + {-50, 24}, {-82, -119}, {-24, -103}, {26, 25}, {28, 27}, + {30, 29}, {-55, -87}, {-66, 31}, {33, 32}, {-98, 34}, + {-35, -67}, {-19, 35}, {-70, 36}, {-71, 37}, {-51, -52}, + {-3, 38}, {40, 39}, {-86, -118}, {42, 41}, {-39, -69}, + {-54, -83}, {44, 43}, {-102, 45}, {-101, 46}, {-68, -85}, + {-36, -53}, {-5, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}}, + {{{{-1, 1}, {-18, 2}, {-2, -17}}, + {{-52, 1}, + {-1, 2}, + {4, 3}, + {-2, -17}, + {-18, 5}, + {-36, 6}, + {-51, 7}, + {9, 8}, + {-33, 10}, + {-34, 11}, + {-35, 12}, + {-19, -20}, + {-3, 13}, + {-49, 14}, + {-4, -50}}, + {{-1, 1}, {-86, 2}, {4, 3}, {-17, 5}, {-2, 6}, {-18, 7}, + {-70, 8}, {-85, 9}, {11, 10}, {13, 12}, {-33, 14}, {16, 15}, + {-34, -54}, {-69, 17}, {-38, 18}, {-50, 19}, {-35, -53}, {-49, 20}, + {-19, 21}, {-3, 22}, {-65, 23}, {-68, 24}, {-22, 25}, {-81, -84}, + {-66, 26}, {-37, 27}, {-20, -51}, {29, 28}, {-52, 30}, {-4, -83}, + {-36, 31}, {-67, 32}, {-5, 33}, {-82, 34}, {-21, 0}}, + {{-1, 1}, {-120, 2}, {4, 3}, {-17, 5}, {-2, 6}, + {8, 7}, {-18, 9}, {-104, 10}, {12, 11}, {14, 13}, + {16, 15}, {-119, 17}, {-81, 18}, {20, 19}, {-33, 21}, + {-88, 22}, {-103, 23}, {-34, 24}, {-56, 25}, {-72, 26}, + {-49, 27}, {-82, 28}, {-50, 29}, {-65, 30}, {-55, -87}, + {-19, 31}, {-67, 32}, {-35, -40}, {34, 33}, {-52, -71}, + {-66, 35}, {-70, 36}, {38, 37}, {-51, -97}, {-86, -102}, + {-3, 39}, {-118, 40}, {42, 41}, {-24, -85}, {-54, 43}, + {-39, 44}, {-98, -113}, {-36, -37}, {-20, -69}, {-4, 45}, + {-5, 46}, {-21, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-2, -17}}, + {{-52, 1}, + {-1, 2}, + {4, 3}, + {-2, 5}, + {-17, -18}, + {-51, 6}, + {-36, 7}, + {9, 8}, + {-35, 10}, + {-3, 11}, + {-19, -34}, + {-33, 12}, + {-50, 13}, + {-20, 14}, + {-4, -49}}, + {{2, 1}, {-86, 3}, {-1, 4}, {6, 5}, {-18, 7}, {-2, -17}, + {9, 8}, {-70, 10}, {-69, -85}, {-35, 11}, {13, 12}, {-34, 14}, + {-19, 15}, {-53, 16}, {-68, 17}, {-33, 18}, {-3, -52}, {20, 19}, + {-54, 21}, {-84, 22}, {-50, 23}, {-20, -51}, {-36, 24}, {26, 25}, + {-83, 27}, {-4, -38}, {-49, 28}, {-37, 29}, {-67, 30}, {-5, 31}, + {-21, 32}, {-65, -66}, {-82, 33}, {-22, 34}, {-6, -81}}, + {{2, 1}, {-1, -120}, {4, 3}, {6, 5}, {-18, 7}, {9, 8}, + {-17, 10}, {-2, 11}, {-103, 12}, {-52, 13}, {-35, -104}, {-119, 14}, + {16, 15}, {-69, -86}, {18, 17}, {-34, 19}, {-19, 20}, {22, 21}, + {-70, 23}, {-87, 24}, {-102, 25}, {-85, 26}, {-33, 27}, {-36, 28}, + {-3, 29}, {-88, 30}, {-51, 31}, {-118, 32}, {34, 33}, {-68, 35}, + {-53, 36}, {-67, 37}, {-20, 38}, {-101, 39}, {-50, 40}, {42, 41}, + {-37, 43}, {-116, 44}, {-117, 45}, {-49, 46}, {-21, -100}, {48, 47}, + {-55, -71}, {-4, 49}, {-22, -84}, {-115, 50}, {-66, -82}, {-72, 51}, + {-5, -6}, {-54, 52}, {-38, 53}, {-83, 54}, {-40, 55}, {-39, 56}, + {-99, 57}, {-23, -56}, {-7, 58}, {-65, -97}, {-8, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}}, + {{{{-1, 1}, {-18, 2}, {-2, -17}}, + {{2, 1}, + {-1, -52}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-2, 7}, + {-18, -33}, + {9, 8}, + {-20, 10}, + {-34, -51}, + {-49, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {-86, 3}, {-1, 4}, {-17, 5}, {7, 6}, {-70, 8}, + {-33, 9}, {-18, 10}, {-2, 11}, {-54, 12}, {-49, 13}, {-38, 14}, + {-34, -65}, {-85, 15}, {-50, 16}, {-69, 17}, {-22, 18}, {-53, 19}, + {21, 20}, {-19, -81}, {-66, 22}, {-3, -35}, {24, 23}, {-37, 25}, + {-68, -84}, {-51, 26}, {28, 27}, {-20, -52}, {30, 29}, {-4, -36}, + {-83, 31}, {-67, 32}, {-82, 33}, {-21, 34}, {-5, -6}}, + {{2, 1}, {-1, 3}, {-120, 4}, {-17, 5}, {7, 6}, + {-104, 8}, {-33, 9}, {11, 10}, {13, 12}, {-49, 14}, + {-88, 15}, {-18, -97}, {-65, 16}, {-40, 17}, {-2, -72}, + {19, 18}, {-113, 20}, {-34, 21}, {-56, -81}, {23, 22}, + {-50, 24}, {-82, -119}, {-24, -103}, {26, 25}, {28, 27}, + {30, 29}, {-55, -87}, {-66, 31}, {33, 32}, {-98, 34}, + {-35, -67}, {-19, 35}, {-70, 36}, {-71, 37}, {-51, -52}, + {-3, 38}, {40, 39}, {-86, -118}, {42, 41}, {-39, -69}, + {-54, -83}, {44, 43}, {-102, 45}, {-101, 46}, {-68, -85}, + {-36, -53}, {-5, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-2, -17}}, + {{2, 1}, + {-1, -52}, + {-17, 3}, + {5, 4}, + {-36, 6}, + {-2, 7}, + {-18, -33}, + {9, 8}, + {-20, 10}, + {-34, -51}, + {-49, 11}, + {-35, 12}, + {-19, 13}, + {-3, 14}, + {-4, -50}}, + {{2, 1}, {-86, 3}, {-1, 4}, {-17, 5}, {7, 6}, {-70, 8}, + {-33, 9}, {-18, 10}, {-2, 11}, {-54, 12}, {-49, 13}, {-38, 14}, + {-34, -65}, {-85, 15}, {-50, 16}, {-69, 17}, {-22, 18}, {-53, 19}, + {21, 20}, {-19, -81}, {-66, 22}, {-3, -35}, {24, 23}, {-37, 25}, + {-68, -84}, {-51, 26}, {28, 27}, {-20, -52}, {30, 29}, {-4, -36}, + {-83, 31}, {-67, 32}, {-82, 33}, {-21, 34}, {-5, -6}}, + {{2, 1}, {-1, 3}, {-120, 4}, {-17, 5}, {7, 6}, + {-104, 8}, {-33, 9}, {11, 10}, {13, 12}, {-49, 14}, + {-88, 15}, {-18, -97}, {-65, 16}, {-40, 17}, {-2, -72}, + {19, 18}, {-113, 20}, {-34, 21}, {-56, -81}, {23, 22}, + {-50, 24}, {-82, -119}, {-24, -103}, {26, 25}, {28, 27}, + {30, 29}, {-55, -87}, {-66, 31}, {33, 32}, {-98, 34}, + {-35, -67}, {-19, 35}, {-70, 36}, {-71, 37}, {-51, -52}, + {-3, 38}, {40, 39}, {-86, -118}, {42, 41}, {-39, -69}, + {-54, -83}, {44, 43}, {-102, 45}, {-101, 46}, {-68, -85}, + {-36, -53}, {-5, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {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 = { + {{{-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}}}, + {{{-1, 1}, {-8, 2}, {-2, 3}, {5, 4}, {-3, -7}, {-6, 6}, {-4, -5}}}}, + {{{{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {-36, 2}, + {-18, 3}, + {-35, 4}, + {-52, 5}, + {7, 6}, + {-34, 8}, + {-33, -49}, + {-20, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {5, 4}, {-86, 6}, {-66, 7}, {9, 8}, + {11, 10}, {-18, 12}, {-51, 13}, {-37, -52}, {-69, 14}, {-38, 15}, + {-53, 16}, {-35, 17}, {-50, -70}, {-22, -49}, {-33, 18}, {-17, 19}, + {-34, -65}, {-81, 20}, {-54, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{2, 1}, {4, 3}, {-1, 5}, {-69, 6}, {-120, 7}, {-68, 8}, + {10, 9}, {12, 11}, {14, 13}, {-52, -54}, {-18, 15}, {-70, 16}, + {-67, 17}, {19, 18}, {-17, 20}, {-113, 21}, {23, 22}, {-83, 24}, + {-24, 25}, {-103, -104}, {-51, -55}, {27, 26}, {-71, 28}, {-86, 29}, + {-35, 30}, {-66, 31}, {-39, -50}, {-82, -98}, {-72, 32}, {-56, -87}, + {-34, 33}, {-33, -88}, {-40, -97}, {-65, 34}, {-49, 35}, {-81, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {-36, 2}, + {-18, 3}, + {-35, 4}, + {-52, 5}, + {7, 6}, + {-34, 8}, + {-33, -49}, + {-20, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {5, 4}, {-86, 6}, {-66, 7}, {9, 8}, + {11, 10}, {-18, 12}, {-51, 13}, {-37, -52}, {-69, 14}, {-38, 15}, + {-53, 16}, {-35, 17}, {-50, -70}, {-22, -49}, {-33, 18}, {-17, 19}, + {-34, -65}, {-81, 20}, {-54, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{2, 1}, {4, 3}, {-1, 5}, {-69, 6}, {-120, 7}, {-68, 8}, + {10, 9}, {12, 11}, {14, 13}, {-52, -54}, {-18, 15}, {-70, 16}, + {-67, 17}, {19, 18}, {-17, 20}, {-113, 21}, {23, 22}, {-83, 24}, + {-24, 25}, {-103, -104}, {-51, -55}, {27, 26}, {-71, 28}, {-86, 29}, + {-35, 30}, {-66, 31}, {-39, -50}, {-82, -98}, {-72, 32}, {-56, -87}, + {-34, 33}, {-33, -88}, {-40, -97}, {-65, 34}, {-49, 35}, {-81, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}}, + {{{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {3, 2}, + {-18, 4}, + {-52, 5}, + {-34, -36}, + {-35, 6}, + {-17, 7}, + {-33, 8}, + {-20, 9}, + {-49, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {-52, 4}, {-86, 5}, {-35, 6}, {-53, 7}, + {-70, 8}, {-17, 9}, {-37, 10}, {12, 11}, {-38, -66}, {-18, 13}, + {-51, 14}, {16, 15}, {-34, -69}, {18, 17}, {-54, -65}, {-50, 19}, + {-33, -49}, {-22, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{-1, 1}, {-69, 2}, {4, 3}, {-120, 5}, {7, 6}, {-113, 8}, + {-68, 9}, {11, 10}, {-17, 12}, {-52, 13}, {-24, 14}, {-18, 15}, + {17, 16}, {-104, 18}, {20, 19}, {-54, -70}, {22, 21}, {24, 23}, + {-86, -97}, {-103, 25}, {-83, 26}, {-35, 27}, {-34, -98}, {-40, 28}, + {-39, -67}, {30, 29}, {-33, -51}, {-87, 31}, {-88, 32}, {-82, 33}, + {-55, -81}, {-56, -71}, {-72, 34}, {-50, -66}, {-65, 35}, {-49, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {3, 2}, + {-18, 4}, + {-52, 5}, + {-34, -36}, + {-35, 6}, + {-17, 7}, + {-33, 8}, + {-20, 9}, + {-49, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {-52, 4}, {-86, 5}, {-35, 6}, {-53, 7}, + {-70, 8}, {-17, 9}, {-37, 10}, {12, 11}, {-38, -66}, {-18, 13}, + {-51, 14}, {16, 15}, {-34, -69}, {18, 17}, {-54, -65}, {-50, 19}, + {-33, -49}, {-22, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{-1, 1}, {-69, 2}, {4, 3}, {-120, 5}, {7, 6}, {-113, 8}, + {-68, 9}, {11, 10}, {-17, 12}, {-52, 13}, {-24, 14}, {-18, 15}, + {17, 16}, {-104, 18}, {20, 19}, {-54, -70}, {22, 21}, {24, 23}, + {-86, -97}, {-103, 25}, {-83, 26}, {-35, 27}, {-34, -98}, {-40, 28}, + {-39, -67}, {30, 29}, {-33, -51}, {-87, 31}, {-88, 32}, {-82, 33}, + {-55, -81}, {-56, -71}, {-72, 34}, {-50, -66}, {-65, 35}, {-49, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}}, + {{{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {-36, 2}, + {-18, 3}, + {-35, 4}, + {-52, 5}, + {7, 6}, + {-34, 8}, + {-33, -49}, + {-20, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {5, 4}, {-86, 6}, {-66, 7}, {9, 8}, + {11, 10}, {-18, 12}, {-51, 13}, {-37, -52}, {-69, 14}, {-38, 15}, + {-53, 16}, {-35, 17}, {-50, -70}, {-22, -49}, {-33, 18}, {-17, 19}, + {-34, -65}, {-81, 20}, {-54, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{2, 1}, {4, 3}, {-1, 5}, {-69, 6}, {-120, 7}, {-68, 8}, + {10, 9}, {12, 11}, {14, 13}, {-52, -54}, {-18, 15}, {-70, 16}, + {-67, 17}, {19, 18}, {-17, 20}, {-113, 21}, {23, 22}, {-83, 24}, + {-24, 25}, {-103, -104}, {-51, -55}, {27, 26}, {-71, 28}, {-86, 29}, + {-35, 30}, {-66, 31}, {-39, -50}, {-82, -98}, {-72, 32}, {-56, -87}, + {-34, 33}, {-33, -88}, {-40, -97}, {-65, 34}, {-49, 35}, {-81, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}}}, + {{{-1, 1}, {-18, 2}, {-17, 0}}, + {{-1, 1}, + {-36, 2}, + {-18, 3}, + {-35, 4}, + {-52, 5}, + {7, 6}, + {-34, 8}, + {-33, -49}, + {-20, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}, + {{-1, 1}, {3, 2}, {5, 4}, {-86, 6}, {-66, 7}, {9, 8}, + {11, 10}, {-18, 12}, {-51, 13}, {-37, -52}, {-69, 14}, {-38, 15}, + {-53, 16}, {-35, 17}, {-50, -70}, {-22, -49}, {-33, 18}, {-17, 19}, + {-34, -65}, {-81, 20}, {-54, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{2, 1}, {4, 3}, {-1, 5}, {-69, 6}, {-120, 7}, {-68, 8}, + {10, 9}, {12, 11}, {14, 13}, {-52, -54}, {-18, 15}, {-70, 16}, + {-67, 17}, {19, 18}, {-17, 20}, {-113, 21}, {23, 22}, {-83, 24}, + {-24, 25}, {-103, -104}, {-51, -55}, {27, 26}, {-71, 28}, {-86, 29}, + {-35, 30}, {-66, 31}, {-39, -50}, {-82, -98}, {-72, 32}, {-56, -87}, + {-34, 33}, {-33, -88}, {-40, -97}, {-65, 34}, {-49, 35}, {-81, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {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 = { + {{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}, + {-13, -23}, {23, 22}, {-24, -31}, {-6, 24}, {-25, -26}, {26, 25}, + {-5, -27}, {-28, 27}, {-4, 28}, {-29, 29}, {-1, -30}, {-2, -3}}, + {{2, 1}, {-5, 3}, {-4, -6}, {-3, 4}, {-2, 5}, {-1, 6}, {-7, -8}}, + {{2, 1}, {4, 3}, {6, 5}, {-15, 7}, {-14, -16}, + {-13, 8}, {-12, 9}, {-11, 10}, {-10, 11}, {-8, -9}, + {-17, 12}, {14, 13}, {-7, 15}, {-18, 16}, {-6, 17}, + {-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 = { + {{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}, + {-13, -23}, {23, 22}, {-24, -31}, {-6, 24}, {-25, -26}, {26, 25}, + {-5, -27}, {-28, 27}, {-4, 28}, {-29, 29}, {-1, -30}, {-2, -3}}, + {{2, 1}, {-5, 3}, {-4, -6}, {-3, 4}, {-2, 5}, {-1, 6}, {-7, -8}}, + {{2, 1}, {4, 3}, {6, 5}, {-15, 7}, {-14, -16}, + {-13, 8}, {-12, 9}, {-11, 10}, {-10, 11}, {-8, -9}, + {-17, 12}, {14, 13}, {-7, 15}, {-18, 16}, {-6, 17}, + {-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 = { + {{-1, 1}, {-2, 2}, {-3, -4}}}; + +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}, + {-2, -39}, {-20, 22}, {-52, 23}, {25, 24}, {-21, 26}, {-66, 27}, + {-53, 28}, {-3, 29}, {31, 30}, {-22, 32}, {-54, 33}, {-4, 34}, + {-56, 35}, {-24, -67}, {-23, -55}, {-8, -72}, {-5, 36}, {-68, 37}, + {-6, 38}, {-7, -69}, {-70, -71}}}; + +const WORD32 ixheaacd_im_weight_Q28[16][8][31] = { + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + { + {-3, -574674, -1017796, -1796901, -3154468, -5481590, + -7575016, -10370478, -14006830, -18549081, -23865573, -27607851, + -31193408, -34233661, -36296902, -37030589, -36296902, -34233661, + -31193411, -27607851, -23865573, -18549082, -14006829, -10370478, + -7575017, -5481590, -3154468, -1796901, -1017796, -574674, + -3}, + {-3, -538644, -954220, -1685385, -2960885, -5151503, + -7126422, -9769580, -13217236, -17537304, -22610489, -26190951, + -29627877, -32546501, -34529291, -35234746, -34529291, -32546501, + -29627879, -26190951, -22610489, -17537304, -13217236, -9769579, + -7126423, -5151503, -2960885, -1685385, -954220, -538644, + -3}, + {-3, -483799, -857386, -1515349, -2665174, -4645760, + -6437353, -8843606, -11995831, -15965514, -20652239, -23974316, + -27173122, -29896409, -31749795, -32409817, -31749798, -29896409, + -27173122, -23974316, -20652241, -15965512, -11995831, -8843606, + -6437353, -4645760, -2665174, -1515349, -857386, -483799, + -3}, + {-2, -346044, -613840, -1086712, -1916795, -3357478, + -4672194, -6454555, -8816980, -11833773, -15450674, -18047554, + -20571857, -22737959, -24220523, -24750059, -24220526, -22737954, + -20571860, -18047555, -15450674, -11833774, -8816980, -6454555, + -4672195, -3357477, -1916795, -1086712, -613840, -346044, + -2}, + {-1, -211963, -376347, -667357, -1180477, -2077857, + -2904213, -4035616, -5554462, -7524805, -9930552, -11685604, + -13412726, -14910621, -15943947, -16314578, -15943948, -14910621, + -13412728, -11685605, -9930552, -7524805, -5554462, -4035615, + -2904213, -2077857, -1180477, -667357, -376347, -211963, + -1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {2, 341283, 608313, 1086175, 1945172, 3500199, 4995375, + 7149357, 10257166, 14719094, 21095209, 27678683, 35807499, 44718702, + 52254129, 55306472, 52254135, 44718696, 35807506, 27678683, 21095208, + 14719092, 10257166, 7149356, 4995375, 3500199, 1945172, 1086175, + 608313, 341283, 2}, + {3, 574839, 1026313, 1838046, 3309837, 6017789, + 8678530, 12620302, 18566315, 29617673, 51387069, 78419391, + 127027624, 219233261, 378389618, 496423988, 378389858, 219233221, + 127027637, 78419391, 51387075, 29617673, 18566315, 12620301, + 8678531, 6017788, 3309837, 1838046, 1026313, 574839, + 3}, + }, + { + {-6, -1063142, -1884657, -3332697, -5866780, -10242061, + -14210618, -19556015, -26583487, -35470365, -46010122, -53508848, + -60748872, -66926406, -71137302, -72638110, -71137307, -66926401, + -60748877, -53508853, -46010127, -35470363, -26583487, -19556013, + -14210619, -10242061, -5866781, -3332697, -1884657, -1063142, + -6}, + {-6, -996411, -1766700, -3125152, -5504594, -9619093, + -13357671, -18402686, -25050704, -33480939, -43509452, -50662425, + -57581404, -63494074, -67528860, -68967732, -67528865, -63494073, + -57581409, -50662430, -43509452, -33480939, -25050704, -18402684, + -13357672, -9619093, -5504594, -3125152, -1766700, -996411, + -6}, + {-5, -894854, -1587094, -2808873, -4951863, -8666114, + -12050168, -16630008, -22687068, -30401449, -39622947, -46227133, + -52634601, -58124037, -61876858, -63216462, -61876863, -58124037, + -52634607, -46227138, -39622951, -30401449, -22687068, -16630007, + -12050168, -8666115, -4951864, -2808873, -1587094, -894854, + -5}, + {-4, -639871, -1135692, -2012557, -3555941, -6246900, + -8715879, -12082768, -16579119, -22374143, -29395763, -34483541, + -39463815, -43763084, -46718677, -47776809, -46718677, -43763084, + -39463820, -34483541, -29395763, -22374143, -16579119, -12082768, + -8715880, -6246900, -3555941, -2012557, -1135692, -639871, + -4}, + {-2, -391832, -695950, -1234845, -2186633, -3856009, + -5398614, -7518849, -10379694, -14115081, -18711418, -22088179, + -25429852, -28342454, -30359291, -31084156, -30359294, -28342454, + -25429854, -22088179, -18711418, -14115079, -10379693, -7518848, + -5398615, -3856009, -2186633, -1234845, -695950, -391832, + -2}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {4, 630153, 1122569, 2002361, 3579289, 6418784, 9130132, + 13002758, 18518363, 26281774, 36854214, 45475090, 56006939, 67371285, + 76348185, 79832098, 76348185, 67371278, 56006945, 45475094, 36854219, + 26281774, 18518363, 13002756, 9130133, 6418784, 3579289, 2002361, + 1122569, 630153, 4}, + {6, 1060871, 1892248, 3382951, 6072244, 10973302, + 15727473, 22653420, 32821245, 47830061, 75342938, 103710864, + 142829663, 191958022, 239742154, 261023300, 239742208, 191958009, + 142829663, 103710864, 75342952, 47830061, 32821243, 22653418, + 15727475, 10973302, 6072245, 3382952, 1892248, 1060871, + 6}, + }, + { + {-8, -1391582, -2470337, -4379084, -7741644, -13613250, + -19010161, -26384297, -36257343, -49022548, -64547243, -75833181, + -86908862, -96491301, -103089782, -105454184, -103089782, -96491301, + -86908862, -75833172, -64547240, -49022548, -36257343, -26384295, + -19010165, -13613251, -7741645, -4379084, -2470337, -1391582, + -8}, + {-7, -1304089, -2315260, -4104938, -7259321, -12772177, + -17844573, -24783192, -34086929, -46138449, -60827308, -71526414, + -82042251, -91152504, -97432108, -99683455, -97432108, -91152495, + -82042260, -71526418, -60827312, -46138449, -34086931, -24783188, + -17844578, -12772178, -7259321, -4104938, -2315260, -1304089, + -7}, + {-7, -1170970, -2079253, -3687531, -6524359, -11488788, + -16063810, -22333022, -30758491, -41703962, -55090554, -64871119, + -74507479, -82873672, -88649676, -90722278, -88649676, -82873672, + -74507487, -64871119, -55090554, -41703962, -30758489, -22333018, + -16063811, -11488789, -6524359, -3687531, -2079253, -1170970, + -7}, + {-5, -836946, -1486730, -2638556, -4674179, -8248466, + -11555711, -16108121, -22262876, -30319528, -40263731, -47590055, + -54856837, -61203595, -65605308, -67188665, -65605308, -61203586, + -54856842, -47590059, -40263731, -30319526, -22262874, -16108120, + -11555711, -8248465, -4674180, -2638556, -1486730, -836946, + -5}, + {-3, -512296, -910384, -1616803, -2867623, -5071172, + -7118298, -9948960, -13799297, -18879453, -25211247, -29918728, + -34622928, -38759529, -41643508, -42683912, -41643508, -38759525, + -34622930, -29918732, -25211249, -18879451, -13799296, -9948958, + -7118299, -5071172, -2867624, -1616803, -910384, -512296, + -3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {5, 822447, 1463889, 2607236, 4647839, 8293870, 11741041, + 16605976, 23414447, 32754663, 45010872, 54604473, 64638836, 73862135, + 80529788, 82985438, 80529795, 73862128, 64638850, 54604473, 45010872, + 32754663, 23414449, 16605974, 11741042, 8293870, 4647839, 2607237, + 1463889, 822447, 5}, + {8, 1383579, 2464328, 4394383, 7850862, 14065144, + 19987153, 28424960, 40399126, 57162281, 79807987, 98105864, + 117845260, 140317143, 157927636, 164697609, 157927650, 140317143, + 117845274, 98105858, 79807994, 57162273, 40399123, 28424958, + 19987155, 14065143, 7850864, 4394383, 2464328, 1383579, + 8}, + }, + { + {-8, -1509476, -2684086, -4772023, -8480193, -15047650, + -21188892, -29744494, -41501680, -57227068, -77169768, -92246064, + -107526888, -121143312, -130736632, -134217744, -130736624, -121143312, + -107526896, -92246064, -77169768, -57227064, -41501676, -29744492, + -21188894, -15047650, -8480194, -4772023, -2684086, -1509476, + -8}, + {-8, -1414379, -2514988, -4471386, -7945941, -14099648, + -19853990, -27870592, -38887072, -53621760, -72308072, -86434552, + -100752688, -113511272, -122500224, -125762016, -122500216, -113511280, + -100752696, -86434560, -72308072, -53621760, -38887072, -27870588, + -19853994, -14099649, -7945942, -4471386, -2514989, -1414379, + -8}, + {-7, -1269741, -2257800, -4014131, -7133369, -12657783, + -17823674, -25020474, -34910384, -48138264, -64913664, -77595552, + -90449464, -101903328, -109973032, -112901280, -109973040, -101903328, + -90449472, -77595544, -64913668, -48138264, -34910384, -25020472, + -17823674, -12657783, -7133369, -4014131, -2257800, -1269741, + -7}, + {-5, -907074, -1612921, -2867604, -5095918, -9042434, + -12732830, -17874062, -24939188, -34388892, -46372856, -55432508, + -64615056, -72797440, -78562256, -80654120, -78562256, -72797432, + -64615064, -55432508, -46372860, -34388892, -24939190, -17874060, + -12732831, -9042434, -5095918, -2867604, -1612921, -907074, + -5}, + {-3, -554944, -986777, -1754386, -3117658, -5532118, + -7789884, -10935266, -15257677, -21038960, -28370692, -33913340, + -39531184, -44537124, -48064012, -49343804, -48064012, -44537124, + -39531188, -33913344, -28370694, -21038958, -15257676, -10935264, + -7789885, -5532117, -3117658, -1754387, -986777, -554944, + -3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {5, 889081, 1580927, 2810722, 4994834, 8863066, 12480257, + 17519508, 24444488, 33706744, 45452992, 54332928, 63333332, 71353408, + 77003864, 79054240, 77003872, 71353400, 63333336, 54332932, 45452992, + 33706744, 24444488, 17519506, 12480258, 8863066, 4994834, 2810722, + 1580927, 889081, 5}, + {8, 1494381, 2657245, 4724303, 8395391, 14897174, + 20977002, 29447048, 41086664, 56654796, 76398072, 91323608, + 106451616, 119931880, 129429263, 132875552, 129429264, 119931878, + 106451624, 91323608, 76398072, 56654796, 41086660, 29447048, + 20977004, 14897174, 8395392, 4724304, 2657245, 1494381, + 8}, + }, + { + {-8, -1397585, -2489316, -4439078, -7931147, -14210401, + -20195533, -28725381, -40834574, -57795944, -80727760, -99273505, + -119386757, -142482370, -160470890, -167392516, -160470890, -142482357, + -119386757, -99273512, -80727756, -57795944, -40834574, -28725377, + -20195535, -14210400, -7931148, -4439078, -2489316, -1397585, + -8}, + {-7, -1309358, -2331922, -4157610, -7425692, -13296383, + -18885003, -26837459, -38101253, -53825212, -74978577, -91990894, + -110257644, -129210650, -144934890, -150951436, -144934903, -129210650, + -110257650, -91990901, -74978584, -53825215, -38101253, -26837455, + -18885005, -13296384, -7425692, -4157610, -2331922, -1309358, + -7}, + {-7, -1175217, -2092682, -3729980, -6658434, -11911179, + -16901999, -23987347, -33988896, -47881077, -66434665, -81236418, + -97003508, -111774388, -123343304, -128186650, -123343317, -111774382, + -97003515, -81236418, -66434665, -47881077, -33988892, -23987347, + -16902001, -11911179, -6658434, -3729980, -2092681, -1175217, + -7}, + {-5, -839113, -1493583, -2660218, -4742594, -8463942, + -11983129, -16951064, -23906436, -33453557, -45991133, -55813174, + -66094542, -75552455, -82394424, -84915283, -82394417, -75552441, + -66094540, -55813171, -45991139, -33453554, -23906434, -16951065, + -11983130, -8463941, -4742595, -2660218, -1493583, -839113, + -5}, + {-3, -513107, -912949, -1624911, -2893228, -5151802, + -7278196, -10264146, -14413252, -20048070, -27340204, -32966174, + -38772409, -44037899, -47801354, -49178242, -47801358, -44037903, + -38772413, -32966178, -27340208, -20048068, -14413250, -10264145, + -7278196, -5151802, -2893229, -1624911, -912949, -513107, + -3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {5, 820365, 1457305, 2586425, 4582113, 8086863, 11330426, + 15796198, 21835646, 29744456, 39510836, 46709319, 53851835, 60092071, + 64420974, 65978354, 64420974, 60092067, 53851844, 46709315, 39510836, + 29744457, 21835644, 15796195, 11330427, 8086863, 4582113, 2586425, + 1457305, 820365, 5}, + {8, 1377696, 2445727, 4335584, 7665133, 13479892, + 18825424, 26130668, 35913779, 48566398, 63959479, 75153138, + 86140901, 95649257, 102197733, 104544436, 102197742, 95649257, + 86140901, 75153138, 63959483, 48566398, 35913779, 26130668, + 18825426, 13479892, 7665134, 4335585, 2445727, 1377696, + 8}, + }, + { + {-6, -1071630, -1911499, -3417563, -6135014, -11088915, + -15896315, -22903493, -33199122, -48417346, -76625352, -105748897, + -146157663, -197317649, -247522927, -270025194, -247522954, -197317609, + -146157677, -105748904, -76625358, -48417346, -33199122, -22903491, + -15896315, -11088915, -6135014, -3417563, -1911499, -1071630, + -6}, + {-6, -1003864, -1790265, -3199659, -5740059, -10362247, + -14836237, -21336047, -30836947, -44762533, -68827345, -93516451, + -126532850, -166393343, -203549915, -219611661, -203549928, -166393329, + -126532890, -93516458, -68827352, -44762536, -30836951, -21336046, + -14836239, -10362246, -5740059, -3199659, -1790265, -1003864, + -6}, + {-5, -900861, -1606086, -2868917, -5141593, -9264643, + -13240198, -18987808, -27325830, -39399654, -58130792, -77340471, + -101814498, -129653024, -154062530, -164186529, -154062570, -129653010, + -101814518, -77340471, -58130799, -39399654, -27325828, -18987806, + -13240198, -9264643, -5141593, -2868917, -1606086, -900860, + -5}, + {-4, -642936, -1145384, -2043195, -3652724, -6551934, + -9321546, -13279575, -18921457, -26872438, -37720430, -46584838, + -57725379, -69582952, -78984425, -82641451, -78984418, -69582945, + -57725385, -46584841, -37720434, -26872436, -18921457, -13279575, + -9321547, -6551934, -3652725, -2043195, -1145384, -642936, + -4}, + {-2, -392979, -699578, -1246312, -2222848, -3970081, + -5624912, -7965246, -11250449, -15776819, -21752506, -26460379, + -31414830, -35997598, -39328571, -40559278, -39328574, -35997598, + -31414833, -26460381, -21752510, -15776818, -11250449, -7965245, + -5624912, -3970080, -2222848, -1246312, -699578, -392979, + -2}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {4, 627208, 1113258, 1972927, 3486308, 6125748, 8548319, + 11853214, 16269000, 21963762, 28868936, 33875540, 38778800, 43013413, + 45925477, 46968213, 45925482, 43013409, 38778804, 33875542, 28868936, + 21963760, 16269001, 11853213, 8548320, 6125748, 3486308, 1972927, + 1113257, 627208, 4}, + {6, 1052552, 1865940, 3299774, 5809354, 10143366, 14075580, + 19373582, 26341294, 35156402, 45615999, 53060599, 60250435, 66386585, + 70569986, 72061134, 70569991, 66386585, 60250429, 53060599, 45615999, + 35156405, 26341292, 19373582, 14075583, 10143366, 5809355, 3299775, + 1865941, 1052552, 6}, + }, + { + {-3, -580676, -1036778, -1856927, -3344306, -6082086, + -8773675, -12764181, -18791317, -30111286, -52494265, -80589391, + -131965584, -232564048, -416579297, -562298280, -416579510, -232563968, + -131965624, -80589405, -52494275, -30111283, -18791315, -12764179, + -8773676, -6082086, -3344306, -1856927, -1036778, -580676, + -3}, + {-3, -543914, -970885, -1738082, -3127514, -5678284, + -8177066, -11864206, -17389757, -27104441, -45909909, -68054278, + -104838298, -165555583, -249179407, -298573540, -249179487, -165555569, + -104838338, -68054292, -45909909, -27104439, -17389757, -11864205, + -8177067, -5678284, -3127513, -1738082, -970885, -543913, + -3}, + {-3, -488046, -870816, -1557814, -2799416, -5069822, + -7282155, -10523970, -15327605, -22959079, -37422722, -53115972, + -76430452, -108848624, -144319570, -161563289, -144319637, -108848611, + -76430472, -53115969, -37422729, -22959078, -15327603, -10523969, + -7282156, -5069822, -2799417, -1557814, -870816, -488046, + -3}, + {-2, -348211, -620694, -1108379, -1985253, -3573386, + -5101324, -7304187, -10486237, -15063094, -21722298, -28584446, + -37112672, -46532696, -54556959, -57822712, -54556959, -46532689, + -37112682, -28584446, -21722299, -15063095, -10486238, -7304186, + -5101324, -3573386, -1985253, -1108378, -620694, -348211, + -2}, + {-1, -212775, -378912, -675466, -1206088, -2158548, + -3064349, -4351732, -6171956, -8706333, -12102898, -14823042, + -17731555, -20482223, -22906153, -23829791, -22906156, -20482223, + -17731555, -14823041, -12102899, -8706332, -6171955, -4351731, + -3064349, -2158548, -1206088, -675466, -378913, -212775, + -1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {2, 339200, 601729, 1065360, 1879405, 3292792, 4583180, + 6333406, 8654669, 11621118, 15180668, 17738214, 20225637, 22361080, + 23823154, 24345462, 23823157, 22361078, 20225641, 17738213, 15180668, + 11621118, 8654670, 6333406, 4583181, 3292792, 1879405, 1065360, + 601729, 339200, 2}, + {3, 568956, 1007710, 1779215, 3123785, 5429323, 7504044, + 10275511, 13882195, 18389595, 23668008, 27385006, 30947362, 33968646, + 36019344, 36748630, 36019347, 33968643, 30947364, 27385006, 23668008, + 18389595, 13882195, 10275510, 7504045, 5429323, 3123785, 1779215, + 1007710, 568956, 3}, + }, + { + {0, 0, 0, 0, 1, 1, 2, 3, 4, 7, 13, 21, 39, 91, 367, -858993460, + 367, 91, 39, 21, 13, 7, 4, 3, 2, 1, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 1, 2, 3, 4, 7, 11, 18, 29, 54, 102, 145, + 102, 54, 29, 18, 11, 7, 4, 3, 2, 1, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 1, 2, 2, 4, 5, 9, 13, 20, 31, 44, 52, + 44, 31, 20, 13, 9, 5, 4, 2, 2, 1, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 5, 7, 9, 12, 14, 15, + 14, 12, 9, 7, 5, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3, 4, 5, 5, 6, + 5, 5, 4, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, -1, -1, -1, -2, -3, -3, -4, -5, -5, -5, -5, + -5, -5, -5, -4, -3, -3, -2, -1, -1, -1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, -1, -1, -2, -2, -3, -4, -5, -6, -7, -8, -8, -8, + -8, -8, -7, -6, -5, -4, -3, -2, -2, -1, -1, 0, 0, 0, 0}, + }, + { + {3, 580676, 1036777, 1856927, 3344305, 6082085, + 8773674, 12764179, 18791313, 30111279, 52494259, 80589378, + 131965557, 232564021, 416579217, 562298173, 416579430, 232563941, + 131965610, 80589391, 52494265, 30111279, 18791313, 12764177, + 8773674, 6082085, 3344306, 1856927, 1036778, 580676, + 3}, + {3, 543913, 970885, 1738082, 3127513, 5678283, + 8177065, 11864205, 17389754, 27104436, 45909902, 68054265, + 104838284, 165555556, 249179381, 298573513, 249179434, 165555543, + 104838318, 68054278, 45909902, 27104436, 17389756, 11864203, + 8177066, 5678283, 3127513, 1738082, 970885, 543913, + 3}, + {3, 488046, 870816, 1557814, 2799416, 5069821, + 7282153, 10523969, 15327601, 22959076, 37422716, 53115965, + 76430438, 108848611, 144319557, 161563263, 144319610, 108848597, + 76430458, 53115962, 37422722, 22959074, 15327601, 10523968, + 7282155, 5069821, 2799416, 1557814, 870816, 488046, + 3}, + {2, 348211, 620693, 1108378, 1985253, 3573386, 5101323, + 7304185, 10486235, 15063092, 21722294, 28584443, 37112666, 46532689, + 54556952, 57822705, 54556949, 46532682, 37112676, 28584443, 21722296, + 15063092, 10486236, 7304185, 5101323, 3573385, 1985253, 1108378, + 620693, 348211, 2}, + {1, 212775, 378912, 675465, 1206088, 2158547, 3064349, + 4351731, 6171955, 8706331, 12102897, 14823040, 17731552, 20482220, + 22906149, 23829786, 22906153, 20482220, 17731554, 14823040, 12102898, + 8706331, 6171954, 4351731, 3064349, 2158547, 1206088, 675466, + 378912, 212775, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-2, -339200, -601729, -1065360, -1879405, -3292791, + -4583180, -6333406, -8654668, -11621117, -15180664, -17738211, + -20225634, -22361078, -23823152, -24345457, -23823152, -22361075, + -20225636, -17738211, -15180665, -11621117, -8654668, -6333405, + -4583180, -3292791, -1879405, -1065360, -601729, -339200, + -2}, + {-3, -568956, -1007709, -1779214, -3123784, -5429322, + -7504043, -10275508, -13882193, -18389592, -23668005, -27385003, + -30947359, -33968641, -36019338, -36748625, -36019341, -33968638, + -30947359, -27385003, -23668005, -18389591, -13882193, -10275507, + -7504044, -5429322, -3123785, -1779214, -1007709, -568956, + -3}, + }, + { + {6, 1071630, 1911498, 3417563, 6135013, 11088914, + 15896313, 22903491, 33199122, 48417342, 76625352, 105748897, + 146157663, 197317649, 247522954, 270025220, 247523007, 197317609, + 146157677, 105748911, 76625358, 48417339, 33199122, 22903489, + 15896315, 11088914, 6135014, 3417563, 1911498, 1071630, + 6}, + {6, 1003864, 1790265, 3199659, 5740058, 10362246, + 14836235, 21336046, 30836947, 44762529, 68827352, 93516444, + 126532850, 166393343, 203549915, 219611675, 203549942, 166393329, + 126532890, 93516458, 68827345, 44762533, 30836947, 21336044, + 14836238, 10362246, 5740058, 3199659, 1790265, 1003864, + 6}, + {5, 900860, 1606086, 2868917, 5141592, 9264643, + 13240197, 18987806, 27325827, 39399651, 58130785, 77340471, + 101814498, 129653024, 154062530, 164186529, 154062570, 129653010, + 101814518, 77340465, 58130799, 39399651, 27325825, 18987804, + 13240199, 9264643, 5141593, 2868916, 1606086, 900860, + 5}, + {4, 642936, 1145384, 2043195, 3652724, 6551933, 9321545, + 13279574, 18921455, 26872435, 37720428, 46584834, 57725379, 69582952, + 78984425, 82641458, 78984418, 69582945, 57725385, 46584838, 37720430, + 26872435, 18921455, 13279574, 9321546, 6551933, 3652724, 2043195, + 1145384, 642936, 4}, + {2, 392979, 699578, 1246311, 2222848, 3970080, 5624911, + 7965245, 11250448, 15776818, 21752506, 26460378, 31414826, 35997601, + 39328568, 40559278, 39328574, 35997598, 31414830, 26460379, 21752508, + 15776818, 11250448, 7965244, 5624912, 3970080, 2222848, 1246312, + 699578, 392979, 2}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-4, -627208, -1113257, -1972926, -3486308, -6125748, + -8548319, -11853212, -16268999, -21963760, -28868934, -33875539, + -38778795, -43013409, -45925473, -46968213, -45925477, -43013404, + -38778795, -33875539, -28868932, -21963758, -16269000, -11853212, + -8548319, -6125747, -3486308, -1972926, -1113257, -627208, + -4}, + {-6, -1052552, -1865940, -3299774, -5809354, -10143366, + -14075579, -19373580, -26341292, -35156400, -45615994, -53060594, + -60250430, -66386576, -70569981, -72061118, -70569981, -66386576, + -60250430, -53060594, -45615994, -35156400, -26341290, -19373580, + -14075582, -10143365, -5809354, -3299775, -1865940, -1052552, + -6}, + }, + { + {8, 1397585, 2489316, 4439077, 7931147, 14210400, + 20195533, 28725381, 40834574, 57795937, 80727756, 99273505, + 119386770, 142482397, 160470916, 167392556, 160470930, 142482397, + 119386770, 99273512, 80727763, 57795937, 40834574, 28725377, + 20195535, 14210399, 7931147, 4439077, 2489316, 1397584, + 8}, + {7, 1309358, 2331922, 4157610, 7425691, 13296383, + 18885003, 26837457, 38101253, 53825212, 74978579, 91990888, + 110257650, 129210677, 144934930, 150951463, 144934930, 129210664, + 110257648, 91990895, 74978579, 53825212, 38101253, 26837453, + 18885005, 13296383, 7425691, 4157609, 2331922, 1309358, + 7}, + {7, 1175217, 2092681, 3729980, 6658433, 11911178, + 16901999, 23987347, 33988892, 47881081, 66434656, 81236414, + 97003508, 111774386, 123343330, 128186677, 123343330, 111774379, + 97003515, 81236414, 66434672, 47881077, 33988888, 23987345, + 16901999, 11911179, 6658434, 3729980, 2092681, 1175217, + 7}, + {5, 839113, 1493583, 2660218, 4742594, 8463941, 11983129, + 16951064, 23906434, 33453557, 45991133, 55813174, 66094533, 75552445, + 82394424, 84915284, 82394424, 75552445, 66094548, 55813174, 45991133, + 33453557, 23906436, 16951064, 11983129, 8463941, 4742594, 2660218, + 1493583, 839113, 5}, + {3, 513107, 912949, 1624911, 2893228, 5151802, 7278195, + 10264146, 14413251, 20048070, 27340206, 32966174, 38772413, 44037903, + 47801358, 49178236, 47801358, 44037903, 38772413, 32966174, 27340206, + 20048066, 14413251, 10264145, 7278196, 5151802, 2893229, 1624911, + 912949, 513107, 3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-5, -820365, -1457305, -2586425, -4582112, -8086862, + -11330425, -15796197, -21835644, -29744455, -39510832, -46709311, + -53851837, -60092063, -64420965, -65978350, -64420972, -60092058, + -53851841, -46709311, -39510837, -29744455, -21835644, -15796194, + -11330427, -8086862, -4582112, -2586425, -1457305, -820365, + -5}, + {-8, -1377696, -2445727, -4335584, -7665132, -13479891, + -18825424, -26130668, -35913775, -48566394, -63959470, -75153128, + -86140892, -95649238, -102197714, -104544419, -102197714, -95649247, + -86140892, -75153132, -63959470, -48566394, -35913771, -26130665, + -18825426, -13479892, -7665133, -4335584, -2445727, -1377696, + -8}, + }, + { + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {8, 1414379, 2514989, 4471386, 7945941, 14099648, + 19853990, 27870592, 38887072, 53621760, 72308072, 86434552, + 100752688, 113511272, 122500216, 125762008, 122500216, 113511272, + 100752696, 86434560, 72308072, 53621760, 38887072, 27870588, + 19853994, 14099649, 7945942, 4471386, 2514989, 1414379, + 8}, + {7, 1269741, 2257800, 4014131, 7133370, 12657783, + 17823674, 25020474, 34910384, 48138264, 64913664, 77595552, + 90449464, 101903328, 109973032, 112901272, 109973040, 101903328, + 90449472, 77595544, 64913668, 48138264, 34910384, 25020472, + 17823674, 12657783, 7133370, 4014131, 2257800, 1269741, + 7}, + {5, 907074, 1612921, 2867604, 5095918, 9042434, 12732830, + 17874062, 24939188, 34388892, 46372856, 55432508, 64615056, 72797440, + 78562256, 80654120, 78562256, 72797432, 64615064, 55432508, 46372860, + 34388892, 24939190, 17874060, 12732831, 9042434, 5095919, 2867604, + 1612921, 907074, 5}, + {3, 554944, 986777, 1754387, 3117658, 5532118, 7789884, + 10935266, 15257677, 21038960, 28370692, 33913340, 39531184, 44537124, + 48064012, 49343804, 48064012, 44537124, 39531188, 33913344, 28370694, + 21038958, 15257676, 10935264, 7789885, 5532118, 3117659, 1754387, + 986777, 554944, 3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-5, -889081, -1580927, -2810721, -4994834, -8863066, + -12480257, -17519508, -24444488, -33706744, -45452992, -54332928, + -63333332, -71353408, -77003864, -79054240, -77003872, -71353400, + -63333336, -54332932, -45452992, -33706744, -24444488, -17519506, + -12480258, -8863066, -4994834, -2810722, -1580927, -889081, + -5}, + {-8, -1494381, -2657245, -4724303, -8395391, -14897174, + -20977002, -29447048, -41086664, -56654796, -76398072, -91323608, + -106451616, -119931880, -129429256, -132875552, -129429264, -119931872, + -106451624, -91323608, -76398072, -56654796, -41086660, -29447048, + -20977004, -14897174, -8395392, -4724303, -2657245, -1494381, + -8}, + }, + { + {8, 1391582, 2470337, 4379084, 7741644, 13613249, + 19010161, 26384295, 36257343, 49022539, 64547234, 75833163, + 86908844, 96491282, 103089763, 105454176, 103089763, 96491282, + 86908853, 75833163, 64547238, 49022539, 36257339, 26384293, + 19010161, 13613249, 7741645, 4379084, 2470337, 1391582, + 8}, + {7, 1304089, 2315260, 4104938, 7259320, 12772176, 17844574, + 24783190, 34086927, 46138445, 60827299, 71526405, 82042242, 91152486, + 97432080, 99683437, 97432080, 91152486, 82042242, 71526405, 60827303, + 46138450, 34086925, 24783185, 17844576, 12772176, 7259321, 4104938, + 2315260, 1304089, 7}, + {7, 1170970, 2079253, 3687531, 6524358, 11488787, 16063809, + 22333018, 30758490, 41703962, 55090551, 64871110, 74507473, 82873663, + 88649667, 90722260, 88649667, 82873663, 74507478, 64871105, 55090551, + 41703958, 30758487, 22333016, 16063810, 11488788, 6524359, 3687531, + 2079253, 1170970, 7}, + {5, 836946, 1486730, 2638556, 4674179, 8248466, 11555710, + 16108120, 22262872, 30319524, 40263723, 47590046, 54856833, 61203586, + 65605295, 67188663, 65605295, 61203577, 54856842, 47590051, 40263727, + 30319524, 22262872, 16108119, 11555711, 8248465, 4674180, 2638556, + 1486730, 836946, 5}, + {3, 512296, 910384, 1616803, 2867623, 5071172, 7118297, + 9948958, 13799293, 18879451, 25211243, 29918726, 34622925, 38759520, + 41643504, 42683904, 41643508, 38759520, 34622927, 29918726, 25211247, + 18879449, 13799293, 9948957, 7118298, 5071172, 2867623, 1616803, + 910384, 512296, 3}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-5, -822447, -1463889, -2607236, -4647839, -8293870, + -11741041, -16605976, -23414447, -32754663, -45010867, -54604470, + -64638843, -73862135, -80529791, -82985440, -80529802, -73862128, + -64638843, -54604470, -45010867, -32754663, -23414447, -16605974, + -11741041, -8293870, -4647839, -2607236, -1463889, -822447, + -5}, + {-8, -1383579, -2464327, -4394383, -7850861, -14065144, + -19987153, -28424958, -40399126, -57162277, -79807994, -98105864, + -117845265, -140317170, -157927676, -164697636, -157927690, -140317157, + -117845279, -98105864, -79807994, -57162277, -40399126, -28424956, + -19987155, -14065143, -7850863, -4394383, -2464328, -1383579, + -8}, + }, + { + {6, 1063142, 1884657, 3332697, 5866781, 10242063, 14210621, + 19556019, 26583493, 35470370, 46010131, 53508858, 60748887, 66926417, + 71137316, 72638124, 71137318, 66926416, 60748892, 53508858, 46010131, + 35470372, 26583491, 19556017, 14210622, 10242063, 5866782, 3332697, + 1884657, 1063142, 6}, + {6, 996412, 1766700, 3125152, 5504595, 9619094, 13357673, + 18402690, 25050711, 33480946, 43509461, 50662435, 57581418, 63494088, + 67528881, 68967747, 67528880, 63494088, 57581423, 50662440, 43509461, + 33480946, 25050711, 18402688, 13357674, 9619095, 5504595, 3125152, + 1766700, 996411, 6}, + {5, 894855, 1587095, 2808874, 4951864, 8666115, 12050171, + 16630010, 22687072, 30401455, 39622952, 46227143, 52634611, 58124051, + 61876873, 63216472, 61876878, 58124046, 52634616, 46227147, 39622956, + 30401453, 22687072, 16630009, 12050171, 8666116, 4951865, 2808874, + 1587094, 894855, 5}, + {4, 639871, 1135693, 2012557, 3555941, 6246901, 8715881, + 12082770, 16579122, 22374147, 29395768, 34483545, 39463825, 43763098, + 46718682, 47776819, 46718682, 43763093, 39463829, 34483548, 29395770, + 22374147, 16579122, 12082770, 8715881, 6246901, 3555942, 2012557, + 1135693, 639871, 4}, + {2, 391832, 695950, 1234845, 2186633, 3856010, 5398615, + 7518850, 10379695, 14115083, 18711422, 22088181, 25429856, 28342458, + 30359295, 31084165, 30359297, 28342458, 25429858, 22088183, 18711424, + 14115081, 10379695, 7518850, 5398616, 3856010, 2186634, 1234845, + 695950, 391832, 2}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-4, -630153, -1122569, -2002361, -3579289, -6418785, + -9130134, -13002760, -18518365, -26281781, -36854217, -45475104, + -56006945, -67371285, -76348185, -79832098, -76348192, -67371278, + -56006952, -45475104, -36854222, -26281779, -18518367, -13002758, + -9130135, -6418785, -3579289, -2002362, -1122569, -630153, + -4}, + {-6, -1060871, -1892248, -3382952, -6072245, -10973304, + -15727476, -22653422, -32821252, -47830065, -75342945, -103710871, + -142829663, -191958009, -239742101, -261023247, -239742154, -191957982, + -142829663, -103710864, -75342952, -47830065, -32821248, -22653422, + -15727478, -10973304, -6072246, -3382952, -1892248, -1060871, + -6}, + }, + { + {3, 574674, 1017796, 1796900, 3154467, 5481590, 7575015, + 10370478, 14006828, 18549080, 23865568, 27607848, 31193405, 34233658, + 36296899, 37030586, 36296899, 34233658, 31193408, 27607848, 23865571, + 18549080, 14006828, 10370477, 7575016, 5481590, 3154468, 1796900, + 1017796, 574674, 3}, + {3, 538644, 954220, 1685385, 2960884, 5151503, 7126421, + 9769579, 13217235, 17537303, 22610486, 26190946, 29627874, 32546498, + 34529288, 35234744, 34529288, 32546498, 29627877, 26190948, 22610486, + 17537303, 13217235, 9769578, 7126422, 5151503, 2960885, 1685385, + 954220, 538644, 3}, + {3, 483799, 857386, 1515349, 2665173, 4645760, 6437352, + 8843606, 11995830, 15965511, 20652239, 23974315, 27173119, 29896409, + 31749793, 32409812, 31749796, 29896409, 27173119, 23974315, 20652239, + 15965511, 11995830, 8843605, 6437353, 4645760, 2665173, 1515349, + 857386, 483799, 3}, + {2, 346044, 613840, 1086712, 1916795, 3357477, 4672194, + 6454554, 8816978, 11833772, 15450673, 18047553, 20571855, 22737956, + 24220523, 24750056, 24220523, 22737954, 20571857, 18047553, 15450673, + 11833773, 8816979, 6454554, 4672195, 3357477, 1916795, 1086712, + 613840, 346044, 2}, + {1, 211963, 376347, 667357, 1180477, 2077857, 2904213, + 4035615, 5554462, 7524805, 9930550, 11685603, 13412725, 14910620, + 15943945, 16314576, 15943947, 14910620, 13412727, 11685603, 9930550, + 7524804, 5554462, 4035615, 2904213, 2077857, 1180477, 667357, + 376347, 211963, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {-2, -341283, -608313, -1086175, -1945172, -3500199, + -4995375, -7149356, -10257165, -14719092, -21095208, -27678681, + -35807499, -44718702, -52254129, -55306469, -52254132, -44718696, + -35807502, -27678681, -21095206, -14719093, -10257165, -7149355, + -4995375, -3500199, -1945172, -1086175, -608313, -341283, + -2}, + {-3, -574839, -1026313, -1838045, -3309836, -6017788, + -8678530, -12620301, -18566315, -29617669, -51387072, -78419391, + -127027637, -219233301, -378389804, -496424308, -378390018, -219233261, + -127027650, -78419391, -51387075, -29617669, -18566313, -12620300, + -8678531, -6017788, -3309837, -1838046, -1026313, -574839, + -3}, + }, +}; + +const WORD32 ixheaacd_re_weight_Q28[16][8][31] = { + { + {134217728, 133460863, 132868901, 131810111, 129908442, 126470291, + 123168465, 118415202, 111553289, 101653880, 87503416, 75055587, + 59853017, 41890564, 21615401, 0, -21615400, -41890567, + -59853022, -75055592, -87503416, -101653880, -111553289, -118415202, + -123168474, -126470291, -129908442, -131810119, -132868916, -133460855, + -134217736}, + {134217728, 133507641, 132951036, 131952906, 130152305, 126873835, + 123700894, 119097743, 112392608, 102624793, 88527346, 76037569, + 60709668, 42530952, 21959413, 0, -21959412, -42530956, + -60709668, -76037567, -88527354, -102624793, -112392608, -119097743, + -123700897, -126873843, -130152314, -131952906, -132951044, -133507625, + -134217736}, + {134217728, 133578889, 133076245, 132170971, 130525880, 127495076, + 124524084, 120158840, 113706267, 104156340, 90156022, 77607879, + 62086135, 43563841, 22515636, 0, -22515635, -43563843, + -62086140, -77607874, -90156032, -104156349, -113706267, -120158844, + -124524084, -127495076, -130525880, -132170971, -133076253, -133578881, + -134217736}, + {134217728, 133758012, 133391773, 132722523, 131476888, 129093806, + 126662688, 122949415, 117214012, 108319953, 94671025, 82017354, + 65996439, 46525651, 24120340, 0, -24120340, -46525655, + -65996434, -82017354, -94671025, -108319953, -117214003, -122949415, + -126662696, -129093806, -131476888, -132722531, -133391781, -133758012, + -134217736}, + {134217728, 133932649, 133700308, 133264733, 132420429, 130705061, + 128848242, 125853808, 120950424, 112880929, 99774559, 87108077, + 70599795, 50068507, 26060170, 0, -26060170, -50068507, + -70599792, -87108068, -99774568, -112880929, -120950424, -125853814, + -128848243, -130705069, -132420430, -133264733, -133700308, -133932641, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217744, 134655979, 134988239, 135559790, 136513776, 138005964, + 139162482, 140361258, 141138020, 140293965, 138371877, 136502930, + 126746944, 102804704, 59370579, 0, -59370579, -102804704, + -126746957, -136502930, -138371890, -140293970, -141138020, -140361258, + -139162497, -138005964, -136513792, -135559805, -134988239, -134655979, + -134217744}, + {134217744, 134962683, 135539295, 136557732, 138346233, 141452453, + 144288910, 148135620, 153292676, 175071409, 212428515, 254219167, + 323573619, 452387989, 709374650, 0, -709375876, -452387936, + -323573672, -254219167, -212428528, -175071409, -153292663, -148135606, + -144288924, -141452453, -138346233, -136557732, -135539295, -134962683, + -134217744}, + }, + { + {134217728, 133517388, 132968168, 131982689, 130203271, 126958371, + 123812646, 119241372, 112569794, 102830521, 88745164, 76246965, + 60892748, 42668052, 22033146, 0, -22033144, -42668057, + -60892753, -76246965, -88745164, -102830531, -112569785, -119241363, + -123812654, -126958371, -130203280, -131982697, -132968160, -133517380, + -134217736}, + {134217728, 133560667, 133044207, 132115111, 130430074, 127335394, + 124312090, 119884885, 113366063, 103758318, 89731143, 77197214, + 61725371, 43292653, 22369435, 0, -22369434, -43292655, + -61725371, -77197209, -89731143, -103758309, -113366063, -119884894, + -124312098, -127335394, -130430074, -132115119, -133044215, -133560651, + -134217736}, + {134217728, 133626556, 133160120, 132317284, 130777308, 127915335, + 125083431, 120883935, 114610226, 105218864, 91295851, 78713132, + 63059915, 44297538, 22911785, 0, -22911782, -44297538, + -63059910, -78713137, -91295851, -105218855, -114610226, -120883935, + -125083440, -127915335, -130777308, -132317293, -133160128, -133626540, + -134217736}, + {134217728, 133792202, 133452102, 132828323, 131660297, 129405046, + 127082463, 123503081, 117919375, 109170723, 95610055, 82945267, + 66828178, 47161136, 24466610, 0, -24466610, -47161136, + -66828178, -82945267, -95610064, -109170725, -117919366, -123503090, + -127082486, -129405039, -131660312, -132828331, -133452110, -133792210, + -134217736}, + {134217728, 133953625, 133737455, 133330222, 132534982, 130902453, + 129118100, 126216242, 121423078, 113467678, 100443871, 87784612, + 71219199, 50550149, 26325706, 0, -26325706, -50550154, + -71219202, -87784612, -100443871, -113467678, -121423078, -126216226, + -129118109, -130902453, -132534997, -133330214, -133737456, -133953625, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217744, 134621813, 134927051, 135449572, 136313400, 137636071, + 138622650, 139566056, 139956832, 138536878, 133180717, 129783677, + 118675624, 94628804, 53853292, 0, -53853295, -94628804, + -118675637, -129783677, -133180717, -138536864, -139956832, -139566056, + -138622666, -137636071, -136313400, -135449556, -134927051, -134621813, + -134217744}, + {134217744, 134904883, 135435203, 136368502, 137996233, 140785045, + 143282261, 146575942, 150720567, 165849956, 193015182, 218765195, + 250475781, 276007380, 232012261, 0, -232012394, -276007380, + -250475807, -218765195, -193015209, -165849956, -150720553, -146575942, + -143282270, -140785029, -137996233, -136368502, -135435219, -134904883, + -134217744}, + }, + { + {134217728, 133678764, 133252044, 132477911, 131054012, 128379841, + 125703998, 121692333, 115624163, 106419205, 92593586, 79977946, + 64179408, 45144170, 23370016, 0, -23370016, -45144175, + -64179408, -79977946, -92593586, -106419196, -115624163, -121692324, + -125704006, -128379848, -131054020, -132477902, -133252052, -133678756, + -134217736}, + {134217728, 133712005, 133310620, 132580354, 131230923, 128677921, + 126103542, 122214988, 116283221, 107204353, 93448326, 80814826, + 64923233, 45708586, 23676171, 0, -23676171, -45708586, + -64923233, -80814831, -93448326, -107204344, -116283221, -122214988, + -126103542, -128677921, -131230923, -132580362, -133310620, -133711997, + -134217736}, + {134217728, 133762594, 133399847, 132736656, 131501355, 129135285, + 126718571, 123023009, 117307580, 108432548, 94794977, 82139614, + 66105841, 46609132, 24165789, 0, -24165786, -46609132, + -66105847, -82139614, -94794987, -108432548, -117307580, -123023009, + -126718574, -129135283, -131501371, -132736656, -133399839, -133762594, + -134217736}, + {134217728, 133889704, 133624356, 133130995, 132186884, 130303885, + 128301191, 125121697, 120000061, 111707953, 98445440, 85770865, + 69380893, 49124191, 25540859, 0, -25540857, -49124196, + -69380888, -85770874, -98445440, -111707944, -120000061, -125121697, + -128301191, -130303893, -132186900, -133130995, -133624356, -133889712, + -134217728}, + {134217728, 134013488, 133843425, 133517257, 132862879, 131469447, + 129895964, 127265729, 122800030, 115190043, 102426301, 89801131, + 73076637, 52001860, 27128796, 0, -27128794, -52001864, + -73076641, -89801131, -102426301, -115190039, -122800030, -127265729, + -129895972, -131469447, -132862879, -133517265, -133843441, -134013480, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134524667, 134753225, 135137152, 135747532, 136598811, + 137119080, 137373516, 136748951, 133873231, 125921352, 115399244, + 100457884, 77154931, 42583862, 0, -42583862, -77154938, + -100457891, -115399244, -125921369, -133873231, -136748936, -137373501, + -137119096, -136598811, -135747548, -135137152, -134753241, -134524667, + -134217728}, + {134217744, 134740697, 135140165, 135833916, 137013874, 138934982, + 140527025, 142390637, 144197099, 144950624, 153156303, 156579063, + 152419543, 130790210, 79555611, 0, -79555625, -130790210, + -152419556, -156579063, -153156316, -144950610, -144197089, -142390622, + -140527040, -138934982, -137013890, -135833916, -135140150, -134740697, + -134217744}, + }, + { + {134217728, 133921369, 133680325, 133229561, 132358967, 130599331, + 128703866, 125660282, 120698624, 112569282, 99420258, 86750815, + 70273432, 49815216, 25920711, 0, -25920711, -49815221, + -70273437, -86750806, -99420256, -112569274, -120698624, -125660282, + -128703883, -130599348, -132358983, -133229561, -133680325, -133921361, + -134217728}, + {134217728, 133939441, 133712333, 133285932, 132457505, 130768900, + 128935466, 125970874, 121102931, 113070012, 99989913, 87325519, + 70798672, 50223025, 26145310, 0, -26145308, -50223025, + -70798677, -87325519, -99989913, -113070003, -121102931, -125970860, + -128935481, -130768908, -132457513, -133285932, -133712341, -133939433, + -134217728}, + {134217728, 133966965, 133761027, 133371807, 132607806, 131028081, + 129290134, 126447733, 121725737, 113844587, 100875426, 88221963, + 71620613, 50862941, 26498391, 0, -26498388, -50862946, + -71620620, -88221963, -100875417, -113844587, -121725728, -126447716, + -129290134, -131028089, -132607807, -133371815, -133761036, -133966957, + -134217728}, + {134217728, 134036022, 133883399, 133587872, 132986916, 131684800, + 130192440, 127667609, 123330628, 115859003, 103203522, 90597004, + 73814421, 52581631, 27450709, 0, -27450709, -52581635, + -73814421, -90597004, -103203522, -115858986, -123330612, -127667609, + -130192441, -131684792, -132986917, -133587864, -133883399, -134036014, + -134217728}, + {134217728, 134103202, 134002513, 133798640, 133358145, 132331971, + 131086862, 128886498, 124951227, 117920856, 105625498, 93096793, + 76149690, 54428903, 28481041, 0, -28481039, -54428903, + -76149698, -93096793, -105625498, -117920856, -124951227, -128886489, + -131086879, -132331963, -133358153, -133798640, -134002521, -134103194, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134379666, 134494354, 134673574, 134913679, 135089351, + 134957528, 134277005, 132335084, 127697337, 117706196, 106054041, + 88737129, 64741142, 34377364, 0, -34377364, -64741149, + -88737144, -106054041, -117706196, -127697337, -132335084, -134276990, + -134957528, -135089351, -134913679, -134673590, -134494354, -134379666, + -134217728}, + {134217728, 134496089, 134702142, 135045469, 135582090, 136297572, + 136685209, 136746798, 135844838, 132586209, 124167611, 113363711, + 96250730, 73172752, 40110146, 0, -40110146, -73172752, + -96250737, -113363711, -124167625, -132586192, -135844823, -136746798, + -136685224, -136297557, -135582122, -135045469, -134702142, -134496073, + -134217728}, + }, + { + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369938, 0, -30369936, -57781476, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369938, 0, -30369936, -57781476, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369938, 0, -30369936, -57781479, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + }, + { + {134217728, 134498993, 134707335, 135054789, 135598900, 136328115, + 136729141, 136810142, 135935959, 132715402, 124342638, 113565820, + 96534651, 73558852, 40348512, 0, -40348509, -73558852, + -96534651, -113565820, -124342622, -132715402, -135935959, -136810127, + -136729141, -136328115, -135598916, -135054789, -134707335, -134498977, + -134217728}, + {134217728, 134480680, 134674623, 134996162, 135493192, 136136017, + 136453048, 136412541, 135364880, 131907703, 123252219, 112310293, + 95147250, 71192218, 38892389, 0, -38892389, -71192225, + -95147244, -112310293, -123252233, -131907703, -135364880, -136412525, + -136453064, -136136017, -135493192, -134996162, -134674623, -134480664, + -134217728}, + {134217728, 134452852, 134624907, 134907111, 135332868, 135845392, + 136036318, 135814387, 134509950, 130707034, 121647428, 110478072, + 93245003, 68600479, 36868706, 0, -36868706, -68600486, + -93245010, -110478072, -121647428, -130707019, -134509933, -135814387, + -136036318, -135845392, -135332868, -134907111, -134624907, -134452836, + -134217728}, + {134217728, 134383129, 134500515, 134684594, 134933403, 135124815, + 135007943, 134348491, 132435517, 127834944, 117883926, 106251314, + 88935676, 64909118, 34475644, 0, -34475641, -64909118, + -88935672, -106251314, -117883941, -127834944, -132435502, -134348484, + -135007943, -135124799, -134933403, -134684610, -134500515, -134383113, + -134217728}, + {134217728, 134315558, 134380057, 134469604, 134548899, 134436000, + 134031448, 132969665, 130510521, 125220021, 114545007, 102579384, + 85276062, 61841165, 32692547, 0, -32692543, -61841172, + -85276062, -102579384, -114545015, -125220021, -130510514, -132969665, + -134031463, -134436000, -134548899, -134469604, -134380057, -134315558, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134039455, 133889472, 133598612, 133005816, 131717634, + 130237695, 127729079, 123411911, 115961736, 103323251, 90719885, + 73928581, 52671501, 27500671, 0, -27500669, -52671505, + -73928581, -90719885, -103323259, -115961741, -123411903, -127729055, + -130237711, -131717634, -133005816, -133598612, -133889472, -134039447, + -134217728}, + {134217728, 133924242, 133685411, 133238504, 132374593, 130626201, + 128740547, 125709420, 120762534, 112648312, 99510030, 86841272, + 70356024, 49879283, 25955974, 0, -25955971, -49879287, + -70356024, -86841272, -99510039, -112648312, -120762526, -125709412, + -128740555, -130626209, -132374601, -133238504, -133685403, -133924234, + -134217728}, + }, + { + {134217744, 134746091, 135149853, 135851434, 137045902, 138994799, + 140615296, 142522879, 144398695, 145263100, 154205556, 158059463, + 154411290, 133097557, 81316205, 0, -81316205, -133097543, + -154411303, -158059463, -154205556, -145263100, -144398695, -142522879, + -140615296, -138994799, -137045918, -135851434, -135149837, -134746091, + -134217744}, + {134217744, 134712087, 135088825, 135741208, 136844475, 138619336, + 140061990, 141695888, 143142475, 143327466, 147825370, 149173983, + 142666223, 119784477, 71366265, 0, -71366265, -119784477, + -142666263, -149173983, -147825383, -143327466, -143142475, -141695873, + -140062006, -138619320, -136844467, -135741224, -135088825, -134712087, + -134217744}, + {134217744, 134660400, 134996180, 135574064, 136539790, 138054064, + 139232828, 140465192, 141293136, 140526367, 139073637, 137423970, + 127872797, 103967564, 60168572, 0, -60168579, -103967564, + -127872810, -137423970, -139073650, -140526353, -141293121, -140465192, + -139232828, -138054064, -136539805, -135574064, -134996180, -134660400, + -134217744}, + {134217728, 134531071, 134764682, 135157698, 135784674, 136666568, + 137216832, 137515087, 136953956, 134166704, 126324479, 115870417, + 101486338, 78107065, 43180376, 0, -43180372, -78107065, + -101486344, -115870417, -126324479, -134166690, -136953956, -137515087, + -137216847, -136666568, -135784674, -135157698, -134764682, -134531071, + -134217728}, + {134217728, 134405853, 134541061, 134757061, 135063333, 135358653, + 135340907, 134821548, 133101766, 128751135, 119073216, 107576641, + 90275394, 66047286, 35143667, 0, -35143664, -66047286, + -90275401, -107576641, -119073231, -128751120, -133101751, -134821548, + -135340923, -135358653, -135063349, -134757077, -134541061, -134405853, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 133896028, 133635530, 133150648, 132221176, 130362696, + 128381245, 125228644, 120138520, 111878277, 98637718, 85963798, + 69556315, 49259814, 25615335, 0, -25615335, -49259818, + -69556315, -85963798, -98637718, -111878269, -120138520, -125228635, + -128381253, -130362689, -132221184, -133150656, -133635522, -133896020, + -134217728}, + {134217728, 133684024, 133261330, 132494150, 131082043, 128427016, + 125767162, 121774846, 115728035, 106542671, 92727700, 80109047, + 64295775, 45232367, 23417819, 0, -23417819, -45232367, + -64295774, -80109052, -92727700, -106542671, -115728027, -121774851, + -125767170, -128427016, -131082043, -132494166, -133261346, -133684032, + -134217736}, + }, + { + {134217744, 134911968, 135447966, 136391663, 138039000, 140866367, + 143404554, 146764521, 151021632, 166927889, 195202182, 222570595, + 257610421, 289862500, 252874234, 0, -252874341, -289862420, + -257610501, -222570621, -195202209, -166927876, -151021632, -146764507, + -143404554, -140866352, -138039000, -136391663, -135447966, -134911968, + -134217744}, + {134217744, 134867355, 135367738, 136245965, 137770239, 140356424, + 142639355, 145588557, 149154344, 160361636, 182196342, 200588382, + 218415341, 220218448, 161428236, 0, -161428263, -220218448, + -218415395, -200588409, -182196329, -160361623, -149154344, -145588542, + -142639355, -140356409, -137770238, -136245981, -135367738, -134867355, + -134217744}, + {134217744, 134799630, 135245963, 136025282, 137364449, 139591338, + 141498666, 143852961, 146442545, 151309130, 165431889, 174391809, + 177370022, 161281089, 104146144, 0, -104146171, -161281089, + -177370049, -174391796, -165431903, -151309116, -146442531, -143852947, + -141498681, -139591338, -137364449, -136025297, -135245963, -134799614, + -134217744}, + {134217744, 134630198, 134942075, 135476620, 136362516, 137726655, + 138754657, 139760139, 140244217, 138962344, 134419383, 131372064, + 120561410, 96514144, 55111265, 0, -55111262, -96514144, + -120561424, -131372064, -134419383, -138962344, -140244217, -139760124, + -138754673, -137726655, -136362532, -135476604, -134942075, -134630198, + -134217744}, + {134217728, 134466320, 134648961, 134950176, 135410401, 135985835, + 136237563, 136102933, 134921759, 131284100, 122416352, 111353663, + 94151405, 69439052, 37821289, 0, -37821289, -69439058, + -94151405, -111353655, -122416359, -131284100, -134921744, -136102933, + -136237563, -135985836, -135410401, -134950176, -134648961, -134466304, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 133800456, 133466639, 132853833, 131704577, 129480322, + 127184162, 123637500, 118091100, 109378569, 95840339, 83173415, + 67033158, 47318062, 24552229, 0, -24552227, -47318062, + -67033165, -83173405, -95840348, -109378569, -118091100, -123637492, + -127184170, -129480322, -131704577, -132853833, -133466647, -133800448, + -134217736}, + {134217728, 133524250, 132980227, 132003691, 130239201, 127017985, + 123891524, 119342831, 112695071, 102976138, 88899495, 76395462, + 61022664, 42765392, 22085513, 0, -22085512, -42765395, + -61022669, -76395462, -88899495, -102976129, -112695062, -119342822, + -123891527, -127017985, -130239210, -132003691, -132980227, -133524250, + -134217736}, + }, + { + {134217744, 134970359, 135553135, 136582894, 138392877, 141541743, + 144424094, 148346340, 153978836, 176372729, 215302062, 259806420, + 336609085, 494304735, 975787497, -858993460, -975789097, -494304522, + -336609192, -259806447, -215302075, -176372702, -153978836, -148346340, + -144424109, -141541728, -138392877, -136582894, -135553135, -134970359, + -134217744}, + {134217744, 134922022, 135466091, 136424566, 138099800, 140982070, + 143578731, 147033572, 151452343, 168483023, 198394635, 228208128, + 268470634, 312112739, 289892500, 0, -289892633, -312112739, + -268470714, -228208155, -198394649, -168483009, -151452340, -147033558, + -143578731, -140982070, -138099815, -136424566, -135466075, -134922022, + -134217744}, + {134217744, 134848627, 135333994, 136184803, 137657591, 140143456, + 142320970, 145102040, 148388972, 157750196, 177226889, 192583689, + 205271595, 199995929, 140105690, 0, -140105757, -199995915, + -205271635, -192583689, -177226916, -157750183, -148388958, -145102025, + -142320985, -140143456, -137657591, -136184803, -135334009, -134848611, + -134217744}, + {134217744, 134665058, 135004509, 135589124, 136567188, 138104822, + 139307072, 140574980, 141457125, 140772491, 139820837, 138408050, + 129080970, 105221711, 61032985, 0, -61032985, -105221711, + -129080997, -138408050, -139820850, -140772477, -141457125, -140574962, + -139307072, -138104806, -136567205, -135589140, -135004525, -134665058, + -134217744}, + {134217728, 134487552, 134686918, 135018188, 135532903, 136208162, + 136556685, 136561648, 135578778, 132209698, 123658874, 112777500, + 95635765, 72064052, 39427432, 0, -39427432, -72064065, + -95635772, -112777498, -123658874, -132209683, -135578762, -136561648, + -136556685, -136208146, -135532903, -135018204, -134686918, -134487552, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 133766932, 133407501, 132750065, 131524599, 129174690, + 126771678, 123092977, 117396601, 108539737, 94913060, 82256151, + 66210183, 46688771, 24209158, 0, -24209156, -46688776, + -66210179, -82256150, -94913060, -108539737, -117396605, -123092969, + -126771680, -129174690, -131524607, -132750073, -133407493, -133766932, + -134217736}, + {134217728, 133468277, 132881938, 131832762, 129947063, 126534099, + 123252524, 118522767, 111685262, 101806166, 87663578, 75208916, + 59986579, 41990286, 21668928, 0, -21668926, -41990288, + -59986579, -75208922, -87663568, -101806156, -111685259, -118522767, + -123252524, -126534093, -129947064, -131832762, -132881938, -133468277, + -134217736}, + }, + { + {134217744, 134911968, 135447966, 136391663, 138039000, 140866367, + 143404554, 146764521, 151021632, 166927889, 195202182, 222570595, + 257610421, 289862500, 252874234, 0, -252874341, -289862420, + -257610501, -222570621, -195202209, -166927876, -151021632, -146764507, + -143404554, -140866352, -138039000, -136391663, -135447966, -134911968, + -134217744}, + {134217744, 134867355, 135367738, 136245965, 137770239, 140356424, + 142639355, 145588557, 149154344, 160361636, 182196342, 200588382, + 218415341, 220218448, 161428236, 0, -161428263, -220218448, + -218415395, -200588409, -182196329, -160361623, -149154344, -145588542, + -142639355, -140356409, -137770238, -136245981, -135367738, -134867355, + -134217744}, + {134217744, 134799630, 135245963, 136025282, 137364449, 139591338, + 141498666, 143852961, 146442545, 151309130, 165431889, 174391809, + 177370022, 161281089, 104146144, 0, -104146171, -161281089, + -177370049, -174391796, -165431903, -151309116, -146442531, -143852947, + -141498681, -139591338, -137364449, -136025297, -135245963, -134799614, + -134217744}, + {134217744, 134630198, 134942075, 135476620, 136362516, 137726655, + 138754657, 139760139, 140244217, 138962344, 134419383, 131372064, + 120561410, 96514144, 55111265, 0, -55111262, -96514144, + -120561424, -131372064, -134419383, -138962344, -140244217, -139760124, + -138754673, -137726655, -136362532, -135476604, -134942075, -134630198, + -134217744}, + {134217728, 134466320, 134648961, 134950176, 135410401, 135985835, + 136237563, 136102933, 134921759, 131284100, 122416352, 111353663, + 94151405, 69439052, 37821289, 0, -37821289, -69439058, + -94151405, -111353655, -122416359, -131284100, -134921744, -136102933, + -136237563, -135985836, -135410401, -134950176, -134648961, -134466304, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 133800456, 133466639, 132853833, 131704577, 129480322, + 127184162, 123637500, 118091100, 109378569, 95840339, 83173415, + 67033158, 47318062, 24552229, 0, -24552227, -47318062, + -67033165, -83173405, -95840348, -109378569, -118091100, -123637492, + -127184170, -129480322, -131704577, -132853833, -133466647, -133800448, + -134217736}, + {134217728, 133524250, 132980227, 132003691, 130239201, 127017985, + 123891524, 119342831, 112695071, 102976138, 88899495, 76395462, + 61022664, 42765392, 22085513, 0, -22085512, -42765395, + -61022669, -76395462, -88899495, -102976129, -112695062, -119342822, + -123891527, -127017985, -130239210, -132003691, -132980227, -133524250, + -134217736}, + }, + { + {134217744, 134746091, 135149853, 135851434, 137045902, 138994799, + 140615296, 142522879, 144398709, 145263103, 154205570, 158059476, + 154411303, 133097570, 81316211, 0, -81316218, -133097557, + -154411316, -158059490, -154205570, -145263103, -144398709, -142522879, + -140615296, -138994799, -137045918, -135851434, -135149837, -134746091, + -134217744}, + {134217744, 134712087, 135088825, 135741208, 136844475, 138619336, + 140061990, 141695888, 143142475, 143327470, 147825383, 149173983, + 142666250, 119784490, 71366272, 0, -71366278, -119784490, + -142666277, -149173996, -147825383, -143327466, -143142475, -141695873, + -140062006, -138619320, -136844467, -135741224, -135088825, -134712087, + -134217744}, + {134217744, 134660400, 134996180, 135574064, 136539790, 138054064, + 139232828, 140465192, 141293136, 140526367, 139073637, 137423983, + 127872810, 103967578, 60168579, 0, -60168585, -103967578, + -127872810, -137423970, -139073650, -140526353, -141293121, -140465192, + -139232843, -138054064, -136539805, -135574064, -134996180, -134660400, + -134217744}, + {134217728, 134531071, 134764682, 135157698, 135784674, 136666568, + 137216832, 137515087, 136953956, 134166704, 126324470, 115870417, + 101486344, 78107071, 43180379, 0, -43180376, -78107078, + -101486351, -115870417, -126324479, -134166695, -136953956, -137515087, + -137216847, -136666568, -135784674, -135157698, -134764682, -134531071, + -134217728}, + {134217728, 134405853, 134541061, 134757061, 135063333, 135358653, + 135340907, 134821548, 133101766, 128751127, 119073224, 107576641, + 90275401, 66047293, 35143667, 0, -35143667, -66047293, + -90275401, -107576641, -119073231, -128751127, -133101751, -134821548, + -135340923, -135358653, -135063349, -134757077, -134541061, -134405853, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 133896028, 133635530, 133150648, 132221176, 130362696, + 128381245, 125228635, 120138520, 111878281, 98637718, 85963798, + 69556315, 49259814, 25615335, 0, -25615335, -49259818, + -69556310, -85963798, -98637709, -111878269, -120138520, -125228635, + -128381253, -130362689, -132221184, -133150656, -133635522, -133896020, + -134217728}, + {134217728, 133684024, 133261330, 132494150, 131082043, 128427016, + 125767162, 121774843, 115728035, 106542671, 92727700, 80109047, + 64295775, 45232366, 23417819, 0, -23417819, -45232366, + -64295775, -80109047, -92727700, -106542662, -115728027, -121774851, + -125767170, -128427016, -131082043, -132494166, -133261346, -133684032, + -134217736}, + }, + { + {134217728, 134498993, 134707335, 135054789, 135598916, 136328115, + 136729141, 136810142, 135935974, 132715400, 124342636, 113565825, + 96534671, 73558872, 40348522, 0, -40348522, -73558878, + -96534671, -113565825, -124342636, -132715400, -135935959, -136810142, + -136729157, -136328114, -135598899, -135054789, -134707335, -134498977, + -134217728}, + {134217728, 134480680, 134674623, 134996162, 135493192, 136136017, + 136453048, 136412541, 135364880, 131907703, 123252239, 112310291, + 95147257, 71192238, 38892402, 0, -38892399, -71192238, + -95147250, -112310298, -123252239, -131907703, -135364895, -136412525, + -136453064, -136136017, -135493192, -134996146, -134674623, -134480664, + -134217728}, + {134217728, 134452852, 134624907, 134907111, 135332868, 135845392, + 136036318, 135814387, 134509933, 130707049, 121647427, 110478071, + 93245017, 68600483, 36868716, 0, -36868712, -68600489, + -93245017, -110478064, -121647443, -130707034, -134509933, -135814387, + -136036318, -135845392, -135332883, -134907111, -134624907, -134452836, + -134217728}, + {134217728, 134383129, 134500499, 134684594, 134933403, 135124815, + 135007943, 134348507, 132435517, 127834959, 117883933, 106251321, + 88935672, 64909116, 34475648, 0, -34475644, -64909116, + -88935679, -106251321, -117883933, -127834944, -132435517, -134348491, + -135007943, -135124799, -134933403, -134684610, -134500515, -134383113, + -134217728}, + {134217728, 134315558, 134380057, 134469604, 134548899, 134436000, + 134031448, 132969681, 130510521, 125220028, 114545015, 102579384, + 85276069, 61841172, 32692547, 0, -32692547, -61841176, + -85276077, -102579384, -114545015, -125220021, -130510521, -132969665, + -134031463, -134436000, -134548899, -134469604, -134380057, -134315558, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134039455, 133889472, 133598612, 133005800, 131717634, + 130237695, 127729079, 123411911, 115961741, 103323251, 90719885, + 73928580, 52671496, 27500669, 0, -27500669, -52671501, + -73928580, -90719885, -103323262, -115961741, -123411903, -127729055, + -130237711, -131717634, -133005808, -133598612, -133889472, -134039455, + -134217728}, + {134217728, 133924242, 133685411, 133238504, 132374593, 130626201, + 128740547, 125709420, 120762531, 112648312, 99510021, 86841264, + 70356022, 49879278, 25955971, 0, -25955969, -49879283, + -70356027, -86841273, -99510021, -112648303, -120762517, -125709412, + -128740555, -130626208, -132374601, -133238504, -133685403, -133924234, + -134217728}, + }, + { + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + }, + { + {134217728, 133921369, 133680325, 133229561, 132358967, 130599331, + 128703866, 125660282, 120698624, 112569265, 99420249, 86750797, + 70273427, 49815207, 25920708, 0, -25920706, -49815216, + -70273432, -86750797, -99420258, -112569265, -120698624, -125660282, + -128703874, -130599331, -132358983, -133229561, -133680325, -133921361, + -134217728}, + {134217728, 133939441, 133712333, 133285932, 132457505, 130768900, + 128935465, 125970874, 121102931, 113070012, 99989904, 87325519, + 70798668, 50223016, 26145306, 0, -26145303, -50223020, + -70798668, -87325510, -99989904, -113070007, -121102923, -125970860, + -128935481, -130768900, -132457513, -133285939, -133712341, -133939433, + -134217728}, + {134217728, 133966965, 133761027, 133371807, 132607806, 131028081, + 129290132, 126447716, 121725742, 113844587, 100875428, 88221954, + 71620616, 50862942, 26498391, 0, -26498387, -50862942, + -71620616, -88221954, -100875420, -113844579, -121725728, -126447716, + -129290134, -131028089, -132607814, -133371815, -133761036, -133966957, + -134217728}, + {134217728, 134036022, 133883399, 133587872, 132986916, 131684800, + 130192440, 127667609, 123330612, 115858986, 103203513, 90596996, + 73814421, 52581631, 27450707, 0, -27450704, -52581631, + -73814421, -90596996, -103203522, -115858986, -123330612, -127667609, + -130192441, -131684792, -132986917, -133587864, -133883399, -134036014, + -134217728}, + {134217728, 134103202, 134002513, 133798640, 133358145, 132331971, + 131086862, 128886498, 124951211, 117920856, 105625489, 93096793, + 76149699, 54428898, 28481041, 0, -28481039, -54428898, + -76149699, -93096785, -105625498, -117920856, -124951211, -128886489, + -131086879, -132331963, -133358153, -133798640, -134002521, -134103194, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134379666, 134494354, 134673574, 134913679, 135089351, + 134957528, 134277005, 132335084, 127697337, 117706188, 106054041, + 88737144, 64741149, 34377366, 0, -34377367, -64741156, + -88737144, -106054041, -117706196, -127697337, -132335084, -134276990, + -134957528, -135089351, -134913695, -134673590, -134494354, -134379666, + -134217728}, + {134217728, 134496089, 134702142, 135045469, 135582090, 136297572, + 136685224, 136746798, 135844838, 132586207, 124167625, 113363717, + 96250743, 73172765, 40110159, 0, -40110156, -73172772, + -96250750, -113363724, -124167639, -132586207, -135844838, -136746798, + -136685224, -136297572, -135582122, -135045469, -134702142, -134496073, + -134217728}, + }, + { + {134217728, 133678764, 133252044, 132477911, 131054012, 128379841, + 125703998, 121692333, 115624181, 106419205, 92593586, 79977943, + 64179408, 45144170, 23370016, 0, -23370016, -45144171, + -64179414, -79977946, -92593586, -106419205, -115624163, -121692333, + -125704006, -128379841, -131054020, -132477902, -133252052, -133678756, + -134217736}, + {134217728, 133712005, 133310620, 132580354, 131230923, 128677921, + 126103542, 122214988, 116283239, 107204353, 93448335, 80814831, + 64923238, 45708586, 23676173, 0, -23676171, -45708591, + -64923238, -80814831, -93448335, -107204344, -116283230, -122214988, + -126103542, -128677921, -131230923, -132580362, -133310620, -133711997, + -134217736}, + {134217728, 133762594, 133399847, 132736656, 131501355, 129135285, + 126718565, 123023009, 117307580, 108432557, 94794977, 82139615, + 66105845, 46609132, 24165789, 0, -24165786, -46609132, + -66105845, -82139614, -94794987, -108432548, -117307580, -123023009, + -126718574, -129135285, -131501371, -132736656, -133399839, -133762594, + -134217736}, + {134217728, 133889704, 133624356, 133130995, 132186884, 130303885, + 128301191, 125121697, 120000061, 111707953, 98445440, 85770865, + 69380893, 49124196, 25540859, 0, -25540856, -49124196, + -69380893, -85770874, -98445449, -111707944, -120000061, -125121697, + -128301191, -130303893, -132186900, -133130995, -133624357, -133889712, + -134217728}, + {134217728, 134013488, 133843425, 133517257, 132862879, 131469448, + 129895964, 127265729, 122800030, 115190043, 102426301, 89801131, + 73076634, 52001860, 27128796, 0, -27128794, -52001864, + -73076638, -89801131, -102426301, -115190039, -122800030, -127265729, + -129895972, -131469447, -132862879, -133517265, -133843441, -134013480, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217728, 134524667, 134753225, 135137152, 135747532, 136598811, + 137119081, 137373516, 136748951, 133873234, 125921352, 115399246, + 100457878, 77154925, 42583859, 0, -42583859, -77154925, + -100457884, -115399246, -125921369, -133873234, -136748936, -137373501, + -137119096, -136598811, -135747548, -135137152, -134753241, -134524667, + -134217728}, + {134217744, 134740697, 135140165, 135833916, 137013874, 138934982, + 140527025, 142390622, 144197099, 144950610, 153156290, 156579036, + 152419516, 130790170, 79555585, 0, -79555598, -130790170, + -152419516, -156579036, -153156290, -144950597, -144197099, -142390622, + -140527040, -138934982, -137013891, -135833916, -135140150, -134740697, + -134217744}, + }, + { + {134217728, 133517388, 132968168, 131982689, 130203271, 126958371, + 123812646, 119241372, 112569785, 102830521, 88745154, 76246960, + 60892748, 42668052, 22033146, 0, -22033144, -42668058, + -60892753, -76246960, -88745154, -102830531, -112569785, -119241363, + -123812646, -126958371, -130203280, -131982697, -132968160, -133517380, + -134217736}, + {134217728, 133560667, 133044207, 132115111, 130430074, 127335394, + 124312090, 119884885, 113366063, 103758318, 89731133, 77197209, + 61725371, 43292651, 22369435, 0, -22369434, -43292655, + -61725371, -77197209, -89731143, -103758309, -113366066, -119884894, + -124312098, -127335394, -130430074, -132115119, -133044215, -133560651, + -134217736}, + {134217728, 133626556, 133160120, 132317284, 130777308, 127915335, + 125083431, 120883935, 114610226, 105218855, 91295851, 78713135, + 63059915, 44297538, 22911785, 0, -22911782, -44297538, + -63059910, -78713135, -91295851, -105218855, -114610226, -120883926, + -125083440, -127915335, -130777308, -132317293, -133160128, -133626540, + -134217736}, + {134217728, 133792202, 133452102, 132828323, 131660297, 129405046, + 127082463, 123503081, 117919375, 109170723, 95610055, 82945267, + 66828178, 47161136, 24466610, 0, -24466610, -47161136, + -66828178, -82945267, -95610064, -109170725, -117919366, -123503090, + -127082486, -129405039, -131660312, -132828331, -133452110, -133792210, + -134217736}, + {134217728, 133953625, 133737455, 133330222, 132534982, 130902453, + 129118100, 126216242, 121423078, 113467678, 100443871, 87784612, + 71219202, 50550149, 26325706, 0, -26325706, -50550154, + -71219202, -87784603, -100443871, -113467678, -121423078, -126216226, + -129118109, -130902436, -132534997, -133330214, -133737456, -133953625, + -134217728}, + {134217728, 134209240, 134190888, 134132864, 133949552, 133371536, + 132534624, 130880344, 127640160, 121406192, 109814504, 97493904, + 80326624, 57781472, 30369936, 0, -30369936, -57781472, + -80326624, -97493904, -109814504, -121406184, -127640152, -130880344, + -132534632, -133371536, -133949560, -134132872, -134190888, -134209240, + -134217728}, + {134217744, 134621813, 134927051, 135449572, 136313400, 137636071, + 138622650, 139566056, 139956832, 138536878, 133180717, 129783677, + 118675624, 94628818, 53853299, 0, -53853295, -94628811, + -118675637, -129783677, -133180717, -138536882, -139956832, -139566056, + -138622666, -137636071, -136313400, -135449572, -134927051, -134621813, + -134217744}, + {134217744, 134904883, 135435219, 136368502, 137996233, 140785045, + 143282261, 146575942, 150720567, 165849956, 193015195, 218765208, + 250475834, 276007487, 232012394, 0, -232012528, -276007460, + -250475861, -218765208, -193015222, -165849956, -150720553, -146575942, + -143282275, -140785029, -137996233, -136368502, -135435219, -134904883, + -134217744}, + }, +}; + +const WORD32 ixheaacd_beta_Q28[16][8][31] = { + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 524548, 928967, 1639916, 2878403, 5000493, 6908550, + 9455203, 12765894, 16898498, 21732020, 25132388, 28389032, 31149502, + 33022448, 33688388, 33022450, 31149502, 28389032, 25132388, 21732022, + 16898498, 12765894, 9455202, 6908550, 5000493, 2878403, 1639916, + 928967, 524548, 3}, + {5, 812423, 1439377, 2542753, 4468501, 7778568, 10765468, + 14766874, 19992330, 26548934, 34259648, 39707896, 44942048, 49389848, + 52412912, 53488748, 52412912, 49389844, 44942052, 39707896, 34259652, + 26548934, 19992330, 14766874, 10765469, 7778568, 4468501, 2542753, + 1439377, 812423, 5}, + {7, 1202481, 2132639, 3774216, 6653171, 11641950, 16186106, + 22334354, 30462996, 40811628, 53176452, 62028444, 70614328, 77968304, + 82994936, 84789064, 82994936, 77968304, 70614328, 62028448, 53176452, + 40811628, 30462996, 22334354, 16186107, 11641950, 6653172, 3774216, + 2132639, 1202481, 7}, + {8, 1400871, 2486989, 4409108, 7796283, 13714060, + 19156910, 26599080, 36572432, 49482236, 65204176, 76647304, + 87887896, 97621072, 104327480, 106731360, 104327488, 97621064, + 87887896, 76647304, 65204180, 49482240, 36572432, 26599080, + 19156912, 13714061, 7796283, 4409108, 2486989, 1400871, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1223918, 2181987, 3897455, 6984316, 12583060, + 17979762, 25778776, 37085592, 53441976, 78581112, 104374688, + 137112768, 174183376, 206541584, 219922496, 206541600, 174183344, + 137112784, 104374688, 78581120, 53441980, 37085592, 25778774, + 17979764, 12583059, 6984316, 3897455, 2181987, 1223918, + 7}, + {1, 214133, 382441, 685346, 1235544, 2251347, + 3254155, 4749173, 7031145, 11641319, 21058462, 33931652, + 61102220, 133797576, 430779840, 1577812480, 430780608, 133797536, + 61102232, 33931652, 21058464, 11641320, 7031145, 4749173, + 3254155, 2251347, 1235544, 685346, 382441, 214133, + 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 524756, 929618, 1641931, 2884546, 5018684, 6942684, + 9517694, 12876462, 17085148, 22027532, 25515680, 28863994, 31707368, + 33639036, 34326304, 33639036, 31707366, 28863996, 25515680, 22027532, + 17085148, 12876462, 9517694, 6942685, 5018684, 2884546, 1641932, + 929618, 524756, 3}, + {5, 812713, 1440285, 2545568, 4477108, 7804208, 10813826, + 14855985, 20151268, 26819764, 34692788, 40273396, 45646932, 50221664, + 53335084, 54443828, 53335084, 50221660, 45646932, 40273396, 34692788, + 26819762, 20151268, 14855984, 10813826, 7804208, 4477108, 2545568, + 1440285, 812713, 5}, + {7, 1202789, 2133603, 3777225, 6662453, 11670018, 16239749, + 22434930, 30646316, 41132172, 53703904, 62730216, 71504264, 79033256, + 84186408, 86026976, 84186408, 79033248, 71504272, 62730216, 53703904, + 41132176, 30646314, 22434930, 16239752, 11670018, 6662454, 3777225, + 2133603, 1202789, 7}, + {8, 1401091, 2487681, 4411274, 7803027, 13734770, + 19197032, 26675680, 36715348, 49739444, 65641580, 77242592, + 88658976, 98560160, 105390504, 107840400, 105390512, 98560152, + 88658992, 77242592, 65641576, 49739444, 36715348, 26675674, + 19197034, 13734770, 7803028, 4411274, 2487680, 1401091, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1223607, 2180998, 3894286, 6974063, 12549334, + 17910016, 25632730, 36775224, 52772652, 75633064, 99236928, + 128381344, 160330848, 187347760, 198291376, 187347792, 160330816, + 128381360, 99236928, 75633072, 52772648, 36775220, 25632728, + 17910018, 12549334, 6974064, 3894286, 2180998, 1223607, + 7}, + {1, 214041, 382148, 684396, 1232418, 2240724, + 3231452, 4699171, 6913169, 11028142, 19133978, 29199466, + 47298748, 81631520, 140893408, 184843504, 140893488, 81631504, + 47298752, 29199468, 19133982, 11028142, 6913169, 4699170, + 3231452, 2240724, 1232418, 684397, 382148, 214041, + 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 525351, 931480, 1647714, 2902257, 5071597, 7042735, + 9702682, 13207802, 17652582, 22940042, 26711396, 30359376, 33476790, + 35604100, 36362732, 35604100, 33476786, 30359378, 26711396, 22940042, + 17652582, 13207802, 9702681, 7042735, 5071597, 2902257, 1647714, + 931480, 525351, 3}, + {5, 813540, 1442877, 2553636, 4501896, 7878638, 10955188, + 15118865, 20625528, 27638916, 36022472, 42026548, 47851776, 52842400, + 56254208, 57472080, 56254208, 52842396, 47851784, 42026548, 36022476, + 27638918, 20625528, 15118864, 10955189, 7878638, 4501896, 2553636, + 1442877, 813540, 5}, + {7, 1203665, 2136357, 3785832, 6689100, 11751078, 16395488, + 22728960, 31187070, 42088120, 55296528, 64867172, 74235600, 82322976, + 87882752, 89873216, 87882752, 82322968, 74235600, 64867176, 55296532, + 42088120, 31187070, 22728958, 16395489, 11751078, 6689101, 3785832, + 2136357, 1203665, 7}, + {8, 1401717, 2489652, 4417463, 7822332, 13794262, + 19312684, 26897488, 37131704, 50494456, 66937128, 79016952, + 90971256, 101390632, 108605536, 111198632, 108605544, 101390624, + 90971264, 79016952, 66937124, 50494456, 37131704, 26897486, + 19312686, 13794262, 7822333, 4417463, 2489652, 1401717, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1222724, 2178188, 3885304, 6945113, 12454759, + 17715754, 25230046, 35932316, 50996136, 71510480, 88238104, + 108673696, 130724624, 148143056, 154903104, 148143056, 130724616, + 108673712, 88238104, 71510496, 50996136, 35932312, 25230042, + 17715758, 12454758, 6945114, 3885304, 2178189, 1222724, + 7}, + {1, 213781, 381315, 681714, 1223645, 2211279, 3169313, + 4564991, 6613954, 9638447, 15182689, 20899234, 28782236, 38682308, + 48311500, 52599960, 48311512, 38682304, 28782238, 20899234, 15182691, + 9638447, 6613954, 4564991, 3169313, 2211279, 1223645, 681714, + 381315, 213781, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 526244, 934286, 1656482, 2929383, 5154009, 7200895, + 10000863, 13755239, 18618438, 24545894, 28863348, 33106848, 36783144, + 39317176, 40225672, 39317176, 36783140, 33106852, 28863350, 24545894, + 18618438, 13755239, 10000861, 7200896, 5154009, 2929384, 1656483, + 934287, 526244, 3}, + {5, 814783, 1446784, 2565855, 4539774, 7994119, 11177507, + 15539745, 21402348, 29018418, 38333064, 45138568, 51843732, 57665092, + 61684144, 63126300, 61684144, 57665092, 51843740, 45138568, 38333064, + 29018418, 21402346, 15539743, 11177508, 7994120, 4539775, 2565855, + 1446784, 814783, 5}, + {7, 1204981, 2140499, 3798824, 6729584, 11875611, 16637170, + 23191438, 32052658, 43652108, 57969132, 68517104, 78979352, 88117000, + 94454304, 96733920, 94454304, 88116992, 78979352, 68517104, 57969132, + 43652104, 32052654, 23191436, 16637170, 11875611, 6729584, 3798824, + 2140499, 1204981, 7}, + {8, 1402655, 2492611, 4426772, 7851491, 13884761, + 19489746, 27240036, 37782176, 51691532, 69027848, 81916832, + 94796824, 106122752, 114019032, 116867632, 114019032, 106122744, + 94796832, 81916840, 69027848, 51691532, 37782172, 27240034, + 19489748, 13884760, 7851492, 4426772, 2492611, 1402655, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1221406, 2174004, 3871976, 6902451, 12317130, + 17436482, 24661340, 34772520, 48643564, 66845116, 81092456, + 95994376, 109691784, 119593840, 123240696, 119593848, 109691776, + 95994392, 81092456, 66845116, 48643564, 34772520, 24661336, + 17436482, 12317130, 6902452, 3871976, 2174004, 1221406, + 7}, + {1, 213393, 380079, 677757, 1210858, 2169302, 3082668, + 4384052, 6230857, 8816279, 12308982, 15131108, 18175564, 21641460, + 24357568, 25401718, 24357570, 21641458, 18175566, 15131109, 12308983, + 8816278, 6230857, 4384051, 3082668, 2169302, 1210858, 677757, + 380079, 213393, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 527304, 937630, 1667008, 2962381, 5256587, 7401904, + 10390627, 14497757, 19991098, 26957670, 32224264, 37562304, 42318920, + 45670152, 46886204, 45670152, 42318924, 37562308, 32224264, 26957670, + 19991098, 14497757, 10390626, 7401904, 5256587, 2962381, 1667008, + 937630, 527304, 3}, + {5, 816257, 1451433, 2580496, 4585709, 8137095, 11458003, + 16084489, 22442248, 30945832, 41729952, 49882536, 58145720, 65508872, + 70696504, 72578936, 70696512, 65508868, 58145724, 49882536, 41729952, + 30945832, 22442248, 16084488, 11458004, 8137095, 4585709, 2580496, + 1451434, 816257, 5}, + {7, 1206538, 2145415, 3814322, 6778296, 12027725, + 16936476, 23775046, 33172672, 45742120, 61682500, 73733120, + 85947224, 96830952, 104498976, 107281456, 104498984, 96830952, + 85947232, 73733128, 61682504, 45742116, 33172670, 23775044, + 16936476, 12027724, 6778297, 3814322, 2145415, 1206538, + 7}, + {8, 1403765, 2496115, 4437830, 7886310, 13993836, + 19704996, 27661434, 38595240, 53219352, 71765424, 85785904, + 99996584, 112659424, 121580896, 124818216, 121580904, 112659416, + 99996592, 85785904, 71765432, 53219352, 38595240, 27661430, + 19704998, 13993836, 7886311, 4437830, 2496115, 1403764, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1219857, 2169099, 3856430, 6853125, 12160503, + 17123444, 24037508, 33538878, 46247084, 62363436, 74547088, + 86896032, 97899912, 105652584, 108465784, 105652592, 97899904, + 86896032, 74547096, 62363440, 46247084, 33538876, 24037506, + 17123446, 12160503, 6853125, 3856430, 2169099, 1219857, + 7}, + {1, 212938, 378637, 673176, 1196278, 2122731, 2989060, + 4195976, 5854530, 8072868, 10886130, 13012902, 15168527, 17089358, + 18442662, 18933732, 18442662, 17089358, 15168528, 13012903, 10886130, + 8072867, 5854530, 4195975, 2989060, 2122731, 1196278, 673176, + 378637, 212938, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 528371, 941010, 1677737, 2996520, 5365544, 7620743, + 10829829, 15375154, 21720308, 30256412, 37121464, 44492716, 52140904, + 58486168, 60914048, 58486172, 52140900, 44492720, 37121464, 30256412, + 21720308, 15375154, 10829827, 7620744, 5365544, 2996520, 1677737, + 941010, 528371, 3}, + {5, 817738, 1456128, 2595392, 4633066, 8288027, 11760734, + 16690856, 23650124, 33316570, 46226512, 56525852, 67496896, 77774760, + 85824632, 89194720, 85824640, 77774752, 67496904, 56525856, 46226512, + 33316570, 23650120, 16690854, 11760735, 8288027, 4633066, 2595392, + 1456128, 817738, 5}, + {7, 1208101, 2150365, 3830012, 6828082, 12185838, + 17252538, 24405052, 34418948, 48164280, 66215072, 80356216, + 95158664, 108775560, 118626184, 122255560, 118626184, 108775544, + 95158664, 80356216, 66215080, 48164276, 34418944, 24405050, + 17252540, 12185838, 6828083, 3830012, 2150365, 1208101, + 7}, + {8, 1404877, 2499634, 4448971, 7921597, 14105523, + 19927540, 28103010, 39463168, 54891176, 74856880, 90260672, + 106158016, 120574816, 130879072, 134648960, 130879072, 120574816, + 106158024, 90260672, 74856888, 54891176, 39463164, 28103008, + 19927542, 14105523, 7921598, 4448971, 2499634, 1404876, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1218314, 2164227, 3841070, 6804841, 12009704, 16826680, + 23458746, 32427858, 44173136, 58677072, 69367448, 79974728, 89242016, + 95670824, 97983664, 95670824, 89242016, 79974736, 69367448, 58677072, + 44173140, 32427856, 23458742, 16826682, 12009704, 6804841, 3841070, + 2164227, 1218314, 7}, + {1, 212485, 377211, 668688, 1182212, 2079037, 2903492, + 4030197, 5539070, 7490515, 9864627, 11591052, 13285722, 14752220, + 15762207, 16124145, 15762208, 14752220, 13285722, 11591053, 9864628, + 7490515, 5539070, 4030197, 2903492, 2079037, 1182212, 668688, + 377210, 212485, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 529280, 943904, 1686997, 3026404, 5463419, + 7822298, 11249275, 16258557, 23600720, 36288716, 49305868, + 66713524, 87729680, 107320208, 115788648, 107320216, 87729672, + 66713540, 49305872, 36288720, 23600720, 16258558, 11249274, + 7822299, 5463419, 3026404, 1686997, 943904, 529280, + 3}, + {5, 819001, 1460144, 2608223, 4674384, 8422779, + 12037082, 17262416, 24842774, 35819472, 52848540, 70312664, + 92562776, 117871664, 140063104, 149267152, 140063136, 117871648, + 92562792, 70312664, 52848544, 35819468, 24842772, 17262414, + 12037082, 8422779, 4674385, 2608223, 1460144, 819001, + 5}, + {7, 1209431, 2154588, 3843465, 6871159, 12324878, + 17534810, 24980280, 35593252, 50549888, 70956104, 87630984, + 108587520, 130892864, 148578016, 155457280, 148578016, 130892848, + 108587528, 87630992, 70956112, 50549884, 35593252, 24980278, + 17534812, 12324878, 6871160, 3843465, 2154588, 1209431, + 7}, + {8, 1405821, 2502628, 4458482, 7951885, 14202332, + 20122228, 28494402, 40246696, 56439064, 77816136, 94657800, + 112381552, 128775696, 140691712, 145094384, 140691728, 128775688, + 112381568, 94657808, 77816144, 56439060, 40246696, 28494400, + 20122230, 14202331, 7951885, 4458482, 2502629, 1405821, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1217010, 2160122, 3828190, 6764697, 11886164, 16586827, + 22999516, 31567738, 42617632, 56016164, 65730784, 75244880, 83461560, + 89112016, 91135304, 89112024, 83461552, 75244888, 65730788, 56016164, + 42617628, 31567738, 22999514, 16586829, 11886164, 6764698, 3828190, + 2160122, 1217010, 7}, + {1, 212104, 376014, 664952, 1170669, 2044035, 2836433, + 3904056, 5308151, 7084523, 9192281, 10692476, 12141331, 13377854, + 14220870, 14521357, 14220870, 13377854, 12141331, 10692476, 9192281, + 7084523, 5308151, 3904056, 2836433, 2044035, 1170669, 664952, + 376014, 212104, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 529890, 945853, 1693270, 3046878, 5531883, + 7966241, 11558316, 16941404, 26405616, 44726228, 66299660, + 102135296, 161287136, 242754912, 290875520, 242754976, 161287104, + 102135328, 66299668, 44726228, 26405616, 16941404, 11558314, + 7966241, 5531883, 3046878, 1693270, 945853, 529890, + 3}, + {5, 819848, 1462845, 2616904, 4702616, 8516569, + 12232970, 17678754, 25748164, 38567944, 62864780, 89227176, + 128392144, 182850000, 242436080, 271403040, 242436160, 182849968, + 128392176, 89227168, 62864788, 38567940, 25748164, 17678752, + 12232972, 8516569, 4702617, 2616904, 1462845, 819848, + 5}, + {7, 1210322, 2157425, 3852534, 6900401, 12420479, + 17731328, 25388104, 36448364, 52356736, 75502992, 99354648, + 128997304, 161739680, 189630656, 200981856, 189630656, 161739664, + 128997328, 99354648, 75503000, 52356740, 36448368, 25388100, + 17731330, 12420478, 6900402, 3852534, 2157425, 1210322, + 7}, + {8, 1406453, 2504636, 4464871, 7972318, 14268137, + 20255542, 28765222, 40797016, 57549412, 80000928, 97981248, + 117206704, 135388800, 151411120, 157516432, 151411136, 135388784, + 117206704, 97981248, 80000928, 57549412, 40797012, 28765220, + 20255542, 14268138, 7972319, 4464871, 2504636, 1406453, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1216142, 2157392, 3819657, 6738267, 11805711, 16432165, + 22707286, 31029754, 41665420, 54427540, 63597164, 72515376, 80171616, + 85413624, 87286256, 85413624, 80171608, 72515384, 63597164, 54427544, + 41665420, 31029756, 22707284, 16432167, 11805712, 6738268, 3819657, + 2157392, 1216142, 7}, + {1, 211851, 375221, 662491, 1163142, 2021609, 2794131, + 3826087, 5169036, 6847367, 8812784, 10196808, 11523252, 12648227, + 13411804, 13683354, 13411805, 12648226, 11523253, 10196809, 8812784, + 6847366, 5169036, 3826086, 2794132, 2021609, 1163142, 662491, + 375221, 211851, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -858993460, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 530105, 946540, 1695490, 3054166, 5556542, + 8018704, 11673036, 17202416, 27742908, 48702648, 75428704, + 125542128, 228590144, 435938784, 620187584, 435939008, 228590112, + 125542176, 75428712, 48702652, 27742906, 17202416, 11673035, + 8018704, 5556542, 3054167, 1695490, 946540, 530105, + 3}, + {5, 820146, 1463798, 2619972, 4712652, 8550255, + 12304061, 17832260, 26090394, 40209740, 67346928, 98535008, + 148589136, 226742368, 326144352, 380823904, 326144512, 226742336, + 148589184, 98535016, 67346936, 40209736, 26090392, 17832256, + 12304062, 8550254, 4712652, 2619972, 1463798, 820145, + 5}, + {7, 1210636, 2158423, 3855734, 6910758, 12454582, + 17801918, 25536124, 36763592, 53038744, 78536976, 104675848, + 138113008, 176331952, 210006528, 224018288, 210006544, 176331920, + 138113024, 104675856, 78536984, 53038744, 36763592, 25536118, + 17801920, 12454581, 6910759, 3855734, 2158423, 1210636, + 7}, + {8, 1406676, 2505341, 4467122, 7979530, 14291465, + 20302986, 28862170, 40995684, 57955156, 80812936, 99234096, + 119054544, 140506896, 157841056, 164487296, 157841072, 140506896, + 119054552, 99234096, 80812936, 57955148, 40995680, 28862168, + 20302988, 14291464, 7979531, 4467122, 2505342, 1406676, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1215837, 2156436, 3816673, 6729059, 11777845, 16378872, + 22607278, 30847268, 41345884, 53900940, 62895796, 71625096, 79105408, + 84220136, 86046016, 84220136, 79105408, 71625096, 62895796, 53900940, + 41345884, 30847270, 22607276, 16378873, 11777844, 6729060, 3816673, + 2156436, 1215837, 7}, + {1, 211762, 374943, 661633, 1160533, 2013907, 2779720, + 3799796, 5122719, 6769570, 8690265, 10038436, 11327602, 12418982, + 13158826, 13421767, 13158826, 12418981, 11327602, 10038436, 8690264, + 6769570, 5122719, 3799796, 2779720, 2013907, 1160533, 661633, + 374943, 211762, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 529890, 945853, 1693270, 3046878, 5531883, + 7966241, 11558316, 16941404, 26405616, 44726228, 66299660, + 102135296, 161287136, 242754912, 290875520, 242754976, 161287104, + 102135328, 66299668, 44726228, 26405616, 16941404, 11558314, + 7966241, 5531883, 3046878, 1693270, 945853, 529890, + 3}, + {5, 819848, 1462845, 2616904, 4702616, 8516569, + 12232970, 17678754, 25748164, 38567944, 62864780, 89227176, + 128392144, 182850000, 242436080, 271403040, 242436160, 182849968, + 128392176, 89227168, 62864788, 38567940, 25748164, 17678752, + 12232972, 8516569, 4702617, 2616904, 1462845, 819848, + 5}, + {7, 1210322, 2157425, 3852534, 6900401, 12420479, + 17731328, 25388104, 36448364, 52356736, 75502992, 99354648, + 128997304, 161739680, 189630656, 200981856, 189630656, 161739664, + 128997328, 99354648, 75503000, 52356740, 36448368, 25388100, + 17731330, 12420478, 6900402, 3852534, 2157425, 1210322, + 7}, + {8, 1406453, 2504636, 4464871, 7972318, 14268137, + 20255542, 28765222, 40797016, 57549412, 80000928, 97981248, + 117206704, 135388800, 151411120, 157516432, 151411136, 135388784, + 117206704, 97981248, 80000928, 57549412, 40797012, 28765220, + 20255542, 14268138, 7972319, 4464871, 2504636, 1406453, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1216142, 2157392, 3819657, 6738267, 11805711, 16432165, + 22707286, 31029754, 41665420, 54427540, 63597164, 72515376, 80171616, + 85413624, 87286256, 85413624, 80171608, 72515384, 63597164, 54427544, + 41665420, 31029756, 22707284, 16432167, 11805712, 6738268, 3819657, + 2157392, 1216142, 7}, + {1, 211851, 375221, 662491, 1163142, 2021609, 2794131, + 3826087, 5169036, 6847367, 8812784, 10196808, 11523252, 12648227, + 13411804, 13683354, 13411805, 12648226, 11523253, 10196809, 8812784, + 6847366, 5169036, 3826086, 2794132, 2021609, 1163142, 662491, + 375221, 211851, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 529280, 943904, 1686997, 3026404, 5463419, + 7822298, 11249275, 16258558, 23600720, 36288720, 49305868, + 66713532, 87729688, 107320216, 115788672, 107320232, 87729680, + 66713548, 49305876, 36288720, 23600720, 16258558, 11249274, + 7822299, 5463419, 3026404, 1686997, 943904, 529280, + 3}, + {5, 819001, 1460144, 2608223, 4674384, 8422779, + 12037082, 17262416, 24842774, 35819472, 52848540, 70312672, + 92562784, 117871672, 140063120, 149267168, 140063152, 117871656, + 92562800, 70312664, 52848548, 35819468, 24842772, 17262414, + 12037084, 8422779, 4674385, 2608223, 1460144, 819001, + 5}, + {7, 1209431, 2154588, 3843465, 6871159, 12324878, + 17534810, 24980280, 35593252, 50549888, 70956104, 87630984, + 108587528, 130892872, 148578032, 155457296, 148578032, 130892856, + 108587536, 87630992, 70956112, 50549884, 35593252, 24980278, + 17534812, 12324878, 6871160, 3843465, 2154588, 1209431, + 7}, + {8, 1405821, 2502628, 4458482, 7951885, 14202332, + 20122228, 28494402, 40246696, 56439064, 77816144, 94657800, + 112381560, 128775712, 140691712, 145094384, 140691728, 128775696, + 112381568, 94657808, 77816144, 56439064, 40246696, 28494400, + 20122230, 14202331, 7951885, 4458482, 2502629, 1405821, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1217010, 2160122, 3828190, 6764697, 11886164, 16586827, + 22999514, 31567738, 42617632, 56016164, 65730788, 75244880, 83461560, + 89112016, 91135304, 89112024, 83461552, 75244880, 65730788, 56016160, + 42617628, 31567738, 22999514, 16586829, 11886164, 6764698, 3828190, + 2160122, 1217010, 7}, + {1, 212104, 376014, 664952, 1170669, 2044035, 2836433, + 3904056, 5308151, 7084523, 9192281, 10692476, 12141331, 13377854, + 14220870, 14521356, 14220870, 13377854, 12141332, 10692476, 9192281, + 7084522, 5308151, 3904056, 2836433, 2044035, 1170669, 664952, + 376014, 212104, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 528371, 941010, 1677737, 2996520, 5365544, 7620743, + 10829829, 15375155, 21720310, 30256414, 37121464, 44492724, 52140916, + 58486184, 60914064, 58486188, 52140912, 44492720, 37121464, 30256414, + 21720308, 15375156, 10829827, 7620744, 5365544, 2996520, 1677737, + 941010, 528371, 3}, + {5, 817738, 1456128, 2595392, 4633066, 8288027, 11760734, + 16690856, 23650122, 33316574, 46226512, 56525852, 67496904, 77774760, + 85824656, 89194744, 85824656, 77774760, 67496904, 56525852, 46226516, + 33316574, 23650120, 16690854, 11760735, 8288027, 4633067, 2595392, + 1456128, 817738, 5}, + {7, 1208101, 2150365, 3830012, 6828082, 12185838, + 17252538, 24405054, 34418948, 48164280, 66215076, 80356216, + 95158664, 108775560, 118626192, 122255568, 118626200, 108775552, + 95158672, 80356216, 66215080, 48164280, 34418948, 24405052, + 17252540, 12185838, 6828083, 3830012, 2150365, 1208101, + 7}, + {8, 1404877, 2499634, 4448971, 7921597, 14105523, + 19927540, 28103012, 39463168, 54891176, 74856888, 90260672, + 106158024, 120574824, 130879080, 134648944, 130879088, 120574824, + 106158032, 90260672, 74856888, 54891176, 39463168, 28103008, + 19927542, 14105523, 7921598, 4448971, 2499634, 1404876, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1218314, 2164227, 3841070, 6804840, 12009704, 16826680, + 23458746, 32427858, 44173136, 58677072, 69367448, 79974728, 89242016, + 95670816, 97983664, 95670824, 89242008, 79974736, 69367448, 58677076, + 44173140, 32427856, 23458742, 16826682, 12009704, 6804841, 3841070, + 2164227, 1218314, 7}, + {1, 212485, 377211, 668688, 1182212, 2079037, 2903492, + 4030197, 5539070, 7490515, 9864626, 11591052, 13285722, 14752218, + 15762206, 16124144, 15762206, 14752218, 13285723, 11591053, 9864626, + 7490515, 5539070, 4030197, 2903492, 2079037, 1182212, 668688, + 377210, 212485, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 527304, 937630, 1667008, 2962381, 5256587, 7401904, + 10390627, 14497757, 19991098, 26957670, 32224264, 37562304, 42318920, + 45670148, 46886200, 45670152, 42318920, 37562308, 32224264, 26957670, + 19991098, 14497757, 10390626, 7401904, 5256587, 2962381, 1667008, + 937630, 527304, 3}, + {5, 816257, 1451433, 2580496, 4585709, 8137095, 11458003, + 16084489, 22442248, 30945832, 41729952, 49882536, 58145720, 65508872, + 70696504, 72578928, 70696512, 65508868, 58145724, 49882536, 41729952, + 30945832, 22442248, 16084488, 11458004, 8137095, 4585709, 2580496, + 1451434, 816257, 5}, + {7, 1206538, 2145415, 3814322, 6778296, 12027725, + 16936476, 23775046, 33172672, 45742120, 61682500, 73733120, + 85947224, 96830952, 104498976, 107281456, 104498984, 96830952, + 85947232, 73733128, 61682504, 45742116, 33172670, 23775044, + 16936476, 12027724, 6778297, 3814322, 2145415, 1206538, + 7}, + {8, 1403765, 2496115, 4437830, 7886310, 13993836, + 19704996, 27661434, 38595240, 53219352, 71765424, 85785904, + 99996584, 112659424, 121580896, 124818216, 121580904, 112659416, + 99996592, 85785904, 71765432, 53219352, 38595240, 27661430, + 19704998, 13993836, 7886311, 4437830, 2496115, 1403764, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1219857, 2169099, 3856430, 6853125, 12160503, + 17123444, 24037508, 33538878, 46247084, 62363436, 74547088, + 86896032, 97899912, 105652584, 108465784, 105652592, 97899904, + 86896032, 74547096, 62363440, 46247084, 33538876, 24037506, + 17123446, 12160503, 6853125, 3856430, 2169099, 1219857, + 7}, + {1, 212938, 378637, 673176, 1196278, 2122731, 2989060, + 4195976, 5854530, 8072868, 10886130, 13012902, 15168527, 17089358, + 18442662, 18933732, 18442662, 17089358, 15168528, 13012903, 10886130, + 8072867, 5854530, 4195975, 2989060, 2122731, 1196278, 673176, + 378637, 212938, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 526244, 934286, 1656482, 2929383, 5154009, 7200895, + 10000863, 13755239, 18618438, 24545892, 28863346, 33106846, 36783140, + 39317168, 40225668, 39317172, 36783136, 33106846, 28863346, 24545892, + 18618438, 13755238, 10000861, 7200896, 5154009, 2929384, 1656483, + 934287, 526244, 3}, + {5, 814783, 1446784, 2565855, 4539774, 7994119, 11177507, + 15539743, 21402348, 29018418, 38333064, 45138564, 51843736, 57665092, + 61684144, 63126296, 61684144, 57665088, 51843736, 45138564, 38333064, + 29018416, 21402346, 15539743, 11177508, 7994120, 4539775, 2565855, + 1446784, 814783, 5}, + {7, 1204981, 2140499, 3798824, 6729584, 11875611, 16637170, + 23191438, 32052656, 43652104, 57969124, 68517096, 78979352, 88116992, + 94454288, 96733928, 94454296, 88116984, 78979352, 68517096, 57969132, + 43652104, 32052654, 23191436, 16637170, 11875611, 6729584, 3798824, + 2140499, 1204981, 7}, + {8, 1402655, 2492611, 4426772, 7851491, 13884761, + 19489746, 27240036, 37782168, 51691532, 69027848, 81916832, + 94796824, 106122744, 114019024, 116867616, 114019032, 106122736, + 94796832, 81916832, 69027848, 51691532, 37782168, 27240034, + 19489748, 13884760, 7851492, 4426772, 2492611, 1402655, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1221406, 2174004, 3871976, 6902451, 12317130, + 17436482, 24661340, 34772524, 48643564, 66845112, 81092456, + 95994392, 109691792, 119593848, 123240712, 119593864, 109691784, + 95994392, 81092456, 66845116, 48643564, 34772520, 24661336, + 17436482, 12317130, 6902452, 3871976, 2174004, 1221406, + 7}, + {1, 213393, 380079, 677757, 1210858, 2169302, 3082668, + 4384052, 6230858, 8816279, 12308984, 15131109, 18175568, 21641464, + 24357576, 25401724, 24357578, 21641462, 18175570, 15131110, 12308985, + 8816279, 6230857, 4384051, 3082668, 2169302, 1210858, 677757, + 380079, 213393, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 525351, 931480, 1647714, 2902257, 5071597, 7042735, + 9702682, 13207803, 17652582, 22940042, 26711398, 30359378, 33476790, + 35604104, 36362736, 35604104, 33476788, 30359380, 26711396, 22940042, + 17652582, 13207803, 9702681, 7042735, 5071597, 2902257, 1647714, + 931480, 525351, 3}, + {5, 813540, 1442877, 2553636, 4501896, 7878638, 10955188, + 15118865, 20625528, 27638920, 36022472, 42026544, 47851780, 52842400, + 56254208, 57472080, 56254208, 52842396, 47851784, 42026548, 36022476, + 27638918, 20625528, 15118864, 10955189, 7878638, 4501896, 2553636, + 1442877, 813540, 5}, + {7, 1203665, 2136357, 3785832, 6689100, 11751078, 16395488, + 22728960, 31187070, 42088120, 55296528, 64867172, 74235600, 82322976, + 87882752, 89873216, 87882752, 82322968, 74235600, 64867176, 55296532, + 42088120, 31187070, 22728958, 16395489, 11751078, 6689101, 3785832, + 2136357, 1203665, 7}, + {8, 1401717, 2489652, 4417463, 7822332, 13794261, + 19312684, 26897488, 37131704, 50494456, 66937128, 79016952, + 90971256, 101390632, 108605536, 111198640, 108605544, 101390624, + 90971264, 79016952, 66937132, 50494456, 37131704, 26897486, + 19312686, 13794262, 7822333, 4417463, 2489652, 1401717, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1222724, 2178188, 3885304, 6945113, 12454759, + 17715756, 25230046, 35932312, 50996136, 71510480, 88238112, + 108673688, 130724608, 148143040, 154903072, 148143056, 130724600, + 108673704, 88238112, 71510496, 50996136, 35932312, 25230042, + 17715758, 12454758, 6945114, 3885304, 2178189, 1222724, + 7}, + {1, 213781, 381315, 681714, 1223645, 2211279, 3169313, + 4564991, 6613954, 9638446, 15182688, 20899232, 28782230, 38682300, + 48311484, 52599940, 48311496, 38682296, 28782232, 20899232, 15182688, + 9638446, 6613954, 4564991, 3169313, 2211279, 1223645, 681714, + 381315, 213781, 1}, + }, + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 524756, 929618, 1641931, 2884546, 5018684, 6942684, + 9517694, 12876462, 17085148, 22027530, 25515680, 28863994, 31707368, + 33639036, 34326304, 33639036, 31707366, 28863994, 25515680, 22027532, + 17085148, 12876462, 9517694, 6942685, 5018684, 2884546, 1641932, + 929618, 524756, 3}, + {5, 812713, 1440285, 2545568, 4477108, 7804208, 10813826, + 14855985, 20151268, 26819762, 34692788, 40273396, 45646932, 50221664, + 53335084, 54443824, 53335084, 50221660, 45646932, 40273400, 34692788, + 26819762, 20151268, 14855983, 10813826, 7804208, 4477108, 2545568, + 1440285, 812713, 5}, + {7, 1202789, 2133603, 3777225, 6662453, 11670018, 16239749, + 22434930, 30646316, 41132172, 53703904, 62730216, 71504264, 79033256, + 84186408, 86026976, 84186408, 79033248, 71504272, 62730216, 53703904, + 41132176, 30646314, 22434930, 16239752, 11670018, 6662454, 3777225, + 2133603, 1202789, 7}, + {8, 1401091, 2487681, 4411274, 7803027, 13734770, + 19197032, 26675680, 36715348, 49739444, 65641580, 77242592, + 88658984, 98560160, 105390504, 107840400, 105390512, 98560152, + 88658992, 77242584, 65641576, 49739444, 36715348, 26675674, + 19197034, 13734769, 7803028, 4411274, 2487680, 1401091, + 8}, + {8, 1509476, 2684086, 4772024, 8480193, 15047650, + 21188892, 29744494, 41501680, 57227068, 77169768, 92246064, + 107526888, 121143312, 130736624, 134217728, 130736624, 121143304, + 107526896, 92246064, 77169768, 57227064, 41501676, 29744492, + 21188894, 15047650, 8480194, 4772024, 2684086, 1509476, + 8}, + {7, 1223607, 2180998, 3894286, 6974063, 12549334, + 17910016, 25632730, 36775224, 52772652, 75633064, 99236928, + 128381352, 160330848, 187347776, 198291392, 187347792, 160330832, + 128381360, 99236928, 75633072, 52772652, 36775220, 25632728, + 17910018, 12549334, 6974064, 3894286, 2180998, 1223607, + 7}, + {1, 214041, 382148, 684396, 1232418, 2240724, + 3231452, 4699171, 6913169, 11028142, 19133980, 29199468, + 47298756, 81631544, 140893488, 184843632, 140893568, 81631528, + 47298760, 29199470, 19133982, 11028142, 6913169, 4699170, + 3231452, 2240724, 1232418, 684397, 382148, 214041, + 1}, + }, +}; + +const WORD32 ixheaacd_weight_Q28[16][8][31] = { + { + {134217744, 134970352, 135553120, 136582896, 138392880, 141541712, + 144424112, 148346336, 153572976, 160297488, 168439744, 174342928, + 180128864, 185132320, 188577760, 189812528, 188577760, 185132320, + 180128880, 174342928, 168439744, 160297488, 153572976, 148346336, + 144424112, 141541712, 138392880, 136582896, 135553136, 134970352, + 134217744}, + {134217728, 134923056, 135469392, 136435104, 138133568, 141091536, + 143802496, 147496192, 152426160, 158780944, 166491504, 172091408, + 177587152, 182344784, 185623536, 186799072, 185623552, 182344800, + 177587152, 172091392, 166491520, 158780944, 152426160, 147496192, + 143802480, 141091536, 138133568, 136435104, 135469392, 134923056, + 134217744}, + {134217728, 134851104, 135341920, 136210016, 137738240, 140404048, + 142851840, 146193664, 150665168, 156446176, 163483824, 168609296, + 173650000, 178021440, 181037920, 182120160, 181037920, 178021424, + 173650000, 168609296, 163483824, 156446176, 150665168, 146193680, + 142851840, 140404048, 137738240, 136210000, 135341920, 134851104, + 134217744}, + {134217728, 134670496, 135021776, 135643952, 136741952, 138665264, + 140439920, 142875520, 146156352, 150432704, 155687056, 159544432, + 163361216, 166688640, 168993616, 169822288, 168993632, 166688656, + 163361216, 159544432, 155687056, 150432704, 146156352, 142875520, + 140439920, 138665264, 136741952, 135643952, 135021776, 134670496, + 134217744}, + {134217728, 134494912, 134710224, 135092080, 135767616, 136955856, + 138057744, 139578304, 141641264, 144354416, 147723552, 150220400, + 152709488, 154893744, 156414336, 156962448, 156414336, 154893744, + 152709472, 150220400, 147723552, 144354416, 141641264, 139578320, + 138057728, 136955856, 135767600, 135092080, 134710224, 134494912, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 133772440, 133424920, 132804936, 131696632, 129710520, + 127825384, 125151792, 121381688, 116147984, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 116148000, 121381688, 125151792, + 127825384, 129710520, 131696632, 132804936, 133424920, 133772456, + 134217728}, + {134217728, 133468448, 132882456, 131834416, 129952248, 126550128, + 123283864, 118583656, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 118583656, + 123283864, 126550128, 129952248, 131834416, 132882456, 133468448, + 134217728}, + }, + { + {134217728, 134913216, 135451936, 136404304, 138079504, 140997600, + 143672688, 147318512, 152186224, 158463280, 166082896, 171618768, + 177053216, 181758880, 185002352, 186165328, 185002352, 181758880, + 177053216, 171618768, 166082896, 158463296, 152186224, 147318512, + 143672688, 140997600, 138079504, 136404304, 135451936, 134913216, + 134217744}, + {134217728, 134869504, 135374512, 136267584, 137839408, 140580112, + 143095472, 146527744, 151117280, 157046336, 164257936, 169506256, + 174664912, 179136560, 182221168, 183327616, 182221168, 179136560, + 174664912, 169506256, 164257936, 157046336, 151117280, 146527744, + 143095472, 140580112, 137839408, 136267584, 135374512, 134869504, + 134217744}, + {134217728, 134802992, 135256672, 136059376, 137473424, 139942768, + 142213056, 145316768, 149476832, 154866368, 161442736, 166241760, + 170968496, 175072880, 177907744, 178925312, 177907744, 175072880, + 170968496, 166241760, 161442736, 154866368, 149476832, 145316768, + 142213056, 139942768, 137473424, 136059376, 135256672, 134802992, + 134217744}, + {134217728, 134636080, 134960736, 135535920, 136551440, 138331744, + 139976000, 142235024, 145282080, 149260352, 154157968, 157759584, + 161328032, 164442560, 166601920, 167378576, 166601920, 164442544, + 161328032, 157759584, 154157968, 149260368, 145282080, 142235024, + 139976016, 138331728, 136551456, 135535920, 134960736, 134636096, + 134217744}, + {134217728, 134473824, 134672800, 135025728, 135650240, 136749360, + 137769200, 139177520, 141089920, 143607984, 146739200, 149062688, + 151381312, 153417872, 154836624, 155348256, 154836640, 153417872, + 151381328, 149062688, 146739200, 143607984, 141089920, 139177520, + 137769200, 136749360, 135650256, 135025712, 134672784, 134473824, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 133806400, 133485440, 132913000, 131890240, 130059096, + 128323168, 125864856, 122406120, 117621128, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 117621128, 122406120, 125864856, + 128323168, 130059096, 131890240, 132913000, 133485440, 133806400, + 134217728}, + {134217728, 133525632, 132984568, 132017344, 130281848, 127150040, + 124150024, 119845456, 113664464, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 113664464, 119845456, + 124150032, 127150040, 130281848, 132017344, 132984568, 133525632, + 134217728}, + }, + { + {134217728, 134750352, 135163360, 135894416, 137183168, 139436416, + 141510976, 144351440, 148166016, 153119584, 159180064, 163612736, + 167986224, 171789568, 174419392, 175363920, 174419392, 171789568, + 167986224, 163612736, 159180064, 153119584, 148166016, 144351440, + 141510976, 139436432, 137183168, 135894416, 135163360, 134750352, + 134217744}, + {134217728, 134716864, 135103984, 135789392, 136998240, 139113424, + 141062640, 143734096, 147326256, 151998160, 157724080, 161918432, + 166061616, 169668304, 172163984, 173060688, 172163984, 169668288, + 166061616, 161918432, 157724080, 151998160, 147326256, 143734096, + 141062640, 139113424, 136998240, 135789392, 135103984, 134716864, + 134217744}, + {134217728, 134665904, 135013632, 135629504, 136716496, 138620704, + 140377984, 142790048, 146039760, 150276480, 155483472, 159306944, + 163090832, 166390096, 168675808, 169497600, 168675808, 166390096, + 163090848, 159306944, 155483488, 150276480, 146039760, 142790048, + 140377968, 138620720, 136716496, 135629504, 135013616, 134665904, + 134217744}, + {134217728, 134538048, 134786784, 135227776, 136007472, 137377520, + 138646400, 140395008, 142763040, 145870208, 149717968, 152562416, + 155392320, 157871248, 159594640, 160215424, 159594640, 157871248, + 155392320, 152562416, 149717968, 145870208, 142763040, 140395008, + 138646400, 137377520, 136007472, 135227776, 134786784, 134538048, + 134217728}, + {134217728, 134413792, 134566144, 134836576, 135315504, 136159584, + 136944176, 138029792, 139507872, 141460704, 143899120, 145715424, + 147533584, 149135008, 150253024, 150656672, 150253040, 149135008, + 147533584, 145715424, 143899120, 141460688, 139507872, 138029792, + 136944176, 136159584, 135315504, 134836576, 134566160, 134413792, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 133903024, 133657608, 133220288, 132440008, 131046696, + 129730264, 127873712, 125277552, 121718592, 117049664, 113392512, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 113392512, 117049680, 121718592, 125277552, 127873712, + 129730280, 131046696, 132440024, 133220288, 133657624, 133903024, + 134217728}, + {134217728, 133688336, 133274944, 132536912, 131215936, 128843168, + 126584160, 123368104, 118806640, 112416656, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 112416656, 118806632, 123368104, + 126584160, 128843168, 131215936, 132536912, 133274944, 133688336, + 134217728}, + }, + { + {134217728, 134506240, 134730320, 135127728, 135830656, 137066736, + 138212592, 139793296, 141936768, 144754096, 148250000, 150839072, + 153418688, 155681312, 157255888, 157823344, 157255888, 155681312, + 153418688, 150839072, 148249984, 144754096, 141936768, 139793296, + 138212592, 137066736, 135830656, 135127728, 134730320, 134506240, + 134217728}, + {134217728, 134488080, 134698096, 135070576, 135729600, 136888992, + 137964320, 139448608, 141462896, 144113040, 147405392, 149846352, + 152280496, 154417184, 155904992, 156441360, 155904992, 154417184, + 152280496, 149846352, 147405392, 144113040, 141462896, 139448592, + 137964336, 136888992, 135729600, 135070576, 134698096, 134488080, + 134217728}, + {134217728, 134460464, 134649040, 134983616, 135575776, 136618224, + 137585872, 138922720, 140739104, 143132528, 146111440, 148323744, + 150532864, 152474416, 153827600, 154315696, 153827600, 152474432, + 150532880, 148323744, 146111440, 143132528, 140739104, 138922720, + 137585872, 136618224, 135575760, 134983616, 134649040, 134460464, + 134217728}, + {134217728, 134391168, 134526000, 134765312, 135189280, 135936912, + 136632336, 137595280, 138907696, 140643920, 142815424, 144435360, + 146058944, 147490640, 148491024, 148852368, 148491024, 147490640, + 146058944, 144435360, 142815424, 140643920, 138907696, 137595280, + 136632320, 135936912, 135189264, 134765312, 134526000, 134391168, + 134217728}, + {134217728, 134323872, 134406416, 134552992, 134812944, 135272112, + 135700080, 136294032, 137106080, 138184736, 139540672, 140557056, + 141579776, 142484928, 143119200, 143348672, 143119200, 142484928, + 141579776, 140557056, 139540672, 138184736, 137106080, 136294032, + 135700080, 135272112, 134812944, 134552992, 134406416, 134323872, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134047496, 133914896, 133678832, 133258584, 132511008, + 131808096, 130822576, 129456008, 127605336, 125219016, 123384368, + 121496560, 119789320, 118571736, 118126816, 118571736, 119789320, + 121496560, 123384368, 125219016, 127605336, 129456008, 130822576, + 131808096, 132511008, 133258584, 133678848, 133914896, 134047496, + 134217728}, + {134217728, 133931488, 133708328, 133310696, 132601600, 131336352, + 130142072, 128459768, 126111336, 122900144, 118702864, 115428560, + 112012208, 111848104, 111848104, 111848104, 111848104, 111848104, + 112012208, 115428560, 118702864, 122900128, 126111336, 128459768, + 130142072, 131336352, 132601616, 133310696, 133708328, 133931488, + 134217728}, + }, + { + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217744, 134217728, 134217728, 134217744, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + }, + { + {134217728, 133928592, 133703168, 133301512, 132585192, 131306928, + 130100248, 128400288, 126026792, 122780504, 118535808, 115223152, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 115223152, 118535792, 122780504, 126026792, 128400288, + 130100248, 131306928, 132585192, 133301512, 133703168, 133928592, + 134217728}, + {134217728, 133946816, 133735640, 133359432, 132688632, 131492208, + 130363488, 128774544, 126558464, 123532296, 119584472, 116511248, + 113311296, 111848104, 111848104, 111848104, 111848104, 111848104, + 113311288, 116511248, 119584472, 123532296, 126558464, 128774544, + 130363488, 131492208, 132688632, 133359432, 133735640, 133946816, + 134217728}, + {134217728, 133974552, 133785016, 133447456, 132845800, 131773512, + 130762848, 129341696, 127362872, 124667064, 121162064, 118443520, + 115622880, 113050208, 111848104, 111848104, 111848104, 113050208, + 115622880, 118443520, 121162064, 124667064, 127362856, 129341696, + 130762848, 131773512, 132845800, 133447456, 133785016, 133974552, + 134217728}, + {134217728, 134044048, 133908760, 133667912, 133239096, 132476240, + 131758880, 130752952, 129357832, 127467976, 125030208, 123155288, + 121225344, 119479336, 118233720, 117778472, 118233720, 119479336, + 121225328, 123155288, 125030224, 127467976, 129357832, 130752960, + 131758880, 132476240, 133239096, 133667912, 133908760, 134044048, + 134217728}, + {134217728, 134111512, 134028776, 133881624, 133619856, 133154992, + 132718832, 132108784, 131265840, 130129840, 128674776, 127563760, + 126427688, 125406704, 124682360, 124418480, 124682360, 125406704, + 126427688, 127563760, 128674776, 130129840, 131265840, 132108784, + 132718832, 133154992, 133619856, 133881608, 134028776, 134111512, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134387728, 134519888, 134754464, 135170064, 135903024, + 136584848, 137529104, 138816208, 140519296, 142649904, 144239712, + 145833392, 147238976, 148221248, 148576080, 148221248, 147238976, + 145833392, 144239712, 142649904, 140519312, 138816208, 137529088, + 136584848, 135903024, 135170064, 134754464, 134519888, 134387728, + 134217728}, + {134217728, 134503360, 134725216, 135118656, 135814608, 137038528, + 138173216, 139738624, 141861648, 144652528, 148116256, 150681920, + 153238576, 155481344, 157042224, 157604800, 157042224, 155481344, + 153238576, 150681920, 148116256, 144652528, 141861648, 139738624, + 138173216, 137038528, 135814608, 135118656, 134725200, 134503360, + 134217728}, + }, + { + {134217728, 133682984, 133265384, 132519816, 131185264, 128787744, + 126504696, 123253640, 118640752, 112174832, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 112174832, 118640752, 123253640, + 126504696, 128787744, 131185264, 132519816, 133265384, 133682984, + 134217728}, + {134217728, 133716728, 133325584, 132627440, 131378384, 129136568, + 127004448, 123973008, 119681960, 113689744, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 113689744, 119681960, 123973008, + 127004448, 129136568, 131378376, 132627440, 133325584, 133716744, + 134217728}, + {134217728, 133768056, 133417096, 132790928, 131671560, 129665320, + 127760792, 125059176, 121248440, 115955928, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 115955928, 121248440, 125059176, + 127760792, 129665320, 131671560, 132790928, 133417096, 133768056, + 134217728}, + {134217728, 133896640, 133646248, 133200016, 132403792, 130981736, + 129637848, 127742080, 125090024, 121452368, 116676152, 112931424, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 112931424, 116676152, 121452368, 125090024, 127742080, + 129637848, 130981736, 132403792, 133200016, 133646248, 133896640, + 134217728}, + {134217728, 134021376, 133868400, 133596016, 133110896, 132247376, + 131434736, 130294184, 128710328, 126560936, 123781432, 121638024, + 119426296, 117420384, 115986304, 115461520, 115986304, 117420384, + 119426296, 121638024, 123781432, 126560936, 128710328, 130294184, + 131434736, 132247360, 133110896, 133596016, 133868400, 134021376, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134531696, 134775520, 135207824, 135972192, 137315552, + 138559920, 140275120, 142598512, 145648128, 149426144, 152220016, + 155000416, 157436608, 159130592, 159740864, 159130592, 157436608, + 155000416, 152220016, 149426144, 145648128, 142598512, 140275120, + 138559920, 137315536, 135972192, 135207824, 134775504, 134531696, + 134217728}, + {134217728, 134745024, 135153936, 135877760, 137153824, 139385200, + 141439904, 144253616, 148033040, 152942128, 158949856, 163344976, + 167682224, 171454608, 174063344, 175000352, 174063344, 171454608, + 167682208, 163344976, 158949856, 152942128, 148033040, 144253632, + 141439904, 139385200, 137153824, 135877760, 135153936, 134745040, + 134217744}, + }, + { + {134217728, 133518624, 132972056, 131994936, 130241488, 127076656, + 124044168, 119691480, 113437856, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 113437856, 119691480, + 124044168, 127076656, 130241488, 131994936, 132972056, 133518624, + 134217728}, + {134217728, 133562760, 133050888, 132136072, 130495576, 127538336, + 124709592, 120658264, 114858008, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 114858008, 120658264, + 124709592, 127538336, 130495560, 132136072, 133050888, 133562760, + 134217728}, + {134217728, 133629896, 133170680, 132350456, 130881064, 128237360, + 125714928, 122114032, 116984936, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 116984936, 122114032, + 125714928, 128237360, 130881064, 132350456, 133170680, 133629896, + 134217728}, + {134217728, 133798056, 133470584, 132886472, 131842704, 129973568, + 128201072, 125690088, 122155288, 117261000, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 117261000, 122155288, 125690088, + 128201072, 129973568, 131842704, 132886456, 133470584, 133798056, + 134217728}, + {134217728, 133961128, 133761128, 133404840, 132769744, 131637408, + 130569696, 129067480, 126974144, 124119080, 120401016, 117512176, + 114509792, 111848104, 111848104, 111848104, 111848104, 111848104, + 114509792, 117512160, 120401008, 124119080, 126974144, 129067480, + 130569696, 131637424, 132769744, 133404840, 133761128, 133961128, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134627808, 134946048, 135509888, 136505536, 138251328, + 139864096, 142080384, 145070800, 148976736, 153787568, 157326848, + 160834672, 163897216, 166020960, 166784896, 166020960, 163897200, + 160834688, 157326848, 153787568, 148976736, 145070800, 142080384, + 139864096, 138251328, 136505536, 135509888, 134946048, 134627808, + 134217744}, + {134217728, 134906272, 135439648, 136382608, 138041424, 140931408, + 143581232, 147193280, 152017056, 158239216, 165794560, 171285200, + 176676288, 181345168, 184563696, 185717792, 184563696, 181345168, + 176676272, 171285200, 165794560, 158239216, 152017056, 147193280, + 143581216, 140931408, 138041424, 136382608, 135439648, 134906272, + 134217744}, + }, + { + {134217728, 133460856, 132868912, 131810120, 129908448, 126470312, + 123168472, 118415200, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 0, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 118415200, + 123168472, 126470312, 129908448, 131810120, 132868912, 133460856, + 134217728}, + {134217728, 133508664, 132954296, 131963096, 130184144, 126972336, + 123893664, 119472480, 113115264, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 113115272, 119472480, + 123893664, 126972336, 130184144, 131963096, 132954280, 133508664, + 134217728}, + {134217728, 133581352, 133084040, 132195432, 130602352, 127732136, + 124988584, 121062824, 115450448, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 115450448, 121062824, + 124988584, 127732136, 130602352, 132195432, 133084040, 133581352, + 134217728}, + {134217728, 133763416, 133408824, 132776176, 131645104, 129617688, + 127692704, 124961536, 121107872, 115753192, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 115753192, 121107872, 124961520, + 127692704, 129617688, 131645120, 132776176, 133408840, 133763416, + 134217728}, + {134217728, 133939968, 133723424, 133337648, 132649736, 131422568, + 130264576, 128633952, 126358808, 123250144, 119191232, 116028568, + 112732488, 111848104, 111848104, 111848104, 111848104, 111848104, + 112732488, 116028552, 119191232, 123250144, 126358808, 128633952, + 130264576, 131422568, 132649736, 133337648, 133723424, 133939968, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134661536, 135005888, 135615808, 136692320, 138578416, + 140319184, 142708880, 145929024, 150128080, 155290032, 159081232, + 162833824, 166106272, 168373648, 169188880, 168373648, 166106272, + 162833824, 159081248, 155290032, 150128080, 145929040, 142708880, + 140319168, 138578416, 136692320, 135615808, 135005872, 134661536, + 134217744}, + {134217744, 134962848, 135539840, 136559456, 138351760, 141470368, + 144325616, 148211728, 153391520, 160057728, 168132016, 173987488, + 179727840, 184692672, 188111936, 189337408, 188111936, 184692672, + 179727824, 173987488, 168132016, 160057728, 153391504, 148211728, + 144325616, 141470352, 138351744, 136559456, 135539840, 134962848, + 134217744}, + }, + { + {134217728, 133518624, 132972056, 131994936, 130241488, 127076656, + 124044168, 119691480, 113437856, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 113437856, 119691480, + 124044168, 127076656, 130241488, 131994936, 132972056, 133518624, + 134217728}, + {134217728, 133562760, 133050888, 132136072, 130495576, 127538336, + 124709592, 120658264, 114858008, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 114858008, 120658264, + 124709592, 127538336, 130495560, 132136072, 133050888, 133562760, + 134217728}, + {134217728, 133629896, 133170680, 132350456, 130881064, 128237360, + 125714928, 122114032, 116984936, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 116984936, 122114032, + 125714928, 128237360, 130881064, 132350456, 133170680, 133629896, + 134217728}, + {134217728, 133798056, 133470584, 132886472, 131842704, 129973568, + 128201072, 125690088, 122155288, 117261000, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 117261000, 122155288, 125690088, + 128201072, 129973568, 131842704, 132886456, 133470584, 133798056, + 134217728}, + {134217728, 133961128, 133761128, 133404840, 132769744, 131637408, + 130569696, 129067480, 126974144, 124119080, 120401016, 117512176, + 114509792, 111848104, 111848104, 111848104, 111848104, 111848104, + 114509792, 117512160, 120401008, 124119080, 126974144, 129067480, + 130569696, 131637424, 132769744, 133404840, 133761128, 133961128, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134627808, 134946048, 135509888, 136505536, 138251328, + 139864096, 142080384, 145070800, 148976736, 153787568, 157326848, + 160834672, 163897216, 166020960, 166784896, 166020960, 163897200, + 160834688, 157326848, 153787568, 148976736, 145070800, 142080384, + 139864096, 138251328, 136505536, 135509888, 134946048, 134627808, + 134217744}, + {134217728, 134906272, 135439648, 136382608, 138041424, 140931408, + 143581232, 147193280, 152017056, 158239216, 165794560, 171285200, + 176676288, 181345168, 184563696, 185717792, 184563696, 181345168, + 176676272, 171285200, 165794560, 158239216, 152017056, 147193280, + 143581216, 140931408, 138041424, 136382608, 135439648, 134906272, + 134217744}, + }, + { + {134217728, 133682984, 133265384, 132519816, 131185264, 128787744, + 126504696, 123253640, 118640752, 112174824, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 112174824, 118640752, 123253640, + 126504696, 128787744, 131185264, 132519816, 133265384, 133682984, + 134217728}, + {134217728, 133716728, 133325584, 132627440, 131378384, 129136568, + 127004448, 123973008, 119681960, 113689736, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 113689744, 119681960, 123973008, + 127004448, 129136568, 131378376, 132627440, 133325584, 133716744, + 134217728}, + {134217728, 133768056, 133417096, 132790928, 131671560, 129665320, + 127760792, 125059176, 121248440, 115955928, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 115955928, 121248440, 125059176, + 127760792, 129665320, 131671560, 132790928, 133417096, 133768056, + 134217728}, + {134217728, 133896640, 133646248, 133200016, 132403792, 130981736, + 129637848, 127742080, 125090024, 121452368, 116676144, 112931424, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 112931424, 116676152, 121452360, 125090024, 127742080, + 129637848, 130981736, 132403792, 133200016, 133646248, 133896640, + 134217728}, + {134217728, 134021376, 133868400, 133596016, 133110896, 132247376, + 131434736, 130294184, 128710328, 126560928, 123781432, 121638024, + 119426296, 117420384, 115986304, 115461520, 115986304, 117420384, + 119426296, 121638024, 123781432, 126560928, 128710328, 130294184, + 131434736, 132247360, 133110896, 133596016, 133868400, 134021376, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134531696, 134775520, 135207824, 135972192, 137315552, + 138559920, 140275120, 142598512, 145648144, 149426144, 152220032, + 155000416, 157436608, 159130592, 159740864, 159130592, 157436608, + 155000416, 152220032, 149426144, 145648128, 142598512, 140275120, + 138559920, 137315536, 135972192, 135207824, 134775504, 134531696, + 134217728}, + {134217728, 134745024, 135153936, 135877760, 137153824, 139385200, + 141439904, 144253632, 148033040, 152942128, 158949856, 163344976, + 167682224, 171454624, 174063344, 175000352, 174063344, 171454624, + 167682224, 163344976, 158949856, 152942128, 148033040, 144253632, + 141439904, 139385200, 137153824, 135877760, 135153936, 134745040, + 134217744}, + }, + { + {134217728, 133928592, 133703168, 133301512, 132585192, 131306928, + 130100248, 128400288, 126026792, 122780488, 118535792, 115223136, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 115223136, 118535792, 122780488, 126026792, 128400288, + 130100248, 131306912, 132585176, 133301512, 133703168, 133928592, + 134217728}, + {134217728, 133946816, 133735640, 133359432, 132688632, 131492208, + 130363488, 128774544, 126558464, 123532296, 119584464, 116511232, + 113311288, 111848104, 111848104, 111848104, 111848104, 111848104, + 113311272, 116511232, 119584464, 123532296, 126558464, 128774544, + 130363488, 131492208, 132688632, 133359416, 133735640, 133946816, + 134217728}, + {134217728, 133974552, 133785016, 133447456, 132845800, 131773512, + 130762848, 129341696, 127362856, 124667064, 121162048, 118443504, + 115622880, 113050192, 111848104, 111848104, 111848104, 113050192, + 115622872, 118443504, 121162064, 124667064, 127362856, 129341696, + 130762848, 131773512, 132845800, 133447456, 133785016, 133974552, + 134217728}, + {134217728, 134044048, 133908744, 133667912, 133239096, 132476240, + 131758880, 130752952, 129357832, 127467976, 125030208, 123155288, + 121225328, 119479320, 118233720, 117778464, 118233720, 119479320, + 121225328, 123155288, 125030208, 127467976, 129357832, 130752952, + 131758880, 132476240, 133239096, 133667912, 133908760, 134044048, + 134217728}, + {134217728, 134111512, 134028776, 133881624, 133619856, 133154992, + 132718832, 132108784, 131265840, 130129840, 128674776, 127563760, + 126427688, 125406704, 124682360, 124418464, 124682360, 125406704, + 126427688, 127563760, 128674776, 130129840, 131265840, 132108784, + 132718832, 133154992, 133619856, 133881608, 134028776, 134111512, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134387728, 134519888, 134754464, 135170064, 135903024, + 136584848, 137529104, 138816208, 140519312, 142649904, 144239712, + 145833408, 147238976, 148221248, 148576080, 148221264, 147238976, + 145833408, 144239712, 142649920, 140519312, 138816208, 137529088, + 136584848, 135903024, 135170064, 134754464, 134519888, 134387744, + 134217728}, + {134217728, 134503360, 134725216, 135118656, 135814608, 137038528, + 138173216, 139738624, 141861664, 144652528, 148116256, 150681936, + 153238592, 155481344, 157042224, 157604816, 157042224, 155481344, + 153238592, 150681936, 148116256, 144652528, 141861648, 139738624, + 138173216, 137038544, 135814624, 135118656, 134725200, 134503360, + 134217728}, + }, + { + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + }, + { + {134217728, 134506240, 134730320, 135127728, 135830656, 137066736, + 138212592, 139793296, 141936768, 144754096, 148250000, 150839072, + 153418688, 155681312, 157255888, 157823360, 157255888, 155681312, + 153418688, 150839072, 148250000, 144754096, 141936768, 139793296, + 138212592, 137066736, 135830656, 135127728, 134730320, 134506240, + 134217728}, + {134217728, 134488080, 134698096, 135070576, 135729600, 136888992, + 137964336, 139448608, 141462896, 144113040, 147405392, 149846352, + 152280496, 154417184, 155904992, 156441360, 155904992, 154417184, + 152280496, 149846352, 147405392, 144113056, 141462896, 139448592, + 137964336, 136888992, 135729600, 135070592, 134698096, 134488080, + 134217728}, + {134217728, 134460464, 134649040, 134983616, 135575776, 136618224, + 137585888, 138922720, 140739120, 143132528, 146111456, 148323744, + 150532880, 152474432, 153827616, 154315712, 153827616, 152474432, + 150532880, 148323744, 146111456, 143132528, 140739104, 138922720, + 137585872, 136618224, 135575776, 134983616, 134649040, 134460464, + 134217728}, + {134217728, 134391168, 134526000, 134765312, 135189280, 135936912, + 136632336, 137595280, 138907696, 140643920, 142815424, 144435360, + 146058944, 147490640, 148491024, 148852384, 148491024, 147490640, + 146058944, 144435360, 142815424, 140643920, 138907696, 137595280, + 136632320, 135936912, 135189264, 134765312, 134526000, 134391168, + 134217728}, + {134217728, 134323872, 134406416, 134552992, 134812944, 135272112, + 135700080, 136294032, 137106080, 138184736, 139540672, 140557056, + 141579792, 142484928, 143119200, 143348672, 143119200, 142484928, + 141579792, 140557056, 139540672, 138184736, 137106080, 136294032, + 135700080, 135272112, 134812944, 134552992, 134406416, 134323872, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 134047496, 133914896, 133678832, 133258584, 132511008, + 131808096, 130822576, 129456008, 127605336, 125219000, 123384360, + 121496560, 119789320, 118571720, 118126808, 118571736, 119789320, + 121496560, 123384360, 125219000, 127605336, 129456008, 130822576, + 131808096, 132511008, 133258584, 133678848, 133914896, 134047496, + 134217728}, + {134217728, 133931488, 133708328, 133310696, 132601600, 131336352, + 130142072, 128459768, 126111336, 122900128, 118702864, 115428552, + 112012200, 111848104, 111848104, 111848104, 111848104, 111848104, + 112012200, 115428552, 118702864, 122900128, 126111336, 128459768, + 130142072, 131336352, 132601616, 133310696, 133708328, 133931488, + 134217728}, + }, + { + {134217728, 134750352, 135163360, 135894416, 137183168, 139436416, + 141510976, 144351440, 148166016, 153119584, 159180064, 163612720, + 167986224, 171789568, 174419376, 175363904, 174419392, 171789552, + 167986224, 163612736, 159180064, 153119584, 148166016, 144351440, + 141510976, 139436416, 137183168, 135894416, 135163360, 134750352, + 134217744}, + {134217728, 134716864, 135103984, 135789392, 136998240, 139113424, + 141062640, 143734096, 147326256, 151998160, 157724080, 161918432, + 166061616, 169668288, 172163984, 173060688, 172163968, 169668288, + 166061616, 161918432, 157724080, 151998160, 147326256, 143734096, + 141062640, 139113424, 136998240, 135789392, 135103984, 134716864, + 134217744}, + {134217728, 134665904, 135013632, 135629504, 136716496, 138620704, + 140377968, 142790048, 146039760, 150276480, 155483472, 159306928, + 163090832, 166390080, 168675792, 169497600, 168675792, 166390080, + 163090832, 159306944, 155483488, 150276480, 146039760, 142790048, + 140377968, 138620704, 136716496, 135629504, 135013616, 134665904, + 134217744}, + {134217728, 134538048, 134786784, 135227776, 136007472, 137377520, + 138646400, 140395008, 142763040, 145870208, 149717968, 152562416, + 155392320, 157871248, 159594640, 160215424, 159594624, 157871248, + 155392320, 152562416, 149717968, 145870208, 142763040, 140395008, + 138646400, 137377520, 136007472, 135227776, 134786768, 134538048, + 134217728}, + {134217728, 134413792, 134566144, 134836576, 135315504, 136159568, + 136944176, 138029792, 139507872, 141460704, 143899120, 145715424, + 147533568, 149135008, 150253024, 150656672, 150253024, 149135008, + 147533568, 145715424, 143899120, 141460688, 139507872, 138029792, + 136944176, 136159584, 135315504, 134836576, 134566160, 134413792, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 133903024, 133657608, 133220288, 132440008, 131046696, + 129730280, 127873712, 125277552, 121718608, 117049664, 113392528, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 113392528, 117049680, 121718608, 125277552, 127873712, + 129730280, 131046696, 132440024, 133220288, 133657624, 133903024, + 134217728}, + {134217728, 133688336, 133274944, 132536912, 131215936, 128843168, + 126584160, 123368104, 118806640, 112416656, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 112416656, 118806640, 123368104, + 126584160, 128843168, 131215952, 132536912, 133274944, 133688336, + 134217728}, + }, + { + {134217728, 134913216, 135451936, 136404304, 138079504, 140997600, + 143672688, 147318512, 152186224, 158463280, 166082896, 171618768, + 177053216, 181758880, 185002352, 186165344, 185002352, 181758896, + 177053216, 171618768, 166082896, 158463296, 152186224, 147318512, + 143672688, 140997600, 138079504, 136404304, 135451936, 134913216, + 134217744}, + {134217728, 134869504, 135374512, 136267584, 137839408, 140580112, + 143095472, 146527744, 151117280, 157046336, 164257936, 169506256, + 174664912, 179136576, 182221168, 183327616, 182221168, 179136560, + 174664928, 169506256, 164257936, 157046336, 151117296, 146527744, + 143095472, 140580112, 137839408, 136267584, 135374512, 134869504, + 134217744}, + {134217728, 134802992, 135256672, 136059376, 137473424, 139942768, + 142213056, 145316768, 149476832, 154866368, 161442736, 166241776, + 170968496, 175072880, 177907744, 178925312, 177907760, 175072880, + 170968496, 166241776, 161442736, 154866368, 149476832, 145316768, + 142213056, 139942768, 137473424, 136059376, 135256672, 134802992, + 134217744}, + {134217728, 134636080, 134960736, 135535920, 136551440, 138331744, + 139976000, 142235024, 145282080, 149260352, 154157968, 157759584, + 161328032, 164442560, 166601920, 167378576, 166601920, 164442544, + 161328032, 157759584, 154157968, 149260368, 145282080, 142235024, + 139976016, 138331728, 136551456, 135535920, 134960736, 134636096, + 134217744}, + {134217728, 134473824, 134672800, 135025728, 135650240, 136749360, + 137769200, 139177520, 141089920, 143607984, 146739200, 149062688, + 151381328, 153417872, 154836624, 155348256, 154836640, 153417872, + 151381328, 149062688, 146739200, 143607984, 141089920, 139177520, + 137769200, 136749360, 135650256, 135025712, 134672784, 134473824, + 134217728}, + {134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728, 134217728, 134217728, 134217728, 134217728, 134217728, + 134217728}, + {134217728, 133806400, 133485440, 132913000, 131890240, 130059096, + 128323168, 125864856, 122406120, 117621128, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 117621120, 122406120, 125864856, + 128323168, 130059096, 131890240, 132913000, 133485440, 133806400, + 134217728}, + {134217728, 133525632, 132984568, 132017344, 130281848, 127150040, + 124150024, 119845456, 113664464, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 111848104, 111848104, + 111848104, 111848104, 111848104, 111848104, 113664464, 119845456, + 124150024, 127150040, 130281848, 132017344, 132984568, 133525632, + 134217728}, + }, +}; + +const WORD32 ixheaacd_atan_table_Q28[16][8][31] = { + { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + { + {105414360, 104839440, 104395760, 103614856, 102251296, 99903616, + 97777528, 94910424, 91113928, 86209256, 80075696, 75298264, + 70016792, 64317196, 58324216, 52191708, 46086824, 40171656, + 34586568, 29438704, 24797036, 18844526, 14076835, 10372791, + 7563109, 5470589, 3149178, 1794887, 1017097, 574441, + 3}, + {105414360, 104839456, 104395808, 103614992, 102251712, 99904768, + 97779568, 94913880, 91119464, 86217496, 80086976, 75311480, + 70031656, 64333272, 58341012, 52208712, 46103544, 40187596, + 34601260, 29451742, 24808156, 18852650, 14082295, 10376209, + 7565131, 5471733, 3149591, 1795028, 1017143, 574456, + 3}, + {105414360, 104839480, 104395880, 103615208, 102252344, 99906552, + 97782736, 94919288, 91128192, 86230640, 80105168, 75332944, + 70055936, 64359672, 58368684, 52236768, 46131100, 40213788, + 34625280, 29472930, 24826096, 18865614, 14090922, 10381562, + 7568273, 5473501, 3150225, 1795244, 1017214, 574479, + 3}, + {105414360, 104839536, 104396064, 103615760, 102253976, 99911160, + 97791048, 94933704, 91151936, 86267232, 80157136, 75395312, + 70127632, 64438612, 58452120, 52321616, 46214224, 40292168, + 34696284, 29534604, 24877446, 18901780, 14114422, 10395857, + 7576530, 5478088, 3151847, 1795790, 1017394, 574537, + 3}, + {105414360, 104839592, 104396240, 103616296, 102255600, 99915856, + 97799664, 94949000, 91177904, 86308736, 80218568, 75471136, + 70217072, 64539228, 58560004, 52431916, 46321792, 40392248, + 34785076, 29609790, 24938336, 18942938, 14140199, 10411065, + 7585108, 5482768, 3153468, 1796330, 1017569, 574594, + 3}, + {105414360, 104839680, 104396520, 103617168, 102258248, 99923736, + 97814472, 94976184, 91226104, 86390216, 80347528, 75638144, + 70423488, 64780944, 58826448, 52707184, 46587916, 40633420, + 34990876, 29776224, 25066838, 19024148, 14188262, 10438183, + 7599892, 5490633, 3156118, 1797198, 1017849, 574683, + 3}, + {105414360, 104839824, 104396976, 103618608, 102262752, 99937728, + 97841960, 95029816, 91329816, 86588048, 80716144, 76183448, + 71203432, 65834132, 60122612, 54107316, 47891724, 41697008, + 35779764, 30327720, 25439258, 19223604, 14292623, 10492064, + 7627470, 5504663, 3160627, 1798637, 1018307, 574828, + 3}, + {105414360, 104839928, 104397288, 103619616, 102266008, 99948384, + 97863952, 95076024, 91429712, 86814424, 81270904, 77262808, + 73480384, 71228240, 75154792, 90330880, 64216388, 47491216, + 38190000, 31457082, 26014456, 19455916, 14394385, 10538885, + 7649673, 5515393, 3163899, 1799652, 1018625, 574928, + 3}, + }, + { + {210828704, 209763824, 208938560, 207478752, 204908032, 200419760, + 196290896, 190633616, 183000672, 172937648, 160110704, 149997200, + 138756608, 126624216, 113938336, 101099072, 88510592, 76526288, + 65413280, 55341428, 46391316, 35074004, 26116856, 19208962, + 13991278, 10114556, 5820107, 3316738, 1879389, 1061436, + 6}, + {210828704, 209763936, 208938896, 207479776, 204911072, 200428368, + 196306384, 190660432, 183044720, 173005232, 160205968, 150110720, + 138885968, 126765280, 114085952, 101247824, 88655264, 76662112, + 65536160, 55448352, 46480712, 35137556, 26158596, 19234612, + 14006231, 10122925, 5823092, 3317749, 1879722, 1061544, + 6}, + {210828704, 209764096, 208939392, 207481328, 204915728, 200441616, + 196330368, 190702240, 183113968, 173112496, 160358752, 150294096, + 139096288, 126995848, 114328120, 101492232, 88892824, 76884520, + 65736460, 55621620, 46624620, 35238800, 26224436, 19274734, + 14029455, 10135852, 5827674, 3319296, 1880230, 1061707, + 6}, + {210828704, 209764512, 208940688, 207485280, 204927584, 200475808, + 196392960, 190812912, 183300576, 173407904, 160790096, 150820544, + 139709584, 127677032, 115050024, 102223720, 89602656, 77544544, + 66324264, 56122904, 47034384, 35520108, 26403298, 19381644, + 14090386, 10169363, 5839388, 3323218, 1881511, 1062120, + 6}, + {210828704, 209764912, 208941952, 207489168, 204939376, 200510416, + 196457296, 190929072, 183501872, 173737520, 161290464, 151447920, + 140459456, 128528208, 115965984, 103158064, 90506880, 78375576, + 67050572, 56727860, 47516240, 35838300, 26598646, 19495050, + 14153544, 10203491, 5851081, 3327087, 1882766, 1062523, + 6}, + {210828704, 209765552, 208943952, 207495408, 204958528, 200567968, + 196566624, 191132320, 183868128, 174368352, 162309120, 152784192, + 142129632, 130500344, 118149712, 105414360, 92679000, 80328360, + 68699080, 58044528, 48519584, 36460364, 26960592, 19696396, + 14262089, 10260740, 5870181, 3333310, 1884767, 1063161, + 6}, + {210828704, 209766592, 208947200, 207505680, 204990800, 200668800, + 196765424, 191522096, 184625504, 175818192, 165011728, 156772288, + 147807440, 138128784, 127521456, 115591336, 102270680, 88260824, + 74642472, 62217964, 51336324, 37958764, 27737034, 20093352, + 14463533, 10362519, 5902623, 3343611, 1888032, 1064195, + 6}, + {210828704, 209767296, 208949456, 207512880, 205013952, 200744336, + 196920864, 191846656, 185318832, 177353312, 168608176, 163416640, + 160727504, 165029712, 189073968, 241456736, 178005808, 122049624, + 90479408, 70104040, 55475472, 39658732, 28482874, 20435210, + 14624799, 10440064, 5926123, 3350871, 1890298, 1064906, + 6}, + }, + { + {316243072, 314846656, 313757568, 311816384, 308352896, 302171040, + 296337664, 288127488, 276678912, 261007920, 240267568, 223492192, + 204621200, 184231600, 163158624, 142328864, 122556352, 104403376, + 88154704, 73876200, 61498028, 46182704, 34260640, 25149108, + 18299352, 13222145, 7605578, 4333750, 2455581, 1386840, + 8}, + {316243072, 314846976, 313758496, 311819264, 308361632, 302196576, + 296384960, 288212480, 276825088, 261244544, 240620416, 223927248, + 205130368, 184795488, 163749776, 142917424, 123115312, 104911608, + 88598136, 74247992, 61798064, 46386176, 34389240, 25225820, + 18343072, 13246210, 7614005, 4336575, 2456504, 1387138, + 8}, + {316243072, 314847424, 313759936, 311823680, 308374976, 302235808, + 296457920, 288344224, 277053216, 261616816, 241180800, 224622832, + 205949680, 185708032, 164710624, 143876432, 124026392, 105738528, + 89317024, 74847744, 62279204, 46709404, 34591704, 25345632, + 18410910, 13283357, 7626934, 4340894, 2457913, 1387591, + 8}, + {316243072, 314848576, 313763520, 311834784, 308408896, 302336352, + 296646528, 288688608, 277658208, 262622336, 242727504, 226572640, + 208281664, 188341088, 167512304, 146689696, 126701240, 108155720, + 91400008, 76564704, 63637504, 47602004, 35139296, 25663918, + 18588502, 13379501, 7659962, 4351840, 2461468, 1388732, + 8}, + {316243072, 314849696, 313767008, 311845696, 308442400, 302437088, + 296837792, 289043680, 278295680, 263711664, 244460352, 228811376, + 211025776, 191509408, 170942688, 150169152, 130013904, 111127336, + 93923424, 78603792, 65214388, 48602512, 35733560, 26000040, + 18772012, 13477197, 7692890, 4362631, 2464949, 1389845, + 8}, + {316243072, 314851456, 313772576, 311863104, 308496480, 302602432, + 297156960, 289649728, 279417792, 265709120, 247806384, 233308320, + 216768720, 198401536, 178640624, 158121536, 137602432, 117841520, + 99474352, 82934752, 68436688, 50533952, 36825288, 26593334, + 19086120, 13640627, 7746590, 4379971, 2470496, 1391611, + 8}, + {316243072, 314854304, 313781600, 311891584, 308586432, 302885824, + 297719616, 290762432, 281600928, 269929056, 255733744, 245043360, + 233506176, 220942800, 206510464, 188780448, 167001392, 142516720, + 118085768, 95972968, 77157136, 55082256, 39133424, 27751766, + 19665234, 13929855, 7837575, 4408639, 2479541, 1394467, + 8}, + {316243072, 314856256, 313787808, 311911392, 308650144, 303093152, + 298144768, 291644096, 283459968, 273946560, 264748512, 260980608, + 262699168, 277087168, 321151200, 394123840, 324055360, 228764272, + 162653280, 119096696, 89459480, 60122168, 41317836, 28739580, + 20125738, 14149189, 7903307, 4428811, 2485814, 1396432, + 8}, + }, + { + {421657440, 420139488, 418946528, 416800672, 412909824, 405768000, + 398798528, 388615200, 373701408, 352009344, 321306208, 295197120, + 265052208, 232374288, 199428848, 168474672, 140988912, 117445760, + 97614400, 80976864, 67001780, 50094056, 37102532, 27221784, + 19805402, 14310412, 8231902, 4690748, 2657888, 1501102, + 8}, + {421657440, 420140000, 418948192, 416805888, 412925952, 405817184, + 398893152, 388794176, 374031200, 352591488, 322263552, 296453088, + 266595344, 234127472, 201261264, 170245184, 142589072, 118816240, + 98738176, 81865128, 67681552, 50525452, 37361620, 27370528, + 19887816, 14354855, 8247121, 4695786, 2659523, 1501627, + 8}, + {421657440, 420140832, 418950752, 416813824, 412950592, 405892416, + 399038240, 389069504, 374540352, 353494496, 323757792, 298423616, + 269031008, 236912448, 204189776, 173088128, 145165408, 121023688, + 100545224, 83288680, 68766080, 51208348, 37768500, 27602440, + 20015536, 14423394, 8270460, 4703485, 2662016, 1502426, + 8}, + {421657440, 420142848, 418957120, 416833824, 413012864, 406083584, + 399408640, 389776736, 375859200, 355859264, 327727040, 303720672, + 275669600, 244617728, 212408608, 181157024, 152524352, 127334264, + 105689200, 87307640, 71794608, 53080056, 38863244, 28216278, + 20349054, 14600477, 8330018, 4722985, 2668305, 1504437, + 8}, + {421657440, 420144832, 418963328, 416853376, 413073952, 406272672, + 399777696, 390488160, 377202752, 358308992, 331931552, 309437728, + 282992896, 253322832, 221909888, 190657120, 161278448, 134848896, + 111768392, 91990440, 75259304, 55157184, 40043144, 28861386, + 20692490, 14779977, 8389313, 4742194, 2674461, 1506398, + 8}, + {421657440, 420147936, 418973184, 416884416, 413171584, 406578080, + 400379520, 391663936, 379464224, 362537056, 339441728, 319954336, + 296943136, 270562688, 241463968, 210828720, 180193472, 151094752, + 124714296, 101703104, 82215704, 59120396, 42193204, 29993510, + 21277910, 15079353, 8485847, 4773030, 2684265, 1509508, + 8}, + {421657440, 420152960, 418989056, 416934784, 413331648, 407087776, + 401401312, 393709888, 383542496, 370571008, 354857280, 343114528, + 330489120, 316523552, 299496928, 276320320, 244582704, 205903744, + 165901392, 130010112, 100638336, 68322528, 46691836, 32186576, + 22350768, 15606794, 8648967, 4823931, 2700238, 1514536, + 8}, + {421657440, 420156384, 418999936, 416969536, 413443296, 407450528, + 402143200, 395241024, 386740992, 377366336, 369662080, 368527968, + 375197056, 397609792, 449444704, 516205376, 465462368, 362087840, + 258438672, 179525856, 126554704, 78481920, 50925604, 34045784, + 23199528, 16005132, 8766508, 4859691, 2711304, 1517993, + 8}, + }, + { + {527071776, 525663296, 524547840, 522522432, 518787424, 511719680, + 504553280, 493592128, 476455264, 449151072, 405692192, 364814688, + 314764480, 260204640, 208654512, 165799504, 132838864, 107993088, + 88864512, 73593016, 61016300, 45833920, 34080076, 25068088, + 18265786, 13208915, 7602957, 4333255, 2455490, 1386823, + 8}, + {527071776, 525663968, 524550016, 522529280, 518809216, 511789088, + 504692864, 493873536, 477023936, 450294176, 407912896, 368083040, + 319153344, 265360480, 213877824, 170466944, 136659360, 110950480, + 91074048, 75204000, 62168492, 46509388, 34462976, 25278940, + 18379172, 13268763, 7622987, 4339800, 2457598, 1387497, + 8}, + {527071776, 525665024, 524553312, 522539712, 518842368, 511894848, + 504905440, 494302048, 477888864, 452029248, 411276832, 373037344, + 325837408, 273286560, 222000448, 177798416, 142702912, 115647968, + 94588960, 77764896, 63995604, 47574420, 35062716, 25607106, + 18554672, 13360983, 7653688, 4349799, 2460814, 1388524, + 8}, + {527071776, 525667616, 524561568, 522565952, 518925728, 512160800, + 505440320, 495379776, 480060704, 456371808, 419671424, 385428736, + 342733856, 293748832, 243537984, 197712496, 159394864, 128736152, + 104401184, 84889304, 69041664, 50472228, 36668388, 26472714, + 19011836, 13598833, 7731958, 4375112, 2468920, 1391105, + 8}, + {527071776, 525670144, 524569600, 522591456, 519006944, 512420320, + 505962656, 496432544, 482180128, 460599008, 427832576, 397536000, + 359516736, 314728096, 266563520, 219861040, 178476000, 143891040, + 115765904, 93067576, 74749312, 53662744, 38389064, 27378586, + 19481140, 13839382, 7809780, 4400025, 2476852, 1393623, + 8}, + {527071776, 525674176, 524582304, 522631776, 519135520, 512832256, + 506793344, 498109984, 485562304, 467353856, 440933088, 417176416, + 387412832, 351185728, 309140992, 263535888, 217930800, 175886048, + 139658944, 109895352, 86138704, 59717932, 41509480, 28961788, + 20278430, 14239528, 7936269, 4439982, 2489476, 1397613, + 8}, + {527071776, 525680576, 524602688, 522696672, 519343104, 513501216, + 508149376, 500867616, 491177920, 478742400, 463639360, 452372192, + 440252448, 426573952, 408733792, 381475072, 338855168, 280525408, + 216504432, 159999104, 116811992, 73859864, 48033652, 32018526, + 21734042, 14942109, 8149504, 4505844, 2510026, 1404063, + 8}, + {527071776, 525684960, 524616608, 522741088, 519485728, 513964384, + 509095872, 502817408, 495235360, 487294368, 481973920, 483250624, + 492921600, 517327296, 563364480, 613069184, 582305664, 502086528, + 381071808, 253160960, 162730896, 89940184, 54233516, 34613092, + 22883530, 15471362, 8302829, 4552048, 2524252, 1408495, + 8}, + }, + { + {632486144, 631404160, 630541632, 628962560, 626006848, 620254784, + 614202752, 604493888, 588124864, 558622016, 501272640, 434361248, + 339721664, 238866928, 162754096, 116484152, 89986864, 73763176, + 62238744, 52877240, 44742032, 34289616, 25778564, 19071620, + 13937721, 10094245, 5816231, 3316020, 1879259, 1061412, + 6}, + {632486144, 631404800, 630543680, 628969216, 626028480, 620326592, + 614353408, 604818816, 588856448, 560378560, 505802368, 442767520, + 353024832, 254136256, 175962480, 126430968, 96994048, 78520456, + 65419852, 54997780, 46155356, 35055980, 26190098, 19289814, + 14051970, 10153425, 5835647, 3322294, 1881268, 1062052, + 6}, + {632486144, 631405824, 630546880, 628979392, 626061312, 620435456, + 614581376, 605308288, 589949440, 562964736, 512317856, 454700768, + 372074880, 276762944, 196044128, 141682288, 107802384, 85920168, + 70405200, 58335116, 48381672, 36259776, 26833198, 19628898, + 14228628, 10244553, 5865397, 3331877, 1884330, 1063026, + 6}, + {632486144, 631408256, 630554752, 629004736, 626143360, 620706752, + 615146880, 606512512, 592597440, 569059456, 527028256, 480971968, + 414517856, 330765376, 247566576, 182256848, 137009328, 106116024, + 84093808, 67506720, 54475932, 39516588, 28548308, 20520860, + 14687895, 10479249, 5941177, 3356125, 1892049, 1065476, + 6}, + {632486144, 631410688, 630562432, 629029312, 626222784, 620968128, + 615688640, 607654336, 595061824, 574547584, 539620928, 502759456, + 449954304, 379751840, 300289600, 227398144, 170699200, 129631024, + 99970280, 78022152, 61351280, 43090368, 30380256, 21451668, + 15158278, 10716186, 6016439, 3379975, 1899599, 1067865, + 6}, + {632486144, 631414464, 630574528, 629067968, 626347520, 621376512, + 616530368, 609410496, 598784192, 582583360, 557211968, 532248416, + 497725888, 450454656, 388712384, 316243072, 243773744, 182031456, + 134760256, 100237736, 75274184, 49902756, 33701968, 23075620, + 15955780, 11109605, 6138617, 3418196, 1911610, 1071650, + 6}, + {632486144, 631420544, 630593856, 629129728, 626546304, 622024256, + 617857472, 612152256, 604500352, 594592960, 582468992, 573393728, + 563597248, 552304000, 536529024, 509232736, 458470464, 373144992, + 265980880, 175277520, 115809552, 66314040, 40717416, 26216598, + 17410064, 11799018, 6344228, 3481124, 1931149, 1077765, + 6}, + {632486144, 631424704, 630607040, 629171712, 626681152, 622462336, + 618753152, 613998592, 608344384, 602686208, 599701056, 602055040, + 611306560, 631195136, 663846400, 695665664, 678745600, 629219584, + 527619200, 345921568, 187985760, 86310936, 47549656, 28903180, + 18560056, 12317920, 6491857, 3525223, 1944665, 1081966, + 6}, + }, + { + {737900480, 737313472, 736843456, 735978112, 734341632, 731092416, + 727578432, 721723200, 711172416, 689515200, 632898368, 524671456, + 291627872, 124282568, 61909856, 39166204, 32726406, 30782714, + 28778620, 26053694, 22893106, 18076024, 13777827, 10259417, + 7520912, 5455094, 3146319, 1794368, 1017003, 574424, + 3}, + {737900480, 737313856, 736844736, 735982272, 734355200, 731139072, + 727679616, 721953472, 711743296, 691176960, 639550656, 546400448, + 337176160, 153194576, 79696616, 51414392, 40409976, 35288896, + 31462072, 27703048, 23931236, 18606918, 14052068, 10401011, + 7593699, 5492314, 3158367, 1798231, 1018235, 574816, + 3}, + {737900480, 737314496, 736846656, 735988544, 734375872, 731209600, + 727831808, 722297216, 712582592, 693540736, 648325568, 572924864, + 400936960, 201170544, 106893592, 68502096, 51196844, 41932300, + 35558792, 30265664, 25555562, 19438326, 14479913, 10620826, + 7706165, 5549599, 3176820, 1804132, 1020113, 575412, + 3}, + {737900480, 737315968, 736851520, 736004224, 734427392, 731384128, + 728205504, 723128192, 714552448, 698767168, 665389440, 617851520, + 518249088, 341071744, 189979888, 115866720, 79793448, 59627348, + 46625756, 37240340, 29975502, 21679968, 15618320, 11198082, + 7998192, 5697000, 3223802, 1819057, 1024845, 576910, + 3}, + {737900480, 737317504, 736856256, 736019456, 734476992, 731550720, + 728558400, 723898048, 716313280, 703122688, 677714048, 645514624, + 585425152, 469729280, 304799264, 181937120, 116903752, 81417144, + 59804904, 45335940, 34988372, 24141316, 16833072, 11799646, + 8296896, 5845648, 3270431, 1833731, 1029473, 578371, + 3}, + {737900480, 737319808, 736863680, 736043264, 734554432, 731808256, + 729097600, 725051328, 718858688, 709018048, 692447360, 674422272, + 645810304, 597029312, 509281120, 368950240, 228619376, 140871152, + 92090184, 63478204, 45453116, 28882404, 19041826, 12849181, + 8802888, 6092218, 3346065, 1857236, 1036832, 580686, + 3}, + {737900480, 737323520, 736875456, 736081088, 734676800, 732210048, + 729927424, 726786624, 722546496, 717012160, 710183424, 705045120, + 699473920, 692939328, 683288384, 664622720, 621866048, 513176832, + 298800288, 144682432, 80228568, 40814640, 23774754, 14887523, + 9725975, 6523960, 3473221, 1895906, 1048798, 584424, + 3}, + {737900480, 737326016, 736883520, 736106688, 734759040, 732477632, + 730474944, 727916992, 724904832, 721986304, 720753536, 722497344, + 728061952, 739005568, 755619392, 771010688, 763544704, 740635136, + 685348544, 485060256, 169322848, 56755684, 28517764, 16647276, + 10457803, 6848975, 3564451, 1922987, 1057072, 586991, + 3}, + }, + { + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314752, + -99, -23, -8, 0, -5, -6, + -6, -6, -5, -4, -3, -2, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314752, + -180, -33, -14, -9, -7, -7, + -7, -6, -5, -4, -3, -2, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314752, + -3092, -53, -23, -14, -11, -9, + -8, -7, -6, -4, -3, -2, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314752, -298, -55, -28, -19, -14, + -11, -9, -7, -5, -4, -3, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314688, -193, -55, -30, -20, + -14, -11, -8, -6, -4, -3, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314752, -421657440, -91, -40, + -24, -16, -11, -7, -4, -3, + -2, -1, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314752, + -252, -43, -21, -10, -6, -3, + -2, -2, -1, 0, 0, 0, + 0}, + {-843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314816, -843314816, -843314816, -843314816, -843314816, + -843314816, -843314752, -56, -14, -7, -4, + -2, -2, -1, 0, 0, 0, + 0}, + }, + { + {-737900480, -737313472, -736843456, -735978176, -734341632, -731092480, + -727578496, -721723200, -711172416, -689515200, -632898368, -524671488, + -291627872, -124282552, -61909848, -39166196, -32726402, -30782708, + -28778616, -26053690, -22893104, -18076022, -13777825, -10259415, + -7520911, -5455092, -3146318, -1794368, -1017003, -574424, + -3}, + {-737900480, -737313856, -736844736, -735982272, -734355264, -731139072, + -727679616, -721953472, -711743360, -691176960, -639550656, -546400448, + -337176160, -153194560, -79696608, -51414384, -40409972, -35288892, + -31462068, -27703042, -23931232, -18606916, -14052066, -10401010, + -7593697, -5492313, -3158366, -1798231, -1018235, -574816, + -3}, + {-737900480, -737314496, -736846656, -735988544, -734375872, -731209600, + -727831808, -722297216, -712582592, -693540736, -648325568, -572924928, + -400936960, -201170512, -106893576, -68502088, -51196836, -41932292, + -35558788, -30265660, -25555558, -19438322, -14479910, -10620825, + -7706164, -5549598, -3176819, -1804131, -1020113, -575412, + -3}, + {-737900480, -737316032, -736851520, -736004288, -734427392, -731384128, + -728205504, -723128192, -714552448, -698767168, -665389504, -617851520, + -518249088, -341071712, -189979872, -115866704, -79793440, -59627336, + -46625748, -37240336, -29975498, -21679964, -15618318, -11198080, + -7998190, -5696998, -3223801, -1819057, -1024845, -576910, + -3}, + {-737900480, -737317504, -736856256, -736019456, -734476992, -731550784, + -728558400, -723898112, -716313280, -703122688, -677714048, -645514624, + -585425152, -469729280, -304799232, -181937104, -116903736, -81417128, + -59804896, -45335932, -34988368, -24141312, -16833070, -11799644, + -8296895, -5845647, -3270430, -1833731, -1029472, -578371, + -3}, + {-737900480, -737319808, -736863680, -736043264, -734554432, -731808256, + -729097600, -725051328, -718858688, -709018112, -692447360, -674422272, + -645810304, -597029312, -509281120, -368950240, -228619360, -140871136, + -92090168, -63478192, -45453108, -28882400, -19041824, -12849179, + -8802887, -6092216, -3346064, -1857235, -1036832, -580686, + -3}, + {-737900480, -737323520, -736875520, -736081152, -734676800, -732210112, + -729927424, -726786624, -722546560, -717012224, -710183488, -705045120, + -699473920, -692939328, -683288448, -664622784, -621866048, -513176832, + -298800256, -144682416, -80228552, -40814632, -23774750, -14887520, + -9725973, -6523959, -3473220, -1895905, -1048798, -584424, + -3}, + {-737900480, -737326080, -736883520, -736106752, -734759104, -732477632, + -730474944, -727917056, -724904896, -721986368, -720753536, -722497344, + -728061952, -739005568, -755619456, -771010688, -763544704, -740635136, + -685348544, -485060256, -169322832, -56755676, -28517758, -16647273, + -10457802, -6848973, -3564450, -1922987, -1057072, -586991, + -3}, + }, + { + {-632486144, -631404160, -630541632, -628962624, -626006912, -620254848, + -614202752, -604493888, -588124928, -558622016, -501272672, -434361280, + -339721664, -238866896, -162754096, -116484128, -89986864, -73763168, + -62238740, -52877228, -44742028, -34289608, -25778562, -19071618, + -13937720, -10094244, -5816230, -3316020, -1879259, -1061412, + -6}, + {-632486144, -631404800, -630543744, -628969280, -626028480, -620326656, + -614353408, -604818880, -588856448, -560378624, -505802400, -442767552, + -353024864, -254136224, -175962480, -126430968, -96994048, -78520448, + -65419836, -54997768, -46155352, -35055976, -26190096, -19289814, + -14051969, -10153424, -5835646, -3322294, -1881267, -1062052, + -6}, + {-632486144, -631405824, -630546880, -628979392, -626061312, -620435456, + -614581376, -605308352, -589949440, -562964800, -512317888, -454700800, + -372074880, -276762944, -196044080, -141682256, -107802384, -85920168, + -70405192, -58335112, -48381668, -36259772, -26833196, -19628898, + -14228625, -10244552, -5865396, -3331876, -1884330, -1063026, + -6}, + {-632486144, -631408320, -630554816, -629004736, -626143424, -620706752, + -615146880, -606512512, -592597440, -569059456, -527028288, -480972000, + -414517888, -330765376, -247566576, -182256848, -137009312, -106116016, + -84093792, -67506712, -54475932, -39516584, -28548306, -20520858, + -14687894, -10479248, -5941176, -3356124, -1892049, -1065476, + -6}, + {-632486144, -631410688, -630562496, -629029312, -626222848, -620968128, + -615688640, -607654400, -595061824, -574547648, -539620928, -502759488, + -449954304, -379751872, -300289600, -227398144, -170699200, -129631024, + -99970272, -78022152, -61351276, -43090364, -30380254, -21451666, + -15158277, -10716185, -6016438, -3379975, -1899599, -1067865, + -6}, + {-632486144, -631414528, -630574528, -629067968, -626347520, -621376576, + -616530368, -609410560, -598784192, -582583424, -557211968, -532248448, + -497725920, -450454688, -388712416, -316243072, -243773744, -182031456, + -134760256, -100237728, -75274176, -49902756, -33701964, -23075618, + -15955779, -11109604, -6138616, -3418196, -1911610, -1071650, + -6}, + {-632486144, -631420608, -630593920, -629129728, -626546368, -622024256, + -617857472, -612152256, -604500352, -594593024, -582468992, -573393792, + -563597248, -552304000, -536529056, -509232736, -458470496, -373144992, + -265980880, -175277520, -115809544, -66314036, -40717412, -26216596, + -17410062, -11799017, -6344227, -3481124, -1931149, -1077765, + -6}, + {-632486144, -631424704, -630607040, -629171712, -626681152, -622462336, + -618753152, -613998656, -608344384, -602686272, -599701056, -602055040, + -611306560, -631195136, -663846464, -695665728, -678745600, -629219648, + -527619232, -345921600, -187985760, -86310936, -47549652, -28903178, + -18560056, -12317919, -6491856, -3525223, -1944664, -1081966, + -6}, + }, + { + {-527071808, -525663328, -524547904, -522522464, -518787456, -511719712, + -504553344, -493592160, -476455328, -449151136, -405692224, -364814720, + -314764512, -260204640, -208654496, -165799488, -132838856, -107993080, + -88864496, -73593008, -61016300, -45833920, -34080072, -25068086, + -18265786, -13208914, -7602956, -4333254, -2455489, -1386823, + -8}, + {-527071808, -525664032, -524550048, -522529344, -518809248, -511789152, + -504692896, -493873600, -477024000, -450294240, -407912928, -368083072, + -319153344, -265360496, -213877824, -170466928, -136659360, -110950464, + -91074040, -75203984, -62168492, -46509388, -34462972, -25278938, + -18379172, -13268760, -7622986, -4339799, -2457598, -1387497, + -8}, + {-527071808, -525665056, -524553344, -522539776, -518842432, -511894880, + -504905472, -494302080, -477888896, -452029312, -411276864, -373037408, + -325837408, -273286560, -222000464, -177798416, -142702912, -115647952, + -94588960, -77764888, -63995600, -47574416, -35062712, -25607104, + -18554672, -13360983, -7653687, -4349798, -2460813, -1388524, + -8}, + {-527071808, -525667680, -524561632, -522566016, -518925792, -512160864, + -505440352, -495379840, -480060736, -456371840, -419671488, -385428768, + -342733888, -293748864, -243538000, -197712512, -159394864, -128736136, + -104401192, -84889288, -69041664, -50472220, -36668384, -26472714, + -19011836, -13598832, -7731957, -4375111, -2468919, -1391105, + -8}, + {-527071808, -525670208, -524569664, -522591520, -519007008, -512420384, + -505962688, -496432608, -482180192, -460599072, -427832640, -397536032, + -359516800, -314728128, -266563552, -219861056, -178475984, -143891040, + -115765912, -93067576, -74749312, -53662744, -38389064, -27378586, + -19481138, -13839381, -7809779, -4400024, -2476851, -1393623, + -8}, + {-527071808, -525674208, -524582336, -522631840, -519135552, -512832288, + -506793408, -498110048, -485562336, -467353888, -440933120, -417176480, + -387412896, -351185760, -309141024, -263535920, -217930816, -175886064, + -139658944, -109895352, -86138704, -59717932, -41509480, -28961786, + -20278428, -14239527, -7936268, -4439981, -2489476, -1397613, + -8}, + {-527071808, -525680640, -524602720, -522696736, -519343168, -513501280, + -508149440, -500867680, -491177984, -478742432, -463639424, -452372288, + -440252512, -426573984, -408733888, -381475168, -338855200, -280525440, + -216504464, -159999152, -116811992, -73859864, -48033648, -32018524, + -21734040, -14942109, -8149503, -4505843, -2510026, -1404062, + -8}, + {-527071808, -525685024, -524616640, -522741120, -519485760, -513964448, + -509095936, -502817440, -495235424, -487294400, -481973952, -483250688, + -492921664, -517327360, -563364544, -613069184, -582305664, -502086560, + -381071904, -253160976, -162730944, -89940184, -54233516, -34613092, + -22883530, -15471361, -8302828, -4552048, -2524252, -1408494, + -8}, + }, + { + {-421657408, -420139456, -418946528, -416800672, -412909824, -405768000, + -398798528, -388615168, -373701408, -352009344, -321306208, -295197120, + -265052192, -232374288, -199428848, -168474672, -140988896, -117445752, + -97614400, -80976864, -67001780, -50094052, -37102532, -27221788, + -19805402, -14310412, -8231902, -4690747, -2657887, -1501102, + -8}, + {-421657408, -420140000, -418948192, -416805888, -412925952, -405817184, + -398893120, -388794176, -374031200, -352591488, -322263520, -296453056, + -266595328, -234127456, -201261264, -170245168, -142589072, -118816232, + -98738176, -81865128, -67681552, -50525456, -37361620, -27370528, + -19887816, -14354855, -8247121, -4695785, -2659522, -1501627, + -8}, + {-421657408, -420140800, -418950720, -416813824, -412950592, -405892416, + -399038240, -389069472, -374540320, -353494496, -323757792, -298423616, + -269030976, -236912448, -204189776, -173088112, -145165408, -121023680, + -100545224, -83288680, -68766080, -51208344, -37768500, -27602440, + -20015536, -14423394, -8270459, -4703484, -2662016, -1502426, + -8}, + {-421657408, -420142816, -418957120, -416833824, -413012832, -406083552, + -399408640, -389776736, -375859200, -355859232, -327727008, -303720672, + -275669600, -244617712, -212408608, -181157008, -152524352, -127334256, + -105689208, -87307640, -71794608, -53080056, -38863244, -28216278, + -20349054, -14600477, -8330017, -4722985, -2668305, -1504437, + -8}, + {-421657408, -420144800, -418963328, -416853344, -413073952, -406272672, + -399777664, -390488160, -377202752, -358308960, -331931552, -309437728, + -282992896, -253322816, -221909888, -190657120, -161278432, -134848896, + -111768392, -91990440, -75259304, -55157184, -40043144, -28861386, + -20692490, -14779979, -8389313, -4742193, -2674461, -1506398, + -8}, + {-421657408, -420147904, -418973152, -416884384, -413171584, -406578080, + -400379520, -391663904, -379464224, -362537024, -339441728, -319954336, + -296943136, -270562688, -241463968, -210828720, -180193456, -151094736, + -124714296, -101703096, -82215704, -59120396, -42193204, -29993510, + -21277910, -15079353, -8485847, -4773029, -2684265, -1509508, + -8}, + {-421657408, -420152928, -418989024, -416934752, -413331616, -407087776, + -401401280, -393709888, -383542496, -370571008, -354857280, -343114528, + -330489120, -316523520, -299496896, -276320320, -244582704, -205903728, + -165901376, -130010112, -100638328, -68322528, -46691836, -32186576, + -22350768, -15606794, -8648966, -4823931, -2700238, -1514536, + -8}, + {-421657408, -420156352, -418999936, -416969504, -413443264, -407450528, + -402143200, -395241024, -386740960, -377366304, -369662048, -368527936, + -375197024, -397609792, -449444704, -516205344, -465462368, -362087840, + -258438672, -179525856, -126554704, -78481920, -50925604, -34045784, + -23199528, -16005132, -8766508, -4859691, -2711304, -1517993, + -8}, + }, + { + {-316243008, -314846624, -313757504, -311816352, -308352832, -302171008, + -296337632, -288127456, -276678880, -261007888, -240267536, -223492144, + -204621168, -184231584, -163158624, -142328848, -122556336, -104403368, + -88154688, -73876192, -61498028, -46182700, -34260636, -25149106, + -18299350, -13222144, -7605577, -4333749, -2455580, -1386840, + -8}, + {-316243008, -314846912, -313758464, -311819232, -308361568, -302196544, + -296384928, -288212416, -276825056, -261244496, -240620368, -223927216, + -205130336, -184795472, -163749760, -142917408, -123115296, -104911600, + -88598128, -74247992, -61798056, -46386168, -34389244, -25225818, + -18343070, -13246209, -7614004, -4336575, -2456504, -1387137, + -8}, + {-316243008, -314847392, -313759872, -311823616, -308374912, -302235744, + -296457888, -288344192, -277053152, -261616784, -241180768, -224622800, + -205949648, -185708016, -164710592, -143876416, -124026376, -105738512, + -89317016, -74847736, -62279196, -46709404, -34591708, -25345634, + -18410908, -13283356, -7626933, -4340893, -2457913, -1387591, + -8}, + {-316243008, -314848512, -313763456, -311834752, -308408832, -302336288, + -296646464, -288688576, -277658176, -262622288, -242727472, -226572608, + -208281632, -188341072, -167512272, -146689680, -126701224, -108155704, + -91399992, -76564696, -63637496, -47602000, -35139292, -25663914, + -18588502, -13379500, -7659961, -4351839, -2461468, -1388732, + -8}, + {-316243008, -314849632, -313766976, -311845632, -308442368, -302437024, + -296837728, -289043648, -278295616, -263711632, -244460304, -228811328, + -211025744, -191509376, -170942672, -150169120, -130013896, -111127320, + -93923416, -78603784, -65214380, -48602508, -35733556, -26000038, + -18772010, -13477196, -7692889, -4362630, -2464949, -1389845, + -8}, + {-316243008, -314851424, -313772512, -311863040, -308496416, -302602400, + -297156896, -289649696, -279417728, -265709072, -247806336, -233308272, + -216768688, -198401504, -178640608, -158121504, -137602416, -117841504, + -99474336, -82934744, -68436680, -50533948, -36825284, -26593332, + -19086118, -13640626, -7746589, -4379970, -2470496, -1391610, + -8}, + {-316243008, -314854272, -313781536, -311891520, -308586368, -302885760, + -297719584, -290762368, -281600896, -269929024, -255733712, -245043328, + -233506144, -220942752, -206510416, -188780416, -167001360, -142516672, + -118085752, -95972952, -77157128, -55082252, -39133420, -27751764, + -19665234, -13929854, -7837574, -4408639, -2479541, -1394467, + -8}, + {-316243008, -314856224, -313787744, -311911360, -308650080, -303093120, + -298144704, -291644064, -283459904, -273946496, -264748464, -260980560, + -262699104, -277087104, -321151136, -394123776, -324055296, -228764208, + -162653232, -119096664, -89459472, -60122148, -41317832, -28739578, + -20125736, -14149188, -7903306, -4428810, -2485814, -1396432, + -8}, + }, + { + {-210828752, -209763872, -208938592, -207478800, -204908080, -200419808, + -196290928, -190633648, -183000704, -172937696, -160110736, -149997216, + -138756640, -126624232, -113938360, -101099096, -88510608, -76526296, + -65413292, -55341440, -46391320, -35074012, -26116860, -19208966, + -13991280, -10114557, -5820108, -3316738, -1879390, -1061436, + -6}, + {-210828752, -209763984, -208938928, -207479824, -204911120, -200428400, + -196306416, -190660464, -183044768, -173005280, -160206000, -150110752, + -138886000, -126765304, -114085976, -101247840, -88655288, -76662120, + -65536172, -55448360, -46480720, -35137564, -26158602, -19234616, + -14006233, -10122926, -5823093, -3317749, -1879722, -1061544, + -6}, + {-210828752, -209764144, -208939440, -207481376, -204915760, -200441648, + -196330416, -190702288, -183114016, -173112528, -160358784, -150294128, + -139096320, -126995880, -114328144, -101492256, -88892840, -76884536, + -65736472, -55621628, -46624628, -35238804, -26224440, -19274738, + -14029458, -10135854, -5827674, -3319296, -1880230, -1061707, + -6}, + {-210828752, -209764560, -208940736, -207485328, -204927632, -200475856, + -196392992, -190812944, -183300624, -173407952, -160790128, -150820560, + -139709616, -127677056, -115050048, -102223736, -89602680, -77544552, + -66324276, -56122908, -47034392, -35520116, -26403304, -19381648, + -14090389, -10169365, -5839389, -3323218, -1881511, -1062120, + -6}, + {-210828752, -209764960, -208941984, -207489216, -204939424, -200510464, + -196457344, -190929120, -183501920, -173737552, -161290496, -151447952, + -140459488, -128528240, -115966008, -103158080, -90506904, -78375592, + -67050588, -56727872, -47516252, -35838308, -26598652, -19495052, + -14153547, -10203492, -5851082, -3327087, -1882766, -1062523, + -6}, + {-210828752, -209765600, -208944000, -207495456, -204958576, -200568016, + -196566672, -191132352, -183868160, -174368384, -162309168, -152784224, + -142129664, -130500376, -118149736, -105414376, -92679024, -80328376, + -68699096, -58044540, -48519596, -36460372, -26960598, -19696400, + -14262092, -10260742, -5870182, -3333310, -1884767, -1063161, + -6}, + {-210828752, -209766624, -208947248, -207505712, -204990848, -200668832, + -196765472, -191522144, -184625552, -175818224, -165011760, -156772320, + -147807488, -138128816, -127521488, -115591360, -102270704, -88260840, + -74642488, -62217976, -51336332, -37958768, -27737038, -20093356, + -14463535, -10362521, -5902624, -3343612, -1888032, -1064195, + -6}, + {-210828752, -209767344, -208949504, -207512928, -205014000, -200744384, + -196920912, -191846704, -185318880, -177353360, -168608208, -163416672, + -160727552, -165029760, -189074016, -241456784, -178005872, -122049664, + -90479424, -70104056, -55475480, -39658748, -28482878, -20435214, + -14624802, -10440065, -5926123, -3350872, -1890299, -1064907, + -6}, + }, + { + {-105414352, -104839424, -104395752, -103614840, -102251280, -99903608, + -97777512, -94910408, -91113920, -86209240, -80075680, -75298248, + -70016784, -64317188, -58324212, -52191704, -46086820, -40171652, + -34586568, -29438702, -24797034, -18844524, -14076834, -10372790, + -7563107, -5470588, -3149178, -1794887, -1017097, -574441, + -3}, + {-105414352, -104839440, -104395800, -103614984, -102251696, -99904760, + -97779552, -94913864, -91119448, -86217488, -80086968, -75311472, + -70031648, -64333264, -58341004, -52208708, -46103540, -40187592, + -34601256, -29451740, -24808154, -18852650, -14082296, -10376208, + -7565130, -5471732, -3149590, -1795028, -1017143, -574456, + -3}, + {-105414352, -104839464, -104395864, -103615200, -102252328, -99906536, + -97782720, -94919272, -91128184, -86230632, -80105160, -75332928, + -70055928, -64359668, -58368680, -52236764, -46131096, -40213784, + -34625276, -29472926, -24826094, -18865612, -14090921, -10381562, + -7568272, -5473500, -3150225, -1795243, -1017214, -574479, + -3}, + {-105414352, -104839520, -104396048, -103615744, -102253960, -99911152, + -97791032, -94933688, -91151920, -86267216, -80157128, -75395304, + -70127624, -64438604, -58452116, -52321612, -46214216, -40292164, + -34696280, -29534602, -24877444, -18901780, -14114420, -10395856, + -7576529, -5478088, -3151847, -1795790, -1017393, -574537, + -3}, + {-105414352, -104839576, -104396224, -103616288, -102255584, -99915840, + -97799648, -94948992, -91177888, -86308728, -80218552, -75471128, + -70217064, -64539224, -58559996, -52431912, -46321788, -40392244, + -34785072, -29609788, -24938334, -18942936, -14140198, -10411064, + -7585107, -5482767, -3153468, -1796330, -1017569, -574593, + -3}, + {-105414352, -104839672, -104396504, -103617152, -102258232, -99923720, + -97814464, -94976168, -91226088, -86390208, -80347520, -75638136, + -70423480, -64780936, -58826440, -52707176, -46587912, -40633416, + -34990872, -29776222, -25066836, -19024146, -14188261, -10438183, + -7599891, -5490632, -3156117, -1797198, -1017849, -574683, + -3}, + {-105414352, -104839816, -104396960, -103618592, -102262736, -99937720, + -97841944, -95029800, -91329808, -86588032, -80716136, -76183440, + -71203424, -65834124, -60122608, -54107304, -47891720, -41697004, + -35779764, -30327718, -25439256, -19223604, -14292622, -10492064, + -7627469, -5504662, -3160627, -1798637, -1018307, -574828, + -3}, + {-105414352, -104839912, -104397280, -103619608, -102266000, -99948376, + -97863944, -95076008, -91429704, -86814408, -81270896, -77262800, + -73480376, -71228232, -75154784, -90330848, -64216360, -47491208, + -38189996, -31457080, -26014454, -19455914, -14394384, -10538884, + -7649672, -5515392, -3163898, -1799652, -1018624, -574928, + -3}, + }}; + +const WORD32 ixheaacd_c_l_table_Q31[31] = { + 68, 12075997, 21473763, 38182223, 67875466, 120571390, + 170045077, 239449100, 336157459, 469148859, 647490682, 794298694, + 962206904, 1145934076, 1335698887, 1518500250, 1681545272, 1816183116, + 1919855175, 1995188112, 2047545319, 2095610977, 2121010179, 2134092347, + 2140740687, 2144096210, 2146410711, 2147144182, 2147376282, 2147449694, + 2147483647}; + +const WORD32 ixheaacd_sin_table_Q31[16][31] = { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {750179061, 746245580, 743210706, 737870331, 728548620, 712505595, + 697979429, 678386783, 652421439, 618809885, 576615606, 543587743, + 506876195, 466993926, 424737371, 381140538, 337380886, 294653248, + 254039878, 216406178, 182341865, 138534277, 103401830, 76116249, + 55442477, 40067134, 23038730, 13121396, 7432107, 4196447, + 24}, + {1161262961, 1155790434, 1151559607, 1144096867, 1131016382, 1108345689, + 1087649071, 1059486043, 1021740286, 972201548, 909011376, 858841310, + 802424715, 740453756, 674139243, 605156167, 535487835, 467194735, + 402165023, 341910884, 287454637, 217648816, 161934922, 118876289, + 86395037, 62326858, 35765878, 20345239, 11515596, 6499487, + 37}, + {1716503346, 1710705303, 1706196326, 1698186767, 1683975371, 1658827737, + 1635302807, 1602433676, 1556860619, 1494490287, 1410930784, 1341611885, + 1260794215, 1168902519, 1067487796, 959278806, 847935697, 737527629, + 631893965, 534105311, 446175490, 334574700, 246745780, 179796016, + 129896719, 93282739, 53251977, 30198506, 17061963, 9620003, + 54}, + {1997091453, 1992944085, 1989690856, 1983852214, 1973306896, 1954076825, + 1935447004, 1908416859, 1869093029, 1812001456, 1730062329, 1657802892, + 1569207783, 1463537141, 1341868672, 1207527592, 1065884173, 923429508, + 786466908, 659983219, 547093745, 405656596, 296231282, 214127893, + 153738020, 109885815, 62401443, 35278435, 19896909, 11207148, + 63}, + {2147483647, 2147449694, 2147376282, 2147144182, 2146410711, 2144096210, + 2140740687, 2134092347, 2121010179, 2095610977, 2047545319, 1995188112, + 1919855175, 1816183116, 1681545272, 1518500250, 1335698887, 1145934076, + 962206904, 794298694, 647490682, 469148859, 336157459, 239449100, + 170045077, 120571390, 67875466, 38182223, 21473763, 12075997, + 68}, + {1735452507, 1741201627, 1745677174, 1753637197, 1767790913, 1792923770, + 1816518097, 1849561983, 1895318984, 1957003931, 2034703322, 2089967744, + 2134916861, 2144595142, 2081353083, 1914153740, 1653277521, 1353148056, + 1069993076, 832031145, 643429686, 438118607, 300387816, 207524268, + 144291161, 100823513, 55902457, 31184569, 17456772, 9791496, + 55}, + {302939858, 304635714, 305968630, 308367663, 312727041, 320788003, + 328771547, 340741324, 359192238, 388879484, 440075553, 497870534, + 595446097, 785304289, 1255861595, 2142108211, 997566324, 495493509, + 298429982, 198205829, 139164109, 87059272, 56928133, 38231805, + 26115252, 18039235, 9889297, 5483639, 3059686, 1713093, + 10}, + {329205034, 331044496, 332490231, 335092198, 339819934, 348560631, + 357215536, 370188297, 390176357, 422312259, 477650750, 539980675, + 644803507, 846880778, 1332052144, 2141128430, 1058086628, 534345646, + 323167286, 214970179, 151046430, 94543938, 61838785, 41535810, + 28374639, 19601005, 10746050, 5958876, 3324902, 1861600, + 10}, + {1497748045, 1503796643, 1508521727, 1516961790, 1532087179, 1559339680, + 1585420057, 1622844547, 1676673047, 1753885899, 1862379403, 1953397438, + 2051811629, 2131459107, 2134283647, 1989548276, 1695321762, 1344859778, + 1028341794, 777661527, 588936078, 392646144, 265734770, 182086153, + 125934391, 87688114, 48448851, 26975819, 15085217, 8456470, + 47}, + {1819124703, 1824556610, 1828777565, 1836267987, 1849532387, 1872907535, + 1894631673, 1924668687, 1965428606, 2018548171, 2081362225, 2121366279, + 2146115448, 2132815850, 2050987089, 1879164766, 1629156954, 1345715825, + 1075605664, 844531127, 658184527, 451896646, 311499442, 215951378, + 150495943, 105321331, 58487349, 32653976, 18287776, 10260236, + 58}, + {1923585203, 1928381715, 1932097038, 1938664124, 1950209521, 1970281404, + 1988600282, 2013343744, 2045676827, 2085120607, 2125770747, 2144599223, + 2143208195, 2102454500, 2000402838, 1825095804, 1588976455, 1326559108, + 1074148586, 853780328, 672227734, 466800358, 324217928, 225900884, + 157960135, 110797066, 61671040, 34474865, 19320970, 10844087, + 61}, + {1985155606, 1989395440, 1992670162, 1998437861, 2008511637, 2025809362, + 2041332134, 2061836802, 2087645355, 2116966052, 2142166480, 2147133001, + 2129677751, 2073262009, 1960755061, 1784738505, 1557483106, 1308139892, + 1067367301, 854789044, 677412520, 473929665, 330869491, 231341894, + 162148775, 113919632, 63514715, 35537809, 19926702, 11187193, + 63}, + {2020686784, 2024512419, 2027460265, 2032636996, 2041629534, 2056910757, + 2070427091, 2087934395, 2109221115, 2131716042, 2146880706, 2143192060, + 2116099812, 2050733580, 1932676750, 1756826697, 1535179711, 1293925414, + 1060562211, 853220127, 678903290, 477231777, 334289019, 234270092, + 164459870, 115668592, 64561995, 36145965, 20274603, 11384670, + 64}, + {2039090402, 2042664488, 2045414146, 2050233276, 2058573831, 2072646538, + 2084969290, 2100708700, 2119359676, 2137940103, 2147475978, 2139046746, + 2106802112, 2036793002, 1916001986, 1740449052, 1521934475, 1285129504, + 1055902322, 851569848, 679091531, 478625170, 335895872, 235703393, + 165614998, 116553480, 65097820, 36458876, 20454141, 11486747, + 64}, + {2044775589, 2048265671, 2050949194, 2055649103, 2063772641, 2077444225, + 2089372175, 2104529140, 2122316535, 2139624159, 2147348884, 2137411299, + 2103545985, 2032097722, 1910481747, 1735055157, 1517549594, 1282166983, + 1054270393, 850918765, 679051340, 479002183, 336364503, 236132053, + 165964731, 116823274, 65262221, 36555185, 20509492, 11518244, + 65} + +}; + +const WORD32 ixheaacd_cos_table_Q31[16][31] = { + {2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647}, + {2012192186, 2013654279, 2014776381, 2016738305, 2020124483, 2025838542, + 2030889149, 2037517458, 2045979541, 2056394987, 2068622842, 2077546241, + 2086806781, 2096092243, 2105061563, 2113390146, 2120815918, 2127173120, + 2132404689, 2136551985, 2139728362, 2143010563, 2144992793, 2146134277, + 2146767838, 2147109835, 2147360062, 2147443561, 2147470787, 2147479548, + 2147483647}, + {1806420315, 1809926653, 1812621442, 1817341018, 1825510329, 1839362893, + 1851676407, 1867933442, 1888844304, 1914813351, 1945606419, 1968267671, + 1991933883, 2015791223, 2038926752, 2060454327, 2079648720, 2096047494, + 2109490297, 2120090320, 2128157854, 2136425756, 2141369445, 2144190861, + 2145745072, 2146578995, 2147185791, 2147387271, 2147452772, 2147473812, + 2147483647}, + {1290465917, 1298142282, 1304062927, 1314476217, 1332633846, 1363809575, + 1391930582, 1429647625, 1479145371, 1542136441, 1618938029, 1676831408, + 1738414210, 1801486309, 1863372164, 1921319908, 1972990388, 2016863658, + 2052412248, 2080004215, 2100622158, 2121260425, 2133261010, 2139943787, + 2143551460, 2145456676, 2146823292, 2147271308, 2147415867, 2147462101, + 2147483647}, + {789500947, 799912428, 807970493, 822202171, 847198862, 890656938, + 930446620, 984698487, 1057439013, 1152534920, 1272230465, 1365055160, + 1466039887, 1571542254, 1676625923, 1775827450, 1864289931, 1938804777, + 1998288223, 2043552830, 2076625737, 2108821648, 2126953936, 2136781520, + 2141973538, 2144670400, 2146576828, 2147193855, 2147391471, 2147454404, + 2147483647}, + {68, 12075997, 21473763, 38182223, 67875466, 120571390, + 170045077, 239449100, 336157459, 469148859, 647490682, 794298694, + 962206904, 1145934076, 1335698887, 1518500250, 1681545272, 1816183116, + 1919855175, 1995188112, 2047545319, 2095610977, 2121010179, 2134092347, + 2140740687, 2144096210, 2146410711, 2147144182, 2147376282, 2147449694, + 2147483647}, + {-1264867824, -1256941889, -1250718683, -1239533218, -1219262608, + -1181994236, -1145402996, -1091240803, -1009679140, -884206781, + -686781195, -493680916, -231982790, 111344931, 528824509, + 973499603, 1370532546, 1667536014, 1861934703, 1979750033, + 2048825092, 2102317318, 2126370894, 2137432969, 2142630645, + 2145115530, 2146755909, 2147257214, 2147412694, 2147461326, + 2147483647}, + {-2126008810, -2125766474, -2125575032, -2125228318, -2124591212, + -2123389054, -2122167592, -2120278606, -2117230964, -2111979821, + -2101908544, -2088973660, -2063281359, -1998745405, -1741980962, + 151850025, 1901722232, 2089538753, 2126646554, 2138317205, + 2142969755, 2145718225, 2146728955, 2147143299, 2147324850, + 2147407880, 2147460877, 2147476647, 2147481468, 2147482965, + 2147483647}, + {-2122100390, -2121814214, -2121588147, -2121178738, -2120426474, + -2119007198, -2117565366, -2115336059, -2111740616, -2105549423, + -2093689514, -2078486682, -2048393140, -1973443429, -1684435545, + 165091079, 1868726493, 2079942487, 2123028244, 2136696946, + 2142165025, 2145401469, 2146593111, 2147081926, 2147296183, + 2147394193, 2147456761, 2147475381, 2147481074, 2147482841, + 2147483647}, + {-1538972648, -1533062841, -1528413627, -1520037153, -1504790648, + -1476531673, -1448492065, -1406435777, -1341809789, -1239181290, + -1069218864, -892145989, -633841507, -261855100, 237737945, + 808321517, 1318169239, 1674227642, 1885258383, 2001731392, + 2065148981, 2111282791, 2130978895, 2139750138, 2143787897, + 2145692618, 2146937057, 2147314212, 2147430664, 2147466998, + 2147483647}, + {-1141258661, -1132554280, -1125725826, -1113465715, -1091290965, + -1050668066, -1010968269, -952542107, -865318678, -732904701, + -528788529, -333902874, -76645308, 250564500, 636504499, + 1039435328, 1399118879, 1673539643, 1858698059, 1974450099, + 2044132860, 2099398828, 2124771544, 2136598002, 2142203769, + 2144899400, 2146687040, 2147235370, 2147405778, 2147459137, + 2147483647}, + {-954728226, -945002634, -937383089, -923724761, -899093346, -854211454, + -810650934, -747082986, -653369987, -513768503, -304605894, -111266315, + 135442430, 437459820, 781072662, 1131685170, 1444589853, 1688764919, + 1859540490, 1970468261, 2039557769, 2096135359, 2122868049, 2135568966, + 2141666317, 2144623517, 2146597937, 2147206907, 2147396731, 2147456268, + 2147483647}, + {-819050205, -808697596, -800594558, -786086595, -759978305, -712588553, + -666820168, -600429030, -503411252, -360750262, -151025800, 38805847, + 275968648, 559705870, 875857071, 1194317582, 1478489903, 1703072530, + 1863441189, 1970030890, 2037841578, 2094534958, 2121841511, 2134986404, + 2141353262, 2144459917, 2146544176, 2147189578, 2147391195, 2147454508, + 2147483647}, + {-726987579, -716264954, -707877738, -692872903, -665909053, -617093312, + -570103217, -502211092, -403574415, -259755142, -50884692, 135697496, + 365797219, 637320800, 936187267, 1235008492, 1501635533, 1713897034, + 1867322633, 1970710895, 2037345415, 2093785053, 2121305464, 2134667080, + 2141177006, 2144366292, 2146512932, 2147179426, 2147387939, 2147453470, + 2147483647}, + {-673644084, -662727550, -654191860, -638928424, -611522528, -561980736, + -514382230, -445767850, -346411003, -202232874, 5739490, 190171073, + 416017882, 680558805, 969856901, 1257983750, 1515058240, 1720502304, + 1869961578, 1971424564, 2037282678, 2093466973, 2121051622, 2134509295, + 2141087969, 2144318378, 2146496749, 2147174136, 2147386236, 2147452927, + 2147483647}, + {-656185042, -645208306, -636626596, -621283175, -593741108, -543977491, + -496195458, -427367659, -327808702, -183560558, 24058044, 207747337, + 432180873, 694452925, 980686245, 1265412826, 1519450311, 1722711191, + 1870882133, 1971705676, 2037296075, 2093380741, 2120977355, 2134461916, + 2141060888, 2144303696, 2146491757, 2147172498, 2147385708, 2147452758, + 2147483647}}; + +const WORD32 + ixheaacd_mps_polyphase_filter_coeff_fix[10 * MAX_NUM_QMF_BANDS_SAC / 2] = { + 0x00000000, 0x0055dba0, 0xffede50e, 0x005b5370, 0xffed978a, 0x006090c3, + 0xffefc9b9, 0x0065fde5, 0xfff0065d, 0x006b47fa, 0xffeff6cb, 0x0070c8a4, + 0xffef7b8b, 0x0075fdec, 0xffeedfa4, 0x007b3874, 0xffee1650, 0x00807993, + 0xffed651e, 0x0085c217, 0xffecc31c, 0x008a7dd6, 0xffebe77b, 0x008f4bfc, + 0xffeb50b3, 0x009424c5, 0xffea9193, 0x0098b855, 0xffe9ca76, 0x009d10bf, + 0xffe940f4, 0x00a1039c, 0xffe88ba8, 0x00a520bb, 0xffe83a08, 0x00a8739d, + 0xffe79e16, 0x00abe79d, 0xffe7746f, 0x00af374c, 0xffe6d466, 0x00b1978d, + 0xffe6afee, 0x00b3d15b, 0xffe65416, 0x00b5c866, 0xffe681c6, 0x00b74c36, + 0xffe66dd0, 0x00b8394b, 0xffe66fac, 0x00b8fe0d, 0xffe69424, 0x00b8c6b0, + 0xffe6fed4, 0x00b85f70, 0xffe75361, 0x00b73aaf, 0xffe80415, 0x00b58c8c, + 0xffe85b4b, 0x00b36acd, 0xffe954d1, 0x00b06b68, 0xffea353b, 0x00acbd2e, + 0xffeb3849, 0x00a85e93, 0xffec8409, 0x00a3508f, 0xffedc419, 0x009da525, + 0xffef2395, 0x0096dcc1, 0xfff0e7f0, 0x008f87aa, 0xfff294c4, 0x00872c62, + 0xfff48701, 0x007e0392, 0xfff681d7, 0x007400b7, 0xfff91fca, 0x006928a0, + 0xfffb42b1, 0x005d36de, 0xfffdfa25, 0x00504f40, 0x00007134, 0x00426f36, + 0x00039608, 0x0033b926, 0x0006b1ce, 0x0023b989, 0x0009aa3e, 0x00131c75, + 0x000d31b4, 0x0000e790, 0x0010bc63, 0xffee183b, 0x001471f7, 0xffda17f2, + 0x0018703e, 0xffc4e365, 0x001c3549, 0xffaea5d6, 0x002064f7, 0xff975c02, + 0x0024dd50, 0xff7ee3f2, 0x00293718, 0xff6542d1, 0x002d8e42, 0xff4aabc9, + 0x00329ab6, 0xff2ef726, 0x003745f9, 0xff120d71, 0x003c1fa3, 0xfef3f6ac, + 0x004103f4, 0xfed4bec3, 0x00465347, 0xfeb48d0d, 0x004b6c45, 0xfe933dc1, + 0x0050b176, 0xfe70b8d1, 0x01b2e41c, 0x09015651, 0x01d78bfb, 0x08d3e41b, + 0x01fd3ba0, 0x08a24899, 0x02244a24, 0x086b1eeb, 0x024bf7a1, 0x082f552e, + 0x0274ba42, 0x07ee507b, 0x029e35b4, 0x07a8127c, 0x02c89900, 0x075ca90c, + 0x02f3e48d, 0x070bbf58, 0x03201115, 0x06b559c3, 0x034d01f0, 0x06593911, + 0x037ad437, 0x05f7fb90, 0x03a966bb, 0x0590a67d, 0x03d8afe6, 0x05237f9c, + 0x04083fec, 0x04b0adcb, 0x043889c5, 0x0437fb0a, 0x04694101, 0x03b8f8db, + 0x049aa82e, 0x03343533, 0x04cc2fce, 0x02a99097, 0x04fe20bd, 0x02186a91, + 0x05303f87, 0x01816e05, 0x05626209, 0x00e42fa2, 0x05950122, 0x0040c496, + 0x05c76fec, 0xff96db90, 0x05f9c050, 0xfee723c7, 0x062bf5eb, 0xfe310658, + 0x065dd569, 0xfd7475d8, 0x068f8b44, 0xfcb1d740, 0x06c0f0c0, 0xfbe8f5be, + 0x06f1825c, 0xfb19b7be, 0x0721bf21, 0xfa44a06a, 0x075112a1, 0xf96916f5, + 0x077fedb2, 0xf887507c, 0x07ad8c26, 0xf79fa13b, 0x07da2b7f, 0xf6b1f3c3, + 0x08061671, 0xf5be0fa9, 0x08303897, 0xf4c473c6, 0x08594887, 0xf3c4e887, + 0x0880ffdc, 0xf2bf6ea5, 0x08a75da4, 0xf1b461ab, 0x08cb4e22, 0xf0a395a0, + 0x08edfeaa, 0xef8d4d7c, 0x090ec1fc, 0xee71b2ff, 0x092d796f, 0xed50a31e, + 0x0949eaac, 0xec2a3f60, 0x0963ed46, 0xeafee7f2, 0x097c1ee8, 0xe9cea84b, + 0x099140a6, 0xe89971b7, 0x09a3e163, 0xe75f8bb8, 0x09b3d77f, 0xe620c476, + 0x09c0e59e, 0xe4de0cb0, 0x09cab9f1, 0xe396a45e, 0x09d19ca8, 0xe24b8f67, + 0x09d52709, 0xe0fc421f, 0x09d5560a, 0xdfa93ab5, 0x09d1fa22, 0xde529087, + 0x09caeb0e, 0xdcf898fb, 0x09c018ce, 0xdb9b5b13, 0x09b18a1c, 0xda3b176b, + 0x099ec3db, 0xd8d7f220, 0x09881dc5, 0xd7722f05, 0x096d0e21, 0xd60a46e6, + 0x094d7ec2, 0xd49fd55f, 0x09299ead, 0xd3337b3e, 0x2e3a7532, 0x6d474e1d, + 0x2faa221c, 0x6d41d963, 0x311af3a4, 0x6d32730f, 0x328cc6f0, 0x6d18520d, + 0x33ff670e, 0x6cf4073e, 0x3572ec70, 0x6cc59baa, 0x36e69691, 0x6c8c4c7a, + 0x385a49c3, 0x6c492216, 0x39ce0477, 0x6bfbdd97, 0x3b415115, 0x6ba4629e, + 0x3cb41218, 0x6b42a863, 0x3e25b17e, 0x6ad73e8d, 0x3f962fb8, 0x6a619c5e, + 0x41058bc5, 0x69e29784, 0x4272a385, 0x6959709d, 0x43de620a, 0x68c7269b, + 0x4547daea, 0x682b39a3, 0x46aea856, 0x6785c24d, 0x4812f848, 0x66d76725, + 0x4973fef1, 0x661fd6b7, 0x4ad237a2, 0x655f63f1, 0x4c2ca3df, 0x64964062, + 0x4d83976c, 0x63c45243, 0x4ed62be2, 0x62ea6473, 0x5024d70e, 0x6207f21f, + 0x516eefb9, 0x611d58a2, 0x52b449dd, 0x602b0c7f, 0x53f495a9, 0x5f30ff5f, + 0x552f8ff6, 0x5e2f6366, 0x56654bdd, 0x5d26be9b, 0x579505f5, 0x5c16d0ae, + 0x58befacd, 0x5b001db7, 0x59e2f69e, 0x59e2f69e, 0x5b001db7, 0x58befacd, + 0x5c16d0ae, 0x579505f5, 0x5d26be9b, 0x56654bdd, 0x5e2f6366, 0x552f8ff6, + 0x5f30ff5f, 0x53f495a9, 0x602b0c7f, 0x52b449dd, 0x611d58a2, 0x516eefb9, + 0x6207f21f, 0x5024d70e, 0x62ea6473, 0x4ed62be2, 0x63c45243, 0x4d83976c, + 0x64964062, 0x4c2ca3df, 0x655f63f1, 0x4ad237a2, 0x661fd6b7, 0x4973fef1, + 0x66d76725, 0x4812f848, 0x6785c24d, 0x46aea856, 0x682b39a3, 0x4547daea, + 0x68c7269b, 0x43de620a, 0x6959709d, 0x4272a385, 0x69e29784, 0x41058bc5, + 0x6a619c5e, 0x3f962fb8, 0x6ad73e8d, 0x3e25b17e, 0x6b42a863, 0x3cb41218, + 0x6ba4629e, 0x3b415115, 0x6bfbdd97, 0x39ce0477, 0x6c492216, 0x385a49c3, + 0x6c8c4c7a, 0x36e69691, 0x6cc59baa, 0x3572ec70, 0x6cf4073e, 0x33ff670e, + 0x6d18520d, 0x328cc6f0, 0x6d32730f, 0x311af3a4, 0x6d41d963, 0x2faa221c, + 0xd1c58ace, 0x09015651, 0xd3337b3e, 0x09299ead, 0xd49fd55f, 0x094d7ec2, + 0xd60a46e6, 0x096d0e21, 0xd7722f05, 0x09881dc5, 0xd8d7f220, 0x099ec3db, + 0xda3b176b, 0x09b18a1c, 0xdb9b5b13, 0x09c018ce, 0xdcf898fb, 0x09caeb0e, + 0xde529087, 0x09d1fa22, 0xdfa93ab5, 0x09d5560a, 0xe0fc421f, 0x09d52709, + 0xe24b8f67, 0x09d19ca8, 0xe396a45e, 0x09cab9f1, 0xe4de0cb0, 0x09c0e59e, + 0xe620c476, 0x09b3d77f, 0xe75f8bb8, 0x09a3e163, 0xe89971b7, 0x099140a6, + 0xe9cea84b, 0x097c1ee8, 0xeafee7f2, 0x0963ed46, 0xec2a3f60, 0x0949eaac, + 0xed50a31e, 0x092d796f, 0xee71b2ff, 0x090ec1fc, 0xef8d4d7c, 0x08edfeaa, + 0xf0a395a0, 0x08cb4e22, 0xf1b461ab, 0x08a75da4, 0xf2bf6ea5, 0x0880ffdc, + 0xf3c4e887, 0x08594887, 0xf4c473c6, 0x08303897, 0xf5be0fa9, 0x08061671, + 0xf6b1f3c3, 0x07da2b7f, 0xf79fa13b, 0x07ad8c26, 0xf887507c, 0x077fedb2, + 0xf96916f5, 0x075112a1, 0xfa44a06a, 0x0721bf21, 0xfb19b7be, 0x06f1825c, + 0xfbe8f5be, 0x06c0f0c0, 0xfcb1d740, 0x068f8b44, 0xfd7475d8, 0x065dd569, + 0xfe310658, 0x062bf5eb, 0xfee723c7, 0x05f9c050, 0xff96db90, 0x05c76fec, + 0x0040c496, 0x05950122, 0x00e42fa2, 0x05626209, 0x01816e05, 0x05303f87, + 0x02186a91, 0x04fe20bd, 0x02a99097, 0x04cc2fce, 0x03343533, 0x049aa82e, + 0x03b8f8db, 0x04694101, 0x0437fb0a, 0x043889c5, 0x04b0adcb, 0x04083fec, + 0x05237f9c, 0x03d8afe6, 0x0590a67d, 0x03a966bb, 0x05f7fb90, 0x037ad437, + 0x06593911, 0x034d01f0, 0x06b559c3, 0x03201115, 0x070bbf58, 0x02f3e48d, + 0x075ca90c, 0x02c89900, 0x07a8127c, 0x029e35b4, 0x07ee507b, 0x0274ba42, + 0x082f552e, 0x024bf7a1, 0x086b1eeb, 0x02244a24, 0x08a24899, 0x01fd3ba0, + 0x08d3e41b, 0x01d78bfb, 0xfe4d1be4, 0x0055dba0, 0xfe70b8d1, 0x0050b176, + 0xfe933dc1, 0x004b6c45, 0xfeb48d0d, 0x00465347, 0xfed4bec3, 0x004103f4, + 0xfef3f6ac, 0x003c1fa3, 0xff120d71, 0x003745f9, 0xff2ef726, 0x00329ab6, + 0xff4aabc9, 0x002d8e42, 0xff6542d1, 0x00293718, 0xff7ee3f2, 0x0024dd50, + 0xff975c02, 0x002064f7, 0xffaea5d6, 0x001c3549, 0xffc4e365, 0x0018703e, + 0xffda17f2, 0x001471f7, 0xffee183b, 0x0010bc63, 0x0000e790, 0x000d31b4, + 0x00131c75, 0x0009aa3e, 0x0023b989, 0x0006b1ce, 0x0033b926, 0x00039608, + 0x00426f36, 0x00007134, 0x00504f40, 0xfffdfa25, 0x005d36de, 0xfffb42b1, + 0x006928a0, 0xfff91fca, 0x007400b7, 0xfff681d7, 0x007e0392, 0xfff48701, + 0x00872c62, 0xfff294c4, 0x008f87aa, 0xfff0e7f0, 0x0096dcc1, 0xffef2395, + 0x009da525, 0xffedc419, 0x00a3508f, 0xffec8409, 0x00a85e93, 0xffeb3849, + 0x00acbd2e, 0xffea353b, 0x00b06b68, 0xffe954d1, 0x00b36acd, 0xffe85b4b, + 0x00b58c8c, 0xffe80415, 0x00b73aaf, 0xffe75361, 0x00b85f70, 0xffe6fed4, + 0x00b8c6b0, 0xffe69424, 0x00b8fe0d, 0xffe66fac, 0x00b8394b, 0xffe66dd0, + 0x00b74c36, 0xffe681c6, 0x00b5c866, 0xffe65416, 0x00b3d15b, 0xffe6afee, + 0x00b1978d, 0xffe6d466, 0x00af374c, 0xffe7746f, 0x00abe79d, 0xffe79e16, + 0x00a8739d, 0xffe83a08, 0x00a520bb, 0xffe88ba8, 0x00a1039c, 0xffe940f4, + 0x009d10bf, 0xffe9ca76, 0x0098b855, 0xffea9193, 0x009424c5, 0xffeb50b3, + 0x008f4bfc, 0xffebe77b, 0x008a7dd6, 0xffecc31c, 0x0085c217, 0xffed651e, + 0x00807993, 0xffee1650, 0x007b3874, 0xffeedfa4, 0x0075fdec, 0xffef7b8b, + 0x0070c8a4, 0xffeff6cb, 0x006b47fa, 0xfff0065d, 0x0065fde5, 0xffefc9b9, + 0x006090c3, 0xffed978a, 0x005b5370, 0xffede50e}; + +WORD32 ixheaacd_mps_pre_re[64] = { + 0x01fff621, 0x01ffa72e, 0x01ff0956, 0x01fe1caf, 0x01fce15f, 0x01fb5797, + 0x01f97f92, 0x01f7599a, 0x01f4e603, 0x01f2252f, 0x01ef178a, 0x01ebbd8c, + 0x01e817ba, 0x01e426a4, 0x01dfeae6, 0x01db6526, 0x01d69617, 0x01d17e77, + 0x01cc1f0f, 0x01c678b3, 0x01c08c42, 0x01ba5aa6, 0x01b3e4d3, 0x01ad2bc9, + 0x01a63091, 0x019ef43e, 0x019777ee, 0x018fbcc9, 0x0187c400, 0x017f8ecd, + 0x01771e75, 0x016e7444, 0x01659191, 0x015c77bb, 0x01532828, 0x0149a449, + 0x013fed94, 0x0136058a, 0x012bedb1, 0x0121a798, 0x011734d5, 0x010c9704, + 0x0101cfc7, 0x00f6e0c9, 0x00ebcbb9, 0x00e0924d, 0x00d53640, 0x00c9b952, + 0x00be1d48, 0x00b263ed, 0x00a68f10, 0x009aa084, 0x008e9a20, 0x00827dbf, + 0x00764d3e, 0x006a0a7f, 0x005db766, 0x005155d9, 0x0044e7c1, 0x00386f0a, + 0x002bed9e, 0x001f656d, 0x0012d864, 0x00064873}; + +WORD32 ixheaacd_mps_pre_im[64] = { + 0x00064874, 0x0012d865, 0x001f656e, 0x002beda0, 0x00386f0b, 0x0044e7c3, + 0x005155da, 0x005db767, 0x006a0a80, 0x00764d3f, 0x00827dc0, 0x008e9a22, + 0x009aa086, 0x00a68f12, 0x00b263ef, 0x00be1d49, 0x00c9b953, 0x00d53641, + 0x00e0924f, 0x00ebcbbb, 0x00f6e0cb, 0x0101cfc8, 0x010c9705, 0x011734d6, + 0x0121a79a, 0x012bedb2, 0x0136058b, 0x013fed95, 0x0149a44a, 0x01532829, + 0x015c77bc, 0x01659192, 0x016e7445, 0x01771e76, 0x017f8ece, 0x0187c401, + 0x018fbcca, 0x019777ef, 0x019ef43f, 0x01a63092, 0x01ad2bca, 0x01b3e4d4, + 0x01ba5aa6, 0x01c08c42, 0x01c678b3, 0x01cc1f0f, 0x01d17e77, 0x01d69617, + 0x01db6526, 0x01dfeae6, 0x01e426a5, 0x01e817bb, 0x01ebbd8c, 0x01ef178a, + 0x01f2252f, 0x01f4e603, 0x01f7599a, 0x01f97f92, 0x01fb5797, 0x01fce15f, + 0x01fe1caf, 0x01ff0956, 0x01ffa72f, 0x01fff621}; + +WORD32 ixheaacd_mps_post_re[128] = { + 0x7fffffff, 0x7ff62182, 0x7fd8878d, 0x7fa736b3, 0x7f62368e, 0x7f0991c2, + 0x7e9d55fa, 0x7e1d93e8, 0x7d8a5f3d, 0x7ce3ceae, 0x7c29fbea, 0x7b5d0399, + 0x7a7d0555, 0x798a23ab, 0x7884840c, 0x776c4ed3, 0x7641af33, 0x7504d33b, + 0x73b5ebc5, 0x72552c78, 0x70e2cbb8, 0x6f5f02a2, 0x6dca0d03, 0x6c24294e, + 0x6a6d9890, 0x68a69e6b, 0x66cf8109, 0x64e8890d, 0x62f20192, 0x60ec3814, + 0x5ed77c6c, 0x5cb420c0, 0x5a827978, 0x5842dd31, 0x55f5a4ad, 0x539b2ac8, + 0x5133cc6b, 0x4ebfe879, 0x4c3fdfc6, 0x49b41504, 0x471cecb5, 0x447acd1d, + 0x41ce1e2f, 0x3f174981, 0x3c56ba37, 0x398cdcf7, 0x36ba1fd6, 0x33def248, + 0x30fbc50c, 0x2e110a1e, 0x2b1f34a6, 0x2826b8e1, 0x25280c14, 0x2223a47a, + 0x1f19f92e, 0x1c0b821b, 0x18f8b7eb, 0x15e213f2, 0x12c8101a, 0x0fab26d5, + 0x0c8bd306, 0x096a8ff0, 0x0647d921, 0x03242a62, 0xffffffa3, 0xfcdbd4e2, + 0xf9b82624, 0xf6956f55, 0xf3742c3f, 0xf054d871, 0xed37ef2c, 0xea1deb55, + 0xe707475d, 0xe3f47d2e, 0xe0e6061c, 0xdddc5ad1, 0xdad7f338, 0xd7d9466d, + 0xd4e0caa9, 0xd1eef532, 0xcf043a47, 0xcc210d0d, 0xc945df80, 0xc6732261, + 0xc3a94524, 0xc0e8b5dc, 0xbe31e130, 0xbb853244, 0xb8e312ae, 0xb64bea62, + 0xb3c01fa3, 0xb14016f3, 0xaecc3304, 0xac64d4aa, 0xaa0a5ac8, 0xa7bd2247, + 0xa57d8603, 0xa34bdebf, 0xa1288316, 0x9f13c772, 0x9d0dfdf7, 0x9b17767f, + 0x99307e88, 0x97596128, 0x95926708, 0x93dbd64e, 0x9235f29c, 0x90a0fd01, + 0x8f1d33f0, 0x8daad334, 0x8c4a13eb, 0x8afb2c79, 0x89be5085, 0x8893b0ea, + 0x877b7bb4, 0x8675dc1a, 0x8582fa74, 0x84a2fc35, 0x83d603e8, 0x831c3129, + 0x8275a09e, 0x81e26bf8, 0x8162a9ea, 0x80f66e27, 0x809dc95f, 0x8058c93f, + 0x8027786a, 0x8009de7a}; + +WORD32 ixheaacd_mps_post_im[128] = { + 0x00000000, 0x03242ac0, 0x0647d97f, 0x096a904d, 0x0c8bd363, 0x0fab2732, + 0x12c81077, 0x15e2144e, 0x18f8b847, 0x1c0b8277, 0x1f19f989, 0x2223a4d4, + 0x25280c6e, 0x2826b93a, 0x2b1f34fe, 0x2e110a76, 0x30fbc563, 0x33def29e, + 0x36ba202b, 0x398cdd4b, 0x3c56ba89, 0x3f1749d2, 0x41ce1e80, 0x447acd6c, + 0x471ced03, 0x49b41551, 0x4c3fe012, 0x4ebfe8c3, 0x5133ccb3, 0x539b2b0f, + 0x55f5a4f2, 0x5842dd75, 0x5a8279bb, 0x5cb42101, 0x5ed77cab, 0x60ec3851, + 0x62f201cd, 0x64e88947, 0x66cf8141, 0x68a69ea2, 0x6a6d98c4, 0x6c242980, + 0x6dca0d34, 0x6f5f02d0, 0x70e2cbe4, 0x72552ca2, 0x73b5ebed, 0x7504d361, + 0x7641af57, 0x776c4ef5, 0x7884842c, 0x798a23c8, 0x7a7d0571, 0x7b5d03b2, + 0x7c29fc01, 0x7ce3cec3, 0x7d8a5f4f, 0x7e1d93f8, 0x7e9d5608, 0x7f0991ce, + 0x7f623697, 0x7fa736ba, 0x7fd88792, 0x7ff62184, 0x7fffffff, 0x7ff6217f, + 0x7fd88789, 0x7fa736ac, 0x7f623685, 0x7f0991b7, 0x7e9d55ed, 0x7e1d93d7, + 0x7d8a5f2b, 0x7ce3ce9a, 0x7c29fbd3, 0x7b5d0380, 0x7a7d053a, 0x798a238d, + 0x788483ed, 0x776c4eb1, 0x7641af0f, 0x7504d315, 0x73b5eb9d, 0x72552c4e, + 0x70e2cb8b, 0x6f5f0274, 0x6dca0cd3, 0x6c24291c, 0x6a6d985c, 0x68a69e35, + 0x66cf80d1, 0x64e888d4, 0x62f20156, 0x60ec37d6, 0x5ed77c2d, 0x5cb4207f, + 0x5a827936, 0x5842dced, 0x55f5a467, 0x539b2a81, 0x5133cc22, 0x4ebfe82f, + 0x4c3fdf7b, 0x49b414b7, 0x471cec67, 0x447accce, 0x41ce1ddf, 0x3f17492f, + 0x3c56b9e4, 0x398cdca3, 0x36ba1f81, 0x33def1f2, 0x30fbc4b5, 0x2e1109c7, + 0x2b1f344d, 0x2826b888, 0x25280bba, 0x2223a420, 0x1f19f8d3, 0x1c0b81c0, + 0x18f8b78f, 0x15e21395, 0x12c80fbd, 0x0fab2678, 0x0c8bd2a9, 0x096a8f92, + 0x0647d8c3, 0x03242a04}; + +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] = { + 0, 20395592, 0, -78309485, 0, 328528819, 536870911, + 328528819, 0, -78309485, 0, 20395592, 0}; + +WORD32 ixheaacd_cosine[8][13] = { + { + -759250175, -410903263, -46, 410903167, 759250111, 992008063, + 1073741823, 992008063, 759250111, 410903167, -46, -410903263, + -759250175, + }, + { + 759249983, 992008191, 140, -992008063, -759250175, 410903167, + 1073741823, 410903167, -759250175, -992008063, 140, 992008191, + 759249983, + }, + { + 759250367, -992007999, -234, 992008191, -759250047, -410903263, + 1073741823, -410903263, -759250047, 992008191, -234, -992007999, + 759250367, + }, + { + -759249791, 410902815, 328, -410903423, 759250239, -992008127, + 1073741823, -992008127, 759250239, -410903423, 328, 410902815, + -759249791, + }, + { + -759250559, 410903679, -422, -410902911, 759249983, -992008063, + 1073741823, -992008063, 759249983, -410902911, -422, 410903679, + -759250559, + }, + { + 759249599, -992008319, 516, 992007935, -759250303, -410903071, + 1073741823, -410903071, -759250303, 992007935, 516, -992008319, + 759249599, + }, + { + 759250751, 992007807, -610, -992008255, -759249919, 410903359, + 1073741823, 410903359, -759249919, -992008255, -610, 992007807, + 759250751, + }, + {-759249407, -410902399, 704, 410903679, 759250367, 992008191, 1073741823, + 992008191, 759250367, 410903679, 704, -410902399, -759249407}}; + +WORD32 ixheaacd_sine[8][13] = { + { + 759250047, 992008063, 1073741823, 992008127, 759250111, 410903231, 0, + -410903231, -759250111, -992008127, -1073741823, -992008063, -759250047, + }, + { + 759250303, -410903039, -1073741823, -410903295, 759250047, 992008127, 0, + -992008127, -759250047, 410903295, 1073741823, 410903039, -759250303, + }, + { + -759249855, -410903487, 1073741823, -410903039, -759250175, 992008063, + 0, -992008063, 759250175, 410903039, -1073741823, 410903487, 759249855, + }, + { + -759250495, 992008255, -1073741823, 992007999, -759249983, 410903135, 0, + -410903135, 759249983, -992007999, 1073741823, -992008255, 759250495, + }, + { + 759249663, -992007871, 1073741823, -992008191, 759250303, -410903295, 0, + 410903295, -759250303, 992008191, -1073741823, 992007871, -759249663, + }, + { + 759250687, 410902623, -1073741823, 410903551, 759249919, -992008127, 0, + 992008127, -759249919, -410903551, 1073741823, -410902623, -759250687, + }, + { + -759249471, 410903903, 1073741823, 410902783, -759250367, -992008063, 0, + 992008063, 759250367, -410902783, -1073741823, -410903903, 759249471, + }, + {-759250879, -992008447, -1073741823, -992007871, -759249855, -410903039, 0, + 410903039, 759249855, 992007871, 1073741823, 992008447, 759250879}}; + +WORD32 ixheaacd_cosine2[2][13] = { + { + 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, + 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, + 1073741823, + }, + { + 1073741823, -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 new file mode 100644 index 0000000..9a46d5c --- /dev/null +++ b/decoder/ixheaacd_mps_smoothing.c @@ -0,0 +1,213 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" +#include +#include +#include +#include "ixheaacd_constants.h" +#include +#include + +VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing( + ia_mps_dec_state_struct *self) { + int smooth_band; + int delta, one_minus_delta; + + int ps = 0, pb, row, col; + int res_bands = 0; + int *p_smoothing_data; + + if (self->residual_coding) res_bands = self->max_res_bands; + + p_smoothing_data = &self->smoothing_data[ps][res_bands]; + + delta = self->param_slot_diff[ps] * self->inv_smoothing_time[ps]; + one_minus_delta = 1073741824 - delta; + + for (pb = res_bands; pb < self->bs_param_bands; pb++) { + smooth_band = *p_smoothing_data++; + if (smooth_band) { + for (row = 0; row < MAX_M_OUTPUT; row++) { + for (col = 0; col < MAX_M_INPUT; col++) { + self->m1_param_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m1_param_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m1_param_re_prev[pb][row][col])) + << 2; + self->m1_param_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m1_param_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m1_param_im_prev[pb][row][col])) + << 2; + self->m2_decor_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_decor_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_decor_re_prev[pb][row][col])) + << 2; + self->m2_decor_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_decor_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_decor_im_prev[pb][row][col])) + << 2; + self->m2_resid_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_resid_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_resid_re_prev[pb][row][col])) + << 2; + self->m2_resid_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_resid_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_resid_im_prev[pb][row][col])) + << 2; + } + } + } + } + + for (ps = 1; ps < self->num_parameter_sets; ps++) { + delta = self->param_slot_diff[ps] * self->inv_smoothing_time[ps]; + one_minus_delta = 1073741824 - delta; + + p_smoothing_data = &self->smoothing_data[ps][res_bands]; + + for (pb = res_bands; pb < self->bs_param_bands; pb++) { + smooth_band = *p_smoothing_data++; + if (smooth_band) { + for (row = 0; row < MAX_M_OUTPUT; row++) { + for (col = 0; col < MAX_M_INPUT; col++) { + self->m1_param_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m1_param_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m1_param_re[ps - 1][pb][row][col])) + << 2; + self->m1_param_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m1_param_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m1_param_im[ps - 1][pb][row][col])) + << 2; + self->m2_resid_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_resid_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_resid_re[ps - 1][pb][row][col])) + << 2; + self->m2_decor_re[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_decor_re[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_decor_re[ps - 1][pb][row][col])) + << 2; + self->m2_decor_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_decor_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_decor_im[ps - 1][pb][row][col])) + << 2; + self->m2_resid_im[ps][pb][row][col] = + (ixheaacd_mult32(delta, self->m2_resid_im[ps][pb][row][col]) + + ixheaacd_mult32(one_minus_delta, + self->m2_resid_im[ps - 1][pb][row][col])) + << 2; + } + } + } + } + } +} + +#define ONE_BY_128_IN_Q30 (8388608) +#define ONE_IN_Q30 (1073741824) +#define PI_IN_Q27 (421657440) +#define FIFTY_X_PI_BY_180_Q27 (117127067) +#define TWENTY_FIVE_X_PI_BY_180_Q27 (58563533) + +VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self) { + int ps, pb; + int delta, one_minus_delta; + + if (self->opd_smoothing_mode == 0) { + for (pb = 0; pb < self->bs_param_bands; pb++) { + self->opd_smooth.smooth_l_phase[pb] = + self->phase_l_fix[self->num_parameter_sets - 1][pb] >> 1; + self->opd_smooth.smooth_r_phase[pb] = + self->phase_r_fix[self->num_parameter_sets - 1][pb] >> 1; + } + return; + } + for (ps = 0; ps < self->num_parameter_sets; ps++) { + int thr = self->bs_frame.ipd_data.bs_quant_coarse_xxx[ps] + ? FIFTY_X_PI_BY_180_Q27 + : TWENTY_FIVE_X_PI_BY_180_Q27; + + delta = self->param_slot_diff[ps] * ONE_BY_128_IN_Q30; + one_minus_delta = ONE_IN_Q30 - delta; + + for (pb = 0; pb < self->bs_param_bands; pb++) { + int ltemp, rtemp, tmp; + + ltemp = self->phase_l_fix[ps][pb] >> 1; + rtemp = self->phase_r_fix[ps][pb] >> 1; + + while (ltemp > self->opd_smooth.smooth_l_phase[pb] + PI_IN_Q27) + ltemp -= 2 * PI_IN_Q27; + while (ltemp < self->opd_smooth.smooth_l_phase[pb] - PI_IN_Q27) + ltemp += 2 * PI_IN_Q27; + while (rtemp > self->opd_smooth.smooth_r_phase[pb] + PI_IN_Q27) + rtemp -= 2 * PI_IN_Q27; + while (rtemp < self->opd_smooth.smooth_r_phase[pb] - PI_IN_Q27) + rtemp += 2 * PI_IN_Q27; + + self->opd_smooth.smooth_l_phase[pb] = + (ixheaacd_mult32_shl(delta, ltemp) + + ixheaacd_mult32_shl(one_minus_delta, + self->opd_smooth.smooth_l_phase[pb])) + << 1; + self->opd_smooth.smooth_r_phase[pb] = + (ixheaacd_mult32_shl(delta, rtemp) + + ixheaacd_mult32_shl(one_minus_delta, + self->opd_smooth.smooth_r_phase[pb])) + << 1; + + tmp = (ltemp - rtemp) - (self->opd_smooth.smooth_l_phase[pb] - + self->opd_smooth.smooth_r_phase[pb]); + while (tmp > PI_IN_Q27) tmp -= 2 * PI_IN_Q27; + while (tmp < -PI_IN_Q27) tmp += 2 * PI_IN_Q27; + + if (ixheaacd_abs32(tmp) > thr) { + self->opd_smooth.smooth_l_phase[pb] = ltemp; + self->opd_smooth.smooth_r_phase[pb] = rtemp; + } + + while (self->opd_smooth.smooth_l_phase[pb] > 2 * PI_IN_Q27) + self->opd_smooth.smooth_l_phase[pb] -= 2 * PI_IN_Q27; + while (self->opd_smooth.smooth_l_phase[pb] < 0) + self->opd_smooth.smooth_l_phase[pb] += 2 * PI_IN_Q27; + while (self->opd_smooth.smooth_r_phase[pb] > 2 * PI_IN_Q27) + self->opd_smooth.smooth_r_phase[pb] -= 2 * PI_IN_Q27; + while (self->opd_smooth.smooth_r_phase[pb] < 0) + self->opd_smooth.smooth_r_phase[pb] += 2 * PI_IN_Q27; + + self->phase_l_fix[ps][pb] = self->opd_smooth.smooth_l_phase[pb] << 1; + self->phase_r_fix[ps][pb] = self->opd_smooth.smooth_r_phase[pb] << 1; + } + } +} diff --git a/decoder/ixheaacd_mps_temp_process.c b/decoder/ixheaacd_mps_temp_process.c new file mode 100644 index 0000000..32f47c8 --- /dev/null +++ b/decoder/ixheaacd_mps_temp_process.c @@ -0,0 +1,241 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" + +#include "ixheaacd_mps_process.h" + +#include +#include +#include + +#include + +#include "ixheaacd_common_rom.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#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 +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_env_calc.h" +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" + +#define HP_SIZE (9) + +#define STP_LPF_COEFF1 (0.950f) +#define STP_LPF_COEFF2 (0.450f) +#define STP_UPDATE_ENERGY_RATE (32) +#define STP_SCALE_LIMIT (2.82f) +#define STP_DAMP (0.1f) + +#define max(a, b) ((a > b) ? (a) : (b)) +#define min(a, b) ((a < b) ? (a) : (b)) + +static 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] = { + 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, + 9.801e-005f, 0.00012321f, 0.00015625f, 0.00019881f, 0.00024964f, + 0.00032041f, 0.00041209f, 0.00053824f, 0.00070756f, 0.00094249f}; + +static VOID ixheaacd_mps_temp_process_scale_calc(ia_mps_dec_state_struct* self, + WORD32 ts, FLOAT32* scale) { + FLOAT32 dir_energy; + FLOAT32 diff_energy[2]; + FLOAT32 temp; + + WORD32 ch, n; + WORD32 left_ch = 0, right_ch = 1; + + if (self->subband_var.init_flag == 0) { + for (ch = 0; ch < 2; ch++) { + self->subband_var.tp_scale_last[ch] = 1.0f; + self->subband_var.nrg_diff_prev[ch] = 32768 * 32768; + } + + self->subband_var.nrg_dir_prev = 32768 * 32768; + self->subband_var.init_flag = 1; + } + + if (self->subband_var.update_old_ener == STP_UPDATE_ENERGY_RATE) { + self->subband_var.update_old_ener = 1; + self->subband_var.nrg_dir_prev = self->subband_var.nrg_dir; + for (ch = 0; ch < self->out_ch_count; ch++) + self->subband_var.nrg_diff_prev[ch] = self->subband_var.nrg_diff[ch]; + } else + self->subband_var.update_old_ener++; + + dir_energy = 0; + + for (n = 6; n < BP_SIZE; n++) { + FLOAT32 dir_left_re = self->hyb_dir_out[left_ch][ts][n + 7].re; + FLOAT32 dir_right_re = self->hyb_dir_out[right_ch][ts][n + 7].re; + FLOAT32 dir_left_im = self->hyb_dir_out[left_ch][ts][n + 7].im; + FLOAT32 dir_right_im = self->hyb_dir_out[right_ch][ts][n + 7].im; + + temp = ((dir_left_re + dir_right_re) * (dir_left_re + dir_right_re)) + + ((dir_left_im + dir_right_im) * (dir_left_im + dir_right_im)); + dir_energy += temp * ixheaacd_bp[n] * ixheaacd_bp[n] * ixheaacd_gf[n] * + ixheaacd_gf[n]; + } + + self->subband_var.nrg_dir = + (FLOAT32)(STP_LPF_COEFF1 * self->subband_var.nrg_dir + + (1.0 - STP_LPF_COEFF1) * dir_energy); + + dir_energy /= (self->subband_var.nrg_dir_prev + ABS_THR); + + for (ch = 0; ch < self->out_ch_count; ch++) { + diff_energy[ch] = 0; + for (n = 6; n < BP_SIZE; n++) { + FLOAT32 diff_re = self->hyb_diff_out[ch][ts][n + 7].re; + FLOAT32 diff_im = self->hyb_diff_out[ch][ts][n + 7].im; + + temp = (diff_re * diff_re) + (diff_im * diff_im); + diff_energy[ch] += temp * ixheaacd_bp[n] * ixheaacd_bp[n] * + ixheaacd_gf[n] * ixheaacd_gf[n]; + } + + self->subband_var.nrg_diff[ch] = + (FLOAT32)(STP_LPF_COEFF1 * self->subband_var.nrg_diff[ch] + + (1.0 - STP_LPF_COEFF1) * diff_energy[ch]); + diff_energy[ch] /= (self->subband_var.nrg_diff_prev[ch] + ABS_THR); + } + + scale[left_ch] = (FLOAT32)sqrt((dir_energy) / (diff_energy[left_ch] + 1e-9)); + scale[right_ch] = + (FLOAT32)sqrt((dir_energy) / (diff_energy[right_ch] + 1e-9)); + + for (ch = 0; ch < self->out_ch_count; ch++) { + scale[ch] = STP_DAMP + (1 - STP_DAMP) * scale[ch]; + } + + for (ch = 0; ch < self->out_ch_count; ch++) { + scale[ch] = + min(max(scale[ch], (FLOAT32)(1.0 / STP_SCALE_LIMIT)), STP_SCALE_LIMIT); + } + + for (ch = 0; ch < self->out_ch_count; ch++) { + scale[ch] = + (FLOAT32)(STP_LPF_COEFF2 * scale[ch] + + (1.0 - STP_LPF_COEFF2) * self->subband_var.tp_scale_last[ch]); + self->subband_var.tp_scale_last[ch] = scale[ch]; + } +} + +static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) { + FLOAT32 scale[2]; + WORD32 ch, n; + WORD32 no_scaling; + FLOAT32 temp; + const WORD32 ixheaacd_hybrid_to_qmf_map[] = {0, 0, 0, 0, 0, 0, 1, 1, 2, 2}; + + ixheaacd_mps_temp_process_scale_calc(self, ts, scale); + + for (ch = 0; ch < self->out_ch_count; ch++) { + no_scaling = 1; + + if ((self->config->bs_temp_shape_config == 1) || + (self->config->bs_temp_shape_config == 2)) + no_scaling = !self->temp_shape_enable_ch_stp[ch]; + + if (no_scaling == 1) { + for (n = 0; n < self->hyb_band_count; n++) { + self->hyb_dir_out[ch][ts][n].re += self->hyb_diff_out[ch][ts][n].re; + self->hyb_dir_out[ch][ts][n].im += self->hyb_diff_out[ch][ts][n].im; + } + } else { + for (n = 0; n < 10; n++) { + temp = + (FLOAT32)(scale[ch] * ixheaacd_bp[ixheaacd_hybrid_to_qmf_map[n]]); + self->hyb_dir_out[ch][ts][n].re += + (self->hyb_diff_out[ch][ts][n].re * temp); + self->hyb_dir_out[ch][ts][n].im += + (self->hyb_diff_out[ch][ts][n].im * temp); + } + for (; n < HP_SIZE - 3 + 10; n++) { + temp = (FLOAT32)(scale[ch] * ixheaacd_bp[n + 3 - 10]); + self->hyb_dir_out[ch][ts][n].re += + (self->hyb_diff_out[ch][ts][n].re * temp); + self->hyb_dir_out[ch][ts][n].im += + (self->hyb_diff_out[ch][ts][n].im * temp); + } + for (; n < self->hyb_band_count; n++) { + temp = (FLOAT32)(scale[ch]); + self->hyb_dir_out[ch][ts][n].re += + (self->hyb_diff_out[ch][ts][n].re * temp); + self->hyb_dir_out[ch][ts][n].im += + (self->hyb_diff_out[ch][ts][n].im * temp); + } + } + } +} + +VOID ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) { + WORD32 ch, ts, hyb; + + for (ch = 0; ch < self->out_ch_count; ch++) { + for (ts = 0; ts < self->time_slots; ts++) { + for (hyb = 0; hyb < HYBRID_BAND_BORDER; hyb++) { + self->hyb_dir_out[ch][ts][hyb].re += self->hyb_diff_out[ch][ts][hyb].re; + self->hyb_dir_out[ch][ts][hyb].im += self->hyb_diff_out[ch][ts][hyb].im; + self->hyb_diff_out[ch][ts][hyb].re = 0; + self->hyb_diff_out[ch][ts][hyb].im = 0; + } + } + } + + for (ts = 0; ts < self->time_slots; ts++) ixheaacd_mps_subbandtp(self, ts); + + ixheaacd_mps_qmf_hyb_synthesis(self); + + for (ch = 0; ch < self->out_ch_count; ch++) { + ixheaacd_sbr_dec_from_mps(&self->qmf_out_dir[ch][0][0].re, + self->p_sbr_dec[ch], self->p_sbr_frame[ch], + self->p_sbr_header[ch]); + } + + ixheaacd_mps_synt_calc(self); +} diff --git a/decoder/ixheaacd_mps_temp_reshape.c b/decoder/ixheaacd_mps_temp_reshape.c new file mode 100644 index 0000000..428fabd --- /dev/null +++ b/decoder/ixheaacd_mps_temp_reshape.c @@ -0,0 +1,194 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_config.h" + +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_mps_interface.h" +#include + +#define max(a, b) ((a) > (b) ? (a) : (b)) + +#define min(a, b) ((a) < (b) ? (a) : (b)) + +#define DIR_DIFF_IN 0 +#define DOWNMIX_IN 1 + +#define LAMDA (4.0f) +#define GES_ALPHA (0.99637864f) +#define GES_BETA (0.9643691f) + +extern 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) { + WORD32 i; + for (i = 0; i < 3; i++) { + self->guided_env_shaping.avg_energy_prev[i] = 32768.f * 32768.f; + } +} + +static VOID ixheaacd_mps_est_normalized_envelope(ia_mps_dec_state_struct *self, + WORD32 inp, WORD32 ch, + FLOAT32 *env) { + FLOAT32 slot_energy[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS] = {{0}}; + FLOAT32 pb_energy[MAX_PARAMETER_BANDS] = {0}; + FLOAT32 whitening_weight[MAX_PARAMETER_BANDS]; + WORD32 ii, jj, param_band; + + WORD32 k_start = 10; + WORD32 k_stop = 18; + + FLOAT32 total_energy = 0, avg_energy = 0; + + WORD32 ch_offset; + + switch (inp) { + case DIR_DIFF_IN: + ch_offset = 0; + for (ii = 0; ii < self->time_slots; ii++) { + for (jj = 0; jj < self->hyb_band_count; jj++) { + slot_energy[ii] + [ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] += + ((self->hyb_dir_out[ch][ii][jj].re + + self->hyb_diff_out[ch][ii][jj].re) * + (self->hyb_dir_out[ch][ii][jj].re + + self->hyb_diff_out[ch][ii][jj].re)) + + ((self->hyb_dir_out[ch][ii][jj].im + + self->hyb_diff_out[ch][ii][jj].im) * + (self->hyb_dir_out[ch][ii][jj].im + + self->hyb_diff_out[ch][ii][jj].im)); + } + } + break; + case DOWNMIX_IN: + ch_offset = self->out_ch_count; + for (ii = 0; ii < self->time_slots; ii++) { + for (jj = 0; jj < self->hyb_band_count; jj++) { + slot_energy[ii] + [ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] += + self->hyb_in[ch][ii][jj].re * self->hyb_in[ch][ii][jj].re + + self->hyb_in[ch][ii][jj].im * self->hyb_in[ch][ii][jj].im; + } + } + break; + default: + ch_offset = 0; + break; + } + + for (param_band = k_start; param_band <= k_stop; param_band++) + pb_energy[param_band] = + self->guided_env_shaping.pb_energy_prev[ch + ch_offset][param_band]; + + avg_energy = self->guided_env_shaping.avg_energy_prev[ch + ch_offset]; + + for (ii = 0; ii < self->time_slots; ii++) { + total_energy = 0; + for (param_band = k_start; param_band <= k_stop; param_band++) { + pb_energy[param_band] = (1 - GES_ALPHA) * slot_energy[ii][param_band] + + GES_ALPHA * pb_energy[param_band]; + + total_energy += slot_energy[ii][param_band]; + } + total_energy /= (k_stop - k_start + 1); + + total_energy = + (1 - GES_ALPHA) * total_energy + + GES_ALPHA * self->guided_env_shaping.frame_energy_prev[ch + ch_offset]; + + self->guided_env_shaping.frame_energy_prev[ch + ch_offset] = total_energy; + + for (param_band = k_start; param_band <= k_stop; param_band++) { + whitening_weight[param_band] = + total_energy / (pb_energy[param_band] + ABS_THR); + } + + env[ii] = 0; + for (param_band = k_start; param_band <= k_stop; param_band++) { + env[ii] += slot_energy[ii][param_band] * whitening_weight[param_band]; + } + + avg_energy = (1 - GES_BETA) * env[ii] + GES_BETA * avg_energy; + + env[ii] = (FLOAT32)sqrt(env[ii] / (avg_energy + ABS_THR)); + } + + for (param_band = k_start; param_band <= k_stop; param_band++) + self->guided_env_shaping.pb_energy_prev[ch + ch_offset][param_band] = + pb_energy[param_band]; + + self->guided_env_shaping.avg_energy_prev[ch + ch_offset] = avg_energy; +} + +VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self) { + FLOAT32 dir_energy[MAX_TIME_SLOTS]; + FLOAT32 dmx_energy[MAX_TIME_SLOTS]; + WORD32 ch, time_slot, jj; + + WORD32 band_start; + FLOAT32 gain, ratio; + + FLOAT32 amp_direct = 0; + FLOAT32 amp_diff = 0; + FLOAT32 amp_ratio; + + band_start = 6; + + ixheaacd_mps_est_normalized_envelope(self, DOWNMIX_IN, 0, dmx_energy); + + for (ch = 0; ch < self->out_ch_count; ch++) { + ixheaacd_mps_est_normalized_envelope(self, DIR_DIFF_IN, ch, dir_energy); + + if (self->temp_shape_enable_ch_ges[ch]) { + for (time_slot = 0; time_slot < self->time_slots; time_slot++) { + gain = self->env_shape_data[ch][time_slot] * dmx_energy[time_slot] / + (dir_energy[time_slot] + 1e-9f); + + amp_direct = 0; + amp_diff = 0; + + for (jj = band_start; jj < self->hyb_band_count; jj++) { + amp_direct += self->hyb_dir_out[ch][time_slot][jj].re * + self->hyb_dir_out[ch][time_slot][jj].re + + self->hyb_dir_out[ch][time_slot][jj].im * + self->hyb_dir_out[ch][time_slot][jj].im; + + amp_diff += self->hyb_diff_out[ch][time_slot][jj].re * + self->hyb_diff_out[ch][time_slot][jj].re + + self->hyb_diff_out[ch][time_slot][jj].im * + self->hyb_diff_out[ch][time_slot][jj].im; + } + + amp_ratio = (FLOAT32)sqrt(amp_diff / (amp_direct + ABS_THR)); + + ratio = min(max((gain + amp_ratio * (gain - 1)), 1 / LAMDA), LAMDA); + + for (jj = band_start; jj < self->hyb_band_count; jj++) { + self->hyb_dir_out[ch][time_slot][jj].re *= ratio; + self->hyb_dir_out[ch][time_slot][jj].im *= ratio; + } + } + } + } +} diff --git a/decoder/ixheaacd_multichannel.c b/decoder/ixheaacd_multichannel.c new file mode 100644 index 0000000..008a98f --- /dev/null +++ b/decoder/ixheaacd_multichannel.c @@ -0,0 +1,404 @@ +/****************************************************************************** + * * + * 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 + +#include +#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_ops.h" + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_error_codes.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_aac_rom.h" +#include "ixheaacd_pns.h" + +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_headerdecode.h" + +#include "ixheaacd_multichannel.h" +#include + +WORD cblock_decode_huff_symbol(UWORD8 *ptr_read_next, WORD32 bit_pos, + const UWORD16 *huff_ori, WORD16 *input, + WORD32 *readword) + +{ + const UWORD16 *h; + WORD tot_bits; + { + UWORD16 first_offset; + WORD16 sign_ret_val; + UWORD32 read_word1; + + read_word1 = *readword << bit_pos; + + h = (UWORD16 *)(huff_ori); + first_offset = 7; + + h += (read_word1) >> (32 - first_offset); + sign_ret_val = *h; + tot_bits = 0; + + while (sign_ret_val > 0) { + tot_bits += first_offset; + bit_pos += first_offset; + + if ((bit_pos -= 8) >= 0) { + *readword = (*readword << 8) | *ptr_read_next; + ptr_read_next++; + } else { + bit_pos += 8; + } + + read_word1 = (read_word1) << (first_offset); + + first_offset = (sign_ret_val >> 11); + h += sign_ret_val & (0x07FF); + + h += (read_word1) >> (32 - first_offset); + sign_ret_val = *h; + } + + tot_bits += ((sign_ret_val & 0x7fff) >> 11); + bit_pos += ((sign_ret_val & 0x7fff) >> 11); + if ((bit_pos - 8) >= 0) { + *readword = (*readword << 8) | *ptr_read_next; + } + + *input = (sign_ret_val & (0x07FF)) - 60; + } + + return tot_bits; +} + +WORD16 ixheaacd_dec_coupling_channel_element( + ia_handle_bit_buf_struct bs, ia_aac_decoder_struct *aac_handle, + WORD32 samp_rate_idx, ia_aac_dec_tables_struct *ptr_aac_tables, + ixheaacd_misc_tables *common_tables_ptr, WORD *element_index_order, + ia_enhaacplus_dec_ind_cc *ind_channel_info, WORD32 total_channels, + WORD32 frame_size, WORD32 audio_object_type, + ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type) { + WORD32 element_instance_tag; + LOOPIDX c; + + WORD ind_sw_cce_flag, num_coupled_elements; + + WORD num_gain_element_lists = 0; + WORD cc_domain; + WORD gain_element_sign; + WORD gain_element_scale; + + const UWORD16 *hcod_sf = + ptr_aac_tables->pstr_huffmann_tables->huffman_code_book_scl; + const UWORD32 *table_idx = + ptr_aac_tables->pstr_huffmann_tables->huffman_code_book_scl_index; + WORD16 index, length; + + WORD16 error_status = AAC_DEC_OK; + + element_instance_tag = ixheaacd_read_bits_buf(bs, 4); + element_index_order[0] = element_instance_tag; + + ind_sw_cce_flag = ixheaacd_read_bits_buf(bs, 1); + num_coupled_elements = ixheaacd_read_bits_buf(bs, 3); + + for (c = 0; c < MAX_BS_ELEMENT; c++) + ind_channel_info->elements_coupled[c] = -1; + + ind_channel_info->num_coupled_elements = num_coupled_elements; + + for (c = 0; c < (num_coupled_elements + 1); c++) { + num_gain_element_lists++; + + ind_channel_info->cc_target_is_cpe[c] = ixheaacd_read_bits_buf(bs, 1); + ind_channel_info->cc_target_tag_select[c] = ixheaacd_read_bits_buf(bs, 4); + if (ind_channel_info->cc_target_is_cpe[c]) { + ind_channel_info->cc_l[c] = ixheaacd_read_bits_buf(bs, 1); + ind_channel_info->cc_r[c] = ixheaacd_read_bits_buf(bs, 1); + if (ind_channel_info->cc_l[c] && ind_channel_info->cc_r[c]) + num_gain_element_lists++; + ind_channel_info->elements_coupled[c] = 1; + } else + ind_channel_info->elements_coupled[c] = 0; + } + + cc_domain = ixheaacd_read_bits_buf(bs, 1); + gain_element_sign = ixheaacd_read_bits_buf(bs, 1); + gain_element_scale = ixheaacd_read_bits_buf(bs, 2); + + aac_handle->pstr_aac_dec_ch_info[0]->str_ics_info.num_swb_window = 0; + aac_handle->pstr_aac_dec_ch_info[0]->str_ics_info.sampling_rate_index = + samp_rate_idx; + + aac_handle->pstr_aac_dec_ch_info[0]->common_window = 0; + + error_status = ixheaacd_individual_ch_stream( + bs, aac_handle, 1, frame_size, total_channels, audio_object_type, + eld_specific_config, ele_type); + + if (error_status) return error_status; + + ind_channel_info->cc_gain[0] = 1 << 29; + for (c = 1; c < num_gain_element_lists; c++) { + WORD cge; + WORD common_gain_element_present[MAX_BS_ELEMENT]; + WORD16 norm_value; + + if (ind_sw_cce_flag) + cge = 1; + else { + common_gain_element_present[c] = ixheaacd_read_bits_buf(bs, 1); + cge = common_gain_element_present[c]; + error_status = + (WORD)((WORD32)IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE); + } + if (cge) { + UWORD8 *ptr_read_next = bs->ptr_read_next; + WORD32 bit_pos = 7 - bs->bit_pos; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + ixheaacd_huffman_decode(read_word1, &index, &length, hcod_sf, table_idx); + + bit_pos += length; + + ixheaacd_aac_read_byte(&ptr_read_next, &bit_pos, &read_word); + while (bit_pos > 8) + ixheaacd_aac_read_byte(&ptr_read_next, &bit_pos, &read_word); + + bs->ptr_read_next = ptr_read_next; + bs->bit_pos = 7 - bit_pos; + bs->cnt_bits -= length; + + norm_value = index - 60; + if (norm_value == -1) + ind_channel_info->cc_gain[c] = + common_tables_ptr->cc_gain_scale[gain_element_scale]; + else { + int i; + ind_channel_info->cc_gain[c] = + common_tables_ptr->cc_gain_scale[gain_element_scale]; + for (i = 0; i < (-norm_value) - 1; i++) { + ind_channel_info->cc_gain[c] *= + common_tables_ptr->cc_gain_scale[gain_element_scale]; + } + } + } else { + error_status = + (WORD)((WORD32)IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE); + } + } + if (bs->cnt_bits < 0) { + error_status = (WORD16)( + (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } + return error_status; +} + +void ixheaacd_dec_couple_channel(WORD16 *p_time_data, WORD16 *out_samp_cc, + WORD16 frame_size, WORD total_channels, + WORD32 gain_cc) + +{ + WORD i; + WORD16 out_cc; + WORD16 *ptr_out_samp = &out_samp_cc[0]; + for (i = frame_size - 1; i >= 0; i--) { + out_cc = ixheaacd_round16(ixheaacd_shl32_sat( + ixheaacd_mult32x16in32(gain_cc, *ptr_out_samp++), 3)); + *p_time_data = ixheaacd_add16_sat(out_cc, *p_time_data); + p_time_data += total_channels; + } +} + +void ixheaacd_dec_ind_coupling( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD16 *coup_ch_output, + WORD16 frame_size, WORD total_channels, WORD16 *ptr_time_data) + +{ + WORD c, j, k; + WORD l; + WORD coupling_channel; + + WORD16 *out_samp_cc; + + ia_enhaacplus_dec_ind_cc *ind_channel_info; + + { + coupling_channel = p_obj_exhaacplus_dec->aac_config.ui_coupling_channel; + + ind_channel_info = &p_obj_exhaacplus_dec->p_state_aac->ind_cc_info; + + out_samp_cc = coup_ch_output; + + j = 0; + for (c = 0; c < ind_channel_info->num_coupled_elements + 1; c++) { + for (l = 0; l < MAX_BS_ELEMENT; l++) { + if (p_obj_exhaacplus_dec->aac_config.element_type[l] == + ind_channel_info->elements_coupled[c] && + p_obj_exhaacplus_dec->aac_config.element_instance_order[l] == + ind_channel_info->cc_target_tag_select[c]) { + break; + } + } + if (l == MAX_BS_ELEMENT) { + continue; + } + + k = p_obj_exhaacplus_dec->aac_config.slot_element[l]; + + if (ind_channel_info->cc_target_is_cpe[c] == 0) { + WORD16 *p_time_data = &ptr_time_data[k]; + + WORD32 gain_cc = ind_channel_info->cc_gain[j]; + + ixheaacd_dec_couple_channel(p_time_data, out_samp_cc, frame_size, + total_channels, gain_cc); + } + if (ind_channel_info->cc_target_is_cpe[c] == 1) { + if (ind_channel_info->cc_l[c] == 1) { + WORD16 *p_time_data = &ptr_time_data[k]; + + WORD32 gain_cc = ind_channel_info->cc_gain[j]; + + ixheaacd_dec_couple_channel(p_time_data, out_samp_cc, frame_size, + total_channels, gain_cc); + } + + k = p_obj_exhaacplus_dec->aac_config.slot_element[l]; + + if (ind_channel_info->cc_r[c] == 1) { + WORD16 *p_time_data = &ptr_time_data[k + 1]; + WORD32 gain_cc = ind_channel_info->cc_gain[j + 1]; + + ixheaacd_dec_couple_channel(p_time_data, out_samp_cc, frame_size, + total_channels, gain_cc); + } + } + if (ind_channel_info->cc_target_is_cpe[c] == 1) { + j += 2; + } else { + j += 1; + } + } + } +} + +void ixheaacd_dec_downmix_to_stereo( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD16 frame_size, + WORD total_elements, WORD16 *ptr_time_data, WORD total_channels) { + LOOPIDX i, j; + WORD k = 0; + if (5 == total_channels) k = 0; + if (6 == total_channels) k = 1; + if (7 == total_channels) k = 2; + if (8 == total_channels) k = 3; + + for (j = 0; j < frame_size; j++) { + WORD16 temp_l = 0, temp_r = 0; + for (i = 0; i < total_elements; i++) { + if (0 == p_obj_exhaacplus_dec->aac_config.element_type[i] || + 3 == p_obj_exhaacplus_dec->aac_config.element_type[i]) { + temp_l += (WORD16)( + ixheaacd_mult32x16in32( + p_obj_exhaacplus_dec->common_tables->down_mix_martix + [k][0][p_obj_exhaacplus_dec->aac_config.slot_element[i]], + ptr_time_data[j * total_channels + + p_obj_exhaacplus_dec->aac_config + .slot_element[i]]) >> + 14); + + temp_r += (WORD16)( + ixheaacd_mult32x16in32( + p_obj_exhaacplus_dec->common_tables->down_mix_martix + [k][1][p_obj_exhaacplus_dec->aac_config.slot_element[i]], + ptr_time_data[j * total_channels + + p_obj_exhaacplus_dec->aac_config + .slot_element[i]]) >> + 14); + } + if (1 == p_obj_exhaacplus_dec->aac_config.element_type[i]) { + temp_l += (WORD16)( + ixheaacd_mult32x16in32( + p_obj_exhaacplus_dec->common_tables->down_mix_martix + [k][0][p_obj_exhaacplus_dec->aac_config.slot_element[i]], + ptr_time_data[j * total_channels + + p_obj_exhaacplus_dec->aac_config + .slot_element[i]]) >> + 14); + + temp_r += (WORD16)( + ixheaacd_mult32x16in32( + p_obj_exhaacplus_dec->common_tables->down_mix_martix + [k][1] + [p_obj_exhaacplus_dec->aac_config.slot_element[i] + 1], + ptr_time_data[j * total_channels + + p_obj_exhaacplus_dec->aac_config.slot_element[i] + + 1]) >> + 14); + } + } + + ptr_time_data[2 * j] = temp_l; + ptr_time_data[2 * j + 1] = temp_r; + } +} diff --git a/decoder/ixheaacd_multichannel.h b/decoder/ixheaacd_multichannel.h new file mode 100644 index 0000000..2f280c7 --- /dev/null +++ b/decoder/ixheaacd_multichannel.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * * + * 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 IA_EAACP_DEC_MUTLCHANNEL_H +#define IA_EAACP_DEC_MUTLCHANNEL_H + +WORD16 ixheaacd_dec_coupling_channel_element( + ia_handle_bit_buf_struct bs, ia_aac_decoder_struct *aac_handle, + WORD32 sample_rate_idx, ia_aac_dec_tables_struct *ptr_aac_tables, + ixheaacd_misc_tables *common_tables_ptr, WORD *element_index_order, + ia_enhaacplus_dec_ind_cc *ind_channel_info, WORD32 total_channels, + WORD32 frame_size, WORD32 audio_object_type, + ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type); + +void ixheaacd_dec_ind_coupling( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, WORD16 *coup_ch_output, + WORD16 frame_size, WORD total_channels, WORD16 *ptr_time_data); + +void ixheaacd_dec_downmix_to_stereo( + ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, WORD16 frame_size, + WORD total_elements, WORD16 *ptr_time_data, WORD total_channels); + +#endif /* IA_EAACP_DEC_MUTLCHANNEL_H */ \ No newline at end of file diff --git a/decoder/ixheaacd_pns.h b/decoder/ixheaacd_pns.h new file mode 100644 index 0000000..ec6c4c9 --- /dev/null +++ b/decoder/ixheaacd_pns.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PNS_H +#define IXHEAACD_PNS_H + +#define PNS_BAND_FLAGS_SIZE 16 +#define PNS_BAND_FLAGS_MASK \ + ((WORD16)((((WORD16)1) << PNS_BAND_FLAGS_SHIFT) - 1)) +#define PNS_BAND_FLAGS_SHIFT 3 + +#define PNS_SCALE_MANT_TAB_SIZE 4 +#define PNS_SCALE_MANT_TAB_MASK (PNS_SCALE_MANT_TAB_SIZE - 1) +#define PNS_SCALE_MANT_TAB_SCALING -4 + +#define PNS_SCALEFACTOR_SCALING 2 + +#define PNS_SPEC_SCALE 3 + +typedef struct { + UWORD8 correlated[PNS_BAND_FLAGS_SIZE]; + WORD32 random_vector[PNS_BAND_FLAGS_SIZE * 8]; +} ia_pns_correlation_info_struct; + +typedef struct { + WORD32 current_seed; + WORD16 pns_frame_number; +} ia_pns_rand_vec_struct; + +typedef struct { + UWORD8 pns_used[PNS_BAND_FLAGS_SIZE * 8]; + WORD16 noise_energy; + UWORD16 pns_active; +} ia_pns_info_struct; + +#endif /* #ifndef IXHEAACD_PNS_H */ diff --git a/decoder/ixheaacd_pns_js_thumb.c b/decoder/ixheaacd_pns_js_thumb.c new file mode 100644 index 0000000..d6dfae7 --- /dev/null +++ b/decoder/ixheaacd_pns_js_thumb.c @@ -0,0 +1,441 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include +#include "string.h" +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_error_codes.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_aac_imdct.h" +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_cnst.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_block.h" + +#include "ixheaacd_channel.h" + +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_aacdec.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_function_selector.h" + +#include +#include +#include + +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 = + ptr_aac_dec_channel_info->pstr_pns_corr_info; + + return ((ptr_corr_info->correlated[(pns_band >> PNS_BAND_FLAGS_SHIFT)] >> + (pns_band & PNS_BAND_FLAGS_MASK)) & + 1); +} + +VOID ixheaacd_gen_rand_vec(WORD32 scale, WORD shift, WORD32 *ptr_spec_coef, + WORD32 sfb_width, WORD32 *seed) { + WORD nrg_scale; + WORD32 nrg = 0; + WORD32 *spec = ptr_spec_coef; + WORD32 sfb; + + for (sfb = 0; sfb <= sfb_width; sfb++) { + *seed = (WORD32)(((WORD64)1664525 * (WORD64)(*seed)) + (WORD64)1013904223); + + *spec = (*seed >> 3); + + nrg = ixheaacd_add32_sat(nrg, ixheaacd_mult32_shl_sat(*spec, *spec)); + + spec++; + } + + nrg_scale = ixheaacd_norm32(nrg); + + if (nrg_scale > 0) { + nrg_scale &= ~1; + nrg = ixheaacd_shl32_sat(nrg, nrg_scale); + shift = shift - (nrg_scale >> 1); + } + + nrg = ixheaacd_sqrt(nrg); + scale = ixheaacd_div32_pos_normb(scale, nrg); + + spec = ptr_spec_coef; + + for (sfb = 0; sfb <= sfb_width; sfb++) { + *spec = ixheaacd_shr32_dir_sat_limit(ixheaacd_mult32_shl_sat(*spec, scale), + shift); + spec++; + } +} + +VOID ixheaacd_pns_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], WORD32 channel, + ia_aac_dec_tables_struct *ptr_aac_tables) { + ia_pns_info_struct *ptr_pns_info = + &ptr_aac_dec_channel_info[channel]->str_pns_info; + ia_ics_info_struct *ptr_ics_info = + &ptr_aac_dec_channel_info[channel]->str_ics_info; + WORD32 *ptr_scale_mant_tab = + ptr_aac_tables->pstr_block_tables->scale_mant_tab; + + if (ptr_pns_info->pns_active) { + const WORD16 *swb_offset = + ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence] + .sfb_index; + + WORD num_win_group, grp_len, sfb; + WORD32 *spec = &ptr_aac_dec_channel_info[channel]->ptr_spec_coeff[0]; + + for (num_win_group = 0; num_win_group < ptr_ics_info->num_window_groups; + num_win_group++) { + grp_len = ptr_ics_info->window_group_length[num_win_group]; + + for (grp_len = 0; + grp_len < ptr_ics_info->window_group_length[num_win_group]; + grp_len++) { + for (sfb = 0; sfb < ptr_ics_info->max_sfb; sfb++) { + WORD16 pns_band = ((num_win_group << 4) + sfb); + + if (ptr_aac_dec_channel_info[channel] + ->str_pns_info.pns_used[pns_band]) { + WORD32 scale_mant; + WORD32 scale_exp; + WORD32 sfb_width = swb_offset[sfb + 1] - swb_offset[sfb] - 1; + WORD32 *ptr_spec = &spec[swb_offset[sfb]]; + + scale_mant = ptr_scale_mant_tab[ptr_aac_dec_channel_info[channel] + ->ptr_scale_factor[pns_band] & + PNS_SCALE_MANT_TAB_MASK]; + scale_exp = add_d(sub_d(31, (ptr_aac_dec_channel_info[channel] + ->ptr_scale_factor[pns_band] >> + PNS_SCALEFACTOR_SCALING)), + PNS_SCALE_MANT_TAB_SCALING); + + if (ixheaacd_is_correlation(ptr_aac_dec_channel_info[LEFT], + pns_band)) { + if (channel == 0) { + ptr_aac_dec_channel_info[LEFT] + ->pstr_pns_corr_info->random_vector[pns_band] = + ptr_aac_dec_channel_info[LEFT] + ->pstr_pns_rand_vec_data->current_seed; + + ixheaacd_gen_rand_vec( + scale_mant, scale_exp, ptr_spec, sfb_width, + &(ptr_aac_dec_channel_info[LEFT] + ->pstr_pns_rand_vec_data->current_seed)); + } + + else { + ixheaacd_gen_rand_vec( + scale_mant, scale_exp, ptr_spec, sfb_width, + &(ptr_aac_dec_channel_info[LEFT] + ->pstr_pns_corr_info->random_vector[pns_band])); + } + + } + + else { + ixheaacd_gen_rand_vec( + scale_mant, scale_exp, ptr_spec, sfb_width, + &(ptr_aac_dec_channel_info[LEFT] + ->pstr_pns_rand_vec_data->current_seed)); + } + } + } + + spec += 128; + } + } + } + + if (channel == 0) { + ptr_aac_dec_channel_info[0]->pstr_pns_rand_vec_data->pns_frame_number++; + } +} + +VOID ixheaacd_tns_decode_coef(const ia_filter_info_struct *filter, + WORD16 *parcor_coef, + ia_aac_dec_tables_struct *ptr_aac_tables) { + WORD order, resolution; + WORD16 *ptr_par_coef = parcor_coef; + WORD16 *tns_coeff_ptr; + WORD8 ixheaacd_drc_offset = 4; + WORD8 *ptr_coef = (WORD8 *)filter->coef; + + resolution = filter->resolution; + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff3_16; + + if (resolution) { + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff4_16; + ixheaacd_drc_offset = ixheaacd_drc_offset << 1; + } + + for (order = 0; order < filter->order; order++) { + WORD8 temp = *ptr_coef++; + *ptr_par_coef++ = tns_coeff_ptr[temp + ixheaacd_drc_offset]; + } +} + +VOID ixheaacd_tns_decode_coef_ld(const ia_filter_info_struct *filter, + WORD32 *parcor_coef, + ia_aac_dec_tables_struct *ptr_aac_tables) { + WORD order, resolution; + WORD32 *ptr_par_coef = parcor_coef; + WORD32 *tns_coeff_ptr; + WORD8 offset = 4; + WORD8 *ptr_coef = (WORD8 *)filter->coef; + + resolution = filter->resolution; + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff3; + + if (resolution) { + tns_coeff_ptr = ptr_aac_tables->pstr_block_tables->tns_coeff4; + offset = offset << 1; + } + + for (order = 0; order < filter->order; order++) { + WORD8 temp = *ptr_coef++; + *ptr_par_coef++ = tns_coeff_ptr[temp + offset]; + } +} + +VOID ixheaacd_aac_tns_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 num_ch, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 object_type, + WORD32 ar_flag, WORD32 *predicted_spectrum) { + WORD i; + WORD16 scale_lpc; + + ia_tns_info_aac_struct *ptr_tns_info = + &ptr_aac_dec_channel_info->str_tns_info; + WORD32 *spec = ptr_aac_dec_channel_info->ptr_spec_coeff; + WORD32 *scratch_buf = ptr_aac_dec_channel_info->scratch_buf_ptr; + + WORD win, filt, start, stop, size, scale_spec; + ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; + WORD num_window, tns_max_bands, win_seq; + WORD position; + + WORD32 parcor_coef[MAX_ORDER + 1]; + WORD16 parcor_coef_16[MAX_ORDER + 1]; + + WORD32 lpc_coef[MAX_ORDER + 1]; + WORD16 lpc_coef_16[MAX_ORDER + 1]; + + const WORD16 *ptr_sfb_table; + + win_seq = ptr_ics_info->window_sequence == 0 + ? 0 + : (ptr_ics_info->window_sequence % 2 == 0); + + if (ar_flag) + spec = ptr_aac_dec_channel_info->ptr_spec_coeff; + else { + spec = predicted_spectrum; + } + + if (object_type == AOT_ER_AAC_ELD || object_type == AOT_ER_AAC_LD || + object_type == AOT_AAC_LTP) { + if (512 == ptr_ics_info->frame_length) { + tns_max_bands = + ptr_aac_tables->pstr_block_tables + ->tns_max_bands_tbl_ld[ptr_ics_info->sampling_rate_index]; + win_seq = 1; + num_window = win_seq; + } else if (480 == ptr_ics_info->frame_length) { + tns_max_bands = + ptr_aac_tables->pstr_block_tables + ->tns_max_bands_tbl_480[ptr_ics_info->sampling_rate_index]; + win_seq = 1; + num_window = win_seq; + } else { + tns_max_bands = + ptr_aac_tables->pstr_block_tables + ->tns_max_bands_tbl[ptr_ics_info->sampling_rate_index][win_seq]; + + num_window = win_seq ? 8 : 1; + } + } else { + tns_max_bands = + ptr_aac_tables->pstr_block_tables + ->tns_max_bands_tbl[ptr_ics_info->sampling_rate_index][win_seq]; + + num_window = win_seq ? 8 : 1; + } + + ptr_sfb_table = + ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence].sfb_index; + + for (win = 0; win < num_window; win++) { + WORD n_filt = ptr_tns_info->n_filt[win]; + + for (filt = 0; filt < n_filt; filt++) { + ia_filter_info_struct *filter = &ptr_tns_info->str_filter[win][filt]; + + if (filter->order <= 0) { + continue; + } + + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP) || + (num_ch > 2)) { + ixheaacd_tns_decode_coefficients(filter, parcor_coef, ptr_aac_tables); + + } else { + ixheaacd_tns_decode_coef(filter, parcor_coef_16, ptr_aac_tables); + } + + start = ixheaacd_min32(ixheaacd_min32(filter->start_band, tns_max_bands), + ptr_ics_info->max_sfb); + + start = ptr_sfb_table[start]; + + stop = ixheaacd_min32(ixheaacd_min32(filter->stop_band, tns_max_bands), + ptr_ics_info->max_sfb); + + stop = ptr_sfb_table[stop]; + + size = (stop - start); + + if (size <= 0) { + continue; + } + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP) || + (num_ch > 2)) { + ixheaacd_tns_parcor_to_lpc(parcor_coef, lpc_coef, &scale_lpc, + filter->order); + + } else { + (*ixheaacd_tns_parcor_lpc_convert)(parcor_coef_16, lpc_coef_16, + &scale_lpc, filter->order); + } + + { + WORD32 *ptr_tmp = spec + (win << 7) + start; + scale_spec = (*ixheaacd_calc_max_spectral_line)(ptr_tmp, size); + } + + if (filter->direction == -1) { + position = stop - 1; + } else { + position = start; + } + + if ((num_ch <= 2) && + ((object_type != AOT_ER_AAC_LD) && (object_type != AOT_AAC_LTP))) + scale_spec = ((scale_spec - 4) - scale_lpc); + else { + if (scale_spec > 17) + scale_spec = ((scale_spec - 6) - scale_lpc); + else if (scale_spec > 11) + scale_spec = ((scale_spec - 5) - scale_lpc); + else + scale_spec = ((scale_spec - 4) - scale_lpc); + } + + if (scale_spec > 0) { + scale_spec = ixheaacd_min32(scale_spec, 31); + + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP) || + (num_ch > 2)) { + if (ar_flag) + (*ixheaacd_tns_ar_filter_fixed)(&spec[(win << 7) + position], size, + filter->direction, + (WORD32 *)lpc_coef, filter->order, + (WORD32)scale_lpc, scale_spec); + else + ixheaacd_tns_ma_filter_fixed_ld(&spec[(win << 7) + position], size, + filter->direction, lpc_coef, + filter->order, scale_lpc); + + } else { + if (object_type == AOT_ER_AAC_ELD) scale_spec = scale_spec - 1; + + (*ixheaacd_tns_ar_filter)(&spec[(win << 7) + position], size, + filter->direction, lpc_coef_16, + filter->order, (WORD32)scale_lpc, + scale_spec, scratch_buf); + } + + } + + else { + WORD32 *ptr_tmp = spec + (win << 7) + start; + + scale_spec = -scale_spec; + scale_spec = ixheaacd_min32(scale_spec, 31); + + for (i = size; i != 0; i--) { + *ptr_tmp = (*ptr_tmp >> scale_spec); + ptr_tmp++; + } + + if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP) || + num_ch > 2) { + if (ar_flag) + (*ixheaacd_tns_ar_filter_fixed)( + &spec[(win << 7) + position], size, filter->direction, + (WORD32 *)lpc_coef, filter->order, scale_lpc, 0); + + else + ixheaacd_tns_ma_filter_fixed_ld(&spec[(win << 7) + position], size, + filter->direction, lpc_coef, + filter->order, scale_lpc); + } else { + if (object_type == AOT_ER_AAC_ELD) { + scale_lpc = scale_lpc - 1; + } + (*ixheaacd_tns_ar_filter)(&spec[(win << 7) + position], size, + filter->direction, lpc_coef_16, + filter->order, scale_lpc, 0, scratch_buf); + } + + ptr_tmp = spec + (win << 7) + start; + + for (i = size; i != 0; i--) { + *ptr_tmp = (*ptr_tmp << scale_spec); + ptr_tmp++; + } + } + } + } +} diff --git a/decoder/ixheaacd_pred_vec_block.c b/decoder/ixheaacd_pred_vec_block.c new file mode 100644 index 0000000..7831d07 --- /dev/null +++ b/decoder/ixheaacd_pred_vec_block.c @@ -0,0 +1,239 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_pvc_rom.h" + +static VOID ixheaacd_pvc_sb_parsing(ia_pvc_data_struct *ptr_pvc_data, + WORD16 first_bnd_idx, FLOAT32 *p_qmfh) { + WORD32 ksg, k; + WORD32 start_band, end_band; + WORD32 time_slot; + + FLOAT32 *p_sbr_range_esg = &ptr_pvc_data->sbr_range_esg_arr[0]; + + for (time_slot = 0; time_slot < PVC_NUM_TIME_SLOTS; time_slot++) { + start_band = first_bnd_idx; + end_band = start_band + ptr_pvc_data->nb_high_per_grp - 1; + + for (ksg = 0; ksg < ptr_pvc_data->nb_high; ksg++) { + for (k = start_band; k <= end_band; k++) { + p_qmfh[k] = (FLOAT32)pow(10.0f, (p_sbr_range_esg[ksg] / 10.0)); + } + start_band += ptr_pvc_data->nb_high_per_grp; + if (ksg >= ptr_pvc_data->nb_high - 2) { + end_band = SBR_NUM_QMF_BANDS - 1; + } else { + end_band = start_band + ptr_pvc_data->nb_high_per_grp - 1; + if (end_band >= SBR_NUM_QMF_BANDS - 1) { + end_band = SBR_NUM_QMF_BANDS - 1; + } + } + } + p_sbr_range_esg = p_sbr_range_esg + 8; + p_qmfh = p_qmfh + SBR_NUM_QMF_BANDS; + } + return; +} + +static VOID ixheaacd_pvc_qmf_grouping(ia_pvc_data_struct *ptr_pvc_data, + WORD16 first_bnd_idx, FLOAT32 *p_qmf_ener, + WORD32 first_pvc_timeslot) { + WORD32 ksg, time_slot, ib; + WORD32 lbw, start_band, end_band; + FLOAT32 esg; + FLOAT32 *p_esg = (FLOAT32 *)ptr_pvc_data->esg; + + lbw = 8 / ptr_pvc_data->pvc_rate; + + for (time_slot = 0; time_slot < PVC_NUM_TIME_SLOTS; time_slot++) { + for (ksg = 0; ksg < PVC_NB_LOW; ksg++) { + start_band = first_bnd_idx - lbw * PVC_NB_LOW + lbw * ksg; + end_band = start_band + lbw - 1; + if (start_band >= 0) { + esg = 0.0f; + for (ib = start_band; ib <= end_band; ib++) { + esg += p_qmf_ener[ib]; + } + esg = esg / lbw; + } else { + esg = PVC_ESG_MIN_VAL; + } + + if (esg > PVC_ESG_MIN_VAL) { + p_esg[(time_slot + 16 - 1) * 3 + ksg] = 10 * ((FLOAT32)log10(esg)); + } else { + p_esg[(time_slot + 16 - 1) * 3 + ksg] = PVC_10LOG10_ESG_MIN_VAL; + } + } + p_qmf_ener = p_qmf_ener + SBR_NUM_QMF_BANDS_2; + } + + if ((ptr_pvc_data->prev_pvc_flg == 0) || + ((first_bnd_idx * ptr_pvc_data->pvc_rate) != + (ptr_pvc_data->prev_first_bnd_idx * ptr_pvc_data->prev_pvc_rate))) { + for (time_slot = 0; time_slot < 16 - 1 + first_pvc_timeslot; time_slot++) { + for (ksg = 0; ksg < PVC_NB_LOW; ksg++) { + p_esg[time_slot * 3 + ksg] = + p_esg[(16 - 1 + first_pvc_timeslot) * 3 + ksg]; + } + } + } + + return; +} + +static VOID ixheaacd_pvc_time_smoothing(ia_pvc_data_struct *ptr_pvc_data) { + WORD32 time_slot; + FLOAT32 *p_smooth_esg = (FLOAT32 *)&ptr_pvc_data->smooth_esg_arr[0]; + for (time_slot = 0; time_slot < PVC_NUM_TIME_SLOTS; time_slot++) { + WORD32 ksg, time_slot_idx; + FLOAT32 *p_esg = (FLOAT32 *)&ptr_pvc_data->esg[time_slot + 16 - 1][2]; + FLOAT32 *p_smth_wind_coeff = (FLOAT32 *)&ptr_pvc_data->p_smth_wind_coeff[0]; + memset(p_smooth_esg, (WORD32)0.f, sizeof(FLOAT32) * PVC_NB_LOW); + for (time_slot_idx = 0; time_slot_idx < ptr_pvc_data->num_time_slots; + time_slot_idx++) { + ksg = PVC_NB_LOW - 1; + for (; ksg >= 0; ksg--) { + p_smooth_esg[ksg] += (*p_esg) * (*p_smth_wind_coeff); + p_esg--; + } + p_smth_wind_coeff++; + } + p_smooth_esg = p_smooth_esg + 3; + } + return; +} + +static VOID ixheaacd_pvc_pred_env_sf(ia_pvc_data_struct *ptr_pvc_data) { + WORD32 ksg, kb; + WORD32 tab_1_index, tab_2_index; + WORD32 time_slot; + WORD8 *pred_tab_1, *pred_tab_2; + + FLOAT32 temp; + FLOAT32 *p_smooth_esg = &ptr_pvc_data->smooth_esg_arr[0]; + FLOAT32 *p_sbr_range_esg = &ptr_pvc_data->sbr_range_esg_arr[0]; + + for (time_slot = 0; time_slot < PVC_NUM_TIME_SLOTS; time_slot++) { + tab_2_index = ptr_pvc_data->pvc_id[time_slot]; + + if (tab_2_index < ptr_pvc_data->p_pvc_id_boundary[0]) { + tab_1_index = 0; + } else if (tab_2_index < ptr_pvc_data->p_pvc_id_boundary[1]) { + tab_1_index = 1; + } else { + tab_1_index = 2; + } + + pred_tab_1 = + (WORD8 *)(&(ptr_pvc_data->p_pred_coeff_tab_1[tab_1_index * PVC_NB_LOW * + ptr_pvc_data->nb_high])); + pred_tab_2 = (WORD8 *)(&( + ptr_pvc_data->p_pred_coeff_tab_2[tab_2_index * ptr_pvc_data->nb_high])); + + for (ksg = 0; ksg < ptr_pvc_data->nb_high; ksg++) { + temp = + (FLOAT32)(WORD8)(*(pred_tab_2++)) * ptr_pvc_data->p_q_fac[PVC_NB_LOW]; + p_sbr_range_esg[ksg] = temp; + } + for (kb = 0; kb < PVC_NB_LOW; kb++) { + for (ksg = 0; ksg < ptr_pvc_data->nb_high; ksg++) { + temp = (FLOAT32)(WORD8)(*(pred_tab_1++)) * ptr_pvc_data->p_q_fac[kb]; + p_sbr_range_esg[ksg] += temp * p_smooth_esg[kb]; + } + } + p_smooth_esg = p_smooth_esg + 3; + p_sbr_range_esg = p_sbr_range_esg + 8; + } + + return; +} + +WORD32 ixheaacd_pvc_process(ia_pvc_data_struct *ptr_pvc_data, + WORD16 first_bnd_idx, WORD32 first_pvc_timeslot, + FLOAT32 *p_qmf_ener, FLOAT32 *p_qmfh) { + switch (ptr_pvc_data->pvc_mode) { + case 1: + ptr_pvc_data->nb_high = PVC_NB_HIGH_MODE1; + ptr_pvc_data->nb_high_per_grp = 8 / ptr_pvc_data->pvc_rate; + ptr_pvc_data->p_pred_coeff_tab_1 = + (WORD8 *)ixheaacd_pred_coeff_table_1_mode_1; + ptr_pvc_data->p_pred_coeff_tab_2 = + (WORD8 *)ixheaacd_pred_coeff_table_2_mode_1; + ptr_pvc_data->p_pvc_id_boundary = + (UWORD8 *)ixheaacd_pred_coeff_pvc_id_boundaries_1; + ptr_pvc_data->p_q_fac = (FLOAT32 *)ixheaacd_q_factor_table_mode_1; + if (ptr_pvc_data->ns_mode) { + ptr_pvc_data->num_time_slots = 4; + ptr_pvc_data->p_smth_wind_coeff = + (FLOAT32 *)ixheaacd_pvc_smoothing_wind_tab_ns4; + } else { + ptr_pvc_data->num_time_slots = 16; + ptr_pvc_data->p_smth_wind_coeff = + (FLOAT32 *)ixheaacd_pvc_smoothing_wind_tab_ns16; + } + break; + case 2: + ptr_pvc_data->nb_high = PVC_NB_HIGH_MODE2; + ptr_pvc_data->nb_high_per_grp = 12 / ptr_pvc_data->pvc_rate; + ptr_pvc_data->p_pred_coeff_tab_1 = + (WORD8 *)ixheaacd_pred_coeff_table_1_mode_2; + ptr_pvc_data->p_pred_coeff_tab_2 = + (WORD8 *)ixheaacd_pred_coeff_table_2_mode_2; + ptr_pvc_data->p_pvc_id_boundary = + (UWORD8 *)ixheaacd_pred_coeff_pvc_id_boundaries_2; + ptr_pvc_data->p_q_fac = (FLOAT32 *)ixheaacd_q_factor_table_mode_2; + if (ptr_pvc_data->ns_mode) { + ptr_pvc_data->num_time_slots = 3; + ptr_pvc_data->p_smth_wind_coeff = + (FLOAT32 *)ixheaacd_pvc_smoothing_wind_tab_ns3; + } else { + ptr_pvc_data->num_time_slots = 12; + ptr_pvc_data->p_smth_wind_coeff = + (FLOAT32 *)ixheaacd_pvc_smoothing_wind_tab_ns12; + } + break; + default: + return -1; + } + ptr_pvc_data->prev_pvc_id = ptr_pvc_data->pvc_id[PVC_NUM_TIME_SLOTS - 1]; + + ixheaacd_pvc_qmf_grouping(ptr_pvc_data, first_bnd_idx, p_qmf_ener, + first_pvc_timeslot); + + ixheaacd_pvc_time_smoothing(ptr_pvc_data); + + ixheaacd_pvc_pred_env_sf(ptr_pvc_data); + + ixheaacd_pvc_sb_parsing(ptr_pvc_data, first_bnd_idx, p_qmfh); + + memcpy((FLOAT32 *)(&ptr_pvc_data->esg[0][0]), + (FLOAT32 *)(&ptr_pvc_data->esg[PVC_NUM_TIME_SLOTS][0]), + sizeof(FLOAT32) * (PVC_NUM_TIME_SLOTS - 1) * 3); + + return 0; +} diff --git a/decoder/ixheaacd_process.c b/decoder/ixheaacd_process.c new file mode 100644 index 0000000..1896f24 --- /dev/null +++ b/decoder/ixheaacd_process.c @@ -0,0 +1,419 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#include +#include +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_common_rom.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pulsedata.h" +#include "ixheaacd_pns.h" + +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_audioobjtypes.h" +#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_mps_interface.h" +#include "ixheaacd_struct_def.h" +#include "ixheaacd_config.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_struct.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_bit_extract.h" +#include "ixheaacd_create.h" + +#include "ixheaacd_func_def.h" +#include "ixheaacd_mps_interface.h" +#include "ixheaacd_mps_polyphase.h" + +#include "ixheaacd_defines.h" + +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" + +#define MAXNRSBRELEMENTS 6 + +VOID ixheaacd_allocate_sbr_scr(ia_sbr_scr_struct *sbr_scratch_struct, + VOID *base_scratch_ptr, VOID *output_ptr, + WORD total_elements, WORD ch_fac, + WORD32 object_type); + +WORD16 ixheaacd_applysbr( + ia_handle_sbr_dec_inst_struct self, + ia_aac_dec_sbr_bitstream_struct *p_sbr_bit_stream, WORD16 *core_sample_buf, + WORD16 *codec_num_channels, FLAG frame_status, FLAG down_samp_flag, + FLAG down_mix_flag, ia_sbr_scr_struct *sbr_scratch_struct, WORD32 ps_enable, + WORD32 ch_fac, WORD32 slot_element, ia_bit_buf_struct *it_bit_buff, + ia_drc_dec_struct *pstr_drc_dec, WORD eld_sbr_flag, WORD32 object_type); + +WORD16 ixheaacd_esbr_process(ia_usac_data_struct *usac_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 stereo_config_idx, WORD16 num_channels, + WORD32 audio_object_type) { + WORD16 err_code; + 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; + + ia_sbr_scr_struct sbr_scratch_struct; + ixheaacd_allocate_sbr_scr(&sbr_scratch_struct, + usac_data->sbr_scratch_mem_base, NULL, 2, 1, + audio_object_type); + + self->usac_independency_flag = usac_data->usac_independency_flg; + + self->time_sample_buf[0] = usac_data->time_sample_vector[0]; + self->time_sample_buf[1] = usac_data->time_sample_vector[1]; + self->stereo_config_idx = stereo_config_idx; + + self->sbr_mode = usac_data->sbr_mode; + self->aot_usac_flag = usac_data->usac_flag; + + 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); + + usac_data->sbr_mode = self->sbr_mode; + + return err_code; +} + +static VOID ixheaacd_sbr_ext_data_read( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_sbr_bitstream_struct *esbr_bit_str) { + WORD32 count = 0; + WORD32 read_bits = 0; + WORD32 unaligned_bits = 0; + WORD32 cnt_bits_in; + + cnt_bits_in = it_bit_buff->cnt_bits; + count = (it_bit_buff->cnt_bits) >> 3; + if (count > 0) { + if ((count < MAXSBRBYTES) && + (esbr_bit_str->no_elements < MAXNRSBRELEMENTS)) { + esbr_bit_str->str_sbr_ele[esbr_bit_str->no_elements].extension_type = + EXT_SBR_DATA; + esbr_bit_str->str_sbr_ele[esbr_bit_str->no_elements].size_payload = count; + + read_bits = count << 3; + + unaligned_bits = (cnt_bits_in - read_bits); + if (unaligned_bits > 0 && unaligned_bits < 8) { + count++; + esbr_bit_str->str_sbr_ele[esbr_bit_str->no_elements].size_payload = + count; + } + esbr_bit_str->no_elements += 1; + } + } +} + +static VOID ixheaacd_read_ext_element( + UWORD32 usac_ext_element_default_length, + UWORD32 usac_ext_element_payload_frag, ia_bit_buf_struct *it_bit_buff +#ifdef ENABLE_DRC + , + ia_usac_decoder_config_struct *pstr_usac_dec_config, WORD32 elem_idx +#endif + ) { + UWORD32 usac_ext_element_present; + UWORD32 usac_ext_element_use_dft_length; + UWORD32 pay_load_length, tmp; +#ifdef ENABLE_DRC + UWORD32 i; +#endif + usac_ext_element_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (usac_ext_element_present) { + usac_ext_element_use_dft_length = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (usac_ext_element_use_dft_length) { + pay_load_length = usac_ext_element_default_length; + } else { + pay_load_length = ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (pay_load_length == 255) { + WORD32 val_add = 0; + val_add = ixheaacd_read_bits_buf(it_bit_buff, 16); + pay_load_length = (UWORD32)((WORD32)pay_load_length + val_add - 2); + } + } + + if (pay_load_length > 0) { + if (usac_ext_element_payload_frag) + tmp = ixheaacd_read_bits_buf(it_bit_buff, 2); + +#ifdef ENABLE_DRC + 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] = + ixheaacd_read_bits_buf(it_bit_buff, 8); + } + pstr_usac_dec_config->usac_ext_gain_payload_len += pay_load_length; + } else { +#endif + + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_read_next + pay_load_length; + it_bit_buff->cnt_bits = + it_bit_buff->cnt_bits - (WORD32)(pay_load_length * 8); + +#ifdef ENABLE_DRC + } +#endif + } + } +} + +static VOID ixheaacd_sbr_ele_type_set( + ia_aac_dec_sbr_bitstream_struct *esbr_bit_str0, + ia_aac_dec_sbr_bitstream_struct *esbr_bit_str1, WORD32 ele_id, + WORD32 st_config_idx) { + if (ele_id == ID_USAC_SCE) { + esbr_bit_str0->str_sbr_ele[esbr_bit_str0->no_elements].sbr_ele_id = + SBR_ID_SCE; + esbr_bit_str1->str_sbr_ele[esbr_bit_str1->no_elements].sbr_ele_id = + SBR_ID_SCE; + } + if (ele_id == ID_USAC_CPE) { + if ((st_config_idx == 0) || (st_config_idx == 3)) { + esbr_bit_str0->str_sbr_ele[esbr_bit_str0->no_elements].sbr_ele_id = + SBR_ID_CPE; + esbr_bit_str1->str_sbr_ele[esbr_bit_str1->no_elements].sbr_ele_id = + SBR_ID_CPE; + } else { + esbr_bit_str0->str_sbr_ele[esbr_bit_str0->no_elements].sbr_ele_id = + SBR_ID_SCE; + esbr_bit_str1->str_sbr_ele[esbr_bit_str1->no_elements].sbr_ele_id = + SBR_ID_SCE; + } + } + if (ele_id == ID_USAC_LFE) { + esbr_bit_str0->str_sbr_ele[esbr_bit_str0->no_elements].sbr_ele_id = + SBR_ID_SCE; + esbr_bit_str1->str_sbr_ele[esbr_bit_str1->no_elements].sbr_ele_id = + SBR_ID_SCE; + + esbr_bit_str0->no_elements++; + esbr_bit_str0->str_sbr_ele[0].size_payload = 0; + } +} + +VOID ixheaacd_ms_processing(ia_usac_data_struct *pstr_usac_data) { + WORD32 i; + + FLOAT32 tmp, tmp1; + FLOAT32 ms_factor = (FLOAT32)0.7071067812; + for (i = 0; i < pstr_usac_data->ccfl; i++) { + tmp = (FLOAT32)((pstr_usac_data->time_sample_vector[0][i] + + pstr_usac_data->time_sample_vector[1][i]) * + ms_factor); + tmp1 = (FLOAT32)((pstr_usac_data->time_sample_vector[0][i] - + pstr_usac_data->time_sample_vector[1][i]) * + ms_factor); + pstr_usac_data->time_sample_vector[1][i] = tmp1; + pstr_usac_data->time_sample_vector[0][i] = tmp; + } +} + +WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, + WORD32 *num_out_channels, VOID *codec_handle) { + WORD32 ele_id = 0; + + ia_aac_dec_state_struct *p_state_aac_dec = + (ia_aac_dec_state_struct *)codec_handle; + + ia_usac_data_struct *pstr_usac_data = pstr_dec_data->pstr_usac_data; + ia_bit_buf_struct *it_bit_buff = &pstr_dec_data->dec_bit_buf; + + ia_frame_data_struct *fd = pstr_dec_data->pstr_frame_data; + + ia_usac_config_struct *pstr_usac_config = + &(fd->str_audio_specific_config.str_usac_config); + ia_usac_decoder_config_struct *pstr_usac_dec_config = + &(fd->str_audio_specific_config.str_usac_config.str_usac_dec_config); + + WORD32 err = 0; + WORD16 nr_core_coder_channels = 0; + WORD32 ch_offset = 0; + + WORD32 elem_idx = 0; + WORD32 num_elements = pstr_usac_dec_config->num_elements; + +#ifdef ENABLE_DRC + pstr_usac_dec_config->usac_ext_gain_payload_len = 0; +#endif + pstr_usac_data->usac_independency_flg = + ixheaacd_read_bits_buf(it_bit_buff, 1); + + for (elem_idx = 0; elem_idx < num_elements; elem_idx++) { + WORD32 stereo_config_index = + pstr_usac_config->str_usac_dec_config.str_usac_element_config[elem_idx] + .stereo_config_index; + + pstr_usac_data->esbr_bit_str[0].no_elements = 0; + pstr_usac_data->esbr_bit_str[1].no_elements = 0; + + switch (ele_id = pstr_usac_dec_config->usac_element_type[elem_idx]) { + case ID_USAC_SCE: + nr_core_coder_channels = 1; + goto core_data_extracting; + + case ID_USAC_CPE: + nr_core_coder_channels = (stereo_config_index == 1) ? 1 : 2; + goto core_data_extracting; + case ID_USAC_LFE: + nr_core_coder_channels = 1; + + core_data_extracting: + err = ixheaacd_core_coder_data(ele_id, pstr_usac_data, elem_idx, + &ch_offset, it_bit_buff, + nr_core_coder_channels); + if (err != 0) return -1; + + ixheaacd_sbr_ele_type_set(&pstr_usac_data->esbr_bit_str[0], + &pstr_usac_data->esbr_bit_str[1], ele_id, + stereo_config_index); + + if (pstr_usac_data->mps_pseudo_lr[elem_idx]) + ixheaacd_ms_processing(pstr_usac_data); + + if (ele_id != ID_USAC_LFE) { + if (pstr_usac_data->sbr_ratio_idx > 0) + ixheaacd_sbr_ext_data_read(it_bit_buff, + &pstr_usac_data->esbr_bit_str[0]); + } + + if ((pstr_usac_data->sbr_ratio_idx > 0) && + (pstr_usac_data->esbr_bit_str[0].no_elements != 0)) { + ixheaacd_esbr_process( + pstr_usac_data, it_bit_buff, stereo_config_index, + nr_core_coder_channels, + pstr_dec_data->pstr_usac_data->audio_object_type); + } + + if (stereo_config_index > 0) { + FLOAT32 **ptr_inp[2 * 2]; + WORD32 ch; + + *num_out_channels = + p_state_aac_dec->mps_dec_handle[elem_idx]->out_ch_count; + + ixheaacd_mps_frame_parsing(p_state_aac_dec->mps_dec_handle[elem_idx], + pstr_usac_data->usac_independency_flg, + it_bit_buff); + + for (ch = 0; ch < nr_core_coder_channels; ch++) { + ptr_inp[2 * ch] = + pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch] + ->str_sbr_dec.pp_qmf_buf_real; + ptr_inp[2 * ch + 1] = + pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch] + ->str_sbr_dec.pp_qmf_buf_imag; + p_state_aac_dec->mps_dec_handle[0]->p_sbr_dec[ch] = + (VOID *)(&pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch] + ->str_sbr_dec); + p_state_aac_dec->mps_dec_handle[0]->p_sbr_header[ch] = + (VOID *)(pstr_usac_data->pstr_esbr_dec->pstr_sbr_header[ch]); + p_state_aac_dec->mps_dec_handle[0]->p_sbr_frame[ch] = + (VOID *)(pstr_usac_data->pstr_esbr_dec->frame_buffer[ch]); + } + if (nr_core_coder_channels == 1) { + p_state_aac_dec->mps_dec_handle[0]->p_sbr_dec[1] = + (VOID *)(&pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[1] + ->str_sbr_dec); + p_state_aac_dec->mps_dec_handle[0]->p_sbr_header[1] = + (VOID *)(pstr_usac_data->pstr_esbr_dec->pstr_sbr_header[1]); + p_state_aac_dec->mps_dec_handle[0]->p_sbr_frame[1] = + (VOID *)(pstr_usac_data->pstr_esbr_dec->frame_buffer[1]); + } + + ixheaacd_mps_apply(p_state_aac_dec->mps_dec_handle[0], ptr_inp, + pstr_usac_data->time_sample_vector); + } + + ch_offset += nr_core_coder_channels; + break; + + case ID_USAC_EXT: { + ia_usac_dec_element_config_struct *pusac_element_config = + &pstr_usac_dec_config->str_usac_element_config[elem_idx]; + ixheaacd_read_ext_element(pusac_element_config->usac_ext_eleme_def_len, + pusac_element_config->usac_ext_elem_pld_frag, + it_bit_buff +#ifdef ENABLE_DRC + , + pstr_usac_dec_config, elem_idx +#endif + ); + + break; + } + + default: + + return -1; + + break; + } + } + + return 0; +} diff --git a/decoder/ixheaacd_process.h b/decoder/ixheaacd_process.h new file mode 100644 index 0000000..5039f59 --- /dev/null +++ b/decoder/ixheaacd_process.h @@ -0,0 +1,29 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PROCESS_H +#define IXHEAACD_PROCESS_H + +WORD32 ixheaacd_dec_data_init(VOID* dec_handle, + ia_frame_data_struct* pstr_frame_data, + ia_usac_data_struct* tf_data); + +VOID ixheaacd_dec_data_delete(VOID* handle, ia_usac_data_struct* usac_data); + +#endif diff --git a/decoder/ixheaacd_ps_bitdec.c b/decoder/ixheaacd_ps_bitdec.c new file mode 100644 index 0000000..73ac4e0 --- /dev/null +++ b/decoder/ixheaacd_ps_bitdec.c @@ -0,0 +1,278 @@ +/****************************************************************************** + * * + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************** + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ +#include "string.h" +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#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 + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" +#include "ixheaacd_ps_bitdec.h" + +const WORD16 ixheaacd_num_bands[3] = {10, 20, 34}; + +static WORD32 ixheaacd_clamp(WORD32 i, WORD16 min, WORD16 max) { + WORD32 result = i; + + if (i < min) { + result = min; + } else { + if (i > max) { + result = max; + } + } + + return result; +} + +WORD16 ixheaacd_divideby2(WORD op) { + FLAG sign = (op < 0); + + if (sign) { + op = -(op); + } + + op = (op >> 1); + + if (sign) { + op = -op; + } + + return (WORD16)op; +} + +WORD16 ixheaacd_divideby3(WORD op) { + WORD16 temp, ret; + FLAG sign = (op < 0); + + if (sign) { + op = -(op); + } + + temp = (WORD16)(op << 2); + + temp = ixheaacd_mult16_shl(temp, 0x2aab); + + ret = (temp >> 2); + + if (sign) { + ret = -(ret); + } + + return (WORD16)ret; +} + +VOID ixheaacd_decode_ps_data(ia_ps_dec_struct *ptr_ps_dec) { + WORD e, i, temp; + WORD16 iid_mode = (WORD16)((ptr_ps_dec->iid_mode) ? 1 : 2); + WORD16 icc_mode = (WORD16)((ptr_ps_dec->icc_mode) ? 1 : 2); + WORD16 num_iid_levels = + (WORD16)(ptr_ps_dec->iid_quant ? NUM_IID_LEVELS_FINE : NUM_IID_LEVELS); + + if (!ptr_ps_dec->ps_data_present) { + ptr_ps_dec->num_env = 0; + } + + for (e = 0; e < ptr_ps_dec->num_env; e++) { + WORD16 *p_iid_par_prev; + WORD16 *p_icc_par_prev; + + if (e == 0) { + p_iid_par_prev = ptr_ps_dec->iid_par_prev; + p_icc_par_prev = ptr_ps_dec->icc_par_prev; + } else { + p_iid_par_prev = ptr_ps_dec->iid_par_table[e - 1]; + p_icc_par_prev = ptr_ps_dec->icc_par_table[e - 1]; + } + + if (ptr_ps_dec->enable_iid) { + if (ptr_ps_dec->iid_dt[e]) { + for (i = 0; i < ixheaacd_num_bands[ptr_ps_dec->iid_mode]; i++) { + temp = + ixheaacd_add16(*p_iid_par_prev, ptr_ps_dec->iid_par_table[e][i]); + ptr_ps_dec->iid_par_table[e][i] = ixheaacd_clamp( + temp, ixheaacd_negate16(num_iid_levels), num_iid_levels); + p_iid_par_prev += iid_mode; + } + } else { + ptr_ps_dec->iid_par_table[e][0] = + ixheaacd_clamp(ptr_ps_dec->iid_par_table[e][0], + ixheaacd_negate16(num_iid_levels), num_iid_levels); + for (i = 1; i < ixheaacd_num_bands[ptr_ps_dec->iid_mode]; i++) { + temp = ixheaacd_add16(ptr_ps_dec->iid_par_table[e][i - 1], + ptr_ps_dec->iid_par_table[e][i]); + ptr_ps_dec->iid_par_table[e][i] = ixheaacd_clamp( + temp, ixheaacd_negate16(num_iid_levels), num_iid_levels); + } + } + } else { + memset(ptr_ps_dec->iid_par_table[e], 0, + sizeof(WORD16) * ixheaacd_num_bands[ptr_ps_dec->iid_mode]); + } + + if (iid_mode == 2) { + for (i = (ixheaacd_num_bands[ptr_ps_dec->iid_mode] * iid_mode - 1); + i != 0; i--) { + ptr_ps_dec->iid_par_table[e][i] = + ptr_ps_dec->iid_par_table[e][ixheaacd_shr32(i, 1)]; + } + } + + if (ptr_ps_dec->enable_icc) { + if (ptr_ps_dec->icc_dt[e]) { + for (i = 0; i < ixheaacd_num_bands[ptr_ps_dec->icc_mode]; i++) { + temp = + ixheaacd_add16(*p_icc_par_prev, ptr_ps_dec->icc_par_table[e][i]); + ptr_ps_dec->icc_par_table[e][i] = + ixheaacd_clamp(temp, 0, (WORD16)(NUM_ICC_LEVELS - 1)); + p_icc_par_prev += icc_mode; + } + } else { + ptr_ps_dec->icc_par_table[e][0] = ixheaacd_clamp( + ptr_ps_dec->icc_par_table[e][0], 0, (WORD16)(NUM_ICC_LEVELS - 1)); + for (i = 1; i < ixheaacd_num_bands[ptr_ps_dec->icc_mode]; i++) { + temp = ixheaacd_add16(ptr_ps_dec->icc_par_table[e][i - 1], + ptr_ps_dec->icc_par_table[e][i]); + ptr_ps_dec->icc_par_table[e][i] = + ixheaacd_clamp(temp, 0, (WORD16)(NUM_ICC_LEVELS - 1)); + } + } + } else { + memset(ptr_ps_dec->icc_par_table[e], 0, + sizeof(WORD16) * ixheaacd_num_bands[ptr_ps_dec->icc_mode]); + } + + if (icc_mode == 2) { + for (i = (ixheaacd_num_bands[ptr_ps_dec->icc_mode] * icc_mode - 1); + i != 0; i--) { + ptr_ps_dec->icc_par_table[e][i] = + ptr_ps_dec->icc_par_table[e][ixheaacd_shr32(i, 1)]; + } + } + } + + if (ptr_ps_dec->num_env == 0) { + ptr_ps_dec->num_env = 1; + + if (ptr_ps_dec->enable_iid) { + memcpy(ptr_ps_dec->iid_par_table[0], ptr_ps_dec->iid_par_prev, + sizeof(WORD16) * NUM_BANDS_FINE); + } else { + memset(ptr_ps_dec->iid_par_table[0], 0, sizeof(WORD16) * NUM_BANDS_FINE); + } + + if (ptr_ps_dec->enable_icc) { + memcpy(ptr_ps_dec->icc_par_table[0], ptr_ps_dec->icc_par_prev, + sizeof(WORD16) * NUM_BANDS_FINE); + } else { + memset(ptr_ps_dec->icc_par_table[0], 0, sizeof(WORD16) * NUM_BANDS_FINE); + } + } + + memcpy(ptr_ps_dec->iid_par_prev, + ptr_ps_dec->iid_par_table[ptr_ps_dec->num_env - 1], + sizeof(WORD16) * NUM_BANDS_FINE); + + memcpy(ptr_ps_dec->icc_par_prev, + ptr_ps_dec->icc_par_table[ptr_ps_dec->num_env - 1], + sizeof(WORD16) * NUM_BANDS_FINE); + + ptr_ps_dec->ps_data_present = 0; + + if (ptr_ps_dec->frame_class == 0) { + WORD env_count; + WORD16 shift = 0; + + switch (ptr_ps_dec->num_env) { + case 1: + shift = 0; + break; + case 2: + shift = 1; + break; + case 4: + shift = 2; + break; + } + ptr_ps_dec->border_position[0] = 0; + env_count = 0; + + for (e = 1; e < ptr_ps_dec->num_env; e++) { + env_count = add_d(env_count, MAX_NUM_COLUMNS); + ptr_ps_dec->border_position[e] = (WORD16)(env_count >> shift); + } + ptr_ps_dec->border_position[ptr_ps_dec->num_env] = MAX_NUM_COLUMNS; + } else { + ptr_ps_dec->border_position[0] = 0; + + if (ptr_ps_dec->border_position[ptr_ps_dec->num_env] < MAX_NUM_COLUMNS) { + ptr_ps_dec->num_env++; + add_d(ptr_ps_dec->num_env, 1); + ptr_ps_dec->border_position[ptr_ps_dec->num_env] = MAX_NUM_COLUMNS; + + memcpy(ptr_ps_dec->iid_par_table[ptr_ps_dec->num_env - 1], + ptr_ps_dec->iid_par_table[ptr_ps_dec->num_env - 2], + sizeof(WORD16) * NUM_BANDS_FINE); + + memcpy(ptr_ps_dec->icc_par_table[ptr_ps_dec->num_env - 1], + ptr_ps_dec->icc_par_table[ptr_ps_dec->num_env - 2], + sizeof(WORD16) * NUM_BANDS_FINE); + } + + for (e = 1; e < ptr_ps_dec->num_env; e++) { + WORD threshold; + threshold = sub_d(MAX_NUM_COLUMNS, sub_d(ptr_ps_dec->num_env, e)); + + if (ptr_ps_dec->border_position[e] > threshold) { + ptr_ps_dec->border_position[e] = threshold; + } else { + threshold = add_d(ptr_ps_dec->border_position[e - 1], 1); + + if (ptr_ps_dec->border_position[e] < threshold) { + ptr_ps_dec->border_position[e] = threshold; + } + } + } + } + + for (e = 0; e < ptr_ps_dec->num_env; e++) { + if (ptr_ps_dec->iid_mode == 2) + ixheaacd_map_34_params_to_20(ptr_ps_dec->iid_par_table[e]); + + if (ptr_ps_dec->icc_mode == 2) + ixheaacd_map_34_params_to_20(ptr_ps_dec->icc_par_table[e]); + } +} diff --git a/decoder/ixheaacd_ps_bitdec.h b/decoder/ixheaacd_ps_bitdec.h new file mode 100644 index 0000000..67f6106 --- /dev/null +++ b/decoder/ixheaacd_ps_bitdec.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PS_BITDEC_H +#define IXHEAACD_PS_BITDEC_H + +#define EXTENSION_ID_PS_CODING 2 + +WORD16 ixheaacd_read_ps_data(ia_ps_dec_struct *ptr_ps_dec, + ia_bit_buf_struct *it_bit_buff, WORD16 n_bits_left, + ia_ps_tables_struct *ps_tables_ptr); + +VOID ixheaacd_decode_ps_data(ia_ps_dec_struct *ptr_ps_dec); + +extern VOID ixheaacd_map_34_params_to_20(WORD16 *a_idx); + +#endif diff --git a/decoder/ixheaacd_ps_dec.c b/decoder/ixheaacd_ps_dec.c new file mode 100644 index 0000000..f8cd6ec --- /dev/null +++ b/decoder/ixheaacd_ps_dec.c @@ -0,0 +1,990 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops_arr.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include + +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_function_selector.h" + +static PLATFORM_INLINE WORD16 ixheaacd_shl16_saturate(WORD16 op1, + WORD16 shift) { + WORD16 var_out; + WORD32 temp; + + temp = (WORD32)(op1 << shift); + var_out = ixheaacd_sat16(temp); + return (var_out); +} + +static PLATFORM_INLINE VOID ixheaacd_shl16_arr_saturate(WORD16 *word16_arr, + WORD16 shift, WORD n) { + WORD i; + + for (i = n - 1; i >= 0; i--) { + *word16_arr = ixheaacd_shl16_saturate(*word16_arr, shift); + word16_arr++; + } + + return; +} + +VOID ixheaacd_scale_short_vec_left(WORD16 *word16_arr, WORD32 n, WORD16 shift) { + ixheaacd_shl16_arr_saturate(word16_arr, shift, n); +} + +VOID ixheaacd_scale_int_vec_left(WORD32 *word32_arr, WORD32 n, WORD16 shift) { + ixheaacd_shl32_arr_sat(word32_arr, shift, n); +} + +VOID ixheaacd_scale_int_vec_right(WORD32 *word32_arr, WORD32 n, WORD16 shift) { + ixheaacd_shr32_arr(word32_arr, shift, n); +} + +VOID ixheaacd_scale_short_vec_right(WORD16 *word16_arr, WORD32 n, + WORD16 shift) { + ixheaacd_shr16_arr(word16_arr, shift, n); +} + +WORD32 ixheaacd_calc_max(WORD16 *array, WORD32 size) { + WORD n; + WORD32 max_val = 0; + WORD16 temp1, temp2; + + for (n = size; n != 0; n--) { + temp1 = *array++; + temp2 = *array++; + + max_val = max_val | ixheaacd_abs32_nrm(temp1); + max_val = max_val | ixheaacd_abs32_nrm(temp2); + } + + return max_val; +} + +static WORD ixheaacd_get_ps_scale(ia_ps_dec_struct *ptr_ps_dec) { + WORD i, m, n, len; + WORD32 max_val = 0; + WORD16 *ptr_re; + WORD32 *ptr_re_temp, *ptr_im; + + for (m = 0; m < 2; m++) { + ptr_re = &ptr_ps_dec->delay_buf_qmf_ap_re_im[m][2 * 3]; + max_val |= + ixheaacd_calc_max(ptr_re, NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS); + } + + ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_ld_re_im; + + max_val |= ixheaacd_calc_max(ptr_re, HIGH_DEL * SMALL_DEL_STRT); + + ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sd_re_im; + + max_val |= ixheaacd_calc_max( + ptr_re, (SMALL_DEL * + (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS - + (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)))); + + ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_re_im; + + max_val |= ixheaacd_calc_max(ptr_re, 16 * DEL_ALL_PASS); + + for (i = 0; i < NUM_SER_AP_LINKS; i++) { + for (m = 0; m < ptr_ps_dec->delay_sample_ser[i]; m++) { + ptr_re = &ptr_ps_dec->delay_buf_qmf_ser_re_im[m][i][2 * 3]; + + max_val |= + ixheaacd_calc_max(ptr_re, NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS); + } + } + + ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_ser_re_im; + max_val |= ixheaacd_calc_max(ptr_re, NUM_SER_AP_LINKS * 5 * 16); + + max_val = max_val << 16; + + len = ptr_ps_dec->str_hybrid.ptr_qmf_buf; + + for (i = 0; i < NO_QMF_CHANNELS_IN_HYBRID; i++) { + ptr_re_temp = &ptr_ps_dec->str_hybrid.ptr_qmf_buf_re[i][0]; + ptr_im = &ptr_ps_dec->str_hybrid.ptr_qmf_buf_im[i][0]; + + for (n = len; n != 0; n--) { + WORD32 temp3 = *ptr_re_temp++; + WORD32 temp4 = *ptr_im++; + + max_val = max_val | ixheaacd_abs32_nrm(temp3); + max_val = max_val | ixheaacd_abs32_nrm(temp4); + } + } + + return ixheaacd_pnorm32(max_val); +} + +VOID ixheaacd_init_ps_scale(ia_ps_dec_struct *ptr_ps_dec, + ia_sbr_scale_fact_struct *sbr_scale_factor) + +{ + WORD32 reserve, change; + WORD16 temp; + + reserve = ixheaacd_get_ps_scale(ptr_ps_dec); + + ptr_ps_dec->delay_buffer_scale = (ptr_ps_dec->delay_buffer_scale + reserve); + temp = + ixheaacd_min16(sbr_scale_factor->lb_scale, sbr_scale_factor->ov_lb_scale); + temp = ixheaacd_min16(temp, sbr_scale_factor->hb_scale); + temp = ixheaacd_min16(temp, ptr_ps_dec->delay_buffer_scale); + sbr_scale_factor->ps_scale = (temp - 1); + + change = (sbr_scale_factor->ps_scale - ptr_ps_dec->delay_buffer_scale); + change = (change + reserve); + + ixheaacd_scale_ps_states(ptr_ps_dec, (WORD16)change); + + ptr_ps_dec->delay_buffer_scale = sbr_scale_factor->ps_scale; +} + +WORD32 ixheaacd_divide16_pos_dec(WORD32 op1, WORD32 op2) { + UWORD32 v; + UWORD32 u; + WORD k, nrm; + + nrm = ixheaacd_norm32(op2); + u = (op1 << nrm); + v = (op2 << nrm); + u = (u & 0xffff0000); + v = (v & 0xffff0000); + + if (u != 0) { + for (k = 16; k > 0; k--) { + if (u >= (UWORD32)v) { + u = ((u - v) << 1) + 1; + } else { + u = (u << 1); + } + } + } + + return (u); +} + +VOID ixheaacd_decorr_filter1_dec(ia_ps_dec_struct *ptr_ps_dec, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) { + WORD sb; + WORD m; + + WORD16 delay_buf_idx; + WORD16 *p_delay_buf_sub_re_im; + WORD16 *p_frac_delay_phase_fac_ser_re_im, *p_frac_delay_phase_fac_ser_re_im1; + + const WORD16 *p_frac_delay_phase_fac_re_im; + REVERB_BUFFERS_CH_RI *p_delay_buf_ser_sub_re_im; + + WORD32 *p_left_real; + WORD32 *p_left_imag; + WORD32 *p_right_real; + WORD32 *p_right_imag; + + p_frac_delay_phase_fac_re_im = + &ps_tables_ptr->frac_delay_phase_fac_qmf_sub_re_im[0]; + p_delay_buf_ser_sub_re_im = &ptr_ps_dec->delay_buf_qmf_sub_ser_re_im; + p_frac_delay_phase_fac_ser_re_im = + &ps_tables_ptr->frac_delay_phase_fac_qmf_sub_ser_re_im[0][0]; + + p_left_real = ptr_ps_dec->ptr_hyb_left_re; + p_left_imag = ptr_ps_dec->ptr_hyb_left_im; + p_right_real = ptr_ps_dec->ptr_hyb_right_re; + p_right_imag = ptr_ps_dec->ptr_hyb_right_im; + + delay_buf_idx = ptr_ps_dec->delay_buf_idx; + p_delay_buf_sub_re_im = + &ptr_ps_dec->delay_buf_qmf_sub_re_im[delay_buf_idx][0]; + for (sb = 0; sb < SUBQMF_GROUPS; sb++) { + WORD16 real_tmp, imag_tmp, real_tmp0, imag_tmp0, real_in, imag_in, bin; + + real_tmp0 = p_delay_buf_sub_re_im[0]; + imag_tmp0 = p_delay_buf_sub_re_im[1]; + + real_in = (WORD16)( + ixheaacd_sub32_sat( + ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[0]), + ixheaacd_mult16x16in32(imag_tmp0, + p_frac_delay_phase_fac_re_im[1])) >> + 15); + imag_in = (WORD16)( + ixheaacd_add32_sat( + ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[1]), + ixheaacd_mult16x16in32(imag_tmp0, + p_frac_delay_phase_fac_re_im[0])) >> + 15); + *p_delay_buf_sub_re_im++ = ixheaacd_round16(p_left_real[sb]); + *p_delay_buf_sub_re_im++ = ixheaacd_round16(p_left_imag[sb]); + p_frac_delay_phase_fac_re_im += 2; + + p_frac_delay_phase_fac_ser_re_im1 = p_frac_delay_phase_fac_ser_re_im; + p_frac_delay_phase_fac_ser_re_im += 2; + + for (m = 0; m < NUM_SER_AP_LINKS; m++) { + WORD16 decay; + WORD16 delay_buf_idx_ser; + delay_buf_idx_ser = ptr_ps_dec->delay_buf_idx_ser[m]; + real_tmp0 = (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][2 * sb]; + imag_tmp0 = + (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][2 * sb + 1]; + + real_tmp = + (WORD16)(ixheaacd_sub32_sat( + ixheaacd_mult16x16in32( + real_tmp0, p_frac_delay_phase_fac_ser_re_im1[0]), + ixheaacd_mult16x16in32( + imag_tmp0, p_frac_delay_phase_fac_ser_re_im1[1])) >> + 15); + imag_tmp = + (WORD16)(ixheaacd_add32_sat( + ixheaacd_mult16x16in32( + real_tmp0, p_frac_delay_phase_fac_ser_re_im1[1]), + ixheaacd_mult16x16in32( + imag_tmp0, p_frac_delay_phase_fac_ser_re_im1[0])) >> + 15); + + decay = ps_tables_ptr->rev_link_decay_ser[m]; + + real_tmp = ixheaacd_sub16(real_tmp, ixheaacd_mult16_shl(real_in, decay)); + imag_tmp = ixheaacd_sub16(imag_tmp, ixheaacd_mult16_shl(imag_in, decay)); + + (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][sb * 2] = + ixheaacd_add16(real_in, ixheaacd_mult16_shl(real_tmp, decay)); + (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][sb * 2 + 1] = + ixheaacd_add16(imag_in, ixheaacd_mult16_shl(imag_tmp, decay)); + + real_in = real_tmp; + imag_in = imag_tmp; + p_frac_delay_phase_fac_ser_re_im1 += 32; + } + + bin = ps_tables_ptr->hybrid_to_bin[sb]; + p_right_real[sb] = + ixheaacd_mult16x16in32_shl(real_in, transient_ratio[bin]); + p_right_imag[sb] = + ixheaacd_mult16x16in32_shl(imag_in, transient_ratio[bin]); + } +} + +VOID ixheaacd_decorr_filter2_dec( + ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio) { + WORD sb, di, sb_delay; + WORD m, bin; + WORD32 *p_left_real; + WORD32 *p_left_imag; + WORD32 *p_right_real; + WORD32 *p_right_imag; + WORD16 delay_buf_idx; + REVERB_BUFFERS_RI *p_delay_buf_ser_re_im; + WORD16 *p_delay_buf_ap_re_im; + const WORD16 *p_frac_delay_phase_fac_re_im; + WORD16 *p_frac_delay_phase_fac_ser_ap_re_im, + *p_frac_delay_phase_fac_ser_ap_re_im_temp; + + p_left_real = p_buf_left_real; + p_left_imag = p_buf_left_imag; + p_right_real = p_buf_right_real; + p_right_imag = p_buf_right_imag; + + p_delay_buf_ser_re_im = &ptr_ps_dec->delay_buf_qmf_ser_re_im; + p_frac_delay_phase_fac_re_im = ps_tables_ptr->frac_delay_phase_fac_qmf_re_im; + p_frac_delay_phase_fac_ser_ap_re_im = + &ps_tables_ptr->frac_delay_phase_fac_qmf_ser_re_im[0][0]; + + delay_buf_idx = ptr_ps_dec->delay_buf_idx; + + p_delay_buf_ap_re_im = &ptr_ps_dec->delay_buf_qmf_ap_re_im[delay_buf_idx][0]; + p_frac_delay_phase_fac_re_im += 6; + p_frac_delay_phase_fac_ser_ap_re_im += 6; + p_delay_buf_ap_re_im += 6; + + for (sb = 3, di = 9; sb < 23; sb++) { + WORD16 real_tmp, imag_tmp, real_tmp0, imag_tmp0, real_in, imag_in; + + sb_delay = sb; + + real_tmp0 = p_delay_buf_ap_re_im[0]; + imag_tmp0 = p_delay_buf_ap_re_im[1]; + + real_in = (WORD16)( + ixheaacd_sub32_sat( + ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[0]), + ixheaacd_mult16x16in32(imag_tmp0, + p_frac_delay_phase_fac_re_im[1])) >> + 15); + imag_in = (WORD16)( + ixheaacd_add32_sat( + ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[1]), + ixheaacd_mult16x16in32(imag_tmp0, + p_frac_delay_phase_fac_re_im[0])) >> + 15); + + *p_delay_buf_ap_re_im++ = ixheaacd_round16(p_left_real[sb]); + *p_delay_buf_ap_re_im++ = ixheaacd_round16(p_left_imag[sb]); + + p_frac_delay_phase_fac_re_im += 2; + + p_frac_delay_phase_fac_ser_ap_re_im_temp = + p_frac_delay_phase_fac_ser_ap_re_im; + p_frac_delay_phase_fac_ser_ap_re_im += 2; + + for (m = 0; m < NUM_SER_AP_LINKS; m++, di++) { + WORD16 decay; + WORD16 delay_buf_idx_ser; + delay_buf_idx_ser = ptr_ps_dec->delay_buf_idx_ser[m]; + + real_tmp0 = (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2]; + imag_tmp0 = + (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2 + 1]; + + real_tmp = (WORD16)( + ixheaacd_sub32_sat( + ixheaacd_mult16x16in32( + real_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[0]), + ixheaacd_mult16x16in32( + imag_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[1])) >> + 15); + imag_tmp = (WORD16)( + ixheaacd_add32_sat( + ixheaacd_mult16x16in32( + real_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[1]), + ixheaacd_mult16x16in32( + imag_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[0])) >> + 15); + + decay = ps_tables_ptr->decay_scale_factor[di]; + + real_tmp = ixheaacd_sub16(real_tmp, ixheaacd_mult16_shl(real_in, decay)); + imag_tmp = ixheaacd_sub16(imag_tmp, ixheaacd_mult16_shl(imag_in, decay)); + + (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2] = + ixheaacd_add16(real_in, ixheaacd_mult16_shl(real_tmp, decay)); + (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2 + 1] = + ixheaacd_add16(imag_in, ixheaacd_mult16_shl(imag_tmp, decay)); + + real_in = real_tmp; + imag_in = imag_tmp; + p_frac_delay_phase_fac_ser_ap_re_im_temp += 64; + } + + bin = ps_tables_ptr->delay_to_bin[sb_delay]; + p_right_real[sb] = + ixheaacd_mult16x16in32_shl(real_in, transient_ratio[bin]); + p_right_imag[sb] = + ixheaacd_mult16x16in32_shl(imag_in, transient_ratio[bin]); + } +} + +VOID ixheaacd_decorrelation_dec(ia_ps_dec_struct *ptr_ps_dec, + WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, + WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) { + WORD sb; + + WORD gr, bin, sband, maxsband; + + WORD32 peak_diff, nrg; + WORD32 power_buf[NUM_OF_BINS]; + WORD16 transient_ratio[NUM_OF_BINS + 1]; + + WORD32 *p_left_real; + WORD32 *p_left_imag; + WORD32 *p_right_real; + WORD32 *p_right_imag; + + WORD16 *p_delay_buf_re_im_ld; + WORD16 *p_delay_buf_re_im_sd; + + WORD usb = ptr_ps_dec->usb; + WORD16 delay_buf_idx; + + p_left_real = ptr_ps_dec->ptr_hyb_left_re; + p_left_imag = ptr_ps_dec->ptr_hyb_left_im; + p_right_real = ptr_ps_dec->ptr_hyb_right_re; + p_right_imag = ptr_ps_dec->ptr_hyb_right_im; + + { + WORD32 re0, im0, re1, im1; + + re0 = (p_left_real[0]); + im0 = (p_left_imag[0]); + re1 = (p_left_real[5]); + im1 = (p_left_imag[5]); + + power_buf[0] = ixheaacd_mult32x16in32(re0, (WORD16)(re0 >> 16)); + power_buf[0] = ixheaacd_add32_sat( + power_buf[0], ixheaacd_mult32x16in32(im0, (WORD16)(im0 >> 16))); + power_buf[0] = ixheaacd_add32_sat( + power_buf[0], ixheaacd_mult32x16in32(re1, (WORD16)(re1 >> 16))); + power_buf[0] = ixheaacd_add32_sat( + power_buf[0], ixheaacd_mult32x16in32(im1, (WORD16)(im1 >> 16))); + + re0 = (p_left_real[4]); + im0 = (p_left_imag[4]); + re1 = (p_left_real[1]); + im1 = (p_left_imag[1]); + + power_buf[1] = ixheaacd_mult32x16in32(re0, (WORD16)(re0 >> 16)); + power_buf[1] = ixheaacd_add32_sat( + power_buf[1], ixheaacd_mult32x16in32(im0, (WORD16)(im0 >> 16))); + power_buf[1] = ixheaacd_add32_sat( + power_buf[1], ixheaacd_mult32x16in32(re1, (WORD16)(re1 >> 16))); + power_buf[1] = ixheaacd_add32_sat( + power_buf[1], ixheaacd_mult32x16in32(im1, (WORD16)(im1 >> 16))); + } + + bin = 4 - 2; + for (gr = 4; gr < SUBQMF_GROUPS; gr++) { + WORD32 re, im; + sb = ps_tables_ptr->borders_group[gr]; + re = (p_left_real[sb]); + im = (p_left_imag[sb]); + power_buf[bin] = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16)); + power_buf[bin] = ixheaacd_add32_sat( + power_buf[bin], ixheaacd_mult32x16in32(im, (WORD16)(im >> 16))); + bin++; + } + + p_left_real = p_buf_left_real; + p_left_imag = p_buf_left_imag; + + bin = NO_QMF_CHANNELS_IN_HYBRID + 5; + for (sband = NO_QMF_CHANNELS_IN_HYBRID; sband < NO_QMF_CHANNELS_IN_HYBRID + 6; + sband++) { + WORD32 re = (p_left_real[sband]); + WORD32 im = (p_left_imag[sband]); + power_buf[bin] = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16)); + power_buf[bin] = ixheaacd_add32_sat( + power_buf[bin], ixheaacd_mult32x16in32(im, (WORD16)(im >> 16))); + bin++; + } + + bin = 16 - 2; + for (gr = 16; gr < NO_IID_GROUPS; gr++) { + WORD32 accu = 0, tmp; + WORD32 re, im; + + maxsband = ixheaacd_min32(usb, ps_tables_ptr->borders_group[gr + 1]); + + for (sband = ps_tables_ptr->borders_group[gr]; sband < maxsband; sband++) { + re = (p_left_real[sband]); + im = (p_left_imag[sband]); + + tmp = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16)); + tmp = ixheaacd_add32_sat(tmp, + ixheaacd_mult32x16in32(im, (WORD16)(im >> 16))); + tmp = (tmp >> ps_tables_ptr->group_shift[gr - (SUBQMF_GROUPS + 6)]); + + accu = ixheaacd_add32_sat(accu, tmp); + } + power_buf[bin] = accu; + bin++; + } + + p_left_real = ptr_ps_dec->ptr_hyb_left_re; + p_left_imag = ptr_ps_dec->ptr_hyb_left_im; + + for (bin = 0; bin < NUM_OF_BINS; bin++) { + power_buf[bin] = ixheaacd_shl32(power_buf[bin], 1); + + power_buf[bin] = ixheaacd_max32(0, power_buf[bin]); + + ptr_ps_dec->peak_decay_diff[bin] = ixheaacd_mult32x16in32_shl( + ptr_ps_dec->peak_decay_diff[bin], PEAK_DECAYING_FACT); + + ptr_ps_dec->peak_decay_diff[bin] = + ixheaacd_max32(ptr_ps_dec->peak_decay_diff[bin], power_buf[bin]); + + peak_diff = ixheaacd_add32_sat( + ixheaacd_mult32x16in32_shl(ptr_ps_dec->peak_decay_diff_prev[bin], + 0x6000), + ((ixheaacd_sub32_sat(ptr_ps_dec->peak_decay_diff[bin], + power_buf[bin]) >> + 2))); + + ptr_ps_dec->peak_decay_diff_prev[bin] = peak_diff; + + nrg = ixheaacd_add32_sat( + ixheaacd_mult32x16in32_shl(ptr_ps_dec->energy_prev[bin], 0x6000), + (power_buf[bin] >> 2)); + ptr_ps_dec->energy_prev[bin] = nrg; + + peak_diff = ixheaacd_add32_sat(peak_diff, (peak_diff >> 1)); + + if (peak_diff <= nrg) { + transient_ratio[bin] = 0x7fff; + } else { + transient_ratio[bin] = + ixheaacd_extract16l((*ixheaacd_divide16_pos)(nrg, peak_diff)); + } + } + + (*ixheaacd_decorr_filter1)(ptr_ps_dec, ps_tables_ptr, transient_ratio); + + transient_ratio[20] = 0; + + (*ixheaacd_decorr_filter2)(ptr_ps_dec, p_buf_left_real, p_buf_left_imag, + p_buf_right_real, p_buf_right_imag, ps_tables_ptr, + transient_ratio); + + { + WORD16 trans_ratio = transient_ratio[18]; + + p_left_real = p_buf_left_real; + p_left_imag = p_buf_left_imag; + p_right_real = p_buf_right_real; + p_right_imag = p_buf_right_imag; + + maxsband = ixheaacd_min32((WORD16)usb, ps_tables_ptr->borders_group[21]); + delay_buf_idx = ptr_ps_dec->delay_buf_idx_long; + p_delay_buf_re_im_ld = + &ptr_ps_dec->delay_buf_qmf_ld_re_im[delay_buf_idx][0]; + + for (sband = ps_tables_ptr->borders_group[20]; sband < maxsband; sband++) { + WORD16 real_in, imag_in; + + real_in = p_delay_buf_re_im_ld[0]; + imag_in = p_delay_buf_re_im_ld[1]; + *p_delay_buf_re_im_ld++ = ixheaacd_round16(p_left_real[sband]); + *p_delay_buf_re_im_ld++ = ixheaacd_round16(p_left_imag[sband]); + + p_right_real[sband] = ixheaacd_mult16x16in32_shl(real_in, trans_ratio); + p_right_imag[sband] = ixheaacd_mult16x16in32_shl(imag_in, trans_ratio); + } + + ptr_ps_dec->delay_buf_idx_long = + ixheaacd_add16(ptr_ps_dec->delay_buf_idx_long, 1); + + if (ptr_ps_dec->delay_buf_idx_long >= 14) { + ptr_ps_dec->delay_buf_idx_long = 0; + } + + p_delay_buf_re_im_sd = &ptr_ps_dec->delay_buf_qmf_sd_re_im[0][0]; + + trans_ratio = transient_ratio[19]; + maxsband = ixheaacd_min32((WORD16)usb, ps_tables_ptr->borders_group[22]); + for (sband = ps_tables_ptr->borders_group[21]; sband < maxsband; sband++) { + WORD16 real_in, imag_in; + + real_in = p_delay_buf_re_im_sd[0]; + imag_in = p_delay_buf_re_im_sd[1]; + *p_delay_buf_re_im_sd++ = ixheaacd_round16(p_left_real[sband]); + *p_delay_buf_re_im_sd++ = ixheaacd_round16(p_left_imag[sband]); + + p_right_real[sband] = ixheaacd_mult16x16in32_shl(real_in, trans_ratio); + p_right_imag[sband] = ixheaacd_mult16x16in32_shl(imag_in, trans_ratio); + } + } + + for (sband = usb; sband < NO_SYNTHESIS_CHANNELS; sband++) { + p_right_real[sband] = 0; + p_right_imag[sband] = 0; + } + + ptr_ps_dec->delay_buf_idx = (WORD16)(ptr_ps_dec->delay_buf_idx + 1); + if (ptr_ps_dec->delay_buf_idx >= DEL_ALL_PASS) { + ptr_ps_dec->delay_buf_idx = 0; + } + + { + WORD delay_m; + + for (delay_m = 0; delay_m < NUM_SER_AP_LINKS; delay_m++) { + ptr_ps_dec->delay_buf_idx_ser[delay_m] = + (ptr_ps_dec->delay_buf_idx_ser[delay_m] + 1); + if (ptr_ps_dec->delay_buf_idx_ser[delay_m] >= + ptr_ps_dec->delay_sample_ser[delay_m]) { + ptr_ps_dec->delay_buf_idx_ser[delay_m] = 0; + } + } + } +} + +static WORD16 ixheaacd_cos512(WORD phi_by_4, const WORD16 *cos_sin_lookup_tab) { + WORD index; + index = ixheaacd_round16(ixheaacd_abs32_sat(phi_by_4)); + + index = (index & 0x3FF); + + if (index < 512) { + return cos_sin_lookup_tab[512 - index]; + } else { + return (WORD16)(-(cos_sin_lookup_tab[index - 512])); + } +} + +static WORD16 ixheaacd_sin512(WORD phi_by_4, const WORD16 *cos_sin_lookup_tab) { + WORD index; + + index = ixheaacd_round16(phi_by_4); + + if (index < 0) { + index = (-(index)&0x3FF); + + if (index < 512) { + return (WORD16)(-cos_sin_lookup_tab[index]); + } else { + return (WORD16)(-cos_sin_lookup_tab[1024 - index]); + } + } else { + index = (index & 0x3FF); + + if (index < 512) { + return cos_sin_lookup_tab[index]; + } else { + return cos_sin_lookup_tab[1024 - index]; + } + } +} + +VOID ixheaacd_init_rot_env(ia_ps_dec_struct *ptr_ps_dec, WORD16 env, WORD16 usb, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *cos_sin_lookup_tab) { + WORD group, bin, num_iid_steps; + WORD16 c2, c1; + WORD32 alpha, beta; + WORD16 h11, h12, h21, h22; + WORD16 inv_env_len; + const WORD16 *p_scale_factors; + WORD16 *p_iid_idx; + WORD indexplusa, indexminusa; + + const WORD32 rescale = (0x0517cc1b << 1); + + if (env == 0) { + WORD usb_prev = ptr_ps_dec->usb; + WORD16 *ptr_tmp; + ptr_ps_dec->usb = usb; + + if ((usb > usb_prev) && usb_prev) { + WORD i, j, delay, offset1; + WORD ixheaacd_drc_offset = + (usb < NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + ? usb + : NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS); + + if (ixheaacd_drc_offset > usb_prev) { + for (i = 0; i < NUM_SER_AP_LINKS; i++) { + for (j = 0; j < ptr_ps_dec->delay_sample_ser[i]; j++) { + ptr_tmp = &ptr_ps_dec->delay_buf_qmf_ser_re_im[j][i][usb_prev * 2]; + + memset(ptr_tmp, 0, + sizeof(WORD16) * (ixheaacd_drc_offset - usb_prev) * 2); + } + } + } + + offset1 = + (usb < (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT) + ? usb + : (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)); + delay = HIGH_DEL; + + if ((offset1 >= ixheaacd_drc_offset) && (offset1 <= SMALL_DEL_STRT)) { + for (i = 0; i < delay; i++) { + ptr_tmp = + &ptr_ps_dec->delay_buf_qmf_ld_re_im[i][ixheaacd_drc_offset * 2]; + + memset(ptr_tmp, 0, + sizeof(WORD16) * 2 * (offset1 - ixheaacd_drc_offset)); + } + } + + delay = SMALL_DEL; + + if ((usb >= offset1) && (usb <= 16)) { + for (i = 0; i < delay; i++) { + ptr_tmp = &ptr_ps_dec->delay_buf_qmf_sd_re_im[i][offset1 * 2]; + + memset(ptr_tmp, 0, sizeof(WORD16) * 2 * (usb - offset1)); + } + } + } + } + + if (ptr_ps_dec->iid_quant) { + num_iid_steps = NUM_IID_LEVELS_FINE; + p_scale_factors = sbr_tables_ptr->ps_tables_ptr->scale_factors_fine; + } else { + num_iid_steps = NUM_IID_LEVELS; + p_scale_factors = sbr_tables_ptr->ps_tables_ptr->scale_factors; + } + + inv_env_len = + sbr_tables_ptr->env_calc_tables_ptr->sbr_inv_int_table[ixheaacd_abs16( + ixheaacd_sub16_sat(ptr_ps_dec->border_position[env + 1], + ptr_ps_dec->border_position[env]))]; + + p_iid_idx = &ptr_ps_dec->iid_par_table[env][0]; + + for (group = 0; group < NO_IID_GROUPS; group++) { + WORD16 bplusa, bminusa; + WORD num_iid_idx, num_icc_idx; + + bin = sbr_tables_ptr->ps_tables_ptr->group_to_bin[group]; + + num_iid_idx = p_iid_idx[bin]; + num_icc_idx = p_iid_idx[bin + 238]; + + c1 = p_scale_factors[(num_iid_steps + num_iid_idx)]; + c2 = p_scale_factors[(num_iid_steps - num_iid_idx)]; + + beta = ixheaacd_mult32x16in32_shl( + ixheaacd_mult16x16in32_shl( + sbr_tables_ptr->ps_tables_ptr->alpha_values[num_icc_idx], + ixheaacd_sub16(c1, c2)), + PSC_SQRT05F); + alpha = ixheaacd_shr32_dir_sat_limit( + ixheaacd_deposit16h_in32( + sbr_tables_ptr->ps_tables_ptr->alpha_values[num_icc_idx]), + 1); + + bplusa = ixheaacd_round16(ixheaacd_add32_sat(beta, alpha)); + bminusa = ixheaacd_round16(ixheaacd_sub32_sat(beta, alpha)); + + indexplusa = ixheaacd_mult32x16in32(rescale, bplusa); + indexminusa = ixheaacd_mult32x16in32(rescale, bminusa); + + h11 = ixheaacd_mult16_shl(ixheaacd_cos512(indexplusa, cos_sin_lookup_tab), + c2); + h12 = ixheaacd_mult16_shl(ixheaacd_cos512(indexminusa, cos_sin_lookup_tab), + c1); + h21 = ixheaacd_mult16_shl(ixheaacd_sin512(indexplusa, cos_sin_lookup_tab), + c2); + h22 = ixheaacd_mult16_shl(ixheaacd_sin512(indexminusa, cos_sin_lookup_tab), + c1); + + ptr_ps_dec->delta_h11_h12[2 * group + 0] = ixheaacd_mult16_shl( + inv_env_len, + ixheaacd_sub16(h11, ptr_ps_dec->h11_h12_vec[2 * group + 0])); + ptr_ps_dec->delta_h11_h12[2 * group + 1] = ixheaacd_mult16_shl( + inv_env_len, + ixheaacd_sub16(h12, ptr_ps_dec->h11_h12_vec[2 * group + 1])); + ptr_ps_dec->delta_h21_h22[2 * group + 0] = ixheaacd_mult16_shl( + inv_env_len, + ixheaacd_sub16(h21, ptr_ps_dec->h21_h22_vec[2 * group + 0])); + ptr_ps_dec->delta_h21_h22[2 * group + 1] = ixheaacd_mult16_shl( + inv_env_len, + ixheaacd_sub16(h22, ptr_ps_dec->h21_h22_vec[2 * group + 1])); + + ptr_ps_dec->H11_H12[2 * group + 0] = ptr_ps_dec->h11_h12_vec[2 * group + 0]; + ptr_ps_dec->H11_H12[2 * group + 1] = ptr_ps_dec->h11_h12_vec[2 * group + 1]; + ptr_ps_dec->H21_H22[2 * group + 0] = ptr_ps_dec->h21_h22_vec[2 * group + 0]; + ptr_ps_dec->H21_H22[2 * group + 1] = ptr_ps_dec->h21_h22_vec[2 * group + 1]; + + ptr_ps_dec->h11_h12_vec[2 * group + 0] = h11; + ptr_ps_dec->h11_h12_vec[2 * group + 1] = h12; + ptr_ps_dec->h21_h22_vec[2 * group + 0] = h21; + ptr_ps_dec->h21_h22_vec[2 * group + 1] = h22; + } +} + +VOID ixheaacd_apply_rot_dec(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, + WORD32 *p_qmf_left_im, WORD32 *p_qmf_right_re, + WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res) { + WORD group, subband, max_subband, usb, k; + WORD32 *p_hyb_left_re, *p_hyb_left_re1; + WORD32 *p_hyb_left_im, *p_hyb_left_im1; + WORD32 *p_hyb_right_re, *p_hyb_right_re1; + WORD32 *p_hyb_right_im, *p_hyb_right_im1; + WORD32 temp_left_real, temp_left_imag; + WORD32 temp_right_real, temp_right_imag; + WORD16 hybrid_resol; + WORD32 tmp_real, tmp_img; + WORD32 tmp_real1, tmp_img1; + WORD32 loopcnt; + WORD16 H11_H12[128 * 2]; + + usb = ptr_ps_dec->usb; + + p_hyb_left_re1 = ptr_ps_dec->ptr_hyb_left_re; + p_hyb_left_im1 = ptr_ps_dec->ptr_hyb_left_im; + p_hyb_right_re1 = ptr_ps_dec->ptr_hyb_right_re; + p_hyb_right_im1 = ptr_ps_dec->ptr_hyb_right_im; + + for (group = 0; group < NO_IID_GROUPS; group++) { + ptr_ps_dec->H11_H12[2 * group + 0] = + ixheaacd_add16(ptr_ps_dec->H11_H12[2 * group + 0], + ptr_ps_dec->delta_h11_h12[2 * group + 0]); + ptr_ps_dec->H11_H12[2 * group + 1] = + ixheaacd_add16(ptr_ps_dec->H11_H12[2 * group + 1], + ptr_ps_dec->delta_h11_h12[2 * group + 1]); + + ptr_ps_dec->H21_H22[2 * group + 0] = + ixheaacd_add16(ptr_ps_dec->H21_H22[2 * group + 0], + ptr_ps_dec->delta_h21_h22[2 * group + 0]); + ptr_ps_dec->H21_H22[2 * group + 1] = + ixheaacd_add16(ptr_ps_dec->H21_H22[2 * group + 1], + ptr_ps_dec->delta_h21_h22[2 * group + 1]); + } + + for (subband = 0; subband < SUBQMF_GROUPS; subband++) { + temp_left_real = ixheaacd_add32_sat( + ixheaacd_mult32x16in32(p_hyb_left_re1[subband], + ptr_ps_dec->H11_H12[2 * subband + 0]), + ixheaacd_mult32x16in32(p_hyb_right_re1[subband], + ptr_ps_dec->H21_H22[2 * subband + 0])); + temp_left_imag = ixheaacd_add32_sat( + ixheaacd_mult32x16in32(p_hyb_left_im1[subband], + ptr_ps_dec->H11_H12[2 * subband + 0]), + ixheaacd_mult32x16in32(p_hyb_right_im1[subband], + ptr_ps_dec->H21_H22[2 * subband + 0])); + temp_right_real = ixheaacd_add32_sat( + ixheaacd_mult32x16in32(p_hyb_left_re1[subband], + ptr_ps_dec->H11_H12[2 * subband + 1]), + ixheaacd_mult32x16in32(p_hyb_right_re1[subband], + ptr_ps_dec->H21_H22[2 * subband + 1])); + temp_right_imag = ixheaacd_add32_sat( + ixheaacd_mult32x16in32(p_hyb_left_im1[subband], + ptr_ps_dec->H11_H12[2 * subband + 1]), + ixheaacd_mult32x16in32(p_hyb_right_im1[subband], + ptr_ps_dec->H21_H22[2 * subband + 1])); + p_hyb_left_re1[subband] = ixheaacd_shl32(temp_left_real, 2); + p_hyb_left_im1[subband] = ixheaacd_shl32(temp_left_imag, 2); + p_hyb_right_re1[subband] = ixheaacd_shl32(temp_right_real, 2); + p_hyb_right_im1[subband] = ixheaacd_shl32(temp_right_imag, 2); + } + + p_hyb_left_re = p_qmf_left_re; + p_hyb_left_im = p_qmf_left_im; + p_hyb_right_re = p_qmf_right_re; + p_hyb_right_im = p_qmf_right_im; + + { + WORD32 *h11_h12_src = (WORD32 *)ptr_ps_dec->H11_H12; + WORD32 *h21_h22_src = (WORD32 *)ptr_ps_dec->H21_H22; + WORD32 *h11_h12_dst = (WORD32 *)H11_H12; + + for (group = SUBQMF_GROUPS; group < NO_IID_GROUPS; group++) { + max_subband = ixheaacd_min32( + usb, sbr_tables_ptr->ps_tables_ptr->borders_group[group + 1]); + for (subband = sbr_tables_ptr->ps_tables_ptr->borders_group[group]; + subband < max_subband; subband++) { + h11_h12_dst[2 * subband] = h11_h12_src[group]; + h11_h12_dst[2 * subband + 1] = h21_h22_src[group]; + } + } + } + loopcnt = (usb + 15) >> 4; + + for (subband = 0; subband < NO_QMF_CHANNELS_IN_HYBRID; subband++) { + tmp_real = *p_hyb_left_re1++; + tmp_img = *p_hyb_left_im1++; + tmp_real1 = *p_hyb_right_re1++; + tmp_img1 = *p_hyb_right_im1++; + + hybrid_resol = ixheaacd_min16(*ptr_res++, 6); + + for (k = hybrid_resol - 2; k >= 0; k--) { + tmp_real = ixheaacd_add32_sat(tmp_real, *p_hyb_left_re1++); + tmp_img = ixheaacd_add32_sat(tmp_img, *p_hyb_left_im1++); + tmp_real1 = ixheaacd_add32_sat(tmp_real1, *p_hyb_right_re1++); + tmp_img1 = ixheaacd_add32_sat(tmp_img1, *p_hyb_right_im1++); + } + + p_hyb_left_re[subband] = tmp_real; + p_hyb_left_im[subband] = tmp_img; + p_hyb_right_re[subband] = tmp_real1; + p_hyb_right_im[subband] = tmp_img1; + } + + for (; subband < usb; subband++) { + temp_left_real = + ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_re[subband], + H11_H12[4 * subband + 0]), + ixheaacd_mult32x16in32(p_hyb_right_re[subband], + H11_H12[4 * subband + 2])); + temp_left_imag = + ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_im[subband], + H11_H12[4 * subband + 0]), + ixheaacd_mult32x16in32(p_hyb_right_im[subband], + H11_H12[4 * subband + 2])); + temp_right_real = + ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_re[subband], + H11_H12[4 * subband + 1]), + ixheaacd_mult32x16in32(p_hyb_right_re[subband], + H11_H12[4 * subband + 3])); + temp_right_imag = + ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_im[subband], + H11_H12[4 * subband + 1]), + ixheaacd_mult32x16in32(p_hyb_right_im[subband], + H11_H12[4 * subband + 3])); + p_hyb_left_re[subband] = ixheaacd_shl32(temp_left_real, 2); + p_hyb_left_im[subband] = ixheaacd_shl32(temp_left_imag, 2); + p_hyb_right_re[subband] = ixheaacd_shl32(temp_right_real, 2); + p_hyb_right_im[subband] = ixheaacd_shl32(temp_right_imag, 2); + } +} diff --git a/decoder/ixheaacd_ps_dec.h b/decoder/ixheaacd_ps_dec.h new file mode 100644 index 0000000..c4f957d --- /dev/null +++ b/decoder/ixheaacd_ps_dec.h @@ -0,0 +1,182 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PS_DEC_H +#define IXHEAACD_PS_DEC_H + +#define MAX_NUM_COLUMNS 32 +#define NUM_OF_QUAD_MIRROR_FILTER_CHNLS 64 +#define NUM_OF_ALL_PASS_CHNLS 23 +#define NUM_OF_DEL_CHNLS \ + (NUM_OF_QUAD_MIRROR_FILTER_CHNLS - NUM_OF_ALL_PASS_CHNLS) +#define DEL_ALL_PASS 2 +#define SMALL_DEL_STRT 12 +#define SMALL_DEL 1 +#define HIGH_DEL 14 +#define NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS \ + (NUM_OF_ALL_PASS_CHNLS - NO_QMF_CHANNELS_IN_HYBRID) +#define NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS \ + (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + NUM_OF_DEL_CHNLS) +#define PEAK_DECAYING_FACT 0x620a +#define NUM_SER_AP_LINKS 3 +#define MAXIM_NUM_OF_PS_ENVLOPS 5 +#define PSC_SQRT05F (0x5a82) +#define NUM_OF_BINS (20) +#define NUM_BANDS_FINE (34) + +typedef WORD16((*REVERB_BUFFERS_RI)[NUM_SER_AP_LINKS])[32 * 2]; +typedef WORD16((REVERB_BUFFERS_CH_RI[5])[NUM_SER_AP_LINKS])[16 * 2]; + +typedef struct { + WORD16 (*delay_buf_qmf_ap_re_im)[32 * 2]; + + WORD16 (*delay_buf_qmf_ld_re_im)[SMALL_DEL_STRT * 2]; + + WORD16 (*delay_buf_qmf_sd_re_im)[2 * 32]; + + WORD16 delay_buf_idx_ser[NUM_SER_AP_LINKS]; + WORD16 delay_sample_ser[NUM_SER_AP_LINKS]; + + REVERB_BUFFERS_RI delay_buf_qmf_ser_re_im; + WORD16 delay_buf_idx; + WORD16 delay_buf_idx_long; + + WORD32 *peak_decay_diff; + WORD32 *energy_prev; + WORD32 *peak_decay_diff_prev; + + WORD32 *ptr_hyb_left_re; + WORD32 *ptr_hyb_left_im; + WORD32 *ptr_hyb_right_re; + WORD32 *ptr_hyb_right_im; + + WORD16 delay_buf_qmf_sub_re_im[DEL_ALL_PASS][16 * 2]; + REVERB_BUFFERS_CH_RI delay_buf_qmf_sub_ser_re_im; + + WORD16 h11_h12_vec[2 * 24]; + WORD16 h21_h22_vec[2 * 24]; + + WORD16 H11_H12[2 * 24]; + WORD16 H21_H22[2 * 24]; + + WORD16 delta_h11_h12[2 * 24]; + WORD16 delta_h21_h22[2 * 24]; + + FLAG force_mono; + + WORD16 delay_buffer_scale; + WORD16 usb; + + WORD16 iid_par_prev[NUM_BANDS_FINE]; + WORD16 icc_par_prev[NUM_BANDS_FINE]; + + FLAG ps_data_present; + + FLAG enable_iid; + FLAG enable_icc; + + FLAG enable_ext; + + WORD16 iid_mode; + WORD16 icc_mode; + FLAG iid_quant; + + FLAG frame_class; + WORD16 num_env; + WORD16 border_position[MAXIM_NUM_OF_PS_ENVLOPS + 2]; + + FLAG iid_dt[MAXIM_NUM_OF_PS_ENVLOPS]; + FLAG icc_dt[MAXIM_NUM_OF_PS_ENVLOPS]; + + WORD16 iid_par_table[MAXIM_NUM_OF_PS_ENVLOPS + 2][NUM_BANDS_FINE]; + WORD16 icc_par_table[MAXIM_NUM_OF_PS_ENVLOPS + 2][NUM_BANDS_FINE]; + + ia_hybrid_struct str_hybrid; +} ia_ps_dec_struct; + +WORD32 ixheaacd_create_psdec(ia_ps_dec_struct *ptr_ps_dec, + VOID *sbr_persistent_mem, WORD32 *ptr_overlap_buf); + +VOID ixheaacd_decorr_filter1_dec(ia_ps_dec_struct *ptr_ps_dec, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio); + +VOID ixheaacd_decorr_filter1_armv7(ia_ps_dec_struct *ptr_ps_dec, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio); + +VOID ixheaacd_decorr_filter2_dec( + ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio); + +VOID ixheaacd_decorr_filter2_armv7( + ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio); + +WORD32 ixheaacd_divide16_pos_dec(WORD32 op1, WORD32 op2); + +WORD32 ixheaacd_divide16_pos_armv7(WORD32 op1, WORD32 op2); + +VOID ixheaacd_decorrelation_dec(ia_ps_dec_struct *ptr_ps_dec, + WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, + WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr); + +VOID ixheaacd_decorrelation_armv7(ia_ps_dec_struct *ptr_ps_dec, + WORD32 *p_buf_left_real, + WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, + WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr); + +VOID ixheaacd_init_ps_scale(ia_ps_dec_struct *ptr_ps_dec, + ia_sbr_scale_fact_struct *sbr_scale_factor); + +VOID ixheaacd_init_rot_env(ia_ps_dec_struct *ptr_ps_dec, WORD16 env, WORD16 usb, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *cos_sin_lookup_tab); + +VOID ixheaacd_apply_ps(ia_ps_dec_struct *ptr_ps_dec, WORD32 **real_buf_left, + WORD32 **imag_buf_left, WORD32 *real_buf_right, + WORD32 *imag_buf_right, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 slot, + ia_sbr_tables_struct *sbr_tables_ptr); + +VOID ixheaacd_apply_rot_dec(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, + WORD32 *p_qmf_left_im, WORD32 *p_qmf_right_re, + WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res); + +VOID ixheaacd_apply_rot_armv7(ia_ps_dec_struct *ptr_ps_dec, + WORD32 *qmf_left_real, WORD32 *qmf_left_imag, + WORD32 *qmf_right_real, WORD32 *qmf_right_imag, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_resol); + +VOID ixheaacd_scale_ps_states(ia_ps_dec_struct *ptr_ps_dec, WORD16 scale); + +extern WORD16 ixheaacd_divideby2(WORD32 op); +extern WORD16 ixheaacd_divideby3(WORD32 op); + +#endif diff --git a/decoder/ixheaacd_pulsedata.h b/decoder/ixheaacd_pulsedata.h new file mode 100644 index 0000000..dd604cd --- /dev/null +++ b/decoder/ixheaacd_pulsedata.h @@ -0,0 +1,41 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PULSEDATA_H +#define IXHEAACD_PULSEDATA_H + +#define MAX_LINES 4 + +typedef struct { + FLAG pulse_data_present; + WORD16 number_pulse; + WORD16 pulse_start_band; + WORD8 pulse_offset[MAX_LINES]; + WORD8 pulse_amp[MAX_LINES]; +} ia_pulse_info_struct; + +WORD32 ixheaacd_read_pulse_data(ia_bit_buf_struct *it_bit_buff, + ia_pulse_info_struct *ptr_pulse_data, + ia_aac_dec_tables_struct *ptr_aac_tables); + +VOID ixheaacd_pulse_data_apply(ia_pulse_info_struct *ptr_pulse_data, + WORD8 *pulse_scratch, + const WORD16 *ptr_swb_offset, WORD object_type); + +#endif /* #ifndef IXHEAACD_PULSEDATA_H */ diff --git a/decoder/ixheaacd_pvc_dec.h b/decoder/ixheaacd_pvc_dec.h new file mode 100644 index 0000000..12099e4 --- /dev/null +++ b/decoder/ixheaacd_pvc_dec.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PVC_DEC_H +#define IXHEAACD_PVC_DEC_H + +typedef struct { + UWORD8 pvc_mode; + UWORD8 div_mode; + UWORD8 ns_mode; + UWORD8 num_time_slots; + UWORD8 nb_high; + UWORD8 nb_high_per_grp; + UWORD8 prev_pvc_flg; + UWORD8 prev_pvc_mode; + UWORD8 pvc_rate; + UWORD8 prev_pvc_rate; + WORD16 dummy; + + UWORD16 pvc_id[PVC_NUM_TIME_SLOTS]; + UWORD16 prev_pvc_id; + WORD8 *p_pred_coeff_tab_1; + WORD8 *p_pred_coeff_tab_2; + UWORD8 *p_pvc_id_boundary; + WORD16 prev_first_bnd_idx; + WORD32 prev_sbr_mode; + FLOAT32 *p_smth_wind_coeff; + FLOAT32 *p_q_fac; + FLOAT32 esg[2 * PVC_NUM_TIME_SLOTS - 1][3]; + FLOAT32 smooth_esg_arr[PVC_NUM_TIME_SLOTS * 3]; + FLOAT32 sbr_range_esg_arr[PVC_NUM_TIME_SLOTS * 8]; + +} ia_pvc_data_struct; + +WORD32 ixheaacd_pvc_process(ia_pvc_data_struct *ptr_pvc_data, + WORD16 first_bnd_idx, WORD32 first_pvc_timelost, + FLOAT32 *a_qmfl, FLOAT32 *a_qmfh); + +#endif /* IXHEAACD_PVC_DEC_H */ diff --git a/decoder/ixheaacd_pvc_rom.c b/decoder/ixheaacd_pvc_rom.c new file mode 100644 index 0000000..3cf4ad5 --- /dev/null +++ b/decoder/ixheaacd_pvc_rom.c @@ -0,0 +1,616 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_pvc_dec.h" + +const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns4[4] = { + 2.9233807677393114e-001f, 2.8099141963307617e-001f, + 2.4582604080136389e-001f, 1.8084446279162875e-001f}; +const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns16[16] = { + 7.9120074720078801e-002f, 7.8929352455315405e-002f, + 7.8356252741836802e-002f, 7.7397889626247995e-002f, + 7.6049149540866515e-002f, 7.4302186813164264e-002f, + 7.2145604983589517e-002f, 6.9563171210312247e-002f, + 6.6531787206720316e-002f, 6.3018197524834882e-002f, + 5.8973400826190611e-002f, 5.4322528277253423e-002f, + 4.8944795582858927e-002f, 4.2628371779453236e-002f, + 3.4946569619925177e-002f, 2.4770667091351901e-002f}; + +const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns3[3] = { + 3.7911649807579761e-001f, 3.5280765527510910e-001f, + 2.6807584664909323e-001f}; +const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns12[12] = { + 1.0440702692045410e-001f, 1.0395945931915132e-001f, + 1.0261281883061703e-001f, 1.0035462721037963e-001f, + 9.7161686576578310e-002f, 9.2995740369570576e-002f, + 8.7795494664707929e-002f, 8.1461666975864891e-002f, + 7.3826916738979523e-002f, 6.4587661325082549e-002f, + 5.3116303570036522e-002f, 3.7720597498577493e-002f}; + +const UWORD8 ixheaacd_pred_coeff_pvc_id_boundaries_1[PVC_ID_NUM_GROUPS - 1] = { + 17, 68}; + +const FLOAT32 ixheaacd_q_factor_table_mode_1[PVC_NB_LOW + 1] = { + 1.0 / 256.0, 1.0 / 256.0, 1.0 / 128.0, 1.0 / 2.0}; + +const WORD8 ixheaacd_pred_coeff_table_1_mode_1 + [PVC_ID_NUM_GROUPS][PVC_NB_LOW][PVC_NB_HIGH_MODE1] = { + {{(WORD8)0x4F, (WORD8)0x5B, (WORD8)0x57, (WORD8)0x52, (WORD8)0x4D, + (WORD8)0x65, (WORD8)0x45, (WORD8)0x57}, + {(WORD8)0xF3, (WORD8)0x0F, (WORD8)0x18, (WORD8)0x20, (WORD8)0x19, + (WORD8)0x4F, (WORD8)0x3D, (WORD8)0x23}, + {(WORD8)0x78, (WORD8)0x57, (WORD8)0x55, (WORD8)0x50, (WORD8)0x50, + (WORD8)0x20, (WORD8)0x36, (WORD8)0x37}}, + {{(WORD8)0x4C, (WORD8)0x5F, (WORD8)0x53, (WORD8)0x37, (WORD8)0x1E, + (WORD8)0xFD, (WORD8)0x15, (WORD8)0x0A}, + {(WORD8)0x05, (WORD8)0x0E, (WORD8)0x28, (WORD8)0x41, (WORD8)0x48, + (WORD8)0x6E, (WORD8)0x54, (WORD8)0x5B}, + {(WORD8)0x59, (WORD8)0x47, (WORD8)0x40, (WORD8)0x40, (WORD8)0x3D, + (WORD8)0x33, (WORD8)0x3F, (WORD8)0x39}}, + {{(WORD8)0x47, (WORD8)0x5F, (WORD8)0x57, (WORD8)0x34, (WORD8)0x3C, + (WORD8)0x2E, (WORD8)0x2E, (WORD8)0x31}, + {(WORD8)0xFA, (WORD8)0x13, (WORD8)0x23, (WORD8)0x4E, (WORD8)0x44, + (WORD8)0x7C, (WORD8)0x34, (WORD8)0x38}, + {(WORD8)0x63, (WORD8)0x43, (WORD8)0x41, (WORD8)0x3D, (WORD8)0x35, + (WORD8)0x19, (WORD8)0x3D, (WORD8)0x33}}}; + +const WORD8 ixheaacd_pred_coeff_table_2_mode_1[PVC_NB_HIGH][PVC_NB_HIGH_MODE1] = + {{(WORD8)0xCB, (WORD8)0xD1, (WORD8)0xCC, (WORD8)0xD2, (WORD8)0xE2, + (WORD8)0xEB, (WORD8)0xE7, (WORD8)0xE8}, + {(WORD8)0x80, (WORD8)0x80, (WORD8)0x80, (WORD8)0x80, (WORD8)0x80, + (WORD8)0x80, (WORD8)0x80, (WORD8)0x80}, + {(WORD8)0x84, (WORD8)0x8C, (WORD8)0x88, (WORD8)0x83, (WORD8)0x90, + (WORD8)0x93, (WORD8)0x86, (WORD8)0x80}, + {(WORD8)0xD7, (WORD8)0xD8, (WORD8)0xC0, (WORD8)0xC7, (WORD8)0xCF, + (WORD8)0xE5, (WORD8)0xF1, (WORD8)0xF6}, + {(WORD8)0xA5, (WORD8)0xA6, (WORD8)0xAA, (WORD8)0xA8, (WORD8)0xB0, + (WORD8)0xB1, (WORD8)0xB8, (WORD8)0xB8}, + {(WORD8)0xD7, (WORD8)0xCB, (WORD8)0xC1, (WORD8)0xC3, (WORD8)0xC5, + (WORD8)0xC9, (WORD8)0xC9, (WORD8)0xCE}, + {(WORD8)0xCA, (WORD8)0xB5, (WORD8)0xB8, (WORD8)0xB3, (WORD8)0xAC, + (WORD8)0xB6, (WORD8)0xBB, (WORD8)0xB8}, + {(WORD8)0xC1, (WORD8)0xC4, (WORD8)0xC3, (WORD8)0xC5, (WORD8)0xC6, + (WORD8)0xCA, (WORD8)0xCA, (WORD8)0xCB}, + {(WORD8)0xE0, (WORD8)0xE1, (WORD8)0xD8, (WORD8)0xCD, (WORD8)0xCB, + (WORD8)0xCB, (WORD8)0xCE, (WORD8)0xCC}, + {(WORD8)0xDB, (WORD8)0xE1, (WORD8)0xDF, (WORD8)0xDB, (WORD8)0xDC, + (WORD8)0xD9, (WORD8)0xD9, (WORD8)0xD6}, + {(WORD8)0xE0, (WORD8)0xDE, (WORD8)0xDD, (WORD8)0xDD, (WORD8)0xE0, + (WORD8)0xE3, (WORD8)0xE5, (WORD8)0xE6}, + {(WORD8)0xCA, (WORD8)0xD2, (WORD8)0xCD, (WORD8)0xCE, (WORD8)0xD5, + (WORD8)0xDB, (WORD8)0xD9, (WORD8)0xDB}, + {(WORD8)0xD2, (WORD8)0xE0, (WORD8)0xDB, (WORD8)0xD5, (WORD8)0xDB, + (WORD8)0xDE, (WORD8)0xE3, (WORD8)0xE1}, + {(WORD8)0xE5, (WORD8)0xDB, (WORD8)0xD0, (WORD8)0xD2, (WORD8)0xD8, + (WORD8)0xDD, (WORD8)0xDB, (WORD8)0xDD}, + {(WORD8)0xC0, (WORD8)0xB5, (WORD8)0xBF, (WORD8)0xDD, (WORD8)0xE3, + (WORD8)0xDC, (WORD8)0xDC, (WORD8)0xE4}, + {(WORD8)0xDB, (WORD8)0xCE, (WORD8)0xC6, (WORD8)0xCF, (WORD8)0xCF, + (WORD8)0xD1, (WORD8)0xD3, (WORD8)0xD4}, + {(WORD8)0xC9, (WORD8)0xD7, (WORD8)0xDA, (WORD8)0xE2, (WORD8)0xE9, + (WORD8)0xE7, (WORD8)0xDF, (WORD8)0xDC}, + {(WORD8)0x0A, (WORD8)0x07, (WORD8)0x0A, (WORD8)0x08, (WORD8)0x19, + (WORD8)0x24, (WORD8)0x1F, (WORD8)0x22}, + {(WORD8)0x1E, (WORD8)0x1F, (WORD8)0x11, (WORD8)0x0E, (WORD8)0x22, + (WORD8)0x2D, (WORD8)0x33, (WORD8)0x32}, + {(WORD8)0xF0, (WORD8)0xDA, (WORD8)0xDC, (WORD8)0x18, (WORD8)0x1F, + (WORD8)0x19, (WORD8)0x0A, (WORD8)0x1E}, + {(WORD8)0x09, (WORD8)0xF8, (WORD8)0xE6, (WORD8)0x05, (WORD8)0x19, + (WORD8)0x11, (WORD8)0x0E, (WORD8)0x0B}, + {(WORD8)0x09, (WORD8)0x10, (WORD8)0x0E, (WORD8)0xE6, (WORD8)0xF4, + (WORD8)0x20, (WORD8)0x22, (WORD8)0xFA}, + {(WORD8)0xF2, (WORD8)0xE5, (WORD8)0xF8, (WORD8)0x0E, (WORD8)0x18, + (WORD8)0x15, (WORD8)0x0D, (WORD8)0x10}, + {(WORD8)0x15, (WORD8)0x13, (WORD8)0x16, (WORD8)0x0A, (WORD8)0x0D, + (WORD8)0x1F, (WORD8)0x1D, (WORD8)0x1B}, + {(WORD8)0xFA, (WORD8)0xFF, (WORD8)0xFE, (WORD8)0xFF, (WORD8)0x09, + (WORD8)0x11, (WORD8)0x03, (WORD8)0x0B}, + {(WORD8)0xFE, (WORD8)0xFA, (WORD8)0xF2, (WORD8)0xF8, (WORD8)0x0C, + (WORD8)0x1E, (WORD8)0x11, (WORD8)0x12}, + {(WORD8)0xFA, (WORD8)0xF8, (WORD8)0x0B, (WORD8)0x17, (WORD8)0x1D, + (WORD8)0x17, (WORD8)0x0E, (WORD8)0x16}, + {(WORD8)0x00, (WORD8)0xF3, (WORD8)0xFD, (WORD8)0x0A, (WORD8)0x1C, + (WORD8)0x17, (WORD8)0xFD, (WORD8)0x08}, + {(WORD8)0xEA, (WORD8)0xEA, (WORD8)0x03, (WORD8)0x12, (WORD8)0x1E, + (WORD8)0x14, (WORD8)0x09, (WORD8)0x04}, + {(WORD8)0x02, (WORD8)0xFE, (WORD8)0x04, (WORD8)0xFB, (WORD8)0x0C, + (WORD8)0x0E, (WORD8)0x07, (WORD8)0x02}, + {(WORD8)0xF6, (WORD8)0x02, (WORD8)0x07, (WORD8)0x0B, (WORD8)0x17, + (WORD8)0x17, (WORD8)0x01, (WORD8)0xFF}, + {(WORD8)0xF5, (WORD8)0xFB, (WORD8)0xFE, (WORD8)0x04, (WORD8)0x12, + (WORD8)0x14, (WORD8)0x0C, (WORD8)0x0D}, + {(WORD8)0x10, (WORD8)0x10, (WORD8)0x0E, (WORD8)0x04, (WORD8)0x07, + (WORD8)0x11, (WORD8)0x0F, (WORD8)0x13}, + {(WORD8)0x0C, (WORD8)0x0F, (WORD8)0xFB, (WORD8)0xF2, (WORD8)0x0A, + (WORD8)0x12, (WORD8)0x09, (WORD8)0x0D}, + {(WORD8)0x0D, (WORD8)0x1D, (WORD8)0xF1, (WORD8)0xF4, (WORD8)0x2A, + (WORD8)0x06, (WORD8)0x3B, (WORD8)0x32}, + {(WORD8)0xFC, (WORD8)0x08, (WORD8)0x06, (WORD8)0x02, (WORD8)0x0E, + (WORD8)0x17, (WORD8)0x08, (WORD8)0x0E}, + {(WORD8)0x07, (WORD8)0x02, (WORD8)0xEE, (WORD8)0xEE, (WORD8)0x2B, + (WORD8)0xF6, (WORD8)0x23, (WORD8)0x13}, + {(WORD8)0x04, (WORD8)0x02, (WORD8)0x05, (WORD8)0x08, (WORD8)0x0B, + (WORD8)0x0E, (WORD8)0xFB, (WORD8)0xFB}, + {(WORD8)0x00, (WORD8)0x04, (WORD8)0x10, (WORD8)0x18, (WORD8)0x22, + (WORD8)0x25, (WORD8)0x1D, (WORD8)0x1F}, + {(WORD8)0xFB, (WORD8)0x0D, (WORD8)0x07, (WORD8)0x00, (WORD8)0x0C, + (WORD8)0x0F, (WORD8)0xFC, (WORD8)0x02}, + {(WORD8)0x00, (WORD8)0x00, (WORD8)0x00, (WORD8)0x01, (WORD8)0x05, + (WORD8)0x07, (WORD8)0x03, (WORD8)0x05}, + {(WORD8)0x04, (WORD8)0x05, (WORD8)0x08, (WORD8)0x13, (WORD8)0xFF, + (WORD8)0xEB, (WORD8)0x0C, (WORD8)0x06}, + {(WORD8)0x05, (WORD8)0x13, (WORD8)0x0E, (WORD8)0x0B, (WORD8)0x12, + (WORD8)0x15, (WORD8)0x09, (WORD8)0x0A}, + {(WORD8)0x09, (WORD8)0x03, (WORD8)0x09, (WORD8)0x05, (WORD8)0x12, + (WORD8)0x16, (WORD8)0x11, (WORD8)0x12}, + {(WORD8)0x14, (WORD8)0x1A, (WORD8)0x06, (WORD8)0x01, (WORD8)0x10, + (WORD8)0x11, (WORD8)0xFE, (WORD8)0x02}, + {(WORD8)0x01, (WORD8)0x0B, (WORD8)0x0B, (WORD8)0x0C, (WORD8)0x18, + (WORD8)0x21, (WORD8)0x10, (WORD8)0x13}, + {(WORD8)0x12, (WORD8)0x0D, (WORD8)0x0A, (WORD8)0x10, (WORD8)0x1C, + (WORD8)0x1D, (WORD8)0x0D, (WORD8)0x10}, + {(WORD8)0x03, (WORD8)0x09, (WORD8)0x14, (WORD8)0x15, (WORD8)0x1B, + (WORD8)0x1A, (WORD8)0x01, (WORD8)0xFF}, + {(WORD8)0x08, (WORD8)0x12, (WORD8)0x13, (WORD8)0x0E, (WORD8)0x16, + (WORD8)0x1D, (WORD8)0x14, (WORD8)0x1B}, + {(WORD8)0x07, (WORD8)0x15, (WORD8)0x1C, (WORD8)0x1B, (WORD8)0x20, + (WORD8)0x21, (WORD8)0x11, (WORD8)0x0E}, + {(WORD8)0x12, (WORD8)0x18, (WORD8)0x19, (WORD8)0x17, (WORD8)0x20, + (WORD8)0x25, (WORD8)0x1A, (WORD8)0x1E}, + {(WORD8)0x0C, (WORD8)0x1A, (WORD8)0x1D, (WORD8)0x22, (WORD8)0x2F, + (WORD8)0x33, (WORD8)0x27, (WORD8)0x28}, + {(WORD8)0x0E, (WORD8)0x1A, (WORD8)0x17, (WORD8)0x10, (WORD8)0x0A, + (WORD8)0x0E, (WORD8)0xFF, (WORD8)0x06}, + {(WORD8)0x1A, (WORD8)0x1C, (WORD8)0x18, (WORD8)0x14, (WORD8)0x1A, + (WORD8)0x16, (WORD8)0x0A, (WORD8)0x0E}, + {(WORD8)0x1E, (WORD8)0x27, (WORD8)0x25, (WORD8)0x26, (WORD8)0x27, + (WORD8)0x2A, (WORD8)0x21, (WORD8)0x21}, + {(WORD8)0xF1, (WORD8)0x0A, (WORD8)0x16, (WORD8)0x1C, (WORD8)0x28, + (WORD8)0x25, (WORD8)0x15, (WORD8)0x19}, + {(WORD8)0x08, (WORD8)0x12, (WORD8)0x09, (WORD8)0x08, (WORD8)0x16, + (WORD8)0x17, (WORD8)0xEF, (WORD8)0xF6}, + {(WORD8)0x0C, (WORD8)0x0B, (WORD8)0x00, (WORD8)0xFC, (WORD8)0x04, + (WORD8)0x09, (WORD8)0xFC, (WORD8)0x03}, + {(WORD8)0xFB, (WORD8)0xF1, (WORD8)0xF8, (WORD8)0x26, (WORD8)0x24, + (WORD8)0x18, (WORD8)0x1D, (WORD8)0x20}, + {(WORD8)0xF9, (WORD8)0x01, (WORD8)0x0C, (WORD8)0x0F, (WORD8)0x07, + (WORD8)0x08, (WORD8)0x06, (WORD8)0x07}, + {(WORD8)0x07, (WORD8)0x06, (WORD8)0x08, (WORD8)0x04, (WORD8)0x07, + (WORD8)0x0D, (WORD8)0x07, (WORD8)0x09}, + {(WORD8)0xFE, (WORD8)0x01, (WORD8)0x06, (WORD8)0x05, (WORD8)0x13, + (WORD8)0x1B, (WORD8)0x14, (WORD8)0x19}, + {(WORD8)0x09, (WORD8)0x0C, (WORD8)0x0E, (WORD8)0x01, (WORD8)0x08, + (WORD8)0x05, (WORD8)0xFB, (WORD8)0xFD}, + {(WORD8)0x07, (WORD8)0x06, (WORD8)0x03, (WORD8)0x0A, (WORD8)0x16, + (WORD8)0x12, (WORD8)0x04, (WORD8)0x07}, + {(WORD8)0x04, (WORD8)0x01, (WORD8)0x00, (WORD8)0x04, (WORD8)0x1F, + (WORD8)0x20, (WORD8)0x0E, (WORD8)0x0A}, + {(WORD8)0x03, (WORD8)0xFF, (WORD8)0xF6, (WORD8)0xFB, (WORD8)0x15, + (WORD8)0x1A, (WORD8)0x00, (WORD8)0x03}, + {(WORD8)0xFC, (WORD8)0x18, (WORD8)0x0B, (WORD8)0x2D, (WORD8)0x35, + (WORD8)0x23, (WORD8)0x12, (WORD8)0x09}, + {(WORD8)0x02, (WORD8)0xFE, (WORD8)0x01, (WORD8)0xFF, (WORD8)0x0C, + (WORD8)0x11, (WORD8)0x0D, (WORD8)0x0F}, + {(WORD8)0xFA, (WORD8)0xE9, (WORD8)0xD9, (WORD8)0xFF, (WORD8)0x0D, + (WORD8)0x05, (WORD8)0x0D, (WORD8)0x10}, + {(WORD8)0xF1, (WORD8)0xE0, (WORD8)0xF0, (WORD8)0x01, (WORD8)0x06, + (WORD8)0x06, (WORD8)0x06, (WORD8)0x10}, + {(WORD8)0xE9, (WORD8)0xD4, (WORD8)0xD7, (WORD8)0x0F, (WORD8)0x14, + (WORD8)0x0B, (WORD8)0x0D, (WORD8)0x16}, + {(WORD8)0x00, (WORD8)0xFF, (WORD8)0xEE, (WORD8)0xE5, (WORD8)0xFF, + (WORD8)0x08, (WORD8)0x02, (WORD8)0xF9}, + {(WORD8)0xE0, (WORD8)0xDA, (WORD8)0xE5, (WORD8)0xFE, (WORD8)0x09, + (WORD8)0x02, (WORD8)0xF9, (WORD8)0x04}, + {(WORD8)0xE0, (WORD8)0xE2, (WORD8)0xF4, (WORD8)0x09, (WORD8)0x13, + (WORD8)0x0C, (WORD8)0x0D, (WORD8)0x09}, + {(WORD8)0xFC, (WORD8)0x02, (WORD8)0x04, (WORD8)0xFF, (WORD8)0x00, + (WORD8)0xFF, (WORD8)0xF8, (WORD8)0xF7}, + {(WORD8)0xFE, (WORD8)0xFB, (WORD8)0xED, (WORD8)0xF2, (WORD8)0xFE, + (WORD8)0xFE, (WORD8)0x08, (WORD8)0x0C}, + {(WORD8)0xF3, (WORD8)0xEF, (WORD8)0xD0, (WORD8)0xE3, (WORD8)0x05, + (WORD8)0x11, (WORD8)0xFD, (WORD8)0xFF}, + {(WORD8)0xFA, (WORD8)0xEF, (WORD8)0xEA, (WORD8)0xFE, (WORD8)0x0D, + (WORD8)0x0E, (WORD8)0xFE, (WORD8)0x02}, + {(WORD8)0xF7, (WORD8)0xFB, (WORD8)0xDB, (WORD8)0xDF, (WORD8)0x14, + (WORD8)0xDD, (WORD8)0x07, (WORD8)0xFE}, + {(WORD8)0xFE, (WORD8)0x08, (WORD8)0x00, (WORD8)0xDB, (WORD8)0xE5, + (WORD8)0x1A, (WORD8)0x13, (WORD8)0xED}, + {(WORD8)0xF9, (WORD8)0xFE, (WORD8)0xFF, (WORD8)0xF4, (WORD8)0xF3, + (WORD8)0x00, (WORD8)0x05, (WORD8)0x02}, + {(WORD8)0xEF, (WORD8)0xDE, (WORD8)0xD8, (WORD8)0xEB, (WORD8)0xEA, + (WORD8)0xF5, (WORD8)0x0E, (WORD8)0x19}, + {(WORD8)0xFB, (WORD8)0xFC, (WORD8)0xFA, (WORD8)0xEC, (WORD8)0xEB, + (WORD8)0xED, (WORD8)0xEE, (WORD8)0xE8}, + {(WORD8)0xEE, (WORD8)0xFC, (WORD8)0xFD, (WORD8)0x00, (WORD8)0x04, + (WORD8)0xFC, (WORD8)0xF0, (WORD8)0xF5}, + {(WORD8)0x00, (WORD8)0xFA, (WORD8)0xF4, (WORD8)0xF1, (WORD8)0xF5, + (WORD8)0xFA, (WORD8)0xFB, (WORD8)0xF9}, + {(WORD8)0xEB, (WORD8)0xF0, (WORD8)0xDF, (WORD8)0xE3, (WORD8)0xEF, + (WORD8)0x07, (WORD8)0x02, (WORD8)0x05}, + {(WORD8)0xF7, (WORD8)0xF0, (WORD8)0xE6, (WORD8)0xE7, (WORD8)0x06, + (WORD8)0x15, (WORD8)0x06, (WORD8)0x0C}, + {(WORD8)0xF1, (WORD8)0xE4, (WORD8)0xD8, (WORD8)0xEA, (WORD8)0x06, + (WORD8)0xF2, (WORD8)0x07, (WORD8)0x09}, + {(WORD8)0xFF, (WORD8)0xFE, (WORD8)0xFE, (WORD8)0xF9, (WORD8)0xFF, + (WORD8)0xFF, (WORD8)0x02, (WORD8)0xF9}, + {(WORD8)0xDD, (WORD8)0xF4, (WORD8)0xF0, (WORD8)0xF1, (WORD8)0xFF, + (WORD8)0xFF, (WORD8)0xEA, (WORD8)0xF1}, + {(WORD8)0xF0, (WORD8)0xF1, (WORD8)0xFD, (WORD8)0x03, (WORD8)0x03, + (WORD8)0xFE, (WORD8)0x00, (WORD8)0x05}, + {(WORD8)0xF1, (WORD8)0xF6, (WORD8)0xE0, (WORD8)0xDF, (WORD8)0xF5, + (WORD8)0x01, (WORD8)0xF4, (WORD8)0xF8}, + {(WORD8)0x02, (WORD8)0x03, (WORD8)0xE5, (WORD8)0xDC, (WORD8)0xE7, + (WORD8)0xFD, (WORD8)0x02, (WORD8)0x08}, + {(WORD8)0xEC, (WORD8)0xF1, (WORD8)0xF5, (WORD8)0xEC, (WORD8)0xF2, + (WORD8)0xF8, (WORD8)0xF6, (WORD8)0xEE}, + {(WORD8)0xF3, (WORD8)0xF4, (WORD8)0xF6, (WORD8)0xF4, (WORD8)0xF5, + (WORD8)0xF1, (WORD8)0xE7, (WORD8)0xEA}, + {(WORD8)0xF7, (WORD8)0xF3, (WORD8)0xEC, (WORD8)0xEA, (WORD8)0xEF, + (WORD8)0xF0, (WORD8)0xEE, (WORD8)0xF1}, + {(WORD8)0xEB, (WORD8)0xF6, (WORD8)0xFB, (WORD8)0xFA, (WORD8)0xEF, + (WORD8)0xF3, (WORD8)0xF3, (WORD8)0xF7}, + {(WORD8)0x01, (WORD8)0x03, (WORD8)0xF1, (WORD8)0xF6, (WORD8)0x05, + (WORD8)0xF8, (WORD8)0xE1, (WORD8)0xEB}, + {(WORD8)0xF5, (WORD8)0xF6, (WORD8)0xF6, (WORD8)0xF4, (WORD8)0xFB, + (WORD8)0xFB, (WORD8)0xFF, (WORD8)0x00}, + {(WORD8)0xF8, (WORD8)0x01, (WORD8)0xFB, (WORD8)0xFA, (WORD8)0xFF, + (WORD8)0x03, (WORD8)0xFE, (WORD8)0x04}, + {(WORD8)0x04, (WORD8)0xFB, (WORD8)0x03, (WORD8)0xFD, (WORD8)0xF5, + (WORD8)0xF7, (WORD8)0xF6, (WORD8)0xFB}, + {(WORD8)0x06, (WORD8)0x09, (WORD8)0xFB, (WORD8)0xF4, (WORD8)0xF9, + (WORD8)0xFA, (WORD8)0xFC, (WORD8)0xFF}, + {(WORD8)0xF5, (WORD8)0xF6, (WORD8)0xF1, (WORD8)0xEE, (WORD8)0xF5, + (WORD8)0xF8, (WORD8)0xF5, (WORD8)0xF9}, + {(WORD8)0xF5, (WORD8)0xF9, (WORD8)0xFA, (WORD8)0xFC, (WORD8)0x07, + (WORD8)0x09, (WORD8)0x01, (WORD8)0xFB}, + {(WORD8)0xD7, (WORD8)0xE9, (WORD8)0xE8, (WORD8)0xEC, (WORD8)0x00, + (WORD8)0x0C, (WORD8)0xFE, (WORD8)0xF1}, + {(WORD8)0xEC, (WORD8)0x04, (WORD8)0xE9, (WORD8)0xDF, (WORD8)0x03, + (WORD8)0xE8, (WORD8)0x00, (WORD8)0xFA}, + {(WORD8)0xE6, (WORD8)0xE2, (WORD8)0xFF, (WORD8)0x0A, (WORD8)0x13, + (WORD8)0x01, (WORD8)0x00, (WORD8)0xF7}, + {(WORD8)0xF1, (WORD8)0xFA, (WORD8)0xF7, (WORD8)0xF5, (WORD8)0x01, + (WORD8)0x06, (WORD8)0x05, (WORD8)0x0A}, + {(WORD8)0xF6, (WORD8)0xF6, (WORD8)0xFC, (WORD8)0xF6, (WORD8)0xE8, + (WORD8)0x11, (WORD8)0xF2, (WORD8)0xFE}, + {(WORD8)0xFE, (WORD8)0x08, (WORD8)0x05, (WORD8)0x12, (WORD8)0xFD, + (WORD8)0xD0, (WORD8)0x0E, (WORD8)0x07}, + {(WORD8)0xF1, (WORD8)0xFE, (WORD8)0xF7, (WORD8)0xF2, (WORD8)0xFB, + (WORD8)0x02, (WORD8)0xFA, (WORD8)0xF8}, + {(WORD8)0xF4, (WORD8)0xEA, (WORD8)0xEC, (WORD8)0xF3, (WORD8)0xFE, + (WORD8)0x01, (WORD8)0xF7, (WORD8)0xF6}, + {(WORD8)0xFF, (WORD8)0xFA, (WORD8)0xFB, (WORD8)0xF9, (WORD8)0xFF, + (WORD8)0x01, (WORD8)0x04, (WORD8)0x03}, + {(WORD8)0x00, (WORD8)0xF9, (WORD8)0xF4, (WORD8)0xFC, (WORD8)0x05, + (WORD8)0xFC, (WORD8)0xF7, (WORD8)0xFB}, + {(WORD8)0xF8, (WORD8)0xFF, (WORD8)0xEF, (WORD8)0xEC, (WORD8)0xFB, + (WORD8)0x04, (WORD8)0xF8, (WORD8)0x03}, + {(WORD8)0xEB, (WORD8)0xF1, (WORD8)0xED, (WORD8)0xF4, (WORD8)0x02, + (WORD8)0x0E, (WORD8)0x0B, (WORD8)0x04}, + {(WORD8)0xF7, (WORD8)0x01, (WORD8)0xF8, (WORD8)0xF4, (WORD8)0xF8, + (WORD8)0xEF, (WORD8)0xF8, (WORD8)0x04}, + {(WORD8)0xEB, (WORD8)0xF0, (WORD8)0xF7, (WORD8)0xFC, (WORD8)0x10, + (WORD8)0x0D, (WORD8)0xF8, (WORD8)0xF8}, + {(WORD8)0xE8, (WORD8)0xFE, (WORD8)0xEE, (WORD8)0xE8, (WORD8)0xED, + (WORD8)0xF7, (WORD8)0xF5, (WORD8)0xF8}, + {(WORD8)0xED, (WORD8)0xEB, (WORD8)0xE9, (WORD8)0xEA, (WORD8)0xF2, + (WORD8)0xF5, (WORD8)0xF4, (WORD8)0xF9}, + {(WORD8)0xEA, (WORD8)0xF2, (WORD8)0xEF, (WORD8)0xEE, (WORD8)0xF9, + (WORD8)0xFE, (WORD8)0xFD, (WORD8)0x02}, + {(WORD8)0xFA, (WORD8)0xFD, (WORD8)0x02, (WORD8)0x0D, (WORD8)0xFA, + (WORD8)0xE4, (WORD8)0x0F, (WORD8)0x01}, + {(WORD8)0xFF, (WORD8)0x08, (WORD8)0x05, (WORD8)0xF6, (WORD8)0xF7, + (WORD8)0xFB, (WORD8)0xF1, (WORD8)0xF1}, + {(WORD8)0xF4, (WORD8)0xEC, (WORD8)0xEE, (WORD8)0xF6, (WORD8)0xEE, + (WORD8)0xEE, (WORD8)0xF8, (WORD8)0x06}, + {(WORD8)0xE8, (WORD8)0xFA, (WORD8)0xF8, (WORD8)0xE8, (WORD8)0xF8, + (WORD8)0xE9, (WORD8)0xEE, (WORD8)0xF9}, + {(WORD8)0xE5, (WORD8)0xE9, (WORD8)0xF0, (WORD8)0x00, (WORD8)0x00, + (WORD8)0xEF, (WORD8)0xF3, (WORD8)0xF8}, + {(WORD8)0xF7, (WORD8)0xFB, (WORD8)0xFB, (WORD8)0xF7, (WORD8)0xF9, + (WORD8)0xF9, (WORD8)0xF5, (WORD8)0xF0}, + {(WORD8)0xFD, (WORD8)0xFF, (WORD8)0xF2, (WORD8)0xEE, (WORD8)0xF2, + (WORD8)0xF5, (WORD8)0xF1, (WORD8)0xF3}}; + +const UWORD8 ixheaacd_pred_coeff_pvc_id_boundaries_2[PVC_ID_NUM_GROUPS - 1] = { + 16, 52}; + +const FLOAT32 ixheaacd_q_factor_table_mode_2[PVC_NB_LOW + 1] = { + 1.0 / 128.0, 1.0 / 128.0, 1.0 / 64.0, 1.0 / 1.0}; + +const WORD8 ixheaacd_pred_coeff_table_1_mode_2 + [PVC_ID_NUM_GROUPS][PVC_NB_LOW][PVC_NB_HIGH_MODE2] = { + {{(WORD8)0x11, (WORD8)0x27, (WORD8)0x0F, (WORD8)0xFD, (WORD8)0x04, + (WORD8)0xFC}, + {(WORD8)0x00, (WORD8)0xBE, (WORD8)0xE3, (WORD8)0xF4, (WORD8)0xDB, + (WORD8)0xF0}, + {(WORD8)0x09, (WORD8)0x1E, (WORD8)0x18, (WORD8)0x1A, (WORD8)0x21, + (WORD8)0x1B}}, + {{(WORD8)0x16, (WORD8)0x28, (WORD8)0x2B, (WORD8)0x29, (WORD8)0x25, + (WORD8)0x32}, + {(WORD8)0xF2, (WORD8)0xE9, (WORD8)0xE4, (WORD8)0xE5, (WORD8)0xE2, + (WORD8)0xD4}, + {(WORD8)0x0E, (WORD8)0x0B, (WORD8)0x0C, (WORD8)0x0D, (WORD8)0x0D, + (WORD8)0x0E}}, + {{(WORD8)0x2E, (WORD8)0x3C, (WORD8)0x20, (WORD8)0x16, (WORD8)0x1B, + (WORD8)0x1A}, + {(WORD8)0xE4, (WORD8)0xC6, (WORD8)0xE5, (WORD8)0xF4, (WORD8)0xDC, + (WORD8)0xDC}, + {(WORD8)0x0F, (WORD8)0x1B, (WORD8)0x18, (WORD8)0x14, (WORD8)0x1E, + (WORD8)0x1A}}}; + +const WORD8 ixheaacd_pred_coeff_table_2_mode_2[PVC_NB_HIGH][PVC_NB_HIGH_MODE2] = + {{(WORD8)0x26, (WORD8)0x25, (WORD8)0x11, (WORD8)0x0C, (WORD8)0xFA, + (WORD8)0x15}, + {(WORD8)0x1B, (WORD8)0x18, (WORD8)0x11, (WORD8)0x0E, (WORD8)0x0E, + (WORD8)0x0E}, + {(WORD8)0x12, (WORD8)0x10, (WORD8)0x10, (WORD8)0x10, (WORD8)0x11, + (WORD8)0x10}, + {(WORD8)0x1E, (WORD8)0x24, (WORD8)0x19, (WORD8)0x15, (WORD8)0x14, + (WORD8)0x12}, + {(WORD8)0x24, (WORD8)0x16, (WORD8)0x12, (WORD8)0x13, (WORD8)0x15, + (WORD8)0x1C}, + {(WORD8)0xEA, (WORD8)0xED, (WORD8)0xEB, (WORD8)0xEA, (WORD8)0xEC, + (WORD8)0xEB}, + {(WORD8)0xFC, (WORD8)0xFD, (WORD8)0xFD, (WORD8)0xFC, (WORD8)0xFE, + (WORD8)0xFE}, + {(WORD8)0x0F, (WORD8)0x0C, (WORD8)0x0B, (WORD8)0x0A, (WORD8)0x0B, + (WORD8)0x0B}, + {(WORD8)0x22, (WORD8)0x0B, (WORD8)0x16, (WORD8)0x18, (WORD8)0x13, + (WORD8)0x19}, + {(WORD8)0x1C, (WORD8)0x14, (WORD8)0x1D, (WORD8)0x20, (WORD8)0x19, + (WORD8)0x1A}, + {(WORD8)0x10, (WORD8)0x08, (WORD8)0x00, (WORD8)0xFF, (WORD8)0x02, + (WORD8)0x05}, + {(WORD8)0x06, (WORD8)0x07, (WORD8)0x05, (WORD8)0x03, (WORD8)0x05, + (WORD8)0x04}, + {(WORD8)0x2A, (WORD8)0x1F, (WORD8)0x12, (WORD8)0x12, (WORD8)0x11, + (WORD8)0x18}, + {(WORD8)0x19, (WORD8)0x19, (WORD8)0x02, (WORD8)0x04, (WORD8)0x00, + (WORD8)0x04}, + {(WORD8)0x18, (WORD8)0x17, (WORD8)0x17, (WORD8)0x15, (WORD8)0x16, + (WORD8)0x15}, + {(WORD8)0x21, (WORD8)0x1E, (WORD8)0x1B, (WORD8)0x19, (WORD8)0x1C, + (WORD8)0x1B}, + {(WORD8)0x3C, (WORD8)0x35, (WORD8)0x20, (WORD8)0x1D, (WORD8)0x30, + (WORD8)0x34}, + {(WORD8)0x3A, (WORD8)0x1F, (WORD8)0x37, (WORD8)0x38, (WORD8)0x33, + (WORD8)0x31}, + {(WORD8)0x37, (WORD8)0x34, (WORD8)0x25, (WORD8)0x27, (WORD8)0x35, + (WORD8)0x34}, + {(WORD8)0x34, (WORD8)0x2E, (WORD8)0x32, (WORD8)0x31, (WORD8)0x34, + (WORD8)0x31}, + {(WORD8)0x36, (WORD8)0x33, (WORD8)0x2F, (WORD8)0x2F, (WORD8)0x32, + (WORD8)0x2F}, + {(WORD8)0x35, (WORD8)0x20, (WORD8)0x2F, (WORD8)0x32, (WORD8)0x2F, + (WORD8)0x2C}, + {(WORD8)0x2E, (WORD8)0x2B, (WORD8)0x2F, (WORD8)0x34, (WORD8)0x36, + (WORD8)0x30}, + {(WORD8)0x3F, (WORD8)0x39, (WORD8)0x30, (WORD8)0x28, (WORD8)0x29, + (WORD8)0x29}, + {(WORD8)0x3C, (WORD8)0x30, (WORD8)0x32, (WORD8)0x37, (WORD8)0x39, + (WORD8)0x36}, + {(WORD8)0x37, (WORD8)0x36, (WORD8)0x30, (WORD8)0x2B, (WORD8)0x26, + (WORD8)0x24}, + {(WORD8)0x44, (WORD8)0x38, (WORD8)0x2F, (WORD8)0x2D, (WORD8)0x2D, + (WORD8)0x2D}, + {(WORD8)0x38, (WORD8)0x2B, (WORD8)0x2C, (WORD8)0x2C, (WORD8)0x30, + (WORD8)0x2D}, + {(WORD8)0x37, (WORD8)0x36, (WORD8)0x2F, (WORD8)0x23, (WORD8)0x2D, + (WORD8)0x32}, + {(WORD8)0x3C, (WORD8)0x39, (WORD8)0x29, (WORD8)0x2E, (WORD8)0x38, + (WORD8)0x37}, + {(WORD8)0x3B, (WORD8)0x3A, (WORD8)0x35, (WORD8)0x32, (WORD8)0x31, + (WORD8)0x2D}, + {(WORD8)0x32, (WORD8)0x31, (WORD8)0x2F, (WORD8)0x2C, (WORD8)0x2D, + (WORD8)0x28}, + {(WORD8)0x2C, (WORD8)0x31, (WORD8)0x32, (WORD8)0x30, (WORD8)0x32, + (WORD8)0x2D}, + {(WORD8)0x35, (WORD8)0x34, (WORD8)0x34, (WORD8)0x34, (WORD8)0x35, + (WORD8)0x33}, + {(WORD8)0x34, (WORD8)0x38, (WORD8)0x3B, (WORD8)0x3C, (WORD8)0x3E, + (WORD8)0x3A}, + {(WORD8)0x3E, (WORD8)0x3C, (WORD8)0x3B, (WORD8)0x3A, (WORD8)0x3C, + (WORD8)0x39}, + {(WORD8)0x3D, (WORD8)0x41, (WORD8)0x46, (WORD8)0x41, (WORD8)0x3D, + (WORD8)0x38}, + {(WORD8)0x44, (WORD8)0x41, (WORD8)0x40, (WORD8)0x3E, (WORD8)0x3F, + (WORD8)0x3A}, + {(WORD8)0x47, (WORD8)0x47, (WORD8)0x47, (WORD8)0x42, (WORD8)0x44, + (WORD8)0x40}, + {(WORD8)0x4C, (WORD8)0x4A, (WORD8)0x4A, (WORD8)0x46, (WORD8)0x49, + (WORD8)0x45}, + {(WORD8)0x53, (WORD8)0x52, (WORD8)0x52, (WORD8)0x4C, (WORD8)0x4E, + (WORD8)0x49}, + {(WORD8)0x41, (WORD8)0x3D, (WORD8)0x39, (WORD8)0x2C, (WORD8)0x2E, + (WORD8)0x2E}, + {(WORD8)0x2D, (WORD8)0x37, (WORD8)0x36, (WORD8)0x30, (WORD8)0x28, + (WORD8)0x36}, + {(WORD8)0x3B, (WORD8)0x32, (WORD8)0x2E, (WORD8)0x2D, (WORD8)0x2D, + (WORD8)0x29}, + {(WORD8)0x40, (WORD8)0x39, (WORD8)0x36, (WORD8)0x35, (WORD8)0x36, + (WORD8)0x32}, + {(WORD8)0x30, (WORD8)0x2D, (WORD8)0x2D, (WORD8)0x2E, (WORD8)0x31, + (WORD8)0x30}, + {(WORD8)0x38, (WORD8)0x3D, (WORD8)0x3B, (WORD8)0x37, (WORD8)0x35, + (WORD8)0x34}, + {(WORD8)0x44, (WORD8)0x3D, (WORD8)0x3C, (WORD8)0x38, (WORD8)0x37, + (WORD8)0x33}, + {(WORD8)0x3A, (WORD8)0x36, (WORD8)0x37, (WORD8)0x37, (WORD8)0x39, + (WORD8)0x36}, + {(WORD8)0x32, (WORD8)0x36, (WORD8)0x37, (WORD8)0x30, (WORD8)0x2E, + (WORD8)0x2A}, + {(WORD8)0x3C, (WORD8)0x33, (WORD8)0x33, (WORD8)0x31, (WORD8)0x33, + (WORD8)0x30}, + {(WORD8)0x30, (WORD8)0x31, (WORD8)0x36, (WORD8)0x37, (WORD8)0x38, + (WORD8)0x34}, + {(WORD8)0x26, (WORD8)0x27, (WORD8)0x2E, (WORD8)0x29, (WORD8)0x1C, + (WORD8)0x16}, + {(WORD8)0x14, (WORD8)0x15, (WORD8)0x1F, (WORD8)0x17, (WORD8)0x15, + (WORD8)0x1C}, + {(WORD8)0x38, (WORD8)0x2D, (WORD8)0x18, (WORD8)0x13, (WORD8)0x1E, + (WORD8)0x2B}, + {(WORD8)0x30, (WORD8)0x22, (WORD8)0x17, (WORD8)0x1A, (WORD8)0x26, + (WORD8)0x2B}, + {(WORD8)0x24, (WORD8)0x20, (WORD8)0x1F, (WORD8)0x10, (WORD8)0x0C, + (WORD8)0x11}, + {(WORD8)0x27, (WORD8)0x1F, (WORD8)0x13, (WORD8)0x17, (WORD8)0x24, + (WORD8)0x2A}, + {(WORD8)0x2F, (WORD8)0x13, (WORD8)0x18, (WORD8)0x13, (WORD8)0x2A, + (WORD8)0x32}, + {(WORD8)0x31, (WORD8)0x1E, (WORD8)0x1E, (WORD8)0x1E, (WORD8)0x21, + (WORD8)0x28}, + {(WORD8)0x2A, (WORD8)0x12, (WORD8)0x19, (WORD8)0x17, (WORD8)0x16, + (WORD8)0x24}, + {(WORD8)0x27, (WORD8)0x0F, (WORD8)0x16, (WORD8)0x1D, (WORD8)0x17, + (WORD8)0x1C}, + {(WORD8)0x2F, (WORD8)0x26, (WORD8)0x25, (WORD8)0x22, (WORD8)0x20, + (WORD8)0x22}, + {(WORD8)0x1E, (WORD8)0x1B, (WORD8)0x1E, (WORD8)0x18, (WORD8)0x1E, + (WORD8)0x24}, + {(WORD8)0x31, (WORD8)0x26, (WORD8)0x0E, (WORD8)0x15, (WORD8)0x15, + (WORD8)0x25}, + {(WORD8)0x2D, (WORD8)0x22, (WORD8)0x1E, (WORD8)0x14, (WORD8)0x10, + (WORD8)0x22}, + {(WORD8)0x25, (WORD8)0x1B, (WORD8)0x18, (WORD8)0x11, (WORD8)0x13, + (WORD8)0x1F}, + {(WORD8)0x2F, (WORD8)0x1B, (WORD8)0x13, (WORD8)0x1B, (WORD8)0x18, + (WORD8)0x22}, + {(WORD8)0x21, (WORD8)0x24, (WORD8)0x1D, (WORD8)0x1C, (WORD8)0x1D, + (WORD8)0x1B}, + {(WORD8)0x23, (WORD8)0x1E, (WORD8)0x28, (WORD8)0x29, (WORD8)0x27, + (WORD8)0x25}, + {(WORD8)0x2E, (WORD8)0x2A, (WORD8)0x1D, (WORD8)0x17, (WORD8)0x26, + (WORD8)0x2D}, + {(WORD8)0x31, (WORD8)0x2C, (WORD8)0x1A, (WORD8)0x0E, (WORD8)0x1A, + (WORD8)0x24}, + {(WORD8)0x26, (WORD8)0x16, (WORD8)0x20, (WORD8)0x1D, (WORD8)0x14, + (WORD8)0x1E}, + {(WORD8)0x29, (WORD8)0x20, (WORD8)0x1B, (WORD8)0x1B, (WORD8)0x17, + (WORD8)0x17}, + {(WORD8)0x1D, (WORD8)0x06, (WORD8)0x1A, (WORD8)0x1E, (WORD8)0x1B, + (WORD8)0x1D}, + {(WORD8)0x2B, (WORD8)0x23, (WORD8)0x1F, (WORD8)0x1F, (WORD8)0x1D, + (WORD8)0x1C}, + {(WORD8)0x27, (WORD8)0x1A, (WORD8)0x0C, (WORD8)0x0E, (WORD8)0x0F, + (WORD8)0x1A}, + {(WORD8)0x29, (WORD8)0x1D, (WORD8)0x1E, (WORD8)0x22, (WORD8)0x22, + (WORD8)0x24}, + {(WORD8)0x20, (WORD8)0x21, (WORD8)0x1B, (WORD8)0x18, (WORD8)0x13, + (WORD8)0x21}, + {(WORD8)0x27, (WORD8)0x0E, (WORD8)0x10, (WORD8)0x14, (WORD8)0x10, + (WORD8)0x1A}, + {(WORD8)0x26, (WORD8)0x24, (WORD8)0x25, (WORD8)0x25, (WORD8)0x26, + (WORD8)0x28}, + {(WORD8)0x1A, (WORD8)0x24, (WORD8)0x25, (WORD8)0x29, (WORD8)0x26, + (WORD8)0x24}, + {(WORD8)0x1D, (WORD8)0x1D, (WORD8)0x15, (WORD8)0x12, (WORD8)0x0F, + (WORD8)0x18}, + {(WORD8)0x1E, (WORD8)0x14, (WORD8)0x13, (WORD8)0x12, (WORD8)0x14, + (WORD8)0x18}, + {(WORD8)0x16, (WORD8)0x13, (WORD8)0x13, (WORD8)0x1A, (WORD8)0x1B, + (WORD8)0x1D}, + {(WORD8)0x20, (WORD8)0x27, (WORD8)0x22, (WORD8)0x24, (WORD8)0x1A, + (WORD8)0x19}, + {(WORD8)0x1F, (WORD8)0x17, (WORD8)0x19, (WORD8)0x18, (WORD8)0x17, + (WORD8)0x18}, + {(WORD8)0x20, (WORD8)0x1B, (WORD8)0x1C, (WORD8)0x1C, (WORD8)0x1B, + (WORD8)0x1A}, + {(WORD8)0x23, (WORD8)0x19, (WORD8)0x1D, (WORD8)0x1F, (WORD8)0x1E, + (WORD8)0x21}, + {(WORD8)0x26, (WORD8)0x1F, (WORD8)0x1D, (WORD8)0x1B, (WORD8)0x19, + (WORD8)0x1A}, + {(WORD8)0x23, (WORD8)0x1E, (WORD8)0x1F, (WORD8)0x20, (WORD8)0x1F, + (WORD8)0x1E}, + {(WORD8)0x29, (WORD8)0x20, (WORD8)0x22, (WORD8)0x20, (WORD8)0x20, + (WORD8)0x1F}, + {(WORD8)0x26, (WORD8)0x23, (WORD8)0x21, (WORD8)0x22, (WORD8)0x23, + (WORD8)0x23}, + {(WORD8)0x29, (WORD8)0x1F, (WORD8)0x24, (WORD8)0x25, (WORD8)0x26, + (WORD8)0x29}, + {(WORD8)0x2B, (WORD8)0x22, (WORD8)0x25, (WORD8)0x27, (WORD8)0x23, + (WORD8)0x21}, + {(WORD8)0x29, (WORD8)0x21, (WORD8)0x19, (WORD8)0x0E, (WORD8)0x22, + (WORD8)0x2D}, + {(WORD8)0x32, (WORD8)0x29, (WORD8)0x1F, (WORD8)0x1C, (WORD8)0x1B, + (WORD8)0x21}, + {(WORD8)0x1E, (WORD8)0x1A, (WORD8)0x1E, (WORD8)0x24, (WORD8)0x25, + (WORD8)0x25}, + {(WORD8)0x24, (WORD8)0x1D, (WORD8)0x21, (WORD8)0x22, (WORD8)0x22, + (WORD8)0x25}, + {(WORD8)0x2C, (WORD8)0x25, (WORD8)0x21, (WORD8)0x22, (WORD8)0x23, + (WORD8)0x25}, + {(WORD8)0x24, (WORD8)0x1E, (WORD8)0x21, (WORD8)0x26, (WORD8)0x2B, + (WORD8)0x2C}, + {(WORD8)0x28, (WORD8)0x24, (WORD8)0x1B, (WORD8)0x1F, (WORD8)0x28, + (WORD8)0x2D}, + {(WORD8)0x23, (WORD8)0x13, (WORD8)0x16, (WORD8)0x22, (WORD8)0x22, + (WORD8)0x29}, + {(WORD8)0x1B, (WORD8)0x23, (WORD8)0x1C, (WORD8)0x20, (WORD8)0x14, + (WORD8)0x0D}, + {(WORD8)0x1E, (WORD8)0x16, (WORD8)0x1A, (WORD8)0x1E, (WORD8)0x1C, + (WORD8)0x1D}, + {(WORD8)0x2B, (WORD8)0x1C, (WORD8)0x1D, (WORD8)0x20, (WORD8)0x1B, + (WORD8)0x1C}, + {(WORD8)0x1C, (WORD8)0x1B, (WORD8)0x23, (WORD8)0x1F, (WORD8)0x19, + (WORD8)0x1E}, + {(WORD8)0x21, (WORD8)0x23, (WORD8)0x26, (WORD8)0x20, (WORD8)0x20, + (WORD8)0x22}, + {(WORD8)0x1D, (WORD8)0x0B, (WORD8)0x19, (WORD8)0x1E, (WORD8)0x11, + (WORD8)0x19}, + {(WORD8)0x18, (WORD8)0x17, (WORD8)0x16, (WORD8)0x17, (WORD8)0x14, + (WORD8)0x16}, + {(WORD8)0x16, (WORD8)0x19, (WORD8)0x1C, (WORD8)0x20, (WORD8)0x21, + (WORD8)0x22}, + {(WORD8)0x30, (WORD8)0x1E, (WORD8)0x22, (WORD8)0x24, (WORD8)0x25, + (WORD8)0x26}, + {(WORD8)0x1B, (WORD8)0x1F, (WORD8)0x17, (WORD8)0x1D, (WORD8)0x1E, + (WORD8)0x21}, + {(WORD8)0x32, (WORD8)0x2B, (WORD8)0x27, (WORD8)0x1F, (WORD8)0x1B, + (WORD8)0x1A}, + {(WORD8)0x28, (WORD8)0x20, (WORD8)0x1A, (WORD8)0x1B, (WORD8)0x1F, + (WORD8)0x23}, + {(WORD8)0x32, (WORD8)0x21, (WORD8)0x20, (WORD8)0x21, (WORD8)0x1D, + (WORD8)0x1F}, + {(WORD8)0x22, (WORD8)0x18, (WORD8)0x12, (WORD8)0x15, (WORD8)0x1B, + (WORD8)0x20}, + {(WORD8)0x27, (WORD8)0x27, (WORD8)0x2A, (WORD8)0x24, (WORD8)0x21, + (WORD8)0x21}, + {(WORD8)0x1E, (WORD8)0x0F, (WORD8)0x0D, (WORD8)0x1A, (WORD8)0x1D, + (WORD8)0x23}, + {(WORD8)0x28, (WORD8)0x25, (WORD8)0x27, (WORD8)0x21, (WORD8)0x17, + (WORD8)0x25}, + {(WORD8)0x2B, (WORD8)0x27, (WORD8)0x23, (WORD8)0x19, (WORD8)0x13, + (WORD8)0x14}, + {(WORD8)0x25, (WORD8)0x2B, (WORD8)0x22, (WORD8)0x22, (WORD8)0x20, + (WORD8)0x21}, + {(WORD8)0x27, (WORD8)0x1B, (WORD8)0x16, (WORD8)0x17, (WORD8)0x0F, + (WORD8)0x15}, + {(WORD8)0x29, (WORD8)0x26, (WORD8)0x23, (WORD8)0x15, (WORD8)0x1E, + (WORD8)0x28}, + {(WORD8)0x24, (WORD8)0x1C, (WORD8)0x19, (WORD8)0x1A, (WORD8)0x18, + (WORD8)0x19}, + {(WORD8)0x2D, (WORD8)0x15, (WORD8)0x27, (WORD8)0x2B, (WORD8)0x24, + (WORD8)0x23}, + {(WORD8)0x2C, (WORD8)0x12, (WORD8)0x1F, (WORD8)0x23, (WORD8)0x1F, + (WORD8)0x20}, + {(WORD8)0x25, (WORD8)0x0F, (WORD8)0x22, (WORD8)0x27, (WORD8)0x1F, + (WORD8)0x21}}; diff --git a/decoder/ixheaacd_pvc_rom.h b/decoder/ixheaacd_pvc_rom.h new file mode 100644 index 0000000..a952c66 --- /dev/null +++ b/decoder/ixheaacd_pvc_rom.h @@ -0,0 +1,53 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_PVC_ROM_H +#define IXHEAACD_PVC_ROM_H + +extern const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns4[4]; +extern const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns16[16]; + +extern const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns3[3]; +extern const FLOAT32 ixheaacd_pvc_smoothing_wind_tab_ns12[12]; + +extern const UWORD8 + ixheaacd_pred_coeff_pvc_id_boundaries_1[PVC_ID_NUM_GROUPS - 1]; + +extern const FLOAT32 ixheaacd_q_factor_table_mode_1[PVC_NB_LOW + 1]; + +extern const WORD8 ixheaacd_pred_coeff_table_1_mode_1[PVC_ID_NUM_GROUPS] + [PVC_NB_LOW] + [PVC_NB_HIGH_MODE1]; + +extern const WORD8 ixheaacd_pred_coeff_table_2_mode_1[PVC_NB_HIGH] + [PVC_NB_HIGH_MODE1]; + +extern const UWORD8 + ixheaacd_pred_coeff_pvc_id_boundaries_2[PVC_ID_NUM_GROUPS - 1]; + +extern const FLOAT32 ixheaacd_q_factor_table_mode_2[PVC_NB_LOW + 1]; + +extern const WORD8 ixheaacd_pred_coeff_table_1_mode_2[PVC_ID_NUM_GROUPS] + [PVC_NB_LOW] + [PVC_NB_HIGH_MODE2]; + +extern const WORD8 ixheaacd_pred_coeff_table_2_mode_2[PVC_NB_HIGH] + [PVC_NB_HIGH_MODE2]; + +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_qmf_dec.c b/decoder/ixheaacd_qmf_dec.c new file mode 100644 index 0000000..582278d --- /dev/null +++ b/decoder/ixheaacd_qmf_dec.c @@ -0,0 +1,2803 @@ +/****************************************************************************** + * * + * 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 + +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_qmf_dec.h" + +#include +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_interface.h" +#include "ixheaacd_function_selector.h" +#include "ixheaacd_audioobjtypes.h" + +#define DCT3_LEN (32) +#define DCT2_LEN (64) + +#define LP_SHIFT_VAL 7 +#define HQ_SHIFT_64 4 +#define RADIXSHIFT 1 +#define ROUNDING_SPECTRA 1 +#define HQ_SHIFT_VAL 4 + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x32in32_shift25(WORD32 a, + WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 25); + + return (result); +} + +VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, + const WORD16 *main_twidle_fwd, const WORD16 *post_tbl, + const WORD16 *w_16, const WORD32 *p_table) { + WORD32 n, k; + + WORD32 temp1[6]; + WORD32 temp2[4]; + WORD16 twid_re, twid_im; + WORD32 *ptr_reverse, *ptr_forward, *p_out, *ptr_out1; + const WORD16 *twidle_fwd, *twidle_rev; + + ptr_forward = &input[49]; + ptr_reverse = &input[47]; + + p_out = output; + twidle_fwd = main_twidle_fwd; + twidle_fwd += 4; + + *p_out++ = input[48] >> LP_SHIFT_VAL; + *p_out++ = 0; + + 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[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)); + 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); + } + + twid_re = *twidle_fwd++; + + twid_im = *twidle_fwd; + twidle_fwd += 3; + + 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[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); + + ptr_forward = output; + ptr_reverse = &output[DCT3_LEN - 1]; + + 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]); + + temp2[0] >>= 1; + temp2[1] >>= 1; + + *ptr_forward++ = temp2[0]; + *ptr_forward++ = temp2[1]; + + twidle_fwd = post_tbl + 2; + twidle_rev = post_tbl + 14; + + for (n = 1; n < DCT3_LEN / 4; n++) { + temp2[0] = *ptr_forward++; + temp2[1] = *ptr_forward--; + temp2[3] = *ptr_reverse--; + temp2[2] = *ptr_reverse++; + + twid_re = *twidle_rev; + twidle_rev -= 2; + twid_im = *twidle_fwd; + twidle_fwd += 2; + + temp1[0] = temp2[0] - temp2[2]; + temp1[1] = (temp2[0] + temp2[2]); + + temp1[2] = temp2[1] + temp2[3]; + temp1[3] = (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[1] >>= 1; + temp1[3] >>= 1; + + *ptr_forward++ = temp1[1] - temp1[4]; + *ptr_forward++ = temp1[3] + temp1[5]; + + *ptr_reverse-- = -temp1[3] + temp1[5]; + *ptr_reverse-- = temp1[1] + temp1[4]; + } + temp2[0] = *ptr_forward++; + temp2[1] = *ptr_forward--; + temp2[3] = *ptr_reverse--; + temp2[2] = *ptr_reverse++; + + twid_re = -*twidle_rev; + twidle_rev -= 2; + twid_im = *twidle_fwd; + twidle_fwd += 2; + + temp1[0] = temp2[0] - temp2[2]; + temp1[1] = (temp2[0] + temp2[2]); + + temp1[2] = temp2[1] + temp2[3]; + temp1[3] = (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[1] >>= 1; + temp1[3] >>= 1; + *ptr_forward++ = temp1[1] + temp1[4]; + *ptr_forward++ = temp1[3] + temp1[5]; + + ixheaacd_radix4bfly(w_16, output, 1, 4); + ixheaacd_postradixcompute4(input, output, p_table, 16); + + output[0] = input[0]; + output[2] = input[1]; + + p_out = input + 2; + ptr_forward = output + 1; + ptr_reverse = output + 30; + ptr_out1 = input + 18; + + for (k = (DCT3_LEN / 4) - 1; k != 0; k--) { + WORD32 tempre, tempim; + + tempre = *p_out++; + tempim = *p_out++; + *ptr_forward = (tempim); + ptr_forward += 2; + *ptr_forward = (tempre); + ptr_forward += 2; + + tempre = *ptr_out1++; + tempim = *ptr_out1++; + *ptr_reverse = (tempim); + ptr_reverse -= 2; + *ptr_reverse = (tempre); + ptr_reverse -= 2; + } + + { + WORD32 tempre, tempim; + tempre = *p_out++; + tempim = *p_out++; + *ptr_forward = (tempim); + ptr_forward += 2; + *ptr_forward = (tempre); + ptr_forward += 2; + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2(WORD32 *inp, WORD32 *out_fwd) { + WORD32 n; + WORD32 *out_rev = out_fwd + DCT2_LEN - 1; + + for (n = 0; n < DCT2_LEN / 2; n++) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +VOID ixheaacd_fftposttw(WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *p_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 1; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 15; + + p_out_fwd = out; + ptr_out_rev = out + DCT2_LEN - 1; + + in1 = ((*p_out_fwd++) << 1); + val1 = ((*p_out_fwd--) << 1); + + *p_out_fwd++ = in1; + *p_out_fwd++ = val1; + + for (k = 1; k <= DCT2_LEN / 4; k++) { + WORD32 temp[4]; + WORD16 twid_re, twid_im; + + temp[0] = *p_out_fwd++; + temp[1] = *p_out_fwd--; + temp[3] = *ptr_out_rev--; + temp[2] = *ptr_out_rev++; + + in2 = temp[3] - temp[1]; + in1 = temp[3] + temp[1]; + + temp[1] = temp[0] - temp[2]; + temp[3] = temp[0] + temp[2]; + + twid_re = *twidle_fwd++; + twid_im = *twidle_rev--; + val1 = ixheaacd_mult32x16in32(in1, twid_re) - + ixheaacd_mult32x16in32(temp[1], twid_im); + val2 = ixheaacd_mult32x16in32(temp[1], twid_re) + + ixheaacd_mult32x16in32(in1, twid_im); + val1 = val1 << 1; + val2 = val2 << 1; + + *p_out_fwd++ = temp[3] + val1; + *p_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp[3] - val1; + } + + return; +} + +VOID ixheaacd_posttwdct2(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 k; + WORD32 inp_re, inp_im, out_re, out_im, last_val, out_re1; + WORD16 *out_fwd2, *out_rev2, *out_rev; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + WORD32 dummy1 = 0, dummy2 = 0x80000000; + + out_rev = out_fwd + DCT2_LEN - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 65; + out_re = *inp++; + out_im = *inp++; + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32(out_re1, (5 - 1))); + + *out_fwd++ = re1; + + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 2; + for (k = DCT2_LEN / 2 - 2; k >= 0; k--) { + inp_re = *inp++; + inp_im = *inp++; + + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd++; + out_re = ixheaacd_sub32(ixheaacd_mult32x16in32(inp_re, twid_re), + ixheaacd_mult32x16in32(inp_im, twid_im)); + out_im = ixheaacd_add32(ixheaacd_mult32x16in32(inp_im, twid_re), + ixheaacd_mult32x16in32(inp_re, twid_im)); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + im1 = ixheaacd_round16(ixheaacd_shl32(out_im, (5 - 1))); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1))); + + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_64(WORD32 *x, WORD32 *X, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + ixheaacd_pretwdct2(x, X); + + ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_32, X, 1, 8); + + ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_32 + 48, X, 4, 2); + + ixheaacd_postradixcompute2(x, X, qmf_dec_tables_ptr->dig_rev_table2_32, 32); + + ixheaacd_fftposttw(x, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2(x, filter_states, qmf_dec_tables_ptr); + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_pretwdct2_32(WORD32 *inp, WORD32 *out_fwd, + int dct2_len) { + WORD32 n; + + WORD32 *out_rev = out_fwd + dct2_len - 1; + for (n = dct2_len / 2 - 1; n >= 0; n--) { + *out_fwd = *inp; + inp++; + *out_rev = *inp; + out_fwd++; + + out_rev--; + inp++; + } + + return; +} + +static PLATFORM_INLINE VOID ixheaacd_fftposttw_32( + WORD32 *out, int dct2_len, ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 *ptr_out_fwd, *ptr_out_rev; + const WORD16 *twidle_fwd, *twidle_rev; + WORD32 in1, in2, val1, val2; + + twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 2; + twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 14; + + ptr_out_fwd = out; + ptr_out_rev = out + dct2_len - 1; + + in1 = ((*ptr_out_fwd++) << 1); + val1 = ((*ptr_out_fwd--) << 1); + + *ptr_out_fwd++ = in1; + *ptr_out_fwd++ = val1; + + for (k = dct2_len / 4 - 1; k >= 0; k--) { + WORD32 temp0, temp1, temp2, temp3; + WORD16 twid_re, twid_im; + + temp0 = *ptr_out_fwd++; + temp1 = *ptr_out_fwd--; + temp3 = *ptr_out_rev--; + temp2 = *ptr_out_rev++; + + in1 = temp1 + temp3; + in2 = -temp1 + temp3; + + temp1 = temp0 - temp2; + temp3 = temp0 + temp2; + + twid_re = *twidle_fwd; + twidle_fwd += 2; + + twid_im = *twidle_rev; + twidle_rev -= 2; + + val1 = ixheaacd_mult32x16in32(in1, twid_re) - + ixheaacd_mult32x16in32(temp1, twid_im); + val2 = ixheaacd_mult32x16in32(temp1, twid_re) + + ixheaacd_mult32x16in32(in1, twid_im); + + val1 = val1 << 1; + val2 = val2 << 1; + + *ptr_out_fwd++ = temp3 + val1; + *ptr_out_fwd++ = in2 + val2; + + *ptr_out_rev-- = -in2 + val2; + *ptr_out_rev-- = temp3 - val1; + } + + return; +} + +static PLATFORM_INLINE WORD32 mult32x16in32t(WORD32 a, WORD16 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + temp_result += 32768; + + result = (WORD32)(temp_result >> 16); + + return (result); +} + +static PLATFORM_INLINE VOID +ixheaacd_posttwdct2_32(WORD32 *inp, WORD16 *out_fwd, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + int k; + WORD32 inp_re, out_re, out_im, last_val, out_re1; + WORD16 *out_rev, *out_rev2, *out_fwd2; + WORD16 twid_re, twid_im; + const WORD16 *twidle_fwd; + WORD16 re1, im1, im2; + WORD32 rounding_fac = 0x8000; + + out_rev = out_fwd + 32 - 1; + out_rev2 = out_fwd - 1; + out_fwd2 = out_fwd + 32 + 1; + out_fwd[32] = 0; + + out_re = *inp++; + out_im = *inp++; + + out_re1 = (out_re + out_im) >> 1; + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re1, (5 - 1))); + *out_fwd++ = re1; + last_val = (out_re - out_im); + + twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 4; + for (k = 14; k >= 0; k--) { + WORD32 temp1, temp2; + inp_re = *inp++; + twid_re = *twidle_fwd++; + twid_im = *twidle_fwd; + twidle_fwd += 3; + + temp1 = ixheaacd_mult32x16in32(inp_re, twid_re); + temp2 = ixheaacd_mult32x16in32(inp_re, twid_im); + + inp_re = *inp++; + + out_re = ixheaacd_sub32(temp1, ixheaacd_mult32x16in32(inp_re, twid_im)); + out_im = ixheaacd_add32(ixheaacd_mult32x16in32(inp_re, twid_re), temp2); + + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, out_re); + out_im = ixheaacd_add32_sat(out_im, out_im); + out_re = ixheaacd_add32_sat(out_re, rounding_fac); + out_im = ixheaacd_add32_sat(out_im, rounding_fac); + re1 = (out_re >> 16); + im1 = (out_im >> 16); + im2 = ixheaacd_negate16(im1); + + *out_fwd++ = re1; + *out_rev2-- = re1; + *out_rev-- = im1; + *out_fwd2++ = im2; + } + twid_re = *twidle_fwd++; + + out_re = ixheaacd_mult32x16in32(last_val, twid_re); + re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re, (5 - 1))); + *out_fwd++ = re1; + *out_rev2-- = re1; + + return; +} + +VOID ixheaacd_dct2_32(WORD32 *inp, WORD32 *out, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD16 *filter_states) { + WORD32 *output; + + output = out + 16; + filter_states = filter_states + 16; + ixheaacd_pretwdct2_32(inp, output, 32); + + ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_16, output, 1, 4); + ixheaacd_postradixcompute4(inp, output, qmf_dec_tables_ptr->dig_rev_table4_16, + 16); + ixheaacd_fftposttw_32(inp, 32, qmf_dec_tables_ptr); + + ixheaacd_posttwdct2_32(inp, filter_states, qmf_dec_tables_ptr); + + return; +} + +VOID ixheaacd_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD16 *p_twiddle, WORD32 *p_dig_rev_tbl) { + WORD32 re2, re3; + WORD16 wim, wre; + + WORD32 i, M_2; + WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1); + + const WORD16 *p_sin; + const WORD16 *p_sin_cos = &qmf_bank->cos_twiddle[0]; + WORD32 subband_tmp[128]; + WORD32 re; + WORD32 im; + WORD32 *psubband, *psubband1; + WORD32 *psubband_t, *psubband1_t; + WORD32 *psubband2, *psubband12; + WORD32 *psubband_t2, *psubband1_t2; + + M_2 = ixheaacd_shr32(M, 1); + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + psubband_t = subband_tmp; + psubband1_t = &subband_tmp[2 * M - 1]; + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + psubband_t2 = &subband_tmp[64]; + psubband1_t2 = &subband_tmp[2 * M - 1 + 64]; + + for (i = (M_2 >> 1) - 1; i >= 0; i--) { + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = ixheaacd_add32(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + *psubband_t++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re, wim)); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wim), + ixheaacd_mult32x16in32(re, wre)); + *psubband_t2++ = ixheaacd_add32(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + + re = *psubband1--; + im = *psubband++; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re, wim)); + *psubband1_t-- = ixheaacd_add32(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + + re = *psubband12--; + im = *psubband2++; + + *psubband1_t2-- = ixheaacd_add32(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + *psubband1_t2-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wim), + ixheaacd_mult32x16in32(re, wre)); + + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = ixheaacd_add32(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + *psubband_t++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re, wim)); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wim), + ixheaacd_mult32x16in32(re, wre)); + *psubband_t2++ = ixheaacd_add32(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + + re = *psubband1--; + im = *psubband++; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re, wim)); + *psubband1_t-- = ixheaacd_add32(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + + re = *psubband12--; + im = *psubband2++; + ; + + *psubband1_t2-- = ixheaacd_add32(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + *psubband1_t2-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wim), + ixheaacd_mult32x16in32(re, wre)); + } + + if (M == 32) { + ixheaacd_radix4bfly(p_twiddle, subband_tmp, 1, 8); + ixheaacd_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2); + ixheaacd_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32); + + ixheaacd_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8); + ixheaacd_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2); + ixheaacd_postradixcompute2(&subband[64], &subband_tmp[64], p_dig_rev_tbl, + 32); + + } else { + ixheaacd_radix4bfly(p_twiddle, subband_tmp, 1, 4); + ixheaacd_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16); + + ixheaacd_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4); + ixheaacd_postradixcompute4(&subband[64], &subband_tmp[64], p_dig_rev_tbl, + 16); + } + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + + re = *psubband1; + + *psubband = *psubband >> 1; + psubband++; + *psubband1 = ixheaacd_negate32(*psubband >> 1); + psubband1--; + + p_sin = &qmf_bank->alt_sin_twiddle[0]; + wim = *p_sin++; + wre = *p_sin++; + + im = *psubband1; + + *psubband1-- = ixheaacd_add32(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + *psubband++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re, wim)); + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + + re = *psubband12; + + *psubband12-- = ixheaacd_negate32_sat(*psubband2 >> 1); + + *psubband2 = psubband2[1] >> 1; + + psubband2++; + + im = *psubband12; + + *psubband2++ = ixheaacd_negate32_sat(ixheaacd_add32( + ixheaacd_mult32x16in32(re, wre), ixheaacd_mult32x16in32(im, wim))); + *psubband12-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + + for (i = (M_2 - 2); i >= 0; i--) { + im = psubband[0]; + + re = psubband[1]; + + re2 = *psubband1; + + *psubband++ = ixheaacd_add32(ixheaacd_mult32x16in32(re, wim), + ixheaacd_mult32x16in32(im, wre)); + *psubband1-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wim), + ixheaacd_mult32x16in32(re, wre)); + + im = psubband2[0]; + + re = psubband2[1]; + + re3 = *psubband12; + + *psubband12-- = ixheaacd_negate32_sat(ixheaacd_add32( + ixheaacd_mult32x16in32(re, wim), ixheaacd_mult32x16in32(im, wre))); + *psubband2++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(re, wre), + ixheaacd_mult32x16in32(im, wim)); + + wim = *p_sin++; + wre = *p_sin++; + im = psubband1[0]; + + *psubband1-- = ixheaacd_add32(ixheaacd_mult32x16in32(re2, wre), + ixheaacd_mult32x16in32(im, wim)); + *psubband++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(im, wre), + ixheaacd_mult32x16in32(re2, wim)); + + im = psubband12[0]; + + *psubband2++ = ixheaacd_negate32_sat(ixheaacd_add32( + ixheaacd_mult32x16in32(re3, wre), ixheaacd_mult32x16in32(im, wim))); + *psubband12-- = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(re3, wim), + ixheaacd_mult32x16in32(im, wre)); + } +} + +VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband, + WORD32 *imag_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 i; + const WORD32 *p_time_in2 = &p_time_in1[2 * NO_ANALYSIS_CHANNELS - 1]; + WORD32 temp1, temp2; + WORD32 *t_real_subband = real_subband; + WORD32 *t_imag_subband = imag_subband; + const WORD16 *tcos; + + for (i = NO_ANALYSIS_CHANNELS - 1; i >= 0; i--) { + temp1 = ixheaacd_shr32(*p_time_in1++, HQ_SHIFT_VAL); + temp2 = ixheaacd_shr32(*p_time_in2--, HQ_SHIFT_VAL); + + *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); + + *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + } + + ixheaacd_cos_sin_mod(real_subband, qmf_bank, qmf_dec_tables_ptr->w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + + tcos = qmf_bank->t_cos; + + for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) { + WORD16 cosh, sinh; + WORD32 re, im; + + re = *real_subband; + im = *imag_subband; + cosh = *tcos++; + sinh = *tcos++; + *real_subband++ = ixheaacd_add32(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)); + } +} + +VOID ixheaacd_sbr_qmfanal32_winadd(WORD16 *inp1, WORD16 *inp2, WORD16 *p_qmf1, + WORD16 *p_qmf2, WORD32 *p_out) { + WORD32 n; + + for (n = 0; n < 32; n += 2) { + WORD32 accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[2 * (n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[2 * (n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[2 * (n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[2 * (n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[2 * (n + 256)])); + p_out[n] = accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[2 * (n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[2 * (n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[2 * (n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[2 * (n + 1 + 256)])); + p_out[n + 1] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[2 * (n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[2 * (n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[2 * (n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[2 * (n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[2 * (n + 256)])); + p_out[n + 32] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[2 * (n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[2 * (n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[2 * (n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, + ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[2 * (n + 1 + 256)])); + p_out[n + 1 + 32] = accu; + } +} + +VOID ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 *inp1, WORD16 *inp2, + WORD16 *p_qmf1, WORD16 *p_qmf2, + WORD32 *p_out) { + WORD32 n; + for (n = 0; n < 32; n += 2) { + WORD32 accu; + accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[(n + 256)])); + p_out[n] = accu; + + accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[(n + 1 + 256)])); + p_out[n + 1] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[(n + 64)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[(n + 128)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[(n + 192)])); + accu = ixheaacd_add32( + accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[(n + 256)])); + p_out[n + 32] = accu; + + accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[(n + 1 + 64)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[(n + 1 + 128)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[(n + 1 + 192)])); + accu = ixheaacd_add32_sat( + accu, ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[(n + 1 + 256)])); + p_out[n + 1 + 32] = accu; + } +} + +VOID ixheaacd_esbr_qmfanal32_winadd(WORD32 *inp1, WORD32 *inp2, WORD32 *p_qmf1, + WORD32 *p_qmf2, WORD32 *p_out, + WORD32 num_band_anal_qmf) { + WORD32 n; + WORD64 accu; + + if (num_band_anal_qmf == 32) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[2 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[2 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } else if (num_band_anal_qmf == 24) { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[(n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[(n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[(n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[(n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[(n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[(n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[(n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[(n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[(n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[(n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + + } else { + for (n = 0; n < num_band_anal_qmf; n += 2) { + accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf], + p_qmf1[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[4 * (n + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 8 * num_band_anal_qmf)])); + p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31); + + accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[4 * (n + 1 + 0)]); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 2 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 4 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 6 * num_band_anal_qmf)])); + accu = ixheaacd_add64( + accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf], + p_qmf2[4 * (n + 1 + 8 * num_band_anal_qmf)])); + p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31); + } + } +} + +VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_sample_buf, + ia_sbr_scale_fact_struct *sbr_scale_factor, + WORD32 **qmf_real, WORD32 **qmf_imag, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD32 ch_fac, WORD32 low_pow_flag, + WORD audio_object_type) { + WORD32 i, k; + WORD32 num_time_slots = qmf_bank->num_time_slots; + + WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS]; + WORD16 *filter_states = qmf_bank->core_samples_buffer; + + WORD16 *fp1, *fp2, *tmp; + + WORD16 *filter_1; + WORD16 *filter_2; + WORD16 *filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos += + (qmf_dec_tables_ptr->qmf_c_eld3 - qmf_bank->analy_win_coeff); + qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3; + } + + filter_1 = qmf_bank->filter_pos; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_2 = filter_1 + 64; + } else { + filter_2 = filter_1 + 32; + } + + sbr_scale_factor->st_lb_scale = 0; + sbr_scale_factor->lb_scale = -10; + if (!low_pow_flag) { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + sbr_scale_factor->lb_scale = -8; + } else { + sbr_scale_factor->lb_scale = -9; + } + qmf_bank->cos_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->t_cos = (WORD16 *)qmf_dec_tables_ptr->sbr_t_cos_sin_l32; + } else { + qmf_bank->t_cos = + (WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld; + } + } + + fp1 = qmf_bank->anal_filter_states; + fp2 = qmf_bank->anal_filter_states + NO_ANALYSIS_CHANNELS; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + filter_2 = qmf_bank->filter_2; + fp1 = qmf_bank->fp1_anal; + fp2 = qmf_bank->fp2_anal; + } + + for (i = 0; i < num_time_slots; i++) { + for (k = 0; k < NO_ANALYSIS_CHANNELS; k++) + filter_states[NO_ANALYSIS_CHANNELS - 1 - k] = time_sample_buf[ch_fac * k]; + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ixheaacd_sbr_qmfanal32_winadd(fp1, fp2, filter_1, filter_2, + analysis_buffer); + } else { + ixheaacd_sbr_qmfanal32_winadd_eld(fp1, fp2, filter_1, filter_2, + analysis_buffer); + } + + time_sample_buf += NO_ANALYSIS_CHANNELS * ch_fac; + + filter_states -= NO_ANALYSIS_CHANNELS; + if (filter_states < qmf_bank->anal_filter_states) { + filter_states = qmf_bank->anal_filter_states + 288; + } + + tmp = fp1; + fp1 = fp2; + fp2 = tmp; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + filter_1 += 64; + filter_2 += 64; + } else { + filter_1 += 32; + filter_2 += 32; + } + + filt_ptr = filter_1; + filter_1 = filter_2; + filter_2 = filt_ptr; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + if (filter_2 > (qmf_bank->analy_win_coeff + 640)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 64; + } + } else { + if (filter_2 > (qmf_bank->analy_win_coeff + 320)) { + filter_1 = (WORD16 *)qmf_bank->analy_win_coeff; + filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 32; + } + } + + if (!low_pow_flag) { + ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i], + qmf_bank, qmf_dec_tables_ptr); + } else { + ixheaacd_dct3_32( + (WORD32 *)analysis_buffer, qmf_real[i], qmf_dec_tables_ptr->dct23_tw, + qmf_dec_tables_ptr->post_fft_tbl, qmf_dec_tables_ptr->w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + } + } + + qmf_bank->filter_pos = filter_1; + qmf_bank->core_samples_buffer = filter_states; + + if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD) + + { + qmf_bank->fp1_anal = fp1; + qmf_bank->fp2_anal = fp2; + qmf_bank->filter_2 = filter_2; + } +} + +static PLATFORM_INLINE VOID +ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states, + ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 L = syn_qmf->no_channels; + const WORD32 M = (L >> 1); + WORD32 *dct_in = qmf_real; + WORD32 time_out[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 *ptime_out = &time_out[0]; + + if (L == 64) + ixheaacd_dct2_64(dct_in, ptime_out, qmf_dec_tables_ptr, filter_states + M); + else + ixheaacd_dct2_32(dct_in, time_out, qmf_dec_tables_ptr, filter_states); + + filter_states[3 * M] = 0; +} + +static VOID ixheaacd_inv_emodulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + if (syn_qmf->no_channels == 64) + ixheaacd_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->w_32, + qmf_dec_tables_ptr->dig_rev_table2_32); + else + ixheaacd_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); +} + +VOID ixheaacd_esbr_radix4bfly(const WORD32 *w, WORD32 *x, WORD32 index1, + WORD32 index) { + int i; + WORD32 l1, l2, h2, fft_jmp; + WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0; + WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0; + WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1; + WORD32 x_h2_0, x_h2_1; + WORD32 si10, si20, si30, co10, co20, co30; + + WORD64 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6; + WORD64 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12; + WORD32 *x_l1; + WORD32 *x_l2; + WORD32 *x_h2; + const WORD32 *w_ptr = w; + WORD32 i1; + + h2 = index << 1; + l1 = index << 2; + l2 = (index << 2) + (index << 1); + + x_l1 = &(x[l1]); + x_l2 = &(x[l2]); + x_h2 = &(x[h2]); + + fft_jmp = 6 * (index); + + for (i1 = 0; i1 < index1; i1++) { + for (i = 0; i < index; i++) { + si10 = (*w_ptr++); + co10 = (*w_ptr++); + si20 = (*w_ptr++); + co20 = (*w_ptr++); + si30 = (*w_ptr++); + co30 = (*w_ptr++); + + x_0 = x[0]; + x_h2_0 = x[h2]; + x_l1_0 = x[l1]; + x_l2_0 = x[l2]; + + xh0_0 = x_0 + x_l1_0; + xl0_0 = x_0 - x_l1_0; + + xh20_0 = x_h2_0 + x_l2_0; + xl20_0 = x_h2_0 - x_l2_0; + + x[0] = xh0_0 + xh20_0; + xt0_0 = 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; + + xh21_0 = x_h2_1 + x_l2_1; + xl21_0 = x_h2_1 - x_l2_1; + + x[1] = xh1_0 + xh21_0; + yt0_0 = xh1_0 - xh21_0; + + xt1_0 = xl0_0 + xl21_0; + xt2_0 = xl0_0 - xl21_0; + + yt2_0 = xl1_0 + xl20_0; + yt1_0 = xl1_0 - xl20_0; + + mul_11 = ixheaacd_mult64(xt2_0, co30); + mul_3 = ixheaacd_mult64(yt2_0, si30); + x[l2] = (WORD32)((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; + + mul_12 = ixheaacd_mult64(xt0_0, co20); + mul_2 = ixheaacd_mult64(yt0_0, si20); + x[l1] = (WORD32)((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; + + mul_4 = ixheaacd_mult64(xt1_0, co10); + mul_1 = ixheaacd_mult64(yt1_0, si10); + x[h2] = (WORD32)((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 += 2; + } + x += fft_jmp; + w_ptr = w_ptr - fft_jmp; + } +} + +VOID ixheaacd_esbr_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *pdig_rev_tbl, + WORD32 npoints) { + WORD32 i, j = 0, k; + WORD32 h2; + WORD32 x_0, x_1, x_2, x_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 2); + y3 = y2 + (WORD32)(npoints >> 2); + j0 = 8; + n0 = npoints >> 1; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *pdig_rev_tbl++ >> 2; + + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + x_6 = *x0++; + x_7 = *x0++; + + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + x_e = *x2++; + x_f = *x2++; + + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} + +VOID ixheaacd_esbr_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, + WORD32 npoints) { + WORD32 i, j = 0, k; + WORD32 h2; + WORD32 xh0_0, xh1_0, xl0_0, xl1_0; + WORD32 xh0_1, xh1_1, xl0_1, xl1_1; + WORD32 x_0, x_1, x_2, x_3; + WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 1); + y3 = y2 + (WORD32)(npoints >> 1); + + j0 = 4; + n0 = npoints >> 2; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *p_dig_rev_tbl++ >> 2; + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} + +VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl) { + WORD32 z; + WORD32 temp[128]; + WORD32 scaleshift = 0; + + WORD32 re2, re3; + WORD32 wim, wre; + + WORD32 i, M_2; + WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1); + + const WORD32 *p_sin; + const WORD32 *p_sin_cos; + + WORD32 subband_tmp[128]; + WORD32 re; + WORD32 im; + WORD32 *psubband, *psubband1; + WORD32 *psubband_t, *psubband1_t; + WORD32 *psubband2, *psubband12; + WORD32 *psubband_t2, *psubband1_t2; + + M_2 = ixheaacd_shr32(M, 1); + + p_sin_cos = qmf_bank->esbr_cos_twiddle; + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + psubband_t = subband_tmp; + psubband1_t = &subband_tmp[2 * M - 1]; + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + psubband_t2 = &subband_tmp[64]; + psubband1_t2 = &subband_tmp[2 * M - 1 + 64]; + + for (i = (M_2 >> 1) - 1; i >= 0; i--) { + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband_t++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + *psubband_t2++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + + re = *psubband1--; + im = *psubband++; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + *psubband1_t-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + + re = *psubband12--; + im = *psubband2++; + + *psubband1_t2-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1_t2-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + + re = *psubband++; + im = *psubband1--; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband_t++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband_t++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + re = *psubband2++; + im = *psubband12--; + + *psubband_t2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + *psubband_t2++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + + re = *psubband1--; + im = *psubband++; + + wim = *p_sin_cos++; + wre = *p_sin_cos++; + + *psubband1_t-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + *psubband1_t-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + + re = *psubband12--; + im = *psubband2++; + + *psubband1_t2-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1_t2-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + } + + if (M == 32) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2); + ixheaacd_esbr_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8); + ixheaacd_esbr_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2); + ixheaacd_esbr_postradixcompute2(&subband[64], &subband_tmp[64], + p_dig_rev_tbl, 32); + + } + + else if (M == 16) { + ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 4); + ixheaacd_esbr_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16); + + ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4); + ixheaacd_esbr_postradixcompute4(&subband[64], &subband_tmp[64], + p_dig_rev_tbl, 16); + + } + + else if (M == 12) { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[12 + z] = subband_tmp[2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z]; + subband[2 * z + 1] = temp[z + 12]; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[12 + z] = subband_tmp[64 + 2 * z + 1]; + } + + ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z]; + subband[64 + 2 * z + 1] = temp[z + 12]; + } + + } + + else { + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[2 * z]; + temp[8 + z] = subband_tmp[2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[2 * z] = temp[z] << scaleshift; + subband[2 * z + 1] = temp[z + 8] << scaleshift; + } + scaleshift = 0; + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + temp[z] = subband_tmp[64 + 2 * z]; + temp[8 + z] = subband_tmp[64 + 2 * z + 1]; + } + + (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift); + + for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { + subband[64 + 2 * z] = temp[z] << scaleshift; + subband[64 + 2 * z + 1] = temp[8 + z] << scaleshift; + } + } + + psubband = &subband[0]; + psubband1 = &subband[2 * M - 1]; + + re = *psubband1; + + *psubband = *psubband >> 1; + psubband++; + *psubband1 = ixheaacd_negate32(*psubband >> 1); + psubband1--; + + p_sin = qmf_bank->esbr_alt_sin_twiddle; + + wim = *p_sin++; + wre = *p_sin++; + + im = *psubband1; + + *psubband1-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re, wim))) >> + 32); + + psubband2 = &subband[64]; + psubband12 = &subband[2 * M - 1 + 64]; + + re = *psubband12; + + *psubband12-- = ixheaacd_negate32_sat(*psubband2 >> 1); + + *psubband2 = psubband2[1] >> 1; + + psubband2++; + + im = *psubband12; + + *psubband2++ = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wre), ixheaacd_mult64(im, wim))) >> + 32)); + *psubband12-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re, wim), + ixheaacd_mult64(im, wre))) >> + 32); + + for (i = (M_2 - 2); i >= 0; i--) { + im = psubband[0]; + + re = psubband[1]; + + re2 = *psubband1; + + *psubband++ = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32); + *psubband1-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wim), + ixheaacd_mult64(re, wre))) >> + 32); + + im = psubband2[0]; + + re = psubband2[1]; + + re3 = *psubband12; + + *psubband12-- = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re, wim), ixheaacd_mult64(im, wre))) >> + 32)); + *psubband2++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re, wre), + ixheaacd_mult64(im, wim))) >> + 32); + + wim = *p_sin++; + wre = *p_sin++; + im = psubband1[0]; + + *psubband1-- = (WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re2, wre), ixheaacd_mult64(im, wim))) >> + 32); + *psubband++ = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, wre), + ixheaacd_mult64(re2, wim))) >> + 32); + + im = psubband12[0]; + + *psubband2++ = ixheaacd_negate32_sat((WORD32)( + (ixheaacd_add64(ixheaacd_mult64(re3, wre), ixheaacd_mult64(im, wim))) >> + 32)); + *psubband12-- = (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(re3, wim), + ixheaacd_mult64(im, wre))) >> + 32); + } +} + +VOID ixheaacd_esbr_fwd_modulation( + const WORD32 *time_sample_buf, WORD32 *real_subband, WORD32 *imag_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + WORD32 i; + const WORD32 *time_sample_buf1 = + &time_sample_buf[2 * qmf_bank->no_channels - 1]; + WORD32 temp1, temp2; + WORD32 *t_real_subband = real_subband; + WORD32 *t_imag_subband = imag_subband; + const WORD32 *tcos; + + for (i = qmf_bank->no_channels - 1; i >= 0; i--) { + temp1 = ixheaacd_shr32(*time_sample_buf++, HQ_SHIFT_64); + temp2 = ixheaacd_shr32(*time_sample_buf1--, HQ_SHIFT_64); + + *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); + + *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + } + + ixheaacd_esbr_cos_sin_mod(real_subband, qmf_bank, + qmf_dec_tables_ptr->esbr_w_16, + qmf_dec_tables_ptr->dig_rev_table4_16); + + tcos = qmf_bank->esbr_t_cos; + + for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) { + WORD32 cosh, sinh; + WORD32 re, im; + + re = *real_subband; + im = *imag_subband; + cosh = *tcos++; + sinh = *tcos++; + *real_subband++ = (WORD32)((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); + } +} + +VOID ixheaacd_esbr_inv_modulation( + WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) { + ixheaacd_esbr_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->esbr_w_32, + qmf_dec_tables_ptr->dig_rev_table2_32); +} + +VOID ixheaacd_sbr_qmfsyn64_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac) { + WORD32 k; + WORD32 rounding_fac = 0x8000; + rounding_fac = rounding_fac >> shift; + + for (k = 0; k < 64; k++) { + WORD32 syn_out = rounding_fac; + + syn_out = ixheaacd_add32(syn_out, + ixheaacd_mult16x16in32(tmp1[0 + k], inp1[k + 0])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[256 + k], inp1[k + 128])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[512 + k], inp1[k + 256])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[768 + k], inp1[k + 384])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[1024 + k], inp1[k + 512])); + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[128 + k], inp1[k + 64])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[384 + k], inp1[k + 192])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[640 + k], inp1[k + 320])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[896 + k], inp1[k + 448])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[1152 + k], inp1[k + 576])); + + sample_buffer[ch_fac * k] = (ixheaacd_shl32_sat(syn_out, shift) >> 16); + } +} + +VOID ixheaacd_esbr_qmfsyn64_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *inp1, + WORD32 *sample_buffer, WORD32 ch_fac) { + WORD32 k; + + for (k = 0; k < 64; k++) { + WORD64 syn_out = 0; + + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[0 + k], inp1[k + 0])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[256 + k], inp1[k + 128])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[512 + k], inp1[k + 256])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[768 + k], inp1[k + 384])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp1[1024 + k], inp1[k + 512])); + + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[128 + k], inp1[k + 64])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[384 + k], inp1[k + 192])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[640 + k], inp1[k + 320])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[896 + k], inp1[k + 448])); + syn_out = + ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[1152 + k], inp1[k + 576])); + + sample_buffer[ch_fac * k] = (WORD32)(syn_out >> 31); + } +} + +VOID ixheaacd_sbr_qmfsyn32_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1, + WORD16 *sample_buffer, FLAG shift, + WORD32 ch_fac) { + WORD32 k; + WORD32 rounding_fac = 0x8000; + rounding_fac = rounding_fac >> shift; + + for (k = 0; k < 32; k++) { + WORD32 syn_out = rounding_fac; + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[0 + k], inp1[2 * (k + 0)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[128 + k], inp1[2 * (k + 64)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[256 + k], inp1[2 * (k + 128)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[384 + k], inp1[2 * (k + 192)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp1[512 + k], inp1[2 * (k + 256)])); + + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[64 + k], inp1[2 * (k + 32)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[192 + k], inp1[2 * (k + 96)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[320 + k], inp1[2 * (k + 160)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[448 + k], inp1[2 * (k + 224)])); + syn_out = ixheaacd_add32( + syn_out, ixheaacd_mult16x16in32(tmp2[576 + k], inp1[2 * (k + 288)])); + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + if (shift == 2) { + syn_out = ixheaacd_add32_sat(syn_out, syn_out); + } + sample_buffer[ch_fac * k] = (syn_out >> 16); + } +} + +VOID ixheaacd_shiftrountine(WORD32 *qmf_real, WORD32 *qmf_imag, WORD32 len, + WORD32 common_shift) { + WORD32 treal, timag; + WORD32 j; + + if (common_shift < 0) { + WORD32 cshift = -common_shift; + cshift = ixheaacd_min32(cshift, 31); + for (j = len - 1; j >= 0; j--) { + treal = *qmf_real; + timag = *qmf_imag; + + treal = (ixheaacd_shr32(treal, cshift)); + timag = (ixheaacd_shr32(timag, cshift)); + + *qmf_real++ = treal; + *qmf_imag++ = timag; + } + } else { + for (j = len - 1; j >= 0; j--) { + treal = (ixheaacd_shl32_sat(*qmf_real, common_shift)); + timag = (ixheaacd_shl32_sat(*qmf_imag, common_shift)); + *qmf_real++ = treal; + *qmf_imag++ = timag; + } + } +} + +VOID ixheaacd_shiftrountine_with_rnd(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD16 *filter_states, WORD32 len, + WORD32 shift) { + WORD16 *filter_states_rev = filter_states + len; + WORD32 treal, timag; + WORD32 j; + + for (j = (len - 1); j >= 0; j -= 2) { + WORD32 r1, r2, i1, i2; + i2 = qmf_imag[j]; + r2 = qmf_real[j]; + + r1 = *qmf_real++; + i1 = *qmf_imag++; + + timag = ixheaacd_add32(i1, r1); + timag = (ixheaacd_shl32_sat(timag, shift)); + filter_states_rev[j] = ixheaacd_round16(timag); + + treal = ixheaacd_sub32(i2, r2); + treal = (ixheaacd_shl32_sat(treal, shift)); + filter_states[j] = ixheaacd_round16(treal); + + treal = ixheaacd_sub32(i1, r1); + treal = (ixheaacd_shl32_sat(treal, shift)); + *filter_states++ = ixheaacd_round16(treal); + + timag = ixheaacd_add32(i2, r2); + ; + timag = (ixheaacd_shl32_sat(timag, shift)); + *filter_states_rev++ = ixheaacd_round16(timag); + } +} + +VOID ixheaacd_shiftrountine_with_rnd_eld(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD16 *filter_states, WORD32 len, + WORD32 shift) { + WORD16 *filter_states_rev = filter_states + len; + WORD32 treal, timag; + WORD32 j; + + for (j = (len - 1); j >= 0; j -= 2) { + WORD32 r1, r2, i1, i2; + i2 = qmf_imag[j]; + r2 = qmf_real[j]; + r1 = *qmf_real++; + i1 = *qmf_imag++; + + timag = ixheaacd_negate32(ixheaacd_add32(i1, r1)); + timag = (ixheaacd_shl32_sat(timag, shift)); + filter_states_rev[j] = ixheaacd_round16(timag); + + treal = ixheaacd_sub32(r2, i2); + treal = (ixheaacd_shl32_sat(treal, shift)); + filter_states[j] = ixheaacd_round16(treal); + + treal = ixheaacd_sub32(r1, i1); + treal = (ixheaacd_shl32_sat(treal, shift)); + *filter_states++ = ixheaacd_round16(treal); + + timag = ixheaacd_negate32(ixheaacd_add32(i2, r2)); + timag = (ixheaacd_shl32_sat(timag, shift)); + *filter_states_rev++ = ixheaacd_round16(timag); + } +} + +VOID ixheaacd_shiftrountine_with_rnd_hq(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD32 *filter_states, WORD32 len, + WORD32 shift) { + WORD32 *filter_states_rev = filter_states + len; + WORD32 treal, timag; + WORD32 j; + + for (j = (len - 1); j >= 0; j -= 2) { + WORD32 r1, r2, i1, i2; + i2 = qmf_imag[j]; + r2 = qmf_real[j]; + r1 = *qmf_real++; + i1 = *qmf_imag++; + + timag = ixheaacd_add32(i1, r1); + timag = (ixheaacd_shl32_sat(timag, shift)); + filter_states_rev[j] = timag; + + treal = ixheaacd_sub32(i2, r2); + treal = (ixheaacd_shl32_sat(treal, shift)); + filter_states[j] = treal; + + treal = ixheaacd_sub32(i1, r1); + treal = (ixheaacd_shl32_sat(treal, shift)); + *filter_states++ = treal; + + timag = ixheaacd_add32(i2, r2); + timag = (ixheaacd_shl32_sat(timag, shift)); + *filter_states_rev++ = timag; + } +} + +void ixheaacd_sbr_pre_twiddle(WORD32 *p_xre, WORD32 *p_xim, + WORD16 *p_twiddles) { + int k; + + for (k = 62; k >= 0; k--) { + WORD32 x_re = *p_xre; + WORD32 x_im = *p_xim; + + WORD16 ixheaacd_cosine = *p_twiddles++; + WORD16 ixheaacd_sine = *p_twiddles++; + + WORD32 re, im; + + re = ixheaacd_mac32x16in32_shl( + ixheaacd_mult32x16in32_shl(x_re, ixheaacd_cosine), x_im, ixheaacd_sine); + im = ixheaacd_sub32(ixheaacd_mult32x16in32_shl(x_im, ixheaacd_cosine), + ixheaacd_mult32x16in32_shl(x_re, ixheaacd_sine)); + + *p_xre++ = re; + *p_xim++ = im; + } +} + +VOID ixheaacd_cplx_synt_qmffilt( + WORD32 **qmf_real, WORD32 **qmf_imag, WORD32 split, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 *time_out, + ia_sbr_qmf_filter_bank_struct *qmf_bank, ia_ps_dec_struct *ptr_ps_dec, + FLAG active, FLAG low_pow_flag, ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD32 ch_fac, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type) { + WORD32 i; + + WORD32 code_scale_factor; + WORD32 scale_factor; + WORD32 out_scale_factor; + WORD32 low_band_scale_factor; + WORD32 high_band_scale_factor; + WORD16 *filter_states = qmf_bank->filter_states; + WORD32 **ptr_qmf_imag_temp; + WORD32 qmf_real2[2 * NO_SYNTHESIS_CHANNELS]; + + WORD32 no_synthesis_channels = qmf_bank->no_channels; + WORD32 p1; + + WORD16 *fp1; + WORD16 *fp2; + + WORD32 sixty4 = NO_SYNTHESIS_CHANNELS; + WORD32 thirty2 = qmf_bank->no_channels; + + WORD16 *filter_coeff; + WORD32 num_time_slots = qmf_bank->num_time_slots; + WORD32 ixheaacd_drc_offset; + WORD32 ov_lb_scale = sbr_scale_factor->ov_lb_scale; + WORD32 lb_scale = sbr_scale_factor->lb_scale; + WORD32 st_syn_scale = sbr_scale_factor->st_syn_scale; + WORD32 ov_lb_shift, lb_shift, hb_shift; + + WORD32 *qmf_real_tmp = qmf_real2; + WORD32 *qmf_imag_tmp = &qmf_real2[NO_SYNTHESIS_CHANNELS]; + WORD32 env = 0; + + WORD32 common_shift; + + if (no_synthesis_channels == 32) { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32; + qmf_bank->t_cos = + (WORD16 *) + sbr_tables_ptr->qmf_dec_tables_ptr->sbr_cos_sin_twiddle_ds_l32; + } else { + qmf_bank->cos_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64; + qmf_bank->alt_sin_twiddle = + (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64; + } + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c; + } else { + qmf_bank->filter_pos_syn += + (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld - qmf_bank->p_filter); + qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld; + } + + fp1 = &filter_states[0]; + fp2 = fp1 + no_synthesis_channels; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + fp1 = qmf_bank->fp1_syn; + fp2 = qmf_bank->fp2_syn; + sixty4 = qmf_bank->sixty4; + } + + filter_coeff = qmf_bank->filter_pos_syn; + + if (active) { + code_scale_factor = scale_factor = sbr_scale_factor->ps_scale; + } else { + code_scale_factor = ixheaacd_min32(lb_scale, ov_lb_scale); + scale_factor = sbr_scale_factor->hb_scale; + } + + low_band_scale_factor = (st_syn_scale - code_scale_factor); + high_band_scale_factor = (st_syn_scale - scale_factor); + + p1 = 0; + if (low_pow_flag) + + { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 4; + lb_shift = (st_syn_scale - lb_scale) - 4; + hb_shift = high_band_scale_factor - 4; + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 1)); + ptr_qmf_imag_temp = 0; + + } + + else { + out_scale_factor = -((sbr_scale_factor->st_syn_scale - 3)); + if (active) { + ov_lb_shift = (sbr_scale_factor->ps_scale - ov_lb_scale); + lb_shift = (sbr_scale_factor->ps_scale - lb_scale); + hb_shift = (sbr_scale_factor->ps_scale - sbr_scale_factor->hb_scale); + common_shift = low_band_scale_factor - 8; + + } else { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 8; + lb_shift = (st_syn_scale - lb_scale) - 8; + hb_shift = high_band_scale_factor - 8; + } else { + ov_lb_shift = (st_syn_scale - ov_lb_scale) - 7; + lb_shift = (st_syn_scale - lb_scale) - 7; + hb_shift = high_band_scale_factor - 7; + } + common_shift = 0; + } + ptr_qmf_imag_temp = qmf_imag; + } + + { + if (ov_lb_shift == lb_shift) { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + num_time_slots, ov_lb_shift, low_pow_flag); + + } else { + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0, + split, ov_lb_shift, low_pow_flag); + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, + split, num_time_slots, lb_shift, low_pow_flag); + } + + (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, qmf_bank->lsb, + qmf_bank->usb, 0, num_time_slots, hb_shift, + low_pow_flag); + } + + ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; + + if (1 == drc_on) { + for (i = 0; i < num_time_slots; i++) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + } + if (low_pow_flag) + + { + WORD16 *fptemp; + + VOID(*sbr_qmf_syn_winadd) + (WORD16 *, WORD16 *, WORD16 *, WORD16 *, FLAG, WORD32); + ia_qmf_dec_tables_struct *qmf_tab_ptr = sbr_tables_ptr->qmf_dec_tables_ptr; + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn32_winadd; + else + sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn64_winadd; + + for (i = 0; i < num_time_slots; i++) { + ixheaacd_inv_modulation_lp(qmf_real[i], + &filter_states[ixheaacd_drc_offset], qmf_bank, + qmf_tab_ptr); + + sbr_qmf_syn_winadd(fp1, fp2, filter_coeff, &time_out[ch_fac * p1], 2, + ch_fac); + + ixheaacd_drc_offset -= no_synthesis_channels << 1; + + if (ixheaacd_drc_offset < 0) + ixheaacd_drc_offset += ((no_synthesis_channels << 1) * 10); + + fptemp = fp1; + fp1 = fp2; + fp2 = fptemp; + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + } + + } else { + for (i = 0; i < num_time_slots; i++) { + WORD32 *t_qmf_imag; + t_qmf_imag = qmf_imag[i]; + + if (active) { + if ((i == ptr_ps_dec->border_position[env])) { + ixheaacd_init_rot_env(ptr_ps_dec, (WORD16)env, qmf_bank->usb, + sbr_tables_ptr, pstr_common_tables->trig_data); + env++; + } + + ixheaacd_apply_ps(ptr_ps_dec, &qmf_real[i], &qmf_imag[i], qmf_real_tmp, + qmf_imag_tmp, sbr_scale_factor, (WORD16)i, + sbr_tables_ptr); + } + if (1 == drc_on) { + WORD32 loop_val; + for (loop_val = 0; loop_val < 64; loop_val++) { + qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25( + qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]); + } + } + + if (active) { + if (common_shift) + ixheaacd_shiftrountine(qmf_real[i], t_qmf_imag, no_synthesis_channels, + common_shift); + } + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) + ixheaacd_sbr_pre_twiddle( + qmf_real[i], t_qmf_imag, + sbr_tables_ptr->qmf_dec_tables_ptr->ixheaacd_sbr_synth_cos_sin_l32); + + ixheaacd_inv_emodulation(qmf_real[i], qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); + + { + WORD32 temp_out_scale_fac = out_scale_factor + 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp_out_scale_fac = temp_out_scale_fac - 1; + + ixheaacd_shiftrountine_with_rnd_eld( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + + } + + else { + ixheaacd_shiftrountine_with_rnd( + qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset], + no_synthesis_channels, temp_out_scale_fac); + } + } + + if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn32_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += thirty2; + fp2 -= thirty2; + thirty2 = -thirty2; + + ixheaacd_drc_offset -= 64; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 640; + + } else { + WORD32 temp = 1; + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + temp = 2; + } + ixheaacd_sbr_qmfsyn64_winadd(fp1, fp2, filter_coeff, + &time_out[ch_fac * p1], temp, ch_fac); + + fp1 += sixty4; + fp2 -= sixty4; + sixty4 = -sixty4; + ixheaacd_drc_offset -= 128; + + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; + } + + filter_coeff += 64; + + if (filter_coeff == qmf_bank->p_filter + 640) + filter_coeff = (WORD16 *)qmf_bank->p_filter; + + p1 += no_synthesis_channels; + + if (active) + memcpy(qmf_real[i], qmf_real_tmp, + 2 * no_synthesis_channels * sizeof(WORD32)); + } + } + + if (audio_object_type == AOT_ER_AAC_LD || + audio_object_type == AOT_ER_AAC_ELD) { + qmf_bank->fp1_syn = fp1; + qmf_bank->fp2_syn = fp2; + qmf_bank->sixty4 = sixty4; + } + + qmf_bank->filter_pos_syn = filter_coeff; + qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; +} + +VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 index1, + WORD32 index) { + int i; + WORD32 l1, l2, h2, fft_jmp; + WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0; + WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0; + WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1; + WORD32 x_h2_0, x_h2_1; + WORD16 si10, si20, si30, co10, co20, co30; + + WORD32 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6; + WORD32 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12; + WORD32 *x_l1; + WORD32 *x_l2; + WORD32 *x_h2; + const WORD16 *w_ptr = w; + WORD32 i1; + + h2 = index << 1; + l1 = index << 2; + l2 = (index << 2) + (index << 1); + + x_l1 = &(x[l1]); + x_l2 = &(x[l2]); + x_h2 = &(x[h2]); + + fft_jmp = 6 * (index); + + for (i1 = 0; i1 < index1; i1++) { + for (i = 0; i < index; i++) { + si10 = (*w_ptr++); + co10 = (*w_ptr++); + si20 = (*w_ptr++); + co20 = (*w_ptr++); + si30 = (*w_ptr++); + co30 = (*w_ptr++); + + x_0 = x[0]; + x_h2_0 = x[h2]; + x_l1_0 = x[l1]; + x_l2_0 = x[l2]; + + xh0_0 = x_0 + x_l1_0; + xl0_0 = x_0 - x_l1_0; + + xh20_0 = x_h2_0 + x_l2_0; + xl20_0 = x_h2_0 - x_l2_0; + + x[0] = xh0_0 + xh20_0; + xt0_0 = 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; + + xh21_0 = x_h2_1 + x_l2_1; + xl21_0 = x_h2_1 - x_l2_1; + + x[1] = xh1_0 + xh21_0; + yt0_0 = xh1_0 - xh21_0; + + xt1_0 = xl0_0 + xl21_0; + xt2_0 = xl0_0 - xl21_0; + + yt2_0 = xl1_0 + xl20_0; + yt1_0 = 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; + + mul_5 = ixheaacd_mult32x16in32(xt2_0, si30); + mul_9 = ixheaacd_mult32x16in32(yt2_0, co30); + x[l2 + 1] = (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; + + mul_6 = ixheaacd_mult32x16in32(xt0_0, si20); + mul_8 = ixheaacd_mult32x16in32(yt0_0, co20); + x[l1 + 1] = (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; + + mul_10 = ixheaacd_mult32x16in32(xt1_0, si10); + mul_7 = ixheaacd_mult32x16in32(yt1_0, co10); + x[h2 + 1] = (mul_7 - mul_10) << RADIXSHIFT; + + x += 2; + } + x += fft_jmp; + w_ptr = w_ptr - fft_jmp; + } +} + +VOID ixheaacd_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, WORD32 npoints) { + WORD32 i, j = 0, k; + WORD32 h2; + WORD32 xh0_0, xh1_0, xl0_0, xl1_0; + WORD32 xh0_1, xh1_1, xl0_1, xl1_1; + WORD32 x_0, x_1, x_2, x_3; + WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 1); + y3 = y2 + (WORD32)(npoints >> 1); + + j0 = 4; + n0 = npoints >> 2; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *p_dig_rev_tbl++ >> 2; + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} + +VOID ixheaacd_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *pdig_rev_tbl, WORD32 npoints) { + WORD32 i, j = 0, k; + WORD32 h2; + WORD32 x_0, x_1, x_2, x_3; + WORD32 x_4, x_5, x_6, x_7; + WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f; + WORD32 n00, n10, n20, n30, n01, n11, n21, n31; + WORD32 n02, n12, n22, n32, n03, n13, n23, n33; + WORD32 n0, j0; + WORD32 *x2, *x0; + WORD32 *y0, *y1, *y2, *y3; + + y0 = ptr_y; + y2 = ptr_y + (WORD32)npoints; + x0 = ptr_x; + x2 = ptr_x + (WORD32)(npoints >> 1); + + y1 = y0 + (WORD32)(npoints >> 2); + y3 = y2 + (WORD32)(npoints >> 2); + j0 = 8; + n0 = npoints >> 1; + + for (k = 0; k < 2; k++) { + for (i = 0; i> 1; i += 8) { + h2 = *pdig_rev_tbl++ >> 2; + + x_0 = *x0++; + x_1 = *x0++; + x_2 = *x0++; + x_3 = *x0++; + x_4 = *x0++; + x_5 = *x0++; + x_6 = *x0++; + x_7 = *x0++; + + 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; + + y0[h2] = n00; + y0[h2 + 1] = n01; + y1[h2] = n10; + y1[h2 + 1] = n11; + y2[h2] = n20; + y2[h2 + 1] = n21; + y3[h2] = n30; + y3[h2 + 1] = n31; + + x_8 = *x2++; + x_9 = *x2++; + x_a = *x2++; + x_b = *x2++; + x_c = *x2++; + x_d = *x2++; + x_e = *x2++; + x_f = *x2++; + + 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; + + y0[h2 + 2] = n02; + y0[h2 + 3] = n03; + y1[h2 + 2] = n12; + y1[h2 + 3] = n13; + y2[h2 + 2] = n22; + y2[h2 + 3] = n23; + y3[h2 + 2] = n32; + y3[h2 + 3] = n33; + } + x0 += (WORD32)npoints >> 1; + x2 += (WORD32)npoints >> 1; + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_qmf_dec.h b/decoder/ixheaacd_qmf_dec.h new file mode 100644 index 0000000..0b9c0a4 --- /dev/null +++ b/decoder/ixheaacd_qmf_dec.h @@ -0,0 +1,181 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_QMF_DEC_H +#define IXHEAACD_QMF_DEC_H + +typedef struct { + WORD32 no_channels; + const WORD16 *analy_win_coeff; + const WORD16 *p_filter; + const WORD16 *cos_twiddle; + const WORD16 *sin_twiddle; + const WORD16 *alt_sin_twiddle; + const WORD16 *t_cos; + const WORD16 *t_sin; + + WORD16 *anal_filter_states; + WORD16 *filter_states; + WORD16 num_time_slots; + + WORD16 lsb; + WORD16 usb; + + WORD16 qmf_filter_state_size; + WORD16 *core_samples_buffer; + WORD16 ana_offset; + WORD16 *filter_pos; + WORD16 *dummy_0; + WORD16 ixheaacd_drc_offset; + WORD16 *filter_pos_syn; + WORD16 *dummy_1; + + WORD32 *analy_win_coeff_32; + const WORD32 *p_filter_32; + const WORD32 *esbr_cos_twiddle; + const WORD32 *esbr_alt_sin_twiddle; + const WORD32 *esbr_t_cos; + WORD32 *anal_filter_states_32; + WORD32 *state_new_samples_pos_low_32; + WORD32 *filter_states_32; + WORD32 *filter_pos_32; + WORD32 *filter_pos_syn_32; + + WORD16 *fp1_anal; + WORD16 *fp2_anal; + WORD16 *filter_2; + + WORD16 *fp1_syn; + WORD16 *fp2_syn; + WORD16 sixty4; + +} ia_sbr_qmf_filter_bank_struct; + +VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_inp, + ia_sbr_scale_fact_struct *sbr_scale_factor, + WORD32 **qmf_real, WORD32 **qmf_imag, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, + WORD ch_fac, WORD32 low_pow_flag, + WORD audio_object_type); + +VOID ixheaacd_cplx_synt_qmffilt( + WORD32 **qmf_real, WORD32 **qmf_im, WORD32 split_slot, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 *time_out, + ia_sbr_qmf_filter_bank_struct *qmf_bank, ia_ps_dec_struct *ptr_ps_dec, + FLAG active, FLAG low_pow_flag, ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD ch_fac, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type); + +VOID ixheaacd_esbr_qmfanal32_winadd(WORD32 *inp1, WORD32 *inp2, + WORD32 *tmp_qmf_1, WORD32 *tmp_qmf_2, + WORD32 *out, WORD32 num_band); + +VOID ixheaacd_esbr_fwd_modulation(const WORD32 *time_in, WORD32 *r_subband, + WORD32 *i_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr); + +VOID ixheaacd_esbr_inv_modulation(WORD32 *qmf_real, + ia_sbr_qmf_filter_bank_struct *syn_qmf, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr); + +VOID ixheaacd_shiftrountine_with_rnd_hq(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD32 *filter_states, WORD32 len, + WORD32 shift); + +VOID ixheaacd_esbr_qmfsyn64_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *tmp3, + WORD32 *sample_buffer, WORD ch_fac); + +VOID ixheaacd_sbr_qmfanal32_winadds(WORD16 *fp1, WORD16 *fp2, WORD16 *filter_1, + WORD16 *filter_2, WORD32 *analysis_buffer, + WORD16 *filter_states, + const WORD16 *time_sample_buf, + WORD32 ch_fac); + +VOID ixheaacd_sbr_qmfanal32_winadds_eld(WORD16 *fp1, WORD16 *fp2, + WORD16 *filter_1, WORD16 *filter_2, + WORD32 *analysis_buffer, + WORD16 *filter_states, + const WORD16 *time_sample_buf, + WORD32 ch_fac); + +VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband, + WORD32 *imag_subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr); +VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, + const WORD16 *main_twidle_fwd, const WORD16 *post_tbl, + const WORD16 *w_16, const WORD32 *p_table); + +VOID ixheaacd_dec_DCT2_64_asm(WORD32 *dct_in, WORD32 *ptime_out, WORD32 *w1024, + UWORD8 *dig_rev_table2_128, WORD16 *post_fft_tbl, + WORD16 *dct23_tw, WORD16 *filter_states); +VOID ixheaacd_cos_sin_mod(WORD32 *subband, + ia_sbr_qmf_filter_bank_struct *qmf_bank, + WORD16 *p_twiddle, WORD32 *p_dig_rev_tbl); +VOID ixheaacd_shiftrountine(WORD32 *qmf_real, WORD32 *qmf_imag, WORD32 len, + WORD32 common_shift); +VOID ixheaacd_shiftrountine_with_rnd(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD16 *filter_states, WORD32 len, + WORD32 shift); + +VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 npoints, + WORD32 ch_fac); + +VOID ixheaacd_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, WORD32 npoints); + +VOID ixheaacd_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, WORD32 npoints); + +VOID ixheaacd_shiftrountine_with_rnd_eld(WORD32 *qmf_real, WORD32 *qmf_imag, + WORD16 *filter_states, WORD32 len, + WORD32 shift); + +void ixheaacd_sbr_imdct_using_fft(const WORD32 *ptr_w, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y, + UWORD8 *bit_rev_1024, UWORD8 *bit_rev_512, + UWORD8 *bit_rev_128, UWORD8 *bit_rev_32); + +VOID ixheaacd_esbr_cos_sin_mod_loop1(WORD32 *subband, WORD32 M, + const WORD32 *p_sin_cos, + WORD32 subband_tmp[]); + +VOID ixheaacd_esbr_cos_sin_mod_loop2(WORD32 *subband, const WORD32 *p_sin, + WORD32 M); + +VOID ixheaacd_esbr_radix4bfly(const WORD32 *p_twiddle, WORD32 subband_tmp[], + WORD32 a, WORD32 npoint); + +VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 npoints, + WORD32 ch_fac); + +VOID ixheaacd_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, WORD32 npoints); + +VOID ixheaacd_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x, + const WORD32 *p_dig_rev_tbl, WORD32 npoints); + +VOID ixheaacd_cos_sin_mod_loop1(WORD32 *subband, WORD32 M, + const WORD16 *p_sin_cos, WORD32 subband_tmp[]); + +VOID ixheaacd_cos_sin_mod_loop2(WORD32 *subband, const WORD16 *p_sin, WORD32 M); + +#endif diff --git a/decoder/ixheaacd_qmf_poly.h b/decoder/ixheaacd_qmf_poly.h new file mode 100644 index 0000000..25d4694 --- /dev/null +++ b/decoder/ixheaacd_qmf_poly.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_QMF_POLY_H +#define IXHEAACD_QMF_POLY_H + +double *ixheaacd_interpo_esbr_fcoff(const double *orig_prot, WORD32 no, + WORD32 lo, WORD32 li); + +VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer); + +VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 num_columns, FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64]); + +VOID ixheaacd_cmplx_anal_fft_p2(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +VOID ixheaacd_cmplx_anal_fft_p3(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +VOID ixheaacd_real_synth_fft_p2(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +VOID ixheaacd_real_synth_fft_p3(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +VOID (*ixheaacd_real_synth_fft)(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +VOID (*ixheaacd_cmplx_anal_fft)(FLOAT32 *inp, FLOAT32 *out, WORD32 n_points); + +#endif diff --git a/decoder/ixheaacd_rev_vlc.c b/decoder/ixheaacd_rev_vlc.c new file mode 100644 index 0000000..12b16b1 --- /dev/null +++ b/decoder/ixheaacd_rev_vlc.c @@ -0,0 +1,1769 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#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_bitbuffer.h" +#include "ixheaacd_error_codes.h" +#include "ixheaacd_defines.h" +#include "ixheaacd_aac_rom.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" + +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_block.h" +#include "ixheaacd_channel.h" + +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_basic_op.h" + +#include "ixheaacd_aacdec.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_env_extr_part.h" +#include "ixheaacd_sbr_rom.h" +#include "ixheaacd_audioobjtypes.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_latmdemux.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_config.h" +#include "ixheaacd_mps_dec.h" +#include "ixheaacd_struct_def.h" + +#include "ixheaacd_cnst.h" + +#define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID 0x80000000 +#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD 0x40000000 +#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD 0x20000000 +#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD 0x08000000 +#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD 0x04000000 + +#define FWD 0 +#define BWD 1 + +#define MAX_RVL 7 +#define MIN_RVL -7 +#define MAX_ALLOWED_DPCM_INDEX 14 +#define TABLE_OFFSET 7 +#define MAX_LEN_RVLC_CODE_WORD 9 +#define MAX_LEN_RVLC_ESCAPE_WORD 20 + +#define DPCM_NOISE_NRG_BITS 9 +#define SF_OFFSET 100 + +#define CONCEAL_MAX_INIT 1311 +#define CONCEAL_MIN_INIT -1311 + +#define RVLC_MAX_SFB ((8) * (16)) + +#define MASK_LEFT 0xFFF000 +#define MASK_RIGHT 0xFFF +#define CLR_BIT_10 0x3FF +#define NODE_MASK 0x400 + +#define LEFT_OFFSET 12 + +static int ixheaacd_rvlc_decode(short cw, int len, int *found) { + short indx = 0; + *found = 0; + switch (len) { + case 1: + if (cw == 0) + indx = 0; + else + return 3; + break; + case 3: + switch (cw) { + case 5: + indx = -1; + break; + case 7: + indx = 1; + break; + default: + return 4; + } + break; + case 4: + if (cw == 9) + indx = -2; + else + return 5; + break; + case 5: + switch (cw) { + case 17: + indx = -3; + break; + case 27: + indx = 2; + break; + default: + return 6; + } + break; + case 6: + switch (cw) { + case 33: + indx = -4; + break; + case 51: + indx = 3; + break; + default: + return 7; + } + break; + case 7: + switch (cw) { + case 65: + indx = -7; + break; + case 107: + indx = 4; + break; + case 99: + indx = 7; + break; + default: + return 8; + } + break; + case 8: + switch (cw) { + case 129: + indx = -5; + break; + case 195: + indx = 5; + break; + default: + return 9; + } + break; + case 9: + switch (cw) { + case 257: + indx = -6; + break; + case 427: + indx = 6; + break; + default: + return -1; + } + break; + default: + return -1; + } + *found = 1; + return indx; +} + +static int ixheaacd_rvlc_decode_esc(int cw, int len, int *found) { + short indx = 0; + *found = 0; + switch (len) { + case 2: + switch (cw) { + case 2: + indx = 0; + break; + case 0: + indx = 1; + break; + default: + return 3; + } + break; + case 3: + switch (cw) { + case 6: + indx = 2; + break; + case 2: + indx = 3; + break; + default: + return 4; + } + break; + case 4: + if (cw == 14) + indx = 4; + else + return 5; + break; + case 5: + switch (cw) { + case 31: + indx = 5; + break; + case 15: + indx = 6; + break; + case 13: + indx = 7; + break; + default: + return 6; + } + break; + case 6: + switch (cw) { + case 61: + indx = 8; + break; + case 29: + indx = 9; + break; + case 25: + indx = 10; + break; + case 24: + indx = 11; + break; + default: + return 7; + } + break; + case 7: + switch (cw) { + case 120: + indx = 12; + break; + case 56: + indx = 13; + break; + default: + return 8; + } + break; + case 8: + switch (cw) { + case 242: + indx = 14; + break; + case 114: + indx = 15; + break; + default: + return 9; + } + break; + case 9: + switch (cw) { + case 486: + indx = 16; + break; + case 230: + indx = 17; + break; + default: + return 10; + } + break; + case 10: + switch (cw) { + case 974: + indx = 18; + break; + case 463: + indx = 19; + break; + default: + return 11; + } + break; + case 11: + switch (cw) { + case 1950: + indx = 20; + break; + case 1951: + indx = 21; + break; + case 925: + indx = 22; + break; + default: + return 12; + } + break; + case 12: + if (cw == 1848) + indx = 23; + else + return 13; + break; + case 13: + if (cw == 3698) + indx = 25; + else + return 14; + break; + case 14: + if (cw == 7399) + indx = 24; + else + return 15; + break; + case 15: + if (cw == 14797) + indx = 26; + else + return 19; + break; + case 19: + if ((cw >= 236736) && (cw <= 236740)) + indx = 53 - (236740 - cw); + else + return 20; + break; + case 20: + if ((cw >= 473482) && (cw <= 473503)) + indx = 48 - (473503 - cw); + else + return -1; + break; + default: + return -1; + } + *found = 1; + return indx; +} +static VOID ixheaacd_rvlc_check_intensity_cb( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + WORD32 group, band, bnds; + + ptr_rvlc->intensity_used = 0; + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + if ((ptr_aac_dec_channel_info->ptr_code_book[bnds] == INTENSITY_HCB) || + (ptr_aac_dec_channel_info->ptr_code_book[bnds] == INTENSITY_HCB2)) { + ptr_rvlc->intensity_used = 1; + break; + } + } + } +} + +VOID ixheaacd_carry_bit_branch_val(UWORD8 carry_bit, UWORD32 tree_node, + UWORD32 *branch_val, UWORD32 *branch_node) { + if (carry_bit == 0) { + *branch_node = (tree_node & MASK_LEFT) >> LEFT_OFFSET; + } else { + *branch_node = tree_node & MASK_RIGHT; + } + + *branch_val = *branch_node & CLR_BIT_10; +} + +UWORD8 ixheaacd_rvlc_read_bits(ia_bit_buf_struct *it_bit_buff, + UWORD16 *ptr_position, UWORD8 read_direction) { + UWORD32 bit; + WORD32 read_bit_offset = + *ptr_position - (it_bit_buff->size - it_bit_buff->cnt_bits); + + if (read_bit_offset) it_bit_buff->cnt_bits -= read_bit_offset; + + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); + + if (read_direction == 0) { + bit = ixheaacd_aac_read_bit_rev(it_bit_buff); + + *ptr_position += 1; + } else { + bit = ixheaacd_aac_read_bit(it_bit_buff); + + *ptr_position -= 1; + } + + return (bit); +} + +static WORD8 ixheaacd_rvlc_decode_escape_word(ia_rvlc_info_struct *ptr_rvlc, + ia_bit_buf_struct *it_bit_buff) { + WORD32 i; + + UWORD8 carry_bit; + + UWORD16 *ptr_bitstream_index_esc; + + int len = 0; + int codeword = 0; + int found = 0; + int indx; + + ptr_bitstream_index_esc = &(ptr_rvlc->esc_bit_str_idx); + + for (i = MAX_LEN_RVLC_ESCAPE_WORD - 1; i >= 0; i--) { + carry_bit = + ixheaacd_rvlc_read_bits(it_bit_buff, ptr_bitstream_index_esc, FWD); + + len++; + codeword = codeword << 1 | carry_bit; + indx = ixheaacd_rvlc_decode_esc(codeword, len, &found); + + if (found) { + ptr_rvlc->rvlc_esc_len -= (MAX_LEN_RVLC_ESCAPE_WORD - i); + return indx; + } + } + + ptr_rvlc->rvlc_err_log |= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID; + + return -1; +} + +static VOID ixheaacd_rvlc_decode_escape(ia_rvlc_info_struct *ptr_rvlc, + WORD16 *ptr_escape, + ia_bit_buf_struct *it_bit_buff) { + WORD8 esc_word; + WORD8 esc_cnt = 0; + WORD16 *ptr_esc_bit_cnt_sum; + + ptr_esc_bit_cnt_sum = &(ptr_rvlc->rvlc_esc_len); + + while (*ptr_esc_bit_cnt_sum > 0) { + esc_word = ixheaacd_rvlc_decode_escape_word(ptr_rvlc, it_bit_buff); + + if (esc_word >= 0) { + ptr_escape[esc_cnt] = esc_word; + esc_cnt++; + } else { + ptr_rvlc->rvlc_err_log |= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID; + ptr_rvlc->num_esc_words_decoded = esc_cnt; + + return; + } + } + + ptr_rvlc->num_esc_words_decoded = esc_cnt; +} + +WORD8 ixheaacd_decode_rvlc_code_word(ia_bit_buf_struct *it_bit_buff, + ia_rvlc_info_struct *ptr_rvlc) { + WORD32 i; + + UWORD8 carry_bit; + + UWORD8 direction = ptr_rvlc->direction; + UWORD16 *ptr_bit_str_idx_rvl = ptr_rvlc->ptr_rvl_bit_str_idx; + + int len = 0; + short codeword = 0; + int found = 0; + int indx; + + for (i = MAX_LEN_RVLC_CODE_WORD - 1; i >= 0; i--) { + carry_bit = + ixheaacd_rvlc_read_bits(it_bit_buff, ptr_bit_str_idx_rvl, direction); + + len++; + codeword = codeword << 1 | carry_bit; + indx = ixheaacd_rvlc_decode(codeword, len, &found); + if (found) { + indx = indx + 7; + *ptr_rvlc->ptr_rvl_bit_cnt -= (MAX_LEN_RVLC_CODE_WORD - i); + return indx; + } + } + + return -1; +} + +static VOID ixheaacd_rvlc_decode_forward( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_bit_buf_struct *it_bit_buff) { + WORD32 band = 0; + WORD32 group = 0; + WORD32 bnds = 0; + + WORD16 dpcm; + + ia_bit_buf_struct temp_buf; + + WORD16 factor = ptr_aac_dec_channel_info->global_gain; + WORD16 position = 0; + WORD16 noise_energy = ptr_aac_dec_channel_info->global_gain - 90 - 256; + + WORD16 *ptr_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr; + WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; + UWORD8 *ptr_esc_fwd_cnt = &(ptr_rvlc->num_fwd_esc_words_decoded); + + ptr_rvlc->ptr_rvl_bit_cnt = &(ptr_rvlc->rvlc_sf_fwd_len); + ptr_rvlc->ptr_rvl_bit_str_idx = &(ptr_rvlc->rvl_fwd_bit_str_idx); + + *ptr_esc_fwd_cnt = 0; + ptr_rvlc->direction = 0; + ptr_rvlc->noise_used = 0; + ptr_rvlc->sf_used = 0; + ptr_rvlc->last_scale_fac = 0; + ptr_rvlc->last_nrg = 0; + ptr_rvlc->is_last = 0; + + ixheaacd_rvlc_check_intensity_cb(ptr_rvlc, ptr_aac_dec_channel_info); + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + ptr_scf_fwd[bnds] = 0; + break; + + case INTENSITY_HCB2: + case INTENSITY_HCB: + + { + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_rvlc->conceal_max = bnds; + return; + } + dpcm -= 7; + } + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_rvlc->conceal_max = bnds; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc++; + } else { + dpcm += *ptr_scf_esc++; + } + (*ptr_esc_fwd_cnt)++; + if (ptr_rvlc->conceal_max_esc == 1311) { + ptr_rvlc->conceal_max_esc = bnds; + } + } + } + position += dpcm; + ptr_scf_fwd[bnds] = position; + ptr_rvlc->is_last = position; + break; + + case NOISE_HCB: + if (ptr_rvlc->noise_used == 0) { + ptr_rvlc->noise_used = 1; + ptr_rvlc->first_noise_band = bnds; + noise_energy += ptr_rvlc->dpcm_noise_nrg; + ptr_scf_fwd[bnds] = noise_energy; + ptr_rvlc->last_nrg = noise_energy; + } else { + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_rvlc->conceal_max = bnds; + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_rvlc->conceal_max = bnds; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc++; + } else { + dpcm += *ptr_scf_esc++; + } + (*ptr_esc_fwd_cnt)++; + if (ptr_rvlc->conceal_max_esc == 1311) { + ptr_rvlc->conceal_max_esc = bnds; + } + } + } + noise_energy += dpcm; + ptr_scf_fwd[bnds] = noise_energy; + ptr_rvlc->last_nrg = noise_energy; + } + ptr_aac_dec_channel_info->str_pns_info.pns_used[bnds] = 1; + break; + + default: + ptr_rvlc->sf_used = 1; + { + memcpy(&temp_buf, it_bit_buff, sizeof(ia_bit_buf_struct)); + + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_rvlc->conceal_max = bnds; + return; + } + dpcm -= 7; + } + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_rvlc->conceal_max = bnds; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc++; + } else { + dpcm += *ptr_scf_esc++; + } + (*ptr_esc_fwd_cnt)++; + if (ptr_rvlc->conceal_max_esc == 1311) { + ptr_rvlc->conceal_max_esc = bnds; + } + } + } + factor += dpcm; + ptr_scf_fwd[bnds] = factor; + ptr_rvlc->last_scale_fac = factor; + break; + } + } + } + + if (ptr_rvlc->intensity_used) { + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_rvlc->conceal_max = bnds; + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_rvlc->conceal_max = bnds; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc++; + } else { + dpcm += *ptr_scf_esc++; + } + (*ptr_esc_fwd_cnt)++; + if (ptr_rvlc->conceal_max_esc == 1311) { + ptr_rvlc->conceal_max_esc = bnds; + } + } + } + ptr_rvlc->dpcm_is_last_pos = dpcm; + } +} + +static VOID ixheaacd_rvlc_decode_backward( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_bit_buf_struct *it_bit_buff) { + WORD16 band, group, dpcm, ixheaacd_drc_offset; + WORD16 bnds = ptr_rvlc->max_sfb_transmitted - 1; + + WORD16 factor = ptr_rvlc->rev_global_gain; + WORD16 position = ptr_rvlc->dpcm_is_last_pos; + WORD16 noise_energy = + ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - 90 - 256; + + WORD16 *ptr_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr; + WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; + UWORD8 *ptr_esc_cnt = &(ptr_rvlc->num_esc_words_decoded); + UWORD8 *ptr_esc_bwd_cnt = &(ptr_rvlc->num_bwd_esc_words_decoded); + + ptr_rvlc->ptr_rvl_bit_cnt = &(ptr_rvlc->rvlc_sf_bwd_len); + ptr_rvlc->ptr_rvl_bit_str_idx = &(ptr_rvlc->rvl_bwd_bit_str_idx); + + *ptr_esc_bwd_cnt = 0; + ptr_rvlc->direction = 1; + ptr_scf_esc += *ptr_esc_cnt - 1; + ptr_rvlc->firt_scale_fac = 0; + ptr_rvlc->first_nrg = 0; + ptr_rvlc->is_first = 0; + + if (ptr_rvlc->intensity_used) { + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_rvlc->dpcm_is_last_pos = 0; + ptr_rvlc->conceal_min = bnds; + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_rvlc->conceal_min = bnds; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc--; + } else { + dpcm += *ptr_scf_esc--; + } + (*ptr_esc_bwd_cnt)++; + if (ptr_rvlc->conceal_min_esc == -1311) { + ptr_rvlc->conceal_min_esc = bnds; + } + } + } + ptr_rvlc->dpcm_is_last_pos = dpcm; + } + + for (group = ptr_rvlc->num_wind_grps - 1; group >= 0; group--) { + for (band = ptr_rvlc->max_sfb_transmitted - 1; band >= 0; band--) { + bnds = 16 * group + band; + if ((band == 0) && (ptr_rvlc->num_wind_grps != 1)) + ixheaacd_drc_offset = 16 - ptr_rvlc->max_sfb_transmitted + 1; + else + ixheaacd_drc_offset = 1; + + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + ptr_scf_bwd[bnds] = 0; + break; + + case INTENSITY_HCB2: + case INTENSITY_HCB: + + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_scf_bwd[bnds] = position; + + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_scf_bwd[bnds] = position; + + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc--; + } else { + dpcm += *ptr_scf_esc--; + } + (*ptr_esc_bwd_cnt)++; + if (ptr_rvlc->conceal_min_esc == -1311) { + } + } + } + ptr_scf_bwd[bnds] = position; + position -= dpcm; + ptr_rvlc->is_first = position; + break; + + case NOISE_HCB: + if (bnds == ptr_rvlc->first_noise_band) { + ptr_scf_bwd[bnds] = ptr_rvlc->dpcm_noise_nrg + + ptr_aac_dec_channel_info->global_gain - 90 - + 256; + ptr_rvlc->first_nrg = ptr_scf_bwd[bnds]; + } else { + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_scf_bwd[bnds] = noise_energy; + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_scf_bwd[bnds] = noise_energy; + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc--; + } else { + dpcm += *ptr_scf_esc--; + } + (*ptr_esc_bwd_cnt)++; + if (ptr_rvlc->conceal_min_esc == -1311) { + } + } + } + ptr_scf_bwd[bnds] = noise_energy; + noise_energy -= dpcm; + ptr_rvlc->first_nrg = noise_energy; + } + break; + + default: + dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); + if (dpcm < 0) { + ptr_scf_bwd[bnds] = factor; + + return; + } + dpcm -= 7; + if ((dpcm == -7) || (dpcm == 7)) { + if (ptr_rvlc->rvlc_esc_len) { + ptr_scf_bwd[bnds] = factor; + + return; + } else { + if (dpcm == -7) { + dpcm -= *ptr_scf_esc--; + } else { + dpcm += *ptr_scf_esc--; + } + (*ptr_esc_bwd_cnt)++; + if (ptr_rvlc->conceal_min_esc == -1311) { + } + } + } + ptr_scf_bwd[bnds] = factor; + factor -= dpcm; + ptr_rvlc->firt_scale_fac = factor; + break; + } + } + } +} + +VOID ixheaacd_rvlc_read( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + + WORD32 group, band; + + ptr_rvlc->num_wind_grps = + ptr_aac_dec_channel_info->str_ics_info.num_window_groups; + ptr_rvlc->max_sfb_transmitted = + ptr_aac_dec_channel_info->str_ics_info.max_sfb; + ptr_rvlc->noise_used = 0; + ptr_rvlc->dpcm_noise_nrg = 0; + ptr_rvlc->dpcm_noise_last_pos = 0; + ptr_rvlc->rvlc_esc_len = -1; + ptr_rvlc->dpcm_is_last_pos = 0; + + ptr_rvlc->sf_concealment = ixheaacd_read_bits_buf(it_bit_buff, 1); + ptr_rvlc->rev_global_gain = ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + ptr_rvlc->rvlc_sf_len = ixheaacd_read_bits_buf(it_bit_buff, 11); + } else { + ptr_rvlc->rvlc_sf_len = ixheaacd_read_bits_buf(it_bit_buff, 9); + } + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + if (ptr_aac_dec_channel_info->ptr_code_book[16 * group + band] == + NOISE_HCB) { + ptr_rvlc->noise_used = 1; + break; + } + } + } + + if (ptr_rvlc->noise_used) + ptr_rvlc->dpcm_noise_nrg = ixheaacd_read_bits_buf(it_bit_buff, 9); + + ptr_rvlc->sf_esc_present = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (ptr_rvlc->sf_esc_present) { + ptr_rvlc->rvlc_esc_len = ixheaacd_read_bits_buf(it_bit_buff, 8); + } + + if (ptr_rvlc->noise_used) { + ptr_rvlc->dpcm_noise_last_pos = ixheaacd_read_bits_buf(it_bit_buff, 9); + ptr_rvlc->rvlc_sf_len -= 9; + } + + ptr_rvlc->rvlc_sf_fwd_len = ptr_rvlc->rvlc_sf_len; + ptr_rvlc->rvlc_sf_bwd_len = ptr_rvlc->rvlc_sf_len; +} + +VOID ixheaacd_hcr_read(ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + WORD32 ele_type) { + WORD16 len_reordered_spec_data; + WORD8 len_longest_code_word; + + ptr_aac_dec_channel_info->reorder_spect_data_len = 0; + ptr_aac_dec_channel_info->longest_cw_len = 0; + + len_reordered_spec_data = ixheaacd_read_bits_buf(it_bit_buff, 14); + if (ele_type == ID_CPE) { + if ((len_reordered_spec_data >= 0) && (len_reordered_spec_data <= 12288)) { + ptr_aac_dec_channel_info->reorder_spect_data_len = + len_reordered_spec_data; + } else { + if (len_reordered_spec_data > 12288) { + ptr_aac_dec_channel_info->reorder_spect_data_len = 12288; + } + } + } else if (ele_type == ID_SCE || ele_type == ID_LFE || ele_type == ID_CCE) { + if ((len_reordered_spec_data >= 0) && (len_reordered_spec_data <= 6144)) { + ptr_aac_dec_channel_info->reorder_spect_data_len = + len_reordered_spec_data; + } else { + if (len_reordered_spec_data > 6144) { + ptr_aac_dec_channel_info->reorder_spect_data_len = 6144; + } + } + } + + len_longest_code_word = ixheaacd_read_bits_buf(it_bit_buff, 6); + if ((len_longest_code_word >= 0) && (len_longest_code_word <= 49)) { + ptr_aac_dec_channel_info->longest_cw_len = len_longest_code_word; + } else { + if (len_longest_code_word > 49) { + ptr_aac_dec_channel_info->longest_cw_len = 49; + } + } +} + +static VOID ixheaacd_rvlc_init( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_bit_buf_struct *it_bit_buff) { + WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; + WORD16 *ptr_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr; + WORD16 *ptr_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr; + WORD16 *ptr_scale_factor = ptr_aac_dec_channel_info->ptr_scale_factor; + WORD32 bnds; + + ptr_aac_dec_channel_info->rvlc_intensity_used = 0; + + ptr_rvlc->num_esc_words_decoded = 0; + ptr_rvlc->num_fwd_esc_words_decoded = 0; + ptr_rvlc->num_bwd_esc_words_decoded = 0; + + ptr_rvlc->intensity_used = 0; + ptr_rvlc->rvlc_err_log = 0; + + ptr_rvlc->conceal_max = CONCEAL_MAX_INIT; + ptr_rvlc->conceal_min = CONCEAL_MIN_INIT; + + ptr_rvlc->conceal_max_esc = CONCEAL_MAX_INIT; + ptr_rvlc->conceal_min_esc = CONCEAL_MIN_INIT; + + for (bnds = 0; bnds < RVLC_MAX_SFB; bnds++) { + ptr_scf_fwd[bnds] = 0; + ptr_scf_bwd[bnds] = 0; + ptr_scf_esc[bnds] = 0; + ptr_scale_factor[bnds] = 0; + } + + ptr_rvlc->rvl_fwd_bit_str_idx = it_bit_buff->size - it_bit_buff->cnt_bits; + ptr_rvlc->rvl_bwd_bit_str_idx = + it_bit_buff->size - it_bit_buff->cnt_bits + ptr_rvlc->rvlc_sf_len - 1; + + it_bit_buff->cnt_bits -= ptr_rvlc->rvlc_sf_len; + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); + + if (ptr_rvlc->sf_esc_present != 0) { + ptr_rvlc->esc_bit_str_idx = it_bit_buff->size - it_bit_buff->cnt_bits; + + it_bit_buff->cnt_bits -= ptr_rvlc->rvlc_esc_len; + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); + } +} + +VOID ixheaacd_bi_dir_est_scf_prev_frame_reference( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + WORD32 band, bnds, start_band, end_band, group; + WORD32 conceal_min, conceal_max; + WORD32 conceal_group_min, conceal_group_max; + WORD32 max_scf_bands; + WORD32 common_min; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + max_scf_bands = 16; + } else { + max_scf_bands = 64; + } + + if (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) ptr_rvlc->conceal_min = 0; + + if (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) + ptr_rvlc->conceal_max = + (ptr_rvlc->num_wind_grps - 1) * 16 + ptr_rvlc->max_sfb_transmitted - 1; + + conceal_min = ptr_rvlc->conceal_min % max_scf_bands; + conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; + conceal_max = ptr_rvlc->conceal_max % max_scf_bands; + conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; + + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_max] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_max]; + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_min] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_min]; + + start_band = conceal_min; + if (conceal_group_min == conceal_group_max) + end_band = conceal_max; + else + end_band = ptr_rvlc->max_sfb_transmitted - 1; + + for (group = conceal_group_min; group <= conceal_group_max; group++) { + for (band = start_band; band <= end_band; band++) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; + break; + + case INTENSITY_HCB: + case INTENSITY_HCB2: + if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + INTENSITY_HCB) || + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + INTENSITY_HCB2)) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + } + break; + + case NOISE_HCB: + if (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + NOISE_HCB) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + } + break; + + default: + if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + ZERO_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + NOISE_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + INTENSITY_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + INTENSITY_HCB2)) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + } + break; + } + } + start_band = 0; + if ((group + 1) == conceal_group_max) end_band = conceal_max; + } + + if (conceal_group_min == 0) + end_band = conceal_min; + else + end_band = ptr_rvlc->max_sfb_transmitted; + for (group = 0; group <= conceal_group_min; group++) { + for (band = 0; band < end_band; band++) { + bnds = 16 * group + band; + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + } + if ((group + 1) == conceal_group_min) end_band = conceal_min; + } + + start_band = conceal_max + 1; + for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { + for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + } + start_band = 0; + } +} + +static VOID ixheaacd_calc_ref_val_fwd( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 *ref_fwd, + WORD32 *ref_nrg_fwd, WORD32 *ref_scf_fwd) { + WORD32 band, bnds, group, start_band; + WORD32 id_is, id_nrg, id_scf; + WORD32 conceal_min, conceal_group_min; + WORD32 max_scf_bands; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) + max_scf_bands = 16; + else + max_scf_bands = 64; + + conceal_min = ptr_rvlc->conceal_min % max_scf_bands; + conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; + + id_is = id_nrg = id_scf = 1; + + *ref_nrg_fwd = ptr_aac_dec_channel_info->global_gain - 90 - 256; + *ref_scf_fwd = ptr_aac_dec_channel_info->global_gain; + + start_band = conceal_min - 1; + for (group = conceal_group_min; group >= 0; group--) { + for (band = start_band; band >= 0; band--) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + break; + case INTENSITY_HCB: + case INTENSITY_HCB2: + if (id_is) { + *ref_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + id_is = 0; + } + break; + case NOISE_HCB: + if (id_nrg) { + *ref_nrg_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + id_nrg = 0; + } + break; + default: + if (id_scf) { + *ref_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + id_scf = 0; + } + break; + } + } + start_band = ptr_rvlc->max_sfb_transmitted - 1; + } +} + +static VOID ixheaacd_calc_ref_val_bwd( + ia_rvlc_info_struct *ptr_rvlc, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 *ref_bwd, + WORD32 *ref_nrg_bwd, WORD32 *ref_scf_bwd) { + WORD32 band, bnds, group, start_band; + WORD32 id_is, id_nrg, id_scf; + WORD32 conceal_max, conceal_group_max; + WORD32 max_scf_bands; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) + max_scf_bands = 16; + else + max_scf_bands = 64; + + conceal_max = ptr_rvlc->conceal_max % max_scf_bands; + conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; + + id_is = id_nrg = id_scf = 1; + + *ref_bwd = ptr_rvlc->dpcm_is_last_pos; + *ref_nrg_bwd = ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - + 90 - 256 + ptr_rvlc->dpcm_noise_nrg; + *ref_scf_bwd = ptr_rvlc->rev_global_gain; + + start_band = conceal_max + 1; + + for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { + for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + break; + case INTENSITY_HCB: + case INTENSITY_HCB2: + if (id_is) { + *ref_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + id_is = 0; + } + break; + case NOISE_HCB: + if (id_nrg) { + *ref_nrg_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + id_nrg = 0; + } + break; + default: + if (id_scf) { + *ref_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + id_scf = 0; + } + break; + } + } + start_band = 0; + } +} + +VOID ixheaacd_bi_dir_est_lower_scf_cur_frame( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + WORD32 band, bnds, start_band, end_band, group; + WORD32 conceal_min, conceal_max; + WORD32 conceal_group_min, conceal_group_max; + WORD32 max_scf_bands; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) { + max_scf_bands = 16; + } else { + max_scf_bands = 64; + } + + if (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) ptr_rvlc->conceal_min = 0; + + if (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) + ptr_rvlc->conceal_max = + (ptr_rvlc->num_wind_grps - 1) * 16 + ptr_rvlc->max_sfb_transmitted - 1; + + conceal_min = ptr_rvlc->conceal_min % max_scf_bands; + conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; + conceal_max = ptr_rvlc->conceal_max % max_scf_bands; + conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; + + if (ptr_rvlc->conceal_min == ptr_rvlc->conceal_max) { + WORD32 ref_fwd, ref_nrg_fwd, ref_scf_fwd; + WORD32 ref_bwd, ref_nrg_bwd, ref_scf_bwd; + + bnds = ptr_rvlc->conceal_min; + ixheaacd_calc_ref_val_fwd(ptr_rvlc, ptr_aac_dec_channel_info, &ref_fwd, + &ref_nrg_fwd, &ref_scf_fwd); + ixheaacd_calc_ref_val_bwd(ptr_rvlc, ptr_aac_dec_channel_info, &ref_bwd, + &ref_nrg_bwd, &ref_scf_bwd); + + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + break; + case INTENSITY_HCB: + case INTENSITY_HCB2: + if (ref_fwd < ref_bwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_fwd; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_bwd; + break; + case NOISE_HCB: + if (ref_nrg_fwd < ref_nrg_bwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_nrg_fwd; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_nrg_bwd; + break; + default: + if (ref_scf_fwd < ref_scf_bwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_scf_fwd; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_scf_bwd; + break; + } + } else { + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_max] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_max]; + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_min] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_min]; + + start_band = conceal_min; + if (conceal_group_min == conceal_group_max) + end_band = conceal_max; + else + end_band = ptr_rvlc->max_sfb_transmitted - 1; + + for (group = conceal_group_min; group <= conceal_group_max; group++) { + for (band = start_band; band <= end_band; band++) { + bnds = 16 * group + band; + if (ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds] < + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + } + start_band = 0; + if ((group + 1) == conceal_group_max) end_band = conceal_max; + } + } + + if (conceal_group_min == 0) + end_band = conceal_min; + else + end_band = ptr_rvlc->max_sfb_transmitted; + for (group = 0; group <= conceal_group_min; group++) { + for (band = 0; band < end_band; band++) { + bnds = 16 * group + band; + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + } + if ((group + 1) == conceal_group_min) end_band = conceal_min; + } + + start_band = conceal_max + 1; + for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { + for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + } + start_band = 0; + } +} + +VOID ixheaacd_statistical_estimation( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + WORD32 band, bnds, group; + WORD32 sum_fwd, sum_bwd; + WORD32 sum_nrg_fwd, sum_nrg_bwd; + WORD32 sum_scf_fwd, sum_scf_bwd; + WORD32 use_fwd, use_nrg_fwd, use_scf_fwd; + WORD32 max_scf_bands; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) + max_scf_bands = 16; + else + max_scf_bands = 64; + + sum_fwd = sum_bwd = sum_nrg_fwd = sum_nrg_bwd = sum_scf_fwd = sum_scf_bwd = 0; + use_fwd = use_nrg_fwd = use_scf_fwd = 0; + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + break; + + case INTENSITY_HCB: + case INTENSITY_HCB2: + sum_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + sum_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + + case NOISE_HCB: + sum_nrg_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + sum_nrg_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + + default: + sum_scf_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + sum_scf_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + } + } + } + + if (sum_fwd < sum_bwd) use_fwd = 1; + + if (sum_nrg_fwd < sum_nrg_bwd) use_nrg_fwd = 1; + + if (sum_scf_fwd < sum_scf_bwd) use_scf_fwd = 1; + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + break; + + case INTENSITY_HCB: + case INTENSITY_HCB2: + if (use_fwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + + case NOISE_HCB: + if (use_nrg_fwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + + default: + if (use_scf_fwd) + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + else + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; + break; + } + } + } +} + +VOID ixheaacd_predictive_interpolation( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + WORD32 band, bnds, group; + WORD32 max_scf_bands; + WORD32 common_min; + + if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) + max_scf_bands = 16; + else + max_scf_bands = 64; + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { + case ZERO_HCB: + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; + break; + + case INTENSITY_HCB: + case INTENSITY_HCB2: + if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + INTENSITY_HCB) || + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + INTENSITY_HCB2)) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = -110; + } + break; + + case NOISE_HCB: + if (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == + NOISE_HCB) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = -110; + } + break; + + default: + if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + ZERO_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + NOISE_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + INTENSITY_HCB) && + (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != + INTENSITY_HCB2)) { + common_min = ixheaacd_min32( + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], + ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaacd_min32( + common_min, + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); + } else { + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; + } + break; + } + } + } +} +static VOID ixheaacd_rvlc_final_error_detection( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + UWORD8 err_status_complete = 0; + UWORD8 err_status_length_fwd = 0; + UWORD8 err_status_length_bwd = 0; + UWORD8 err_status_length_escape = 0; + UWORD8 err_status_first_scf = 0; + UWORD8 err_status_last_scf = 0; + UWORD8 err_status_first_nrg = 0; + UWORD8 err_status_last_nrg = 0; + UWORD8 err_status_first_is = 0; + UWORD8 err_status_last_is = 0; + UWORD8 err_status_forbidden_cw_fwd = 0; + UWORD8 err_status_forbidden_cw_bwd = 0; + UWORD8 err_status_num_escapes_fwd = 0; + UWORD8 err_status_num_escapes_bwd = 0; + UWORD8 conceal_status = 1; + UWORD8 current_block_type; + + ptr_aac_dec_channel_info->rvlc_curr_sf_flag = 1; + + if (ptr_rvlc->rvlc_err_log & RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD) + err_status_forbidden_cw_fwd = 1; + + if (ptr_rvlc->rvlc_err_log & RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD) + err_status_forbidden_cw_bwd = 1; + + if (ptr_rvlc->rvlc_sf_fwd_len) err_status_length_fwd = 1; + + if (ptr_rvlc->rvlc_sf_bwd_len) err_status_length_bwd = 1; + + if (ptr_rvlc->sf_esc_present) + if (ptr_rvlc->rvlc_esc_len) err_status_length_escape = 1; + + if (ptr_rvlc->sf_used) { + if (ptr_rvlc->firt_scale_fac != (ptr_aac_dec_channel_info->global_gain)) + err_status_first_scf = 1; + + if (ptr_rvlc->last_scale_fac != (ptr_rvlc->rev_global_gain)) + err_status_last_scf = 1; + } + + if (ptr_rvlc->noise_used) { + if (ptr_rvlc->first_nrg != (ptr_aac_dec_channel_info->global_gain + + ptr_rvlc->dpcm_noise_nrg - 90 - 256)) + err_status_first_nrg = 1; + + if (ptr_rvlc->last_nrg != + (ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - 90 - 256)) + err_status_last_nrg = 1; + } + + if (ptr_rvlc->intensity_used) { + if (ptr_rvlc->is_first != 0) err_status_first_is = 1; + + if (ptr_rvlc->is_last != (ptr_rvlc->dpcm_is_last_pos)) + err_status_last_is = 1; + } + + if ((ptr_rvlc->num_fwd_esc_words_decoded != + ptr_rvlc->num_esc_words_decoded) && + (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT)) { + err_status_num_escapes_fwd = 1; + } + + if ((ptr_rvlc->num_bwd_esc_words_decoded != + ptr_rvlc->num_esc_words_decoded) && + (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT)) { + err_status_num_escapes_bwd = 1; + } + + if (err_status_length_escape || + (((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) && + (ptr_rvlc->num_fwd_esc_words_decoded != + ptr_rvlc->num_esc_words_decoded) && + (err_status_last_scf || err_status_last_nrg || err_status_last_is)) + + && + + ((ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) && + (ptr_rvlc->num_bwd_esc_words_decoded != + ptr_rvlc->num_esc_words_decoded) && + (err_status_first_scf || err_status_first_nrg || + err_status_first_is))) || + ((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) && + ((ptr_rvlc->rev_global_gain - ptr_rvlc->last_scale_fac) < -15)) || + ((ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) && + ((ptr_aac_dec_channel_info->global_gain - ptr_rvlc->firt_scale_fac) < + -15))) { + if ((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) || + (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT)) { + ptr_rvlc->conceal_max = 0; + ptr_rvlc->conceal_min = + ixheaacd_max32(0, (ptr_rvlc->num_wind_grps - 1) * 16 + + ptr_rvlc->max_sfb_transmitted - 1); + } else { + ptr_rvlc->conceal_max = + ixheaacd_min32(ptr_rvlc->conceal_max, ptr_rvlc->conceal_max_esc); + ptr_rvlc->conceal_min = + ixheaacd_max32(ptr_rvlc->conceal_min, ptr_rvlc->conceal_min_esc); + } + } + + err_status_complete = + err_status_last_scf || err_status_first_scf || err_status_last_nrg || + err_status_first_nrg || err_status_last_is || err_status_first_is || + err_status_forbidden_cw_fwd || err_status_forbidden_cw_bwd || + err_status_length_fwd || err_status_length_bwd || + err_status_length_escape || err_status_num_escapes_fwd || + err_status_num_escapes_bwd; + + current_block_type = + (ptr_aac_dec_channel_info->str_ics_info.window_sequence == + EIGHT_SHORT_SEQUENCE) + ? 0 + : 1; + + if (!err_status_complete) { + WORD32 band; + WORD32 group; + WORD32 bnds; + WORD32 last_sfb_idx; + + last_sfb_idx = (ptr_rvlc->num_wind_grps > 1) ? 16 : 64; + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = + ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds] = + ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; + } + } + + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + bnds = 16 * group + band; + ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] = + ptr_aac_dec_channel_info->ptr_code_book[bnds]; + } + for (; band < last_sfb_idx; band++) { + bnds = 16 * group + band; + ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] = ZERO_HCB; + } + } + } else { + WORD32 band; + WORD32 group; + + if (((ptr_rvlc->conceal_min != CONCEAL_MIN_INIT) || + (ptr_rvlc->conceal_max != CONCEAL_MAX_INIT)) && + (ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && + (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == + current_block_type) && + ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && + ptr_rvlc->sf_concealment && conceal_status) { + ixheaacd_bi_dir_est_scf_prev_frame_reference( + ptr_aac_dec_channel_info, ptr_aac_dec_static_channel_info); + conceal_status = 0; + } + + if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && + ((ptr_rvlc->conceal_min != CONCEAL_MIN_INIT) || + (ptr_rvlc->conceal_max != CONCEAL_MAX_INIT)) && + !(ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && + ptr_rvlc->sf_concealment && + (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == + current_block_type)) && + conceal_status) { + ixheaacd_bi_dir_est_lower_scf_cur_frame(ptr_aac_dec_channel_info); + conceal_status = 0; + } + + if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && + ((err_status_last_scf && err_status_first_scf) || + (err_status_last_nrg && err_status_first_nrg) || + (err_status_last_is && err_status_first_is)) && + !(err_status_forbidden_cw_fwd || err_status_forbidden_cw_bwd || + err_status_length_escape) && + conceal_status) { + ixheaacd_statistical_estimation(ptr_aac_dec_channel_info); + conceal_status = 0; + } + + if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && + ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && + ptr_rvlc->sf_concealment && + (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == + current_block_type) && + conceal_status) { + ixheaacd_predictive_interpolation(ptr_aac_dec_channel_info, + ptr_aac_dec_static_channel_info); + conceal_status = 0; + } + + if (conceal_status) { + for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { + for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { + ptr_aac_dec_channel_info->ptr_scale_factor[16 * group + band] = 0; + } + } + ptr_aac_dec_channel_info->rvlc_curr_sf_flag = 0; + } + } +} + +VOID ixheaacd_rvlc_dec(ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info, + ia_bit_buf_struct *it_bit_buff) { + ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; + WORD32 bit_cnt_offset; + UWORD32 save_bit_cnt; + + ixheaacd_rvlc_init(ptr_rvlc, ptr_aac_dec_channel_info, it_bit_buff); + + save_bit_cnt = it_bit_buff->cnt_bits; + + if (ptr_rvlc->sf_esc_present) + ixheaacd_rvlc_decode_escape( + ptr_rvlc, ptr_aac_dec_channel_info->rvlc_scf_esc_arr, it_bit_buff); + + ixheaacd_rvlc_decode_forward(ptr_rvlc, ptr_aac_dec_channel_info, it_bit_buff); + ixheaacd_rvlc_decode_backward(ptr_rvlc, ptr_aac_dec_channel_info, + it_bit_buff); + ixheaacd_rvlc_final_error_detection(ptr_aac_dec_channel_info, + ptr_aac_dec_static_channel_info); + + ptr_aac_dec_channel_info->rvlc_intensity_used = ptr_rvlc->intensity_used; + ptr_aac_dec_channel_info->str_pns_info.pns_active = ptr_rvlc->noise_used; + + bit_cnt_offset = it_bit_buff->cnt_bits - save_bit_cnt; + if (bit_cnt_offset) { + it_bit_buff->cnt_bits -= bit_cnt_offset; + it_bit_buff->ptr_read_next = + it_bit_buff->ptr_bit_buf_base + + ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); + it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); + } +} \ No newline at end of file diff --git a/decoder/ixheaacd_rom.c b/decoder/ixheaacd_rom.c new file mode 100644 index 0000000..9467156 --- /dev/null +++ b/decoder/ixheaacd_rom.c @@ -0,0 +1,4295 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" + +#include "ixheaacd_info.h" + +ia_huff_code_book_struct ixheaacd_book; + +const WORD16 ixheaacd_sfb_96_1024[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024}; + +const WORD16 ixheaacd_sfb_96_128[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 128}; + +const WORD16 ixheaacd_sfb_96_960[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960}; + +const WORD16 ixheaacd_sfb_96_120[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 120}; + +const WORD16 ixheaacd_sfb_96_768[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, + 56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, + 212, 240, 276, 320, 384, 448, 512, 576, 640, 704, 768}; + +const WORD16 ixheaacd_sfb_96_96[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 96}; + +const WORD16 ixheaacd_sfb_64_1024[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, + 52, 56, 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, + 192, 216, 240, 268, 304, 344, 384, 424, 464, 504, 544, 584, + 624, 664, 704, 744, 784, 824, 864, 904, 944, 984, 1024}; + +const WORD16 ixheaacd_sfb_64_128[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 128}; + +const WORD16 ixheaacd_sfb_64_960[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, + 52, 56, 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, + 192, 216, 240, 268, 304, 344, 384, 424, 464, 504, 544, 584, + 624, 664, 704, 744, 784, 824, 864, 904, 944, 960}; + +const WORD16 ixheaacd_sfb_64_120[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 120}; + +const WORD16 ixheaacd_sfb_64_768[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, + 304, 344, 384, 424, 464, 504, 544, 584, 624, 664, 704, 744, 768}; + +const WORD16 ixheaacd_sfb_64_96[] = {4, 8, 12, 16, 20, 24, + 32, 40, 48, 64, 92, 96}; + +const WORD16 ixheaacd_sfb_48_1024[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, + 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, + 264, 292, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, + 672, 704, 736, 768, 800, 832, 864, 896, 928, 1024}; + +const WORD16 ixheaacd_sfb_48_960[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, + 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, + 264, 292, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, + 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 0}; + +const WORD16 ixheaacd_sfb_48_768[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, + 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, + 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768}; + +const WORD16 ixheaacd_sfb_48_512[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, + 52, 56, 60, 68, 76, 84, 92, 100, 112, 124, 136, 148, + 164, 184, 208, 236, 268, 300, 332, 364, 396, 428, 460, 512}; + +const WORD16 ixheaacd_sfb_48_480[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, + 52, 56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, + 172, 188, 212, 240, 272, 304, 336, 368, 400, 432, 480}; + +const WORD16 ixheaacd_sfb_48_128[] = {4, 8, 12, 16, 20, 28, 36, + 44, 56, 68, 80, 96, 112, 128}; + +const WORD16 ixheaacd_sfb_48_120[] = {4, 8, 12, 16, 20, 28, 36, + 44, 56, 68, 80, 96, 112, 120}; + +const WORD16 ixheaacd_sfb_48_96[] = {4, 8, 12, 16, 20, 28, + 36, 44, 56, 68, 80, 96}; + +const WORD16 ixheaacd_sfb_32_1024[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, + 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, + 264, 292, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, + 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024}; + +const WORD16 ixheaacd_sfb_32_960[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, + 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, + 264, 292, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, + 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 0}; + +const WORD16 ixheaacd_sfb_32_768[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, + 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, + 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768}; + +const WORD16 ixheaacd_sfb_32_512[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, + 56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, 192, + 212, 236, 260, 288, 320, 352, 384, 416, 448, 480, 512}; + +const WORD16 ixheaacd_sfb_32_480[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, + 56, 60, 64, 72, 80, 88, 96, 104, 112, 124, 136, 148, 164, + 180, 200, 224, 256, 288, 320, 352, 384, 416, 448, 480}; + +const WORD16 sfb_32_120[] = {4, 8, 12, 16, 20, 28, 36, 44, + 56, 68, 80, 96, 112, 120, 0}; + +const WORD16 ixheaacd_sfb_24_1024[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, + 60, 68, 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, + 172, 188, 204, 220, 240, 260, 284, 308, 336, 364, 396, 432, + 468, 508, 552, 600, 652, 704, 768, 832, 896, 960, 1024}; + +const WORD16 ixheaacd_sfb_24_960[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, + 60, 68, 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, + 172, 188, 204, 220, 240, 260, 284, 308, 336, 364, 396, 432, + 468, 508, 552, 600, 652, 704, 768, 832, 896, 960, 0}; + +const WORD16 ixheaacd_sfb_24_768[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 76, + 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, 240, 260, + 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, 768}; + +const WORD16 ixheaacd_sfb_24_128[] = {4, 8, 12, 16, 20, 24, 28, 36, + 44, 52, 64, 76, 92, 108, 128}; + +const WORD16 ixheaacd_sfb_24_120[] = {4, 8, 12, 16, 20, 24, 28, 36, + 44, 52, 64, 76, 92, 108, 120, 0}; + +const WORD16 ixheaacd_sfb_24_96[] = {4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 64, 76, 92, 96}; + +const WORD16 ixheaacd_sfb_24_512[] = {4, 8, 12, 16, 20, 24, 28, 32, + 36, 40, 44, 52, 60, 68, 80, 92, + 104, 120, 140, 164, 192, 224, 256, 288, + 320, 352, 384, 416, 448, 480, 512}; + +const WORD16 ixheaacd_sfb_24_480[] = { + 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 80, + 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480}; + +const WORD16 ixheaacd_sfb_16_1024[] = { + 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, 136, + 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, 368, 396, + 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024}; + +const WORD16 ixheaacd_sfb_16_960[] = { + 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, + 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, + 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960}; + +const WORD16 ixheaacd_sfb_16_768[] = { + 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, + 124, 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, + 320, 344, 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 768}; + +const WORD16 ixheaacd_sfb_16_128[] = {4, 8, 12, 16, 20, 24, 28, 32, + 40, 48, 60, 72, 88, 108, 128}; + +const WORD16 ixheaacd_sfb_16_120[] = {4, 8, 12, 16, 20, 24, 28, 32, + 40, 48, 60, 72, 88, 108, 120}; + +const WORD16 ixheaacd_sfb_16_96[] = {4, 8, 12, 16, 20, 24, 28, + 32, 40, 48, 60, 72, 88, 96}; + +const WORD16 ixheaacd_sfb_8_1024[] = { + 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024}; + +const WORD16 ixheaacd_sfb_8_768[] = { + 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, + 172, 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, + 420, 448, 476, 508, 544, 580, 620, 664, 712, 764, 768}; + +const WORD16 ixheaacd_sfb_8_128[] = {4, 8, 12, 16, 20, 24, 28, 36, + 44, 52, 60, 72, 88, 108, 128}; + +const WORD16 ixheaacd_sfb_8_96[] = {4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 60, 72, 88, 96}; + +const WORD16 ixheaacd_sfb_8_960[] = { + 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 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)] = { + 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)] = { + + {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, + ixheaacd_sfb_96_96, 8, 4, 0, 0, 0, 0}, + {88200, 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, + ixheaacd_sfb_96_96, 8, 4, 0, 0, 0, 0}, + {64000, 47, ixheaacd_sfb_64_1024, 12, ixheaacd_sfb_64_128, 46, + ixheaacd_sfb_64_960, 12, ixheaacd_sfb_64_120, 41, ixheaacd_sfb_64_768, 12, + ixheaacd_sfb_64_96, 13, 5, 0, 0, 0, 0}, + {48000, 49, ixheaacd_sfb_48_1024, 14, ixheaacd_sfb_48_128, 49, + ixheaacd_sfb_48_960, 14, ixheaacd_sfb_48_120, 43, ixheaacd_sfb_48_768, 12, + ixheaacd_sfb_48_96, 18, 5, 35, ixheaacd_sfb_48_480, 36, + ixheaacd_sfb_48_512}, + {44100, 49, ixheaacd_sfb_48_1024, 14, ixheaacd_sfb_48_128, 49, + ixheaacd_sfb_48_960, 14, ixheaacd_sfb_48_120, 43, ixheaacd_sfb_48_768, 12, + ixheaacd_sfb_48_96, 18, 5, 35, ixheaacd_sfb_48_480, 36, + ixheaacd_sfb_48_512}, + {32000, 51, ixheaacd_sfb_32_1024, 14, ixheaacd_sfb_48_128, 49, + ixheaacd_sfb_32_960, 14, ixheaacd_sfb_48_120, 43, ixheaacd_sfb_32_768, 12, + ixheaacd_sfb_48_96, 26, 6, 37, ixheaacd_sfb_32_480, 37, + ixheaacd_sfb_32_512}, + {24000, 47, ixheaacd_sfb_24_1024, 15, ixheaacd_sfb_24_128, 46, + ixheaacd_sfb_24_960, 15, ixheaacd_sfb_24_120, 43, ixheaacd_sfb_24_768, 14, + ixheaacd_sfb_24_96, 36, 8, 30, ixheaacd_sfb_24_480, 31, + ixheaacd_sfb_24_512}, + {22050, 47, ixheaacd_sfb_24_1024, 15, ixheaacd_sfb_24_128, 46, + ixheaacd_sfb_24_960, 15, ixheaacd_sfb_24_120, 43, ixheaacd_sfb_24_768, 14, + ixheaacd_sfb_24_96, 36, 8, 30, ixheaacd_sfb_24_480, 31, + ixheaacd_sfb_24_512}, + {16000, 43, ixheaacd_sfb_16_1024, 15, ixheaacd_sfb_16_128, 42, + ixheaacd_sfb_16_960, 15, ixheaacd_sfb_16_120, 39, ixheaacd_sfb_16_768, 14, + ixheaacd_sfb_16_96, 54, 8, 0, 0, 0, 0}, + {12000, 43, ixheaacd_sfb_16_1024, 15, ixheaacd_sfb_16_128, 42, + ixheaacd_sfb_16_960, 15, ixheaacd_sfb_16_120, 39, ixheaacd_sfb_16_768, 14, + ixheaacd_sfb_16_96, 104, 10, 0, 0, 0, 0}, + {11025, 43, ixheaacd_sfb_16_1024, 15, ixheaacd_sfb_16_128, 42, + ixheaacd_sfb_16_960, 15, ixheaacd_sfb_16_120, 39, ixheaacd_sfb_16_768, 14, + ixheaacd_sfb_16_96, 104, 10, 0, 0, 0, 0}, + {8000, 40, ixheaacd_sfb_8_1024, 15, ixheaacd_sfb_8_128, 40, + ixheaacd_sfb_8_960, 15, ixheaacd_sfb_8_120, 37, ixheaacd_sfb_8_768, 14, + ixheaacd_sfb_8_96, 104, 9, 0, 0, 0, 0}, + {7350, 40, ixheaacd_sfb_8_1024, 15, ixheaacd_sfb_8_128, 40, + ixheaacd_sfb_8_960, 15, ixheaacd_sfb_8_120, 37, ixheaacd_sfb_8_768, 14, + ixheaacd_sfb_8_96, 104, 9, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + +const FLOAT32 ixheaacd_int_leave_gain_table[256] = { + 0.012445F, 0.215546F, 0.028326F, 0.965442F, 0.053042F, 0.525819F, + 0.065409F, 1.495322F, 0.078212F, 2.323725F, 0.100504F, 0.751276F, + 0.112617F, 3.427530F, 0.113124F, 0.309583F, 0.121763F, 1.140685F, + 0.143515F, 7.519609F, 0.162430F, 0.568752F, 0.164940F, 1.904113F, + 0.165429F, 4.947562F, 0.194985F, 0.855463F, 0.213527F, 1.281019F, + 0.223544F, 0.414672F, 0.243135F, 2.781766F, 0.257180F, 1.659565F, + 0.269488F, 0.636749F, 0.286539F, 1.003938F, 0.328124F, 2.225436F, + 0.328761F, 0.330278F, 0.336807F, 11.500983F, 0.339794F, 3.805726F, + 0.344454F, 1.494626F, 0.346165F, 0.738748F, 0.363605F, 1.141454F, + 0.398729F, 0.517614F, 0.415276F, 2.928666F, 0.416282F, 0.862935F, + 0.423421F, 1.873310F, 0.444151F, 0.202244F, 0.445842F, 1.301113F, + 0.455671F, 5.519512F, 0.484764F, 0.387607F, 0.488696F, 0.967884F, + 0.488730F, 0.666771F, 0.508189F, 1.516224F, 0.508792F, 2.348662F, + 0.531504F, 3.883870F, 0.548649F, 1.112861F, 0.551182F, 0.514986F, + 0.564397F, 1.742030F, 0.566598F, 0.796454F, 0.589255F, 3.081743F, + 0.598816F, 1.271936F, 0.617654F, 0.333501F, 0.619073F, 2.040522F, + 0.625282F, 0.950244F, 0.630798F, 0.594883F, 0.638918F, 4.863197F, + 0.650102F, 1.464846F, 0.668412F, 0.747138F, 0.669490F, 2.583027F, + 0.683757F, 1.125479F, 0.691216F, 1.739274F, 0.718441F, 3.297789F, + 0.722608F, 0.902743F, 0.728827F, 2.194941F, 0.729586F, 0.633849F, + 0.730907F, 7.432957F, 0.731017F, 0.431076F, 0.731543F, 1.387847F, + 0.759183F, 1.045210F, 0.768606F, 1.789648F, 0.771245F, 4.085637F, + 0.772613F, 0.778145F, 0.786483F, 1.283204F, 0.792467F, 2.412891F, + 0.802393F, 0.544588F, 0.807156F, 0.255978F, 0.814280F, 1.544409F, + 0.817839F, 0.938798F, 0.826959F, 2.910633F, 0.830453F, 0.684066F, + 0.833431F, 1.171532F, 0.841208F, 1.908628F, 0.846440F, 5.333522F, + 0.868280F, 0.841519F, 0.868662F, 1.435230F, 0.871449F, 3.675784F, + 0.881317F, 2.245058F, 0.882020F, 0.480249F, 0.882476F, 1.105804F, + 0.902856F, 0.684850F, 0.904419F, 1.682113F, 0.909384F, 2.787801F, + 0.916558F, 7.500981F, 0.918444F, 0.950341F, 0.919721F, 1.296319F, + 0.940272F, 4.682978F, 0.940273F, 1.991736F, 0.950291F, 3.507281F, + 0.957455F, 1.116284F, 0.957723F, 0.793034F, 0.958217F, 1.497824F, + 0.962628F, 2.514156F, 0.968507F, 0.588605F, 0.974739F, 0.339933F, + 0.991738F, 1.750201F, 0.997210F, 0.936131F, 1.002422F, 1.250008F, + 1.006040F, 2.167232F, 1.008848F, 3.129940F, 1.014404F, 5.842819F, + 1.027798F, 4.287319F, 1.039404F, 1.489295F, 1.039628F, 8.947958F, + 1.043214F, 0.765733F, 1.045089F, 2.537806F, 1.058994F, 1.031496F, + 1.060415F, 0.478612F, 1.072132F, 12.8F, 1.074778F, 1.910049F, + 1.076570F, 15.9999F, 1.107853F, 3.843067F, 1.110673F, 1.228576F, + 1.110969F, 2.758471F, 1.140058F, 1.603077F, 1.155384F, 0.668935F, + 1.176229F, 6.717108F, 1.179008F, 2.011940F, 1.187735F, 0.963552F, + 1.199569F, 4.891432F, 1.206311F, 3.316329F, 1.215323F, 2.507536F, + 1.223150F, 1.387102F, 1.296012F, 9.684225F}; +const WORD32 twiddle_table_fft[257] = { + 0x00007fff, 0xff377fff, 0xfe6e7ffe, 0xfda57ffa, 0xfcdc7ff6, 0xfc137ff1, + 0xfb4a7fea, 0xfa817fe2, 0xf9b87fd9, 0xf8ef7fce, 0xf8277fc2, 0xf75e7fb5, + 0xf6957fa7, 0xf5cd7f98, 0xf5057f87, 0xf43c7f75, 0xf3747f62, 0xf2ac7f4e, + 0xf1e47f38, 0xf11c7f22, 0xf0557f0a, 0xef8d7ef0, 0xeec67ed6, 0xedff7eba, + 0xed387e9d, 0xec717e7f, 0xebab7e60, 0xeae47e3f, 0xea1e7e1e, 0xe9587dfb, + 0xe8927dd6, 0xe7cd7db1, 0xe7077d8a, 0xe6427d63, 0xe57d7d3a, 0xe4b97d0f, + 0xe3f47ce4, 0xe3307cb7, 0xe26d7c89, 0xe1a97c5a, 0xe0e67c2a, 0xe0237bf9, + 0xdf617bc6, 0xde9e7b92, 0xdddc7b5d, 0xdd1b7b27, 0xdc597aef, 0xdb997ab7, + 0xdad87a7d, 0xda187a42, 0xd9587a06, 0xd89879c9, 0xd7d9798a, 0xd71b794a, + 0xd65c790a, 0xd59e78c8, 0xd4e17885, 0xd4247840, 0xd36777fb, 0xd2ab77b4, + 0xd1ef776c, 0xd1347723, 0xd07976d9, 0xcfbe768e, 0xcf047642, 0xce4b75f4, + 0xcd9275a6, 0xccd97556, 0xcc217505, 0xcb6974b3, 0xcab27460, 0xc9fc740b, + 0xc94673b6, 0xc890735f, 0xc7db7308, 0xc72772af, 0xc6737255, 0xc5c071fa, + 0xc50d719e, 0xc45b7141, 0xc3a970e3, 0xc2f87083, 0xc2487023, 0xc1986fc2, + 0xc0e96f5f, 0xc03a6efb, 0xbf8c6e97, 0xbedf6e31, 0xbe326dca, 0xbd866d62, + 0xbcda6cf9, 0xbc2f6c8f, 0xbb856c24, 0xbadc6bb8, 0xba336b4b, 0xb98b6add, + 0xb8e36a6e, 0xb83c69fd, 0xb796698c, 0xb6f1691a, 0xb64c68a7, 0xb5a86832, + 0xb50567bd, 0xb4626747, 0xb3c066d0, 0xb31f6657, 0xb27f65de, 0xb1df6564, + 0xb14064e9, 0xb0a2646c, 0xb00563ef, 0xaf686371, 0xaecc62f2, 0xae316272, + 0xad9761f1, 0xacfd616f, 0xac6560ec, 0xabcd6068, 0xab365fe4, 0xaaa05f5e, + 0xaa0a5ed7, 0xa9765e50, 0xa8e25dc8, 0xa84f5d3e, 0xa7bd5cb4, 0xa72c5c29, + 0xa69c5b9d, 0xa60c5b10, 0xa57e5a82, 0xa4f059f4, 0xa4635964, 0xa3d758d4, + 0xa34c5843, 0xa2c257b1, 0xa238571e, 0xa1b0568a, 0xa12955f6, 0xa0a25560, + 0xa01c54ca, 0x9f985433, 0x9f14539b, 0x9e915303, 0x9e0f5269, 0x9d8e51cf, + 0x9d0e5134, 0x9c8f5098, 0x9c114ffb, 0x9b944f5e, 0x9b174ec0, 0x9a9c4e21, + 0x9a224d81, 0x99a94ce1, 0x99304c40, 0x98b94b9e, 0x98434afb, 0x97ce4a58, + 0x975949b4, 0x96e6490f, 0x9674486a, 0x960347c4, 0x9592471d, 0x95234675, + 0x94b545cd, 0x94484524, 0x93dc447b, 0x937143d1, 0x93074326, 0x929e427a, + 0x923641ce, 0x91cf4121, 0x91694074, 0x91053fc6, 0x90a13f17, 0x903e3e68, + 0x8fdd3db8, 0x8f7d3d08, 0x8f1d3c57, 0x8ebf3ba5, 0x8e623af3, 0x8e063a40, + 0x8dab398d, 0x8d5138d9, 0x8cf83825, 0x8ca13770, 0x8c4a36ba, 0x8bf53604, + 0x8ba0354e, 0x8b4d3497, 0x8afb33df, 0x8aaa3327, 0x8a5a326e, 0x8a0c31b5, + 0x89be30fc, 0x89723042, 0x89272f87, 0x88dd2ecc, 0x88942e11, 0x884c2d55, + 0x88052c99, 0x87c02bdc, 0x877b2b1f, 0x87382a62, 0x86f629a4, 0x86b628e5, + 0x86762827, 0x86372768, 0x85fa26a8, 0x85be25e8, 0x85832528, 0x85492467, + 0x851123a7, 0x84d922e5, 0x84a32224, 0x846e2162, 0x843a209f, 0x84071fdd, + 0x83d61f1a, 0x83a61e57, 0x83771d93, 0x83491cd0, 0x831c1c0c, 0x82f11b47, + 0x82c61a83, 0x829d19be, 0x827618f9, 0x824f1833, 0x822a176e, 0x820516a8, + 0x81e215e2, 0x81c1151c, 0x81a01455, 0x8181138f, 0x816312c8, 0x81461201, + 0x812a113a, 0x81101073, 0x80f60fab, 0x80de0ee4, 0x80c80e1c, 0x80b20d54, + 0x809e0c8c, 0x808b0bc4, 0x80790afb, 0x80680a33, 0x8059096b, 0x804b08a2, + 0x803e07d9, 0x80320711, 0x80270648, 0x801e057f, 0x801604b6, 0x800f03ed, + 0x800a0324, 0x8006025b, 0x80020192, 0x800100c9, 0x80000000}; + +const WORD32 ixheaacd_twiddle_table_fft_32x32[514] = { + 0x00000000, 0x7fffffff, 0xff36f079, 0x7fff6215, 0xfe6de2e1, 0x7ffd8859, + 0xfda4d929, 0x7ffa72d0, 0xfcdbd542, 0x7ff62181, 0xfc12d91a, 0x7ff09476, + 0xfb49e6a3, 0x7fe9cbbe, 0xfa80ffcc, 0x7fe1c76a, 0xf9b82684, 0x7fd8878c, + 0xf8ef5cbc, 0x7fce0c3d, 0xf826a462, 0x7fc25595, 0xf75dff66, 0x7fb563b1, + 0xf6956fb7, 0x7fa736b3, 0xf5ccf744, 0x7f97cebb, 0xf50497fb, 0x7f872bf1, + 0xf43c53cb, 0x7f754e7e, 0xf3742ca2, 0x7f62368e, 0xf2ac246e, 0x7f4de44f, + 0xf1e43d1d, 0x7f3857f4, 0xf11c789b, 0x7f2191b2, 0xf054d8d5, 0x7f0991c2, + 0xef8d5fb9, 0x7ef0585e, 0xeec60f32, 0x7ed5e5c5, 0xedfee92c, 0x7eba3a38, + 0xed37ef92, 0x7e9d55fb, 0xec712450, 0x7e7f3955, 0xebaa894f, 0x7e5fe492, + 0xeae4207b, 0x7e3f57fd, 0xea1debbc, 0x7e1d93e8, 0xe957ecfc, 0x7dfa98a6, + 0xe8922622, 0x7dd6668d, 0xe7cc9918, 0x7db0fdf6, 0xe70747c4, 0x7d8a5f3e, + 0xe642340e, 0x7d628ac4, 0xe57d5fdb, 0x7d3980eb, 0xe4b8cd11, 0x7d0f4217, + 0xe3f47d96, 0x7ce3ceb0, 0xe330734d, 0x7cb72723, 0xe26cb01b, 0x7c894bdc, + 0xe1a935e2, 0x7c5a3d4e, 0xe0e60685, 0x7c29fbed, 0xe02323e6, 0x7bf8882f, + 0xdf608fe4, 0x7bc5e28e, 0xde9e4c61, 0x7b920b88, 0xdddc5b3b, 0x7b5d039c, + 0xdd1abe52, 0x7b26cb4e, 0xdc597782, 0x7aef6322, 0xdb9888a9, 0x7ab6cba2, + 0xdad7f3a3, 0x7a7d055a, 0xda17ba4b, 0x7a4210d7, 0xd957de7b, 0x7a05eeac, + 0xd898620c, 0x79c89f6c, 0xd7d946d8, 0x798a23b0, 0xd71a8eb6, 0x794a7c10, + 0xd65c3b7c, 0x7909a92b, 0xd59e4eff, 0x78c7aba0, 0xd4e0cb15, 0x78848412, + 0xd423b191, 0x78403327, 0xd3670446, 0x77fab987, 0xd2aac505, 0x77b417de, + 0xd1eef59f, 0x776c4eda, 0xd13397e2, 0x77235f2c, 0xd078ad9e, 0x76d94987, + 0xcfbe38a0, 0x768e0ea4, 0xcf043ab3, 0x7641af3b, 0xce4ab5a3, 0x75f42c09, + 0xcd91ab39, 0x75a585ce, 0xccd91d3e, 0x7555bd4a, 0xcc210d79, 0x7504d344, + 0xcb697db1, 0x74b2c882, 0xcab26faa, 0x745f9dd0, 0xc9fbe528, 0x740b53f9, + 0xc945dfed, 0x73b5ebd0, 0xc89061ba, 0x735f6625, 0xc7db6c50, 0x7307c3cf, + 0xc727016d, 0x72af05a5, 0xc67322ce, 0x72552c83, 0xc5bfd22f, 0x71fa3947, + 0xc50d1149, 0x719e2cd1, 0xc45ae1d7, 0x71410803, 0xc3a94590, 0x70e2cbc5, + 0xc2f83e2b, 0x708378fd, 0xc247cd5b, 0x70231098, 0xc197f4d4, 0x6fc19384, + 0xc0e8b649, 0x6f5f02b0, 0xc03a1369, 0x6efb5f11, 0xbf8c0de3, 0x6e96a99b, + 0xbedea766, 0x6e30e348, 0xbe31e19c, 0x6dca0d13, 0xbd85be30, 0x6d6227f9, + 0xbcda3ecb, 0x6cf934fa, 0xbc2f6514, 0x6c8f351b, 0xbb8532b0, 0x6c24295f, + 0xbadba944, 0x6bb812d0, 0xba32ca71, 0x6b4af277, 0xb98a97d9, 0x6adcc963, + 0xb8e3131a, 0x6a6d98a3, 0xb83c3dd2, 0x69fd6149, 0xb796199c, 0x698c246b, + 0xb6f0a812, 0x6919e31f, 0xb64beacd, 0x68a69e80, 0xb5a7e363, 0x683257aa, + 0xb5049369, 0x67bd0fbb, 0xb461fc71, 0x6746c7d6, 0xb3c0200d, 0x66cf811f, + 0xb31effcc, 0x66573cba, 0xb27e9d3c, 0x65ddfbd2, 0xb1def9e9, 0x6563bf91, + 0xb140175c, 0x64e88925, 0xb0a1f71d, 0x646c59be, 0xb0049ab3, 0x63ef328e, + 0xaf6803a2, 0x637114cb, 0xaecc336c, 0x62f201ab, 0xae312b92, 0x6271fa68, + 0xad96ed92, 0x61f1003e, 0xacfd7ae9, 0x616f146a, 0xac64d511, 0x60ec382f, + 0xabccfd83, 0x60686cce, 0xab35f5b6, 0x5fe3b38c, 0xaa9fbf1e, 0x5f5e0db2, + 0xaa0a5b2e, 0x5ed77c88, 0xa975cb57, 0x5e50015c, 0xa8e21107, 0x5dc79d7b, + 0xa84f2daa, 0x5d3e5235, 0xa7bd22ac, 0x5cb420df, 0xa72bf174, 0x5c290acb, + 0xa69b9b69, 0x5b9d1152, 0xa60c21ee, 0x5b1035ce, 0xa57d8667, 0x5a827999, + 0xa4efca31, 0x59f3de11, 0xa462eead, 0x59646497, 0xa3d6f534, 0x58d40e8b, + 0xa34bdf21, 0x5842dd53, 0xa2c1adca, 0x57b0d255, 0xa2386284, 0x571deef8, + 0xa1affea3, 0x568a34a8, 0xa1288377, 0x55f5a4d1, 0xa0a1f24d, 0x556040e1, + 0xa01c4c73, 0x54ca0a49, 0x9f979332, 0x5433027c, 0x9f13c7d1, 0x539b2aee, + 0x9e90eb95, 0x53028517, 0x9e0effc2, 0x5269126d, 0x9d8e0597, 0x51ced46d, + 0x9d0dfe54, 0x5133cc93, 0x9c8eeb34, 0x5097fc5d, 0x9c10cd71, 0x4ffb654c, + 0x9b93a641, 0x4f5e08e2, 0x9b1776da, 0x4ebfe8a3, 0x9a9c406e, 0x4e210616, + 0x9a22042d, 0x4d8162c3, 0x99a8c345, 0x4ce10033, 0x99307ee1, 0x4c3fdff2, + 0x98b93829, 0x4b9e038f, 0x9842f044, 0x4afb6c97, 0x97cda856, 0x4a581c9c, + 0x9759617f, 0x49b41532, 0x96e61ce0, 0x490f57ed, 0x9673db94, 0x4869e664, + 0x96029eb6, 0x47c3c22e, 0x9592675c, 0x471cece6, 0x9523369c, 0x46756827, + 0x94b50d88, 0x45cd358e, 0x9447ed30, 0x452456bc, 0x93dbd6a0, 0x447acd4f, + 0x9370cae4, 0x43d09aec, 0x9306cb05, 0x4325c134, 0x929dd806, 0x427a41cf, + 0x9235f2ec, 0x41ce1e64, 0x91cf1cb7, 0x4121589a, 0x91695664, 0x4073f21c, + 0x9104a0ee, 0x3fc5ec97, 0x90a0fd4f, 0x3f1749b7, 0x903e6c7b, 0x3e680b2c, + 0x8fdcef67, 0x3db832a5, 0x8f7c8702, 0x3d07c1d5, 0x8f1d343a, 0x3c56ba6f, + 0x8ebef7fc, 0x3ba51e28, 0x8e61d32e, 0x3af2eeb6, 0x8e05c6b8, 0x3a402dd1, + 0x8daad37c, 0x398cdd31, 0x8d50fa5a, 0x38d8fe92, 0x8cf83c31, 0x382493af, + 0x8ca099da, 0x376f9e45, 0x8c4a1430, 0x36ba2013, 0x8bf4ac06, 0x36041ad8, + 0x8ba06230, 0x354d9056, 0x8b4d377d, 0x3496824f, 0x8afb2cbb, 0x33def286, + 0x8aaa42b5, 0x3326e2c2, 0x8a5a7a31, 0x326e54c7, 0x8a0bd3f6, 0x31b54a5d, + 0x89be50c4, 0x30fbc54c, 0x8971f15b, 0x3041c760, 0x8926b678, 0x2f875261, + 0x88dca0d3, 0x2ecc681d, 0x8893b125, 0x2e110a61, 0x884be821, 0x2d553afb, + 0x88054678, 0x2c98fbba, 0x87bfccd8, 0x2bdc4e6e, 0x877b7bed, 0x2b1f34eb, + 0x8738545f, 0x2a61b101, 0x86f656d4, 0x29a3c484, 0x86b583ef, 0x28e5714a, + 0x8675dc4f, 0x2826b927, 0x86376093, 0x27679df3, 0x85fa1153, 0x26a82185, + 0x85bdef28, 0x25e845b5, 0x8582faa5, 0x25280c5d, 0x8549345d, 0x24677757, + 0x85109cdd, 0x23a6887e, 0x84d934b1, 0x22e541ae, 0x84a2fc63, 0x2223a4c5, + 0x846df477, 0x2161b39f, 0x843a1d71, 0x209f701c, 0x840777d0, 0x1fdcdc1a, + 0x83d60412, 0x1f19f97a, 0x83a5c2b1, 0x1e56ca1d, 0x8376b423, 0x1d934fe5, + 0x8348d8dc, 0x1ccf8cb2, 0x831c314f, 0x1c0b826a, 0x82f0bde9, 0x1b4732ef, + 0x82c67f14, 0x1a82a025, 0x829d753b, 0x19bdcbf2, 0x8275a0c1, 0x18f8b83c, + 0x824f0209, 0x183366e8, 0x82299972, 0x176dd9de, 0x82056759, 0x16a81304, + 0x81e26c17, 0x15e21444, 0x81c0a802, 0x151bdf85, 0x81a01b6d, 0x145576b1, + 0x8180c6aa, 0x138edbb0, 0x8162aa04, 0x12c8106e, 0x8145c5c7, 0x120116d4, + 0x812a1a3a, 0x1139f0ce, 0x810fa7a1, 0x1072a047, 0x80f66e3d, 0x0fab272b, + 0x80de6e4d, 0x0ee38765, 0x80c7a80b, 0x0e1bc2e3, 0x80b21bb0, 0x0d53db92, + 0x809dc971, 0x0c8bd35d, 0x808ab181, 0x0bc3ac35, 0x8078d40e, 0x0afb6805, + 0x80683144, 0x0a3308bc, 0x8058c94c, 0x096a9049, 0x804a9c4e, 0x08a2009a, + 0x803daa6a, 0x07d95b9e, 0x8031f3c2, 0x0710a344, 0x80277873, 0x0647d97c, + 0x801e3895, 0x057f0034, 0x80163441, 0x04b6195d, 0x800f6b89, 0x03ed26e6, + 0x8009de7e, 0x03242abe, 0x80058d2f, 0x025b26d7, 0x800277a6, 0x01921d1f, + 0x80009dea, 0x00c90f87, 0x80000000, 0x00000000}; + +const WORD32 ixheaacd_twiddle_table_3pr[1155] = { + 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7ffb9d14, 0x7fee74a1, + 0x7fffffff, 0x7fee74a1, 0x7fb9d757, 0x7fffffff, 0x7fd8878c, 0x7f62368e, + 0x7fffffff, 0x7fb9d757, 0x7ee7aa4a, 0x7fffffff, 0x7f92661c, 0x7e4a5425, + 0x7fffffff, 0x7f62368e, 0x7d8a5f3e, 0x7fffffff, 0x7f294bfb, 0x7ca80037, + 0x7fffffff, 0x7ee7aa4a, 0x7ba3751c, 0x7fffffff, 0x7e9d55fb, 0x7a7d055a, + 0x7fffffff, 0x7e4a5425, 0x793501a7, 0x7fffffff, 0x7deeaa78, 0x77cbc3f0, + 0x7fffffff, 0x7d8a5f3e, 0x7641af3b, 0x7fffffff, 0x7d1d7956, 0x74972f90, + 0x7fffffff, 0x7ca80037, 0x72ccb9d9, 0x7fffffff, 0x7c29fbed, 0x70e2cbc5, + 0x7fffffff, 0x7ba3751c, 0x6ed9eba0, 0x7fffffff, 0x7b1474fc, 0x6cb2a835, + 0x7fffffff, 0x7a7d055a, 0x6a6d98a3, 0x7fffffff, 0x79dd3097, 0x680b5c32, + 0x7fffffff, 0x793501a7, 0x658c9a2c, 0x7fffffff, 0x78848412, 0x62f201ab, + 0x7fffffff, 0x77cbc3f0, 0x603c496b, 0x7fffffff, 0x770acdeb, 0x5d6c2f98, + 0x7fffffff, 0x7641af3b, 0x5a827999, 0x7fffffff, 0x757075ab, 0x577ff3d9, + 0x7fffffff, 0x74972f90, 0x54657193, 0x7fffffff, 0x73b5ebd0, 0x5133cc93, + 0x7fffffff, 0x72ccb9d9, 0x4debe4fd, 0x7fffffff, 0x71dba9a9, 0x4a8ea110, + 0x7fffffff, 0x70e2cbc5, 0x471cece6, 0x7fffffff, 0x6fe2313a, 0x4397ba31, + 0x7fffffff, 0x6ed9eba0, 0x3fffffff, 0x7fffffff, 0x6dca0d13, 0x3c56ba6f, + 0x7fffffff, 0x6cb2a835, 0x389cea71, 0x7fffffff, 0x6b93d02d, 0x34d3957d, + 0x7fffffff, 0x6a6d98a3, 0x30fbc54c, 0x7fffffff, 0x694015c1, 0x2d168791, + 0x7fffffff, 0x680b5c32, 0x2924edab, 0x7fffffff, 0x66cf811f, 0x25280c5d, + 0x7fffffff, 0x658c9a2c, 0x2120fb82, 0x7fffffff, 0x6442bd7c, 0x1d10d5c1, + 0x7fffffff, 0x62f201ab, 0x18f8b83c, 0x7fffffff, 0x619a7dcc, 0x14d9c245, + 0x7fffffff, 0x603c496b, 0x10b5150f, 0x7fffffff, 0x5ed77c88, 0x0c8bd35d, + 0x7fffffff, 0x5d6c2f98, 0x085f2136, 0x7fffffff, 0x5bfa7b81, 0x0430238f, + 0x7fffffff, 0x5a827999, 0x00000000, 0x7fffffff, 0x590443a6, 0xfbcfdc71, + 0x7fffffff, 0x577ff3d9, 0xf7a0deca, 0x7fffffff, 0x55f5a4d1, 0xf3742ca2, + 0x7fffffff, 0x54657193, 0xef4aeaf1, 0x7fffffff, 0x52cf758d, 0xeb263dbb, + 0x7fffffff, 0x5133cc93, 0xe70747c4, 0x7fffffff, 0x4f9292db, 0xe2ef2a3f, + 0x7fffffff, 0x4debe4fd, 0xdedf047d, 0x7fffffff, 0x4c3fdff2, 0xdad7f3a3, + 0x7fffffff, 0x4a8ea110, 0xd6db1255, 0x7fffffff, 0x48d84608, 0xd2e9786f, + 0x7fffffff, 0x471cece6, 0xcf043ab3, 0x7fffffff, 0x455cb40b, 0xcb2c6a83, + 0x7fffffff, 0x4397ba31, 0xc763158f, 0x7fffffff, 0x41ce1e64, 0xc3a94590, + 0x7fffffff, 0x3fffffff, 0xc0000000, 0x7fffffff, 0x3e2d7eb0, 0xbc6845ce, + 0x7fffffff, 0x3c56ba6f, 0xb8e3131a, 0x7fffffff, 0x3a7bd381, 0xb5715eef, + 0x7fffffff, 0x389cea71, 0xb2141b02, 0x7fffffff, 0x36ba2013, 0xaecc336c, + 0x7fffffff, 0x34d3957d, 0xab9a8e6c, 0x7fffffff, 0x32e96c08, 0xa8800c26, + 0x7fffffff, 0x30fbc54c, 0xa57d8667, 0x7fffffff, 0x2f0ac31f, 0xa293d067, + 0x7fffffff, 0x2d168791, 0x9fc3b694, 0x7fffffff, 0x2b1f34eb, 0x9d0dfe54, + 0x7fffffff, 0x2924edab, 0x9a7365d3, 0x7fffffff, 0x2727d485, 0x97f4a3cd, + 0x7fffffff, 0x25280c5d, 0x9592675c, 0x7fffffff, 0x2325b847, 0x934d57ca, + 0x7fffffff, 0x2120fb82, 0x9126145f, 0x7fffffff, 0x1f19f97a, 0x8f1d343a, + 0x7fffffff, 0x1d10d5c1, 0x8d334626, 0x7fffffff, 0x1b05b40e, 0x8b68d06f, + 0x7fffffff, 0x18f8b83c, 0x89be50c4, 0x7fffffff, 0x16ea0646, 0x88343c0f, + 0x7fffffff, 0x14d9c245, 0x86cafe58, 0x7fffffff, 0x12c8106e, 0x8582faa5, + 0x7fffffff, 0x10b5150f, 0x845c8ae3, 0x7fffffff, 0x0ea0f48c, 0x8357ffc8, + 0x7fffffff, 0x0c8bd35d, 0x8275a0c1, 0x7fffffff, 0x0a75d60e, 0x81b5abda, + 0x7fffffff, 0x085f2136, 0x811855b5, 0x7fffffff, 0x0647d97c, 0x809dc971, + 0x7fffffff, 0x0430238f, 0x804628a8, 0x7fffffff, 0x02182427, 0x80118b5e, + 0x7fffffff, 0x00000000, 0x80000000, 0x7fffffff, 0xfde7dbd9, 0x80118b5e, + 0x7fffffff, 0xfbcfdc71, 0x804628a8, 0x7fffffff, 0xf9b82684, 0x809dc971, + 0x7fffffff, 0xf7a0deca, 0x811855b5, 0x7fffffff, 0xf58a29f2, 0x81b5abda, + 0x7fffffff, 0xf3742ca2, 0x8275a0c1, 0x7fffffff, 0xf15f0b74, 0x8357ffc8, + 0x7fffffff, 0xef4aeaf1, 0x845c8ae3, 0x7fffffff, 0xed37ef92, 0x8582faa5, + 0x7fffffff, 0xeb263dbb, 0x86cafe58, 0x7fffffff, 0xe915f9ba, 0x88343c0f, + 0x7fffffff, 0xe70747c4, 0x89be50c4, 0x7fffffff, 0xe4fa4bf2, 0x8b68d06f, + 0x7fffffff, 0xe2ef2a3f, 0x8d334626, 0x7fffffff, 0xe0e60685, 0x8f1d343a, + 0x7fffffff, 0xdedf047d, 0x9126145f, 0x7fffffff, 0xdcda47b9, 0x934d57ca, + 0x7fffffff, 0xdad7f3a3, 0x9592675c, 0x7fffffff, 0xd8d82b7b, 0x97f4a3cd, + 0x7fffffff, 0xd6db1255, 0x9a7365d3, 0x7fffffff, 0xd4e0cb15, 0x9d0dfe54, + 0x7fffffff, 0xd2e9786f, 0x9fc3b694, 0x7fffffff, 0xd0f53ce0, 0xa293d067, + 0x7fffffff, 0xcf043ab3, 0xa57d8667, 0x7fffffff, 0xcd1693f7, 0xa8800c26, + 0x7fffffff, 0xcb2c6a83, 0xab9a8e6c, 0x7fffffff, 0xc945dfed, 0xaecc336c, + 0x7fffffff, 0xc763158f, 0xb2141b02, 0x7fffffff, 0xc5842c7f, 0xb5715eef, + 0x7fffffff, 0xc3a94590, 0xb8e3131a, 0x7fffffff, 0xc1d28150, 0xbc6845ce, + 0x7fffffff, 0xc0000000, 0xc0000000, 0x7fffffff, 0xbe31e19c, 0xc3a94590, + 0x7fffffff, 0xbc6845ce, 0xc763158f, 0x7fffffff, 0xbaa34bf4, 0xcb2c6a83, + 0x7fffffff, 0xb8e3131a, 0xcf043ab3, 0x7fffffff, 0xb727b9f7, 0xd2e9786f, + 0x7fffffff, 0xb5715eef, 0xd6db1255, 0x7fffffff, 0xb3c0200d, 0xdad7f3a3, + 0x7fffffff, 0xb2141b02, 0xdedf047d, 0x7fffffff, 0xb06d6d25, 0xe2ef2a3f, + 0x7fffffff, 0xaecc336c, 0xe70747c4, 0x7fffffff, 0xad308a72, 0xeb263dbb, + 0x7fffffff, 0xab9a8e6c, 0xef4aeaf1, 0x7fffffff, 0xaa0a5b2e, 0xf3742ca2, + 0x7fffffff, 0xa8800c26, 0xf7a0deca, 0x7fffffff, 0xa6fbbc5a, 0xfbcfdc71, + 0x7fffffff, 0xa57d8667, 0x00000000, 0x7fffffff, 0xa405847f, 0x0430238f, + 0x7fffffff, 0xa293d067, 0x085f2136, 0x7fffffff, 0xa1288377, 0x0c8bd35d, + 0x7fffffff, 0x9fc3b694, 0x10b5150f, 0x7fffffff, 0x9e658233, 0x14d9c245, + 0x7fffffff, 0x9d0dfe54, 0x18f8b83c, 0x7fffffff, 0x9bbd4283, 0x1d10d5c1, + 0x7fffffff, 0x9a7365d3, 0x2120fb82, 0x7fffffff, 0x99307ee1, 0x25280c5d, + 0x7fffffff, 0x97f4a3cd, 0x2924edab, 0x7fffffff, 0x96bfea3e, 0x2d168791, + 0x7fffffff, 0x9592675c, 0x30fbc54c, 0x7fffffff, 0x946c2fd2, 0x34d3957d, + 0x7fffffff, 0x934d57ca, 0x389cea71, 0x7fffffff, 0x9235f2ec, 0x3c56ba6f, + 0x7fffffff, 0x9126145f, 0x3fffffff, 0x7fffffff, 0x901dcec5, 0x4397ba31, + 0x7fffffff, 0x8f1d343a, 0x471cece6, 0x7fffffff, 0x8e245656, 0x4a8ea110, + 0x7fffffff, 0x8d334626, 0x4debe4fd, 0x7fffffff, 0x8c4a1430, 0x5133cc93, + 0x7fffffff, 0x8b68d06f, 0x54657193, 0x7fffffff, 0x8a8f8a54, 0x577ff3d9, + 0x7fffffff, 0x89be50c4, 0x5a827999, 0x7fffffff, 0x88f53214, 0x5d6c2f98, + 0x7fffffff, 0x88343c0f, 0x603c496b, 0x7fffffff, 0x877b7bed, 0x62f201ab, + 0x7fffffff, 0x86cafe58, 0x658c9a2c, 0x7fffffff, 0x8622cf68, 0x680b5c32, + 0x7fffffff, 0x8582faa5, 0x6a6d98a3, 0x7fffffff, 0x84eb8b03, 0x6cb2a835, + 0x7fffffff, 0x845c8ae3, 0x6ed9eba0, 0x7fffffff, 0x83d60412, 0x70e2cbc5, + 0x7fffffff, 0x8357ffc8, 0x72ccb9d9, 0x7fffffff, 0x82e286a9, 0x74972f90, + 0x7fffffff, 0x8275a0c1, 0x7641af3b, 0x7fffffff, 0x82115587, 0x77cbc3f0, + 0x7fffffff, 0x81b5abda, 0x793501a7, 0x7fffffff, 0x8162aa04, 0x7a7d055a, + 0x7fffffff, 0x811855b5, 0x7ba3751c, 0x7fffffff, 0x80d6b404, 0x7ca80037, + 0x7fffffff, 0x809dc971, 0x7d8a5f3e, 0x7fffffff, 0x806d99e3, 0x7e4a5425, + 0x7fffffff, 0x804628a8, 0x7ee7aa4a, 0x7fffffff, 0x80277873, 0x7f62368e, + 0x7fffffff, 0x80118b5e, 0x7fb9d757, 0x7fffffff, 0x800462eb, 0x7fee74a1, + 0x7fffffff, 0x80000000, 0x7fffffff, 0x7fffffff, 0x800462eb, 0x7fee74a1, + 0x7fffffff, 0x80118b5e, 0x7fb9d757, 0x7fffffff, 0x80277873, 0x7f62368e, + 0x7fffffff, 0x804628a8, 0x7ee7aa4a, 0x7fffffff, 0x806d99e3, 0x7e4a5425, + 0x7fffffff, 0x809dc971, 0x7d8a5f3e, 0x7fffffff, 0x80d6b404, 0x7ca80037, + 0x7fffffff, 0x811855b5, 0x7ba3751c, 0x7fffffff, 0x8162aa04, 0x7a7d055a, + 0x7fffffff, 0x81b5abda, 0x793501a7, 0x7fffffff, 0x82115587, 0x77cbc3f0, + 0x7fffffff, 0x8275a0c1, 0x7641af3b, 0x7fffffff, 0x82e286a9, 0x74972f90, + 0x7fffffff, 0x8357ffc8, 0x72ccb9d9, 0x7fffffff, 0x83d60412, 0x70e2cbc5, + 0x7fffffff, 0x845c8ae3, 0x6ed9eba0, 0x7fffffff, 0x84eb8b03, 0x6cb2a835, + 0x7fffffff, 0x8582faa5, 0x6a6d98a3, 0x7fffffff, 0x8622cf68, 0x680b5c32, + 0x7fffffff, 0x86cafe58, 0x658c9a2c, 0x7fffffff, 0x877b7bed, 0x62f201ab, + 0x7fffffff, 0x88343c0f, 0x603c496b, 0x7fffffff, 0x88f53214, 0x5d6c2f98, + 0x7fffffff, 0x89be50c4, 0x5a827999, 0x7fffffff, 0x8a8f8a54, 0x577ff3d9, + 0x7fffffff, 0x8b68d06f, 0x54657193, 0x7fffffff, 0x8c4a1430, 0x5133cc93, + 0x7fffffff, 0x8d334626, 0x4debe4fd, 0x7fffffff, 0x8e245656, 0x4a8ea110, + 0x7fffffff, 0x8f1d343a, 0x471cece6, 0x7fffffff, 0x901dcec5, 0x4397ba31, + 0x7fffffff, 0x9126145f, 0x3fffffff, 0x7fffffff, 0x9235f2ec, 0x3c56ba6f, + 0x7fffffff, 0x934d57ca, 0x389cea71, 0x7fffffff, 0x946c2fd2, 0x34d3957d, + 0x7fffffff, 0x9592675c, 0x30fbc54c, 0x7fffffff, 0x96bfea3e, 0x2d168791, + 0x7fffffff, 0x97f4a3cd, 0x2924edab, 0x7fffffff, 0x99307ee1, 0x25280c5d, + 0x7fffffff, 0x9a7365d3, 0x2120fb82, 0x7fffffff, 0x9bbd4283, 0x1d10d5c1, + 0x7fffffff, 0x9d0dfe54, 0x18f8b83c, 0x7fffffff, 0x9e658233, 0x14d9c245, + 0x7fffffff, 0x9fc3b694, 0x10b5150f, 0x7fffffff, 0xa1288377, 0x0c8bd35d, + 0x7fffffff, 0xa293d067, 0x085f2136, 0x7fffffff, 0xa405847f, 0x0430238f, + 0x7fffffff, 0xa57d8667, 0x00000000, 0x7fffffff, 0xa6fbbc5a, 0xfbcfdc71, + 0x7fffffff, 0xa8800c26, 0xf7a0deca, 0x7fffffff, 0xaa0a5b2e, 0xf3742ca2, + 0x7fffffff, 0xab9a8e6c, 0xef4aeaf1, 0x7fffffff, 0xad308a72, 0xeb263dbb, + 0x7fffffff, 0xaecc336c, 0xe70747c4, 0x7fffffff, 0xb06d6d25, 0xe2ef2a3f, + 0x7fffffff, 0xb2141b02, 0xdedf047d, 0x7fffffff, 0xb3c0200d, 0xdad7f3a3, + 0x7fffffff, 0xb5715eef, 0xd6db1255, 0x7fffffff, 0xb727b9f7, 0xd2e9786f, + 0x7fffffff, 0xb8e3131a, 0xcf043ab3, 0x7fffffff, 0xbaa34bf4, 0xcb2c6a83, + 0x7fffffff, 0xbc6845ce, 0xc763158f, 0x7fffffff, 0xbe31e19c, 0xc3a94590, + 0x7fffffff, 0xc0000000, 0xc0000000, 0x7fffffff, 0xc1d28150, 0xbc6845ce, + 0x7fffffff, 0xc3a94590, 0xb8e3131a, 0x7fffffff, 0xc5842c7f, 0xb5715eef, + 0x7fffffff, 0xc763158f, 0xb2141b02, 0x7fffffff, 0xc945dfed, 0xaecc336c, + 0x7fffffff, 0xcb2c6a83, 0xab9a8e6c, 0x7fffffff, 0xcd1693f7, 0xa8800c26, + 0x7fffffff, 0xcf043ab3, 0xa57d8667, 0x7fffffff, 0xd0f53ce0, 0xa293d067, + 0x7fffffff, 0xd2e9786f, 0x9fc3b694, 0x7fffffff, 0xd4e0cb15, 0x9d0dfe54, + 0x7fffffff, 0xd6db1255, 0x9a7365d3, 0x7fffffff, 0xd8d82b7b, 0x97f4a3cd, + 0x7fffffff, 0xdad7f3a3, 0x9592675c, 0x7fffffff, 0xdcda47b9, 0x934d57ca, + 0x7fffffff, 0xdedf047d, 0x9126145f, 0x7fffffff, 0xe0e60685, 0x8f1d343a, + 0x7fffffff, 0xe2ef2a3f, 0x8d334626, 0x7fffffff, 0xe4fa4bf2, 0x8b68d06f, + 0x7fffffff, 0xe70747c4, 0x89be50c4, 0x7fffffff, 0xe915f9ba, 0x88343c0f, + 0x7fffffff, 0xeb263dbb, 0x86cafe58, 0x7fffffff, 0xed37ef92, 0x8582faa5, + 0x7fffffff, 0xef4aeaf1, 0x845c8ae3, 0x7fffffff, 0xf15f0b74, 0x8357ffc8, + 0x7fffffff, 0xf3742ca2, 0x8275a0c1, 0x7fffffff, 0xf58a29f2, 0x81b5abda, + 0x7fffffff, 0xf7a0deca, 0x811855b5, 0x7fffffff, 0xf9b82684, 0x809dc971, + 0x7fffffff, 0xfbcfdc71, 0x804628a8, 0x7fffffff, 0xfde7dbd9, 0x80118b5e, + 0x7fffffff, 0x00000000, 0x80000000, 0x7fffffff, 0x02182427, 0x80118b5e, + 0x7fffffff, 0x0430238f, 0x804628a8, 0x7fffffff, 0x0647d97c, 0x809dc971, + 0x7fffffff, 0x085f2136, 0x811855b5, 0x7fffffff, 0x0a75d60e, 0x81b5abda, + 0x7fffffff, 0x0c8bd35d, 0x8275a0c1, 0x7fffffff, 0x0ea0f48c, 0x8357ffc8, + 0x7fffffff, 0x10b5150f, 0x845c8ae3, 0x7fffffff, 0x12c8106e, 0x8582faa5, + 0x7fffffff, 0x14d9c245, 0x86cafe58, 0x7fffffff, 0x16ea0646, 0x88343c0f, + 0x7fffffff, 0x18f8b83c, 0x89be50c4, 0x7fffffff, 0x1b05b40e, 0x8b68d06f, + 0x7fffffff, 0x1d10d5c1, 0x8d334626, 0x7fffffff, 0x1f19f97a, 0x8f1d343a, + 0x7fffffff, 0x2120fb82, 0x9126145f, 0x7fffffff, 0x2325b847, 0x934d57ca, + 0x7fffffff, 0x25280c5d, 0x9592675c, 0x7fffffff, 0x2727d485, 0x97f4a3cd, + 0x7fffffff, 0x2924edab, 0x9a7365d3, 0x7fffffff, 0x2b1f34eb, 0x9d0dfe54, + 0x7fffffff, 0x2d168791, 0x9fc3b694, 0x7fffffff, 0x2f0ac31f, 0xa293d067, + 0x7fffffff, 0x30fbc54c, 0xa57d8667, 0x7fffffff, 0x32e96c08, 0xa8800c26, + 0x7fffffff, 0x34d3957d, 0xab9a8e6c, 0x7fffffff, 0x36ba2013, 0xaecc336c, + 0x7fffffff, 0x389cea71, 0xb2141b02, 0x7fffffff, 0x3a7bd381, 0xb5715eef, + 0x7fffffff, 0x3c56ba6f, 0xb8e3131a, 0x7fffffff, 0x3e2d7eb0, 0xbc6845ce, + 0x7fffffff, 0x3fffffff, 0xc0000000, 0x7fffffff, 0x41ce1e64, 0xc3a94590, + 0x7fffffff, 0x4397ba31, 0xc763158f, 0x7fffffff, 0x455cb40b, 0xcb2c6a83, + 0x7fffffff, 0x471cece6, 0xcf043ab3, 0x7fffffff, 0x48d84608, 0xd2e9786f, + 0x7fffffff, 0x4a8ea110, 0xd6db1255, 0x7fffffff, 0x4c3fdff2, 0xdad7f3a3, + 0x7fffffff, 0x4debe4fd, 0xdedf047d, 0x7fffffff, 0x4f9292db, 0xe2ef2a3f, + 0x7fffffff, 0x5133cc93, 0xe70747c4, 0x7fffffff, 0x52cf758d, 0xeb263dbb, + 0x7fffffff, 0x54657193, 0xef4aeaf1, 0x7fffffff, 0x55f5a4d1, 0xf3742ca2, + 0x7fffffff, 0x577ff3d9, 0xf7a0deca, 0x7fffffff, 0x590443a6, 0xfbcfdc71, + 0x7fffffff, 0x5a827999, 0x00000000, 0x7fffffff, 0x5bfa7b81, 0x0430238f, + 0x7fffffff, 0x5d6c2f98, 0x085f2136, 0x7fffffff, 0x5ed77c88, 0x0c8bd35d, + 0x7fffffff, 0x603c496b, 0x10b5150f, 0x7fffffff, 0x619a7dcc, 0x14d9c245, + 0x7fffffff, 0x62f201ab, 0x18f8b83c, 0x7fffffff, 0x6442bd7c, 0x1d10d5c1, + 0x7fffffff, 0x658c9a2c, 0x2120fb82, 0x7fffffff, 0x66cf811f, 0x25280c5d, + 0x7fffffff, 0x680b5c32, 0x2924edab, 0x7fffffff, 0x694015c1, 0x2d168791, + 0x7fffffff, 0x6a6d98a3, 0x30fbc54c, 0x7fffffff, 0x6b93d02d, 0x34d3957d, + 0x7fffffff, 0x6cb2a835, 0x389cea71, 0x7fffffff, 0x6dca0d13, 0x3c56ba6f, + 0x7fffffff, 0x6ed9eba0, 0x3fffffff, 0x7fffffff, 0x6fe2313a, 0x4397ba31, + 0x7fffffff, 0x70e2cbc5, 0x471cece6, 0x7fffffff, 0x71dba9a9, 0x4a8ea110, + 0x7fffffff, 0x72ccb9d9, 0x4debe4fd, 0x7fffffff, 0x73b5ebd0, 0x5133cc93, + 0x7fffffff, 0x74972f90, 0x54657193, 0x7fffffff, 0x757075ab, 0x577ff3d9, + 0x7fffffff, 0x7641af3b, 0x5a827999, 0x7fffffff, 0x770acdeb, 0x5d6c2f98, + 0x7fffffff, 0x77cbc3f0, 0x603c496b, 0x7fffffff, 0x78848412, 0x62f201ab, + 0x7fffffff, 0x793501a7, 0x658c9a2c, 0x7fffffff, 0x79dd3097, 0x680b5c32, + 0x7fffffff, 0x7a7d055a, 0x6a6d98a3, 0x7fffffff, 0x7b1474fc, 0x6cb2a835, + 0x7fffffff, 0x7ba3751c, 0x6ed9eba0, 0x7fffffff, 0x7c29fbed, 0x70e2cbc5, + 0x7fffffff, 0x7ca80037, 0x72ccb9d9, 0x7fffffff, 0x7d1d7956, 0x74972f90, + 0x7fffffff, 0x7d8a5f3e, 0x7641af3b, 0x7fffffff, 0x7deeaa78, 0x77cbc3f0, + 0x7fffffff, 0x7e4a5425, 0x793501a7, 0x7fffffff, 0x7e9d55fb, 0x7a7d055a, + 0x7fffffff, 0x7ee7aa4a, 0x7ba3751c, 0x7fffffff, 0x7f294bfb, 0x7ca80037, + 0x7fffffff, 0x7f62368e, 0x7d8a5f3e, 0x7fffffff, 0x7f92661c, 0x7e4a5425, + 0x7fffffff, 0x7fb9d757, 0x7ee7aa4a, 0x7fffffff, 0x7fd8878c, 0x7f62368e, + 0x7fffffff, 0x7fee74a1, 0x7fb9d757, 0x7fffffff, 0x7ffb9d14, 0x7fee74a1, + 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 ixheaacd_twiddle_table_3pi[1155] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xfde7dbd9, 0xfbcfdc71, + 0x00000000, 0xfbcfdc71, 0xf7a0deca, 0x00000000, 0xf9b82684, 0xf3742ca2, + 0x00000000, 0xf7a0deca, 0xef4aeaf1, 0x00000000, 0xf58a29f2, 0xeb263dbb, + 0x00000000, 0xf3742ca2, 0xe70747c4, 0x00000000, 0xf15f0b74, 0xe2ef2a3f, + 0x00000000, 0xef4aeaf1, 0xdedf047d, 0x00000000, 0xed37ef92, 0xdad7f3a3, + 0x00000000, 0xeb263dbb, 0xd6db1255, 0x00000000, 0xe915f9ba, 0xd2e9786f, + 0x00000000, 0xe70747c4, 0xcf043ab3, 0x00000000, 0xe4fa4bf2, 0xcb2c6a83, + 0x00000000, 0xe2ef2a3f, 0xc763158f, 0x00000000, 0xe0e60685, 0xc3a94590, + 0x00000000, 0xdedf047d, 0xc0000000, 0x00000000, 0xdcda47b9, 0xbc6845ce, + 0x00000000, 0xdad7f3a3, 0xb8e3131a, 0x00000000, 0xd8d82b7b, 0xb5715eef, + 0x00000000, 0xd6db1255, 0xb2141b02, 0x00000000, 0xd4e0cb15, 0xaecc336c, + 0x00000000, 0xd2e9786f, 0xab9a8e6c, 0x00000000, 0xd0f53ce0, 0xa8800c26, + 0x00000000, 0xcf043ab3, 0xa57d8667, 0x00000000, 0xcd1693f7, 0xa293d067, + 0x00000000, 0xcb2c6a83, 0x9fc3b694, 0x00000000, 0xc945dfed, 0x9d0dfe54, + 0x00000000, 0xc763158f, 0x9a7365d3, 0x00000000, 0xc5842c7f, 0x97f4a3cd, + 0x00000000, 0xc3a94590, 0x9592675c, 0x00000000, 0xc1d28150, 0x934d57ca, + 0x00000000, 0xc0000000, 0x9126145f, 0x00000000, 0xbe31e19c, 0x8f1d343a, + 0x00000000, 0xbc6845ce, 0x8d334626, 0x00000000, 0xbaa34bf4, 0x8b68d06f, + 0x00000000, 0xb8e3131a, 0x89be50c4, 0x00000000, 0xb727b9f7, 0x88343c0f, + 0x00000000, 0xb5715eef, 0x86cafe58, 0x00000000, 0xb3c0200d, 0x8582faa5, + 0x00000000, 0xb2141b02, 0x845c8ae3, 0x00000000, 0xb06d6d25, 0x8357ffc8, + 0x00000000, 0xaecc336c, 0x8275a0c1, 0x00000000, 0xad308a72, 0x81b5abda, + 0x00000000, 0xab9a8e6c, 0x811855b5, 0x00000000, 0xaa0a5b2e, 0x809dc971, + 0x00000000, 0xa8800c26, 0x804628a8, 0x00000000, 0xa6fbbc5a, 0x80118b5e, + 0x00000000, 0xa57d8667, 0x80000000, 0x00000000, 0xa405847f, 0x80118b5e, + 0x00000000, 0xa293d067, 0x804628a8, 0x00000000, 0xa1288377, 0x809dc971, + 0x00000000, 0x9fc3b694, 0x811855b5, 0x00000000, 0x9e658233, 0x81b5abda, + 0x00000000, 0x9d0dfe54, 0x8275a0c1, 0x00000000, 0x9bbd4283, 0x8357ffc8, + 0x00000000, 0x9a7365d3, 0x845c8ae3, 0x00000000, 0x99307ee1, 0x8582faa5, + 0x00000000, 0x97f4a3cd, 0x86cafe58, 0x00000000, 0x96bfea3e, 0x88343c0f, + 0x00000000, 0x9592675c, 0x89be50c4, 0x00000000, 0x946c2fd2, 0x8b68d06f, + 0x00000000, 0x934d57ca, 0x8d334626, 0x00000000, 0x9235f2ec, 0x8f1d343a, + 0x00000000, 0x9126145f, 0x9126145f, 0x00000000, 0x901dcec5, 0x934d57ca, + 0x00000000, 0x8f1d343a, 0x9592675c, 0x00000000, 0x8e245656, 0x97f4a3cd, + 0x00000000, 0x8d334626, 0x9a7365d3, 0x00000000, 0x8c4a1430, 0x9d0dfe54, + 0x00000000, 0x8b68d06f, 0x9fc3b694, 0x00000000, 0x8a8f8a54, 0xa293d067, + 0x00000000, 0x89be50c4, 0xa57d8667, 0x00000000, 0x88f53214, 0xa8800c26, + 0x00000000, 0x88343c0f, 0xab9a8e6c, 0x00000000, 0x877b7bed, 0xaecc336c, + 0x00000000, 0x86cafe58, 0xb2141b02, 0x00000000, 0x8622cf68, 0xb5715eef, + 0x00000000, 0x8582faa5, 0xb8e3131a, 0x00000000, 0x84eb8b03, 0xbc6845ce, + 0x00000000, 0x845c8ae3, 0xc0000000, 0x00000000, 0x83d60412, 0xc3a94590, + 0x00000000, 0x8357ffc8, 0xc763158f, 0x00000000, 0x82e286a9, 0xcb2c6a83, + 0x00000000, 0x8275a0c1, 0xcf043ab3, 0x00000000, 0x82115587, 0xd2e9786f, + 0x00000000, 0x81b5abda, 0xd6db1255, 0x00000000, 0x8162aa04, 0xdad7f3a3, + 0x00000000, 0x811855b5, 0xdedf047d, 0x00000000, 0x80d6b404, 0xe2ef2a3f, + 0x00000000, 0x809dc971, 0xe70747c4, 0x00000000, 0x806d99e3, 0xeb263dbb, + 0x00000000, 0x804628a8, 0xef4aeaf1, 0x00000000, 0x80277873, 0xf3742ca2, + 0x00000000, 0x80118b5e, 0xf7a0deca, 0x00000000, 0x800462eb, 0xfbcfdc71, + 0x00000000, 0x80000000, 0x00000000, 0x00000000, 0x800462eb, 0x0430238f, + 0x00000000, 0x80118b5e, 0x085f2136, 0x00000000, 0x80277873, 0x0c8bd35d, + 0x00000000, 0x804628a8, 0x10b5150f, 0x00000000, 0x806d99e3, 0x14d9c245, + 0x00000000, 0x809dc971, 0x18f8b83c, 0x00000000, 0x80d6b404, 0x1d10d5c1, + 0x00000000, 0x811855b5, 0x2120fb82, 0x00000000, 0x8162aa04, 0x25280c5d, + 0x00000000, 0x81b5abda, 0x2924edab, 0x00000000, 0x82115587, 0x2d168791, + 0x00000000, 0x8275a0c1, 0x30fbc54c, 0x00000000, 0x82e286a9, 0x34d3957d, + 0x00000000, 0x8357ffc8, 0x389cea71, 0x00000000, 0x83d60412, 0x3c56ba6f, + 0x00000000, 0x845c8ae3, 0x3fffffff, 0x00000000, 0x84eb8b03, 0x4397ba31, + 0x00000000, 0x8582faa5, 0x471cece6, 0x00000000, 0x8622cf68, 0x4a8ea110, + 0x00000000, 0x86cafe58, 0x4debe4fd, 0x00000000, 0x877b7bed, 0x5133cc93, + 0x00000000, 0x88343c0f, 0x54657193, 0x00000000, 0x88f53214, 0x577ff3d9, + 0x00000000, 0x89be50c4, 0x5a827999, 0x00000000, 0x8a8f8a54, 0x5d6c2f98, + 0x00000000, 0x8b68d06f, 0x603c496b, 0x00000000, 0x8c4a1430, 0x62f201ab, + 0x00000000, 0x8d334626, 0x658c9a2c, 0x00000000, 0x8e245656, 0x680b5c32, + 0x00000000, 0x8f1d343a, 0x6a6d98a3, 0x00000000, 0x901dcec5, 0x6cb2a835, + 0x00000000, 0x9126145f, 0x6ed9eba0, 0x00000000, 0x9235f2ec, 0x70e2cbc5, + 0x00000000, 0x934d57ca, 0x72ccb9d9, 0x00000000, 0x946c2fd2, 0x74972f90, + 0x00000000, 0x9592675c, 0x7641af3b, 0x00000000, 0x96bfea3e, 0x77cbc3f0, + 0x00000000, 0x97f4a3cd, 0x793501a7, 0x00000000, 0x99307ee1, 0x7a7d055a, + 0x00000000, 0x9a7365d3, 0x7ba3751c, 0x00000000, 0x9bbd4283, 0x7ca80037, + 0x00000000, 0x9d0dfe54, 0x7d8a5f3e, 0x00000000, 0x9e658233, 0x7e4a5425, + 0x00000000, 0x9fc3b694, 0x7ee7aa4a, 0x00000000, 0xa1288377, 0x7f62368e, + 0x00000000, 0xa293d067, 0x7fb9d757, 0x00000000, 0xa405847f, 0x7fee74a1, + 0x00000000, 0xa57d8667, 0x7fffffff, 0x00000000, 0xa6fbbc5a, 0x7fee74a1, + 0x00000000, 0xa8800c26, 0x7fb9d757, 0x00000000, 0xaa0a5b2e, 0x7f62368e, + 0x00000000, 0xab9a8e6c, 0x7ee7aa4a, 0x00000000, 0xad308a72, 0x7e4a5425, + 0x00000000, 0xaecc336c, 0x7d8a5f3e, 0x00000000, 0xb06d6d25, 0x7ca80037, + 0x00000000, 0xb2141b02, 0x7ba3751c, 0x00000000, 0xb3c0200d, 0x7a7d055a, + 0x00000000, 0xb5715eef, 0x793501a7, 0x00000000, 0xb727b9f7, 0x77cbc3f0, + 0x00000000, 0xb8e3131a, 0x7641af3b, 0x00000000, 0xbaa34bf4, 0x74972f90, + 0x00000000, 0xbc6845ce, 0x72ccb9d9, 0x00000000, 0xbe31e19c, 0x70e2cbc5, + 0x00000000, 0xc0000000, 0x6ed9eba0, 0x00000000, 0xc1d28150, 0x6cb2a835, + 0x00000000, 0xc3a94590, 0x6a6d98a3, 0x00000000, 0xc5842c7f, 0x680b5c32, + 0x00000000, 0xc763158f, 0x658c9a2c, 0x00000000, 0xc945dfed, 0x62f201ab, + 0x00000000, 0xcb2c6a83, 0x603c496b, 0x00000000, 0xcd1693f7, 0x5d6c2f98, + 0x00000000, 0xcf043ab3, 0x5a827999, 0x00000000, 0xd0f53ce0, 0x577ff3d9, + 0x00000000, 0xd2e9786f, 0x54657193, 0x00000000, 0xd4e0cb15, 0x5133cc93, + 0x00000000, 0xd6db1255, 0x4debe4fd, 0x00000000, 0xd8d82b7b, 0x4a8ea110, + 0x00000000, 0xdad7f3a3, 0x471cece6, 0x00000000, 0xdcda47b9, 0x4397ba31, + 0x00000000, 0xdedf047d, 0x3fffffff, 0x00000000, 0xe0e60685, 0x3c56ba6f, + 0x00000000, 0xe2ef2a3f, 0x389cea71, 0x00000000, 0xe4fa4bf2, 0x34d3957d, + 0x00000000, 0xe70747c4, 0x30fbc54c, 0x00000000, 0xe915f9ba, 0x2d168791, + 0x00000000, 0xeb263dbb, 0x2924edab, 0x00000000, 0xed37ef92, 0x25280c5d, + 0x00000000, 0xef4aeaf1, 0x2120fb82, 0x00000000, 0xf15f0b74, 0x1d10d5c1, + 0x00000000, 0xf3742ca2, 0x18f8b83c, 0x00000000, 0xf58a29f2, 0x14d9c245, + 0x00000000, 0xf7a0deca, 0x10b5150f, 0x00000000, 0xf9b82684, 0x0c8bd35d, + 0x00000000, 0xfbcfdc71, 0x085f2136, 0x00000000, 0xfde7dbd9, 0x0430238f, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02182427, 0xfbcfdc71, + 0x00000000, 0x0430238f, 0xf7a0deca, 0x00000000, 0x0647d97c, 0xf3742ca2, + 0x00000000, 0x085f2136, 0xef4aeaf1, 0x00000000, 0x0a75d60e, 0xeb263dbb, + 0x00000000, 0x0c8bd35d, 0xe70747c4, 0x00000000, 0x0ea0f48c, 0xe2ef2a3f, + 0x00000000, 0x10b5150f, 0xdedf047d, 0x00000000, 0x12c8106e, 0xdad7f3a3, + 0x00000000, 0x14d9c245, 0xd6db1255, 0x00000000, 0x16ea0646, 0xd2e9786f, + 0x00000000, 0x18f8b83c, 0xcf043ab3, 0x00000000, 0x1b05b40e, 0xcb2c6a83, + 0x00000000, 0x1d10d5c1, 0xc763158f, 0x00000000, 0x1f19f97a, 0xc3a94590, + 0x00000000, 0x2120fb82, 0xc0000000, 0x00000000, 0x2325b847, 0xbc6845ce, + 0x00000000, 0x25280c5d, 0xb8e3131a, 0x00000000, 0x2727d485, 0xb5715eef, + 0x00000000, 0x2924edab, 0xb2141b02, 0x00000000, 0x2b1f34eb, 0xaecc336c, + 0x00000000, 0x2d168791, 0xab9a8e6c, 0x00000000, 0x2f0ac31f, 0xa8800c26, + 0x00000000, 0x30fbc54c, 0xa57d8667, 0x00000000, 0x32e96c08, 0xa293d067, + 0x00000000, 0x34d3957d, 0x9fc3b694, 0x00000000, 0x36ba2013, 0x9d0dfe54, + 0x00000000, 0x389cea71, 0x9a7365d3, 0x00000000, 0x3a7bd381, 0x97f4a3cd, + 0x00000000, 0x3c56ba6f, 0x9592675c, 0x00000000, 0x3e2d7eb0, 0x934d57ca, + 0x00000000, 0x3fffffff, 0x9126145f, 0x00000000, 0x41ce1e64, 0x8f1d343a, + 0x00000000, 0x4397ba31, 0x8d334626, 0x00000000, 0x455cb40b, 0x8b68d06f, + 0x00000000, 0x471cece6, 0x89be50c4, 0x00000000, 0x48d84608, 0x88343c0f, + 0x00000000, 0x4a8ea110, 0x86cafe58, 0x00000000, 0x4c3fdff2, 0x8582faa5, + 0x00000000, 0x4debe4fd, 0x845c8ae3, 0x00000000, 0x4f9292db, 0x8357ffc8, + 0x00000000, 0x5133cc93, 0x8275a0c1, 0x00000000, 0x52cf758d, 0x81b5abda, + 0x00000000, 0x54657193, 0x811855b5, 0x00000000, 0x55f5a4d1, 0x809dc971, + 0x00000000, 0x577ff3d9, 0x804628a8, 0x00000000, 0x590443a6, 0x80118b5e, + 0x00000000, 0x5a827999, 0x80000000, 0x00000000, 0x5bfa7b81, 0x80118b5e, + 0x00000000, 0x5d6c2f98, 0x804628a8, 0x00000000, 0x5ed77c88, 0x809dc971, + 0x00000000, 0x603c496b, 0x811855b5, 0x00000000, 0x619a7dcc, 0x81b5abda, + 0x00000000, 0x62f201ab, 0x8275a0c1, 0x00000000, 0x6442bd7c, 0x8357ffc8, + 0x00000000, 0x658c9a2c, 0x845c8ae3, 0x00000000, 0x66cf811f, 0x8582faa5, + 0x00000000, 0x680b5c32, 0x86cafe58, 0x00000000, 0x694015c1, 0x88343c0f, + 0x00000000, 0x6a6d98a3, 0x89be50c4, 0x00000000, 0x6b93d02d, 0x8b68d06f, + 0x00000000, 0x6cb2a835, 0x8d334626, 0x00000000, 0x6dca0d13, 0x8f1d343a, + 0x00000000, 0x6ed9eba0, 0x9126145f, 0x00000000, 0x6fe2313a, 0x934d57ca, + 0x00000000, 0x70e2cbc5, 0x9592675c, 0x00000000, 0x71dba9a9, 0x97f4a3cd, + 0x00000000, 0x72ccb9d9, 0x9a7365d3, 0x00000000, 0x73b5ebd0, 0x9d0dfe54, + 0x00000000, 0x74972f90, 0x9fc3b694, 0x00000000, 0x757075ab, 0xa293d067, + 0x00000000, 0x7641af3b, 0xa57d8667, 0x00000000, 0x770acdeb, 0xa8800c26, + 0x00000000, 0x77cbc3f0, 0xab9a8e6c, 0x00000000, 0x78848412, 0xaecc336c, + 0x00000000, 0x793501a7, 0xb2141b02, 0x00000000, 0x79dd3097, 0xb5715eef, + 0x00000000, 0x7a7d055a, 0xb8e3131a, 0x00000000, 0x7b1474fc, 0xbc6845ce, + 0x00000000, 0x7ba3751c, 0xc0000000, 0x00000000, 0x7c29fbed, 0xc3a94590, + 0x00000000, 0x7ca80037, 0xc763158f, 0x00000000, 0x7d1d7956, 0xcb2c6a83, + 0x00000000, 0x7d8a5f3e, 0xcf043ab3, 0x00000000, 0x7deeaa78, 0xd2e9786f, + 0x00000000, 0x7e4a5425, 0xd6db1255, 0x00000000, 0x7e9d55fb, 0xdad7f3a3, + 0x00000000, 0x7ee7aa4a, 0xdedf047d, 0x00000000, 0x7f294bfb, 0xe2ef2a3f, + 0x00000000, 0x7f62368e, 0xe70747c4, 0x00000000, 0x7f92661c, 0xeb263dbb, + 0x00000000, 0x7fb9d757, 0xef4aeaf1, 0x00000000, 0x7fd8878c, 0xf3742ca2, + 0x00000000, 0x7fee74a1, 0xf7a0deca, 0x00000000, 0x7ffb9d14, 0xfbcfdc71, + 0x00000000, 0x7fffffff, 0x00000000, 0x00000000, 0x7ffb9d14, 0x0430238f, + 0x00000000, 0x7fee74a1, 0x085f2136, 0x00000000, 0x7fd8878c, 0x0c8bd35d, + 0x00000000, 0x7fb9d757, 0x10b5150f, 0x00000000, 0x7f92661c, 0x14d9c245, + 0x00000000, 0x7f62368e, 0x18f8b83c, 0x00000000, 0x7f294bfb, 0x1d10d5c1, + 0x00000000, 0x7ee7aa4a, 0x2120fb82, 0x00000000, 0x7e9d55fb, 0x25280c5d, + 0x00000000, 0x7e4a5425, 0x2924edab, 0x00000000, 0x7deeaa78, 0x2d168791, + 0x00000000, 0x7d8a5f3e, 0x30fbc54c, 0x00000000, 0x7d1d7956, 0x34d3957d, + 0x00000000, 0x7ca80037, 0x389cea71, 0x00000000, 0x7c29fbed, 0x3c56ba6f, + 0x00000000, 0x7ba3751c, 0x3fffffff, 0x00000000, 0x7b1474fc, 0x4397ba31, + 0x00000000, 0x7a7d055a, 0x471cece6, 0x00000000, 0x79dd3097, 0x4a8ea110, + 0x00000000, 0x793501a7, 0x4debe4fd, 0x00000000, 0x78848412, 0x5133cc93, + 0x00000000, 0x77cbc3f0, 0x54657193, 0x00000000, 0x770acdeb, 0x577ff3d9, + 0x00000000, 0x7641af3b, 0x5a827999, 0x00000000, 0x757075ab, 0x5d6c2f98, + 0x00000000, 0x74972f90, 0x603c496b, 0x00000000, 0x73b5ebd0, 0x62f201ab, + 0x00000000, 0x72ccb9d9, 0x658c9a2c, 0x00000000, 0x71dba9a9, 0x680b5c32, + 0x00000000, 0x70e2cbc5, 0x6a6d98a3, 0x00000000, 0x6fe2313a, 0x6cb2a835, + 0x00000000, 0x6ed9eba0, 0x6ed9eba0, 0x00000000, 0x6dca0d13, 0x70e2cbc5, + 0x00000000, 0x6cb2a835, 0x72ccb9d9, 0x00000000, 0x6b93d02d, 0x74972f90, + 0x00000000, 0x6a6d98a3, 0x7641af3b, 0x00000000, 0x694015c1, 0x77cbc3f0, + 0x00000000, 0x680b5c32, 0x793501a7, 0x00000000, 0x66cf811f, 0x7a7d055a, + 0x00000000, 0x658c9a2c, 0x7ba3751c, 0x00000000, 0x6442bd7c, 0x7ca80037, + 0x00000000, 0x62f201ab, 0x7d8a5f3e, 0x00000000, 0x619a7dcc, 0x7e4a5425, + 0x00000000, 0x603c496b, 0x7ee7aa4a, 0x00000000, 0x5ed77c88, 0x7f62368e, + 0x00000000, 0x5d6c2f98, 0x7fb9d757, 0x00000000, 0x5bfa7b81, 0x7fee74a1, + 0x00000000, 0x5a827999, 0x7fffffff, 0x00000000, 0x590443a6, 0x7fee74a1, + 0x00000000, 0x577ff3d9, 0x7fb9d757, 0x00000000, 0x55f5a4d1, 0x7f62368e, + 0x00000000, 0x54657193, 0x7ee7aa4a, 0x00000000, 0x52cf758d, 0x7e4a5425, + 0x00000000, 0x5133cc93, 0x7d8a5f3e, 0x00000000, 0x4f9292db, 0x7ca80037, + 0x00000000, 0x4debe4fd, 0x7ba3751c, 0x00000000, 0x4c3fdff2, 0x7a7d055a, + 0x00000000, 0x4a8ea110, 0x793501a7, 0x00000000, 0x48d84608, 0x77cbc3f0, + 0x00000000, 0x471cece6, 0x7641af3b, 0x00000000, 0x455cb40b, 0x74972f90, + 0x00000000, 0x4397ba31, 0x72ccb9d9, 0x00000000, 0x41ce1e64, 0x70e2cbc5, + 0x00000000, 0x3fffffff, 0x6ed9eba0, 0x00000000, 0x3e2d7eb0, 0x6cb2a835, + 0x00000000, 0x3c56ba6f, 0x6a6d98a3, 0x00000000, 0x3a7bd381, 0x680b5c32, + 0x00000000, 0x389cea71, 0x658c9a2c, 0x00000000, 0x36ba2013, 0x62f201ab, + 0x00000000, 0x34d3957d, 0x603c496b, 0x00000000, 0x32e96c08, 0x5d6c2f98, + 0x00000000, 0x30fbc54c, 0x5a827999, 0x00000000, 0x2f0ac31f, 0x577ff3d9, + 0x00000000, 0x2d168791, 0x54657193, 0x00000000, 0x2b1f34eb, 0x5133cc93, + 0x00000000, 0x2924edab, 0x4debe4fd, 0x00000000, 0x2727d485, 0x4a8ea110, + 0x00000000, 0x25280c5d, 0x471cece6, 0x00000000, 0x2325b847, 0x4397ba31, + 0x00000000, 0x2120fb82, 0x3fffffff, 0x00000000, 0x1f19f97a, 0x3c56ba6f, + 0x00000000, 0x1d10d5c1, 0x389cea71, 0x00000000, 0x1b05b40e, 0x34d3957d, + 0x00000000, 0x18f8b83c, 0x30fbc54c, 0x00000000, 0x16ea0646, 0x2d168791, + 0x00000000, 0x14d9c245, 0x2924edab, 0x00000000, 0x12c8106e, 0x25280c5d, + 0x00000000, 0x10b5150f, 0x2120fb82, 0x00000000, 0x0ea0f48c, 0x1d10d5c1, + 0x00000000, 0x0c8bd35d, 0x18f8b83c, 0x00000000, 0x0a75d60e, 0x14d9c245, + 0x00000000, 0x085f2136, 0x10b5150f, 0x00000000, 0x0647d97c, 0x0c8bd35d, + 0x00000000, 0x0430238f, 0x085f2136, 0x00000000, 0x02182427, 0x0430238f, + 0x00000000, 0x00000000, 0x00000000}; + +const WORD32 ixheaacd_pre_post_twid_cos_512[512] = { + 0x7fffff7f, 0x7fffcdff, 0x7fff4d7f, 0x7ffe7e7f, 0x7ffd607f, 0x7ffbf2ff, + 0x7ffa36ff, 0x7ff82bff, 0x7ff5d1ff, 0x7ff328ff, 0x7ff030ff, 0x7fecea7f, + 0x7fe9547f, 0x7fe56fff, 0x7fe13c7f, 0x7fdcba7f, 0x7fd7e8ff, 0x7fd2c8ff, + 0x7fcd59ff, 0x7fc79c7f, 0x7fc18f7f, 0x7fbb347f, 0x7fb489ff, 0x7fad90ff, + 0x7fa6497f, 0x7f9eb2ff, 0x7f96cdff, 0x7f8e99ff, 0x7f86177f, 0x7f7d45ff, + 0x7f7425ff, 0x7f6ab77f, 0x7f60fa7f, 0x7f56eeff, 0x7f4c947f, 0x7f41ebff, + 0x7f36f4ff, 0x7f2baeff, 0x7f201aff, 0x7f14387f, 0x7f08077f, 0x7efb87ff, + 0x7eeeba7f, 0x7ee19e7f, 0x7ed433ff, 0x7ec67bff, 0x7eb874ff, 0x7eaa207f, + 0x7e9b7d7f, 0x7e8c8c7f, 0x7e7d4cff, 0x7e6dbfff, 0x7e5de4ff, 0x7e4dbbff, + 0x7e3d44ff, 0x7e2c7fff, 0x7e1b6d7f, 0x7e0a0cff, 0x7df85e7f, 0x7de6627f, + 0x7dd418ff, 0x7dc181ff, 0x7dae9cff, 0x7d9b6aff, 0x7d87eaff, 0x7d741dff, + 0x7d6002ff, 0x7d4b9b7f, 0x7d36e5ff, 0x7d21e37f, 0x7d0c93ff, 0x7cf6f6ff, + 0x7ce10cff, 0x7ccad67f, 0x7cb4527f, 0x7c9d817f, 0x7c8663ff, 0x7c6ef97f, + 0x7c5741ff, 0x7c3f3e7f, 0x7c26ed7f, 0x7c0e507f, 0x7bf566ff, 0x7bdc307f, + 0x7bc2adff, 0x7ba8deff, 0x7b8ec3ff, 0x7b745c7f, 0x7b59a8ff, 0x7b3ea97f, + 0x7b235d7f, 0x7b07c5ff, 0x7aebe27f, 0x7acfb2ff, 0x7ab337ff, 0x7a96717f, + 0x7a795eff, 0x7a5c00ff, 0x7a3e577f, 0x7a20627f, 0x7a02227f, 0x79e396ff, + 0x79c4c07f, 0x79a59eff, 0x798631ff, 0x79667a7f, 0x7946777f, 0x792629ff, + 0x790591ff, 0x78e4af7f, 0x78c381ff, 0x78a209ff, 0x7880477f, 0x785e3aff, + 0x783be3ff, 0x781942ff, 0x77f657ff, 0x77d322ff, 0x77afa3ff, 0x778bdaff, + 0x7767c87f, 0x77436bff, 0x771ec67f, 0x76f9d6ff, 0x76d49e7f, 0x76af1c7f, + 0x768950ff, 0x76633cff, 0x763cdf7f, 0x7616397f, 0x75ef49ff, 0x75c8127f, + 0x75a091ff, 0x7578c87f, 0x7550b6ff, 0x75285cff, 0x74ffbaff, 0x74d6d07f, + 0x74ad9e7f, 0x748423ff, 0x745a617f, 0x7430577f, 0x740605ff, 0x73db6c7f, + 0x73b08bff, 0x7385637f, 0x7359f47f, 0x732e3dff, 0x73023fff, 0x72d5fb7f, + 0x72a9707f, 0x727c9e7f, 0x724f857f, 0x7222267f, 0x71f4807f, 0x71c694ff, + 0x7198627f, 0x7169ea7f, 0x713b2c7f, 0x710c287f, 0x70dcdeff, 0x70ad4f7f, + 0x707d7a7f, 0x704d607f, 0x701d00ff, 0x6fec5bff, 0x6fbb727f, 0x6f8a43ff, + 0x6f58d07f, 0x6f27187f, 0x6ef51b7f, 0x6ec2da7f, 0x6e9054ff, 0x6e5d8b7f, + 0x6e2a7dff, 0x6df72bff, 0x6dc3967f, 0x6d8fbd7f, 0x6d5ba07f, 0x6d27407f, + 0x6cf29cff, 0x6cbdb5ff, 0x6c888bff, 0x6c531f7f, 0x6c1d6fff, 0x6be77d7f, + 0x6bb1487f, 0x6b7ad17f, 0x6b44177f, 0x6b0d1bff, 0x6ad5ddff, 0x6a9e5e7f, + 0x6a669cff, 0x6a2e997f, 0x69f654ff, 0x69bdceff, 0x698507ff, 0x694bff7f, + 0x6912b67f, 0x68d92c7f, 0x689f617f, 0x6865567f, 0x682b0a7f, 0x67f07eff, + 0x67b5b27f, 0x677aa67f, 0x673f5aff, 0x6703cf7f, 0x66c8047f, 0x668bf9ff, + 0x664fafff, 0x661326ff, 0x65d65f7f, 0x659958ff, 0x655c137f, 0x651e8f7f, + 0x64e0cd7f, 0x64a2ccff, 0x64648e7f, 0x642611ff, 0x63e757ff, 0x63a85fff, + 0x63692aff, 0x6329b7ff, 0x62ea087f, 0x62aa1b7f, 0x6269f1ff, 0x62298b7f, + 0x61e8e87f, 0x61a808ff, 0x6166ed7f, 0x612595ff, 0x60e4027f, 0x60a232ff, + 0x606027ff, 0x601de1ff, 0x5fdb5fff, 0x5f98a37f, 0x5f55ab7f, 0x5f1278ff, + 0x5ecf0b7f, 0x5e8b63ff, 0x5e4781ff, 0x5e03657f, 0x5dbf0f7f, 0x5d7a7f7f, + 0x5d35b5ff, 0x5cf0b27f, 0x5cab75ff, 0x5c66007f, 0x5c2051ff, 0x5bda6a7f, + 0x5b9449ff, 0x5b4df17f, 0x5b07607f, 0x5ac0977f, 0x5a79967f, 0x5a325d7f, + 0x59eaecff, 0x59a344ff, 0x595b657f, 0x59134eff, 0x58cb01ff, 0x58827d7f, + 0x5839c2ff, 0x57f0d1ff, 0x57a7aa7f, 0x575e4cff, 0x5714b97f, 0x56caf07f, + 0x5680f1ff, 0x5636bdff, 0x55ec54ff, 0x55a1b67f, 0x5556e37f, 0x550bdbff, + 0x54c09fff, 0x54752f7f, 0x54298aff, 0x53ddb27f, 0x5391a67f, 0x534566ff, + 0x52f8f3ff, 0x52ac4d7f, 0x525f747f, 0x5212687f, 0x51c529ff, 0x5177b8ff, + 0x512a157f, 0x50dc3fff, 0x508e387f, 0x503fffff, 0x4ff1957f, 0x4fa2f97f, + 0x4f542c7f, 0x4f052e7f, 0x4eb5ffff, 0x4e66a0ff, 0x4e17117f, 0x4dc751ff, + 0x4d7761ff, 0x4d2742ff, 0x4cd6f37f, 0x4c86757f, 0x4c35c77f, 0x4be4eaff, + 0x4b93df7f, 0x4b42a57f, 0x4af13cff, 0x4a9fa67f, 0x4a4de17f, 0x49fbeeff, + 0x49a9ce7f, 0x495780ff, 0x490505ff, 0x48b25dff, 0x485f897f, 0x480c87ff, + 0x47b959ff, 0x4765ffff, 0x4712797f, 0x46bec77f, 0x466ae9ff, 0x4616e0ff, + 0x45c2ac7f, 0x456e4d7f, 0x4519c2ff, 0x44c50e7f, 0x44702eff, 0x441b257f, + 0x43c5f1ff, 0x437094ff, 0x431b0dff, 0x42c55dff, 0x426f847f, 0x421981ff, + 0x41c356ff, 0x416d02ff, 0x411686ff, 0x40bfe27f, 0x4069167f, 0x4012227f, + 0x3fbb06ff, 0x3f63c43f, 0x3f0c5a3f, 0x3eb4c97f, 0x3e5d123f, 0x3e05343f, + 0x3dad2fff, 0x3d5505bf, 0x3cfcb5bf, 0x3ca43fff, 0x3c4ba4ff, 0x3bf2e4bf, + 0x3b99ff7f, 0x3b40f57f, 0x3ae7c6ff, 0x3a8e73ff, 0x3a34fcff, 0x39db61ff, + 0x3981a37f, 0x3927c13f, 0x38cdbbff, 0x3873937f, 0x3819487f, 0x37beda7f, + 0x37644a7f, 0x370997ff, 0x36aec3bf, 0x3653cdbf, 0x35f8b5ff, 0x359d7d3f, + 0x3542233f, 0x34e6a87f, 0x348b0cff, 0x342f513f, 0x33d3753f, 0x3377793f, + 0x331b5d7f, 0x32bf223f, 0x3262c7bf, 0x32064dff, 0x31a9b57f, 0x314cfe7f, + 0x30f028ff, 0x3093353f, 0x3036237f, 0x2fd8f3ff, 0x2f7ba73f, 0x2f1e3cff, + 0x2ec0b57f, 0x2e63117f, 0x2e0550bf, 0x2da7737f, 0x2d497a3f, 0x2ceb64ff, + 0x2c8d33ff, 0x2c2ee7bf, 0x2bd07fff, 0x2b71fd3f, 0x2b135fbf, 0x2ab4a7bf, + 0x2a55d53f, 0x29f6e8bf, 0x2997e23f, 0x2938c23f, 0x28d988bf, 0x287a35ff, + 0x281aca3f, 0x27bb45ff, 0x275ba8ff, 0x26fbf3bf, 0x269c267f, 0x263c417f, + 0x25dc44bf, 0x257c30bf, 0x251c05bf, 0x24bbc3bf, 0x245b6aff, 0x23fafbff, + 0x239a76bf, 0x2339db3f, 0x22d92a7f, 0x227863ff, 0x2217883f, 0x21b6973f, + 0x215591bf, 0x20f477bf, 0x2093493f, 0x203206bf, 0x1fd0b03f, 0x1f6f461f, + 0x1f0dc8bf, 0x1eac381f, 0x1e4a949f, 0x1de8de7f, 0x1d8715df, 0x1d253aff, + 0x1cc34e1f, 0x1c614f7f, 0x1bff3f7f, 0x1b9d1e1f, 0x1b3aebbf, 0x1ad8a87f, + 0x1a7654bf, 0x1a13f0bf, 0x19b17c7f, 0x194ef87f, 0x18ec64ff, 0x1889c1ff, + 0x18270fdf, 0x17c44ebf, 0x17617f1f, 0x16fea0ff, 0x169bb4bf, 0x1638ba7f, + 0x15d5b27f, 0x15729d1f, 0x150f7a7f, 0x14ac4adf, 0x14490e7f, 0x13e5c57f, + 0x1382705f, 0x131f0f1f, 0x12bba21f, 0x1258299f, 0x11f4a5bf, 0x119116bf, + 0x112d7cff, 0x10c9d89f, 0x106629df, 0x100270ff, 0x0f9eae4f, 0x0f3ae1ef, + 0x0ed70c2f, 0x0e732d3f, 0x0e0f456f, 0x0dab54ef, 0x0d475bff, 0x0ce35adf, + 0x0c7f51cf, 0x0c1b40ff, 0x0bb728bf, 0x0b53094f, 0x0aeee2cf, 0x0a8ab59f, + 0x0a2681ef, 0x09c247ef, 0x095e07ef, 0x08f9c22f, 0x089576df, 0x0831264f, + 0x07ccd0a7, 0x0768762f, 0x07041727, 0x069fb3c7, 0x063b4c57, 0x05d6e10f, + 0x05727227, 0x050dffe7, 0x04a98a87, 0x04451247, 0x03e09767, 0x037c1a1f, + 0x03179ab3, 0x02b3195f, 0x024e9663, 0x01ea11f7, 0x01858c5d, 0x012105d3, + 0x00bc7e98, 0x0057f6e8}; + +const WORD32 ixheaacd_pre_post_twid_sin_512[512] = { + 0x000c90fd, 0x007118dc, 0x00d5a074, 0x013a2789, 0x019eaddd, 0x0203332f, + 0x0267b747, 0x02cc39df, 0x0330babf, 0x039539a7, 0x03f9b65b, 0x045e3097, + 0x04c2a827, 0x05271cc7, 0x058b8e2f, 0x05effc37, 0x0654668f, 0x06b8cd07, + 0x071d2f4f, 0x07818d3f, 0x07e5e687, 0x084a3aef, 0x08ae8a3f, 0x0912d42f, + 0x0977187f, 0x09db56ff, 0x0a3f8f6f, 0x0aa3c18f, 0x0b07ed1f, 0x0b6c11cf, + 0x0bd02f7f, 0x0c3445ef, 0x0c9854cf, 0x0cfc5bef, 0x0d605aff, 0x0dc451df, + 0x0e28402f, 0x0e8c25cf, 0x0ef0027f, 0x0f53d5ef, 0x0fb79fdf, 0x101b601f, + 0x107f167f, 0x10e2c2bf, 0x1146647f, 0x11a9fb7f, 0x120d87bf, 0x127108df, + 0x12d47e7f, 0x1337e89f, 0x139b46bf, 0x13fe98ff, 0x1461debf, 0x14c517ff, + 0x1528445f, 0x158b63bf, 0x15ee75bf, 0x16517a5f, 0x16b4711f, 0x171759df, + 0x177a345f, 0x17dd007f, 0x183fbdbf, 0x18a26c1f, 0x19050b3f, 0x19679aff, + 0x19ca1b1f, 0x1a2c8b3f, 0x1a8eeb3f, 0x1af13adf, 0x1b5379df, 0x1bb5a7ff, + 0x1c17c51f, 0x1c79d0df, 0x1cdbcaff, 0x1d3db35f, 0x1d9f89bf, 0x1e014dbf, + 0x1e62ff3f, 0x1ec49e1f, 0x1f2629df, 0x1f87a27f, 0x1fe9079f, 0x204a593f, + 0x20ab96bf, 0x210cbfff, 0x216dd53f, 0x21ced57f, 0x222fc0ff, 0x2290977f, + 0x22f158bf, 0x2352043f, 0x23b299ff, 0x241319bf, 0x2473833f, 0x24d3d63f, + 0x253412bf, 0x259437ff, 0x25f4463f, 0x26543cff, 0x26b41bff, 0x2713e33f, + 0x2773927f, 0x27d3293f, 0x2832a77f, 0x28920cff, 0x28f1597f, 0x29508cbf, + 0x29afa63f, 0x2a0ea63f, 0x2a6d8c3f, 0x2acc583f, 0x2b2b09bf, 0x2b89a07f, + 0x2be81c7f, 0x2c467d3f, 0x2ca4c2ff, 0x2d02ecff, 0x2d60fb3f, 0x2dbeed7f, + 0x2e1cc37f, 0x2e7a7d3f, 0x2ed81a3f, 0x2f359a3f, 0x2f92fd3f, 0x2ff042bf, + 0x304d6abf, 0x30aa74ff, 0x3107613f, 0x31642f3f, 0x31c0debf, 0x321d6f7f, + 0x3279e13f, 0x32d633ff, 0x3332677f, 0x338e7b3f, 0x33ea6f3f, 0x3446433f, + 0x34a1f6ff, 0x34fd8a3f, 0x3558fcbf, 0x35b44e7f, 0x360f7eff, 0x366a8e3f, + 0x36c57bff, 0x372047bf, 0x377af1bf, 0x37d5793f, 0x382fde7f, 0x388a20ff, + 0x38e4407f, 0x393e3d3f, 0x3998167f, 0x39f1cc3f, 0x3a4b5dff, 0x3aa4cbff, + 0x3afe15ff, 0x3b573b7f, 0x3bb03c3f, 0x3c09183f, 0x3c61cf3f, 0x3cba60ff, + 0x3d12cd3f, 0x3d6b13ff, 0x3dc334bf, 0x3e1b2f3f, 0x3e73037f, 0x3ecab17f, + 0x3f22387f, 0x3f79987f, 0x3fd0d17f, 0x4027e2ff, 0x407eccff, 0x40d58f7f, + 0x412c297f, 0x41829b7f, 0x41d8e57f, 0x422f067f, 0x4284fe7f, 0x42dacdff, + 0x4330737f, 0x4385efff, 0x43db42ff, 0x44306bff, 0x44856aff, 0x44da3f7f, + 0x452ee97f, 0x458368ff, 0x45d7bdff, 0x462be77f, 0x467fe57f, 0x46d3b87f, + 0x47275f7f, 0x477ada7f, 0x47ce297f, 0x48214c7f, 0x4874427f, 0x48c70c7f, + 0x4919a8ff, 0x496c187f, 0x49be5aff, 0x4a106fff, 0x4a6256ff, 0x4ab4107f, + 0x4b059b7f, 0x4b56f87f, 0x4ba826ff, 0x4bf9267f, 0x4c49f77f, 0x4c9a997f, + 0x4ceb0bff, 0x4d3b4eff, 0x4d8b627f, 0x4ddb467f, 0x4e2af9ff, 0x4e7a7d7f, + 0x4ec9d07f, 0x4f18f2ff, 0x4f67e47f, 0x4fb6a4ff, 0x5005347f, 0x5053927f, + 0x50a1beff, 0x50efb9ff, 0x513d82ff, 0x518b197f, 0x51d87dff, 0x5225afff, + 0x5272af7f, 0x52bf7bff, 0x530c157f, 0x53587b7f, 0x53a4ae7f, 0x53f0ad7f, + 0x543c78ff, 0x5488107f, 0x54d373ff, 0x551ea2ff, 0x55699d7f, 0x55b462ff, + 0x55fef3ff, 0x56494fff, 0x5693767f, 0x56dd67ff, 0x5727237f, 0x5770a97f, + 0x57b9f97f, 0x580312ff, 0x584bf6ff, 0x5894a3ff, 0x58dd1a7f, 0x592559ff, + 0x596d627f, 0x59b533ff, 0x59fcce7f, 0x5a4430ff, 0x5a8b5bff, 0x5ad24eff, + 0x5b1909ff, 0x5b5f8cff, 0x5ba5d77f, 0x5bebe97f, 0x5c31c2ff, 0x5c77637f, + 0x5cbcca7f, 0x5d01f8ff, 0x5d46ed7f, 0x5d8ba8ff, 0x5dd02a7f, 0x5e1471ff, + 0x5e587fff, 0x5e9c537f, 0x5edfec7f, 0x5f234aff, 0x5f666eff, 0x5fa957ff, + 0x5fec05ff, 0x602e78ff, 0x6070b07f, 0x60b2ac7f, 0x60f46cff, 0x6135f17f, + 0x617739ff, 0x61b8467f, 0x61f916ff, 0x6239aaff, 0x627a01ff, 0x62ba1c7f, + 0x62f9f9ff, 0x63399a7f, 0x6378fdff, 0x63b823ff, 0x63f70bff, 0x6435b6ff, + 0x647423ff, 0x64b252ff, 0x64f043ff, 0x652df67f, 0x656b6a7f, 0x65a8a07f, + 0x65e5977f, 0x66224f7f, 0x665ec87f, 0x669b027f, 0x66d6fcff, 0x6712b7ff, + 0x674e33ff, 0x67896f7f, 0x67c46b7f, 0x67ff27ff, 0x6839a37f, 0x6873deff, + 0x68adda7f, 0x68e794ff, 0x69210eff, 0x695a47ff, 0x69933fff, 0x69cbf6ff, + 0x6a046c7f, 0x6a3ca07f, 0x6a74937f, 0x6aac447f, 0x6ae3b37f, 0x6b1ae0ff, + 0x6b51cc7f, 0x6b88757f, 0x6bbedbff, 0x6bf5007f, 0x6c2ae1ff, 0x6c6080ff, + 0x6c95dcff, 0x6ccaf5ff, 0x6cffcbff, 0x6d345eff, 0x6d68adff, 0x6d9cb9ff, + 0x6dd0827f, 0x6e0406ff, 0x6e37477f, 0x6e6a447f, 0x6e9cfcff, 0x6ecf717f, + 0x6f01a17f, 0x6f338cff, 0x6f6533ff, 0x6f9695ff, 0x6fc7b37f, 0x6ff88bff, + 0x70291eff, 0x70596d7f, 0x7089767f, 0x70b939ff, 0x70e8b77f, 0x7117efff, + 0x7146e27f, 0x71758eff, 0x71a3f5ff, 0x71d2167f, 0x71fff07f, 0x722d84ff, + 0x725ad27f, 0x7287d97f, 0x72b499ff, 0x72e1137f, 0x730d467f, 0x733931ff, + 0x7364d6ff, 0x7390347f, 0x73bb4a7f, 0x73e6197f, 0x7410a0ff, 0x743ae0ff, + 0x7464d8ff, 0x748e88ff, 0x74b7f17f, 0x74e111ff, 0x7509ea7f, 0x75327a7f, + 0x755ac27f, 0x7582c1ff, 0x75aa787f, 0x75d1e6ff, 0x75f90cff, 0x761fe97f, + 0x76467dff, 0x766cc8ff, 0x7692caff, 0x76b883ff, 0x76ddf37f, 0x770319ff, + 0x7727f6ff, 0x774c89ff, 0x7770d3ff, 0x7794d3ff, 0x77b88a7f, 0x77dbf6ff, + 0x77ff19ff, 0x7821f27f, 0x784480ff, 0x7866c4ff, 0x7888bf7f, 0x78aa6eff, + 0x78cbd3ff, 0x78eceeff, 0x790dbeff, 0x792e447f, 0x794e7f7f, 0x796e6eff, + 0x798e13ff, 0x79ad6dff, 0x79cc7cff, 0x79eb40ff, 0x7a09b97f, 0x7a27e6ff, + 0x7a45c8ff, 0x7a635f7f, 0x7a80aa7f, 0x7a9da9ff, 0x7aba5dff, 0x7ad6c5ff, + 0x7af2e27f, 0x7b0eb2ff, 0x7b2a377f, 0x7b45707f, 0x7b605cff, 0x7b7afd7f, + 0x7b9551ff, 0x7baf59ff, 0x7bc915ff, 0x7be2857f, 0x7bfba87f, 0x7c147eff, + 0x7c2d08ff, 0x7c45467f, 0x7c5d36ff, 0x7c74db7f, 0x7c8c327f, 0x7ca33cff, + 0x7cb9fa7f, 0x7cd06b7f, 0x7ce68eff, 0x7cfc657f, 0x7d11eeff, 0x7d272b7f, + 0x7d3c1a7f, 0x7d50bc7f, 0x7d6510ff, 0x7d79187f, 0x7d8cd1ff, 0x7da03e7f, + 0x7db35d7f, 0x7dc62eff, 0x7dd8b2ff, 0x7deae8ff, 0x7dfcd17f, 0x7e0e6c7f, + 0x7e1fb97f, 0x7e30b87f, 0x7e4169ff, 0x7e51cd7f, 0x7e61e2ff, 0x7e71aa7f, + 0x7e81247f, 0x7e904fff, 0x7e9f2d7f, 0x7eadbcff, 0x7ebbfdff, 0x7ec9f0ff, + 0x7ed795ff, 0x7ee4ecff, 0x7ef1f4ff, 0x7efeaeff, 0x7f0b1aff, 0x7f17387f, + 0x7f23077f, 0x7f2e87ff, 0x7f39b9ff, 0x7f449d7f, 0x7f4f327f, 0x7f5978ff, + 0x7f63717f, 0x7f6d1a7f, 0x7f76757f, 0x7f7f81ff, 0x7f883f7f, 0x7f90adff, + 0x7f98ce7f, 0x7fa09fff, 0x7fa8227f, 0x7faf56ff, 0x7fb63bff, 0x7fbcd27f, + 0x7fc319ff, 0x7fc912ff, 0x7fcebcff, 0x7fd4187f, 0x7fd924ff, 0x7fdde27f, + 0x7fe250ff, 0x7fe6707f, 0x7fea417f, 0x7fedc37f, 0x7ff0f67f, 0x7ff3da7f, + 0x7ff66fff, 0x7ff8b5ff, 0x7ffaad7f, 0x7ffc55ff, 0x7ffdaeff, 0x7ffeb97f, + 0x7fff74ff, 0x7fffe1ff}; + +const WORD32 ixheaacd_pre_post_twid_cos_384[384] = { + 0x7ffffeff, 0x7fffa6ff, 0x7ffec2ff, 0x7ffd527f, 0x7ffb55ff, 0x7ff8cc7f, + 0x7ff5b6ff, 0x7ff2157f, 0x7fede6ff, 0x7fe92cff, 0x7fe3e5ff, 0x7fde12ff, + 0x7fd7b3ff, 0x7fd0c87f, 0x7fc950ff, 0x7fc14d7f, 0x7fb8bd7f, 0x7fafa1ff, + 0x7fa5f9ff, 0x7f9bc5ff, 0x7f91067f, 0x7f85baff, 0x7f79e37f, 0x7f6d7fff, + 0x7f6090ff, 0x7f53167f, 0x7f450fff, 0x7f367dff, 0x7f27607f, 0x7f17b7ff, + 0x7f07837f, 0x7ef6c3ff, 0x7ee5797f, 0x7ed3a37f, 0x7ec1427f, 0x7eae567f, + 0x7e9adf7f, 0x7e86ddff, 0x7e72517f, 0x7e5d39ff, 0x7e47987f, 0x7e316bff, + 0x7e1ab57f, 0x7e03747f, 0x7deba97f, 0x7dd3547f, 0x7dba74ff, 0x7da10bff, + 0x7d87197f, 0x7d6c9cff, 0x7d5196ff, 0x7d36077f, 0x7d19ee7f, 0x7cfd4cff, + 0x7ce021ff, 0x7cc26dff, 0x7ca430ff, 0x7c856b7f, 0x7c661d7f, 0x7c46477f, + 0x7c25e87f, 0x7c0501ff, 0x7be392ff, 0x7bc19c7f, 0x7b9f1dff, 0x7b7c17ff, + 0x7b588a7f, 0x7b3475ff, 0x7b0fd9ff, 0x7aeab77f, 0x7ac50dff, 0x7a9eddff, + 0x7a7826ff, 0x7a50ea7f, 0x7a2926ff, 0x7a00ddff, 0x79d80f7f, 0x79aebaff, + 0x7984e0ff, 0x795a81ff, 0x792f9dff, 0x790434ff, 0x78d846ff, 0x78abd47f, + 0x787eddff, 0x785162ff, 0x7823647f, 0x77f4e1ff, 0x77c5dbff, 0x7796527f, + 0x776645ff, 0x7735b67f, 0x7704a47f, 0x76d30fff, 0x76a0f8ff, 0x766e5f7f, + 0x763b44ff, 0x7607a7ff, 0x75d389ff, 0x759eeaff, 0x7569ca7f, 0x7534297f, + 0x74fe07ff, 0x74c765ff, 0x7490447f, 0x7458a27f, 0x7420817f, 0x73e7e07f, + 0x73aec0ff, 0x7375227f, 0x733b04ff, 0x7300697f, 0x72c54fff, 0x7289b7ff, + 0x724da2ff, 0x7211107f, 0x71d400ff, 0x7196747f, 0x71586b7f, 0x7119e5ff, + 0x70dae4ff, 0x709b67ff, 0x705b6eff, 0x701afb7f, 0x6fda0c7f, 0x6f98a37f, + 0x6f56bf7f, 0x6f14617f, 0x6ed189ff, 0x6e8e38ff, 0x6e4a6e7f, 0x6e062aff, + 0x6dc16eff, 0x6d7c3a7f, 0x6d368dff, 0x6cf069ff, 0x6ca9cdff, 0x6c62bb7f, + 0x6c1b317f, 0x6bd3317f, 0x6b8abaff, 0x6b41ce7f, 0x6af86c7f, 0x6aae94ff, + 0x6a64487f, 0x6a19877f, 0x69ce527f, 0x6982a8ff, 0x69368bff, 0x68e9fb7f, + 0x689cf7ff, 0x684f817f, 0x680198ff, 0x67b33dff, 0x676471ff, 0x671533ff, + 0x66c584ff, 0x6675657f, 0x6624d57f, 0x65d3d57f, 0x658265ff, 0x653086ff, + 0x64de397f, 0x648b7cff, 0x643851ff, 0x63e4b97f, 0x6390b37f, 0x633c3fff, + 0x62e75f7f, 0x629212ff, 0x623c5a7f, 0x61e635ff, 0x618fa5ff, 0x6138aaff, + 0x60e1457f, 0x608975ff, 0x60313c7f, 0x5fd8997f, 0x5f7f8d7f, 0x5f26187f, + 0x5ecc3aff, 0x5e71f5ff, 0x5e17497f, 0x5dbc357f, 0x5d60ba7f, 0x5d04d97f, + 0x5ca8927f, 0x5c4be57f, 0x5beed37f, 0x5b915cff, 0x5b3381ff, 0x5ad5427f, + 0x5a769fff, 0x5a1799ff, 0x59b830ff, 0x595865ff, 0x58f8387f, 0x5897a9ff, + 0x5836b9ff, 0x57d5697f, 0x5773b87f, 0x5711a77f, 0x56af377f, 0x564c67ff, + 0x55e939ff, 0x5585ad7f, 0x5521c37f, 0x54bd7c7f, 0x5458d7ff, 0x53f3d6ff, + 0x538e7a7f, 0x5328c1ff, 0x52c2adff, 0x525c3f7f, 0x51f576ff, 0x518e547f, + 0x5126d7ff, 0x50bf02ff, 0x5056d57f, 0x4fee4fff, 0x4f85727f, 0x4f1c3dff, + 0x4eb2b27f, 0x4e48d0ff, 0x4dde997f, 0x4d740c7f, 0x4d092a7f, 0x4c9df47f, + 0x4c3269ff, 0x4bc68bff, 0x4b5a5aff, 0x4aedd77f, 0x4a8101ff, 0x4a13da7f, + 0x49a6617f, 0x493897ff, 0x48ca7e7f, 0x485c14ff, 0x47ed5bff, 0x477e53ff, + 0x470efdff, 0x469f597f, 0x462f67ff, 0x45bf297f, 0x454e9e7f, 0x44ddc77f, + 0x446ca4ff, 0x43fb377f, 0x43897eff, 0x43177cff, 0x42a530ff, 0x42329bff, + 0x41bfbeff, 0x414c98ff, 0x40d92bff, 0x4065777f, 0x3ff17cbf, 0x3f7d3bbf, + 0x3f08b4ff, 0x3e93e93f, 0x3e1ed8ff, 0x3da9843f, 0x3d33ec3f, 0x3cbe10ff, + 0x3c47f2ff, 0x3bd192ff, 0x3b5af17f, 0x3ae40ebf, 0x3a6ceb7f, 0x39f5883f, + 0x397de57f, 0x3906037f, 0x388de2ff, 0x3815847f, 0x379ce87f, 0x37240f7f, + 0x36aaf9ff, 0x3631a8bf, 0x35b81bff, 0x353e543f, 0x34c451ff, 0x344a15ff, + 0x33cfa0bf, 0x3354f27f, 0x32da0c3f, 0x325eedff, 0x31e3987f, 0x31680c7f, + 0x30ec49ff, 0x307051ff, 0x2ff424ff, 0x2f77c33f, 0x2efb2d7f, 0x2e7e643f, + 0x2e0167ff, 0x2d84397f, 0x2d06d8bf, 0x2c8946bf, 0x2c0b83ff, 0x2b8d90bf, + 0x2b0f6dff, 0x2a911bbf, 0x2a129aff, 0x2993ec3f, 0x29150fbf, 0x289605ff, + 0x2816cfff, 0x27976dff, 0x2717e07f, 0x2698283f, 0x2618457f, 0x259838ff, + 0x2518037f, 0x2497a4ff, 0x24171ebf, 0x2396707f, 0x23159b7f, 0x22949fff, + 0x22137e7f, 0x219237bf, 0x2110cbff, 0x208f3c3f, 0x200d887f, 0x1f8bb1bf, + 0x1f09b87f, 0x1e879cff, 0x1e05601f, 0x1d83025f, 0x1d00843f, 0x1c7de63f, + 0x1bfb291f, 0x1b784d3f, 0x1af5531f, 0x1a723b9f, 0x19ef06ff, 0x196bb5ff, + 0x18e8491f, 0x1864c0df, 0x17e11dff, 0x175d60df, 0x16d989ff, 0x16559a3f, + 0x15d191df, 0x154d719f, 0x14c93a1f, 0x1444eb9f, 0x13c086ff, 0x133c0cbf, + 0x12b77d5f, 0x1232d97f, 0x11ae219f, 0x1129565f, 0x10a4783f, 0x101f87ff, + 0x0f9a85ff, 0x0f1572df, 0x0e904f2f, 0x0e0b1b8f, 0x0d85d88f, 0x0d0086af, + 0x0c7b268f, 0x0bf5b8cf, 0x0b703ddf, 0x0aeab66f, 0x0a6522ff, 0x09df842f, + 0x0959da7f, 0x08d4269f, 0x084e68ff, 0x07c8a24f, 0x0742d30f, 0x06bcfbdf, + 0x06371d47, 0x05b137df, 0x052b4c37, 0x04a55ae7, 0x041f647f, 0x0399698f, + 0x03136aaf, 0x028d686f, 0x02076363, 0x01815c1b, 0x00fb532f, 0x0075492e}; + +const WORD32 ixheaacd_pre_post_twid_sin_384[384] = { + 0x0010c152, 0x0096cbc0, 0x011cd589, 0x01a2de1b, 0x0228e4df, 0x02aee947, + 0x0334eabf, 0x03bae8af, 0x0440e28f, 0x04c6d7bf, 0x054cc7af, 0x05d2b1d7, + 0x06589597, 0x06de725f, 0x076447a7, 0x07ea14cf, 0x086fd93f, 0x08f5947f, + 0x097b45df, 0x0a00ecef, 0x0a8688ef, 0x0b0c196f, 0x0b919dcf, 0x0c17157f, + 0x0c9c7fef, 0x0d21dc7f, 0x0da72abf, 0x0e2c69ef, 0x0eb1999f, 0x0f36b92f, + 0x0fbbc81f, 0x1040c5bf, 0x10c5b17f, 0x114a8aff, 0x11cf515f, 0x1254045f, + 0x12d8a31f, 0x135d2d5f, 0x13e1a23f, 0x1466015f, 0x14ea4a1f, 0x156e7bff, + 0x15f2963f, 0x1676987f, 0x16fa821f, 0x177e527f, 0x1802091f, 0x1885a57f, + 0x190926df, 0x198c8cdf, 0x1a0fd6df, 0x1a93043f, 0x1b16147f, 0x1b9906ff, + 0x1c1bdb3f, 0x1c9e90bf, 0x1d2126bf, 0x1da39cdf, 0x1e25f27f, 0x1ea826ff, + 0x1f2a39ff, 0x1fac2abf, 0x202df8bf, 0x20afa37f, 0x21312a7f, 0x21b28cff, + 0x2233ca7f, 0x22b4e27f, 0x2335d47f, 0x23b69fbf, 0x243743ff, 0x24b7c07f, + 0x253814bf, 0x25b83fff, 0x263841ff, 0x26b81a3f, 0x2737c7ff, 0x27b74a7f, + 0x2836a1bf, 0x28b5ccbf, 0x2934caff, 0x29b39c3f, 0x2a323f7f, 0x2ab0b4bf, + 0x2b2efb3f, 0x2bad123f, 0x2c2af93f, 0x2ca8afff, 0x2d26357f, 0x2da389bf, + 0x2e20abff, 0x2e9d9b7f, 0x2f1a57bf, 0x2f96e0bf, 0x3013353f, 0x308f54ff, + 0x310b3fbf, 0x3186f47f, 0x320272ff, 0x327dbabf, 0x32f8caff, 0x3373a37f, + 0x33ee437f, 0x3468aa7f, 0x34e2d7ff, 0x355ccb7f, 0x35d684bf, 0x365002bf, + 0x36c944ff, 0x37424b7f, 0x37bb153f, 0x3833a1ff, 0x38abf0ff, 0x392401bf, + 0x399bd3ff, 0x3a1366ff, 0x3a8aba7f, 0x3b01cd7f, 0x3b789fff, 0x3bef313f, + 0x3c6580bf, 0x3cdb8dff, 0x3d51587f, 0x3dc6dfbf, 0x3e3c237f, 0x3eb122bf, + 0x3f25dd3f, 0x3f9a527f, 0x400e81ff, 0x40826b7f, 0x40f60dff, 0x4169697f, + 0x41dc7cff, 0x424f487f, 0x42c1caff, 0x4334047f, 0x43a5f3ff, 0x4417997f, + 0x4488f47f, 0x44fa047f, 0x456ac87f, 0x45db407f, 0x464b6b7f, 0x46bb49ff, + 0x472ada7f, 0x479a1d7f, 0x4809117f, 0x4877b67f, 0x48e60c7f, 0x495411ff, + 0x49c1c77f, 0x4a2f2bff, 0x4a9c3eff, 0x4b09007f, 0x4b756eff, 0x4be18b7f, + 0x4c4d547f, 0x4cb8c9ff, 0x4d23eaff, 0x4d8eb77f, 0x4df92f7f, 0x4e63517f, + 0x4ecd1d7f, 0x4f3692ff, 0x4f9fb1ff, 0x5008797f, 0x5070e8ff, 0x50d9007f, + 0x5140bf7f, 0x51a8257f, 0x520f317f, 0x5275e3ff, 0x52dc3b7f, 0x5342387f, + 0x53a7d9ff, 0x540d1fff, 0x5472097f, 0x54d696ff, 0x553ac6ff, 0x559e997f, + 0x56020e7f, 0x5665247f, 0x56c7dc7f, 0x572a34ff, 0x578c2d7f, 0x57edc67f, + 0x584efeff, 0x58afd67f, 0x59104cff, 0x597061ff, 0x59d0147f, 0x5a2f647f, + 0x5a8e51ff, 0x5aecdbff, 0x5b4b01ff, 0x5ba8c3ff, 0x5c06217f, 0x5c631a7f, + 0x5cbfad7f, 0x5d1bdb7f, 0x5d77a2ff, 0x5dd303ff, 0x5e2dfdff, 0x5e8890ff, + 0x5ee2bc7f, 0x5f3c7f7f, 0x5f95d9ff, 0x5feecbff, 0x6047547f, 0x609f73ff, + 0x60f728ff, 0x614e73ff, 0x61a553ff, 0x61fbc8ff, 0x6251d27f, 0x62a7707f, + 0x62fca1ff, 0x635166ff, 0x63a5beff, 0x63f9a9ff, 0x644d26ff, 0x64a0367f, + 0x64f2d6ff, 0x6545097f, 0x6596cc7f, 0x65e81fff, 0x663903ff, 0x668977ff, + 0x66d97b7f, 0x67290dff, 0x67782f7f, 0x67c6df7f, 0x68151d7f, 0x6862e9ff, + 0x68b0437f, 0x68fd29ff, 0x69499dff, 0x69959dff, 0x69e12a7f, 0x6a2c42ff, + 0x6a76e67f, 0x6ac115ff, 0x6b0acfff, 0x6b54147f, 0x6b9ce37f, 0x6be53c7f, + 0x6c2d1eff, 0x6c748aff, 0x6cbb807f, 0x6d01fdff, 0x6d48047f, 0x6d8d92ff, + 0x6dd2a97f, 0x6e1746ff, 0x6e5b6c7f, 0x6e9f187f, 0x6ee24b7f, 0x6f25047f, + 0x6f6743ff, 0x6fa908ff, 0x6fea53ff, 0x702b23ff, 0x706b78ff, 0x70ab527f, + 0x70eab0ff, 0x712992ff, 0x7167f97f, 0x71a5e2ff, 0x71e3507f, 0x722040ff, + 0x725cb3ff, 0x7298a9ff, 0x72d421ff, 0x730f1bff, 0x734997ff, 0x738395ff, + 0x73bd147f, 0x73f6147f, 0x742e957f, 0x746696ff, 0x749e18ff, 0x74d51a7f, + 0x750b9c7f, 0x75419dff, 0x75771e7f, 0x75ac1eff, 0x75e09d7f, 0x76149b7f, + 0x7648177f, 0x767b11ff, 0x76ad8aff, 0x76df80ff, 0x7710f57f, 0x7741e6ff, + 0x7772557f, 0x77a2417f, 0x77d1a9ff, 0x78008eff, 0x782ef07f, 0x785cce7f, + 0x788a27ff, 0x78b6fd7f, 0x78e34eff, 0x790f1b7f, 0x793a637f, 0x7965267f, + 0x798f63ff, 0x79b91c7f, 0x79e24f7f, 0x7a0afcff, 0x7a33247f, 0x7a5ac5ff, + 0x7a81e17f, 0x7aa8767f, 0x7ace84ff, 0x7af40c7f, 0x7b190d7f, 0x7b3d877f, + 0x7b617a7f, 0x7b84e5ff, 0x7ba7c9ff, 0x7bca267f, 0x7bebfb7f, 0x7c0d487f, + 0x7c2e0cff, 0x7c4e497f, 0x7c6dfdff, 0x7c8d29ff, 0x7cabccff, 0x7cc9e77f, + 0x7ce7797f, 0x7d0481ff, 0x7d2101ff, 0x7d3cf7ff, 0x7d58657f, 0x7d7348ff, + 0x7d8da2ff, 0x7da7737f, 0x7dc0b9ff, 0x7dd9767f, 0x7df1a97f, 0x7e0951ff, + 0x7e206fff, 0x7e3703ff, 0x7e4d0dff, 0x7e628cff, 0x7e77817f, 0x7e8beaff, + 0x7e9fca7f, 0x7eb31e7f, 0x7ec5e77f, 0x7ed825ff, 0x7ee9d8ff, 0x7efb00ff, + 0x7f0b9d7f, 0x7f1baeff, 0x7f2b34ff, 0x7f3a2f7f, 0x7f489e7f, 0x7f5681ff, + 0x7f63d9ff, 0x7f70a5ff, 0x7f7ce67f, 0x7f889aff, 0x7f93c37f, 0x7f9e607f, + 0x7fa870ff, 0x7fb1f5ff, 0x7fbaeeff, 0x7fc35b7f, 0x7fcb3bff, 0x7fd2907f, + 0x7fd958ff, 0x7fdf94ff, 0x7fe544ff, 0x7fea687f, 0x7feeffff, 0x7ff30aff, + 0x7ff6897f, 0x7ff97bff, 0x7ffbe1ff, 0x7ffdbbff, 0x7fff097f, 0x7fffca7f}; + +const WORD32 ixheaacd_pre_post_twid_sin_64[64] = { + 0x006487e2, 0x0388a9e7, 0x06ac406f, 0x09cecf8f, 0x0cefdb6f, 0x100ee89f, + 0x132b7bff, 0x16451a7f, 0x195b49df, 0x1c6d905f, 0x1f7b747f, 0x22847dbf, + 0x2588347f, 0x288621bf, 0x2b7dceff, 0x2e6ec77f, 0x315896ff, 0x343aca7f, + 0x3714f03f, 0x39e6973f, 0x3caf50bf, 0x3f6eaebf, 0x4224447f, 0x44cfa6ff, + 0x47706d7f, 0x4a062f7f, 0x4c90877f, 0x4f0f10ff, 0x5181697f, 0x53e7307f, + 0x5640077f, 0x588b90ff, 0x5ac9737f, 0x5cf955ff, 0x5f1ae27f, 0x612dc47f, + 0x6331a9ff, 0x6526437f, 0x670b447f, 0x68e060ff, 0x6aa551ff, 0x6c59d07f, + 0x6dfd99ff, 0x6f906d7f, 0x71120cff, 0x72823c7f, 0x73e0c37f, 0x752d6c7f, + 0x7668037f, 0x779057ff, 0x78a63cff, 0x79a986ff, 0x7a9a0e7f, 0x7b77ad7f, + 0x7c4242ff, 0x7cf9aeff, 0x7d9dd57f, 0x7e2e9cff, 0x7eabeeff, 0x7f15b8ff, + 0x7f6be9ff, 0x7fae747f, 0x7fdd4eff, 0x7ff8717f}; + +const WORD32 ixheaacd_pre_post_twid_cos_64[64] = { + 0x7fffd87f, 0x7ff3827f, 0x7fd3717f, 0x7f9fa9ff, 0x7f58347f, 0x7efd1bff, + 0x7e8e6e7f, 0x7e0c3cff, 0x7d769b7f, 0x7ccda17f, 0x7c11687f, 0x7b420d7f, + 0x7a5fb0ff, 0x796a757f, 0x7862807f, 0x7747fbff, 0x761b11ff, 0x74dbf1ff, + 0x738acc7f, 0x7227d5ff, 0x70b344ff, 0x6f2d52ff, 0x6d963c7f, 0x6bee3f7f, + 0x6a359d7f, 0x686c9b7f, 0x66937e7f, 0x64aa907f, 0x62b21c7f, 0x60aa707f, + 0x5e93dbff, 0x5c6eb27f, 0x5a3b477f, 0x57f9f2ff, 0x55ab0d7f, 0x534ef17f, + 0x50e5fd7f, 0x4e708f7f, 0x4bef08ff, 0x4961ccff, 0x46c9407f, 0x4425c8ff, + 0x4177cf7f, 0x3ebfbdbf, 0x3bfdfebf, 0x3932ff7f, 0x365f2e3f, 0x3382fa7f, + 0x309ed53f, 0x2db330bf, 0x2ac0803f, 0x27c737bf, 0x24c7cd3f, 0x21c2b67f, + 0x1eb86b3f, 0x1ba9633f, 0x1896171f, 0x157f007f, 0x1264993f, 0x0f475bff, + 0x0c27c38f, 0x09064b3f, 0x05e36ea7, 0x02bfa9a3}; + +const WORD32 ixheaacd_pre_post_twid_sin_48[48] = { + 0x00860a78, 0x04b6195f, 0x08e4dd9f, 0x0d1131bf, 0x1139f0bf, 0x155df6ff, + 0x197c219f, 0x1d934fdf, 0x21a2627f, 0x25a83cff, 0x29a3c47f, 0x2d93e1ff, + 0x317780ff, 0x354d903f, 0x391502ff, 0x3ccccfff, 0x4073f1ff, 0x440968ff, + 0x478c397f, 0x4afb6c7f, 0x4e5611ff, 0x519b3d7f, 0x54ca0a7f, 0x57e198ff, + 0x5ae10fff, 0x5dc79d7f, 0x609475ff, 0x6346d47f, 0x65ddfbff, 0x6859367f, + 0x6ab7d67f, 0x6cf934ff, 0x6f1cb3ff, 0x7121bd7f, 0x7307c3ff, 0x74ce417f, + 0x7674b9ff, 0x77fab97f, 0x795fd4ff, 0x7aa3aaff, 0x7bc5e27f, 0x7cc62bff, + 0x7da440ff, 0x7e5fe47f, 0x7ef8e37f, 0x7f6f13ff, 0x7fc2557f, 0x7ff290ff}; + +const WORD32 ixheaacd_pre_post_twid_cos_48[48] = { + 0x7fffb9ff, 0x7fe9cb7f, 0x7fb0ccff, 0x7f54cd7f, 0x7ed5e5ff, 0x7e3438ff, + 0x7d6ff3ff, 0x7c894bff, 0x7b807fff, 0x7a55d8ff, 0x7909a8ff, 0x779c4aff, + 0x760e22ff, 0x745f9dff, 0x729131ff, 0x70a35dff, 0x6e96a97f, 0x6c6ba3ff, + 0x6a22e5ff, 0x67bd0f7f, 0x653ac8ff, 0x629cc27f, 0x5fe3b37f, 0x5d105b7f, + 0x5a237fff, 0x571deeff, 0x54007c7f, 0x50cc027f, 0x4d8162ff, 0x4a2183ff, + 0x46ad527f, 0x4325c0ff, 0x3f8bc7bf, 0x3be062bf, 0x382493bf, 0x345960bf, + 0x307fd3ff, 0x2c98fbbf, 0x28a5e9bf, 0x24a7b2ff, 0x209f6fff, 0x1c8e3bbf, + 0x1875335f, 0x145576bf, 0x103026ff, 0x0c06673f, 0x07d95b9f, 0x03aa2927}; + +const WORD32 ixheaacd_sine_win_128[128] = { + 0x00c91080, 0x025b291c, 0x03ed288c, 0x057efe10, 0x0710a138, 0x08a20140, + 0x0a330510, 0x0bc3ac90, 0x0d53dea0, 0x0ee38a80, 0x10729f60, 0x120114e0, + 0x138eda20, 0x151bde80, 0x16a81120, 0x183369c0, 0x19bdcf00, 0x1b473040, + 0x1ccf8d80, 0x1e56cd60, 0x1fdcdf60, 0x2161b2c0, 0x22e53ec0, 0x24677b40, + 0x25e846c0, 0x2767a100, 0x28e57100, 0x2a61ae80, 0x2bdc50c0, 0x2d553f00, + 0x2ecc6840, 0x3041c400, 0x31b54a00, 0x3326e100, 0x34968100, 0x36041880, + 0x376f9fc0, 0x38d8fd40, 0x3a403140, 0x3ba52280, 0x3d07c000, 0x3e6809c0, + 0x3fc5ef80, 0x4121577f, 0x427a41ff, 0x43d09dff, 0x45245aff, 0x4675687f, + 0x47c3c57f, 0x490f59ff, 0x4a581cff, 0x4b9e05ff, 0x4ce1047f, 0x4e21077f, + 0x4f5e06ff, 0x5097fa7f, 0x51ced07f, 0x5302817f, 0x543304ff, 0x5560417f, + 0x568a36ff, 0x57b0d4ff, 0x58d40a7f, 0x59f3dfff, 0x5b1033ff, 0x5c290eff, + 0x5d3e4eff, 0x5e5004ff, 0x5f5e0f7f, 0x60686e7f, 0x616f10ff, 0x6271f77f, + 0x637110ff, 0x646c5cff, 0x6563c2ff, 0x66573a7f, 0x6746cb7f, 0x683254ff, + 0x6919e6ff, 0x69fd60ff, 0x6adcca7f, 0x6bb812ff, 0x6c8f31ff, 0x6d6227ff, + 0x6e30e3ff, 0x6efb5cff, 0x6fc1937f, 0x708376ff, 0x714106ff, 0x71fa3b7f, + 0x72af037f, 0x735f677f, 0x740b567f, 0x74b2c7ff, 0x7555bcff, 0x75f42b7f, + 0x768e0c7f, 0x77235f7f, 0x77b41bff, 0x7840317f, 0x78c7a7ff, 0x794a7f7f, + 0x79c89f7f, 0x7a420f7f, 0x7ab6c77f, 0x7b26c7ff, 0x7b9207ff, 0x7bf8877f, + 0x7c5a3dff, 0x7cb723ff, 0x7d0f40ff, 0x7d628c7f, 0x7db0feff, 0x7dfa97ff, + 0x7e3f56ff, 0x7e7f3cff, 0x7eba387f, 0x7ef05a7f, 0x7f2191ff, 0x7f4de7ff, + 0x7f754aff, 0x7f97cbff, 0x7fb562ff, 0x7fce0fff, 0x7fe1c97f, 0x7ff090ff, + 0x7ffa767f, 0x7fff607f}; + +const WORD32 ixheaacd_sine_win_1024[1024] = { + 0x00192210, 0x004b6630, 0x007daa50, 0x00afee70, 0x00e23290, 0x011476b0, + 0x0146bad0, 0x0178fef0, 0x01ab3aac, 0x01dd7ecc, 0x020fc2ec, 0x0242070c, + 0x02744b2c, 0x02a686e8, 0x02d8cb08, 0x030b06c4, 0x033d4ae4, 0x036f86a0, + 0x03a1cac0, 0x03d4067c, 0x04064238, 0x04388658, 0x046ac218, 0x049cfdd0, + 0x04cf3990, 0x05017548, 0x0533a8a0, 0x0565e460, 0x05982020, 0x05ca5378, + 0x05fc86d0, 0x062ec288, 0x0660f5e8, 0x06932940, 0x06c55c98, 0x06f78788, + 0x0729bae8, 0x075bee40, 0x078e1930, 0x07c04428, 0x07f26f20, 0x08249a10, + 0x0856c510, 0x0888f000, 0x08bb1290, 0x08ed3520, 0x091f6010, 0x095182b0, + 0x09839ce0, 0x09b5bf70, 0x09e7e200, 0x0a19fc30, 0x0a4c1660, 0x0a7e3080, + 0x0ab04ab0, 0x0ae25c80, 0x0b146e50, 0x0b468880, 0x0b7891e0, 0x0baaa3b0, + 0x0bdcb580, 0x0c0ebee0, 0x0c40c840, 0x0c72d1b0, 0x0ca4d2b0, 0x0cd6dc20, + 0x0d08dd20, 0x0d3ade20, 0x0d6cd6c0, 0x0d9ed7c0, 0x0dd0d060, 0x0e02c910, + 0x0e34b940, 0x0e66b1e0, 0x0e98a220, 0x0eca9260, 0x0efc7a40, 0x0f2e6a70, + 0x0f605250, 0x0f9231c0, 0x0fc419a0, 0x0ff5f910, 0x1027d880, 0x1059afa0, + 0x108b8f20, 0x10bd6620, 0x10ef34e0, 0x11210be0, 0x1152daa0, 0x1184a0e0, + 0x11b66fa0, 0x11e835e0, 0x1219fc20, 0x124bba20, 0x127d7800, 0x12af35e0, + 0x12e0eb60, 0x1312a0e0, 0x13445680, 0x137603a0, 0x13a7b0c0, 0x13d95de0, + 0x140b02a0, 0x143ca760, 0x146e43a0, 0x149fe000, 0x14d17c60, 0x150318c0, + 0x1534aca0, 0x15663840, 0x1597c3e0, 0x15c94f60, 0x15fadb00, 0x162c5e20, + 0x165dd900, 0x168f53c0, 0x16c0cea0, 0x16f24100, 0x1723b360, 0x175525c0, + 0x17868fe0, 0x17b7f180, 0x17e95b80, 0x181ab4c0, 0x184c1660, 0x187d6fa0, + 0x18aec080, 0x18e01140, 0x19116220, 0x1942aaa0, 0x1973eac0, 0x19a52ac0, + 0x19d66ae0, 0x1a07a280, 0x1a38da40, 0x1a6a0980, 0x1a9b38e0, 0x1acc5fc0, + 0x1afd86a0, 0x1b2ea520, 0x1b5fc3c0, 0x1b90d9e0, 0x1bc1f000, 0x1bf2fdc0, + 0x1c240b80, 0x1c5510e0, 0x1c860dc0, 0x1cb71320, 0x1ce807c0, 0x1d18fc60, + 0x1d49f0e0, 0x1d7add20, 0x1dabc0e0, 0x1ddca4c0, 0x1e0d8880, 0x1e3e5b80, + 0x1e6f36e0, 0x1ea001a0, 0x1ed0d4a0, 0x1f0196e0, 0x1f325920, 0x1f631b60, + 0x1f93cce0, 0x1fc486a0, 0x1ff52fc0, 0x2025d8c0, 0x20568200, 0x20872280, + 0x20b7bb00, 0x20e85340, 0x2118e340, 0x21497300, 0x2179f240, 0x21aa79c0, + 0x21daf080, 0x220b6740, 0x223bde00, 0x226c4c40, 0x229cb240, 0x22cd1000, + 0x22fd6d80, 0x232dc2c0, 0x235e1800, 0x238e64c0, 0x23bea900, 0x23eeed80, + 0x241f2980, 0x244f5d40, 0x247f90c0, 0x24afbc00, 0x24dfdf00, 0x251001c0, + 0x25401c40, 0x25702e80, 0x25a03800, 0x25d041c0, 0x26004300, 0x26304480, + 0x26603d40, 0x26902e00, 0x26c01600, 0x26effe40, 0x271fde00, 0x274fb540, + 0x277f8440, 0x27af5340, 0x27df19c0, 0x280ed800, 0x283e9640, 0x286e4c00, + 0x289df980, 0x28cd9e80, 0x28fd4380, 0x292ce040, 0x295c7480, 0x298c0040, + 0x29bb83c0, 0x29eb0740, 0x2a1a8280, 0x2a49f500, 0x2a7967c0, 0x2aa8d200, + 0x2ad83400, 0x2b078d80, 0x2b36dec0, 0x2b662780, 0x2b957040, 0x2bc4b080, + 0x2bf3e880, 0x2c231840, 0x2c5247c0, 0x2c816f00, 0x2cb08dc0, 0x2cdfa440, + 0x2d0eb240, 0x2d3db800, 0x2d6cbd80, 0x2d9bb280, 0x2dcaa740, 0x2df993c0, + 0x2e288040, 0x2e575c00, 0x2e862f40, 0x2eb502c0, 0x2ee3cd80, 0x2f129040, + 0x2f414a40, 0x2f6ffc00, 0x2f9ea580, 0x2fcd4ec0, 0x2ffbe780, 0x302a8000, + 0x30591040, 0x30879800, 0x30b61780, 0x30e48e80, 0x3112fd40, 0x31416380, + 0x316fc9c0, 0x319e1f40, 0x31cc74c0, 0x31fab980, 0x3228fe40, 0x32573a80, + 0x32856e80, 0x32b39a00, 0x32e1bd00, 0x330fd800, 0x333dea40, 0x336bf440, + 0x3399fe40, 0x33c7f780, 0x33f5e840, 0x3423d940, 0x3451b940, 0x347f9940, + 0x34ad6880, 0x34db37c0, 0x3508fec0, 0x3536b4c0, 0x35646b00, 0x35921040, + 0x35bfb580, 0x35ed5280, 0x361ae700, 0x36486ac0, 0x3675ee80, 0x36a36a00, + 0x36d0d480, 0x36fe3f40, 0x372ba180, 0x3758f300, 0x37864440, 0x37b38d80, + 0x37e0c5c0, 0x380dfe00, 0x383b2580, 0x38684d00, 0x389563c0, 0x38c27a80, + 0x38ef8040, 0x391c8640, 0x39497b80, 0x39766840, 0x39a34cc0, 0x39d028c0, + 0x39fd04c0, 0x3a29cfc0, 0x3a568a40, 0x3a8344c0, 0x3aaff6c0, 0x3adca080, + 0x3b093980, 0x3b35d240, 0x3b625a80, 0x3b8ee280, 0x3bbb59c0, 0x3be7c8c0, + 0x3c142f80, 0x3c408d80, 0x3c6ce340, 0x3c9930c0, 0x3cc56d40, 0x3cf1aa00, + 0x3d1dd5c0, 0x3d4a01c0, 0x3d761cc0, 0x3da22f80, 0x3dce39c0, 0x3dfa3340, + 0x3e262cc0, 0x3e521580, 0x3e7dfe40, 0x3ea9d640, 0x3ed5a5c0, 0x3f016d00, + 0x3f2d2340, 0x3f58d9c0, 0x3f847f40, 0x3fb02500, 0x3fdbb9c0, 0x40073dff, + 0x4032c1ff, 0x405e3d7f, 0x4089a87f, 0x40b50aff, 0x40e064ff, 0x410bb6ff, + 0x4136f7ff, 0x416238ff, 0x418d68ff, 0x41b890ff, 0x41e3a7ff, 0x420ebeff, + 0x4239c4ff, 0x4264c2ff, 0x428fb87f, 0x42baa57f, 0x42e581ff, 0x43105dff, + 0x433b297f, 0x4365e47f, 0x43909eff, 0x43bb48ff, 0x43e5ea7f, 0x441083ff, + 0x443b0c7f, 0x4465947f, 0x449003ff, 0x44ba72ff, 0x44e4d9ff, 0x450f2fff, + 0x45397dff, 0x4563ba7f, 0x458df77f, 0x45b823ff, 0x45e2477f, 0x460c5a7f, + 0x46366d7f, 0x46606f7f, 0x468a60ff, 0x46b4527f, 0x46de32ff, 0x470802ff, + 0x4731d2ff, 0x475b91ff, 0x4785487f, 0x47aeee7f, 0x47d8947f, 0x4802217f, + 0x482badff, 0x485529ff, 0x487e9d7f, 0x48a808ff, 0x48d162ff, 0x48fab4ff, + 0x4923f67f, 0x494d37ff, 0x49765fff, 0x499f87ff, 0x49c89f7f, 0x49f1adff, + 0x4a1aac7f, 0x4a43a1ff, 0x4a6c8f7f, 0x4a95747f, 0x4abe487f, 0x4ae70bff, + 0x4b0fc6ff, 0x4b3879ff, 0x4b6123ff, 0x4b89bd7f, 0x4bb245ff, 0x4bdaceff, + 0x4c0346ff, 0x4c2badff, 0x4c540cff, 0x4c7c62ff, 0x4ca4a8ff, 0x4ccce5ff, + 0x4cf51aff, 0x4d1d3eff, 0x4d4551ff, 0x4d6d5cff, 0x4d955f7f, 0x4dbd597f, + 0x4de542ff, 0x4e0d1b7f, 0x4e34eb7f, 0x4e5cb37f, 0x4e846a7f, 0x4eac18ff, + 0x4ed3b6ff, 0x4efb4bff, 0x4f22d0ff, 0x4f4a4cff, 0x4f71c0ff, 0x4f9923ff, + 0x4fc0767f, 0x4fe7c07f, 0x500f01ff, 0x503632ff, 0x505d5aff, 0x508472ff, + 0x50ab81ff, 0x50d2807f, 0x50f9767f, 0x51205bff, 0x5147387f, 0x516e04ff, + 0x5194c87f, 0x51bb7b7f, 0x51e225ff, 0x5208bfff, 0x522f50ff, 0x5255d9ff, + 0x527c49ff, 0x52a2b17f, 0x52c9107f, 0x52ef5eff, 0x5315a47f, 0x533bd9ff, + 0x5362067f, 0x5388227f, 0x53ae2d7f, 0x53d4307f, 0x53fa2aff, 0x5420147f, + 0x5445ed7f, 0x546bbd7f, 0x54917d7f, 0x54b7347f, 0x54dcdaff, 0x5502797f, + 0x5528067f, 0x554d837f, 0x5572f77f, 0x559862ff, 0x55bdb5ff, 0x55e2ffff, + 0x560841ff, 0x562d72ff, 0x56529b7f, 0x5677aaff, 0x569cba7f, 0x56c1b0ff, + 0x56e69eff, 0x570b847f, 0x5730597f, 0x57551d7f, 0x5779d8ff, 0x579e83ff, + 0x57c31dff, 0x57e7af7f, 0x580c307f, 0x5830a8ff, 0x585510ff, 0x587967ff, + 0x589db67f, 0x58c1f3ff, 0x58e6297f, 0x590a45ff, 0x592e61ff, 0x595264ff, + 0x59765fff, 0x599a49ff, 0x59be2b7f, 0x59e1fbff, 0x5a05bbff, 0x5a29737f, + 0x5a4d1a7f, 0x5a70b07f, 0x5a943dff, 0x5ab7baff, 0x5adb26ff, 0x5afe8a7f, + 0x5b21dd7f, 0x5b451fff, 0x5b68597f, 0x5b8b827f, 0x5bae9a7f, 0x5bd1aa7f, + 0x5bf4a97f, 0x5c1797ff, 0x5c3a7d7f, 0x5c5d4a7f, 0x5c8016ff, 0x5ca2ca7f, + 0x5cc575ff, 0x5ce80fff, 0x5d0a997f, 0x5d2d1aff, 0x5d4f8b7f, 0x5d71eaff, + 0x5d9439ff, 0x5db6807f, 0x5dd8b5ff, 0x5dfadaff, 0x5e1cf77f, 0x5e3f037f, + 0x5e60fe7f, 0x5e82e87f, 0x5ea4ca7f, 0x5ec69b7f, 0x5ee85b7f, 0x5f0a0aff, + 0x5f2bb1ff, 0x5f4d487f, 0x5f6ecdff, 0x5f904aff, 0x5fb1aeff, 0x5fd30aff, + 0x5ff4557f, 0x601597ff, 0x6036c17f, 0x6057e1ff, 0x6078f27f, 0x6099f17f, + 0x60bae87f, 0x60dbceff, 0x60fca3ff, 0x611d68ff, 0x613e1c7f, 0x615ec7ff, + 0x617f627f, 0x619fec7f, 0x61c0657f, 0x61e0cdff, 0x62012dff, 0x62217cff, + 0x6241bb7f, 0x6261e8ff, 0x628205ff, 0x62a21a7f, 0x62c21dff, 0x62e210ff, + 0x6301f2ff, 0x6321c47f, 0x63418d7f, 0x63613cff, 0x6380e47f, 0x63a07aff, + 0x63c000ff, 0x63df7e7f, 0x63fee2ff, 0x641e3e7f, 0x643d89ff, 0x645cc3ff, + 0x647bed7f, 0x649b067f, 0x64ba16ff, 0x64d90dff, 0x64f7fcff, 0x6516daff, + 0x6535a87f, 0x655464ff, 0x657318ff, 0x6591b3ff, 0x65b0467f, 0x65cebfff, + 0x65ed30ff, 0x660b90ff, 0x6629e07f, 0x66481f7f, 0x6666557f, 0x668472ff, + 0x66a2877f, 0x66c082ff, 0x66de767f, 0x66fc587f, 0x671a2a7f, 0x6737eaff, + 0x67559aff, 0x677342ff, 0x6790d17f, 0x67ae577f, 0x67cbc47f, 0x67e928ff, + 0x68067cff, 0x6823bfff, 0x6840f1ff, 0x685e137f, 0x687b247f, 0x6898247f, + 0x68b5137f, 0x68d1f9ff, 0x68eec7ff, 0x690b8cff, 0x692838ff, 0x6944dc7f, + 0x696166ff, 0x697de8ff, 0x699a5a7f, 0x69b6baff, 0x69d30aff, 0x69ef49ff, + 0x6a0b77ff, 0x6a27957f, 0x6a43a1ff, 0x6a5f9dff, 0x6a7b88ff, 0x6a976bff, + 0x6ab3357f, 0x6aceedff, 0x6aea9e7f, 0x6b06357f, 0x6b21c47f, 0x6b3d39ff, + 0x6b58a77f, 0x6b73fb7f, 0x6b8f46ff, 0x6baa797f, 0x6bc5a3ff, 0x6be0bd7f, + 0x6bfbbd7f, 0x6c16b57f, 0x6c319c7f, 0x6c4c69ff, 0x6c672f7f, 0x6c81e47f, + 0x6c9c7fff, 0x6cb712ff, 0x6cd1957f, 0x6cec06ff, 0x6d065f7f, 0x6d20af7f, + 0x6d3aeeff, 0x6d5514ff, 0x6d6f327f, 0x6d893f7f, 0x6da3337f, 0x6dbd1eff, + 0x6dd6f97f, 0x6df0baff, 0x6e0a73ff, 0x6e2413ff, 0x6e3dab7f, 0x6e57297f, + 0x6e709f7f, 0x6e89fc7f, 0x6ea350ff, 0x6ebc8bff, 0x6ed5beff, 0x6eeed87f, + 0x6f07e17f, 0x6f20d97f, 0x6f39c97f, 0x6f529fff, 0x6f6b657f, 0x6f841a7f, + 0x6f9cbeff, 0x6fb5527f, 0x6fcdd4ff, 0x6fe646ff, 0x6ffe9f7f, 0x7016efff, + 0x702f2f7f, 0x704755ff, 0x705f73ff, 0x707778ff, 0x708f757f, 0x70a7587f, + 0x70bf2aff, 0x70d6ecff, 0x70eea5ff, 0x7106467f, 0x711dd5ff, 0x71354bff, + 0x714cb9ff, 0x716416ff, 0x717b637f, 0x7192967f, 0x71a9c0ff, 0x71c0d2ff, + 0x71d7d37f, 0x71eec37f, 0x7205a2ff, 0x721c717f, 0x72332eff, 0x7249dbff, + 0x726077ff, 0x7276faff, 0x728d757f, 0x72a3d6ff, 0x72ba2fff, 0x72d06fff, + 0x72e69eff, 0x72fcbd7f, 0x7312caff, 0x7328beff, 0x733eaaff, 0x73547dff, + 0x736a487f, 0x737ff97f, 0x739599ff, 0x73ab29ff, 0x73c0a8ff, 0x73d616ff, + 0x73eb6bff, 0x7400b87f, 0x7415ebff, 0x742b0e7f, 0x7440207f, 0x7455217f, + 0x746a11ff, 0x747ef17f, 0x7493b7ff, 0x74a875ff, 0x74bd1a7f, 0x74d1ae7f, + 0x74e631ff, 0x74faa47f, 0x750efdff, 0x75234e7f, 0x7537867f, 0x754bad7f, + 0x755fc37f, 0x7573c8ff, 0x7587bdff, 0x759b997f, 0x75af6c7f, 0x75c3267f, + 0x75d6cf7f, 0x75ea67ff, 0x75fdef7f, 0x76115dff, 0x7624c3ff, 0x763810ff, + 0x764b4cff, 0x765e787f, 0x76718a7f, 0x7684947f, 0x769784ff, 0x76aa64ff, + 0x76bd33ff, 0x76cff1ff, 0x76e29f7f, 0x76f533ff, 0x7707b77f, 0x771a2a7f, + 0x772c8c7f, 0x773edd7f, 0x7751157f, 0x77633cff, 0x77755bff, 0x778758ff, + 0x77994dff, 0x77ab327f, 0x77bcfd7f, 0x77ceb77f, 0x77e060ff, 0x77f1f97f, + 0x780378ff, 0x7814e7ff, 0x782645ff, 0x783792ff, 0x7848cf7f, 0x7859f27f, + 0x786b04ff, 0x787c06ff, 0x788cf7ff, 0x789dd7ff, 0x78ae9eff, 0x78bf54ff, + 0x78cffa7f, 0x78e08eff, 0x78f10a7f, 0x79017d7f, 0x7911d77f, 0x7922187f, + 0x7932507f, 0x79426fff, 0x79527e7f, 0x79627bff, 0x797268ff, 0x79823c7f, + 0x7991ff7f, 0x79a1b17f, 0x79b152ff, 0x79c0e37f, 0x79d05aff, 0x79dfc17f, + 0x79ef177f, 0x79fe53ff, 0x7a0d7fff, 0x7a1c9b7f, 0x7a2ba57f, 0x7a3a9eff, + 0x7a497f7f, 0x7a584f7f, 0x7a670dff, 0x7a75b3ff, 0x7a8450ff, 0x7a92d57f, + 0x7aa1487f, 0x7aafa2ff, 0x7abdec7f, 0x7acc24ff, 0x7ada4cff, 0x7ae863ff, + 0x7af661ff, 0x7b044eff, 0x7b122b7f, 0x7b1fee7f, 0x7b2da0ff, 0x7b3b42ff, + 0x7b48d37f, 0x7b564b7f, 0x7b63b27f, 0x7b71087f, 0x7b7e4dff, 0x7b8b79ff, + 0x7b98957f, 0x7ba59fff, 0x7bb299ff, 0x7bbf7aff, 0x7bcc4aff, 0x7bd9017f, + 0x7be5afff, 0x7bf244ff, 0x7bfec97f, 0x7c0b34ff, 0x7c1797ff, 0x7c23e17f, + 0x7c3011ff, 0x7c3c3a7f, 0x7c48497f, 0x7c54477f, 0x7c602c7f, 0x7c6c08ff, + 0x7c77ccff, 0x7c8376ff, 0x7c8f18ff, 0x7c9aa1ff, 0x7ca619ff, 0x7cb1787f, + 0x7cbcceff, 0x7cc80c7f, 0x7cd3307f, 0x7cde4c7f, 0x7ce94eff, 0x7cf4407f, + 0x7cff197f, 0x7d09e0ff, 0x7d1497ff, 0x7d1f3e7f, 0x7d29cb7f, 0x7d3447ff, + 0x7d3eb37f, 0x7d4905ff, 0x7d53477f, 0x7d5d787f, 0x7d67987f, 0x7d719f7f, + 0x7d7b957f, 0x7d85727f, 0x7d8f46ff, 0x7d99027f, 0x7da2a4ff, 0x7dac3e7f, + 0x7db5bf7f, 0x7dbf26ff, 0x7dc885ff, 0x7dd1cbff, 0x7ddb017f, 0x7de41d7f, + 0x7ded287f, 0x7df622ff, 0x7dff0c7f, 0x7e07dd7f, 0x7e109cff, 0x7e19437f, + 0x7e21d97f, 0x7e2a5e7f, 0x7e32d27f, 0x7e3b2dff, 0x7e4377ff, 0x7e4bb17f, + 0x7e53d1ff, 0x7e5be17f, 0x7e63e07f, 0x7e6bc5ff, 0x7e739aff, 0x7e7b5eff, + 0x7e8309ff, 0x7e8aac7f, 0x7e922d7f, 0x7e99a5ff, 0x7ea1057f, 0x7ea84bff, + 0x7eaf89ff, 0x7eb6ae7f, 0x7ebdc27f, 0x7ec4bcff, 0x7ecba6ff, 0x7ed2807f, + 0x7ed948ff, 0x7edff7ff, 0x7ee68dff, 0x7eed1bff, 0x7ef3907f, 0x7ef9f47f, + 0x7f003eff, 0x7f0678ff, 0x7f0ca1ff, 0x7f12b9ff, 0x7f18b8ff, 0x7f1e9eff, + 0x7f247c7f, 0x7f2a40ff, 0x7f2ff47f, 0x7f358eff, 0x7f3b18ff, 0x7f4091ff, + 0x7f45f17f, 0x7f4b407f, 0x7f507e7f, 0x7f55abff, 0x7f5abfff, 0x7f5fbb7f, + 0x7f64adff, 0x7f69877f, 0x7f6e47ff, 0x7f72ffff, 0x7f779e7f, 0x7f7c23ff, + 0x7f80a17f, 0x7f85057f, 0x7f89507f, 0x7f8d8a7f, 0x7f91b3ff, 0x7f95cc7f, + 0x7f99cbff, 0x7f9dba7f, 0x7fa1987f, 0x7fa55cff, 0x7fa910ff, 0x7facabff, + 0x7fb0357f, 0x7fb3aeff, 0x7fb70eff, 0x7fba667f, 0x7fbd9c7f, 0x7fc0ca7f, + 0x7fc3deff, 0x7fc6e27f, 0x7fc9ccff, 0x7fcca6ff, 0x7fcf6fff, 0x7fd21fff, + 0x7fd4beff, 0x7fd74d7f, 0x7fd9c27f, 0x7fdc26ff, 0x7fde71ff, 0x7fe0ac7f, + 0x7fe2d5ff, 0x7fe4eeff, 0x7fe6ee7f, 0x7fe8dd7f, 0x7feab37f, 0x7fec787f, + 0x7fee2c7f, 0x7fefcfff, 0x7ff15a7f, 0x7ff2cb7f, 0x7ff433ff, 0x7ff5837f, + 0x7ff6b9ff, 0x7ff7e7ff, 0x7ff8fcff, 0x7ff9f87f, 0x7ffae37f, 0x7ffbbd7f, + 0x7ffc86ff, 0x7ffd36ff, 0x7ffdd67f, 0x7ffe5c7f, 0x7ffed1ff, 0x7fff367f, + 0x7fff8a7f, 0x7fffc57f, 0x7fffe6ff, 0x7fffffff, +}; + +const WORD32 ixheaacd_sine_win_64[64] = { + 0x019220ff, 0x04b6177f, 0x07d95dd7, 0x0afb655f, 0x0e1bc11f, 0x1139f33f, + 0x1455757f, 0x176ddabf, 0x1a829cff, 0x1d934eff, 0x209f72ff, 0x23a68aff, + 0x26a821ff, 0x29a3c1ff, 0x2c98fe7f, 0x2f8750bf, 0x326e547f, 0x354d93ff, + 0x382491bf, 0x3af2f13f, 0x3db8347f, 0x4073eeff, 0x4325c3ff, 0x45cd357f, + 0x4869e7ff, 0x4afb6dff, 0x4d81627f, 0x4ffb697f, 0x5269167f, 0x54ca0bff, + 0x571deeff, 0x5964627f, 0x5b9d12ff, 0x5dc79aff, 0x5fe3afff, 0x61f0fdff, + 0x63ef307f, 0x65ddfc7f, 0x67bd0dff, 0x698c21ff, 0x6b4af4ff, 0x6cf9337f, + 0x6e96aaff, 0x70230fff, 0x719e2fff, 0x7307bfff, 0x745f9dff, 0x75a586ff, + 0x76d948ff, 0x77fab97f, 0x7909a67f, 0x7a05ee7f, 0x7aef66ff, 0x7bc5de7f, + 0x7c894c7f, 0x7d397dff, 0x7dd6627f, 0x7e5fe0ff, 0x7ed5e8ff, 0x7f3857ff, + 0x7f872eff, 0x7fc2547f, 0x7fe9c87f, 0x7ffd8aff}; + +const WORD32 ixheaacd_sine_win_768[768] = { + 0x0021858b, 0x0064883f, 0x00a78af3, 0x00ea960a, 0x012d98bf, 0x01709b73, + 0x01b39e27, 0x01f6a0db, 0x0239a38f, 0x027ca643, 0x02bfa8f7, 0x0302abab, + 0x0345ae5f, 0x0388a8af, 0x03cbab63, 0x040ea5b7, 0x0451a007, 0x04949a57, + 0x04d794a7, 0x051a8ef7, 0x055d8947, 0x05a07b37, 0x05e36d1f, 0x06265f0f, + 0x066950ff, 0x06ac42e7, 0x06ef2c6f, 0x073215ff, 0x0774ff87, 0x07b7e90f, + 0x07faca37, 0x083db3bf, 0x088094df, 0x08c36daf, 0x09064ecf, 0x0949278f, + 0x098bf7ef, 0x09ced0af, 0x0a11a10f, 0x0a54716f, 0x0a97396f, 0x0ada016f, + 0x0b1cc95f, 0x0b5f915f, 0x0ba250ff, 0x0be5082f, 0x0c27bf5f, 0x0c6a768f, + 0x0cad2dcf, 0x0cefdc9f, 0x0d32830f, 0x0d7531df, 0x0db7cfdf, 0x0dfa764f, + 0x0e3d145f, 0x0e7fa9ff, 0x0ec23faf, 0x0f04ccef, 0x0f475a2f, 0x0f89e76f, + 0x0fcc6c4f, 0x100ee8df, 0x1051653f, 0x1093d95f, 0x10d64d7f, 0x1118b93f, + 0x115b24df, 0x119d883f, 0x11dfeb7f, 0x1222467f, 0x126498ff, 0x12a6eb9f, + 0x12e935bf, 0x132b7fdf, 0x136db93f, 0x13affaff, 0x13f22bff, 0x14345cff, + 0x14768dff, 0x14b8ae3f, 0x14face5f, 0x153cee9f, 0x157efdff, 0x15c10d7f, + 0x1603147f, 0x16451b9f, 0x16871a3f, 0x16c9107f, 0x170afe5f, 0x174ce3df, + 0x178ec95f, 0x17d0a67f, 0x18127b1f, 0x18544fdf, 0x189613df, 0x18d7d7bf, + 0x1919933f, 0x195b467f, 0x199cf99f, 0x19de9bff, 0x1a203e5f, 0x1a61d85f, + 0x1aa369ff, 0x1ae4f33f, 0x1b2673ff, 0x1b67ec7f, 0x1ba964df, 0x1beacc9f, + 0x1c2c343f, 0x1c6d937f, 0x1caee1ff, 0x1cf0307f, 0x1d31769f, 0x1d72b45f, + 0x1db3e99f, 0x1df5169f, 0x1e363b1f, 0x1e77573f, 0x1eb86b1f, 0x1ef9767f, + 0x1f3a797f, 0x1f7b741f, 0x1fbc663f, 0x1ffd501f, 0x203e317f, 0x207f0abf, + 0x20bfd2ff, 0x21009b3f, 0x21415aff, 0x21820a3f, 0x21c2b93f, 0x220357bf, + 0x2243ed7f, 0x22847b3f, 0x22c5003f, 0x23057cff, 0x2345f17f, 0x238654ff, + 0x23c6b8bf, 0x24070b7f, 0x244755ff, 0x248797ff, 0x24c7c93f, 0x2507fabf, + 0x25481b3f, 0x2588333f, 0x25c842ff, 0x26084a3f, 0x264840ff, 0x26882eff, + 0x26c814bf, 0x2707e9bf, 0x2747b67f, 0x27877abf, 0x27c7367f, 0x2806e9ff, + 0x28468cbf, 0x28861e7f, 0x28c5b07f, 0x2905317f, 0x2944aa3f, 0x2984123f, + 0x29c371bf, 0x2a02c8ff, 0x2a420f7f, 0x2a814d7f, 0x2ac082ff, 0x2affa7ff, + 0x2b3ec47f, 0x2b7dcfff, 0x2bbcd33f, 0x2bfbc5bf, 0x2c3aafff, 0x2c7991bf, + 0x2cb862bf, 0x2cf72b3f, 0x2d35e2ff, 0x2d74927f, 0x2db330ff, 0x2df1c73f, + 0x2e304cbf, 0x2e6ec9ff, 0x2ead363f, 0x2eeb99ff, 0x2f29ed3f, 0x2f682f7f, + 0x2fa671ff, 0x2fe49aff, 0x3022bbff, 0x3060cbff, 0x309ed37f, 0x30dcca7f, + 0x311ab8ff, 0x3158967f, 0x3196637f, 0x31d427ff, 0x3211dbbf, 0x324f873f, + 0x328d21bf, 0x32caab7f, 0x33082cff, 0x3345953f, 0x3382fd7f, 0x33c04c7f, + 0x33fd933f, 0x343ac93f, 0x3477f6bf, 0x34b50aff, 0x34f216ff, 0x352f1a7f, + 0x356c04ff, 0x35a8e6ff, 0x35e5b83f, 0x362278bf, 0x365f30ff, 0x369bcfbf, + 0x36d8663f, 0x3714ec3f, 0x3751697f, 0x378dcdbf, 0x37ca297f, 0x3806747f, + 0x3842aebf, 0x387ed83f, 0x38baf97f, 0x38f7013f, 0x393300bf, 0x396eefbf, + 0x39aacd7f, 0x39e69abf, 0x3a22573f, 0x3a5e02ff, 0x3a999dbf, 0x3ad5303f, + 0x3b10a97f, 0x3b4c1a7f, 0x3b87723f, 0x3bc2c1bf, 0x3bfe003f, 0x3c392dff, + 0x3c7442bf, 0x3caf4eff, 0x3cea4a7f, 0x3d25353f, 0x3d600f3f, 0x3d9ad83f, + 0x3dd5883f, 0x3e102fff, 0x3e4ac6bf, 0x3e854cbf, 0x3ebfb9bf, 0x3efa1e3f, + 0x3f3471ff, 0x3f6eac7f, 0x3fa8debf, 0x3fe2f7bf, 0x401cffff, 0x4056ffff, + 0x4090e67f, 0x40cabc7f, 0x4104817f, 0x413e2d7f, 0x4177d0ff, 0x41b15b7f, + 0x41eadd7f, 0x422445ff, 0x425d9e7f, 0x4296e57f, 0x42d0137f, 0x4309397f, + 0x434245ff, 0x437b417f, 0x43b42cff, 0x43ed06ff, 0x4425c7ff, 0x445e787f, + 0x449717ff, 0x44cfa67f, 0x4508247f, 0x4540897f, 0x4578dd7f, 0x45b1207f, + 0x45e94a7f, 0x462163ff, 0x46596c7f, 0x46915bff, 0x46c942ff, 0x4701107f, + 0x4738c57f, 0x4770717f, 0x47a7fbff, 0x47df7e7f, 0x4816e77f, 0x484e3fff, + 0x4885877f, 0x48bcb5ff, 0x48f3d37f, 0x492ad7ff, 0x4961cbff, 0x4998ae7f, + 0x49cf787f, 0x4a06317f, 0x4a3cd17f, 0x4a73607f, 0x4aa9de7f, 0x4ae0437f, + 0x4b168f7f, 0x4b4cd2ff, 0x4b82f4ff, 0x4bb90e7f, 0x4bef067f, 0x4c24f67f, + 0x4c5ac47f, 0x4c9089ff, 0x4cc6367f, 0x4cfbc9ff, 0x4d314c7f, 0x4d66b5ff, + 0x4d9c0e7f, 0x4dd14dff, 0x4e06747f, 0x4e3b927f, 0x4e708eff, 0x4ea57a7f, + 0x4eda4cff, 0x4f0f0e7f, 0x4f43bf7f, 0x4f784eff, 0x4faccd7f, 0x4fe13aff, + 0x50158f7f, 0x5049caff, 0x507ded7f, 0x50b1feff, 0x50e5ff7f, 0x5119deff, + 0x514dacff, 0x51816aff, 0x51b50f7f, 0x51e89a7f, 0x521c0c7f, 0x524f6dff, + 0x5282b5ff, 0x52b5e4ff, 0x52e9037f, 0x531c087f, 0x534ef47f, 0x5381c6ff, + 0x53b488ff, 0x53e731ff, 0x5419c17f, 0x544c407f, 0x547e9d7f, 0x54b0e9ff, + 0x54e325ff, 0x55153fff, 0x5547497f, 0x5579397f, 0x55ab107f, 0x55dcce7f, + 0x560e737f, 0x5640077f, 0x567181ff, 0x56a2e3ff, 0x56d42bff, 0x57055b7f, + 0x573679ff, 0x57677f7f, 0x579862ff, 0x57c935ff, 0x57f9efff, 0x582a98ff, + 0x585b207f, 0x588b8eff, 0x58bbec7f, 0x58ec287f, 0x591c53ff, 0x594c65ff, + 0x597c5eff, 0x59ac3e7f, 0x59dc057f, 0x5a0bb27f, 0x5a3b46ff, 0x5a6ac1ff, + 0x5a9a2c7f, 0x5ac974ff, 0x5af8a4ff, 0x5b27c37f, 0x5b56c0ff, 0x5b85a4ff, + 0x5bb4787f, 0x5be329ff, 0x5c11c27f, 0x5c404a7f, 0x5c6eb07f, 0x5c9d05ff, + 0x5ccb39ff, 0x5cf954ff, 0x5d27567f, 0x5d55477f, 0x5d83167f, 0x5db0cc7f, + 0x5dde697f, 0x5e0bed7f, 0x5e3957ff, 0x5e66a97f, 0x5e93d97f, 0x5ec0f87f, + 0x5eedfe7f, 0x5f1ae2ff, 0x5f47adff, 0x5f74687f, 0x5fa1017f, 0x5fcd80ff, + 0x5ff9df7f, 0x60262c7f, 0x605260ff, 0x607e737f, 0x60aa6cff, 0x60d64d7f, + 0x6102147f, 0x612dc27f, 0x6159577f, 0x6184caff, 0x61b024ff, 0x61db65ff, + 0x62068d7f, 0x62319c7f, 0x625c897f, 0x6287657f, 0x62b2207f, 0x62dcb97f, + 0x630741ff, 0x6331a8ff, 0x635bf67f, 0x63862aff, 0x63b0467f, 0x63da407f, + 0x640420ff, 0x642de87f, 0x64578e7f, 0x64811aff, 0x64aa8e7f, 0x64d3e8ff, + 0x64fd21ff, 0x6526417f, 0x654f47ff, 0x65782cff, 0x65a0f8ff, 0x65c9ab7f, + 0x65f244ff, 0x661abcff, 0x66431bff, 0x666b58ff, 0x66937cff, 0x66bb87ff, + 0x66e3717f, 0x670b417f, 0x6732f87f, 0x675a8dff, 0x678209ff, 0x67a96d7f, + 0x67d0aeff, 0x67f7d6ff, 0x681eddff, 0x6845cb7f, 0x686c97ff, 0x689352ff, + 0x68b9e47f, 0x68e064ff, 0x6906bbff, 0x692d01ff, 0x695325ff, 0x697928ff, + 0x699f127f, 0x69c4e2ff, 0x69ea91ff, 0x6a10277f, 0x6a359bff, 0x6a5af6ff, + 0x6a802fff, 0x6aa5507f, 0x6aca577f, 0x6aef34ff, 0x6b1400ff, 0x6b38abff, + 0x6b5d357f, 0x6b81a57f, 0x6ba5f3ff, 0x6bca297f, 0x6bee3d7f, 0x6c1237ff, + 0x6c3610ff, 0x6c59d0ff, 0x6c7d6f7f, 0x6ca0f4ff, 0x6cc4587f, 0x6ce79a7f, + 0x6d0ac37f, 0x6d2dd37f, 0x6d50b97f, 0x6d738e7f, 0x6d96397f, 0x6db8cb7f, + 0x6ddb447f, 0x6dfd9b7f, 0x6e1fd17f, 0x6e41edff, 0x6e63e8ff, 0x6e85c27f, + 0x6ea7827f, 0x6ec9297f, 0x6eeaa6ff, 0x6f0c0aff, 0x6f2d557f, 0x6f4e767f, + 0x6f6f867f, 0x6f906cff, 0x6fb139ff, 0x6fd1e4ff, 0x6ff2777f, 0x7012e7ff, + 0x7033377f, 0x705364ff, 0x7073797f, 0x70936c7f, 0x70b345ff, 0x70d2fdff, + 0x70f294ff, 0x711209ff, 0x713165ff, 0x71509fff, 0x716fc17f, 0x718eb87f, + 0x71ad967f, 0x71cc52ff, 0x71eaf67f, 0x7209787f, 0x7227d87f, 0x724616ff, + 0x72643cff, 0x7282387f, 0x72a022ff, 0x72bde3ff, 0x72db8b7f, 0x72f9097f, + 0x7316767f, 0x7333b97f, 0x7350daff, 0x736de2ff, 0x738ac9ff, 0x73a7977f, + 0x73c43aff, 0x73e0c57f, 0x73fd2e7f, 0x741975ff, 0x74359bff, 0x7451a87f, + 0x746d8aff, 0x7489547f, 0x74a4fc7f, 0x74c08b7f, 0x74dbf07f, 0x74f73bff, + 0x751265ff, 0x752d6eff, 0x754855ff, 0x75631b7f, 0x757dc77f, 0x759849ff, + 0x75b2b37f, 0x75ccfaff, 0x75e720ff, 0x76012dff, 0x761b10ff, 0x7634daff, + 0x764e7a7f, 0x7668017f, 0x7681667f, 0x769aa9ff, 0x76b3d47f, 0x76ccd4ff, + 0x76e5b3ff, 0x76fe79ff, 0x77171dff, 0x772f987f, 0x7747f97f, 0x776038ff, + 0x777856ff, 0x77905bff, 0x77a836ff, 0x77bff07f, 0x77d7907f, 0x77ef067f, + 0x780663ff, 0x781d9f7f, 0x7834b0ff, 0x784ba97f, 0x78627fff, 0x7879357f, + 0x788fc8ff, 0x78a63b7f, 0x78bc8bff, 0x78d2c37f, 0x78e8d0ff, 0x78febcff, + 0x7914877f, 0x792a387f, 0x793fbfff, 0x79552dff, 0x796a727f, 0x797f9d7f, + 0x79949e7f, 0x79a9867f, 0x79be4cff, 0x79d2e97f, 0x79e76c7f, 0x79fbce7f, + 0x7a1005ff, 0x7a24247f, 0x7a38217f, 0x7a4bfcff, 0x7a5fae7f, 0x7a7346ff, + 0x7a86bdff, 0x7a9a0aff, 0x7aad3e7f, 0x7ac0507f, 0x7ad3417f, 0x7ae607ff, + 0x7af8b57f, 0x7b0b38ff, 0x7b1da37f, 0x7b2fec7f, 0x7b420aff, 0x7b5410ff, + 0x7b65ecff, 0x7b77af7f, 0x7b8947ff, 0x7b9ac77f, 0x7bac1cff, 0x7bbd50ff, + 0x7bce6bff, 0x7bdf5cff, 0x7bf02c7f, 0x7c00d9ff, 0x7c11667f, 0x7c21d0ff, + 0x7c3219ff, 0x7c4241ff, 0x7c5247ff, 0x7c622c7f, 0x7c71eeff, 0x7c8187ff, + 0x7c9107ff, 0x7ca05dff, 0x7caf9a7f, 0x7cbead7f, 0x7ccd9e7f, 0x7cdc767f, + 0x7ceb247f, 0x7cf9b0ff, 0x7d081bff, 0x7d16657f, 0x7d2484ff, 0x7d328b7f, + 0x7d406fff, 0x7d4e2aff, 0x7d5bcc7f, 0x7d69447f, 0x7d769a7f, 0x7d83ceff, + 0x7d90e1ff, 0x7d9dd37f, 0x7daaa37f, 0x7db751ff, 0x7dc3d67f, 0x7dd041ff, + 0x7ddc82ff, 0x7de8a2ff, 0x7df4a97f, 0x7e0085ff, 0x7e0c38ff, 0x7e17d27f, + 0x7e234a7f, 0x7e2ea0ff, 0x7e39cd7f, 0x7e44d87f, 0x7e4fc1ff, 0x7e5a897f, + 0x7e652fff, 0x7e6fb4ff, 0x7e7a17ff, 0x7e8450ff, 0x7e8e717f, 0x7e98677f, + 0x7ea23bff, 0x7eabeeff, 0x7eb5807f, 0x7ebef07f, 0x7ec8367f, 0x7ed15aff, + 0x7eda65ff, 0x7ee3477f, 0x7eec06ff, 0x7ef4a57f, 0x7efd197f, 0x7f05747f, + 0x7f0da5ff, 0x7f15b57f, 0x7f1da37f, 0x7f256fff, 0x7f2d1aff, 0x7f34a47f, + 0x7f3c037f, 0x7f43417f, 0x7f4a667f, 0x7f5160ff, 0x7f5831ff, 0x7f5ee97f, + 0x7f65777f, 0x7f6bebff, 0x7f72367f, 0x7f785f7f, 0x7f7e66ff, 0x7f84447f, + 0x7f8a08ff, 0x7f8fa37f, 0x7f951c7f, 0x7f9a737f, 0x7f9fa97f, 0x7fa4bd7f, + 0x7fa9a7ff, 0x7fae70ff, 0x7fb3207f, 0x7fb7a5ff, 0x7fbc017f, 0x7fc043ff, + 0x7fc45c7f, 0x7fc85bff, 0x7fcc317f, 0x7fcfe57f, 0x7fd36f7f, 0x7fd6e07f, + 0x7fda26ff, 0x7fdd4c7f, 0x7fe04fff, 0x7fe3327f, 0x7fe5f2ff, 0x7fe889ff, + 0x7feafeff, 0x7fed5aff, 0x7fef8cff, 0x7ff194ff, 0x7ff383ff, 0x7ff548ff, + 0x7ff6ec7f, 0x7ff86dff, 0x7ff9ce7f, 0x7ffb0d7f, 0x7ffc21ff, 0x7ffd1dff, + 0x7ffdef7f, 0x7ffe9f7f, 0x7fff25ff, 0x7fff92ff, 0x7fffd5ff, 0x7ffff77f}; + +const WORD32 ixheaacd_sine_win_192[192] = { + 0x00860dcc, 0x01922100, 0x029e2bd0, 0x03aa25d8, 0x04b61780, 0x05c1f860, + 0x06cdb7b0, 0x07d95dd8, 0x08e4da10, 0x09f034b0, 0x0afb6560, 0x0c0663c0, + 0x0d112fd0, 0x0e1bc120, 0x0f2617c0, 0x103022e0, 0x1139f340, 0x12436fc0, + 0x134ca0c0, 0x14557580, 0x155df660, 0x16661ae0, 0x176ddac0, 0x18753600, + 0x197c2440, 0x1a829d00, 0x1b88a8c0, 0x1c8e3f00, 0x1d934f00, 0x1e97e140, + 0x1f9bed40, 0x209f7300, 0x21a261c0, 0x22a4c200, 0x23a68b00, 0x24a7b500, + 0x25a83f40, 0x26a82200, 0x27a75cc0, 0x28a5e780, 0x29a3c200, 0x2aa0ec80, + 0x2b9d5600, 0x2c98fe80, 0x2d93e600, 0x2e8e0440, 0x2f8750c0, 0x307fd400, + 0x31777d00, 0x326e5480, 0x33644940, 0x34596400, 0x354d9400, 0x3640d900, + 0x37332ac0, 0x382491c0, 0x39150540, 0x3a0474c0, 0x3af2f140, 0x3be06100, + 0x3cccccc0, 0x3db83480, 0x3ea28780, 0x3f8bc580, 0x4073eeff, 0x415b037f, + 0x4240f1ff, 0x4325c3ff, 0x4409677f, 0x44ebe57f, 0x45cd357f, 0x46ad4f7f, + 0x478c3aff, 0x4869e7ff, 0x494655ff, 0x4a21857f, 0x4afb6dff, 0x4bd40eff, + 0x4cab607f, 0x4d81627f, 0x4e5614ff, 0x4f2966ff, 0x4ffb60ff, 0x50cc037f, + 0x519b3cff, 0x5269167f, 0x53357e7f, 0x54007dff, 0x54ca0bff, 0x559220ff, + 0x5658c47f, 0x571deeff, 0x57e1977f, 0x58a3bdff, 0x5964627f, 0x5a237cff, + 0x5ae10cff, 0x5b9d12ff, 0x5c577d7f, 0x5d105dff, 0x5dc79aff, 0x5e7d457f, + 0x5f314c7f, 0x5fe3afff, 0x609478ff, 0x61438cff, 0x61f0fdff, 0x629cc2ff, + 0x6346d3ff, 0x63ef307f, 0x6495d8ff, 0x653acd7f, 0x65ddfc7f, 0x667f6f7f, + 0x671f257f, 0x67bd0dff, 0x685939ff, 0x68f3907f, 0x698c21ff, 0x6a22e5ff, + 0x6ab7d3ff, 0x6b4af4ff, 0x6bdc377f, 0x6c6ba47f, 0x6cf9337f, 0x6d84e3ff, + 0x6e0eb67f, 0x6e96aaff, 0x6f1cafff, 0x6fa0d77f, 0x70230fff, 0x70a3617f, + 0x7121bbff, 0x719e2fff, 0x7218ac7f, 0x729131ff, 0x7307bfff, 0x737c5eff, + 0x73eefe7f, 0x745f9dff, 0x74ce3dff, 0x753ae67f, 0x75a586ff, 0x760e1f7f, + 0x7674b7ff, 0x76d948ff, 0x773bd17f, 0x779c497f, 0x77fab97f, 0x785718ff, + 0x78b167ff, 0x7909a67f, 0x795fd47f, 0x79b3e97f, 0x7a05ee7f, 0x7a55d9ff, + 0x7aa3acff, 0x7aef66ff, 0x7b38ffff, 0x7b807fff, 0x7bc5de7f, 0x7c09247f, + 0x7c4a48ff, 0x7c894c7f, 0x7cc62e7f, 0x7d00e67f, 0x7d397dff, 0x7d6ff37f, + 0x7da43fff, 0x7dd6627f, 0x7e0663ff, 0x7e343b7f, 0x7e5fe0ff, 0x7e89657f, + 0x7eb0b7ff, 0x7ed5e8ff, 0x7ef8df7f, 0x7f19b4ff, 0x7f3857ff, 0x7f54c97f, + 0x7f6f10ff, 0x7f872eff, 0x7f9d12ff, 0x7fb0cc7f, 0x7fc2547f, 0x7fd1aa7f, + 0x7fded67f, 0x7fe9c87f, 0x7ff2907f, 0x7ff926ff, 0x7ffd8aff, 0x7fffbcff, +}; + +const WORD32 ixheaacd_sine_win_96[96] = { + 0x010c1334, 0x032428d4, 0x053c0c20, 0x07538ac0, 0x096a93f0, 0x0b80ed00, + 0x0d968510, 0x0fab29e0, 0x11beb9e0, 0x13d11380, 0x15e21540, 0x17f19500, + 0x19ff7160, 0x1c0b8060, 0x1e15a8e0, 0x201dc0c0, 0x2223a6c0, 0x242730c0, + 0x26284580, 0x2826bb40, 0x2a227080, 0x2c1b3b00, 0x2e110a00, 0x3003ab80, + 0x31f30600, 0x33def000, 0x35c74fc0, 0x37abfb80, 0x398cda80, 0x3b69ca80, + 0x3d42a240, 0x3f174800, 0x40e79a7f, 0x42b380ff, 0x447ad07f, 0x463d687f, + 0x47fb377f, 0x49b4137f, 0x4b67e3ff, 0x4d168f7f, 0x4ebfebff, 0x5063e07f, + 0x5202537f, 0x539b2c7f, 0x552e48ff, 0x56bb87ff, 0x5842e0ff, 0x59c421ff, + 0x5b3f41ff, 0x5cb41fff, 0x5e22a2ff, 0x5f8ab0ff, 0x60ec397f, 0x62471b7f, + 0x639b3cff, 0x64e8857f, 0x662eec7f, 0x676e4fff, 0x68a69fff, 0x69d7c2ff, + 0x6b019eff, 0x6c242cff, 0x6d3f4a7f, 0x6e52ef7f, 0x6f5f02ff, 0x7063737f, + 0x716030ff, 0x725529ff, 0x73424e7f, 0x74278cff, 0x7504d57f, 0x75da167f, + 0x76a73f7f, 0x776c507f, 0x782927ff, 0x78ddce7f, 0x798a21ff, 0x7a2e22ff, + 0x7ac9c8ff, 0x7b5d02ff, 0x7be7c8ff, 0x7c6a11ff, 0x7ce3cd7f, 0x7d54fbff, + 0x7dbd9c7f, 0x7e1d96ff, 0x7e74ea7f, 0x7ec3977f, 0x7f09957f, 0x7f46dc7f, + 0x7f7b637f, 0x7fa732ff, 0x7fca4aff, 0x7fe4927f, 0x7ff622ff, 0x7ffeeaff}; + +const WORD32 ixheaacd_sine_win_256[256] = { + 0x006487ea, 0x012d96a6, 0x01f6a29e, 0x02bfa9a4, 0x0388a9f4, 0x0451a170, + 0x051a8e60, 0x05e36ea8, 0x06ac4068, 0x077501b8, 0x083db0a0, 0x09064b30, + 0x09cecf80, 0x0a973ba0, 0x0b5f8da0, 0x0c27c390, 0x0cefdb70, 0x0db7d370, + 0x0e7fa9a0, 0x0f475bf0, 0x100ee8a0, 0x10d64dc0, 0x119d8940, 0x12649940, + 0x132b7be0, 0x13f22f60, 0x14b8b180, 0x157f0080, 0x16451a80, 0x170afd80, + 0x17d0a7c0, 0x18961720, 0x195b49e0, 0x1a203e20, 0x1ae4f1e0, 0x1ba96340, + 0x1c6d9060, 0x1d317740, 0x1df51640, 0x1eb86b40, 0x1f7b7480, 0x203e3000, + 0x21009c00, 0x21c2b680, 0x22847e00, 0x2345f000, 0x24070b00, 0x24c7cd40, + 0x25883480, 0x26483f80, 0x2707ebc0, 0x27c737c0, 0x288621c0, 0x2944a7c0, + 0x2a02c7c0, 0x2ac08040, 0x2b7dcf00, 0x2c3ab2c0, 0x2cf72940, 0x2db330c0, + 0x2e6ec780, 0x2f29ebc0, 0x2fe49bc0, 0x309ed540, 0x31589700, 0x3211df00, + 0x32caab80, 0x3382fa80, 0x343aca80, 0x34f219c0, 0x35a8e640, 0x365f2e40, + 0x3714f040, 0x37ca2a40, 0x387eda80, 0x3932ff80, 0x39e69780, 0x3a99a040, + 0x3b4c18c0, 0x3bfdfec0, 0x3caf50c0, 0x3d600d40, 0x3e103200, 0x3ebfbdc0, + 0x3f6eaec0, 0x401d02ff, 0x40cab97f, 0x4177cf7f, 0x4224447f, 0x42d015ff, + 0x437b42ff, 0x4425c8ff, 0x44cfa77f, 0x4578db7f, 0x4621647f, 0x46c9407f, + 0x47706d7f, 0x4816ea7f, 0x48bcb57f, 0x4961ccff, 0x4a062fff, 0x4aa9db7f, + 0x4b4ccf7f, 0x4bef08ff, 0x4c90877f, 0x4d31497f, 0x4dd14c7f, 0x4e708f7f, + 0x4f0f10ff, 0x4faccf7f, 0x5049c97f, 0x50e5fd7f, 0x5181697f, 0x521c0c7f, + 0x52b5e4ff, 0x534ef17f, 0x53e7307f, 0x547ea07f, 0x55153fff, 0x55ab0d7f, + 0x5640077f, 0x56d42c7f, 0x57677b7f, 0x57f9f2ff, 0x588b917f, 0x591c54ff, + 0x59ac3cff, 0x5a3b477f, 0x5ac9737f, 0x5b56bf7f, 0x5be32a7f, 0x5c6eb27f, + 0x5cf9567f, 0x5d83147f, 0x5e0bec7f, 0x5e93dbff, 0x5f1ae27f, 0x5fa0fdff, + 0x60262dff, 0x60aa707f, 0x612dc47f, 0x61b0287f, 0x62319b7f, 0x62b21c7f, + 0x6331a9ff, 0x63b0427f, 0x642de4ff, 0x64aa907f, 0x6526437f, 0x65a0fcff, + 0x661abbff, 0x66937e7f, 0x670b447f, 0x67820b7f, 0x67f7d3ff, 0x686c9b7f, + 0x68e060ff, 0x695323ff, 0x69c4e37f, 0x6a359d7f, 0x6aa551ff, 0x6b13feff, + 0x6b81a3ff, 0x6bee3f7f, 0x6c59d07f, 0x6cc4567f, 0x6d2dcfff, 0x6d963c7f, + 0x6dfd99ff, 0x6e63e87f, 0x6ec9267f, 0x6f2d52ff, 0x6f906d7f, 0x6ff2747f, + 0x7053677f, 0x70b344ff, 0x71120cff, 0x716fbd7f, 0x71cc55ff, 0x7227d5ff, + 0x72823c7f, 0x72db87ff, 0x7333b87f, 0x738acc7f, 0x73e0c37f, 0x74359cff, + 0x748956ff, 0x74dbf1ff, 0x752d6c7f, 0x757dc5ff, 0x75ccfd7f, 0x761b11ff, + 0x7668037f, 0x76b3d07f, 0x76fe78ff, 0x7747fbff, 0x779057ff, 0x77d78d7f, + 0x781d9b7f, 0x7862807f, 0x78a63cff, 0x78e8cf7f, 0x792a37ff, 0x796a757f, + 0x79a986ff, 0x79e76c7f, 0x7a24257f, 0x7a5fb0ff, 0x7a9a0e7f, 0x7ad33cff, + 0x7b0b3cff, 0x7b420d7f, 0x7b77ad7f, 0x7bac1cff, 0x7bdf5b7f, 0x7c11687f, + 0x7c4242ff, 0x7c71eaff, 0x7ca05fff, 0x7ccda17f, 0x7cf9aeff, 0x7d2487ff, + 0x7d4e2c7f, 0x7d769b7f, 0x7d9dd57f, 0x7dc3d8ff, 0x7de8a67f, 0x7e0c3cff, + 0x7e2e9cff, 0x7e4fc4ff, 0x7e6fb5ff, 0x7e8e6e7f, 0x7eabeeff, 0x7ec836ff, + 0x7ee345ff, 0x7efd1bff, 0x7f15b8ff, 0x7f2d1bff, 0x7f43457f, 0x7f58347f, + 0x7f6be9ff, 0x7f7e647f, 0x7f8fa47f, 0x7f9fa9ff, 0x7fae747f, 0x7fbc03ff, + 0x7fc8587f, 0x7fd3717f, 0x7fdd4eff, 0x7fe5f0ff, 0x7fed577f, 0x7ff3827f, + 0x7ff8717f, 0x7ffc24ff, 0x7ffe9c7f, 0x7fffd87f, +}; + +const WORD32 ixheaacd_kbd_win120[120] = { + 0x00017b6e, 0x00042d2e, 0x000849d0, 0x000e3494, 0x00165efc, 0x002149bd, + 0x002f854b, 0x0041b235, 0x0058814f, 0x0074b3af, 0x00971a67, 0x00c0960d, + 0x00f21602, 0x012c9774, 0x01712428, 0x01c0d0f7, 0x021cbc12, 0x02860b04, + 0x02fde874, 0x038581b2, 0x041e040c, 0x04c899f3, 0x05866802, 0x065889d5, + 0x07400ed3, 0x083df6e8, 0x09532f37, 0x0a808ed0, 0x0bc6d380, 0x0d269eb0, + 0x0ea07270, 0x1034aeb5, 0x11e38ed2, 0x13ad2732, 0x1591636c, 0x179004a6, + 0x19a8a05f, 0x1bda9fa1, 0x1e253ea1, 0x20878cce, 0x23006d5d, 0x258e9847, + 0x28309bc5, 0x2ae4de3d, 0x2da9a0a7, 0x307d0162, 0x335cff71, 0x36477e1e, + 0x393a48f0, 0x3c3317f8, 0x3f2f945b, 0x422d5d17, 0x452a0bf2, 0x48233a80, + 0x4b16873d, 0x4e019a9c, 0x50e22c0a, 0x53b606ca, 0x567b0ea6, 0x592f445e, + 0x5bd0c9c5, 0x5e5de587, 0x60d50688, 0x6334c6d0, 0x657bedf8, 0x67a97316, + 0x69bc7e1d, 0x6bb468af, 0x6d90be60, 0x6f513c5f, 0x70f5d09a, 0x727e984c, + 0x73ebde0f, 0x753e1762, 0x7675e1cb, 0x7793ff86, 0x789953de, 0x7986df3d, + 0x7a5dbaff, 0x7b1f1524, 0x7bcc2be6, 0x7c664952, 0x7ceebeee, 0x7d66e18a, + 0x7dd0053a, 0x7e2b79a1, 0x7e7a8685, 0x7ebe68c3, 0x7ef84fb5, 0x7f295af3, + 0x7f529898, 0x7f7503f1, 0x7f918499, 0x7fa8ee08, 0x7fbbff80, 0x7fcb6458, + 0x7fd7b492, 0x7fe175b9, 0x7fe91bf2, 0x7fef0b3a, 0x7ff398ba, 0x7ff70c37, + 0x7ff9a17a, 0x7ffb89c1, 0x7ffced19, 0x7ffdebb1, 0x7ffe9f09, 0x7fff1b10, + 0x7fff6f1d, 0x7fffa6ce, 0x7fffcacb, 0x7fffe165, 0x7fffef23, 0x7ffff72c, + 0x7ffffbaa, 0x7ffffe0a, 0x7fffff35, 0x7fffffba, 0x7fffffed, 0x7ffffffc}; + +const WORD32 ixheaacd_kbd_win128[128] = { + 0x00017119, 0x0003e63e, 0x000791c4, 0x000cbf2b, 0x0013db7f, 0x001d3aa3, + 0x00295a6c, 0x0038b04a, 0x004bd33c, 0x006351de, 0x007fdc58, 0x00a21a71, + 0x00cacd17, 0x00fab53c, 0x0132b55d, 0x017396cf, 0x01be4cd7, 0x0213b9ef, + 0x0274d163, 0x02e28ed3, 0x035de58f, 0x03e7d133, 0x0481450f, 0x052b345f, + 0x05e6926f, 0x06b43957, 0x07950b97, 0x0889d27f, 0x09934eff, 0x0ab2313f, + 0x0be707df, 0x0d32591f, 0x0e9491ef, 0x100dfddf, 0x119ecf5f, 0x13471f7f, + 0x1506dd5f, 0x16dde79f, 0x18cbe1df, 0x1ad06fdf, 0x1ceaf25f, 0x1f1ab8df, + 0x215efa7f, 0x23b6aa3f, 0x2620bc3f, 0x289bf17f, 0x2b26f1bf, 0x2dc054ff, + 0x3066773f, 0x3317c5ff, 0x35d27c3f, 0x3894ccbf, 0x3b5cd8ff, 0x3e28baff, + 0x40f6727f, 0x43c408ff, 0x468f8e7f, 0x495703ff, 0x4c187a7f, 0x4ed2027f, + 0x5181be7f, 0x5425e0ff, 0x56bcb5ff, 0x5944997f, 0x5bbc09ff, 0x5e218dff, + 0x6073ddff, 0x62b1d4ff, 0x64da65ff, 0x66ecaeff, 0x68e7e5ff, 0x6acb857f, + 0x6c970f7f, 0x6e4a37ff, 0x6fe4d5ff, 0x7166f8ff, 0x72d0bb7f, 0x74225f7f, + 0x755c52ff, 0x767f1b7f, 0x778b4fff, 0x7881ba7f, 0x79632bff, 0x7a307eff, + 0x7aeab77f, 0x7b92c8ff, 0x7c29c77f, 0x7cb0d0ff, 0x7d28f17f, 0x7d933dff, + 0x7df0dc7f, 0x7e42d8ff, 0x7e8a3f7f, 0x7ec80c7f, 0x7efd3aff, 0x7f2ab67f, + 0x7f5160ff, 0x7f7203ff, 0x7f8d68ff, 0x7fa42eff, 0x7fb7067f, 0x7fc6757f, + 0x7fd3027f, 0x7fdd2aff, 0x7fe542ff, 0x7febaeff, 0x7ff0baff, 0x7ff4a97f, + 0x7ff7ad7f, 0x7ff9f87f, 0x7ffbac7f, 0x7ffcf3ff, 0x7ffde6ff, 0x7ffe8eff, + 0x7fff0c7f, 0x7fff607f, 0x7fff9b7f, 0x7fffbcff, 0x7fffd5ff, 0x7fffe6ff, + 0x7ffff77f, 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, + 0x7fffffff, 0x7fffffff}; + +const WORD32 kbd_win32[32] = { + 0x0002dec5, 0x001e8ba8, 0x00693bb0, 0x01097406, 0x02311ec3, 0x041af00f, + 0x0704b1f7, 0x0b274746, 0x10ad6b60, 0x17aaa83a, 0x2014320f, 0x29bd3b7d, + 0x3457df96, 0x3f7b02c1, 0x4aaca77c, 0x556f55f4, 0x5f508afc, 0x67f5d1a0, + 0x6f264993, 0x74ceee0d, 0x7900e380, 0x7bea421b, 0x7dcb051e, 0x7ee8ac51, + 0x7f835d29, 0x7fceb4af, 0x7fef248c, 0x7ffb3200, 0x7ffeecbc, 0x7fffd4bc, + 0x7ffffc59, 0x7ffffff6}; + +const WORD32 ixheaacd_kbd_win960[960] = { + 0x0009e6ab, 0x000e96d5, 0x0012987d, 0x001652b5, 0x0019ebce, 0x001d76bf, + 0x0020fe78, 0x002489ef, 0x00281de1, 0x002bbdbb, 0x002f6c0d, 0x00332ad8, + 0x0036fbb8, 0x003ae003, 0x003ed8d8, 0x0042e72f, 0x00470be3, 0x004b47b8, + 0x004f9b5e, 0x00540779, 0x00588ca0, 0x005d2b61, 0x0061e441, 0x0066b7c1, + 0x006ba65b, 0x0070b086, 0x0075d6b4, 0x007b1955, 0x008078d5, 0x0085f59f, + 0x008b901c, 0x009148b4, 0x00971fcb, 0x009d15c7, 0x00a32b0a, 0x00a95ff9, + 0x00afb4f3, 0x00b62a5c, 0x00bcc093, 0x00c377f8, 0x00ca50ea, 0x00d14bcb, + 0x00d868f7, 0x00dfa8cd, 0x00e70bad, 0x00ee91f3, 0x00f63bfe, 0x00fe0a2b, + 0x0105fcd8, 0x010e1462, 0x01165126, 0x011eb381, 0x01273bcf, 0x012fea6f, + 0x0138bfbb, 0x0141bc11, 0x014adfce, 0x01542b4c, 0x015d9ee9, 0x01673b00, + 0x0170ffee, 0x017aee0e, 0x018505bc, 0x018f4753, 0x0199b32f, 0x01a449ac, + 0x01af0b24, 0x01b9f7f3, 0x01c51074, 0x01d05501, 0x01dbc5f5, 0x01e763ab, + 0x01f32e7d, 0x01ff26c5, 0x020b4cdd, 0x0217a120, 0x022423e6, 0x0230d589, + 0x023db663, 0x024ac6cd, 0x02580720, 0x026577b3, 0x027318e0, 0x0280eaff, + 0x028eee67, 0x029d2371, 0x02ab8a74, 0x02ba23c6, 0x02c8efbf, 0x02d7eeb6, + 0x02e72101, 0x02f686f5, 0x030620e9, 0x0315ef31, 0x0325f223, 0x03362a14, + 0x03469757, 0x03573a42, 0x03681327, 0x0379225a, 0x038a682d, 0x039be4f4, + 0x03ad9900, 0x03bf84a3, 0x03d1a82e, 0x03e403f2, 0x03f69840, 0x04096567, + 0x041c6bb8, 0x042fab80, 0x0443250f, 0x0456d8b3, 0x046ac6ba, 0x047eef70, + 0x04935322, 0x04a7f21c, 0x04bcccab, 0x04d1e318, 0x04e735af, 0x04fcc4b9, + 0x05129080, 0x0528994d, 0x053edf67, 0x05556318, 0x056c24a5, 0x05832455, + 0x059a626e, 0x05b1df35, 0x05c99aef, 0x05e195e0, 0x05f9d04b, 0x06124a72, + 0x062b0499, 0x0643feff, 0x065d39e7, 0x0676b58f, 0x06907237, 0x06aa701d, + 0x06c4af7f, 0x06df309b, 0x06f9f3ad, 0x0714f8f0, 0x0730409f, 0x074bcaf4, + 0x07679829, 0x0783a876, 0x079ffc13, 0x07bc9337, 0x07d96e18, 0x07f68cec, + 0x0813efe7, 0x0831973c, 0x084f831f, 0x086db3c2, 0x088c2956, 0x08aae40b, + 0x08c9e411, 0x08e92996, 0x0908b4c9, 0x092885d5, 0x09489ce8, 0x0968fa2b, + 0x09899dca, 0x09aa87ed, 0x09cbb8bd, 0x09ed3061, 0x0a0eef00, 0x0a30f4bf, + 0x0a5341c2, 0x0a75d62d, 0x0a98b224, 0x0abbd5c7, 0x0adf4137, 0x0b02f494, + 0x0b26effc, 0x0b4b338e, 0x0b6fbf66, 0x0b94939f, 0x0bb9b055, 0x0bdf15a1, + 0x0c04c39c, 0x0c2aba5c, 0x0c50f9fa, 0x0c778289, 0x0c9e5420, 0x0cc56ed0, + 0x0cecd2ad, 0x0d147fc7, 0x0d3c7630, 0x0d64b5f5, 0x0d8d3f25, 0x0db611cd, + 0x0ddf2df9, 0x0e0893b3, 0x0e324306, 0x0e5c3bf9, 0x0e867e93, 0x0eb10add, + 0x0edbe0d9, 0x0f07008d, 0x0f3269fb, 0x0f5e1d26, 0x0f8a1a0d, 0x0fb660b0, + 0x0fe2f10e, 0x100fcb24, 0x103ceeed, 0x106a5c65, 0x10981385, 0x10c61446, + 0x10f45ea0, 0x1122f287, 0x1151cff2, 0x1180f6d4, 0x11b06720, 0x11e020c7, + 0x121023ba, 0x12406fe7, 0x1271053d, 0x12a1e3a8, 0x12d30b14, 0x13047b6c, + 0x13363497, 0x1368367e, 0x139a8108, 0x13cd141a, 0x13ffef99, 0x14331367, + 0x14667f67, 0x149a3378, 0x14ce2f7b, 0x1502734e, 0x1536fece, 0x156bd1d6, + 0x15a0ec41, 0x15d64de8, 0x160bf6a4, 0x1641e64b, 0x16781cb3, 0x16ae99b1, + 0x16e55d18, 0x171c66b9, 0x1753b666, 0x178b4bef, 0x17c32720, 0x17fb47c9, + 0x1833adb4, 0x186c58ad, 0x18a5487c, 0x18de7ceb, 0x1917f5c0, 0x1951b2c1, + 0x198bb3b3, 0x19c5f85a, 0x1a008076, 0x1a3b4bca, 0x1a765a16, 0x1ab1ab18, + 0x1aed3e8d, 0x1b291431, 0x1b652bc0, 0x1ba184f4, 0x1bde1f85, 0x1c1afb2b, + 0x1c58179b, 0x1c95748c, 0x1cd311b1, 0x1d10eebc, 0x1d4f0b5f, 0x1d8d674c, + 0x1dcc0230, 0x1e0adbba, 0x1e49f397, 0x1e894973, 0x1ec8dcf8, 0x1f08adcf, + 0x1f48bba2, 0x1f890617, 0x1fc98cd5, 0x200a4f80, 0x204b4dbc, 0x208c872b, + 0x20cdfb70, 0x210faa2b, 0x215192fb, 0x2193b57f, 0x21d61153, 0x2218a613, + 0x225b735c, 0x229e78c6, 0x22e1b5ea, 0x23252a61, 0x2368d5c1, 0x23acb79f, + 0x23f0cf91, 0x24351d29, 0x24799ffb, 0x24be5798, 0x25034391, 0x25486374, + 0x258db6d1, 0x25d33d34, 0x2618f62c, 0x265ee142, 0x26a4fe01, 0x26eb4bf4, + 0x2731caa2, 0x27787994, 0x27bf5850, 0x2806665b, 0x284da33b, 0x28950e73, + 0x28dca787, 0x29246df9, 0x296c6149, 0x29b480f9, 0x29fccc86, 0x2a454371, + 0x2a8de537, 0x2ad6b154, 0x2b1fa744, 0x2b68c683, 0x2bb20e8b, 0x2bfb7ed6, + 0x2c4516db, 0x2c8ed614, 0x2cd8bbf6, 0x2d22c7f9, 0x2d6cf992, 0x2db75036, + 0x2e01cb58, 0x2e4c6a6c, 0x2e972ce5, 0x2ee21234, 0x2f2d19cb, 0x2f78431a, + 0x2fc38d90, 0x300ef89d, 0x305a83ae, 0x30a62e33, 0x30f1f797, 0x313ddf48, + 0x3189e4b0, 0x31d6073c, 0x32224656, 0x326ea167, 0x32bb17da, 0x3307a916, + 0x33545485, 0x33a1198d, 0x33edf797, 0x343aee08, 0x3487fc48, 0x34d521ba, + 0x35225dc6, 0x356fafcf, 0x35bd1739, 0x360a9368, 0x365823c0, 0x36a5c7a3, + 0x36f37e74, 0x37414795, 0x378f2267, 0x37dd0e4b, 0x382b0aa3, 0x387916cf, + 0x38c7322f, 0x39155c23, 0x3963940b, 0x39b1d945, 0x3a002b30, 0x3a4e892c, + 0x3a9cf295, 0x3aeb66cb, 0x3b39e52b, 0x3b886d13, 0x3bd6fde0, 0x3c2596f0, + 0x3c74379e, 0x3cc2df48, 0x3d118d4b, 0x3d604102, 0x3daef9cb, 0x3dfdb701, + 0x3e4c77ff, 0x3e9b3c24, 0x3eea02c9, 0x3f38cb4a, 0x3f879504, 0x3fd65f52, + 0x4025298f, 0x4073f317, 0x40c2bb45, 0x41118175, 0x41604503, 0x41af0549, + 0x41fdc1a4, 0x424c796f, 0x429b2c05, 0x42e9d8c3, 0x43387f04, 0x43871e25, + 0x43d5b580, 0x44244473, 0x4472ca59, 0x44c1468f, 0x450fb872, 0x455e1f5e, + 0x45ac7ab1, 0x45fac9c7, 0x46490bfe, 0x469740b4, 0x46e56746, 0x47337f12, + 0x47818778, 0x47cf7fd5, 0x481d6789, 0x486b3df2, 0x48b90271, 0x4906b465, + 0x4954532f, 0x49a1de2f, 0x49ef54c7, 0x4a3cb656, 0x4a8a0241, 0x4ad737e7, + 0x4b2456ad, 0x4b715df6, 0x4bbe4d24, 0x4c0b239b, 0x4c57e0c1, 0x4ca483f9, + 0x4cf10caa, 0x4d3d7a3a, 0x4d89cc0e, 0x4dd6018d, 0x4e221a20, 0x4e6e152f, + 0x4eb9f221, 0x4f05b060, 0x4f514f56, 0x4f9cce6e, 0x4fe82d12, 0x50336aae, + 0x507e86af, 0x50c98080, 0x51145791, 0x515f0b50, 0x51a99b2a, 0x51f40691, + 0x523e4cf3, 0x52886dc4, 0x52d26874, 0x531c3c75, 0x5365e93d, 0x53af6e3d, + 0x53f8caec, 0x5441febf, 0x548b092d, 0x54d3e9ac, 0x551c9fb6, 0x55652ac2, + 0x55ad8a4b, 0x55f5bdcc, 0x563dc4bf, 0x56859ea2, 0x56cd4af1, 0x5714c92b, + 0x575c18cf, 0x57a3395d, 0x57ea2a55, 0x5830eb39, 0x58777b8d, 0x58bddad4, + 0x59040892, 0x594a044d, 0x598fcd8d, 0x59d563d8, 0x5a1ac6b7, 0x5a5ff5b4, + 0x5aa4f059, 0x5ae9b632, 0x5b2e46cc, 0x5b72a1b5, 0x5bb6c67b, 0x5bfab4ad, + 0x5c3e6bde, 0x5c81eb9f, 0x5cc53382, 0x5d08431d, 0x5d4b1a04, 0x5d8db7ce, + 0x5dd01c12, 0x5e124669, 0x5e54366c, 0x5e95ebb7, 0x5ed765e4, 0x5f18a493, + 0x5f59a75f, 0x5f9a6dea, 0x5fdaf7d4, 0x601b44be, 0x605b544b, 0x609b2620, + 0x60dab9e2, 0x611a0f37, 0x615925c8, 0x6197fd3d, 0x61d69540, 0x6214ed7c, + 0x6253059f, 0x6290dd56, 0x62ce7450, 0x630bca3d, 0x6348ded0, 0x6385b1ba, + 0x63c242b1, 0x63fe9168, 0x643a9d98, 0x647666f7, 0x64b1ed3e, 0x64ed3029, + 0x65282f73, 0x6562ead9, 0x659d6218, 0x65d794f1, 0x66118325, 0x664b2c75, + 0x668490a5, 0x66bdaf79, 0x66f688b9, 0x672f1c2a, 0x67676995, 0x679f70c5, + 0x67d73185, 0x680eaba2, 0x6845dee8, 0x687ccb28, 0x68b37031, 0x68e9cdd7, + 0x691fe3eb, 0x6955b242, 0x698b38b3, 0x69c07713, 0x69f56d3d, 0x6a2a1b09, + 0x6a5e8052, 0x6a929cf5, 0x6ac670d0, 0x6af9fbc1, 0x6b2d3da9, 0x6b60366b, + 0x6b92e5e7, 0x6bc54c04, 0x6bf768a7, 0x6c293bb7, 0x6c5ac51b, 0x6c8c04be, + 0x6cbcfa8b, 0x6ceda66e, 0x6d1e0854, 0x6d4e202c, 0x6d7dede7, 0x6dad7176, + 0x6ddcaacb, 0x6e0b99db, 0x6e3a3e9c, 0x6e689903, 0x6e96a90a, 0x6ec46ea8, + 0x6ef1e9d9, 0x6f1f1a99, 0x6f4c00e4, 0x6f789cb9, 0x6fa4ee19, 0x6fd0f502, + 0x6ffcb179, 0x70282380, 0x70534b1c, 0x707e2853, 0x70a8bb2d, 0x70d303b1, + 0x70fd01e9, 0x7126b5e1, 0x71501fa5, 0x71793f41, 0x71a214c5, 0x71caa040, + 0x71f2e1c4, 0x721ad962, 0x7242872f, 0x7269eb3e, 0x729105a5, 0x72b7d67c, + 0x72de5dda, 0x73049bd9, 0x732a9094, 0x73503c25, 0x73759eaa, 0x739ab840, + 0x73bf8908, 0x73e4111f, 0x740850a9, 0x742c47c8, 0x744ff69e, 0x74735d50, + 0x74967c04, 0x74b952e1, 0x74dbe20f, 0x74fe29b6, 0x75202a00, 0x7541e319, + 0x7563552c, 0x75848066, 0x75a564f5, 0x75c60308, 0x75e65ad0, 0x76066c7d, + 0x76263841, 0x7645be50, 0x7664fedc, 0x7683fa1c, 0x76a2b045, 0x76c1218e, + 0x76df4e2e, 0x76fd365f, 0x771ada59, 0x77383a56, 0x77555694, 0x77722f4d, + 0x778ec4be, 0x77ab1726, 0x77c726c3, 0x77e2f3d5, 0x77fe7e9d, 0x7819c75b, + 0x7834ce51, 0x784f93c3, 0x786a17f4, 0x78845b28, 0x789e5da5, 0x78b81fb0, + 0x78d1a190, 0x78eae38c, 0x7903e5ed, 0x791ca8fb, 0x79352d00, 0x794d7246, + 0x79657917, 0x797d41c0, 0x7994cc8b, 0x79ac19c8, 0x79c329c1, 0x79d9fcc6, + 0x79f09325, 0x7a06ed2e, 0x7a1d0b2f, 0x7a32ed7a, 0x7a489460, 0x7a5e0031, + 0x7a733141, 0x7a8827e0, 0x7a9ce463, 0x7ab1671d, 0x7ac5b061, 0x7ad9c085, + 0x7aed97dd, 0x7b0136bf, 0x7b149d81, 0x7b27cc78, 0x7b3ac3fb, 0x7b4d8462, + 0x7b600e03, 0x7b726138, 0x7b847e57, 0x7b9665b9, 0x7ba817b8, 0x7bb994ac, + 0x7bcadcef, 0x7bdbf0db, 0x7becd0ca, 0x7bfd7d17, 0x7c0df61b, 0x7c1e3c32, + 0x7c2e4fb8, 0x7c3e3107, 0x7c4de07b, 0x7c5d5e70, 0x7c6cab42, 0x7c7bc74d, + 0x7c8ab2ee, 0x7c996e82, 0x7ca7fa64, 0x7cb656f1, 0x7cc48488, 0x7cd28384, + 0x7ce05444, 0x7cedf723, 0x7cfb6c80, 0x7d08b4b9, 0x7d15d02a, 0x7d22bf31, + 0x7d2f822c, 0x7d3c1978, 0x7d488573, 0x7d54c67a, 0x7d60dcec, 0x7d6cc925, + 0x7d788b84, 0x7d842466, 0x7d8f9427, 0x7d9adb27, 0x7da5f9c2, 0x7db0f055, + 0x7dbbbf3d, 0x7dc666d8, 0x7dd0e782, 0x7ddb4199, 0x7de57578, 0x7def837d, + 0x7df96c03, 0x7e032f68, 0x7e0cce07, 0x7e16483c, 0x7e1f9e62, 0x7e28d0d5, + 0x7e31dff1, 0x7e3acc0f, 0x7e43958c, 0x7e4c3cc2, 0x7e54c20a, 0x7e5d25bf, + 0x7e65683b, 0x7e6d89d7, 0x7e758aed, 0x7e7d6bd5, 0x7e852ce7, 0x7e8cce7d, + 0x7e9450ee, 0x7e9bb492, 0x7ea2f9c1, 0x7eaa20d0, 0x7eb12a17, 0x7eb815ec, + 0x7ebee4a5, 0x7ec59697, 0x7ecc2c19, 0x7ed2a57d, 0x7ed90319, 0x7edf4541, + 0x7ee56c49, 0x7eeb7882, 0x7ef16a41, 0x7ef741d7, 0x7efcff97, 0x7f02a3d1, + 0x7f082ed7, 0x7f0da0f9, 0x7f12fa87, 0x7f183bd2, 0x7f1d6527, 0x7f2276d6, + 0x7f27712d, 0x7f2c5479, 0x7f312109, 0x7f35d727, 0x7f3a7721, 0x7f3f0143, + 0x7f4375d7, 0x7f47d528, 0x7f4c1f81, 0x7f50552b, 0x7f54766f, 0x7f588396, + 0x7f5c7ce7, 0x7f6062ab, 0x7f643528, 0x7f67f4a4, 0x7f6ba167, 0x7f6f3bb4, + 0x7f72c3d1, 0x7f763a01, 0x7f799e8a, 0x7f7cf1ac, 0x7f8033ad, 0x7f8364cc, + 0x7f86854c, 0x7f89956d, 0x7f8c9570, 0x7f8f8594, 0x7f926619, 0x7f95373d, + 0x7f97f93d, 0x7f9aac58, 0x7f9d50ca, 0x7f9fe6d0, 0x7fa26ea4, 0x7fa4e882, + 0x7fa754a5, 0x7fa9b346, 0x7fac049e, 0x7fae48e7, 0x7fb08058, 0x7fb2ab29, + 0x7fb4c991, 0x7fb6dbc6, 0x7fb8e1fe, 0x7fbadc6e, 0x7fbccb4b, 0x7fbeaec8, + 0x7fc0871a, 0x7fc25472, 0x7fc41704, 0x7fc5cf00, 0x7fc77c98, 0x7fc91ffd, + 0x7fcab95e, 0x7fcc48eb, 0x7fcdced2, 0x7fcf4b42, 0x7fd0be68, 0x7fd22872, + 0x7fd3898b, 0x7fd4e1e0, 0x7fd6319c, 0x7fd778ea, 0x7fd8b7f4, 0x7fd9eee4, + 0x7fdb1de2, 0x7fdc4518, 0x7fdd64ad, 0x7fde7cc9, 0x7fdf8d93, 0x7fe09731, + 0x7fe199c9, 0x7fe29580, 0x7fe38a7b, 0x7fe478de, 0x7fe560cc, 0x7fe6426a, + 0x7fe71dda, 0x7fe7f33d, 0x7fe8c2b5, 0x7fe98c64, 0x7fea506a, 0x7feb0ee6, + 0x7febc7fa, 0x7fec7bc3, 0x7fed2a60, 0x7fedd3ef, 0x7fee788f, 0x7fef185b, + 0x7fefb371, 0x7ff049ed, 0x7ff0dbeb, 0x7ff16985, 0x7ff1f2d6, 0x7ff277f9, + 0x7ff2f908, 0x7ff3761c, 0x7ff3ef4d, 0x7ff464b5, 0x7ff4d66c, 0x7ff54488, + 0x7ff5af22, 0x7ff61650, 0x7ff67a28, 0x7ff6dac0, 0x7ff7382e, 0x7ff79287, + 0x7ff7e9df, 0x7ff83e4c, 0x7ff88fe0, 0x7ff8deb0, 0x7ff92ace, 0x7ff9744d, + 0x7ff9bb3f, 0x7ff9ffb8, 0x7ffa41c7, 0x7ffa817f, 0x7ffabef0, 0x7ffafa2b, + 0x7ffb3341, 0x7ffb6a40, 0x7ffb9f38, 0x7ffbd23a, 0x7ffc0353, 0x7ffc3292, + 0x7ffc6005, 0x7ffc8bba, 0x7ffcb5bf, 0x7ffcde21, 0x7ffd04ed, 0x7ffd2a30, + 0x7ffd4df5, 0x7ffd704a, 0x7ffd9139, 0x7ffdb0cf, 0x7ffdcf16, 0x7ffdec19, + 0x7ffe07e4, 0x7ffe2280, 0x7ffe3bf8, 0x7ffe5456, 0x7ffe6ba3, 0x7ffe81e8, + 0x7ffe9730, 0x7ffeab82, 0x7ffebee7, 0x7ffed169, 0x7ffee30e, 0x7ffef3e0, + 0x7fff03e5, 0x7fff1326, 0x7fff21aa, 0x7fff2f78, 0x7fff3c96, 0x7fff490d, + 0x7fff54e1, 0x7fff601a, 0x7fff6abe, 0x7fff74d3, 0x7fff7e5e, 0x7fff8765, + 0x7fff8fee, 0x7fff97fe, 0x7fff9f9b, 0x7fffa6c8, 0x7fffad8b, 0x7fffb3e9, + 0x7fffb9e5, 0x7fffbf85, 0x7fffc4cd, 0x7fffc9c0, 0x7fffce64, 0x7fffd2ba, + 0x7fffd6c8, 0x7fffda90, 0x7fffde16, 0x7fffe15e, 0x7fffe46a, 0x7fffe73d, + 0x7fffe9db, 0x7fffec47, 0x7fffee82, 0x7ffff091, 0x7ffff274, 0x7ffff42f, + 0x7ffff5c4, 0x7ffff736, 0x7ffff885, 0x7ffff9b5, 0x7ffffac7, 0x7ffffbbe, + 0x7ffffc9a, 0x7ffffd5f, 0x7ffffe0c, 0x7ffffea5, 0x7fffff2a, 0x7fffff9c}; + +const WORD32 ixheaacd_kbd_win1024[1024] = { + 0x000999dc, 0x000e1719, 0x0011ec91, 0x00157689, 0x0018def4, 0x001c3697, + 0x001f85d7, 0x0022d516, 0x00262cba, 0x00298cc1, 0x002cf52b, 0x00306e5c, + 0x0033f854, 0x00379314, 0x003b3636, 0x003ef283, 0x0042bf97, 0x0046a5d6, + 0x004a9478, 0x004ea4a8, 0x0052c59f, 0x0056f75d, 0x005b4245, 0x005fa658, + 0x00642395, 0x0068b19a, 0x006d58c8, 0x00722185, 0x0076fb08, 0x007bedb6, + 0x0080f98f, 0x00861e92, 0x008b5cbf, 0x0090bc7a, 0x00963560, 0x009bc770, + 0x00a172ab, 0x00a73710, 0x00ad1d03, 0x00b31c21, 0x00b93ccc, 0x00bf76a2, + 0x00c5c9a2, 0x00cc4694, 0x00d2d44d, 0x00d98393, 0x00e05468, 0x00e746cb, + 0x00ee5258, 0x00f57f72, 0x00fcce1b, 0x01043e53, 0x010bc7b3, 0x01137b07, + 0x011b4783, 0x0123358f, 0x012b4527, 0x01337eb1, 0x013bd167, 0x014445a9, + 0x014ce3dd, 0x0155a39f, 0x015e84ef, 0x016787cd, 0x0170b49d, 0x0179fa97, + 0x018372e5, 0x018d045f, 0x0196bfc9, 0x01a09cc3, 0x01aaa3ad, 0x01b4d487, + 0x01bf26f1, 0x01c99ae9, 0x01d44135, 0x01df090f, 0x01e9f277, 0x01f50e33, + 0x02004b7f, 0x020bb2bb, 0x02173b83, 0x0222f6a3, 0x022ed353, 0x023ae253, + 0x024712e3, 0x025375c7, 0x025ffa3b, 0x026cb103, 0x02798957, 0x02869403, + 0x0293c89f, 0x02a12f8f, 0x02aeb80f, 0x02bc72e3, 0x02ca57a7, 0x02d8665f, + 0x02e6a767, 0x02f51267, 0x0303afb7, 0x031276fb, 0x0321682f, 0x0330941b, + 0x033fe197, 0x034f69cb, 0x035f1bef, 0x036ef803, 0x037f0ed3, 0x038f4f93, + 0x039fc2a7, 0x03b05faf, 0x03c1376b, 0x03d2391b, 0x03e36d23, 0x03f4dbdf, + 0x0406748f, 0x04183f8f, 0x042a3ce7, 0x043c6c97, 0x044ece97, 0x04616b57, + 0x047431ff, 0x04873367, 0x049a671f, 0x04adcd2f, 0x04c1658f, 0x04d538af, + 0x04e935b7, 0x04fd75df, 0x0511dfff, 0x052684cf, 0x053b6457, 0x05506dd7, + 0x0565ba6f, 0x057b395f, 0x0590ea9f, 0x05a6d697, 0x05bcf4e7, 0x05d34def, + 0x05e9e1af, 0x0600b027, 0x0617b0f7, 0x062ee417, 0x06465a57, 0x065e02e7, + 0x0675e637, 0x068e0437, 0x06a65cf7, 0x06bef067, 0x06d7b637, 0x06f0b6b7, + 0x0709fa57, 0x07237047, 0x073d20ef, 0x07570c57, 0x07713ad7, 0x078b9ba7, + 0x07a63737, 0x07c10d77, 0x07dc26df, 0x07f77af7, 0x0813015f, 0x082ecaef, + 0x084acf2f, 0x0867168f, 0x0883903f, 0x08a04d0f, 0x08bd449f, 0x08da76df, + 0x08f7ec2f, 0x09159c4f, 0x0933870f, 0x0951b4ff, 0x0970153f, 0x098ec0ff, + 0x09ad9f0f, 0x09ccc02f, 0x09ec247f, 0x0a0bc37f, 0x0a2b9d3f, 0x0a4bba0f, + 0x0a6c19ff, 0x0a8cac4f, 0x0aad8a0f, 0x0acea28f, 0x0aeff5bf, 0x0b118c1f, + 0x0b335d1f, 0x0b55714f, 0x0b77c88f, 0x0b9a5a8f, 0x0bbd2f9f, 0x0be03f6f, + 0x0c03925f, 0x0c27285f, 0x0c4af91f, 0x0c6f0cff, 0x0c9363ef, 0x0cb7f59f, + 0x0cdcca6f, 0x0d01e25f, 0x0d2734ff, 0x0d4ccaaf, 0x0d729b2f, 0x0d98b71f, + 0x0dbf0dbf, 0x0de59f2f, 0x0e0c7c0f, 0x0e3393af, 0x0e5aee5f, 0x0e8283cf, + 0x0eaa64bf, 0x0ed2806f, 0x0efad6cf, 0x0f2378af, 0x0f4c553f, 0x0f7574ef, + 0x0f9ecf5f, 0x0fc8754f, 0x0ff255ef, 0x101c79bf, 0x1046d81f, 0x107179bf, + 0x109c5e5f, 0x10c7863f, 0x10f2e8bf, 0x111e8e5f, 0x114a771f, 0x1176a2ff, + 0x11a3097f, 0x11cfb33f, 0x11fc979f, 0x1229c77f, 0x125729bf, 0x1284d75f, + 0x12b2bfdf, 0x12e0eb5f, 0x130f5a1f, 0x133e037f, 0x136ce77f, 0x139c171f, + 0x13cb817f, 0x13fb267f, 0x142b0e9f, 0x145b39df, 0x148b9fdf, 0x14bc48ff, + 0x14ed2cbf, 0x151e539f, 0x154fbd9f, 0x158159ff, 0x15b341df, 0x15e55bff, + 0x1617c1bf, 0x164a59bf, 0x167d34df, 0x16b0531f, 0x16e3a39f, 0x17173fbf, + 0x174b0e1f, 0x177f1f9f, 0x17b36bdf, 0x17e7f2bf, 0x181cbcbf, 0x1851c19f, + 0x1887011f, 0x18bc7b3f, 0x18f2389f, 0x1928309f, 0x195e5aff, 0x1994c87f, + 0x19cb709f, 0x1a02539f, 0x1a39713f, 0x1a70d1ff, 0x1aa864ff, 0x1ae032df, + 0x1b183b5f, 0x1b507e9f, 0x1b88fc9f, 0x1bc1acdf, 0x1bfaa03f, 0x1c33c5ff, + 0x1c6d267f, 0x1ca6c19f, 0x1ce0977f, 0x1d1a9fbf, 0x1d54e2bf, 0x1d8f57ff, + 0x1dca105f, 0x1e04f29f, 0x1e40181f, 0x1e7b677f, 0x1eb6f9ff, 0x1ef2b65f, + 0x1f2ead9f, 0x1f6adf7f, 0x1fa73b3f, 0x1fe3d1bf, 0x2020a2ff, 0x205d9e3f, + 0x209ad43f, 0x20d83c7f, 0x2115d6ff, 0x2153a3ff, 0x2191a33f, 0x21cfd4bf, + 0x220e38bf, 0x224cceff, 0x228b977f, 0x22ca923f, 0x2309bf7f, 0x234916bf, + 0x2388a03f, 0x23c85c3f, 0x240841ff, 0x244859ff, 0x2488a47f, 0x24c918ff, + 0x2509bf7f, 0x254a903f, 0x258b8aff, 0x25ccb7bf, 0x260e0ebf, 0x264f8f7f, + 0x269142bf, 0x26d31fbf, 0x27151e7f, 0x27574f7f, 0x2799aa7f, 0x27dc2f3f, + 0x281eddff, 0x2861b6bf, 0x28a4b13f, 0x28e7ddbf, 0x292b2bff, 0x296ea43f, + 0x29b23dbf, 0x29f6017f, 0x2a39eeff, 0x2a7dfe3f, 0x2ac2373f, 0x2b0691ff, + 0x2b4b0dff, 0x2b8fb43f, 0x2bd4737f, 0x2c195cbf, 0x2c5e6fff, 0x2ca39c3f, + 0x2ce8ea3f, 0x2d2e61ff, 0x2d73f2ff, 0x2db9a5bf, 0x2dff79bf, 0x2e4566ff, + 0x2e8b7e3f, 0x2ed1aebf, 0x2f1800bf, 0x2f5e6bbf, 0x2fa4efff, 0x2feb9e3f, + 0x30325d3f, 0x30793dbf, 0x30c0377f, 0x31074a7f, 0x314e7eff, 0x3195cc7f, + 0x31dd2aff, 0x3224aabf, 0x326c3b7f, 0x32b3edbf, 0x32fbb0ff, 0x33438cff, + 0x338b827f, 0x33d388bf, 0x341ba7ff, 0x3463d7ff, 0x34ac213f, 0x34f483bf, + 0x353cee7f, 0x3585727f, 0x35ce073f, 0x3616b53f, 0x365f6bbf, 0x36a832bf, + 0x36f112ff, 0x3739fbbf, 0x3782f4ff, 0x37cbff3f, 0x38151a3f, 0x385e3dbf, + 0x38a77a3f, 0x38f0b6bf, 0x393a03ff, 0x398361ff, 0x39ccc87f, 0x3a16377f, + 0x3a5faebf, 0x3aa936bf, 0x3af2bebf, 0x3b3c577f, 0x3b85f8bf, 0x3bcfa27f, + 0x3c194bff, 0x3c63063f, 0x3cacc0bf, 0x3cf6837f, 0x3d40463f, 0x3d8a117f, + 0x3dd3e4ff, 0x3e1db87f, 0x3e678bff, 0x3eb167ff, 0x3efb3b7f, 0x3f45177f, + 0x3f8efbbf, 0x3fd8d77f, 0x4022b37f, 0x406c8f7f, 0x40b66b7f, 0x4100477f, + 0x414a1aff, 0x4193f6ff, 0x41ddc1ff, 0x4227957f, 0x4271607f, 0x42bb237f, + 0x4304e5ff, 0x434ea07f, 0x4398527f, 0x43e1fbff, 0x442ba57f, 0x44753e7f, + 0x44beceff, 0x45085f7f, 0x4551deff, 0x459b55ff, 0x45e4c4ff, 0x462e22ff, + 0x4677817f, 0x46c0c5ff, 0x470a027f, 0x475336ff, 0x479c59ff, 0x47e56cff, + 0x482e6e7f, 0x487767ff, 0x48c0487f, 0x49091fff, 0x4951e77f, 0x499a9d7f, + 0x49e33aff, 0x4a2bc6ff, 0x4a744aff, 0x4abcad7f, 0x4b05077f, 0x4b4d487f, + 0x4b956fff, 0x4bdd86ff, 0x4c2584ff, 0x4c6d71ff, 0x4cb545ff, 0x4cfd007f, + 0x4d44a1ff, 0x4d8c327f, 0x4dd3a1ff, 0x4e1af7ff, 0x4e62347f, 0x4ea9587f, + 0x4ef062ff, 0x4f3753ff, 0x4f7e23ff, 0x4fc4da7f, 0x500b77ff, 0x5051f3ff, + 0x50984dff, 0x50de8f7f, 0x5124aeff, 0x516ab57f, 0x51b09a7f, 0x51f6557f, + 0x523bff7f, 0x52817fff, 0x52c6de7f, 0x530c1b7f, 0x535136ff, 0x539630ff, + 0x53db017f, 0x541fafff, 0x546444ff, 0x54a8a7ff, 0x54ece97f, 0x5531097f, + 0x5574ff7f, 0x55b8d3ff, 0x55fc7e7f, 0x5640077f, 0x56835dff, 0x56c692ff, + 0x57099dff, 0x574c877f, 0x578f3eff, 0x57d1cbff, 0x58142f7f, 0x585670ff, + 0x5898807f, 0x58da65ff, 0x591c18ff, 0x595daaff, 0x599f09ff, 0x59e03f7f, + 0x5a21427f, 0x5a621b7f, 0x5aa2ca7f, 0x5ae3477f, 0x5b2391ff, 0x5b63b27f, + 0x5ba3a07f, 0x5be3647f, 0x5c22ee7f, 0x5c624dff, 0x5ca17aff, 0x5ce075ff, + 0x5d1f46ff, 0x5d5ddcff, 0x5d9c40ff, 0x5dda727f, 0x5e187a7f, 0x5e5646ff, + 0x5e93e1ff, 0x5ed1417f, 0x5f0e777f, 0x5f4b72ff, 0x5f883b7f, 0x5fc4d1ff, + 0x60012dff, 0x603d577f, 0x607945ff, 0x60b5027f, 0x60f0847f, 0x612bd3ff, + 0x6166e87f, 0x61a1caff, 0x61dc727f, 0x6216deff, 0x6251117f, 0x628b117f, + 0x62c4d67f, 0x62fe68ff, 0x6337b8ff, 0x6370cdff, 0x63a9b07f, 0x63e2587f, + 0x641abcff, 0x6452ef7f, 0x648ae77f, 0x64c29bff, 0x64fa1dff, 0x65315d7f, + 0x65686a7f, 0x659f33ff, 0x65d5c2ff, 0x660c177f, 0x664230ff, 0x6678077f, + 0x66ada2ff, 0x66e3047f, 0x67182a7f, 0x674d0dff, 0x6781b67f, 0x67b61b7f, + 0x67ea4e7f, 0x681e367f, 0x6851eb7f, 0x68855d7f, 0x68b88c7f, 0x68eb80ff, + 0x691e31ff, 0x6950a87f, 0x6982dbff, 0x69b4d47f, 0x69e6927f, 0x6a1804ff, + 0x6a493c7f, 0x6a7a397f, 0x6aaaf37f, 0x6adb69ff, 0x6b0ba5ff, 0x6b3b9eff, + 0x6b6b54ff, 0x6b9ac77f, 0x6bc9ff7f, 0x6bf8f47f, 0x6c27ae7f, 0x6c56257f, + 0x6c84597f, 0x6cb24a7f, 0x6ce0007f, 0x6d0d6aff, 0x6d3a9aff, 0x6d678fff, + 0x6d9439ff, 0x6dc0a8ff, 0x6decd47f, 0x6e18bd7f, 0x6e446b7f, 0x6e6fcdff, + 0x6e9af57f, 0x6ec5da7f, 0x6ef07bff, 0x6f1ae2ff, 0x6f44fdff, 0x6f6edeff, + 0x6f987c7f, 0x6fc1d6ff, 0x6feaf67f, 0x7013d2ff, 0x703c63ff, 0x7064ba7f, + 0x708cd5ff, 0x70b4a67f, 0x70dc3bff, 0x71038dff, 0x712a9d7f, 0x7151697f, + 0x7177faff, 0x719e40ff, 0x71c44bff, 0x71ea1c7f, 0x720fa17f, 0x7234eb7f, + 0x7259f27f, 0x727eb67f, 0x72a33fff, 0x72c785ff, 0x72eb897f, 0x730f517f, + 0x7332d6ff, 0x735618ff, 0x737917ff, 0x739bdc7f, 0x73be65ff, 0x73e0a3ff, + 0x7402a77f, 0x74246fff, 0x7445f57f, 0x746737ff, 0x74883fff, 0x74a9047f, + 0x74c98e7f, 0x74e9d4ff, 0x7509e0ff, 0x7529a9ff, 0x7549387f, 0x75688bff, + 0x75879c7f, 0x75a6697f, 0x75c4fbff, 0x75e353ff, 0x760170ff, 0x761f4aff, + 0x763cea7f, 0x765a467f, 0x767767ff, 0x76944eff, 0x76b0faff, 0x76cd6bff, + 0x76e99a7f, 0x7705967f, 0x77214eff, 0x773cccff, 0x7758107f, 0x7773107f, + 0x778dde7f, 0x77a8717f, 0x77c2c9ff, 0x77dce7ff, 0x77f6c27f, 0x78106a7f, + 0x7829d87f, 0x78430aff, 0x785c0b7f, 0x7874c8ff, 0x788d53ff, 0x78a5a47f, + 0x78bdb9ff, 0x78d594ff, 0x78ed3d7f, 0x7904ab7f, 0x791be6ff, 0x7932df7f, + 0x7949adff, 0x796038ff, 0x79769a7f, 0x798cb8ff, 0x79a2acff, 0x79b85e7f, + 0x79cde5ff, 0x79e3327f, 0x79f84c7f, 0x7a0d2bff, 0x7a21d97f, 0x7a36547f, + 0x7a4a947f, 0x7a5eaa7f, 0x7a7285ff, 0x7a862f7f, 0x7a99ae7f, 0x7aacf2ff, + 0x7ac004ff, 0x7ad2e4ff, 0x7ae5927f, 0x7af80dff, 0x7b0a567f, 0x7b1c6cff, + 0x7b2e597f, 0x7b400b7f, 0x7b51937f, 0x7b62f17f, 0x7b74147f, 0x7b850dff, + 0x7b95d4ff, 0x7ba671ff, 0x7bb6dc7f, 0x7bc71d7f, 0x7bd72bff, 0x7be707ff, + 0x7bf6b9ff, 0x7c0641ff, 0x7c15a07f, 0x7c24cc7f, 0x7c33ce7f, 0x7c429dff, + 0x7c514bff, 0x7c5fc7ff, 0x7c6e197f, 0x7c7c417f, 0x7c8a3f7f, 0x7c980aff, + 0x7ca5b4ff, 0x7cb3357f, 0x7cc08b7f, 0x7ccdb77f, 0x7cdab9ff, 0x7ce79a7f, + 0x7cf448ff, 0x7d00d5ff, 0x7d0d38ff, 0x7d1979ff, 0x7d25917f, 0x7d317eff, + 0x7d3d427f, 0x7d48e47f, 0x7d5464ff, 0x7d5fbb7f, 0x7d6aefff, 0x7d75faff, + 0x7d80e47f, 0x7d8bac7f, 0x7d964a7f, 0x7da0c67f, 0x7dab217f, 0x7db55aff, + 0x7dbf69ff, 0x7dc95fff, 0x7dd32c7f, 0x7ddcdf7f, 0x7de6687f, 0x7defcfff, + 0x7df91e7f, 0x7e0242ff, 0x7e0b4dff, 0x7e1437ff, 0x7e1cffff, 0x7e25aeff, + 0x7e2e33ff, 0x7e369fff, 0x7e3ef27f, 0x7e471b7f, 0x7e4f2aff, 0x7e57217f, + 0x7e5ef5ff, 0x7e66b1ff, 0x7e6e4bff, 0x7e75ccff, 0x7e7d2c7f, 0x7e8472ff, + 0x7e8b9fff, 0x7e92ab7f, 0x7e99a5ff, 0x7ea07f7f, 0x7ea73f7f, 0x7eadddff, + 0x7eb46b7f, 0x7ebadfff, 0x7ec132ff, 0x7ec7757f, 0x7ecd95ff, 0x7ed3a5ff, + 0x7ed99c7f, 0x7edf7a7f, 0x7ee53e7f, 0x7eeae9ff, 0x7ef07bff, 0x7ef5fd7f, + 0x7efb657f, 0x7f00b47f, 0x7f05f27f, 0x7f0b177f, 0x7f10237f, 0x7f151e7f, + 0x7f1a007f, 0x7f1ed17f, 0x7f2391ff, 0x7f2838ff, 0x7f2cc6ff, 0x7f31447f, + 0x7f35b07f, 0x7f3a0c7f, 0x7f3e4eff, 0x7f42807f, 0x7f46997f, 0x7f4aa97f, + 0x7f4ea07f, 0x7f52867f, 0x7f565bff, 0x7f5a20ff, 0x7f5dd4ff, 0x7f6177ff, + 0x7f650a7f, 0x7f688bff, 0x7f6bfc7f, 0x7f6f547f, 0x7f72abff, 0x7f75ea7f, + 0x7f7917ff, 0x7f7c34ff, 0x7f7f497f, 0x7f824d7f, 0x7f85407f, 0x7f882aff, + 0x7f8afc7f, 0x7f8dc57f, 0x7f9085ff, 0x7f9335ff, 0x7f95d4ff, 0x7f9862ff, + 0x7f9ae8ff, 0x7f9d667f, 0x7f9fd37f, 0x7fa22f7f, 0x7fa482ff, 0x7fa6cdff, + 0x7fa9087f, 0x7fab3a7f, 0x7fad5bff, 0x7faf74ff, 0x7fb1857f, 0x7fb384ff, + 0x7fb5847f, 0x7fb76aff, 0x7fb951ff, 0x7fbb277f, 0x7fbcf4ff, 0x7fbeb9ff, + 0x7fc0767f, 0x7fc22a7f, 0x7fc3cdff, 0x7fc5717f, 0x7fc703ff, 0x7fc88e7f, + 0x7fca107f, 0x7fcb91ff, 0x7fcd037f, 0x7fce6bff, 0x7fcfcc7f, 0x7fd1247f, + 0x7fd273ff, 0x7fd3c37f, 0x7fd501ff, 0x7fd6387f, 0x7fd76eff, 0x7fd89cff, + 0x7fd9c27f, 0x7fdadf7f, 0x7fdbf47f, 0x7fdd00ff, 0x7fde0d7f, 0x7fdf117f, + 0x7fe00cff, 0x7fe1007f, 0x7fe1f37f, 0x7fe2de7f, 0x7fe3c0ff, 0x7fe49aff, + 0x7fe574ff, 0x7fe646ff, 0x7fe7187f, 0x7fe7e1ff, 0x7fe8a2ff, 0x7fe963ff, + 0x7fea1c7f, 0x7feacc7f, 0x7feb7c7f, 0x7fec247f, 0x7feccc7f, 0x7fed73ff, + 0x7fee0aff, 0x7feea1ff, 0x7fef38ff, 0x7fefc77f, 0x7ff055ff, 0x7ff0dc7f, + 0x7ff1627f, 0x7ff1e8ff, 0x7ff2667f, 0x7ff2dbff, 0x7ff3517f, 0x7ff3c6ff, + 0x7ff433ff, 0x7ff4a0ff, 0x7ff50dff, 0x7ff572ff, 0x7ff5ceff, 0x7ff633ff, + 0x7ff68fff, 0x7ff6ec7f, 0x7ff73fff, 0x7ff793ff, 0x7ff7e7ff, 0x7ff8337f, + 0x7ff8877f, 0x7ff8ca7f, 0x7ff915ff, 0x7ff958ff, 0x7ff99bff, 0x7ff9df7f, + 0x7ffa227f, 0x7ffa5cff, 0x7ffa97ff, 0x7ffad27f, 0x7ffb04ff, 0x7ffb3f7f, + 0x7ffb71ff, 0x7ffba47f, 0x7ffbce7f, 0x7ffc007f, 0x7ffc2a7f, 0x7ffc547f, + 0x7ffc7e7f, 0x7ffca87f, 0x7ffcc9ff, 0x7ffcf3ff, 0x7ffd157f, 0x7ffd36ff, + 0x7ffd587f, 0x7ffd79ff, 0x7ffd9b7f, 0x7ffdb4ff, 0x7ffdcdff, 0x7ffdef7f, + 0x7ffe087f, 0x7ffe21ff, 0x7ffe3aff, 0x7ffe4bff, 0x7ffe64ff, 0x7ffe7dff, + 0x7ffe8eff, 0x7ffe9f7f, 0x7ffeb07f, 0x7ffec97f, 0x7ffeda7f, 0x7ffeeaff, + 0x7ffef37f, 0x7fff047f, 0x7fff14ff, 0x7fff25ff, 0x7fff2e7f, 0x7fff3eff, + 0x7fff477f, 0x7fff4fff, 0x7fff607f, 0x7fff68ff, 0x7fff717f, 0x7fff79ff, + 0x7fff81ff, 0x7fff8a7f, 0x7fff92ff, 0x7fff9b7f, 0x7fffa37f, 0x7fffabff, + 0x7fffabff, 0x7fffb47f, 0x7fffbcff, 0x7fffbcff, 0x7fffc57f, 0x7fffc57f, + 0x7fffcd7f, 0x7fffcd7f, 0x7fffd5ff, 0x7fffd5ff, 0x7fffde7f, 0x7fffde7f, + 0x7fffde7f, 0x7fffe6ff, 0x7fffe6ff, 0x7fffe6ff, 0x7fffeeff, 0x7fffeeff, + 0x7fffeeff, 0x7fffeeff, 0x7ffff77f, 0x7ffff77f, 0x7ffff77f, 0x7ffff77f, + 0x7ffff77f, 0x7ffff77f, 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff, + 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 kbd_win256[256] = { + 0x00132c5e, 0x001f986b, 0x002c6d72, 0x003a3c1b, 0x00493eaa, 0x00599862, + 0x006b63fc, 0x007eb86c, 0x0093aacb, 0x00aa4f3b, 0x00c2b958, 0x00dcfc70, + 0x00f92ba8, 0x01175a0a, 0x01379a8f, 0x015a0023, 0x017e9da6, 0x01a585e6, + 0x01cecba4, 0x01fa8186, 0x0228ba1b, 0x025987d1, 0x028cfcee, 0x02c32b8e, + 0x02fc259c, 0x0337fcc8, 0x0376c285, 0x03b88801, 0x03fd5e1a, 0x04455560, + 0x04907e06, 0x04dee7e0, 0x0530a25b, 0x0585bc76, 0x05de44bb, 0x063a4939, + 0x0699d77f, 0x06fcfc92, 0x0763c4ea, 0x07ce3c6a, 0x083c6e59, 0x08ae655f, + 0x09242b7d, 0x099dca06, 0x0a1b499d, 0x0a9cb22d, 0x0b220ae4, 0x0bab5a2f, + 0x0c38a5b4, 0x0cc9f24f, 0x0d5f440b, 0x0df89e21, 0x0e9602f2, 0x0f377404, + 0x0fdcf1ff, 0x10867ca8, 0x113412e1, 0x11e5b2a4, 0x129b5901, 0x13550220, + 0x1412a936, 0x14d44890, 0x1599d986, 0x16635483, 0x1730b0fe, 0x1801e581, + 0x18d6e7a1, 0x19afac06, 0x1a8c2664, 0x1b6c4986, 0x1c500746, 0x1d375093, + 0x1e221575, 0x1f10450b, 0x2001cd93, 0x20f69c66, 0x21ee9e04, 0x22e9be10, + 0x23e7e75a, 0x24e903de, 0x25ecfcd0, 0x26f3ba97, 0x27fd24db, 0x29092288, + 0x2a1799d1, 0x2b28703a, 0x2c3b8a9b, 0x2d50cd2b, 0x2e681b83, 0x2f8158a5, + 0x309c6709, 0x31b9289c, 0x32d77ed0, 0x33f74a9e, 0x35186c95, 0x363ac4d8, + 0x375e3333, 0x3882971a, 0x39a7cfb6, 0x3acdbbf0, 0x3bf43a75, 0x3d1b29c5, + 0x3e426836, 0x3f69d405, 0x40914b59, 0x41b8ac51, 0x42dfd50a, 0x4406a3ac, + 0x452cf672, 0x4652abb4, 0x4777a1f0, 0x489bb7d4, 0x49becc4a, 0x4ae0be7e, + 0x4c016de7, 0x4d20ba56, 0x4e3e83f8, 0x4f5aab65, 0x507511a6, 0x518d983d, + 0x52a42131, 0x53b88f14, 0x54cac50d, 0x55daa6dc, 0x56e818ea, 0x57f30047, + 0x58fb42b9, 0x5a00c6c1, 0x5b03739e, 0x5c03315a, 0x5cffe8cc, 0x5df983a1, + 0x5eefec5d, 0x5fe30e66, 0x60d2d607, 0x61bf3073, 0x62a80bcb, 0x638d5722, + 0x646f0282, 0x654cfeec, 0x66273e5f, 0x66fdb3d5, 0x67d0534d, 0x689f11c6, + 0x6969e543, 0x6a30c4cc, 0x6af3a870, 0x6bb28941, 0x6c6d6159, 0x6d242bd6, + 0x6dd6e4da, 0x6e85898a, 0x6f30180d, 0x6fd68f86, 0x7078f015, 0x71173ad6, + 0x71b171d8, 0x7247981c, 0x72d9b193, 0x7367c317, 0x73f1d266, 0x7477e620, + 0x74fa05bd, 0x7578398b, 0x75f28aa7, 0x766902f5, 0x76dbad1c, 0x774a947c, + 0x77b5c529, 0x781d4be4, 0x78813611, 0x78e191b2, 0x793e6d5d, 0x7997d834, + 0x79ede1dc, 0x7a409a77, 0x7a90129a, 0x7adc5b43, 0x7b2585d1, 0x7b6ba3fd, + 0x7baec7ce, 0x7bef0393, 0x7c2c69d7, 0x7c670d5c, 0x7c9f0110, 0x7cd45801, + 0x7d07255b, 0x7d377c5b, 0x7d657049, 0x7d91146a, 0x7dba7c02, 0x7de1ba42, + 0x7e06e247, 0x7e2a070f, 0x7e4b3b72, 0x7e6a921d, 0x7e881d8a, 0x7ea3effa, + 0x7ebe1b6d, 0x7ed6b19e, 0x7eedc3fe, 0x7f0363ae, 0x7f17a177, 0x7f2a8dcd, + 0x7f3c38c3, 0x7f4cb20c, 0x7f5c08f4, 0x7f6a4c62, 0x7f778ad0, 0x7f83d24c, + 0x7f8f3073, 0x7f99b274, 0x7fa36509, 0x7fac547b, 0x7fb48c9e, 0x7fbc18d2, + 0x7fc30404, 0x7fc958ad, 0x7fcf20d1, 0x7fd46604, 0x7fd93169, 0x7fdd8bb1, + 0x7fe17d22, 0x7fe50d93, 0x7fe84475, 0x7feb28ce, 0x7fedc13f, 0x7ff01409, + 0x7ff2270b, 0x7ff3ffc7, 0x7ff5a368, 0x7ff716bf, 0x7ff85e4b, 0x7ff97e3b, + 0x7ffa7a71, 0x7ffb5686, 0x7ffc15cb, 0x7ffcbb50, 0x7ffd49e5, 0x7ffdc41f, + 0x7ffe2c57, 0x7ffe84b3, 0x7ffecf28, 0x7fff0d78, 0x7fff413b, 0x7fff6be1, + 0x7fff8eb1, 0x7fffaad1, 0x7fffc144, 0x7fffd2f2, 0x7fffe0a3, 0x7fffeb0a, + 0x7ffff2bf, 0x7ffff849, 0x7ffffc18, 0x7ffffe8f}; + +const WORD32 ixheaacd_kbd_win4[4] = {0x000807ab, 0x22b0608e, 0x7b35bb1c, + 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win16[16] = { + 0x00040f1f, 0x008e78fe, 0x02c97f7b, 0x0884e8da, 0x137eb190, 0x244db0c4, + 0x398f9632, 0x5009fdd5, 0x63e3825f, 0x7253cdb4, 0x7abe6e47, 0x7e81b826, + 0x7fb757e1, 0x7ff83b3b, 0x7fffb0c4, 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win_64[64] = { + 0x00020817, 0x00096787, 0x0017763e, 0x002f8bde, 0x00559f6e, 0x008e7146, + 0x00df9378, 0x014f3fd9, 0x01e45803, 0x02a63b67, 0x039c8c93, 0x04cf17ff, + 0x06456f77, 0x0806b7af, 0x0a195ccf, 0x0c82be8f, 0x0f46ed1f, 0x1268555f, + 0x15e7a73f, 0x19c38aff, 0x1df8875f, 0x2280f97f, 0x27552e3f, 0x2c6b58ff, + 0x31b7e0bf, 0x372d903f, 0x3cbdf4bf, 0x4259b7ff, 0x47f11f7f, 0x4d745fff, + 0x52d43cff, 0x580242ff, 0x5cf1777f, 0x6196747f, 0x65e7e1ff, 0x69de9bff, + 0x6d75ea7f, 0x70ab607f, 0x737f0eff, 0x75f316ff, 0x780ba1ff, 0x79ce95ff, + 0x7b4306ff, 0x7c7114ff, 0x7d615e7f, 0x7e1c9b7f, 0x7eab607f, 0x7f15c5ff, + 0x7f631b7f, 0x7f99dc7f, 0x7fbf82ff, 0x7fd8a57f, 0x7fe8dd7f, 0x7ff2f57f, + 0x7ff8fcff, 0x7ffc6d7f, 0x7ffe4bff, 0x7fff3eff, 0x7fffb47f, 0x7fffe6ff, + 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win768[768] = { + 0x000b1359, 0x00107b78, 0x0015336d, 0x0019b0ab, 0x001e14bd, 0x002278d0, + 0x0026e546, 0x002b6ae7, 0x0030014f, 0x0034b0e1, 0x00398201, 0x003e6c4c, + 0x00438088, 0x0048adee, 0x004e0da9, 0x0053868f, 0x00592966, 0x005efe92, + 0x0064f54c, 0x006b15f8, 0x00716095, 0x0077d523, 0x007e7c06, 0x00854cda, + 0x008c5004, 0x00937d1f, 0x009adc8f, 0x00a26e53, 0x00aa326d, 0x00b22078, + 0x00ba493c, 0x00c2a454, 0x00cb31c1, 0x00d3f9e7, 0x00dcf461, 0x00e62131, + 0x00ef88b8, 0x00f92af9, 0x0102ff8d, 0x010d0edb, 0x01176145, 0x0121e603, + 0x012ca579, 0x0137a80b, 0x0142dcf3, 0x014e5d5b, 0x015a1015, 0x016605ed, + 0x01723ee1, 0x017eb28d, 0x018b6955, 0x01986337, 0x01a5a037, 0x01b32053, + 0x01c0e389, 0x01cee9dd, 0x01dd3baf, 0x01ebc839, 0x01faa043, 0x0209c3cf, + 0x021932d7, 0x0228e4fb, 0x0238da3b, 0x0249235f, 0x0259af9f, 0x026a8fbf, + 0x027bb2ff, 0x028d2a1f, 0x029eecbf, 0x02b0fadf, 0x02c35cdf, 0x02d60a63, + 0x02e90bc7, 0x02fc58ab, 0x030ff973, 0x0323ee1b, 0x033836a7, 0x034ccab3, + 0x0361bb03, 0x0376ff3b, 0x038c8eef, 0x03a2834b, 0x03b8c32b, 0x03cf5f4f, + 0x03e64f53, 0x03fd9b9f, 0x04154437, 0x042d40a7, 0x04459967, 0x045e4607, + 0x0477574f, 0x0490c4df, 0x04aa864f, 0x04c4ac6f, 0x04df2ecf, 0x04fa0d77, + 0x05154867, 0x0530e7ff, 0x054ce3df, 0x05694467, 0x05860997, 0x05a32b0f, + 0x05c0a8cf, 0x05de939f, 0x05fcdaaf, 0x061b866f, 0x063a96d7, 0x065a0be7, + 0x0679e59f, 0x069a23ff, 0x06bacf77, 0x06dbd727, 0x06fd4bef, 0x071f255f, + 0x07416bd7, 0x076416ff, 0x07872f2f, 0x07aaac0f, 0x07ce8d97, 0x07f2e48f, + 0x0817a02f, 0x083cc07f, 0x0862562f, 0x0888509f, 0x08aec06f, 0x08d594ef, + 0x08fcd67f, 0x0924851f, 0x094ca0bf, 0x0975296f, 0x099e279f, 0x09c78a6f, + 0x09f162af, 0x0a1ba7ff, 0x0a465a4f, 0x0a7179bf, 0x0a9d0e9f, 0x0ac9107f, + 0x0af587cf, 0x0b226c3f, 0x0b4fbdaf, 0x0b7d848f, 0x0babb87f, 0x0bda61df, + 0x0c09784f, 0x0c39042f, 0x0c69057f, 0x0c9973df, 0x0cca4f3f, 0x0cfba87f, + 0x0d2d6ecf, 0x0d5fa21f, 0x0d92534f, 0x0dc5718f, 0x0df8fccf, 0x0e2d05ef, + 0x0e617c1f, 0x0e9667af, 0x0ecbc05f, 0x0f0196df, 0x0f37da5f, 0x0f6e8aff, + 0x0fa5b95f, 0x0fdd54df, 0x101565bf, 0x104dec1f, 0x1086df7f, 0x10c0485f, + 0x10fa269f, 0x11347a5f, 0x116f3b1f, 0x11aa715f, 0x11e6149f, 0x122235bf, + 0x125ec3df, 0x129bbeff, 0x12d92fbf, 0x131715bf, 0x135568df, 0x1394317f, + 0x13d3671f, 0x1413121f, 0x14532a3f, 0x1493b7df, 0x14d4b27f, 0x15161a1f, + 0x1557f73f, 0x159a415f, 0x15dcf89f, 0x1620253f, 0x1663bedf, 0x16a7c59f, + 0x16ec397f, 0x17311a5f, 0x1776683f, 0x17bc233f, 0x18024b3f, 0x1848e03f, + 0x188fe25f, 0x18d7517f, 0x191f255f, 0x1967663f, 0x19b0141f, 0x19f926bf, + 0x1a42a65f, 0x1a8c8abf, 0x1ad6dc1f, 0x1b21921f, 0x1b6cacdf, 0x1bb8347f, + 0x1c04189f, 0x1c50699f, 0x1c9d1f5f, 0x1cea39bf, 0x1d37b8df, 0x1d85941f, + 0x1dd3d41f, 0x1e2278df, 0x1e7179bf, 0x1ec0df5f, 0x1f10a99f, 0x1f60d01f, + 0x1fb152ff, 0x200231ff, 0x20536d7f, 0x20a504ff, 0x20f7013f, 0x2149517f, + 0x219bf57f, 0x21eefe3f, 0x22425aff, 0x229613bf, 0x22ea207f, 0x233e813f, + 0x239335bf, 0x23e846bf, 0x243da2ff, 0x24935b7f, 0x24e95fbf, 0x253fb7bf, + 0x2596637f, 0x25ed5aff, 0x26449dbf, 0x269c347f, 0x26f416bf, 0x274c447f, + 0x27a4bdbf, 0x27fd79ff, 0x28568a3f, 0x28afddbf, 0x29097c7f, 0x29635e7f, + 0x29bd837f, 0x2a17f3ff, 0x2a729f3f, 0x2acd8dbf, 0x2b28c77f, 0x2b843c3f, + 0x2bdfeb7f, 0x2c3bddff, 0x2c980b3f, 0x2cf47b7f, 0x2d511dff, 0x2dae03bf, + 0x2e0b1bbf, 0x2e686e7f, 0x2ec5f37f, 0x2f23b37f, 0x2f81a57f, 0x2fdfd27f, + 0x303e293f, 0x309cb23f, 0x30fb6dbf, 0x315a5b7f, 0x31b9733f, 0x3218bd7f, + 0x327828ff, 0x32d7c6ff, 0x33378eff, 0x3397783f, 0x33f7943f, 0x3457d17f, + 0x34b8303f, 0x3518b0bf, 0x35795b3f, 0x35da1ebf, 0x363b0c3f, 0x369c12ff, + 0x36fd32bf, 0x375e743f, 0x37bfcebf, 0x38214abf, 0x3882d7bf, 0x38e47dbf, + 0x39463cff, 0x39a80cff, 0x3a09f63f, 0x3a6befff, 0x3acdfabf, 0x3b30163f, + 0x3b923a3f, 0x3bf4773f, 0x3c56b43f, 0x3cb90a7f, 0x3d1b60bf, 0x3d7dbf3f, + 0x3de02ebf, 0x3e429dff, 0x3ea515bf, 0x3f078d7f, 0x3f6a053f, 0x3fcc857f, + 0x402efd7f, 0x40917d7f, 0x40f3f4ff, 0x41566cff, 0x41b8dc7f, 0x421b437f, + 0x427daa7f, 0x42e0007f, 0x43424e7f, 0x43a493ff, 0x4406d0ff, 0x4468f47f, + 0x44cb0fff, 0x452d1aff, 0x458f14ff, 0x45f0fdff, 0x4652cdff, 0x46b48cff, + 0x4716337f, 0x4777c87f, 0x47d93c7f, 0x483a96ff, 0x489bd7ff, 0x48fd007f, + 0x495e06ff, 0x49beebff, 0x4a1fafff, 0x4a8059ff, 0x4ae0da7f, 0x4b41397f, + 0x4ba176ff, 0x4c018a7f, 0x4c61737f, 0x4cc13b7f, 0x4d20d0ff, 0x4d8044ff, + 0x4ddf86ff, 0x4e3e9e7f, 0x4e9d83ff, 0x4efc36ff, 0x4f5abfff, 0x4fb916ff, + 0x501732ff, 0x5075257f, 0x50d2dc7f, 0x513061ff, 0x518dabff, 0x51eabbff, + 0x5247907f, 0x52a4337f, 0x530092ff, 0x535cb77f, 0x53b898ff, 0x54143fff, + 0x546fac7f, 0x54caccff, 0x5525b2ff, 0x558055ff, 0x55daad7f, 0x5634c9ff, + 0x568e92ff, 0x56e820ff, 0x5741637f, 0x579a5a7f, 0x57f305ff, 0x584b65ff, + 0x58a37aff, 0x58fb43ff, 0x5952c17f, 0x59a9eaff, 0x5a00c97f, 0x5a57537f, + 0x5aad89ff, 0x5b0374ff, 0x5b59037f, 0x5bae46ff, 0x5c032d7f, 0x5c57c07f, + 0x5cabffff, 0x5cffe27f, 0x5d53717f, 0x5da6a47f, 0x5df97a7f, 0x5e4bfcff, + 0x5e9e1aff, 0x5eefe4ff, 0x5f414a7f, 0x5f925b7f, 0x5fe3087f, 0x6033507f, + 0x60833c7f, 0x60d2cbff, 0x6121f6ff, 0x6170bcff, 0x61bf26ff, 0x620d23ff, + 0x625ac47f, 0x62a8007f, 0x62f4cf7f, 0x634141ff, 0x638d477f, 0x63d8e87f, + 0x6424247f, 0x646ef3ff, 0x64b955ff, 0x65035bff, 0x654cec7f, 0x659617ff, + 0x65ded67f, 0x6627287f, 0x666f157f, 0x66b68cff, 0x66fd9fff, 0x6744457f, + 0x678a75ff, 0x67d041ff, 0x681597ff, 0x685a817f, 0x689efd7f, 0x68e3047f, + 0x6926a67f, 0x6969ca7f, 0x69ac89ff, 0x69eed47f, 0x6a30a8ff, 0x6a72107f, + 0x6ab30b7f, 0x6af3907f, 0x6b33a07f, 0x6b7342ff, 0x6bb26fff, 0x6bf127ff, + 0x6c2f727f, 0x6c6d47ff, 0x6caaa7ff, 0x6ce7927f, 0x6d240f7f, 0x6d60177f, + 0x6d9ba9ff, 0x6dd6c6ff, 0x6e1176ff, 0x6e4ba97f, 0x6e856e7f, 0x6ebebdff, + 0x6ef7987f, 0x6f2ffcff, 0x6f67ec7f, 0x6f9f667f, 0x6fd672ff, 0x700d0a7f, + 0x7043247f, 0x7078d0ff, 0x70ae07ff, 0x70e2c97f, 0x71171dff, 0x714af4ff, + 0x717e5e7f, 0x71b152ff, 0x71e3d1ff, 0x7215e37f, 0x7247777f, 0x72789e7f, + 0x72a94fff, 0x72d9947f, 0x7309637f, 0x7338bcff, 0x7367a0ff, 0x739617ff, + 0x73c421ff, 0x73f1b67f, 0x741ed57f, 0x744b877f, 0x7477c47f, 0x74a393ff, + 0x74cef67f, 0x74f9e37f, 0x7524637f, 0x754e767f, 0x75781c7f, 0x75a14cff, + 0x75ca107f, 0x75f26eff, 0x761a587f, 0x7641d47f, 0x7668e3ff, 0x768f85ff, + 0x76b5c37f, 0x76db8b7f, 0x7700eeff, 0x7725e57f, 0x774a76ff, 0x776e9b7f, + 0x7792537f, 0x77b5a5ff, 0x77d88bff, 0x77fb157f, 0x781d29ff, 0x783ee17f, + 0x78602c7f, 0x78811aff, 0x78a19c7f, 0x78c1b97f, 0x78e1717f, 0x7900cd7f, + 0x791fbc7f, 0x793e4eff, 0x795c7cff, 0x797a4e7f, 0x7997bb7f, 0x79b4cbff, + 0x79d177ff, 0x79edc7ff, 0x7a09b2ff, 0x7a2549ff, 0x7a407cff, 0x7a5b52ff, + 0x7a75d57f, 0x7a8ff2ff, 0x7aa9bcff, 0x7ac32a7f, 0x7adc3bff, 0x7af4f8ff, + 0x7b0d5a7f, 0x7b25677f, 0x7b3d20ff, 0x7b547dff, 0x7b6b86ff, 0x7b823c7f, + 0x7b989dff, 0x7baeab7f, 0x7bc464ff, 0x7bd9d37f, 0x7beeed7f, 0x7c03b3ff, + 0x7c18267f, 0x7c2c4d7f, 0x7c4028ff, 0x7c53b8ff, 0x7c66f4ff, 0x7c79e57f, + 0x7c8c8a7f, 0x7c9eec7f, 0x7cb0faff, 0x7cc2c5ff, 0x7cd43cff, 0x7ce5797f, + 0x7cf66a7f, 0x7d070f7f, 0x7d1771ff, 0x7d2790ff, 0x7d3764ff, 0x7d46fdff, + 0x7d564b7f, 0x7d655dff, 0x7d74257f, 0x7d82b1ff, 0x7d9103ff, 0x7d9f09ff, + 0x7dacd57f, 0x7dba667f, 0x7dc7bcff, 0x7dd4cfff, 0x7de1a7ff, 0x7dee45ff, + 0x7dfaa87f, 0x7e06d0ff, 0x7e12be7f, 0x7e1e797f, 0x7e29f17f, 0x7e353f7f, + 0x7e4052ff, 0x7e4b2b7f, 0x7e55d1ff, 0x7e60457f, 0x7e6a7eff, 0x7e748e7f, + 0x7e7e62ff, 0x7e880d7f, 0x7e9185ff, 0x7e9acbff, 0x7ea3df7f, 0x7eacc8ff, + 0x7eb5807f, 0x7ebe0dff, 0x7ec668ff, 0x7ece99ff, 0x7ed6a17f, 0x7ede7e7f, + 0x7ee631ff, 0x7eedb2ff, 0x7ef5127f, 0x7efc47ff, 0x7f03537f, 0x7f0a3d7f, + 0x7f10fd7f, 0x7f17937f, 0x7f1e07ff, 0x7f245aff, 0x7f2a83ff, 0x7f308b7f, + 0x7f36697f, 0x7f3c2d7f, 0x7f41d07f, 0x7f47497f, 0x7f4ca8ff, 0x7f51e77f, + 0x7f5703ff, 0x7f5bfeff, 0x7f60e0ff, 0x7f65a17f, 0x7f6a3fff, 0x7f6ecdff, + 0x7f7331ff, 0x7f77857f, 0x7f7bb6ff, 0x7f7fcfff, 0x7f83c6ff, 0x7f87acff, + 0x7f8b79ff, 0x7f8f257f, 0x7f92c07f, 0x7f9641ff, 0x7f99aa7f, 0x7f9cf97f, + 0x7fa037ff, 0x7fa35d7f, 0x7fa671ff, 0x7fa964ff, 0x7fac4f7f, 0x7faf20ff, + 0x7fb1d8ff, 0x7fb488ff, 0x7fb71f7f, 0x7fb9a57f, 0x7fbc127f, 0x7fbe76ff, + 0x7fc0c1ff, 0x7fc2fc7f, 0x7fc52e7f, 0x7fc7477f, 0x7fc957ff, 0x7fcb4eff, + 0x7fcd3dff, 0x7fcf1bff, 0x7fd0e97f, 0x7fd2ae7f, 0x7fd462ff, 0x7fd605ff, + 0x7fd7a0ff, 0x7fd92b7f, 0x7fdaad7f, 0x7fdc1e7f, 0x7fdd86ff, 0x7fdee77f, + 0x7fe036ff, 0x7fe175ff, 0x7fe2b47f, 0x7fe3e27f, 0x7fe507ff, 0x7fe6257f, + 0x7fe739ff, 0x7fe83e7f, 0x7fe9427f, 0x7fea357f, 0x7feb28ff, 0x7fec0b7f, + 0x7fece57f, 0x7fedbf7f, 0x7fee88ff, 0x7fef51ff, 0x7ff012ff, 0x7ff0cb7f, + 0x7ff17bff, 0x7ff2237f, 0x7ff2cb7f, 0x7ff3627f, 0x7ff401ff, 0x7ff4907f, + 0x7ff51eff, 0x7ff5a4ff, 0x7ff622ff, 0x7ff6a0ff, 0x7ff7167f, 0x7ff7837f, + 0x7ff7f07f, 0x7ff85d7f, 0x7ff8c1ff, 0x7ff91e7f, 0x7ff97a7f, 0x7ff9d6ff, + 0x7ffa2aff, 0x7ffa767f, 0x7ffac9ff, 0x7ffb0d7f, 0x7ffb58ff, 0x7ffb9bff, + 0x7ffbd67f, 0x7ffc117f, 0x7ffc4bff, 0x7ffc86ff, 0x7ffcb8ff, 0x7ffceb7f, + 0x7ffd1dff, 0x7ffd477f, 0x7ffd717f, 0x7ffd9b7f, 0x7ffdc57f, 0x7ffde6ff, + 0x7ffe087f, 0x7ffe29ff, 0x7ffe4bff, 0x7ffe64ff, 0x7ffe867f, 0x7ffe9f7f, + 0x7ffeb8ff, 0x7ffed1ff, 0x7ffee2ff, 0x7ffefbff, 0x7fff0c7f, 0x7fff1d7f, + 0x7fff2e7f, 0x7fff3eff, 0x7fff4fff, 0x7fff607f, 0x7fff68ff, 0x7fff79ff, + 0x7fff81ff, 0x7fff92ff, 0x7fff9b7f, 0x7fffa37f, 0x7fffabff, 0x7fffb47f, + 0x7fffbcff, 0x7fffc57f, 0x7fffc57f, 0x7fffcd7f, 0x7fffd5ff, 0x7fffd5ff, + 0x7fffde7f, 0x7fffde7f, 0x7fffe6ff, 0x7fffe6ff, 0x7fffeeff, 0x7fffeeff, + 0x7fffeeff, 0x7fffeeff, 0x7ffff77f, 0x7ffff77f, 0x7ffff77f, 0x7ffff77f, + 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win192[192] = { + 0x00012dfd, 0x000296b3, 0x00047d3d, 0x0006f262, 0x000a0f4d, 0x000ded28, + 0x0012a51e, 0x0018611f, 0x001f31f4, 0x002749f0, 0x0030c23f, 0x003bcd35, + 0x004894c4, 0x005742dc, 0x00680170, 0x007b0b38, 0x00908a25, 0x00a8c154, + 0x00c3eb7c, 0x00e2328f, 0x0103ea6f, 0x01293d0f, 0x015275ed, 0x017fe089, + 0x01b1af39, 0x01e835dd, 0x0223b793, 0x02647777, 0x02aac107, 0x02f6e827, + 0x0349278f, 0x03a1cabf, 0x04012597, 0x04677b37, 0x04d50eb7, 0x054a2b9f, + 0x05c714ff, 0x064c1657, 0x06d96a67, 0x076f5447, 0x080e064f, 0x08b5cbff, + 0x0966cf3f, 0x0a214acf, 0x0ae5603f, 0x0bb34a3f, 0x0c8b2a6f, 0x0d6d223f, + 0x0e594aef, 0x0f4fc60f, 0x1050939f, 0x115bcc9f, 0x127179bf, 0x1391925f, + 0x14bc169f, 0x15f0ed3f, 0x1730163f, 0x1879701f, 0x19ccd0ff, 0x1b2a1f7f, + 0x1c91211f, 0x1e01abdf, 0x1f7b741f, 0x20fe477f, 0x2289d27f, 0x241dc93f, + 0x25b9cf7f, 0x275d91bf, 0x2908aabf, 0x2abaa57f, 0x2c73257f, 0x2e31ad3f, + 0x2ff5c6bf, 0x31bef47f, 0x338cb07f, 0x355e7c7f, 0x3733ca3f, 0x390c133f, + 0x3ae6c07f, 0x3cc343bf, 0x3ea10dff, 0x407f7fff, 0x425e0b7f, 0x443c20ff, + 0x461921ff, 0x47f476ff, 0x49cd897f, 0x4ba3d2ff, 0x4d76b37f, 0x4f45ae7f, + 0x5110237f, 0x52d594ff, 0x54957cff, 0x564f5cff, 0x5802afff, 0x59af0fff, + 0x5b53f7ff, 0x5cf10a7f, 0x5e85db7f, 0x60120dff, 0x61954e7f, 0x630f387f, + 0x647f98ff, 0x65e61cff, 0x674288ff, 0x6894aaff, 0x69dc58ff, 0x6b19697f, + 0x6c4bc27f, 0x6d7342ff, 0x6e8feaff, 0x6fa1a8ff, 0x70a8867f, 0x71a482ff, + 0x7295a6ff, 0x737c137f, 0x7457d9ff, 0x752923ff, 0x75f01b7f, 0x76ace27f, + 0x775fb2ff, 0x7808bfff, 0x78a84bff, 0x793e9a7f, 0x79cbdd7f, 0x7a5071ff, + 0x7acc91ff, 0x7b4091ff, 0x7bacbc7f, 0x7c11667f, 0x7c6ee2ff, 0x7cc57dff, + 0x7d1593ff, 0x7d5f6fff, 0x7da36dff, 0x7de1da7f, 0x7e1affff, 0x7e4f3b7f, + 0x7e7ecfff, 0x7eaa10ff, 0x7ed149ff, 0x7ef4be7f, 0x7f14b9ff, 0x7f31767f, + 0x7f4b37ff, 0x7f62497f, 0x7f76ccff, 0x7f890d7f, 0x7f9934ff, 0x7fa77e7f, + 0x7fb40aff, 0x7fbf0dff, 0x7fc8afff, 0x7fd10aff, 0x7fd8517f, 0x7fde9bff, + 0x7fe403ff, 0x7fe8a2ff, 0x7fec99ff, 0x7feff9ff, 0x7ff2cb7f, 0x7ff52fff, + 0x7ff737ff, 0x7ff8e37f, 0x7ffa43ff, 0x7ffb697f, 0x7ffc5cff, 0x7ffd1dff, + 0x7ffdbcff, 0x7ffe437f, 0x7ffea7ff, 0x7ffefbff, 0x7fff367f, 0x7fff68ff, + 0x7fff92ff, 0x7fffabff, 0x7fffc57f, 0x7fffd5ff, 0x7fffde7f, 0x7fffeeff, + 0x7fffeeff, 0x7ffff77f, 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff, + 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win96[96] = { + 0x0001abd1, 0x00057082, 0x000ba1f4, 0x001511df, 0x0022ab25, 0x00359bc3, + 0x004f11b5, 0x0070867a, 0x009b7bf1, 0x00d1b716, 0x01150549, 0x0167663f, + 0x01caf2d7, 0x0241d4b7, 0x02ce570f, 0x0372bcb3, 0x043150d7, 0x050c5eaf, + 0x06061847, 0x0720a73f, 0x085dfa7f, 0x09bfe7df, 0x0b480a5f, 0x0cf7b17f, + 0x0ecff21f, 0x10d184bf, 0x12fcc5bf, 0x1551bd5f, 0x17cffebf, 0x1a76c05f, + 0x1d44c37f, 0x203864bf, 0x234f7a7f, 0x268797ff, 0x29ddca3f, 0x2d4ed2bf, + 0x30d70e7f, 0x34729f3f, 0x381d53bf, 0x3bd2bf3f, 0x3f8e6cff, 0x434ba4ff, + 0x4705b7ff, 0x4ab8067f, 0x4e5de9ff, 0x51f2f57f, 0x5572de7f, 0x58d9ad7f, + 0x5c239e7f, 0x5f4d617f, 0x6253eaff, 0x6534b4ff, 0x67eda67f, 0x6a7d137f, + 0x6ce1d67f, 0x6f1b2e7f, 0x7128f17f, 0x730b527f, 0x74c2efff, 0x7650deff, + 0x77b6887f, 0x78f5a0ff, 0x7a10387f, 0x7b0880ff, 0x7be0deff, 0x7c9bd7ff, + 0x7d3c037f, 0x7dc3f7ff, 0x7e364bff, 0x7e957cff, 0x7ee3e6ff, 0x7f23dd7f, + 0x7f57687f, 0x7f80777f, 0x7fa0ceff, 0x7fb9e8ff, 0x7fcd24ff, 0x7fdbb17f, + 0x7fe6817f, 0x7fee677f, 0x7ff41aff, 0x7ff8227f, 0x7ffae37f, 0x7ffcc9ff, + 0x7ffe087f, 0x7ffed1ff, 0x7fff4fff, 0x7fffa37f, 0x7fffcd7f, 0x7fffe6ff, + 0x7ffff77f, 0x7ffff77f, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; + +const WORD32 ixheaacd_kbd_win48[48] = { + 0x000257ef, 0x000eb8da, 0x0029a9c3, 0x005c2d23, 0x00b19012, 0x0137851d, + 0x01fddfc9, 0x0316102f, 0x04926117, 0x0684ff27, 0x08fed5af, 0x0c0e533f, + 0x0fbe2c0f, 0x1414349f, 0x19106c7f, 0x1eac53df, 0x24da9d7f, 0x2b874cff, + 0x3298467f, 0x39ee4b7f, 0x41665bff, 0x48db617f, 0x50280e7f, 0x5728c9ff, + 0x5dbd86ff, 0x63cb63ff, 0x693def7f, 0x6e07fb7f, 0x7223ed7f, 0x759381ff, + 0x785f127f, 0x7a9467ff, 0x7c453f7f, 0x7d85a5ff, 0x7e6a537f, 0x7f0737ff, + 0x7f6e547f, 0x7faefb7f, 0x7fd577ff, 0x7feb177f, 0x7ff6797f, 0x7ffc087f, + 0x7ffe84ff, 0x7fff84ff, 0x7fffdeff, 0x7ffff8ff, 0x7ffffeff, 0x7fffffff}; + +const FLOAT32 mean_lsf_conc[16] = { + 415.8089f, 810.0709f, 1291.5637f, 1674.4192f, 2077.4895f, 2464.5791f, + 2841.3894f, 3217.6775f, 3587.4265f, 3976.9675f, 4366.0098f, 4766.7573f, + 5149.4009f, 5545.2534f, 5918.0859f, 1577.0078f}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_512[4][512] = { + {2147483015, 2147467855, 2147432483, 2147376898, 2147301101, 2147205093, + 2147088874, 2146952447, 2146795811, 2146618969, 2146421922, 2146204673, + 2145967222, 2145709573, 2145431727, 2145133688, 2144815458, 2144477040, + 2144118438, 2143739654, 2143340693, 2142921558, 2142482252, 2142022781, + 2141543148, 2141043359, 2140523417, 2139983327, 2139423095, 2138842727, + 2138242226, 2137621600, 2136980853, 2136319993, 2135639024, 2134937954, + 2134216790, 2133475537, 2132714203, 2131932795, 2131131321, 2130309787, + 2129468203, 2128606574, 2127724911, 2126823221, 2125901512, 2124959794, + 2123998074, 2123016363, 2122014669, 2120993002, 2119951371, 2118889786, + 2117808258, 2116706796, 2115585411, 2114444113, 2113282913, 2112101822, + 2110900851, 2109680012, 2108439315, 2107178773, 2105898398, 2104598201, + 2103278194, 2101938391, 2100578804, 2099199445, 2097800328, 2096381465, + 2094942870, 2093484557, 2092006540, 2090508831, 2088991446, 2087454399, + 2085897703, 2084321375, 2082725428, 2081109877, 2079474738, 2077820027, + 2076145758, 2074451948, 2072738612, 2071005767, 2069253429, 2067481614, + 2065690339, 2063879622, 2062049478, 2060199925, 2058330981, 2056442663, + 2054534990, 2052607978, 2050661646, 2048696012, 2046711096, 2044706915, + 2042683488, 2040640835, 2038578975, 2036497927, 2034397710, 2032278345, + 2030139852, 2027982250, 2025805559, 2023609802, 2021394997, 2019161166, + 2016908330, 2014636510, 2012345727, 2010036004, 2007707361, 2005359821, + 2002993406, 2000608137, 1998204039, 1995781132, 1993339441, 1990878987, + 1988399795, 1985901886, 1983385286, 1980850018, 1978296105, 1975723571, + 1973132441, 1970522740, 1967894491, 1965247719, 1962582450, 1959898708, + 1957196519, 1954475908, 1951736901, 1948979523, 1946203800, 1943409760, + 1940597427, 1937766828, 1934917991, 1932050941, 1929165706, 1926262314, + 1923340790, 1920401163, 1917443461, 1914467711, 1911473941, 1908462180, + 1905432455, 1902384796, 1899319231, 1896235789, 1893134498, 1890015389, + 1886878490, 1883723832, 1880551443, 1877361353, 1874153593, 1870928193, + 1867685183, 1864424593, 1861146455, 1857850799, 1854537656, 1851207058, + 1847859035, 1844493620, 1841110843, 1837710737, 1834293334, 1830858666, + 1827406765, 1823937664, 1820451396, 1816947992, 1813427487, 1809889913, + 1806335304, 1802763693, 1799175113, 1795569599, 1791947185, 1788307904, + 1784651790, 1780978879, 1777289205, 1773582802, 1769859705, 1766119950, + 1762363572, 1758590605, 1754801086, 1750995050, 1747172533, 1743333571, + 1739478200, 1735606457, 1731718377, 1727813998, 1723893355, 1719956487, + 1716003430, 1712034221, 1708048898, 1704047499, 1700030060, 1695996619, + 1691947216, 1687881887, 1683800671, 1679703606, 1675590732, 1671462086, + 1667317708, 1663157636, 1658981910, 1654790569, 1650583653, 1646361200, + 1642123252, 1637869847, 1633601026, 1629316829, 1625017296, 1620702468, + 1616372385, 1612027088, 1607666618, 1603291017, 1598900324, 1594494582, + 1590073832, 1585638116, 1581187475, 1576721951, 1572241587, 1567746424, + 1563236505, 1558711872, 1554172567, 1549618635, 1545050117, 1540467056, + 1535869495, 1531257479, 1526631050, 1521990251, 1517335127, 1512665721, + 1507982078, 1503284241, 1498572254, 1493846162, 1489106009, 1484351841, + 1479583701, 1474801635, 1470005687, 1465195903, 1460372328, 1455535008, + 1450683987, 1445819312, 1440941029, 1436049183, 1431143820, 1426224987, + 1421292729, 1416347094, 1411388127, 1406415876, 1401430388, 1396431708, + 1391419885, 1386394965, 1381356996, 1376306025, 1371242100, 1366165268, + 1361075577, 1355973076, 1350857811, 1345729832, 1340589186, 1335435922, + 1330270088, 1325091733, 1319900906, 1314697656, 1309482031, 1304254081, + 1299013854, 1293761401, 1288496771, 1283220012, 1277931176, 1272630311, + 1267317467, 1261992696, 1256656045, 1251307567, 1245947311, 1240575328, + 1235191667, 1229796381, 1224389520, 1218971133, 1213541274, 1208099992, + 1202647339, 1197183367, 1191708126, 1186221668, 1180724045, 1175215309, + 1169695511, 1164164703, 1158622938, 1153070268, 1147506744, 1141932419, + 1136347347, 1130751578, 1125145167, 1119528165, 1113900626, 1108262602, + 1102614147, 1096955313, 1091286155, 1085606725, 1079917077, 1074217265, + 1068507341, 1062787360, 1057057376, 1051317442, 1045567614, 1039807943, + 1034038486, 1028259296, 1022470427, 1016671935, 1010863874, 1005046297, + 999219261, 993382820, 987537029, 981681942, 975817616, 969944105, + 964061464, 958169750, 952269016, 946359320, 940440716, 934513260, + 928577009, 922632017, 916678341, 910716037, 904745160, 898765769, + 892777917, 886781662, 880777061, 874764170, 868743044, 862713742, + 856676320, 850630834, 844577342, 838515900, 832446566, 826369397, + 820284450, 814191781, 808091449, 801983512, 795868025, 789745048, + 783614637, 777476851, 771331746, 765179382, 759019815, 752853104, + 746679307, 740498482, 734310687, 728115981, 721914421, 715706067, + 709490975, 703269206, 697040818, 690805868, 684564417, 678316522, + 672062242, 665801637, 659534765, 653261685, 646982457, 640697138, + 634405790, 628108470, 621805238, 615496153, 609181275, 602860664, + 596534378, 590202477, 583865021, 577522069, 571173681, 564819918, + 558460838, 552096501, 545726969, 539352299, 532972553, 526587790, + 520198071, 513803456, 507404004, 500999777, 494590834, 488177236, + 481759043, 475336315, 468909113, 462477498, 456041530, 449601269, + 443156776, 436708113, 430255339, 423798515, 417337702, 410872961, + 404404353, 397931938, 391455778, 384975933, 378492465, 372005434, + 365514902, 359020929, 352523578, 346022908, 339518981, 333011858, + 326501601, 319988271, 313471929, 306952637, 300430455, 293905446, + 287377670, 280847190, 274314066, 267778360, 261240133, 254699448, + 248156365, 241610947, 235063254, 228513349, 221961293, 215407148, + 208850976, 202292837, 195732795, 189170910, 182607245, 176041861, + 169474820, 162906184, 156336014, 149764373, 143191322, 136616924, + 130041240, 123464331, 116886261, 110307090, 103726882, 97145696, + 90563597, 83980645, 77396903, 70812432, 64227294, 57641552, + 51055268, 44468503, 37881319, 31293779, 24705944, 18117877, + 11529639, 4941293}, + {-1647099, -8235476, -14823776, -21411936, -27999895, + -34587590, -41174959, -47761942, -54348474, -60934495, + -67519942, -74104754, -80688869, -87272224, -93854757, + -100436407, -107017112, -113596809, -120175438, -126752935, + -133329239, -139904288, -146478020, -153050374, -159621287, + -166190697, -172758544, -179324764, -185889296, -192452079, + -199013050, -205572148, -212129312, -218684478, -225237586, + -231788574, -238337381, -244883944, -251428202, -257970094, + -264509558, -271046532, -277580954, -284112764, -290641900, + -297168300, -303691903, -310212648, -316730473, -323245317, + -329757118, -336265815, -342771348, -349273654, -355772672, + -362268342, -368760602, -375249391, -381734648, -388216312, + -394694322, -401168617, -407639136, -414105819, -420568603, + -427027429, -433482236, -439932962, -446379548, -452821932, + -459260054, -465693853, -472123270, -478548242, -484968710, + -491384613, -497795891, -504202484, -510604331, -517001372, + -523393547, -529780795, -536163057, -542540272, -548912381, + -555279323, -561641039, -567997468, -574348551, -580694228, + -587034439, -593369125, -599698226, -606021683, -612339435, + -618651423, -624957589, -631257872, -637552214, -643840555, + -650122836, -656398997, -662668981, -668932727, -675190176, + -681441271, -687685951, -693924159, -700155836, -706380922, + -712599359, -718811090, -725016054, -731214195, -737405452, + -743589770, -749767088, -755937349, -762100495, -768256468, + -774405209, -780546662, -786680768, -792807469, -798926708, + -805038428, -811142570, -817239077, -823327892, -829408958, + -835482216, -841547611, -847605085, -853654581, -859696043, + -865729412, -871754633, -877771648, -883780402, -889780837, + -895772897, -901756525, -907731667, -913698264, -919656261, + -925605602, -931546230, -937478091, -943401128, -949315285, + -955220507, -961116738, -967003922, -972882005, -978750931, + -984610644, -990461090, -996302213, -1002133958, -1007956271, + -1013769097, -1019572381, -1025366068, -1031150104, -1036924435, + -1042689005, -1048443762, -1054188650, -1059923615, -1065648604, + -1071363563, -1077068438, -1082763175, -1088447721, -1094122022, + -1099786024, -1105439675, -1111082921, -1116715709, -1122337986, + -1127949700, -1133550796, -1139141223, -1144720928, -1150289859, + -1155847963, -1161395187, -1166931480, -1172456789, -1177971063, + -1183474249, -1188966296, -1194447152, -1199916765, -1205375084, + -1210822058, -1216257635, -1221681764, -1227094394, -1232495474, + -1237884954, -1243262782, -1248628908, -1253983282, -1259325852, + -1264656569, -1269975383, -1275282244, -1280577101, -1285859904, + -1291130605, -1296389153, -1301635499, -1306869593, -1312091387, + -1317300831, -1322497876, -1327682472, -1332854573, -1338014128, + -1343161089, -1348295408, -1353417036, -1358525925, -1363622027, + -1368705294, -1373775679, -1378833133, -1383877609, -1388909059, + -1393927437, -1398932694, -1403924784, -1408903660, -1413869274, + -1418821581, -1423760533, -1428686084, -1433598188, -1438496798, + -1443381869, -1448253354, -1453111207, -1457955383, -1462785837, + -1467602522, -1472405393, -1477194406, -1481969514, -1486730674, + -1491477840, -1496210968, -1500930013, -1505634931, -1510325677, + -1515002207, -1519664477, -1524312444, -1528946063, -1533565291, + -1538170085, -1542760401, -1547336196, -1551897427, -1556444051, + -1560976025, -1565493306, -1569995852, -1574483621, -1578956571, + -1583414658, -1587857842, -1592286081, -1596699332, -1601097554, + -1605480706, -1609848747, -1614201636, -1618539331, -1622861791, + -1627168977, -1631460847, -1635737361, -1639998479, -1644244161, + -1648474366, -1652689055, -1656888189, -1661071727, -1665239631, + -1669391861, -1673528378, -1677649143, -1681754117, -1685843262, + -1689916539, -1693973910, -1698015337, -1702040782, -1706050206, + -1710043572, -1714020842, -1717981980, -1721926947, -1725855707, + -1729768222, -1733664457, -1737544373, -1741407935, -1745255106, + -1749085850, -1752900131, -1756697913, -1760479160, -1764243837, + -1767991908, -1771723338, -1775438092, -1779136135, -1782817432, + -1786481949, -1790129650, -1793760503, -1797374471, -1800971522, + -1804551622, -1808114736, -1811660832, -1815189875, -1818701834, + -1822196674, -1825674363, -1829134868, -1832578156, -1836004196, + -1839412954, -1842804399, -1846178499, -1849535222, -1852874537, + -1856196411, -1859500815, -1862787716, -1866057083, -1869308887, + -1872543096, -1875759680, -1878958608, -1882139852, -1885303379, + -1888449162, -1891577169, -1894687373, -1897779743, -1900854250, + -1903910866, -1906949561, -1909970307, -1912973077, -1915957840, + -1918924570, -1921873238, -1924803816, -1927716278, -1930610595, + -1933486741, -1936344688, -1939184409, -1942005878, -1944809068, + -1947593953, -1950360506, -1953108702, -1955838514, -1958549918, + -1961242886, -1963917395, -1966573418, -1969210932, -1971829910, + -1974430329, -1977012164, -1979575390, -1982119984, -1984645921, + -1987153178, -1989641732, -1992111558, -1994562633, -1996994935, + -1999408441, -2001803127, -2004178971, -2006535952, -2008874046, + -2011193232, -2013493487, -2015774791, -2018037122, -2020280458, + -2022504779, -2024710063, -2026896289, -2029063438, -2031211488, + -2033340420, -2035450213, -2037540848, -2039612305, -2041664564, + -2043697606, -2045711412, -2047705963, -2049681241, -2051637226, + -2053573900, -2055491245, -2057389243, -2059267876, -2061127127, + -2062966977, -2064787410, -2066588408, -2068369955, -2070132034, + -2071874627, -2073597720, -2075301295, -2076985336, -2078649828, + -2080294755, -2081920102, -2083525853, -2085111992, -2086678506, + -2088225379, -2089752597, -2091260146, -2092748011, -2094216178, + -2095664633, -2097093364, -2098502355, -2099891595, -2101261070, + -2102610767, -2103940673, -2105250776, -2106541064, -2107811524, + -2109062145, -2110292914, -2111503821, -2112694853, -2113866000, + -2115017250, -2116148593, -2117260018, -2118351514, -2119423072, + -2120474681, -2121506331, -2122518013, -2123509717, -2124481433, + -2125433154, -2126364868, -2127276569, -2128168247, -2129039893, + -2129891501, -2130723061, -2131534566, -2132326008, -2133097379, + -2133848674, -2134579883, -2135291001, -2135982021, -2136652937, + -2137303741, -2137934428, -2138544992, -2139135428, -2139705729, + -2140255890, -2140785906, -2141295773, -2141785485, -2142255037, + -2142704426, -2143133647, -2143542696, -2143931569, -2144300262, + -2144648773, -2144977097, -2145285232, -2145573174, -2145840922, + -2146088472, -2146315823, -2146522971, -2146709916, -2146876655, + -2147023187, -2147149510, -2147255623, -2147341526, -2147407217, + -2147452695, -2147477962}, + {2147483647, 2147473540, 2147443221, 2147392689, 2147321945, 2147230990, + 2147119824, 2146988448, 2146836865, 2146665074, 2146473078, 2146260879, + 2146028478, 2145775879, 2145503082, 2145210091, 2144896908, 2144563537, + 2144209981, 2143836242, 2143442325, 2143028233, 2142593969, 2142139539, + 2141664947, 2141170196, 2140655291, 2140120238, 2139565041, 2138989706, + 2138394238, 2137778643, 2137142926, 2136487093, 2135811151, 2135115106, + 2134398964, 2133662733, 2132906418, 2132130028, 2131333570, 2130517051, + 2129680478, 2128823860, 2127947205, 2127050521, 2126133816, 2125197099, + 2124240379, 2123263664, 2122266965, 2121250290, 2120213650, 2119157053, + 2118080509, 2116984030, 2115867624, 2114731304, 2113575078, 2112398959, + 2111202957, 2109987084, 2108751350, 2107495769, 2106220350, 2104925108, + 2103610052, 2102275197, 2100920555, 2099546137, 2098151959, 2096738031, + 2095304368, 2093850983, 2092377891, 2090885104, 2089372636, 2087840503, + 2086288718, 2084717297, 2083126253, 2081515602, 2079885359, 2078235539, + 2076566158, 2074877232, 2073168776, 2071440807, 2069693340, 2067926393, + 2066139982, 2064334123, 2062508834, 2060664132, 2058800034, 2056916558, + 2055013722, 2053091543, 2051150039, 2049189229, 2047209132, 2045209765, + 2043191148, 2041153300, 2039096240, 2037019987, 2034924560, 2032809981, + 2030676267, 2028523440, 2026351520, 2024160527, 2021950482, 2019721406, + 2017473319, 2015206243, 2012920199, 2010615209, 2008291294, 2005948476, + 2003586778, 2001206221, 1998806828, 1996388621, 1993951623, 1991495858, + 1989021348, 1986528117, 1984016187, 1981485584, 1978936329, 1976368449, + 1973781966, 1971176905, 1968553290, 1965911147, 1963250500, 1960571374, + 1957873794, 1955157786, 1952423376, 1949670588, 1946899449, 1944109986, + 1941302224, 1938476189, 1935631909, 1932769410, 1929888719, 1926989863, + 1924072869, 1921137766, 1918184579, 1915213339, 1912224071, 1909216805, + 1906191569, 1903148391, 1900087299, 1897008324, 1893911493, 1890796835, + 1887664381, 1884514160, 1881346200, 1878160533, 1874957188, 1871736195, + 1868497584, 1865241387, 1861967633, 1858676353, 1855367579, 1852041342, + 1848697672, 1845336602, 1841958163, 1838562387, 1835149305, 1831718950, + 1828271354, 1824806550, 1821324571, 1817825448, 1814309215, 1810775905, + 1807225552, 1803658188, 1800073847, 1796472564, 1792854371, 1789219303, + 1785567395, 1781898680, 1778213193, 1774510969, 1770792043, 1767056449, + 1763304223, 1759535400, 1755750016, 1751948106, 1748129706, 1744294851, + 1740443579, 1736575926, 1732691926, 1728791618, 1724875039, 1720942223, + 1716993210, 1713028036, 1709046738, 1705049354, 1701035921, 1697006477, + 1692961061, 1688899710, 1684822462, 1680729356, 1676620430, 1672495724, + 1668355275, 1664199123, 1660027307, 1655839866, 1651636840, 1647418268, + 1643184190, 1638934645, 1634669674, 1630389317, 1626093615, 1621782607, + 1617456334, 1613114836, 1608758156, 1604386334, 1599999410, 1595597426, + 1591180424, 1586748446, 1582301532, 1577839725, 1573363067, 1568871600, + 1564365365, 1559844407, 1555308767, 1550758487, 1546193611, 1541614182, + 1537020242, 1532411836, 1527789006, 1523151796, 1518500249, 1513834409, + 1509154321, 1504460028, 1499751575, 1495029005, 1490292363, 1485541694, + 1480777043, 1475998454, 1471205973, 1466399644, 1461579512, 1456745624, + 1451898024, 1447036759, 1442161873, 1437273413, 1432371425, 1427455955, + 1422527049, 1417584754, 1412629116, 1407660182, 1402677998, 1397682612, + 1392674071, 1387652420, 1382617709, 1377569984, 1372509293, 1367435684, + 1362349203, 1357249900, 1352137821, 1347013016, 1341875532, 1336725418, + 1331562722, 1326387493, 1321199779, 1315999630, 1310787094, 1305562221, + 1300325059, 1295075658, 1289814067, 1284540336, 1279254514, 1273956652, + 1268646799, 1263325004, 1257991319, 1252645793, 1247288476, 1241919420, + 1236538674, 1231146290, 1225742317, 1220326808, 1214899812, 1209461381, + 1204011566, 1198550418, 1193077990, 1187594331, 1182099495, 1176593532, + 1171076494, 1165548434, 1160009404, 1154459455, 1148898639, 1143327010, + 1137744620, 1132151520, 1126547764, 1120933405, 1115308495, 1109673088, + 1104027236, 1098370992, 1092704410, 1087027543, 1081340444, 1075643168, + 1069935767, 1064218295, 1058490807, 1052753356, 1047005996, 1041248781, + 1035481765, 1029705003, 1023918549, 1018122458, 1012316783, 1006501580, + 1000676904, 994842809, 988999350, 983146582, 977284561, 971413341, + 965532977, 959643526, 953745042, 947837581, 941921199, 935995951, + 930061893, 924119081, 918167571, 912207418, 906238680, 900261412, + 894275670, 888281511, 882278991, 876268167, 870249094, 864221831, + 858186434, 852142958, 846091463, 840032003, 833964637, 827889421, + 821806412, 815715669, 809617248, 803511206, 797397601, 791276491, + 785147933, 779011985, 772868705, 766718150, 760560379, 754395449, + 748223418, 742044344, 735858286, 729665302, 723465451, 717258789, + 711045377, 704825271, 698598532, 692365217, 686125386, 679879096, + 673626407, 667367378, 661102067, 654830534, 648552837, 642269036, + 635979189, 629683356, 623381597, 617073970, 610760535, 604441351, + 598116478, 591785975, 585449902, 579108319, 572761285, 566408859, + 560051103, 553688075, 547319836, 540946445, 534567962, 528184448, + 521795962, 515402565, 509004317, 502601278, 496193509, 489781068, + 483364018, 476942419, 470516330, 464085812, 457650927, 451211733, + 444768293, 438320666, 431868914, 425413097, 418953276, 412489511, + 406021864, 399550395, 393075166, 386596236, 380113668, 373627522, + 367137860, 360644742, 354148229, 347648383, 341145265, 334638935, + 328129456, 321616889, 315101294, 308582733, 302061268, 295536960, + 289009870, 282480060, 275947591, 269412525, 262874923, 256334846, + 249792357, 243247517, 236700387, 230151030, 223599506, 217045877, + 210490205, 203932553, 197372981, 190811551, 184248325, 177683365, + 171116732, 164548489, 157978697, 151407418, 144834714, 138260647, + 131685278, 125108670, 118530884, 111951983, 105372028, 98791081, + 92209204, 85626459, 79042909, 72458614, 65873638, 59288041, + 52701886, 46115236, 39528151, 32940694, 26352927, 19764912, + 13176711, 6588386}, + {0, -6588386, -13176711, -19764912, -26352927, + -32940694, -39528151, -46115236, -52701886, -59288041, + -65873638, -72458614, -79042909, -85626459, -92209204, + -98791081, -105372028, -111951983, -118530884, -125108670, + -131685278, -138260647, -144834714, -151407418, -157978697, + -164548489, -171116732, -177683365, -184248325, -190811551, + -197372981, -203932553, -210490205, -217045877, -223599506, + -230151030, -236700387, -243247517, -249792357, -256334846, + -262874923, -269412525, -275947591, -282480060, -289009870, + -295536960, -302061268, -308582733, -315101294, -321616889, + -328129456, -334638935, -341145265, -347648383, -354148229, + -360644742, -367137860, -373627522, -380113668, -386596236, + -393075166, -399550395, -406021864, -412489511, -418953276, + -425413097, -431868914, -438320666, -444768293, -451211733, + -457650927, -464085812, -470516330, -476942419, -483364018, + -489781068, -496193509, -502601278, -509004317, -515402565, + -521795962, -528184448, -534567962, -540946445, -547319836, + -553688075, -560051103, -566408859, -572761285, -579108319, + -585449902, -591785975, -598116478, -604441351, -610760535, + -617073970, -623381597, -629683356, -635979189, -642269036, + -648552837, -654830534, -661102067, -667367378, -673626407, + -679879096, -686125386, -692365217, -698598532, -704825271, + -711045377, -717258789, -723465451, -729665302, -735858286, + -742044344, -748223418, -754395449, -760560379, -766718150, + -772868705, -779011985, -785147933, -791276491, -797397601, + -803511206, -809617248, -815715669, -821806412, -827889421, + -833964637, -840032003, -846091463, -852142958, -858186434, + -864221831, -870249094, -876268167, -882278991, -888281511, + -894275670, -900261412, -906238680, -912207418, -918167571, + -924119081, -930061893, -935995951, -941921199, -947837581, + -953745042, -959643526, -965532977, -971413341, -977284561, + -983146582, -988999350, -994842809, -1000676904, -1006501580, + -1012316783, -1018122458, -1023918549, -1029705003, -1035481765, + -1041248781, -1047005996, -1052753356, -1058490807, -1064218295, + -1069935767, -1075643168, -1081340444, -1087027543, -1092704410, + -1098370992, -1104027236, -1109673088, -1115308495, -1120933405, + -1126547764, -1132151520, -1137744620, -1143327010, -1148898639, + -1154459455, -1160009404, -1165548434, -1171076494, -1176593532, + -1182099495, -1187594331, -1193077990, -1198550418, -1204011566, + -1209461381, -1214899812, -1220326808, -1225742317, -1231146290, + -1236538674, -1241919420, -1247288476, -1252645793, -1257991319, + -1263325004, -1268646799, -1273956652, -1279254514, -1284540336, + -1289814067, -1295075658, -1300325059, -1305562221, -1310787094, + -1315999630, -1321199779, -1326387493, -1331562722, -1336725418, + -1341875532, -1347013016, -1352137821, -1357249900, -1362349203, + -1367435684, -1372509293, -1377569984, -1382617709, -1387652420, + -1392674071, -1397682612, -1402677998, -1407660182, -1412629116, + -1417584754, -1422527049, -1427455955, -1432371425, -1437273413, + -1442161873, -1447036759, -1451898024, -1456745624, -1461579512, + -1466399644, -1471205973, -1475998454, -1480777043, -1485541694, + -1490292363, -1495029005, -1499751575, -1504460028, -1509154321, + -1513834409, -1518500249, -1523151796, -1527789006, -1532411836, + -1537020242, -1541614182, -1546193611, -1550758487, -1555308767, + -1559844407, -1564365365, -1568871600, -1573363067, -1577839725, + -1582301532, -1586748446, -1591180424, -1595597426, -1599999410, + -1604386334, -1608758156, -1613114836, -1617456334, -1621782607, + -1626093615, -1630389317, -1634669674, -1638934645, -1643184190, + -1647418268, -1651636840, -1655839866, -1660027307, -1664199123, + -1668355275, -1672495724, -1676620430, -1680729356, -1684822462, + -1688899710, -1692961061, -1697006477, -1701035921, -1705049354, + -1709046738, -1713028036, -1716993210, -1720942223, -1724875039, + -1728791618, -1732691926, -1736575926, -1740443579, -1744294851, + -1748129706, -1751948106, -1755750016, -1759535400, -1763304223, + -1767056449, -1770792043, -1774510969, -1778213193, -1781898680, + -1785567395, -1789219303, -1792854371, -1796472564, -1800073847, + -1803658188, -1807225552, -1810775905, -1814309215, -1817825448, + -1821324571, -1824806550, -1828271354, -1831718950, -1835149305, + -1838562387, -1841958163, -1845336602, -1848697672, -1852041342, + -1855367579, -1858676353, -1861967633, -1865241387, -1868497584, + -1871736195, -1874957188, -1878160533, -1881346200, -1884514160, + -1887664381, -1890796835, -1893911493, -1897008324, -1900087299, + -1903148391, -1906191569, -1909216805, -1912224071, -1915213339, + -1918184579, -1921137766, -1924072869, -1926989863, -1929888719, + -1932769410, -1935631909, -1938476189, -1941302224, -1944109986, + -1946899449, -1949670588, -1952423376, -1955157786, -1957873794, + -1960571374, -1963250500, -1965911147, -1968553290, -1971176905, + -1973781966, -1976368449, -1978936329, -1981485584, -1984016187, + -1986528117, -1989021348, -1991495858, -1993951623, -1996388621, + -1998806828, -2001206221, -2003586778, -2005948476, -2008291294, + -2010615209, -2012920199, -2015206243, -2017473319, -2019721406, + -2021950482, -2024160527, -2026351520, -2028523440, -2030676267, + -2032809981, -2034924560, -2037019987, -2039096240, -2041153300, + -2043191148, -2045209765, -2047209132, -2049189229, -2051150039, + -2053091543, -2055013722, -2056916558, -2058800034, -2060664132, + -2062508834, -2064334123, -2066139982, -2067926393, -2069693340, + -2071440807, -2073168776, -2074877232, -2076566158, -2078235539, + -2079885359, -2081515602, -2083126253, -2084717297, -2086288718, + -2087840503, -2089372636, -2090885104, -2092377891, -2093850983, + -2095304368, -2096738031, -2098151959, -2099546137, -2100920555, + -2102275197, -2103610052, -2104925108, -2106220350, -2107495769, + -2108751350, -2109987084, -2111202957, -2112398959, -2113575078, + -2114731304, -2115867624, -2116984030, -2118080509, -2119157053, + -2120213650, -2121250290, -2122266965, -2123263664, -2124240379, + -2125197099, -2126133816, -2127050521, -2127947205, -2128823860, + -2129680478, -2130517051, -2131333570, -2132130028, -2132906418, + -2133662733, -2134398964, -2135115106, -2135811151, -2136487093, + -2137142926, -2137778643, -2138394238, -2138989706, -2139565041, + -2140120238, -2140655291, -2141170196, -2141664947, -2142139539, + -2142593969, -2143028233, -2143442325, -2143836242, -2144209981, + -2144563537, -2144896908, -2145210091, -2145503082, -2145775879, + -2146028478, -2146260879, -2146473078, -2146665074, -2146836865, + -2146988448, -2147119824, -2147230990, -2147321945, -2147392689, + -2147443221, -2147473540}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_384[4][384] = { + {2147483647, 2147465679, 2147411779, 2147321945, 2147196180, 2147034485, + 2146836865, 2146603320, 2146333857, 2146028478, 2145687190, 2145309998, + 2144896908, 2144447928, 2143963064, 2143442325, 2142885719, 2142293256, + 2141664947, 2141000800, 2140300828, 2139565041, 2138793454, 2137986077, + 2137142926, 2136264013, 2135349354, 2134398964, 2133412859, 2132391055, + 2131333570, 2130240421, 2129111626, 2127947205, 2126747176, 2125511561, + 2124240379, 2122933651, 2121591401, 2120213650, 2118800421, 2117351737, + 2115867624, 2114348106, 2112793208, 2111202957, 2109577379, 2107916501, + 2106220350, 2104488957, 2102722348, 2100920555, 2099083606, 2097211534, + 2095304368, 2093362142, 2091384887, 2089372636, 2087325424, 2085243285, + 2083126253, 2080974364, 2078787653, 2076566158, 2074309916, 2072018964, + 2069693340, 2067333084, 2064938236, 2062508834, 2060044920, 2057546536, + 2055013722, 2052446521, 2049844977, 2047209132, 2044539031, 2041834718, + 2039096240, 2036323641, 2033516967, 2030676267, 2027801588, 2024892976, + 2021950482, 2018974155, 2015964044, 2012920199, 2009842672, 2006731514, + 2003586778, 2000408515, 1997196779, 1993951623, 1990673103, 1987361273, + 1984016187, 1980637903, 1977226477, 1973781966, 1970304427, 1966793919, + 1963250500, 1959674230, 1956065168, 1952423376, 1948748913, 1945041841, + 1941302224, 1937530122, 1933725599, 1929888719, 1926019545, 1922118144, + 1918184579, 1914218918, 1910221225, 1906191569, 1902130016, 1898036634, + 1893911493, 1889754660, 1885566206, 1881346200, 1877094714, 1872811818, + 1868497584, 1864152085, 1859775392, 1855367579, 1850928721, 1846458890, + 1841958163, 1837426614, 1832864319, 1828271354, 1823647797, 1818993725, + 1814309215, 1809594346, 1804849197, 1800073847, 1795268377, 1790432865, + 1785567395, 1780672046, 1775746901, 1770792043, 1765807553, 1760793516, + 1755750016, 1750677136, 1745574962, 1740443579, 1735283073, 1730093531, + 1724875039, 1719627684, 1714351554, 1709046738, 1703713324, 1698351402, + 1692961061, 1687542392, 1682095484, 1676620430, 1671117321, 1665586249, + 1660027307, 1654440587, 1648826183, 1643184190, 1637514700, 1631817810, + 1626093615, 1620342210, 1614563691, 1608758156, 1602925701, 1597066425, + 1591180424, 1585267799, 1579328646, 1573363067, 1567371160, 1561353026, + 1555308767, 1549238481, 1543142273, 1537020242, 1530872493, 1524699127, + 1518500249, 1512275961, 1506026368, 1499751575, 1493451686, 1487126807, + 1480777043, 1474402502, 1468003289, 1461579512, 1455131279, 1448658696, + 1442161873, 1435640918, 1429095940, 1422527049, 1415934355, 1409317968, + 1402677998, 1396014558, 1389327757, 1382617709, 1375884526, 1369128319, + 1362349203, 1355547290, 1348722695, 1341875532, 1335005915, 1328113959, + 1321199779, 1314263492, 1307305213, 1300325059, 1293323146, 1286299592, + 1279254514, 1272188031, 1265100259, 1257991319, 1250861328, 1243710407, + 1236538674, 1229346251, 1222133256, 1214899812, 1207646038, 1200372057, + 1193077990, 1185763959, 1178430086, 1171076494, 1163703307, 1156310648, + 1148898639, 1141467406, 1134017073, 1126547764, 1119059605, 1111552720, + 1104027236, 1096483277, 1088920971, 1081340444, 1073741823, 1066125235, + 1058490807, 1050838667, 1043168944, 1035481765, 1027777259, 1020055555, + 1012316783, 1004561071, 996788550, 988999350, 981193601, 973371433, + 965532977, 957678366, 949807729, 941921199, 934018908, 926100988, + 918167571, 910218790, 902254779, 894275670, 886281597, 878272694, + 870249094, 862210933, 854158344, 846091463, 838010423, 829915361, + 821806412, 813683712, 805547396, 797397601, 789234463, 781058119, + 772868705, 764666359, 756451217, 748223418, 739983098, 731730396, + 723465451, 715188399, 706899380, 698598532, 690285995, 681961907, + 673626407, 665279636, 656921733, 648552837, 640173089, 631782629, + 623381597, 614970134, 606548381, 598116478, 589674567, 581222788, + 572761285, 564290197, 555809666, 547319836, 538820847, 530312841, + 521795962, 513270352, 504736153, 496193509, 487642561, 479083454, + 470516330, 461941333, 453358606, 444768293, 436170538, 427565484, + 418953276, 410334057, 401707972, 393075166, 384435782, 375789965, + 367137860, 358479612, 349815365, 341145265, 332469456, 323788084, + 315101294, 306409231, 297712042, 289009870, 280302863, 271591165, + 262874923, 254154282, 245429388, 236700387, 227967426, 219230650, + 210490205, 201746239, 192998897, 184248325, 175494670, 166738078, + 157978697, 149216672, 140452150, 131685278, 122916202, 114145070, + 105372028, 96597222, 87820800, 79042909, 70263695, 61483305, + 52701886, 43919586, 35136551, 26352927, 17568863, 8784505}, + {0, -8784505, -17568863, -26352927, -35136551, + -43919586, -52701886, -61483305, -70263695, -79042909, + -87820800, -96597222, -105372028, -114145070, -122916202, + -131685278, -140452150, -149216672, -157978697, -166738078, + -175494670, -184248325, -192998897, -201746239, -210490205, + -219230650, -227967426, -236700387, -245429388, -254154282, + -262874923, -271591165, -280302863, -289009870, -297712042, + -306409231, -315101294, -323788084, -332469456, -341145265, + -349815365, -358479612, -367137860, -375789965, -384435782, + -393075166, -401707972, -410334057, -418953276, -427565484, + -436170538, -444768293, -453358606, -461941333, -470516330, + -479083454, -487642561, -496193509, -504736153, -513270352, + -521795962, -530312841, -538820847, -547319836, -555809666, + -564290197, -572761285, -581222788, -589674567, -598116478, + -606548381, -614970134, -623381597, -631782629, -640173089, + -648552837, -656921733, -665279636, -673626407, -681961907, + -690285995, -698598532, -706899380, -715188399, -723465451, + -731730396, -739983098, -748223418, -756451217, -764666359, + -772868705, -781058119, -789234463, -797397601, -805547396, + -813683712, -821806412, -829915361, -838010423, -846091463, + -854158344, -862210933, -870249094, -878272694, -886281597, + -894275670, -902254779, -910218790, -918167571, -926100988, + -934018908, -941921199, -949807729, -957678366, -965532977, + -973371433, -981193601, -988999350, -996788550, -1004561071, + -1012316783, -1020055555, -1027777259, -1035481765, -1043168944, + -1050838667, -1058490807, -1066125235, -1073741823, -1081340444, + -1088920971, -1096483277, -1104027236, -1111552720, -1119059605, + -1126547764, -1134017073, -1141467406, -1148898639, -1156310648, + -1163703307, -1171076494, -1178430086, -1185763959, -1193077990, + -1200372057, -1207646038, -1214899812, -1222133256, -1229346251, + -1236538674, -1243710407, -1250861328, -1257991319, -1265100259, + -1272188031, -1279254514, -1286299592, -1293323146, -1300325059, + -1307305213, -1314263492, -1321199779, -1328113959, -1335005915, + -1341875532, -1348722695, -1355547290, -1362349203, -1369128319, + -1375884526, -1382617709, -1389327757, -1396014558, -1402677998, + -1409317968, -1415934355, -1422527049, -1429095940, -1435640918, + -1442161873, -1448658696, -1455131279, -1461579512, -1468003289, + -1474402502, -1480777043, -1487126807, -1493451686, -1499751575, + -1506026368, -1512275961, -1518500249, -1524699127, -1530872493, + -1537020242, -1543142273, -1549238481, -1555308767, -1561353026, + -1567371160, -1573363067, -1579328646, -1585267799, -1591180424, + -1597066425, -1602925701, -1608758156, -1614563691, -1620342210, + -1626093615, -1631817810, -1637514700, -1643184190, -1648826183, + -1654440587, -1660027307, -1665586249, -1671117321, -1676620430, + -1682095484, -1687542392, -1692961061, -1698351402, -1703713324, + -1709046738, -1714351554, -1719627684, -1724875039, -1730093531, + -1735283073, -1740443579, -1745574962, -1750677136, -1755750016, + -1760793516, -1765807553, -1770792043, -1775746901, -1780672046, + -1785567395, -1790432865, -1795268377, -1800073847, -1804849197, + -1809594346, -1814309215, -1818993725, -1823647797, -1828271354, + -1832864319, -1837426614, -1841958163, -1846458890, -1850928721, + -1855367579, -1859775392, -1864152085, -1868497584, -1872811818, + -1877094714, -1881346200, -1885566206, -1889754660, -1893911493, + -1898036634, -1902130016, -1906191569, -1910221225, -1914218918, + -1918184579, -1922118144, -1926019545, -1929888719, -1933725599, + -1937530122, -1941302224, -1945041841, -1948748913, -1952423376, + -1956065168, -1959674230, -1963250500, -1966793919, -1970304427, + -1973781966, -1977226477, -1980637903, -1984016187, -1987361273, + -1990673103, -1993951623, -1997196779, -2000408515, -2003586778, + -2006731514, -2009842672, -2012920199, -2015964044, -2018974155, + -2021950482, -2024892976, -2027801588, -2030676267, -2033516967, + -2036323641, -2039096240, -2041834718, -2044539031, -2047209132, + -2049844977, -2052446521, -2055013722, -2057546536, -2060044920, + -2062508834, -2064938236, -2067333084, -2069693340, -2072018964, + -2074309916, -2076566158, -2078787653, -2080974364, -2083126253, + -2085243285, -2087325424, -2089372636, -2091384887, -2093362142, + -2095304368, -2097211534, -2099083606, -2100920555, -2102722348, + -2104488957, -2106220350, -2107916501, -2109577379, -2111202957, + -2112793208, -2114348106, -2115867624, -2117351737, -2118800421, + -2120213650, -2121591401, -2122933651, -2124240379, -2125511561, + -2126747176, -2127947205, -2129111626, -2130240421, -2131333570, + -2132391055, -2133412859, -2134398964, -2135349354, -2136264013, + -2137142926, -2137986077, -2138793454, -2139565041, -2140300828, + -2141000800, -2141664947, -2142293256, -2142885719, -2143442325, + -2143963064, -2144447928, -2144896908, -2145309998, -2145687190, + -2146028478, -2146333857, -2146603320, -2146836865, -2147034485, + -2147196180, -2147321945, -2147411779, -2147465679}, + {2147482524, 2147455573, 2147392689, 2147293872, 2147159125, 2146988448, + 2146781846, 2146539322, 2146260879, 2145946523, 2145596258, 2145210091, + 2144788028, 2144330076, 2143836242, 2143306535, 2142740965, 2142139539, + 2141502269, 2140829165, 2140120238, 2139375500, 2138594964, 2137778643, + 2136926550, 2136038699, 2135115106, 2134155786, 2133160754, 2132130028, + 2131063626, 2129961563, 2128823860, 2127650535, 2126441608, 2125197099, + 2123917028, 2122601418, 2121250290, 2119863668, 2118441573, 2116984030, + 2115491063, 2113962698, 2112398959, 2110799873, 2109165467, 2107495769, + 2105790805, 2104050605, 2102275197, 2100464612, 2098618880, 2096738031, + 2094822097, 2092871111, 2090885104, 2088864110, 2086808163, 2084717297, + 2082591547, 2080430949, 2078235539, 2076005354, 2073740430, 2071440807, + 2069106521, 2066737614, 2064334123, 2061896089, 2059423554, 2056916558, + 2054375144, 2051799353, 2049189229, 2046544816, 2043866158, 2041153300, + 2038406287, 2035625165, 2032809981, 2029960781, 2027077614, 2024160527, + 2021209571, 2018224792, 2015206243, 2012153973, 2009068034, 2005948476, + 2002795353, 1999608717, 1996388621, 1993135119, 1989848266, 1986528117, + 1983174727, 1979788152, 1976368449, 1972915675, 1969429888, 1965911147, + 1962359510, 1958775036, 1955157786, 1951507820, 1947825200, 1944109986, + 1940362241, 1936582028, 1932769410, 1928924450, 1925047214, 1921137766, + 1917196171, 1913222495, 1909216805, 1905179168, 1901109652, 1897008324, + 1892875253, 1888710508, 1884514160, 1880286277, 1876026932, 1871736195, + 1867414138, 1863060833, 1858676353, 1854260772, 1849814164, 1845336602, + 1840828162, 1836288920, 1831718950, 1827118330, 1822487137, 1817825448, + 1813133341, 1808410894, 1803658188, 1798875300, 1794062312, 1789219303, + 1784346356, 1779443550, 1774510969, 1769548695, 1764556811, 1759535400, + 1754484547, 1749404336, 1744294851, 1739156180, 1733988407, 1728791618, + 1723565902, 1718311345, 1713028036, 1707716062, 1702375513, 1697006477, + 1691609046, 1686183309, 1680729356, 1675247280, 1669737171, 1664199123, + 1658633228, 1653039578, 1647418268, 1641769391, 1636093043, 1630389317, + 1624658311, 1618900118, 1613114836, 1607302562, 1601463393, 1595597426, + 1589704760, 1583785493, 1577839725, 1571867554, 1565869082, 1559844407, + 1553793631, 1547716856, 1541614182, 1535485712, 1529331549, 1523151796, + 1516946555, 1510715931, 1504460028, 1498178951, 1491872805, 1485541694, + 1479185727, 1472805008, 1466399644, 1459969743, 1453515412, 1447036759, + 1440533892, 1434006921, 1427455955, 1420881103, 1414282475, 1407660182, + 1401014334, 1394345043, 1387652420, 1380936578, 1374197628, 1367435684, + 1360650858, 1353843264, 1347013016, 1340160228, 1333285016, 1326387493, + 1319467776, 1312525980, 1305562221, 1298576616, 1291569282, 1284540336, + 1277489896, 1270418079, 1263325004, 1256210790, 1249075556, 1241919420, + 1234742504, 1227544926, 1220326808, 1213088269, 1205829433, 1198550418, + 1191251349, 1183932346, 1176593532, 1169235030, 1161856963, 1154459455, + 1147042629, 1139606609, 1132151520, 1124677487, 1117184634, 1109673088, + 1102142973, 1094594416, 1087027543, 1079442480, 1071839355, 1064218295, + 1056579428, 1048922880, 1041248781, 1033557258, 1025848440, 1018122458, + 1010379438, 1002619512, 994842809, 987049459, 979239593, 971413341, + 963570834, 955712204, 947837581, 939947099, 932040888, 924119081, + 916181811, 908229210, 900261412, 892278549, 884280756, 876268167, + 868240914, 860199133, 852142958, 844072525, 835987967, 827889421, + 819777021, 811650904, 803511206, 795358062, 787191610, 779011985, + 770819326, 762613767, 754395449, 746164506, 737921078, 729665302, + 721397317, 713117261, 704825271, 696521488, 688206050, 679879096, + 671540766, 663191198, 654830534, 646458912, 638076473, 629683356, + 621279704, 612865655, 604441351, 596006933, 587562542, 579108319, + 570644406, 562170944, 553688075, 545195941, 536694685, 528184448, + 519665373, 511137602, 502601278, 494056544, 485503544, 476942419, + 468373313, 459796370, 451211733, 442619546, 434019953, 425413097, + 416799123, 408178174, 399550395, 390915931, 382274925, 373627522, + 364973868, 356314107, 347648383, 338976842, 330299629, 321616889, + 312928767, 304235409, 295536960, 286833566, 278125372, 269412525, + 260695169, 251973451, 243247517, 234517512, 225783584, 217045877, + 208304538, 199559714, 190811551, 182060194, 173305792, 164548489, + 155788433, 147025770, 138260647, 129493210, 120723606, 111951983, + 103178486, 94403263, 85626459, 76848224, 68068702, 59288041, + 50506388, 41723890, 32940694, 24156947, 15372795, 6588386}, + {-2196132, -10980614, -19764912, -28548880, -37332370, + -46115236, -54897329, -63678505, -72458614, -81237511, + -90015049, -98791081, -107565459, -116338038, -125108670, + -133877208, -142643507, -151407418, -160168796, -168927494, + -177683365, -186436262, -195186041, -203932553, -212675652, + -221415193, -230151030, -238883014, -247611002, -256334846, + -265054401, -273769521, -282480060, -291185872, -299886812, + -308582733, -317273491, -325958940, -334638935, -343313330, + -351981981, -360644742, -369301468, -377952014, -386596236, + -395233990, -403865129, -412489511, -421106991, -429717424, + -438320666, -446916575, -455505004, -464085812, -472658854, + -481223988, -489781068, -498329954, -506870500, -515402565, + -523926006, -532440680, -540946445, -549443158, -557930676, + -566408859, -574877565, -583336650, -591785975, -600225397, + -608654776, -617073970, -625482838, -633881240, -642269036, + -650646084, -659012245, -667367378, -675711344, -684044004, + -692365217, -700674845, -708972749, -717258789, -725532827, + -733794725, -742044344, -750281547, -758506195, -766718150, + -774917276, -783103436, -791276491, -799436306, -807582744, + -815715669, -823834944, -831940434, -840032003, -848109516, + -856172837, -864221831, -872256365, -880276303, -888281511, + -896271855, -904247202, -912207418, -920152371, -928081926, + -935995951, -943894314, -951776883, -959643526, -967494111, + -975328507, -983146582, -990948207, -998733250, -1006501580, + -1014253069, -1021987587, -1029705003, -1037405189, -1045088016, + -1052753356, -1060401079, -1068031059, -1075643168, -1083237277, + -1090813261, -1098370992, -1105910344, -1113431190, -1120933405, + -1128416864, -1135881440, -1143327010, -1150753449, -1158160631, + -1165548434, -1172916734, -1180265407, -1187594331, -1194903383, + -1202192440, -1209461381, -1216710083, -1223938427, -1231146290, + -1238333552, -1245500093, -1252645793, -1259770532, -1266874191, + -1273956652, -1281017795, -1288057503, -1295075658, -1302072142, + -1309046838, -1315999630, -1322930401, -1329839036, -1336725418, + -1343589432, -1350430964, -1357249900, -1364046124, -1370819523, + -1377569984, -1384297395, -1391001641, -1397682612, -1404340196, + -1410974280, -1417584754, -1424171508, -1430734431, -1437273413, + -1443788345, -1450279119, -1456745624, -1463187754, -1469605400, + -1475998454, -1482366811, -1488710363, -1495029005, -1501322630, + -1507591133, -1513834409, -1520052355, -1526244865, -1532411836, + -1538553165, -1544668750, -1550758487, -1556822275, -1562860013, + -1568871600, -1574856934, -1580815916, -1586748446, -1592654425, + -1598533753, -1604386334, -1610212067, -1616010857, -1621782607, + -1627527218, -1633244596, -1638934645, -1644597269, -1650232375, + -1655839866, -1661419650, -1666971634, -1672495724, -1677991828, + -1683459854, -1688899710, -1694311306, -1699694550, -1705049354, + -1710375626, -1715673279, -1720942223, -1726182371, -1731393634, + -1736575926, -1741729159, -1746853247, -1751948106, -1757013649, + -1762049791, -1767056449, -1772033539, -1776980976, -1781898680, + -1786786567, -1791644555, -1796472564, -1801270512, -1806038319, + -1810775905, -1815483192, -1820160100, -1824806550, -1829422467, + -1834007771, -1838562387, -1843086237, -1847579248, -1852041342, + -1856472446, -1860872486, -1865241387, -1869579077, -1873885483, + -1878160533, -1882404156, -1886616280, -1890796835, -1894945752, + -1899062960, -1903148391, -1907201976, -1911223648, -1915213339, + -1919170982, -1923096512, -1926989863, -1930850969, -1934679765, + -1938476189, -1942240176, -1945971663, -1949670588, -1953336889, + -1956970504, -1960571374, -1964139437, -1967674633, -1971176905, + -1974646192, -1978082438, -1981485584, -1984855573, -1988192350, + -1991495858, -1994766042, -1998002848, -2001206221, -2004376107, + -2007512454, -2010615209, -2013684320, -2016719736, -2019721406, + -2022689280, -2025623308, -2028523440, -2031389630, -2034221828, + -2037019987, -2039784060, -2042514001, -2045209765, -2047871306, + -2050498580, -2053091543, -2055650151, -2058174361, -2060664132, + -2063119422, -2065540189, -2067926393, -2070277994, -2072594954, + -2074877232, -2077124791, -2079337593, -2081515602, -2083658780, + -2085767092, -2087840503, -2089878978, -2091882483, -2093850983, + -2095784448, -2097682843, -2099546137, -2101374300, -2103167300, + -2104925108, -2106647693, -2108335028, -2109987084, -2111603833, + -2113185248, -2114731304, -2116241973, -2117717231, -2119157053, + -2120561414, -2121930293, -2123263664, -2124561507, -2125823800, + -2127050521, -2128241649, -2129397166, -2130517051, -2131601286, + -2132649852, -2133662733, -2134639911, -2135581369, -2136487093, + -2137357067, -2138191276, -2138989706, -2139752345, -2140479179, + -2141170196, -2141825384, -2142444733, -2143028233, -2143575872, + -2144087643, -2144563537, -2145003546, -2145407662, -2145775879, + -2146108190, -2146404590, -2146665074, -2146889638, -2147078277, + -2147230990, -2147347772, -2147428623, -2147473540}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_256[4][256] = { + {2147481120, 2147420481, 2147278994, 2147056662, 2146753495, 2146369504, + 2145904703, 2145359111, 2144732746, 2144025634, 2143237800, 2142369275, + 2141420091, 2140390283, 2139279891, 2138088956, 2136817524, 2135465641, + 2134033359, 2132520732, 2130927817, 2129254674, 2127501366, 2125667958, + 2123754520, 2121761124, 2119687845, 2117534761, 2115301953, 2112989505, + 2110597504, 2108126040, 2105575206, 2102945099, 2100235817, 2097447462, + 2094580140, 2091633958, 2088609027, 2085505461, 2082323377, 2079062895, + 2075724137, 2072307229, 2068812301, 2065239482, 2061588909, 2057860717, + 2054055049, 2050172046, 2046211856, 2042174627, 2038060511, 2033869663, + 2029602242, 2025258407, 2020838322, 2016342154, 2011770071, 2007122247, + 2002398855, 1997600075, 1992726085, 1987777071, 1982753218, 1977654716, + 1972481756, 1967234533, 1961913245, 1956518092, 1951049277, 1945507007, + 1939891489, 1934202935, 1928441559, 1922607579, 1916701214, 1910722686, + 1904672221, 1898550045, 1892356390, 1886091490, 1879755578, 1873348896, + 1866871682, 1860324182, 1853706642, 1847019310, 1840262440, 1833436285, + 1826541101, 1819577150, 1812544693, 1805443994, 1798275321, 1791038944, + 1783735136, 1776364171, 1768926327, 1761421884, 1753851124, 1746214333, + 1738511798, 1730743809, 1722910658, 1715012641, 1707050054, 1699023198, + 1690932375, 1682777889, 1674560047, 1666279160, 1657935537, 1649529495, + 1641061348, 1632531417, 1623940021, 1615287485, 1606574135, 1597800298, + 1588966305, 1580072488, 1571119182, 1562106724, 1553035454, 1543905713, + 1534717845, 1525472195, 1516169113, 1506808947, 1497392051, 1487918779, + 1478389488, 1468804536, 1459164285, 1449469097, 1439719337, 1429915373, + 1420057573, 1410146308, 1400181953, 1390164881, 1380095471, 1369974100, + 1359801151, 1349577006, 1339302051, 1328976671, 1318601256, 1308176197, + 1297701885, 1287178716, 1276607085, 1265987391, 1255320033, 1244605413, + 1233843934, 1223036001, 1212182022, 1201282406, 1190337561, 1179347901, + 1168313839, 1157235791, 1146114173, 1134949405, 1123741907, 1112492100, + 1101200409, 1089867258, 1078493075, 1067078287, 1055623323, 1044128616, + 1032594599, 1021021705, 1009410369, 997761030, 986074126, 974350097, + 962589384, 950792430, 938959680, 927091578, 915188571, 903251109, + 891279639, 879274613, 867236483, 855165702, 843062725, 830928006, + 818762004, 806565176, 794337981, 782080880, 769794333, 757478805, + 745134758, 732762657, 720362967, 707936157, 695482693, 683003045, + 670497682, 657967075, 645411696, 632832017, 620228513, 607601658, + 594951926, 582279796, 569585742, 556870244, 544133780, 531376830, + 518599874, 505803393, 492987869, 480153783, 467301621, 454431865, + 441544999, 428641510, 415721883, 402786603, 389836160, 376871039, + 363891729, 350898719, 337892497, 324873555, 311842381, 298799466, + 285745301, 272680379, 259605190, 246520227, 233425983, 220322950, + 207211623, 194092494, 180966058, 167832808, 154693239, 141547847, + 128397125, 115241569, 102081674, 88917936, 75750851, 62580913, + 49408619, 36234465, 23058947, 9882561}, + {-3294197, -16470831, -29646846, -42821744, -55995030, + -69166207, -82334781, -95500255, -108662133, -121819920, + -134973121, -148121240, -161263783, -174400253, -187530158, + -200653003, -213768293, -226875534, -239974234, -253063900, + -266144037, -279214154, -292273759, -305322360, -318359466, + -331384586, -344397229, -357396906, -370383127, -383355403, + -396313247, -409256169, -422183683, -435095302, -447990540, + -460868912, -473729932, -486573116, -499397981, -512204044, + -524990823, -537757836, -550504603, -563230644, -575935479, + -588618631, -601279622, -613917975, -626533214, -639124864, + -651692452, -664235504, -676753548, -689246113, -701712727, + -714152923, -726566231, -738952185, -751310317, -763640163, + -775941258, -788213140, -800455345, -812667415, -824848887, + -836999305, -849118210, -861205146, -873259658, -885281292, + -897269597, -909224119, -921144410, -933030020, -944880502, + -956695410, -968474299, -980216725, -991922247, -1003590423, + -1015220815, -1026812984, -1038366494, -1049880911, -1061355800, + -1072790729, -1084185269, -1095538990, -1106851464, -1118122266, + -1129350971, -1140537157, -1151680402, -1162780287, -1173836394, + -1184848307, -1195815611, -1206737893, -1217614742, -1228445749, + -1239230505, -1249968605, -1260659645, -1271303221, -1281898933, + -1292446383, -1302945173, -1313394908, -1323795194, -1334145640, + -1344445856, -1354695454, -1364894049, -1375041257, -1385136695, + -1395179983, -1405170743, -1415108600, -1424993179, -1434824107, + -1444601016, -1454323535, -1463991301, -1473603947, -1483161114, + -1492662440, -1502107569, -1511496144, -1520827811, -1530102221, + -1539319023, -1548477871, -1557578419, -1566620326, -1575603250, + -1584526853, -1593390800, -1602194757, -1610938392, -1619621376, + -1628243382, -1636804086, -1645303165, -1653740299, -1662115171, + -1670427465, -1678676868, -1686863071, -1694985763, -1703044641, + -1711039400, -1718969739, -1726835360, -1734635967, -1742371265, + -1750040965, -1757644776, -1765182413, -1772653592, -1780058031, + -1787395452, -1794665579, -1801868137, -1809002857, -1816069468, + -1823067705, -1829997305, -1836858007, -1843649552, -1850371684, + -1857024151, -1863606703, -1870119090, -1876561068, -1882932395, + -1889232831, -1895462138, -1901620082, -1907706431, -1913720956, + -1919663431, -1925533631, -1931331336, -1937056328, -1942708390, + -1948287311, -1953792880, -1959224889, -1964583135, -1969867415, + -1975077531, -1980213286, -1985274488, -1990260945, -1995172470, + -2000008877, -2004769986, -2009455616, -2014065591, -2018599738, + -2023057885, -2027439866, -2031745514, -2035974669, -2040127170, + -2044202862, -2048201590, -2052123205, -2055967559, -2059734506, + -2063423906, -2067035619, -2070569510, -2074025444, -2077403293, + -2080702928, -2083924227, -2087067066, -2090131329, -2093116900, + -2096023666, -2098851517, -2101600349, -2104270056, -2106860538, + -2109371699, -2111803443, -2114155678, -2116428317, -2118621274, + -2120734465, -2122767812, -2124721239, -2126594670, -2128388037, + -2130101271, -2131734307, -2133287086, -2134759547, -2136151635, + -2137463299, -2138694489, -2139845157, -2140915262, -2141904763, + -2142813622, -2143641805, -2144389282, -2145056023, -2145642005, + -2146147204, -2146571602, -2146915182, -2147177933, -2147359843, + -2147460907}, + {2147483647, 2147443221, 2147321945, 2147119824, 2146836865, 2146473078, + 2146028478, 2145503082, 2144896908, 2144209981, 2143442325, 2142593969, + 2141664947, 2140655291, 2139565041, 2138394238, 2137142926, 2135811151, + 2134398964, 2132906418, 2131333570, 2129680478, 2127947205, 2126133816, + 2124240379, 2122266965, 2120213650, 2118080509, 2115867624, 2113575078, + 2111202957, 2108751350, 2106220350, 2103610052, 2100920555, 2098151959, + 2095304368, 2092377891, 2089372636, 2086288718, 2083126253, 2079885359, + 2076566158, 2073168776, 2069693340, 2066139982, 2062508834, 2058800034, + 2055013722, 2051150039, 2047209132, 2043191148, 2039096240, 2034924560, + 2030676267, 2026351520, 2021950482, 2017473319, 2012920199, 2008291294, + 2003586778, 1998806828, 1993951623, 1989021348, 1984016187, 1978936329, + 1973781966, 1968553290, 1963250500, 1957873794, 1952423376, 1946899449, + 1941302224, 1935631909, 1929888719, 1924072869, 1918184579, 1912224071, + 1906191569, 1900087299, 1893911493, 1887664381, 1881346200, 1874957188, + 1868497584, 1861967633, 1855367579, 1848697672, 1841958163, 1835149305, + 1828271354, 1821324571, 1814309215, 1807225552, 1800073847, 1792854371, + 1785567395, 1778213193, 1770792043, 1763304223, 1755750016, 1748129706, + 1740443579, 1732691926, 1724875039, 1716993210, 1709046738, 1701035921, + 1692961061, 1684822462, 1676620430, 1668355275, 1660027307, 1651636840, + 1643184190, 1634669674, 1626093615, 1617456334, 1608758156, 1599999410, + 1591180424, 1582301532, 1573363067, 1564365365, 1555308767, 1546193611, + 1537020242, 1527789006, 1518500249, 1509154321, 1499751575, 1490292363, + 1480777043, 1471205973, 1461579512, 1451898024, 1442161873, 1432371425, + 1422527049, 1412629116, 1402677998, 1392674071, 1382617709, 1372509293, + 1362349203, 1352137821, 1341875532, 1331562722, 1321199779, 1310787094, + 1300325059, 1289814067, 1279254514, 1268646799, 1257991319, 1247288476, + 1236538674, 1225742317, 1214899812, 1204011566, 1193077990, 1182099495, + 1171076494, 1160009404, 1148898639, 1137744620, 1126547764, 1115308495, + 1104027236, 1092704410, 1081340444, 1069935767, 1058490807, 1047005996, + 1035481765, 1023918549, 1012316783, 1000676904, 988999350, 977284561, + 965532977, 953745042, 941921199, 930061893, 918167571, 906238680, + 894275670, 882278991, 870249094, 858186434, 846091463, 833964637, + 821806412, 809617248, 797397601, 785147933, 772868705, 760560379, + 748223418, 735858286, 723465451, 711045377, 698598532, 686125386, + 673626407, 661102067, 648552837, 635979189, 623381597, 610760535, + 598116478, 585449902, 572761285, 560051103, 547319836, 534567962, + 521795962, 509004317, 496193509, 483364018, 470516330, 457650927, + 444768293, 431868914, 418953276, 406021864, 393075166, 380113668, + 367137860, 354148229, 341145265, 328129456, 315101294, 302061268, + 289009870, 275947591, 262874923, 249792357, 236700387, 223599506, + 210490205, 197372981, 184248325, 171116732, 157978697, 144834714, + 131685278, 118530884, 105372028, 92209204, 79042909, 65873638, + 52701886, 39528151, 26352927, 13176711}, + {0, -13176711, -26352927, -39528151, -52701886, + -65873638, -79042909, -92209204, -105372028, -118530884, + -131685278, -144834714, -157978697, -171116732, -184248325, + -197372981, -210490205, -223599506, -236700387, -249792357, + -262874923, -275947591, -289009870, -302061268, -315101294, + -328129456, -341145265, -354148229, -367137860, -380113668, + -393075166, -406021864, -418953276, -431868914, -444768293, + -457650927, -470516330, -483364018, -496193509, -509004317, + -521795962, -534567962, -547319836, -560051103, -572761285, + -585449902, -598116478, -610760535, -623381597, -635979189, + -648552837, -661102067, -673626407, -686125386, -698598532, + -711045377, -723465451, -735858286, -748223418, -760560379, + -772868705, -785147933, -797397601, -809617248, -821806412, + -833964637, -846091463, -858186434, -870249094, -882278991, + -894275670, -906238680, -918167571, -930061893, -941921199, + -953745042, -965532977, -977284561, -988999350, -1000676904, + -1012316783, -1023918549, -1035481765, -1047005996, -1058490807, + -1069935767, -1081340444, -1092704410, -1104027236, -1115308495, + -1126547764, -1137744620, -1148898639, -1160009404, -1171076494, + -1182099495, -1193077990, -1204011566, -1214899812, -1225742317, + -1236538674, -1247288476, -1257991319, -1268646799, -1279254514, + -1289814067, -1300325059, -1310787094, -1321199779, -1331562722, + -1341875532, -1352137821, -1362349203, -1372509293, -1382617709, + -1392674071, -1402677998, -1412629116, -1422527049, -1432371425, + -1442161873, -1451898024, -1461579512, -1471205973, -1480777043, + -1490292363, -1499751575, -1509154321, -1518500249, -1527789006, + -1537020242, -1546193611, -1555308767, -1564365365, -1573363067, + -1582301532, -1591180424, -1599999410, -1608758156, -1617456334, + -1626093615, -1634669674, -1643184190, -1651636840, -1660027307, + -1668355275, -1676620430, -1684822462, -1692961061, -1701035921, + -1709046738, -1716993210, -1724875039, -1732691926, -1740443579, + -1748129706, -1755750016, -1763304223, -1770792043, -1778213193, + -1785567395, -1792854371, -1800073847, -1807225552, -1814309215, + -1821324571, -1828271354, -1835149305, -1841958163, -1848697672, + -1855367579, -1861967633, -1868497584, -1874957188, -1881346200, + -1887664381, -1893911493, -1900087299, -1906191569, -1912224071, + -1918184579, -1924072869, -1929888719, -1935631909, -1941302224, + -1946899449, -1952423376, -1957873794, -1963250500, -1968553290, + -1973781966, -1978936329, -1984016187, -1989021348, -1993951623, + -1998806828, -2003586778, -2008291294, -2012920199, -2017473319, + -2021950482, -2026351520, -2030676267, -2034924560, -2039096240, + -2043191148, -2047209132, -2051150039, -2055013722, -2058800034, + -2062508834, -2066139982, -2069693340, -2073168776, -2076566158, + -2079885359, -2083126253, -2086288718, -2089372636, -2092377891, + -2095304368, -2098151959, -2100920555, -2103610052, -2106220350, + -2108751350, -2111202957, -2113575078, -2115867624, -2118080509, + -2120213650, -2122266965, -2124240379, -2126133816, -2127947205, + -2129680478, -2131333570, -2132906418, -2134398964, -2135811151, + -2137142926, -2138394238, -2139565041, -2140655291, -2141664947, + -2142593969, -2143442325, -2144209981, -2144896908, -2145503082, + -2146028478, -2146473078, -2146836865, -2147119824, -2147321945, + -2147443221}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_192[4][192] = { + {2147479155, 2147371353, 2147119824, 2146724583, 2146185657, 2145503082, + 2144676904, 2143707178, 2142593969, 2141337352, 2139937411, 2138394238, + 2136707939, 2134878625, 2132906418, 2130791452, 2128533868, 2126133816, + 2123591457, 2120906961, 2118080509, 2115112289, 2112002500, 2108751350, + 2105359057, 2101825848, 2098151959, 2094337635, 2090383134, 2086288718, + 2082054663, 2077681251, 2073168776, 2068517539, 2063727851, 2058800034, + 2053734417, 2048531339, 2043191148, 2037714202, 2032100868, 2026351520, + 2020466545, 2014446335, 2008291294, 2002001834, 1995578375, 1989021348, + 1982331192, 1975508353, 1968553290, 1961466467, 1954248359, 1946899449, + 1939420229, 1931811199, 1924072869, 1916205757, 1908210388, 1900087299, + 1891837033, 1883460143, 1874957188, 1866328738, 1857575371, 1848697672, + 1839696236, 1830571666, 1821324571, 1811955570, 1802465292, 1792854371, + 1783123450, 1773273181, 1763304223, 1753217243, 1743012917, 1732691926, + 1722254963, 1711702726, 1701035921, 1690255262, 1679361470, 1668355275, + 1657237413, 1646008629, 1634669674, 1623221307, 1611664295, 1599999410, + 1588227433, 1576349154, 1564365365, 1552276871, 1540084479, 1527789006, + 1515391275, 1502892115, 1490292363, 1477592863, 1464794465, 1451898024, + 1438904405, 1425814477, 1412629116, 1399349205, 1385975632, 1372509293, + 1358951089, 1345301928, 1331562722, 1317734392, 1303817863, 1289814067, + 1275723941, 1261548428, 1247288476, 1232945041, 1218519083, 1204011566, + 1189423462, 1174755747, 1160009404, 1145185418, 1130284783, 1115308495, + 1100257558, 1085132977, 1069935767, 1054666943, 1039327528, 1023918549, + 1008441037, 992896027, 977284561, 961607683, 945866442, 930061893, + 914195093, 898267103, 882278991, 866231826, 850126682, 833964637, + 817746773, 801474175, 785147933, 768769140, 752338891, 735858286, + 719328429, 702750426, 686125386, 669454422, 652738650, 635979189, + 619177160, 602333689, 585449902, 568526930, 551565905, 534567962, + 517534240, 500465878, 483364018, 466229806, 449064389, 431868914, + 414644534, 397392400, 380113668, 362809495, 345481037, 328129456, + 310755913, 293361570, 275947591, 258515143, 241065392, 223599506, + 206118653, 188624005, 171116732, 153598006, 136068999, 118530884, + 100984836, 83432029, 65873638, 48310837, 30744803, 13176711}, + {-4392261, -21960941, -39528151, -57092715, -74653458, + -92209204, -109758778, -127301006, -144834714, -162358727, + -179871873, -197372981, -214860877, -232334392, -249792357, + -267233603, -284656962, -302061268, -319445357, -336808065, + -354148229, -371464689, -388756287, -406021864, -423260265, + -440470337, -457650927, -474800885, -491919064, -509004317, + -526055502, -543071477, -560051103, -576993243, -593896764, + -610760535, -627583425, -644364311, -661102067, -677795575, + -694443716, -711045377, -727599445, -744104814, -760560379, + -776965037, -793317692, -809617248, -825862614, -842052704, + -858186434, -874262723, -890280496, -906238680, -922136208, + -937972015, -953745042, -969454233, -985098536, -1000676904, + -1016188295, -1031631670, -1047005996, -1062310243, -1077543387, + -1092704410, -1107792295, -1122806033, -1137744620, -1152607054, + -1167392343, -1182099495, -1196727526, -1211275459, -1225742317, + -1240127135, -1254428947, -1268646799, -1282779736, -1296826815, + -1310787094, -1324659640, -1338443523, -1352137821, -1365741618, + -1379254002, -1392674071, -1406000924, -1419233671, -1432371425, + -1445413308, -1458358446, -1471205973, -1483955029, -1496604760, + -1509154321, -1521602871, -1533949576, -1546193611, -1558334156, + -1570370398, -1582301532, -1594126759, -1605845288, -1617456334, + -1628959120, -1640352876, -1651636840, -1662810256, -1673872377, + -1684822462, -1695659778, -1706383600, -1716993210, -1727487898, + -1737866961, -1748129706, -1758275444, -1768303497, -1778213193, + -1788003870, -1797674872, -1807225552, -1816655270, -1825963395, + -1835149305, -1844212384, -1853152026, -1861967633, -1870658614, + -1879224388, -1887664381, -1895978029, -1904164775, -1912224071, + -1920155378, -1927958165, -1935631909, -1943176097, -1950590224, + -1957873794, -1965026319, -1972047321, -1978936329, -1985692883, + -1992316530, -1998806828, -2005163340, -2011385643, -2017473319, + -2023425962, -2029243172, -2034924560, -2040469747, -2045878361, + -2051150039, -2056284430, -2061281189, -2066139982, -2070860483, + -2075442378, -2079885359, -2084189128, -2088353398, -2092377891, + -2096262335, -2100006473, -2103610052, -2107072833, -2110394582, + -2113575078, -2116614108, -2119511468, -2122266965, -2124880414, + -2127351640, -2129680478, -2131866772, -2133910375, -2135811151, + -2137568973, -2139183722, -2140655291, -2141983582, -2143168505, + -2144209981, -2145107940, -2145862323, -2146473078, -2146940166, + -2147263554, -2147443221}, + {2147483647, 2147411779, 2147196180, 2146836865, 2146333857, 2145687190, + 2144896908, 2143963064, 2142885719, 2141664947, 2140300828, 2138793454, + 2137142926, 2135349354, 2133412859, 2131333570, 2129111626, 2126747176, + 2124240379, 2121591401, 2118800421, 2115867624, 2112793208, 2109577379, + 2106220350, 2102722348, 2099083606, 2095304368, 2091384887, 2087325424, + 2083126253, 2078787653, 2074309916, 2069693340, 2064938236, 2060044920, + 2055013722, 2049844977, 2044539031, 2039096240, 2033516967, 2027801588, + 2021950482, 2015964044, 2009842672, 2003586778, 1997196779, 1990673103, + 1984016187, 1977226477, 1970304427, 1963250500, 1956065168, 1948748913, + 1941302224, 1933725599, 1926019545, 1918184579, 1910221225, 1902130016, + 1893911493, 1885566206, 1877094714, 1868497584, 1859775392, 1850928721, + 1841958163, 1832864319, 1823647797, 1814309215, 1804849197, 1795268377, + 1785567395, 1775746901, 1765807553, 1755750016, 1745574962, 1735283073, + 1724875039, 1714351554, 1703713324, 1692961061, 1682095484, 1671117321, + 1660027307, 1648826183, 1637514700, 1626093615, 1614563691, 1602925701, + 1591180424, 1579328646, 1567371160, 1555308767, 1543142273, 1530872493, + 1518500249, 1506026368, 1493451686, 1480777043, 1468003289, 1455131279, + 1442161873, 1429095940, 1415934355, 1402677998, 1389327757, 1375884526, + 1362349203, 1348722695, 1335005915, 1321199779, 1307305213, 1293323146, + 1279254514, 1265100259, 1250861328, 1236538674, 1222133256, 1207646038, + 1193077990, 1178430086, 1163703307, 1148898639, 1134017073, 1119059605, + 1104027236, 1088920971, 1073741823, 1058490807, 1043168944, 1027777259, + 1012316783, 996788550, 981193601, 965532977, 949807729, 934018908, + 918167571, 902254779, 886281597, 870249094, 854158344, 838010423, + 821806412, 805547396, 789234463, 772868705, 756451217, 739983098, + 723465451, 706899380, 690285995, 673626407, 656921733, 640173089, + 623381597, 606548381, 589674567, 572761285, 555809666, 538820847, + 521795962, 504736153, 487642561, 470516330, 453358606, 436170538, + 418953276, 401707972, 384435782, 367137860, 349815365, 332469456, + 315101294, 297712042, 280302863, 262874923, 245429388, 227967426, + 210490205, 192998897, 175494670, 157978697, 140452150, 122916202, + 105372028, 87820800, 70263695, 52701886, 35136551, 17568863}, + {0, -17568863, -35136551, -52701886, -70263695, + -87820800, -105372028, -122916202, -140452150, -157978697, + -175494670, -192998897, -210490205, -227967426, -245429388, + -262874923, -280302863, -297712042, -315101294, -332469456, + -349815365, -367137860, -384435782, -401707972, -418953276, + -436170538, -453358606, -470516330, -487642561, -504736153, + -521795962, -538820847, -555809666, -572761285, -589674567, + -606548381, -623381597, -640173089, -656921733, -673626407, + -690285995, -706899380, -723465451, -739983098, -756451217, + -772868705, -789234463, -805547396, -821806412, -838010423, + -854158344, -870249094, -886281597, -902254779, -918167571, + -934018908, -949807729, -965532977, -981193601, -996788550, + -1012316783, -1027777259, -1043168944, -1058490807, -1073741823, + -1088920971, -1104027236, -1119059605, -1134017073, -1148898639, + -1163703307, -1178430086, -1193077990, -1207646038, -1222133256, + -1236538674, -1250861328, -1265100259, -1279254514, -1293323146, + -1307305213, -1321199779, -1335005915, -1348722695, -1362349203, + -1375884526, -1389327757, -1402677998, -1415934355, -1429095940, + -1442161873, -1455131279, -1468003289, -1480777043, -1493451686, + -1506026368, -1518500249, -1530872493, -1543142273, -1555308767, + -1567371160, -1579328646, -1591180424, -1602925701, -1614563691, + -1626093615, -1637514700, -1648826183, -1660027307, -1671117321, + -1682095484, -1692961061, -1703713324, -1714351554, -1724875039, + -1735283073, -1745574962, -1755750016, -1765807553, -1775746901, + -1785567395, -1795268377, -1804849197, -1814309215, -1823647797, + -1832864319, -1841958163, -1850928721, -1859775392, -1868497584, + -1877094714, -1885566206, -1893911493, -1902130016, -1910221225, + -1918184579, -1926019545, -1933725599, -1941302224, -1948748913, + -1956065168, -1963250500, -1970304427, -1977226477, -1984016187, + -1990673103, -1997196779, -2003586778, -2009842672, -2015964044, + -2021950482, -2027801588, -2033516967, -2039096240, -2044539031, + -2049844977, -2055013722, -2060044920, -2064938236, -2069693340, + -2074309916, -2078787653, -2083126253, -2087325424, -2091384887, + -2095304368, -2099083606, -2102722348, -2106220350, -2109577379, + -2112793208, -2115867624, -2118800421, -2121591401, -2124240379, + -2126747176, -2129111626, -2131333570, -2133412859, -2135349354, + -2137142926, -2138793454, -2140300828, -2141664947, -2142885719, + -2143963064, -2144896908, -2145687190, -2146333857, -2146836865, + -2147196180, -2147411779}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_128[4][128] = { + {2147473540, 2147230990, 2146665074, 2145775879, 2144563537, 2143028233, + 2141170196, 2138989706, 2136487093, 2133662733, 2130517051, 2127050521, + 2123263664, 2119157053, 2114731304, 2109987084, 2104925108, 2099546137, + 2093850983, 2087840503, 2081515602, 2074877232, 2067926393, 2060664132, + 2053091543, 2045209765, 2037019987, 2028523440, 2019721406, 2010615209, + 2001206221, 1991495858, 1981485584, 1971176905, 1960571374, 1949670588, + 1938476189, 1926989863, 1915213339, 1903148391, 1890796835, 1878160533, + 1865241387, 1852041342, 1838562387, 1824806550, 1810775905, 1796472564, + 1781898680, 1767056449, 1751948106, 1736575926, 1720942223, 1705049354, + 1688899710, 1672495724, 1655839866, 1638934645, 1621782607, 1604386334, + 1586748446, 1568871600, 1550758487, 1532411836, 1513834409, 1495029005, + 1475998454, 1456745624, 1437273413, 1417584754, 1397682612, 1377569984, + 1357249900, 1336725418, 1315999630, 1295075658, 1273956652, 1252645793, + 1231146290, 1209461381, 1187594331, 1165548434, 1143327010, 1120933405, + 1098370992, 1075643168, 1052753356, 1029705003, 1006501580, 983146582, + 959643526, 935995951, 912207418, 888281511, 864221831, 840032003, + 815715669, 791276491, 766718150, 742044344, 717258789, 692365217, + 667367378, 642269036, 617073970, 591785975, 566408859, 540946445, + 515402565, 489781068, 464085812, 438320666, 412489511, 386596236, + 360644742, 334638935, 308582733, 282480060, 256334846, 230151030, + 203932553, 177683365, 151407418, 125108670, 98791081, 72458614, + 46115236, 19764912}, + {-6588386, -32940694, -59288041, -85626459, -111951983, + -138260647, -164548489, -190811551, -217045877, -243247517, + -269412525, -295536960, -321616889, -347648383, -373627522, + -399550395, -425413097, -451211733, -476942419, -502601278, + -528184448, -553688075, -579108319, -604441351, -629683356, + -654830534, -679879096, -704825271, -729665302, -754395449, + -779011985, -803511206, -827889421, -852142958, -876268167, + -900261412, -924119081, -947837581, -971413341, -994842809, + -1018122458, -1041248781, -1064218295, -1087027543, -1109673088, + -1132151520, -1154459455, -1176593532, -1198550418, -1220326808, + -1241919420, -1263325004, -1284540336, -1305562221, -1326387493, + -1347013016, -1367435684, -1387652420, -1407660182, -1427455955, + -1447036759, -1466399644, -1485541694, -1504460028, -1523151796, + -1541614182, -1559844407, -1577839725, -1595597426, -1613114836, + -1630389317, -1647418268, -1664199123, -1680729356, -1697006477, + -1713028036, -1728791618, -1744294851, -1759535400, -1774510969, + -1789219303, -1803658188, -1817825448, -1831718950, -1845336602, + -1858676353, -1871736195, -1884514160, -1897008324, -1909216805, + -1921137766, -1932769410, -1944109986, -1955157786, -1965911147, + -1976368449, -1986528117, -1996388621, -2005948476, -2015206243, + -2024160527, -2032809981, -2041153300, -2049189229, -2056916558, + -2064334123, -2071440807, -2078235539, -2084717297, -2090885104, + -2096738031, -2102275197, -2107495769, -2112398959, -2116984030, + -2121250290, -2125197099, -2128823860, -2132130028, -2135115106, + -2137778643, -2140120238, -2142139539, -2143836242, -2145210091, + -2146260879, -2146988448, -2147392689}, + {2147483647, 2147321945, 2146836865, 2146028478, 2144896908, 2143442325, + 2141664947, 2139565041, 2137142926, 2134398964, 2131333570, 2127947205, + 2124240379, 2120213650, 2115867624, 2111202957, 2106220350, 2100920555, + 2095304368, 2089372636, 2083126253, 2076566158, 2069693340, 2062508834, + 2055013722, 2047209132, 2039096240, 2030676267, 2021950482, 2012920199, + 2003586778, 1993951623, 1984016187, 1973781966, 1963250500, 1952423376, + 1941302224, 1929888719, 1918184579, 1906191569, 1893911493, 1881346200, + 1868497584, 1855367579, 1841958163, 1828271354, 1814309215, 1800073847, + 1785567395, 1770792043, 1755750016, 1740443579, 1724875039, 1709046738, + 1692961061, 1676620430, 1660027307, 1643184190, 1626093615, 1608758156, + 1591180424, 1573363067, 1555308767, 1537020242, 1518500249, 1499751575, + 1480777043, 1461579512, 1442161873, 1422527049, 1402677998, 1382617709, + 1362349203, 1341875532, 1321199779, 1300325059, 1279254514, 1257991319, + 1236538674, 1214899812, 1193077990, 1171076494, 1148898639, 1126547764, + 1104027236, 1081340444, 1058490807, 1035481765, 1012316783, 988999350, + 965532977, 941921199, 918167571, 894275670, 870249094, 846091463, + 821806412, 797397601, 772868705, 748223418, 723465451, 698598532, + 673626407, 648552837, 623381597, 598116478, 572761285, 547319836, + 521795962, 496193509, 470516330, 444768293, 418953276, 393075166, + 367137860, 341145265, 315101294, 289009870, 262874923, 236700387, + 210490205, 184248325, 157978697, 131685278, 105372028, 79042909, + 52701886, 26352927}, + {0, -26352927, -52701886, -79042909, -105372028, + -131685278, -157978697, -184248325, -210490205, -236700387, + -262874923, -289009870, -315101294, -341145265, -367137860, + -393075166, -418953276, -444768293, -470516330, -496193509, + -521795962, -547319836, -572761285, -598116478, -623381597, + -648552837, -673626407, -698598532, -723465451, -748223418, + -772868705, -797397601, -821806412, -846091463, -870249094, + -894275670, -918167571, -941921199, -965532977, -988999350, + -1012316783, -1035481765, -1058490807, -1081340444, -1104027236, + -1126547764, -1148898639, -1171076494, -1193077990, -1214899812, + -1236538674, -1257991319, -1279254514, -1300325059, -1321199779, + -1341875532, -1362349203, -1382617709, -1402677998, -1422527049, + -1442161873, -1461579512, -1480777043, -1499751575, -1518500249, + -1537020242, -1555308767, -1573363067, -1591180424, -1608758156, + -1626093615, -1643184190, -1660027307, -1676620430, -1692961061, + -1709046738, -1724875039, -1740443579, -1755750016, -1770792043, + -1785567395, -1800073847, -1814309215, -1828271354, -1841958163, + -1855367579, -1868497584, -1881346200, -1893911493, -1906191569, + -1918184579, -1929888719, -1941302224, -1952423376, -1963250500, + -1973781966, -1984016187, -1993951623, -2003586778, -2012920199, + -2021950482, -2030676267, -2039096240, -2047209132, -2055013722, + -2062508834, -2069693340, -2076566158, -2083126253, -2089372636, + -2095304368, -2100920555, -2106220350, -2111202957, -2115867624, + -2120213650, -2124240379, -2127947205, -2131333570, -2134398964, + -2137142926, -2139565041, -2141664947, -2143442325, -2144896908, + -2146028478, -2146836865, -2147321945}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_96[4][96] = { + {2147465679, 2147034485, 2146028478, 2144447928, 2142293256, 2139565041, + 2136264013, 2132391055, 2127947205, 2122933651, 2117351737, 2111202957, + 2104488957, 2097211534, 2089372636, 2080974364, 2072018964, 2062508834, + 2052446521, 2041834718, 2030676267, 2018974155, 2006731514, 1993951623, + 1980637903, 1966793919, 1952423376, 1937530122, 1922118144, 1906191569, + 1889754660, 1872811818, 1855367579, 1837426614, 1818993725, 1800073847, + 1780672046, 1760793516, 1740443579, 1719627684, 1698351402, 1676620430, + 1654440587, 1631817810, 1608758156, 1585267799, 1561353026, 1537020242, + 1512275961, 1487126807, 1461579512, 1435640918, 1409317968, 1382617709, + 1355547290, 1328113959, 1300325059, 1272188031, 1243710407, 1214899812, + 1185763959, 1156310648, 1126547764, 1096483277, 1066125235, 1035481765, + 1004561071, 973371433, 941921199, 910218790, 878272694, 846091463, + 813683712, 781058119, 748223418, 715188399, 681961907, 648552837, + 614970134, 581222788, 547319836, 513270352, 479083454, 444768293, + 410334057, 375789965, 341145265, 306409231, 271591165, 236700387, + 201746239, 166738078, 131685278, 96597222, 61483305, 26352927}, + {-8784505, -43919586, -79042909, -114145070, -149216672, + -184248325, -219230650, -254154282, -289009870, -323788084, + -358479612, -393075166, -427565484, -461941333, -496193509, + -530312841, -564290197, -598116478, -631782629, -665279636, + -698598532, -731730396, -764666359, -797397601, -829915361, + -862210933, -894275670, -926100988, -957678366, -988999350, + -1020055555, -1050838667, -1081340444, -1111552720, -1141467406, + -1171076494, -1200372057, -1229346251, -1257991319, -1286299592, + -1314263492, -1341875532, -1369128319, -1396014558, -1422527049, + -1448658696, -1474402502, -1499751575, -1524699127, -1549238481, + -1573363067, -1597066425, -1620342210, -1643184190, -1665586249, + -1687542392, -1709046738, -1730093531, -1750677136, -1770792043, + -1790432865, -1809594346, -1828271354, -1846458890, -1864152085, + -1881346200, -1898036634, -1914218918, -1929888719, -1945041841, + -1959674230, -1973781966, -1987361273, -2000408515, -2012920199, + -2024892976, -2036323641, -2047209132, -2057546536, -2067333084, + -2076566158, -2085243285, -2093362142, -2100920555, -2107916501, + -2114348106, -2120213650, -2125511561, -2130240421, -2134398964, + -2137986077, -2141000800, -2143442325, -2145309998, -2146603320, + -2147321945}, + {2147483647, 2147196180, 2146333857, 2144896908, 2142885719, 2140300828, + 2137142926, 2133412859, 2129111626, 2124240379, 2118800421, 2112793208, + 2106220350, 2099083606, 2091384887, 2083126253, 2074309916, 2064938236, + 2055013722, 2044539031, 2033516967, 2021950482, 2009842672, 1997196779, + 1984016187, 1970304427, 1956065168, 1941302224, 1926019545, 1910221225, + 1893911493, 1877094714, 1859775392, 1841958163, 1823647797, 1804849197, + 1785567395, 1765807553, 1745574962, 1724875039, 1703713324, 1682095484, + 1660027307, 1637514700, 1614563691, 1591180424, 1567371160, 1543142273, + 1518500249, 1493451686, 1468003289, 1442161873, 1415934355, 1389327757, + 1362349203, 1335005915, 1307305213, 1279254514, 1250861328, 1222133256, + 1193077990, 1163703307, 1134017073, 1104027236, 1073741823, 1043168944, + 1012316783, 981193601, 949807729, 918167571, 886281597, 854158344, + 821806412, 789234463, 756451217, 723465451, 690285995, 656921733, + 623381597, 589674567, 555809666, 521795962, 487642561, 453358606, + 418953276, 384435782, 349815365, 315101294, 280302863, 245429388, + 210490205, 175494670, 140452150, 105372028, 70263695, 35136551}, + {0, -35136551, -70263695, -105372028, -140452150, + -175494670, -210490205, -245429388, -280302863, -315101294, + -349815365, -384435782, -418953276, -453358606, -487642561, + -521795962, -555809666, -589674567, -623381597, -656921733, + -690285995, -723465451, -756451217, -789234463, -821806412, + -854158344, -886281597, -918167571, -949807729, -981193601, + -1012316783, -1043168944, -1073741823, -1104027236, -1134017073, + -1163703307, -1193077990, -1222133256, -1250861328, -1279254514, + -1307305213, -1335005915, -1362349203, -1389327757, -1415934355, + -1442161873, -1468003289, -1493451686, -1518500249, -1543142273, + -1567371160, -1591180424, -1614563691, -1637514700, -1660027307, + -1682095484, -1703713324, -1724875039, -1745574962, -1765807553, + -1785567395, -1804849197, -1823647797, -1841958163, -1859775392, + -1877094714, -1893911493, -1910221225, -1926019545, -1941302224, + -1956065168, -1970304427, -1984016187, -1997196779, -2009842672, + -2021950482, -2033516967, -2044539031, -2055013722, -2064938236, + -2074309916, -2083126253, -2091384887, -2099083606, -2106220350, + -2112793208, -2118800421, -2124240379, -2129111626, -2133412859, + -2137142926, -2140300828, -2142885719, -2144896908, -2146333857, + -2147196180}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_64[4][64] = { + {2147443221, 2146473078, 2144209981, 2140655291, 2135811151, 2129680478, + 2122266965, 2113575078, 2103610052, 2092377891, 2079885359, 2066139982, + 2051150039, 2034924560, 2017473319, 1998806828, 1978936329, 1957873794, + 1935631909, 1912224071, 1887664381, 1861967633, 1835149305, 1807225552, + 1778213193, 1748129706, 1716993210, 1684822462, 1651636840, 1617456334, + 1582301532, 1546193611, 1509154321, 1471205973, 1432371425, 1392674071, + 1352137821, 1310787094, 1268646799, 1225742317, 1182099495, 1137744620, + 1092704410, 1047005996, 1000676904, 953745042, 906238680, 858186434, + 809617248, 760560379, 711045377, 661102067, 610760535, 560051103, + 509004317, 457650927, 406021864, 354148229, 302061268, 249792357, + 197372981, 144834714, 92209204, 39528151}, + {-13176711, -65873638, -118530884, -171116732, -223599506, + -275947591, -328129456, -380113668, -431868914, -483364018, + -534567962, -585449902, -635979189, -686125386, -735858286, + -785147933, -833964637, -882278991, -930061893, -977284561, + -1023918549, -1069935767, -1115308495, -1160009404, -1204011566, + -1247288476, -1289814067, -1331562722, -1372509293, -1412629116, + -1451898024, -1490292363, -1527789006, -1564365365, -1599999410, + -1634669674, -1668355275, -1701035921, -1732691926, -1763304223, + -1792854371, -1821324571, -1848697672, -1874957188, -1900087299, + -1924072869, -1946899449, -1968553290, -1989021348, -2008291294, + -2026351520, -2043191148, -2058800034, -2073168776, -2086288718, + -2098151959, -2108751350, -2118080509, -2126133816, -2132906418, + -2138394238, -2142593969, -2145503082, -2147119824}, + {2147483647, 2146836865, 2144896908, 2141664947, 2137142926, 2131333570, + 2124240379, 2115867624, 2106220350, 2095304368, 2083126253, 2069693340, + 2055013722, 2039096240, 2021950482, 2003586778, 1984016187, 1963250500, + 1941302224, 1918184579, 1893911493, 1868497584, 1841958163, 1814309215, + 1785567395, 1755750016, 1724875039, 1692961061, 1660027307, 1626093615, + 1591180424, 1555308767, 1518500249, 1480777043, 1442161873, 1402677998, + 1362349203, 1321199779, 1279254514, 1236538674, 1193077990, 1148898639, + 1104027236, 1058490807, 1012316783, 965532977, 918167571, 870249094, + 821806412, 772868705, 723465451, 673626407, 623381597, 572761285, + 521795962, 470516330, 418953276, 367137860, 315101294, 262874923, + 210490205, 157978697, 105372028, 52701886}, + {0, -52701886, -105372028, -157978697, -210490205, + -262874923, -315101294, -367137860, -418953276, -470516330, + -521795962, -572761285, -623381597, -673626407, -723465451, + -772868705, -821806412, -870249094, -918167571, -965532977, + -1012316783, -1058490807, -1104027236, -1148898639, -1193077990, + -1236538674, -1279254514, -1321199779, -1362349203, -1402677998, + -1442161873, -1480777043, -1518500249, -1555308767, -1591180424, + -1626093615, -1660027307, -1692961061, -1724875039, -1755750016, + -1785567395, -1814309215, -1841958163, -1868497584, -1893911493, + -1918184579, -1941302224, -1963250500, -1984016187, -2003586778, + -2021950482, -2039096240, -2055013722, -2069693340, -2083126253, + -2095304368, -2106220350, -2115867624, -2124240379, -2131333570, + -2137142926, -2141664947, -2144896908, -2146836865}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_48[4][48] = { + {2147411779, 2145687190, 2141664947, 2135349354, 2126747176, 2115867624, + 2102722348, 2087325424, 2069693340, 2049844977, 2027801588, 2003586778, + 1977226477, 1948748913, 1918184579, 1885566206, 1850928721, 1814309215, + 1775746901, 1735283073, 1692961061, 1648826183, 1602925701, 1555308767, + 1506026368, 1455131279, 1402677998, 1348722695, 1293323146, 1236538674, + 1178430086, 1119059605, 1058490807, 996788550, 934018908, 870249094, + 805547396, 739983098, 673626407, 606548381, 538820847, 470516330, + 401707972, 332469456, 262874923, 192998897, 122916202, 52701886}, + {-17568863, -87820800, -157978697, -227967426, -297712042, + -367137860, -436170538, -504736153, -572761285, -640173089, + -706899380, -772868705, -838010423, -902254779, -965532977, + -1027777259, -1088920971, -1148898639, -1207646038, -1265100259, + -1321199779, -1375884526, -1429095940, -1480777043, -1530872493, + -1579328646, -1626093615, -1671117321, -1714351554, -1755750016, + -1795268377, -1832864319, -1868497584, -1902130016, -1933725599, + -1963250500, -1990673103, -2015964044, -2039096240, -2060044920, + -2078787653, -2095304368, -2109577379, -2121591401, -2131333570, + -2138793454, -2143963064, -2146836865}, + {2147483647, 2146333857, 2142885719, 2137142926, 2129111626, 2118800421, + 2106220350, 2091384887, 2074309916, 2055013722, 2033516967, 2009842672, + 1984016187, 1956065168, 1926019545, 1893911493, 1859775392, 1823647797, + 1785567395, 1745574962, 1703713324, 1660027307, 1614563691, 1567371160, + 1518500249, 1468003289, 1415934355, 1362349203, 1307305213, 1250861328, + 1193077990, 1134017073, 1073741823, 1012316783, 949807729, 886281597, + 821806412, 756451217, 690285995, 623381597, 555809666, 487642561, + 418953276, 349815365, 280302863, 210490205, 140452150, 70263695}, + {0, -70263695, -140452150, -210490205, -280302863, + -349815365, -418953276, -487642561, -555809666, -623381597, + -690285995, -756451217, -821806412, -886281597, -949807729, + -1012316783, -1073741823, -1134017073, -1193077990, -1250861328, + -1307305213, -1362349203, -1415934355, -1468003289, -1518500249, + -1567371160, -1614563691, -1660027307, -1703713324, -1745574962, + -1785567395, -1823647797, -1859775392, -1893911493, -1926019545, + -1956065168, -1984016187, -2009842672, -2033516967, -2055013722, + -2074309916, -2091384887, -2106220350, -2118800421, -2129111626, + -2137142926, -2142885719, -2146333857}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_32[4][32] = { + {2147321945, 2143442325, 2134398964, 2120213650, 2100920555, 2076566158, + 2047209132, 2012920199, 1973781966, 1929888719, 1881346200, 1828271354, + 1770792043, 1709046738, 1643184190, 1573363067, 1499751575, 1422527049, + 1341875532, 1257991319, 1171076494, 1081340444, 988999350, 894275670, + 797397601, 698598532, 598116478, 496193509, 393075166, 289009870, + 184248325, 79042909}, + {-26352927, -131685278, -236700387, -341145265, -444768293, + -547319836, -648552837, -748223418, -846091463, -941921199, + -1035481765, -1126547764, -1214899812, -1300325059, -1382617709, + -1461579512, -1537020242, -1608758156, -1676620430, -1740443579, + -1800073847, -1855367579, -1906191569, -1952423376, -1993951623, + -2030676267, -2062508834, -2089372636, -2111202957, -2127947205, + -2139565041, -2146028478}, + {2147483647, 2144896908, 2137142926, 2124240379, 2106220350, 2083126253, + 2055013722, 2021950482, 1984016187, 1941302224, 1893911493, 1841958163, + 1785567395, 1724875039, 1660027307, 1591180424, 1518500249, 1442161873, + 1362349203, 1279254514, 1193077990, 1104027236, 1012316783, 918167571, + 821806412, 723465451, 623381597, 521795962, 418953276, 315101294, + 210490205, 105372028}, + {0, -105372028, -210490205, -315101294, -418953276, + -521795962, -623381597, -723465451, -821806412, -918167571, + -1012316783, -1104027236, -1193077990, -1279254514, -1362349203, + -1442161873, -1518500249, -1591180424, -1660027307, -1724875039, + -1785567395, -1841958163, -1893911493, -1941302224, -1984016187, + -2021950482, -2055013722, -2083126253, -2106220350, -2124240379, + -2137142926, -2144896908}}; + +const WORD32 ixheaacd_pre_post_twid_cos_sin_24[4][24] = { + {2147196180, 2140300828, 2124240379, 2099083606, 2064938236, 2021950482, + 1970304427, 1910221225, 1841958163, 1765807553, 1682095484, 1591180424, + 1493451686, 1389327757, 1279254514, 1163703307, 1043168944, 918167571, + 789234463, 656921733, 521795962, 384435782, 245429388, 105372028}, + {-35136551, -175494670, -315101294, -453358606, -589674567, + -723465451, -854158344, -981193601, -1104027236, -1222133256, + -1335005915, -1442161873, -1543142273, -1637514700, -1724875039, + -1804849197, -1877094714, -1941302224, -1997196779, -2044539031, + -2083126253, -2112793208, -2133412859, -2144896908}, + {2147483647, 2142885719, 2129111626, 2106220350, 2074309916, 2033516967, + 1984016187, 1926019545, 1859775392, 1785567395, 1703713324, 1614563691, + 1518500249, 1415934355, 1307305213, 1193077990, 1073741823, 949807729, + 821806412, 690285995, 555809666, 418953276, 280302863, 140452150}, + {0, -140452150, -280302863, -418953276, -555809666, + -690285995, -821806412, -949807729, -1073741823, -1193077990, + -1307305213, -1415934355, -1518500249, -1614563691, -1703713324, + -1785567395, -1859775392, -1926019545, -1984016187, -2033516967, + -2074309916, -2106220350, -2129111626, -2142885719}}; + +const FLOAT64 ixheaacd_power_10_table[28] = { + 1.000000000000, 1.085711119402, 1.178768634794, 1.279802213998, + 1.389495494373, 1.508590708600, 1.637893706954, 1.778279410039, + 1.930697728883, 2.096179992453, 2.275845926075, 2.470911227986, + 2.682695795280, 2.912632654909, 3.162277660168, 3.433320018282, + 3.727593720315, 4.047089950760, 4.393970560761, 4.770582696144, + 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] = { + 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, + 1384.3585f, 1652.9448f, 1978.3910f, 2311.2676f, 2674.0537f, 3010.3896f, + 3360.0623f, 3725.9336f, 4093.3335f, 4470.6431f, 4859.1006f, 5210.4717f, + 5598.3716f, 5954.4204f, 552.5036f, 859.7047f, 1355.2023f, 1624.9041f, + 1887.5609f, 2173.1638f, 2540.7429f, 2926.8169f, 3323.2173f, 3680.7197f, + 4008.3447f, 4330.8442f, 4692.8228f, 5033.9697f, 5443.3467f, 5875.4497f, + 459.4534f, 793.3189f, 1293.7278f, 1617.3970f, 1920.0642f, 2192.2153f, + 2487.5627f, 2772.1514f, 3111.3823f, 3461.2671f, 3867.0176f, 4279.8550f, + 4741.0664f, 5141.0181f, 5552.8237f, 5933.6934f, 327.9834f, 430.4954f, + 723.9031f, 1528.6172f, 1763.1125f, 2013.7936f, 2334.2153f, 2569.0334f, + 3017.9436f, 3308.0610f, 3591.7820f, 3865.5430f, 4693.5786f, 5286.7646f, + 5647.7036f, 5987.2305f, 455.0753f, 606.0817f, 963.7564f, 1374.9937f, + 1536.4897f, 1914.7618f, 2376.9631f, 2580.8184f, 2989.1501f, 3258.8386f, + 3485.1460f, 3741.1270f, 4297.4912f, 5207.3779f, 5672.3818f, 5980.5322f, + 434.9507f, 558.8508f, 890.7061f, 1355.7625f, 1552.6155f, 1895.7960f, + 2222.5579f, 2502.6079f, 2841.8738f, 3137.5264f, 3367.7336f, 3860.7769f, + 4795.2554f, 5090.9370f, 5421.8218f, 5874.4287f, 281.0164f, 404.5417f, + 729.2898f, 997.1851f, 1699.8862f, 1961.3673f, 2255.7202f, 2540.9187f, + 2804.4553f, 3057.1843f, 3750.2288f, 4340.9893f, 4716.8647f, 5002.7471f, + 5477.2998f, 5965.7402f, 372.2410f, 505.3570f, 762.3755f, 997.3586f, + 1174.4255f, 1986.1741f, 2368.1367f, 2624.1733f, 3194.6084f, 3403.2793f, + 3877.7622f, 4425.7676f, 4824.7837f, 5158.1606f, 5532.7466f, 5893.5483f, + 367.3766f, 501.1806f, 824.5358f, 1090.6857f, 1271.9792f, 1527.7137f, + 2381.4382f, 2694.4634f, 2964.5359f, 3639.4832f, 3946.4038f, 4254.3916f, + 4645.8076f, 5033.5396f, 5373.8735f, 5878.4385f, 229.4505f, 352.5671f, + 701.0831f, 1226.4518f, 1678.3601f, 1895.7949f, 2140.0664f, 2526.5515f, + 3080.3391f, 3297.8284f, 3845.3987f, 4427.9785f, 4704.4551f, 4997.4155f, + 5434.0698f, 5918.4785f, 336.3082f, 516.7915f, 881.9847f, 1272.5824f, + 1505.1870f, 1880.7520f, 2274.9458f, 2611.0083f, 3126.5256f, 3655.5332f, + 4183.3877f, 4668.2993f, 5004.0029f, 5305.3491f, 5650.4985f, 5943.7383f, + 296.0867f, 469.6519f, 956.5997f, 1224.1262f, 1443.0049f, 1727.6880f, + 2216.1677f, 2689.3677f, 3060.4456f, 3520.9438f, 3916.6050f, 4343.7954f, + 4763.8906f, 5156.0132f, 5553.8115f, 5936.9634f, 407.1503f, 577.5120f, + 839.7361f, 1455.3907f, 1665.2137f, 1935.0054f, 2398.0537f, 2652.2605f, + 3111.1831f, 3505.5962f, 3766.7554f, 4204.8730f, 4699.1631f, 4970.8652f, + 5295.5962f, 5695.6919f, 281.0083f, 361.8386f, 950.9102f, 1464.1158f, + 1634.7019f, 1965.4950f, 2211.1406f, 2662.1055f, 2846.0122f, 3585.8884f, + 4048.7148f, 4358.9150f, 4683.8755f, 5046.0908f, 5400.0859f, 5956.1040f, + 279.1811f, 393.9142f, 876.8306f, 1502.2417f, 1673.0590f, 2288.7161f, + 2545.3674f, 3028.9507f, 3517.5840f, 3824.4246f, 4144.8486f, 4481.8140f, + 4821.2769f, 5162.3975f, 5542.8560f, 5928.5854f, 379.7892f, 500.9199f, + 725.0223f, 998.7143f, 1179.6127f, 1771.9886f, 2775.4812f, 3136.8457f, + 3378.6143f, 3674.0188f, 3946.3604f, 4184.4824f, 4521.5454f, 4934.8940f, + 5315.5029f, 5759.7544f, 317.4339f, 442.2628f, 778.7388f, 1167.8633f, + 1356.1576f, 1578.5603f, 1840.1584f, 2870.7527f, 3236.1504f, 3502.7249f, + 3876.3696f, 4100.5244f, 4650.2632f, 5235.1890f, 5665.2285f, 5999.0649f, + 350.2696f, 492.2163f, 763.0640f, 1264.7550f, 1515.0244f, 1755.7783f, + 2489.3274f, 2898.6252f, 3143.1018f, 3643.0640f, 4035.0657f, 4255.0889f, + 4641.7231f, 5138.5107f, 5557.1318f, 5920.2402f, 301.3833f, 464.9852f, + 762.3419f, 1012.2126f, 1803.5172f, 2192.4214f, 2651.6287f, 3013.6697f, + 3251.3591f, 3539.4675f, 3946.3433f, 4469.3560f, 4890.7446f, 5200.4878f, + 5509.6753f, 5910.2397f, 253.1752f, 356.8990f, 630.3325f, 1163.1683f, + 1528.6230f, 2023.4438f, 2488.6001f, 2745.5627f, 2933.7024f, 3237.4414f, + 3976.9258f, 4415.2534f, 4789.9131f, 5194.3423f, 5714.6445f, 6032.4160f, + 265.1815f, 364.7549f, 590.0148f, 805.2595f, 1564.7582f, 2150.6536f, + 2365.6501f, 2598.7876f, 2861.5334f, 3514.1265f, 4005.6328f, 4609.3091f, + 4955.4478f, 5238.4116f, 5519.5884f, 5890.7925f, 209.3544f, 313.1497f, + 503.2642f, 949.4504f, 1729.7280f, 1912.6814f, 2117.5051f, 2498.6272f, + 3284.6587f, 3810.8555f, 4105.0195f, 4349.5151f, 4770.3682f, 5210.2910f, + 5585.1533f, 5970.3638f, 302.3150f, 415.6502f, 684.1018f, 922.3598f, + 1489.4418f, 2235.6252f, 2449.9773f, 2800.6938f, 3061.3721f, 3526.1001f, + 3905.8174f, 4170.7891f, 4446.4209f, 4907.9937f, 5470.7158f, 5914.7261f, + 264.9068f, 366.4342f, 582.8182f, 790.8568f, 1619.4548f, 2034.0782f, + 2337.6724f, 2632.1714f, 2933.2356f, 3430.1858f, 3815.0198f, 4276.3931f, + 4748.3149f, 5164.0098f, 5553.3320f, 5974.9092f, 249.6359f, 361.9234f, + 581.9844f, 841.1097f, 1657.5543f, 2184.4114f, 2525.9739f, 2820.0503f, + 3120.7190f, 3623.7678f, 4050.5435f, 4434.5742f, 4802.6782f, 5171.8438f, + 5575.0068f, 5963.7402f, 290.1085f, 404.2538f, 664.1223f, 878.2748f, + 1237.1085f, 2237.4707f, 2497.5647f, 2957.7786f, 3289.3928f, 3626.5276f, + 4190.9243f, 4594.6450f, 4981.7456f, 5283.5513f, 5617.1538f, 5938.3760f, + 182.7846f, 270.3831f, 490.2131f, 1070.2524f, 1674.5724f, 2092.4905f, + 2524.1472f, 2929.3523f, 3334.8005f, 3712.0061f, 4101.2896f, 4475.7324f, + 4866.1919f, 5231.7559f, 5606.4077f, 5960.9644f, 286.7701f, 386.1487f, + 577.4210f, 764.3087f, 1151.2404f, 2014.4502f, 2399.8547f, 2879.0371f, + 3160.2502f, 3450.6274f, 3869.8240f, 4368.3618f, 4816.7861f, 5187.6450f, + 5564.7231f, 5962.0386f, 179.9538f, 266.0682f, 647.9122f, 1380.2810f, + 1776.1240f, 2208.4592f, 2590.6843f, 2993.6758f, 3368.2034f, 3753.2156f, + 4125.2124f, 4508.6050f, 4878.9932f, 5249.3291f, 5612.5049f, 5965.2134f, + 309.2416f, 434.7111f, 724.6614f, 936.5360f, 1264.9886f, 2272.1338f, + 2548.4519f, 2904.0798f, 3313.4990f, 3579.7854f, 3914.5811f, 4297.5938f, + 4756.9072f, 5163.2017f, 5592.2822f, 5943.7222f, 256.9009f, 393.7155f, + 769.3966f, 1200.9640f, 1774.4797f, 2307.9629f, 2794.6799f, 3165.9431f, + 3507.7952f, 3840.5791f, 4142.8877f, 4453.5078f, 4790.6973f, 5142.6123f, + 5530.5977f, 5923.2188f, 394.1425f, 602.0079f, 934.5173f, 1352.9718f, + 1813.9639f, 2172.5435f, 2603.7295f, 2963.9590f, 3335.2344f, 3732.0515f, + 4120.0151f, 4487.9668f, 4877.6294f, 5238.9336f, 5596.1479f, 5939.6489f, + 373.0307f, 665.4328f, 1227.4684f, 1524.6017f, 1947.3784f, 2361.6384f, + 2778.1921f, 3134.5396f, 3462.3992f, 3752.4592f, 4069.0352f, 4404.2720f, + 4782.2241f, 5145.0581f, 5541.9980f, 5932.9136f, 449.9942f, 814.1862f, + 1344.2784f, 1682.7061f, 2086.3599f, 2486.9709f, 2916.1177f, 3265.9099f, + 3616.3977f, 3919.6345f, 4218.5342f, 4519.2207f, 4857.5220f, 5193.5269f, + 5573.7339f, 5934.5400f, 531.4455f, 965.7403f, 1458.5353f, 1773.3784f, + 2236.0146f, 2650.9109f, 3099.2871f, 3467.1567f, 3809.7056f, 4094.6472f, + 4378.5811f, 4660.2471f, 4962.5078f, 5270.9863f, 5629.4160f, 5973.6450f, + 565.5986f, 1091.1300f, 1561.4944f, 1983.5482f, 2492.8821f, 2897.5085f, + 3233.5361f, 3539.8831f, 3838.6494f, 4093.4460f, 4372.1924f, 4678.2251f, + 4999.2646f, 5325.0371f, 5672.8887f, 5998.9990f, 581.0623f, 976.0275f, + 1447.0302f, 1779.9243f, 2148.2158f, 2543.8347f, 2979.5061f, 3373.6099f, + 3796.8259f, 4164.8242f, 4510.5493f, 4853.5527f, 5175.6318f, 5465.3647f, + 5763.2334f, 6050.6582f, 429.4613f, 802.5781f, 1229.0529f, 1512.6678f, + 1835.8625f, 2216.9915f, 2625.3999f, 2995.9927f, 3379.5146f, 3764.7837f, + 4156.1382f, 4532.4570f, 4906.4678f, 5262.8960f, 5626.6519f, 5970.6504f, + 224.5468f, 328.6938f, 615.8844f, 1207.4470f, 1520.9565f, 1865.9806f, + 2182.4731f, 2431.4897f, 3239.3486f, 3490.9065f, 3775.7139f, 4291.4312f, + 4740.0815f, 5192.0786f, 5532.9302f, 5928.7236f, 312.1133f, 424.3103f, + 716.4448f, 921.9969f, 1244.5491f, 2017.9143f, 2248.4170f, 2840.0688f, + 3138.9390f, 3399.7288f, 3723.3479f, 3999.6824f, 4582.2339f, 5148.5166f, + 5631.8989f, 6000.7192f, 373.5378f, 506.7356f, 789.6149f, 942.6201f, + 1695.8035f, 2021.6426f, 2323.3867f, 2649.5979f, 2853.1729f, 3169.5815f, + 3524.9375f, 3848.6399f, 4261.7319f, 4978.9668f, 5505.4004f, 5924.7939f, + 503.2296f, 724.8124f, 940.3833f, 1220.5646f, 1439.8641f, 1726.9827f, + 2215.5464f, 2476.0925f, 2846.8127f, 3232.0950f, 3638.5989f, 3986.3333f, + 4371.3052f, 5022.0664f, 5657.4897f, 6040.3452f, 398.3355f, 530.8898f, + 835.5377f, 1058.3699f, 1327.2036f, 1814.9178f, 2114.2439f, 2515.8892f, + 2754.9077f, 3094.8794f, 3598.7061f, 3981.2385f, 4605.9160f, 5110.8364f, + 5550.1899f, 5953.9600f, 327.7583f, 454.8903f, 825.9029f, 1025.4349f, + 1321.1567f, 1551.4836f, 1978.2037f, 2838.9021f, 3111.9041f, 3417.3940f, + 3841.0564f, 4696.0547f, 5126.1641f, 5409.5347f, 5711.7163f, 5968.3394f, + 327.1260f, 431.3983f, 721.9533f, 871.1266f, 1507.7616f, 1847.8716f, + 2144.9641f, 2491.1108f, 2702.0847f, 3483.1516f, 3917.5173f, 4254.1260f, + 4704.4863f, 4981.6284f, 5450.1035f, 5937.7861f, 443.5867f, 610.7686f, + 818.9614f, 999.3525f, 1181.9182f, 1884.4948f, 2243.3950f, 2522.8867f, + 2993.8594f, 3196.6631f, 3835.5020f, 4233.2568f, 4506.8604f, 4985.0249f, + 5544.1382f, 5980.0083f, 395.7788f, 582.9504f, 822.1151f, 1013.0453f, + 1224.6812f, 1988.4263f, 2452.4744f, 2686.4263f, 2952.8831f, 3135.0867f, + 3562.5471f, 4006.6929f, 4401.7471f, 5038.5654f, 5567.4189f, 5986.0850f, + 264.3071f, 372.0398f, 616.4940f, 842.1705f, 1350.0250f, 1822.1957f, + 2165.8896f, 2662.2937f, 3055.4390f, 3502.6787f, 3923.4236f, 4352.6587f, + 4772.5068f, 5158.1309f, 5573.9385f, 5972.6895f, 218.7390f, 325.2024f, + 635.0441f, 1103.4701f, 1636.4287f, 2070.2615f, 2274.2910f, 2453.2002f, + 3069.4382f, 3615.7065f, 3980.0811f, 4484.8662f, 4848.6416f, 5093.7163f, + 5522.6973f, 5907.4048f, 260.0797f, 461.2137f, 1049.2261f, 1334.1865f, + 1628.6233f, 2014.9823f, 2413.4802f, 2844.4973f, 3232.3040f, 3661.0122f, + 4069.8274f, 4466.5210f, 4857.6553f, 5234.4463f, 5608.4517f, 5954.7920f, + 301.7969f, 406.3861f, 706.7324f, 1387.1207f, 1581.4719f, 2004.7585f, + 2291.9421f, 2548.9978f, 3076.8755f, 3343.1306f, 3623.1770f, 4279.7432f, + 4777.6563f, 5084.3960f, 5473.4536f, 5872.0615f, 344.0269f, 472.3550f, + 776.6819f, 1455.1270f, 1611.6870f, 2012.4386f, 2417.4033f, 2621.8564f, + 3318.9663f, 3709.0132f, 3944.1958f, 4299.0293f, 4776.4038f, 5184.1089f, + 5545.5454f, 5913.9531f, 332.1463f, 433.0623f, 992.1605f, 1254.8217f, + 1498.4819f, 1824.6357f, 2118.3374f, 2444.6484f, 2684.8369f, 2930.4683f, + 3557.4851f, 4292.9014f, 4786.7251f, 5138.2168f, 5616.2739f, 5996.8369f, + 281.7202f, 372.7708f, 1074.7051f, 1443.0428f, 1687.6460f, 1980.7075f, + 2275.4241f, 2632.2017f, 2848.1765f, 3118.7881f, 3628.5857f, 4522.9585f, + 4876.2163f, 5177.2739f, 5600.6675f, 5960.9634f, 412.0151f, 535.6881f, + 768.8618f, 1462.2601f, 1789.1055f, 1947.8196f, 2224.6890f, 2447.9089f, + 2834.6140f, 3472.6721f, 3729.8525f, 4008.2893f, 4525.7271f, 4822.9194f, + 5204.6611f, 5895.0942f, 263.8760f, 379.7789f, 825.0498f, 1113.1218f, + 1465.8749f, 1846.7463f, 2146.0496f, 2487.2766f, 2845.8447f, 3388.4800f, + 3883.8447f, 4440.7603f, 4867.0815f, 5214.7280f, 5535.8149f, 5906.9932f, + 409.8116f, 583.7237f, 859.1983f, 1172.0491f, 1377.6473f, 1984.8322f, + 2361.7292f, 2688.9368f, 3238.6563f, 3542.6716f, 3944.3005f, 4441.0840f, + 4881.1211f, 5224.6045f, 5604.3711f, 5909.3657f, 318.0743f, 438.8244f, + 852.9153f, 1061.4503f, 1290.7609f, 1552.5408f, 2053.1118f, 2373.2883f, + 2926.1560f, 3452.9551f, 4098.6626f, 4585.2773f, 4967.0898f, 5271.2720f, + 5644.6709f, 5961.9585f, 370.3631f, 496.5860f, 932.6390f, 1213.4189f, + 1452.6641f, 1803.1532f, 2092.2354f, 2607.5247f, 2883.8086f, 3112.1086f, + 3687.5657f, 4525.1274f, 4846.9404f, 5130.0537f, 5416.4141f, 5804.5122f, + 247.8941f, 343.9862f, 751.6780f, 1526.2566f, 1712.5012f, 2038.0667f, + 2324.0371f, 2727.9749f, 3005.8975f, 3378.9817f, 3858.2002f, 4339.2017f, + 4716.4580f, 5125.0918f, 5564.3589f, 5969.7163f, 297.6552f, 401.7544f, + 891.9346f, 1380.2275f, 1540.3125f, 1782.6058f, 2009.2045f, 2614.2092f, + 2899.5396f, 3379.9722f, 3804.1169f, 4284.8540f, 4696.3335f, 5118.4551f, + 5525.9839f, 5934.2686f, 226.1444f, 333.4511f, 682.9995f, 1307.4166f, + 1554.1943f, 1849.3679f, 2116.3438f, 2756.3567f, 3204.3018f, 3540.4106f, + 4002.1895f, 4402.7734f, 4796.4395f, 5192.6812f, 5600.6841f, 5960.1855f, + 196.3791f, 299.9716f, 572.3173f, 1201.8826f, 1804.7235f, 2012.0171f, + 2264.7415f, 2790.3406f, 3272.6926f, 3668.4863f, 4063.0435f, 4442.4419f, + 4810.5957f, 5156.0923f, 5512.8501f, 5900.7441f, 280.1911f, 391.5190f, + 705.9903f, 1435.5063f, 1588.2345f, 2116.5032f, 2357.1875f, 2670.7461f, + 3299.0071f, 3507.9336f, 4044.3057f, 4591.9023f, 4981.4575f, 5281.1270f, + 5654.7158f, 5949.9263f, 262.5740f, 370.5089f, 654.7243f, 1278.9299f, + 1847.3096f, 2087.3394f, 2553.8892f, 2887.8269f, 3254.0747f, 3810.6626f, + 4258.4390f, 4528.8022f, 4872.9741f, 5206.0483f, 5565.2876f, 5918.5596f, + 193.6133f, 356.3127f, 1076.8109f, 1485.8608f, 1887.7994f, 2273.1333f, + 2676.7832f, 3052.3513f, 3419.1294f, 3792.5024f, 4161.7036f, 4532.6431f, + 4898.5176f, 5262.0498f, 5622.8901f, 5976.4863f, 302.7377f, 409.7598f, + 899.1851f, 1176.6501f, 1531.3615f, 1933.6494f, 2229.9561f, 2819.8936f, + 3031.6248f, 3807.0129f, 4118.7495f, 4412.7339f, 4704.6758f, 5012.0190f, + 5351.4160f, 5892.3232f, 421.1889f, 587.3521f, 835.9208f, 1248.0127f, + 1475.8882f, 1779.3772f, 2330.6294f, 2606.6780f, 3026.0417f, 3513.8035f, + 3754.6023f, 4081.0518f, 4536.3438f, 4815.9336f, 5117.6392f, 5802.9902f, + 378.0719f, 722.0884f, 1327.5808f, 1665.8940f, 1954.7782f, 2238.9473f, + 2608.8538f, 2958.7910f, 3341.5112f, 3721.2021f, 4095.8457f, 4457.6865f, + 4843.8672f, 5212.5142f, 5589.5122f, 5945.3730f, 468.4631f, 962.3222f, + 1541.0238f, 1919.1746f, 2347.4365f, 2650.7366f, 2927.5945f, 3166.4202f, + 3451.0664f, 3757.8477f, 4109.2383f, 4467.9443f, 4858.6045f, 5211.8428f, + 5593.3311f, 5951.0137f, 422.2508f, 845.8956f, 1495.2552f, 1811.3933f, + 2128.1157f, 2371.2532f, 2656.0715f, 2942.9011f, 3294.5308f, 3652.0935f, + 4031.2534f, 4399.2222f, 4801.9497f, 5163.3721f, 5559.4517f, 5934.4063f, + 423.1028f, 661.7286f, 991.1974f, 1204.3813f, 1472.8564f, 2003.0298f, + 2443.5833f, 2789.2795f, 3354.1692f, 3722.7822f, 4032.7351f, 4320.9727f, + 4621.8140f, 4963.7310f, 5429.8203f, 5900.1465f, 361.2513f, 485.9720f, + 828.4865f, 1340.9952f, 1497.8477f, 2072.8511f, 2437.9839f, 2674.9912f, + 3259.3357f, 3539.0474f, 3789.1389f, 4087.5015f, 4404.8867f, 4771.0947f, + 5500.2227f, 6015.7041f, 301.8146f, 392.9569f, 685.1938f, 1783.6246f, + 2034.8542f, 2257.1614f, 2519.8713f, 2782.6279f, 3152.1135f, 3400.8662f, + 3614.3801f, 3906.7375f, 4233.1968f, 4712.3682f, 5596.0396f, 5998.5742f, + 242.0591f, 371.0809f, 729.0743f, 1190.6813f, 1851.5691f, 2132.6724f, + 2334.7773f, 2522.3608f, 3091.8643f, 3621.4614f, 3854.5227f, 4174.7017f, + 4490.7510f, 4780.1230f, 5157.6147f, 5865.4756f, 431.2477f, 562.1808f, + 888.5207f, 1034.2062f, 1443.2480f, 2109.8850f, 2337.1443f, 2829.1870f, + 3070.1301f, 3252.6370f, 3510.3967f, 4366.2236f, 4843.2139f, 5133.0537f, + 5549.8911f, 5850.3252f, 420.2594f, 668.9339f, 911.1281f, 1218.0372f, + 1806.5541f, 2050.8423f, 2394.5708f, 2761.3542f, 3021.1716f, 3414.0020f, + 3970.9626f, 4342.2900f, 4691.6074f, 5062.5386f, 5452.6655f, 5792.8384f, + 257.3011f, 370.8905f, 604.8825f, 1096.4209f, 1711.8464f, 1934.4335f, + 2319.4717f, 2769.0144f, 3019.0200f, 3354.3726f, 4119.8809f, 4354.8589f, + 4557.7979f, 4893.5776f, 5450.3042f, 5910.4136f, 241.4264f, 347.9253f, + 622.2432f, 1248.8121f, 1559.7318f, 1848.8098f, 2315.5635f, 2571.5894f, + 2879.5754f, 3624.1069f, 3968.0334f, 4238.9727f, 4713.4746f, 5156.6792f, + 5568.5596f, 5975.8716f, 478.7131f, 629.4184f, 918.1857f, 1342.7815f, + 1535.1541f, 1803.0487f, 2483.7764f, 2724.4321f, 2998.1257f, 3634.9932f, + 3915.9443f, 4119.2837f, 4327.0283f, 4980.3516f, 5532.6880f, 5964.3052f, + 265.7818f, 373.8575f, 723.3755f, 1186.0619f, 1509.2827f, 2064.2075f, + 2298.1992f, 2566.4395f, 2785.7659f, 3423.1396f, 3883.9011f, 4136.8940f, + 4463.0386f, 5010.6592f, 5539.0337f, 5931.4414f, 221.4221f, 347.7610f, + 707.4465f, 1187.0800f, 1575.9095f, 1824.3983f, 1979.3307f, 2299.3174f, + 2967.6799f, 3472.3381f, 3955.8469f, 4292.6079f, 4794.8745f, 5127.5181f, + 5652.6729f, 5953.0132f, 397.2769f, 510.2605f, 746.8268f, 1588.0735f, + 1991.5200f, 2150.6843f, 2439.0486f, 2712.2754f, 2972.5825f, 3501.2673f, + 3917.5459f, 4143.6069f, 4443.4414f, 4829.1929f, 5490.0376f, 6028.3794f, + 280.5184f, 370.6464f, 640.7120f, 1721.3899f, 1948.9806f, 2149.9592f, + 2400.4678f, 2674.0542f, 3146.3154f, 3419.8850f, 3813.9553f, 4417.4497f, + 4818.3652f, 5139.6323f, 5465.0669f, 5879.7183f, 325.2418f, 431.2627f, + 1008.7708f, 1271.9235f, 1527.4150f, 2066.6370f, 2242.3311f, 2883.4065f, + 3180.6614f, 3352.5015f, 3756.9688f, 4386.6904f, 4857.6621f, 5189.2212f, + 5514.7573f, 5856.8086f, 451.8427f, 582.4401f, 925.8821f, 1363.4249f, + 1503.2460f, 1961.5940f, 2265.6001f, 2574.4414f, 3123.0769f, 3345.1587f, + 3634.3022f, 4266.0137f, 4880.8052f, 5223.5776f, 5567.8901f, 5880.3770f, + 411.0873f, 553.3847f, 809.2106f, 1023.4841f, 1189.0618f, 1786.0770f, + 2121.8489f, 2454.6458f, 2947.4700f, 3220.3210f, 3828.0911f, 4218.0229f, + 4831.2383f, 5322.1445f, 5727.3906f, 6033.3887f, 310.5608f, 442.2204f, + 742.7755f, 1097.5740f, 1340.9608f, 1854.4385f, 2261.6399f, 2634.8315f, + 3297.8879f, 3638.6956f, 3925.8770f, 4232.9146f, 4559.9287f, 4893.5830f, + 5403.0981f, 5917.7056f, 377.5583f, 488.4103f, 945.2491f, 1234.1572f, + 1416.0774f, 1666.5979f, 1932.9910f, 2746.2000f, 2997.4753f, 3216.6152f, + 3559.3999f, 3843.8130f, 4359.6626f, 5014.2920f, 5560.6162f, 5992.7212f, + 285.2173f, 389.6116f, 825.5790f, 1238.8229f, 1459.6588f, 1860.8855f, + 2178.6296f, 2519.1597f, 2828.0032f, 3278.8101f, 3560.8286f, 4142.0552f, + 4691.0698f, 5117.7778f, 5558.7944f, 5954.6680f, 465.7002f, 631.7491f, + 914.5521f, 1340.0057f, 1562.5760f, 1844.1741f, 2186.1208f, 2483.7080f, + 2901.9417f, 3190.3162f, 3474.7651f, 3873.4065f, 4240.1973f, 4761.1255f, + 5428.2832f, 5958.5273f, 340.5456f, 449.2341f, 793.7005f, 1387.7467f, + 1555.8701f, 1938.7877f, 2201.6155f, 2579.5762f, 2914.9724f, 3149.8584f, + 3699.3984f, 3985.6790f, 4331.7534f, 4999.4805f, 5514.6924f, 5969.4897f, + 395.8350f, 564.1188f, 774.8214f, 1276.3201f, 1721.8716f, 1864.0143f, + 2267.5696f, 2790.2031f, 3003.9434f, 3377.6140f, 3917.7395f, 4167.3867f, + 4465.2529f, 4936.1138f, 5464.0479f, 5905.0444f, 324.1844f, 443.0006f, + 728.8958f, 1398.6589f, 1584.1820f, 1923.8724f, 2348.0903f, 2561.5554f, + 3154.5991f, 3449.1746f, 3771.7927f, 4182.1899f, 4937.0791f, 5361.6509f, + 5727.7656f, 6002.7505f, 267.1790f, 373.7663f, 703.5949f, 1173.7009f, + 1390.2002f, 1905.7941f, 2177.4961f, 2703.2627f, 3022.9121f, 3308.9612f, + 3798.5823f, 4187.1533f, 4703.2163f, 5136.0918f, 5571.1655f, 5966.6577f, + 272.9294f, 399.3804f, 797.7335f, 1180.1516f, 1426.4850f, 2097.2839f, + 2355.4727f, 2793.8774f, 3137.1907f, 3458.7727f, 3893.6628f, 4245.8047f, + 4652.3794f, 5106.5293f, 5568.1885f, 5948.3169f, 324.5529f, 431.7663f, + 759.6147f, 1494.8739f, 1668.8168f, 2110.5635f, 2427.4104f, 2672.9270f, + 3170.5266f, 3448.2080f, 3717.1240f, 4034.2280f, 4375.3647f, 5041.1372f, + 5666.9517f, 6014.7217f, 306.4759f, 404.5361f, 795.7795f, 1675.9967f, + 1835.0950f, 2160.6624f, 2430.8855f, 2734.2646f, 3270.1426f, 3586.1355f, + 3821.9670f, 4102.0078f, 4372.9404f, 4918.9146f, 5412.0376f, 5868.5225f, + 421.3803f, 607.7995f, 813.0241f, 1286.8525f, 1827.2451f, 2026.8683f, + 2333.9453f, 2730.9817f, 2988.4067f, 3303.8513f, 3759.1897f, 4057.5264f, + 4441.5493f, 4890.0078f, 5212.0469f, 5672.2188f, 423.8560f, 599.5201f, + 829.0651f, 1082.6381f, 1245.9272f, 1623.7075f, 2453.0420f, 2855.6631f, + 3171.3855f, 3475.5881f, 3715.4219f, 3972.1326f, 4419.1597f, 4894.0283f, + 5363.8691f, 5919.2681f, 441.2789f, 634.8879f, 921.6287f, 1189.0240f, + 1368.7466f, 2012.1312f, 2383.7656f, 2638.5222f, 2975.0288f, 3163.6150f, + 3433.9958f, 3838.9917f, 4186.6426f, 4856.8477f, 5559.1196f, 5977.2290f, + 349.2039f, 466.2342f, 724.2582f, 904.4043f, 1190.4492f, 1981.7565f, + 2226.5554f, 2592.5098f, 2865.5525f, 3195.8196f, 3735.6345f, 4267.1660f, + 4810.9893f, 5207.5093f, 5605.1445f, 5952.0361f, 497.7713f, 719.9073f, + 925.0815f, 1146.3021f, 1326.7095f, 1574.5039f, 2306.7678f, 2714.8022f, + 2967.5190f, 3400.1121f, 3732.0544f, 3981.7878f, 4553.4819f, 5090.0869f, + 5426.2085f, 5833.5220f, 471.7526f, 648.3213f, 902.1542f, 1245.7086f, + 1423.3403f, 1701.1757f, 2125.8530f, 2407.0481f, 2969.5583f, 3294.1296f, + 3712.8398f, 4140.7930f, 4808.4668f, 5322.3896f, 5662.1255f, 5950.6211f, + 345.3843f, 485.9887f, 841.2579f, 1035.9401f, 1244.8905f, 1488.1833f, + 2340.4253f, 2607.0859f, 2845.4153f, 3223.1768f, 3557.0696f, 4119.7944f, + 4666.8896f, 5145.8589f, 5565.7534f, 5976.6875f, 332.4270f, 427.5984f, + 829.9191f, 1138.0469f, 1339.4468f, 1589.0535f, 1926.0630f, 2432.9331f, + 2699.7964f, 3311.4355f, 3716.1003f, 4270.4990f, 4760.3647f, 5208.3950f, + 5619.2080f, 5971.2715f, 249.0114f, 381.2982f, 925.7067f, 1520.3356f, + 1842.8396f, 2368.2908f, 2783.4033f, 3272.5757f, 3673.7402f, 4046.3950f, + 4370.4966f, 4688.0269f, 5002.6772f, 5316.3594f, 5650.2192f, 5977.6587f, + 263.3275f, 451.6255f, 1252.2307f, 1503.0652f, 1786.7695f, 2082.7554f, + 2451.1829f, 2804.7590f, 3116.7583f, 3493.8892f, 3884.6575f, 4349.6724f, + 4770.0156f, 5143.1636f, 5542.5913f, 5931.5522f, 252.9447f, 341.5762f, + 632.7664f, 1766.8096f, 2084.1511f, 2272.7332f, 2531.1006f, 2765.2080f, + 3134.5417f, 3380.6223f, 3640.8015f, 3932.7854f, 4532.1172f, 5245.2070f, + 5597.0776f, 5973.6831f, 234.9979f, 324.6731f, 1239.8643f, 1663.1921f, + 1858.7769f, 2171.1614f, 2403.8818f, 2680.6433f, 2836.4985f, 3192.6577f, + 3864.8811f, 4385.8066f, 4845.9766f, 5150.2412f, 5631.1519f, 6011.7773f, + 284.5302f, 410.1263f, 985.4119f, 1298.3987f, 1789.4304f, 1996.9287f, + 2450.8525f, 2831.6011f, 2994.2073f, 3214.1306f, 3525.0498f, 3819.9141f, + 4672.7544f, 5424.3545f, 5691.0732f, 5980.3096f, 244.2704f, 415.5891f, + 1038.3009f, 1317.5186f, 1686.4528f, 2081.3147f, 2476.9873f, 2959.5393f, + 3214.9561f, 3569.1431f, 3934.4736f, 4308.7114f, 4728.3687f, 5105.7964f, + 5488.1938f, 5908.9443f, 335.8417f, 468.3464f, 1003.6253f, 1275.0145f, + 1534.2854f, 1985.3167f, 2348.3411f, 2743.3169f, 2956.0967f, 3408.5063f, + 3866.8574f, 4287.0034f, 4556.7222f, 4922.7832f, 5259.7480f, 5800.2876f, + 388.2726f, 518.0591f, 832.5999f, 1325.0247f, 1528.8624f, 1808.1732f, + 2151.0820f, 2486.1331f, 2815.4980f, 3158.5391f, 3635.3606f, 3960.5383f, + 4671.7686f, 5371.8140f, 5777.8940f, 6056.4722f, 506.5153f, 673.0771f, + 900.0349f, 1154.2124f, 1378.2689f, 1786.9409f, 2081.9631f, 2398.6965f, + 2859.7441f, 3075.4841f, 3546.6563f, 4322.6694f, 4732.0049f, 4992.5542f, + 5267.5859f, 5807.1812f, 487.2466f, 653.6116f, 968.5656f, 1389.2708f, + 1601.5822f, 1910.9694f, 2282.4038f, 2608.7063f, 3032.6233f, 3361.9692f, + 3629.8552f, 3908.8335f, 4318.4009f, 4646.5781f, 5043.5962f, 5792.7393f, + 432.8733f, 591.7551f, 899.2619f, 1490.1176f, 1789.8751f, 2060.3750f, + 2434.8779f, 2840.3374f, 3122.1292f, 3472.8079f, 3830.8870f, 4097.2622f, + 4353.5464f, 4650.2075f, 4981.5752f, 5482.9565f, 378.4767f, 508.5656f, + 802.8280f, 947.2892f, 1532.0898f, 2038.8177f, 2349.1965f, 2650.2039f, + 2863.8018f, 3591.6697f, 3918.9211f, 4256.6255f, 4604.8467f, 4899.0996f, + 5237.6084f, 5791.5029f, 407.0908f, 546.0364f, 866.1215f, 1098.6927f, + 1347.2009f, 1657.1525f, 1965.5845f, 2717.7190f, 3033.4961f, 3509.9031f, + 3873.4150f, 4131.4438f, 4389.5693f, 4774.2295f, 5450.1768f, 5977.5151f, + 429.3459f, 568.8134f, 903.5659f, 1099.2942f, 1379.4979f, 2207.5940f, + 2479.9919f, 2780.9072f, 3206.3960f, 3425.4084f, 3682.5911f, 3950.1941f, + 4324.0840f, 4689.4922f, 5068.2534f, 5787.2852f, 371.9443f, 524.7249f, + 890.0464f, 1670.7485f, 1958.5308f, 2182.7007f, 2558.5007f, 2835.4937f, + 3192.0740f, 3634.4817f, 3950.0942f, 4259.6953f, 4628.0049f, 4999.1616f, + 5364.9893f, 5801.6855f, 323.1922f, 451.0327f, 787.1655f, 1011.6555f, + 1323.8138f, 2177.6636f, 2401.1392f, 2826.8796f, 3432.8999f, 3653.1851f, + 3883.9897f, 4082.7559f, 4361.6753f, 4635.1475f, 5084.7544f, 5823.3062f, + 377.0061f, 524.2181f, 743.6288f, 1378.9187f, 1857.6434f, 2056.4695f, + 2453.7949f, 2902.1995f, 3127.2651f, 3463.3523f, 3980.1316f, 4241.2578f, + 4528.5859f, 4881.4521f, 5239.3145f, 5580.5986f, 308.7965f, 403.7058f, + 705.9506f, 1823.8571f, 2126.9387f, 2369.2810f, 2647.2048f, 2855.8276f, + 3209.7708f, 3498.2310f, 3747.6047f, 3972.8647f, 4254.3325f, 4574.4292f, + 5087.3965f, 5890.4219f, 274.7571f, 383.7251f, 573.6029f, 1142.8372f, + 2151.7173f, 2558.8972f, 2751.9468f, 2987.4412f, 3234.3350f, 3526.0127f, + 3922.9927f, 4189.0249f, 4483.3774f, 4877.1860f, 5396.7798f, 5921.8125f, + 248.5916f, 423.6264f, 1260.9626f, 1696.0492f, 1972.9108f, 2298.5972f, + 2592.9307f, 2947.2292f, 3266.2227f, 3614.3572f, 3980.3892f, 4359.4067f, + 4770.2842f, 5158.9058f, 5554.6597f, 5936.9043f, 320.5471f, 429.6766f, + 657.1440f, 1390.1080f, 2194.6426f, 2507.6086f, 2712.3662f, 2980.3408f, + 3216.1682f, 3544.8467f, 3956.9790f, 4227.5308f, 4463.7563f, 4745.7124f, + 5088.6650f, 5525.8516f, 245.5478f, 520.3131f, 1177.0693f, 1454.0125f, + 1770.2620f, 2160.8779f, 2551.2700f, 2950.2324f, 3326.8621f, 3710.4624f, + 4104.3936f, 4481.9971f, 4865.9736f, 5230.6396f, 5608.5649f, 5965.6162f, + 514.5864f, 956.9897f, 1287.9597f, 1520.3473f, 1802.0631f, 2116.4980f, + 2509.8552f, 2865.9822f, 3238.7510f, 3611.3108f, 4016.4353f, 4431.8457f, + 4860.3442f, 5231.4814f, 5614.6016f, 5963.9976f, 537.0523f, 932.2803f, + 1380.2690f, 1709.4702f, 2079.9902f, 2446.4014f, 2859.4204f, 3229.6975f, + 3623.4031f, 4012.5327f, 4373.7568f, 4724.3359f, 5078.2686f, 5397.6040f, + 5721.9639f, 6028.1167f, 452.5153f, 798.2777f, 1099.3080f, 1317.0807f, + 1652.6885f, 2059.7708f, 2471.0164f, 2808.5396f, 3146.5076f, 3494.0779f, + 3870.6912f, 4310.8281f, 4777.5024f, 5181.2617f, 5574.4912f, 5934.3813f, + 340.3716f, 430.5102f, 872.3513f, 1636.3792f, 1772.8615f, 2074.0161f, + 2295.1008f, 2693.0037f, 3177.7710f, 3391.7559f, 3670.8718f, 4224.3926f, + 4896.3877f, 5199.9883f, 5580.4512f, 5911.7671f, 317.8269f, 414.8185f, + 881.1970f, 1658.4944f, 1852.0098f, 2136.0415f, 2380.8228f, 2668.9141f, + 3046.8027f, 3299.0051f, 3523.0593f, 3758.9412f, 4116.9063f, 5061.2124f, + 5624.1777f, 5989.4761f, 374.0671f, 488.0840f, 734.0546f, 1415.9261f, + 1648.7783f, 1852.8462f, 2099.1895f, 2347.5562f, 2954.8359f, 3269.6714f, + 3536.7920f, 4116.1743f, 4481.4355f, 4913.8838f, 5467.2817f, 5909.8779f, + 340.4291f, 448.5775f, 1041.4979f, 1426.0011f, 1637.8165f, 1968.6743f, + 2210.7976f, 2647.5144f, 2913.8650f, 3131.7698f, 3429.8755f, 3722.6763f, + 4104.6479f, 4969.0093f, 5574.2231f, 5978.2070f, 254.2538f, 412.7710f, + 947.8206f, 1209.3683f, 1690.4813f, 2040.7881f, 2401.4314f, 2728.0066f, + 3016.2290f, 3530.3865f, 3964.6563f, 4393.6934f, 4804.2168f, 5187.9302f, + 5586.4399f, 5954.8950f, 241.0244f, 347.0750f, 835.2348f, 1601.9089f, + 1786.4336f, 2134.3950f, 2396.0139f, 2848.9712f, 3239.9138f, 3623.8250f, + 4029.5088f, 4400.3936f, 4797.3564f, 5195.7310f, 5596.6689f, 5965.9878f, + 309.3683f, 453.6776f, 812.9343f, 1125.9915f, 1423.5935f, 2149.2227f, + 2514.9277f, 3031.3599f, 3463.7219f, 3790.7839f, 4064.0039f, 4297.9839f, + 4653.4551f, 5189.7061f, 5721.2954f, 6033.0752f, 469.4284f, 730.1902f, + 973.0643f, 1170.5016f, 1572.2559f, 2084.2769f, 2567.8604f, 2963.4592f, + 3286.9617f, 3580.3228f, 3882.8706f, 4335.5483f, 4859.7197f, 5258.2827f, + 5627.9785f, 5957.8623f, 454.6165f, 795.2360f, 1078.7705f, 1294.9473f, + 1761.6650f, 2235.2788f, 2695.8455f, 3095.7695f, 3473.4897f, 3833.0889f, + 4185.7290f, 4528.9863f, 4893.0039f, 5240.7627f, 5608.8594f, 5951.0718f, + 563.4587f, 875.8987f, 1139.0026f, 1378.2317f, 1855.7401f, 2279.7683f, + 2651.3079f, 2968.4397f, 3279.4453f, 3607.2500f, 3975.5796f, 4358.3574f, + 4768.7969f, 5135.3706f, 5525.3501f, 5904.2617f, 461.7852f, 855.0644f, + 1367.4387f, 1702.5593f, 2141.0093f, 2500.9055f, 2853.8596f, 3123.9744f, + 3406.0178f, 3694.0481f, 4028.9985f, 4373.1113f, 4768.2891f, 5137.6895f, + 5541.3721f, 5921.4507f, 438.6031f, 753.0179f, 1269.3203f, 1630.4396f, + 2027.2959f, 2350.9695f, 2672.1396f, 2957.1809f, 3250.1545f, 3546.5315f, + 3894.0161f, 4249.9346f, 4666.2266f, 5061.2524f, 5490.7749f, 5904.6362f, + 543.3182f, 828.4835f, 1239.1818f, 1471.1134f, 1737.8622f, 2037.2484f, + 2434.5112f, 2801.3242f, 3162.3250f, 3508.1255f, 3849.0903f, 4165.7588f, + 4588.3809f, 5020.0952f, 5475.2813f, 5904.6377f, 519.5982f, 837.6639f, + 1171.2003f, 1363.0320f, 1617.4617f, 1976.1787f, 2472.0303f, 2901.3264f, + 3340.7300f, 3736.0830f, 4103.3843f, 4444.8657f, 4800.9482f, 5145.6011f, + 5544.2002f, 5933.0981f, 433.3774f, 582.7663f, 899.6142f, 1150.7437f, + 1321.1309f, 1947.8643f, 2557.8604f, 2733.1497f, 3240.4907f, 3634.7915f, + 3855.9856f, 4058.0281f, 4364.2568f, 5096.5225f, 5659.0952f, 6013.8145f, + 424.9731f, 604.3164f, 868.1793f, 1207.7882f, 1414.2374f, 1713.2893f, + 2520.2900f, 2960.8887f, 3210.8542f, 3584.5403f, 3914.5796f, 4149.8550f, + 4505.7705f, 4886.9575f, 5214.5361f, 5597.8389f, 347.0334f, 494.2440f, + 753.7191f, 1451.0435f, 1700.7461f, 1925.4844f, 2605.7988f, 2870.4744f, + 3173.7312f, 3758.7219f, 4112.1929f, 4400.3882f, 4866.1016f, 5165.8799f, + 5433.0371f, 5781.1509f, 318.4942f, 464.3939f, 783.5214f, 1491.0234f, + 1708.4984f, 2280.2876f, 2533.3354f, 2885.1736f, 3443.7451f, 3669.8506f, + 4000.6792f, 4269.6626f, 4571.2739f, 4827.2158f, 5277.3813f, 5850.4736f, + 386.8698f, 519.0056f, 725.0029f, 981.5649f, 1156.1665f, 1500.4691f, + 2421.7993f, 2962.4722f, 3175.0166f, 3548.4756f, 3860.7961f, 4146.4150f, + 4658.9897f, 5088.3999f, 5531.8945f, 5951.4624f, 315.9294f, 738.5538f, + 1171.9581f, 1553.7167f, 1949.9159f, 2319.6641f, 2707.5493f, 3069.2996f, + 3444.6157f, 3811.2139f, 4177.5469f, 4545.6943f, 4905.0444f, 5271.3926f, + 5622.6831f, 5974.4141f, 216.5136f, 598.1122f, 1059.3214f, 1466.4785f, + 1880.1747f, 2263.6533f, 2658.3081f, 3030.4099f, 3413.6802f, 3780.1853f, + 4157.1455f, 4519.1919f, 4893.5439f, 5244.3530f, 5603.1064f, 5926.8379f, + 375.4021f, 487.0890f, 844.4013f, 1574.3596f, 1794.5249f, 2106.2878f, + 2418.5217f, 2657.8938f, 3116.6096f, 3457.8625f, 3691.0596f, 3930.1062f, + 4259.5928f, 4592.4370f, 5020.5078f, 5840.3989f, 474.3148f, 724.2144f, + 974.0716f, 1283.4182f, 1521.2632f, 1746.4248f, 2333.0957f, 2874.2966f, + 3111.9636f, 3440.0410f, 3752.9678f, 3975.7139f, 4294.7056f, 4821.9893f, + 5201.5562f, 5658.8301f, 400.0291f, 564.9626f, 808.2393f, 1083.2745f, + 1300.4403f, 2080.7405f, 2588.6882f, 2858.4629f, 3206.4502f, 3429.8623f, + 3746.9080f, 4341.4868f, 4713.2803f, 4986.4258f, 5336.7339f, 5710.1123f, + 354.4416f, 480.1495f, 834.1089f, 1037.7775f, 1350.0652f, 1791.1736f, + 2193.0159f, 2504.6775f, 2776.0623f, 3153.0994f, 4108.1357f, 4597.4082f, + 4861.9688f, 5092.8613f, 5473.2295f, 5932.0332f, 237.3935f, 346.9133f, + 675.5335f, 1481.0535f, 1716.8414f, 1884.7153f, 2099.3057f, 2725.5403f, + 3022.8506f, 3276.2922f, 3639.1001f, 4185.3926f, 4941.6597f, 5292.0093f, + 5682.0391f, 5981.0215f, 367.4981f, 469.7130f, 820.7811f, 1219.7736f, + 1368.4479f, 1624.6671f, 1804.2581f, 2607.8589f, 2891.3174f, 3212.2432f, + 3760.7290f, 4015.6111f, 4618.0068f, 5129.3213f, 5652.1582f, 6042.1113f, + 312.6796f, 415.8322f, 674.1500f, 853.7709f, 1808.7385f, 2232.5310f, + 2497.8157f, 2834.2991f, 3039.7012f, 3301.4050f, 3659.2969f, 4455.9453f, + 4841.4912f, 5111.6167f, 5502.2534f, 5924.6357f, 341.9309f, 471.7513f, + 758.1926f, 979.7221f, 1287.4463f, 1737.0303f, 2160.7915f, 2664.5562f, + 2961.8315f, 3461.7439f, 3732.6611f, 4109.0928f, 4568.9111f, 5037.4331f, + 5511.3169f, 5966.1304f, 351.3721f, 462.1897f, 765.1075f, 946.3102f, + 1322.8093f, 2292.2400f, 2503.6494f, 2819.7234f, 3079.2803f, 3297.6252f, + 3571.4668f, 3872.0823f, 4337.6426f, 5079.1504f, 5562.8110f, 5942.7153f, + 435.4323f, 614.4746f, 892.8980f, 1215.9469f, 1395.9762f, 1814.3936f, + 2155.9590f, 2465.0427f, 3201.6211f, 3490.9224f, 3853.2620f, 4410.1855f, + 4786.0625f, 5095.0181f, 5394.4805f, 5715.3364f, 294.6053f, 417.1553f, + 1046.2922f, 1443.0247f, 1636.7180f, 1956.4248f, 2189.9697f, 2869.8071f, + 3129.9385f, 3462.5681f, 3895.2805f, 4213.4541f, 4541.8950f, 5009.1958f, + 5472.7642f, 5983.0063f, 322.1185f, 446.8733f, 689.4188f, 1338.2788f, + 1643.1023f, 1903.8652f, 2494.2722f, 2804.6968f, 3103.8682f, 3640.1233f, + 3965.9861f, 4172.5596f, 4404.7388f, 4670.7544f, 5240.3682f, 5893.4600f, + 209.7024f, 336.5508f, 729.0126f, 1217.3285f, 1699.0111f, 1891.2837f, + 2146.8486f, 2830.0850f, 3108.6204f, 3446.0396f, 3754.1230f, 3945.1038f, + 4474.5806f, 5191.6987f, 5613.3076f, 5970.2695f, 346.6580f, 470.5094f, + 663.3455f, 1266.9061f, 2020.5759f, 2270.5173f, 2527.3550f, 2826.9104f, + 3078.3403f, 3401.2625f, 3804.3770f, 4100.3091f, 4407.7876f, 4732.2319f, + 5150.2749f, 5808.2559f, 283.7796f, 391.4603f, 1165.6863f, 1456.1125f, + 1692.9001f, 2008.4825f, 2322.7837f, 2784.0608f, 2998.5811f, 3268.5164f, + 3548.9373f, 4167.1289f, 4643.9878f, 5099.2881f, 5473.0781f, 5929.8242f, + 301.0849f, 383.1578f, 692.0848f, 1648.9374f, 1873.0947f, 2109.6113f, + 2345.0110f, 2613.1121f, 2922.0193f, 3170.0020f, 3405.0774f, 3881.9875f, + 4778.3154f, 5092.5205f, 5445.7100f, 5920.7896f, 509.1023f, 750.8580f, + 963.8820f, 1295.3452f, 1634.8796f, 1818.7975f, 2151.1250f, 2590.3354f, + 2867.5596f, 3238.7666f, 3747.2834f, 4053.8911f, 4457.8164f, 4928.0151f, + 5295.3521f, 5789.0571f, 421.8951f, 547.9814f, 967.4185f, 1153.8607f, + 1461.4230f, 1813.0994f, 2155.2703f, 2570.9712f, 2777.6597f, 3048.9863f, + 3432.0986f, 3729.3877f, 4395.7461f, 5028.7402f, 5486.4946f, 5951.5024f, + 340.6758f, 445.7014f, 931.8882f, 1253.4775f, 1521.9260f, 1969.5759f, + 2267.5332f, 2735.0112f, 2948.7678f, 3236.5166f, 3529.5505f, 3882.3674f, + 4699.5781f, 5089.6641f, 5377.7842f, 5880.7778f, 284.1882f, 408.6918f, + 786.3123f, 1670.3220f, 2042.9493f, 2265.2275f, 2691.2012f, 3035.8762f, + 3334.1719f, 3863.1194f, 4276.8916f, 4571.0420f, 4996.4404f, 5336.5205f, + 5647.9556f, 5944.5996f, 300.0066f, 616.4817f, 1238.7324f, 1614.8296f, + 1997.6188f, 2367.4343f, 2784.5605f, 3168.8354f, 3569.8250f, 3965.6011f, + 4336.3804f, 4689.5874f, 5044.2012f, 5365.7456f, 5697.5654f, 6010.6572f, + 242.9420f, 476.8371f, 1250.6661f, 1671.6031f, 2159.6443f, 2637.7417f, + 3049.8589f, 3371.6045f, 3674.8706f, 3951.1006f, 4230.6416f, 4543.2827f, + 4887.4478f, 5220.5581f, 5595.2686f, 5962.1313f, 242.6795f, 331.1335f, + 635.2861f, 1801.5236f, 2084.1472f, 2264.4692f, 2506.2891f, 2799.4441f, + 3236.7134f, 3489.6038f, 3859.3291f, 4424.8008f, 4964.6348f, 5298.6533f, + 5640.2031f, 5988.0552f, 254.0538f, 336.2447f, 1216.6261f, 1717.7201f, + 1886.0708f, 2176.6338f, 2405.8547f, 2762.3037f, 2934.8816f, 3167.0657f, + 3385.5457f, 3804.4346f, 4848.8198f, 5286.0352f, 5630.5391f, 6086.4492f, + 295.2298f, 426.2079f, 630.7856f, 1155.5609f, 1827.6831f, 2120.5283f, + 2462.4373f, 2759.6152f, 2990.9526f, 3253.4216f, 3910.9834f, 4204.2754f, + 4462.7944f, 4909.7529f, 5579.9653f, 5985.8579f, 298.9633f, 410.3875f, + 810.1115f, 1346.1040f, 1499.2391f, 2210.3948f, 2467.9424f, 2792.7122f, + 3284.0874f, 3493.0740f, 3784.1899f, 4319.6396f, 4860.6548f, 5213.8540f, + 5609.8672f, 5949.6890f, 437.9900f, 575.3093f, 866.0077f, 1104.2080f, + 1307.4966f, 1959.9323f, 2293.9365f, 2604.6704f, 2966.6514f, 3228.0056f, + 3548.8499f, 4096.4424f, 4769.5420f, 5086.5449f, 5416.5317f, 5853.6909f, + 412.4955f, 569.1867f, 864.0179f, 1117.6798f, 1348.6332f, 1976.5171f, + 2334.3960f, 2640.3381f, 3006.5347f, 3327.5784f, 3695.8564f, 4042.1753f, + 4362.7837f, 4687.4751f, 5389.8662f, 5966.5825f, 406.8686f, 542.0319f, + 867.3541f, 1436.3810f, 1678.6399f, 2000.1501f, 2358.1204f, 2651.3806f, + 3042.1216f, 3339.2766f, 3617.9963f, 3933.3860f, 4249.0278f, 4591.8530f, + 5502.0400f, 6020.7910f, 375.4336f, 519.7731f, 764.5574f, 1215.1381f, + 1482.9417f, 1696.8020f, 1957.0332f, 2169.1169f, 2973.4634f, 3687.7449f, + 3966.8525f, 4258.8042f, 4680.6567f, 4947.0225f, 5230.9824f, 5843.2466f, + 443.2378f, 574.0562f, 813.3345f, 1282.7894f, 1538.0752f, 1727.8997f, + 2007.8584f, 2194.5601f, 2755.8220f, 3460.9243f, 3654.1399f, 4030.5530f, + 4572.4727f, 4904.7847f, 5400.6147f, 5934.2656f, 423.6246f, 540.1947f, + 862.8629f, 1386.7659f, 1577.2052f, 1811.0304f, 2046.7363f, 2309.0366f, + 3129.1145f, 3533.0020f, 3738.4211f, 4021.1111f, 4357.3677f, 4634.8740f, + 5307.2920f, 5944.9155f, 287.7661f, 401.5490f, 725.6079f, 950.8911f, + 1186.5465f, 1490.1750f, 2114.7920f, 2562.4019f, 3028.3977f, 3519.6277f, + 3940.5737f, 4339.3086f, 4765.8188f, 5172.3428f, 5582.8022f, 5971.0273f, + 382.6039f, 537.7234f, 836.8093f, 1371.3546f, 1578.9803f, 1869.8213f, + 2292.5596f, 2540.8601f, 3032.9834f, 3402.5059f, 3737.0569f, 4053.9937f, + 4446.6240f, 5251.8457f, 5710.7935f, 6022.2925f, 313.2195f, 415.0511f, + 690.6860f, 1561.4832f, 1815.6521f, 2059.9187f, 2345.5095f, 2614.8701f, + 3006.9604f, 3291.9744f, 3590.4119f, 3996.1516f, 4365.4995f, 4853.4956f, + 5465.1572f, 5954.5718f, 361.7959f, 448.4001f, 921.3198f, 1343.1167f, + 1488.6287f, 1736.7700f, 1950.8906f, 2536.0193f, 2768.7393f, 3062.4473f, + 3484.6570f, 3888.5618f, 4618.4038f, 5092.6641f, 5523.3657f, 5966.6772f, + 249.5541f, 366.6601f, 684.6592f, 1203.0931f, 1642.2089f, 1961.8837f, + 2227.3289f, 2421.1348f, 2660.5676f, 3229.5410f, 3822.5837f, 4232.7266f, + 4782.5181f, 5127.2612f, 5570.2676f, 5978.9858f, 287.4206f, 421.3210f, + 704.0352f, 1279.8597f, 1562.7307f, 2115.4241f, 2492.4517f, 2780.9470f, + 3317.3616f, 3606.1492f, 4026.6375f, 4337.9014f, 4699.6895f, 4997.2573f, + 5431.1787f, 5903.8628f, 487.9554f, 740.9349f, 1021.9616f, 1327.3262f, + 1620.8544f, 1890.7717f, 2269.1218f, 2584.4868f, 2911.2896f, 3424.9221f, + 3855.1670f, 4205.9272f, 4707.2466f, 5147.1846f, 5601.1152f, 5953.4673f, + 400.8269f, 513.4500f, 786.8242f, 1269.3298f, 1441.4178f, 1696.9789f, + 1911.0537f, 2223.0684f, 2847.1619f, 3113.3845f, 3670.6318f, 4146.2900f, + 4555.9204f, 5083.8579f, 5574.8120f, 5987.6030f, 379.0329f, 487.7222f, + 914.8179f, 1130.9854f, 1430.1394f, 1830.0769f, 2088.8796f, 2613.6855f, + 2803.1633f, 3457.1777f, 4032.6118f, 4306.7344f, 4662.6899f, 4959.6348f, + 5245.5234f, 5787.3940f, 340.6941f, 451.0338f, 656.2767f, 911.5805f, + 1124.9330f, 1733.8730f, 2518.7861f, 2768.6851f, 3211.3733f, 3717.7583f, + 3929.6772f, 4176.2993f, 4522.4517f, 5011.5547f, 5575.8784f, 6006.7222f, + 341.5027f, 441.6417f, 807.2695f, 1060.2080f, 1251.2837f, 1478.9895f, + 1750.0796f, 2594.8977f, 2924.5027f, 3401.4751f, 3852.0557f, 4292.4683f, + 4718.2930f, 5159.4775f, 5562.4067f, 5972.5571f, 313.8985f, 421.5380f, + 667.2407f, 873.6023f, 1110.1119f, 2060.7332f, 2381.0916f, 2746.2288f, + 3080.5649f, 3399.9905f, 3897.5884f, 4434.9990f, 5048.1343f, 5390.8149f, + 5744.3931f, 6007.9326f, 252.1832f, 354.2392f, 673.5427f, 1339.1161f, + 1554.8853f, 2014.9351f, 2300.4138f, 2829.6182f, 3213.1714f, 3409.5105f, + 3604.3242f, 3927.8020f, 4622.3218f, 5103.4565f, 5559.5024f, 5971.5986f, + 385.2648f, 513.7607f, 760.7678f, 983.5819f, 1175.7727f, 2134.7810f, + 2592.9614f, 2822.0161f, 3232.2524f, 3445.3516f, 3750.7583f, 4094.6714f, + 4401.5830f, 4753.4204f, 5549.2319f, 6034.7148f, 220.6833f, 314.5706f, + 622.2172f, 1350.8225f, 1785.5879f, 2077.5837f, 2504.2158f, 3057.6992f, + 3436.0974f, 3695.2976f, 3953.4272f, 4267.8701f, 4660.6865f, 5073.6831f, + 5501.9478f, 5929.9780f, 207.8814f, 310.4071f, 646.2098f, 1270.5835f, + 1542.7271f, 2079.3804f, 2440.0339f, 2843.4690f, 3272.4854f, 3657.9851f, + 4061.2014f, 4444.9780f, 4841.6060f, 5224.5947f, 5620.9141f, 5972.7261f, + 326.1488f, 456.7737f, 740.3350f, 961.4597f, 1262.7579f, 2190.7178f, + 2483.5300f, 2872.4180f, 3328.4910f, 3811.0334f, 4153.1602f, 4441.8271f, + 4801.1802f, 5065.2988f, 5381.6309f, 5693.2886f, 206.2046f, 328.0855f, + 618.9507f, 980.9994f, 1695.9775f, 1982.3051f, 2275.5444f, 2806.0271f, + 3269.5178f, 3491.2456f, 3722.1775f, 4145.9121f, 4843.1167f, 5266.8677f, + 5656.8794f, 5992.1201f, 308.1086f, 407.7706f, 806.7985f, 1045.7629f, + 1401.8912f, 2108.3472f, 2331.7849f, 2952.5391f, 3174.1865f, 3374.0686f, + 3645.4260f, 4292.7183f, 4939.2969f, 5250.4829f, 5607.2358f, 5932.8657f, + 267.5990f, 378.7492f, 642.2629f, 871.7917f, 1691.7523f, 2087.5117f, + 2423.1462f, 2686.1487f, 3021.7893f, 3724.0247f, 4035.5454f, 4369.5903f, + 4680.1167f, 4991.4175f, 5323.6875f, 5811.7471f, 312.3856f, 437.4281f, + 714.5340f, 899.5771f, 1632.7545f, 1938.5369f, 2295.5544f, 2625.6189f, + 2900.5576f, 3295.4934f, 3557.1260f, 3960.1123f, 4731.6079f, 5141.8447f, + 5502.7793f, 5954.0049f, 332.2842f, 449.0976f, 875.9957f, 1206.1912f, + 1422.6793f, 2097.5745f, 2354.2483f, 2715.8494f, 3093.4697f, 3344.5132f, + 3623.4814f, 3889.3655f, 4256.2002f, 4994.5742f, 5593.8428f, 5985.9575f, + 286.9586f, 434.7701f, 781.3996f, 1248.3495f, 1835.5530f, 2137.1155f, + 2573.7449f, 2869.9299f, 3126.0564f, 3459.1448f, 3769.4475f, 4138.3076f, + 4688.0298f, 5084.9028f, 5436.8086f, 5894.2520f, 327.0000f, 429.0804f, + 663.7327f, 849.7463f, 1174.9340f, 2383.3875f, 2695.9597f, 2941.2026f, + 3214.4724f, 3433.6287f, 3778.9312f, 4134.8096f, 4504.8022f, 5066.7559f, + 5599.2290f, 5985.7334f, 244.4052f, 499.2254f, 1294.8232f, 1689.3677f, + 2123.5024f, 2572.4958f, 3042.9067f, 3446.8752f, 3836.3740f, 4175.6729f, + 4485.3213f, 4792.3755f, 5094.9077f, 5386.1816f, 5699.6411f, 6008.2114f, + 561.9757f, 1020.3204f, 1494.1995f, 1841.8171f, 2297.0906f, 2772.6184f, + 3204.8804f, 3565.8628f, 3935.4106f, 4253.4141f, 4559.7021f, 4849.9653f, + 5140.2852f, 5428.6934f, 5731.2251f, 6023.5078f, 581.6182f, 1053.5670f, + 1478.5878f, 1784.4789f, 2125.1157f, 2454.5889f, 2809.0256f, 3141.7256f, + 3490.7529f, 3848.5923f, 4201.7271f, 4568.7720f, 4945.9619f, 5288.6289f, + 5647.7642f, 5981.9341f, 258.9683f, 364.0963f, 722.5463f, 1763.2114f, + 1969.3870f, 2265.5239f, 2532.1821f, 2883.3557f, 3388.1838f, 3725.3120f, + 4080.9338f, 4390.3818f, 4716.3599f, 5068.4941f, 5452.2778f, 5847.1401f, + 271.5428f, 401.4228f, 695.5894f, 857.3072f, 1776.5358f, 2008.5603f, + 2554.4143f, 2844.4021f, 3018.6877f, 3226.1279f, 3482.3398f, 3810.6858f, + 4549.3071f, 5266.2764f, 5614.6157f, 5945.6904f, 330.3132f, 444.6271f, + 669.0279f, 874.5479f, 1102.9247f, 2052.1780f, 2436.2378f, 2711.1165f, + 3037.7537f, 3298.2036f, 3898.6858f, 4241.5415f, 4606.7637f, 5086.6919f, + 5569.7397f, 5988.6797f, 232.3014f, 344.5512f, 578.5155f, 1213.9569f, + 1880.9729f, 2105.6685f, 2335.4148f, 2550.3965f, 3147.6501f, 3491.9253f, + 3791.5613f, 4159.6694f, 4642.2441f, 5103.3340f, 5605.4106f, 5989.7969f, + 346.3687f, 444.8047f, 714.3775f, 889.1195f, 1211.8463f, 2168.7598f, + 2430.2490f, 2760.6326f, 3012.4961f, 3268.8750f, 3565.1558f, 4172.5791f, + 4781.5391f, 5127.6704f, 5512.6323f, 5911.3779f, 398.0477f, 553.8537f, + 845.8521f, 1119.3066f, 1309.7244f, 1928.3351f, 2351.2095f, 2649.8230f, + 3050.6750f, 3297.0566f, 3592.7275f, 3916.1785f, 4723.3325f, 5318.1221f, + 5703.9697f, 5996.7651f, 371.4409f, 471.0789f, 896.4924f, 1197.7544f, + 1400.8007f, 1611.1555f, 1867.3550f, 2818.4475f, 3002.5906f, 3250.1440f, + 3546.5891f, 4265.0371f, 4890.3369f, 5274.4722f, 5659.3560f, 5946.9644f, + 330.9331f, 448.7211f, 808.3973f, 978.2021f, 1652.6361f, 1969.0725f, + 2357.0146f, 2680.4792f, 2859.9165f, 3078.9578f, 3423.6895f, 4233.3169f, + 4856.7813f, 5086.5723f, 5393.9961f, 5938.6035f, 323.9659f, 433.8731f, + 1045.5168f, 1369.1907f, 1561.9178f, 1984.2457f, 2224.0959f, 2747.3657f, + 2995.0359f, 3242.9248f, 3501.0344f, 4022.2388f, 4847.4985f, 5210.9922f, + 5658.1357f, 6005.0718f, 354.6574f, 501.6520f, 852.5305f, 1020.8707f, + 1540.5925f, 1998.5675f, 2253.1487f, 2845.3960f, 3056.5273f, 3305.0466f, + 3954.2900f, 4591.7471f, 4915.2856f, 5221.9082f, 5544.7285f, 5879.9150f, + 363.1311f, 474.7310f, 907.5490f, 1106.8586f, 1367.2662f, 1646.6934f, + 2031.3650f, 2326.4382f, 2568.6519f, 3030.1091f, 3905.6482f, 4265.9111f, + 4716.1831f, 5017.0454f, 5469.8149f, 5958.6182f, 379.9262f, 524.4459f, + 845.4813f, 1275.4414f, 1458.2488f, 1772.5863f, 2067.7981f, 2526.8850f, + 3066.4063f, 3307.8713f, 3807.2900f, 4199.1509f, 4452.4653f, 4854.7471f, + 5464.8833f, 5947.7842f, 371.8218f, 483.9148f, 778.2747f, 1208.0812f, + 1366.3983f, 1623.4895f, 1798.8777f, 2224.6445f, 3103.7175f, 3386.0408f, + 3782.8284f, 4307.4727f, 4698.8994f, 5118.1255f, 5505.1919f, 5921.1724f, + 217.9059f, 323.3224f, 639.7305f, 1026.5331f, 1312.9242f, 1885.6948f, + 2361.8403f, 2805.5396f, 3213.2600f, 3631.5017f, 4033.4087f, 4426.3423f, + 4821.3203f, 5208.3833f, 5590.5205f, 5956.1538f, 211.9971f, 311.2018f, + 504.6345f, 858.3289f, 1574.7019f, 1934.9866f, 2381.4163f, 2786.2043f, + 3238.9326f, 3611.0518f, 4005.2578f, 4401.0615f, 4802.1479f, 5192.5493f, + 5587.1479f, 5965.5977f, 219.3884f, 319.3835f, 604.0102f, 1114.8630f, + 1481.3870f, 2036.0469f, 2303.4883f, 2616.1384f, 3253.6335f, 3556.5107f, + 3946.6567f, 4520.3555f, 5091.0479f, 5416.3037f, 5748.5737f, 5946.5757f, + 350.3716f, 515.4462f, 756.5206f, 1061.4270f, 1251.9570f, 1723.2751f, + 2687.6689f, 3036.2019f, 3273.9678f, 3744.2939f, 4098.6284f, 4391.4160f, + 4917.6777f, 5244.2852f, 5551.4976f, 5880.1572f, 311.6069f, 458.7317f, + 795.9418f, 969.5021f, 1511.2507f, 1952.5673f, 2273.6116f, 2795.8657f, + 3049.7053f, 3578.0598f, 3911.1873f, 4327.2598f, 4735.3105f, 5122.3423f, + 5479.7817f, 5858.1504f, 267.8399f, 390.6757f, 886.2357f, 1179.5110f, + 1466.6409f, 2088.7725f, 2328.1262f, 2993.5786f, 3283.5256f, 3593.2822f, + 4095.7588f, 4500.4009f, 4887.5132f, 5219.0859f, 5553.4224f, 5915.6831f, + 279.2209f, 413.3200f, 648.4438f, 1282.1798f, 1793.2556f, 1952.1060f, + 2484.9436f, 2857.3630f, 3077.2114f, 3548.2585f, 4045.4526f, 4309.5947f, + 4760.2900f, 5208.1948f, 5620.9717f, 5968.3237f, 306.2321f, 424.7843f, + 618.7867f, 1288.7572f, 2110.7849f, 2346.5396f, 2582.5366f, 2833.5730f, + 3074.3774f, 3464.7886f, 3984.6379f, 4262.0337f, 4601.5132f, 4999.6992f, + 5498.8926f, 5920.4814f, 259.2613f, 353.6931f, 762.5328f, 1906.2162f, + 2088.1213f, 2317.9741f, 2546.5935f, 2880.3687f, 3332.0002f, 3636.9216f, + 3946.4287f, 4226.0356f, 4502.1084f, 5007.0601f, 5496.4824f, 5924.8877f, + 244.3871f, 357.0287f, 1114.7865f, 1651.1329f, 1850.2976f, 2200.5942f, + 2484.7026f, 2872.6968f, 3092.8455f, 3373.5869f, 3707.5891f, 4180.1289f, + 4603.5298f, 5132.2671f, 5554.7617f, 5973.5220f, 700.5439f, 1363.5277f, + 1745.2494f, 2081.9539f, 2379.8628f, 2623.6003f, 2883.6484f, 3133.9824f, + 3457.7092f, 3819.0100f, 4191.0537f, 4547.0400f, 4912.5127f, 5241.3423f, + 5594.9395f, 5930.6099f, 268.7704f, 370.8200f, 609.4679f, 1558.5339f, + 1961.6279f, 2155.8916f, 2419.4485f, 2655.5103f, 3152.6685f, 3426.9221f, + 3716.8181f, 4107.1616f, 4965.5698f, 5384.2026f, 5706.7183f, 6015.6196f, + 305.7638f, 395.9599f, 1103.0944f, 1383.6494f, 1612.9742f, 1915.2496f, + 2189.8008f, 2555.3608f, 2720.8220f, 3038.2434f, 3927.1301f, 4263.0518f, + 4685.7217f, 4984.1377f, 5272.6162f, 5984.5376f, 294.0385f, 426.7762f, + 814.5162f, 1056.9037f, 1715.3539f, 2005.3177f, 2316.4392f, 2647.4297f, + 2893.8242f, 3196.7476f, 3720.0044f, 4186.9790f, 4840.4512f, 5290.1250f, + 5684.2139f, 5967.5859f, 359.5141f, 517.6051f, 807.4898f, 1143.5930f, + 1328.1393f, 1814.7098f, 2309.8894f, 2618.8655f, 3160.5962f, 3445.0479f, + 3883.2664f, 4235.5200f, 4718.7324f, 5367.3608f, 5765.9331f, 6034.9233f, + 241.5752f, 375.5109f, 818.8776f, 1298.7773f, 1656.9050f, 2169.8962f, + 2565.1440f, 3015.9919f, 3437.9463f, 3863.8203f, 4254.4023f, 4637.0952f, + 5027.8252f, 5358.3784f, 5685.5000f, 5980.4063f, 322.5406f, 454.9644f, + 963.3659f, 1513.8885f, 1704.5070f, 2235.6599f, 2523.6467f, 2995.0757f, + 3287.8682f, 3552.8811f, 3872.4360f, 4201.2227f, 4571.9087f, 5066.6792f, + 5562.1206f, 5935.7900f, 412.5748f, 615.8419f, 1126.9519f, 1455.5172f, + 1653.3076f, 1965.2689f, 2240.6904f, 2672.5129f, 3127.3301f, 3477.8540f, + 3983.6145f, 4458.6558f, 4896.7998f, 5237.9814f, 5609.1597f, 5939.6416f, + 342.1361f, 470.6100f, 958.3576f, 1195.0166f, 1426.4667f, 1684.2009f, + 2194.0950f, 2545.9453f, 2946.1851f, 3415.2820f, 3657.4158f, 4408.6763f, + 5097.2251f, 5404.2202f, 5719.9829f, 5977.7959f, 297.8767f, 386.6347f, + 1095.8346f, 1454.3085f, 1651.6417f, 1927.9633f, 2198.4927f, 2583.1694f, + 2757.0144f, 3009.6497f, 3310.9514f, 3956.9753f, 4677.3208f, 5122.2222f, + 5539.0688f, 5993.0542f, 334.7170f, 450.1582f, 747.3162f, 1560.2024f, + 1808.2147f, 2006.5011f, 2415.2419f, 2680.1956f, 3016.5549f, 3651.1340f, + 3975.3625f, 4209.6563f, 4531.0396f, 5121.7212f, 5585.2202f, 5962.3667f, + 256.4101f, 495.5723f, 1341.4860f, 1805.1255f, 2201.8318f, 2514.7769f, + 2820.4092f, 3102.3867f, 3414.3872f, 3754.7742f, 4108.2378f, 4465.9258f, + 4857.4355f, 5216.2144f, 5592.3076f, 5951.9995f, 530.7974f, 1017.4255f, + 1463.9575f, 1858.6631f, 2360.1265f, 2770.3811f, 3106.0894f, 3379.1919f, + 3647.7175f, 3895.9026f, 4188.8652f, 4522.8984f, 4893.7954f, 5241.4312f, + 5623.8994f, 5975.3608f, 597.1553f, 1198.0758f, 1722.7361f, 2128.6658f, + 2519.1504f, 2825.5122f, 3086.1943f, 3330.0283f, 3608.2961f, 3906.9929f, + 4241.8105f, 4603.1694f, 4972.8159f, 5308.1670f, 5651.1968f, 5976.6704f, + 699.1581f, 1293.3193f, 1637.3395f, 1912.7987f, 2163.3445f, 2425.7944f, + 2704.0396f, 3006.5984f, 3358.2126f, 3746.1548f, 4125.0762f, 4489.7485f, + 4854.0088f, 5188.5146f, 5558.2056f, 5913.3164f, 489.0107f, 921.4806f, + 1329.8511f, 1644.8383f, 2013.6794f, 2365.2683f, 2746.1553f, 3085.6912f, + 3457.0234f, 3825.2183f, 4203.4224f, 4575.9331f, 4950.6606f, 5298.7559f, + 5659.8618f, 5997.0015f, 230.3653f, 389.8415f, 938.1970f, 1294.3594f, + 1768.8275f, 2189.1001f, 2597.3755f, 2985.8518f, 3323.6023f, 3705.8533f, + 4065.5361f, 4446.4224f, 4818.4502f, 5185.9634f, 5583.2168f, 5954.2573f, + 283.9404f, 400.2146f, 630.6198f, 1491.5646f, 2295.1375f, 2496.3457f, + 2726.5803f, 2971.1951f, 3207.2317f, 3634.5439f, 4178.0376f, 4423.5537f, + 4836.2109f, 5172.1821f, 5464.0454f, 5777.5801f, 242.6232f, 351.1541f, + 807.9852f, 1621.9950f, 2043.8676f, 2532.5122f, 2860.5505f, 3200.3403f, + 3499.8274f, 3760.3772f, 4068.9617f, 4410.7339f, 4778.8413f, 5153.0142f, + 5553.1997f, 5932.5996f, 227.3320f, 323.2667f, 752.3189f, 1572.3750f, + 1930.6083f, 2355.0117f, 2717.6223f, 2968.3215f, 3233.4026f, 3551.9622f, + 3918.5608f, 4346.0190f, 4778.6880f, 5159.6172f, 5568.5566f, 5980.8086f, + 307.9120f, 439.7297f, 660.0276f, 1243.3854f, 1532.3577f, 1796.3936f, + 2437.3232f, 2691.4072f, 3030.3025f, 3524.1379f, 3771.7576f, 4083.2375f, + 4601.1567f, 4963.4697f, 5434.8530f, 5942.8315f}; + +const WORD8 ixheaacd_mps_dig_rev[16] = {0, 8, 16, 24, 2, 10, 18, 26, + 4, 12, 20, 28, 6, 14, 22, 30}; \ No newline at end of file diff --git a/decoder/ixheaacd_rvlc.h b/decoder/ixheaacd_rvlc.h new file mode 100644 index 0000000..f574a84 --- /dev/null +++ b/decoder/ixheaacd_rvlc.h @@ -0,0 +1,20 @@ +#ifndef IXHEAACD_RVLC_H +#define IXHEAACD_RVLC_H +void ixheaacd_rvlc_read( + ia_bit_buf_struct *itt_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info); +void ixheaacd_rvlc_dec(ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info, + ia_bit_buf_struct *itt_bit_buff); +void ixheaacd_hcr_read(ia_bit_buf_struct *itt_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, + WORD32 ele_type); + +void ixheaacd_carry_bit_branch_val(UWORD8 carry_bit, UWORD32 tree_node, + UWORD32 *branch_val, UWORD32 *branch_node); + +VOID ixheaacd_huff_sfb_table(WORD32 it_bit_buff, WORD16 *huff_index, + WORD16 *len, const UWORD16 *code_book_tbl, + const UWORD32 *idx_table); + +#endif \ No newline at end of file diff --git a/decoder/ixheaacd_sbr_common.h b/decoder/ixheaacd_sbr_common.h new file mode 100644 index 0000000..01848e9 --- /dev/null +++ b/decoder/ixheaacd_sbr_common.h @@ -0,0 +1,25 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_COMMON_H +#define IXHEAACD_SBR_COMMON_H + +#define MAX_CC_CHANNEL_NUM (2) +#define MAX_BS_ELEMENT (8 + MAX_CC_CHANNEL_NUM) +#endif diff --git a/decoder/ixheaacd_sbr_const.h b/decoder/ixheaacd_sbr_const.h new file mode 100644 index 0000000..10b0959 --- /dev/null +++ b/decoder/ixheaacd_sbr_const.h @@ -0,0 +1,242 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_CONST_H +#define IXHEAACD_SBR_CONST_H + +#define SBR_AMPLITUDE_RESOLUTION_1_5 0 +#define SBR_AMPLITUDE_RESOLUTION_3_0 1 +#define NOISE_FLOOR_OFFSET_INT 6 + +#define LOW 0 +#define HIGH 1 + +#define DTDF_DIR_TIME 1 +#define DTDF_DIR_FREQ 0 + +#define SBR_CYC_REDCY_CHK_BITS 10 + +#define SBR_SAMP_FEQ_LVL_DEF 2 +#define SBR_CHANGE_LVL_DEF 1 +#define SBR_NOISE_BND_DEF 2 + +#define SBR_BND_LIMIT_DEF 2 +#define SBR_GAIN_LIMIT_DEF 2 +#define SBR_INTERPOL_SAMP_FEQ_DEF 1 +#define SBR_SMOOTH_LEN_DEF 1 + +#define SBR_AMPLITUDE_RESOLUTION_BITS 1 +#define SBR_BEGIN_SAMP_FREQ_BITS 4 +#define SBR_END_SAMP_FREQ_BITS 4 +#define SBR_CROSS_OVER_BND_BITS 3 + +#define ESBR_CROSS_OVER_BND_BITS 4 +#define ESBR_PRE_FLAT_BITS 1 +#define ESBR_PVC_MODE_BITS 2 + +#define ESBR_HEADER_EXTRA_3_BITS 1 +#define PVC_MODE_BITS 2 + +#define SBR_HDR_EXTR_1_BITS 1 +#define SBR_HDR_EXTR_2_BITS 1 + +#define SBR_SAMP_FREQ_LVL_BITS 2 +#define SBR_CHANGE_LVL_BITS 1 +#define SBR_NOISE_BND_BITS 2 + +#define SBR_BND_LIMIT_BITS 2 +#define SBR_GAIN_LIMIT_BITS 2 +#define SBR_INTERPOL_SAMP_FREQ_BITS 1 +#define SBR_SMOOTH_LEN_BITS 1 +#define SBR_STOCK_HE2_BITS 1 +#define SBR_HDR_RESERV_BITS 2 +#define SBR_SCE_RESERV_BITS 4 + +#define SBR_COUPLNG_MODE_BITS 1 + +#define SBR_INVERSE_FILT_MODE_BITS 2 + +#define SBR_ENLARGED_DATA_BITS 1 +#define SBR_CONT_SIZE_BITS 4 +#define SBR_CONT_ESC_CNT_BITS 8 +#define SBR_CONT_ID_BITS 2 + +#define SBR_DEL_COD_DIR_BITS 1 + +#define SBR_ADD_SINE_FLAG_BITS 1 + +#define SBR_BEGIN_ENVN_BITS_AMPLITUDE_RESOLUTION_3_0 6 +#define SBR_BEGIN_ENVN_BITS_BALNCE_AMPLITUDE_RESOLUTION_3_0 5 +#define SBR_BEGIN_NOISE_BITS_AMPLITUDE_RESOLUTION_3_0 5 +#define SBR_BEGIN_NOISE_BITS_BALNCE_AMPLITUDE_RESOLUTION_3_0 5 + +#define SBR_BEGIN_ENVN_BITS_AMPLITUDE_RESOLUTION_1_5 7 +#define SBR_BEGIN_ENVN_BITS_BALNCE_AMPLITUDE_RESOLUTION_1_5 6 + +#define NOISE_FLOOR_OFFSET 6.0f + +#define QMF_BUFFER_SIZE 64 +#define TIMESLOT_BUFFER_SIZE 78 + +#define MAX_NUM_QMF_BANDS_ESBR 128 + +#define SBR_HF_ADJ_OFFSET 2 + +#define ESBR_HBE_DELAY_OFFSET 32 + +#define HBE_OPER_WIN_LEN (13) +#define NO_QMF_SYNTH_CHANNELS 64 +#define TWICE_QMF_SYNTH_CHANNELS_NUM 128 + +#define MAX_NO_COLS_VALUE 64 +#define MAX_NO_COLS_VALUE_BY_2 (MAX_NO_COLS_VALUE >> 1) + +#define MAX_QMF_X_INBUF_SIZE (MAX_NO_COLS_VALUE_BY_2 + HBE_OPER_WIN_LEN - 1) +#define MAX_QMF_X_OUTBUF_SIZE \ + 2 * (MAX_NO_COLS_VALUE_BY_2 + HBE_OPER_WIN_LEN - 1) +#define MAX_QMF_X_IN_REAL_BUF (NO_QMF_SYNTH_CHANNELS * MAX_QMF_X_INBUF_SIZE) +#define MAX_QMF_X_IN_IMAG_BUF (NO_QMF_SYNTH_CHANNELS * MAX_QMF_X_INBUF_SIZE) + +#define MAX_QMF_X_OUT_REAL_BUF (NO_QMF_SYNTH_CHANNELS * MAX_QMF_X_OUTBUF_SIZE) +#define MAX_QMF_X_OUT_IMAG_BUF (NO_QMF_SYNTH_CHANNELS * MAX_QMF_X_OUTBUF_SIZE) + +#define X_INBUF_SIZE (MAX_FRAME_SIZE + NO_QMF_SYNTH_CHANNELS) +#define X_OUTBUF_SIZE (X_INBUF_SIZE * 2) + +#define HBE_OPER_BLK_LEN_2 10 +#define HBE_OPER_BLK_LEN_3 8 +#define HBE_OPER_BLK_LEN_4 6 + +#define MAX_HBE_PERSISTENT_SIZE \ + (MAX_QMF_X_INBUF_SIZE * sizeof(FLOAT32*) + \ + MAX_QMF_X_OUTBUF_SIZE * sizeof(FLOAT32*) + \ + MAX_QMF_X_IN_REAL_BUF * sizeof(FLOAT32) + \ + MAX_QMF_X_IN_IMAG_BUF * sizeof(FLOAT32) + \ + MAX_QMF_X_OUT_REAL_BUF * sizeof(FLOAT32) + \ + MAX_QMF_X_OUT_IMAG_BUF * sizeof(FLOAT32) + X_INBUF_SIZE * sizeof(FLOAT32) + \ + X_OUTBUF_SIZE * sizeof(FLOAT32)) + +#define MAX_QMF_BUF_LEN 78 + +#define SBR_FRAME_CLASS_BITS 2 +#define SBR_VAR_BORD_BITS 2 +#define SBR_FRQ_RES_BITS 1 +#define SBR_REL_BITS 2 +#define SBR_ENV_BITS 2 +#define SBR_NUM_BITS 2 + +#define FIXFIX 0 +#define FIXVAR 1 +#define VARFIX 2 +#define VARVAR 3 + +#define LEN_NIBBLE (4) + +#define PI 3.14159265358979323846264338327950288 +#define EPS 1e-12f +#define LOG2 0.69314718056f + +#define MAX_STRETCH 4 +#define MAXDEG 3 + +#define EXP_FOR_SQRT 0.5f + +#define SBR_HF_RELAXATION_PARAM 0.999999f + +#define ESBR_PATCHING_MODE_BITS 1 +#define ESBR_OVERSAMPLING_FLAG_BITS 1 +#define ESBR_PITCHIN_FLAG_BITS 1 +#define ESBR_PITCHIN_BINS_BITS 7 +#define ESBR_RESERVED_PRESENT 1 +#define ESBR_RESERVED_BITS_DATA 4 +#define ESBR_INVF_MODE_BITS 2 +#define ESBR_NOISE_MODE_BITS 1 +#define ESBR_DOMAIN_BITS 1 + +#define SBR_NUM_QMF_BANDS 64 +#define SBR_NUM_QMF_BANDS_2 32 + +#define PVC_NUM_TIME_SLOTS 16 +#define PVC_ESG_MIN_VAL 0.1f + +#define PVC_10LOG10_ESG_MIN_VAL -10.0f + +#define PVC_DIV_MODE_BITS 3 +#define PVC_NS_MODE_BITS 1 +#define PVC_GRID_INFO_BITS 1 +#define PVC_REUSE_PVC_ID_BITS 1 +#define PVC_ID_BITS 7 +#define PVC_NB_HIGH_MODE1 8 +#define PVC_NB_HIGH_MODE2 6 + +#define PVC_NB_LOW 3 +#define PVC_ID_NUM_GROUPS 3 +#define PVC_NB_HIGH 128 +#define PVC_ID_NBIT 7 + +#define ESC_SIN_POS 31 +#define MAX_OCTAVE 29 +#define MAX_SECOND_REGION 50 + +#define SBR_ENERGY_PAN_OFFSET 12 +#define SBR_ENV_SF_MAX_VAL_1_5 70 +#define MAX_NOISE_FLOOR_FAC_VAL 35 +#define MIN_NOISE_FLOOR_FAC_VAL 0 + +#define HBE_ZERO_BAND_IDX 6 + +#define MAX_OV_DELAY 12 + +#define LD_TRAN 1 +#define SBR_TRAN_BITS 4 +#define SBRLD_CLA_BITS 1 +#define SBR_ENVT_NUMENV 0 +#define SBR_ENVT_TRANIDX 3 + +static const int ixheaacd_ld_env_table_512[16][4] = { + {2, 4, -1, 0}, {2, 5, -1, 0}, {3, 2, 6, 1}, {3, 3, 7, 1}, + {3, 4, 8, 1}, {3, 5, 9, 1}, {3, 6, 10, 1}, {3, 7, 11, 1}, + {3, 8, 12, 1}, {3, 9, 13, 1}, {3, 10, 14, 1}, {2, 11, -1, 1}, + {2, 12, -1, 1}, {2, 13, -1, 1}, {2, 14, -1, 1}, {2, 15, -1, 1}, +}; + +static const int ixheaacd_ld_env_table_480[15][4] = { + {2, 4, -1, 0}, {2, 5, -1, 0}, {3, 2, 6, 1}, {3, 3, 7, 1}, + {3, 4, 8, 1}, {3, 5, 9, 1}, {3, 6, 10, 1}, {3, 7, 11, 1}, + {3, 8, 12, 1}, {3, 9, 13, 1}, {2, 10, -1, 1}, {2, 11, -1, 1}, + {2, 12, -1, 1}, {2, 13, -1, 1}, {2, 14, -1, 1}, +}; + +static const int ixheaacd_ld_env_table_time_slot[4] = {8, 5, 0, 0}; + +#define SBR_CLA_BITS 2 +#define SBR_ABS_BITS 2 +#define SBR_RES_BITS 1 +#define SBR_REL_BITS 2 +#define SBR_ENV_BITS 2 +#define SBR_NUM_BITS 2 + +#define FIXFIX 0 +#define FIXVAR 1 +#define VARFIX 2 +#define VARVAR 3 + +#define LEN_NIBBLE (4) + +#endif diff --git a/decoder/ixheaacd_sbr_crc.c b/decoder/ixheaacd_sbr_crc.c new file mode 100644 index 0000000..0c90373 --- /dev/null +++ b/decoder/ixheaacd_sbr_crc.c @@ -0,0 +1,97 @@ +/****************************************************************************** + * * + * 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 + +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbr_crc.h" +#include "ixheaacd_sbr_const.h" + +static VOID ixheaacd_calc_chk_sum(WORD16* crc_state, WORD32 stream_data, + WORD32 num_bits) { + WORD32 i; + WORD32 data_bit_mask = (1 << (num_bits - 1)); + WORD16 crc10 = SBR_CRC_POLY; + WORD16 crc_mask = (1 << 9); + WORD16 crc_state_local = *crc_state; + + for (i = 0; i < num_bits; i++) { + WORD32 bit0, bit1; + bit0 = ((crc_state_local & crc_mask) ? 1 : 0); + bit1 = ((data_bit_mask & stream_data) ? 1 : 0); + bit0 ^= bit1; + crc_state_local = (WORD16)((WORD32)(crc_state_local & 0x0000FFFF) << 1); + if (bit0) { + crc_state_local ^= crc10; + } + data_bit_mask = (data_bit_mask >> 1); + } + *crc_state = crc_state_local; + return; +} + +static PLATFORM_INLINE WORD32 ixheaacd_sbr_crc(ia_bit_buf_struct* it_bit_buff, + WORD32 num_crc_bits) { + WORD32 i; + WORD32 num_full_bytes, rem_bits; + WORD32 byte_value; + WORD16 crc_state = 0; + + num_full_bytes = (num_crc_bits >> 3); + rem_bits = (num_crc_bits & 0x7); + + for (i = 0; i < num_full_bytes; i++) { + byte_value = ixheaacd_read_bits_buf(it_bit_buff, 8); + ixheaacd_calc_chk_sum(&crc_state, byte_value, 8); + } + + byte_value = ixheaacd_read_bits_buf(it_bit_buff, rem_bits); + ixheaacd_calc_chk_sum(&crc_state, byte_value, rem_bits); + + return (crc_state & 0x03FF); +} + +FLAG ixheaacd_sbr_crccheck(ia_bit_buf_struct* it_bit_buff, + WORD32 crc_bits_len) { + struct ia_bit_buf_struct it_bit_buff_local; + WORD32 num_crc_bits; + WORD32 calc_crc_sum; + WORD32 bits_available; + WORD32 crc_check_sum; + + crc_check_sum = ixheaacd_read_bits_buf(it_bit_buff, SBR_CYC_REDCY_CHK_BITS); + + it_bit_buff_local = *it_bit_buff; + + bits_available = it_bit_buff->cnt_bits; + + if (bits_available <= 0) { + return 0; + } + + num_crc_bits = + (crc_bits_len > bits_available) ? bits_available : crc_bits_len; + + calc_crc_sum = ixheaacd_sbr_crc(&it_bit_buff_local, num_crc_bits); + + if (calc_crc_sum != crc_check_sum) { + return 0; + } + return 1; +} diff --git a/decoder/ixheaacd_sbr_crc.h b/decoder/ixheaacd_sbr_crc.h new file mode 100644 index 0000000..def78ea --- /dev/null +++ b/decoder/ixheaacd_sbr_crc.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_CRC_H +#define IXHEAACD_SBR_CRC_H + +#define SBR_CRC_POLY 0x0233 +#define SBR_CRC_MASK 0x0200 +#define SBR_CRC_START 0x0000 +#define SBR_CRC_RANGE 0x03FF + +FLAG ixheaacd_sbr_crccheck(ia_bit_buf_struct* it_bit_buff, WORD32 crc_bits_len); + +#endif diff --git a/decoder/ixheaacd_sbr_dec.c b/decoder/ixheaacd_sbr_dec.c new file mode 100644 index 0000000..1372f4b --- /dev/null +++ b/decoder/ixheaacd_sbr_dec.c @@ -0,0 +1,1243 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_defines.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_definitions.h" +#include "ixheaacd_error_codes.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 +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_env_calc.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_function_selector.h" + +#include "ixheaacd_audioobjtypes.h" + +VOID ixheaacd_qmf_enrg_calc(ia_sbr_dec_struct *ptr_sbr_dec, + WORD32 upsample_ratio_idx, WORD32 low_pow_flag) { + WORD32 i, j; + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (j = 0; j < 16; j++) { + ptr_sbr_dec->qmf_energy_buf[i][j] = + ptr_sbr_dec->qmf_buf_real[2 + i][j] * + ptr_sbr_dec->qmf_buf_real[2 + i][j]; + if (!low_pow_flag) + ptr_sbr_dec->qmf_energy_buf[i][j] += + (ptr_sbr_dec->qmf_buf_imag[2 + i][j] * + ptr_sbr_dec->qmf_buf_imag[2 + i][j]); + } + } + + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + ptr_sbr_dec->pvc_qmf_enrg_arr[32 * i + j] = + (ptr_sbr_dec->qmf_energy_buf[4 * i + 0][j] + + ptr_sbr_dec->qmf_energy_buf[4 * i + 1][j] + + ptr_sbr_dec->qmf_energy_buf[4 * i + 2][j] + + ptr_sbr_dec->qmf_energy_buf[4 * i + 3][j]) * + 0.25f; + } + } + } else { + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (j = 0; j < 32; j++) { + ptr_sbr_dec->qmf_energy_buf[i][j] = + ptr_sbr_dec->qmf_buf_real[2 + i][j] * + ptr_sbr_dec->qmf_buf_real[2 + i][j]; + if (!low_pow_flag) + ptr_sbr_dec->qmf_energy_buf[i][j] += + (ptr_sbr_dec->qmf_buf_imag[2 + i][j] * + ptr_sbr_dec->qmf_buf_imag[2 + i][j]); + } + } + + for (i = 0; i < 16; i++) { + for (j = 0; j < 32; j++) { + ptr_sbr_dec->pvc_qmf_enrg_arr[32 * i + j] = + (ptr_sbr_dec->qmf_energy_buf[2 * i + 0][j] + + ptr_sbr_dec->qmf_energy_buf[2 * i + 1][j]) * + 0.5f; + } + } + } +} + +VOID ixheaacd_hbe_repl_spec(WORD32 x_over_qmf[MAX_NUM_PATCHES], + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 no_bins, + WORD32 max_stretch) { + WORD32 patch_bands; + WORD32 patch, band, col, target, source_bands, i; + WORD32 num_patches = 0; + + for (i = 1; i < MAX_NUM_PATCHES; i++) { + if (x_over_qmf[i] != 0) { + num_patches++; + } + } + + for (patch = (max_stretch - 1); patch < num_patches; patch++) { + patch_bands = x_over_qmf[patch + 1] - x_over_qmf[patch]; + target = x_over_qmf[patch]; + source_bands = x_over_qmf[max_stretch - 1] - x_over_qmf[max_stretch - 2]; + while (patch_bands > 0) { + WORD32 ixheaacd_num_bands = source_bands; + WORD32 start_band = x_over_qmf[max_stretch - 1] - 1; + if (target + ixheaacd_num_bands >= x_over_qmf[patch + 1]) { + ixheaacd_num_bands = x_over_qmf[patch + 1] - target; + } + if ((((target + ixheaacd_num_bands - 1) & 1) + + ((x_over_qmf[max_stretch - 1] - 1) & 1)) & + 1) { + if (ixheaacd_num_bands == source_bands) { + ixheaacd_num_bands--; + } else { + start_band--; + } + } + for (col = 0; col < no_bins; col++) { + WORD32 i = 0; + band = target + ixheaacd_num_bands - 1; + if (64 <= band) { + band = 63; + } + if (x_over_qmf[patch + 1] <= band) { + band = x_over_qmf[patch + 1] - 1; + } + for (i = 0; i < ixheaacd_num_bands; i++, band--) { + qmf_buf_real[col][band] = qmf_buf_real[col][start_band - i]; + qmf_buf_imag[col][band] = qmf_buf_imag[col][start_band - i]; + } + } + target += ixheaacd_num_bands; + patch_bands -= ixheaacd_num_bands; + } + } +} + +VOID ixheaacd_esbr_analysis_filt_block(ia_sbr_dec_struct *ptr_sbr_dec, + ia_sbr_tables_struct *sbr_tables_ptr, + WORD32 op_delay) { + FLOAT32 *core_coder_samples; + WORD32 *ptr_filt_states; + WORD32 *ptr_filt_states_1; + WORD32 *ptr_filt_states_2; + WORD32 *ptr_temp; + WORD32 *ptr_win_coeffs_1; + WORD32 *ptr_win_coeffs_2; + WORD32 *ptr_win_coeffs; + WORD32 *ploc_qmf_buf_real; + WORD32 *ploc_qmf_buf_imag; + WORD32 local_qmf_buffer[128] = {0}; + WORD32 anal_buf[2 * 32]; + WORD32 idx, z; + WORD32 core_syn_ch_index; + FLOAT32 gain; + WORD32 filt_offset; + WORD32 num_columns; + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr = + sbr_tables_ptr->qmf_dec_tables_ptr; + ia_sbr_qmf_filter_bank_struct *pstr_qmf_anal_bank = + &ptr_sbr_dec->str_codec_qmf_bank; + core_coder_samples = ptr_sbr_dec->time_sample_buf; + ptr_filt_states = pstr_qmf_anal_bank->state_new_samples_pos_low_32; + ptr_win_coeffs_1 = pstr_qmf_anal_bank->filter_pos_32; + num_columns = pstr_qmf_anal_bank->no_channels; + + switch (num_columns) { + case 16: + ptr_win_coeffs_2 = ptr_win_coeffs_1 + 64; + gain = 128.0f; + filt_offset = 64; + break; + case 24: + ptr_win_coeffs_2 = ptr_win_coeffs_1 + 24; + gain = 12.0f; + filt_offset = 24; + break; + case 32: + ptr_win_coeffs_2 = ptr_win_coeffs_1 + 64; + gain = 256.0f; + filt_offset = 64; + break; + default: + ptr_win_coeffs_2 = ptr_win_coeffs_1 + 64; + gain = 256.0f; + filt_offset = 64; + break; + } + gain = 1.0f / gain; + + pstr_qmf_anal_bank->usb = num_columns; + + ploc_qmf_buf_real = &local_qmf_buffer[0]; + ploc_qmf_buf_imag = &local_qmf_buffer[64]; + + ptr_filt_states_1 = pstr_qmf_anal_bank->anal_filter_states_32; + ptr_filt_states_2 = pstr_qmf_anal_bank->anal_filter_states_32 + num_columns; + + for (idx = 0; idx < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; idx++) { + for (z = 0; z < num_columns; z++) { + ptr_filt_states[num_columns - 1 - z] = + (WORD32)(core_coder_samples[z] * (1 << 15)); + } + ixheaacd_esbr_qmfanal32_winadd(ptr_filt_states_1, ptr_filt_states_2, + ptr_win_coeffs_1, ptr_win_coeffs_2, anal_buf, + num_columns); + + core_coder_samples += num_columns; + + ptr_filt_states -= num_columns; + if (ptr_filt_states < pstr_qmf_anal_bank->anal_filter_states_32) { + ptr_filt_states = pstr_qmf_anal_bank->anal_filter_states_32 + + 10 * num_columns - num_columns; + } + + ptr_temp = ptr_filt_states_1; + ptr_filt_states_1 = ptr_filt_states_2; + ptr_filt_states_2 = ptr_temp; + + ptr_win_coeffs_1 += filt_offset; + ptr_win_coeffs_2 += filt_offset; + + ptr_win_coeffs = ptr_win_coeffs_1; + ptr_win_coeffs_1 = ptr_win_coeffs_2; + ptr_win_coeffs_2 = ptr_win_coeffs; + + if (ptr_win_coeffs_2 > + (pstr_qmf_anal_bank->analy_win_coeff_32 + filt_offset * 10)) { + ptr_win_coeffs_1 = pstr_qmf_anal_bank->analy_win_coeff_32; + ptr_win_coeffs_2 = pstr_qmf_anal_bank->analy_win_coeff_32 + filt_offset; + } + + ixheaacd_esbr_fwd_modulation(anal_buf, &ploc_qmf_buf_real[0], + &ploc_qmf_buf_imag[0], pstr_qmf_anal_bank, + qmf_dec_tables_ptr); + core_syn_ch_index = num_columns; + + for (z = 0; z < core_syn_ch_index; z++) { + ptr_sbr_dec->qmf_buf_real[op_delay + idx][z] = + ((FLOAT32)ploc_qmf_buf_real[z] * gain); + ptr_sbr_dec->qmf_buf_imag[op_delay + idx][z] = + ((FLOAT32)ploc_qmf_buf_imag[z] * gain); + } + for (z = core_syn_ch_index; z < num_columns; z++) { + ptr_sbr_dec->qmf_buf_real[op_delay + idx][z] = (FLOAT32)0.0f; + ptr_sbr_dec->qmf_buf_imag[op_delay + idx][z] = (FLOAT32)0.0f; + } + } + + pstr_qmf_anal_bank->filter_pos_32 = ptr_win_coeffs_1; + pstr_qmf_anal_bank->state_new_samples_pos_low_32 = ptr_filt_states; +} + +VOID ixheaacd_esbr_synthesis_regrp( + FLOAT32 *qmf_buf_real, FLOAT32 *qmf_buf_imag, + ia_sbr_dec_struct *ptr_sbr_dec, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_header_data_struct *ptr_header_data, WORD32 stereo_config_idx, + WORD32 apply_processing) { + WORD32 i, k; + WORD32 stop_border = 0; + WORD32 num_anal_bands = ptr_sbr_dec->str_codec_qmf_bank.no_channels; + WORD32 x_over_band = num_anal_bands; + + if (apply_processing) { + if (ptr_header_data->sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + stop_border = 4 * ptr_frame_data->str_frame_info_details.border_vec[0]; + } else { + stop_border = 2 * ptr_frame_data->str_frame_info_details.border_vec[0]; + } + x_over_band = ptr_header_data->pstr_freq_band_data->qmf_sb_prev; + } + + if (stereo_config_idx > 0) { + for (i = 0; i < stop_border; i++) { + for (k = 0; k < 3; k++) { + *qmf_buf_real++ = + ptr_sbr_dec->qmf_buf_real[(2) + i + HYBRID_FILTER_DELAY][k]; + *qmf_buf_imag++ = + ptr_sbr_dec->qmf_buf_imag[(2) + i + HYBRID_FILTER_DELAY][k]; + } + + for (; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = ptr_sbr_dec->sbr_qmf_out_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->sbr_qmf_out_imag[(2) + i][k]; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + + x_over_band = ptr_header_data->pstr_freq_band_data->sub_band_start; + + for (; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < 3; k++) { + *qmf_buf_real++ = + ptr_sbr_dec->qmf_buf_real[(2) + i + HYBRID_FILTER_DELAY][k]; + *qmf_buf_imag++ = + ptr_sbr_dec->qmf_buf_imag[(2) + i + HYBRID_FILTER_DELAY][k]; + } + + for (; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = ptr_sbr_dec->sbr_qmf_out_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->sbr_qmf_out_imag[(2) + i][k]; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + + } else { + for (i = 0; i < stop_border; i++) { + for (k = 0; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = ptr_sbr_dec->sbr_qmf_out_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->sbr_qmf_out_imag[(2) + i][k]; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + + x_over_band = ptr_header_data->pstr_freq_band_data->sub_band_start; + + for (; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = ptr_sbr_dec->sbr_qmf_out_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->sbr_qmf_out_imag[(2) + i][k]; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + } +} + +VOID ixheaacd_mps_esbr_synthesis_regrp(FLOAT32 *qmf_buf_real, + FLOAT32 *qmf_buf_imag, + ia_sbr_dec_struct *ptr_sbr_dec, + WORD32 stereo_config_idx) { + WORD32 i, k; + WORD32 num_anal_bands = ptr_sbr_dec->str_codec_qmf_bank.no_channels; + WORD32 x_over_band = num_anal_bands; + + if (stereo_config_idx > 0) { + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < 3; k++) { + *qmf_buf_real++ = + ptr_sbr_dec->qmf_buf_real[(2) + i + HYBRID_FILTER_DELAY][k]; + *qmf_buf_imag++ = + ptr_sbr_dec->qmf_buf_imag[(2) + i + HYBRID_FILTER_DELAY][k]; + } + + for (; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = 0; + *qmf_buf_imag++ = 0; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + } else { + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < x_over_band; k++) { + *qmf_buf_real++ = ptr_sbr_dec->qmf_buf_real[(2) + i][k]; + *qmf_buf_imag++ = ptr_sbr_dec->qmf_buf_imag[(2) + i][k]; + } + + for (; k < 64; k++) { + *qmf_buf_real++ = 0.0f; + *qmf_buf_imag++ = 0.0f; + } + + qmf_buf_real += 14; + qmf_buf_imag += 14; + } + } +} + +VOID ixheaacd_esbr_synthesis_filt_block( + ia_sbr_dec_struct *ptr_sbr_dec, ia_sbr_header_data_struct *ptr_header_data, + 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, + stereo_config_idx, apply_processing); + } else { + ixheaacd_mps_esbr_synthesis_regrp(&qmf_buf_real[0][0], &qmf_buf_imag[0][0], + 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; + + 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; + + 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; + + ixheaacd_esbr_inv_modulation(ploc_qmf_buf_real, + &ptr_sbr_dec->str_synthesis_qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); + + 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); + + ixheaacd_esbr_qmfsyn64_winadd(ptr_filt_states_1, ptr_filt_states_2, + filter_l, &time_out[0], ch_fac); + + 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); + } + + 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; + + if (!mps_sbr_flag) ptr_frame_data->reset_flag = 0; + + if (apply_processing && !mps_sbr_flag) { + ptr_header_data->pstr_freq_band_data->qmf_sb_prev = + ptr_header_data->pstr_freq_band_data->sub_band_start; + } +} + +VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, + ia_ps_dec_struct *ptr_ps_dec, + ia_sbr_qmf_filter_bank_struct *ptr_qmf_synth_bank_r, + ia_sbr_scale_fact_struct *ptr_sbr_sf_r, + FLAG apply_processing, FLAG low_pow_flag, + WORD32 *ptr_work_buf_core, + ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD ch_fac, + ia_pvc_data_struct *ptr_pvc_data, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type) { + WORD i; + WORD slot, reserve; + WORD save_lb_scale; + WORD op_delay; + + WORD32 *p_arr_qmf_buf_real[MAX_ENV_COLS + MAX_ENV_COLS]; + WORD32 **p_arr_qmf_buf_imag = &p_arr_qmf_buf_real[MAX_ENV_COLS]; + WORD32 *ptr; + WORD hbe_flag = ptr_header_data->hbe_flag; + + FLOAT32 **pp_qmf_buf_real = NULL; + FLOAT32 **pp_qmf_buf_imag = NULL; + FLOAT32 pvc_dec_out_buf[16 * 64]; + + WORD upsample_ratio_idx = ptr_header_data->sbr_ratio_idx; + WORD no_bins; + WORD mps_sbr_flag = ptr_frame_data->mps_sbr_flag; + WORD stereo_config_idx = ptr_frame_data->stereo_config_idx; + WORD sbr_mode = ptr_frame_data->sbr_mode; + WORD usac_flag = ptr_header_data->usac_flag; + + FLOAT32 *pvc_qmf_enrg_arr = (FLOAT32 *)ptr_sbr_dec->pvc_qmf_enrg_arr; + + memset(pvc_dec_out_buf, 0, 1024 * sizeof(FLOAT32)); + memset(pvc_qmf_enrg_arr, 0, 512 * sizeof(FLOAT32)); + if (audio_object_type == AOT_ER_AAC_ELD) { + op_delay = 0; + } else { + op_delay = 6; + } + if (usac_flag) { + pp_qmf_buf_real = ptr_sbr_dec->pp_qmf_buf_real; + pp_qmf_buf_imag = ptr_sbr_dec->pp_qmf_buf_imag; + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + op_delay = 2 * 6; + } + } + + no_bins = (ptr_header_data->num_time_slots * ptr_header_data->time_step); + + if (!usac_flag) { + WORD32 num = op_delay; + WORD32 *ptr_pers_qmf_real = ptr_sbr_dec->ptr_sbr_overlap_buf; + WORD32 *p_scr_qmf_real = ptr_work_buf_core + (2 << (6 + !low_pow_flag)); + if (!low_pow_flag) { + num = num << 1; + } + if (audio_object_type != AOT_ER_AAC_ELD) { + memcpy(p_scr_qmf_real, ptr_pers_qmf_real, + sizeof(WORD32) * NO_SYNTHESIS_CHANNELS * num); + } + ptr = p_scr_qmf_real; + + for (slot = 0; slot < op_delay + no_bins; slot++) { + p_arr_qmf_buf_real[slot] = ptr; + ptr += NO_SYNTHESIS_CHANNELS; + + if (!low_pow_flag) { + p_arr_qmf_buf_imag[slot] = ptr; + ptr += NO_SYNTHESIS_CHANNELS; + } + } + + ptr_sbr_dec->str_sbr_scale_fact.lb_scale = 0; + + if (apply_processing) { + ixheaacd_rescale_x_overlap(ptr_sbr_dec, ptr_header_data, ptr_frame_data, + ptr_frame_data_prev, p_arr_qmf_buf_real, + low_pow_flag); + } + } + + if (usac_flag) { + WORD32 num_anal_bands = ptr_sbr_dec->str_codec_qmf_bank.no_channels; + WORD32 codec_x_delay = 0; + WORD32 core_syn_ch_index = 0; + WORD32 frame_move = 288; + WORD32 core_frame_size = ptr_header_data->core_frame_size; + + if (hbe_flag) { + codec_x_delay = 32; + } + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + codec_x_delay = 2 * codec_x_delay; + } + + if (hbe_flag || mps_sbr_flag) { + core_syn_ch_index = num_anal_bands; + } else { + core_syn_ch_index = ptr_header_data->pstr_freq_band_data->sub_band_start; + } + + frame_move = 9 * num_anal_bands; + + memmove(ptr_sbr_dec->core_sample_buf, + ptr_sbr_dec->core_sample_buf + core_frame_size, + frame_move * sizeof(FLOAT32)); + memcpy(&ptr_sbr_dec->core_sample_buf[frame_move], + &ptr_sbr_dec->time_sample_buf[0], core_frame_size * sizeof(FLOAT32)); + + memmove( + &ptr_sbr_dec->qmf_buf_real[0][0], + &ptr_sbr_dec + ->qmf_buf_real[ptr_sbr_dec->str_codec_qmf_bank.num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET + codec_x_delay) * sizeof(FLOAT32) * 64); + + memmove( + &ptr_sbr_dec->qmf_buf_imag[0][0], + &ptr_sbr_dec + ->qmf_buf_imag[ptr_sbr_dec->str_codec_qmf_bank.num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET + codec_x_delay) * sizeof(FLOAT32) * 64); + + memmove(&ptr_sbr_dec->sbr_qmf_out_real[0][0], + &ptr_sbr_dec->sbr_qmf_out_real[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET) * sizeof(FLOAT32) * 64); + + memmove(&ptr_sbr_dec->sbr_qmf_out_imag[0][0], + &ptr_sbr_dec->sbr_qmf_out_imag[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET) * sizeof(FLOAT32) * 64); + + if (hbe_flag) { + memmove(&ptr_sbr_dec->ph_vocod_qmf_real[0][0], + &ptr_sbr_dec->ph_vocod_qmf_real[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + 64 * sizeof(FLOAT32) * (op_delay + SBR_HF_ADJ_OFFSET)); + + memmove(ptr_sbr_dec->ph_vocod_qmf_imag, + ptr_sbr_dec->ph_vocod_qmf_imag + + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + 64 * sizeof(FLOAT32) * (op_delay + SBR_HF_ADJ_OFFSET)); + } + ixheaacd_esbr_analysis_filt_block( + ptr_sbr_dec, sbr_tables_ptr, + op_delay + codec_x_delay + SBR_HF_ADJ_OFFSET); + + if (hbe_flag) { + ixheaacd_qmf_hbe_apply( + ptr_sbr_dec->p_hbe_txposer, + ptr_sbr_dec->qmf_buf_real + (op_delay + SBR_HF_ADJ_OFFSET) + + ESBR_HBE_DELAY_OFFSET, + ptr_sbr_dec->qmf_buf_imag + (op_delay + SBR_HF_ADJ_OFFSET) + + ESBR_HBE_DELAY_OFFSET, + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_frame_data->pitch_in_bins); + + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + ixheaacd_hbe_repl_spec( + &ptr_sbr_dec->p_hbe_txposer->x_over_qmf[0], + ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + ptr_sbr_dec->p_hbe_txposer->max_stretch); + } + } + ixheaacd_qmf_enrg_calc(ptr_sbr_dec, upsample_ratio_idx, low_pow_flag); + + if (!mps_sbr_flag && apply_processing) { + ixheaacd_generate_hf(ptr_sbr_dec->qmf_buf_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->qmf_buf_imag + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_imag + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->sbr_qmf_out_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->sbr_qmf_out_imag + (SBR_HF_ADJ_OFFSET), + ptr_frame_data, ptr_header_data); + + ptr_pvc_data->pvc_rate = ptr_header_data->upsamp_fac; + + if (sbr_mode == PVC_SBR) { + ixheaacd_pvc_process( + ptr_pvc_data, ptr_header_data->pstr_freq_band_data->sub_band_start, + ptr_frame_data->str_pvc_frame_info.border_vec[0], + &pvc_qmf_enrg_arr[0], &pvc_dec_out_buf[0]); + ptr_pvc_data->prev_pvc_flg = 1; + } else { + memset(pvc_dec_out_buf, 0, 1024 * sizeof(FLOAT32)); + ptr_pvc_data->prev_pvc_flg = 0; + } + + ptr_pvc_data->prev_first_bnd_idx = + ptr_header_data->pstr_freq_band_data->sub_band_start; + ptr_pvc_data->prev_pvc_rate = ptr_pvc_data->pvc_rate; + + ptr_frame_data->pstr_sbr_header = ptr_header_data; + + ixheaacd_sbr_env_calc(ptr_frame_data, + ptr_sbr_dec->sbr_qmf_out_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->sbr_qmf_out_imag + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->qmf_buf_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->qmf_buf_imag + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->p_hbe_txposer->x_over_qmf, + ptr_sbr_dec->scratch_buff, pvc_dec_out_buf); + + } else { + for (i = 0; i < 64; i++) { + memset(ptr_sbr_dec->sbr_qmf_out_real[i], 0, 64 * sizeof(FLOAT32)); + memset(ptr_sbr_dec->sbr_qmf_out_imag[i], 0, 64 * sizeof(FLOAT32)); + } + } + + ixheaacd_esbr_synthesis_filt_block( + ptr_sbr_dec, ptr_header_data, ptr_frame_data, apply_processing, + pp_qmf_buf_real, pp_qmf_buf_imag, stereo_config_idx, sbr_tables_ptr, + mps_sbr_flag, ch_fac); + + ptr_frame_data->prev_sbr_mode = sbr_mode; + + return; + } + + ixheaacd_cplx_anal_qmffilt( + ptr_time_data, &ptr_sbr_dec->str_sbr_scale_fact, + &p_arr_qmf_buf_real[op_delay], &p_arr_qmf_buf_imag[op_delay], + &ptr_sbr_dec->str_codec_qmf_bank, sbr_tables_ptr->qmf_dec_tables_ptr, + ch_fac, low_pow_flag, audio_object_type); + + { + WORD shift1, shift2; + WORD min_shift; + WORD shift_over; + WORD reserve_ov1, reserve_ov2; + WORD reservea[2]; + WORD i = 0; + WORD usb = ptr_sbr_dec->str_codec_qmf_bank.usb; + WORD iter_val = 1; + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + iter_val = 0; + } + do { + WORD t1 = op_delay; + WORD t2 = no_bins + op_delay; + if (i) { + t1 = 0; + t2 = op_delay; + } + reservea[i] = (*ixheaacd_ixheaacd_expsubbandsamples)( + p_arr_qmf_buf_real, p_arr_qmf_buf_imag, 0, usb, t1, t2, low_pow_flag); + i++; + } while (i <= iter_val); + ; + + reserve = reservea[0]; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) + reserve_ov1 = reservea[1]; + else + reserve_ov1 = reserve; + ptr_sbr_dec->max_samp_val = ixheaacd_min32(reserve, reserve_ov1); + + reserve_ov2 = (*ixheaacd_ixheaacd_expsubbandsamples)( + ptr_sbr_dec->str_hf_generator.lpc_filt_states_real, + ptr_sbr_dec->str_hf_generator.lpc_filt_states_imag, 0, usb, 0, + LPC_ORDER, low_pow_flag); + + reserve_ov1 = ixheaacd_min32(reserve_ov1, reserve_ov2); + + shift1 = ptr_sbr_dec->str_sbr_scale_fact.lb_scale + reserve; + + shift2 = ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale + reserve_ov1; + min_shift = ixheaacd_min32(shift1, shift2); + shift_over = (shift2 - min_shift); + reserve -= (shift1 - min_shift); + + ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale += (reserve_ov1 - shift_over); + + (*ixheaacd_adjust_scale)(p_arr_qmf_buf_real, p_arr_qmf_buf_imag, 0, usb, 0, + op_delay, reserve_ov1 - shift_over, low_pow_flag); + + (*ixheaacd_adjust_scale)(p_arr_qmf_buf_real, p_arr_qmf_buf_imag, 0, usb, + op_delay, (no_bins + op_delay), reserve, + low_pow_flag); + + (*ixheaacd_adjust_scale)(ptr_sbr_dec->str_hf_generator.lpc_filt_states_real, + ptr_sbr_dec->str_hf_generator.lpc_filt_states_imag, + 0, usb, 0, LPC_ORDER, reserve_ov1 - shift_over, + low_pow_flag); + + ptr_sbr_dec->str_sbr_scale_fact.lb_scale += reserve; + + save_lb_scale = ptr_sbr_dec->str_sbr_scale_fact.lb_scale; + } + + { + WORD32 num = no_bins; + WORD32 *p_loc_qmf_real = + &p_arr_qmf_buf_real[op_delay][NO_ANALYSIS_CHANNELS]; + + if (!low_pow_flag) { + num = num << 1; + } + + ixheaacd_clr_subsamples(p_loc_qmf_real, num - 1, (NO_SYN_ANA_CHANNELS)); + } + + if (apply_processing) { + WORD16 degree_alias[NO_SYNTHESIS_CHANNELS]; + WORD16 *border_vec = ptr_frame_data->str_frame_info_details.border_vec; + + if (low_pow_flag) { + memset(degree_alias, 0, NO_SYNTHESIS_CHANNELS * sizeof(WORD16)); + } + + if (low_pow_flag) { + WORD32 com_low_band_scale; + ixheaacd_low_pow_hf_generator( + &ptr_sbr_dec->str_hf_generator, p_arr_qmf_buf_real, degree_alias, + border_vec[0] * ptr_header_data->time_step, + ptr_header_data->time_step * + ixheaacd_sub16_sat( + border_vec[ptr_frame_data->str_frame_info_details.num_env], + ptr_header_data->num_time_slots), + ptr_header_data->pstr_freq_band_data->num_if_bands, + ptr_frame_data->max_qmf_subband_aac, ptr_frame_data->sbr_invf_mode, + ptr_frame_data_prev->sbr_invf_mode, ptr_sbr_dec->max_samp_val, + ptr_work_buf_core); + + com_low_band_scale = + ixheaacd_min32(ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale, + ptr_sbr_dec->str_sbr_scale_fact.lb_scale); + + ptr_sbr_dec->str_sbr_scale_fact.hb_scale = + (WORD16)(com_low_band_scale - 2); + } else { + ixheaacd_hf_generator( + &ptr_sbr_dec->str_hf_generator, &ptr_sbr_dec->str_sbr_scale_fact, + p_arr_qmf_buf_real, p_arr_qmf_buf_imag, ptr_header_data->time_step, + border_vec[0], + ixheaacd_sub16_sat( + border_vec[ptr_frame_data->str_frame_info_details.num_env], + ptr_header_data->num_time_slots), + ptr_header_data->pstr_freq_band_data->num_if_bands, + ptr_frame_data->max_qmf_subband_aac, ptr_frame_data->sbr_invf_mode, + ptr_frame_data_prev->sbr_invf_mode, ptr_work_buf_core, + audio_object_type); + } + + 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); + + 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)); + + ptr_frame_data_prev->coupling_mode = ptr_frame_data->coupling_mode; + ptr_frame_data_prev->max_qmf_subband_aac = + ptr_frame_data->max_qmf_subband_aac; + ptr_frame_data_prev->end_position = + border_vec[ptr_frame_data->str_frame_info_details.num_env]; + ptr_frame_data_prev->amp_res = ptr_frame_data->amp_res; + } else { + ptr_sbr_dec->str_sbr_scale_fact.hb_scale = save_lb_scale; + } + + if (!low_pow_flag) { + for (i = 0; i < LPC_ORDER; i++) { + WORD32 *p_loc_qmf_real = &p_arr_qmf_buf_real[no_bins - LPC_ORDER + i][0]; + WORD32 *p_loc_qmf_imag = &p_arr_qmf_buf_imag[no_bins - LPC_ORDER + i][0]; + WORD32 *plpc_filt_states_real = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_real[i][0]; + WORD32 *plpc_filt_states_imag = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_imag[i][0]; + + memcpy(plpc_filt_states_real, p_loc_qmf_real, + sizeof(WORD32) * (ptr_sbr_dec->str_codec_qmf_bank.usb)); + memcpy(plpc_filt_states_imag, p_loc_qmf_imag, + sizeof(WORD32) * (ptr_sbr_dec->str_codec_qmf_bank.usb)); + } + } else { + for (i = 0; i < LPC_ORDER; i++) { + WORD32 *p_loc_qmf_real = &p_arr_qmf_buf_real[no_bins - LPC_ORDER + i][0]; + WORD32 *plpc_filt_states_real = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_real[i][0]; + memcpy(plpc_filt_states_real, p_loc_qmf_real, + sizeof(WORD32) * (ptr_sbr_dec->str_codec_qmf_bank.usb)); + } + } + + if (apply_processing && ptr_header_data->channel_mode == PS_STEREO && + ((audio_object_type != AOT_ER_AAC_ELD) && + (audio_object_type != AOT_ER_AAC_LD))) { + WORD32 ps_scale; + + ixheaacd_init_ps_scale(ptr_ps_dec, &ptr_sbr_dec->str_sbr_scale_fact); + + ixheaacd_cplx_synt_qmffilt(p_arr_qmf_buf_real, p_arr_qmf_buf_imag, op_delay, + &ptr_sbr_dec->str_sbr_scale_fact, ptr_time_data, + &ptr_sbr_dec->str_synthesis_qmf_bank, ptr_ps_dec, + 1, 0, sbr_tables_ptr, pstr_common_tables, ch_fac, + drc_on, drc_sbr_factors, audio_object_type); + + ps_scale = ptr_sbr_dec->str_sbr_scale_fact.ps_scale; + ptr_sbr_sf_r->ov_lb_scale = ps_scale; + ptr_sbr_sf_r->lb_scale = ps_scale; + ptr_sbr_sf_r->hb_scale = ps_scale; + + ixheaacd_cplx_synt_qmffilt(p_arr_qmf_buf_real, p_arr_qmf_buf_imag, op_delay, + ptr_sbr_sf_r, ptr_time_data + 1, + ptr_qmf_synth_bank_r, ptr_ps_dec, 0, 0, + sbr_tables_ptr, pstr_common_tables, ch_fac, + drc_on, drc_sbr_factors, audio_object_type); + } else { + ixheaacd_cplx_synt_qmffilt(p_arr_qmf_buf_real, p_arr_qmf_buf_imag, op_delay, + &ptr_sbr_dec->str_sbr_scale_fact, ptr_time_data, + &ptr_sbr_dec->str_synthesis_qmf_bank, ptr_ps_dec, + 0, low_pow_flag, sbr_tables_ptr, + pstr_common_tables, ch_fac, drc_on, + drc_sbr_factors, audio_object_type); + } + + { + WORD32 num = op_delay; + WORD32 *p_loc_qmf_real = ptr_sbr_dec->ptr_sbr_overlap_buf; + WORD32 *p_loc_qmf_real_1 = &p_arr_qmf_buf_real[no_bins][0]; + + if (!low_pow_flag) { + num = num << 1; + } + + memcpy(p_loc_qmf_real, p_loc_qmf_real_1, + sizeof(WORD32) * NO_SYNTHESIS_CHANNELS * num); + } + + ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale = save_lb_scale; +} + +void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + FLAG apply_processing, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, WORD ch_fac) { + WORD32 i; + WORD32 op_delay; + + WORD32 codec_x_delay = 0; + + FLOAT32 **pp_qmf_buf_real = ptr_sbr_dec->pp_qmf_buf_real; + FLOAT32 **pp_qmf_buf_imag = ptr_sbr_dec->pp_qmf_buf_imag; + + WORD32 upsample_ratio_idx = ptr_header_data->sbr_ratio_idx; + WORD32 core_frame_size = ptr_header_data->core_frame_size; + + WORD32 no_bins; + WORD32 mps_sbr_flag = ptr_frame_data->mps_sbr_flag; + WORD32 stereo_config_idx = ptr_frame_data->stereo_config_idx; + WORD32 hbe_flag = ptr_header_data->hbe_flag; + WORD32 sbr_mode = ptr_frame_data->sbr_mode; + + op_delay = 6; + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + op_delay = 2 * 6; + } + + no_bins = ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; + + ptr_sbr_dec->str_sbr_scale_fact.lb_scale = 0; + { + WORD32 num_anal_bands = ptr_sbr_dec->str_codec_qmf_bank.no_channels; + WORD32 frame_move = 288; + if (hbe_flag) { + codec_x_delay = 32; + } + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + codec_x_delay = 2 * codec_x_delay; + } + + frame_move = 9 * num_anal_bands; + + memmove(ptr_sbr_dec->core_sample_buf, + ptr_sbr_dec->core_sample_buf + core_frame_size, + frame_move * sizeof(FLOAT32)); + + memcpy(&ptr_sbr_dec->core_sample_buf[frame_move], + &ptr_sbr_dec->time_sample_buf[0], core_frame_size * sizeof(FLOAT32)); + + memmove( + &ptr_sbr_dec->qmf_buf_real[0][0], + &ptr_sbr_dec + ->qmf_buf_real[ptr_sbr_dec->str_codec_qmf_bank.num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET + codec_x_delay) * sizeof(FLOAT32) * 64); + memmove( + &ptr_sbr_dec->qmf_buf_imag[0][0], + &ptr_sbr_dec + ->qmf_buf_imag[ptr_sbr_dec->str_codec_qmf_bank.num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET + codec_x_delay) * sizeof(FLOAT32) * 64); + + memmove(&ptr_sbr_dec->sbr_qmf_out_real[0][0], + &ptr_sbr_dec->sbr_qmf_out_real[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET) * sizeof(FLOAT32) * 64); + memmove(&ptr_sbr_dec->sbr_qmf_out_imag[0][0], + &ptr_sbr_dec->sbr_qmf_out_imag[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + (op_delay + SBR_HF_ADJ_OFFSET) * sizeof(FLOAT32) * 64); + + if (hbe_flag) { + memmove(&ptr_sbr_dec->ph_vocod_qmf_real[0][0], + &ptr_sbr_dec->ph_vocod_qmf_real[ptr_sbr_dec->str_codec_qmf_bank + .num_time_slots][0], + 64 * sizeof(FLOAT32) * (op_delay + SBR_HF_ADJ_OFFSET)); + memmove(ptr_sbr_dec->ph_vocod_qmf_imag, + ptr_sbr_dec->ph_vocod_qmf_imag + + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + 64 * sizeof(FLOAT32) * (op_delay + SBR_HF_ADJ_OFFSET)); + } + } + + ixheaacd_esbr_analysis_filt_block( + ptr_sbr_dec, ptr_sbr_tables, + op_delay + codec_x_delay + SBR_HF_ADJ_OFFSET); + + if (hbe_flag) { + ixheaacd_qmf_hbe_apply( + ptr_sbr_dec->p_hbe_txposer, + ptr_sbr_dec->qmf_buf_real + (op_delay + SBR_HF_ADJ_OFFSET) + + ESBR_HBE_DELAY_OFFSET, + ptr_sbr_dec->qmf_buf_imag + (op_delay + SBR_HF_ADJ_OFFSET) + + ESBR_HBE_DELAY_OFFSET, + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_frame_data->pitch_in_bins); + + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + ixheaacd_hbe_repl_spec( + &ptr_sbr_dec->p_hbe_txposer->x_over_qmf[0], + ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->str_codec_qmf_bank.num_time_slots, + ptr_sbr_dec->p_hbe_txposer->max_stretch); + } + } + ixheaacd_qmf_enrg_calc(ptr_sbr_dec, upsample_ratio_idx, low_pow_flag); + + for (i = 0; i < 64; i++) { + memset(ptr_sbr_dec->sbr_qmf_out_real[i], 0, 64 * sizeof(FLOAT32)); + memset(ptr_sbr_dec->sbr_qmf_out_imag[i], 0, 64 * sizeof(FLOAT32)); + } + + ixheaacd_esbr_synthesis_filt_block( + ptr_sbr_dec, ptr_header_data, ptr_frame_data, apply_processing, + pp_qmf_buf_real, pp_qmf_buf_imag, stereo_config_idx, ptr_sbr_tables, + mps_sbr_flag, ch_fac); + + ptr_frame_data->prev_sbr_mode = sbr_mode; + return; +} + +void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, + VOID *p_sbr_frame, VOID *p_sbr_header) { + WORD32 i, k; + ia_sbr_frame_info_data_struct *ptr_frame_data = + (ia_sbr_frame_info_data_struct *)p_sbr_frame; + ia_sbr_header_data_struct *ptr_header_data = + (ia_sbr_header_data_struct *)p_sbr_header; + ia_sbr_dec_struct *ptr_sbr_dec = (ia_sbr_dec_struct *)p_sbr_dec; + ia_frame_info_struct *p_frame_info = &ptr_frame_data->str_frame_info_details; + WORD32 no_bins; + WORD32 upsample_ratio_idx = ptr_header_data->sbr_ratio_idx; + WORD32 op_delay = 6 + SBR_HF_ADJ_OFFSET; + WORD32 num_anal_bands = 40; + WORD32 mps_sbr_flag = ptr_frame_data->mps_sbr_flag; + + if (ptr_header_data->is_usf_4) { + op_delay += 6; + } + + num_anal_bands = num_anal_bands - (upsample_ratio_idx << 3); + + if (!mps_sbr_flag) { + return; + } + + no_bins = ptr_header_data->output_framesize / 64; + + for (i = 0; i < no_bins; i++) { + FLOAT32 *p_loc_mps_qmf_output = + p_mps_qmf_output + i * (MAX_NUM_QMF_BANDS_ESBR * 2); + for (k = 0; k < ptr_header_data->pstr_freq_band_data->sub_band_start; k++) { + ptr_sbr_dec->mps_qmf_buf_real[op_delay + i][k] = *p_loc_mps_qmf_output++; + ptr_sbr_dec->mps_qmf_buf_imag[op_delay + i][k] = *p_loc_mps_qmf_output++; + + ptr_sbr_dec->mps_sbr_qmf_buf_real[SBR_HF_ADJ_OFFSET + i][k] = + ptr_sbr_dec->qmf_buf_real[SBR_HF_ADJ_OFFSET + i][k]; + ptr_sbr_dec->mps_sbr_qmf_buf_imag[SBR_HF_ADJ_OFFSET + i][k] = + ptr_sbr_dec->qmf_buf_real[SBR_HF_ADJ_OFFSET + i][k]; + } + } + + if (ptr_frame_data->reset_flag) { + WORD32 l; + WORD32 start_band = ptr_header_data->pstr_freq_band_data->qmf_sb_prev; + WORD32 end_band = num_anal_bands; + WORD32 start_slot = + SBR_HF_ADJ_OFFSET + ptr_frame_data->rate * p_frame_info->border_vec[0]; + + for (l = start_slot; l < op_delay; l++) { + for (k = start_band; k < end_band; k++) { + ptr_sbr_dec->mps_qmf_buf_real[l][k] = 0.0; + ptr_sbr_dec->mps_qmf_buf_imag[l][k] = 0.0; + } + } + + for (l = 0; l < SBR_HF_ADJ_OFFSET; l++) { + for (k = start_band; k < end_band; k++) { + ptr_sbr_dec->mps_qmf_buf_real[l][k] = 0.0; + ptr_sbr_dec->mps_qmf_buf_imag[l][k] = 0.0; + } + } + } + ptr_header_data->pstr_freq_band_data->qmf_sb_prev = + ptr_header_data->pstr_freq_band_data->sub_band_start; + + ixheaacd_generate_hf(ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_qmf_buf_imag + SBR_HF_ADJ_OFFSET, NULL, + NULL, + ptr_sbr_dec->mps_sbr_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_sbr_qmf_buf_imag + SBR_HF_ADJ_OFFSET, + ptr_frame_data, ptr_header_data); + + ptr_frame_data->pstr_sbr_header = ptr_header_data; + ptr_frame_data->sbr_mode = ORIG_SBR; + ptr_frame_data->prev_sbr_mode = ORIG_SBR; + + ixheaacd_sbr_env_calc( + ptr_frame_data, ptr_sbr_dec->mps_sbr_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_sbr_qmf_buf_imag + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_qmf_buf_imag + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->p_hbe_txposer->x_over_qmf, ptr_sbr_dec->scratch_buff, NULL); + + for (i = 0; i < no_bins; i++) { + FLOAT32 *p_loc_mps_qmf_output = + p_mps_qmf_output + i * (MAX_NUM_QMF_BANDS_ESBR * 2); + for (k = 0; k < ptr_header_data->pstr_freq_band_data->sub_band_start; k++) { + *p_loc_mps_qmf_output++ = + ptr_sbr_dec->mps_qmf_buf_real[SBR_HF_ADJ_OFFSET + i][k]; + *p_loc_mps_qmf_output++ = + ptr_sbr_dec->mps_qmf_buf_imag[SBR_HF_ADJ_OFFSET + i][k]; + } + for (k = ptr_header_data->pstr_freq_band_data->sub_band_start; k < 64; + k++) { + *p_loc_mps_qmf_output++ = + ptr_sbr_dec->mps_sbr_qmf_buf_real[SBR_HF_ADJ_OFFSET + i][k]; + *p_loc_mps_qmf_output++ = + ptr_sbr_dec->mps_sbr_qmf_buf_imag[SBR_HF_ADJ_OFFSET + i][k]; + } + } + + for (i = 0; i < op_delay; i++) { + memmove(ptr_sbr_dec->mps_qmf_buf_real[i], + ptr_sbr_dec->mps_qmf_buf_real[no_bins + i], 64 * sizeof(FLOAT32)); + + memmove(ptr_sbr_dec->mps_qmf_buf_imag[i], + ptr_sbr_dec->mps_qmf_buf_imag[no_bins + i], 64 * sizeof(FLOAT32)); + + memmove(ptr_sbr_dec->mps_sbr_qmf_buf_real[i], + ptr_sbr_dec->mps_sbr_qmf_buf_real[no_bins + i], + 64 * sizeof(FLOAT32)); + + memmove(ptr_sbr_dec->mps_sbr_qmf_buf_imag[i], + ptr_sbr_dec->mps_sbr_qmf_buf_imag[no_bins + i], + 64 * sizeof(FLOAT32)); + } + + ptr_frame_data->reset_flag = 0; +} diff --git a/decoder/ixheaacd_sbr_dec.h b/decoder/ixheaacd_sbr_dec.h new file mode 100644 index 0000000..8fef0e0 --- /dev/null +++ b/decoder/ixheaacd_sbr_dec.h @@ -0,0 +1,237 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_DEC_H +#define IXHEAACD_SBR_DEC_H + +typedef struct { + WORD32 x_over_qmf[MAX_NUM_PATCHES]; + WORD32 max_stretch; + WORD32 core_frame_length; + WORD32 hbe_qmf_in_len; + WORD32 hbe_qmf_out_len; + WORD32 no_bins; + WORD32 start_band; + WORD32 end_band; + WORD32 upsamp_4_flag; + WORD32 synth_buf_offset; + + FLOAT32 *ptr_input_buf; + + FLOAT32 **qmf_in_buf; + FLOAT32 **qmf_out_buf; + + WORD32 k_start; + WORD32 synth_size; + FLOAT32 synth_buf[1280]; + FLOAT32 analy_buf[640]; + FLOAT32 *synth_wind_coeff; + FLOAT32 *analy_wind_coeff; + + FLOAT32 *synth_cos_tab; + FLOAT32 *analy_cos_sin_tab; + + FLOAT32 norm_qmf_in_buf[46][128]; + +} ia_esbr_hbe_txposer_struct; + +typedef struct { + WORD32 *ptr_sbr_overlap_buf; + WORD32 **drc_factors_sbr; + ia_sbr_qmf_filter_bank_struct str_codec_qmf_bank; + ia_sbr_qmf_filter_bank_struct str_synthesis_qmf_bank; + ia_sbr_calc_env_struct str_sbr_calc_env; + ia_sbr_hf_generator_struct str_hf_generator; + + ia_sbr_scale_fact_struct str_sbr_scale_fact; + + WORD32 max_samp_val; + ia_esbr_hbe_txposer_struct *p_hbe_txposer; + + FLOAT32 core_sample_buf[2624]; + FLOAT32 ph_vocod_qmf_real[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 ph_vocod_qmf_imag[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 sbr_qmf_out_real[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 sbr_qmf_out_imag[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 qmf_buf_real[TIMESLOT_BUFFER_SIZE + 2 * 32][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 qmf_buf_imag[TIMESLOT_BUFFER_SIZE + 2 * 32][NO_QMF_SYNTH_CHANNELS]; + + FLOAT32 mps_qmf_buf_real[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 mps_qmf_buf_imag[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 mps_sbr_qmf_buf_real[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + FLOAT32 mps_sbr_qmf_buf_imag[TIMESLOT_BUFFER_SIZE][NO_QMF_SYNTH_CHANNELS]; + + WORD32 sbr_scratch_local[256]; + FLOAT32 scratch_buff[320]; + + FLOAT32 qmf_energy_buf[64][32]; + FLOAT32 pvc_qmf_enrg_arr[16 * 32]; + + FLOAT32 **pp_qmf_buf_real; + FLOAT32 **pp_qmf_buf_imag; + + FLOAT32 *time_sample_buf; +} ia_sbr_dec_struct; + +typedef struct { + ia_sbr_prev_frame_data_struct *pstr_prev_frame_data; + ia_sbr_dec_struct str_sbr_dec; + WORD32 output_frame_size; + WORD32 sync_state; +} ia_sbr_channel_struct; + +struct ia_sbr_dec_inst_struct { + ia_ps_dec_struct *pstr_ps_stereo_dec; + FLAG ps_present; + ia_sbr_channel_struct *pstr_sbr_channel[MAXNRSBRCHANNELS]; + ia_sbr_header_data_struct *pstr_sbr_header[MAXNRSBRCHANNELS]; + ia_freq_band_data_struct *pstr_freq_band_data[MAXNRSBRCHANNELS]; + ia_sbr_tables_struct *pstr_sbr_tables; + ixheaacd_misc_tables *pstr_common_tables; + ia_pvc_data_struct *ptr_pvc_data_str; + VOID *hbe_txposer_buffers; + FLOAT32 *time_sample_buf[MAXNRSBRCHANNELS]; + VOID *scratch_mem_v; + VOID *frame_buffer[2]; + ia_sbr_header_data_struct str_sbr_dflt_header; + FLAG stereo_config_idx; + FLAG usac_independency_flag; + FLAG pvc_flag; + FLAG hbe_flag; + FLAG sbr_mode; + FLAG prev_sbr_mode; + FLAG inter_tes_flag; + FLAG aot_usac_flag; +}; + +typedef struct ia_sbr_pers_struct { + WORD16 *sbr_qmf_analy_states; + + WORD32 *sbr_qmf_analy_states_32; + + WORD16 *sbr_qmf_synth_states; + + WORD32 *sbr_qmf_synth_states_32; + + WORD32 **sbr_lpc_filter_states_real[MAXNRSBRCHANNELS]; + + WORD32 **sbr_lpc_filter_states_imag[MAXNRSBRCHANNELS]; + + WORD32 *ptr_sbr_overlap_buf[MAXNRSBRCHANNELS]; + + struct ia_sbr_dec_inst_struct str_sbr_dec_inst; + + ia_transposer_settings_struct str_sbr_tran_settings; + + WORD16 *sbr_smooth_gain_buf[MAXNRSBRCHANNELS]; + + WORD16 *sbr_smooth_noise_buf[MAXNRSBRCHANNELS]; + + ia_sbr_prev_frame_data_struct *pstr_prev_frame_data[MAXNRSBRCHANNELS]; + +} ia_sbr_pers_struct; + +VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, + ia_ps_dec_struct *ptr_ps_dec, + ia_sbr_qmf_filter_bank_struct *ptr_qmf_synth_bank_r, + ia_sbr_scale_fact_struct *ptr_sbr_sf_r, + FLAG apply_processing, FLAG low_pow_flag, + WORD32 *ptr_work_buf_core, + ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables, WORD ch_fac, + ia_pvc_data_struct *ptr_pvc_data_str, FLAG drc_on, + WORD32 drc_sbr_factors[][64], WORD32 audio_object_type); + +WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, + ixheaacd_misc_tables *pstr_common_table, + ia_sbr_channel_struct *ptr_sbr_channel, + ia_sbr_header_data_struct *ptr_header_data, + WORD16 chan, FLAG down_sample_flag, + VOID *sbr_persistent_mem_v, WORD ps_enable, + WORD audio_object_type); + +#define MAX_NUM_QMF_BANDS_ESBR 128 + +VOID ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, + VOID *p_sbr_frame, VOID *p_sbr_header); + +VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer, + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 num_columns, + FLOAT32 pv_qmf_buf_real[][64], + FLOAT32 pv_qmf_buf_imag[][64], + WORD32 pitch_in_bins); + +VOID ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, + FLOAT32 input_real[][64], FLOAT32 input_imag[][64], + FLOAT32 input_real1[][64], FLOAT32 input_imag1[][64], + WORD32 x_over_qmf[MAX_NUM_PATCHES], + FLOAT32 *scratch_buff, FLOAT32 *env_out); + +VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], + FLOAT32 ptr_src_buf_imag[][64], + FLOAT32 ptr_ph_vocod_buf_real[][64], + FLOAT32 ptr_ph_vocod_buf_imag[][64], + FLOAT32 ptr_dst_buf_real[][64], + FLOAT32 ptr_dst_buf_imag[][64], + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_header_data_struct *ptr_header_data); + +VOID ixheaacd_clr_subsamples(WORD32 *ptr_qmf_buf, WORD32 num, WORD32 size); + +VOID ixheaacd_rescale_x_overlap( + ia_sbr_dec_struct *ptr_sbr_dec, ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, + WORD32 **pp_overlap_buffer_real, FLAG low_pow_flag); + +VOID ixheaacd_qmf_hbe_data_reinit( + ia_esbr_hbe_txposer_struct *ptr_hbe_transposer_str, + WORD16 *ptr_freq_band_tbl[MAX_FREQ_COEFFS + 1], WORD16 *ptr_num_sf_bands, + WORD32 upsamp_4_flag); + +WORD32 ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_bit_buf_struct *it_bit_buff, + WORD32 hbe_flag, + ia_pvc_data_struct *ptr_pvc_data, + ia_sbr_tables_struct *sbr_tables_ptr, + ia_sbr_header_data_struct *ptr_header_data); + +VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer, + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 num_columns, + FLOAT32 pv_qmf_buf_real[][64], + FLOAT32 pv_qmf_buf_imag[][64], + WORD32 pitch_in_bins); + +VOID ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + FLAG apply_processing, FLAG low_pow_flag, + ia_sbr_tables_struct *sbr_tables_ptr, WORD32 ch_fac); + +VOID ixheaacd_hbe_repl_spec(WORD32 x_over_qmf[MAX_NUM_PATCHES], + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 no_bins, + WORD32 max_stretch); + +#endif diff --git a/decoder/ixheaacd_sbr_payload.h b/decoder/ixheaacd_sbr_payload.h new file mode 100644 index 0000000..db3accc --- /dev/null +++ b/decoder/ixheaacd_sbr_payload.h @@ -0,0 +1,34 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_PAYLOAD_H +#define IXHEAACD_SBR_PAYLOAD_H + +FLAG ixheaacd_check_for_sbr_payload( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_sbr_bitstream_struct *pstr_stream_sbr, WORD16 prev_element, + ia_drc_dec_struct *pstr_drc_dec, WORD32 object_type, WORD32 adtsheader, + WORD32 cnt_bits, WORD32 ld_sbr_crc_flag, ia_drc_dec_struct *drc_dummy); + +WORD8 ixheaacd_aac_plus_get_payload( + ia_bit_buf_struct *it_bit_buff, + ia_sbr_element_stream_struct *pstr_stream_sbr, + ia_drc_dec_struct *pstr_drc_dec); + +#endif diff --git a/decoder/ixheaacd_sbr_rom.c b/decoder/ixheaacd_sbr_rom.c new file mode 100644 index 0000000..a827c8f --- /dev/null +++ b/decoder/ixheaacd_sbr_rom.c @@ -0,0 +1,2428 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include +#include "ixheaacd_defines.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_qmf_dec.h" + +const ia_env_calc_tables_struct ixheaacd_aac_dec_env_calc_tables = { + {(WORD16)0x4027, 0, (WORD16)0x4000, 1, (WORD16)0x7fb2, 1, (WORD16)0x56bc, + 67}, + + // const WORD16 sbr_lim_bands_per_octave_q13[4] = + {(WORD16)0x2000, (WORD16)0x2666, (WORD16)0x4000, (WORD16)0x6000}, + + // const WORD16 sbr_smooth_filter[4] = + {(WORD16)0x5555, (WORD16)0x461d, (WORD16)0x3387, (WORD16)0x1bb8}, + + // const WORD16 sbr_inv_int_table[INV_INT_TABLE_SIZE] = + {(WORD16)0x7fff, (WORD16)0x7fff, (WORD16)0x4000, (WORD16)0x2aab, + (WORD16)0x2000, (WORD16)0x199a, (WORD16)0x1555, (WORD16)0x1249, + (WORD16)0x1000, (WORD16)0x0e39, (WORD16)0x0ccd, (WORD16)0x0ba3, + (WORD16)0x0aab, (WORD16)0x09d9, (WORD16)0x0925, (WORD16)0x0889, + (WORD16)0x0800, (WORD16)0x0788, (WORD16)0x071c, (WORD16)0x06bd, + (WORD16)0x0666, (WORD16)0x0618, (WORD16)0x05d1, (WORD16)0x0591, + (WORD16)0x0555, (WORD16)0x051f, (WORD16)0x04ec, (WORD16)0x04be, + (WORD16)0x0492, (WORD16)0x046a, (WORD16)0x0444, (WORD16)0x0421, + (WORD16)0x0400, (WORD16)0x03e1, (WORD16)0x03c4, (WORD16)0x03a8, + (WORD16)0x038e, (WORD16)0x0376, (WORD16)0x035e, (WORD16)0x0348, + (WORD16)0x0333, (WORD16)0x031f, (WORD16)0x030c, (WORD16)0x02fa, + (WORD16)0x02e9, (WORD16)0x02d8, (WORD16)0x02c8, (WORD16)0x02b9}, + + // const WORD32 sbr_rand_ph[SBR_NF_NO_RANDOM_VAL + MAX_FREQ_COEFFS] = + {((WORD32)0xf801 << 16) | ((WORD32)0xfb3e & 0xFFFF), + ((WORD32)0x07c5 << 16) | ((WORD32)0xfa99 & 0xFFFF), + ((WORD32)0x0121 << 16) | ((WORD32)0xf865 & 0xFFFF), + ((WORD32)0xfc3d << 16) | ((WORD32)0xfd03 & 0xFFFF), + ((WORD32)0x0675 << 16) | ((WORD32)0x025f & 0xFFFF), + ((WORD32)0xfce2 << 16) | ((WORD32)0x072a & 0xFFFF), + ((WORD32)0xffea << 16) | ((WORD32)0xfaa5 & 0xFFFF), + ((WORD32)0xf8b3 << 16) | ((WORD32)0xff14 & 0xFFFF), + ((WORD32)0x0463 << 16) | ((WORD32)0x0605 & 0xFFFF), + ((WORD32)0x0333 << 16) | ((WORD32)0xf816 & 0xFFFF), + ((WORD32)0xf803 << 16) | ((WORD32)0xf8f3 & 0xFFFF), + ((WORD32)0xf85c << 16) | ((WORD32)0x0746 & 0xFFFF), + ((WORD32)0xfc58 << 16) | ((WORD32)0xfb76 & 0xFFFF), + ((WORD32)0xfa2a << 16) | ((WORD32)0xf829 & 0xFFFF), + ((WORD32)0x060d << 16) | ((WORD32)0x01ad & 0xFFFF), + ((WORD32)0x0091 << 16) | ((WORD32)0xf9bd & 0xFFFF), + ((WORD32)0x05f6 << 16) | ((WORD32)0xf8b5 & 0xFFFF), + ((WORD32)0xf849 << 16) | ((WORD32)0xf86c & 0xFFFF), + ((WORD32)0x026f << 16) | ((WORD32)0xfc0c & 0xFFFF), + ((WORD32)0x0553 << 16) | ((WORD32)0x052c & 0xFFFF), + ((WORD32)0x0756 << 16) | ((WORD32)0x0167 & 0xFFFF), + ((WORD32)0xfa57 << 16) | ((WORD32)0x0434 & 0xFFFF), + ((WORD32)0xfa65 << 16) | ((WORD32)0xfc5f & 0xFFFF), + ((WORD32)0xf80a << 16) | ((WORD32)0xf8cb & 0xFFFF), + ((WORD32)0x07da << 16) | ((WORD32)0xf9ce & 0xFFFF), + ((WORD32)0xfba0 << 16) | ((WORD32)0xffcb & 0xFFFF), + ((WORD32)0xffdd << 16) | ((WORD32)0x0006 & 0xFFFF), + ((WORD32)0xf91c << 16) | ((WORD32)0x0367 & 0xFFFF), + ((WORD32)0xf817 << 16) | ((WORD32)0xf8f8 & 0xFFFF), + ((WORD32)0x0424 << 16) | ((WORD32)0x055b & 0xFFFF), + ((WORD32)0xf807 << 16) | ((WORD32)0xfb5a & 0xFFFF), + ((WORD32)0xf801 << 16) | ((WORD32)0x07df & 0xFFFF), + ((WORD32)0x046c << 16) | ((WORD32)0x04c2 & 0xFFFF), + ((WORD32)0x02c4 << 16) | ((WORD32)0x0797 & 0xFFFF), + ((WORD32)0x0503 << 16) | ((WORD32)0xfa0c & 0xFFFF), + ((WORD32)0xf9d4 << 16) | ((WORD32)0xfd4a & 0xFFFF), + ((WORD32)0xf8ac << 16) | ((WORD32)0x004c & 0xFFFF), + ((WORD32)0xf9e6 << 16) | ((WORD32)0xf8b1 & 0xFFFF), + ((WORD32)0x0662 << 16) | ((WORD32)0xf88c & 0xFFFF), + ((WORD32)0x045c << 16) | ((WORD32)0xff0c & 0xFFFF), + ((WORD32)0xf926 << 16) | ((WORD32)0x0365 & 0xFFFF), + ((WORD32)0xf892 << 16) | ((WORD32)0x023b & 0xFFFF), + ((WORD32)0xff10 << 16) | ((WORD32)0xf804 & 0xFFFF), + ((WORD32)0x01b5 << 16) | ((WORD32)0xf8be & 0xFFFF), + ((WORD32)0xf9e8 << 16) | ((WORD32)0x07fb & 0xFFFF), + ((WORD32)0x07d9 << 16) | ((WORD32)0xf855 & 0xFFFF), + ((WORD32)0xf920 << 16) | ((WORD32)0x07a9 & 0xFFFF), + ((WORD32)0xf889 << 16) | ((WORD32)0x03f4 & 0xFFFF), + ((WORD32)0x0270 << 16) | ((WORD32)0xfa5b & 0xFFFF), + ((WORD32)0x06d3 << 16) | ((WORD32)0x03be & 0xFFFF), + ((WORD32)0x074e << 16) | ((WORD32)0xf803 & 0xFFFF), + ((WORD32)0xff87 << 16) | ((WORD32)0x05a9 & 0xFFFF), + ((WORD32)0x0246 << 16) | ((WORD32)0x02c5 & 0xFFFF), + ((WORD32)0x079f << 16) | ((WORD32)0xfb9c & 0xFFFF), + ((WORD32)0xf9b7 << 16) | ((WORD32)0xf9f4 & 0xFFFF), + ((WORD32)0xf856 << 16) | ((WORD32)0xfe5e & 0xFFFF), + ((WORD32)0x0698 << 16) | ((WORD32)0x07bb & 0xFFFF), + ((WORD32)0xfac9 << 16) | ((WORD32)0xf8e7 & 0xFFFF), + ((WORD32)0xf882 << 16) | ((WORD32)0x07fd & 0xFFFF), + ((WORD32)0x0750 << 16) | ((WORD32)0xf823 & 0xFFFF), + ((WORD32)0xfa5e << 16) | ((WORD32)0x04b4 & 0xFFFF), + ((WORD32)0x000c << 16) | ((WORD32)0x04f1 & 0xFFFF), + ((WORD32)0x0720 << 16) | ((WORD32)0x0439 & 0xFFFF), + ((WORD32)0xfa81 << 16) | ((WORD32)0x0677 & 0xFFFF), + ((WORD32)0x05c6 << 16) | ((WORD32)0xfa76 & 0xFFFF), + ((WORD32)0xfaf7 << 16) | ((WORD32)0x0117 & 0xFFFF), + ((WORD32)0x0265 << 16) | ((WORD32)0xfc51 & 0xFFFF), + ((WORD32)0xf8a8 << 16) | ((WORD32)0xfa14 & 0xFFFF), + ((WORD32)0x07f2 << 16) | ((WORD32)0x0344 & 0xFFFF), + ((WORD32)0x0697 << 16) | ((WORD32)0xfa14 & 0xFFFF), + ((WORD32)0xf81e << 16) | ((WORD32)0xf801 & 0xFFFF), + ((WORD32)0xf854 << 16) | ((WORD32)0xf810 & 0xFFFF), + ((WORD32)0xfe4a << 16) | ((WORD32)0xf887 & 0xFFFF), + ((WORD32)0xfa7f << 16) | ((WORD32)0xfdd9 & 0xFFFF), + ((WORD32)0x0759 << 16) | ((WORD32)0x00c0 & 0xFFFF), + ((WORD32)0xf851 << 16) | ((WORD32)0x02e3 & 0xFFFF), + ((WORD32)0x0422 << 16) | ((WORD32)0xfa4a & 0xFFFF), + ((WORD32)0x04e4 << 16) | ((WORD32)0x03c2 & 0xFFFF), + ((WORD32)0x03c9 << 16) | ((WORD32)0xfdd0 & 0xFFFF), + ((WORD32)0x0748 << 16) | ((WORD32)0x07bd & 0xFFFF), + ((WORD32)0x0396 << 16) | ((WORD32)0x07f0 & 0xFFFF), + ((WORD32)0x0554 << 16) | ((WORD32)0x07ba & 0xFFFF), + ((WORD32)0x05fe << 16) | ((WORD32)0xf8cf & 0xFFFF), + ((WORD32)0xf809 << 16) | ((WORD32)0x0439 & 0xFFFF), + ((WORD32)0x07cb << 16) | ((WORD32)0xfea7 & 0xFFFF), + ((WORD32)0x05d1 << 16) | ((WORD32)0xfc28 & 0xFFFF), + ((WORD32)0x07a2 << 16) | ((WORD32)0x0582 & 0xFFFF), + ((WORD32)0xfa2a << 16) | ((WORD32)0xf9df & 0xFFFF), + ((WORD32)0xf92c << 16) | ((WORD32)0x0719 & 0xFFFF), + ((WORD32)0xf97d << 16) | ((WORD32)0xf834 & 0xFFFF), + ((WORD32)0xf8f7 << 16) | ((WORD32)0x05fb & 0xFFFF), + ((WORD32)0xfa46 << 16) | ((WORD32)0xf81d & 0xFFFF), + ((WORD32)0x06af << 16) | ((WORD32)0x06b2 & 0xFFFF), + ((WORD32)0xfc27 << 16) | ((WORD32)0xf818 & 0xFFFF), + ((WORD32)0x07c5 << 16) | ((WORD32)0x0668 & 0xFFFF), + ((WORD32)0x0429 << 16) | ((WORD32)0x066b & 0xFFFF), + ((WORD32)0xffef << 16) | ((WORD32)0xf9de & 0xFFFF), + ((WORD32)0xfa60 << 16) | ((WORD32)0x046e & 0xFFFF), + ((WORD32)0xf854 << 16) | ((WORD32)0xfc8a & 0xFFFF), + ((WORD32)0x07c4 << 16) | ((WORD32)0x00bf & 0xFFFF), + ((WORD32)0xf89c << 16) | ((WORD32)0x06d7 & 0xFFFF), + ((WORD32)0xfa71 << 16) | ((WORD32)0x07e4 & 0xFFFF), + ((WORD32)0x0220 << 16) | ((WORD32)0x05dd & 0xFFFF), + ((WORD32)0x023e << 16) | ((WORD32)0x012a & 0xFFFF), + ((WORD32)0xfa12 << 16) | ((WORD32)0x07f2 & 0xFFFF), + ((WORD32)0xffdc << 16) | ((WORD32)0xf964 & 0xFFFF), + ((WORD32)0xfb97 << 16) | ((WORD32)0xf817 & 0xFFFF), + ((WORD32)0x07d6 << 16) | ((WORD32)0xf87a & 0xFFFF), + ((WORD32)0xf810 << 16) | ((WORD32)0x055d & 0xFFFF), + ((WORD32)0xfa96 << 16) | ((WORD32)0x0103 & 0xFFFF), + ((WORD32)0x00bb << 16) | ((WORD32)0xfe5b & 0xFFFF), + ((WORD32)0xfa44 << 16) | ((WORD32)0xf82d & 0xFFFF), + ((WORD32)0x067b << 16) | ((WORD32)0x044c & 0xFFFF), + ((WORD32)0x0340 << 16) | ((WORD32)0xfde2 & 0xFFFF), + ((WORD32)0xfa96 << 16) | ((WORD32)0x078f & 0xFFFF), + ((WORD32)0x06f3 << 16) | ((WORD32)0xfe89 & 0xFFFF), + ((WORD32)0xf80a << 16) | ((WORD32)0xffca & 0xFFFF), + ((WORD32)0x06bf << 16) | ((WORD32)0x00d5 & 0xFFFF), + ((WORD32)0xff43 << 16) | ((WORD32)0x0590 & 0xFFFF), + ((WORD32)0x07ff << 16) | ((WORD32)0xff03 & 0xFFFF), + ((WORD32)0xf99f << 16) | ((WORD32)0xf8ac & 0xFFFF), + ((WORD32)0x07b5 << 16) | ((WORD32)0x07bb & 0xFFFF), + ((WORD32)0xf99b << 16) | ((WORD32)0x0525 & 0xFFFF), + ((WORD32)0xff13 << 16) | ((WORD32)0x0249 & 0xFFFF), + ((WORD32)0xfcce << 16) | ((WORD32)0x0788 & 0xFFFF), + ((WORD32)0x07ed << 16) | ((WORD32)0xf8a3 & 0xFFFF), + ((WORD32)0x024a << 16) | ((WORD32)0xf8b8 & 0xFFFF), + ((WORD32)0xf956 << 16) | ((WORD32)0xfa9d & 0xFFFF), + ((WORD32)0x07a2 << 16) | ((WORD32)0x03ef & 0xFFFF), + ((WORD32)0xff7c << 16) | ((WORD32)0x0043 & 0xFFFF), + ((WORD32)0xf809 << 16) | ((WORD32)0x0364 & 0xFFFF), + ((WORD32)0xfac3 << 16) | ((WORD32)0x069b & 0xFFFF), + ((WORD32)0xf980 << 16) | ((WORD32)0xfbdf & 0xFFFF), + ((WORD32)0xf807 << 16) | ((WORD32)0x06c2 & 0xFFFF), + ((WORD32)0x0006 << 16) | ((WORD32)0x052e & 0xFFFF), + ((WORD32)0x059d << 16) | ((WORD32)0xfe5d & 0xFFFF), + ((WORD32)0x07b5 << 16) | ((WORD32)0x0342 & 0xFFFF), + ((WORD32)0xfa7d << 16) | ((WORD32)0x074f & 0xFFFF), + ((WORD32)0xfd36 << 16) | ((WORD32)0x05b8 & 0xFFFF), + ((WORD32)0x075c << 16) | ((WORD32)0x0552 & 0xFFFF), + ((WORD32)0xf814 << 16) | ((WORD32)0x06df & 0xFFFF), + ((WORD32)0x0582 << 16) | ((WORD32)0x0474 & 0xFFFF), + ((WORD32)0xf80b << 16) | ((WORD32)0xfe65 & 0xFFFF), + ((WORD32)0x078a << 16) | ((WORD32)0xf806 & 0xFFFF), + ((WORD32)0xfa9b << 16) | ((WORD32)0x03f7 & 0xFFFF), + ((WORD32)0xfc36 << 16) | ((WORD32)0xf921 & 0xFFFF), + ((WORD32)0x0125 << 16) | ((WORD32)0xf878 & 0xFFFF), + ((WORD32)0xfda9 << 16) | ((WORD32)0x0076 & 0xFFFF), + ((WORD32)0x0381 << 16) | ((WORD32)0xf9b0 & 0xFFFF), + ((WORD32)0xfd18 << 16) | ((WORD32)0x0531 & 0xFFFF), + ((WORD32)0xff4d << 16) | ((WORD32)0x07d1 & 0xFFFF), + ((WORD32)0xf848 << 16) | ((WORD32)0xfbaf & 0xFFFF), + ((WORD32)0x0471 << 16) | ((WORD32)0x0650 & 0xFFFF), + ((WORD32)0x05e2 << 16) | ((WORD32)0x07b7 & 0xFFFF), + ((WORD32)0xfd87 << 16) | ((WORD32)0xf98c & 0xFFFF), + ((WORD32)0x0049 << 16) | ((WORD32)0xf837 & 0xFFFF), + ((WORD32)0x07e6 << 16) | ((WORD32)0x03df & 0xFFFF), + ((WORD32)0xf977 << 16) | ((WORD32)0xf8bc & 0xFFFF), + ((WORD32)0x056e << 16) | ((WORD32)0x0681 & 0xFFFF), + ((WORD32)0xfebc << 16) | ((WORD32)0x06d3 & 0xFFFF), + ((WORD32)0x0675 << 16) | ((WORD32)0xfe06 & 0xFFFF), + ((WORD32)0x03d3 << 16) | ((WORD32)0xfc4b & 0xFFFF), + ((WORD32)0x07b6 << 16) | ((WORD32)0x0314 & 0xFFFF), + ((WORD32)0xf812 << 16) | ((WORD32)0xfe01 & 0xFFFF), + ((WORD32)0x06a6 << 16) | ((WORD32)0xf86b & 0xFFFF), + ((WORD32)0xfb4d << 16) | ((WORD32)0x001a & 0xFFFF), + ((WORD32)0x07a5 << 16) | ((WORD32)0xf928 & 0xFFFF), + ((WORD32)0xf848 << 16) | ((WORD32)0xfae1 & 0xFFFF), + ((WORD32)0xf837 << 16) | ((WORD32)0x00fe & 0xFFFF), + ((WORD32)0x0750 << 16) | ((WORD32)0x04a3 & 0xFFFF), + ((WORD32)0xf802 << 16) | ((WORD32)0x05b0 & 0xFFFF), + ((WORD32)0xf90d << 16) | ((WORD32)0xfe60 & 0xFFFF), + ((WORD32)0xfde7 << 16) | ((WORD32)0xfa8a & 0xFFFF), + ((WORD32)0xfe07 << 16) | ((WORD32)0xf8fd & 0xFFFF), + ((WORD32)0x0031 << 16) | ((WORD32)0x022d & 0xFFFF), + ((WORD32)0x0691 << 16) | ((WORD32)0xf931 & 0xFFFF), + ((WORD32)0x0715 << 16) | ((WORD32)0xf8d4 & 0xFFFF), + ((WORD32)0xfe8c << 16) | ((WORD32)0xfde8 & 0xFFFF), + ((WORD32)0x00c0 << 16) | ((WORD32)0x0463 & 0xFFFF), + ((WORD32)0xfba0 << 16) | ((WORD32)0x07ae & 0xFFFF), + ((WORD32)0x02f7 << 16) | ((WORD32)0xfb35 & 0xFFFF), + ((WORD32)0xfa5f << 16) | ((WORD32)0x074c & 0xFFFF), + ((WORD32)0xfd3b << 16) | ((WORD32)0xf80b & 0xFFFF), + ((WORD32)0xfa7f << 16) | ((WORD32)0xfd95 & 0xFFFF), + ((WORD32)0xfdda << 16) | ((WORD32)0x06a6 & 0xFFFF), + ((WORD32)0x03ed << 16) | ((WORD32)0xfc5f & 0xFFFF), + ((WORD32)0x031e << 16) | ((WORD32)0x07a4 & 0xFFFF), + ((WORD32)0xf82e << 16) | ((WORD32)0x006d & 0xFFFF), + ((WORD32)0xfe9d << 16) | ((WORD32)0xf894 & 0xFFFF), + ((WORD32)0x07ff << 16) | ((WORD32)0x04aa & 0xFFFF), + ((WORD32)0xface << 16) | ((WORD32)0x057e & 0xFFFF), + ((WORD32)0xff0a << 16) | ((WORD32)0xfb6e & 0xFFFF), + ((WORD32)0xfb49 << 16) | ((WORD32)0xfd36 & 0xFFFF), + ((WORD32)0xfca8 << 16) | ((WORD32)0x014d & 0xFFFF), + ((WORD32)0x07fe << 16) | ((WORD32)0x00e4 & 0xFFFF), + ((WORD32)0xfb78 << 16) | ((WORD32)0xf8c3 & 0xFFFF), + ((WORD32)0x0788 << 16) | ((WORD32)0x02d3 & 0xFFFF), + ((WORD32)0xf9f1 << 16) | ((WORD32)0x044b & 0xFFFF), + ((WORD32)0x01a5 << 16) | ((WORD32)0xf872 & 0xFFFF), + ((WORD32)0x0800 << 16) | ((WORD32)0x0663 & 0xFFFF), + ((WORD32)0x0254 << 16) | ((WORD32)0x02d5 & 0xFFFF), + ((WORD32)0xfaf9 << 16) | ((WORD32)0x031a & 0xFFFF), + ((WORD32)0x037a << 16) | ((WORD32)0xf81e & 0xFFFF), + ((WORD32)0xf823 << 16) | ((WORD32)0x01af & 0xFFFF), + ((WORD32)0x0190 << 16) | ((WORD32)0xf876 & 0xFFFF), + ((WORD32)0xf85d << 16) | ((WORD32)0x07df & 0xFFFF), + ((WORD32)0x0778 << 16) | ((WORD32)0xfa54 & 0xFFFF), + ((WORD32)0xf92e << 16) | ((WORD32)0xff55 & 0xFFFF), + ((WORD32)0xf916 << 16) | ((WORD32)0xfc56 & 0xFFFF), + ((WORD32)0x031c << 16) | ((WORD32)0x07c8 & 0xFFFF), + ((WORD32)0x075d << 16) | ((WORD32)0xfb01 & 0xFFFF), + ((WORD32)0x0722 << 16) | ((WORD32)0x0465 & 0xFFFF), + ((WORD32)0xfd0e << 16) | ((WORD32)0x07b7 & 0xFFFF), + ((WORD32)0x0783 << 16) | ((WORD32)0xf8cd & 0xFFFF), + ((WORD32)0x07f1 << 16) | ((WORD32)0xffb3 & 0xFFFF), + ((WORD32)0xf87a << 16) | ((WORD32)0x034e & 0xFFFF), + ((WORD32)0x07fb << 16) | ((WORD32)0xfea7 & 0xFFFF), + ((WORD32)0xfd21 << 16) | ((WORD32)0xfc45 & 0xFFFF), + ((WORD32)0x006b << 16) | ((WORD32)0xfdf3 & 0xFFFF), + ((WORD32)0x02f0 << 16) | ((WORD32)0xfce8 & 0xFFFF), + ((WORD32)0x0755 << 16) | ((WORD32)0xfd8e & 0xFFFF), + ((WORD32)0x0585 << 16) | ((WORD32)0x0747 & 0xFFFF), + ((WORD32)0xfce8 << 16) | ((WORD32)0x07f6 & 0xFFFF), + ((WORD32)0xfda9 << 16) | ((WORD32)0x02ff & 0xFFFF), + ((WORD32)0xfb2f << 16) | ((WORD32)0x06f1 & 0xFFFF), + ((WORD32)0xf835 << 16) | ((WORD32)0x07b8 & 0xFFFF), + ((WORD32)0x0714 << 16) | ((WORD32)0x049a & 0xFFFF), + ((WORD32)0x006a << 16) | ((WORD32)0x01b4 & 0xFFFF), + ((WORD32)0xfbb8 << 16) | ((WORD32)0x07c8 & 0xFFFF), + ((WORD32)0xfc0c << 16) | ((WORD32)0x07db & 0xFFFF), + ((WORD32)0xf816 << 16) | ((WORD32)0xfcc8 & 0xFFFF), + ((WORD32)0xf827 << 16) | ((WORD32)0xfa2c & 0xFFFF), + ((WORD32)0xfdd0 << 16) | ((WORD32)0x07ff & 0xFFFF), + ((WORD32)0x0081 << 16) | ((WORD32)0xfba3 & 0xFFFF), + ((WORD32)0xfe5d << 16) | ((WORD32)0xfedd & 0xFFFF), + ((WORD32)0x054c << 16) | ((WORD32)0x05cd & 0xFFFF), + ((WORD32)0xf938 << 16) | ((WORD32)0x0031 & 0xFFFF), + ((WORD32)0xf8e0 << 16) | ((WORD32)0x071c & 0xFFFF), + ((WORD32)0x07ac << 16) | ((WORD32)0x0624 & 0xFFFF), + ((WORD32)0x05e1 << 16) | ((WORD32)0xffb3 & 0xFFFF), + ((WORD32)0xfd76 << 16) | ((WORD32)0xfd0e & 0xFFFF), + ((WORD32)0xfd45 << 16) | ((WORD32)0x0338 & 0xFFFF), + ((WORD32)0x03d3 << 16) | ((WORD32)0xfcd9 & 0xFFFF), + ((WORD32)0x07dd << 16) | ((WORD32)0x0029 & 0xFFFF), + ((WORD32)0xfd86 << 16) | ((WORD32)0xfe8e & 0xFFFF), + ((WORD32)0x0800 << 16) | ((WORD32)0xfde6 & 0xFFFF), + ((WORD32)0xf88c << 16) | ((WORD32)0xf823 & 0xFFFF), + ((WORD32)0x07fe << 16) | ((WORD32)0xf997 & 0xFFFF), + ((WORD32)0xfdeb << 16) | ((WORD32)0xf9ec & 0xFFFF), + ((WORD32)0xfd25 << 16) | ((WORD32)0x018b & 0xFFFF), + ((WORD32)0xf802 << 16) | ((WORD32)0x05f9 & 0xFFFF), + ((WORD32)0x06ed << 16) | ((WORD32)0x0473 & 0xFFFF), + ((WORD32)0x02ac << 16) | ((WORD32)0x06e5 & 0xFFFF), + ((WORD32)0x07ec << 16) | ((WORD32)0x005e & 0xFFFF), + ((WORD32)0xfaaa << 16) | ((WORD32)0xf8ab & 0xFFFF), + ((WORD32)0x051f << 16) | ((WORD32)0x0141 & 0xFFFF), + ((WORD32)0x07f7 << 16) | ((WORD32)0x03ab & 0xFFFF), + ((WORD32)0xfaed << 16) | ((WORD32)0x01b0 & 0xFFFF), + ((WORD32)0xff62 << 16) | ((WORD32)0xf8d5 & 0xFFFF), + ((WORD32)0x07e3 << 16) | ((WORD32)0x070f & 0xFFFF), + ((WORD32)0x0668 << 16) | ((WORD32)0xfd0d & 0xFFFF), + ((WORD32)0x0645 << 16) | ((WORD32)0x03a4 & 0xFFFF), + ((WORD32)0x00b2 << 16) | ((WORD32)0x067a & 0xFFFF), + ((WORD32)0xf90e << 16) | ((WORD32)0x0326 & 0xFFFF), + ((WORD32)0xfcd8 << 16) | ((WORD32)0xfaa8 & 0xFFFF), + ((WORD32)0x07d4 << 16) | ((WORD32)0xfa34 & 0xFFFF), + ((WORD32)0xf866 << 16) | ((WORD32)0x072a & 0xFFFF), + ((WORD32)0x015c << 16) | ((WORD32)0x0460 & 0xFFFF), + ((WORD32)0xf9d9 << 16) | ((WORD32)0xf84d & 0xFFFF), + ((WORD32)0x07fb << 16) | ((WORD32)0x036a & 0xFFFF), + ((WORD32)0x07a3 << 16) | ((WORD32)0x07c3 & 0xFFFF), + ((WORD32)0x07f7 << 16) | ((WORD32)0xfbac & 0xFFFF), + ((WORD32)0x023f << 16) | ((WORD32)0xf92c & 0xFFFF), + ((WORD32)0x06d2 << 16) | ((WORD32)0xfad6 & 0xFFFF), + ((WORD32)0xfbf4 << 16) | ((WORD32)0xfabb & 0xFFFF), + ((WORD32)0xf839 << 16) | ((WORD32)0xfe27 & 0xFFFF), + ((WORD32)0x07a2 << 16) | ((WORD32)0xf810 & 0xFFFF), + ((WORD32)0xf83f << 16) | ((WORD32)0x05e7 & 0xFFFF), + ((WORD32)0x0278 << 16) | ((WORD32)0x0352 & 0xFFFF), + ((WORD32)0xfe0a << 16) | ((WORD32)0x050e & 0xFFFF), + ((WORD32)0xfd4c << 16) | ((WORD32)0xfce8 & 0xFFFF), + ((WORD32)0xff89 << 16) | ((WORD32)0xff72 & 0xFFFF), + ((WORD32)0xfe2b << 16) | ((WORD32)0x07c4 & 0xFFFF), + ((WORD32)0xfe85 << 16) | ((WORD32)0x03ce & 0xFFFF), + ((WORD32)0xff29 << 16) | ((WORD32)0xf8fa & 0xFFFF), + ((WORD32)0xfa40 << 16) | ((WORD32)0x063e & 0xFFFF), + ((WORD32)0x07fc << 16) | ((WORD32)0x0734 & 0xFFFF), + ((WORD32)0x049b << 16) | ((WORD32)0xf8b8 & 0xFFFF), + ((WORD32)0x0250 << 16) | ((WORD32)0x07b4 & 0xFFFF), + ((WORD32)0x0360 << 16) | ((WORD32)0x03da & 0xFFFF), + ((WORD32)0x0778 << 16) | ((WORD32)0xfc84 & 0xFFFF), + ((WORD32)0xf83c << 16) | ((WORD32)0x06ee & 0xFFFF), + ((WORD32)0x02f0 << 16) | ((WORD32)0x0539 & 0xFFFF), + ((WORD32)0xf983 << 16) | ((WORD32)0x00b4 & 0xFFFF), + ((WORD32)0xfde7 << 16) | ((WORD32)0xf894 & 0xFFFF), + ((WORD32)0x06b8 << 16) | ((WORD32)0x0478 & 0xFFFF), + ((WORD32)0xf802 << 16) | ((WORD32)0xf851 & 0xFFFF), + ((WORD32)0x05f9 << 16) | ((WORD32)0x00f9 & 0xFFFF), + ((WORD32)0xfa05 << 16) | ((WORD32)0xfdd9 & 0xFFFF), + ((WORD32)0x07aa << 16) | ((WORD32)0xf9ad & 0xFFFF), + ((WORD32)0x07a3 << 16) | ((WORD32)0xff50 & 0xFFFF), + ((WORD32)0x03e6 << 16) | ((WORD32)0x0800 & 0xFFFF), + ((WORD32)0x03b5 << 16) | ((WORD32)0x00e1 & 0xFFFF), + ((WORD32)0xf9e1 << 16) | ((WORD32)0x0723 & 0xFFFF), + ((WORD32)0x0497 << 16) | ((WORD32)0x02d3 & 0xFFFF), + ((WORD32)0x0608 << 16) | ((WORD32)0x07bd & 0xFFFF), + ((WORD32)0xfb44 << 16) | ((WORD32)0xf8d9 & 0xFFFF), + ((WORD32)0x0602 << 16) | ((WORD32)0xfda2 & 0xFFFF), + ((WORD32)0xf81d << 16) | ((WORD32)0x0201 & 0xFFFF), + ((WORD32)0xfcbd << 16) | ((WORD32)0xf8cc & 0xFFFF), + ((WORD32)0x055b << 16) | ((WORD32)0x07e4 & 0xFFFF), + ((WORD32)0xf834 << 16) | ((WORD32)0xfffc & 0xFFFF), + ((WORD32)0x0736 << 16) | ((WORD32)0x07fc & 0xFFFF), + ((WORD32)0xf905 << 16) | ((WORD32)0x07f0 & 0xFFFF), + ((WORD32)0xf8ad << 16) | ((WORD32)0xfebe & 0xFFFF), + ((WORD32)0xffbc << 16) | ((WORD32)0xfd06 & 0xFFFF), + ((WORD32)0x0094 << 16) | ((WORD32)0xf8e5 & 0xFFFF), + ((WORD32)0x07f6 << 16) | ((WORD32)0x07c4 & 0xFFFF), + ((WORD32)0xfa02 << 16) | ((WORD32)0x0800 & 0xFFFF), + ((WORD32)0x005e << 16) | ((WORD32)0x07fc & 0xFFFF), + ((WORD32)0xf8e0 << 16) | ((WORD32)0xfd75 & 0xFFFF), + ((WORD32)0xf94c << 16) | ((WORD32)0x07d0 & 0xFFFF), + ((WORD32)0x02ad << 16) | ((WORD32)0xf91a & 0xFFFF), + ((WORD32)0xf806 << 16) | ((WORD32)0x0776 & 0xFFFF), + ((WORD32)0xfe2c << 16) | ((WORD32)0x0183 & 0xFFFF), + ((WORD32)0x0561 << 16) | ((WORD32)0xffb5 & 0xFFFF), + ((WORD32)0xff97 << 16) | ((WORD32)0xf898 & 0xFFFF), + ((WORD32)0x07ff << 16) | ((WORD32)0x077d & 0xFFFF), + ((WORD32)0x055b << 16) | ((WORD32)0x07ea & 0xFFFF), + ((WORD32)0xf808 << 16) | ((WORD32)0xfc6d & 0xFFFF), + ((WORD32)0x0692 << 16) | ((WORD32)0x07f7 & 0xFFFF), + ((WORD32)0x07ef << 16) | ((WORD32)0x05c3 & 0xFFFF), + ((WORD32)0xfac7 << 16) | ((WORD32)0x042d & 0xFFFF), + ((WORD32)0x0783 << 16) | ((WORD32)0xfa02 & 0xFFFF), + ((WORD32)0x07bd << 16) | ((WORD32)0x0745 & 0xFFFF), + ((WORD32)0xfe39 << 16) | ((WORD32)0x0492 & 0xFFFF), + ((WORD32)0xfc78 << 16) | ((WORD32)0xf896 & 0xFFFF), + ((WORD32)0xf925 << 16) | ((WORD32)0x071c & 0xFFFF), + ((WORD32)0x0758 << 16) | ((WORD32)0xfc4b & 0xFFFF), + ((WORD32)0x05ce << 16) | ((WORD32)0xf802 & 0xFFFF), + ((WORD32)0xf806 << 16) | ((WORD32)0x04a8 & 0xFFFF), + ((WORD32)0x0636 << 16) | ((WORD32)0x078c & 0xFFFF), + ((WORD32)0x009e << 16) | ((WORD32)0x04b1 & 0xFFFF), + ((WORD32)0xfb84 << 16) | ((WORD32)0x069a & 0xFFFF), + ((WORD32)0x07df << 16) | ((WORD32)0x0328 & 0xFFFF), + ((WORD32)0x03ce << 16) | ((WORD32)0x057d & 0xFFFF), + ((WORD32)0x0541 << 16) | ((WORD32)0x0177 & 0xFFFF), + ((WORD32)0x0043 << 16) | ((WORD32)0xfa01 & 0xFFFF), + ((WORD32)0xfce8 << 16) | ((WORD32)0x041b & 0xFFFF), + ((WORD32)0xf836 << 16) | ((WORD32)0xf847 & 0xFFFF), + ((WORD32)0xfbbd << 16) | ((WORD32)0xf8b0 & 0xFFFF), + ((WORD32)0x07fc << 16) | ((WORD32)0x04e4 & 0xFFFF), + ((WORD32)0xfbfb << 16) | ((WORD32)0xf8e5 & 0xFFFF), + ((WORD32)0x0029 << 16) | ((WORD32)0x06d1 & 0xFFFF), + ((WORD32)0x07ff << 16) | ((WORD32)0x0791 & 0xFFFF), + ((WORD32)0x06a2 << 16) | ((WORD32)0xff7e & 0xFFFF), + ((WORD32)0xfb4f << 16) | ((WORD32)0x07bf & 0xFFFF), + ((WORD32)0xfe98 << 16) | ((WORD32)0xfc26 & 0xFFFF), + ((WORD32)0x06ad << 16) | ((WORD32)0xfef5 & 0xFFFF), + ((WORD32)0x007a << 16) | ((WORD32)0x01a4 & 0xFFFF), + ((WORD32)0x0685 << 16) | ((WORD32)0xf86d & 0xFFFF), + ((WORD32)0xfc67 << 16) | ((WORD32)0x0346 & 0xFFFF), + ((WORD32)0xf8d2 << 16) | ((WORD32)0x07fd & 0xFFFF), + ((WORD32)0x032d << 16) | ((WORD32)0xfa03 & 0xFFFF), + ((WORD32)0xff65 << 16) | ((WORD32)0x05ed & 0xFFFF), + ((WORD32)0x061c << 16) | ((WORD32)0x0357 & 0xFFFF), + ((WORD32)0xfa0a << 16) | ((WORD32)0x0794 & 0xFFFF), + ((WORD32)0x0531 << 16) | ((WORD32)0x034f & 0xFFFF), + ((WORD32)0x04fc << 16) | ((WORD32)0xf88d & 0xFFFF), + ((WORD32)0x0361 << 16) | ((WORD32)0xff62 & 0xFFFF), + ((WORD32)0x0037 << 16) | ((WORD32)0xff91 & 0xFFFF), + ((WORD32)0x0666 << 16) | ((WORD32)0x0753 & 0xFFFF), + ((WORD32)0xf9a7 << 16) | ((WORD32)0xfd1a & 0xFFFF), + ((WORD32)0x051c << 16) | ((WORD32)0x00a6 & 0xFFFF), + ((WORD32)0x043b << 16) | ((WORD32)0x04ce & 0xFFFF), + ((WORD32)0x05f0 << 16) | ((WORD32)0x005c & 0xFFFF), + ((WORD32)0x07ed << 16) | ((WORD32)0xfe72 & 0xFFFF), + ((WORD32)0xf991 << 16) | ((WORD32)0xf8eb & 0xFFFF), + ((WORD32)0xfad5 << 16) | ((WORD32)0x05c7 & 0xFFFF), + ((WORD32)0x00ef << 16) | ((WORD32)0xf94f & 0xFFFF), + ((WORD32)0xf865 << 16) | ((WORD32)0xf83f & 0xFFFF), + ((WORD32)0xfb06 << 16) | ((WORD32)0x069f & 0xFFFF), + ((WORD32)0x003e << 16) | ((WORD32)0xf805 & 0xFFFF), + ((WORD32)0xf829 << 16) | ((WORD32)0x02ec & 0xFFFF), + ((WORD32)0xf800 << 16) | ((WORD32)0xfd1e & 0xFFFF), + ((WORD32)0x0721 << 16) | ((WORD32)0xf82b & 0xFFFF), + ((WORD32)0x00d5 << 16) | ((WORD32)0x0630 & 0xFFFF), + ((WORD32)0x07ad << 16) | ((WORD32)0xfd2a & 0xFFFF), + ((WORD32)0x0411 << 16) | ((WORD32)0x07b0 & 0xFFFF), + ((WORD32)0x015c << 16) | ((WORD32)0xf9da & 0xFFFF), + ((WORD32)0x0212 << 16) | ((WORD32)0x07fe & 0xFFFF), + ((WORD32)0xffe9 << 16) | ((WORD32)0x07e1 & 0xFFFF), + ((WORD32)0xf9a2 << 16) | ((WORD32)0x07c5 & 0xFFFF), + ((WORD32)0xf80f << 16) | ((WORD32)0xf809 & 0xFFFF), + ((WORD32)0xf803 << 16) | ((WORD32)0x0026 & 0xFFFF), + ((WORD32)0xfa56 << 16) | ((WORD32)0x02b2 & 0xFFFF), + ((WORD32)0xfa5d << 16) | ((WORD32)0x0776 & 0xFFFF), + ((WORD32)0x07fd << 16) | ((WORD32)0xf81a & 0xFFFF), + ((WORD32)0xfaee << 16) | ((WORD32)0xfeaf & 0xFFFF), + ((WORD32)0xfeb3 << 16) | ((WORD32)0xf853 & 0xFFFF), + ((WORD32)0xfc82 << 16) | ((WORD32)0xf86a & 0xFFFF), + ((WORD32)0xf803 << 16) | ((WORD32)0x07b3 & 0xFFFF), + ((WORD32)0xfea8 << 16) | ((WORD32)0xf815 & 0xFFFF), + ((WORD32)0xf8f6 << 16) | ((WORD32)0xfa43 & 0xFFFF), + ((WORD32)0x0389 << 16) | ((WORD32)0xf884 & 0xFFFF), + ((WORD32)0x0777 << 16) | ((WORD32)0xf802 & 0xFFFF), + ((WORD32)0xf87c << 16) | ((WORD32)0xfb7d & 0xFFFF), + ((WORD32)0xf8ea << 16) | ((WORD32)0x03cf & 0xFFFF), + ((WORD32)0x07ff << 16) | ((WORD32)0xf94a & 0xFFFF), + ((WORD32)0xf9f8 << 16) | ((WORD32)0x0011 & 0xFFFF), + ((WORD32)0x0783 << 16) | ((WORD32)0xff19 & 0xFFFF), + ((WORD32)0x06cf << 16) | ((WORD32)0x0430 & 0xFFFF), + ((WORD32)0x032d << 16) | ((WORD32)0x068b & 0xFFFF), + ((WORD32)0xfd0a << 16) | ((WORD32)0xf909 & 0xFFFF), + ((WORD32)0xfd1e << 16) | ((WORD32)0x02c6 & 0xFFFF), + ((WORD32)0xf887 << 16) | ((WORD32)0xf93e & 0xFFFF), + ((WORD32)0xfac7 << 16) | ((WORD32)0xfe86 & 0xFFFF), + ((WORD32)0x00f5 << 16) | ((WORD32)0x07fe & 0xFFFF), + ((WORD32)0x078b << 16) | ((WORD32)0x06a7 & 0xFFFF), + ((WORD32)0x0602 << 16) | ((WORD32)0xfd28 & 0xFFFF), + ((WORD32)0x048a << 16) | ((WORD32)0xfe13 & 0xFFFF), + ((WORD32)0x03c0 << 16) | ((WORD32)0xfd97 & 0xFFFF), + ((WORD32)0x07c9 << 16) | ((WORD32)0xf809 & 0xFFFF), + ((WORD32)0xfcf0 << 16) | ((WORD32)0x07e2 & 0xFFFF), + ((WORD32)0x0348 << 16) | ((WORD32)0x002b & 0xFFFF), + ((WORD32)0x00c5 << 16) | ((WORD32)0x005a & 0xFFFF), + ((WORD32)0xf92d << 16) | ((WORD32)0x0751 & 0xFFFF), + ((WORD32)0x071c << 16) | ((WORD32)0xf805 & 0xFFFF), + ((WORD32)0xfc25 << 16) | ((WORD32)0xf841 & 0xFFFF), + ((WORD32)0x0235 << 16) | ((WORD32)0x04b1 & 0xFFFF), + ((WORD32)0xfabb << 16) | ((WORD32)0x04b5 & 0xFFFF), + ((WORD32)0x07e8 << 16) | ((WORD32)0x0800 & 0xFFFF), + ((WORD32)0xfe59 << 16) | ((WORD32)0x045e & 0xFFFF), + ((WORD32)0xfb08 << 16) | ((WORD32)0xfb35 & 0xFFFF), + ((WORD32)0x01a0 << 16) | ((WORD32)0xf90d & 0xFFFF), + ((WORD32)0xf82d << 16) | ((WORD32)0x07b4 & 0xFFFF), + ((WORD32)0x00e4 << 16) | ((WORD32)0x01b8 & 0xFFFF), + ((WORD32)0xfcb1 << 16) | ((WORD32)0x0242 & 0xFFFF), + ((WORD32)0x01ee << 16) | ((WORD32)0x041b & 0xFFFF), + ((WORD32)0xfab0 << 16) | ((WORD32)0xff57 & 0xFFFF), + ((WORD32)0xfbb4 << 16) | ((WORD32)0xf830 & 0xFFFF), + ((WORD32)0xf839 << 16) | ((WORD32)0x01c4 & 0xFFFF), + ((WORD32)0x06fe << 16) | ((WORD32)0xfefa & 0xFFFF), + ((WORD32)0x0186 << 16) | ((WORD32)0x0021 & 0xFFFF), + ((WORD32)0xfc4b << 16) | ((WORD32)0xf861 & 0xFFFF), + ((WORD32)0xff6f << 16) | ((WORD32)0xf871 & 0xFFFF), + ((WORD32)0xf89b << 16) | ((WORD32)0xff2a & 0xFFFF), + ((WORD32)0xf94b << 16) | ((WORD32)0xffdd & 0xFFFF), + ((WORD32)0x0604 << 16) | ((WORD32)0xf801 & 0xFFFF), + ((WORD32)0xfca2 << 16) | ((WORD32)0x07fa & 0xFFFF), + ((WORD32)0xfa3b << 16) | ((WORD32)0xfd33 & 0xFFFF), + ((WORD32)0x064f << 16) | ((WORD32)0x043a & 0xFFFF), + ((WORD32)0x07cb << 16) | ((WORD32)0xfddd & 0xFFFF), + ((WORD32)0x07f0 << 16) | ((WORD32)0xfb70 & 0xFFFF), + ((WORD32)0x0625 << 16) | ((WORD32)0xf9e1 & 0xFFFF), + ((WORD32)0xf971 << 16) | ((WORD32)0xfa1e & 0xFFFF), + ((WORD32)0x068e << 16) | ((WORD32)0x07fa & 0xFFFF), + ((WORD32)0xfddd << 16) | ((WORD32)0x0583 & 0xFFFF), + ((WORD32)0xfc89 << 16) | ((WORD32)0x06d3 & 0xFFFF), + ((WORD32)0x07f0 << 16) | ((WORD32)0x075a & 0xFFFF), + ((WORD32)0xf98b << 16) | ((WORD32)0xfd64 & 0xFFFF), + ((WORD32)0x0372 << 16) | ((WORD32)0xfe3f & 0xFFFF), + ((WORD32)0x056b << 16) | ((WORD32)0xf85d & 0xFFFF), + ((WORD32)0x047e << 16) | ((WORD32)0xfa58 & 0xFFFF), + ((WORD32)0x00de << 16) | ((WORD32)0xff4f & 0xFFFF), + ((WORD32)0x074c << 16) | ((WORD32)0xfab9 & 0xFFFF), + ((WORD32)0xfc15 << 16) | ((WORD32)0x0481 & 0xFFFF), + ((WORD32)0xf8e1 << 16) | ((WORD32)0xfa44 & 0xFFFF), + ((WORD32)0x0539 << 16) | ((WORD32)0x0546 & 0xFFFF), + ((WORD32)0x0565 << 16) | ((WORD32)0xf977 & 0xFFFF), + ((WORD32)0xfc2e << 16) | ((WORD32)0xfea8 & 0xFFFF), + ((WORD32)0xf806 << 16) | ((WORD32)0xf884 & 0xFFFF), + ((WORD32)0xf8bb << 16) | ((WORD32)0x04f6 & 0xFFFF), + ((WORD32)0xff78 << 16) | ((WORD32)0xfe18 & 0xFFFF), + ((WORD32)0x07f4 << 16) | ((WORD32)0x0181 & 0xFFFF), + ((WORD32)0x07d1 << 16) | ((WORD32)0xfdb5 & 0xFFFF), + ((WORD32)0x0796 << 16) | ((WORD32)0xf833 & 0xFFFF), + ((WORD32)0xf85e << 16) | ((WORD32)0xf9a2 & 0xFFFF), + ((WORD32)0xfc12 << 16) | ((WORD32)0x02a2 & 0xFFFF), + ((WORD32)0x07fe << 16) | ((WORD32)0x071f & 0xFFFF), + ((WORD32)0x0409 << 16) | ((WORD32)0xf91f & 0xFFFF), + ((WORD32)0x03c6 << 16) | ((WORD32)0xfe81 & 0xFFFF), + ((WORD32)0xfb09 << 16) | ((WORD32)0x0600 & 0xFFFF), + ((WORD32)0xfc7e << 16) | ((WORD32)0x0800 & 0xFFFF), + ((WORD32)0x07e4 << 16) | ((WORD32)0xfbb7 & 0xFFFF), + ((WORD32)0xfb14 << 16) | ((WORD32)0xf8d7 & 0xFFFF), + ((WORD32)0xffb1 << 16) | ((WORD32)0xfa69 & 0xFFFF), + ((WORD32)0xfd98 << 16) | ((WORD32)0xff63 & 0xFFFF), + ((WORD32)0x035a << 16) | ((WORD32)0x002d & 0xFFFF), + ((WORD32)0xf91c << 16) | ((WORD32)0x07ea & 0xFFFF), + ((WORD32)0x0561 << 16) | ((WORD32)0xfeec & 0xFFFF), + ((WORD32)0xfa57 << 16) | ((WORD32)0xf9e0 & 0xFFFF), + ((WORD32)0x0786 << 16) | ((WORD32)0x00b9 & 0xFFFF), + ((WORD32)0xf969 << 16) | ((WORD32)0x00b7 & 0xFFFF), + ((WORD32)0xfd6f << 16) | ((WORD32)0x0403 & 0xFFFF), + ((WORD32)0x049c << 16) | ((WORD32)0xf815 & 0xFFFF), + ((WORD32)0xfd18 << 16) | ((WORD32)0x0098 & 0xFFFF), + ((WORD32)0x0800 << 16) | ((WORD32)0xfedf & 0xFFFF), + ((WORD32)0xf89c << 16) | ((WORD32)0xf829 & 0xFFFF), + ((WORD32)0xfc6e << 16) | ((WORD32)0xfba9 & 0xFFFF), + ((WORD32)0x038a << 16) | ((WORD32)0x05b5 & 0xFFFF), + ((WORD32)0x004b << 16) | ((WORD32)0x0517 & 0xFFFF), + ((WORD32)0x042d << 16) | ((WORD32)0xf92b & 0xFFFF), + ((WORD32)0xf86d << 16) | ((WORD32)0xffdb & 0xFFFF), + ((WORD32)0xf819 << 16) | ((WORD32)0x0695 & 0xFFFF), + ((WORD32)0x06ff << 16) | ((WORD32)0x0727 & 0xFFFF), + ((WORD32)0xf887 << 16) | ((WORD32)0x034f & 0xFFFF), + ((WORD32)0x07af << 16) | ((WORD32)0x0773 & 0xFFFF), + ((WORD32)0x07ce << 16) | ((WORD32)0x06e4 & 0xFFFF), + ((WORD32)0x07f9 << 16) | ((WORD32)0x059d & 0xFFFF), + ((WORD32)0xf86c << 16) | ((WORD32)0xfda2 & 0xFFFF), + ((WORD32)0x0754 << 16) | ((WORD32)0xf826 & 0xFFFF), + + ((WORD32)0xf801 << 16) | ((WORD32)0xfb3e & 0xFFFF), + ((WORD32)0x07c5 << 16) | ((WORD32)0xfa99 & 0xFFFF), + ((WORD32)0x0121 << 16) | ((WORD32)0xf865 & 0xFFFF), + ((WORD32)0xfc3d << 16) | ((WORD32)0xfd03 & 0xFFFF), + ((WORD32)0x0675 << 16) | ((WORD32)0x025f & 0xFFFF), + ((WORD32)0xfce2 << 16) | ((WORD32)0x072a & 0xFFFF), + ((WORD32)0xffea << 16) | ((WORD32)0xfaa5 & 0xFFFF), + ((WORD32)0xf8b3 << 16) | ((WORD32)0xff14 & 0xFFFF), + ((WORD32)0x0463 << 16) | ((WORD32)0x0605 & 0xFFFF), + ((WORD32)0x0333 << 16) | ((WORD32)0xf816 & 0xFFFF), + ((WORD32)0xf803 << 16) | ((WORD32)0xf8f3 & 0xFFFF), + ((WORD32)0xf85c << 16) | ((WORD32)0x0746 & 0xFFFF), + ((WORD32)0xfc58 << 16) | ((WORD32)0xfb76 & 0xFFFF), + ((WORD32)0xfa2a << 16) | ((WORD32)0xf829 & 0xFFFF), + ((WORD32)0x060d << 16) | ((WORD32)0x01ad & 0xFFFF), + ((WORD32)0x0091 << 16) | ((WORD32)0xf9bd & 0xFFFF), + ((WORD32)0x05f6 << 16) | ((WORD32)0xf8b5 & 0xFFFF), + ((WORD32)0xf849 << 16) | ((WORD32)0xf86c & 0xFFFF), + ((WORD32)0x026f << 16) | ((WORD32)0xfc0c & 0xFFFF), + ((WORD32)0x0553 << 16) | ((WORD32)0x052c & 0xFFFF), + ((WORD32)0x0756 << 16) | ((WORD32)0x0167 & 0xFFFF), + ((WORD32)0xfa57 << 16) | ((WORD32)0x0434 & 0xFFFF), + ((WORD32)0xfa65 << 16) | ((WORD32)0xfc5f & 0xFFFF), + ((WORD32)0xf80a << 16) | ((WORD32)0xf8cb & 0xFFFF), + ((WORD32)0x07da << 16) | ((WORD32)0xf9ce & 0xFFFF), + ((WORD32)0xfba0 << 16) | ((WORD32)0xffcb & 0xFFFF), + ((WORD32)0xffdd << 16) | ((WORD32)0x0006 & 0xFFFF), + ((WORD32)0xf91c << 16) | ((WORD32)0x0367 & 0xFFFF), + ((WORD32)0xf817 << 16) | ((WORD32)0xf8f8 & 0xFFFF), + ((WORD32)0x0424 << 16) | ((WORD32)0x055b & 0xFFFF), + ((WORD32)0xf807 << 16) | ((WORD32)0xfb5a & 0xFFFF), + ((WORD32)0xf801 << 16) | ((WORD32)0x07df & 0xFFFF), + ((WORD32)0x046c << 16) | ((WORD32)0x04c2 & 0xFFFF), + ((WORD32)0x02c4 << 16) | ((WORD32)0x0797 & 0xFFFF), + ((WORD32)0x0503 << 16) | ((WORD32)0xfa0c & 0xFFFF), + ((WORD32)0xf9d4 << 16) | ((WORD32)0xfd4a & 0xFFFF), + ((WORD32)0xf8ac << 16) | ((WORD32)0x004c & 0xFFFF), + ((WORD32)0xf9e6 << 16) | ((WORD32)0xf8b1 & 0xFFFF), + ((WORD32)0x0662 << 16) | ((WORD32)0xf88c & 0xFFFF), + ((WORD32)0x045c << 16) | ((WORD32)0xff0c & 0xFFFF), + ((WORD32)0xf926 << 16) | ((WORD32)0x0365 & 0xFFFF), + ((WORD32)0xf892 << 16) | ((WORD32)0x023b & 0xFFFF), + ((WORD32)0xff10 << 16) | ((WORD32)0xf804 & 0xFFFF), + ((WORD32)0x01b5 << 16) | ((WORD32)0xf8be & 0xFFFF), + ((WORD32)0xf9e8 << 16) | ((WORD32)0x07fb & 0xFFFF), + ((WORD32)0x07d9 << 16) | ((WORD32)0xf855 & 0xFFFF), + ((WORD32)0xf920 << 16) | ((WORD32)0x07a9 & 0xFFFF), + ((WORD32)0xf889 << 16) | ((WORD32)0x03f4 & 0xFFFF)} + +}; + +const ia_qmf_dec_tables_struct ixheaacd_aac_qmf_dec_tables = { + + // const WORD16 w_32[2 * 30] = + {0, 32767, 0, 32767, 0, 32767, 6393, 32138, 12540, + 30274, 18205, 27246, 12540, 30274, 23170, 23170, 30274, 12540, + 18205, 27246, 30274, 12540, 32138, -6393, 23170, 23170, 32767, + 0, 23170, -23170, 27246, 18205, 30274, -12540, 6393, -32138, + 30274, 12540, 23170, -23170, -12540, -30274, 32138, 6393, 12540, + -30274, -27246, -18205, 0, 32767, 0, 32767, 0, 32767, + 23170, 23170, 32767, 0, 23170, -23170}, + + // const WORD16 w_16[2 * 12] = + {0, 32767, 0, 32767, 0, 32767, 12540, 30274, + 23170, 23170, 30274, 12540, 23170, 23170, 32767, 0, + 23170, -23170, 30274, 12540, 23170, -23170, -12540, -30274}, + + // const WORD32 ixheaacd_dig_rev_table2_32[4]= + {0, 64, 16, 80}, + + // const WORD32 ixheaacd_dig_rev_table4_16[2]= + {0, 16}, + + // const WORD16 ixheaacd_sbr_sin_twiddle_l64 and + // ixheaacd_sbr_cos_twiddle_l64 [32] = + { + (WORD16)0x0192, (WORD16)0x7ffe, (WORD16)0x7fea, (WORD16)0x04b6, + (WORD16)0x07d9, (WORD16)0x7fc2, (WORD16)0x7f87, (WORD16)0x0afb, + (WORD16)0x0e1c, (WORD16)0x7f38, (WORD16)0x7ed6, (WORD16)0x113a, + (WORD16)0x1455, (WORD16)0x7e60, (WORD16)0x7dd6, (WORD16)0x176e, + (WORD16)0x1a83, (WORD16)0x7d3a, (WORD16)0x7c89, (WORD16)0x1d93, + (WORD16)0x209f, (WORD16)0x7bc6, (WORD16)0x7aef, (WORD16)0x23a7, + (WORD16)0x26a8, (WORD16)0x7a06, (WORD16)0x790a, (WORD16)0x29a4, + (WORD16)0x2c99, (WORD16)0x77fb, (WORD16)0x76d9, (WORD16)0x2f87, + (WORD16)0x326e, (WORD16)0x75a6, (WORD16)0x7460, (WORD16)0x354e, + (WORD16)0x3825, (WORD16)0x7308, (WORD16)0x719e, (WORD16)0x3af3, + (WORD16)0x3db8, (WORD16)0x7023, (WORD16)0x6e97, (WORD16)0x4074, + (WORD16)0x4326, (WORD16)0x6cf9, (WORD16)0x6b4b, (WORD16)0x45cd, + (WORD16)0x486a, (WORD16)0x698c, (WORD16)0x67bd, (WORD16)0x4afb, + (WORD16)0x4d81, (WORD16)0x65de, (WORD16)0x63ef, (WORD16)0x4ffb, + (WORD16)0x5269, (WORD16)0x61f1, (WORD16)0x5fe4, (WORD16)0x54ca, + (WORD16)0x571e, (WORD16)0x5dc8, (WORD16)0x5b9d, (WORD16)0x5964, + + }, + // WORD16 sbr_alt_sin_twiddle_l64[32]; + { + // (WORD16)0x0000, (WORD16)0x7fff, + (WORD16)0x0648, (WORD16)0x7fd9, (WORD16)0x0c8c, (WORD16)0x7f62, + (WORD16)0x12c8, (WORD16)0x7e9d, (WORD16)0x18f9, (WORD16)0x7d8a, + (WORD16)0x1f1a, (WORD16)0x7c2a, (WORD16)0x2528, (WORD16)0x7a7d, + (WORD16)0x2b1f, (WORD16)0x7885, (WORD16)0x30fc, (WORD16)0x7642, + (WORD16)0x36ba, (WORD16)0x73b6, (WORD16)0x3c57, (WORD16)0x70e3, + (WORD16)0x41ce, (WORD16)0x6dca, (WORD16)0x471d, (WORD16)0x6a6e, + (WORD16)0x4c40, (WORD16)0x66d0, (WORD16)0x5134, (WORD16)0x62f2, + (WORD16)0x55f6, (WORD16)0x5ed7, (WORD16)0x5a82, (WORD16)0x5a82, + + }, + + // const WORD16 ixheaacd_sbr_cos_sin_twiddle_ds_l32[32+32] = + {(WORD16)0x7ffe, (WORD16)0x0192, (WORD16)0x7fea, (WORD16)0x04b6, + (WORD16)0x7fc2, (WORD16)0x07d9, (WORD16)0x7f87, (WORD16)0x0afb, + (WORD16)0x7f38, (WORD16)0x0e1c, (WORD16)0x7ed6, (WORD16)0x113a, + (WORD16)0x7e60, (WORD16)0x1455, (WORD16)0x7dd6, (WORD16)0x176e, + (WORD16)0x7d3a, (WORD16)0x1a83, (WORD16)0x7c89, (WORD16)0x1d93, + (WORD16)0x7bc6, (WORD16)0x209f, (WORD16)0x7aef, (WORD16)0x23a7, + (WORD16)0x7a06, (WORD16)0x26a8, (WORD16)0x790a, (WORD16)0x29a4, + (WORD16)0x77fb, (WORD16)0x2c99, (WORD16)0x76d9, (WORD16)0x2f87, + (WORD16)0x75a6, (WORD16)0x326e, (WORD16)0x7460, (WORD16)0x354e, + (WORD16)0x7308, (WORD16)0x3825, (WORD16)0x719e, (WORD16)0x3af3, + (WORD16)0x7023, (WORD16)0x3db8, (WORD16)0x6e97, (WORD16)0x4074, + (WORD16)0x6cf9, (WORD16)0x4326, (WORD16)0x6b4b, (WORD16)0x45cd, + (WORD16)0x698c, (WORD16)0x486a, (WORD16)0x67bd, (WORD16)0x4afb, + (WORD16)0x65de, (WORD16)0x4d81, (WORD16)0x63ef, (WORD16)0x4ffb, + (WORD16)0x61f1, (WORD16)0x5269, (WORD16)0x5fe4, (WORD16)0x54ca, + (WORD16)0x5dc8, (WORD16)0x571e, (WORD16)0x5b9d, (WORD16)0x5964}, + + // const WORD16 ixheaacd_sbr_cos_twiddle_l32 and + // ixheaacd_sbr_sin_twiddle_l32[16]= + { + (WORD16)0x0324, (WORD16)0x7ff6, (WORD16)0x7fa7, (WORD16)0x096b, + (WORD16)0x0fab, (WORD16)0x7f0a, (WORD16)0x7e1e, (WORD16)0x15e2, + (WORD16)0x1c0c, (WORD16)0x7ce4, (WORD16)0x7b5d, (WORD16)0x2224, + (WORD16)0x2827, (WORD16)0x798a, (WORD16)0x776c, (WORD16)0x2e11, + (WORD16)0x33df, (WORD16)0x7505, (WORD16)0x7255, (WORD16)0x398d, + (WORD16)0x3f17, (WORD16)0x6f5f, (WORD16)0x6c24, (WORD16)0x447b, + (WORD16)0x49b4, (WORD16)0x68a7, (WORD16)0x64e9, (WORD16)0x4ec0, + (WORD16)0x539b, (WORD16)0x60ec, (WORD16)0x5cb4, (WORD16)0x5843, + + }, + // const WORD16 ixheaacd_sbr_alt_sin_twiddle_l32[17] = + { + //(WORD16)0x0000, (WORD16)0x7fff, + (WORD16)0x0c8c, (WORD16)0x7f62, (WORD16)0x18f9, (WORD16)0x7d8a, + (WORD16)0x2528, (WORD16)0x7a7d, (WORD16)0x30fc, (WORD16)0x7642, + (WORD16)0x3c57, (WORD16)0x70e3, (WORD16)0x471d, (WORD16)0x6a6e, + (WORD16)0x5134, (WORD16)0x62f2, (WORD16)0x5a82, (WORD16)0x5a82, + + }, + // const WORD16 ixheaacd_sbr_t_cos_sin_l32[32+32] = //exp[-i * pi/32* 3/4 * + // (k +0.5)] + {(WORD16)0x7fea, (WORD16)0x04b6, (WORD16)0x7f38, (WORD16)0x0e1c, + (WORD16)0x7dd6, (WORD16)0x176e, (WORD16)0x7bc6, (WORD16)0x209f, + (WORD16)0x790a, (WORD16)0x29a4, (WORD16)0x75a6, (WORD16)0x326e, + (WORD16)0x719e, (WORD16)0x3af3, (WORD16)0x6cf9, (WORD16)0x4326, + (WORD16)0x67bd, (WORD16)0x4afb, (WORD16)0x61f1, (WORD16)0x5269, + (WORD16)0x5b9d, (WORD16)0x5964, (WORD16)0x54ca, (WORD16)0x5fe4, + (WORD16)0x4d81, (WORD16)0x65de, (WORD16)0x45cd, (WORD16)0x6b4b, + (WORD16)0x3db8, (WORD16)0x7023, (WORD16)0x354e, (WORD16)0x7460, + (WORD16)0x2c99, (WORD16)0x77fb, (WORD16)0x23a7, (WORD16)0x7aef, + (WORD16)0x1a83, (WORD16)0x7d3a, (WORD16)0x113a, (WORD16)0x7ed6, + (WORD16)0x07d9, (WORD16)0x7fc2, (WORD16)-0x0192, (WORD16)0x7ffe, + (WORD16)-0x0afb, (WORD16)0x7f87, (WORD16)-0x1455, (WORD16)0x7e60, + (WORD16)-0x1d93, (WORD16)0x7c89, (WORD16)-0x26a8, (WORD16)0x7a06, + (WORD16)-0x2f87, (WORD16)0x76d9, (WORD16)-0x3825, (WORD16)0x7308, + (WORD16)-0x4074, (WORD16)0x6e97, (WORD16)-0x486a, (WORD16)0x698c, + (WORD16)-0x4ffb, (WORD16)0x63ef, (WORD16)-0x571e, (WORD16)0x5dc8}, + + // const WORD16 ixheeaacd_post_fft_tw_tab[17] = + {32767, 32610, 32138, 31357, 30274, 28899, 27246, 25330, 23170, 20788, + 18205, 15447, 12540, 9512, 6393, 3212, 0}, + + // const WORD16 ixheaacd_dct23_tw[66] = + {0, 0, 32758, 804, 32729, 1608, 32679, 2411, 32610, 3212, + 32522, 4011, 32413, 4808, 32286, 5602, 32138, 6393, 31972, 7180, + 31786, 7962, 31581, 8740, 31357, 9512, 31114, 10279, 30853, 11039, + 30572, 11793, 30274, 12540, 29957, 13279, 29622, 14010, 29269, 14733, + 28899, 15447, 28511, 16151, 28106, 16846, 27684, 17531, 27246, 18205, + 26791, 18868, 26320, 19520, 25833, 20160, 25330, 20788, 24812, 21403, + 24279, 22006, 23732, 22595, 23170, 23170}, + + // const WORD16 qmf_c[1280] = + {0, -18, -18, -16, -16, -16, -17, -17, -18, + -19, -19, -20, -21, -21, -22, -23, -23, -24, + -24, -25, -25, -25, -26, -25, -26, -26, -25, + -25, -25, -24, -24, -23, -22, -21, -19, -18, + -17, -15, -13, -11, -9, -7, -5, -2, 0, + 4, 7, 10, 13, 17, 20, 24, 28, 32, + 37, 41, 46, 51, 55, 60, 65, 70, 75, + 81, 86, 91, 97, 102, 107, 113, 118, 123, + 128, 134, 138, 143, 148, 153, 157, 161, 165, + 168, 172, 175, 178, 180, 182, 183, 184, 185, + 185, 184, 183, 182, 179, 176, 173, 168, 163, + 158, 151, 144, 135, 126, 116, 105, 93, 80, + 66, 52, 36, 19, 1, -18, -38, -59, -81, + -105, -129, -155, -181, -209, -238, -268, -299, -331, + -365, -399, 435, 472, 509, 548, 588, 629, 670, + 713, 756, 800, 845, 891, 937, 985, 1032, 1081, + 1129, 1179, 1228, 1278, 1328, 1378, 1429, 1479, 1530, + 1580, 1630, 1680, 1729, 1778, 1826, 1873, 1920, 1966, + 2010, 2054, 2096, 2137, 2177, 2215, 2251, 2286, 2319, + 2349, 2378, 2404, 2428, 2449, 2468, 2484, 2497, 2507, + 2514, 2517, 2517, 2514, 2507, 2496, 2482, 2463, 2440, + 2413, 2381, 2346, 2305, 2260, 2210, 2155, 2095, 2030, + 1960, 1885, 1804, 1717, 1625, 1528, 1425, 1315, 1201, + 1080, 953, 820, 682, 536, 385, 228, 65, -105, + -281, -463, -652, -846, -1047, -1254, -1467, -1687, -1913, + -2144, -2382, -2626, -2876, -3131, -3393, -3660, -3932, -4211, + -4494, -4783, -5078, -5377, -5681, -5991, -6304, -6623, -6946, + -7273, -7604, -7940, -8279, -8621, -8967, -9317, -9669, -10024, + -10382, -10742, -11104, -11469, 11834, 12202, 12571, 12941, 13311, + 13683, 14055, 14426, 14798, 15169, 15540, 15910, 16278, 16646, + 17011, 17374, 17736, 18095, 18451, 18804, 19154, 19501, 19844, + 20182, 20517, 20847, 21172, 21493, 21808, 22117, 22421, 22719, + 23011, 23296, 23575, 23847, 24111, 24369, 24619, 24861, 25096, + 25322, 25540, 25750, 25951, 26144, 26327, 26502, 26667, 26823, + 26969, 27107, 27234, 27351, 27459, 27556, 27644, 27721, 27788, + 27846, 27892, 27928, 27954, 27970, 27975, 27970, 27954, 27928, + 27892, 27846, 27788, 27721, 27644, 27556, 27459, 27351, 27234, + 27107, 26969, 26823, 26667, 26502, 26327, 26144, 25951, 25750, + 25540, 25322, 25096, 24861, 24619, 24369, 24111, 23847, 23575, + 23296, 23011, 22719, 22421, 22117, 21808, 21493, 21172, 20847, + 20517, 20182, 19844, 19501, 19154, 18804, 18451, 18095, 17736, + 17374, 17011, 16646, 16278, 15910, 15540, 15169, 14798, 14426, + 14055, 13683, 13311, 12941, 12571, 12202, -11834, -11469, -11104, + -10742, -10382, -10024, -9669, -9317, -8967, -8621, -8279, -7940, + -7604, -7273, -6946, -6623, -6304, -5991, -5681, -5377, -5078, + -4783, -4494, -4211, -3932, -3660, -3393, -3131, -2876, -2626, + -2382, -2144, -1913, -1687, -1467, -1254, -1047, -846, -652, + -463, -281, -105, 65, 228, 385, 536, 682, 820, + 953, 1080, 1201, 1315, 1425, 1528, 1625, 1717, 1804, + 1885, 1960, 2030, 2095, 2155, 2210, 2260, 2305, 2346, + 2381, 2413, 2440, 2463, 2482, 2496, 2507, 2514, 2517, + 2517, 2514, 2507, 2497, 2484, 2468, 2449, 2428, 2404, + 2378, 2349, 2319, 2286, 2251, 2215, 2177, 2137, 2096, + 2054, 2010, 1966, 1920, 1873, 1826, 1778, 1729, 1680, + 1630, 1580, 1530, 1479, 1429, 1378, 1328, 1278, 1228, + 1179, 1129, 1081, 1032, 985, 937, 891, 845, 800, + 756, 713, 670, 629, 588, 548, 509, 472, -435, + -399, -365, -331, -299, -268, -238, -209, -181, -155, + -129, -105, -81, -59, -38, -18, 1, 19, 36, + 52, 66, 80, 93, 105, 116, 126, 135, 144, + 151, 158, 163, 168, 173, 176, 179, 182, 183, + 184, 185, 185, 184, 183, 182, 180, 178, 175, + 172, 168, 165, 161, 157, 153, 148, 143, 138, + 134, 128, 123, 118, 113, 107, 102, 97, 91, + 86, 81, 75, 70, 65, 60, 55, 51, 46, + 41, 37, 32, 28, 24, 20, 17, 13, 10, + 7, 4, 0, -2, -5, -7, -9, -11, -13, + -15, -17, -18, -19, -21, -22, -23, -24, -24, + -25, -25, -25, -26, -26, -25, -26, -25, -25, + -25, -24, -24, -23, -23, -22, -21, -21, -20, + -19, -19, -18, -17, -17, -16, -16, -16, -18, + -18, 0, -18, -18, -16, -16, -16, -17, -17, + -18, -19, -19, -20, -21, -21, -22, -23, -23, + -24, -24, -25, -25, -25, -26, -25, -26, -26, + -25, -25, -25, -24, -24, -23, -22, -21, -19, + -18, -17, -15, -13, -11, -9, -7, -5, -2, + 0, 4, 7, 10, 13, 17, 20, 24, 28, + 32, 37, 41, 46, 51, 55, 60, 65, 70, + 75, 81, 86, 91, 97, 102, 107, 113, 118, + 123, 128, 134, 138, 143, 148, 153, 157, 161, + 165, 168, 172, 175, 178, 180, 182, 183, 184, + 185, 185, 184, 183, 182, 179, 176, 173, 168, + 163, 158, 151, 144, 135, 126, 116, 105, 93, + 80, 66, 52, 36, 19, 1, -18, -38, -59, + -81, -105, -129, -155, -181, -209, -238, -268, -299, + -331, -365, -399, 435, 472, 509, 548, 588, 629, + 670, 713, 756, 800, 845, 891, 937, 985, 1032, + 1081, 1129, 1179, 1228, 1278, 1328, 1378, 1429, 1479, + 1530, 1580, 1630, 1680, 1729, 1778, 1826, 1873, 1920, + 1966, 2010, 2054, 2096, 2137, 2177, 2215, 2251, 2286, + 2319, 2349, 2378, 2404, 2428, 2449, 2468, 2484, 2497, + 2507, 2514, 2517, 2517, 2514, 2507, 2496, 2482, 2463, + 2440, 2413, 2381, 2346, 2305, 2260, 2210, 2155, 2095, + 2030, 1960, 1885, 1804, 1717, 1625, 1528, 1425, 1315, + 1201, 1080, 953, 820, 682, 536, 385, 228, 65, + -105, -281, -463, -652, -846, -1047, -1254, -1467, -1687, + -1913, -2144, -2382, -2626, -2876, -3131, -3393, -3660, -3932, + -4211, -4494, -4783, -5078, -5377, -5681, -5991, -6304, -6623, + -6946, -7273, -7604, -7940, -8279, -8621, -8967, -9317, -9669, + -10024, -10382, -10742, -11104, -11469, 11834, 12202, 12571, 12941, + 13311, 13683, 14055, 14426, 14798, 15169, 15540, 15910, 16278, + 16646, 17011, 17374, 17736, 18095, 18451, 18804, 19154, 19501, + 19844, 20182, 20517, 20847, 21172, 21493, 21808, 22117, 22421, + 22719, 23011, 23296, 23575, 23847, 24111, 24369, 24619, 24861, + 25096, 25322, 25540, 25750, 25951, 26144, 26327, 26502, 26667, + 26823, 26969, 27107, 27234, 27351, 27459, 27556, 27644, 27721, + 27788, 27846, 27892, 27928, 27954, 27970, 27975, 27970, 27954, + 27928, 27892, 27846, 27788, 27721, 27644, 27556, 27459, 27351, + 27234, 27107, 26969, 26823, 26667, 26502, 26327, 26144, 25951, + 25750, 25540, 25322, 25096, 24861, 24619, 24369, 24111, 23847, + 23575, 23296, 23011, 22719, 22421, 22117, 21808, 21493, 21172, + 20847, 20517, 20182, 19844, 19501, 19154, 18804, 18451, 18095, + 17736, 17374, 17011, 16646, 16278, 15910, 15540, 15169, 14798, + 14426, 14055, 13683, 13311, 12941, 12571, 12202, -11834, -11469, + -11104, -10742, -10382, -10024, -9669, -9317, -8967, -8621, -8279, + -7940, -7604, -7273, -6946, -6623, -6304, -5991, -5681, -5377, + -5078, -4783, -4494, -4211, -3932, -3660, -3393, -3131, -2876, + -2626, -2382, -2144, -1913, -1687, -1467, -1254, -1047, -846, + -652, -463, -281, -105, 65, 228, 385, 536, 682, + 820, 953, 1080, 1201, 1315, 1425, 1528, 1625, 1717, + 1804, 1885, 1960, 2030, 2095, 2155, 2210, 2260, 2305, + 2346, 2381, 2413, 2440, 2463, 2482, 2496, 2507, 2514, + 2517, 2517, 2514, 2507, 2497, 2484, 2468, 2449, 2428, + 2404, 2378, 2349, 2319, 2286, 2251, 2215, 2177, 2137, + 2096, 2054, 2010, 1966, 1920, 1873, 1826, 1778, 1729, + 1680, 1630, 1580, 1530, 1479, 1429, 1378, 1328, 1278, + 1228, 1179, 1129, 1081, 1032, 985, 937, 891, 845, + 800, 756, 713, 670, 629, 588, 548, 509, 472, + -435, -399, -365, -331, -299, -268, -238, -209, -181, + -155, -129, -105, -81, -59, -38, -18, 1, 19, + 36, 52, 66, 80, 93, 105, 116, 126, 135, + 144, 151, 158, 163, 168, 173, 176, 179, 182, + 183, 184, 185, 185, 184, 183, 182, 180, 178, + 175, 172, 168, 165, 161, 157, 153, 148, 143, + 138, 134, 128, 123, 118, 113, 107, 102, 97, + 91, 86, 81, 75, 70, 65, 60, 55, 51, + 46, 41, 37, 32, 28, 24, 20, 17, 13, + 10, 7, 4, 0, -2, -5, -7, -9, -11, + -13, -15, -17, -18, -19, -21, -22, -23, -24, + -24, -25, -25, -25, -26, -26, -25, -26, -25, + -25, -25, -24, -24, -23, -23, -22, -21, -21, + -20, -19, -19, -18, -17, -17, -16, -16, -16, + -18, -18}, + + { + 0x00, 0x01, 0x02, 0x03, + }, + + // w1024[1536]; + { + 0x00007fff, 0xff377fff, 0xfe6e7ffe, 0xfda57ffa, 0xfcdc7ff6, 0xfc137ff1, + 0xfb4a7fea, 0xfa817fe2, 0xf9b87fd9, 0xf8ef7fce, 0xf8277fc2, 0xf75e7fb5, + 0xf6957fa7, 0xf5cd7f98, 0xf5057f87, 0xf43c7f75, 0xf3747f62, 0xf2ac7f4e, + 0xf1e47f38, 0xf11c7f22, 0xf0557f0a, 0xef8d7ef0, 0xeec67ed6, 0xedff7eba, + 0xed387e9d, 0xec717e7f, 0xebab7e60, 0xeae47e3f, 0xea1e7e1e, 0xe9587dfb, + 0xe8927dd6, 0xe7cd7db1, 0xe7077d8a, 0xe6427d63, 0xe57d7d3a, 0xe4b97d0f, + 0xe3f47ce4, 0xe3307cb7, 0xe26d7c89, 0xe1a97c5a, 0xe0e67c2a, 0xe0237bf9, + 0xdf617bc6, 0xde9e7b92, 0xdddc7b5d, 0xdd1b7b27, 0xdc597aef, 0xdb997ab7, + 0xdad87a7d, 0xda187a42, 0xd9587a06, 0xd89879c9, 0xd7d9798a, 0xd71b794a, + 0xd65c790a, 0xd59e78c8, 0xd4e17885, 0xd4247840, 0xd36777fb, 0xd2ab77b4, + 0xd1ef776c, 0xd1347723, 0xd07976d9, 0xcfbe768e, 0xcf047642, 0xce4b75f4, + 0xcd9275a6, 0xccd97556, 0xcc217505, 0xcb6974b3, 0xcab27460, 0xc9fc740b, + 0xc94673b6, 0xc890735f, 0xc7db7308, 0xc72772af, 0xc6737255, 0xc5c071fa, + 0xc50d719e, 0xc45b7141, 0xc3a970e3, 0xc2f87083, 0xc2487023, 0xc1986fc2, + 0xc0e96f5f, 0xc03a6efb, 0xbf8c6e97, 0xbedf6e31, 0xbe326dca, 0xbd866d62, + 0xbcda6cf9, 0xbc2f6c8f, 0xbb856c24, 0xbadc6bb8, 0xba336b4b, 0xb98b6add, + 0xb8e36a6e, 0xb83c69fd, 0xb796698c, 0xb6f1691a, 0xb64c68a7, 0xb5a86832, + 0xb50567bd, 0xb4626747, 0xb3c066d0, 0xb31f6657, 0xb27f65de, 0xb1df6564, + 0xb14064e9, 0xb0a2646c, 0xb00563ef, 0xaf686371, 0xaecc62f2, 0xae316272, + 0xad9761f1, 0xacfd616f, 0xac6560ec, 0xabcd6068, 0xab365fe4, 0xaaa05f5e, + 0xaa0a5ed7, 0xa9765e50, 0xa8e25dc8, 0xa84f5d3e, 0xa7bd5cb4, 0xa72c5c29, + 0xa69c5b9d, 0xa60c5b10, 0xa57e5a82, 0xa4f059f4, 0xa4635964, 0xa3d758d4, + 0xa34c5843, 0xa2c257b1, 0xa238571e, 0xa1b0568a, 0xa12955f6, 0xa0a25560, + 0xa01c54ca, 0x9f985433, 0x9f14539b, 0x9e915303, 0x9e0f5269, 0x9d8e51cf, + 0x9d0e5134, 0x9c8f5098, 0x9c114ffb, 0x9b944f5e, 0x9b174ec0, 0x9a9c4e21, + 0x9a224d81, 0x99a94ce1, 0x99304c40, 0x98b94b9e, 0x98434afb, 0x97ce4a58, + 0x975949b4, 0x96e6490f, 0x9674486a, 0x960347c4, 0x9592471d, 0x95234675, + 0x94b545cd, 0x94484524, 0x93dc447b, 0x937143d1, 0x93074326, 0x929e427a, + 0x923641ce, 0x91cf4121, 0x91694074, 0x91053fc6, 0x90a13f17, 0x903e3e68, + 0x8fdd3db8, 0x8f7d3d08, 0x8f1d3c57, 0x8ebf3ba5, 0x8e623af3, 0x8e063a40, + 0x8dab398d, 0x8d5138d9, 0x8cf83825, 0x8ca13770, 0x8c4a36ba, 0x8bf53604, + 0x8ba0354e, 0x8b4d3497, 0x8afb33df, 0x8aaa3327, 0x8a5a326e, 0x8a0c31b5, + 0x89be30fc, 0x89723042, 0x89272f87, 0x88dd2ecc, 0x88942e11, 0x884c2d55, + 0x88052c99, 0x87c02bdc, 0x877b2b1f, 0x87382a62, 0x86f629a4, 0x86b628e5, + 0x86762827, 0x86372768, 0x85fa26a8, 0x85be25e8, 0x85832528, 0x85492467, + 0x851123a7, 0x84d922e5, 0x84a32224, 0x846e2162, 0x843a209f, 0x84071fdd, + 0x83d61f1a, 0x83a61e57, 0x83771d93, 0x83491cd0, 0x831c1c0c, 0x82f11b47, + 0x82c61a83, 0x829d19be, 0x827618f9, 0x824f1833, 0x822a176e, 0x820516a8, + 0x81e215e2, 0x81c1151c, 0x81a01455, 0x8181138f, 0x816312c8, 0x81461201, + 0x812a113a, 0x81101073, 0x80f60fab, 0x80de0ee4, 0x80c80e1c, 0x80b20d54, + 0x809e0c8c, 0x808b0bc4, 0x80790afb, 0x80680a33, 0x8059096b, 0x804b08a2, + 0x803e07d9, 0x80320711, 0x80270648, 0x801e057f, 0x801604b6, 0x800f03ed, + 0x800a0324, 0x8006025b, 0x80020192, 0x800100c9, 0x80000000, 0x8001ff37, + 0x8002fe6e, 0x8006fda5, 0x800afcdc, 0x800ffc13, 0x8016fb4a, 0x801efa81, + 0x8027f9b8, 0x8032f8ef, 0x803ef827, 0x804bf75e, 0x8059f695, 0x8068f5cd, + 0x8079f505, 0x808bf43c, 0x809ef374, 0x80b2f2ac, 0x80c8f1e4, 0x80def11c, + 0x80f6f055, 0x8110ef8d, 0x812aeec6, 0x8146edff, 0x8163ed38, 0x8181ec71, + 0x81a0ebab, 0x81c1eae4, 0x81e2ea1e, 0x8205e958, 0x822ae892, 0x824fe7cd, + 0x8276e707, 0x829de642, 0x82c6e57d, 0x82f1e4b9, 0x831ce3f4, 0x8349e330, + 0x8377e26d, 0x83a6e1a9, 0x83d6e0e6, 0x8407e023, 0x843adf61, 0x846ede9e, + 0x84a3dddc, 0x84d9dd1b, 0x8511dc59, 0x8549db99, 0x8583dad8, 0x85beda18, + 0x85fad958, 0x8637d898, 0x8676d7d9, 0x86b6d71b, 0x86f6d65c, 0x8738d59e, + 0x877bd4e1, 0x87c0d424, 0x8805d367, 0x884cd2ab, 0x8894d1ef, 0x88ddd134, + 0x8927d079, 0x8972cfbe, 0x89becf04, 0x8a0cce4b, 0x8a5acd92, 0x8aaaccd9, + 0x8afbcc21, 0x8b4dcb69, 0x8ba0cab2, 0x8bf5c9fc, 0x8c4ac946, 0x8ca1c890, + 0x8cf8c7db, 0x8d51c727, 0x8dabc673, 0x8e06c5c0, 0x8e62c50d, 0x8ebfc45b, + 0x8f1dc3a9, 0x8f7dc2f8, 0x8fddc248, 0x903ec198, 0x90a1c0e9, 0x9105c03a, + 0x9169bf8c, 0x91cfbedf, 0x9236be32, 0x929ebd86, 0x9307bcda, 0x9371bc2f, + 0x93dcbb85, 0x9448badc, 0x94b5ba33, 0x9523b98b, 0x9592b8e3, 0x9603b83c, + 0x9674b796, 0x96e6b6f1, 0x9759b64c, 0x97ceb5a8, 0x9843b505, 0x98b9b462, + 0x9930b3c0, 0x99a9b31f, 0x9a22b27f, 0x9a9cb1df, 0x9b17b140, 0x9b94b0a2, + 0x9c11b005, 0x9c8faf68, 0x9d0eaecc, 0x9d8eae31, 0x9e0fad97, 0x9e91acfd, + 0x9f14ac65, 0x9f98abcd, 0xa01cab36, 0xa0a2aaa0, 0xa129aa0a, 0xa1b0a976, + 0xa238a8e2, 0xa2c2a84f, 0xa34ca7bd, 0xa3d7a72c, 0xa463a69c, 0xa4f0a60c, + 0xa57ea57e, 0xa60ca4f0, 0xa69ca463, 0xa72ca3d7, 0xa7bda34c, 0xa84fa2c2, + 0xa8e2a238, 0xa976a1b0, 0xaa0aa129, 0xaaa0a0a2, 0xab36a01c, 0xabcd9f98, + 0xac659f14, 0xacfd9e91, 0xad979e0f, 0xae319d8e, 0xaecc9d0e, 0xaf689c8f, + 0xb0059c11, 0xb0a29b94, 0xb1409b17, 0xb1df9a9c, 0xb27f9a22, 0xb31f99a9, + 0xb3c09930, 0xb46298b9, 0xb5059843, 0xb5a897ce, 0xb64c9759, 0xb6f196e6, + 0xb7969674, 0xb83c9603, 0xb8e39592, 0xb98b9523, 0xba3394b5, 0xbadc9448, + 0xbb8593dc, 0xbc2f9371, 0xbcda9307, 0xbd86929e, 0xbe329236, 0xbedf91cf, + 0xbf8c9169, 0xc03a9105, 0xc0e990a1, 0xc198903e, 0xc2488fdd, 0xc2f88f7d, + 0xc3a98f1d, 0xc45b8ebf, 0xc50d8e62, 0xc5c08e06, 0xc6738dab, 0xc7278d51, + 0xc7db8cf8, 0xc8908ca1, 0xc9468c4a, 0xc9fc8bf5, 0xcab28ba0, 0xcb698b4d, + 0xcc218afb, 0xccd98aaa, 0xcd928a5a, 0xce4b8a0c, 0xcf0489be, 0xcfbe8972, + 0xd0798927, 0xd13488dd, 0xd1ef8894, 0xd2ab884c, 0xd3678805, 0xd42487c0, + 0xd4e1877b, 0xd59e8738, 0xd65c86f6, 0xd71b86b6, 0xd7d98676, 0xd8988637, + 0xd95885fa, 0xda1885be, 0xdad88583, 0xdb998549, 0xdc598511, 0xdd1b84d9, + 0xdddc84a3, 0xde9e846e, 0xdf61843a, 0xe0238407, 0xe0e683d6, 0xe1a983a6, + 0xe26d8377, 0xe3308349, 0xe3f4831c, 0xe4b982f1, 0xe57d82c6, 0xe642829d, + 0xe7078276, 0xe7cd824f, 0xe892822a, 0xe9588205, 0xea1e81e2, 0xeae481c1, + 0xebab81a0, 0xec718181, 0xed388163, 0xedff8146, 0xeec6812a, 0xef8d8110, + 0xf05580f6, 0xf11c80de, 0xf1e480c8, 0xf2ac80b2, 0xf374809e, 0xf43c808b, + 0xf5058079, 0xf5cd8068, 0xf6958059, 0xf75e804b, 0xf827803e, 0xf8ef8032, + 0xf9b88027, 0xfa81801e, 0xfb4a8016, 0xfc13800f, 0xfcdc800a, 0xfda58006, + 0xfe6e8002, 0xff378001, 0x00008000, 0x00c98001, 0x01928002, 0x025b8006, + 0x0324800a, 0x03ed800f, 0x04b68016, 0x057f801e, 0x06488027, 0x07118032, + 0x07d9803e, 0x08a2804b, 0x096b8059, 0x0a338068, 0x0afb8079, 0x0bc4808b, + 0x0c8c809e, 0x0d5480b2, 0x0e1c80c8, 0x0ee480de, 0x0fab80f6, 0x10738110, + 0x113a812a, 0x12018146, 0x12c88163, 0x138f8181, 0x145581a0, 0x151c81c1, + 0x15e281e2, 0x16a88205, 0x176e822a, 0x1833824f, 0x18f98276, 0x19be829d, + 0x1a8382c6, 0x1b4782f1, 0x1c0c831c, 0x1cd08349, 0x1d938377, 0x1e5783a6, + 0x1f1a83d6, 0x1fdd8407, 0x209f843a, 0x2162846e, 0x222484a3, 0x22e584d9, + 0x23a78511, 0x24678549, 0x25288583, 0x25e885be, 0x26a885fa, 0x27688637, + 0x28278676, 0x28e586b6, 0x29a486f6, 0x2a628738, 0x2b1f877b, 0x2bdc87c0, + 0x2c998805, 0x2d55884c, 0x2e118894, 0x2ecc88dd, 0x2f878927, 0x30428972, + 0x30fc89be, 0x31b58a0c, 0x326e8a5a, 0x33278aaa, 0x33df8afb, 0x34978b4d, + 0x354e8ba0, 0x36048bf5, 0x36ba8c4a, 0x37708ca1, 0x38258cf8, 0x38d98d51, + 0x398d8dab, 0x3a408e06, 0x3af38e62, 0x3ba58ebf, 0x3c578f1d, 0x3d088f7d, + 0x3db88fdd, 0x3e68903e, 0x3f1790a1, 0x3fc69105, 0x40749169, 0x412191cf, + 0x41ce9236, 0x427a929e, 0x43269307, 0x43d19371, 0x447b93dc, 0x45249448, + 0x45cd94b5, 0x46759523, 0x471d9592, 0x47c49603, 0x486a9674, 0x490f96e6, + 0x49b49759, 0x4a5897ce, 0x4afb9843, 0x4b9e98b9, 0x4c409930, 0x4ce199a9, + 0x4d819a22, 0x4e219a9c, 0x4ec09b17, 0x4f5e9b94, 0x4ffb9c11, 0x50989c8f, + 0x51349d0e, 0x51cf9d8e, 0x52699e0f, 0x53039e91, 0x539b9f14, 0x54339f98, + 0x54caa01c, 0x5560a0a2, 0x55f6a129, 0x568aa1b0, 0x571ea238, 0x57b1a2c2, + 0x5843a34c, 0x58d4a3d7, 0x5964a463, 0x59f4a4f0, 0x5a82a57e, 0x5b10a60c, + 0x5b9da69c, 0x5c29a72c, 0x5cb4a7bd, 0x5d3ea84f, 0x5dc8a8e2, 0x5e50a976, + 0x5ed7aa0a, 0x5f5eaaa0, 0x5fe4ab36, 0x6068abcd, 0x60ecac65, 0x616facfd, + 0x61f1ad97, 0x6272ae31, 0x62f2aecc, 0x6371af68, 0x63efb005, 0x646cb0a2, + 0x64e9b140, 0x6564b1df, 0x65deb27f, 0x6657b31f, 0x66d0b3c0, 0x6747b462, + 0x67bdb505, 0x6832b5a8, 0x68a7b64c, 0x691ab6f1, 0x698cb796, 0x69fdb83c, + 0x6a6eb8e3, 0x6addb98b, 0x6b4bba33, 0x6bb8badc, 0x6c24bb85, 0x6c8fbc2f, + 0x6cf9bcda, 0x6d62bd86, 0x6dcabe32, 0x6e31bedf, 0x6e97bf8c, 0x6efbc03a, + 0x6f5fc0e9, 0x6fc2c198, 0x7023c248, 0x7083c2f8, 0x70e3c3a9, 0x7141c45b, + 0x719ec50d, 0x71fac5c0, 0x7255c673, 0x72afc727, 0x7308c7db, 0x735fc890, + 0x73b6c946, 0x740bc9fc, 0x7460cab2, 0x74b3cb69, 0x7505cc21, 0x7556ccd9, + 0x75a6cd92, 0x75f4ce4b, 0x7642cf04, 0x768ecfbe, 0x76d9d079, 0x7723d134, + 0x776cd1ef, 0x77b4d2ab, 0x77fbd367, 0x7840d424, 0x7885d4e1, 0x78c8d59e, + 0x790ad65c, 0x794ad71b, 0x798ad7d9, 0x79c9d898, 0x7a06d958, 0x7a42da18, + 0x7a7ddad8, 0x7ab7db99, 0x7aefdc59, 0x7b27dd1b, 0x7b5ddddc, 0x7b92de9e, + 0x7bc6df61, 0x7bf9e023, 0x7c2ae0e6, 0x7c5ae1a9, 0x7c89e26d, 0x7cb7e330, + 0x7ce4e3f4, 0x7d0fe4b9, 0x7d3ae57d, 0x7d63e642, 0x7d8ae707, 0x7db1e7cd, + 0x7dd6e892, 0x7dfbe958, 0x7e1eea1e, 0x7e3feae4, 0x7e60ebab, 0x7e7fec71, + 0x7e9ded38, 0x7ebaedff, 0x7ed6eec6, 0x7ef0ef8d, 0x7f0af055, 0x7f22f11c, + 0x7f38f1e4, 0x7f4ef2ac, 0x7f62f374, 0x7f75f43c, 0x7f87f505, 0x7f98f5cd, + 0x7fa7f695, 0x7fb5f75e, 0x7fc2f827, 0x7fcef8ef, 0x7fd9f9b8, 0x7fe2fa81, + 0x7feafb4a, 0x7ff1fc13, 0x7ff6fcdc, 0x7ffafda5, 0x7ffefe6e, 0x7fffff37, + }, + + // WORD32 esbr_qmf_c[1280] = + {0, -1186546, -1206390, -1062471, -1046947, -1050933, + -1082485, -1122396, -1173936, -1219298, -1260772, -1316997, + -1355597, -1404525, -1455498, -1490700, -1537112, -1558008, + -1597930, -1608593, -1649562, -1658898, -1682410, -1670714, + -1675824, -1675348, -1666012, -1638700, -1617055, -1571819, + -1549493, -1485615, -1428165, -1361847, -1276919, -1194983, + -1105003, -989200, -879420, -751871, -622121, -450614, + -310607, -132571, 28980, 235016, 438734, 633406, + 864692, 1096803, 1339895, 1601598, 1848649, 2122999, + 2415952, 2701080, 2985538, 3316406, 3622393, 3940259, + 4260852, 4608839, 4942917, 5288310, 5626784, 5985136, + 6328515, 6684133, 7030778, 7391396, 7732716, 8075380, + 8419731, 8765975, 9076182, 9391100, 9708741, 10008661, + 10293439, 10552220, 10821819, 11039645, 11265949, 11482956, + 11638669, 11784539, 11913318, 12012598, 12073291, 12123661, + 12109488, 12083056, 12008111, 11897996, 11758285, 11561832, + 11320622, 11034259, 10702991, 10331429, 9886913, 9406378, + 8858722, 8258450, 7602359, 6891679, 6108894, 5263168, + 4353846, 3389734, 2341257, 1252469, 59280, -1173445, + -2484238, -3873947, -5331498, -6857726, -8461326, -10140975, + -11883575, -13699290, -15594127, -17566036, -19611965, -21721843, + -23904831, -26167087, 28501020, 30903291, 33373088, 35932708, + 38533025, 41204290, 43922868, 46700800, 49538189, 52433173, + 55378416, 58381367, 61433531, 64532454, 67649516, 70814149, + 74006785, 77244462, 80490446, 83763389, 87048071, 90333705, + 93651234, 96956396, 100253776, 103544299, 106812777, 110070596, + 113307839, 116490844, 119652129, 122753697, 125824434, 128814117, + 131738494, 134616689, 137377942, 140068999, 142671836, 145186212, + 147541538, 149814954, 151962108, 153975151, 155839148, 157543750, + 159129320, 160514214, 161735011, 162781055, 163636638, 164280817, + 164732072, 164964105, 164976138, 164756002, 164293390, 163584206, + 162630172, 161399771, 159915461, 158141985, 156073666, 153722541, + 151082577, 148104219, 144853145, 141237995, 137319726, 133058683, + 128455292, 123513100, 118210392, 112548291, 106510609, 100137872, + 93365884, 86212508, 78687691, 70777610, 62453979, 53753139, + 44667031, 35154577, 25259525, 14954402, 4244630, -6890608, + -18406457, -30341544, -42699304, -55453887, -68618818, -82200642, + -96165782, -110553355, -125349764, -140533445, -156109885, -172093527, + -188451898, -205199224, -222335323, -239836757, -257714784, -275952260, + -294538497, -313482466, -332775584, -352393230, -372332469, -392597065, + -413168712, -434060170, -455209808, -476666786, -498364569, -520338913, + -542557514, -565014393, -587687684, -610575597, -633661589, -656936416, + -680382715, -703969562, -727722656, -751600834, 775583025, 799679004, + 823849891, 848086767, 872376077, 896724080, 921081488, 945441219, + 969802871, 994136341, 1018434072, 1042657661, 1066807223, 1090882501, + 1114809220, 1138647561, 1162337001, 1185851477, 1209202759, 1232338673, + 1255290785, 1277993950, 1300469611, 1322658785, 1344591629, 1366224824, + 1387547101, 1408538024, 1429180406, 1449479132, 1469384180, 1488911052, + 1508046493, 1526734263, 1544999085, 1562820250, 1580163942, 1597046622, + 1613433982, 1629313186, 1644687903, 1659528307, 1673810498, 1687568481, + 1700750320, 1713362615, 1725392676, 1736819276, 1747663266, 1757882010, + 1767469212, 1776457603, 1784781917, 1792491148, 1799530594, 1805935261, + 1811668375, 1816732182, 1821133945, 1824889769, 1827931965, 1830310413, + 1832022798, 1833032034, 1833389596, 1833032034, 1832022798, 1830310413, + 1827931965, 1824889769, 1821133945, 1816732182, 1811668375, 1805935261, + 1799530594, 1792491148, 1784781917, 1776457603, 1767469212, 1757882010, + 1747663266, 1736819276, 1725392676, 1713362615, 1700750320, 1687568481, + 1673810498, 1659528307, 1644687903, 1629313186, 1613433982, 1597046622, + 1580163942, 1562820250, 1544999085, 1526734263, 1508046493, 1488911052, + 1469384180, 1449479132, 1429180406, 1408538024, 1387547101, 1366224824, + 1344591629, 1322658785, 1300469611, 1277993950, 1255290785, 1232338673, + 1209202759, 1185851477, 1162337001, 1138647561, 1114809220, 1090882501, + 1066807223, 1042657661, 1018434072, 994136341, 969802871, 945441219, + 921081488, 896724080, 872376077, 848086767, 823849891, 799679004, + -775583025, -751600834, -727722656, -703969562, -680382715, -656936416, + -633661589, -610575597, -587687684, -565014393, -542557514, -520338913, + -498364569, -476666786, -455209808, -434060170, -413168712, -392597065, + -372332469, -352393230, -332775584, -313482466, -294538497, -275952260, + -257714784, -239836757, -222335323, -205199224, -188451898, -172093527, + -156109885, -140533445, -125349764, -110553355, -96165782, -82200642, + -68618818, -55453887, -42699304, -30341544, -18406457, -6890608, + 4244630, 14954402, 25259525, 35154577, 44667031, 53753139, + 62453979, 70777610, 78687691, 86212508, 93365884, 100137872, + 106510609, 112548291, 118210392, 123513100, 128455292, 133058683, + 137319726, 141237995, 144853145, 148104219, 151082577, 153722541, + 156073666, 158141985, 159915461, 161399771, 162630172, 163584206, + 164293390, 164756002, 164976138, 164964105, 164732072, 164280817, + 163636638, 162781055, 161735011, 160514214, 159129320, 157543750, + 155839148, 153975151, 151962108, 149814954, 147541538, 145186212, + 142671836, 140068999, 137377942, 134616689, 131738494, 128814117, + 125824434, 122753697, 119652129, 116490844, 113307839, 110070596, + 106812777, 103544299, 100253776, 96956396, 93651234, 90333705, + 87048071, 83763389, 80490446, 77244462, 74006785, 70814149, + 67649516, 64532454, 61433531, 58381367, 55378416, 52433173, + 49538189, 46700800, 43922868, 41204290, 38533025, 35932708, + 33373088, 30903291, -28501020, -26167087, -23904831, -21721843, + -19611965, -17566036, -15594127, -13699290, -11883575, -10140975, + -8461326, -6857726, -5331498, -3873947, -2484238, -1173445, + 59280, 1252469, 2341257, 3389734, 4353846, 5263168, + 6108894, 6891679, 7602359, 8258450, 8858722, 9406378, + 9886913, 10331429, 10702991, 11034259, 11320622, 11561832, + 11758285, 11897996, 12008111, 12083056, 12109488, 12123661, + 12073291, 12012598, 11913318, 11784539, 11638669, 11482956, + 11265949, 11039645, 10821819, 10552220, 10293439, 10008661, + 9708741, 9391100, 9076182, 8765975, 8419731, 8075380, + 7732716, 7391396, 7030778, 6684133, 6328515, 5985136, + 5626784, 5288310, 4942917, 4608839, 4260852, 3940259, + 3622393, 3316406, 2985538, 2701080, 2415952, 2122999, + 1848649, 1601598, 1339895, 1096803, 864692, 633406, + 438734, 235016, 28980, -132571, -310607, -450614, + -622121, -751871, -879420, -989200, -1105003, -1194983, + -1276919, -1361847, -1428165, -1485615, -1549493, -1571819, + -1617055, -1638700, -1666012, -1675348, -1675824, -1670714, + -1682410, -1658898, -1649562, -1608593, -1597930, -1558008, + -1537112, -1490700, -1455498, -1404525, -1355597, -1316997, + -1260772, -1219298, -1173936, -1122396, -1082485, -1050933, + -1046947, -1062471, -1206390, -1186546, + + 0, -1186546, -1206390, -1062471, -1046947, -1050933, + -1082485, -1122396, -1173936, -1219298, -1260772, -1316997, + -1355597, -1404525, -1455498, -1490700, -1537112, -1558008, + -1597930, -1608593, -1649562, -1658898, -1682410, -1670714, + -1675824, -1675348, -1666012, -1638700, -1617055, -1571819, + -1549493, -1485615, -1428165, -1361847, -1276919, -1194983, + -1105003, -989200, -879420, -751871, -622121, -450614, + -310607, -132571, 28980, 235016, 438734, 633406, + 864692, 1096803, 1339895, 1601598, 1848649, 2122999, + 2415952, 2701080, 2985538, 3316406, 3622393, 3940259, + 4260852, 4608839, 4942917, 5288310, 5626784, 5985136, + 6328515, 6684133, 7030778, 7391396, 7732716, 8075380, + 8419731, 8765975, 9076182, 9391100, 9708741, 10008661, + 10293439, 10552220, 10821819, 11039645, 11265949, 11482956, + 11638669, 11784539, 11913318, 12012598, 12073291, 12123661, + 12109488, 12083056, 12008111, 11897996, 11758285, 11561832, + 11320622, 11034259, 10702991, 10331429, 9886913, 9406378, + 8858722, 8258450, 7602359, 6891679, 6108894, 5263168, + 4353846, 3389734, 2341257, 1252469, 59280, -1173445, + -2484238, -3873947, -5331498, -6857726, -8461326, -10140975, + -11883575, -13699290, -15594127, -17566036, -19611965, -21721843, + -23904831, -26167087, 28501020, 30903291, 33373088, 35932708, + 38533025, 41204290, 43922868, 46700800, 49538189, 52433173, + 55378416, 58381367, 61433531, 64532454, 67649516, 70814149, + 74006785, 77244462, 80490446, 83763389, 87048071, 90333705, + 93651234, 96956396, 100253776, 103544299, 106812777, 110070596, + 113307839, 116490844, 119652129, 122753697, 125824434, 128814117, + 131738494, 134616689, 137377942, 140068999, 142671836, 145186212, + 147541538, 149814954, 151962108, 153975151, 155839148, 157543750, + 159129320, 160514214, 161735011, 162781055, 163636638, 164280817, + 164732072, 164964105, 164976138, 164756002, 164293390, 163584206, + 162630172, 161399771, 159915461, 158141985, 156073666, 153722541, + 151082577, 148104219, 144853145, 141237995, 137319726, 133058683, + 128455292, 123513100, 118210392, 112548291, 106510609, 100137872, + 93365884, 86212508, 78687691, 70777610, 62453979, 53753139, + 44667031, 35154577, 25259525, 14954402, 4244630, -6890608, + -18406457, -30341544, -42699304, -55453887, -68618818, -82200642, + -96165782, -110553355, -125349764, -140533445, -156109885, -172093527, + -188451898, -205199224, -222335323, -239836757, -257714784, -275952260, + -294538497, -313482466, -332775584, -352393230, -372332469, -392597065, + -413168712, -434060170, -455209808, -476666786, -498364569, -520338913, + -542557514, -565014393, -587687684, -610575597, -633661589, -656936416, + -680382715, -703969562, -727722656, -751600834, 775583025, 799679004, + 823849891, 848086767, 872376077, 896724080, 921081488, 945441219, + 969802871, 994136341, 1018434072, 1042657661, 1066807223, 1090882501, + 1114809220, 1138647561, 1162337001, 1185851477, 1209202759, 1232338673, + 1255290785, 1277993950, 1300469611, 1322658785, 1344591629, 1366224824, + 1387547101, 1408538024, 1429180406, 1449479132, 1469384180, 1488911052, + 1508046493, 1526734263, 1544999085, 1562820250, 1580163942, 1597046622, + 1613433982, 1629313186, 1644687903, 1659528307, 1673810498, 1687568481, + 1700750320, 1713362615, 1725392676, 1736819276, 1747663266, 1757882010, + 1767469212, 1776457603, 1784781917, 1792491148, 1799530594, 1805935261, + 1811668375, 1816732182, 1821133945, 1824889769, 1827931965, 1830310413, + 1832022798, 1833032034, 1833389596, 1833032034, 1832022798, 1830310413, + 1827931965, 1824889769, 1821133945, 1816732182, 1811668375, 1805935261, + 1799530594, 1792491148, 1784781917, 1776457603, 1767469212, 1757882010, + 1747663266, 1736819276, 1725392676, 1713362615, 1700750320, 1687568481, + 1673810498, 1659528307, 1644687903, 1629313186, 1613433982, 1597046622, + 1580163942, 1562820250, 1544999085, 1526734263, 1508046493, 1488911052, + 1469384180, 1449479132, 1429180406, 1408538024, 1387547101, 1366224824, + 1344591629, 1322658785, 1300469611, 1277993950, 1255290785, 1232338673, + 1209202759, 1185851477, 1162337001, 1138647561, 1114809220, 1090882501, + 1066807223, 1042657661, 1018434072, 994136341, 969802871, 945441219, + 921081488, 896724080, 872376077, 848086767, 823849891, 799679004, + -775583025, -751600834, -727722656, -703969562, -680382715, -656936416, + -633661589, -610575597, -587687684, -565014393, -542557514, -520338913, + -498364569, -476666786, -455209808, -434060170, -413168712, -392597065, + -372332469, -352393230, -332775584, -313482466, -294538497, -275952260, + -257714784, -239836757, -222335323, -205199224, -188451898, -172093527, + -156109885, -140533445, -125349764, -110553355, -96165782, -82200642, + -68618818, -55453887, -42699304, -30341544, -18406457, -6890608, + 4244630, 14954402, 25259525, 35154577, 44667031, 53753139, + 62453979, 70777610, 78687691, 86212508, 93365884, 100137872, + 106510609, 112548291, 118210392, 123513100, 128455292, 133058683, + 137319726, 141237995, 144853145, 148104219, 151082577, 153722541, + 156073666, 158141985, 159915461, 161399771, 162630172, 163584206, + 164293390, 164756002, 164976138, 164964105, 164732072, 164280817, + 163636638, 162781055, 161735011, 160514214, 159129320, 157543750, + 155839148, 153975151, 151962108, 149814954, 147541538, 145186212, + 142671836, 140068999, 137377942, 134616689, 131738494, 128814117, + 125824434, 122753697, 119652129, 116490844, 113307839, 110070596, + 106812777, 103544299, 100253776, 96956396, 93651234, 90333705, + 87048071, 83763389, 80490446, 77244462, 74006785, 70814149, + 67649516, 64532454, 61433531, 58381367, 55378416, 52433173, + 49538189, 46700800, 43922868, 41204290, 38533025, 35932708, + 33373088, 30903291, -28501020, -26167087, -23904831, -21721843, + -19611965, -17566036, -15594127, -13699290, -11883575, -10140975, + -8461326, -6857726, -5331498, -3873947, -2484238, -1173445, + 59280, 1252469, 2341257, 3389734, 4353846, 5263168, + 6108894, 6891679, 7602359, 8258450, 8858722, 9406378, + 9886913, 10331429, 10702991, 11034259, 11320622, 11561832, + 11758285, 11897996, 12008111, 12083056, 12109488, 12123661, + 12073291, 12012598, 11913318, 11784539, 11638669, 11482956, + 11265949, 11039645, 10821819, 10552220, 10293439, 10008661, + 9708741, 9391100, 9076182, 8765975, 8419731, 8075380, + 7732716, 7391396, 7030778, 6684133, 6328515, 5985136, + 5626784, 5288310, 4942917, 4608839, 4260852, 3940259, + 3622393, 3316406, 2985538, 2701080, 2415952, 2122999, + 1848649, 1601598, 1339895, 1096803, 864692, 633406, + 438734, 235016, 28980, -132571, -310607, -450614, + -622121, -751871, -879420, -989200, -1105003, -1194983, + -1276919, -1361847, -1428165, -1485615, -1549493, -1571819, + -1617055, -1638700, -1666012, -1675348, -1675824, -1670714, + -1682410, -1658898, -1649562, -1608593, -1597930, -1558008, + -1537112, -1490700, -1455498, -1404525, -1355597, -1316997, + -1260772, -1219298, -1173936, -1122396, -1082485, -1050933, + -1046947, -1062471, -1206390, -1186546}, + + // WORD32 esbr_qmf_c_24[480] = + {0, -1110444, -1061450, -1173936, -1298255, -1421516, + -1537112, -1605039, -1666735, -1675824, -1647804, -1564377, + -1428165, -1222295, -952607, -622121, -191917, 302922, + 864692, 1514364, 2220650, 2985538, 3834304, 4720199, + 5626784, 6565594, 7505170, 8419731, 9286127, 10103587, + 10821819, 11410620, 11827466, 12073291, 12091866, 11851426, + 11320622, 10455283, 9223826, 7602359, 5545077, 3040242, + 59280, -3410710, -7392260, -11883575, -16908733, -22449506, + 28501020, 35079501, 42110483, 49538189, 57380384, 65571474, + 74006785, 82672408, 91439548, 100253776, 108984656, 117544606, + 125824434, 133657291, 140936611, 147541538, 153304137, 158072273, + 161735011, 164066091, 164968116, 164293390, 161809905, 157452545, + 151082577, 142443045, 131524220, 118210392, 102262118, 83704236, + 62453979, 38325395, 11384478, -18406457, -51202360, -86855689, + -125349764, -166765646, -210911257, -257714784, -307167810, -359039643, + -413168712, -469514460, -527745114, -587687684, -649178140, -711887260, + 775583025, 840007809, 904843216, 969802871, 1034583131, 1098858074, + 1162337001, 1224626701, 1285485837, 1344591629, 1401541050, 1456114148, + 1508046493, 1556879862, 1602509075, 1644687903, 1682982487, 1717372635, + 1747663266, 1773461472, 1794837630, 1811668375, 1823637828, 1830881208, + 1833389596, 1830881208, 1823637828, 1811668375, 1794837630, 1773461472, + 1747663266, 1717372635, 1682982487, 1644687903, 1602509075, 1556879862, + 1508046493, 1456114148, 1401541050, 1344591629, 1285485837, 1224626701, + 1162337001, 1098858074, 1034583131, 969802871, 904843216, 840007809, + -775583025, -711887260, -649178140, -587687684, -527745114, -469514460, + -413168712, -359039643, -307167810, -257714784, -210911257, -166765646, + -125349764, -86855689, -51202360, -18406457, 11384478, 38325395, + 62453979, 83704236, 102262118, 118210392, 131524220, 142443045, + 151082577, 157452545, 161809905, 164293390, 164968116, 164066091, + 161735011, 158072273, 153304137, 147541538, 140936611, 133657291, + 125824434, 117544606, 108984656, 100253776, 91439548, 82672408, + 74006785, 65571474, 57380384, 49538189, 42110483, 35079501, + -28501020, -22449506, -16908733, -11883575, -7392260, -3410710, + 59280, 3040242, 5545077, 7602359, 9223826, 10455283, + 11320622, 11851426, 12091866, 12073291, 11827466, 11410620, + 10821819, 10103587, 9286127, 8419731, 7505170, 6565594, + 5626784, 4720199, 3834304, 2985538, 2220650, 1514364, + 864692, 302922, -191917, -622121, -952607, -1222295, + -1428165, -1564377, -1647804, -1675824, -1666735, -1605039, + -1537112, -1421516, -1298255, -1173936, -1061450, -1110444, + + 0, -1110444, -1061450, -1173936, -1298255, -1421516, + -1537112, -1605039, -1666735, -1675824, -1647804, -1564377, + -1428165, -1222295, -952607, -622121, -191917, 302922, + 864692, 1514364, 2220650, 2985538, 3834304, 4720199, + 5626784, 6565594, 7505170, 8419731, 9286127, 10103587, + 10821819, 11410620, 11827466, 12073291, 12091866, 11851426, + 11320622, 10455283, 9223826, 7602359, 5545077, 3040242, + 59280, -3410710, -7392260, -11883575, -16908733, -22449506, + 28501020, 35079501, 42110483, 49538189, 57380384, 65571474, + 74006785, 82672408, 91439548, 100253776, 108984656, 117544606, + 125824434, 133657291, 140936611, 147541538, 153304137, 158072273, + 161735011, 164066091, 164968116, 164293390, 161809905, 157452545, + 151082577, 142443045, 131524220, 118210392, 102262118, 83704236, + 62453979, 38325395, 11384478, -18406457, -51202360, -86855689, + -125349764, -166765646, -210911257, -257714784, -307167810, -359039643, + -413168712, -469514460, -527745114, -587687684, -649178140, -711887260, + 775583025, 840007809, 904843216, 969802871, 1034583131, 1098858074, + 1162337001, 1224626701, 1285485837, 1344591629, 1401541050, 1456114148, + 1508046493, 1556879862, 1602509075, 1644687903, 1682982487, 1717372635, + 1747663266, 1773461472, 1794837630, 1811668375, 1823637828, 1830881208, + 1833389596, 1830881208, 1823637828, 1811668375, 1794837630, 1773461472, + 1747663266, 1717372635, 1682982487, 1644687903, 1602509075, 1556879862, + 1508046493, 1456114148, 1401541050, 1344591629, 1285485837, 1224626701, + 1162337001, 1098858074, 1034583131, 969802871, 904843216, 840007809, + -775583025, -711887260, -649178140, -587687684, -527745114, -469514460, + -413168712, -359039643, -307167810, -257714784, -210911257, -166765646, + -125349764, -86855689, -51202360, -18406457, 11384478, 38325395, + 62453979, 83704236, 102262118, 118210392, 131524220, 142443045, + 151082577, 157452545, 161809905, 164293390, 164968116, 164066091, + 161735011, 158072273, 153304137, 147541538, 140936611, 133657291, + 125824434, 117544606, 108984656, 100253776, 91439548, 82672408, + 74006785, 65571474, 57380384, 49538189, 42110483, 35079501, + -28501020, -22449506, -16908733, -11883575, -7392260, -3410710, + 59280, 3040242, 5545077, 7602359, 9223826, 10455283, + 11320622, 11851426, 12091866, 12073291, 11827466, 11410620, + 10821819, 10103587, 9286127, 8419731, 7505170, 6565594, + 5626784, 4720199, 3834304, 2985538, 2220650, 1514364, + 864692, 302922, -191917, -622121, -952607, -1222295, + -1428165, -1564377, -1647804, -1675824, -1666735, -1605039, + -1537112, -1421516, -1298255, -1173936, -1061450, -1110444}, + + // const WORD32 esbr_w_32[2 * 30] = + {0, 2147483647, 0, 2147483647, 0, 2147483647, + 418953276, 2106220350, 821806413, 1984016188, 1193077990, 1785567395, + 821806413, 1984016188, 1518500249, 1518500249, 1984016188, 821806413, + 1193077990, 1785567395, 1984016188, 821806413, 2106220350, -418953276, + 1518500249, 1518500249, 2147483647, 0, 1518500249, -1518500249, + 1785567395, 1193077990, 1984016188, -821806413, 418953276, -2106220350, + 1984016188, 821806413, 1518500249, -1518500249, -821806413, -1984016188, + 2106220350, 418953276, 821806413, -1984016188, -1785567395, -1193077990, + 0, 2147483647, 0, 2147483647, 0, 2147483647, + 1518500249, 1518500249, 2147483647, 0, 1518500249, -1518500249}, + + // const WORD32 esbr_w_16[2 * 12] = + {0, 2147483647, 0, 2147483647, 0, 2147483647, + 821806413, 1984016188, 1518500249, 1518500249, 1984016188, 821806413, + 1518500249, 1518500249, 2147483647, 0, 1518500249, -1518500249, + 1984016188, 821806413, 1518500249, -1518500249, -821806413, -1984016188}, + + // WORD32 ixheaacd_esbr_sin_cos_twiddle_l64[64] = + {(WORD32)0x1921d1f, (WORD32)0x7ffd8859, (WORD32)0x7fe9cbbe, + (WORD32)0x4b6195d, (WORD32)0x7d95b9e, (WORD32)0x7fc25595, + (WORD32)0x7f872bf1, (WORD32)0xafb6805, (WORD32)0xe1bc2e3, + (WORD32)0x7f3857f4, (WORD32)0x7ed5e5c5, (WORD32)0x1139f0ce, + (WORD32)0x145576b1, (WORD32)0x7e5fe492, (WORD32)0x7dd6668d, + (WORD32)0x176dd9de, (WORD32)0x1a82a025, (WORD32)0x7d3980eb, + (WORD32)0x7c894bdc, (WORD32)0x1d934fe5, (WORD32)0x209f701c, + (WORD32)0x7bc5e28e, (WORD32)0x7aef6322, (WORD32)0x23a6887e, + (WORD32)0x26a82185, (WORD32)0x7a05eeac, (WORD32)0x7909a92b, + (WORD32)0x29a3c484, (WORD32)0x2c98fbba, (WORD32)0x77fab987, + (WORD32)0x76d94987, (WORD32)0x2f875261, (WORD32)0x326e54c7, + (WORD32)0x75a585ce, (WORD32)0x745f9dd0, (WORD32)0x354d9056, + (WORD32)0x382493af, (WORD32)0x7307c3cf, (WORD32)0x719e2cd1, + (WORD32)0x3af2eeb6, (WORD32)0x3db832a5, (WORD32)0x70231098, + (WORD32)0x6e96a99b, (WORD32)0x4073f21c, (WORD32)0x4325c134, + (WORD32)0x6cf934fa, (WORD32)0x6b4af277, (WORD32)0x45cd358e, + (WORD32)0x4869e664, (WORD32)0x698c246b, (WORD32)0x67bd0fbb, + (WORD32)0x4afb6c97, (WORD32)0x4d8162c3, (WORD32)0x65ddfbd2, + (WORD32)0x63ef328e, (WORD32)0x4ffb654c, (WORD32)0x5269126d, + (WORD32)0x61f1003e, (WORD32)0x5fe3b38c, (WORD32)0x54ca0a49, + (WORD32)0x571deef8, (WORD32)0x5dc79d7b, (WORD32)0x5b9d1152, + (WORD32)0x59646497}, + + // WORD32 ixheaacd_esbr_alt_sin_twiddle_l64[32]= + { + (WORD32)0x647d97c, (WORD32)0x7fd8878c, (WORD32)0xc8bd35d, + (WORD32)0x7f62368e, (WORD32)0x12c8106e, (WORD32)0x7e9d55fb, + (WORD32)0x18f8b83c, (WORD32)0x7d8a5f3e, (WORD32)0x1f19f97a, + (WORD32)0x7c29fbed, (WORD32)0x25280c5d, (WORD32)0x7a7d055a, + (WORD32)0x2b1f34eb, (WORD32)0x78848412, (WORD32)0x30fbc54c, + (WORD32)0x7641af3b, (WORD32)0x36ba2013, (WORD32)0x73b5ebd0, + (WORD32)0x3c56ba6f, (WORD32)0x70e2cbc5, (WORD32)0x41ce1e64, + (WORD32)0x6dca0d13, (WORD32)0x471cece6, (WORD32)0x6a6d98a3, + (WORD32)0x4c3fdff2, (WORD32)0x66cf811f, (WORD32)0x5133cc93, + (WORD32)0x62f201ab, (WORD32)0x55f5a4d1, (WORD32)0x5ed77c88, + (WORD32)0x5a827999, (WORD32)0x5a827999, + }, + + // const WORD32 ixheaacd_esbr_sin_cos_twiddle_l32[32] = + {(WORD32)0x3242abf, (WORD32)0x7ff62181, (WORD32)0x7fa736b3, + (WORD32)0x96a9049, (WORD32)0xfab272b, (WORD32)0x7f0991c3, + (WORD32)0x7e1d93e9, (WORD32)0x15e21444, (WORD32)0x1c0b826a, + (WORD32)0x7ce3ceb1, (WORD32)0x7b5d039d, (WORD32)0x2223a4c5, + (WORD32)0x2826b928, (WORD32)0x798a23b0, (WORD32)0x776c4eda, + (WORD32)0x2e110a62, (WORD32)0x33def287, (WORD32)0x7504d344, + (WORD32)0x72552c84, (WORD32)0x398cdd32, (WORD32)0x3f1749b7, + (WORD32)0x6f5f02b1, (WORD32)0x6c24295f, (WORD32)0x447acd50, + (WORD32)0x49b41533, (WORD32)0x68a69e80, (WORD32)0x64e88925, + (WORD32)0x4ebfe8a4, (WORD32)0x539b2aef, (WORD32)0x60ec382f, + (WORD32)0x5cb420df, (WORD32)0x5842dd54}, + + // const WORD32 ixheaacd_esbr_alt_sin_twiddle_l32[16] = + {(WORD32)0xc8bd35e, (WORD32)0x7f62368e, (WORD32)0x18f8b83c, + (WORD32)0x7d8a5f3f, (WORD32)0x25280c5d, (WORD32)0x7a7d055a, + (WORD32)0x30fbc54d, (WORD32)0x7641af3c, (WORD32)0x3c56ba70, + (WORD32)0x70e2cbc5, (WORD32)0x471cece6, (WORD32)0x6a6d98a3, + (WORD32)0x5133cc94, (WORD32)0x62f201ac, (WORD32)0x5a827999, + (WORD32)0x5a827999}, + + // const WORD32 ixheaacd_esbr_t_cos_sin_l32[32+32] = //exp[-i * pi/32* 3/4 * + // (k + // +0.5)] + {(WORD32)0x7fe9cbbe, (WORD32)0x4b6195d, (WORD32)0x7f3857f4, + (WORD32)0xe1bc2e3, (WORD32)0x7dd6668d, (WORD32)0x176dd9de, + (WORD32)0x7bc5e28e, (WORD32)0x209f701c, (WORD32)0x7909a92b, + (WORD32)0x29a3c484, (WORD32)0x75a585ce, (WORD32)0x326e54c7, + (WORD32)0x719e2cd1, (WORD32)0x3af2eeb6, (WORD32)0x6cf934fa, + (WORD32)0x4325c134, (WORD32)0x67bd0fbb, (WORD32)0x4afb6c97, + (WORD32)0x61f1003e, (WORD32)0x5269126d, (WORD32)0x5b9d1152, + (WORD32)0x59646497, (WORD32)0x54ca0a49, (WORD32)0x5fe3b38c, + (WORD32)0x4d8162c3, (WORD32)0x65ddfbd2, (WORD32)0x45cd358e, + (WORD32)0x6b4af277, (WORD32)0x3db832a5, (WORD32)0x70231098, + (WORD32)0x354d9056, (WORD32)0x745f9dd0, (WORD32)0x2c98fbba, + (WORD32)0x77fab987, (WORD32)0x23a6887e, (WORD32)0x7aef6322, + (WORD32)0x1a82a025, (WORD32)0x7d3980eb, (WORD32)0x1139f0ce, + (WORD32)0x7ed5e5c5, (WORD32)0x7d95b9e, (WORD32)0x7fc25595, + (WORD32)0xfe6de2e1, (WORD32)0x7ffd8859, (WORD32)0xf50497fb, + (WORD32)0x7f872bf1, (WORD32)0xebaa894f, (WORD32)0x7e5fe492, + (WORD32)0xe26cb01b, (WORD32)0x7c894bdc, (WORD32)0xd957de7b, + (WORD32)0x7a05eeac, (WORD32)0xd078ad9f, (WORD32)0x76d94987, + (WORD32)0xc7db6c51, (WORD32)0x7307c3cf, (WORD32)0xbf8c0de4, + (WORD32)0x6e96a99b, (WORD32)0xb796199c, (WORD32)0x698c246b, + (WORD32)0xb0049ab4, (WORD32)0x63ef328e, (WORD32)0xa8e21108, + (WORD32)0x5dc79d7b}, + + // const WORD32 ixheaacd_esbr_sin_cos_twiddle_l24[24] = + {(WORD32)0x430238f, (WORD32)0x7fee74a1, (WORD32)0x7f62368e, + (WORD32)0xc8bd35e, (WORD32)0x14d9c245, (WORD32)0x7e4a5425, + (WORD32)0x7ca80037, (WORD32)0x1d10d5c1, (WORD32)0x25280c5d, + (WORD32)0x7a7d055a, (WORD32)0x77cbc3f1, (WORD32)0x2d168792, + (WORD32)0x34d3957e, (WORD32)0x74972f91, (WORD32)0x70e2cbc5, + (WORD32)0x3c56ba70, (WORD32)0x4397ba32, (WORD32)0x6cb2a836, + (WORD32)0x680b5c33, (WORD32)0x4a8ea111, (WORD32)0x5133cc94, + (WORD32)0x62f201ac, (WORD32)0x5d6c2f99, (WORD32)0x577ff3da}, + + // const WORD32 ixheaacd_esbr_alt_sin_twiddle_l24[12] = + {(WORD32)0x10b5150f, (WORD32)0x7ee7aa4b, (WORD32)0x2120fb83, + (WORD32)0x7ba3751c, (WORD32)0x30fbc54d, (WORD32)0x7641af3c, + (WORD32)0x3fffffff, (WORD32)0x6ed9eba1, (WORD32)0x4debe4fe, + (WORD32)0x658c9a2d, (WORD32)0x5a827999, (WORD32)0x5a827999}, + + // const WORD32 ixheaacd_esbr_t_cos_sin_l24[24+24] = //exp[-i * pi/24* 11/8 + // * (k + // +0.5)] + {(WORD32)0x7fded52e, (WORD32)0x5c1f4e6, (WORD32)0x7ed5e5c5, + (WORD32)0x1139f0ce, (WORD32)0x7cc62bde, (WORD32)0x1c8e3bbe, + (WORD32)0x79b3ecde, (WORD32)0x27a75c94, (WORD32)0x75a585ce, + (WORD32)0x326e54c7, (WORD32)0x70a35e24, (WORD32)0x3cccd003, + (WORD32)0x6ab7d661, (WORD32)0x46ad5277, (WORD32)0x63ef328e, + (WORD32)0x4ffb654c, (WORD32)0x5c5780d1, (WORD32)0x58a3c117, + (WORD32)0x54007c50, (WORD32)0x609475c2, (WORD32)0x4afb6c97, + (WORD32)0x67bd0fbb, (WORD32)0x415b01cd, (WORD32)0x6e0eba0a, + (WORD32)0x37332dfc, (WORD32)0x737c5d0a, (WORD32)0x2c98fbba, + (WORD32)0x77fab987, (WORD32)0x21a26295, (WORD32)0x7b808014, + (WORD32)0x1666198d, (WORD32)0x7e06644a, (WORD32)0xafb6805, + (WORD32)0x7f872bf1, (WORD32)0xff79f587, (WORD32)0x7fffb9cf, + (WORD32)0xf3f998c1, (WORD32)0x7f6f141d, (WORD32)0xe8922622, + (WORD32)0x7dd6668d, (WORD32)0xdd5b3e7c, (WORD32)0x7b38ffdc, + (WORD32)0xd26c1e09, (WORD32)0x779c4afa, (WORD32)0xc7db6c51, + (WORD32)0x7307c3cf, (WORD32)0xbdbf0d30, (WORD32)0x6d84e7b6}, + + // const WORD32 ixheaacd_esbr_sin_cos_twiddle_l16[16] = + {(WORD32)0x647d97c, (WORD32)0x7fd8878d, (WORD32)0x7e9d55fb, + (WORD32)0x12c8106e, (WORD32)0x1f19f97b, (WORD32)0x7c29fbed, + (WORD32)0x78848413, (WORD32)0x2b1f34eb, (WORD32)0x36ba2013, + (WORD32)0x73b5ebd0, (WORD32)0x6dca0d14, (WORD32)0x41ce1e64, + (WORD32)0x4c3fdff3, (WORD32)0x66cf811f, (WORD32)0x5ed77c89, + (WORD32)0x55f5a4d2}, + + // const WORD32 ixheaacd_esbr_alt_sin_twiddle_l16[8] = + {(WORD32)0x18f8b83c, (WORD32)0x7d8a5f3f, (WORD32)0x30fbc54d, + (WORD32)0x7641af3c, (WORD32)0x471cece6, (WORD32)0x6a6d98a3, + (WORD32)0x5a827999, (WORD32)0x5a827999}, + + // const WORD32 ixheaacd_esbr_t_cos_sin_l16[16+16] = //exp[-i * pi/16* 5/4 * + // (k + // +0.5)] + {(WORD32)0x7fc25595, (WORD32)0x7d95b9e, (WORD32)0x7dd6668d, + (WORD32)0x176dd9de, (WORD32)0x7a05eeac, (WORD32)0x26a82185, + (WORD32)0x745f9dd0, (WORD32)0x354d9056, (WORD32)0x6cf934fa, + (WORD32)0x4325c134, (WORD32)0x63ef328e, (WORD32)0x4ffb654c, + (WORD32)0x59646497, (WORD32)0x5b9d1152, (WORD32)0x4d8162c3, + (WORD32)0x65ddfbd2, (WORD32)0x4073f21c, (WORD32)0x6e96a99b, + (WORD32)0x326e54c7, (WORD32)0x75a585ce, (WORD32)0x23a6887e, + (WORD32)0x7aef6322, (WORD32)0x145576b1, (WORD32)0x7e5fe492, + (WORD32)0x4b6195d, (WORD32)0x7fe9cbbe, (WORD32)0xf50497fb, + (WORD32)0x7f872bf1, (WORD32)0xe57d5fdb, (WORD32)0x7d3980eb, + (WORD32)0xd65c3b7c, (WORD32)0x7909a92b}, + + // WORD16 ixheaacd_sbr_t_cos_sin_l32_eld[32+32]; + { + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a82, + (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)-0x5a82, + }, + + // WORD16 qmf_c_eld[640]; + {185, 386, 565, 759, 970, 1200, 1447, 1707, 1977, 2255, + 2535, 2818, 3099, 3379, 3657, 3933, 4208, 4481, 4754, 5027, + 5301, 5576, 5852, 6129, 6407, 6685, 6963, 7242, 7520, 7797, + 8073, 8349, 8624, 8898, 9172, 9445, 9717, 9989, 10259, 10528, + 10796, 11061, 11325, 11586, 11845, 12102, 12357, 12611, 12863, 13114, + 13364, 13612, 13858, 14103, 14344, 14581, 14813, 15040, 15260, 15473, + 15678, 15876, 16069, 16265, 16408, 16497, 16589, 16674, 16752, 16820, + 16879, 16928, 16969, 17001, 17027, 17045, 17057, 17063, 17063, 17056, + 17044, 17024, 16997, 16963, 16920, 16869, 16809, 16741, 16664, 16578, + 16484, 16381, 16270, 16150, 16023, 15887, 15743, 15590, 15430, 15262, + 15087, 14903, 14713, 14515, 14310, 14099, 13882, 13659, 13431, 13197, + 12958, 12715, 12467, 12214, 11958, 11698, 11435, 11168, 10899, 10627, + 10354, 10078, 9801, 9522, 9243, 8963, 8683, 8403, -8120, -7836, + -7553, -7270, -6989, -6710, -6431, -6155, -5881, -5610, -5341, -5076, + -4813, -4554, -4299, -4047, -3799, -3555, -3315, -3080, -2848, -2622, + -2399, -2182, -1969, -1761, -1558, -1360, -1167, -979, -796, -619, + -447, -280, -120, 36, 186, 330, 468, 601, 727, 848, + 964, 1073, 1177, 1275, 1368, 1454, 1535, 1610, 1679, 1742, + 1800, 1852, 1898, 1939, 1974, 2004, 2030, 2050, 2066, 2078, + 2085, 2087, 2088, 2090, 2087, 2080, 2069, 2056, 2039, 2019, + 1996, 1970, 1942, 1911, 1878, 1842, 1804, 1765, 1723, 1680, + 1636, 1590, 1544, 1496, 1449, 1400, 1352, 1303, 1255, 1206, + 1158, 1109, 1062, 1015, 969, 924, 880, 837, 795, 754, + 714, 676, 640, 606, 572, 540, 510, 480, 452, 426, + 400, 376, 353, 332, 311, 291, 273, 255, 239, 223, + 208, 194, 181, 169, 158, 147, -138, -129, -121, -113, + -107, -100, -94, -88, -83, -78, -73, -68, -62, -57, + -53, -48, -43, -39, -35, -32, -28, -24, -21, -19, + -16, -13, -9, -5, -1, 2, 7, 10, 10, 15, + 20, 24, 28, 33, 36, 30, 22, 15, 9, 3, + -3, -10, -17, -26, -35, -43, -50, -57, -62, -67, + -72, -75, -76, -77, -77, -76, -74, -71, -68, -63, + -59, -54, -49, -44, -38, -31, -25, -19, -13, -7, + -2, 2, 5, 8, 10, 11, 11, 11, 11, 12, + 12, 12, 11, 9, 5, 2, 11, 20, 26, 31, + 36, 41, 45, 45, 44, 43, 40, 37, 33, 32, + 28, 23, 18, 13, 8, 1, -5, -8, -9, -11, + -13, -16, -20, -21, -19, -17, -16, -15, -16, -17, + -18, -19, -20, -20, 21, 21, 20, 19, 18, 18, + 17, 15, 13, 10, 5, 4, 4, 4, 3, 3, + 2, 1, 1, 0, 0, 0, -2, 1, 2, 0, + 1, 1, -1, -2, -3, -6, 0, 3, 2, 1, + 1, 1, 1, 1, 0, 2, 2, 2, 1, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, + 1, 0, 0, 0, 0, 0, 0, -1, -3, -3, + -3, -3, -3, -3, -3, -3, -4, -4, -2, -1, + -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, + 3, 1, -1, 0, -1, -1, 1, 1, 1, 10, + 4, 1, 1, 1, 1, 1, 1, 1, 1, -1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + + // WORD16 qmf_c_eld2[640]; + + {185, 386, 565, 759, 970, 1200, 1447, 1707, 1977, 2255, + 2535, 2818, 3099, 3379, 3657, 3933, 4208, 4481, 4754, 5027, + 5301, 5576, 5852, 6129, 6407, 6685, 6963, 7242, 7520, 7797, + 8073, 8349, 8624, 8898, 9172, 9445, 9717, 9989, 10259, 10528, + 10796, 11061, 11325, 11586, 11845, 12102, 12357, 12611, 12863, 13114, + 13364, 13612, 13858, 14103, 14344, 14581, 14813, 15040, 15260, 15473, + 15678, 15876, 16069, 16265, 16408, 16497, 16589, 16674, 16752, 16820, + 16879, 16928, 16969, 17001, 17027, 17045, 17057, 17063, 17063, 17056, + 17044, 17024, 16997, 16963, 16920, 16869, 16809, 16741, 16664, 16578, + 16484, 16381, 16270, 16150, 16023, 15887, 15743, 15590, 15430, 15262, + 15087, 14903, 14713, 14515, 14310, 14099, 13882, 13659, 13431, 13197, + 12958, 12715, 12467, 12214, 11958, 11698, 11435, 11168, 10899, 10627, + 10354, 10078, 9801, 9522, 9243, 8963, 8683, 8403, -8120, -7836, + -7553, -7270, -6989, -6710, -6431, -6155, -5881, -5610, -5341, -5076, + -4813, -4554, -4299, -4047, -3799, -3555, -3315, -3080, -2848, -2622, + -2399, -2182, -1969, -1761, -1558, -1360, -1167, -979, -796, -619, + -447, -280, -120, 36, 186, 330, 468, 601, 727, 848, + 964, 1073, 1177, 1275, 1368, 1454, 1535, 1610, 1679, 1742, + 1800, 1852, 1898, 1939, 1974, 2004, 2030, 2050, 2066, 2078, + 2085, 2087, 2088, 2090, 2087, 2080, 2069, 2056, 2039, 2019, + 1996, 1970, 1942, 1911, 1878, 1842, 1804, 1765, 1723, 1680, + 1636, 1590, 1544, 1496, 1449, 1400, 1352, 1303, 1255, 1206, + 1158, 1109, 1062, 1015, 969, 924, 880, 837, 795, 754, + 714, 676, 640, 606, 572, 540, 510, 480, 452, 426, + 400, 376, 353, 332, 311, 291, 273, 255, 239, 223, + 208, 194, 181, 169, 158, 147, -138, -129, -121, -113, + -107, -100, -94, -88, -83, -78, -73, -68, -62, -57, + -53, -48, -43, -39, -35, -32, -28, -24, -21, -19, + -16, -13, -9, -5, -1, 2, 7, 10, 10, 15, + 20, 24, 28, 33, 36, 30, 22, 15, 9, 3, + -3, -10, -17, -26, -35, -43, -50, -57, -62, -67, + -72, -75, -76, -77, -77, -76, -74, -71, -68, -63, + -59, -54, -49, -44, -38, -31, -25, -19, -13, -7, + -2, 2, 5, 8, 10, 11, 11, 11, 11, 12, + 12, 12, 11, 9, 5, 2, 11, 20, 26, 31, + 36, 41, 45, 45, 44, 43, 40, 37, 33, 32, + 28, 23, 18, 13, 8, 1, -5, -8, -9, -11, + -13, -16, -20, -21, -19, -17, -16, -15, -16, -17, + -18, -19, -20, -20, 21, 21, 20, 19, 18, 18, + 17, 15, 13, 10, 5, 4, 4, 4, 3, 3, + 2, 1, 1, 0, 0, 0, -2, 1, 2, 0, + 1, 1, -1, -2, -3, -6, 0, 3, 2, 1, + 1, 1, 1, 1, 0, 2, 2, 2, 1, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, + 1, 0, 0, 0, 0, 0, 0, -1, -3, -3, + -3, -3, -3, -3, -3, -3, -4, -4, -2, -1, + -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, + 3, 1, -1, 0, -1, -1, 1, 1, 1, 10, + 4, 1, 1, 1, 1, 1, 1, 1, 1, -1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + + // WORD16 qmf_c_eld3[640]; + { + 285, 662, 1085, 1577, 2116, 2676, 3239, 3795, 4344, 4890, + 5438, 5990, 6546, 7102, 7658, 8211, 8761, 9308, 9853, 10393, + 10928, 11455, 11973, 12484, 12988, 13488, 13980, 14462, 14926, 15366, + 15777, 16167, 16452, 16631, 16786, 16903, 16985, 17036, 17060, 17059, + 17034, 16980, 16894, 16775, 16621, 16432, 16210, 15955, 15666, 15346, + 14995, 14614, 14204, 13770, 13314, 12836, 12340, 11828, 11301, 10763, + 10216, 9661, 9103, 8543, -7978, -7412, -6850, -6293, -5746, -5209, + -4684, -4173, -3677, -3198, -2735, -2291, -1865, -1459, -1073, -708, + -364, -42, 258, 534, 787, 1018, 1226, 1411, 1572, 1710, + 1826, 1918, 1989, 2040, 2072, 2086, 2089, 2083, 2062, 2029, + 1983, 1926, 1860, 1784, 1701, 1613, 1520, 1424, 1327, 1230, + 1133, 1038, 946, 858, 774, 695, 623, 556, 495, 439, + 388, 342, 301, 264, 231, 201, 175, 152, -134, -117, + -104, -91, -81, -71, -60, -51, -41, -34, -26, -20, + -15, -7, 0, 8, 12, 22, 30, 33, 18, 6, + -7, -22, -39, -54, -65, -74, -77, -77, -73, -66, + -57, -47, -35, -22, -10, 0, 6, 10, 11, 11, + 12, 10, 3, 15, 28, 38, 45, 43, 38, 32, + 25, 15, 4, -7, -10, -15, -21, -18, -16, -17, + -19, -20, 21, 19, 18, 16, 11, 4, 4, 3, + 1, 0, 0, -1, 1, 1, -2, -5, 1, 1, + 1, 1, 1, 2, 1, 0, 0, 0, 0, 1, + 0, 0, 0, -1, -3, -3, -3, -3, -4, -2, + -1, -1, -1, 0, 0, 2, -1, -1, 1, 5, + 2, 1, 1, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 285, 662, 1085, 1577, 2116, 2676, 3239, 3795, 4344, 4890, + 5438, 5990, 6546, 7102, 7658, 8211, 8761, 9308, 9853, 10393, + 10928, 11455, 11973, 12484, 12988, 13488, 13980, 14462, 14926, 15366, + 15777, 16167, 16452, 16631, 16786, 16903, 16985, 17036, 17060, 17059, + 17034, 16980, 16894, 16775, 16621, 16432, 16210, 15955, 15666, 15346, + 14995, 14614, 14204, 13770, 13314, 12836, 12340, 11828, 11301, 10763, + 10216, 9661, 9103, 8543, -7978, -7412, -6850, -6293, -5746, -5209, + -4684, -4173, -3677, -3198, -2735, -2291, -1865, -1459, -1073, -708, + -364, -42, 258, 534, 787, 1018, 1226, 1411, 1572, 1710, + 1826, 1918, 1989, 2040, 2072, 2086, 2089, 2083, 2062, 2029, + 1983, 1926, 1860, 1784, 1701, 1613, 1520, 1424, 1327, 1230, + 1133, 1038, 946, 858, 774, 695, 623, 556, 495, 439, + 388, 342, 301, 264, 231, 201, 175, 152, -134, -117, + -104, -91, -81, -71, -60, -51, -41, -34, -26, -20, + -15, -7, 0, 8, 12, 22, 30, 33, 18, 6, + -7, -22, -39, -54, -65, -74, -77, -77, -73, -66, + -57, -47, -35, -22, -10, 0, 6, 10, 11, 11, + 12, 10, 3, 15, 28, 38, 45, 43, 38, 32, + 25, 15, 4, -7, -10, -15, -21, -18, -16, -17, + -19, -20, 21, 19, 18, 16, 11, 4, 4, 3, + 1, 0, 0, -1, 1, 1, -2, -5, 1, 1, + 1, 1, 1, 2, 1, 0, 0, 0, 0, 1, + 0, 0, 0, -1, -3, -3, -3, -3, -4, -2, + -1, -1, -1, 0, 0, 2, -1, -1, 1, 5, + 2, 1, 1, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }, + // const WORD16 ixheaacd_sbr_synth_cos_sin_l32[64+64] = //exp[-i * pi/4* (2k + // + 1)] + { + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + (WORD16)0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, + (WORD16)-0x5a82, (WORD16)-0x5a82, (WORD16)0x5a82, (WORD16)-0x5a82, + + }, + +}; + +const ia_env_extr_tables_struct ixheaacd_aac_dec_env_extr_tables = { + { + // const ia_frame_info_struct sbr_frame_info1_16 = + {0, + 1, + -1, + 1, + {0, 16, 0, 0, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 16, 0}}, + + // const ia_frame_info_struct sbr_frame_info2_16 = + {0, + 2, + -1, + 2, + {0, 8, 16, 0, 0, 0, 0, 0, 0}, + {1, 1, 0, 0, 0, 0, 0, 0}, + {0, 8, 16}}, + + // const ia_frame_info_struct sbr_frame_info4_16 = + {0, + 4, + -1, + 2, + {0, 4, 8, 12, 16, 0, 0, 0, 0}, + {1, 1, 1, 1, 0, 0, 0, 0}, + {0, 8, 16}}, + + // const ia_frame_info_struct sbr_frame_info8_16 = + {0, + 8, + -1, + 2, + {0, 2, 4, 6, 8, 10, 12, 14, 16}, + {1, 1, 1, 1, 1, 1, 1, 1}, + {0, 8, 16}}, + + }, + + // const ia_sbr_header_data_struct sbr_default_header = + {SBR_NOT_INITIALIZED, + 0, + 0, + 16, + 2, + 1024, + 44100, + + 0, + SBR_AMPLITUDE_RESOLUTION_3_0, + + 15, + 6, + 0, + SBR_SAMP_FEQ_LVL_DEF, + SBR_CHANGE_LVL_DEF, + SBR_NOISE_BND_DEF, + + SBR_BND_LIMIT_DEF, + SBR_GAIN_LIMIT_DEF, + SBR_INTERPOL_SAMP_FEQ_DEF, + SBR_SMOOTH_LEN_DEF, + + NULL, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}, + + // WORD16 ixheaacd_t_huffman_env_bal_1_5db_inp_table[50]; + {0x0011, 0x0301, 0x0322, 0x02e3, 0x0344, 0x02c5, 0x0366, 0x02a7, 0x0388, + 0x0289, 0x026b, 0x03ab, 0x024c, 0x03cc, 0x03ef, 0x0230, 0x0410, 0x0010, + 0x0030, 0x0050, 0x0070, 0x0090, 0x00b0, 0x00d0, 0x00f0, 0x0110, 0x0130, + 0x0150, 0x0170, 0x0190, 0x01b0, 0x01d0, 0x01f0, 0x0210, 0x0430, 0x0450, + 0x0470, 0x0490, 0x04b0, 0x04d0, 0x04f1, 0x0511, 0x0531, 0x0551, 0x0571, + 0x0591, 0x05b1, 0x05d1, 0x05f1, 0x0611}, + // WORD16 ixheaacd_f_huffman_env_bal_1_5db_inp_table[50]; + {0x0013, 0x0301, 0x02e2, 0x0323, 0x02c4, 0x0345, 0x0366, 0x02a7, 0x0288, + 0x0389, 0x026b, 0x03ab, 0x024b, 0x03cc, 0x022e, 0x03ef, 0x0410, 0x01f0, + 0x0211, 0x0012, 0x0032, 0x0052, 0x0072, 0x0092, 0x00b2, 0x00d2, 0x00f2, + 0x0112, 0x0132, 0x0152, 0x0172, 0x0192, 0x01b2, 0x01d2, 0x0432, 0x0452, + 0x0472, 0x0492, 0x04b2, 0x04d2, 0x04f2, 0x0512, 0x0532, 0x0552, 0x0572, + 0x0592, 0x05b2, 0x05d2, 0x05f3, 0x0613}, + // WORD16 ixheaacd_t_huffman_env_bal_3_0db_inp_table[26]; + {0x000e, 0x0181, 0x01a2, 0x0163, 0x0144, 0x01c5, 0x01e6, 0x0127, 0x0108, + 0x0209, 0x00ec, 0x000d, 0x002d, 0x004d, 0x006d, 0x008d, 0x00ad, 0x00cd, + 0x022d, 0x024d, 0x026d, 0x028d, 0x02ad, 0x02cd, 0x02ee, 0x030e}, + // WORD16 ixheaacd_f_huffman_env_bal_3_0db_inp_table[26]; + {0x000e, 0x0181, 0x0162, 0x01a3, 0x0144, 0x01c5, 0x01e6, 0x0127, 0x0108, + 0x0209, 0x00eb, 0x022c, 0x024d, 0x000d, 0x002d, 0x004d, 0x006d, 0x008d, + 0x00ae, 0x00ce, 0x026e, 0x028e, 0x02ae, 0x02ce, 0x02ee, 0x030e}, + // WORD16 ixheaacd_t_huffman_noise_3_0db_inp_table[64]; + {0x000e, 0x03e1, 0x0402, 0x03c3, 0x03a4, 0x0425, 0x0386, 0x0448, + 0x0368, 0x046a, 0x034b, 0x048d, 0x054d, 0x000d, 0x002d, 0x004d, + 0x006d, 0x008d, 0x00ad, 0x00cd, 0x00ed, 0x010d, 0x012d, 0x014d, + 0x016d, 0x018d, 0x01ad, 0x01cd, 0x01ed, 0x020d, 0x022d, 0x024d, + 0x026d, 0x028d, 0x02ad, 0x02cd, 0x02ed, 0x030d, 0x032d, 0x04ad, + 0x04cd, 0x04ed, 0x050d, 0x052d, 0x056d, 0x058d, 0x05ad, 0x05cd, + 0x05ed, 0x060d, 0x062d, 0x064d, 0x066d, 0x068d, 0x06ad, 0x06cd, + 0x06ed, 0x070d, 0x072d, 0x074d, 0x076d, 0x078d, 0x07ae, 0x07ce}, + // WORD16 ixheaacd_t_huffman_noise_bal_3_0db_inp_table[26]; + {0x0008, 0x0181, 0x0162, 0x01a3, 0x0145, 0x01c6, 0x0008, 0x0028, 0x0048, + 0x0068, 0x0088, 0x00a8, 0x00c8, 0x00e8, 0x0108, 0x0128, 0x01e8, 0x0208, + 0x0228, 0x0248, 0x0268, 0x0288, 0x02a8, 0x02c8, 0x02e8, 0x0308}, + // WORD16 ixheaacd_t_huffman_env_1_5db_inp_table[122]; + {0x0013, 0x0782, 0x0762, 0x07a3, 0x0743, 0x07c4, 0x0724, 0x07e5, 0x0705, + 0x0806, 0x06e6, 0x0827, 0x06c7, 0x0848, 0x06a8, 0x0869, 0x0689, 0x066a, + 0x088a, 0x064b, 0x08ac, 0x062c, 0x08cd, 0x060d, 0x05ed, 0x08ee, 0x05ce, + 0x090e, 0x05ae, 0x058f, 0x092f, 0x0530, 0x0550, 0x0570, 0x0950, 0x0490, + 0x0510, 0x0990, 0x0451, 0x04f1, 0x0971, 0x04b1, 0x0472, 0x04d2, 0x0012, + 0x0032, 0x0052, 0x0072, 0x0092, 0x00b2, 0x00d3, 0x00f3, 0x0113, 0x0133, + 0x0153, 0x0173, 0x0193, 0x01b3, 0x01d3, 0x01f3, 0x0213, 0x0233, 0x0253, + 0x0273, 0x0293, 0x02b3, 0x02d3, 0x02f3, 0x0313, 0x0333, 0x0353, 0x0373, + 0x0393, 0x03b3, 0x03d3, 0x03f3, 0x0413, 0x0433, 0x09b3, 0x09d3, 0x09f3, + 0x0a13, 0x0a33, 0x0a53, 0x0a73, 0x0a93, 0x0ab3, 0x0ad3, 0x0af3, 0x0b13, + 0x0b33, 0x0b53, 0x0b73, 0x0b93, 0x0bb3, 0x0bd3, 0x0bf3, 0x0c13, 0x0c33, + 0x0c53, 0x0c73, 0x0c93, 0x0cb3, 0x0cd3, 0x0cf3, 0x0d13, 0x0d33, 0x0d53, + 0x0d73, 0x0d93, 0x0db3, 0x0dd3, 0x0df3, 0x0e13, 0x0e33, 0x0e53, 0x0e73, + 0x0e93, 0x0eb3, 0x0ed3, 0x0ef3, 0x0f13}, + // WORD16 ixheaacd_f_huffman_env_1_5db_inp_table[122]; + {0x0014, 0x0782, 0x0762, 0x07a3, 0x0743, 0x0724, 0x07c4, 0x0705, 0x07e5, + 0x06e6, 0x0806, 0x06c7, 0x0828, 0x06a8, 0x0848, 0x0689, 0x0869, 0x0669, + 0x088a, 0x064a, 0x08ab, 0x062b, 0x08cb, 0x08eb, 0x060c, 0x090c, 0x05ec, + 0x092c, 0x094d, 0x05cd, 0x05ad, 0x096d, 0x098e, 0x09ae, 0x058e, 0x056f, + 0x054f, 0x0530, 0x09d0, 0x09f0, 0x0510, 0x04f0, 0x0a11, 0x0a31, 0x0491, + 0x04b1, 0x04d1, 0x0451, 0x0412, 0x0a52, 0x0a72, 0x0ab2, 0x0272, 0x0472, + 0x0ad2, 0x0af2, 0x03d2, 0x0432, 0x0a92, 0x0b12, 0x0d12, 0x0133, 0x01d3, + 0x0213, 0x0233, 0x02f3, 0x0373, 0x03b3, 0x03f3, 0x0b53, 0x0c33, 0x0cd3, + 0x0d73, 0x0d93, 0x0013, 0x0033, 0x0054, 0x0074, 0x0094, 0x00b4, 0x00d4, + 0x00f4, 0x0114, 0x0154, 0x0174, 0x0194, 0x01b4, 0x01f4, 0x0254, 0x0294, + 0x02b4, 0x02d4, 0x0314, 0x0334, 0x0354, 0x0394, 0x0b34, 0x0b74, 0x0b94, + 0x0bb4, 0x0bd4, 0x0bf4, 0x0c14, 0x0c54, 0x0c74, 0x0c94, 0x0cb4, 0x0cf4, + 0x0d34, 0x0d54, 0x0db4, 0x0dd4, 0x0df4, 0x0e14, 0x0e34, 0x0e54, 0x0e74, + 0x0e94, 0x0eb4, 0x0ed4, 0x0ef4, 0x0f14}, + // WORD16 ixheaacd_t_huffman_env_3_0db_inp_table[64]; + {0x0013, 0x03e1, 0x03c2, 0x0403, 0x03a4, 0x0425, 0x0386, 0x0447, + 0x0368, 0x0469, 0x034b, 0x048b, 0x032c, 0x030d, 0x04ad, 0x02ee, + 0x04ce, 0x02ce, 0x02ae, 0x04ee, 0x050f, 0x0530, 0x0250, 0x0290, + 0x0270, 0x0231, 0x0551, 0x0572, 0x0012, 0x0032, 0x0053, 0x0073, + 0x0093, 0x00b3, 0x00d3, 0x00f3, 0x0113, 0x0133, 0x0153, 0x0173, + 0x0193, 0x01b3, 0x01d3, 0x01f3, 0x0213, 0x0593, 0x05b3, 0x05d3, + 0x05f3, 0x0613, 0x0633, 0x0653, 0x0673, 0x0693, 0x06b3, 0x06d3, + 0x06f3, 0x0713, 0x0733, 0x0753, 0x0773, 0x0793, 0x07b3, 0x07d3}, + // WORD16 ixheaacd_f_huffman_env_3_0db_inp_table[64]; + {0x0014, 0x03e1, 0x03c2, 0x0403, 0x03a4, 0x0425, 0x0386, 0x0448, + 0x0368, 0x0469, 0x0349, 0x048a, 0x032a, 0x04ab, 0x030b, 0x04cc, + 0x02ec, 0x04ed, 0x050e, 0x02ce, 0x02af, 0x052f, 0x054f, 0x0290, + 0x0270, 0x0570, 0x0590, 0x0251, 0x0211, 0x05b1, 0x05d1, 0x0232, + 0x0632, 0x01b2, 0x00f2, 0x0192, 0x05f2, 0x0612, 0x0133, 0x0153, + 0x01f3, 0x0673, 0x0693, 0x06b3, 0x0713, 0x0113, 0x0173, 0x06f3, + 0x0014, 0x0034, 0x0054, 0x0074, 0x0094, 0x00b4, 0x00d4, 0x01d4, + 0x0654, 0x06d4, 0x0734, 0x0754, 0x0774, 0x0794, 0x07b4, 0x07d4}, + // WORD32 ixheaacd_t_huffman_env_bal_1_5db_idx_table[20]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, + 0x0050003e, 0x0060007e, 0x007000fe, 0x008001fe, 0x00a007fd, + 0x00c00ffd, 0x10d07ff0, 0x0230fff7, 0x2260fffa, 0x02c1fffb, + 0x02e1fffd, 0x02f1fffe, 0x0301ffff, 0x01b0ffef, 0x0281fff7}, + // WORD32 ixheaacd_f_huffman_env_bal_1_5db_idx_table[23]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, 0x0050003e, + 0x0060007e, 0x007000fe, 0x008001fe, 0x00a007fd, 0x00b007fe, 0x00c00ffe, + 0x10d03ffc, 0x2111fff0, 0x0273fff7, 0x02b3fffb, 0x02d3fffd, 0x02e3fffe, + 0x02f7fffe, 0x0307ffff, 0x20e07ffa, 0x01f3ffef, 0x0100fff7}, + // WORD32 ixheaacd_t_huffman_env_bal_3_0db_idx_table[16]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, 0x0050003e, + 0x0060007e, 0x007000fe, 0x008001fe, 0x10900ff8, 0x01301ffb, 0x01501ffd, + 0x01601ffe, 0x01703ffe, 0x01803fff, 0x00f01ff7}, + // WORD32 ixheaacd_f_huffman_env_bal_3_0db_idx_table[17]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, 0x0050003e, + 0x0060007e, 0x007000fe, 0x008001fe, 0x109007fc, 0x01001ffb, 0x01403ffb, + 0x01603ffd, 0x01703ffe, 0x01803fff, 0x10a00ffa, 0x00c01ff7}, + // WORD32 ixheaacd_t_huffman_noise_3_0db_idx_table[17]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, 0x0050003e, + 0x007000fd, 0x108003f8, 0x02d01fef, 0x03501ff7, 0x03901ffb, 0x03b01ffd, + 0x03c01ffe, 0x03d03ffe, 0x03e03fff, 0x109007f2, 0x01d01fdf}, + // WORD32 ixheaacd_t_huffman_noise_bal_3_0db_idx_table[11]; + {0x00000000, 0x00100002, 0x00200006, 0x1030001c, 0x010000f7, 0x014000fb, + 0x016000fd, 0x017000fe, 0x018000ff, 0x1040003a, 0x008000ef}, + // WORD32 ixheaacd_t_huffman_env_1_5db_idx_table[27]; + {0x00100001, 0x00300005, 0x0050000d, 0x0070001d, 0x0090003d, 0x00b0007d, + 0x00d000fd, 0x00f001fd, 0x011003fd, 0x112007fc, 0x21701ffa, 0x31b03ff9, + 0x4240fff2, 0x0587ffdf, 0x0687ffef, 0x0707fff7, 0x0747fffb, 0x0767fffd, + 0x0777fffe, 0x0787ffff, 0x01400ffb, 0x01903ff7, 0x21d07ff5, 0x2281ffe9, + 0x0210ffef, 0x1303ffdb, 0x0387ffbf}, + // WORD32 ixheaacd_f_huffman_env_1_5db_idx_table[28]; + {0x00100001, 0x00300005, 0x0050000d, 0x0070001d, 0x0090003d, 0x10a0007c, + 0x20d000fc, 0x310001fc, 0x016007fb, 0x01a00ffb, 0x01e01ffb, 0x42103ffa, + 0x5280fff4, 0x63b3ffec, 0x74a7ffe8, 0x068fffef, 0x070ffff7, 0x074ffffb, + 0x076ffffd, 0x077ffffe, 0x078fffff, 0x00c000fb, 0x00f001fb, 0x012003fb, + 0x02307ff7, 0x02e1ffef, 0x0417ffdf, 0x058fffdf}, + // WORD32 ixheaacd_t_huffman_env_3_0db_idx_table[26]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, 0x0050003e, + 0x0060007e, 0x007000fe, 0x008001fe, 0x00a007fd, 0x10b00ffc, 0x01103ffb, + 0x21203ffc, 0x3170fff9, 0x02e7ffef, 0x0367fff7, 0x03a7fffb, 0x03c7fffd, + 0x03d7fffe, 0x03e7ffff, 0x00d01ffb, 0x21307ffa, 0x2191fff5, 0x0150fff7, + 0x11c3ffee, 0x01e7ffdf}, + // WORD32 ixheaacd_f_huffman_env_3_0db_idx_table[25]; + {0x00000000, 0x00100002, 0x00200006, 0x0030000e, 0x0040001e, + 0x0050003e, 0x007000fd, 0x009001fd, 0x00b003fd, 0x00d007fd, + 0x00f00ffd, 0x11001ffc, 0x21507ffa, 0x3190fff9, 0x4243fff6, + 0x02e7fff7, 0x036ffff7, 0x03affffb, 0x03cffffd, 0x03dffffe, + 0x03efffff, 0x01203ffb, 0x0170fff7, 0x01d1fff7, 0x0267ffef}, + + // const WORD8 start_min[12] = + {7, 7, 10, 11, 12, 16, 16, 17, 24, 32, 35, 48}, + + // const WORD8 offset_idx[12] = + {5, 5, 4, 4, 4, 3, 2, 1, 0, 6, 6, 6}, + + // const WORD8 ixheaacd_drc_offset[7][16] = + {{-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, + {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, + {-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + {-6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + {-4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, + {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, + {0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33}}, + + // const WORD8 stop_min[12] = + {13, 15, 20, 21, 23, 32, 32, 35, 48, 64, 70, 96}, + + // const WORD8 stop_off[12][14] = + {{0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51}, + {0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49}, + {0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44}, + {0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43}, + {0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41}, + {0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32}, + {0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6}, + {0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32}} + +}; + +const ia_ps_tables_struct ixheaacd_aac_dec_ps_tables = { + { + // const WORD16 decay_scale_factor[70]= + + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x5361, 0x4848, 0x3ea8, 0x4f36, 0x44ab, 0x3b86, 0x4b0b, 0x410e, 0x3864, + 0x46e0, 0x3d71, 0x3542, 0x42b5, 0x39d4, 0x3221, 0x3e8a, 0x3637, 0x2eff, + 0x3a5f, 0x329a, 0x2bdd, 0x3634, 0x2efd, 0x28bb, 0x3209, 0x2b60, 0x2599, + 0x2ddd, 0x27c3, 0x2277, 0x29b2, 0x2426, 0x1f55, 0x2587, 0x2089, 0x1c34, + 0x215c, 0x1cec, 0x1912, 0x1d31, 0x194f, 0x15f0, 0x1906, 0x15b2, 0x12ce, + 0x14db, 0x1215, 0x0fac, 0x10b0, 0x0e78, 0x0c8a, 0x0c85, 0x0adb, 0x0968, + 0x085a, 0x073e, 0x0647, 0x042f, 0x03a0, 0x0325, 0x0000, 0x0000, 0x0000, + } + + , + // const WORD16 hyb_resol[3] = + {8, 2, 2}, + + // const WORD16 rev_link_decay_ser[NO_SERIAL_ALLPASS_LINKS]= + {0x5362, 0x4849, 0x3ea9}, + + // const WORD16 rev_link_delay_ser[3] = + {3, 4, 5}, + + // const WORD16 borders_group[NO_IID_GROUPS + 1] = + {4, 5, 0, 1, 2, 3, 7, 6, 8, 9, 3, 4, 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64}, + + // const WORD16 group_shift[6] = + {0, 1, 1, 2, 3, 4}, + + // const WORD16 group_to_bin[NO_IID_GROUPS] = + {0, 1, 2, 3, 1, 0, 5, 4, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, + + // const WORD16 hybrid_to_bin[SUBQMF_GROUPS] = + {0, 1, 2, 3, 1, 0, 5, 4, 6, 7}, + + // const WORD16 delay_to_bin[32] = + {20, 20, 20, 8, 9, 10, 11, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, + 16, 17, 17, 17, 17, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20 + + }, + + // const WORD16 frac_delay_phase_fac_qmf_re_im[24*2]= + { + 0, + 0, + 0, + 0, + 0, + 0, + (WORD16)-0x34ac, + (WORD16)0x74a9, + (WORD16)0x5bec, + (WORD16)0x5914, + (WORD16)0x72f3, + (WORD16)-0x3850, + (WORD16)-0x0e0c, + (WORD16)-0x7f3a, + (WORD16)-0x7c77, + (WORD16)-0x1de2, + (WORD16)-0x4646, + (WORD16)0x6afc, + (WORD16)0x4cdb, + (WORD16)0x665c, + (WORD16)0x7a57, + (WORD16)-0x25a3, + (WORD16)0x0608, + (WORD16)-0x7fdc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)-0x5625, + (WORD16)0x5eac, + (WORD16)0x3be5, + (WORD16)0x711f, + (WORD16)0x7eb9, + (WORD16)-0x1209, + (WORD16)0x19f5, + (WORD16)-0x7d57, + (WORD16)-0x6d23, + (WORD16)-0x42e1, + (WORD16)-0x63e5, + (WORD16)0x5008, + (WORD16)0x2976, + (WORD16)0x7919, + (WORD16)0x7ffc, + (WORD16)0x0203, + (WORD16)0x2d3f, + (WORD16)-0x77bd, + (WORD16)-0x6155, + (WORD16)-0x5321, + }, + + // const WORD16 frac_delay_phase_fac_qmf_sub_re_im[16*2]= + { + (WORD16)0x7e80, (WORD16)-0x1387, (WORD16)0x72ba, (WORD16)-0x38c3, + (WORD16)0x5c45, (WORD16)-0x58b7, (WORD16)0x3d39, (WORD16)-0x7069, + (WORD16)0x72ba, (WORD16)0x38c3, (WORD16)0x7e80, (WORD16)0x1387, + (WORD16)-0x456f, (WORD16)-0x6b88, (WORD16)0x0506, (WORD16)-0x7fe7, + (WORD16)-0x76a3, (WORD16)-0x300e, (WORD16)-0x7cb2, (WORD16)0x1ce7, + }, + + // const WORD16 frac_delay_phase_fac_qmf_ser_re_im[3][32]= + { + // const WORD16 + { + 0, + 0, + 0, + 0, + 0, + 0, + (WORD16)0x0203, + (WORD16)0x7ffc, + (WORD16)0x7d57, + (WORD16)0x19f5, + (WORD16)0x34ac, + (WORD16)-0x74a9, + (WORD16)-0x665c, + (WORD16)-0x4cdb, + (WORD16)-0x6155, + (WORD16)0x5321, + (WORD16)0x3be5, + (WORD16)0x711f, + (WORD16)0x7b77, + (WORD16)-0x21c7, + (WORD16)-0x0608, + (WORD16)-0x7fdc, + (WORD16)-0x7e18, + (WORD16)-0x1602, + (WORD16)-0x30fc, + (WORD16)0x7642, + (WORD16)0x68b9, + (WORD16)0x499a, + (WORD16)0x5eac, + (WORD16)-0x5625, + (WORD16)-0x3f6b, + (WORD16)-0x6f2f, + (WORD16)-0x7a57, + (WORD16)0x25a3, + (WORD16)0x0a0b, + (WORD16)0x7f9b, + (WORD16)0x7eb9, + (WORD16)0x1209, + (WORD16)0x2d3f, + (WORD16)-0x77bd, + (WORD16)-0x6afc, + (WORD16)-0x4646, + (WORD16)-0x5bec, + (WORD16)0x5914, + (WORD16)0x42e1, + (WORD16)0x6d23, + }, + + // const WORD16 + { + 0, + 0, + 0, + 0, + 0, + 0, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)0x7642, + (WORD16)0x7642, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)0x30fc, + (WORD16)0x7642, + (WORD16)0x30fc, + (WORD16)-0x7642, + (WORD16)-0x7642, + (WORD16)0x30fc, + (WORD16)0x7642, + (WORD16)0x30fc, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)0x7642, + (WORD16)0x7642, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)0x30fc, + (WORD16)0x7642, + (WORD16)0x30fc, + (WORD16)-0x7642, + (WORD16)-0x7642, + (WORD16)0x30fc, + (WORD16)0x7642, + (WORD16)0x30fc, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + (WORD16)0x7642, + (WORD16)0x7642, + (WORD16)-0x30fc, + (WORD16)-0x7642, + (WORD16)-0x30fc, + }, + + // const WORD16 + { + 0, + 0, + 0, + 0, + 0, + 0, + (WORD16)-0x6405, + (WORD16)0x4fe0, + (WORD16)0x1894, + (WORD16)0x7d9e, + (WORD16)0x7abf, + (WORD16)0x244a, + (WORD16)0x58ef, + (WORD16)-0x5c0f, + (WORD16)-0x2882, + (WORD16)-0x796c, + (WORD16)-0x7e64, + (WORD16)-0x1439, + (WORD16)-0x4c5f, + (WORD16)0x66b8, + (WORD16)0x37c5, + (WORD16)0x7336, + (WORD16)0x7ff1, + (WORD16)0x03d2, + (WORD16)0x3e8b, + (WORD16)-0x6fae, + (WORD16)-0x461b, + (WORD16)-0x6b18, + (WORD16)-0x7f60, + (WORD16)0x0ca5, + (WORD16)-0x2fae, + (WORD16)0x76ca, + (WORD16)0x5348, + (WORD16)0x6134, + (WORD16)0x7cb2, + (WORD16)-0x1ce7, + (WORD16)0x2007, + (WORD16)-0x7bee, + (WORD16)-0x5f14, + (WORD16)-0x55b3, + (WORD16)-0x77f3, + (WORD16)0x2cae, + (WORD16)-0x0fd8, + (WORD16)0x7f04, + (WORD16)0x694c, + (WORD16)0x48c7, + }, + + }, + // const WORD16 frac_delay_phase_fac_qmf_sub_ser_re_im[3][16]= + { + { + (WORD16)0x7e2e, (WORD16)-0x1583, (WORD16)0x6fed, (WORD16)-0x3e1b, + (WORD16)0x5506, (WORD16)-0x5fae, (WORD16)0x3085, (WORD16)-0x7673, + (WORD16)0x6fed, (WORD16)0x3e1b, (WORD16)0x7e2e, (WORD16)0x1583, + (WORD16)-0x5b38, (WORD16)-0x59cc, (WORD16)-0x0f0b, (WORD16)-0x7f1d, + (WORD16)-0x7f55, (WORD16)-0x0d0c, (WORD16)-0x6b88, (WORD16)0x456f, + }, + { + (WORD16)0x7a7d, (WORD16)-0x2528, (WORD16)0x5134, (WORD16)-0x62f2, + (WORD16)0x0c8c, (WORD16)-0x7f62, (WORD16)-0x3c57, (WORD16)-0x70e3, + (WORD16)0x5134, (WORD16)0x62f2, (WORD16)0x7a7d, (WORD16)0x2528, + (WORD16)-0x471d, (WORD16)0x6a6e, (WORD16)-0x7d8a, (WORD16)-0x18f9, + (WORD16)0x471d, (WORD16)0x6a6e, (WORD16)0x7d8a, (WORD16)-0x18f9, + }, + { + (WORD16)0x7ed0, (WORD16)-0x1163, (WORD16)0x7574, (WORD16)-0x32e2, + (WORD16)0x636c, (WORD16)-0x509e, (WORD16)0x4a0d, (WORD16)-0x6867, + (WORD16)0x7574, (WORD16)0x32e2, (WORD16)0x7ed0, (WORD16)0x1163, + (WORD16)-0x2a51, (WORD16)-0x78ce, (WORD16)0x1a73, (WORD16)-0x7d3d, + (WORD16)-0x62d1, (WORD16)-0x515c, (WORD16)-0x7eae, (WORD16)-0x1255, + }, + + }, + // const WORD16 scale_factors[NO_IID_LEVELS]= + {(WORD16)0x5a5e, (WORD16)0x59cd, (WORD16)0x58c3, (WORD16)0x564c, + (WORD16)0x52a4, (WORD16)0x4c8c, (WORD16)0x46df, (WORD16)0x4000, + (WORD16)0x384c, (WORD16)0x304c, (WORD16)0x24ea, (WORD16)0x1b4a, + (WORD16)0x11b6, (WORD16)0x0b4e, (WORD16)0x0515}, + + // const WORD16 scale_factors_fine[NO_IID_LEVELS_FINE] = + {(WORD16)0x5a82, (WORD16)0x5a82, (WORD16)0x5a81, (WORD16)0x5a7f, + (WORD16)0x5a77, (WORD16)0x5a5e, (WORD16)0x5a3a, (WORD16)0x59f2, + (WORD16)0x5965, (WORD16)0x5853, (WORD16)0x564c, (WORD16)0x5417, + (WORD16)0x50ea, (WORD16)0x4c8c, (WORD16)0x46df, (WORD16)0x4000, + (WORD16)0x384c, (WORD16)0x304c, (WORD16)0x288e, (WORD16)0x217a, + (WORD16)0x1b4a, (WORD16)0x13c6, (WORD16)0x0e2b, (WORD16)0x0a18, + (WORD16)0x072b, (WORD16)0x0515, (WORD16)0x02dc, (WORD16)0x019c, + (WORD16)0x00e8, (WORD16)0x0082, (WORD16)0x0049}, + + // const WORD16 alpha_values[NO_ICC_LEVELS]= + {(WORD16)0x0000, (WORD16)0x0b6b, (WORD16)0x1248, (WORD16)0x1da3, + (WORD16)0x2638, (WORD16)0x3244, (WORD16)0x466b, (WORD16)0x6488}, + + // const WORD32 p2_6[6] = + { + (WORD32)0x026e, (WORD32)-0x0956, (WORD32)0x272a, (WORD32)0x272a, + (WORD32)-0x0956, (WORD32)0x026e, + }, + + // const WORD32 p8_13[13] = + { + (WORD32)-0x00f4, (WORD32)-0x02e8, (WORD32)-0x05d2, (WORD32)-0x094d, + (WORD32)-0x0ca7, (WORD32)0x0f19, (WORD32)0x1000, (WORD32)0x0f19, + (WORD32)0x0ca7, (WORD32)0x094d, (WORD32)0x05d2, (WORD32)0x02e8, + (WORD32)0x00f4, + }, + + // const WORD16 huff_iid_dt[28] = + { + (WORD16)-0x3fff, (WORD16)-0x40fe, (WORD16)-0x3efd, (WORD16)-0x41fc, + (WORD16)-0x3dfb, (WORD16)-0x42fa, (WORD16)-0x3cf9, (WORD16)-0x43f8, + (WORD16)-0x3bf7, (WORD16)-0x44f6, (WORD16)-0x3af5, (WORD16)-0x45f4, + (WORD16)-0x39f3, (WORD16)-0x38f2, (WORD16)-0x46f1, (WORD16)0x1011, + (WORD16)-0x3748, (WORD16)0x1215, (WORD16)0x1314, (WORD16)-0x364e, + (WORD16)-0x4c4c, (WORD16)0x1619, (WORD16)0x1718, (WORD16)-0x4a4a, + (WORD16)-0x4836, (WORD16)0x1a1b, (WORD16)-0x3434, (WORD16)-0x3232, + }, + + // const WORD16 huff_iid_df[28] = + { + (WORD16)-0x3fff, (WORD16)0x0203, (WORD16)-0x3e41, (WORD16)0x0405, + (WORD16)-0x3d42, (WORD16)0x0607, (WORD16)-0x3c43, (WORD16)0x0809, + (WORD16)-0x433c, (WORD16)-0x3af6, (WORD16)-0x44f5, (WORD16)-0x39f4, + (WORD16)-0x45f3, (WORD16)-0x46f2, (WORD16)-0x38f1, (WORD16)0x1011, + (WORD16)-0x3748, (WORD16)0x1213, (WORD16)-0x3636, (WORD16)0x1415, + (WORD16)-0x4835, (WORD16)0x1618, (WORD16)-0x49e9, (WORD16)-0x4a4e, + (WORD16)0x191a, (WORD16)-0x4c4c, (WORD16)-0x33e5, (WORD16)-0x3232, + }, + + // const WORD16 huff_icc_dt[14] = + { + (WORD16)-0x3fff, (WORD16)-0x3efe, (WORD16)-0x40fd, (WORD16)-0x3dfc, + (WORD16)-0x41fb, (WORD16)-0x3cfa, (WORD16)-0x42f9, (WORD16)-0x3bf8, + (WORD16)-0x43f7, (WORD16)-0x3af6, (WORD16)-0x44f5, (WORD16)-0x39f4, + (WORD16)-0x45f3, (WORD16)-0x4639, + }, + + // const WORD16 huff_icc_df[14] = + { + (WORD16)-0x3fff, (WORD16)-0x3efe, (WORD16)-0x40fd, (WORD16)-0x3dfc, + (WORD16)-0x41fb, (WORD16)-0x3cfa, (WORD16)-0x42f9, (WORD16)-0x3bf8, + (WORD16)-0x3af7, (WORD16)-0x43f6, (WORD16)-0x39f5, (WORD16)-0x44f4, + (WORD16)-0x38f3, (WORD16)-0x4547, + }, + + // const WORD16 huff_iid_dt_fine[60] = + { + (WORD16)0x01c0, (WORD16)-0x3efe, (WORD16)0x03bf, (WORD16)0x043b, + (WORD16)0x0507, (WORD16)0x06bd, (WORD16)-0x433c, (WORD16)-0x3cf8, + (WORD16)0x090b, (WORD16)-0x3af6, (WORD16)-0x453a, (WORD16)0x0c29, + (WORD16)0x0d14, (WORD16)0x0eb9, (WORD16)-0x36f1, (WORD16)-0x34f0, + (WORD16)0x11b3, (WORD16)0x1213, (WORD16)-0x5454, (WORD16)-0x2d2d, + (WORD16)-0x38eb, (WORD16)0x1628, (WORD16)0x171d, (WORD16)-0x32e8, + (WORD16)0x191a, (WORD16)-0x5252, (WORD16)0x1b1c, (WORD16)-0x5926, + (WORD16)-0x5b5b, (WORD16)0x1e25, (WORD16)0x1f22, (WORD16)0x2021, + (WORD16)-0x2222, (WORD16)-0x2424, (WORD16)0x2324, (WORD16)-0x5d5d, + (WORD16)-0x5827, (WORD16)0x26b1, (WORD16)0x27af, (WORD16)-0x5728, + (WORD16)-0x4936, (WORD16)0x2abb, (WORD16)0x2b2c, (WORD16)-0x4738, + (WORD16)0x2d34, (WORD16)0x2e32, (WORD16)0x2fb4, (WORD16)-0x30d0, + (WORD16)-0x2ecf, (WORD16)-0x5629, (WORD16)-0x33cd, (WORD16)-0x4d32, + (WORD16)0x35b7, (WORD16)0x36b5, (WORD16)0x3739, (WORD16)0x38b0, + (WORD16)-0x552a, (WORD16)-0x2fc6, (WORD16)-0x2b2b, (WORD16)-0x413e, + }, + + // const WORD16 huff_iid_df_fine[60] = + { + (WORD16)0x01c0, (WORD16)0x0204, (WORD16)0x03bf, (WORD16)-0x413e, + (WORD16)-0x3efb, (WORD16)0x0607, (WORD16)-0x423d, (WORD16)0x0809, + (WORD16)-0x433c, (WORD16)0x0a0b, (WORD16)-0x443b, (WORD16)0x0c0d, + (WORD16)-0x453a, (WORD16)0x0e12, (WORD16)-0x38f1, (WORD16)0x10b8, + (WORD16)-0x35ef, (WORD16)-0x4a35, (WORD16)0x1325, (WORD16)-0x37ec, + (WORD16)0x15b7, (WORD16)0x161d, (WORD16)0x17b4, (WORD16)0x18b2, + (WORD16)0x191c, (WORD16)0x1a1b, (WORD16)-0x542b, (WORD16)-0x522d, + (WORD16)-0x502f, (WORD16)-0x33e2, (WORD16)-0x31e1, (WORD16)0x20b1, + (WORD16)0x2122, (WORD16)-0x512e, (WORD16)0x2324, (WORD16)-0x5959, + (WORD16)-0x5b5b, (WORD16)0x26b9, (WORD16)-0x36d9, (WORD16)0x28b6, + (WORD16)0x2932, (WORD16)0x2ab3, (WORD16)-0x30d5, (WORD16)0x2c2f, + (WORD16)0x2d2e, (WORD16)-0x552a, (WORD16)-0x5757, (WORD16)0x3031, + (WORD16)-0x2626, (WORD16)-0x2828, (WORD16)-0x32cd, (WORD16)0x343b, + (WORD16)0x3538, (WORD16)0x3637, (WORD16)-0x2222, (WORD16)-0x2424, + (WORD16)0x393a, (WORD16)-0x5d5d, (WORD16)-0x532c, (WORD16)-0x4f30, + }, + 0}; diff --git a/decoder/ixheaacd_sbr_rom.h b/decoder/ixheaacd_sbr_rom.h new file mode 100644 index 0000000..dcd081a --- /dev/null +++ b/decoder/ixheaacd_sbr_rom.h @@ -0,0 +1,180 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_ROM_H +#define IXHEAACD_SBR_ROM_H + +#define INV_INT_TABLE_SIZE 49 +#define SBR_NF_NO_RANDOM_VAL 512 +#define NUM_SER_AP_LINKS 3 +#define SUBQMF_GROUPS (10) +#define QMF_GROUPS (12) +#define NO_IID_GROUPS (SUBQMF_GROUPS + QMF_GROUPS) +#define NUM_IID_LEVELS (7) +#define NUM_IID_LEVELS_FINE (15) +#define NUM_ICC_LEVELS (8) +#define NO_IID_LEVELS (2 * NUM_IID_LEVELS + 1) +#define NO_IID_LEVELS_FINE (2 * NUM_IID_LEVELS_FINE + 1) +#define NO_ICC_LEVELS (NUM_ICC_LEVELS) + +typedef struct { + WORD16 sbr_lim_gains_m[8]; + + WORD16 sbr_lim_bands_per_octave_q13[4]; + WORD16 sbr_smooth_filter[4]; + WORD16 sbr_inv_int_table[INV_INT_TABLE_SIZE]; + + WORD32 sbr_rand_ph[SBR_NF_NO_RANDOM_VAL + MAX_FREQ_COEFFS]; + +} ia_env_calc_tables_struct; + +extern const ia_env_calc_tables_struct ixheaacd_aac_dec_env_calc_tables; + +typedef struct { + WORD16 w_32[2 * 30]; + WORD16 w_16[2 * 12]; + WORD32 dig_rev_table2_32[4]; + WORD32 dig_rev_table4_16[2]; + + WORD16 sbr_sin_cos_twiddle_l64[64]; + WORD16 sbr_alt_sin_twiddle_l64[32]; + WORD16 sbr_cos_sin_twiddle_ds_l32[32 + 32]; + WORD16 sbr_sin_cos_twiddle_l32[32]; + WORD16 sbr_alt_sin_twiddle_l32[16]; + WORD16 sbr_t_cos_sin_l32[32 + 32]; + + WORD16 post_fft_tbl[18]; + WORD16 dct23_tw[66]; + + WORD16 qmf_c[1280]; + + UWORD8 dig_rev_table2_128[4]; + WORD32 w1024[1536]; + WORD32 esbr_qmf_c[1280]; + WORD32 esbr_qmf_c_24[480]; + WORD32 esbr_w_32[2 * 30]; + WORD32 esbr_w_16[2 * 12]; + + WORD32 esbr_sin_cos_twiddle_l64[64]; + WORD32 esbr_alt_sin_twiddle_l64[32]; + + WORD32 esbr_sin_cos_twiddle_l32[32]; + WORD32 esbr_alt_sin_twiddle_l32[16]; + WORD32 esbr_t_cos_sin_l32[32 + 32]; + + WORD32 esbr_sin_cos_twiddle_l24[24]; + WORD32 esbr_alt_sin_twiddle_l24[12]; + WORD32 esbr_t_cos_sin_l24[24 + 24]; + + WORD32 esbr_sin_cos_twiddle_l16[16]; + WORD32 esbr_alt_sin_twiddle_l16[8]; + WORD32 esbr_t_cos_sin_l16[16 + 16]; + + WORD16 ixheaacd_sbr_t_cos_sin_l32_eld[32 + 32]; + + WORD16 qmf_c_eld[640]; + WORD16 qmf_c_eld2[640]; + + WORD16 qmf_c_eld3[640]; + + WORD16 ixheaacd_sbr_synth_cos_sin_l32[64 + 64]; + +} ia_qmf_dec_tables_struct; + +extern const ia_qmf_dec_tables_struct ixheaacd_aac_qmf_dec_tables; + +typedef struct { + ia_frame_info_struct sbr_frame_info1_2_4_16[3 + 1]; + + ia_sbr_header_data_struct str_sbr_default_header; + WORD16 ixheaacd_t_huffman_env_bal_1_5db_inp_table[50]; + WORD16 ixheaacd_f_huffman_env_bal_1_5db_inp_table[50]; + WORD16 ixheaacd_t_huffman_env_bal_3_0db_inp_table[26]; + WORD16 ixheaacd_f_huffman_env_bal_3_0db_inp_table[26]; + WORD16 ixheaacd_t_huffman_noise_3_0db_inp_table[64]; + WORD16 ixheaacd_t_huffman_noise_bal_3_0db_inp_table[26]; + WORD16 ixheaacd_t_huffman_env_1_5db_inp_table[122]; + WORD16 ixheaacd_f_huffman_env_1_5db_inp_table[122]; + WORD16 ixheaacd_t_huffman_env_3_0db_inp_table[64]; + WORD16 ixheaacd_f_huffman_env_3_0db_inp_table[64]; + + WORD32 ixheaacd_t_huffman_env_bal_1_5db_idx_table[20]; + WORD32 ixheaacd_f_huffman_env_bal_1_5db_idx_table[23]; + WORD32 ixheaacd_t_huffman_env_bal_3_0db_idx_table[16]; + WORD32 ixheaacd_f_huffman_env_bal_3_0db_idx_table[17]; + WORD32 ixheaacd_t_huffman_noise_3_0db_idx_table[17]; + WORD32 ixheaacd_t_huffman_noise_bal_3_0db_idx_table[11]; + WORD32 ixheaacd_t_huffman_env_1_5db_idx_table[27]; + WORD32 ixheaacd_f_huffman_env_1_5db_idx_table[28]; + WORD32 ixheaacd_t_huffman_env_3_0db_idx_table[26]; + WORD32 ixheaacd_f_huffman_env_3_0db_idx_table[25]; + + WORD8 start_min[12]; + WORD8 offset_idx[12]; + WORD8 ixheaacd_drc_offset[7][16]; + WORD8 stop_min[12]; + WORD8 stop_off[12][14]; + +} ia_env_extr_tables_struct; + +extern const ia_env_extr_tables_struct ixheaacd_aac_dec_env_extr_tables; + +typedef struct { + WORD16 decay_scale_factor[72]; + + WORD16 hyb_resol[3]; + WORD16 rev_link_decay_ser[NUM_SER_AP_LINKS]; + WORD16 rev_link_delay_ser[3]; + WORD16 borders_group[NO_IID_GROUPS + 1]; + WORD16 group_shift[6]; + WORD16 group_to_bin[NO_IID_GROUPS]; + WORD16 hybrid_to_bin[SUBQMF_GROUPS]; + WORD16 delay_to_bin[32]; + + WORD16 frac_delay_phase_fac_qmf_re_im[24 * 2]; + WORD16 frac_delay_phase_fac_qmf_sub_re_im[16 * 2]; + WORD16 frac_delay_phase_fac_qmf_ser_re_im[3][32 * 2]; + WORD16 frac_delay_phase_fac_qmf_sub_ser_re_im[3][16 * 2]; + + WORD16 scale_factors[NO_IID_LEVELS]; + WORD16 scale_factors_fine[NO_IID_LEVELS_FINE]; + WORD16 alpha_values[NO_ICC_LEVELS]; + WORD16 p2_6[6]; + WORD16 p8_13[13]; + WORD16 huff_iid_dt[28]; + WORD16 huff_iid_df[28]; + WORD16 huff_icc_dt[14]; + WORD16 huff_icc_df[14]; + WORD16 huff_iid_dt_fine[60]; + WORD16 huff_iid_df_fine[60]; + WORD32 dummy; + +} ia_ps_tables_struct; + +extern const ia_ps_tables_struct ixheaacd_aac_dec_ps_tables; + +typedef struct { + ia_env_calc_tables_struct *env_calc_tables_ptr; + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr; + ia_env_extr_tables_struct *env_extr_tables_ptr; + ia_ps_tables_struct *ps_tables_ptr; + WORD32 *sbr_rand_ph; +} ia_sbr_tables_struct; + +#endif diff --git a/decoder/ixheaacd_sbr_scale.h b/decoder/ixheaacd_sbr_scale.h new file mode 100644 index 0000000..800c927 --- /dev/null +++ b/decoder/ixheaacd_sbr_scale.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBR_SCALE_H +#define IXHEAACD_SBR_SCALE_H + +typedef struct { + WORD16 lb_scale; + WORD16 st_lb_scale; + WORD16 ov_lb_scale; + WORD16 hb_scale; + WORD16 ov_hb_scale; + WORD16 st_syn_scale; + WORD16 ps_scale; +} ia_sbr_scale_fact_struct; + +#endif diff --git a/decoder/ixheaacd_sbrdec_initfuncs.c b/decoder/ixheaacd_sbrdec_initfuncs.c new file mode 100644 index 0000000..a41e868 --- /dev/null +++ b/decoder/ixheaacd_sbrdec_initfuncs.c @@ -0,0 +1,1153 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_sbr_const.h" +#include +#include "ixheaacd_defines.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_freq_sca.h" + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_env_dec.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_sbr_crc.h" + +#include "ixheaacd_sbrqmftrans.h" + +#include "ixheaacd_audioobjtypes.h" + +#define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) + +WORD32 ixheaacd_getsize_sbr_persistent() { + return (ALIGN_SIZE64(sizeof(ia_sbr_pers_struct))); +} + +WORD32 ixheaacd_esbr_hbe_data_init( + ia_esbr_hbe_txposer_struct *pstr_esbr_hbe_txposer, + const WORD32 num_aac_samples, WORD32 samp_fac_4_flag, + const WORD32 num_out_samples, VOID *persistent_hbe_mem) { + WORD32 i; + WORD32 used_persistent = 0; + + if (pstr_esbr_hbe_txposer) { + memset(pstr_esbr_hbe_txposer, 0, sizeof(ia_esbr_hbe_txposer_struct)); + + pstr_esbr_hbe_txposer->core_frame_length = num_aac_samples; + + pstr_esbr_hbe_txposer->no_bins = num_out_samples / NO_QMF_SYNTH_CHANNELS; + + pstr_esbr_hbe_txposer->hbe_qmf_in_len = + pstr_esbr_hbe_txposer->no_bins / 2 + HBE_OPER_WIN_LEN - 1; + pstr_esbr_hbe_txposer->hbe_qmf_out_len = + 2 * pstr_esbr_hbe_txposer->hbe_qmf_in_len; + + pstr_esbr_hbe_txposer->ptr_input_buf = + (FLOAT32 *)((WORD8 *)persistent_hbe_mem); + used_persistent += + (num_aac_samples + NO_QMF_SYNTH_CHANNELS) * sizeof(FLOAT32); + + pstr_esbr_hbe_txposer->qmf_in_buf = + (FLOAT32 **)((WORD8 *)persistent_hbe_mem + used_persistent); + used_persistent += + pstr_esbr_hbe_txposer->hbe_qmf_in_len * sizeof(FLOAT32 *); + + for (i = 0; i < pstr_esbr_hbe_txposer->hbe_qmf_in_len; i++) { + pstr_esbr_hbe_txposer->qmf_in_buf[i] = + (FLOAT32 *)((WORD8 *)persistent_hbe_mem + used_persistent); + + used_persistent += (TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + } + + pstr_esbr_hbe_txposer->qmf_out_buf = + (FLOAT32 **)((WORD8 *)persistent_hbe_mem + used_persistent); + used_persistent += + (pstr_esbr_hbe_txposer->hbe_qmf_out_len * sizeof(FLOAT32 *)); + + for (i = 0; i < pstr_esbr_hbe_txposer->hbe_qmf_out_len; i++) { + pstr_esbr_hbe_txposer->qmf_out_buf[i] = + (FLOAT32 *)((WORD8 *)persistent_hbe_mem + used_persistent); + used_persistent += (TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + } + pstr_esbr_hbe_txposer->upsamp_4_flag = samp_fac_4_flag; + } + + return 0; +} + +VOID ixheaacd_set_sbr_persistent_table_pointer( + VOID *sbr_persistent_mem_v, ia_sbr_tables_struct *sbr_tables_ptr, + ixheaacd_misc_tables *pstr_common_tables) { + ia_sbr_pers_struct *sbr_persistent_mem = + (ia_sbr_pers_struct *)sbr_persistent_mem_v; + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables = sbr_tables_ptr; + sbr_persistent_mem->str_sbr_dec_inst.pstr_common_tables = pstr_common_tables; +} + +VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, + WORD32 *persistent_used, + WORD32 num_channel, WORD ps_enable) { + WORD32 i = 0; + WORD32 used_persistent = *persistent_used; + WORD32 temp, temp1, temp2, temp3; + struct ia_sbr_pers_struct *sbr_persistent_mem = + (struct ia_sbr_pers_struct *)sbr_persistent_mem_v; + + struct ia_sbr_dec_inst_struct *p_str_sbr_dec_inst = + &sbr_persistent_mem->str_sbr_dec_inst; + + memset(sbr_persistent_mem, 0, sizeof(struct ia_sbr_pers_struct)); + + sbr_persistent_mem->sbr_qmf_analy_states = + (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + temp = num_channel * ((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(WORD16)); + used_persistent += temp; + + sbr_persistent_mem->sbr_qmf_analy_states_32 = + (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + temp1 = + num_channel * + ((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD32)); + used_persistent += temp1; + + sbr_persistent_mem->sbr_qmf_synth_states = + (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + temp2 = + (num_channel * ((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(WORD16))); + used_persistent += temp2; + + sbr_persistent_mem->sbr_qmf_synth_states_32 = + (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + temp3 = + (num_channel * ((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(WORD32))); + used_persistent += temp3; + + memset(sbr_persistent_mem->sbr_qmf_analy_states, 0, + (temp + temp1 + temp2 + temp3)); + + for (i = 0; i < num_channel; i++) { + sbr_persistent_mem->ptr_sbr_overlap_buf[i] = + (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + if (ps_enable) { + memset(sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, + 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32)); + used_persistent += + 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + } else { + memset(sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, + MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32)); + used_persistent += MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + } + } + + for (i = 0; i < num_channel; i++) { + WORD32 j; + sbr_persistent_mem->sbr_lpc_filter_states_real[i] = + (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += LPC_ORDER * sizeof(WORD32 *); + for (j = 0; j < LPC_ORDER; j++) { + sbr_persistent_mem->sbr_lpc_filter_states_real[i][j] = + (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + used_persistent += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + + memset(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j], 0, + NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + } + } + + if (ps_enable) { + for (i = 0; i < num_channel; i++) { + WORD32 j; + + sbr_persistent_mem->sbr_lpc_filter_states_imag[i] = + (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += LPC_ORDER * sizeof(WORD32 *); + for (j = 0; j < LPC_ORDER; j++) { + sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j] = + (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + used_persistent += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + + memset(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j], 0, + NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + } + } + } + for (i = 0; i < num_channel; i++) { + WORD32 initial_used = used_persistent; + WORD32 temp_used = used_persistent; + + sbr_persistent_mem->sbr_smooth_gain_buf[i] = + (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); + temp_used += 2 * MAX_FREQ_COEFFS * sizeof(WORD16); + + sbr_persistent_mem->sbr_smooth_noise_buf[i] = + (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); + + temp_used += MAX_FREQ_COEFFS * sizeof(WORD16); + + p_str_sbr_dec_inst->pstr_freq_band_data[i] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); + + temp_used += ALIGN_SIZE64(sizeof(ia_freq_band_data_struct)); + + sbr_persistent_mem->pstr_prev_frame_data[i] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); + + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_prev_frame_data_struct)); + + p_str_sbr_dec_inst->pstr_sbr_channel[i] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); + + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_channel_struct)); + + p_str_sbr_dec_inst->pstr_sbr_header[i] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); + + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_header_data_struct)); + + memset(sbr_persistent_mem->sbr_smooth_gain_buf[i], 0, + temp_used - initial_used); + + used_persistent = temp_used; + } + + if (ps_enable) { + p_str_sbr_dec_inst->pstr_ps_stereo_dec = + (ia_ps_dec_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + + memset(p_str_sbr_dec_inst->pstr_ps_stereo_dec, 0, sizeof(ia_ps_dec_struct)); + + used_persistent += sizeof(ia_ps_dec_struct); + } + + p_str_sbr_dec_inst->frame_buffer[0] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->frame_buffer[0], 0, + (sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8)); + used_persistent = used_persistent + (sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) + 8); + + p_str_sbr_dec_inst->frame_buffer[1] = + (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->frame_buffer[1], 0, + (sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8)); + used_persistent = used_persistent + (sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) + 8); + + { + WORD32 index = 0; + p_str_sbr_dec_inst->ptr_pvc_data_str = + (ia_pvc_data_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->ptr_pvc_data_str, 0, sizeof(ia_pvc_data_struct)); + used_persistent += sizeof(ia_pvc_data_struct); + + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer = + (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer, + 0, sizeof(ia_esbr_hbe_txposer_struct)); + used_persistent += sizeof(ia_esbr_hbe_txposer_struct); + + if (num_channel == 2) { + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer = + (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer, + 0, sizeof(ia_esbr_hbe_txposer_struct)); + used_persistent += sizeof(ia_esbr_hbe_txposer_struct); + } + + p_str_sbr_dec_inst->hbe_txposer_buffers = + (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->hbe_txposer_buffers, 0, + num_channel * MAX_HBE_PERSISTENT_SIZE); + used_persistent += num_channel * MAX_HBE_PERSISTENT_SIZE; + + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real = + (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real, + 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag = + (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag, + 0, MAX_QMF_BUF_LEN); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + + if (num_channel == 2) { + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real = + (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset( + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real, + 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag = + (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset( + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag, + 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + } + + for (index = 0; index < MAX_QMF_BUF_LEN; index++) { + p_str_sbr_dec_inst->pstr_sbr_channel[0] + ->str_sbr_dec.pp_qmf_buf_real[index] = + (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + } + + for (index = 0; index < MAX_QMF_BUF_LEN; index++) { + p_str_sbr_dec_inst->pstr_sbr_channel[0] + ->str_sbr_dec.pp_qmf_buf_imag[index] = + (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + } + + if (num_channel == 2) { + for (index = 0; index < MAX_QMF_BUF_LEN; index++) { + p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.pp_qmf_buf_real[index] = + (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + } + + for (index = 0; index < MAX_QMF_BUF_LEN; index++) { + p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.pp_qmf_buf_imag[index] = + (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + } + } + } + + *persistent_used = used_persistent; +} + +WORD32 ia_enhaacplus_dec_get_sbr_buffers_size(WORD32 channels) { + WORD32 sbr_buffers_size = 0; + WORD32 temp, temp2; + WORD32 num_channel = channels; + WORD32 i; + + temp = num_channel * ((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(WORD16)); + sbr_buffers_size += temp; + + temp2 = + (num_channel * ((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(WORD16))); + sbr_buffers_size += temp2; + + for (i = 0; i < num_channel; i++) { + sbr_buffers_size += + 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + } + + for (i = 0; i < num_channel; i++) { + int j; + sbr_buffers_size += LPC_ORDER * sizeof(VOID *); + + for (j = 0; j < LPC_ORDER; j++) { + sbr_buffers_size += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + } + } + + for (i = 0; i < num_channel; i++) { + int j; + sbr_buffers_size += LPC_ORDER * sizeof(WORD32); + for (j = 0; j < LPC_ORDER; j++) { + sbr_buffers_size += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + } + } + + for (i = 0; i < num_channel; i++) { + WORD32 temp_used = sbr_buffers_size; + + temp_used += 2 * MAX_FREQ_COEFFS * sizeof(WORD16); + temp_used += MAX_FREQ_COEFFS * sizeof(WORD16); + temp_used += ALIGN_SIZE64(sizeof(ia_freq_band_data_struct)); + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_prev_frame_data_struct)); + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_channel_struct)); + temp_used += ALIGN_SIZE64(sizeof(ia_sbr_header_data_struct)); + + sbr_buffers_size = temp_used; + } + + sbr_buffers_size += sizeof(ia_ps_dec_struct); + + return sbr_buffers_size; +} + +static PLATFORM_INLINE VOID ixheaacd_init_headerdata( + ia_sbr_header_data_struct *ptr_header_data, WORD32 sample_rate_dec, + WORD32 samp_per_frame, ia_freq_band_data_struct *freq_band_data, + ia_sbr_tables_struct *sbr_tables, WORD audio_obj_type) { + ia_freq_band_data_struct *pstr_freq_band_data = freq_band_data; + WORD32 tmp; + + if (audio_obj_type != AOT_ER_AAC_ELD) { + memcpy(ptr_header_data, + &sbr_tables->env_extr_tables_ptr->str_sbr_default_header, + sizeof(ia_sbr_header_data_struct)); + } + + if (audio_obj_type == AOT_ER_AAC_ELD) ptr_header_data->time_step -= 1; + + pstr_freq_band_data->freq_band_table[LOW] = + pstr_freq_band_data->freq_band_tbl_lo; + pstr_freq_band_data->freq_band_table[HIGH] = + pstr_freq_band_data->freq_band_tbl_hi; + ptr_header_data->pstr_freq_band_data = pstr_freq_band_data; + + ptr_header_data->core_frame_size = samp_per_frame; + ptr_header_data->out_sampling_freq = sample_rate_dec << 1; + + if (audio_obj_type != AOT_ER_AAC_ELD) { + tmp = ptr_header_data->time_step + 4; + + if (tmp < 0) + ptr_header_data->num_time_slots = + ixheaacd_extract16l(samp_per_frame << (-tmp)); + else + ptr_header_data->num_time_slots = + ixheaacd_extract16l(samp_per_frame >> tmp); + } else { + ptr_header_data->time_step = 1; + + ptr_header_data->num_time_slots = + (samp_per_frame / 32 >> (ptr_header_data->time_step - 1)); + } +} + +VOID ixheaacd_setesbr_flags(VOID *sbr_persistent_mem_v, FLAG pvc_flag, + FLAG hbe_flag, FLAG inter_tes_flag) { + ia_sbr_pers_struct *sbr_persistent_mem; + sbr_persistent_mem = (ia_sbr_pers_struct *)sbr_persistent_mem_v; + sbr_persistent_mem->str_sbr_dec_inst.hbe_flag = hbe_flag; + sbr_persistent_mem->str_sbr_dec_inst.pvc_flag = pvc_flag; + sbr_persistent_mem->str_sbr_dec_inst.inter_tes_flag = inter_tes_flag; + return; +} + +ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( + WORD32 sample_rate_dec, WORD32 samp_per_frame, FLAG *down_sample_flag, + VOID *sbr_persistent_mem_v, WORD32 *ptr_overlap_buf, WORD32 channel, + WORD32 ps_enable, WORD32 sbr_ratio_idx, WORD32 output_frame_size, + WORD32 *use_hbe, VOID *p_usac_dflt_header, + ia_sbr_header_data_struct str_sbr_config, WORD32 audio_object_type) { + WORD16 i; + WORD16 err; + ia_sbr_header_data_struct *ptr_header_data[MAXNRSBRCHANNELS]; + ia_sbr_dec_struct *ptr_sbr_dec[2]; + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr; + ia_sbr_pers_struct *sbr_persistent_mem; + + sbr_persistent_mem = (ia_sbr_pers_struct *)sbr_persistent_mem_v; + ptr_sbr_dec[0] = + &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[0]->str_sbr_dec; + ptr_sbr_dec[1] = + &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[1]->str_sbr_dec; + + qmf_dec_tables_ptr = + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr; + + if (sample_rate_dec > 48000) { + *down_sample_flag = 1; + } + + for (i = 0; i < channel; i++) { + if (audio_object_type == AOT_ER_AAC_ELD) { + memcpy(sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[i], + &str_sbr_config, sizeof(ia_sbr_header_data_struct)); + } + ptr_header_data[i] = + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[i]; + + ixheaacd_init_headerdata( + ptr_header_data[i], sample_rate_dec, samp_per_frame, + sbr_persistent_mem->str_sbr_dec_inst.pstr_freq_band_data[i], + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables, + audio_object_type); + + err = ixheaacd_create_sbrdec( + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables, + sbr_persistent_mem->str_sbr_dec_inst.pstr_common_tables, + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[i], + ptr_header_data[i], i, *down_sample_flag, sbr_persistent_mem, ps_enable, + audio_object_type); + + ptr_header_data[i]->status = 1; + + if (err) { + return NULL; + } + } + + if (channel != 1) { + if (ps_enable) { + if (audio_object_type == AOT_ER_AAC_ELD) + err = (WORD16)ixheaacd_create_psdec( + sbr_persistent_mem->str_sbr_dec_inst.pstr_ps_stereo_dec, + sbr_persistent_mem, &ptr_overlap_buf[512 * 4]); + else + err = (WORD16)ixheaacd_create_psdec( + sbr_persistent_mem->str_sbr_dec_inst.pstr_ps_stereo_dec, + sbr_persistent_mem, ptr_overlap_buf); + if (err) { + return NULL; + } + } + } + + if (use_hbe != NULL) { + ia_sbr_header_data_struct *ptr_sbr_dflt_header = + &sbr_persistent_mem->str_sbr_dec_inst.str_sbr_dflt_header; + ia_sbr_header_data_struct *ptr_usac_dflt_header = + (ia_sbr_header_data_struct *)p_usac_dflt_header; + struct ia_sbr_dec_inst_struct *p_str_sbr_dec_inst = + &sbr_persistent_mem->str_sbr_dec_inst; + VOID *hbe_txposer_buffers = p_str_sbr_dec_inst->hbe_txposer_buffers; + + ptr_header_data[0] = p_str_sbr_dec_inst->pstr_sbr_header[0]; + ptr_header_data[1] = p_str_sbr_dec_inst->pstr_sbr_header[1]; + + ptr_header_data[0]->sbr_ratio_idx = sbr_ratio_idx; + ptr_header_data[0]->output_framesize = output_frame_size; + ptr_header_data[0]->pstr_freq_band_data->sub_band_start = 64; + ptr_header_data[0]->esbr_start_up = 1; + ptr_header_data[0]->esbr_start_up_pvc = 1; + + if (channel > 1) { + ptr_header_data[1]->sbr_ratio_idx = sbr_ratio_idx; + ptr_header_data[1]->output_framesize = output_frame_size; + ptr_header_data[1]->pstr_freq_band_data->sub_band_start = 64; + ptr_header_data[1]->esbr_start_up = 1; + ptr_header_data[1]->esbr_start_up_pvc = 1; + } + if (hbe_txposer_buffers != NULL && (use_hbe[0] == 1)) { + ixheaacd_esbr_hbe_data_init(ptr_sbr_dec[0]->p_hbe_txposer, samp_per_frame, + sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, + output_frame_size, hbe_txposer_buffers); + + hbe_txposer_buffers = + (WORD8 *)hbe_txposer_buffers + MAX_HBE_PERSISTENT_SIZE; + + ixheaacd_esbr_hbe_data_init(ptr_sbr_dec[1]->p_hbe_txposer, samp_per_frame, + sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, + output_frame_size, hbe_txposer_buffers); + + } else { + ptr_sbr_dec[0]->p_hbe_txposer = NULL; + ptr_sbr_dec[1]->p_hbe_txposer = NULL; + } + + p_str_sbr_dec_inst->ptr_pvc_data_str->prev_first_bnd_idx = -1; + p_str_sbr_dec_inst->ptr_pvc_data_str->prev_pvc_rate = -1; + p_str_sbr_dec_inst->ptr_pvc_data_str->prev_sbr_mode = UNKNOWN_SBR; + + p_str_sbr_dec_inst->pstr_sbr_channel[0] + ->str_sbr_dec.str_codec_qmf_bank.num_time_slots = + output_frame_size / 64; + p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.str_codec_qmf_bank.num_time_slots = + output_frame_size / 64; + + ptr_header_data[0]->core_frame_size = samp_per_frame; + ptr_header_data[1]->core_frame_size = samp_per_frame; + + switch (sbr_ratio_idx) { + case SBR_UPSAMPLE_IDX_0_0: + ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; + ptr_header_data[0]->is_usf_4 = 0; + ptr_header_data[0]->upsamp_fac = 1; + + ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; + ptr_header_data[1]->is_usf_4 = 0; + ptr_header_data[1]->upsamp_fac = 1; + break; + case SBR_UPSAMPLE_IDX_2_1: + ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; + ptr_header_data[0]->is_usf_4 = 0; + ptr_header_data[0]->upsamp_fac = 2; + + ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 32; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; + ptr_header_data[1]->is_usf_4 = 0; + ptr_header_data[1]->upsamp_fac = 2; + break; + case SBR_UPSAMPLE_IDX_8_3: + ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 24; + ptr_sbr_dec[0]->str_codec_qmf_bank.filter_pos_32 = + qmf_dec_tables_ptr->esbr_qmf_c_24; + ptr_sbr_dec[0]->str_codec_qmf_bank.analy_win_coeff_32 = + qmf_dec_tables_ptr->esbr_qmf_c_24; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l24; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l24; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l24; + + ptr_header_data[0]->is_usf_4 = 0; + ptr_header_data[0]->upsamp_fac = 2; + + ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 24; + ptr_sbr_dec[1]->str_codec_qmf_bank.filter_pos_32 = + qmf_dec_tables_ptr->esbr_qmf_c_24; + ptr_sbr_dec[1]->str_codec_qmf_bank.analy_win_coeff_32 = + qmf_dec_tables_ptr->esbr_qmf_c_24; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l24; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l24; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l24; + + ptr_header_data[1]->is_usf_4 = 0; + ptr_header_data[1]->upsamp_fac = 2; + break; + case SBR_UPSAMPLE_IDX_4_1: + ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 16; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l16; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l16; + ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l16; + ptr_header_data[0]->is_usf_4 = 1; + ptr_header_data[0]->upsamp_fac = 4; + ptr_header_data[0]->out_sampling_freq = + ptr_header_data[0]->out_sampling_freq * 2; + + ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 16; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l16; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l16; + ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = + (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l16; + ptr_header_data[1]->is_usf_4 = 1; + ptr_header_data[1]->upsamp_fac = 4; + ptr_header_data[1]->out_sampling_freq = + ptr_header_data[1]->out_sampling_freq * 2; + break; + } + + ptr_sbr_dflt_header->start_freq = ptr_usac_dflt_header->start_freq; + ptr_sbr_dflt_header->stop_freq = ptr_usac_dflt_header->stop_freq; + + if (ptr_usac_dflt_header->header_extra_1) { + ptr_sbr_dflt_header->freq_scale = ptr_usac_dflt_header->freq_scale; + ptr_sbr_dflt_header->alter_scale = ptr_usac_dflt_header->alter_scale; + ptr_sbr_dflt_header->noise_bands = ptr_usac_dflt_header->noise_bands; + } else { + ptr_sbr_dflt_header->freq_scale = SBR_FREQ_SCALE_DEFAULT; + ptr_sbr_dflt_header->alter_scale = SBR_ALTER_SCALE_DEFAULT; + ptr_sbr_dflt_header->noise_bands = SBR_NOISE_BANDS_DEFAULT; + } + + if (ptr_usac_dflt_header->header_extra_2) { + ptr_sbr_dflt_header->limiter_bands = ptr_usac_dflt_header->limiter_bands; + ptr_sbr_dflt_header->limiter_gains = ptr_usac_dflt_header->limiter_gains; + ptr_sbr_dflt_header->interpol_freq = ptr_usac_dflt_header->interpol_freq; + ptr_sbr_dflt_header->smoothing_mode = + ptr_usac_dflt_header->smoothing_mode; + } else { + ptr_sbr_dflt_header->limiter_bands = SBR_LIMITER_BANDS_DEFAULT; + ptr_sbr_dflt_header->limiter_gains = SBR_LIMITER_GAINS_DEFAULT; + ptr_sbr_dflt_header->interpol_freq = SBR_INTERPOL_FREQ_DEFAULT; + ptr_sbr_dflt_header->smoothing_mode = SBR_SMOOTHING_LENGTH_DEFAULT; + } + } + return &(sbr_persistent_mem->str_sbr_dec_inst); +} + +static PLATFORM_INLINE WORD16 ixheaacd_create_sbr_env_calc( + ia_sbr_tables_struct *pstr_sbr_tables, + ixheaacd_misc_tables *pstr_common_table, ia_sbr_calc_env_struct *hs, + WORD16 chan, VOID *sbr_persistent_mem_v, + ia_sbr_header_data_struct *ptr_header_data, WORD audio_object_type) { + WORD16 err; + ia_sbr_pers_struct *sbr_persistent_mem = + (ia_sbr_pers_struct *)sbr_persistent_mem_v; + + err = 0; + memset(&hs->harm_flags_prev[0], 0, sizeof(WORD8) * MAX_FREQ_COEFFS); + + hs->harm_index = 0; + + hs->filt_buf_me = sbr_persistent_mem->sbr_smooth_gain_buf[chan]; + hs->filt_buf_noise_m = sbr_persistent_mem->sbr_smooth_noise_buf[chan]; + hs->tansient_env_prev = -1; + + ixheaacd_reset_sbrenvelope_calc(hs); + + if ((chan == 0) && (audio_object_type == AOT_ER_AAC_ELD)) { + err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data, pstr_sbr_tables, + pstr_common_table); + } + + return err; +} + +static PLATFORM_INLINE VOID ixheaacd_init_sbr_prev_framedata( + ia_sbr_prev_frame_data_struct *ptr_prev_data, WORD16 time_slots) { + WORD16 *psfb_nrg_prev = ptr_prev_data->sfb_nrg_prev; + WORD16 *psfb_noise_level = ptr_prev_data->prev_noise_level; + WORD32 *ppsbr_invf_mode = ptr_prev_data->sbr_invf_mode; + + memset(psfb_nrg_prev, 0, sizeof(WORD16) * (MAX_FREQ_COEFFS)); + memset(psfb_noise_level, 0, sizeof(WORD16) * (MAX_NOISE_COEFFS)); + + memset(ppsbr_invf_mode, 0, sizeof(WORD32) * MAX_INVF_BANDS); + + ptr_prev_data->end_position = time_slots; + ptr_prev_data->coupling_mode = COUPLING_OFF; + ptr_prev_data->amp_res = 0; + ptr_prev_data->max_qmf_subband_aac = 0; +} + +static PLATFORM_INLINE WORD32 +ixheaacd_create_hyb_filterbank(ia_hybrid_struct *ptr_hybrid, WORD32 **p_ptr, + ia_sbr_tables_struct *sbr_tables_ptr) { + WORD16 i, ptr_step; + WORD32 *ptr = (WORD32 *)*p_ptr; + + ptr_hybrid->ptr_resol = sbr_tables_ptr->ps_tables_ptr->hyb_resol; + ptr_hybrid->ptr_qmf_buf = HYBRID_FILTER_LENGTH - 1; + + ptr_hybrid->ptr_temp_re = ptr; + ptr += NO_HYBRID_CHANNELS_HIGH; + ptr_hybrid->ptr_temp_im = ptr; + ptr += NO_HYBRID_CHANNELS_HIGH; + + memset(ptr_hybrid->ptr_temp_re, 0, + 2 * NO_HYBRID_CHANNELS_HIGH * sizeof(WORD32)); + + ptr_step = ixheaacd_add16(1, ptr_hybrid->ptr_qmf_buf); + ptr_hybrid->ptr_work_re = ptr; + ptr += 16; + ptr_hybrid->ptr_work_im = ptr; + ptr += 16; + + for (i = 0; i < NO_QMF_CHANNELS_IN_HYBRID; i++) { + ptr_hybrid->ptr_qmf_buf_re[i] = ptr; + ptr += ptr_hybrid->ptr_qmf_buf; + + ptr_hybrid->ptr_qmf_buf_im[i] = ptr; + ptr += ptr_hybrid->ptr_qmf_buf; + + memset(ptr_hybrid->ptr_qmf_buf_re[i], 0, + 2 * ptr_hybrid->ptr_qmf_buf * sizeof(WORD32)); + } + + *p_ptr = ptr; + + return 0; +} + +static PLATFORM_INLINE WORD16 ixheaacd_create_hf_generator( + ia_sbr_hf_generator_struct *ptr_hf_gen_str, WORD16 num_columns, WORD16 chan, + VOID *sbr_persistent_mem_v, WORD32 ps_enable) { + WORD16 i; + ia_sbr_pers_struct *sbr_persistent_mem = + (ia_sbr_pers_struct *)sbr_persistent_mem_v; + + ptr_hf_gen_str->pstr_settings = &sbr_persistent_mem->str_sbr_tran_settings; + + ptr_hf_gen_str->lpc_filt_states_real[0] = + sbr_persistent_mem->sbr_lpc_filter_states_real[chan][0]; + ptr_hf_gen_str->lpc_filt_states_real[1] = + sbr_persistent_mem->sbr_lpc_filter_states_real[chan][1]; + + if (ps_enable) { + ptr_hf_gen_str->lpc_filt_states_imag[0] = + sbr_persistent_mem->sbr_lpc_filter_states_imag[chan][0]; + ptr_hf_gen_str->lpc_filt_states_imag[1] = + sbr_persistent_mem->sbr_lpc_filter_states_imag[chan][1]; + } + + for (i = 0; i < LPC_ORDER; i++) { + memset(ptr_hf_gen_str->lpc_filt_states_real[i], 0, + NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + + if (ps_enable) + memset(ptr_hf_gen_str->lpc_filt_states_imag[i], 0, + NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + } + + if (chan == 0) { + ptr_hf_gen_str->pstr_settings->num_columns = num_columns; + } + return 0; +} + +WORD32 ixheaacd_create_psdec(ia_ps_dec_struct *ptr_ps_dec, + VOID *sbr_persistent_mem_v, + WORD32 *ptr_overlap_buf) { + ia_sbr_pers_struct *sbr_persistent_mem = + (ia_sbr_pers_struct *)sbr_persistent_mem_v; + + WORD16 *ptr1 = (WORD16 *)&( + sbr_persistent_mem->ptr_sbr_overlap_buf[MAXNRSBRCHANNELS - 1][0]); + WORD32 *ptr2 = (WORD32 *)&ptr_overlap_buf[512]; + WORD16 *initial_ptr; + WORD16 delay; + WORD32 temp; + + ia_sbr_tables_struct *sbr_tables_ptr = + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables; + + memset(ptr_ps_dec, 0, sizeof(ia_ps_dec_struct)); + + ptr_ps_dec->ps_data_present = 0; + ptr_ps_dec->enable_iid = 0; + ptr_ps_dec->enable_icc = 0; + ptr_ps_dec->enable_ext = 0; + ptr_ps_dec->iid_mode = 0; + ptr_ps_dec->icc_mode = 0; + + ptr_ps_dec->ptr_hyb_left_re = ptr2; + ptr2 += 16; + ptr_ps_dec->ptr_hyb_left_im = ptr2; + ptr2 += 16; + ptr_ps_dec->ptr_hyb_right_re = ptr2; + ptr2 += 16; + ptr_ps_dec->ptr_hyb_right_im = ptr2; + ptr2 += 16; + + memset(ptr_ps_dec->ptr_hyb_left_re, 0, sizeof(WORD32) * 16 * 4); + + ixheaacd_create_hyb_filterbank(&ptr_ps_dec->str_hybrid, &ptr2, + sbr_tables_ptr); + + ptr_ps_dec->peak_decay_diff = ptr2; + ptr2 += NUM_OF_BINS; + ptr_ps_dec->energy_prev = ptr2; + ptr2 += NUM_OF_BINS; + ptr_ps_dec->peak_decay_diff_prev = ptr2; + ptr2 += NUM_OF_BINS; + + memset(ptr_ps_dec->peak_decay_diff, 0, 3 * sizeof(WORD32) * NUM_OF_BINS); + + ptr_ps_dec->delay_buf_idx = 0; + ptr_ps_dec->delay_buf_idx_long = 0; + + memset(ptr_ps_dec->delay_buf_qmf_sub_re_im, 0, + 2 * 16 * DEL_ALL_PASS * sizeof(WORD16)); + memset(ptr_ps_dec->delay_buf_qmf_sub_ser_re_im, 0, + 2 * 16 * NUM_SER_AP_LINKS * 5 * sizeof(WORD16)); + + initial_ptr = ptr1; + ptr_ps_dec->delay_buf_qmf_ser_re_im = (VOID *)ptr1; + ptr1 += 2 * NUM_SER_AP_LINKS * 32 * 5; + + delay = 2; + ptr_ps_dec->delay_buf_qmf_ap_re_im = (VOID *)ptr1; + ptr1 += 2 * delay * 32; + + delay = HIGH_DEL; + ptr_ps_dec->delay_buf_qmf_ld_re_im = (VOID *)ptr1; + ptr1 += 2 * delay * SMALL_DEL_STRT; + + delay = SMALL_DEL; + ptr_ps_dec->delay_buf_qmf_sd_re_im = (VOID *)ptr1; + ptr1 += + 2 * delay * (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS - + (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)); + + temp = ptr1 - initial_ptr; + memset(ptr_ps_dec->delay_buf_qmf_ser_re_im, 0, temp * sizeof(WORD16)); + + memset(ptr_ps_dec->delay_buf_idx_ser, 0, NUM_SER_AP_LINKS * sizeof(WORD16)); + memcpy(ptr_ps_dec->delay_sample_ser, + sbr_tables_ptr->ps_tables_ptr->rev_link_delay_ser, + NUM_SER_AP_LINKS * sizeof(WORD16)); + + memset(ptr_ps_dec->h11_h12_vec, 0xff, + (NO_IID_GROUPS + 2) * 2 * sizeof(WORD16)); + memset(ptr_ps_dec->h21_h22_vec, 0, sizeof(ptr_ps_dec->h21_h22_vec)); + + return 0; +} + +static PLATFORM_INLINE WORD32 ixheaacd_create_cplx_anal_qmfbank( + ia_sbr_qmf_filter_bank_struct *ptr_sbr_qmf, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 no_bins, WORD16 usb, + WORD16 chan, WORD16 *sbr_qmf_analy_states, WORD32 *sbr_qmf_analy_states_32, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, WORD32 audio_object_type) { + memset(ptr_sbr_qmf, 0, sizeof(ia_sbr_qmf_filter_bank_struct)); + + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ptr_sbr_qmf->analy_win_coeff = qmf_dec_tables_ptr->qmf_c; + } else { + ptr_sbr_qmf->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3; + } + + ptr_sbr_qmf->analy_win_coeff_32 = qmf_dec_tables_ptr->esbr_qmf_c; + + ptr_sbr_qmf->no_channels = NO_ANALYSIS_CHANNELS; + ptr_sbr_qmf->num_time_slots = no_bins; + + ptr_sbr_qmf->lsb = 0; + ptr_sbr_qmf->usb = usb; + + ptr_sbr_qmf->anal_filter_states = + &(sbr_qmf_analy_states[chan ? QMF_FILTER_STATE_ANA_SIZE : 0]); + + memset(ptr_sbr_qmf->anal_filter_states, 0, + sizeof(WORD16) * QMF_FILTER_STATE_ANA_SIZE); + + ptr_sbr_qmf->anal_filter_states_32 = + &(sbr_qmf_analy_states_32[chan ? QMF_FILTER_STATE_ANA_SIZE : 0]); + + memset(ptr_sbr_qmf->anal_filter_states_32, 0, + sizeof(WORD32) * QMF_FILTER_STATE_ANA_SIZE); + + ptr_sbr_qmf->core_samples_buffer = ptr_sbr_qmf->anal_filter_states; + + ptr_sbr_qmf->state_new_samples_pos_low_32 = + ptr_sbr_qmf->anal_filter_states_32; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ptr_sbr_qmf->filter_pos = (WORD16 *)qmf_dec_tables_ptr->qmf_c; + } else { + ptr_sbr_qmf->filter_pos = (WORD16 *)qmf_dec_tables_ptr->qmf_c_eld3; + } + + ptr_sbr_qmf->filter_pos_32 = (WORD32 *)qmf_dec_tables_ptr->esbr_qmf_c; + + sbr_scale_factor->st_lb_scale = 0; + + sbr_scale_factor->st_syn_scale = -6; + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + ptr_sbr_qmf->filter_2 = ptr_sbr_qmf->filter_pos + 32; + ptr_sbr_qmf->fp1_anal = ptr_sbr_qmf->anal_filter_states; + ptr_sbr_qmf->fp2_anal = + ptr_sbr_qmf->anal_filter_states + NO_ANALYSIS_CHANNELS; + } + + return 0; +} + +static PLATFORM_INLINE WORD32 ixheaacd_create_cplx_synt_qmfbank( + ia_sbr_qmf_filter_bank_struct *ptr_sbr_qmf, WORD16 no_bins, WORD16 lsb, + WORD16 usb, WORD16 chan, FLAG down_sample_flag, + WORD16 *sbr_qmf_synth_states, WORD32 *sbr_qmf_synth_states_32, + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, WORD32 audio_object_type) { + WORD32 L; + + WORD32 qmf_filter_state_size; + + memset(ptr_sbr_qmf, 0, sizeof(ia_sbr_qmf_filter_bank_struct)); + + 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; + } + + ptr_sbr_qmf->ixheaacd_drc_offset = 0; + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + ptr_sbr_qmf->filter_pos_syn = (WORD16 *)qmf_dec_tables_ptr->qmf_c; + ptr_sbr_qmf->p_filter = qmf_dec_tables_ptr->qmf_c; + } else { + ptr_sbr_qmf->filter_pos_syn = (WORD16 *)qmf_dec_tables_ptr->qmf_c_eld; + ptr_sbr_qmf->p_filter = qmf_dec_tables_ptr->qmf_c_eld; + } + + ptr_sbr_qmf->filter_pos_syn_32 = (WORD32 *)qmf_dec_tables_ptr->esbr_qmf_c; + ptr_sbr_qmf->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; + + ptr_sbr_qmf->no_channels = L; + ptr_sbr_qmf->qmf_filter_state_size = qmf_filter_state_size; + ptr_sbr_qmf->num_time_slots = no_bins; + ptr_sbr_qmf->lsb = lsb; + + ptr_sbr_qmf->filter_states = + &sbr_qmf_synth_states[chan ? qmf_filter_state_size : 0]; + + memset(ptr_sbr_qmf->filter_states, 0, sizeof(WORD16) * qmf_filter_state_size); + + ptr_sbr_qmf->filter_states_32 = + &sbr_qmf_synth_states_32[chan ? qmf_filter_state_size : 0]; + + memset(ptr_sbr_qmf->filter_states_32, 0, + sizeof(WORD32) * qmf_filter_state_size); + + if (audio_object_type == AOT_ER_AAC_ELD || + audio_object_type == AOT_ER_AAC_LD) { + ptr_sbr_qmf->fp1_syn = ptr_sbr_qmf->filter_states; + ptr_sbr_qmf->fp2_syn = + ptr_sbr_qmf->filter_states + ptr_sbr_qmf->no_channels; + ptr_sbr_qmf->sixty4 = NO_SYNTHESIS_CHANNELS; + } + + return 0; +} + +WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, + ixheaacd_misc_tables *pstr_common_table, + ia_sbr_channel_struct *ptr_sbr_channel, + ia_sbr_header_data_struct *ptr_header_data, + WORD16 chan, FLAG down_sample_flag, + VOID *sbr_persistent_mem_v, WORD ps_enable, + WORD audio_object_type) + +{ + WORD16 err; + WORD16 time_slots; + WORD16 no_bins; + ia_sbr_pers_struct *sbr_persistent_mem = + (ia_sbr_pers_struct *)sbr_persistent_mem_v; + ia_sbr_dec_struct *hs = &(ptr_sbr_channel->str_sbr_dec); + + time_slots = ptr_header_data->num_time_slots; + + no_bins = (WORD16)(time_slots * ptr_header_data->time_step); + + hs->str_sbr_scale_fact.ov_lb_scale = INT_BITS - 1; + hs->str_sbr_scale_fact.hb_scale = INT_BITS - 1; + hs->str_sbr_scale_fact.ov_hb_scale = INT_BITS - 1; + hs->str_sbr_scale_fact.st_syn_scale = INT_BITS - 1; + + ptr_sbr_channel->pstr_prev_frame_data = + sbr_persistent_mem->pstr_prev_frame_data[chan]; + + err = ixheaacd_create_sbr_env_calc( + pstr_sbr_tables, pstr_common_table, &hs->str_sbr_calc_env, chan, + sbr_persistent_mem, ptr_header_data, audio_object_type); + + if (err) { + return (-1); + } + + ixheaacd_create_cplx_anal_qmfbank( + &hs->str_codec_qmf_bank, &hs->str_sbr_scale_fact, no_bins, + ptr_header_data->pstr_freq_band_data->sub_band_start, chan, + sbr_persistent_mem->sbr_qmf_analy_states, + sbr_persistent_mem->sbr_qmf_analy_states_32, + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr, + audio_object_type); + + ixheaacd_create_cplx_synt_qmfbank( + &hs->str_synthesis_qmf_bank, no_bins, + ptr_header_data->pstr_freq_band_data->sub_band_start, + ptr_header_data->pstr_freq_band_data->sub_band_end, chan, + down_sample_flag, sbr_persistent_mem->sbr_qmf_synth_states, + sbr_persistent_mem->sbr_qmf_synth_states_32, + sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr, + audio_object_type); + + ixheaacd_init_sbr_prev_framedata(ptr_sbr_channel->pstr_prev_frame_data, + time_slots); + + err = ixheaacd_create_hf_generator(&hs->str_hf_generator, + hs->str_codec_qmf_bank.num_time_slots, + chan, sbr_persistent_mem, ps_enable); + + if (err) { + return (-1); + } + + hs->ptr_sbr_overlap_buf = sbr_persistent_mem->ptr_sbr_overlap_buf[chan]; + + return 0; +} diff --git a/decoder/ixheaacd_sbrdec_lpfuncs.c b/decoder/ixheaacd_sbrdec_lpfuncs.c new file mode 100644 index 0000000..e317b57 --- /dev/null +++ b/decoder/ixheaacd_sbrdec_lpfuncs.c @@ -0,0 +1,1248 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_sbr_const.h" +#include +#include "ixheaacd_defines.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_freq_sca.h" + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_env_dec.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_sbr_crc.h" +#include "ixheaacd_function_selector.h" + +#include "ixheaacd_audioobjtypes.h" + +#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] = { + {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7}, + {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7}, + {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, + {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}}; + +VOID ixheaacd_reset_sbrenvelope_calc(ia_sbr_calc_env_struct *h_cal_env) { + h_cal_env->ph_index = 0; + h_cal_env->filt_buf_noise_e = 0; + h_cal_env->start_up = 1; +} + +WORD32 ixheaacd_derive_lim_band_tbl( + ia_sbr_header_data_struct *ptr_header_data, + const ia_patch_param_struct *p_str_patch_param, WORD16 num_patches, + ixheaacd_misc_tables *pstr_common_tables) { + WORD32 i, k, k_1; + WORD32 nr_lim, patch_border_k, patch_border_k_1, temp_nr_lim; + + WORD16 lim_table[MAX_FREQ_COEFFS / 2 + MAX_NUM_PATCHES + 1]; + WORD16 patch_borders[MAX_NUM_PATCHES + 1]; + WORD16 kx, k2; + WORD16 temp, lim_bands, num_octaves; + + WORD16 *f_lim_tbl = ptr_header_data->pstr_freq_band_data->freq_band_tbl_lim; + WORD16 *num_lf_bands = &ptr_header_data->pstr_freq_band_data->num_lf_bands; + WORD16 *f_low_tbl = + ptr_header_data->pstr_freq_band_data->freq_band_table[LOW]; + WORD16 num_low_bnd = ptr_header_data->pstr_freq_band_data->num_sf_bands[LOW]; + WORD16 limiter_bands = ptr_header_data->limiter_bands; + + 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}; + + if (limiter_bands == 0) { + f_lim_tbl[0] = 0; + f_lim_tbl[1] = sub_band_end - sub_band_start; + nr_lim = 1; + } else { + for (k = 0; k < num_patches; k++) { + patch_borders[k] = p_str_patch_param[k].guard_start_band - sub_band_start; + } + patch_borders[k] = sub_band_end - sub_band_start; + + for (k = 0; k <= num_low_bnd; k++) { + lim_table[k] = f_low_tbl[k] - sub_band_start; + } + for (k = 1; k < num_patches; k++) { + lim_table[num_low_bnd + k] = patch_borders[k]; + } + + temp_nr_lim = nr_lim = (num_low_bnd + num_patches) - 1; + ixheaacd_aac_shellsort(lim_table, (temp_nr_lim + 1)); + + k = 1; + k_1 = 0; + + lim_bands = limbnd_per_oct[limiter_bands]; + + while ((k - temp_nr_lim) <= 0) { + k2 = lim_table[k] + sub_band_start; + kx = lim_table[k_1] + sub_band_start; + + num_octaves = pstr_common_tables->log_dual_is_table[k2]; + num_octaves -= pstr_common_tables->log_dual_is_table[kx]; + + temp = (WORD16)(((WORD32)lim_bands * (WORD32)num_octaves) >> 15); + + if (temp < 0x01f6) { + if (lim_table[k_1] == lim_table[k]) { + lim_table[k] = sub_band_end; + nr_lim = nr_lim - 1; + k = (k + 1); + continue; + } + patch_border_k_1 = patch_border_k = 0; + + for (i = 0; i <= num_patches; i++) { + if (lim_table[k] == patch_borders[i]) { + patch_border_k = 1; + } + if (lim_table[k_1] == patch_borders[i]) { + patch_border_k_1 = 1; + } + } + if (!patch_border_k) { + lim_table[k] = sub_band_end; + nr_lim = nr_lim - 1; + k = (k + 1); + continue; + } + + if (!patch_border_k_1) { + lim_table[k_1] = sub_band_end; + nr_lim = nr_lim - 1; + } + } + k_1 = k; + k = (k + 1); + } + ixheaacd_aac_shellsort(lim_table, (temp_nr_lim + 1)); + + memcpy(f_lim_tbl, lim_table, sizeof(WORD16) * (nr_lim + 1)); + } + *num_lf_bands = nr_lim; + + return 0; +} + +VOID ixheaacd_lean_sbrconcealment( + ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_sbr_data, + ia_sbr_prev_frame_data_struct *ptr_prev_data) { + WORD32 target; + WORD32 step; + WORD32 i; + + WORD16 cur_start_pos; + WORD16 cur_stop_pos; + + ptr_sbr_data->amp_res = ptr_prev_data->amp_res; + ptr_sbr_data->coupling_mode = ptr_prev_data->coupling_mode; + ptr_sbr_data->max_qmf_subband_aac = ptr_prev_data->max_qmf_subband_aac; + + memcpy(ptr_sbr_data->sbr_invf_mode, ptr_prev_data->sbr_invf_mode, + sizeof(WORD32) * MAX_INVF_BANDS); + + ptr_sbr_data->str_frame_info_details.num_env = 1; + + cur_start_pos = ptr_prev_data->end_position - ptr_header_data->num_time_slots; + cur_stop_pos = ptr_header_data->num_time_slots; + + ptr_sbr_data->str_frame_info_details.border_vec[0] = cur_start_pos; + ptr_sbr_data->str_frame_info_details.border_vec[1] = cur_stop_pos; + + ptr_sbr_data->str_frame_info_details.noise_border_vec[0] = cur_start_pos; + ptr_sbr_data->str_frame_info_details.noise_border_vec[1] = cur_stop_pos; + ; + + ptr_sbr_data->str_frame_info_details.freq_res[0] = 1; + ptr_sbr_data->str_frame_info_details.transient_env = -1; + ptr_sbr_data->str_frame_info_details.num_noise_env = 1; + + ptr_sbr_data->num_env_sfac = + ptr_header_data->pstr_freq_band_data->num_sf_bands[1]; + + ptr_sbr_data->del_cod_dir_arr[0] = DTDF_DIR_TIME; + + if (ptr_sbr_data->coupling_mode == COUPLING_BAL) { + target = SBR_ENERGY_PAN_OFFSET; + } else { + target = 0; + } + + step = 1; + + if (ptr_sbr_data->amp_res - SBR_AMPLITUDE_RESOLUTION_1_5 == 0) { + target = (target << 1); + step = (step << 1); + } + + for (i = 0; i < ptr_sbr_data->num_env_sfac; i++) { + if (ptr_prev_data->sfb_nrg_prev[i] > target) + ptr_sbr_data->int_env_sf_arr[i] = -(step); + else + ptr_sbr_data->int_env_sf_arr[i] = step; + } + + ptr_sbr_data->del_cod_dir_noise_arr[0] = DTDF_DIR_TIME; + + memset(ptr_sbr_data->int_noise_floor, 0, + sizeof(WORD16) * ptr_header_data->pstr_freq_band_data->num_nf_bands); + + memset(ptr_sbr_data->add_harmonics, 0, sizeof(FLAG) * MAX_FREQ_COEFFS); +} + +static WORD16 ixheaacd_find_closest_entry(WORD32 goal_sb, WORD16 *f_master_tbl, + WORD16 num_mf_bands, + WORD16 direction) { + WORD32 index; + + if (goal_sb <= f_master_tbl[0]) return f_master_tbl[0]; + + if (goal_sb >= f_master_tbl[num_mf_bands]) return f_master_tbl[num_mf_bands]; + + if (direction) { + index = 0; + while (f_master_tbl[index] < goal_sb) { + index++; + } + } else { + index = num_mf_bands; + while (f_master_tbl[index] > goal_sb) { + index--; + } + } + + return f_master_tbl[index]; +} + +WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *ptr_hf_gen_str, + ia_sbr_header_data_struct *ptr_header_data, + WORD audio_object_type) { + WORD32 patch, sb; + WORD32 temp; + WORD16 *ptr_noise_freq_tbl; + WORD32 num_nf_bands; + + ia_transposer_settings_struct *pstr_transposer_settings = + ptr_hf_gen_str->pstr_settings; + ia_patch_param_struct *p_str_patch_param = + pstr_transposer_settings->str_patch_param; + + WORD32 sub_band_start = ptr_header_data->pstr_freq_band_data->sub_band_start; + WORD16 *f_master_tbl = ptr_header_data->pstr_freq_band_data->f_master_tbl; + WORD16 num_mf_bands = ptr_header_data->pstr_freq_band_data->num_mf_bands; + WORD16 usb = ptr_header_data->pstr_freq_band_data->sub_band_end; + + WORD32 src_start_band; + WORD32 patch_stride; + WORD32 num_bands_in_patch; + + WORD32 lsb = f_master_tbl[0]; + WORD16 xover_offset = sub_band_start - lsb; + + WORD16 goal_sb; + WORD32 fs = ptr_header_data->out_sampling_freq; + + if (lsb < (SHIFT_START_SB + 4)) { + return (1); + } + switch (fs) { + case 16000: + case 22050: + case 24000: + case 32000: + goal_sb = 64; + break; + case 44100: + goal_sb = 46; + break; + case 48000: + goal_sb = 43; + break; + case 64000: + goal_sb = 32; + break; + case 88200: + goal_sb = 23; + break; + case 96000: + goal_sb = 21; + break; + default: + return (0); + } + + goal_sb = ixheaacd_find_closest_entry(goal_sb, f_master_tbl, num_mf_bands, 1); + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) { + if (ixheaacd_abs16_sat((WORD16)(goal_sb - usb)) < 4) { + goal_sb = usb; + } + } + + src_start_band = SHIFT_START_SB + xover_offset; + sb = (lsb + xover_offset); + + patch = 0; + + while (((sb - usb) < 0) && (patch < MAX_NUM_PATCHES)) { + ia_patch_param_struct *ptr_loc_patch_param = &p_str_patch_param[patch]; + + 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 - (lsb - src_start_band)) >= 0) { + patch_stride = sb - src_start_band; + patch_stride = (WORD16)(patch_stride & ~1); + num_bands_in_patch = (lsb - (sb - patch_stride)); + num_bands_in_patch = ixheaacd_find_closest_entry( + sb + num_bands_in_patch, f_master_tbl, num_mf_bands, 0); + num_bands_in_patch -= sb; + } + + patch_stride = ((num_bands_in_patch + sb) - lsb); + patch_stride = (WORD16)((patch_stride + 1) & ~1); + + if (num_bands_in_patch > 0) { + ptr_loc_patch_param->src_start_band = (sb - patch_stride); + ptr_loc_patch_param->dst_end_band = patch_stride; + ptr_loc_patch_param->num_bands_in_patch = num_bands_in_patch; + ptr_loc_patch_param->src_end_band = + (ptr_loc_patch_param->src_start_band + num_bands_in_patch); + + sb = (sb + ptr_loc_patch_param->num_bands_in_patch); + patch++; + } + + src_start_band = SHIFT_START_SB; + + if ((ixheaacd_abs16_sat((WORD16)((sb - goal_sb))) - 3) < 0) { + goal_sb = usb; + } + } + + patch--; + + if ((patch > 0) && (p_str_patch_param[patch].num_bands_in_patch < 3)) { + patch--; + sb = p_str_patch_param[patch].dst_start_band + + p_str_patch_param[patch].num_bands_in_patch; + } + + if (patch >= MAX_NUM_PATCHES) { + return -1; + } + + pstr_transposer_settings->num_patches = patch + 1; + + temp = 0; + + for (patch = 0; patch < pstr_transposer_settings->num_patches; patch++) { + sb = ixheaacd_min32(sb, p_str_patch_param[patch].src_start_band); + temp = ixheaacd_max32(temp, p_str_patch_param[patch].src_end_band); + } + + pstr_transposer_settings->start_patch = sb; + pstr_transposer_settings->stop_patch = temp; + + ptr_noise_freq_tbl = + ptr_header_data->pstr_freq_band_data->freq_band_tbl_noise; + num_nf_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands; + + memcpy(&pstr_transposer_settings->bw_borders[0], &ptr_noise_freq_tbl[1], + sizeof(WORD16) * num_nf_bands); + + memset(ptr_hf_gen_str->bw_array_prev, 0, sizeof(WORD32) * MAX_NUM_PATCHES); + + return 0; +} +VOID ixheaacd_rescale_x_overlap( + ia_sbr_dec_struct *ptr_sbr_dec, ia_sbr_header_data_struct *ptr_header_data, + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, + WORD32 **pp_overlap_buffer_real, FLAG low_pow_flag) { + WORD32 k, l; + WORD32 start_band, end_band; + WORD32 target_lsb, target_usb; + WORD32 source_scale, target_scale, delta_scale, reserve; + WORD32 **pp_overlap_buffer_imag = &pp_overlap_buffer_real[MAX_ENV_COLS]; + + WORD32 old_lsb = ptr_frame_data_prev->max_qmf_subband_aac; + WORD32 start_slot = + (ptr_header_data->time_step * + (ptr_frame_data_prev->end_position - ptr_header_data->num_time_slots)); + WORD32 new_lsb = ptr_frame_data->max_qmf_subband_aac; + + ptr_sbr_dec->str_codec_qmf_bank.usb = new_lsb; + ptr_sbr_dec->str_synthesis_qmf_bank.lsb = new_lsb; + + start_band = ixheaacd_min32(old_lsb, new_lsb); + end_band = ixheaacd_max32(old_lsb, new_lsb); + + if (new_lsb != old_lsb && old_lsb > 0) { + for (l = start_slot; l < 6; l++) { + for (k = old_lsb; k < new_lsb; k++) { + pp_overlap_buffer_real[l][k] = 0L; + + if (!low_pow_flag) { + pp_overlap_buffer_imag[l][k] = 0L; + } + } + } + + if (new_lsb > old_lsb) { + source_scale = ptr_sbr_dec->str_sbr_scale_fact.ov_hb_scale; + target_scale = ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale; + target_lsb = 0; + target_usb = old_lsb; + } else { + source_scale = ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale; + target_scale = ptr_sbr_dec->str_sbr_scale_fact.ov_hb_scale; + target_lsb = old_lsb; + target_usb = ptr_sbr_dec->str_synthesis_qmf_bank.usb; + } + + reserve = (*ixheaacd_ixheaacd_expsubbandsamples)( + pp_overlap_buffer_real, pp_overlap_buffer_imag, start_band, end_band, 0, + start_slot, low_pow_flag); + + (*ixheaacd_adjust_scale)(pp_overlap_buffer_real, pp_overlap_buffer_imag, + start_band, end_band, 0, start_slot, reserve, + low_pow_flag); + + source_scale += reserve; + + delta_scale = (target_scale - source_scale); + + if (delta_scale > 0) { + delta_scale = -(delta_scale); + start_band = target_lsb; + end_band = target_usb; + + if (new_lsb > old_lsb) { + ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale = source_scale; + } else { + ptr_sbr_dec->str_sbr_scale_fact.ov_hb_scale = source_scale; + } + } + + (*ixheaacd_adjust_scale)(pp_overlap_buffer_real, pp_overlap_buffer_imag, + start_band, end_band, 0, start_slot, delta_scale, + low_pow_flag); + } +} + +VOID ixheaacd_map_sineflags(WORD16 *freq_band_table, WORD16 num_sf_bands, + FLAG *add_harmonics, WORD8 *harm_flags_prev, + WORD16 transient_env, WORD8 *sine_mapped) + +{ + WORD32 qmfband2, li, ui, i; + WORD32 low_subband_sec; + WORD32 oldflags; + + low_subband_sec = (freq_band_table[0] << 1); + + memset(sine_mapped, MAX_ENVELOPES, sizeof(WORD8) * MAX_FREQ_COEFFS); + + for (i = (num_sf_bands - 1); i >= 0; i--) { + oldflags = *harm_flags_prev; + *harm_flags_prev++ = add_harmonics[i]; + + if (add_harmonics[i]) { + li = freq_band_table[i]; + + ui = freq_band_table[i + 1]; + + qmfband2 = ((ui + li) - low_subband_sec) >> 1; + + if (oldflags) + sine_mapped[qmfband2] = 0; + else + sine_mapped[qmfband2] = (WORD8)transient_env; + } + } +} + +VOID ixheaacd_map_34_params_to_20(WORD16 *params) { + params[0] = ixheaacd_divideby3(params[0] + params[0] + params[1]); + params[1] = ixheaacd_divideby3(params[1] + params[2] + params[2]); + params[2] = ixheaacd_divideby3(params[3] + params[3] + params[4]); + params[3] = ixheaacd_divideby3(params[4] + params[5] + params[5]); + params[4] = ixheaacd_divideby2(params[6] + params[7]); + params[5] = ixheaacd_divideby2(params[8] + params[9]); + params[6] = params[10]; + params[7] = params[11]; + params[8] = ixheaacd_divideby2(params[12] + params[13]); + params[9] = ixheaacd_divideby2(params[14] + params[15]); + params[10] = params[16]; + params[11] = params[17]; + params[12] = params[18]; + params[13] = params[19]; + params[14] = ixheaacd_divideby2(params[20] + params[21]); + params[15] = ixheaacd_divideby2(params[22] + params[23]); + params[16] = ixheaacd_divideby2(params[24] + params[25]); + params[17] = ixheaacd_divideby2(params[26] + params[27]); + params[18] = ixheaacd_divideby2( + ixheaacd_divideby2(params[28] + params[29] + params[30] + params[31])); + params[19] = ixheaacd_divideby2(params[32] + params[33]); +} + +extern const WORD16 ixheaacd_num_bands[3]; + +WORD16 ixheaacd_read_ps_data(ia_ps_dec_struct *ptr_ps_dec, + ia_bit_buf_struct *it_bit_buff, + WORD16 num_bits_left, + ia_ps_tables_struct *ps_tables_ptr) { + WORD b, e, temp; + const WORD16 num_env_tab[4] = {0, 1, 2, 4}; + WORD cnt_bits; + ia_huffman_data_type huffman_table, huffman_df_table, huffman_dt_table; + FLAG enable_ps_header; + + if (!ptr_ps_dec) { + return 0; + } + + cnt_bits = it_bit_buff->cnt_bits; + + enable_ps_header = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (enable_ps_header) { + ptr_ps_dec->enable_iid = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (ptr_ps_dec->enable_iid) { + ptr_ps_dec->iid_mode = ixheaacd_read_bits_buf(it_bit_buff, 3); + } + + if (ptr_ps_dec->iid_mode > 2) { + ptr_ps_dec->iid_quant = 1; + ptr_ps_dec->iid_mode -= 3; + } else { + ptr_ps_dec->iid_quant = 0; + } + + ptr_ps_dec->enable_icc = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (ptr_ps_dec->enable_icc) { + ptr_ps_dec->icc_mode = ixheaacd_read_bits_buf(it_bit_buff, 3); + } + + ptr_ps_dec->enable_ext = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (ptr_ps_dec->icc_mode > 2) { + ptr_ps_dec->icc_mode -= 3; + } + } + + if ((ptr_ps_dec->enable_iid && ptr_ps_dec->iid_mode > 2) || + (ptr_ps_dec->enable_icc && ptr_ps_dec->icc_mode > 2)) { + ptr_ps_dec->ps_data_present = 0; + + num_bits_left -= (cnt_bits - it_bit_buff->cnt_bits); + + while (num_bits_left > 8) { + ixheaacd_read_bits_buf(it_bit_buff, 8); + num_bits_left -= 8; + } + ixheaacd_read_bits_buf(it_bit_buff, num_bits_left); + + return (cnt_bits - it_bit_buff->cnt_bits); + } + + ptr_ps_dec->frame_class = (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + + temp = ixheaacd_read_bits_buf(it_bit_buff, 2); + + if (ptr_ps_dec->frame_class == 0) { + ptr_ps_dec->num_env = num_env_tab[temp]; + } else { + ptr_ps_dec->num_env = (((1 + temp) << 8) >> 8); + + for (e = 1; e < ptr_ps_dec->num_env + 1; e++) { + ptr_ps_dec->border_position[e] = + (((ixheaacd_read_bits_buf(it_bit_buff, 5) + 1) << 8) >> 8); + } + } + + if (ptr_ps_dec->enable_iid) { + if (ptr_ps_dec->iid_quant) { + huffman_df_table = (ia_huffman_data_type)&ps_tables_ptr->huff_iid_df_fine; + huffman_dt_table = (ia_huffman_data_type)&ps_tables_ptr->huff_iid_dt_fine; + } else { + huffman_df_table = (ia_huffman_data_type)&ps_tables_ptr->huff_iid_df; + huffman_dt_table = (ia_huffman_data_type)&ps_tables_ptr->huff_iid_dt; + } + + for (e = 0; e < ptr_ps_dec->num_env; e++) { + ptr_ps_dec->iid_dt[e] = (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (ptr_ps_dec->iid_dt[e]) { + huffman_table = huffman_dt_table; + } else { + huffman_table = huffman_df_table; + } + + for (b = 0; b < ixheaacd_num_bands[ptr_ps_dec->iid_mode]; b++) { + ptr_ps_dec->iid_par_table[e][b] = + ixheaacd_ssc_huff_dec(huffman_table, it_bit_buff); + } + } + } + + if (ptr_ps_dec->enable_icc) { + huffman_df_table = (ia_huffman_data_type)&ps_tables_ptr->huff_icc_df; + huffman_dt_table = (ia_huffman_data_type)&ps_tables_ptr->huff_icc_dt; + + for (e = 0; e < ptr_ps_dec->num_env; e++) { + ptr_ps_dec->icc_dt[e] = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (ptr_ps_dec->icc_dt[e]) { + huffman_table = huffman_dt_table; + } else { + huffman_table = huffman_df_table; + } + + for (b = 0; b < ixheaacd_num_bands[ptr_ps_dec->icc_mode]; b++) { + ptr_ps_dec->icc_par_table[e][b] = + ixheaacd_ssc_huff_dec(huffman_table, it_bit_buff); + } + } + } + + if (ptr_ps_dec->enable_ext) { + WORD32 cnt = ixheaacd_read_bits_buf(it_bit_buff, 4); + + if (cnt == 15) { + cnt += ixheaacd_read_bits_buf(it_bit_buff, 8); + } + while (cnt--) { + ixheaacd_read_bits_buf(it_bit_buff, 8); + } + } + + ptr_ps_dec->ps_data_present = 1; + + return (cnt_bits - it_bit_buff->cnt_bits); +} + +VOID ixheaacd_invfilt_level_emphasis(ia_sbr_hf_generator_struct *ptr_hf_gen_str, + WORD32 num_if_bands, WORD32 *inv_filt_mode, + WORD32 *inv_filt_mode_prev, + WORD32 *bw_array) { + WORD32 i; + WORD32 accu; + WORD16 w1, w2; + + for (i = 0; i < num_if_bands; i++) { + bw_array[i] = + ixheaacd_inew_bw_table[inv_filt_mode_prev[i]][inv_filt_mode[i]]; + + if (bw_array[i] < ptr_hf_gen_str->bw_array_prev[i]) { + w1 = 0x6000; + w2 = 0x2000; + } else { + w1 = 0x7400; + w2 = 0x0c00; + } + accu = ixheaacd_add32( + ixheaacd_mult32x16in32_shl(bw_array[i], w1), + ixheaacd_mult32x16in32_shl(ptr_hf_gen_str->bw_array_prev[i], w2)); + + if (accu < 0x02000000) { + accu = 0; + } + + if (accu >= 0x7f800000) { + accu = 0x7f800000; + } + bw_array[i] = accu; + } +} + +typedef struct { + FLOAT32 phi_0_1_real; + FLOAT32 phi_0_1_imag; + FLOAT32 phi_0_2_real; + FLOAT32 phi_0_2_imag; + FLOAT32 phi_1_1; + FLOAT32 phi_1_2_real; + FLOAT32 phi_1_2_imag; + FLOAT32 phi_2_2; + FLOAT32 det; +} ia_auto_corr_ele_struct; + +static VOID ixheaacd_esbr_calc_co_variance( + ia_auto_corr_ele_struct *pstr_auto_corr, FLOAT32 vec_x_real[][64], + FLOAT32 vec_x_imag[][64], WORD32 bd, WORD32 len) { + WORD32 j, jminus1, jminus2; + + memset(pstr_auto_corr, 0, sizeof(ia_auto_corr_ele_struct)); + + for (j = 0; j < len; j++) { + jminus1 = j - 1; + jminus2 = jminus1 - 1; + + pstr_auto_corr->phi_0_1_real += + vec_x_real[j][bd] * vec_x_real[jminus1][bd] + + vec_x_imag[j][bd] * vec_x_imag[jminus1][bd]; + + pstr_auto_corr->phi_0_1_imag += + vec_x_imag[j][bd] * vec_x_real[jminus1][bd] - + vec_x_real[j][bd] * vec_x_imag[jminus1][bd]; + + pstr_auto_corr->phi_0_2_real += + vec_x_real[j][bd] * vec_x_real[jminus2][bd] + + vec_x_imag[j][bd] * vec_x_imag[jminus2][bd]; + + pstr_auto_corr->phi_0_2_imag += + vec_x_imag[j][bd] * vec_x_real[jminus2][bd] - + vec_x_real[j][bd] * vec_x_imag[jminus2][bd]; + + pstr_auto_corr->phi_1_1 += + vec_x_real[jminus1][bd] * vec_x_real[jminus1][bd] + + vec_x_imag[jminus1][bd] * vec_x_imag[jminus1][bd]; + + pstr_auto_corr->phi_1_2_real += + vec_x_real[jminus1][bd] * vec_x_real[jminus2][bd] + + vec_x_imag[jminus1][bd] * vec_x_imag[jminus2][bd]; + + pstr_auto_corr->phi_1_2_imag += + vec_x_imag[jminus1][bd] * vec_x_real[jminus2][bd] - + vec_x_real[jminus1][bd] * vec_x_imag[jminus2][bd]; + + pstr_auto_corr->phi_2_2 += + vec_x_real[jminus2][bd] * vec_x_real[jminus2][bd] + + vec_x_imag[jminus2][bd] * vec_x_imag[jminus2][bd]; + } + + pstr_auto_corr->det = + pstr_auto_corr->phi_1_1 * pstr_auto_corr->phi_2_2 - + (pstr_auto_corr->phi_1_2_real * pstr_auto_corr->phi_1_2_real + + pstr_auto_corr->phi_1_2_imag * pstr_auto_corr->phi_1_2_imag) * + SBR_HF_RELAXATION_PARAM; +} + +static void ixheaacd_esbr_chirp_fac_calc(WORD32 *inv_filt_mode, + WORD32 *inv_filt_mode_prev, + WORD32 num_if_bands, FLOAT32 *bw_array, + FLOAT32 *bw_array_prev) { + WORD32 i; + + for (i = 0; i < num_if_bands; i++) { + bw_array[i] = + ixheaacd_new_bw_table[inv_filt_mode_prev[i]][inv_filt_mode[i]]; + + if (bw_array[i] < bw_array_prev[i]) + bw_array[i] = 0.75000f * bw_array[i] + 0.25000f * bw_array_prev[i]; + else + bw_array[i] = 0.90625f * bw_array[i] + 0.09375f * bw_array_prev[i]; + + if (bw_array[i] < 0.015625) bw_array[i] = 0; + } +} + +static void ixheaacd_gausssolve(WORD32 n, FLOAT32 a[][MAXDEG + 1], FLOAT32 b[], + FLOAT32 y[]) { + WORD32 i, j, k, imax; + FLOAT32 v; + + for (i = 0; i < n; i++) { + imax = i; + for (k = i + 1; k < n; k++) { + if (fabs(a[k][i]) > fabs(a[imax][i])) { + imax = k; + } + } + if (imax != i) { + v = b[imax]; + b[imax] = b[i]; + b[i] = v; + for (j = i; j < n; j++) { + v = a[imax][j]; + a[imax][j] = a[i][j]; + a[i][j] = v; + } + } + + v = a[i][i]; + + b[i] /= v; + for (j = i; j < n; j++) { + a[i][j] /= v; + } + + for (k = i + 1; k < n; k++) { + v = a[k][i]; + b[k] -= v * b[i]; + for (j = i + 1; j < n; j++) { + a[k][j] -= v * a[i][j]; + } + } + } + + for (i = n - 1; i >= 0; i--) { + y[i] = b[i]; + for (j = i + 1; j < n; j++) { + y[i] -= a[i][j] * y[j]; + } + } +} + +void ixheaacd_polyfit(WORD32 n, FLOAT32 y[], FLOAT32 p[]) { + WORD32 i, j, k; + FLOAT32 a[MAXDEG + 1][MAXDEG + 1]; + FLOAT32 b[MAXDEG + 1]; + FLOAT32 v[2 * MAXDEG + 1]; + + for (i = 0; i <= MAXDEG; i++) { + b[i] = 0.0f; + for (j = 0; j <= MAXDEG; j++) { + a[i][j] = 0.0f; + } + } + + for (k = 0; k < n; k++) { + v[0] = 1.0; + for (i = 1; i <= 2 * MAXDEG; i++) { + v[i] = k * v[i - 1]; + } + + for (i = 0; i <= MAXDEG; i++) { + b[i] += v[MAXDEG - i] * y[k]; + for (j = 0; j <= MAXDEG; j++) { + a[i][j] += v[2 * MAXDEG - i - j]; + } + } + } + + ixheaacd_gausssolve(MAXDEG + 1, a, b, p); +} + +VOID ixheaacd_pre_processing(FLOAT32 ptr_src_buf_real[][64], + FLOAT32 ptr_src_buf_imag[][64], + FLOAT32 gain_vector[], WORD32 num_bands, + WORD32 start_sample, WORD32 end_sample) { + WORD32 k, i; + FLOAT32 poly_coeff[4]; + FLOAT32 mean_enrg = 0; + FLOAT32 low_env_slope[64]; + FLOAT32 low_env[64]; + FLOAT32 a0; + FLOAT32 a1; + FLOAT32 a2; + FLOAT32 a3; + + for (k = 0; k < num_bands; k++) { + FLOAT32 temp = 0; + for (i = start_sample; i < end_sample; i++) { + temp += ptr_src_buf_real[i][k] * ptr_src_buf_real[i][k] + + ptr_src_buf_imag[i][k] * ptr_src_buf_imag[i][k]; + } + temp /= (end_sample - start_sample); + low_env[k] = (FLOAT32)(10 * log10(temp + 1)); + mean_enrg = mean_enrg + low_env[k]; + } + mean_enrg /= num_bands; + + ixheaacd_polyfit(num_bands, low_env, poly_coeff); + + a0 = poly_coeff[0]; + a1 = poly_coeff[1]; + a2 = poly_coeff[2]; + a3 = poly_coeff[3]; + for (k = 0; k < num_bands; k++) { + FLOAT32 x_low_l = (FLOAT32)k; + FLOAT32 low_env_slope_l = a3; + low_env_slope_l = low_env_slope_l + a2 * x_low_l; + + x_low_l = x_low_l * x_low_l; + low_env_slope_l = low_env_slope_l + a1 * x_low_l; + + x_low_l = x_low_l * (FLOAT32)k; + low_env_slope_l = low_env_slope_l + a0 * x_low_l; + + low_env_slope[k] = low_env_slope_l; + } + + for (i = 0; i < num_bands; i++) { + gain_vector[i] = (FLOAT32)pow(10, (mean_enrg - low_env_slope[i]) / 20.0f); + } +} + +VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], + FLOAT32 ptr_src_buf_imag[][64], + FLOAT32 ptr_ph_vocod_buf_real[][64], + FLOAT32 ptr_ph_vocod_buf_imag[][64], + FLOAT32 ptr_dst_buf_real[][64], + FLOAT32 ptr_dst_buf_imag[][64], + ia_sbr_frame_info_data_struct *ptr_frame_data, + ia_sbr_header_data_struct *ptr_header_data) { + WORD32 bw_index, i, k, k2, patch = 0; + WORD32 co_var_len; + WORD32 start_sample, end_sample, goal_sb; + WORD32 sb, source_start_band, patch_stride, num_bands_in_patch; + WORD32 hbe_flag = ptr_header_data->hbe_flag; + FLOAT32 a0r, a0i, a1r, a1i; + FLOAT32 bw_array[MAX_NUM_PATCHES] = {0}; + + ia_auto_corr_ele_struct str_auto_corr; + + WORD16 *ptr_invf_band_tbl = + &ptr_header_data->pstr_freq_band_data->freq_band_tbl_noise[1]; + WORD32 num_if_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands; + WORD32 sub_band_start = ptr_header_data->pstr_freq_band_data->sub_band_start; + WORD16 *f_master_tbl = ptr_header_data->pstr_freq_band_data->f_master_tbl; + WORD32 num_mf_bands = ptr_header_data->pstr_freq_band_data->num_mf_bands; + WORD32 *inv_filt_mode = ptr_frame_data->sbr_invf_mode; + WORD32 *inv_filt_mode_prev = ptr_frame_data->sbr_invf_mode_prev; + WORD32 sbr_patching_mode = ptr_frame_data->sbr_patching_mode; + ia_frame_info_struct *p_frame_info = &ptr_frame_data->str_frame_info_details; + WORD32 pre_proc_flag = ptr_header_data->pre_proc_flag; + WORD32 is_usf_4 = ptr_header_data->is_usf_4; + WORD32 fs = ptr_header_data->out_sampling_freq; + + WORD32 lsb = f_master_tbl[0]; + WORD32 usb = f_master_tbl[num_mf_bands]; + WORD32 xover_offset = sub_band_start - f_master_tbl[0]; + + FLOAT32 bw = 0.0f; + FLOAT32 fac = 0.0f; + + FLOAT32 gain; + FLOAT32 gain_vector[64]; + + WORD32 slope_length = 0; + WORD32 first_slot_offset = p_frame_info->border_vec[0]; + WORD32 end_slot_offs = 0; + + FLOAT32 *bw_array_prev = ptr_frame_data->bw_array_prev; + + end_slot_offs = p_frame_info->border_vec[p_frame_info->num_env] - 16; + if (is_usf_4) { + start_sample = first_slot_offset * 4; + end_sample = 64 + end_slot_offs * 4; + co_var_len = 76; + } else { + start_sample = first_slot_offset * 2; + end_sample = 32 + end_slot_offs * 2; + co_var_len = 38; + } + + if (pre_proc_flag) { + ixheaacd_pre_processing(ptr_src_buf_real, ptr_src_buf_imag, gain_vector, + f_master_tbl[0], start_sample, end_sample); + } + + ixheaacd_esbr_chirp_fac_calc(inv_filt_mode, inv_filt_mode_prev, num_if_bands, + bw_array, bw_array_prev); + + for (i = start_sample; i < end_sample; i++) { + memset(ptr_dst_buf_real[i] + usb, 0, (64 - usb) * sizeof(FLOAT32)); + memset(ptr_dst_buf_imag[i] + usb, 0, (64 - usb) * sizeof(FLOAT32)); + } + + if (sbr_patching_mode || !hbe_flag) { + FLOAT32 alpha_real[64][2], alpha_imag[64][2]; + + for (k = 1; k < f_master_tbl[0]; k++) { + ixheaacd_esbr_calc_co_variance(&str_auto_corr, &ptr_src_buf_real[0], + &ptr_src_buf_imag[0], k, co_var_len); + if (str_auto_corr.det == 0.0f) { + alpha_real[k][1] = alpha_imag[k][1] = 0; + } else { + fac = 1.0f / str_auto_corr.det; + alpha_real[k][1] = + (str_auto_corr.phi_0_1_real * str_auto_corr.phi_1_2_real - + str_auto_corr.phi_0_1_imag * str_auto_corr.phi_1_2_imag - + str_auto_corr.phi_0_2_real * str_auto_corr.phi_1_1) * + fac; + alpha_imag[k][1] = + (str_auto_corr.phi_0_1_imag * str_auto_corr.phi_1_2_real + + str_auto_corr.phi_0_1_real * str_auto_corr.phi_1_2_imag - + str_auto_corr.phi_0_2_imag * str_auto_corr.phi_1_1) * + fac; + } + + if (str_auto_corr.phi_1_1 == 0) { + alpha_real[k][0] = alpha_imag[k][0] = 0; + } else { + fac = 1.0f / str_auto_corr.phi_1_1; + alpha_real[k][0] = -(str_auto_corr.phi_0_1_real + + alpha_real[k][1] * str_auto_corr.phi_1_2_real + + alpha_imag[k][1] * str_auto_corr.phi_1_2_imag) * + fac; + alpha_imag[k][0] = -(str_auto_corr.phi_0_1_imag + + alpha_imag[k][1] * str_auto_corr.phi_1_2_real - + alpha_real[k][1] * str_auto_corr.phi_1_2_imag) * + fac; + } + + if ((alpha_real[k][0] * alpha_real[k][0] + + alpha_imag[k][0] * alpha_imag[k][0] >= + 16.0f) || + (alpha_real[k][1] * alpha_real[k][1] + + alpha_imag[k][1] * alpha_imag[k][1] >= + 16.0f)) { + alpha_real[k][0] = 0.0f; + alpha_imag[k][0] = 0.0f; + alpha_real[k][1] = 0.0f; + alpha_imag[k][1] = 0.0f; + } + } + + goal_sb = (WORD32)(2.048e6f / fs + 0.5f); + { + WORD32 index; + if (goal_sb < f_master_tbl[num_mf_bands]) { + for (index = 0; (f_master_tbl[index] < goal_sb); index++) + ; + goal_sb = f_master_tbl[index]; + } else { + goal_sb = f_master_tbl[num_mf_bands]; + } + } + + source_start_band = xover_offset + 1; + sb = lsb + xover_offset; + + patch = 0; + while (sb < usb) { + ptr_frame_data->patch_param.start_subband[patch] = sb; + num_bands_in_patch = goal_sb - sb; + + if (num_bands_in_patch >= lsb - source_start_band) { + patch_stride = sb - source_start_band; + patch_stride = patch_stride & ~1; + num_bands_in_patch = lsb - (sb - patch_stride); + num_bands_in_patch = + ixheaacd_find_closest_entry(sb + num_bands_in_patch, f_master_tbl, + (WORD16)(num_mf_bands), 0) - + (WORD32)(sb); + } + + patch_stride = num_bands_in_patch + sb - lsb; + patch_stride = (patch_stride + 1) & ~1; + + source_start_band = 1; + + if (goal_sb - (sb + num_bands_in_patch) < 3) { + goal_sb = usb; + } + + if ((num_bands_in_patch < 3) && (patch > 0) && + (sb + num_bands_in_patch == usb)) { + for (i = start_sample + slope_length; i < end_sample + slope_length; + i++) { + for (k2 = sb; k2 < sb + num_bands_in_patch; k2++) { + ptr_dst_buf_real[i][k2] = 0.0f; + ptr_dst_buf_imag[i][k2] = 0.0f; + } + } + + break; + } + + if (num_bands_in_patch <= 0) { + continue; + } + + for (k2 = sb; k2 < sb + num_bands_in_patch; k2++) { + k = k2 - patch_stride; + bw_index = 0; + while (k2 >= ptr_invf_band_tbl[bw_index]) bw_index++; + + bw = bw_array[bw_index]; + + a0r = bw * alpha_real[k][0]; + a0i = bw * alpha_imag[k][0]; + bw *= bw; + a1r = bw * alpha_real[k][1]; + a1i = bw * alpha_imag[k][1]; + + if (pre_proc_flag) { + gain = gain_vector[k]; + } else { + gain = 1.0f; + } + + for (i = start_sample + slope_length; i < end_sample + slope_length; + i++) { + ptr_dst_buf_real[i][k2] = ptr_src_buf_real[i][k] * gain; + + ptr_dst_buf_imag[i][k2] = ptr_src_buf_imag[i][k] * gain; + + if (bw > 0.0f) { + ptr_dst_buf_real[i][k2] += (a0r * ptr_src_buf_real[i - 1][k] - + a0i * ptr_src_buf_imag[i - 1][k] + + a1r * ptr_src_buf_real[i - 2][k] - + a1i * ptr_src_buf_imag[i - 2][k]) * + gain; + ptr_dst_buf_imag[i][k2] += (a0i * ptr_src_buf_real[i - 1][k] + + a0r * ptr_src_buf_imag[i - 1][k] + + a1i * ptr_src_buf_real[i - 2][k] + + a1r * ptr_src_buf_imag[i - 2][k]) * + gain; + } + } + } + sb += num_bands_in_patch; + patch++; + } + } + + if (hbe_flag && !sbr_patching_mode) { + FLOAT32 alpha_real[2], alpha_imag[2]; + + bw_index = 0, patch = 1; + + for (k2 = sub_band_start; k2 < f_master_tbl[num_mf_bands]; k2++) { + ixheaacd_esbr_calc_co_variance(&str_auto_corr, &ptr_ph_vocod_buf_real[0], + &ptr_ph_vocod_buf_imag[0], k2, co_var_len); + + if (str_auto_corr.det == 0.0f) { + alpha_real[1] = alpha_imag[1] = 0; + } else { + fac = 1.0f / str_auto_corr.det; + alpha_real[1] = + (str_auto_corr.phi_0_1_real * str_auto_corr.phi_1_2_real - + str_auto_corr.phi_0_1_imag * str_auto_corr.phi_1_2_imag - + str_auto_corr.phi_0_2_real * str_auto_corr.phi_1_1) * + fac; + alpha_imag[1] = + (str_auto_corr.phi_0_1_imag * str_auto_corr.phi_1_2_real + + str_auto_corr.phi_0_1_real * str_auto_corr.phi_1_2_imag - + str_auto_corr.phi_0_2_imag * str_auto_corr.phi_1_1) * + fac; + } + + if (str_auto_corr.phi_1_1 == 0) { + alpha_real[0] = alpha_imag[0] = 0; + } else { + fac = 1.0f / str_auto_corr.phi_1_1; + alpha_real[0] = -(str_auto_corr.phi_0_1_real + + alpha_real[1] * str_auto_corr.phi_1_2_real + + alpha_imag[1] * str_auto_corr.phi_1_2_imag) * + fac; + alpha_imag[0] = -(str_auto_corr.phi_0_1_imag + + alpha_imag[1] * str_auto_corr.phi_1_2_real - + alpha_real[1] * str_auto_corr.phi_1_2_imag) * + fac; + } + + if (alpha_real[0] * alpha_real[0] + alpha_imag[0] * alpha_imag[0] >= + 16.0f || + alpha_real[1] * alpha_real[1] + alpha_imag[1] * alpha_imag[1] >= + 16.0f) { + alpha_real[0] = 0.0f; + alpha_imag[0] = 0.0f; + alpha_real[1] = 0.0f; + alpha_imag[1] = 0.0f; + } + + while (k2 >= ptr_invf_band_tbl[bw_index]) bw_index++; + + bw = bw_array[bw_index]; + + a0r = bw * alpha_real[0]; + a0i = bw * alpha_imag[0]; + bw *= bw; + a1r = bw * alpha_real[1]; + a1i = bw * alpha_imag[1]; + + if (bw > 0.0f) { + for (i = start_sample; i < end_sample; i++) { + FLOAT32 real1, imag1, real2, imag2, realTarget, imag_target; + + realTarget = ptr_ph_vocod_buf_real[i][k2]; + imag_target = ptr_ph_vocod_buf_imag[i][k2]; + real1 = ptr_ph_vocod_buf_real[i - 1][k2]; + imag1 = ptr_ph_vocod_buf_imag[i - 1][k2]; + real2 = ptr_ph_vocod_buf_real[i - 2][k2]; + imag2 = ptr_ph_vocod_buf_imag[i - 2][k2]; + realTarget += + ((a0r * real1 - a0i * imag1) + (a1r * real2 - a1i * imag2)); + imag_target += + ((a0i * real1 + a0r * imag1) + (a1i * real2 + a1r * imag2)); + + ptr_dst_buf_real[i][k2] = realTarget; + ptr_dst_buf_imag[i][k2] = imag_target; + } + } else { + for (i = start_sample; i < end_sample; i++) { + ptr_dst_buf_real[i][k2] = ptr_ph_vocod_buf_real[i][k2]; + ptr_dst_buf_imag[i][k2] = ptr_ph_vocod_buf_imag[i][k2]; + } + } + } + } + ptr_frame_data->patch_param.num_patches = patch; + for (i = 0; i < num_if_bands; i++) { + bw_array_prev[i] = bw_array[i]; + } +} diff --git a/decoder/ixheaacd_sbrdecoder.c b/decoder/ixheaacd_sbrdecoder.c new file mode 100644 index 0000000..8c79888 --- /dev/null +++ b/decoder/ixheaacd_sbrdecoder.c @@ -0,0 +1,731 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_sbr_const.h" +#include +#include "ixheaacd_defines.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_ps_bitdec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_freq_sca.h" + +#include "ixheaacd_qmf_dec.h" + +#include "ixheaacd_env_calc.h" + +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_env_dec.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_sbr_crc.h" + +#include "ixheaacd_audioobjtypes.h" + +VOID ixheaacd_downmix_to_monosbr(WORD16 *core_sample_buf, WORD32 ch_fac) { + WORD32 i; + WORD16 *ptr1 = &core_sample_buf[0]; + WORD16 *ptr2 = &core_sample_buf[1]; + + for (i = MAX_FRAME_SIZE - 1; i >= 0; i--) { + *ptr1 = ((*ptr1 >> 1) + (*ptr2 >> 1)); + + ptr1 += ch_fac; + ptr2 += ch_fac; + } +} + +static WORD32 ixheaacd_sbr_dec_reset(ia_sbr_dec_struct *ptr_sbr_dec, + ia_sbr_header_data_struct *ptr_header_data, + FLAG low_pow_flag, + ixheaacd_misc_tables *pstr_common_tables, + WORD32 pitch_in_bins, + WORD32 audio_object_type) { + WORD32 old_lsb, new_lsb; + WORD32 l; + WORD32 err = 0; + WORD32 num_time_slots = ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; + WORD32 upsample_ratio_idx = ptr_header_data->sbr_ratio_idx; + WORD32 op_delay = 6 + SBR_HF_ADJ_OFFSET; + WORD32 hbe_flag = ptr_header_data->hbe_flag; + WORD32 usac_flag = ptr_header_data->usac_flag; + + if (ptr_header_data->is_usf_4) { + op_delay = op_delay + 6; + } + + ixheaacd_reset_sbrenvelope_calc(&ptr_sbr_dec->str_sbr_calc_env); + + new_lsb = ptr_header_data->pstr_freq_band_data->sub_band_start; + ptr_sbr_dec->str_synthesis_qmf_bank.lsb = new_lsb; + ptr_sbr_dec->str_synthesis_qmf_bank.usb = + ptr_header_data->pstr_freq_band_data->sub_band_end; + + old_lsb = ptr_sbr_dec->str_synthesis_qmf_bank.lsb; + ptr_sbr_dec->str_codec_qmf_bank.lsb = 0; + ptr_sbr_dec->str_codec_qmf_bank.usb = old_lsb; + + { + WORD32 *plpc_filt_states_real = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_real[0][old_lsb]; + WORD32 *plpc_filt_states_real_1 = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_real[1][old_lsb]; + + WORD32 *plpc_filt_states_imag = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_imag[0][old_lsb]; + WORD32 *plpc_filt_states_imag_1 = + &ptr_sbr_dec->str_hf_generator.lpc_filt_states_imag[1][old_lsb]; + + for (l = new_lsb - old_lsb - 1; l >= 0; l--) { + *plpc_filt_states_real++ = *plpc_filt_states_real_1++ = 0L; + + if (!low_pow_flag) { + *plpc_filt_states_imag++ = *plpc_filt_states_imag_1++ = 0L; + } + } + } + + if (usac_flag) { + WORD32 start_band; + WORD32 stop_band; + WORD32 start_slot = SBR_HF_ADJ_OFFSET; + WORD32 k; + + start_band = ptr_header_data->pstr_freq_band_data->qmf_sb_prev; + stop_band = ptr_header_data->pstr_freq_band_data->sub_band_start; + if (!hbe_flag) { + for (l = 0; l < SBR_HF_ADJ_OFFSET; l++) { + for (k = start_band; k < stop_band; k++) { + ptr_sbr_dec->qmf_buf_real[l][k] = 0.0; + ptr_sbr_dec->qmf_buf_imag[l][k] = 0.0; + } + } + for (l = start_slot; l < op_delay; l++) { + for (k = start_band; k < stop_band; k++) { + ptr_sbr_dec->qmf_buf_real[l][k] = 0.0; + ptr_sbr_dec->qmf_buf_imag[l][k] = 0.0; + } + } + } + if (hbe_flag && ptr_sbr_dec->p_hbe_txposer != NULL) { + WORD32 k, i; + ixheaacd_qmf_hbe_data_reinit( + ptr_sbr_dec->p_hbe_txposer, + ptr_header_data->pstr_freq_band_data->freq_band_table, + ptr_header_data->pstr_freq_band_data->num_sf_bands, + ptr_header_data->is_usf_4); + + for (k = 0; k < 2; k++) { + if (!((upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) && (k == 0))) { + WORD32 xpos_delay = num_time_slots * k; + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + xpos_delay = num_time_slots * k - 32; + } + + for (i = 0; i < 8; i++) { + memmove(ptr_sbr_dec->ph_vocod_qmf_real[i], + ptr_sbr_dec->ph_vocod_qmf_real[num_time_slots + i], + 64 * sizeof(FLOAT32)); + memmove(ptr_sbr_dec->ph_vocod_qmf_imag[i], + ptr_sbr_dec->ph_vocod_qmf_imag[num_time_slots + i], + 64 * sizeof(FLOAT32)); + } + + ixheaacd_qmf_hbe_apply( + ptr_sbr_dec->p_hbe_txposer, + ptr_sbr_dec->qmf_buf_real + op_delay + xpos_delay, + ptr_sbr_dec->qmf_buf_imag + op_delay + xpos_delay, num_time_slots, + ptr_sbr_dec->ph_vocod_qmf_real + op_delay, + ptr_sbr_dec->ph_vocod_qmf_imag + op_delay, pitch_in_bins); + + if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { + ixheaacd_hbe_repl_spec(&ptr_sbr_dec->p_hbe_txposer->x_over_qmf[0], + ptr_sbr_dec->ph_vocod_qmf_real + op_delay, + ptr_sbr_dec->ph_vocod_qmf_imag + op_delay, + num_time_slots, + ptr_sbr_dec->p_hbe_txposer->max_stretch); + } + } + } + } + } + + if (!usac_flag) { + err |= ixheaacd_reset_hf_generator(&ptr_sbr_dec->str_hf_generator, + ptr_header_data, audio_object_type); + + err |= ixheaacd_derive_lim_band_tbl( + ptr_header_data, + ptr_sbr_dec->str_hf_generator.pstr_settings->str_patch_param, + ptr_sbr_dec->str_hf_generator.pstr_settings->num_patches, + pstr_common_tables); + } + + return err; +} + +WORD32 ixheaacd_prepare_upsamp(ia_sbr_header_data_struct **ptr_header_data, + ia_sbr_channel_struct *pstr_sbr_channel[2], + WORD32 num_channels) { + WORD16 err = 0; + WORD32 lr; + ia_sbr_qmf_filter_bank_struct *sbr_qmf_bank; + + for (lr = 0; lr < num_channels; lr++) { + ptr_header_data[lr]->pstr_freq_band_data->sub_band_start = + NO_ANALYSIS_CHANNELS; + ptr_header_data[lr]->pstr_freq_band_data->sub_band_end = + NO_SYNTHESIS_CHANNELS; + + sbr_qmf_bank = &pstr_sbr_channel[lr]->str_sbr_dec.str_synthesis_qmf_bank; + sbr_qmf_bank->lsb = NO_ANALYSIS_CHANNELS; + sbr_qmf_bank->usb = NO_SYNTHESIS_CHANNELS; + + sbr_qmf_bank = &pstr_sbr_channel[lr]->str_sbr_dec.str_codec_qmf_bank; + sbr_qmf_bank->lsb = 0; + sbr_qmf_bank->usb = NO_ANALYSIS_CHANNELS; + ptr_header_data[lr]->sync_state = UPSAMPLING; + } + return err; +} + +WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, + ia_aac_dec_sbr_bitstream_struct *p_sbr_bit_stream, + WORD16 *core_sample_buf, WORD16 *codec_num_channels, + FLAG frame_status, FLAG down_samp_flag, + FLAG down_mix_flag, + ia_sbr_scr_struct *sbr_scratch_struct, + WORD32 ps_enable, WORD32 ch_fac, WORD32 slot_element, + ia_bit_buf_struct *it_bit_buff, + ia_drc_dec_struct *pstr_drc_dec, WORD eld_sbr_flag, + WORD32 audio_object_type) { + WORD32 k; + FLAG prev_ps_flag = 0; + FLAG ps_flag = 0; + FLAG stereo = 0; + FLAG low_pow_flag = 0; + FLAG header_flag = 1; + FLAG dual_mono = 0; + WORD32 err = 0; + WORD32 num_channels = *codec_num_channels; + FLAG prev_stereo; + WORD32 ele_channels = 0; + WORD32 num_elements = p_sbr_bit_stream->no_elements; + WORD32 usac_flag = self->aot_usac_flag; + + ia_sbr_channel_struct *pstr_sbr_channel[2]; + ia_sbr_header_data_struct *ptr_header_data[MAXNRSBRCHANNELS]; + + WORD32 initial_sync_state; + + ia_sbr_header_data_struct *ptr_sbr_dflt_header = + (ia_sbr_header_data_struct *)(&self->str_sbr_dflt_header); + + ia_sbr_frame_info_data_struct *ptr_frame_data[2]; + + for (k = 0; k < 2; k++) { + ptr_frame_data[k] = (ia_sbr_frame_info_data_struct *)self->frame_buffer[k]; + + pstr_sbr_channel[k] = self->pstr_sbr_channel[k]; + + ptr_header_data[k] = self->pstr_sbr_header[k]; + + if (audio_object_type == AOT_ER_AAC_ELD) { + ptr_frame_data[k]->eld_sbr_flag = eld_sbr_flag; + ptr_frame_data[k]->num_time_slots = ptr_header_data[0]->num_time_slots; + } + + ptr_frame_data[k]->usac_independency_flag = self->usac_independency_flag; + ptr_frame_data[k]->mps_sbr_flag = (self->stereo_config_idx == 3) ? 1 : 0; + ptr_frame_data[k]->stereo_config_idx = self->stereo_config_idx; + ptr_frame_data[k]->inter_tes_flag = self->inter_tes_flag; + ptr_frame_data[k]->sbr_mode = self->sbr_mode; + + if (!usac_flag) { + ptr_frame_data[k]->usac_independency_flag = 0; + ptr_frame_data[k]->mps_sbr_flag = 0; + ptr_frame_data[k]->stereo_config_idx = -1; + ptr_frame_data[k]->inter_tes_flag = 0; + ptr_frame_data[k]->sbr_mode = ORIG_SBR; + } + } + + for (k = 0; k < *codec_num_channels; k++) { + ptr_header_data[k]->usac_flag = self->aot_usac_flag; + + ptr_header_data[k]->usac_independency_flag = self->usac_independency_flag; + ptr_header_data[k]->hbe_flag = self->hbe_flag; + ptr_header_data[k]->pvc_flag = self->pvc_flag; + + if (!usac_flag) { + ptr_header_data[k]->usac_independency_flag = 0; + ptr_header_data[k]->hbe_flag = 0; + ptr_header_data[k]->pvc_flag = 0; + } + } + + initial_sync_state = ptr_header_data[0]->sync_state; + + low_pow_flag = !usac_flag; + self->pstr_sbr_tables->sbr_rand_ph = + self->pstr_sbr_tables->env_calc_tables_ptr->sbr_rand_ph; + + if (ps_enable) { + if (num_channels == 1) { + low_pow_flag = 0; + } + } + + if (audio_object_type == AOT_ER_AAC_ELD) { + low_pow_flag = 0; + } + + prev_stereo = (ptr_header_data[0]->channel_mode == SBR_STEREO); + + if (ps_enable) prev_ps_flag = (ptr_header_data[0]->channel_mode == PS_STEREO); + + ptr_header_data[0]->err_flag_prev = ptr_header_data[0]->err_flag; + + if (p_sbr_bit_stream->no_elements == 0) { + frame_status = 0; + ptr_header_data[0]->sync_state = UPSAMPLING; + if (num_channels == 2) ptr_header_data[1]->sync_state = UPSAMPLING; + } + + if ((usac_flag)) { + if ((p_sbr_bit_stream->no_elements) && + (p_sbr_bit_stream->str_sbr_ele->size_payload > 0)) { + num_elements = p_sbr_bit_stream->no_elements; + } else { + num_elements = 0; + } + } + + for (k = 0; k < num_elements; k++) { + struct ia_bit_buf_struct local_bit_buf; + ia_sbr_element_stream_struct *ptr_bit_str_ele = + &p_sbr_bit_stream->str_sbr_ele[k]; + ele_channels = + (p_sbr_bit_stream->str_sbr_ele[0].sbr_ele_id == SBR_ID_CPE) ? 2 : 1; + + switch (ptr_bit_str_ele->sbr_ele_id) { + case SBR_ID_SCE: + case SBR_ID_CCE: + if (num_channels == 2) { + dual_mono = 1; + } + stereo = 0; + break; + case SBR_ID_CPE: + stereo = 1; + ptr_header_data[1] = ptr_header_data[0]; + + self->pstr_sbr_header[1] = self->pstr_sbr_header[0]; + break; + default: + frame_status = 0; + } + + if (frame_status) { + if (!usac_flag) { + ixheaacd_create_init_bit_buf(&local_bit_buf, + (UWORD8 *)ptr_bit_str_ele->ptr_sbr_data, + ptr_bit_str_ele->size_payload); + + it_bit_buff = &local_bit_buf; + if (audio_object_type == AOT_ER_AAC_ELD) { + if (eld_sbr_flag != 1) { + ixheaacd_read_bits_buf(&local_bit_buf, LEN_NIBBLE); + } + } else { + ixheaacd_read_bits_buf(&local_bit_buf, LEN_NIBBLE); + } + } + if (ptr_bit_str_ele->extension_type == SBR_EXTENSION_CRC) { + WORD32 crc_bits = 0; + WORD32 crc_check_flag = 0; + crc_check_flag = 1; + crc_bits = (((ptr_bit_str_ele->size_payload - 1) << 3) + + (4 - SBR_CYC_REDCY_CHK_BITS)); + + if (crc_bits < 0) { + crc_check_flag = 0; + frame_status = 0; + } + if (crc_check_flag) + frame_status = ixheaacd_sbr_crccheck(it_bit_buff, crc_bits); + } + + if (!usac_flag) header_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (audio_object_type != AOT_ER_AAC_ELD) { + if (header_flag) { + header_flag = ixheaacd_sbr_read_header_data( + ptr_header_data[k], it_bit_buff, stereo, ptr_sbr_dflt_header); + if (usac_flag) { + if ((self->ptr_pvc_data_str->prev_pvc_mode == 0) && + (ptr_header_data[k]->pvc_mode != 0)) { + self->ptr_pvc_data_str->prev_pvc_id = 0; + } + self->ptr_pvc_data_str->prev_pvc_mode = + ptr_header_data[k]->pvc_mode; + if (ptr_header_data[k]->pvc_mode == 0) { + ptr_frame_data[k]->sbr_mode = ORIG_SBR; + } else { + ptr_frame_data[k]->sbr_mode = PVC_SBR; + } + } + if (header_flag == SBR_RESET) { + err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data[k], + self->pstr_sbr_tables, + self->pstr_common_tables); + if (!err) { + WORD32 lr; + WORD32 lr1 = ps_enable ? 2 : num_channels; + for (lr = 0; lr < lr1; lr++) { + ptr_frame_data[lr]->reset_flag = 1; + + err |= ixheaacd_sbr_dec_reset( + &(pstr_sbr_channel[lr]->str_sbr_dec), ptr_header_data[k], + low_pow_flag, self->pstr_common_tables, + ptr_frame_data[k]->pitch_in_bins, audio_object_type); + } + } + + if (err == 0) { + ptr_header_data[k]->sync_state = SBR_ACTIVE; + } + } + } + } else { + if (header_flag) { + header_flag = ixheaacd_sbr_read_header_data( + ptr_header_data[k], it_bit_buff, stereo, ptr_sbr_dflt_header); + if (usac_flag) { + if ((self->ptr_pvc_data_str->prev_pvc_mode == 0) && + (ptr_header_data[k]->pvc_mode != 0)) { + self->ptr_pvc_data_str->prev_pvc_id = 0; + } + self->ptr_pvc_data_str->prev_pvc_mode = + ptr_header_data[k]->pvc_mode; + if (ptr_header_data[k]->pvc_mode == 0) { + ptr_frame_data[k]->sbr_mode = ORIG_SBR; + } else { + ptr_frame_data[k]->sbr_mode = PVC_SBR; + } + } + + if (header_flag == SBR_RESET) { + err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data[k], + self->pstr_sbr_tables, + self->pstr_common_tables); + } + } + + { + WORD32 lr; + WORD32 lr1 = ps_enable ? 2 : num_channels; + for (lr = 0; lr < lr1; lr++) { + ptr_frame_data[lr]->reset_flag = 1; + if (ptr_header_data[k]->status) { + err |= ixheaacd_sbr_dec_reset( + &(pstr_sbr_channel[lr]->str_sbr_dec), ptr_header_data[k], + low_pow_flag, self->pstr_common_tables, + ptr_frame_data[k]->pitch_in_bins, audio_object_type); + } + } + ptr_header_data[k]->status = 0; + } + + if (err == 0) { + ptr_header_data[k]->sync_state = SBR_ACTIVE; + } + } + } + + 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 (frame_status && (ptr_header_data[k]->sync_state == SBR_ACTIVE)) { + if (stereo) { + frame_status = ixheaacd_sbr_read_cpe(ptr_header_data[0], ptr_frame_data, + it_bit_buff, self->pstr_sbr_tables, + audio_object_type); + } else { + if (ps_enable) { + if (down_mix_flag) { + self->pstr_ps_stereo_dec->force_mono = 1; + } else { + self->pstr_ps_stereo_dec->force_mono = 0; + } + } else { + self->pstr_ps_stereo_dec = 0; + } + if (ptr_frame_data[k]->sbr_mode == ORIG_SBR) { + frame_status = ixheaacd_sbr_read_sce( + ptr_header_data[k], ptr_frame_data[k], self->pstr_ps_stereo_dec, + it_bit_buff, self->pstr_sbr_tables, audio_object_type); + } else if (ptr_frame_data[k]->sbr_mode == PVC_SBR) { + frame_status = ixheaacd_sbr_read_pvc_sce( + ptr_frame_data[k], it_bit_buff, 0, self->ptr_pvc_data_str, + self->pstr_sbr_tables, ptr_header_data[k]); + } + } + if (audio_object_type != AOT_ER_AAC_ELD) { + WORD32 total_bits_read; + total_bits_read = ixheaacd_no_bits_read(it_bit_buff); + if (total_bits_read > (ptr_bit_str_ele->size_payload << 3) || + total_bits_read < ((ptr_bit_str_ele->size_payload << 3) - 8)) { + frame_status = 0; + } + } + } + } + + if (!usac_flag) { + if (!frame_status || (ptr_header_data[0]->sync_state != SBR_ACTIVE) || + ptr_header_data[0]->err_flag) { + ptr_header_data[0]->err_flag = 1; + stereo = (num_channels == 2) ? 1 : 0; + if (ptr_header_data[0]->channel_mode == 0) { + ptr_header_data[0]->channel_mode = stereo ? SBR_STEREO : SBR_MONO; + } + } + + if (!(stereo || dual_mono)) { + ptr_frame_data[0]->coupling_mode = COUPLING_OFF; + ptr_frame_data[1]->coupling_mode = COUPLING_OFF; + } + + if (ptr_header_data[0]->sync_state == SBR_NOT_INITIALIZED) { + WORD32 lr1 = ps_enable ? 2 : num_channels; + ixheaacd_prepare_upsamp(ptr_header_data, pstr_sbr_channel, lr1); + } + } + + if (ptr_header_data[0]->sync_state == SBR_ACTIVE) { + if (ptr_frame_data[0]->sbr_mode == PVC_SBR) { + ixheaacd_dec_sbrdata_for_pvc(ptr_header_data[0], ptr_frame_data[0], + pstr_sbr_channel[0]->pstr_prev_frame_data); + } else if (ptr_frame_data[0]->sbr_mode == ORIG_SBR) { + ixheaacd_dec_sbrdata( + ptr_header_data[0], ptr_header_data[1], ptr_frame_data[0], + pstr_sbr_channel[0]->pstr_prev_frame_data, + (stereo || dual_mono) ? ptr_frame_data[1] : NULL, + (stereo || dual_mono) ? pstr_sbr_channel[1]->pstr_prev_frame_data + : NULL, + self->pstr_common_tables); + } + + if (ptr_header_data[0]->channel_mode == PS_STEREO && + (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD)) { + ixheaacd_decode_ps_data(self->pstr_ps_stereo_dec); + ps_flag = 1; + self->ps_present = ps_flag; + } + + ptr_frame_data[0]->max_qmf_subband_aac = + ptr_header_data[0]->pstr_freq_band_data->sub_band_start; + if (stereo) { + ptr_frame_data[1]->max_qmf_subband_aac = + ptr_header_data[1]->pstr_freq_band_data->sub_band_start; + } + } + if (audio_object_type != AOT_ER_AAC_ELD) { + if ((initial_sync_state == SBR_NOT_INITIALIZED) && + ptr_header_data[0]->err_flag) { + ptr_header_data[0]->sync_state = SBR_NOT_INITIALIZED; + } + } else { + ptr_header_data[0]->sync_state = SBR_ACTIVE; + } + + if ((num_channels == 2) && !(stereo || dual_mono)) { + ixheaacd_downmix_to_monosbr(&core_sample_buf[slot_element], ch_fac); + } + + if ((!prev_stereo && !prev_ps_flag) && (ps_flag)) { + WORD32 copy_size; + if (down_samp_flag) + copy_size = QMF_FILTER_STATE_SYN_SIZE_DOWN_SAMPLED; + else + copy_size = QMF_FILTER_STATE_SYN_SIZE; + + memcpy( + pstr_sbr_channel[1]->str_sbr_dec.str_synthesis_qmf_bank.filter_states, + pstr_sbr_channel[0]->str_sbr_dec.str_synthesis_qmf_bank.filter_states, + copy_size * sizeof(WORD16)); + + pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact.st_syn_scale = + pstr_sbr_channel[0]->str_sbr_dec.str_sbr_scale_fact.st_syn_scale; + } + + if ((!prev_stereo && stereo && (num_channels == 2)) && + (audio_object_type != AOT_ER_AAC_ELD)) { + WORD32 copy_size; + if (down_samp_flag) + copy_size = QMF_FILTER_STATE_SYN_SIZE_DOWN_SAMPLED; + else + copy_size = QMF_FILTER_STATE_SYN_SIZE; + + memcpy( + pstr_sbr_channel[1]->str_sbr_dec.str_synthesis_qmf_bank.filter_states, + pstr_sbr_channel[0]->str_sbr_dec.str_synthesis_qmf_bank.filter_states, + copy_size * sizeof(WORD16)); + + pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact.st_syn_scale = + pstr_sbr_channel[0]->str_sbr_dec.str_sbr_scale_fact.st_syn_scale; + + memcpy( + pstr_sbr_channel[1]->str_sbr_dec.str_codec_qmf_bank.anal_filter_states, + pstr_sbr_channel[0]->str_sbr_dec.str_codec_qmf_bank.anal_filter_states, + QMF_FILTER_STATE_ANA_SIZE * sizeof(WORD16)); + + pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact.st_lb_scale = + pstr_sbr_channel[0]->str_sbr_dec.str_sbr_scale_fact.st_lb_scale; + + memcpy(pstr_sbr_channel[1]->str_sbr_dec.ptr_sbr_overlap_buf, + pstr_sbr_channel[0]->str_sbr_dec.ptr_sbr_overlap_buf, + MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32)); + + pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact.ov_lb_scale = + pstr_sbr_channel[0]->str_sbr_dec.str_sbr_scale_fact.ov_lb_scale; + pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact.ov_hb_scale = + pstr_sbr_channel[0]->str_sbr_dec.str_sbr_scale_fact.ov_hb_scale; + } + pstr_sbr_channel[0]->str_sbr_dec.time_sample_buf = self->time_sample_buf[0]; + if (pstr_drc_dec == NULL) { + ixheaacd_sbr_dec( + &pstr_sbr_channel[0]->str_sbr_dec, core_sample_buf + slot_element, + ptr_header_data[0], ptr_frame_data[0], + pstr_sbr_channel[0]->pstr_prev_frame_data, self->pstr_ps_stereo_dec, + &pstr_sbr_channel[1]->str_sbr_dec.str_synthesis_qmf_bank, + &pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact, + (ptr_header_data[0]->sync_state == SBR_ACTIVE), low_pow_flag, + sbr_scratch_struct->ptr_work_buf_core, self->pstr_sbr_tables, + self->pstr_common_tables, ch_fac, self->ptr_pvc_data_str, 0, NULL, + audio_object_type); + } else { + ixheaacd_sbr_dec( + &pstr_sbr_channel[0]->str_sbr_dec, core_sample_buf + slot_element, + ptr_header_data[0], ptr_frame_data[0], + pstr_sbr_channel[0]->pstr_prev_frame_data, self->pstr_ps_stereo_dec, + &pstr_sbr_channel[1]->str_sbr_dec.str_synthesis_qmf_bank, + &pstr_sbr_channel[1]->str_sbr_dec.str_sbr_scale_fact, + (ptr_header_data[0]->sync_state == SBR_ACTIVE), low_pow_flag, + sbr_scratch_struct->ptr_work_buf_core, self->pstr_sbr_tables, + self->pstr_common_tables, ch_fac, self->ptr_pvc_data_str, + pstr_drc_dec->drc_on, + pstr_drc_dec->str_drc_channel_data[0].drc_factors_sbr, + audio_object_type); + } + + if (!down_mix_flag && (stereo || dual_mono) && (num_channels == 2)) { + pstr_sbr_channel[1]->str_sbr_dec.time_sample_buf = self->time_sample_buf[1]; + + if (ele_channels == 1 && usac_flag) { + ixheaacd_esbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, ptr_header_data[1], + ptr_frame_data[1], + (ptr_header_data[1]->sync_state == SBR_ACTIVE), + low_pow_flag, self->pstr_sbr_tables, ch_fac); + } else { + if (pstr_drc_dec == NULL) { + ixheaacd_sbr_dec( + &pstr_sbr_channel[1]->str_sbr_dec, + core_sample_buf + slot_element + 1, ptr_header_data[1], + ptr_frame_data[1], pstr_sbr_channel[1]->pstr_prev_frame_data, NULL, + NULL, NULL, (ptr_header_data[1]->sync_state == SBR_ACTIVE), + low_pow_flag, sbr_scratch_struct->ptr_work_buf_core, + self->pstr_sbr_tables, self->pstr_common_tables, ch_fac, + self->ptr_pvc_data_str, 0, NULL, audio_object_type); + + } else { + ixheaacd_sbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, + core_sample_buf + slot_element + 1, ptr_header_data[1], + ptr_frame_data[1], + pstr_sbr_channel[1]->pstr_prev_frame_data, NULL, NULL, + NULL, (ptr_header_data[1]->sync_state == SBR_ACTIVE), + low_pow_flag, sbr_scratch_struct->ptr_work_buf_core, + self->pstr_sbr_tables, self->pstr_common_tables, + ch_fac, self->ptr_pvc_data_str, pstr_drc_dec->drc_on, + pstr_drc_dec->str_drc_channel_data[1].drc_factors_sbr, + audio_object_type); + } + } + + } else { + if (audio_object_type != AOT_ER_AAC_ELD && + audio_object_type != AOT_ER_AAC_LD) + + { + if (sub_d((WORD16)ptr_header_data[0]->channel_mode, PS_STEREO) == 0) { + num_channels = 2; + } + } + } + *codec_num_channels = num_channels; + self->sbr_mode = ptr_frame_data[0]->sbr_mode; + + if (pstr_drc_dec != NULL) { + WORD32 i, j; + for (i = 0; i < *codec_num_channels; i++) { + for (j = 0; j < 32; j++) { + memcpy(pstr_drc_dec->str_drc_channel_data[i].drc_factors_sbr[j], + pstr_drc_dec->str_drc_channel_data[i].drc_factors_sbr[j + 32], + 64 * sizeof(WORD32)); + } + } + } + + return SBRDEC_OK; +} diff --git a/decoder/ixheaacd_sbrdecoder.h b/decoder/ixheaacd_sbrdecoder.h new file mode 100644 index 0000000..cd0cebd --- /dev/null +++ b/decoder/ixheaacd_sbrdecoder.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBRDECODER_H +#define IXHEAACD_SBRDECODER_H + +#define EXT_DYNAMIC_RANGE 11 + +#define SBR_EXTENSION 13 +#define SBR_EXTENSION_CRC 14 + +#define MAXNRELEMENTS 1 +#define MAXNRSBRCHANNELS 2 +#define MAXSBRBYTES 1024 + +#define SBRDEC_OK 0 + +typedef enum { + SBR_ID_SCE = 0, + SBR_ID_CPE, + SBR_ID_CCE = 2, + SBR_ID_LCS, + SBR_ID_LFE, + SBR_ID_DSE, + SBR_ID_PCE, + SBR_ID_FIL, + SBR_ID_END +} SBR_ELEMENT_ID; + +typedef struct { + WORD32 sbr_ele_id; + WORD32 extension_type; + WORD32 size_payload; + WORD8 *ptr_sbr_data; +} ia_sbr_element_stream_struct; + +typedef struct { + WORD16 no_elements; + ia_sbr_element_stream_struct str_sbr_ele[MAXNRELEMENTS]; +} ia_aac_dec_sbr_bitstream_struct; +typedef enum { UNKNOWN_SBR = 0, ORIG_SBR, PVC_SBR } SBR_TYPE_ID; + +typedef struct ia_sbr_dec_inst_struct *ia_handle_sbr_dec_inst_struct; + +typedef struct { + VOID *ptr_work_buf_core; + VOID *ptr_work_buf; + VOID *extra_scr_1k[2]; +} ia_sbr_scr_struct; + +WORD16 ixheaacd_applysbr( + ia_handle_sbr_dec_inst_struct self, + ia_aac_dec_sbr_bitstream_struct *p_sbr_bit_stream, WORD16 *core_sample_buf, + WORD16 *codec_num_channels, FLAG frame_status, FLAG down_samp_flag, + FLAG down_mix_flag, ia_sbr_scr_struct *sbr_scratch_struct, WORD32 ps_enable, + WORD32 ch_fac, WORD32 slot_element, ia_bit_buf_struct *it_bit_buff, + ia_drc_dec_struct *pstr_drc_dec, WORD eld_sbr_flag, WORD audio_object_type); + +WORD32 ixheaacd_getsize_sbr_persistent(); + +VOID ixheaacd_set_sbr_persistent_buffers(VOID *aac_persistent_mem_v, + WORD32 *persistent_used, + WORD32 channels, WORD32 ps_enable); + +#endif diff --git a/decoder/ixheaacd_sbrdecsettings.h b/decoder/ixheaacd_sbrdecsettings.h new file mode 100644 index 0000000..ab9664e --- /dev/null +++ b/decoder/ixheaacd_sbrdecsettings.h @@ -0,0 +1,85 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBRDECSETTINGS_H +#define IXHEAACD_SBRDECSETTINGS_H + +#define SBR_UPSAMPLE_FAC 2 + +#define SBR_UPSAMPLE_IDX_0_0 0 +#define SBR_UPSAMPLE_IDX_2_1 1 +#define SBR_UPSAMPLE_IDX_8_3 2 +#define SBR_UPSAMPLE_IDX_4_1 3 + +#define MAX_FRAME_SIZE 1024 + +#define QMF_FILTER_STATE_SYN_SIZE 1280 +#define QMF_FILTER_STATE_ANA_SIZE 320 +#define NO_SYNTHESIS_CHANNELS 64 +#define NO_ANALYSIS_CHANNELS (NO_SYNTHESIS_CHANNELS / SBR_UPSAMPLE_FAC) +#define NO_POLY (QMF_FILTER_STATE_ANA_SIZE / (2 * NO_ANALYSIS_CHANNELS)) + +#define NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED (NO_SYNTHESIS_CHANNELS / 2) +#define QMF_FILTER_STATE_SYN_SIZE_DOWN_SAMPLED (QMF_FILTER_STATE_SYN_SIZE / 2) +#define NO_SYN_ANA_CHANNELS (NO_SYNTHESIS_CHANNELS - NO_ANALYSIS_CHANNELS) + +#define CALC_STOP_BAND + +#define MAX_NOISE_ENVELOPES 2 +#define MAX_NOISE_COEFFS 5 +#define MAX_NUM_NOISE_VALUES (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS) +#define MAX_NUM_LIMITERS 12 + +#define MAX_ENVELOPES_SBR 5 +#define MAX_ENVELOPES 8 +#define MAX_FREQ_COEFFS 56 + +#define MAX_FREQ_COEFFS_FS44100 35 +#define MAX_FREQ_COEFFS_FS48000 32 +#define MAX_FREQ_COEFFS_SBR 48 + +#define MAX_NUM_ELEMENTS 16 + +#define SBR_TIME_STEP 2 + +#define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS) + +#define MAX_GAIN_EXP 34 + +#define LPC_ORDER 2 + +#define MAX_INVF_BANDS MAX_NOISE_COEFFS + +#define MAX_COLS (MAX_FRAME_SIZE / NO_ANALYSIS_CHANNELS) +#define MAX_OV_COLS 6 +#define MAX_ENV_COLS (MAX_COLS + MAX_OV_COLS) + +#define SBR_FREQ_SCALE_DEFAULT 2 +#define SBR_ALTER_SCALE_DEFAULT 1 +#define SBR_NOISE_BANDS_DEFAULT 2 + +#define SBR_LIMITER_BANDS_DEFAULT 2 +#define SBR_LIMITER_GAINS_DEFAULT 2 +#define SBR_INTERPOL_FREQ_DEFAULT 1 +#define SBR_SMOOTHING_LENGTH_DEFAULT 1 + +#define SBR_TIME_SLOTS (MAX_COLS / SBR_TIME_STEP) +#define SBR_OV_SLOTS (MAX_OV_COLS / SBR_TIME_STEP) + +#endif diff --git a/decoder/ixheaacd_sbrqmftrans.h b/decoder/ixheaacd_sbrqmftrans.h new file mode 100644 index 0000000..6ffe5ed --- /dev/null +++ b/decoder/ixheaacd_sbrqmftrans.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_SBRQMFTRANS_H +#define IXHEAACD_SBRQMFTRANS_H + +VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer, + FLOAT32 qmf_buf_real[][64], + FLOAT32 qmf_buf_imag[][64], WORD32 num_columns, + FLOAT32 pv_qmf_buf_real[][64], + FLOAT32 pv_qmf_buf_imag[][64], + WORD32 pitch_in_bins); + +VOID ixheaacd_qmf_hbe_data_reinit( + ia_esbr_hbe_txposer_struct *ptr_hbe_transposer_str, + WORD16 *ptr_freq_band_tbl[MAX_FREQ_COEFFS + 1], WORD16 *ptr_num_sf_bands, + WORD32 upsamp_4_flag); + +VOID ixheaacd_hbe_post_anal_process(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, + WORD32 pitch_in_bins, + WORD32 sbr_upsamp_4_flg); + +#endif diff --git a/decoder/ixheaacd_spectrum_dec.c b/decoder/ixheaacd_spectrum_dec.c new file mode 100644 index 0000000..72f5421 --- /dev/null +++ b/decoder/ixheaacd_spectrum_dec.c @@ -0,0 +1,447 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include + +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_bit_extract.h" + +#include "ixheaacd_func_def.h" + +#include +#include +#include + +#include "ixheaacd_interface.h" +#include "ixheaacd_info.h" + +#include "ixheaacd_defines.h" + +#define MAX_NR_OF_SWB 120 + +VOID ixheaacd_calc_grp_offset(ia_sfb_info_struct *ptr_sfb_info, pUWORD8 group) { + WORD32 group_offset; + WORD32 group_idx; + WORD32 ixheaacd_drc_offset; + WORD16 *group_offset_p; + WORD32 sfb, len; + + group_offset = 0; + group_idx = 0; + do { + ptr_sfb_info->group_len[group_idx] = group[group_idx] - group_offset; + group_offset = group[group_idx]; + group_idx++; + } while (group_offset < 8); + ptr_sfb_info->num_groups = group_idx; + group_offset_p = ptr_sfb_info->sfb_idx_tbl; + ixheaacd_drc_offset = 0; + for (group_idx = 0; group_idx < ptr_sfb_info->num_groups; group_idx++) { + len = ptr_sfb_info->group_len[group_idx]; + for (sfb = 0; sfb < ptr_sfb_info->sfb_per_sbk; sfb++) { + ixheaacd_drc_offset += ptr_sfb_info->sfb_width[sfb] * len; + *group_offset_p++ = ixheaacd_drc_offset; + } + } +} + +VOID ixheaacd_read_tns_u(ia_sfb_info_struct *ptr_sfb_info, + ia_tns_frame_info_struct *pstr_tns_frame_info, + ia_bit_buf_struct *it_bit_buff) { + WORD32 j, k, top, coef_res, resolution, compress; + WORD32 short_flag, i; + 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}; + + WORD16 n_filt_bits; + WORD16 start_band_bits; + WORD16 order_bits; + + short_flag = (!ptr_sfb_info->islong); + pstr_tns_frame_info->n_subblocks = ptr_sfb_info->max_win_len; + + if (!short_flag) { + n_filt_bits = 2; + start_band_bits = 6; + order_bits = 4; + } else { + n_filt_bits = 1; + start_band_bits = 4; + order_bits = 3; + } + + for (i = 0; i < pstr_tns_frame_info->n_subblocks; i++) { + pstr_tns_info = &pstr_tns_frame_info->str_tns_info[i]; + if (!(pstr_tns_info->n_filt = + ixheaacd_read_bits_buf(it_bit_buff, n_filt_bits))) + continue; + + pstr_tns_info->coef_res = coef_res = + ixheaacd_read_bits_buf(it_bit_buff, 1) + 3; + top = ptr_sfb_info->sfb_per_sbk; + tns_filt = &pstr_tns_info->str_filter[0]; + + for (j = pstr_tns_info->n_filt; j > 0; j--) { + tns_filt->stop_band = top; + top = tns_filt->start_band = + top - ixheaacd_read_bits_buf(it_bit_buff, start_band_bits); + tns_filt->order = ixheaacd_read_bits_buf(it_bit_buff, order_bits); + + if (tns_filt->order) { + tns_filt->direction = ixheaacd_read_bits_buf(it_bit_buff, 1); + compress = ixheaacd_read_bits_buf(it_bit_buff, 1); + resolution = coef_res - compress; + s_mask = sgn_mask[resolution - 2]; + n_mask = neg_mask[resolution - 2]; + sp = tns_filt->coef; + + for (k = tns_filt->order; k > 0; k--) { + tmp = ixheaacd_read_bits_buf(it_bit_buff, resolution); + *sp++ = (tmp & s_mask) ? (tmp | n_mask) : tmp; + } + } + + tns_filt++; + } + } +} +VOID ixheaacd_scale_factor_data(ia_sfb_info_struct *info, WORD32 tot_sfb, + WORD32 max_sfb, WORD32 sfb_per_sbk, + WORD8 *ptr_code_book) { + WORD band; + WORD sect_cb; + WORD sect_len; + WORD8 *ptr_codebook = ptr_code_book; + WORD8 *temp_ptr_codebook = ptr_codebook; + WORD32 win_group = info->max_win_len; + + memset(ptr_codebook, 0, 128); + + band = 0; + while (band < tot_sfb || win_group != 0) { + sect_cb = 11; + sect_len = max_sfb; + + band = band + sfb_per_sbk; + + sect_len = sect_len - 1; + for (; sect_len >= 0; sect_len--) { + *temp_ptr_codebook++ = sect_cb; + } + ptr_codebook += 16; + temp_ptr_codebook = ptr_codebook; + win_group--; + } + return; +} + +WORD32 +ixheaacd_win_seq_select(WORD32 window_sequence_curr, + WORD32 window_sequence_last) { + WORD32 window_sequence; + + switch (window_sequence_curr) { + case ONLY_LONG_SEQUENCE: + window_sequence = ONLY_LONG_SEQUENCE; + break; + + case LONG_START_SEQUENCE: + if ((window_sequence_last == LONG_START_SEQUENCE) || + (window_sequence_last == EIGHT_SHORT_SEQUENCE) || + (window_sequence_last == STOP_START_SEQUENCE)) { + window_sequence = STOP_START_SEQUENCE; + } else { + window_sequence = LONG_START_SEQUENCE; + } + break; + + case LONG_STOP_SEQUENCE: + window_sequence = LONG_STOP_SEQUENCE; + break; + + case EIGHT_SHORT_SEQUENCE: + window_sequence = EIGHT_SHORT_SEQUENCE; + break; + + default: + return -1; + } + + return window_sequence; +} + +VOID ixheaacd_tns_reset(ia_sfb_info_struct *ptr_sfb_info, + ia_tns_frame_info_struct *pstr_tns_frame_info) { + WORD32 s; + + pstr_tns_frame_info->n_subblocks = ptr_sfb_info->max_win_len; + for (s = 0; s < pstr_tns_frame_info->n_subblocks; s++) + pstr_tns_frame_info->str_tns_info[s].n_filt = 0; +} + +VOID ixheaacd_section_data(ia_usac_data_struct *usac_data, + ia_bit_buf_struct *g_bs, ia_sfb_info_struct *info, + WORD16 global_gain, pWORD16 factors, pUWORD8 groups, + WORD8 *ptr_code_book) { + WORD32 band; + WORD16 position = 0; + WORD32 group; + WORD16 factor = global_gain; + WORD8 *temp_codebook_ptr; + WORD16 *ptr_scale_fac, *temp_ptr_scale_fac; + WORD16 norm_val; + WORD32 window_grps, trans_sfb; + WORD16 index, length; + const UWORD16 *hscf = usac_data->huffman_code_book_scl; + const UWORD32 *idx_tab = usac_data->huffman_code_book_scl_index; + + WORD32 start_bit_pos = g_bs->bit_pos; + UWORD8 *start_read_pos = g_bs->ptr_read_next; + UWORD8 *ptr_read_next = g_bs->ptr_read_next; + WORD32 bit_pos = 7 - g_bs->bit_pos; + WORD32 is_1_group = 1; + + WORD32 bb = 0, i; + WORD32 read_word = ixheaacd_aac_showbits_32(ptr_read_next); + ptr_read_next = g_bs->ptr_read_next + 4; + + trans_sfb = info->sfb_per_sbk; + temp_ptr_scale_fac = factors; + window_grps = info->max_win_len; + memset(factors, 0, MAXBANDS); + band = trans_sfb - 1; + + for (group = 0; group < window_grps;) { + temp_codebook_ptr = &ptr_code_book[group * 16]; + ptr_scale_fac = temp_ptr_scale_fac; + group = *groups++; + for (band = trans_sfb - 1; band >= 0; band--) { + WORD32 cb_num = *temp_codebook_ptr++; + + if ((band == trans_sfb - 1) && (is_1_group == 1)) { + *temp_ptr_scale_fac = factor; + temp_ptr_scale_fac++; + continue; + } + + if (cb_num == ZERO_HCB) + *temp_ptr_scale_fac++ = 0; + else { + WORD32 pns_band; + WORD16 curr_energy = 0; + + UWORD32 read_word1; + + read_word1 = read_word << bit_pos; + + ixheaacd_huffman_decode(read_word1, &index, &length, hscf, idx_tab); + + bit_pos += length; + ixheaacd_aac_read_2bytes(&ptr_read_next, &bit_pos, &read_word); + norm_val = index - 60; + + if (cb_num > NOISE_HCB) { + position = position + norm_val; + *temp_ptr_scale_fac++ = -position; + + } else if (cb_num < NOISE_HCB) { + factor = factor + norm_val; + *temp_ptr_scale_fac++ = factor; + + } else { + curr_energy += norm_val; + + pns_band = (group << 4) + trans_sfb - band - 1; + + temp_ptr_scale_fac[pns_band] = curr_energy; + + temp_ptr_scale_fac++; + } + } + } + is_1_group = 0; + + if (!(info->islong)) { + for (bb++; bb < group; bb++) { + for (i = 0; i < trans_sfb; i++) { + ptr_scale_fac[i + trans_sfb] = ptr_scale_fac[i]; + } + temp_ptr_scale_fac += trans_sfb; + ptr_scale_fac += trans_sfb; + } + } + } + + g_bs->ptr_read_next = ptr_read_next - 4; + + g_bs->bit_pos = 7 - bit_pos; + { + WORD32 bits_consumed; + bits_consumed = ((g_bs->ptr_read_next - start_read_pos) << 3) + + (start_bit_pos - g_bs->bit_pos); + g_bs->cnt_bits -= bits_consumed; + } +} + +WORD32 ixheaacd_fd_channel_stream( + ia_usac_data_struct *usac_data, + ia_usac_tmp_core_coder_struct *pstr_core_coder, UWORD8 *max_sfb, + WORD32 window_sequence_last, WORD32 chn, WORD32 noise_filling, WORD32 ch, + ia_bit_buf_struct *it_bit_buff + + ) + +{ + WORD32 i; + + WORD32 tot_sfb; + WORD32 noise_level = 0; + WORD32 arith_reset_flag; + + WORD32 arth_size; + WORD16 global_gain; + WORD32 max_spec_coefficients; + WORD32 err_code = 0; + WORD32 noise_offset; + + WORD32 *fac_data; + ia_sfb_info_struct *info; + + WORD8 *ptr_code_book = (WORD8 *)&usac_data->scratch_buffer; + + global_gain = ixheaacd_read_bits_buf(it_bit_buff, 8); + + if (noise_filling) { + noise_level = ixheaacd_read_bits_buf(it_bit_buff, 3); + noise_offset = ixheaacd_read_bits_buf(it_bit_buff, 5); + + } else { + noise_level = 0; + noise_offset = 0; + } + + if (!pstr_core_coder->common_window) { + err_code = ixheaacd_ics_info(usac_data, chn, max_sfb, it_bit_buff, + window_sequence_last); + + if (err_code == -1) return err_code; + } + info = usac_data->pstr_sfb_info[chn]; + + if (!pstr_core_coder->common_tw && usac_data->tw_mdct[0] == 1) { + usac_data->tw_data_present[chn] = ixheaacd_read_bits_buf(it_bit_buff, 1); + if (usac_data->tw_data_present[chn]) { + WORD32 i; + for (i = 0; i < NUM_TW_NODES; i++) { + usac_data->tw_ratio[chn][i] = ixheaacd_read_bits_buf(it_bit_buff, 3); + } + } + } + + if (*max_sfb == 0) { + tot_sfb = 0; + } else { + i = 0; + tot_sfb = info->sfb_per_sbk; + + while (usac_data->group_dis[chn][i++] < info->max_win_len) { + tot_sfb += info->sfb_per_sbk; + } + } + + ixheaacd_scale_factor_data(info, tot_sfb, *max_sfb, info->sfb_per_sbk, + ptr_code_book); + + ixheaacd_section_data(usac_data, it_bit_buff, info, global_gain, + usac_data->factors[chn], usac_data->group_dis[chn], + ptr_code_book); + + if (pstr_core_coder->tns_data_present[ch] == 0) + ixheaacd_tns_reset(info, usac_data->pstr_tns[chn]); + + if (pstr_core_coder->tns_data_present[ch] == 1) + ixheaacd_read_tns_u(info, usac_data->pstr_tns[chn], it_bit_buff); + + if (*max_sfb > 0) { + max_spec_coefficients = + info->sfb_idx_tbl[*max_sfb - 1] / info->group_len[0]; + } else { + max_spec_coefficients = 0; + } + + if (usac_data->usac_independency_flg) + arith_reset_flag = 1; + else + arith_reset_flag = ixheaacd_read_bits_buf(it_bit_buff, 1); + + switch (usac_data->window_sequence[chn]) { + case EIGHT_SHORT_SEQUENCE: + arth_size = usac_data->ccfl / 8; + break; + default: + arth_size = usac_data->ccfl; + break; + } + + err_code = ixheaacd_ac_spectral_data( + usac_data, max_spec_coefficients, noise_level, noise_offset, arth_size, + it_bit_buff, *max_sfb, arith_reset_flag, noise_filling, chn); + + usac_data->fac_data_present[chn] = ixheaacd_read_bits_buf(it_bit_buff, 1); + + if (usac_data->fac_data_present[chn]) { + WORD32 fac_len; + if ((usac_data->window_sequence[chn]) == EIGHT_SHORT_SEQUENCE) { + fac_len = (usac_data->ccfl) / 16; + } else { + fac_len = (usac_data->ccfl) / 8; + } + + fac_data = usac_data->fac_data[chn]; + fac_data[0] = ixheaacd_read_bits_buf(it_bit_buff, 7); + ixheaacd_fac_decoding(fac_len, 0, &fac_data[1], it_bit_buff); + } + + return 0; +} diff --git a/decoder/ixheaacd_stereo.c b/decoder/ixheaacd_stereo.c new file mode 100644 index 0000000..ac0f313 --- /dev/null +++ b/decoder/ixheaacd_stereo.c @@ -0,0 +1,204 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" + +#include +#include "ixheaacd_intrinsics.h" + +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_pns.h" +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_channel.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_audioobjtypes.h" + +#include "ixheaacd_stereo.h" + +VOID ixheaacd_ms_stereo_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[2], + ia_aac_dec_tables_struct *ptr_aac_tables) + +{ + WORD32 win_grp, grp_len, k; + WORD32 *l_spec = ptr_aac_dec_channel_info[LEFT]->ptr_spec_coeff; + WORD32 *r_spec = ptr_aac_dec_channel_info[RIGHT]->ptr_spec_coeff; + WORD8 *ptr_group_len = + ptr_aac_dec_channel_info[LEFT]->str_ics_info.window_group_length; + const WORD8 *ptr_sfb_width = + ptr_aac_tables + ->str_aac_sfb_info[ptr_aac_dec_channel_info[RIGHT] + ->str_ics_info.window_sequence] + .sfb_width; + + UWORD8 *ptr_ms_used = + &ptr_aac_dec_channel_info[LEFT]->pstr_stereo_info->ms_used[0][0]; + + for (win_grp = 0; + win_grp < ptr_aac_dec_channel_info[LEFT]->str_ics_info.num_window_groups; + win_grp++) { + for (grp_len = 0; grp_len < ptr_group_len[win_grp]; grp_len++) { + WORD32 sfb; + WORD32 ixheaacd_drc_offset = 0; + + for (sfb = 0; sfb < ptr_aac_dec_channel_info[LEFT]->str_ics_info.max_sfb; + sfb++) { + ixheaacd_drc_offset += ptr_sfb_width[sfb]; + + if (*ptr_ms_used++) { + for (k = 0; k < ptr_sfb_width[sfb]; k = k + 2) { + WORD32 left_coef = *l_spec; + WORD32 right_coef = *r_spec; + WORD32 left_coef2 = *(l_spec + 1); + WORD32 right_coef2 = *(r_spec + 1); + + *l_spec++ = ixheaacd_add32_sat(left_coef, right_coef); + *r_spec++ = ixheaacd_sub32_sat(left_coef, right_coef); + *l_spec++ = ixheaacd_add32_sat(left_coef2, right_coef2); + *r_spec++ = ixheaacd_sub32_sat(left_coef2, right_coef2); + } + } else { + l_spec += ptr_sfb_width[sfb]; + r_spec += ptr_sfb_width[sfb]; + } + } + ptr_ms_used -= ptr_aac_dec_channel_info[LEFT]->str_ics_info.max_sfb; + l_spec = l_spec + 128 - ixheaacd_drc_offset; + r_spec = r_spec + 128 - ixheaacd_drc_offset; + } + + ptr_ms_used += JOINT_STEREO_MAX_BANDS; + } +} + +static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32l(WORD32 a, WORD32 b) { + WORD32 result; + WORD64 temp_result; + + temp_result = (WORD64)a * (WORD64)b; + + result = (WORD32)(temp_result >> 16); + + return (result); +} + +VOID ixheaacd_intensity_stereo_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[2], + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) { + UWORD8 *ptr_ms_used = + &ptr_aac_dec_channel_info[LEFT]->pstr_stereo_info->ms_used[0][0]; + WORD8 *ptr_code_book = &ptr_aac_dec_channel_info[RIGHT]->ptr_code_book[0]; + WORD16 *ptr_scale_factor = + &ptr_aac_dec_channel_info[RIGHT]->ptr_scale_factor[0]; + WORD32 *r_spec = &ptr_aac_dec_channel_info[RIGHT]->ptr_spec_coeff[0]; + WORD32 *l_spec = &ptr_aac_dec_channel_info[LEFT]->ptr_spec_coeff[0]; + WORD8 *ptr_group_len = + ptr_aac_dec_channel_info[RIGHT]->str_ics_info.window_group_length; + const WORD8 *ptr_sfb_width = + ptr_aac_tables + ->str_aac_sfb_info[ptr_aac_dec_channel_info[RIGHT] + ->str_ics_info.window_sequence] + .sfb_width; + WORD32 *ptr_scale_table = ptr_aac_tables->pstr_block_tables->scale_table; + WORD32 win_grp, grp_len, k; + + for (win_grp = 0; + win_grp < + ptr_aac_dec_channel_info[RIGHT]->str_ics_info.num_window_groups; + win_grp++) { + for (grp_len = 0; grp_len < ptr_group_len[win_grp]; grp_len++) { + WORD32 sfb; + WORD32 ixheaacd_drc_offset = 0; + + for (sfb = 0; sfb < ptr_aac_dec_channel_info[RIGHT]->str_ics_info.max_sfb; + sfb++) { + WORD8 code_book = ptr_code_book[sfb]; + ixheaacd_drc_offset += ptr_sfb_width[sfb]; + + if (((code_book >= INTENSITY_HCB2) && + ((object_type != AOT_ER_AAC_ELD) && + (object_type != AOT_ER_AAC_LD))) || + (((code_book == INTENSITY_HCB2) || (code_book == INTENSITY_HCB)) && + ((object_type == AOT_ER_AAC_ELD) || + (object_type == AOT_ER_AAC_LD)))) + + { + WORD32 sfb_factor, scale; + WORD32 scf_exp; + + sfb_factor = (ptr_scale_factor[sfb]); + if (aac_sf_data_resil_flag) sfb_factor = -sfb_factor; + + scf_exp = (sfb_factor >> 2); + scale = *(ptr_scale_table + (sfb_factor & 3)); + if (!((ptr_ms_used[sfb]) ^ (code_book & 0x1))) { + scale = ixheaacd_negate32(scale); + } + + scf_exp = -(scf_exp + 2); + + for (k = 0; k < ptr_sfb_width[sfb]; k++) { + WORD32 temp, shift_val; + temp = *l_spec++; + + shift_val = ixheaacd_norm32(temp); + temp = ixheaacd_shl32(temp, shift_val); + + temp = ixheaacd_mult32x16in32l(temp, scale); + shift_val = shift_val + scf_exp; + + if (shift_val < 0) { + temp = ixheaacd_shl32_sat(temp, -shift_val); + } else { + temp = ixheaacd_shr32(temp, shift_val); + } + *r_spec++ = temp; + } + + } else { + l_spec += ptr_sfb_width[sfb]; + r_spec += ptr_sfb_width[sfb]; + } + } + l_spec += 128 - ixheaacd_drc_offset; + r_spec += 128 - ixheaacd_drc_offset; + } + ptr_ms_used += 64; + ptr_code_book += 16; + ptr_scale_factor += 16; + } +} diff --git a/decoder/ixheaacd_stereo.h b/decoder/ixheaacd_stereo.h new file mode 100644 index 0000000..e294798 --- /dev/null +++ b/decoder/ixheaacd_stereo.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_STEREO_H +#define IXHEAACD_STEREO_H + +VOID ixheaacd_read_ms_data(ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_ch_info); + +VOID ixheaacd_ms_stereo_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], + ia_aac_dec_tables_struct *ptr_aac_tables); + +VOID ixheaacd_intensity_stereo_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[2], + ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 object_type, + WORD32 aac_sf_data_resil_flag); + +#endif /* #ifndef IXHEAACD_STEREO_H */ diff --git a/decoder/ixheaacd_struct.h b/decoder/ixheaacd_struct.h new file mode 100644 index 0000000..8a5a20c --- /dev/null +++ b/decoder/ixheaacd_struct.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_STRUCT_H +#define IXHEAACD_STRUCT_H + +typedef struct { + UINT32 audio_object_type; + UINT32 samp_frequency_index; + UINT32 sampling_frequency; + UINT32 channel_configuration; + UINT32 ext_audio_object_type; + UINT32 ext_samp_frequency_index; + UINT32 ext_sampling_frequency; + UINT32 sbr_present_flag; + + UINT32 frame_length; + ia_prog_config_struct* str_prog_config; + ia_usac_config_struct str_usac_config; + + WORD32 num_front_channel; + WORD32 num_side_channel; + WORD32 num_back_channel; + WORD32 num_lfe_channel; + WORD32 num_ind_cce; + UINT32 avg_bit_rate; +} ia_audio_specific_config_struct; + +typedef struct { + WORD32 sample_rate_layer; + WORD32 bit_rate; + +} ia_layer_data_struct; + +typedef struct { + UINT32 stream_count; + ia_audio_specific_config_struct str_audio_specific_config; + ia_layer_data_struct str_layer; + WORD32 tracks_in_layer; + UWORD32 scal_out_select; + WORD32 scal_out_object_type; + WORD32 scal_out_num_channels; + WORD32 scal_out_sampling_frequency; + +} ia_frame_data_struct; + +#endif diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h new file mode 100644 index 0000000..0737448 --- /dev/null +++ b/decoder/ixheaacd_struct_def.h @@ -0,0 +1,290 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_STRUCT_DEF_H +#define IXHEAACD_STRUCT_DEF_H + +#define MAX_OUTPUT_CHANNELS (8) +#define MAX_NUM_OTT (1) + +#define MAX_ARBITRARY_TREE_LEVELS (2) +#define MAX_PARAMETER_SETS (8) +#define MAX_ARBITRARY_TREE_INDEX ((1 << (MAX_ARBITRARY_TREE_LEVELS + 1)) - 1) +#define MAX_NUM_QMF_BANDS (64) +#define MAX_NUM_OTT_AT \ + (MAX_OUTPUT_CHANNELS * ((1 << MAX_ARBITRARY_TREE_LEVELS) - 1)) +#define MAX_PARAMETER_BANDS (28) + +#define MAX_HYBRID_BANDS (MAX_NUM_QMF_BANDS - 3 + 10) + +#define MAX_TIME_SLOTS (72) + +#define MAX_M2_OUTPUT (8) +#define QMF_BANDS_TO_HYBRID (3) +#define PROTO_LEN (13) +#define BUFFER_LEN_LF (PROTO_LEN - 1 + MAX_TIME_SLOTS) +#define BUFFER_LEN_HF ((PROTO_LEN - 1) / 2) +#define MAX_TIME_SLOTS (72) +#define MAX_NO_TIME_SLOTS_DELAY (14) + +typedef struct { + WORD8 element_instance_tag; + WORD32 object_type; + WORD32 samp_freq_index; + WORD32 num_front_channel_elements; + WORD32 num_side_channel_elements; + WORD32 num_back_channel_elements; + WORD32 num_lfe_channel_elements; + WORD32 num_assoc_data_elements; + WORD32 num_valid_cc_elements; + + WORD8 front_element_is_cpe[16]; + WORD8 front_element_tag_select[16]; + WORD8 side_element_is_cpe[16]; + WORD8 side_element_tag_select[16]; + WORD8 back_element_is_cpe[16]; + WORD8 back_element_tag_select[16]; + WORD8 lfe_element_tag_select[16]; + + WORD32 channels; + WORD32 alignment_bits; + +} ia_program_config_struct; + +typedef struct ia_enhaacplus_dec_ind_cc { + WORD8 cc_target_is_cpe[MAX_BS_ELEMENT]; + WORD8 cc_target_tag_select[MAX_BS_ELEMENT]; + WORD8 cc_l[MAX_BS_ELEMENT]; + WORD8 cc_r[MAX_BS_ELEMENT]; + WORD32 cc_gain[2 * MAX_BS_ELEMENT]; + WORD8 elements_coupled[MAX_BS_ELEMENT]; + WORD num_coupled_elements; + +} ia_enhaacplus_dec_ind_cc; + +typedef struct { + UWORD32 ui_pcm_wdsz; + UWORD32 ui_samp_freq; + UWORD32 ui_n_channels; + WORD32 i_channel_mask; + UWORD32 ui_channel_mode; + UWORD32 ui_sbr_mode; + + UWORD32 flag_downmix; + UWORD32 flag_08khz_out; + UWORD32 flag_16khz_out; + UWORD32 flag_to_stereo; + UWORD32 down_sample_flag; + UWORD32 header_dec_done; + UWORD32 ui_mp4_flag; + UWORD32 ui_disable_sync; + UWORD32 ui_auto_sbr_upsample; + WORD32 frame_status; + UWORD32 ui_max_channels; + UWORD32 ui_pce_found_in_hdr; + UWORD32 ui_n_memtabs; + + WORD32 ui_drc_enable; + WORD32 ui_drc_boost; + WORD32 ui_drc_cut; + WORD32 ui_drc_target_level; + WORD32 ui_drc_set; + WORD32 ui_drc_heavy_comp; + + ia_program_config_struct str_prog_config; + WORD32 element_type[MAX_BS_ELEMENT + 1]; + WORD32 slot_element[MAX_BS_ELEMENT + 1]; + + WORD element_instance_order[MAX_BS_ELEMENT]; + WORD ui_coupling_channel; + WORD downmix; + WORD32 loas_present; + + WORD framesize_480; + WORD ld_decoder; + + WORD eld_sbr_present; + + UWORD32 ui_out_channels; + WORD32 ui_channel_mask; + + WORD32 ui_dec_type; + + UWORD32 ui_qmf_bands; + + WORD32 ui_flush_cmd; + +#ifdef ENABLE_DRC + ia_drc_config drc_config_struct; +#endif + +} ia_aac_dec_config_struct; + +typedef struct ia_aac_dec_state_struct { + ia_aac_dec_config_struct *p_config; + + AUDIO_OBJECT_TYPE audio_object_type; + + UWORD32 ui_in_bytes; + UWORD32 ui_out_bytes; + UWORD32 ui_exec_done; + + WORD16 b_n_raw_data_blk; + WORD16 s_adts_hdr_present; + WORD16 s_adif_hdr_present; + WORD16 num_channel_last; + UWORD32 sampling_rate; + UWORD32 extension_samp_rate; + UWORD32 bit_rate; + UWORD32 ui_init_done; + UWORD32 ui_input_over; + UWORD32 header_dec_done; + WORD32 frame_counter; + ia_aac_decoder_struct *pstr_aac_dec_info[MAX_BS_ELEMENT]; + + UWORD32 ch_config; + struct ia_bit_buf_struct str_bit_buf, *pstr_bit_buf; + ia_aac_dec_sbr_bitstream_struct (*pstr_stream_sbr)[2]; + ia_handle_sbr_dec_inst_struct str_sbr_dec_info[MAX_BS_ELEMENT]; + WORD32 sbr_present_flag; + WORD32 ps_present; + + ia_bit_buf_struct *ptr_bit_stream; + + VOID *aac_scratch_mem_v; + VOID *aac_persistent_mem_v; + + VOID *sbr_persistent_mem_v; + WORD32 *ptr_overlap_buf; + WORD16 num_of_out_samples; + WORD32 last_frame_ok; + WORD32 i_bytes_consumed; + + WORD16 *coup_ch_output; + ia_enhaacplus_dec_ind_cc ind_cc_info; + + WORD8 protection_absent; + WORD32 crc_check; + WORD32 ui_flush_cmd; + + WORD32 frame_len_flag; + WORD32 depends_on_core_coder; + WORD32 extension_flag; + + WORD32 bs_format; + WORD32 bit_count; + WORD32 sync_status; + WORD32 extension_flag_3; + + ixheaacd_latm_struct latm_struct_element; + WORD32 latm_initialized; + + ia_drc_dec_struct str_drc_dec_info; + ia_drc_dec_struct drc_dummy; + ia_drc_dec_struct *pstr_drc_dec; + ixheaac_drc_data_struct *pstr_hdrc_data[MAX_BS_ELEMENT * 3]; + + WORD32 prev_channel_mode; + WORD32 drc_cut_fac; + WORD32 drc_boost_fac; + + WORD32 first_drc_frame; + + ia_aac_err_config_struct str_err_config; + WORD32 frame_size; + WORD32 frame_length; + + WORD32 dwnsmp_signal; + ia_eld_specific_config_struct eld_specific_config; + FLAG usac_flag; + + WORD32 num_of_output_ch; + VOID *ia_audio_specific_config; + ia_mps_dec_state_struct *mps_dec_handle[MAX_NUM_ELEMENTS]; + + UWORD16 *huffman_code_book_scl; + UWORD32 *huffman_code_book_scl_index; + + ia_aac_dec_tables_struct *pstr_aac_tables; + + VOID *pstr_dec_data; + VOID *sbr_persistent_mem_u; + VOID *sbr_scratch_mem_u; + UWORD8 *header_ptr; + WORD32 header_length; + ia_sbr_header_data_struct str_sbr_config; +} ia_aac_dec_state_struct; + +typedef struct ia_exhaacplus_dec_api_struct { + ia_aac_dec_state_struct *p_state_aac; + + ia_aac_dec_config_struct aac_config; + + ia_mem_info_struct *p_mem_info_aac; + + pVOID *pp_mem_aac; + + ia_aac_dec_tables_struct aac_tables; + ixheaacd_misc_tables *common_tables; + ia_sbr_tables_struct str_sbr_tables; + +} ia_exhaacplus_dec_api_struct; + +WORD32 ixheaacd_aacdec_decodeframe( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, + ia_aac_dec_scratch_struct *aac_scratch_ptrs, WORD16 *time_data, + FLAG frame_status, WORD *type, WORD *ch_idx, WORD init_flag, WORD channel, + WORD *element_index_order, WORD skip_full_decode, WORD ch_fac, + WORD slot_element, WORD max_channels, WORD32 total_channels, + WORD32 frame_length, WORD32 frame_size, ia_drc_dec_struct *pstr_drc_dec, + WORD32 object_type, WORD32 ch_config, + ia_eld_specific_config_struct eld_specific_config, WORD16 adtsheader, + ia_drc_dec_struct *drc_dummy); + +WORD ixheaacd_get_channel_mask( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +VOID ixheaacd_allocate_mem_persistent( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, + ia_aac_dec_state_struct *p_state_enhaacplus_dec, WORD channels, + WORD *persistent_used_total, WORD *sbr_persistent_start, WORD ps_enable); + +WORD32 ixheaacd_dec_mem_api(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, + WORD32 i_cmd, WORD32 i_idx, VOID *pv_value); + +WORD32 ixheaacd_fill_aac_mem_tables( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +WORD32 ixheaacd_decoder_2_ga_hdr( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +WORD32 ixheaacd_decoder_flush_api( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +WORD32 ixheaacd_fill_usac_mem_tables(ia_exhaacplus_dec_api_struct *self); + +WORD32 ixheaacd_dec_init(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +WORD32 ixheaacd_dec_execute(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec); + +WORD32 ixheaacd_dec_table_api( + ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD32 i_cmd, + WORD32 i_idx, VOID *pv_value); + +#endif /* IXHEAACD_STRUCT_DEF_H */ diff --git a/decoder/ixheaacd_tcx_fwd_alcnx.c b/decoder/ixheaacd_tcx_fwd_alcnx.c new file mode 100644 index 0000000..bf579d2 --- /dev/null +++ b/decoder/ixheaacd_tcx_fwd_alcnx.c @@ -0,0 +1,389 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include +#include "ixheaacd_bitbuffer.h" + +#include "ixheaacd_interface.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" + +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_td_mdct.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_func_def.h" +#include "ixheaacd_windows.h" +#include "ixheaacd_acelp_com.h" + +#include "ixheaacd_constants.h" +#include +#include +#include + +static FLOAT32 ixheaacd_randomsign(UWORD32 *seed); +#define ABS(A) ((A) < 0 ? (-A) : (A)) + +VOID ixheaacd_lpc_coeff_wt_apply(FLOAT32 *a, FLOAT32 *ap) { + FLOAT32 f; + WORD32 i; + ap[0] = a[0]; + f = 0.92f; + for (i = 1; i <= 16; i++) { + ap[i] = f * a[i]; + f *= 0.92f; + } + return; +} + +WORD8 ixheaacd_float2fix(FLOAT32 *x, WORD32 *int_x, WORD32 length) { + WORD32 k, itemp; + FLOAT32 ftemp = 0.0; + WORD8 shiftp; + for (k = 0; k < length; k++) { + if (ABS(x[k]) > ftemp) ftemp = ABS(x[k]); + } + + itemp = (WORD32)(ftemp); + shiftp = ixheaacd_norm32(itemp); + + for (k = 0; k < length; k++) { + int_x[k] = (WORD32)(x[k] * (FLOAT32)((WORD64)1 << shiftp)); + } + + return (shiftp); +} + +VOID ixheaacd_fix2float(WORD32 *int_xn1, FLOAT32 *xn1, WORD32 length, + WORD8 *shiftp, WORD32 *preshift) { + WORD32 k; + FLOAT32 qfac; + if ((*shiftp - *preshift) > 0) { + qfac = 1.0f / (FLOAT32)((WORD64)1 << (*shiftp - *preshift)); + for (k = 0; k < length; k++) { + xn1[k] = (FLOAT32)((FLOAT32)int_xn1[k] * qfac); + } + } else { + for (k = 0; k < length; k++) { + xn1[k] = (FLOAT32)((FLOAT32)int_xn1[k] * + (FLOAT32)((WORD64)1 << (*preshift - *shiftp))); + } + } +} + +static VOID ixheaacd_low_fq_deemphasis(FLOAT32 x[], WORD32 lg, + FLOAT32 gains[]) { + WORD32 i, j, k, i_max; + FLOAT32 max, factor, rm; + + k = 8; + i_max = lg / 4; + + max = 0.01f; + for (i = 0; i < i_max; i += k) { + rm = 0.01f; + for (j = i; j < i + k; j++) rm += x[j] * x[j]; + + if (rm > max) max = rm; + } + + factor = 0.1f; + for (i = 0; i < i_max; i += k) { + rm = 0.01f; + for (j = i; j < i + k; j++) rm += x[j] * x[j]; + + rm = (FLOAT32)sqrt(rm / max); + if (rm > factor) factor = rm; + + for (j = i; j < i + k; j++) x[j] *= factor; + + gains[i / k] = factor; + } + + return; +} + +WORD32 ixheaacd_tcx_mdct(ia_usac_data_struct *usac_data, + ia_td_frame_data_struct *pstr_td_frame_data, + WORD32 frame_index, FLOAT32 lp_flt_coff_a[], WORD32 lg, + ia_usac_lpd_decoder_handle st) { + WORD32 i, mode; + WORD32 *ptr_tcx_quant; + FLOAT32 tmp, gain_tcx, noise_level, energy, temp; + FLOAT32 *ptr_a, i_ap[ORDER + 1]; + const FLOAT32 *sine_window_prev, *sine_window; + WORD32 fac_length_prev; + FLOAT32 alfd_gains[LEN_SUPERFRAME / (4 * 8)]; + FLOAT32 x[LEN_SUPERFRAME], buf[ORDER + LEN_SUPERFRAME]; + WORD32 int_x[LEN_SUPERFRAME + (2 * FAC_LENGTH)]; + WORD32 int_xn1[LEN_SUPERFRAME + (2 * FAC_LENGTH)]; + FLOAT32 gain1[LEN_SUPERFRAME], gain2[LEN_SUPERFRAME]; + FLOAT32 xn_buf[LEN_SUPERFRAME + (2 * FAC_LENGTH)]; + FLOAT32 *xn; + FLOAT32 xn1[2 * FAC_LENGTH], facwindow[2 * FAC_LENGTH]; + WORD32 TTT; + WORD8 shiftp; + WORD32 preshift = 0; + WORD32 loop_count = 0; + FLOAT32 *exc = &usac_data->exc_buf[usac_data->len_subfrm * frame_index + + MAX_PITCH + INTER_LP_FIL_ORDER + 1]; + FLOAT32 *synth = + &usac_data->synth_buf[usac_data->len_subfrm * frame_index + MAX_PITCH + + (((NUM_FRAMES * usac_data->num_subfrm) / 2) - 1) * + LEN_SUBFR]; + + WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; + + WORD32 fac_length = (usac_data->len_subfrm) / 2; + WORD32 err = 0; + + mode = lg / (usac_data->len_subfrm); + if (mode > 2) mode = 3; + + if (st->mode_prev == -2) + fac_length_prev = (usac_data->ccfl) / 16; + + else + fac_length_prev = fac_length; + + if (fac_length == 96) + sine_window = ixheaacd_sine_window192; + else + sine_window = ixheaacd__sine_window256; + + if (fac_length_prev == 48) + sine_window_prev = ixheaacd_sine_window96; + + else if (fac_length_prev == 64) + sine_window_prev = ixheaacd_sine_window128; + + else if (fac_length_prev == 96) + sine_window_prev = ixheaacd_sine_window192; + + else + sine_window_prev = ixheaacd__sine_window256; + + xn = xn_buf + fac_length; + + if (st->mode_prev != 0) { + if (st->mode_prev > 0) { + for (i = 0; i < (2 * fac_length_prev); i++) { + st->exc_prev[i + fac_length - fac_length_prev + 1] *= + sine_window_prev[(2 * fac_length_prev) - 1 - i]; + } + } + for (i = 0; i < fac_length - fac_length_prev; i++) { + st->exc_prev[i + fac_length + fac_length_prev + 1] = 0.0f; + } + } + + noise_level = + 0.0625f * + (8.0f - ((FLOAT32)pstr_td_frame_data->noise_factor[frame_index])); + + ptr_tcx_quant = pstr_td_frame_data->x_tcx_invquant; + for (i = 0; i < frame_index; i++) + ptr_tcx_quant += pstr_td_frame_data->tcx_lg[i]; + + for (i = 0; i < lg; i++) x[i] = (FLOAT32)ptr_tcx_quant[i]; + + for (i = lg / 6; i < lg; i += 8) { + WORD32 k, max_k = min(lg, i + 8); + FLOAT32 tmp = 0.0f; + for (k = i; k < max_k; k++) tmp += ptr_tcx_quant[k] * ptr_tcx_quant[k]; + + if (tmp == 0.0f) { + for (k = i; k < max_k; k++) + x[k] = noise_level * + ixheaacd_randomsign( + &(usac_data->seed_value[usac_data->present_chan])); + } + } + + ixheaacd_low_fq_deemphasis(x, lg, alfd_gains); + + ixheaacd_lpc_coeff_wt_apply(lp_flt_coff_a + (ORDER + 1), i_ap); + ixheaacd_lpc_to_td(i_ap, ORDER, gain1, usac_data->len_subfrm / 4); + + ixheaacd_lpc_coeff_wt_apply(lp_flt_coff_a + (2 * (ORDER + 1)), i_ap); + ixheaacd_lpc_to_td(i_ap, ORDER, gain2, usac_data->len_subfrm / 4); + + energy = 0.01f; + for (i = 0; i < lg; i++) energy += x[i] * x[i]; + + temp = (FLOAT32)sqrt(energy) / lg; + + gain_tcx = + (FLOAT32)pow( + 10.0f, + ((FLOAT32)pstr_td_frame_data->global_gain[frame_index]) / 28.0f) / + (temp * 2.0f); + + ixheaacd_noise_shaping(x, lg, (usac_data->len_subfrm) / 4, gain1, gain2); + + shiftp = ixheaacd_float2fix(x, int_x, lg); + + err = ixheaacd_acelp_mdct_main(usac_data, int_x, int_xn1, (2 * fac_length), + lg - (2 * fac_length), &preshift); + if (err == -1) return err; + + ixheaacd_fix2float(int_xn1, xn_buf, (lg + (2 * fac_length)), &shiftp, + &preshift); + + ixheaacd_vec_cnst_mul((2.0f / lg), xn_buf, xn_buf, lg + (2 * fac_length)); + + st->fac_gain = + gain_tcx * 0.5f * (FLOAT32)sqrt(((FLOAT32)fac_length) / (FLOAT32)lg); + + for (i = 0; i < fac_length / 4; i++) + st->fac_fd_data[i] = alfd_gains[i * lg / (8 * fac_length)]; + + if (st->mode_prev == 0) { + for (i = 0; i < fac_length_prev; i++) { + facwindow[i] = + sine_window_prev[i] * sine_window_prev[(2 * fac_length_prev) - 1 - i]; + facwindow[fac_length_prev + i] = + 1.0f - (sine_window_prev[fac_length_prev + i] * + sine_window_prev[fac_length_prev + i]); + } + + for (i = 0; i < fac_length / 2; i++) { + x[i] = st->fac_gain * + (FLOAT32)pstr_td_frame_data->fac[frame_index * FAC_LENGTH + 2 * i]; + x[fac_length / 2 + i] = + st->fac_gain * + (FLOAT32)pstr_td_frame_data + ->fac[frame_index * FAC_LENGTH + fac_length - 2 * i - 1]; + } + + for (i = 0; i < fac_length / 8; i++) { + x[i] *= st->fac_fd_data[2 * i]; + x[fac_length - i - 1] *= st->fac_fd_data[2 * i + 1]; + } + + preshift = 0; + shiftp = ixheaacd_float2fix(x, int_x, fac_length); + + err = + ixheaacd_acelp_mdct(int_x, int_xn1, &preshift, fac_length, ptr_scratch); + if (err == -1) return err; + + ixheaacd_fix2float(int_xn1, xn1, fac_length, &shiftp, &preshift); + + ixheaacd_vec_cnst_mul((2.0f / (FLOAT32)fac_length), xn1, xn1, fac_length); + + memset(xn1 + fac_length, 0, fac_length * sizeof(FLOAT32)); + + ixheaacd_lpc_coeff_wt_apply(lp_flt_coff_a + (ORDER + 1), i_ap); + ixheaacd_synthesis_tool_float(i_ap, xn1, xn1, 2 * fac_length, + xn1 + fac_length); + + for (i = 0; i < fac_length; i++) { + temp = st->exc_prev[1 + fac_length + i] * facwindow[fac_length + i] + + st->exc_prev[fac_length - i] * facwindow[fac_length - 1 - i]; + xn1[i] += temp; + } + } + + for (i = 0; i < lg + (2 * fac_length); i++) xn_buf[i] *= gain_tcx; + + for (i = 0; i < (2 * fac_length_prev); i++) + xn_buf[i + fac_length - fac_length_prev] *= sine_window_prev[i]; + + for (i = 0; i < fac_length - fac_length_prev; i++) xn_buf[i] = 0.0f; + + if (st->mode_prev != 0) { + for (i = fac_length - fac_length_prev; i < (fac_length + fac_length_prev); + i++) + xn_buf[i] += st->exc_prev[1 + i]; + } else { + for (i = fac_length - fac_length_prev; i < (fac_length + fac_length_prev); + i++) + xn_buf[i + fac_length] += xn1[i]; + } + + ixheaacd_mem_cpy(xn_buf + lg - 1, st->exc_prev, 1 + (2 * fac_length)); + + for (i = 0; i < (2 * fac_length); i++) { + xn_buf[i + lg] *= sine_window[(2 * fac_length) - 1 - i]; + } + + if (st->mode_prev != 0) { + ixheaacd_mem_cpy(xn_buf + fac_length - fac_length_prev, + synth - fac_length_prev, fac_length_prev); + + for (i = 0; i < ORDER + fac_length; i++) + buf[i] = synth[i - ORDER - fac_length] - + (PREEMPH_FILT_FAC * synth[i - ORDER - fac_length - 1]); + + ptr_a = st->lp_flt_coeff_a_prev; + TTT = fac_length % LEN_SUBFR; + if (TTT != 0) + ixheaacd_residual_tool_float(ptr_a, &buf[ORDER], &exc[-fac_length], TTT, + 1); + + loop_count = (fac_length - TTT) / LEN_SUBFR; + ixheaacd_residual_tool_float(ptr_a, &buf[ORDER + TTT], + &exc[TTT - fac_length], LEN_SUBFR, loop_count); + } + + ixheaacd_mem_cpy(xn, synth, lg); + + ixheaacd_mem_cpy(synth - ORDER - 1, xn - ORDER - 1, ORDER + 1); + tmp = xn[-ORDER - 1]; + ixheaacd_preemphsis_tool_float(xn - ORDER, PREEMPH_FILT_FAC, ORDER + lg, tmp); + + ptr_a = lp_flt_coff_a + (2 * (ORDER + 1)); + + ixheaacd_residual_tool_float(ptr_a, xn, exc, lg, 1); + + ixheaacd_mem_cpy(ptr_a, st->lp_flt_coeff_a_prev, ORDER + 1); + ixheaacd_mem_cpy(ptr_a, st->lp_flt_coeff_a_prev + ORDER + 1, ORDER + 1); + + return err; +} + +static FLOAT32 ixheaacd_randomsign(UWORD32 *seed) { + FLOAT32 sign = 0.0f; + *seed = (UWORD32)(((UWORD64)(*seed) * (UWORD64)69069) + 5); + + if (((*seed) & 0x10000) > 0) + sign = -1.f; + else + sign = +1.f; + + return sign; +} diff --git a/decoder/ixheaacd_tcx_fwd_mdct.c b/decoder/ixheaacd_tcx_fwd_mdct.c new file mode 100644 index 0000000..8778224 --- /dev/null +++ b/decoder/ixheaacd_tcx_fwd_mdct.c @@ -0,0 +1,254 @@ +/****************************************************************************** + * * + * 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 +#include +#include +#include +#include + +#include "ixheaacd_cnst.h" +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_acelp_com.h" + +#include +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_interface.h" + +#include "ixheaacd_tns_usac.h" +#include "ixheaacd_cnst.h" + +#include "ixheaacd_acelp_info.h" + +#include "ixheaacd_td_mdct.h" + +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_info.h" +#include "ixheaacd_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_sbr_const.h" + +#include "ixheaacd_constants.h" +#include +#include +#include "ixheaacd_main.h" +#include "ixheaacd_arith_dec.h" + +#define FREQ_MAX 6400.0f + +#define ABS(A) ((A) < 0 ? (-A) : (A)) + +static VOID ixheaacd_compute_coeff_poly_f(FLOAT32 lsp[], FLOAT32 *f1, + FLOAT32 *f2) { + FLOAT32 b1, b2; + FLOAT32 *ptr_lsp; + WORD32 i, j; + + ptr_lsp = lsp; + f1[0] = f2[0] = 1.0f; + + for (i = 1; i <= ORDER_BY_2; i++) { + b1 = -2.0f * (*ptr_lsp++); + b2 = -2.0f * (*ptr_lsp++); + f1[i] = (b1 * f1[i - 1]) + (2.0f * f1[i - 2]); + f2[i] = (b2 * f2[i - 1]) + (2.0f * f2[i - 2]); + for (j = i - 1; j > 0; j--) { + f1[j] += (b1 * f1[j - 1]) + f1[j - 2]; + f2[j] += (b2 * f2[j - 1]) + f2[j - 2]; + } + } + + return; +} +VOID ixheaacd_lsp_to_lp_conversion(FLOAT32 *lsp, FLOAT32 *lp_flt_coff_a) { + WORD32 i; + FLOAT32 *ppoly_f1, *ppoly_f2; + FLOAT32 *plp_flt_coff_a_bott, *plp_flt_coff_a_top; + FLOAT32 poly1[ORDER_BY_2 + 2], poly2[ORDER_BY_2 + 2]; + + poly1[0] = 0.0f; + poly2[0] = 0.0f; + + ixheaacd_compute_coeff_poly_f(lsp, &poly1[1], &poly2[1]); + + ppoly_f1 = poly1 + ORDER_BY_2 + 1; + ppoly_f2 = poly2 + ORDER_BY_2 + 1; + + for (i = 0; i < ORDER_BY_2; i++) { + ppoly_f1[0] += ppoly_f1[-1]; + ppoly_f2[0] -= ppoly_f2[-1]; + ppoly_f1--; + ppoly_f2--; + } + + plp_flt_coff_a_bott = lp_flt_coff_a; + *plp_flt_coff_a_bott++ = 1.0f; + plp_flt_coff_a_top = lp_flt_coff_a + ORDER; + ppoly_f1 = poly1 + 2; + ppoly_f2 = poly2 + 2; + for (i = 0; i < ORDER_BY_2; i++) { + *plp_flt_coff_a_bott++ = 0.5f * (*ppoly_f1 + *ppoly_f2); + *plp_flt_coff_a_top-- = 0.5f * (*ppoly_f1++ - *ppoly_f2++); + } + + return; +} + +VOID ixheaacd_lpc_to_td(float *coeff, WORD32 order, float *gains, WORD32 lg) { + FLOAT32 data_r[LEN_SUPERFRAME * 2]; + FLOAT32 data_i[LEN_SUPERFRAME * 2]; + FLOAT64 avg_fac; + WORD32 idata_r[LEN_SUPERFRAME * 2]; + WORD32 idata_i[LEN_SUPERFRAME * 2]; + WORD8 qshift; + WORD32 preshift = 0; + WORD32 itemp; + FLOAT32 ftemp = 0; + FLOAT32 tmp, qfac; + WORD32 i, size_n; + + size_n = 2 * lg; + avg_fac = PI / (FLOAT32)(size_n); + + for (i = 0; i < order + 1; i++) { + tmp = (FLOAT32)(((FLOAT32)i) * avg_fac); + data_r[i] = (FLOAT32)(coeff[i] * cos(tmp)); + data_i[i] = (FLOAT32)(-coeff[i] * sin(tmp)); + } + for (; i < size_n; i++) { + data_r[i] = 0.f; + data_i[i] = 0.f; + } + + for (i = 0; i < size_n; i++) { + if (ABS(data_r[i]) > ftemp) ftemp = ABS(data_r[i]); + if (ABS(data_i[i]) > ftemp) ftemp = ABS(data_i[i]); + } + + itemp = (WORD32)ftemp; + qshift = ixheaacd_norm32(itemp); + + for (i = 0; i < size_n; i++) { + idata_r[i] = (WORD32)(data_r[i] * ((WORD64)1 << qshift)); + idata_i[i] = (WORD32)(data_i[i] * ((WORD64)1 << qshift)); + } + + ixheaacd_complex_fft(idata_r, idata_i, size_n, -1, &preshift); + + qfac = 1.0f / ((FLOAT32)((WORD64)1 << (qshift - preshift))); + + for (i = 0; i < size_n; i++) { + data_r[i] = (FLOAT32)((FLOAT32)idata_r[i] * qfac); + data_i[i] = (FLOAT32)((FLOAT32)idata_i[i] * qfac); + } + + for (i = 0; i < size_n / 2; i++) { + gains[i] = + (FLOAT32)(1.0f / sqrt(data_r[i] * data_r[i] + data_i[i] * data_i[i])); + } + + return; +} + +VOID ixheaacd_noise_shaping(FLOAT32 r[], WORD32 lg, WORD32 M, FLOAT32 g1[], + FLOAT32 g2[]) { + WORD32 i, k; + FLOAT32 rr_prev, a = 0, b = 0; + FLOAT32 rr[1024]; + + k = lg / M; + + rr_prev = 0; + + memcpy(&rr, r, lg * sizeof(FLOAT32)); + + for (i = 0; i < lg; i++) { + if ((i % k) == 0) { + a = 2.0f * g1[i / k] * g2[i / k] / (g1[i / k] + g2[i / k]); + b = (g2[i / k] - g1[i / k]) / (g1[i / k] + g2[i / k]); + } + + rr[i] = a * rr[i] + b * rr_prev; + rr_prev = rr[i]; + } + + for (i = 0; i < lg / 2; i++) { + r[i] = rr[2 * i]; + r[lg / 2 + i] = rr[lg - 2 * i - 1]; + } + return; +} + +VOID ixheaacd_lpc_coef_gen(FLOAT32 lsf_old[], FLOAT32 lsf_new[], FLOAT32 a[], + WORD32 nb_subfr, WORD32 m) { + FLOAT32 lsf[ORDER], *ptr_a; + FLOAT32 inc, fnew, fold; + WORD32 i; + + ptr_a = a; + + inc = 1.0f / (FLOAT32)nb_subfr; + fnew = 0.5f - (0.5f * inc); + fold = 1.0f - fnew; + + for (i = 0; i < m; i++) { + lsf[i] = (lsf_old[i] * fold) + (lsf_new[i] * fnew); + } + ixheaacd_lsp_to_lp_conversion(lsf, ptr_a); + ptr_a += (m + 1); + ixheaacd_lsp_to_lp_conversion(lsf_old, ptr_a); + ptr_a += (m + 1); + ixheaacd_lsp_to_lp_conversion(lsf_new, ptr_a); + ptr_a += (m + 1); + + return; +} + +VOID ixheaacd_interpolation_lsp_params(FLOAT32 lsp_old[], FLOAT32 lsp_new[], + FLOAT32 lp_flt_coff_a[], + WORD32 nb_subfr) { + FLOAT32 lsp[ORDER]; + FLOAT32 factor; + WORD32 i, k; + FLOAT32 x_plus_y, x_minus_y; + + factor = 1.0f / (FLOAT32)nb_subfr; + + x_plus_y = 0.5f * factor; + + for (k = 0; k < nb_subfr; k++) { + x_minus_y = 1.0f - x_plus_y; + for (i = 0; i < ORDER; i++) { + lsp[i] = (lsp_old[i] * x_minus_y) + (lsp_new[i] * x_plus_y); + } + x_plus_y += factor; + + ixheaacd_lsp_to_lp_conversion(lsp, lp_flt_coff_a); + + lp_flt_coff_a += (ORDER + 1); + } + + ixheaacd_lsp_to_lp_conversion(lsp_new, lp_flt_coff_a); + + return; +} diff --git a/decoder/ixheaacd_td_mdct.h b/decoder/ixheaacd_td_mdct.h new file mode 100644 index 0000000..934d969 --- /dev/null +++ b/decoder/ixheaacd_td_mdct.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_TD_MDCT_H +#define IXHEAACD_TD_MDCT_H + +WORD8 ixheaacd_float2fix(FLOAT32 *x, WORD32 *int_x, WORD32 length); + +VOID ixheaacd_fix2float(WORD32 *int_xn1, FLOAT32 *xn1, WORD32 length, + WORD8 *shiftp, WORD32 *preshift); + +VOID ixheaacd_complex_fft(WORD32 *data_r, WORD32 *data_i, WORD32 len, + WORD32 fft_mode, WORD32 *preshift); + +#endif diff --git a/decoder/ixheaacd_thumb_ps_dec.c b/decoder/ixheaacd_thumb_ps_dec.c new file mode 100644 index 0000000..9810148 --- /dev/null +++ b/decoder/ixheaacd_thumb_ps_dec.c @@ -0,0 +1,169 @@ +/****************************************************************************** + * * + * 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 +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops_arr.h" +#include "ixheaacd_basic_ops.h" + +#include "ixheaacd_defines.h" +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_defines.h" +#include "ixheaacd_pns.h" +#include +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_lt_predict.h" +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" + +#include +#include "ixheaacd_ps_dec.h" + +#include "ixheaacd_qmf_dec.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_sbr_const.h" +#include "ixheaacd_pvc_dec.h" +#include "ixheaacd_sbr_dec.h" +#include "ixheaacd_function_selector.h" + +VOID ixheaacd_apply_ps(ia_ps_dec_struct *ptr_ps_dec, WORD32 **p_buf_left_real, + WORD32 **p_buf_left_imag, WORD32 *p_buf_right_real, + WORD32 *p_buf_right_imag, + ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 slot, + ia_sbr_tables_struct *sbr_tables_ptr) { + WORD16 shiftdelay = + (WORD16)((slot < (32 - MAX_OV_COLS)) ? 0 : (sbr_scale_factor->lb_scale - + sbr_scale_factor->ps_scale)); + + ixheaacd_hybrid_analysis(p_buf_left_real[HYBRID_FILTER_DELAY], + ptr_ps_dec->ptr_hyb_left_re, + ptr_ps_dec->ptr_hyb_left_im, &ptr_ps_dec->str_hybrid, + shiftdelay, sbr_tables_ptr); + + (*ixheaacd_decorrelation)(ptr_ps_dec, p_buf_left_real[0], p_buf_left_imag[0], + p_buf_right_real, p_buf_right_imag, + sbr_tables_ptr->ps_tables_ptr); + + (*ixheaacd_apply_rot)(ptr_ps_dec, p_buf_left_real[0], p_buf_left_imag[0], + p_buf_right_real, p_buf_right_imag, sbr_tables_ptr, + ptr_ps_dec->str_hybrid.ptr_resol); +} + +VOID ixheaacd_scale_ps_states(ia_ps_dec_struct *ptr_ps_dec, WORD16 scale) { + WORD i, m; + WORD32 delay; + + if (scale > 0) { + WORD16 scale1 = scale; + if (scale > 15) scale1 = 15; + + for (m = 0; m < 2; m++) + ixheaacd_scale_short_vec_left( + (WORD16 *)&ptr_ps_dec->delay_buf_qmf_ap_re_im[m][3 * 2], + 2 * NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS, scale1); + + delay = 2 * HIGH_DEL * SMALL_DEL_STRT + + 2 * SMALL_DEL * + (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS - + (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)); + ixheaacd_scale_short_vec_left((WORD16 *)ptr_ps_dec->delay_buf_qmf_ld_re_im, + delay, scale1); + + delay = 2 * 16 * DEL_ALL_PASS + 2 * NUM_SER_AP_LINKS * 5 * 16; + ixheaacd_scale_short_vec_left((WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_re_im, + delay, scale1); + + for (i = 0; i < NUM_SER_AP_LINKS; i++) { + for (m = 0; m < ptr_ps_dec->delay_sample_ser[i]; m++) { + ixheaacd_scale_short_vec_left( + (WORD16 *)&ptr_ps_dec->delay_buf_qmf_ser_re_im[m][i][2 * 3], + 2 * NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS, scale1); + } + } + + ixheaacd_scale_int_vec_left( + ptr_ps_dec->str_hybrid.ptr_qmf_buf_re[0], + 2 * NO_QMF_CHANNELS_IN_HYBRID * ptr_ps_dec->str_hybrid.ptr_qmf_buf, + scale); + + scale = (scale + scale); + + ixheaacd_scale_int_vec_left(ptr_ps_dec->peak_decay_diff, 3 * NUM_OF_BINS, + scale); + + } else { + if (scale != 0) { + scale = -scale; + for (m = 0; m < 2; m++) + ixheaacd_scale_short_vec_right( + (WORD16 *)&ptr_ps_dec->delay_buf_qmf_ap_re_im[m][3 * 2], + 2 * NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS, scale); + + delay = 2 * HIGH_DEL * SMALL_DEL_STRT + + 2 * SMALL_DEL * + (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS - + (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)); + ixheaacd_scale_short_vec_right( + (WORD16 *)ptr_ps_dec->delay_buf_qmf_ld_re_im, delay, scale); + + delay = 2 * 16 * DEL_ALL_PASS + 2 * NUM_SER_AP_LINKS * 5 * 16; + ixheaacd_scale_short_vec_right( + (WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_re_im, delay, scale); + + for (i = 0; i < NUM_SER_AP_LINKS; i++) { + for (m = 0; m < ptr_ps_dec->delay_sample_ser[i]; m++) { + ixheaacd_scale_short_vec_right( + (WORD16 *)&ptr_ps_dec->delay_buf_qmf_ser_re_im[m][i][3 * 2], + 2 * NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS, scale); + } + } + + ixheaacd_scale_int_vec_right( + ptr_ps_dec->str_hybrid.ptr_qmf_buf_re[0], + 2 * NO_QMF_CHANNELS_IN_HYBRID * ptr_ps_dec->str_hybrid.ptr_qmf_buf, + scale); + + scale = (scale + scale); + + ixheaacd_scale_int_vec_right(ptr_ps_dec->peak_decay_diff, 3 * NUM_OF_BINS, + scale); + } + } +} diff --git a/decoder/ixheaacd_tns.c b/decoder/ixheaacd_tns.c new file mode 100644 index 0000000..491cecf --- /dev/null +++ b/decoder/ixheaacd_tns.c @@ -0,0 +1,313 @@ +/****************************************************************************** + * * + * 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 +#include + +#include +#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_sbr_common.h" +#include "ixheaacd_drc_data_struct.h" +#include "ixheaacd_drc_dec.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_function_selector.h" +#include +#include +#include + +#define sfb_offset(x) (((x) > 0) ? sfb_top[(x)-1] : 0) + +static VOID ixheaacd_tns_dec_coef_usac(ia_usac_data_struct *usac_data, + ia_tns_filter_struct *filter, + WORD32 coef_res, WORD32 *par_coeff) { + WORD32 resolution; + WORD32 *ptr_par_coeff = par_coeff; + const WORD32 *tns_coeff_ptr; + WORD32 ixheaacd_drc_offset = 4; + WORD16 *ptr_coeff = filter->coef; + WORD32 order; + + resolution = coef_res - 3; + tns_coeff_ptr = usac_data->tns_coeff3_32; + if (resolution) { + tns_coeff_ptr = usac_data->tns_coeff4_32; + ixheaacd_drc_offset = ixheaacd_drc_offset << 1; + } + order = filter->order; + + do { + WORD16 temp = *ptr_coeff++; + *ptr_par_coeff++ = tns_coeff_ptr[temp + ixheaacd_drc_offset]; + order--; + } while (order != 0); +} + +static VOID ixheaacd_tns_parcor_lpc_convert_usac(WORD32 *parcor, + WORD32 *lpc_coeff, + WORD32 *scale, WORD order) + +{ + WORD i, j, status; + WORD32 accu; + WORD32 temp_buf1[TNS_MAX_ORDER + 1]; + WORD32 temp_buf2[TNS_MAX_ORDER + 1]; + WORD32 accu1, accu2; + + status = 1; + *scale = 1; + + while (status) { + status = 0; + + for (i = TNS_MAX_ORDER; i >= 0; i--) { + temp_buf1[i] = 0; + temp_buf2[i] = 0; + } + + accu1 = (0x40000000 >> (*scale - 1)); + + for (i = 0; i <= order; i++) { + accu = accu1; + + for (j = 0; j < order; j++) { + temp_buf2[j] = (accu1); + + accu1 = ixheaacd_add32_sat( + accu1, ixheaacd_mult32_shl_sat(parcor[j], temp_buf1[j])); + if (ixheaacd_abs32_sat(accu1) == 0x7fffffff) status = 1; + } + + for (j = (order - 1); j >= 0; j--) { + accu2 = (temp_buf1[j]); + accu2 = ixheaacd_add32_sat( + accu2, ixheaacd_mult32_shl_sat(parcor[j], temp_buf2[j])); + temp_buf1[j + 1] = (accu2); + + if (ixheaacd_abs32_sat(accu2) == 0x7fffffff) status = 1; + } + + temp_buf1[0] = (accu); + lpc_coeff[i] = (accu1); + accu1 = 0; + } + + accu1 = (status - 1); + + if (accu1 == 0) { + *scale = *scale + 1; + } + } +} + +static VOID ixheaacd_tns_ar_filter_usac(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc_coeff, + WORD32 order, WORD32 shift_value, + WORD32 *ptr_filter_state) { + WORD32 i, j; + WORD32 y; + WORD64 acc; + + if ((order & 3) != 0) { + for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + lpc_coeff[i] = 0; + } + lpc_coeff[i] = 0; + order = ((order & 0xfffffffc) + 4); + } + + for (i = 0; i < order; i++) { + y = *spectrum; + acc = 0; + + for (j = i; j > 0; j--) { + acc = ixheaacd_add64( + acc, ixheaacd_mult64(ptr_filter_state[j - 1], lpc_coeff[j])); + ptr_filter_state[j] = ptr_filter_state[j - 1]; + } + + y = ixheaacd_sub32(y, (WORD32)(acc >> 31)); + ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); + *spectrum = y; + spectrum += inc; + } + + for (i = order; i < size; i++) { + y = *spectrum; + acc = 0; + for (j = order; j > 0; j--) { + acc = ixheaacd_add64( + acc, ixheaacd_mult64(ptr_filter_state[j - 1], lpc_coeff[j])); + ; + ptr_filter_state[j] = ptr_filter_state[j - 1]; + } + y = ixheaacd_sub32(y, (WORD32)(acc >> 31)); + ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); + *spectrum = y; + spectrum += inc; + } +} + +VOID ixheaacd_tns_apply(ia_usac_data_struct *usac_data, WORD32 *spec, + WORD32 nbands, ia_sfb_info_struct *pstr_sfb_info, + ia_tns_frame_info_struct *pstr_tns) { + WORD32 f, max_order, start, stop, size, inc; + WORD32 n_filt, coef_res, order, direction; + WORD32 *ptr_spec; + WORD32 scale_spec; + WORD32 scale_lpc; + WORD32 guard_band; + WORD32 shift; + WORD32 lpc_coeff[TNS_MAX_ORDER + 1]; + WORD32 par_coeff[TNS_MAX_ORDER + 1]; + ia_tns_filter_struct *filt; + + const WORD16 *sfb_top; + + WORD32 nbins = (pstr_sfb_info->islong) ? 1024 : 128; + WORD32 i, j, idx; + + max_order = (pstr_sfb_info->islong) ? 15 : 7; + idx = (pstr_sfb_info->islong) ? 0 : 1; + + ptr_spec = &usac_data->scratch_buffer[0]; + + for (j = 0; j < pstr_tns->n_subblocks; j++) { + sfb_top = pstr_sfb_info->ptr_sfb_tbl; + + for (i = 0; i < nbins; i++) { + ptr_spec[i] = spec[i]; + } + + if (pstr_tns->str_tns_info[j].n_filt) { + n_filt = pstr_tns->str_tns_info[j].n_filt; + + for (f = 0; f < n_filt; f++) { + WORD32 tmp; + + coef_res = pstr_tns->str_tns_info[j].coef_res; + filt = &pstr_tns->str_tns_info[j].str_filter[f]; + order = filt->order; + direction = filt->direction; + start = filt->start_band; + stop = filt->stop_band; + + if (order > max_order) { + fprintf(stderr, "Error in tns max order: %d %d\n", order, max_order); + } + + if (!order) continue; + + ixheaacd_tns_dec_coef_usac(usac_data, filt, coef_res, + (WORD32 *)par_coeff); + + ixheaacd_tns_parcor_lpc_convert_usac(par_coeff, lpc_coeff, &scale_lpc, + filt->order); + + tmp = (*usac_data->tns_max_bands_tbl_usac)[usac_data->sampling_rate_idx] + [idx]; + + start = ixheaacd_min32(start, tmp); + + start = ixheaacd_min32(start, nbands); + start = sfb_offset(start); + + stop = ixheaacd_min32(stop, tmp); + stop = ixheaacd_min32(stop, nbands); + stop = sfb_offset(stop); + + guard_band = 31 - ixheaacd_norm32(filt->order); + + if ((size = stop - start) <= 0) continue; + + if (direction) { + inc = -1; + shift = stop - 1; + } + + else { + inc = 1; + shift = start; + } + + { + WORD32 *ptr_temp = ptr_spec + start; + scale_spec = (*ixheaacd_calc_max_spectral_line)(ptr_temp, size); + } + + scale_spec = ((scale_spec - guard_band) - scale_lpc); + + if (scale_spec > 0) { + ixheaacd_tns_ar_filter_usac(&ptr_spec[shift], size, inc, lpc_coeff, + filt->order, scale_lpc, + usac_data->x_ac_dec); + } + + else { + WORD32 *ptr_temp = ptr_spec + start; + + scale_spec = -scale_spec; + scale_spec = ixheaacd_min32(scale_spec, 31); + + for (i = size; i != 0; i--) { + *ptr_temp = *ptr_temp >> scale_spec; + ptr_temp++; + } + + { + ixheaacd_tns_ar_filter_usac(&ptr_spec[shift], size, inc, lpc_coeff, + filt->order, scale_lpc, + usac_data->x_ac_dec); + } + + { + ptr_temp = ptr_spec + start; + i = size; + + do { + *ptr_temp = *ptr_temp << scale_spec; + ptr_temp++; + i--; + } while (i != 0); + } + } + + for (i = start; i <= stop - 1; i++) { + spec[i] = ptr_spec[i]; + } + } + } + + spec += pstr_sfb_info->bins_per_sbk; + } +} diff --git a/decoder/ixheaacd_tns.h b/decoder/ixheaacd_tns.h new file mode 100644 index 0000000..bbeecba --- /dev/null +++ b/decoder/ixheaacd_tns.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_TNS_H +#define IXHEAACD_TNS_H + +VOID ixheaacd_aac_tns_process( + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 num_ch, + ia_aac_dec_tables_struct *ptr_aac_tables, WORD object_type, WORD32 ar_flag, + WORD32 *predicted_spectrum); + +WORD16 ixheaacd_read_tns_data( + ia_bit_buf_struct *it_bit_buff, + ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info); + +WORD32 ixheaacd_calc_max_spectral_line_dec(WORD32 *ptr_tmp, WORD32 size); + +WORD32 ixheaacd_calc_max_spectral_line_armv7(WORD32 *ptr_tmp, WORD32 size); + +WORD32 ixheaacd_calc_max_spectral_line_armv8(WORD32 *ptr_tmp, WORD32 size); + +VOID ixheaacd_tns_decode_coef(const ia_filter_info_struct *filter, + WORD16 *parcor_coeff, + ia_aac_dec_tables_struct *ptr_aac_tables); + +VOID ixheaacd_tns_parcor_lpc_convert_dec(WORD16 *parcor, WORD16 *lpc, + WORD16 *scale, WORD order); + +void ixheaacd_tns_parcor_lpc_convert_dec_ld(WORD32 *parcor, WORD32 *lpc, + WORD16 *scale, WORD32 order); + +VOID ixheaacd_tns_parcor_lpc_convert_armv7(WORD16 *parcor, WORD16 *lpc, + WORD16 *scale, WORD order); + +VOID ixheaacd_tns_ar_filter_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD16 *lpc, WORD32 order, WORD32 shift_value, + WORD scale_spec, WORD32 *ptr_filter_state); + +void ixheaacd_tns_ma_filter_fixed_ld(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD32 *lpc, WORD32 order, + WORD16 shift_value); + +VOID ixheaacd_tns_ar_filter_armv7(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD16 *lpc, WORD32 order, WORD32 shift_value, + WORD scale_spec, WORD32 *ptr_filter_state); + +VOID ixheaacd_tns_decode_coefficients(const ia_filter_info_struct *filter, + WORD32 *a, + ia_aac_dec_tables_struct *ptr_aac_tables); +VOID ixheaacd_tns_parcor_to_lpc(WORD32 *parcor, WORD32 *lpc, WORD16 *scale, + WORD32 order); + +VOID ixheaacd_tns_ar_filter_fixed_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, + WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec); + +VOID ixheaacd_tns_ar_filter_fixed_armv7(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec); + +VOID ixheaacd_tns_ar_filter_fixed_armv8(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec); + +#endif /* #ifndef IXHEAACD_TNS_H */ diff --git a/decoder/ixheaacd_tns_usac.h b/decoder/ixheaacd_tns_usac.h new file mode 100644 index 0000000..daf18b0 --- /dev/null +++ b/decoder/ixheaacd_tns_usac.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_TNS_USAC_H +#define IXHEAACD_TNS_USAC_H + +#define TNS_MAX_BANDS 49 +#define TNS_MAX_ORDER 31 +#define TNS_MAX_WIN 8 +#define TNS_MAX_FILT 3 + +typedef struct { + WORD32 start_band; + WORD32 stop_band; + WORD32 order; + WORD32 direction; + WORD32 coef_compress; + WORD16 coef[TNS_MAX_ORDER]; + +} ia_tns_filter_struct; + +typedef struct { + WORD32 n_filt; + WORD32 coef_res; + ia_tns_filter_struct str_filter[TNS_MAX_FILT]; +} ia_tns_info_struct; + +typedef struct { + WORD32 n_subblocks; + ia_tns_info_struct str_tns_info[TNS_MAX_WIN]; +} ia_tns_frame_info_struct; + +#endif /* IXHEAACD_TNS_USAC_H */ diff --git a/decoder/ixheaacd_type_def.h b/decoder/ixheaacd_type_def.h new file mode 100644 index 0000000..1eabe93 --- /dev/null +++ b/decoder/ixheaacd_type_def.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_TYPE_DEF_H +#define IXHEAACD_TYPE_DEF_H + +/****************************************************************************/ +/* types type define prefix examples + * bytes */ +/************************ *********** ****** **************** ***** */ + +#define SIZE_T size_t + +typedef char CHAR8; /* c CHAR8 c_name 1 */ +typedef char* pCHAR8; /* pc pCHAR8 pc_nmae 1 */ + +typedef signed char WORD8; /* b WORD8 b_name 1 */ +typedef signed char* pWORD8; /* pb pWORD8 pb_nmae 1 */ + +typedef unsigned char + UWORD8; /* ub UWORD8 ub_count 1 */ +typedef unsigned char* + pUWORD8; /* pub pUWORD8 pub_count 1 */ + +typedef signed short WORD16; /* s WORD16 s_count 2 */ +typedef signed short* pWORD16; /* ps pWORD16 ps_count 2 */ +typedef unsigned short + UWORD16; /* us UWORD16 us_count 2 */ +typedef unsigned short* + pUWORD16; /* pus pUWORD16 pus_count 2 */ + +typedef signed int WORD24; /* k WORD24 k_count 3 */ +typedef signed int* pWORD24; /* pk pWORD24 pk_count 3 */ +typedef unsigned int + UWORD24; /* uk UWORD24 uk_count 3 */ +typedef unsigned int* + pUWORD24; /* puk pUWORD24 puk_count 3 */ + +typedef signed int WORD32; /* i WORD32 i_count 4 */ +typedef signed int* pWORD32; /* pi pWORD32 pi_count 4 */ +typedef unsigned int + UWORD32; /* ui UWORD32 ui_count 4 */ +typedef unsigned int* + pUWORD32; /* pui pUWORD32 pui_count 4 */ + +typedef signed long long + WORD40; /* m WORD40 m_count 5 */ +typedef signed long long* + pWORD40; /* pm pWORD40 pm_count 5 */ +typedef unsigned long long + UWORD40; /* um UWORD40 um_count 5 */ +typedef unsigned long long* + pUWORD40; /* pum pUWORD40 pum_count 5 */ + +typedef signed long long + WORD64; /* h WORD64 h_count 8 */ +typedef signed long long* + pWORD64; /* ph pWORD64 ph_count 8 */ +typedef unsigned long long + UWORD64; /* uh UWORD64 uh_count 8 */ +typedef unsigned long long* + pUWORD64; /* puh pUWORD64 puh_count 8 */ + +typedef float FLOAT32; /* f FLOAT32 f_count 4 + */ +typedef float* pFLOAT32; /* pf pFLOAT32 pf_count 4 */ +typedef double FLOAT64; /* d UFLOAT64 d_count 8 + */ +typedef double* pFlOAT64; /* pd pFLOAT64 pd_count 8 */ + +typedef void VOID; /* v VOID v_flag 4 */ +typedef void* pVOID; /* pv pVOID pv_flag 4 */ + +/* variable size types: platform optimized implementation */ +typedef signed int BOOL; /* bool BOOL bool_true */ +typedef unsigned int UBOOL; /* ubool BOOL ubool_true */ +typedef signed int FLAG; /* flag FLAG flag_false */ +typedef unsigned int UFLAG; /* uflag FLAG uflag_false */ +typedef signed int LOOPIDX; /* lp LOOPIDX lp_index */ +typedef unsigned int + ULOOPIDX; /* ulp SLOOPIDX ulp_index */ +typedef signed int WORD; /* lp LOOPIDX lp_index */ +typedef unsigned int + UWORD; /* ulp SLOOPIDX ulp_index */ + +typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */ +typedef ULOOPIDX ULOOPINDEX; /* ulp SLOOPIDX ulp_index */ + +#define PLATFORM_INLINE __inline + +#endif /* IXHEAACD_TYPE_DEF_H */ diff --git a/decoder/ixheaacd_vec_baisc_ops.h b/decoder/ixheaacd_vec_baisc_ops.h new file mode 100644 index 0000000..a71ccfd --- /dev/null +++ b/decoder/ixheaacd_vec_baisc_ops.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_VEC_BAISC_OPS_H +#define IXHEAACD_VEC_BAISC_OPS_H + +VOID ixheaacd_combine_fac(WORD32 *src1, WORD32 *src2, WORD32 *dest, WORD32 len, + WORD8 shift1, WORD8 shift2); + +WORD8 ixheaacd_windowing_long1(WORD32 *src1, WORD32 *src2, + const WORD32 *win_fwd, const WORD32 *win_rev, + WORD32 *dest, WORD32 vlen, WORD8 shift1, + WORD8 shift2); + +WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, + WORD32 *fac_data_out, WORD32 *over_lap, + WORD32 *p_out_buffer, + offset_lengths *ixheaacd_drc_offset, + WORD8 shift1, WORD8 shift2, WORD8 shift3); + +WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd, + WORD32 *over_lap, WORD32 *p_out_buffer, + const WORD32 *win_rev, + offset_lengths *ixheaacd_drc_offset, + WORD8 shift1, WORD8 shift2); + +VOID ixheaacd_windowing_short1(WORD32 *src1, WORD32 *src2, WORD32 *fp, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap); + +VOID ixheaacd_windowing_short2(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, + offset_lengths *ixheaacd_drc_offset, + WORD8 shiftp, WORD8 shift_olap); + +WORD8 ixheaacd_windowing_short3(WORD32 *src1, WORD32 *win_rev, WORD32 *fp, + WORD32 nshort, WORD8 shiftp, WORD8 shift_olap); + +WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, + WORD32 *win_fwd1, WORD32 nshort, WORD32 flag, + WORD8 shiftp, WORD8 shift_olap, WORD8 output_q); + +VOID ixheaacd_scale_down(WORD32 *dest, WORD32 *src, WORD32 len, WORD8 shift1, + WORD8 shift2); + +#endif diff --git a/decoder/ixheaacd_ver_number.h b/decoder/ixheaacd_ver_number.h new file mode 100644 index 0000000..b7d5435 --- /dev/null +++ b/decoder/ixheaacd_ver_number.h @@ -0,0 +1,26 @@ +/****************************************************************************** + * * + * 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 +*/ +#ifdef _ARM_ +#define xHE_AAC_DEC_ITTIAM_VER "_ARM $Rev: 1.36 $" +#elif _X86_ +#define xHE_AAC_DEC_ITTIAM_VER "_X86 $Rev: 1.36 $" +#else +#define xHE_AAC_DEC_ITTIAM_VER "_MSVC $Rev: 1.36 $" +#endif diff --git a/decoder/ixheaacd_windows.h b/decoder/ixheaacd_windows.h new file mode 100644 index 0000000..c93c0d0 --- /dev/null +++ b/decoder/ixheaacd_windows.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_WINDOWS_H +#define IXHEAACD_WINDOWS_H + +extern const WORD32 ixheaacd_sine_win_128[128]; +extern const WORD32 ixheaacd_sine_win_1024[1024]; +extern const WORD32 ixheaacd_sine_win_64[64]; +extern const WORD32 ixheaacd_sine_win_768[768]; +extern const WORD32 ixheaacd_sine_win_192[192]; +extern const WORD32 ixheaacd_sine_win_96[96]; +extern const WORD32 ixheaacd_sine_win_256[256]; +extern const WORD32 ixheaacd_kbd_win120[120]; +extern const WORD32 ixheaacd_kbd_win128[128]; +extern const WORD32 ixheaacd_kbd_win960[960]; +extern const WORD32 ixheaacd_kbd_win1024[1024]; +extern const WORD32 kbd_win256[256]; +extern const WORD32 ixheaacd_kbd_win4[4]; +extern const WORD32 ixheaacd_kbd_win16[16]; +extern const WORD32 ixheaacd_kbd_win_64[64]; +extern const WORD32 ixheaacd_kbd_win768[768]; +extern const WORD32 ixheaacd_kbd_win192[192]; +extern const WORD32 ixheaacd_kbd_win96[96]; +extern const WORD32 ixheaacd_kbd_win48[48]; + +extern const FLOAT32 ixheaacd_sine_window96[96]; +extern const FLOAT32 ixheaacd_sine_window128[128]; +extern const FLOAT32 ixheaacd_sine_window192[192]; +extern const FLOAT32 ixheaacd__sine_window256[256]; + +WORD32 ixheaacd_calc_window(WORD32 **win, WORD32 len, WORD32 wfun_select); + +void ixheaacd_acelp_imdct(WORD32 *imdct_in, WORD32 npoints, WORD8 *qshift, + WORD32 *scratch); + +typedef struct { + WORD32 lfac; + WORD32 n_flat_ls; + WORD32 n_trans_ls; + WORD32 n_long; + WORD32 n_short; + +} offset_lengths; + +#endif \ No newline at end of file diff --git a/decoder/x86/ixheaacd_basic_op.h b/decoder/x86/ixheaacd_basic_op.h new file mode 100644 index 0000000..0c3873d --- /dev/null +++ b/decoder/x86/ixheaacd_basic_op.h @@ -0,0 +1,28 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OP_H +#define IXHEAACD_BASIC_OP_H + +#define add_d(a, b) ((a) + (b)) +#define sub_d(a, b) ((a) - (b)) + +#define ixheaacd_cbrt_calc(a) cbrt(1.0f / a) + +#endif diff --git a/decoder/x86/ixheaacd_function_selector_x86.c b/decoder/x86/ixheaacd_function_selector_x86.c new file mode 100644 index 0000000..1501ae2 --- /dev/null +++ b/decoder/x86/ixheaacd_function_selector_x86.c @@ -0,0 +1,248 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_block.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_dsp_fft32x32s.h" + +WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_dec; + +VOID(*ixheaacd_covariance_matrix_calc) +(WORD32 *, ixheaacd_lpp_trans_cov_matrix *, + WORD32) = &ixheaacd_covariance_matrix_calc_dec; + +VOID(*ixheaacd_covariance_matrix_calc_2) +(ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, + WORD16) = &ixheaacd_covariance_matrix_calc_2_dec; + +VOID(*ixheaacd_over_lap_add1) +(WORD32 *, WORD32 *, WORD16 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add1_dec; + +VOID(*ixheaacd_over_lap_add2) +(WORD32 *, WORD32 *, WORD32 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add2_dec; + +VOID(*ixheaacd_decorr_filter2) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter2_dec; + +VOID(*ixheaacd_decorr_filter1) +(ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter1_dec; + +WORD32(*ixheaacd_divide16_pos) +(WORD32 op1, WORD32 op2) = &ixheaacd_divide16_pos_dec; + +VOID(*ixheaacd_decorrelation) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) = &ixheaacd_decorrelation_dec; + +VOID(*ixheaacd_apply_rot) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, WORD32 *p_qmf_left_im, + WORD32 *p_qmf_right_re, WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res) = &ixheaacd_apply_rot_dec; + +VOID(*ixheaacd_conv_ergtoamplitudelp) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitudelp_dec; + +VOID(*ixheaacd_conv_ergtoamplitude) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitude_dec; + +VOID(*ixheaacd_adjust_scale) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) = &ixheaacd_adjust_scale_dec; + +WORD16(*ixheaacd_ixheaacd_expsubbandsamples) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, + FLAG low_pow_flag) = &ixheaacd_expsubbandsamples_dec; + +VOID(*ixheaacd_enery_calc_per_subband) +(WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 frame_exp, WORD16 *nrg_est_mant, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) = &ixheaacd_enery_calc_per_subband_dec; + +VOID(*ixheaacd_harm_idx_zerotwolp) +(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) = &ixheaacd_harm_idx_zerotwolp_dec; + +VOID(*ixheaacd_tns_ar_filter_fixed) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_dec; + +VOID(*ixheaacd_tns_ar_filter) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec, + WORD32 *ptr_filter_state) = &ixheaacd_tns_ar_filter_dec; + +VOID(*ixheaacd_tns_parcor_lpc_convert) +(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, + WORD order) = &ixheaacd_tns_parcor_lpc_convert_dec; + +WORD32(*ixheaacd_calc_max_spectral_line) +(WORD32 *ptr_tmp, WORD32 size) = &ixheaacd_calc_max_spectral_line_dec; + +VOID(*ixheaacd_post_twiddle) +(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) = &ixheaacd_post_twiddle_dec; + +VOID(*ixheaacd_post_twid_overlap_add) +(WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) = &ixheaacd_post_twid_overlap_add_dec; + +VOID(*ixheaacd_neg_shift_spec) +(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) = &ixheaacd_neg_shift_spec_dec; + +VOID(*ixheaacd_spec_to_overlapbuf) +(WORD32 *ptr_overlap_buf, WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) = &ixheaacd_spec_to_overlapbuf_dec; + +VOID(*ixheaacd_overlap_buf_out) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac) = &ixheaacd_overlap_buf_out_dec; + +VOID(*ixheaacd_overlap_out_copy) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) = &ixheaacd_overlap_out_copy_dec; + +VOID(*ixheaacd_pretwiddle_compute) +(WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) = &ixheaacd_pretwiddle_compute_dec; + +VOID(*ixheaacd_imdct_using_fft) +(ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_dec; + +VOID(*ixheaacd_complex_fft_p2) +(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode, + WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec; + +VOID(*ixheaacd_mps_complex_fft_64) +(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im, + WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; + +VOID(*ixheaacd_mps_synt_pre_twiddle) +(WORD32 *ptr_in, WORD32 *table_re, 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 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; + +VOID(*ixheaacd_calc_pre_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec; + +VOID(*ixheaacd_calc_post_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + 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; + +VOID(*ixheaacd_mps_synt_out_calc) +(WORD32 resolution, WORD32 *out, WORD32 *state, + const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec; + +VOID(*ixheaacd_fft_15_ld) +(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr) = &ixheaacd_fft_15_ld_dec; + +VOID(*ixheaacd_aac_ld_dec_rearrange) +(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab) = &ixheaacd_rearrange_dec; + +VOID (*ixheaacd_fft32x32_ld) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = ixheaacd_fft32x32_ld_dec; + +VOID (*ixheaacd_fft32x32_ld2) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_fft32x32_ld_dec; + +WORD16 (*ixheaacd_neg_expo_inc)(WORD16 neg_expo) = &ixheaacd_neg_expo_inc_dec; + +VOID (*ixheaacd_inv_dit_fft_8pt) +(WORD32 *x, WORD32 *real, WORD32 *imag) = &ixheaacd_inv_dit_fft_8pt_dec; + +VOID (*ixheaacd_scale_factor_process) +(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_dec; \ No newline at end of file diff --git a/decoder/x86_64/ixheaacd_basic_op.h b/decoder/x86_64/ixheaacd_basic_op.h new file mode 100644 index 0000000..0c3873d --- /dev/null +++ b/decoder/x86_64/ixheaacd_basic_op.h @@ -0,0 +1,28 @@ +/****************************************************************************** + * * + * 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 IXHEAACD_BASIC_OP_H +#define IXHEAACD_BASIC_OP_H + +#define add_d(a, b) ((a) + (b)) +#define sub_d(a, b) ((a) - (b)) + +#define ixheaacd_cbrt_calc(a) cbrt(1.0f / a) + +#endif diff --git a/decoder/x86_64/ixheaacd_function_selector_x86_64.c b/decoder/x86_64/ixheaacd_function_selector_x86_64.c new file mode 100644 index 0000000..1501ae2 --- /dev/null +++ b/decoder/x86_64/ixheaacd_function_selector_x86_64.c @@ -0,0 +1,248 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_sbr_common.h" +#include + +#include "ixheaacd_constants.h" +#include +#include +#include +#include "ixheaacd_basic_ops.h" + +#include +#include "ixheaacd_intrinsics.h" +#include "ixheaacd_common_rom.h" +#include "ixheaacd_sbrdecsettings.h" +#include "ixheaacd_bitbuffer.h" +#include "ixheaacd_defines.h" + +#include "ixheaacd_pns.h" + +#include +#include "ixheaacd_aac_imdct.h" +#include "ixheaacd_pulsedata.h" + +#include "ixheaacd_drc_data_struct.h" + +#include "ixheaacd_lt_predict.h" + +#include "ixheaacd_channelinfo.h" +#include "ixheaacd_drc_dec.h" + +#include "ixheaacd_sbrdecoder.h" +#include "ixheaacd_tns.h" +#include "ixheaacd_sbr_scale.h" +#include "ixheaacd_lpp_tran.h" +#include "ixheaacd_env_extr_part.h" +#include +#include "ixheaacd_block.h" +#include "ixheaacd_hybrid.h" +#include "ixheaacd_ps_dec.h" +#include "ixheaacd_env_extr.h" +#include "ixheaacd_basic_funcs.h" +#include "ixheaacd_env_calc.h" +#include "ixheaacd_interface.h" +#include "ixheaacd_dsp_fft32x32s.h" + +WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_dec; + +VOID(*ixheaacd_covariance_matrix_calc) +(WORD32 *, ixheaacd_lpp_trans_cov_matrix *, + WORD32) = &ixheaacd_covariance_matrix_calc_dec; + +VOID(*ixheaacd_covariance_matrix_calc_2) +(ixheaacd_lpp_trans_cov_matrix *, WORD32 *, WORD32, + WORD16) = &ixheaacd_covariance_matrix_calc_2_dec; + +VOID(*ixheaacd_over_lap_add1) +(WORD32 *, WORD32 *, WORD16 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add1_dec; + +VOID(*ixheaacd_over_lap_add2) +(WORD32 *, WORD32 *, WORD32 *, const WORD16 *, WORD16, WORD16, + WORD16) = &ixheaacd_over_lap_add2_dec; + +VOID(*ixheaacd_decorr_filter2) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter2_dec; + +VOID(*ixheaacd_decorr_filter1) +(ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ps_tables_ptr, + WORD16 *transient_ratio) = &ixheaacd_decorr_filter1_dec; + +WORD32(*ixheaacd_divide16_pos) +(WORD32 op1, WORD32 op2) = &ixheaacd_divide16_pos_dec; + +VOID(*ixheaacd_decorrelation) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real, WORD32 *p_buf_left_imag, + WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag, + ia_ps_tables_struct *ps_tables_ptr) = &ixheaacd_decorrelation_dec; + +VOID(*ixheaacd_apply_rot) +(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re, WORD32 *p_qmf_left_im, + WORD32 *p_qmf_right_re, WORD32 *p_qmf_right_im, + ia_sbr_tables_struct *sbr_tables_ptr, + const WORD16 *ptr_res) = &ixheaacd_apply_rot_dec; + +VOID(*ixheaacd_conv_ergtoamplitudelp) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitudelp_dec; + +VOID(*ixheaacd_conv_ergtoamplitude) +(WORD32 bands, WORD16 noise_e, WORD16 *nrg_sine, WORD16 *nrg_gain, + WORD16 *noise_level_mant, + WORD16 *sqrt_table) = &ixheaacd_conv_ergtoamplitude_dec; + +VOID(*ixheaacd_adjust_scale) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, WORD32 shift, + FLAG low_pow_flag) = &ixheaacd_adjust_scale_dec; + +WORD16(*ixheaacd_ixheaacd_expsubbandsamples) +(WORD32 **re, WORD32 **im, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 start_pos, WORD32 next_pos, + FLAG low_pow_flag) = &ixheaacd_expsubbandsamples_dec; + +VOID(*ixheaacd_enery_calc_per_subband) +(WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, WORD32 sub_band_end, + WORD32 frame_exp, WORD16 *nrg_est_mant, FLAG low_pow_flag, + ia_sbr_tables_struct *ptr_sbr_tables, + WORD32 *ptr_qmf_matrix) = &ixheaacd_enery_calc_per_subband_dec; + +VOID(*ixheaacd_harm_idx_zerotwolp) +(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, WORD32 scale_change, + WORD16 *ptr_sine_level_buf, const WORD32 *ptr_rand_ph, + WORD16 *noise_level_mant, WORD32 num_sub_bands, FLAG noise_absc_flag, + WORD32 harm_index) = &ixheaacd_harm_idx_zerotwolp_dec; + +VOID(*ixheaacd_tns_ar_filter_fixed) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_dec; + +VOID(*ixheaacd_tns_ar_filter) +(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec, + WORD32 *ptr_filter_state) = &ixheaacd_tns_ar_filter_dec; + +VOID(*ixheaacd_tns_parcor_lpc_convert) +(WORD16 *parcor, WORD16 *lpc, WORD16 *scale, + WORD order) = &ixheaacd_tns_parcor_lpc_convert_dec; + +WORD32(*ixheaacd_calc_max_spectral_line) +(WORD32 *ptr_tmp, WORD32 size) = &ixheaacd_calc_max_spectral_line_dec; + +VOID(*ixheaacd_post_twiddle) +(WORD32 out_ptr[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, + WORD npoints) = &ixheaacd_post_twiddle_dec; + +VOID(*ixheaacd_post_twid_overlap_add) +(WORD16 pcm_out[], WORD32 spec_data[], + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, + WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, + WORD16 ch_fac) = &ixheaacd_post_twid_overlap_add_dec; + +VOID(*ixheaacd_neg_shift_spec) +(WORD32 *coef, WORD16 *out, WORD16 q_shift, + WORD16 ch_fac) = &ixheaacd_neg_shift_spec_dec; + +VOID(*ixheaacd_spec_to_overlapbuf) +(WORD32 *ptr_overlap_buf, WORD32 *ptr_spec_coeff, WORD32 q_shift, + WORD32 size) = &ixheaacd_spec_to_overlapbuf_dec; + +VOID(*ixheaacd_overlap_buf_out) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 size, + const WORD16 ch_fac) = &ixheaacd_overlap_buf_out_dec; + +VOID(*ixheaacd_overlap_out_copy) +(WORD16 *out_samples, WORD32 *ptr_overlap_buf, WORD32 *ptr_overlap_buf1, + const WORD16 ch_fac) = &ixheaacd_overlap_out_copy_dec; + +VOID(*ixheaacd_pretwiddle_compute) +(WORD32 *spec_data1, WORD32 *spec_data2, WORD32 *out_ptr, + ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints4, + WORD32 neg_expo) = &ixheaacd_pretwiddle_compute_dec; + +VOID(*ixheaacd_imdct_using_fft) +(ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_imdct_using_fft_dec; + +VOID(*ixheaacd_complex_fft_p2) +(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode, + WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec; + +VOID(*ixheaacd_mps_complex_fft_64) +(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im, + WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; + +VOID(*ixheaacd_mps_synt_pre_twiddle) +(WORD32 *ptr_in, WORD32 *table_re, 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 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; + +VOID(*ixheaacd_calc_pre_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec; + +VOID(*ixheaacd_calc_post_twid) +(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, + 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; + +VOID(*ixheaacd_mps_synt_out_calc) +(WORD32 resolution, WORD32 *out, WORD32 *state, + const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec; + +VOID(*ixheaacd_fft_15_ld) +(WORD32 *inp, WORD32 *op, WORD32 *fft3out, + UWORD8 *re_arr_tab_sml_240_ptr) = &ixheaacd_fft_15_ld_dec; + +VOID(*ixheaacd_aac_ld_dec_rearrange) +(WORD32 *ip, WORD32 *op, WORD32 mdct_len_2, + UWORD8 *re_arr_tab) = &ixheaacd_rearrange_dec; + +VOID (*ixheaacd_fft32x32_ld) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = ixheaacd_fft32x32_ld_dec; + +VOID (*ixheaacd_fft32x32_ld2) +(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, WORD32 npoints, + WORD32 *ptr_x, WORD32 *ptr_y) = &ixheaacd_fft32x32_ld_dec; + +WORD16 (*ixheaacd_neg_expo_inc)(WORD16 neg_expo) = &ixheaacd_neg_expo_inc_dec; + +VOID (*ixheaacd_inv_dit_fft_8pt) +(WORD32 *x, WORD32 *real, WORD32 *imag) = &ixheaacd_inv_dit_fft_8pt_dec; + +VOID (*ixheaacd_scale_factor_process) +(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width, + WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type, + WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_dec; \ No newline at end of file diff --git a/test/Android.bp b/test/Android.bp new file mode 100644 index 0000000..17910b6 --- /dev/null +++ b/test/Android.bp @@ -0,0 +1,31 @@ +cc_test { + name: "xaacdec", + + vendor_available: true, + vndk: { + enabled: true, + }, + + gtest: false, + + cflags: [ + "-O3", + "-fPIC", + "-mfloat-abi=softfp", + "-UARM_PROFILE_HW", + "-UARM_PROFILE_BOARD", + "-DECLIPSE", + "-DDRC_ENABLE", + "-DMULTICHANNEL_ENABLE" + ], + + include_dirs: [ + "external/libxaac/decoder/", + ], + + srcs: ["ixheaacd_error.c", "ixheaacd_fileifc.c", "ixheaacd_main.c", "ixheaacd_metadata_read.c" ], + + static_libs: ["libia_xaacdec"], + + shared_libs: ["liblog"], +} diff --git a/test/impd_drc_config_params.h b/test/impd_drc_config_params.h new file mode 100644 index 0000000..c0bd642 --- /dev/null +++ b/test/impd_drc_config_params.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * + * 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_CONFIG_PARAMS_H +#define IMPD_DRC_CONFIG_PARAMS_H + + +#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 +#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 +#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 +#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 +#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 +#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 +#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 +#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 +#define IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT 0x0008 +#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 +#define IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY 0x000A +#define IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY 0x000B +#define IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE 0x000C +#define IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF 0x000D +#define IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE 0x000E +#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F +#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 + + +#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 +#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 +#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 +#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A + + +#define IA_CMD_TYPE_INIT_CPY_BSF_BUFF 0x0201 +#define IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF 0x0202 +#define IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF 0x0203 +#define IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF 0x0205 + + +#define IA_CMD_TYPE_INIT_SET_BUFF_PTR 0x020B + +#endif diff --git a/test/ixheaacd_error.c b/test/ixheaacd_error.c new file mode 100644 index 0000000..8256af1 --- /dev/null +++ b/test/ixheaacd_error.c @@ -0,0 +1,325 @@ +/****************************************************************************** + * * + * 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 +#include +#include "ixheaacd_error_standards.h" +#include "ixheaacd_error_handler.h" + +/*****************************************************************************/ +/* Global memory constants */ +/*****************************************************************************/ +/*****************************************************************************/ +/* Ittiam enhaacplus_dec ErrorCode Definitions */ +/*****************************************************************************/ +/*****************************************************************************/ +/* Class 0: API Errors + */ +/*****************************************************************************/ +/* Non Fatal Errors */ +pWORD8 ixheaacd_ppb_api_non_fatal[] = { + (pWORD8) "No Error", (pWORD8) "API Command not supported", + (pWORD8) "API Command type not supported"}; +/* Fatal Errors */ +pWORD8 ixheaacd_ppb_api_fatal[] = { + (pWORD8) "Invalid Memory Table Index", + (pWORD8) "Invalid Library ID String Index", + (pWORD8) "NULL Pointer: Memory Allocation Error", + (pWORD8) "Invalid Config Param", + (pWORD8) "Invalid Execute type", + (pWORD8) "Invalid Command", + (pWORD8) "Memory Allocation Error: Alignment requirement not met"}; +/*****************************************************************************/ +/* Class 1: Configuration Errors + */ +/*****************************************************************************/ +/* Non Fatal Errors */ +pWORD8 ixheaacd_ppb_config_non_fatal[] = { + (pWORD8) "Invalid Output PCM WORD Size. Setting to default, 16 ", + (pWORD8) "Invalid Down-mix flag option. Setting to default, 0 ", + (pWORD8) "Invalid 8 khz output flag option. Setting to default, 0 ", + (pWORD8) "Invalid 16 khz output flag option. Setting to default, 0 ", + (pWORD8) "Invalid interleave to stereo flag option. Setting to default, 1 ", + (pWORD8) "Invalid downsample flag option. Setting to default, 0 ", + (pWORD8) "Invalid Frame OK option. Setting to default, 1 ", + (pWORD8) "Invalid MP4 Flag option. Setting to default, 0 ", + (pWORD8) "Invalid maximum number of channels. limiting to between 2 and 8", + (pWORD8) "Invalid instance for coupling channel. Setting to default 1", + (pWORD8) "Following feature is not supported in this build. ", + (pWORD8) "Invalid Disable Sync Flag option. Setting to default, 0 ", + (pWORD8) "Invalid Auto SBR upsample option. Setting to default, 1 ", + (pWORD8) "Invalid LOAS flag", + (pWORD8) "Invalid DRC flag", + (pWORD8) "Invalid DRC cut value", + (pWORD8) "Invalid DRC boost value", + (pWORD8) "Invalid DRC target", + (pWORD8) "Invalid Frame size", + (pWORD8) "Invalid delay mode", + (pWORD8) "Invalid decode type", + (pWORD8) "Invalid peak limiter flag", + (pWORD8) "Invalid control param index", + (pWORD8) "Inalid gain delay", + (pWORD8) "invalid constant delay mode"}; +/* Fatal Errors */ +pWORD8 ixheaacd_ppb_config_fatal[] = { + (pWORD8) "Invalid Sample rate specified for RAW decoding"}; +/*****************************************************************************/ +/* Class 2: Initialization Errors + */ +/*****************************************************************************/ +/* Non Fatal Errors */ +pWORD8 ixheaacd_ppb_init_non_fatal[] = { + (pWORD8)"Both 16 kHz and 8 kHz output config set. Giving 16 kHz output", + (pWORD8)"Output sampling frequency is 8 kHz, 16 kHz output disabled ", + (pWORD8)"Header not found at the beginning of input data continuing syncing" +}; +/* Fatal Errors */ +pWORD8 ixheaacd_ppb_init_fatal[] = { + (pWORD8) "AAC Decoder initialization failed", + (pWORD8) "End of input reached during initialization", + (pWORD8) "No. of channels in stream greater than max channels defined", + (pWORD8) "AudioObjectType is not supported"}; +/*****************************************************************************/ +/* Class 3: Execution Errors + */ +/*****************************************************************************/ +/* Non Fatal Errors */ +pWORD8 ixheaacd_ppb_exe_non_fatal[] = { + (pWORD8)"ADTS syncronization is lost. Re-syncing", + (pWORD8)"Though SBR was present in previous frame, not present in current frame (SBR turned off)", + (pWORD8)"SBR was not present in previous frame, but it is present in current frame (SBR turned on)", + (pWORD8)"ADTS Header CRC failed.Re-syncing", + (pWORD8)"Input bytes insufficient for decoding", + (pWORD8)"Element instance tag mismatch, because of new channel mode", + (pWORD8)"max huffman decoded value exceeded", + (pWORD8)"Error in AAC decoding", + (pWORD8)"Scale factor exceeds the transmitted boundary", + (pWORD8)"Gain control not supported", + (pWORD8)"Filter Order of TNS data is greater than maximum order", + (pWORD8)"LTP data found, not supported", + (pWORD8)"The base sampling frequency has changed in ADTS header", + (pWORD8)"Pulse Data exceeds the permitted boundary", + (pWORD8)"Invalid code ixheaacd_book number in ia_huffman_data_type decoding", +// (pWORD8)"The base sampling frequency has changed in ADTS header" +}; +/* Fatal Errors */ +pWORD8 ixheaacd_ppb_exe_fatal[] = { + (pWORD8) "Channel coupling not supported", + (pWORD8) "TNS data range is errorneous", (pWORD8) "Invalid LOAS header", + (pWORD8) "Invalid ER profile", (pWORD8) "Invalid DRC data"}; + +/*****************************************************************************/ +/* error info structure */ +/*****************************************************************************/ +/* The Module's Error Info Structure */ +ia_error_info_struct ixheaacd_error_info = { + /* The Module Name */ + (pWORD8) "Ittiam xheaac_dec", + {/* The Class Names */ + (pWORD8) "API", (pWORD8) "Configuration", (pWORD8) "Initialization", + (pWORD8) "Execution", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", + (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", + (pWORD8) "", (pWORD8) "", (pWORD8) "xHeaac"}, + {/* The Message Pointers */ + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL}}}; + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_error_handler_init */ +/* */ +/* Description : Initialize the error struct with string pointers */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : ia_error_info_struct ixheaacd_error_info */ +/* pWORD8 ixheaacd_ppb_api_non_fatal */ +/* pWORD8 ixheaacd_ppb_api_fatal */ +/* pWORD8 ixheaacd_ppb_config_non_fatal */ +/* pWORD8 ixheaacd_ppb_config_fatal */ +/* pWORD8 ixheaacd_ppb_init_non_fatal */ +/* pWORD8 ixheaacd_ppb_init_fatal */ +/* pWORD8 ixheaacd_ppb_exe_non_fatal */ +/* pWORD8 ixheaacd_ppb_exe_fatal */ +/* */ +/* Processing : Init the struct with error string pointers */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +VOID ixheaacd_error_handler_init() { + /* The Message Pointers */ + ixheaacd_error_info.ppppb_error_msg_pointers[0][0] = + ixheaacd_ppb_api_non_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[1][0] = ixheaacd_ppb_api_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[0][1] = + ixheaacd_ppb_config_non_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[1][1] = + ixheaacd_ppb_config_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[0][2] = + ixheaacd_ppb_init_non_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[1][2] = ixheaacd_ppb_init_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[0][3] = + ixheaacd_ppb_exe_non_fatal; + ixheaacd_error_info.ppppb_error_msg_pointers[1][3] = ixheaacd_ppb_exe_fatal; +} + +/*****************************************************************************/ +/* ia_testbench ErrorCode Definitions */ +/*****************************************************************************/ +/*****************************************************************************/ +/* Class 0: Memory & File Manager Errors + */ +/*****************************************************************************/ +/* Non Fatal Errors */ +/* Fatal Errors */ +pWORD8 ixheaacd_ppb_ia_testbench_mem_file_man_fatal[] = { + (pWORD8) "Memory Allocation Error", (pWORD8) "File Open Failed"}; + +/*****************************************************************************/ +/* error info structure */ +/*****************************************************************************/ +/* The Module's Error Info Structure */ +ia_error_info_struct ixheaacd_ia_testbench_error_info = { + /* The Module Name */ + (pWORD8) "ia_testbench", + {/* The Class Names */ + (pWORD8) "Memory & File Manager", (pWORD8) "", (pWORD8) "", (pWORD8) "", + (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", + (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", + (pWORD8) "", (pWORD8) ""}, + {/* The Message Pointers */ + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL}}}; + +/*****************************************************************************/ +/* */ +/* Function name : ia_testbench_error_handler_init */ +/* */ +/* Description : Initialize the error struct with string pointers */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : ia_error_info_struct ixheaacd_ia_testbench_error_info */ +/* pWORD8 ixheaacd_ppb_ia_testbench_mem_file_man_fatal */ +/* */ +/* Processing : Init the struct with error string pointers */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +VOID ia_testbench_error_handler_init() { + /* The Message Pointers */ + ixheaacd_ia_testbench_error_info.ppppb_error_msg_pointers[1][0] = + ixheaacd_ppb_ia_testbench_mem_file_man_fatal; +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_error_handler */ +/* */ +/* Description : Called Prints the status error code from the err_info */ +/* */ +/* Inputs : ia_error_info_struct *p_mod_err_info (Error info struct) */ +/* WORD8 *pb_context (Context of error) */ +/* IA_ERRORCODE code (Error code) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : whenever any module calls the errorhandler, it informs */ +/* it about the module for which it is called and a context */ +/* in which it was called in addition to the error_code */ +/* the message is displayed based on the module's error */ +/* message array that maps to the error_code the context */ +/* gives specific info in which the error occured e.g. for */ +/* testbench module, memory allocator can call the */ +/* errorhandler for memory inavailability in various */ +/* contexts like input_buf or output_buf e.g. for mp3_enc */ +/* module, there can be various instances running. context */ +/* can be used to identify the particular instance the */ +/* error handler is being called for */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Tejaswi/Vishal Created */ +/* */ +/*****************************************************************************/ + +IA_ERRORCODE ixheaacd_error_handler(ia_error_info_struct *p_mod_err_info, + WORD8 *pb_context, IA_ERRORCODE code) { + if (code == IA_NO_ERROR) { + return IA_NO_ERROR; + } + { + WORD is_fatal = (((UWORD)code & 0x8000) >> 15); + WORD err_class = (((UWORD)code & 0x7800) >> 11); + WORD err_sub_code = (((UWORD)code & 0x07FF)); + + if (!is_fatal) { + printf("non "); + } + printf("fatal error: "); + + if (p_mod_err_info->pb_module_name != NULL) { + printf("%s: ", p_mod_err_info->pb_module_name); + } + if (p_mod_err_info->ppb_class_names[err_class] != NULL) { + printf("%s: ", p_mod_err_info->ppb_class_names[err_class]); + } + if (pb_context != NULL) { + printf("%s: ", pb_context); + } + if (err_sub_code != 2047) + printf("%s\n", + p_mod_err_info + ->ppppb_error_msg_pointers[is_fatal][err_class][err_sub_code]); + } + return IA_NO_ERROR; +} diff --git a/test/ixheaacd_fileifc.c b/test/ixheaacd_fileifc.c new file mode 100644 index 0000000..8a5b13b --- /dev/null +++ b/test/ixheaacd_fileifc.c @@ -0,0 +1,172 @@ +/****************************************************************************** + * * + * 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 +#include +#ifndef CORTEX_M4 +#include +#else +#include "cm4_file_operations.h" +#endif +#include + +#include "ixheaacd_fileifc.h" +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +//#define INCLUDE_MP4_PARSER + +FileWrapperPtr FileWrapper_Open(char fileName[]) { + FileWrapperPtr transport = (FileWrapper *)calloc(1, sizeof(FileWrapper)); + + transport->isMp4File = 0; + transport->inputFile = NULL; + +#ifdef INCLUDE_MP4_PARSER + + transport->header_given = 0; + transport->fileCtxt = 0; + transport->mp4Ctxt = 0; + transport->interim_buffer = 0; + transport->avail_buffer = 0; + + if ((transport->fileCtxt = it_fopen((void *)fileName, 1, 0)) == NULL) { + transport->inputFile = fopen(fileName, "rb"); + if (!transport->inputFile) + return 0; + else + return transport; + } + + if ((transport->mp4Ctxt = it_mp4_parser_init(transport->fileCtxt, NULL)) == + NULL) { + transport->inputFile = fopen(fileName, "rb"); + if (!transport->inputFile) + return 0; + else + return transport; + } + transport->isMp4File = 1; + /* 768 * max channels is the max audio block size for AAC */ + /* As max channels is 8 and +2 for upto two Ind CoupCh */ + transport->interim_buffer = malloc(10 * 768); + if (transport->interim_buffer == NULL) { + return 0; + } + return transport; +#else + transport->inputFile = fopen(fileName, "rb"); + if (!transport->inputFile) + return 0; + else + return transport; +#endif +} + +int FileWrapper_Read(FileWrapperPtr transport, unsigned char *buffer, + int bufSize, unsigned int *length) { +#ifdef INCLUDE_MP4_PARSER + if (!transport->isMp4File) + *length = fread(buffer, 1, bufSize, transport->inputFile); + else { + int errorCode; + if (transport->header_given == 0) { + transport->headerCtxt.header = (void *)buffer; + /* MP4 Hook: Audio Header data to be put in buffer pointed by + // headerCtxt.header and length to be put in headerCtxt.headerLength*/ + errorCode = + it_mp4_get_audio_header(transport->mp4Ctxt, &transport->headerCtxt); + transport->header_given = 1; + if (errorCode != 0) /* IT_OK = 0 */ + { + *length = 0; + return 1; + } + *length = transport->headerCtxt.headerLength; + } else { + *length = 0; +/* MP4 Hook: Audio Data to be put in buffer pointed by frameCtxt.header*/ +#ifndef ENABLE_LD_DEC + while ((int)*length < bufSize) +#endif + { + if (transport->avail_buffer == 0) { + transport->frameCtxt.frame = (void *)transport->interim_buffer; + errorCode = + it_mp4_get_audio(transport->mp4Ctxt, &transport->frameCtxt); + if (errorCode != 0) /* IT_OK = 0 */ + { + if (*length == 0) + return 1; + else +#ifndef ENABLE_LD_DEC + break; +#else + return 1; +#endif + } + transport->avail_buffer += transport->frameCtxt.frameLength; + } +#ifndef ENABLE_LD_DEC + else +#endif + { + int size_to_cpy = + min((int)(bufSize - *length), transport->avail_buffer); + memcpy(buffer + (*length), transport->interim_buffer, size_to_cpy); + memmove(transport->interim_buffer, + ((char *)transport->interim_buffer) + size_to_cpy, + (transport->avail_buffer - size_to_cpy)); + *length += size_to_cpy; + transport->avail_buffer -= size_to_cpy; + } + } + } +#ifdef DEBUG_ASSERT + assert(*length <= (unsigned)bufSize); +#endif + } + +#else + *length = fread(buffer, 1, bufSize, transport->inputFile); +#endif + + return 0; +} + +unsigned int FileWrapper_Close(FileWrapperPtr transport) { + if (transport == 0) return 0; + +#ifdef INCLUDE_MP4_PARSER + if (transport->isMp4File) { + it_mp4_parser_close(transport->mp4Ctxt); + it_fclose(transport->fileCtxt); + } else +#endif + if (transport->inputFile) + fclose(transport->inputFile); + + free(transport); + return 0; +} + +unsigned int FileWrapper_IsMp4File(FileWrapperPtr transport) { + return transport->isMp4File; +} diff --git a/test/ixheaacd_fileifc.h b/test/ixheaacd_fileifc.h new file mode 100644 index 0000000..6997c25 --- /dev/null +++ b/test/ixheaacd_fileifc.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * * + * 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 __fileifc_h__ +#define __fileifc_h__ + +#ifndef INCLUDE_MP4_PARSER +//#define INCLUDE_MP4_PARSER +#endif +#ifdef INCLUDE_MP4_PARSER +/* Context structure for media frame*/ +typedef struct { + unsigned char *frame; + unsigned int frameLength; + unsigned int presentationTime; +} ItMp4FrameCtxt; + +/* Context structure for media header*/ +typedef struct { + unsigned char *header; + unsigned int headerLength; +} ItMp4HeaderCtxt; +#endif + +typedef struct FileWrapper { +#ifdef INCLUDE_MP4_PARSER + + void *mp4Ctxt; + void *fileCtxt; + void *interim_buffer; + int avail_buffer; + ItMp4HeaderCtxt headerCtxt; + ItMp4FrameCtxt frameCtxt; + int header_given; +#endif + /* MPEG_2_PROFILE profile; */ + unsigned int isMp4File; + FILE *inputFile; + +} FileWrapper, *FileWrapperPtr; + +FileWrapperPtr FileWrapper_Open(char fileName[]); +int FileWrapper_Read(FileWrapperPtr transport, unsigned char *buffer, + int bufSize, unsigned int *len); +unsigned int FileWrapper_Close(FileWrapperPtr transport); + +unsigned int FileWrapper_IsMp4File(FileWrapperPtr transport); + +/* MP4 function declarations */ + +/*File Initialization, File Header Parsing*/ +void *it_mp4_parser_init(void *mp4Ctxt, void *mallocAddr); + +/*Extracts audio header from file*/ +int it_mp4_get_audio_header(void *mp4Ctxt, void *audioheader); + +/*Extracts an audio frame from the file */ +int it_mp4_get_audio(void *mp4Ctxt, void *frameCtxt); + +/*Frees allocated memory*/ +int it_mp4_parser_close(void *mp4); + +void *it_fopen(unsigned char *file_name, unsigned char withFile, int size); +int it_fclose(void *itf); +#endif diff --git a/test/ixheaacd_main.c b/test/ixheaacd_main.c new file mode 100644 index 0000000..ed53e53 --- /dev/null +++ b/test/ixheaacd_main.c @@ -0,0 +1,2247 @@ +/****************************************************************************** + * * + * 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 +#include +#include + +#define AOSP_CHANGE + +#include "ixheaacd_fileifc.h" +#include +#include "ixheaacd_error_standards.h" +#include "ixheaacd_error_handler.h" +#include "ixheaacd_apicmd_standards.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_aac_config.h" +#include "ixheaacd_metadata_read.h" +#include "impd_drc_config_params.h" + +IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, + pVOID pv_value); + +#ifdef ENABLE_DRC +IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, + pVOID pv_value); +#endif + +VOID ixheaacd_error_handler_init(); +VOID ia_testbench_error_handler_init(); + +extern ia_error_info_struct ixheaacd_ia_testbench_error_info; +extern ia_error_info_struct ixheaacd_error_info; + +/*****************************************************************************/ +/* Process select hash defines */ +/*****************************************************************************/ +#define WAV_HEADER +#define DISPLAY_MESSAGE + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +#define MAX_STACK_PROC 10 +#define MAX_MEM_ALLOCS 100 +#define IA_MAX_CMD_LINE_LENGTH 300 +#define IA_MAX_ARGS 20 +#define IA_SCREEN_WIDTH 80 +#define PARAMFILE "paramfilesimple.txt" + +/*****************************************************************************/ +/* Error codes for the testbench */ +/*****************************************************************************/ +#define IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED 0xFFFF8000 +#define IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED 0xFFFF8001 + +#define IA_HE_AAC_DEC_TABLE_RELOCATABLE_ENABLE 0 + +#ifdef ARM_PROFILE_HW +#include +#define CLK_FREQ_BOARD_MHZ 716 // a9 omap4430 board +//#define CLK_FREQ_BOARD_MHZ 1555 //Nexus6P +//#define CLK_FREQ_BOARD_MHZ 2035 //Tegra Board +//#define CLK_FREQ_BOARD_MHZ 550 //a8 board +//#define CLK_FREQ_BOARD_MHZ 297 //dm365 board +//#define CLK_FREQ_BOARD_MHZ 1209.6 //a5 board +#endif +#ifdef ARM_PROFILE_HW +long long itGetMs(void) { + struct timeval t; + long long currTime; + + if (gettimeofday(&t, NULL) == -1) { + printf("Error in gettimeofday. It has returned -1. \n"); + } + currTime = ((t.tv_sec * 1000 * 1000) + (t.tv_usec)); + return currTime; +} +#endif +/*****************************************************************************/ +/* Global variables */ +/*****************************************************************************/ +pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; +WORD g_w_malloc_count; +FILE *g_pf_out; +FileWrapperPtr g_pf_inp; /* file pointer to bitstream file (mp4) */ + +#ifdef ENABLE_DRC +FILE *g_pf_interface; +WORD32 interface_file_present = 0; +#endif + +metadata_info meta_info; // metadata pointer; +WORD32 ixheaacd_i_bytes_to_read; +FILE *g_pf_meta; + +WORD32 raw_testing = 0; +WORD32 eld_testing = 0; + +#define _IA_PRINT_ERROR(p_mod_err_info, context, e) \ + if ((e) != IA_NO_ERROR) { \ + ixheaacd_error_handler((p_mod_err_info), (context), (e)); \ + } + +#ifndef WIN32 +int ia_fwrite(pVOID buffer[], int size, int nwords, FILE *fp) { + int i, j; + pWORD8 pb_buf = (pWORD8)buffer; + + for (i = 0; i < nwords; i++) { + for (j = 0; j < size; j++) { + putc(pb_buf[i * size + j], fp); + } + } + return 1; +} + +#endif + +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_write16_bits_lh */ +/* */ +/* Description : write 16 bits low high (always little endian) */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; */ +/* WORD g_w_malloc_count; */ +/* FILE *g_pf_inp, *g_pf_out; */ +/* */ +/* Processing : write 16 bits low high (always little endian) */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +static VOID ixheaacd_write16_bits_lh(FILE *fp, WORD32 i) { + putc(i & 0xff, fp); + putc((i >> 8) & 0xff, fp); +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_write32_bits_lh */ +/* */ +/* Description : write 32 bits low high (always little endian) */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : FILE* fp (file to write) */ +/* WORD32 i (value to write) */ +/* */ +/* Processing : write 32 bits low high (always little endian) */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +static VOID ixheaacd_write32_bits_lh(FILE *fp, WORD32 i) { + ixheaacd_write16_bits_lh(fp, (WORD32)(i & 0xffffL)); + ixheaacd_write16_bits_lh(fp, (WORD32)((i >> 16) & 0xffffL)); +} + +/*****************************************************************************/ +/* */ +/* Function name : write_wav_header */ +/* */ +/* Description : Write wav header to a wav file */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : FILE* fp (file to write) */ +/* WORD32 pcmbytes (total bytes in wav file) */ +/* WORD32 freq (sampling freq) */ +/* WORD32 channels (output channels) */ +/* WORD32 bits (bits per sample) */ +/* */ +/* Processing : Write wav header */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +WORD32 write_wav_header(FILE *fp, WORD32 pcmbytes, WORD32 freq, WORD32 channels, + WORD32 bits, WORD32 i_channel_mask) { + if (channels > 2) { + WORD32 bytes = (bits + 7) / 8; + fwrite("RIFF", 1, 4, fp); /* label */ + ixheaacd_write32_bits_lh( + fp, pcmbytes + 44 - 8); /* length in bytes without header */ + fwrite("WAVEfmt ", 2, 4, fp); /* 2 labels */ + /* tag for WAVE_FORMAT_EXTENSIBLE */ + if (channels > 2) { + ixheaacd_write16_bits_lh(fp, 0x28); + ixheaacd_write16_bits_lh(fp, 0x00); + ixheaacd_write16_bits_lh(fp, 0xfffe); + } else { + ixheaacd_write32_bits_lh( + fp, 2 + 2 + 4 + 4 + 2 + 2); /* length of PCM format decl area */ + ixheaacd_write16_bits_lh(fp, 1); /* is pcm? */ + } + + ixheaacd_write16_bits_lh(fp, channels); + ixheaacd_write32_bits_lh(fp, freq); + ixheaacd_write32_bits_lh(fp, freq * channels * bytes); /* bps */ + ixheaacd_write16_bits_lh(fp, channels * bytes); + ixheaacd_write16_bits_lh(fp, bits); + + /* tag for WAVE_FORMAT_EXTENSIBLE */ + if (channels > 2) { + ixheaacd_write16_bits_lh(fp, 0x16); + ixheaacd_write16_bits_lh(fp, 0x10); /*Samples.wReserved*/ + ixheaacd_write32_bits_lh(fp, i_channel_mask); /* dwChannelMask */ + + ixheaacd_write32_bits_lh(fp, 0x0001); /* SubFormat.Data1 */ + ixheaacd_write32_bits_lh( + fp, 0x00100000); /* SubFormat.Data2 and SubFormat.Data3 */ + + ixheaacd_write16_bits_lh(fp, 0x0080); + ixheaacd_write16_bits_lh(fp, 0xAA00); + + ixheaacd_write16_bits_lh(fp, 0x3800); + ixheaacd_write16_bits_lh(fp, 0x719b); + } + + fwrite("data", 1, 4, fp); + ixheaacd_write32_bits_lh(fp, pcmbytes); + + return (ferror(fp) ? -1 : 0); + + } else { + WORD32 bytes = (bits + 7) / 8; + fwrite("RIFF", 1, 4, fp); /* label */ + ixheaacd_write32_bits_lh( + fp, pcmbytes + 44 - 8); /* length in bytes without header */ + fwrite("WAVEfmt ", 2, 4, fp); /* 2 labels */ + ixheaacd_write32_bits_lh( + fp, 2 + 2 + 4 + 4 + 2 + 2); /* length of PCM format decl area */ + ixheaacd_write16_bits_lh(fp, 1); /* is pcm? */ + ixheaacd_write16_bits_lh(fp, channels); + ixheaacd_write32_bits_lh(fp, freq); + ixheaacd_write32_bits_lh(fp, freq * channels * bytes); /* bps */ + ixheaacd_write16_bits_lh(fp, channels * bytes); + ixheaacd_write16_bits_lh(fp, bits); + fwrite("data", 1, 4, fp); + ixheaacd_write32_bits_lh(fp, pcmbytes); + + return (ferror(fp) ? -1 : 0); + } +} +#endif /* WAV_HEADER */ +#endif /*ARM_PROFILE_BOARD*/ + +#ifdef DISPLAY_MESSAGE + +/*****************************************************************************/ +/* */ +/* Function name : ia_display_id_message */ +/* */ +/* Description : Display the ID message of the process */ +/* */ +/* Inputs : WORD8 lib_name[] (library name) */ +/* WORD8 lib_version[] (library version) */ +/* WORD8 api_version[] (API version) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Display all the information about the process */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Tejaswi/Vishal Created */ +/* */ +/*****************************************************************************/ + +VOID ia_display_id_message(WORD8 lib_name[], WORD8 lib_version[]) { + WORD8 str[4][IA_SCREEN_WIDTH] = {"ITTIAM SYSTEMS PVT LTD, BANGALORE\n", + "http:\\\\www.ittiam.com\n", "", ""}; + WORD8 spaces[IA_SCREEN_WIDTH / 2 + 1]; + WORD32 i, spclen; + + strcpy((pCHAR8)str[2], (pCHAR8)lib_name); + strcat((pCHAR8)str[2], (pCHAR8)lib_version); + strcat((pCHAR8)str[2], "\n"); + strcat((pCHAR8)str[4 - 1], "\n"); + + for (i = 0; i < IA_SCREEN_WIDTH / 2 + 1; i++) { + spaces[i] = ' '; + } + + for (i = 0; i < 4; i++) { + spclen = IA_SCREEN_WIDTH / 2 - strlen((pCHAR8)str[i]) / 2; + spaces[spclen] = '\0'; + printf("%s", (pCHAR8)spaces); + spaces[spclen] = ' '; + printf("%s", (pCHAR8)str[i]); + } +} +#endif /* DISPLAY_MESSAGE */ + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_set_config_param */ +/* */ +/* Description : Set config parameters */ +/* */ +/* Inputs : pVOID p_ia_process_api_obj (process API obj) */ +/* WORD32 argc (Arguments count) */ +/* pWORD8 argv[] (Argument strings) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Set config params inside API */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], + pVOID p_ia_process_api_obj) { + LOOPIDX i; + IA_ERRORCODE err_code = IA_NO_ERROR; + /* the process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) = + ixheaacd_dec_api; + ia_error_info_struct *p_proc_err_info = &ixheaacd_error_info; + + for (i = 0; i < argc; i++) { + /* PCM WORD Size (For single input file) */ + if (!strncmp((pCHAR8)argv[i], "-pcmsz:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_pcm_wd_sz = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ, &ui_pcm_wd_sz); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Down-mix stereo to mono. */ + if (!strncmp((pCHAR8)argv[i], "-dmix:", 6)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 6); + UWORD32 ui_down_mix = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX, &ui_down_mix); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#ifdef RESAMPLE_SUPPORT + /* Resample the output to 8 kHz. */ + if (!strncmp((pCHAR8)argv[i], "-f08:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_08khz_out = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT08KHZ, &ui_08khz_out); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Resample the output to 16 kHz. */ + if (!strncmp((pCHAR8)argv[i], "-f16:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_16khz_out = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT16KHZ, &ui_16khz_out); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + /* Interleave mono output to stereo */ + if (!strncmp((pCHAR8)argv[i], "-tostereo:", 10)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 10); + UWORD32 ui_to_stereo = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO, &ui_to_stereo); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Downsampled synthesis to be used */ + if (!strncmp((pCHAR8)argv[i], "-dsample:", 9)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 9); + UWORD32 ui_dsample = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE, &ui_dsample); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-mp4:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_mp4_flag = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4, &ui_mp4_flag); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + +#ifdef HEAACV2_AS_AACLC + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-aac_lc_only:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_aac_lc_only = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_AAC_ONLY, &ui_aac_lc_only); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + +#ifdef LATM_LOAS + /* To indicate if its a LOAS file or not. */ + if (!strncmp((pCHAR8)argv[i], "-isLOAS:", 8)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 8); + UWORD32 ui_loas_flag = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS, &ui_loas_flag); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + +#endif + +#ifdef DRC_ENABLE + if (!strncmp((pCHAR8)argv[i], "-drc:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_cut_fac:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_boost_fac:", 15)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 15); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_target_level:", 18)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 18); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_heavy_comp:", 16)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 16); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + +#endif + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-nosync:", 8)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 8); + UWORD32 ui_disable_sync = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC, &ui_disable_sync); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate SBR upsampling. */ + if (!strncmp((pCHAR8)argv[i], "-sbrup:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_auto_sbr_upsample = atoi(pb_arg_val); + err_code = + (*p_ia_process_api)(p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE, + &ui_auto_sbr_upsample); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate sample rate for a RAW bit-stream. */ + if (!strncmp((pCHAR8)argv[i], "-fs:", 4)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 4); + UWORD32 ui_samp_freq = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ, &ui_samp_freq); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate the number of maximum channels */ + if (!strncmp((pCHAR8)argv[i], "-maxchannel:", 12)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 12); + UWORD32 ui_max_channel = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL, &ui_max_channel); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* To indicate the number of coupling channels to be used for coupling */ + if (!strncmp((pCHAR8)argv[i], "-coupchannel:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_coupling_channel = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL, &ui_coupling_channel); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* Down-mix N.1 to stereo */ + if (!strncmp((pCHAR8)argv[i], "-downmix:", 9)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 9); + UWORD32 ui_downmix = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO, &ui_downmix); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* For LD files, to indicate */ + if (!strncmp((pCHAR8)argv[i], "-fs480:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_fs480 = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE, &ui_fs480); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + + return IA_NO_ERROR; +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_get_config_param */ +/* */ +/* Description : Get config parameters */ +/* */ +/* Inputs : pVOID p_ia_process_api_obj (process API obj) */ +/* pWORD32 pi_samp_freq (Ptr for samp freq param) */ +/* pWORD32 pi_num_chan (Ptr for num chan param) */ +/* pWORD32 pi_pcm_wd_sz (Ptr for PCM WORD size param) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Get config params from API */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +IA_ERRORCODE ixheaacd_get_config_param(pVOID p_ia_process_api_obj, + pWORD32 pi_samp_freq, + pWORD32 pi_num_chan, + pWORD32 pi_pcm_wd_sz, + pWORD32 pi_channel_mask) { + IA_ERRORCODE err_code = IA_NO_ERROR; + /* the process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) = + ixheaacd_dec_api; + ia_error_info_struct *p_proc_err_info = &ixheaacd_error_info; + + /* Sampling frequency */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ, pi_samp_freq); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Total Number of Channels */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS, pi_num_chan); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* PCM word size */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ, pi_pcm_wd_sz); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* channel mask to tell the arrangement of channels in bit stream */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK, pi_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* Channel mode to tell MONO/STEREO/DUAL-MONO/NONE_OF_THESE */ + { + UWORD32 ui_channel_mode; + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE, &ui_channel_mode); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_channel_mode == 0) + printf("Channel Mode: MONO_OR_PS\n"); + else if (ui_channel_mode == 1) + printf("Channel Mode: STEREO\n"); + else if (ui_channel_mode == 2) + printf("Channel Mode: DUAL-MONO\n"); + else + printf("Channel Mode: NONE_OF_THESE or MULTICHANNEL\n"); + } + + /* Channel mode to tell SBR PRESENT/NOT_PRESENT */ + { + UWORD32 ui_sbr_mode; + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &ui_sbr_mode); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_sbr_mode == 0) + printf("SBR Mode: NOT_PRESENT\n"); + else if (ui_sbr_mode == 1) + printf("SBR Mode: UPSAMPLING FACTOR 2 or 8/3\n"); + else if (ui_sbr_mode == 2) + printf("SBR Mode: ILLEGAL\n"); + else if (ui_sbr_mode == 3) + printf("ESBR Mode: UPSAMPLING FACTOR 4\n"); + else + printf("ui_sbr_mode not vaild\n"); + } + return IA_NO_ERROR; +} + +int counter_bl; +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_main_process */ +/* */ +/* Description : Stacked processing with function pointer selection */ +/* */ +/* Inputs : WORD32 argc (Arguments count) */ +/* pWORD8 argv[] (Argument strings) */ +/* */ +/* Globals : pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; */ +/* WORD g_w_malloc_count; */ +/* FILE *g_pf_inp, *g_pf_out; */ +/* */ +/* Processing : Stacked processing of multiple components */ +/* Loop1: Set params + Mem alloc */ +/* Loop2: Set params + Init process + Get params */ +/* Loop3: Execute */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Tejaswi/Vishal Created */ +/* */ +/*****************************************************************************/ + +int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { + LOOPIDX i; + WORD frame_counter = 0; +#ifdef DISPLAY_MESSAGE + /* Library Info and Identification strings */ + WORD8 pb_process_name[IA_SCREEN_WIDTH] = ""; + WORD8 pb_lib_version[IA_SCREEN_WIDTH] = ""; +#endif + + /* Error code */ + IA_ERRORCODE err_code = IA_NO_ERROR; + IA_ERRORCODE err_code_reinit = IA_NO_ERROR; + + /* API obj */ + pVOID pv_ia_process_api_obj; + +#ifdef ENABLE_DRC + pVOID pv_ia_drc_process_api_obj; + UWORD32 pui_api_size; +#endif + +/* First part */ +/* Error Handler Init */ +/* Get Library Name, Library Version and API Version */ +/* Initialize API structure + Default config set */ +/* Set config params from user */ +/* Initialize memory tables */ +/* Get memory information and allocate memory */ + +#ifdef ENABLE_DRC + UWORD8 drc_ip_buf[8192 * 2]; + UWORD8 drc_op_buf[8192 * 2]; +#endif + + /* Memory variables */ + UWORD32 n_mems, ui_rem; + UWORD32 ui_proc_mem_tabs_size; + /* API size */ + UWORD32 pui_ap_isize; + /* Process initing done query variable */ + UWORD32 ui_init_done, ui_exec_done; + pWORD8 pb_inp_buf = 0, pb_out_buf = 0; + + // pWORD16 litt2big; + + UWORD32 ui_inp_size = 0; + WORD32 i_bytes_consumed, i_bytes_read; + WORD32 i_buff_size; + WORD32 prev_sampling_rate = 0; + WORD32 skip_samples = 0; + WORD32 total_samples = 0; + WORD32 write_flag = 1; + WORD32 bytes_to_write = 0; + WORD32 ixheaacd_drc_offset = 0; + WORD32 current_samples = 0; + WORD32 samples_written = 0; + WORD32 init_iteration = 1; + +#ifdef ARM_PROFILE_HW + int frame_count_b = 0; + long long cycles_b = 0; + long long start1_b, stop1_b; + double Curr_b, Ave_b = 0, Sum_b = 0; + double Peak_b = 0; + WORD32 Peak_frame_b = 0; +#endif + WORD32 i_out_bytes, i_total_bytes = 0; + WORD32 i_samp_freq, i_num_chan, i_pcm_wd_sz, i_channel_mask; + +#ifdef ENABLE_DRC + WORD32 drc_flag = 0; + WORD32 mpegd_drc_present = 0; + WORD32 uo_num_chan; +#endif + + /* The process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); + + /* The set config from argc argv */ + IA_ERRORCODE(*p_set_config_param) + (WORD32 argc, pWORD8 argv[], pVOID p_ia_process_api_obj); + + /* The get config from API */ + IA_ERRORCODE(*p_get_config_param) + (pVOID p_ia_process_api_obj, pWORD32 pi_samp_freq, pWORD32 pi_num_chan, + pWORD32 pi_pcm_wd_sz, pWORD32 pi_channel_mask); + + /* The error init function */ + VOID (*p_error_init)(); + + /* The process error info structure */ + ia_error_info_struct *p_proc_err_info; + + /* Process struct initing */ + p_ia_process_api = ixheaacd_dec_api; + p_set_config_param = ixheaacd_set_config_param; + p_get_config_param = ixheaacd_get_config_param; + p_error_init = ixheaacd_error_handler_init; + p_proc_err_info = &ixheaacd_error_info; + /* Process struct initing end */ + + /* ******************************************************************/ + /* Initialize the error handler */ + /* ******************************************************************/ + (*p_error_init)(); + +/* ******************************************************************/ +/* Get the library name, library version and API version */ +/* ******************************************************************/ + +#ifdef DISPLAY_MESSAGE + /* Get the library name string */ + err_code = (*p_ia_process_api)(NULL, IA_API_CMD_GET_LIB_ID_STRINGS, + IA_CMD_TYPE_LIB_NAME, pb_process_name); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get the library version string */ + err_code = (*p_ia_process_api)(NULL, IA_API_CMD_GET_LIB_ID_STRINGS, + IA_CMD_TYPE_LIB_VERSION, pb_lib_version); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Display the ittiam identification message */ + ia_display_id_message(pb_process_name, pb_lib_version); +#endif + + /* ******************************************************************/ + /* Initialize API structure and set config params to default */ + /* ******************************************************************/ + + /* Get the API size */ + err_code = + (*p_ia_process_api)(NULL, IA_API_CMD_GET_API_SIZE, 0, &pui_ap_isize); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Allocate memory for API */ + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(pui_ap_isize + 4); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "API struct alloc", err_code); + } + + /* API object requires 4 bytes (WORD32) alignment */ + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); + /* Set API object with the memory allocated */ + pv_ia_process_api_obj = + (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem); + + g_w_malloc_count++; + + /* Set the config params to default values */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef ENABLE_DRC + /*ITTIAM: Get API size for DRC*/ + + /* Get the API size */ + err_code = ia_drc_dec_api(NULL, IA_API_CMD_GET_API_SIZE, 0, &pui_api_size); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Allocate memory for API */ + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(pui_api_size + 4); + memset(g_pv_arr_alloc_memory[g_w_malloc_count], 0, pui_api_size); + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "API struct alloc", err_code); + } + + /* API object requires 4 bytes (WORD32) alignment */ + ui_rem = ((SIZE_T)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); + /* Set API object with the memory allocated */ + pv_ia_drc_process_api_obj = + (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem); + + g_w_malloc_count++; + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#endif + + /* ******************************************************************/ + /* Set config parameters got from the user present in argc argv */ + /* ******************************************************************/ + + err_code = (*p_set_config_param)(argc, argv, pv_ia_process_api_obj); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +/* ******************************************************************/ +/* Table Relocatibility */ +/* ******************************************************************/ +#if IA_HE_AAC_DEC_TABLE_RELOCATABLE_ENABLE + + /* Get number of tables required */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_GET_N_TABLES, + 0, &n_mems); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (i = 0; i < (WORD32)n_mems; i++) { + int ui_size, ui_alignment; + pVOID pv_alloc_ptr = NULL, pv_curr_ptr = NULL; + LOOPIDX k; + + /* Get table size */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_INFO_SIZE, i, &ui_size); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get table alignment */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_INFO_ALIGNMENT, i, + &ui_alignment); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_size + ui_alignment); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem for table relocation alloc", + IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED); + } + + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] % ui_alignment); + pv_alloc_ptr = (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + + ui_alignment - ui_rem); + + g_w_malloc_count++; + + /* Get the current table pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_PTR, i, &pv_curr_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (k = 0; k < ui_size; k++) { + ((pWORD8)pv_alloc_ptr)[k] = ((pWORD8)pv_curr_ptr)[k]; + /* Disabled for multiple files running +((pWORD8)pv_curr_ptr)[k] = (WORD8)0xab; */ + } + + /* Set the relocated table pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_TABLE_PTR, i, pv_alloc_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + /* ******************************************************************/ + /* Initialize Memory info tables */ + /* ******************************************************************/ + + /* Get memory info tables size */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_GET_MEMTABS_SIZE, 0, + &ui_proc_mem_tabs_size); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_proc_mem_tabs_size + 4); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem tables alloc", err_code); + } + + /* API object requires 4 bytes (WORD32) alignment */ + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); + + /* Set pointer for process memory tables */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_MEMTABS_PTR, 0, + (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem)); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_w_malloc_count++; + + /* initialize the API, post config, fill memory tables */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* ******************************************************************/ + /* Allocate Memory with info from library */ + /* ******************************************************************/ + + /* Get number of memory tables required */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_N_MEMTABS, 0, &n_mems); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (i = 0; i < (WORD32)n_mems; i++) { + int ui_size, ui_alignment, ui_type; + pVOID pv_alloc_ptr; + + /* Get memory size */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory alignment */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, + &ui_alignment); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory type */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, &i_num_chan, + &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /*if (ui_type == IA_MEMTYPE_OUTPUT) { + if (i_pcm_wd_sz == 16) + ui_size = 11 * 2048 * sizeof(WORD16); + else + ui_size = 11 * 2048 * 3 * sizeof(WORD8); + }*/ + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_size + ui_alignment); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem tables alloc", err_code); + } + + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] % ui_alignment); + pv_alloc_ptr = (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + + ui_alignment - ui_rem); + + g_w_malloc_count++; + + /* Set the buffer pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_type == IA_MEMTYPE_INPUT) { + pb_inp_buf = pv_alloc_ptr; + ui_inp_size = ui_size; + } + if (ui_type == IA_MEMTYPE_OUTPUT) { + pb_out_buf = pv_alloc_ptr; + } + } + + /* End first part */ + + /* Second part */ + /* Initialize process */ + /* Get config params */ + + /* ******************************************************************/ + /* Initialize process in a loop (to handle junk data at beginning) */ + /* ******************************************************************/ + + i_bytes_consumed = ui_inp_size; + i_buff_size = ui_inp_size; + + do { + i_bytes_read = 0; + + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - + i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + /* Tell input is over, if algorithm returns with insufficient input and + there is no + more input left in the bitstream*/ + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) + + { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + /* ******************************************************************/ + /* Get config params from API */ + /* ******************************************************************/ + + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // This is done in those cases, where file decodes ends at init time + // Since init is incomplete, sampling freq might be zero and will result + // in + // writing invalid wave header + + if (i_samp_freq == 0) i_samp_freq = prev_sampling_rate; + + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + return 1; + } + + if (init_iteration == 1) { + if (raw_testing) + ixheaacd_i_bytes_to_read = get_metadata_dec_info_init(meta_info); + else + ixheaacd_i_bytes_to_read = i_buff_size; + + /* Set number of bytes to be processed */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + init_iteration++; + + } else { + if (raw_testing) { + ixheaacd_i_bytes_to_read = + get_metadata_dec_exec(meta_info, frame_counter); + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + } else { + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } + } + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Initialize the process */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_PROCESS, NULL); + err_code_reinit = err_code; + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Checking for end of initialization */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_DONE_QUERY, &ui_init_done); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* How much buffer is used in input buffers */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, + &i_bytes_consumed); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + } while (!ui_init_done); + +#ifdef ENABLE_DRC + if (interface_file_present == 1) { + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, &i_num_chan, + &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Sampling Frequency */ + { + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ, &i_samp_freq); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Total Number of Channels */ + { + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &i_num_chan); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* PCM word size */ + { + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ, &i_pcm_wd_sz); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get number of memory tables required */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_GET_N_MEMTABS, 0, &n_mems); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (i = 0; i < (WORD32)n_mems - 2; i++) { + WORD32 ui_size, ui_alignment, ui_type; + pVOID pv_alloc_ptr; + + /* Get memory size */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory alignment */ + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, &ui_alignment); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory type */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_size + ui_alignment); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem tables alloc", err_code); + } + + ui_rem = ((SIZE_T)g_pv_arr_alloc_memory[g_w_malloc_count] % ui_alignment); + pv_alloc_ptr = (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + + ui_alignment - ui_rem); + + g_w_malloc_count++; + + /* Set the buffer pointer */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_MEM_PTR, + 2, drc_ip_buf); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_MEM_PTR, + 3, drc_op_buf); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /*ITTIAM: DRC buffers + buf[0] - contains extension element pay load loudness related + buf[1] - contains extension element pay load*/ + { + VOID *p_array[2][16]; + WORD32 ii; + WORD32 buf_sizes[2][16]; + WORD32 num_elements; + WORD32 num_config_ext; + WORD32 bit_str_fmt = 1; + + memset(buf_sizes, 0, 32 * sizeof(WORD32)); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES, &buf_sizes[0][0]); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR, &p_array); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_SET_BUFF_PTR, 0); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE, &num_elements); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT, &num_config_ext); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (ii = 0; ii < num_config_ext; ii++) { + /*copy loudness bitstream*/ + if (buf_sizes[0][ii] > 0) { + memcpy(drc_ip_buf, p_array[0][ii], buf_sizes[0][ii]); + + /*Set bitstream_split_format */ + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt); + + /* Set number of bytes to be processed */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES_IL_BS, 0, + &buf_sizes[0][ii]); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Execute process */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + drc_flag = 1; + } + } + + for (ii = 0; ii < num_elements; ii++) { + /*copy config bitstream*/ + if (buf_sizes[1][ii] > 0) { + memcpy(drc_ip_buf, p_array[1][ii], buf_sizes[1][ii]); + /* Set number of bytes to be processed */ + + /*Set bitstream_split_format */ + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt); + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES_IC_BS, 0, + &buf_sizes[1][ii]); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Execute process */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + drc_flag = 1; + } + } + + if (drc_flag == 1) { + mpegd_drc_present = 1; + } else { + mpegd_drc_present = 0; + } + + /*Read interface buffer config file bitstream*/ + { + WORD32 interface_is_present = 1; + + i_bytes_read = fread(drc_ip_buf, sizeof(WORD8), 16384, g_pf_interface); + + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT, &interface_is_present); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Set number of bytes to be processed */ + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES_IN_BS, 0, &i_bytes_read); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Execute process */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_PROCESS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &uo_num_chan); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + } +#endif + + /* ******************************************************************/ + /* Get config params from API */ + /* ******************************************************************/ + + err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + if (raw_testing) { + skip_samples = get_start_offset_in_samples(meta_info); + if (eld_testing == 0) total_samples = get_play_time_in_samples(meta_info); + } + +/* End second part */ + +#ifdef WAV_HEADER +// This condition is added so as to avoid re-writing wave header in +// middle of wave file in case of errors and when we are not opening +// new file in case of errors. + +#ifndef ARM_PROFILE_BOARD + + write_wav_header(g_pf_out, 0, i_samp_freq, i_num_chan, i_pcm_wd_sz, + i_channel_mask); +#endif +#endif + prev_sampling_rate = i_samp_freq; + + do { + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } +#ifdef ENABLE_LD_DEC + if (0 != frame_counter) { +#endif + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - + i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); +#ifdef ENABLE_LD_DEC + } else + i_bytes_read = 0; +#endif + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { + i_buff_size = 0; + raw_testing = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + + if (raw_testing) { + ixheaacd_i_bytes_to_read = + get_metadata_dec_exec(meta_info, frame_counter); + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + } else { + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef ARM_PROFILE_HW + start1_b = itGetMs(); +#endif + + /* Execute process */ + + counter_bl = frame_counter; + + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_EXECUTE, + IA_CMD_TYPE_DO_EXECUTE, NULL); + + err_code_reinit = err_code; + +#ifdef ARM_PROFILE_HW + stop1_b = itGetMs(); + cycles_b = (stop1_b - start1_b); +#endif + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Checking for end of processing */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_EXECUTE, + IA_CMD_TYPE_DONE_QUERY, &ui_exec_done); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef ENABLE_DRC + if (interface_file_present == 1) { + if (ui_exec_done != 1) { + VOID *p_array; // ITTIAM:buffer to handle gain payload + WORD32 buf_size = 0; // ITTIAM:gain payload length + WORD32 bit_str_fmt = 1; + WORD32 gain_stream_flag = 1; + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN, &buf_size); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF, &p_array); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + if (buf_size > 0) { + /*Set bitstream_split_format */ + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt); + + memcpy(drc_ip_buf, p_array, buf_size); + /* Set number of bytes to be processed */ + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES_BS, 0, &buf_size); + + err_code = ia_drc_dec_api( + pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG, &gain_stream_flag); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Execute process */ + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_CPY_BSF_BUFF, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + mpegd_drc_present = 1; + } + } + } +#endif + /* How much buffer is used in input buffers */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, + &i_bytes_consumed); + + // printf("bytes_consumed: %d \n", i_bytes_consumed); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get the output bytes */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_OUTPUT_BYTES, 0, &i_out_bytes); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + if (err_code_reinit != 0) memset(pb_out_buf, 0, i_out_bytes); + + i_total_bytes += i_out_bytes; + +#ifdef ENABLE_DRC + if (mpegd_drc_present == 1) { + memcpy(drc_ip_buf, pb_out_buf, i_out_bytes); + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, &i_out_bytes); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_EXECUTE, + IA_CMD_TYPE_DO_EXECUTE, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + memcpy(pb_out_buf, drc_op_buf, i_out_bytes); + } + +#endif + + if (total_samples != 0) // Usac stream + { + if (raw_testing) { + if (i_total_bytes <= skip_samples * i_num_chan * (i_pcm_wd_sz >> 3)) { + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + + write_flag = 0; + } else { + write_flag = 1; + bytes_to_write = + i_total_bytes - skip_samples * i_num_chan * (i_pcm_wd_sz >> 3); + if (bytes_to_write < i_out_bytes) { + ixheaacd_drc_offset = i_out_bytes - bytes_to_write; + i_out_bytes = bytes_to_write; + current_samples = + bytes_to_write / (i_num_chan * (i_pcm_wd_sz >> 3)); + } else { + ixheaacd_drc_offset = 0; + current_samples = i_out_bytes / (i_num_chan * (i_pcm_wd_sz >> 3)); + } + } + } + + if (raw_testing) { + samples_written += current_samples; + + if (samples_written > total_samples) { + i_out_bytes = (total_samples - (samples_written - current_samples)) * + (i_num_chan * (i_pcm_wd_sz >> 3)); // hack + if (i_out_bytes < 0) i_out_bytes = 0; + } + } + } + + if (write_flag) { +#ifndef WIN32 +#ifndef ARM_PROFILE_BOARD + ia_fwrite((pVOID)(pb_out_buf + ixheaacd_drc_offset), (i_pcm_wd_sz / 8), + i_out_bytes / (i_pcm_wd_sz / 8), g_pf_out); +#endif +#else +#ifndef ARM_PROFILE_BOARD + fwrite(pb_out_buf + ixheaacd_drc_offset, sizeof(WORD8), i_out_bytes, + g_pf_out); + fflush(g_pf_out); +#endif +#endif + } + + if (i_out_bytes) { + frame_counter++; + } + +#ifdef _DEBUG + if (frame_counter == 80) frame_counter = frame_counter; +// ui_exec_done=1; +// frame_counter = frame_counter; + +// printf("frame_counter = %d\n", frame_counter); +#endif + +#ifdef ARM_PROFILE_HW + if (i_out_bytes != 0) { + int i_out_samples = i_out_bytes >> 2; + if (frame_count_b) { + double i_out_samples_per_ch = + (i_out_bytes) / ((i_pcm_wd_sz / 8) * i_num_chan); + Curr_b = (((double)cycles_b / 1000000) * CLK_FREQ_BOARD_MHZ) / + (i_out_samples_per_ch / i_samp_freq); + frame_count_b++; + // fprintf(stderr, "Microseconds: %d\t", cycles_b); + // fprintf(stderr, "MCPS: %f\n", Curr_b); + Sum_b += Curr_b; + Ave_b = Sum_b / frame_count_b; + if (Peak_b < Curr_b) { + Peak_b = Curr_b; + Peak_frame_b = frame_count_b; + } + } else { + frame_count_b++; + } + + cycles_b = 0; + } +#endif + + /* Do till the process execution is done */ + } while (!ui_exec_done); + +#ifdef ARM_PROFILE_HW + fprintf(stdout, "\n Peak MCPS = %f\n", Peak_b); + fprintf(stdout, " Avg MCPS = %f\n", Ave_b); + fprintf(stdout, " Peak frame = %d\n", Peak_frame_b); +#endif + fprintf(stderr, "TOTAL FRAMES : [%5d] \n", frame_counter); + + err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + + return IA_NO_ERROR; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ixheaacd_main */ +/* */ +/* Description : Main function */ +/* */ +/* Inputs : None */ +/* */ +/* Globals : None */ +/* */ +/* Processing : Parse the parameter file and run the ixheaacd_main process + */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on success, -1 on error */ +/* */ +/* Issues : None */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 04 09 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +void print_usage() { + printf("\n Usage \n"); + printf("\n -ifile: -ofile: [options]\n"); + printf("\n[options] can be,"); + printf("\n[-pcmsz:]"); + printf("\n[-dmix:]"); +#ifdef RESAMPLE_SUPPORT + /* By default not available */ + printf("\n[-f08:]"); + printf("\n[-f16:]"); +#endif + printf("\n[-tostereo:]"); + printf("\n[-dsample:]"); + printf("\n[-fs:]"); + printf("\n[-nosync:]"); + printf("\n[-sbrup:]"); + + printf("\n[-maxchannel:]"); +#ifdef MULTICHANNEL_ENABLE + printf("\n[-coupchannel:]"); + printf("\n[-downmix:]"); +#endif + + printf("\n\nwhere, \n is the input AAC file name"); + printf("\n is the output file name"); + printf("\n is the bits per sample info. Only 16 is valid"); + + printf("\n is to enable/disable always mono output. Default 0"); +#ifdef RESAMPLE_SUPPORT + printf("\n is to enable/disable 8 kHz output. Default 0 "); + printf("\n is to enable/disable 16 kHz output. Default 0 "); +#endif + printf("\n is to enable/disable always "); + printf("\n interleaved to stereo output. Default 1 "); + printf("\n is to enable/disable down-sampled SBR "); + printf("\n output. Default auto identification from header"); + printf("\n is to indicate the core AAC sample rate for"); + printf("\n a RAW stream. If this is specified no other file format"); + printf("\n headers are searched for. \n"); + printf("\n is to disable the ADTS/ADIF sync search i.e"); + printf("\n when enabled the decoder expects the header to "); + printf("\n be at the start of input buffer. Default 0"); + printf( + "\n is to enable(1) or disable(0) auto SBR " + "upsample "); + printf( + "\n in case of stream changing from SBR present to SBR not present. " + "Default 1"); + printf("\n is the number of maxiumum "); + printf("\n channels the input may have. Default is 6 (5.1)"); + +#ifdef MULTICHANNEL_ENABLE + printf("\n is element instance tag of "); + printf("\n independent coupling channel to be mixed. Default is 0"); + printf("\n is flag for Downmix. Give 1 to"); + printf("\n get stereo (downmix) output. Default is 0"); +#endif +} + +/*******************************************************************************/ +/* */ +/* Function Name : ixheaacd_main */ +/* */ +/* Description : Main function */ +/* */ +/* Inputs : None */ +/* */ +/* Globals : None */ +/* */ +/* Processing : Parse the parameter file and run the ixheaacd_main_process + */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on success, -1 on error */ +/* */ +/* Issues : None */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 04 09 2005 Ittiam Created */ +/* */ +/*******************************************************************************/ + +int main(WORD32 argc, char *argv[]) { + FILE *param_file_id; + + WORD8 curr_cmd[IA_MAX_CMD_LINE_LENGTH]; + WORD32 fargc, curpos; + WORD32 processcmd = 0; + + WORD8 fargv[IA_MAX_ARGS][IA_MAX_CMD_LINE_LENGTH]; + + pWORD8 pargv[IA_MAX_ARGS]; + + WORD8 pb_input_file_path[IA_MAX_CMD_LINE_LENGTH] = ""; + WORD8 pb_output_file_path[IA_MAX_CMD_LINE_LENGTH] = ""; + + ia_testbench_error_handler_init(); + + if (argc == 1) { + param_file_id = fopen(PARAMFILE, "r"); + if (param_file_id == NULL) { + print_usage(); + return IA_NO_ERROR; + } + + /* Process one line at a time */ + while (fgets((char *)curr_cmd, IA_MAX_CMD_LINE_LENGTH, param_file_id)) { + curpos = 0; + fargc = 0; + /* if it is not a param_file command and if */ + /* CLP processing is not enabled */ + if (curr_cmd[0] != '@' && !processcmd) { /* skip it */ + continue; + } + + while (sscanf((char *)curr_cmd + curpos, "%s", fargv[fargc]) != EOF) { + if (fargv[0][0] == '/' && fargv[0][1] == '/') break; + if (strcmp((const char *)fargv[0], "@echo") == 0) break; + if (strcmp((const char *)fargv[fargc], "@New_line") == 0) { + fgets((char *)curr_cmd + curpos, IA_MAX_CMD_LINE_LENGTH, + param_file_id); + continue; + } + curpos += strlen((const char *)fargv[fargc]); + while (*(curr_cmd + curpos) == ' ' || *(curr_cmd + curpos) == '\t') + curpos++; + fargc++; + } + + if (fargc < 1) /* for blank lines etc. */ + continue; + + if (strcmp((const char *)fargv[0], "@Output_path") == 0) { + if (fargc > 1) + strcpy((char *)pb_output_file_path, (const char *)fargv[1]); + else + strcpy((char *)pb_output_file_path, ""); + continue; + } + + if (strcmp((const char *)fargv[0], "@Input_path") == 0) { + if (fargc > 1) + strcpy((char *)pb_input_file_path, (const char *)fargv[1]); + else + strcpy((char *)pb_input_file_path, ""); + continue; + } + + if (strcmp((const char *)fargv[0], "@Start") == 0) { + processcmd = 1; + continue; + } + + if (strcmp((const char *)fargv[0], "@Stop") == 0) { + processcmd = 0; + continue; + } + + /* otherwise if this a normal command and its enabled for execution */ + if (processcmd) { + int i; + int err_code = IA_NO_ERROR; + int file_count = 0; + + for (i = 0; i < fargc; i++) { + printf("%s ", fargv[i]); + pargv[i] = fargv[i]; + + if (!strncmp((const char *)fargv[i], "-ifile:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_input_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_input_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_input_file_name, (const char *)pb_arg_val); + + g_pf_inp = NULL; + g_pf_inp = FileWrapper_Open((char *)pb_input_file_name); + + if (g_pf_inp == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input File", err_code); + exit(1); + } + file_count++; + raw_testing = 0; + } + + if (!strncmp((const char *)fargv[i], "-imeta:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_metadata_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_metadata_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_metadata_file_name, (const char *)pb_arg_val); + + g_pf_meta = NULL; + g_pf_meta = fopen((const char *)pb_metadata_file_name, "r"); + + if (g_pf_meta == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Metadata File", err_code); + exit(1); + } + + metadata_info_init(&meta_info); + err_code = ixheaacd_read_metadata_info(g_pf_meta, &meta_info); + + if (err_code == -1) exit(1); + + raw_testing = 1; + + file_count++; + } + + if (!strncmp((const char *)fargv[i], "-ofile:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_output_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_output_file_name, + (const char *)pb_output_file_path); + strcat((char *)pb_output_file_name, (const char *)pb_arg_val); + + g_pf_out = NULL; + g_pf_out = fopen((const char *)pb_output_file_name, "wb"); + if (g_pf_out == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Output File", err_code); + exit(1); + } + file_count++; + } +#ifdef ENABLE_DRC + if (!strncmp((const char *)fargv[i], "-infile:", 8)) { + pWORD8 pb_arg_val = fargv[i] + 8; + WORD8 pb_interface_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_interface_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_interface_file_name, (const char *)pb_arg_val); + + g_pf_interface = NULL; + g_pf_interface = fopen((const char *)pb_interface_file_name, "rb"); + + if (g_pf_interface == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "DRC Interface File", err_code); + exit(1); + } + interface_file_present = 1; + file_count++; + } +#endif + } + g_w_malloc_count = 0; + + printf("\n"); + +#ifdef ENABLE_DRC + if (file_count != 4 && file_count != 3 && file_count != 2) +#else + if (file_count != 3 && file_count != 2) +#endif + { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input or Output File", err_code); + } + + if (err_code == IA_NO_ERROR) { + if (g_pf_inp->isMp4File == 1) { + strcpy((pCHAR8)fargv[fargc], "-mp4:1"); + pargv[fargc] = fargv[fargc]; + fargc++; + } + + for (i = 0; i < fargc; i++) { + if (strcmp((pCHAR8)fargv[i], "-eld_testing:1")) + eld_testing = 0; + else { + eld_testing = 1; + break; + } + } + + ixheaacd_main_process(fargc, pargv); + } + + for (i = 0; i < g_w_malloc_count; i++) { + if (g_pv_arr_alloc_memory[i]) free(g_pv_arr_alloc_memory[i]); + } + if (g_pf_out) fclose(g_pf_out); + + if (g_pf_meta) { + raw_testing = 0; + fclose(g_pf_meta); + memset_metadata(meta_info); + } + FileWrapper_Close(g_pf_inp); + +#ifdef ENABLE_DRC + if (g_pf_interface) { + fclose(g_pf_interface); + interface_file_present = 0; + } +#endif + } + } + } else { + int i; + int err_code = IA_NO_ERROR; + int file_count = 0; + + for (i = 1; i < argc; i++) { + pargv[i] = fargv[i]; + strcpy((pCHAR8)fargv[i], (pCHAR8)argv[i]); + printf("%s ", pargv[i]); + + if (!strncmp((const char *)pargv[i], "-ifile:", 7)) { + pWORD8 pb_arg_val = pargv[i] + 7; + WORD8 pb_input_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + err_code = IA_NO_ERROR; + strcat((char *)pb_input_file_name, (const char *)pb_input_file_path); + strcat((char *)pb_input_file_name, (const char *)pb_arg_val); + + g_pf_inp = NULL; + g_pf_inp = FileWrapper_Open((char *)pb_input_file_name); + if (g_pf_inp == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input File", err_code); + exit(1); + } + file_count++; + raw_testing = 0; + } + + if (!strncmp((const char *)fargv[i], "-imeta:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_metadata_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_metadata_file_name, (const char *)pb_input_file_path); + strcat((char *)pb_metadata_file_name, (const char *)pb_arg_val); + + g_pf_meta = NULL; + g_pf_meta = fopen((const char *)pb_metadata_file_name, "r"); + + if (g_pf_meta == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Metadata File", err_code); + exit(1); + } + + metadata_info_init(&meta_info); + err_code = ixheaacd_read_metadata_info(g_pf_meta, &meta_info); + + if (err_code == -1) { + exit(1); + } + + raw_testing = 1; + + file_count++; + } + + if (!strncmp((const char *)pargv[i], "-ofile:", 7)) { + pWORD8 pb_arg_val = pargv[i] + 7; + WORD8 pb_output_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_output_file_name, (const char *)pb_output_file_path); + strcat((char *)pb_output_file_name, (const char *)pb_arg_val); + + g_pf_out = NULL; + g_pf_out = fopen((const char *)pb_output_file_name, "wb"); + if (g_pf_out == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Output File", err_code); + exit(1); + } + file_count++; + } + +#ifdef ENABLE_DRC + if (!strncmp((const char *)fargv[i], "-infile:", 8)) { + pWORD8 pb_arg_val = fargv[i] + 8; + WORD8 pb_interface_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_interface_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_interface_file_name, (const char *)pb_arg_val); + + g_pf_interface = NULL; + g_pf_interface = fopen((const char *)pb_interface_file_name, "rb"); + + if (g_pf_interface == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "DRC Interface File", err_code); + exit(1); + } + interface_file_present = 1; + file_count++; + } +#endif + } + g_w_malloc_count = 0; + + printf("\n"); + +#ifdef ENABLE_DRC + if (file_count != 4 && file_count != 3 && file_count != 2) +#else + if (file_count != 2 && file_count != 3) +#endif + { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input or Output File", err_code); + } + + if (err_code == IA_NO_ERROR) { + if (g_pf_inp->isMp4File == 1) { + strcpy((pCHAR8)fargv[argc], "-mp4:1"); + pargv[argc] = fargv[argc]; + argc++; + } + + for (i = 0; i < argc; i++) { + if (strcmp((pCHAR8)fargv[i], "-eld_testing:1")) + eld_testing = 0; + else { + eld_testing = 1; + break; + } + } + + ixheaacd_main_process(argc - 1, &pargv[1]); + } + + for (i = 0; i < g_w_malloc_count; i++) { + if (g_pv_arr_alloc_memory[i]) free(g_pv_arr_alloc_memory[i]); + } + if (g_pf_out) fclose(g_pf_out); + + if (g_pf_meta) { + fclose(g_pf_meta); + memset_metadata(meta_info); + } + FileWrapper_Close(g_pf_inp); +#ifdef ENABLE_DRC + if (g_pf_interface) { + fclose(g_pf_interface); + interface_file_present = 0; + } +#endif + } + + return IA_NO_ERROR; +} /* end ixheaacd_main */ diff --git a/test/ixheaacd_main_flush_csd.c b/test/ixheaacd_main_flush_csd.c new file mode 100644 index 0000000..a67b1a3 --- /dev/null +++ b/test/ixheaacd_main_flush_csd.c @@ -0,0 +1,2477 @@ +/*****************************************************************************/ +/* */ +/* Enhanced aacPlus Decoder */ +/* */ +/* ITTIAM SYSTEMS PVT LTD, BANGALORE */ +/* COPYRIGHT(C) 2004 */ +/* */ +/* This program is proprietary to Ittiam Systems Pvt. Ltd. and is protected */ +/* under Indian Copyright Act as an unpublished work.Its use and disclosure */ +/* is limited by the terms and conditions of a license agreement. It may */ +/* be copied or otherwise reproduced or disclosed to persons outside the */ +/* licensee 's organization except in accordance with the terms and */ +/* conditions of such an agreement. All copies and reproductions shall be */ +/* the property of Ittiam Systems Pvt. Ltd. and must bear this notice */ +/* in its entirety. */ +/* */ +/*****************************************************************************/ + +/* + Main for enhanced aacPlus decoding + */ + +#include +#include +#include + +#define AOSP_CHANGE + +#include "ixheaacd_fileifc.h" +#include +#include "ixheaacd_error_standards.h" +#include "ixheaacd_error_handler.h" +#include "ixheaacd_apicmd_standards.h" +#include "ixheaacd_memory_standards.h" +#include "ixheaacd_aac_config.h" +#include "ixheaacd_metadata_read.h" + +IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, + pVOID pv_value); + +VOID ixheaacd_error_handler_init(); +VOID ia_testbench_error_handler_init(); + +extern ia_error_info_struct ixheaacd_ia_testbench_error_info; +extern ia_error_info_struct ixheaacd_error_info; +// extern int num_of_output_ch; + +/*****************************************************************************/ +/* Process select hash defines */ +/*****************************************************************************/ +#define WAV_HEADER +#define DISPLAY_MESSAGE +//#define REINIT_FOR_ERROR +//#define ERROR_PATTERN_READ +//#define TEST_INSUFFICIENT_INPUT 1 +//#define TEST_FRAMEWISE_INPUT + +#ifdef TEST_FRAMEWISE_INPUT +// Include header file for array of frame sizes : Audio_FrameSize +//#include "0_3gp_4.h" +#endif + +/*****************************************************************************/ +/* Constant hash defines */ +/*****************************************************************************/ +#define MAX_STACK_PROC 10 +#define MAX_MEM_ALLOCS 100 +#define IA_MAX_CMD_LINE_LENGTH 300 +#define IA_MAX_ARGS 20 +#define IA_SCREEN_WIDTH 80 +#define PARAMFILE "paramfilesimple.txt" + +/*****************************************************************************/ +/* Error codes for the testbench */ +/*****************************************************************************/ +#define IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED 0xFFFF8000 +#define IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED 0xFFFF8001 + +#define IA_HE_AAC_DEC_TABLE_RELOCATABLE_ENABLE 0 + +#ifdef ARM_PROFILE +#include "armtimer.h" +#endif + +#ifdef ARM_PROFILE_HW +#include +#define CLK_FREQ_BOARD_MHZ 716 // a9 omap4430 board +//#define CLK_FREQ_BOARD_MHZ 1555 //Nexus6P +//#define CLK_FREQ_BOARD_MHZ 2035 //Tegra Board +//#define CLK_FREQ_BOARD_MHZ 550 //a8 board +//#define CLK_FREQ_BOARD_MHZ 297 //dm365 board +//#define CLK_FREQ_BOARD_MHZ 1209.6 //a5 board +#endif +#ifdef ARM_PROFILE_HW +long long itGetMs(void) { + struct timeval t; + long long currTime; + + if (gettimeofday(&t, NULL) == -1) { + printf("Error in gettimeofday. It has returned -1. \n"); + } + currTime = ((t.tv_sec * 1000 * 1000) + (t.tv_usec)); + return currTime; +} +#endif +/*****************************************************************************/ +/* Global variables */ +/*****************************************************************************/ +pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; +WORD g_w_malloc_count; +FILE *g_pf_out; +FileWrapperPtr g_pf_inp; /* file pointer to bitstream file (mp4) */ + +metadata_info meta_info; // metadata pointer; +WORD32 ixheaacd_i_bytes_to_read; +FILE *g_pf_meta; + +WORD32 raw_testing = 0; + +#define _IA_PRINT_ERROR(p_mod_err_info, context, e) \ + if ((e) != IA_NO_ERROR) { \ + ixheaacd_error_handler((p_mod_err_info), (context), (e)); \ + } + +#ifdef ERROR_PATTERN_READ +FILE *g_pf_err = NULL; /* file pointer to error pattern file */ +#endif + +//#define CHECK_STACK_USAGE +#ifdef CHECK_STACK_USAGE +int *stack_corrupt, stack_used; +void stack_corrupt_func() { + int i, stack_val2; + stack_corrupt = &stack_val2; + for (i = 10; i < 2048; i++) { + stack_corrupt[-(i)] = 0xcfadbe3d; + } +} +#endif + +#ifndef WIN32 +#ifdef ITTIAM_BIG_ENDIAN + +int ia_fwrite(pVOID buffer[], int size, int nwords, FILE *fp) { + int i, k; + pWORD8 pb_buf = (pWORD8)buffer; + + for (i = 0; i < nwords; i++) { + for (k = size - 1; k >= 0; k--) { + putc(pb_buf[i * size + k], fp); + } + } + return 1; +} + +#else +int ia_fwrite(pVOID buffer[], int size, int nwords, FILE *fp) { + int i, j; + pWORD8 pb_buf = (pWORD8)buffer; + + for (i = 0; i < nwords; i++) { + for (j = 0; j < size; j++) { + putc(pb_buf[i * size + j], fp); + } + } + return 1; +} + +#endif +#endif +#ifdef ERROR_PATTERN_READ +/*****************************************************************************/ +/* */ +/* Function name : ReadErrorPatternFile */ +/* */ +/* Description : The function reads the frameError flag from a file. */ +/* */ +/* Inputs : FILE *epf (Input file to read from) */ +/* */ +/* Globals : none */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : 1 if the frame is ok, else 0 */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +static char ReadErrorPatternFile(FILE *epf) { + char tmp; + int readOk; + + if (!epf) return 1; + + readOk = fscanf(epf, "%c\n", &tmp); + if (readOk != 1) { + rewind(epf); + fscanf(epf, "%c\n", &tmp); + } + if (tmp == '0') + return 1; + else + return 0; +} +#endif + +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_write16_bits_lh */ +/* */ +/* Description : write 16 bits low high (always little endian) */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; */ +/* WORD g_w_malloc_count; */ +/* FILE *g_pf_inp, *g_pf_out; */ +/* */ +/* Processing : write 16 bits low high (always little endian) */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +static VOID ixheaacd_write16_bits_lh(FILE *fp, WORD32 i) { + putc(i & 0xff, fp); + putc((i >> 8) & 0xff, fp); +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_write32_bits_lh */ +/* */ +/* Description : write 32 bits low high (always little endian) */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : FILE* fp (file to write) */ +/* WORD32 i (value to write) */ +/* */ +/* Processing : write 32 bits low high (always little endian) */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +static VOID ixheaacd_write32_bits_lh(FILE *fp, WORD32 i) { + ixheaacd_write16_bits_lh(fp, (WORD32)(i & 0xffffL)); + ixheaacd_write16_bits_lh(fp, (WORD32)((i >> 16) & 0xffffL)); +} + +/*****************************************************************************/ +/* */ +/* Function name : write_wav_header */ +/* */ +/* Description : Write wav header to a wav file */ +/* */ +/* Inputs : none */ +/* */ +/* Globals : FILE* fp (file to write) */ +/* WORD32 pcmbytes (total bytes in wav file) */ +/* WORD32 freq (sampling freq) */ +/* WORD32 channels (output channels) */ +/* WORD32 bits (bits per sample) */ +/* */ +/* Processing : Write wav header */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +WORD32 write_wav_header(FILE *fp, WORD32 pcmbytes, WORD32 freq, WORD32 channels, + WORD32 bits, WORD32 i_channel_mask) { + if (channels > 2) { + WORD32 bytes = (bits + 7) / 8; + fwrite("RIFF", 1, 4, fp); /* label */ + ixheaacd_write32_bits_lh( + fp, pcmbytes + 44 - 8); /* length in bytes without header */ + fwrite("WAVEfmt ", 2, 4, fp); /* 2 labels */ + /* tag for WAVE_FORMAT_EXTENSIBLE */ + if (channels > 2) { + ixheaacd_write16_bits_lh(fp, 0x28); + ixheaacd_write16_bits_lh(fp, 0x00); + ixheaacd_write16_bits_lh(fp, 0xfffe); + } else { + ixheaacd_write32_bits_lh( + fp, 2 + 2 + 4 + 4 + 2 + 2); /* length of PCM format decl area */ + ixheaacd_write16_bits_lh(fp, 1); /* is pcm? */ + } + + ixheaacd_write16_bits_lh(fp, channels); + ixheaacd_write32_bits_lh(fp, freq); + ixheaacd_write32_bits_lh(fp, freq * channels * bytes); /* bps */ + ixheaacd_write16_bits_lh(fp, channels * bytes); + ixheaacd_write16_bits_lh(fp, bits); + + /* tag for WAVE_FORMAT_EXTENSIBLE */ + if (channels > 2) { + ixheaacd_write16_bits_lh(fp, 0x16); + ixheaacd_write16_bits_lh(fp, 0x10); /*Samples.wReserved*/ + ixheaacd_write32_bits_lh(fp, i_channel_mask); /* dwChannelMask */ + + ixheaacd_write32_bits_lh(fp, 0x0001); /* SubFormat.Data1 */ + ixheaacd_write32_bits_lh( + fp, 0x00100000); /* SubFormat.Data2 and SubFormat.Data3 */ + + ixheaacd_write16_bits_lh(fp, 0x0080); + ixheaacd_write16_bits_lh(fp, 0xAA00); + + ixheaacd_write16_bits_lh(fp, 0x3800); + ixheaacd_write16_bits_lh(fp, 0x719b); + /* + ixheaacd_write16_bits_lh(fp, 0x6166); + ixheaacd_write16_bits_lh(fp, 0x7463); + + ixheaacd_write16_bits_lh(fp, 0x0004); + ixheaacd_write16_bits_lh(fp, 0x0000); + + ixheaacd_write16_bits_lh(fp, 0x5800); + ixheaacd_write16_bits_lh(fp, 0x0028); + */ } + + fwrite("data", 1, 4, fp); + ixheaacd_write32_bits_lh(fp, pcmbytes); + + return (ferror(fp) ? -1 : 0); + + } else { + WORD32 bytes = (bits + 7) / 8; + fwrite("RIFF", 1, 4, fp); /* label */ + ixheaacd_write32_bits_lh( + fp, pcmbytes + 44 - 8); /* length in bytes without header */ + fwrite("WAVEfmt ", 2, 4, fp); /* 2 labels */ + ixheaacd_write32_bits_lh( + fp, 2 + 2 + 4 + 4 + 2 + 2); /* length of PCM format decl area */ + ixheaacd_write16_bits_lh(fp, 1); /* is pcm? */ + ixheaacd_write16_bits_lh(fp, channels); + ixheaacd_write32_bits_lh(fp, freq); + ixheaacd_write32_bits_lh(fp, freq * channels * bytes); /* bps */ + ixheaacd_write16_bits_lh(fp, channels * bytes); + ixheaacd_write16_bits_lh(fp, bits); + fwrite("data", 1, 4, fp); + ixheaacd_write32_bits_lh(fp, pcmbytes); + + return (ferror(fp) ? -1 : 0); + } +} +#endif /* WAV_HEADER */ +#endif /*ARM_PROFILE_BOARD*/ + +#ifdef DISPLAY_MESSAGE + +/*****************************************************************************/ +/* */ +/* Function name : ia_display_id_message */ +/* */ +/* Description : Display the ID message of the process */ +/* */ +/* Inputs : WORD8 lib_name[] (library name) */ +/* WORD8 lib_version[] (library version) */ +/* WORD8 api_version[] (API version) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Display all the information about the process */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : none */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Tejaswi/Vishal Created */ +/* */ +/*****************************************************************************/ + +VOID ia_display_id_message(WORD8 lib_name[], WORD8 lib_version[]) { + WORD8 str[4][IA_SCREEN_WIDTH] = {"ITTIAM SYSTEMS PVT LTD, BANGALORE\n", + "http:\\\\www.ittiam.com\n", "", ""}; + WORD8 spaces[IA_SCREEN_WIDTH / 2 + 1]; + WORD32 i, spclen; + + strcpy((pCHAR8)str[2], (pCHAR8)lib_name); + strcat((pCHAR8)str[2], (pCHAR8)lib_version); + strcat((pCHAR8)str[2], "\n"); + strcat((pCHAR8)str[4 - 1], "\n"); + + for (i = 0; i < IA_SCREEN_WIDTH / 2 + 1; i++) { + spaces[i] = ' '; + } + + for (i = 0; i < 4; i++) { + spclen = IA_SCREEN_WIDTH / 2 - strlen((pCHAR8)str[i]) / 2; + spaces[spclen] = '\0'; + printf("%s", (pCHAR8)spaces); + spaces[spclen] = ' '; + printf("%s", (pCHAR8)str[i]); + } +} +#endif /* DISPLAY_MESSAGE */ + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_set_config_param */ +/* */ +/* Description : Set config parameters */ +/* */ +/* Inputs : pVOID p_ia_process_api_obj (process API obj) */ +/* WORD32 argc (Arguments count) */ +/* pWORD8 argv[] (Argument strings) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Set config params inside API */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], + pVOID p_ia_process_api_obj) { + LOOPIDX i; + IA_ERRORCODE err_code = IA_NO_ERROR; + /* the process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) = + ixheaacd_dec_api; + ia_error_info_struct *p_proc_err_info = &ixheaacd_error_info; + + for (i = 0; i < argc; i++) { + /* PCM Word Size (For single input file) */ + if (!strncmp((pCHAR8)argv[i], "-pcmsz:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_pcm_wd_sz = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ, &ui_pcm_wd_sz); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Down-mix stereo to mono. */ + if (!strncmp((pCHAR8)argv[i], "-dmix:", 6)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 6); + UWORD32 ui_down_mix = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX, &ui_down_mix); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#ifdef RESAMPLE_SUPPORT + /* Resample the output to 8 kHz. */ + if (!strncmp((pCHAR8)argv[i], "-f08:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_08khz_out = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT08KHZ, &ui_08khz_out); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Resample the output to 16 kHz. */ + if (!strncmp((pCHAR8)argv[i], "-f16:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_16khz_out = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT16KHZ, &ui_16khz_out); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + /* Interleave mono output to stereo */ + if (!strncmp((pCHAR8)argv[i], "-tostereo:", 10)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 10); + UWORD32 ui_to_stereo = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO, &ui_to_stereo); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Downsampled synthesis to be used */ + if (!strncmp((pCHAR8)argv[i], "-dsample:", 9)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 9); + UWORD32 ui_dsample = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE, &ui_dsample); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-mp4:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_mp4_flag = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4, &ui_mp4_flag); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + +#ifdef HEAACV2_AS_AACLC + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-aac_lc_only:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_aac_lc_only = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_AAC_ONLY, &ui_aac_lc_only); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + +#ifdef LATM_LOAS + /* To indicate if its a LOAS file or not. */ + if (!strncmp((pCHAR8)argv[i], "-isLOAS:", 8)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 8); + UWORD32 ui_loas_flag = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS, &ui_loas_flag); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + +#endif + +#ifdef DRC_ENABLE + if (!strncmp((pCHAR8)argv[i], "-drc:", 5)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_cut_fac:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_boost_fac:", 15)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 15); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-drc_target_level:", 18)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 18); + UWORD32 ui_drc_enable = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL, &ui_drc_enable); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + /* To indicate if its a MP4 file or not. */ + if (!strncmp((pCHAR8)argv[i], "-nosync:", 8)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 8); + UWORD32 ui_disable_sync = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC, &ui_disable_sync); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate SBR upsampling. */ + if (!strncmp((pCHAR8)argv[i], "-sbrup:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_auto_sbr_upsample = atoi(pb_arg_val); + err_code = + (*p_ia_process_api)(p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE, + &ui_auto_sbr_upsample); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate sample rate for a RAW bit-stream. */ + if (!strncmp((pCHAR8)argv[i], "-fs:", 4)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 4); + UWORD32 ui_samp_freq = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ, &ui_samp_freq); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* To indicate the number of maximum channels */ + if (!strncmp((pCHAR8)argv[i], "-maxchannel:", 12)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 12); + UWORD32 ui_max_channel = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL, &ui_max_channel); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* To indicate the number of coupling channels to be used for coupling */ + if (!strncmp((pCHAR8)argv[i], "-coupchannel:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 13); + UWORD32 ui_coupling_channel = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL, &ui_coupling_channel); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* Down-mix N.1 to stereo */ + if (!strncmp((pCHAR8)argv[i], "-downmix:", 9)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 9); + UWORD32 ui_downmix = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO, &ui_downmix); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* For LD files, to indicate */ + if (!strncmp((pCHAR8)argv[i], "-fs480:", 7)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); + UWORD32 ui_fs480 = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE, &ui_fs480); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + + return IA_NO_ERROR; +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_get_config_param */ +/* */ +/* Description : Get config parameters */ +/* */ +/* Inputs : pVOID p_ia_process_api_obj (process API obj) */ +/* pWORD32 pi_samp_freq (Ptr for samp freq param) */ +/* pWORD32 pi_num_chan (Ptr for num chan param) */ +/* pWORD32 pi_pcm_wd_sz (Ptr for PCM Word size param) */ +/* */ +/* Globals : none */ +/* */ +/* Processing : Get config params from API */ +/* */ +/* Outputs : none */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +IA_ERRORCODE ixheaacd_get_config_param(pVOID p_ia_process_api_obj, + pWORD32 pi_samp_freq, + pWORD32 pi_num_chan, + pWORD32 pi_pcm_wd_sz, + pWORD32 pi_channel_mask) { + IA_ERRORCODE err_code = IA_NO_ERROR; + /* the process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) = + ixheaacd_dec_api; + ia_error_info_struct *p_proc_err_info = &ixheaacd_error_info; + + /* Sampling frequency */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ, pi_samp_freq); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* Total Number of Channels */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS, pi_num_chan); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* PCM word size */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ, pi_pcm_wd_sz); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /* channel mask to tell the arrangement of channels in bit stream */ + { + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK, pi_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + /* Channel mode to tell MONO/STEREO/DUAL-MONO/NONE_OF_THESE */ + { + UWORD32 ui_channel_mode; + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE, &ui_channel_mode); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_channel_mode == 0) + printf("Channel Mode: MONO_OR_PS\n"); + else if (ui_channel_mode == 1) + printf("Channel Mode: STEREO\n"); + else if (ui_channel_mode == 2) + printf("Channel Mode: DUAL-MONO\n"); + else + printf("Channel Mode: NONE_OF_THESE or MULTICHANNEL\n"); + } + + /* Channel mode to tell SBR PRESENT/NOT_PRESENT */ + { + UWORD32 ui_sbr_mode; + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &ui_sbr_mode); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_sbr_mode == 0) + printf("SBR Mode: NOT_PRESENT\n"); + else if (ui_sbr_mode == 1) + printf("SBR Mode: PRESENT\n"); + else + printf("SBR Mode: ILLEGAL\n"); + } + return IA_NO_ERROR; +} + +/*****************************************************************************/ +/* */ +/* Function name : ixheaacd_main_process */ +/* */ +/* Description : Stacked processing with function pointer selection */ +/* */ +/* Inputs : WORD32 argc (Arguments count) */ +/* pWORD8 argv[] (Argument strings) */ +/* */ +/* Globals : pVOID g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]; */ +/* WORD g_w_malloc_count; */ +/* FILE *g_pf_inp, *g_pf_out; */ +/* */ +/* Processing : Stacked processing of multiple components */ +/* Loop1: Set params + Mem alloc */ +/* Loop2: Set params + Init process + Get params */ +/* Loop3: Execute */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : IA_ERRORCODE error_value (Error value) */ +/* */ +/* Issues : none */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 29 07 2005 Tejaswi/Vishal Created */ +/* */ +/*****************************************************************************/ + +#ifdef REINIT_FOR_ERROR +int ixheaacd_main_process(WORD32 argc, pWORD8 argv[], + pWORD8 pb_output_file_name) +#else +int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) +#endif +{ + LOOPIDX i; + WORD frame_counter = 0; +#ifdef DISPLAY_MESSAGE + /* Library Info and Identification strings */ + WORD8 pb_process_name[IA_SCREEN_WIDTH] = ""; + WORD8 pb_lib_version[IA_SCREEN_WIDTH] = ""; +#endif + + /* Error code */ + IA_ERRORCODE err_code = IA_NO_ERROR; + IA_ERRORCODE err_code_reinit = IA_NO_ERROR; + + /* API obj */ + pVOID pv_ia_process_api_obj; + /* First part */ + /* Error Handler Init */ + /* Get Library Name, Library Version and API Version */ + /* Initialize API structure + Default config set */ + /* Set config params from user */ + /* Initialize memory tables */ + /* Get memory information and allocate memory */ + + /* Memory variables */ + UWORD32 n_mems, ui_rem; + UWORD32 ui_proc_mem_tabs_size; + /* API size */ + UWORD32 pui_ap_isize; + /* Process initing done query variable */ + UWORD32 ui_init_done, ui_exec_done; + pWORD8 pb_inp_buf = 0, pb_out_buf = 0; + pWORD8 pb_inp_buf1 = 0; + // pWORD16 litt2big; + + UWORD32 ui_inp_size = 0; + WORD32 i_bytes_consumed, i_bytes_read; + WORD32 i_buff_size; + WORD32 prev_sampling_rate = 0; + WORD32 skip_samples = 0; + WORD32 total_samples = 0; + WORD32 write_flag = 1; + WORD32 bytes_to_write = 0; + WORD32 ixheaacd_drc_offset = 0; + WORD32 current_samples = 0; + WORD32 samples_written = 0; + WORD32 init_iteration = 1; +#ifdef REINIT_FOR_ERROR + WORD32 i_persist_size; + WORD32 i_process_err = 0, i_op_file_cnt = 0; + WORD32 i_error_in_init = 0; + WORD32 i_count_init_errors = 0; + + pVOID pv_persist_ptr; +#endif + +#ifdef ARM_PROFILE_HW + int frame_count_b = 0; + long long cycles_b = 0; + long long start1_b, stop1_b; + double Curr_b, Ave_b = 0, Sum_b = 0; + double Peak_b = 0; + WORD32 Peak_frame_b = 0; +#endif +#ifdef TEST_INSUFFICIENT_INPUT + WORD32 buff_pos, read_bytes = 330, input_buff_size; +#endif + WORD32 i_out_bytes, i_total_bytes = 0; + WORD32 i_samp_freq, i_num_chan, i_pcm_wd_sz, i_channel_mask; + + /* The process API function */ + IA_ERRORCODE(*p_ia_process_api) + (pVOID p_ia_process_api_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); + + /* The set config from argc argv */ + IA_ERRORCODE(*p_set_config_param) + (WORD32 argc, pWORD8 argv[], pVOID p_ia_process_api_obj); + + /* The get config from API */ + IA_ERRORCODE(*p_get_config_param) + (pVOID p_ia_process_api_obj, pWORD32 pi_samp_freq, pWORD32 pi_num_chan, + pWORD32 pi_pcm_wd_sz, pWORD32 pi_channel_mask); + +#ifdef TEST_FRAMEWISE_INPUT + // Open the file with config header data + FILE *fp_hdr = fopen("0_3gp_4.hdr", "rb"); +#endif + /* The error init function */ + VOID (*p_error_init)(); + + /* The process error info structure */ + ia_error_info_struct *p_proc_err_info; + +#ifdef ARM_PROFILE + + for (profile_index = 0; profile_index < MAX_MODULE; profile_index++) { + profile_instance[profile_index].peak = 0; + profile_instance[profile_index].average = 0; + profile_instance[profile_index].cycles = 0; + profile_instance[profile_index].sum = 0; + profile_instance[profile_index].peak_frame = 0; + // profile_instance[profile_index].info=profile_info[profile_index]; + } + +#endif + + /* Process struct initing */ + p_ia_process_api = ixheaacd_dec_api; + p_set_config_param = ixheaacd_set_config_param; + p_get_config_param = ixheaacd_get_config_param; + p_error_init = ixheaacd_error_handler_init; + p_proc_err_info = &ixheaacd_error_info; + /* Process struct initing end */ + + /* ******************************************************************/ + /* Initialize the error handler */ + /* ******************************************************************/ + (*p_error_init)(); + +/* ******************************************************************/ +/* Get the library name, library version and API version */ +/* ******************************************************************/ + +#ifdef DISPLAY_MESSAGE + /* Get the library name string */ + err_code = (*p_ia_process_api)(NULL, IA_API_CMD_GET_LIB_ID_STRINGS, + IA_CMD_TYPE_LIB_NAME, pb_process_name); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get the library version string */ + err_code = (*p_ia_process_api)(NULL, IA_API_CMD_GET_LIB_ID_STRINGS, + IA_CMD_TYPE_LIB_VERSION, pb_lib_version); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Display the ittiam identification message */ + ia_display_id_message(pb_process_name, pb_lib_version); +#endif + + /* ******************************************************************/ + /* Initialize API structure and set config params to default */ + /* ******************************************************************/ + + /* Get the API size */ + err_code = + (*p_ia_process_api)(NULL, IA_API_CMD_GET_API_SIZE, 0, &pui_ap_isize); +#ifdef MEM_PROFILE + { + float temp = 0; + temp = (float)((float)pui_ap_isize / 1024); + printf("Get the API size %d = %f \n", pui_ap_isize, temp); // added by siva + } +#endif + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Allocate memory for API */ + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(pui_ap_isize + 4); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "API struct alloc", err_code); + } + + /* API object requires 4 bytes (WORD32) alignment */ + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); + /* Set API object with the memory allocated */ + pv_ia_process_api_obj = + (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem); + + g_w_malloc_count++; + + /* Set the config params to default values */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* ******************************************************************/ + /* Set config parameters got from the user present in argc argv */ + /* ******************************************************************/ + + err_code = (*p_set_config_param)(argc, argv, pv_ia_process_api_obj); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +/* ******************************************************************/ +/* Table Relocatibility */ +/* ******************************************************************/ +#if IA_HE_AAC_DEC_TABLE_RELOCATABLE_ENABLE + + /* Get number of tables required */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_GET_N_TABLES, + 0, &n_mems); +#ifdef MEM_PROFILE + printf("Get number of tables required: %d \n", n_mems); // added by siva +#endif + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (i = 0; i < (WORD32)n_mems; i++) { + int ui_size, ui_alignment; + pVOID pv_alloc_ptr = NULL, pv_curr_ptr = NULL; + LOOPIDX k; + + /* Get table size */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_INFO_SIZE, i, &ui_size); +#ifdef MEM_PROFILE + { + float temp = 0; + temp = (float)((float)ui_size / 1024); + printf("get table size: %d =%f\n", ui_size, temp); // added by siva + } +#endif + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get table alignment */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_INFO_ALIGNMENT, i, + &ui_alignment); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_size + ui_alignment); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem for table relocation alloc", + IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED); + } + + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] % ui_alignment); + pv_alloc_ptr = (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + + ui_alignment - ui_rem); + + g_w_malloc_count++; + + /* Get the current table pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_TABLE_PTR, i, &pv_curr_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (k = 0; k < ui_size; k++) { + ((pWORD8)pv_alloc_ptr)[k] = ((pWORD8)pv_curr_ptr)[k]; + /* Disabled for multiple files running +((pWORD8)pv_curr_ptr)[k] = (WORD8)0xab; */ + } + + /* Set the relocated table pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_TABLE_PTR, i, pv_alloc_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + /* ******************************************************************/ + /* Initialize Memory info tables */ + /* ******************************************************************/ + + /* Get memory info tables size */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_GET_MEMTABS_SIZE, 0, + &ui_proc_mem_tabs_size); +#ifdef MEM_PROFILE + printf("memory info table size: %d \n", + ui_proc_mem_tabs_size); // added by siva +#endif + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_proc_mem_tabs_size + 4); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem tables alloc", err_code); + } + + /* API object requires 4 bytes (WORD32) alignment */ + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); + + /* Set pointer for process memory tables */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_MEMTABS_PTR, 0, + (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem)); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + g_w_malloc_count++; + + /* initialize the API, post config, fill memory tables */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* ******************************************************************/ + /* Allocate Memory with info from library */ + /* ******************************************************************/ + + /* Get number of memory tables required */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_N_MEMTABS, 0, &n_mems); +#ifdef MEM_PROFILE + printf("Get number of memory tables required %d \n", n_mems); // added by + // siva +#endif + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + for (i = 0; i < (WORD32)n_mems; i++) { + int ui_size, ui_alignment, ui_type; + pVOID pv_alloc_ptr; + + /* Get memory size */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size); +#ifdef MEM_PROFILE + { + float temp = 0; + printf("memory size: %d =%f \n", ui_size, + temp = (float)((float)ui_size / 1024)); // added by siva + } +#endif + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory alignment */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, + &ui_alignment); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Get memory type */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, &i_num_chan, + &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // ui_size += 20*1024*sizeof(WORD8); + + if (ui_type == IA_MEMTYPE_OUTPUT) { + // ui_size = 8192; + if (i_pcm_wd_sz == 16) + ui_size = 16384 * sizeof(WORD16); // refer SAMPLE_BUF_SIZE value in + // audio.c file //Ramesh + else + ui_size = + 16384 * 3 * + sizeof( + WORD8); // refer SAMPLE_BUF_SIZE value in audio.c file //Ramesh + } + + g_pv_arr_alloc_memory[g_w_malloc_count] = malloc(ui_size + ui_alignment); + + if (g_pv_arr_alloc_memory[g_w_malloc_count] == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_MEM_ALLOC_FAILED; + _IA_HANDLE_ERROR(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Mem tables alloc", err_code); + } + + ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] % ui_alignment); + pv_alloc_ptr = (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + + ui_alignment - ui_rem); + + g_w_malloc_count++; + + /* Set the buffer pointer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + if (ui_type == IA_MEMTYPE_INPUT) { + pb_inp_buf = pv_alloc_ptr; + ui_inp_size = ui_size; +#ifdef TEST_INSUFFICIENT_INPUT + input_buff_size = ui_size; +#endif + } +#ifdef REINIT_FOR_ERROR + if (ui_type == IA_MEMTYPE_PERSIST) { + i_persist_size = ui_size; + pv_persist_ptr = pv_alloc_ptr; + } +#endif + if (ui_type == IA_MEMTYPE_OUTPUT) { + pb_out_buf = pv_alloc_ptr; + } + } + +/* End first part */ + +/* Second part */ +/* Initialize process */ +/* Get config params */ + +/* ******************************************************************/ +/* Initialize process in a loop (to handle junk data at beginning) */ +/* ******************************************************************/ + +#ifndef TEST_FRAMEWISE_INPUT + i_bytes_consumed = ui_inp_size; + i_buff_size = ui_inp_size; + +#else + +#ifdef REINIT_FOR_ERROR +INIT_AGAIN: +#endif + /* Clear input buffer */ + memset(pb_inp_buf, 0, ui_inp_size); + /* Read the config header */ + i_buff_size = fread((unsigned char *)pb_inp_buf, 1, 5, fp_hdr); + /* Reset the read pointer of header file - useful in case of errors */ + fseek(fp_hdr, 0, SEEK_SET); + + /* Read this frame data*/ + i_buff_size += fread((unsigned char *)pb_inp_buf + i_buff_size, 1, + Audio_FrameSize[frame_counter], g_pf_inp->inputFile); + + i_bytes_consumed = 0; +#endif + +#ifdef TEST_INSUFFICIENT_INPUT + buff_pos = 0; +#endif + + do { +#ifndef TEST_FRAMEWISE_INPUT + +#ifdef REINIT_FOR_ERROR + INIT_AGAIN: +#endif + i_bytes_read = 0; + +#ifndef TEST_INSUFFICIENT_INPUT + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - + i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + /* Tell input is over, if algorithm returns with insufficient input and + there is no + more input left in the bitstream*/ + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) + + { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } +#else + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + WORD32 read_bytes_act = read_bytes; + + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + + if (buff_pos + read_bytes > input_buff_size) + read_bytes_act = input_buff_size - buff_pos; + + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + buff_pos), + read_bytes_act, (pUWORD32)&i_bytes_read); + + buff_pos += i_bytes_read; + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + if (i_buff_size <= 0) { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } +#endif + +#else + + if (i_bytes_consumed != 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + i_buff_size -= i_bytes_consumed; + } +#endif + // if( i_buff_size <= 0) + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + /* ******************************************************************/ + /* Get config params from API */ + /* ******************************************************************/ + + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // This is done in those cases, where file decodes ends at init time + // Since init is incomplete, sampling freq might be zero and will result + // in + // writing invalid wave header + + if (i_samp_freq == 0) i_samp_freq = prev_sampling_rate; + + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + return 1; + } + + if (init_iteration == 1) { + if (raw_testing) + ixheaacd_i_bytes_to_read = get_metadata_dec_info_init(meta_info); + else + ixheaacd_i_bytes_to_read = i_buff_size; + + /* Set number of bytes to be processed */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + init_iteration++; + + } else { + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* Initialize the process */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_PROCESS, NULL); + err_code_reinit = err_code; + +#ifdef REINIT_FOR_ERROR + + if (err_code != 0) { + i_process_err = 1; + i_error_in_init = 1; + /* Adding some error code so that the re-init will be + printed as non-fatal error by testbench */ + err_code = 0x00000000; + i_count_init_errors++; + } + // _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8)"", err_code); + if (err_code_reinit == + 0x00001804 /*IA_ENHAACPLUS_DEC_EXE_FATAL_INSUFFICIENT_INPUT_BYTES*/) { + _IA_PRINT_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } else if (err_code_reinit) { + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#else + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#endif + + /* Checking for end of initialization */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_DONE_QUERY, &ui_init_done); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* How much buffer is used in input buffers */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, + &i_bytes_consumed); + + // printf("%d \n",i_bytes_consumed); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#ifdef REINIT_FOR_ERROR + + if (i_process_err == 1) { + /* To avoid going into loop in case of initialization errors + beyond a certain limit */ + if (i_count_init_errors > 6000) { + ixheaacd_error_handler(p_proc_err_info, (pWORD8) "", err_code_reinit); + +#ifdef WAV_HEADER // removed +#ifndef ARM_PROFILE_BOARD + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + /* Try decoding next file */ + return 1; + } + +// frame_counter++; +#ifndef ARM_PROFILE_BOARD +// fprintf(stderr,"\r[%5d]",frame_counter); +#endif + goto HANDLE_ERROR_AT_INIT; + } +#endif + +#ifdef TEST_INSUFFICIENT_INPUT + // shift out consumed data + buff_pos -= i_bytes_consumed; +#endif + + } while (!ui_init_done); + + /* ******************************************************************/ + /* Get config params from API */ + /* ******************************************************************/ + + err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + if (raw_testing) { + skip_samples = get_start_offset_in_samples(meta_info); + total_samples = get_play_time_in_samples(meta_info); + } + +/* End second part */ + +#ifdef WAV_HEADER +// This condition is added so as to avoid re-writing wave header in +// middle of wave file in case of errors and when we are not opening +// new file in case of errors. + +#ifndef WRITE_NEW_FILE + if (frame_counter == 0) +#endif +#ifndef ARM_PROFILE_BOARD + + write_wav_header(g_pf_out, 0, i_samp_freq, i_num_chan, i_pcm_wd_sz, + i_channel_mask); +#endif +#endif + prev_sampling_rate = i_samp_freq; + +#ifdef TEST_INSUFFICIENT_INPUT + buff_pos = i_buff_size; +#endif + do { +#ifndef TEST_FRAMEWISE_INPUT +#ifndef TEST_INSUFFICIENT_INPUT + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } +#ifdef ENABLE_LD_DEC + if (0 != frame_counter) { +#endif + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - + i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); +#ifdef ENABLE_LD_DEC + } else + i_bytes_read = 0; +#endif + + if (i_bytes_read == 0) { + i_bytes_read = i_bytes_read; + } + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { + i_buff_size = 0; + raw_testing = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // if(i_buff_size == 0) + // break; + } + } +#else + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + WORD32 read_bytes_act = read_bytes; + + if (buff_pos + read_bytes > input_buff_size) + read_bytes_act = input_buff_size - buff_pos; + + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + buff_pos), + read_bytes_act, (pUWORD32)&i_bytes_read); + + buff_pos += i_bytes_read; + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + if (i_buff_size <= 0) { + i_buff_size = 0; + raw_testing = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } +#endif +#else // removed + if (i_bytes_consumed != 0) { + /* Clear input buffer*/ + memset(pb_inp_buf, 0, ui_inp_size); + + /* Set frame data to input buffer */ + i_buff_size = fread((unsigned char *)pb_inp_buf, 1, + Audio_FrameSize[frame_counter], g_pf_inp->inputFile); + + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + return 0; + } + } +#endif + + if (raw_testing) { + ixheaacd_i_bytes_to_read = + get_metadata_dec_exec(meta_info, frame_counter); + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + } else { + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef ERROR_PATTERN_READ + { + /* Reading error pattern from file and set config param */ + UWORD32 frame_status = ReadErrorPatternFile(g_pf_err); + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMEOK, &frame_status); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif + +#ifdef CHECK_STACK_USAGE + stack_corrupt_func stack_corrupt -= 2048; +#endif + +#ifdef ARM_PROFILE_HW + // start1 = times(&start); + start1_b = itGetMs(); +// printf("start1_b = %lld\t",start1_b); +#endif + +#ifdef ARM_PROFILE + + IttiamStartTimer1 // Initialize Timer + uiStartTime = IttiamGetTimer1 // Read Start Time +#endif // ARM_PROFILE + /* Execute process */ + + if (frame_counter % 10 == 0) { + do { + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_FLUSH_MEM, + NULL); // api implemented to handle flush call + + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_DONE_QUERY, &ui_init_done); + + if (i_buff_size != 0) { + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } else { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + } + + } while (!ui_init_done); + + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + } + + if (ixheaacd_i_bytes_to_read == 2) // Check to indicate GA header + { + do { + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_GA_HDR, + NULL); // api implemented to handle multiple ga_hdr decode + + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_DONE_QUERY, &ui_init_done); + + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, + &i_bytes_consumed); + + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + + FileWrapper_Read( + g_pf_inp, + (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + } + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + + } while (!ui_init_done); + + // frame_counter++; + } + + else { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_EXECUTE, + IA_CMD_TYPE_DO_EXECUTE, NULL); + } + + err_code_reinit = err_code; + +#ifdef ARM_PROFILE + + uiEndTime = IttiamGetTimer1 // Read End Time + IttiamStopTimer1 // Stop Timer */ + + // Compute cycles taken (timer decrement type) + profile_instance[EAAC_PLUS_DECODER] + .cycles = uiStartTime - uiEndTime; + +#endif // ARM_PROFILE + +#ifdef ARM_PROFILE_HW + stop1_b = itGetMs(); + cycles_b = (stop1_b - start1_b); +// printf("stop1_b = %lld\n",stop1_b); +#endif + +#ifdef CHECK_STACK_USAGE + for (i = 5; i < 2048; i++) { + if ((stack_corrupt[i] != 0xcfadbe3d)) { + stack_used = (2048 - i) * 4; + break; + } + } + printf("Stack used bytes = %d\n", stack_used); +#endif + +#ifdef REINIT_FOR_ERROR + if (err_code != 0) { + i_process_err = 1; + /* Adding some error code so that the re-init will be + printed as non-fatal error by testbench */ + + err_code = 0x00000000; + } + if (err_code_reinit == + 0x00001804 /*IA_ENHAACPLUS_DEC_EXE_FATAL_INSUFFICIENT_INPUT_BYTES*/) { + _IA_PRINT_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } else if (err_code) { + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#else + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#endif + + /* Checking for end of processing */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_EXECUTE, + IA_CMD_TYPE_DONE_QUERY, &ui_exec_done); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* How much buffer is used in input buffers */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, + &i_bytes_consumed); + // printf("%d \n",i_bytes_consumed); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +// fprintf(stderr,"i_bytes_consumed :: [%5d]\n",i_bytes_consumed); + +#ifdef TEST_INSUFFICIENT_INPUT + // shift out consumed data + buff_pos -= i_bytes_consumed; +#endif + + /* Get the output bytes */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_OUTPUT_BYTES, 0, &i_out_bytes); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + i_total_bytes += i_out_bytes; + + if (total_samples != 0) // Usac stream + { + if (raw_testing) { + if (i_total_bytes <= skip_samples * i_num_chan * (i_pcm_wd_sz >> 3)) { + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + + write_flag = 0; + } else { + write_flag = 1; + bytes_to_write = + i_total_bytes - skip_samples * i_num_chan * (i_pcm_wd_sz >> 3); + if (bytes_to_write < i_out_bytes) { + ixheaacd_drc_offset = i_out_bytes - bytes_to_write; + // i_total_bytes = i_total_bytes - i_out_bytes + bytes_to_write; + i_out_bytes = bytes_to_write; + current_samples = + bytes_to_write / (i_num_chan * (i_pcm_wd_sz >> 3)); + } else { + ixheaacd_drc_offset = 0; + current_samples = i_out_bytes / (i_num_chan * (i_pcm_wd_sz >> 3)); + } + } + } + + if (raw_testing) { + samples_written += current_samples; + + if (samples_written > total_samples) { + i_out_bytes = (total_samples - (samples_written - current_samples)) * + (i_num_chan * (i_pcm_wd_sz >> 3)); // hack + if (i_out_bytes < 0) i_out_bytes = 0; + } + } + } + + // printf("i_out_bytes = %d\n",i_out_bytes); + + if (write_flag) { +#ifndef WIN32 +#ifndef ARM_PROFILE_BOARD + ia_fwrite((pVOID)(pb_out_buf + ixheaacd_drc_offset), (i_pcm_wd_sz / 8), + i_out_bytes / (i_pcm_wd_sz / 8), g_pf_out); +#endif +#else +#ifndef ARM_PROFILE_BOARD + fwrite(pb_out_buf + ixheaacd_drc_offset, sizeof(WORD8), i_out_bytes, + g_pf_out); + fflush(g_pf_out); +#endif +#endif + } + + if (i_out_bytes) frame_counter++; + + printf("\r frame count =%d", frame_counter); + +#ifndef ARM_PROFILE_BOARD +// fprintf(stdout,"\r[%5d]\n ",frame_counter); +#endif +#ifdef ARM_PROFILE_HW + if (i_out_bytes != 0) { + int i_out_samples = i_out_bytes >> 2; + if (frame_count_b) { + double i_out_samples_per_ch = + (i_out_bytes) / ((i_pcm_wd_sz / 8) * i_num_chan); + Curr_b = (((double)cycles_b / 1000000) * CLK_FREQ_BOARD_MHZ) / + (i_out_samples_per_ch / i_samp_freq); + frame_count_b++; + // fprintf(stderr, "Microseconds: %d\t", cycles_b); + // fprintf(stderr, "MCPS: %f\n", Curr_b); + Sum_b += Curr_b; + Ave_b = Sum_b / frame_count_b; + if (Peak_b < Curr_b) { + Peak_b = Curr_b; + Peak_frame_b = frame_count_b; + } + } else { + frame_count_b++; + } + + cycles_b = 0; + } +#endif + +#ifdef ARM_PROFILE + if (i_out_bytes) { + WORD32 samples; + samples = (i_out_bytes >> 1) / i_num_chan; + + if (frame_counter == 1) { + fprintf(fprofile, "\t"); + fprintf(fprofile, "EnhAACPlusDec\t"); + for (profile_index = 0; profile_index < MAX_MODULE; profile_index++) + profile_instance[profile_index].cycles = 0; + + fprintf(fprofile, "\n"); + + } else { + fprintf(fprofile, "%d\t", frame_counter); + + for (profile_index = 0; profile_index < MAX_MODULE; profile_index++) { + curr = ((double)(profile_instance[profile_index].cycles) * + TIMER_RESOLUTION_256) / + (samples); + curr = (curr * i_samp_freq) / 1000000.0; + profile_instance[profile_index].sum += curr; + profile_instance[profile_index].average = + profile_instance[profile_index].sum / frame_counter; + fprintf(fprofile, "%f\t", curr); + + if (profile_instance[profile_index].peak < curr) { + profile_instance[profile_index].peak = curr; + profile_instance[profile_index].peak_frame = frame_counter; + } + profile_instance[profile_index].cycles = 0; + } + + fprintf(fprofile, "\n"); + } + } +#endif + +#ifdef REINIT_FOR_ERROR + HANDLE_ERROR_AT_INIT: + if (i_process_err == 1) { + WORD8 pb_file_cnt_arr[9]; + i_process_err = 0; + + ixheaacd_error_handler(p_proc_err_info, (pWORD8) "", err_code_reinit); + // Do re-init only for fatal errors + if (err_code_reinit < 0 || i_error_in_init) { + memset(pv_persist_ptr, 0, i_persist_size); + /* Set the config params to default values */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, + IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + /* ******************************************************************/ + /* Set config parameters got from the user present in argc argv */ + /* ******************************************************************/ + + err_code = (*p_set_config_param)(argc, argv, pv_ia_process_api_obj); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // removed /* Open new file only if the + // error + // occured + // during process */ + if (!i_error_in_init) { +//#define WRITE_NEW_FILE +#ifdef WRITE_NEW_FILE +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + i_op_file_cnt++; + sprintf((char *)pb_file_cnt_arr, "_%03d.wav", i_op_file_cnt); + fclose(g_pf_out); + i_total_bytes = 0; + if (i_op_file_cnt == 1) + (strcpy((char *)(pb_output_file_name + + strlen((char *)pb_output_file_name) - 4), + (const char *)pb_file_cnt_arr), + "wb"); + else + (strcpy((char *)(pb_output_file_name + + strlen((char *)pb_output_file_name) - 8), + (const char *)pb_file_cnt_arr), + "wb"); + g_pf_out = fopen((const char *)pb_output_file_name, "wb"); + if (g_pf_out == 0) { + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "Output file", + IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED); + } +#endif + + } else { + i_error_in_init = 0; + } + + goto INIT_AGAIN; + } + } +#endif + /* Do till the process execution is done */ + } while (!ui_exec_done); + +#ifdef ARM_PROFILE_HW + fprintf(stdout, "\n Peak MCPS = %f\n", Peak_b); + fprintf(stdout, " Avg MCPS = %f\n", Ave_b); + fprintf(stdout, " Peak frame = %d\n", Peak_frame_b); +#endif + +#ifdef ARM_PROFILE + + fprintf(fprofile, "Enh AAC Plus Decoder\n"); + fprintf(fprofile, "Peak MCPS = %lf\n", + profile_instance[EAAC_PLUS_DECODER].peak); + fprintf(fprofile, "Peak frame = %d\n", + profile_instance[EAAC_PLUS_DECODER].peak_frame); + fprintf(fprofile, "Avg MCPS = %lf\n\n", + profile_instance[EAAC_PLUS_DECODER].average); + +#endif + // EXIT: + + fprintf(stderr, "TOTAL FRAMES : [%5d] \n", frame_counter); + + // i_num_chan = num_of_output_ch; + err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + + return IA_NO_ERROR; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ixheaacd_main */ +/* */ +/* Description : Main function */ +/* */ +/* Inputs : None */ +/* */ +/* Globals : None */ +/* */ +/* Processing : Parse the parameter file and run the ixheaacd_main process + */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on success, -1 on error */ +/* */ +/* Issues : None */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 04 09 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +void print_usage() { + printf("\n Usage \n"); + printf("\n -ifile: -ofile: [options]\n"); + printf("\n[options] can be,"); +#ifdef ERROR_PATTERN_READ + printf("\n[-errfile:]"); +#endif + printf("\n[-pcmsz:]"); + printf("\n[-dmix:]"); +#ifdef RESAMPLE_SUPPORT + /* By default not available */ + printf("\n[-f08:]"); + printf("\n[-f16:]"); +#endif + printf("\n[-tostereo:]"); + printf("\n[-dsample:]"); + printf("\n[-fs:]"); + printf("\n[-nosync:]"); + printf("\n[-sbrup:]"); + + printf("\n[-maxchannel:]"); +#ifdef MULTICHANNEL_ENABLE + printf("\n[-coupchannel:]"); + printf("\n[-downmix:]"); +#endif + + printf("\n\nwhere, \n is the input AAC file name"); + printf("\n is the output file name"); +#ifdef ERROR_PATTERN_READ + printf("\n is the error pattern file name"); +#endif + printf("\n is the bits per sample info. Only 16 is valid"); + + printf("\n is to enable/disable always mono output. Default 0"); +#ifdef RESAMPLE_SUPPORT + printf("\n is to enable/disable 8 kHz output. Default 0 "); + printf("\n is to enable/disable 16 kHz output. Default 0 "); +#endif + printf("\n is to enable/disable always "); + printf("\n interleaved to stereo output. Default 1 "); + printf("\n is to enable/disable down-sampled SBR "); + printf("\n output. Default auto identification from header"); + printf("\n is to indicate the core AAC sample rate for"); + printf("\n a RAW stream. If this is specified no other file format"); + printf("\n headers are searched for. \n"); + printf("\n is to disable the ADTS/ADIF sync search i.e"); + printf("\n when enabled the decoder expects the header to "); + printf("\n be at the start of input buffer. Default 0"); + printf( + "\n is to enable(1) or disable(0) auto SBR " + "upsample "); + printf( + "\n in case of stream changing from SBR present to SBR not present. " + "Default 1"); + printf("\n is the number of maxiumum "); + printf("\n channels the input may have. Default is 6 (5.1)"); + +#ifdef MULTICHANNEL_ENABLE + printf("\n is element instance tag of "); + printf("\n independent coupling channel to be mixed. Default is 0"); + printf("\n is flag for Downmix. Give 1 to"); + printf("\n get stereo (downmix) output. Default is 0"); +#endif +} + +/*****************************************************************************/ +/* */ +/* Function Name : ixheaacd_main */ +/* */ +/* Description : Main function */ +/* */ +/* Inputs : None */ +/* */ +/* Globals : None */ +/* */ +/* Processing : Parse the parameter file and run the ixheaacd_main process + */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on success, -1 on error */ +/* */ +/* Issues : None */ +/* */ +/* Revision history : */ +/* */ +/* DD MM YYYY Author Changes */ +/* 04 09 2005 Ittiam Created */ +/* */ +/*****************************************************************************/ + +int main(WORD32 argc, pWORD8 argv[]) { + FILE *param_file_id; + + WORD8 curr_cmd[IA_MAX_CMD_LINE_LENGTH]; + WORD32 fargc, curpos; + WORD32 processcmd = 0; + + WORD8 fargv[IA_MAX_ARGS][IA_MAX_CMD_LINE_LENGTH]; + + pWORD8 pargv[IA_MAX_ARGS]; + + WORD8 pb_input_file_path[IA_MAX_CMD_LINE_LENGTH] = ""; + WORD8 pb_output_file_path[IA_MAX_CMD_LINE_LENGTH] = ""; +#ifdef REINIT_FOR_ERROR + WORD8 pb_output_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; +#endif + + ia_testbench_error_handler_init(); +#ifdef ARM_PROFILE + fprofile = fopen("profile.txt", "wt"); + + if (fprofile == NULL) { + printf("Unable to open profile file\n"); + exit(0); + } +#endif + +#ifdef RVDS_DEBUG + argc = 1; +#endif // siva + + if (argc == 1) { + param_file_id = fopen(PARAMFILE, "r"); + if (param_file_id == NULL) { + print_usage(); + return IA_NO_ERROR; + } + + /* Process one line at a time */ + while (fgets((char *)curr_cmd, IA_MAX_CMD_LINE_LENGTH, param_file_id)) { + curpos = 0; + fargc = 0; + /* if it is not a param_file command and if */ + /* CLP processing is not enabled */ + if (curr_cmd[0] != '@' && !processcmd) { /* skip it */ + continue; + } + + while (sscanf((char *)curr_cmd + curpos, "%s", fargv[fargc]) != EOF) { + if (fargv[0][0] == '/' && fargv[0][1] == '/') break; + if (strcmp((const char *)fargv[0], "@echo") == 0) break; + if (strcmp((const char *)fargv[fargc], "@New_line") == 0) { + fgets((char *)curr_cmd + curpos, IA_MAX_CMD_LINE_LENGTH, + param_file_id); + continue; + } + curpos += strlen((const char *)fargv[fargc]); + while (*(curr_cmd + curpos) == ' ' || *(curr_cmd + curpos) == '\t') + curpos++; + fargc++; + } + + if (fargc < 1) /* for blank lines etc. */ + continue; + + if (strcmp((const char *)fargv[0], "@Output_path") == 0) { + if (fargc > 1) + strcpy((char *)pb_output_file_path, (const char *)fargv[1]); + else + strcpy((char *)pb_output_file_path, ""); + continue; + } + + if (strcmp((const char *)fargv[0], "@Input_path") == 0) { + if (fargc > 1) + strcpy((char *)pb_input_file_path, (const char *)fargv[1]); + else + strcpy((char *)pb_input_file_path, ""); + continue; + } + + if (strcmp((const char *)fargv[0], "@Start") == 0) { + processcmd = 1; + continue; + } + + if (strcmp((const char *)fargv[0], "@Stop") == 0) { + processcmd = 0; + continue; + } + + /* otherwise if this a normal command and its enabled for execution */ + if (processcmd) { + int i; + int err_code = IA_NO_ERROR; + int file_count = 0; + + for (i = 0; i < fargc; i++) { + printf("%s ", fargv[i]); + pargv[i] = fargv[i]; + + if (!strncmp((const char *)fargv[i], "-ifile:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_input_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_input_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_input_file_name, (const char *)pb_arg_val); + + g_pf_inp = NULL; + g_pf_inp = FileWrapper_Open((char *)pb_input_file_name); + + if (g_pf_inp == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input File", err_code); + exit(1); + } + file_count++; + raw_testing = 0; + } + + if (!strncmp((const char *)fargv[i], "-imeta:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_metadata_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_metadata_file_name, + (const char *)pb_input_file_path); + strcat((char *)pb_metadata_file_name, (const char *)pb_arg_val); + + g_pf_meta = NULL; + g_pf_meta = fopen((const char *)pb_metadata_file_name, "r"); + + if (g_pf_meta == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Metadata File", err_code); + exit(1); + } + + metadata_info_init(&meta_info); + err_code = ixheaacd_read_metadata_info(g_pf_meta, &meta_info); + + if (err_code == -1) exit(1); + + raw_testing = 1; + + file_count++; + } + + if (!strncmp((const char *)fargv[i], "-ofile:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; +#ifndef REINIT_FOR_ERROR + WORD8 pb_output_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; +#endif + +#ifdef REINIT_FOR_ERROR + strcpy((char *)pb_output_file_name, + (const char *)pb_output_file_path); +#else + strcat((char *)pb_output_file_name, + (const char *)pb_output_file_path); +#endif + strcat((char *)pb_output_file_name, (const char *)pb_arg_val); + + g_pf_out = NULL; + g_pf_out = fopen((const char *)pb_output_file_name, "wb"); + if (g_pf_out == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Output File", err_code); + exit(1); + } + file_count++; + } +#ifdef ARM_PROFILE + fprintf(fprofile, "%s\n", fargv[i] + 7); +#endif + +#ifdef ERROR_PATTERN_READ + if (!strncmp((const char *)fargv[i], "-errfile:", 9)) { + pWORD8 pb_arg_val = fargv[i] + 9; + g_pf_err = fopen((const char *)pb_arg_val, "r"); + if (g_pf_err == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Error Pattern File", err_code); + } + } +#endif + } + g_w_malloc_count = 0; + + printf("\n"); + if (file_count != 3 && file_count != 2) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input or Output File", err_code); + } + + if (err_code == IA_NO_ERROR) { + if (g_pf_inp->isMp4File == 1) { + strcpy((pCHAR8)fargv[fargc], "-mp4:1"); + pargv[fargc] = fargv[fargc]; + fargc++; + } + +#ifdef REINIT_FOR_ERROR + ixheaacd_main_process(fargc, pargv, pb_output_file_name); +#else + + ixheaacd_main_process(fargc, pargv); +#endif + } + + for (i = 0; i < g_w_malloc_count; i++) { + if (g_pv_arr_alloc_memory[i]) free(g_pv_arr_alloc_memory[i]); + } + if (g_pf_out) fclose(g_pf_out); + + if (g_pf_meta) { + raw_testing = 0; + fclose(g_pf_meta); + memset_metadata(meta_info); + } + FileWrapper_Close(g_pf_inp); +#ifdef ERROR_PATTERN_READ + if (g_pf_err) fclose(g_pf_err); +#endif + } + } + } else { + int i; + int err_code = IA_NO_ERROR; + int file_count = 0; + + for (i = 1; i < argc; i++) { + pargv[i] = fargv[i]; + strcpy((pCHAR8)fargv[i], (pCHAR8)argv[i]); + printf("%s ", pargv[i]); + + if (!strncmp((const char *)pargv[i], "-ifile:", 7)) { + pWORD8 pb_arg_val = pargv[i] + 7; + WORD8 pb_input_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + err_code = IA_NO_ERROR; + strcat((char *)pb_input_file_name, (const char *)pb_input_file_path); + strcat((char *)pb_input_file_name, (const char *)pb_arg_val); + + g_pf_inp = NULL; + g_pf_inp = FileWrapper_Open((char *)pb_input_file_name); + if (g_pf_inp == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input File", err_code); + exit(1); + } + file_count++; + raw_testing = 0; + } + + if (!strncmp((const char *)fargv[i], "-imeta:", 7)) { + pWORD8 pb_arg_val = fargv[i] + 7; + WORD8 pb_metadata_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; + + strcat((char *)pb_metadata_file_name, (const char *)pb_input_file_path); + strcat((char *)pb_metadata_file_name, (const char *)pb_arg_val); + + g_pf_meta = NULL; + g_pf_meta = fopen((const char *)pb_metadata_file_name, "r"); + + if (g_pf_meta == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Metadata File", err_code); + exit(1); + } + + metadata_info_init(&meta_info); + err_code = ixheaacd_read_metadata_info(g_pf_meta, &meta_info); + + if (err_code == -1) { + exit(1); + } + + raw_testing = 1; + + file_count++; + } + + if (!strncmp((const char *)pargv[i], "-ofile:", 7)) { + pWORD8 pb_arg_val = pargv[i] + 7; +#ifndef REINIT_FOR_ERROR + WORD8 pb_output_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; +#endif + + strcat((char *)pb_output_file_name, (const char *)pb_output_file_path); + strcat((char *)pb_output_file_name, (const char *)pb_arg_val); + + g_pf_out = NULL; + g_pf_out = fopen((const char *)pb_output_file_name, "wb"); + if (g_pf_out == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Output File", err_code); + exit(1); + } + file_count++; + } + +#ifdef ERROR_PATTERN_READ + if (!strncmp((const char *)pargv[i], "-errfile:", 9)) { + pWORD8 pb_arg_val = pargv[i] + 9; + g_pf_err = fopen((const char *)pb_arg_val, "r"); + if (g_pf_err == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Error Pattern File", err_code); + } + } +#endif + } + g_w_malloc_count = 0; + + printf("\n"); + if (file_count != 2 && file_count != 3) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input or Output File", err_code); + } + + if (err_code == IA_NO_ERROR) { + if (g_pf_inp->isMp4File == 1) { + strcpy((pCHAR8)fargv[argc], "-mp4:1"); + pargv[argc] = fargv[argc]; + argc++; + } + + ixheaacd_main_process(argc - 1, &pargv[1] +#ifdef REINIT_FOR_ERROR + , + pb_output_file_name +#endif + ); + } + + for (i = 0; i < g_w_malloc_count; i++) { + // printf("I am here %d\n",__LINE__); + if (g_pv_arr_alloc_memory[i]) free(g_pv_arr_alloc_memory[i]); + // printf("I am here %d\n",__LINE__); + } + if (g_pf_out) fclose(g_pf_out); + + if (g_pf_meta) { + fclose(g_pf_meta); + memset_metadata(meta_info); + } + FileWrapper_Close(g_pf_inp); +#ifdef ERROR_PATTERN_READ + if (g_pf_err) fclose(g_pf_err); +#endif + } + +#ifdef ARM_PROFILE + fclose(fprofile); +#endif + + return IA_NO_ERROR; +} /* end ixheaacd_main */ diff --git a/test/ixheaacd_metadata_read.c b/test/ixheaacd_metadata_read.c new file mode 100644 index 0000000..c65a456 --- /dev/null +++ b/test/ixheaacd_metadata_read.c @@ -0,0 +1,202 @@ +/****************************************************************************** + * * + * 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 "ixheaacd_type_def.h" +#include +#include +#include +#include "ixheaacd_metadata_read.h" + +#define IA_MAX_CMDLINE_LENGTH 100 + +void metadata_info_init(metadata_info *meta_info) { + meta_info = (metadata_info *)malloc(sizeof(metadata_info)); +} + +void metadata_free(metadata_info *meta_info) { + if (meta_info->ia_mp4_stsz_size != NULL) free(meta_info->ia_mp4_stsz_size); + // free(meta_info); +} + +int ixheaacd_read_metadata_info(FILE *g_pf_metadata, metadata_info *meta_info) { + char cmd[IA_MAX_CMDLINE_LENGTH]; + + WORD32 file_count = 0; + WORD32 i, j, k, l; + i = j = k = l = 0; + while (fgets((char *)cmd, IA_MAX_CMDLINE_LENGTH, g_pf_metadata)) { + if (file_count < 5) { + if (!strncmp((pCHAR8)cmd, "-dec_info_init:", 15)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 15); + UWORD32 dec_info_init = atoi(pb_arg_val); + meta_info->dec_info_init = dec_info_init; + file_count++; + } else if (!strncmp((pCHAR8)cmd, "-g_track_count:", 15)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 15); + UWORD32 g_track_count = atoi(pb_arg_val); + meta_info->g_track_count = g_track_count; + file_count++; + } + + else if (!strncmp((pCHAR8)cmd, "-movie_time_scale:", 18)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 18); + UWORD32 movie_time_scale = atoi(pb_arg_val); + meta_info->movie_time_scale = movie_time_scale; + file_count++; + } + + else if (!strncmp((pCHAR8)cmd, "-media_time_scale:", 18)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 18); + UWORD32 media_time_scale = atoi(pb_arg_val); + meta_info->media_time_scale = media_time_scale; + file_count++; + } + + else if (!strncmp((pCHAR8)cmd, "-ia_mp4_stsz_entries:", 21)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 21); + UWORD32 ia_mp4_stsz_entries = atoi(pb_arg_val); + meta_info->ia_mp4_stsz_entries = ia_mp4_stsz_entries; + + meta_info->ia_mp4_stsz_size = + (UWORD32 *)malloc(sizeof(int) * ia_mp4_stsz_entries); + file_count++; + } else { + printf("Wrong file order,Check file order"); + return -1; + } + } else { + if (!strncmp((pCHAR8)cmd, "-playTimeInSamples:", 19)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 19); + UWORD32 playTimeInSamples = atoi(pb_arg_val); + meta_info->playTimeInSamples[i] = playTimeInSamples; + i++; + } + + else if (!strncmp((pCHAR8)cmd, "-startOffsetInSamples:", 22)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 22); + UWORD32 startOffsetInSamples = atoi(pb_arg_val); + meta_info->startOffsetInSamples[j] = startOffsetInSamples; + j++; + } + + else if (!strncmp((pCHAR8)cmd, "-useEditlist:", 13)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 13); + UWORD32 useEditlist = atoi(pb_arg_val); + meta_info->useEditlist[k] = useEditlist; + k++; + } + + else if (!strncmp((pCHAR8)cmd, "-ia_mp4_stsz_size:", 18)) { + pCHAR8 pb_arg_val = (pCHAR8)(cmd + 18); + UWORD32 ia_mp4_stsz_size = atoi(pb_arg_val); + meta_info->ia_mp4_stsz_size[l] = ia_mp4_stsz_size; + l++; + } + + else { + printf("Command not found"); + return -1; + } + } + } + + for (; i < MAX_TRACKS_PER_LAYER; i++) { + meta_info->playTimeInSamples[i] = 0; + } + + for (; j < MAX_TRACKS_PER_LAYER; j++) { + meta_info->startOffsetInSamples[j] = 0; + } + + for (; k < MAX_TRACKS_PER_LAYER; k++) { + meta_info->useEditlist[k] = 0; + } + +#if 0 + fill_once=meta_info->fill_once=0; + + for(i=0;iuseEditlist[i]; + startOffsetInSamples[i]=meta_info->startOffsetInSamples[i]; + playTimeInSamples[i]=meta_info->playTimeInSamples[i]; + } +#endif + return 0; +} + +int get_metadata_dec_info_init(metadata_info meta_info) { + return meta_info.dec_info_init; +} + +WORD32 get_metadata_dec_exec(metadata_info meta_info, int frame) { + return meta_info.ia_mp4_stsz_size[frame]; +} + +int get_movie_time_scale(metadata_info meta_info) { + return meta_info.movie_time_scale; +} + +int get_media_time_scale(metadata_info meta_info) { + return meta_info.media_time_scale; +} + +int get_g_track_count(metadata_info meta_info) { + return meta_info.g_track_count; +} + +int get_use_edit_list(metadata_info meta_info) { + return meta_info.useEditlist[0]; +} + +int get_start_offset_in_samples(metadata_info meta_info) { + return meta_info.startOffsetInSamples[0]; +} + +int get_play_time_in_samples(metadata_info meta_info) { + return meta_info.playTimeInSamples[0]; +} +/* +void update_start_offset_in_samples(metadata_info meta_info, int update) +{ + + meta_info.startOffsetInSamples[0]=update; +} +*/ + +/* +void update_play_time_in_samples(metadata_info meta_info, int update) +{ + + meta_info.playTimeInSamples[0]=update; + +} +*/ + +void memset_metadata(metadata_info meta_info) { + unsigned int i; + + for (i = 0; i < meta_info.g_track_count; i++) { + meta_info.startOffsetInSamples[i] = 0; + meta_info.startOffsetInSamples[i] = 0; + meta_info.playTimeInSamples[i] = 0; + } + + meta_info.g_track_count = 0; +} diff --git a/test/ixheaacd_metadata_read.h b/test/ixheaacd_metadata_read.h new file mode 100644 index 0000000..99d386c --- /dev/null +++ b/test/ixheaacd_metadata_read.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * * + * 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 __METADATA_H +#define __METADATA_H + +#define MAX_TRACKS_PER_LAYER 50 + +typedef struct { + UWORD32 *ia_mp4_stsz_size; + UWORD32 ia_mp4_stsz_entries; + UWORD32 fill_once; + UWORD32 movie_time_scale; + UWORD32 media_time_scale; + + UWORD32 dec_info_init; + UWORD32 g_track_count; + UWORD32 useEditlist[MAX_TRACKS_PER_LAYER]; + UWORD32 startOffsetInSamples[MAX_TRACKS_PER_LAYER]; + UWORD32 playTimeInSamples[MAX_TRACKS_PER_LAYER]; + +} metadata_info; + +void metadata_info_init(metadata_info *meta_info); + +int ixheaacd_read_metadata_info(FILE *fp, metadata_info *meta_info); + +int get_metadata_dec_info_init(metadata_info meta_info); + +int get_metadata_dec_exec(metadata_info meta_info, int frame); + +int get_start_offset_in_samples(metadata_info meta_info); + +int get_play_time_in_samples(metadata_info meta_info); + +void update_start_offset_in_samples(metadata_info meta_info, int update); + +void update_play_time_in_samples(metadata_info meta_info, int update); + +void memset_metadata(metadata_info meta_info); + +#endif