mirror of
https://github.com/ittiam-systems/libxaac.git
synced 2026-04-02 20:30:47 +07:00
USAC along with DRC support for libxaac encoder (#37)
This commit is contained in:
parent
e78e1c43c3
commit
797de4d1e9
173 changed files with 47678 additions and 354 deletions
48
Android.bp
48
Android.bp
|
|
@ -353,15 +353,44 @@ cc_library_static {
|
|||
export_include_dirs: [
|
||||
"common",
|
||||
"encoder",
|
||||
"encoder/drc_src",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
"common/ixheaac_esbr_fft.c",
|
||||
"common/ixheaac_esbr_rom.c",
|
||||
"common/ixheaac_fft_ifft_32x32_rom.c",
|
||||
"encoder/iusace_acelp_enc.c",
|
||||
"encoder/iusace_acelp_rom.c",
|
||||
"encoder/iusace_acelp_tools.c",
|
||||
"encoder/iusace_arith_enc.c",
|
||||
"encoder/iusace_avq_enc.c",
|
||||
"encoder/iusace_avq_rom.c",
|
||||
"encoder/iusace_block_switch.c",
|
||||
"encoder/iusace_bitbuffer.c",
|
||||
"encoder/iusace_enc_fac.c",
|
||||
"encoder/iusace_enc_main.c",
|
||||
"encoder/iusace_esbr_inter_tes.c",
|
||||
"encoder/iusace_esbr_pvc.c",
|
||||
"encoder/iusace_esbr_pvc_rom.c",
|
||||
"encoder/iusace_esbr_rom.c",
|
||||
"encoder/iusace_fd_fac.c",
|
||||
"encoder/iusace_fft.c",
|
||||
"encoder/iusace_lpc.c",
|
||||
"encoder/iusace_lpc_avq.c",
|
||||
"encoder/iusace_lpd_enc.c",
|
||||
"encoder/iusace_lpd_rom.c",
|
||||
"encoder/iusace_lpd_utils.c",
|
||||
"encoder/iusace_ms.c",
|
||||
"encoder/iusace_psy_rom.c",
|
||||
"encoder/iusace_psy_mod.c",
|
||||
"encoder/iusace_psy_utils.c",
|
||||
"encoder/iusace_rom.c",
|
||||
"encoder/iusace_tcx_enc.c",
|
||||
"encoder/iusace_tcx_mdct.c",
|
||||
"encoder/iusace_tns_usac.c",
|
||||
"encoder/iusace_windowing.c",
|
||||
"encoder/iusace_write_bitstream.c",
|
||||
"encoder/ixheaace_adjust_threshold.c",
|
||||
"encoder/ixheaace_api.c",
|
||||
"encoder/ixheaace_asc_write.c",
|
||||
|
|
@ -373,9 +402,15 @@ cc_library_static {
|
|||
"encoder/ixheaace_calc_ms_band_energy.c",
|
||||
"encoder/ixheaace_channel_map.c",
|
||||
"encoder/ixheaace_common_rom.c",
|
||||
"encoder/ixheaace_cplx_pred.c",
|
||||
"encoder/ixheaace_dynamic_bits.c",
|
||||
"encoder/ixheaace_enc_init.c",
|
||||
"encoder/ixheaace_enc_main.c",
|
||||
"encoder/ixheaace_fd_enc.c",
|
||||
"encoder/ixheaace_fd_mdct.c",
|
||||
"encoder/ixheaace_fd_qc_adjthr.c",
|
||||
"encoder/ixheaace_fd_qc_util.c",
|
||||
"encoder/ixheaace_fd_quant.c",
|
||||
"encoder/ixheaace_fft.c",
|
||||
"encoder/ixheaace_group_data.c",
|
||||
"encoder/ixheaace_huffman_rom.c",
|
||||
|
|
@ -403,6 +438,7 @@ cc_library_static {
|
|||
"encoder/ixheaace_mps_tree.c",
|
||||
"encoder/ixheaace_mps_vector_functions.c",
|
||||
"encoder/ixheaace_ms_stereo.c",
|
||||
"encoder/ixheaace_nf.c",
|
||||
"encoder/ixheaace_ps_bitenc.c",
|
||||
"encoder/ixheaace_ps_enc.c",
|
||||
"encoder/ixheaace_ps_enc_init.c",
|
||||
|
|
@ -425,6 +461,8 @@ cc_library_static {
|
|||
"encoder/ixheaace_sbr_frame_info_gen.c",
|
||||
"encoder/ixheaace_sbr_freq_scaling.c",
|
||||
"encoder/ixheaace_sbr_hbe_dft_trans.c",
|
||||
"encoder/ixheaace_sbr_hbe_fft_ifft_32x32.c",
|
||||
"encoder/ixheaace_sbr_hbe_polyphase.c",
|
||||
"encoder/ixheaace_sbr_hbe_trans.c",
|
||||
"encoder/ixheaace_sbr_inv_filtering_estimation.c",
|
||||
"encoder/ixheaace_sbr_main.c",
|
||||
|
|
@ -440,6 +478,8 @@ cc_library_static {
|
|||
"encoder/ixheaace_sbr_tran_det_hp.c",
|
||||
"encoder/ixheaace_sbr_write_bitstream.c",
|
||||
"encoder/ixheaace_sf_estimation.c",
|
||||
"encoder/ixheaace_signal_classifier.c",
|
||||
"encoder/ixheaace_signal_classifier_rom.c",
|
||||
"encoder/ixheaace_static_bits.c",
|
||||
"encoder/ixheaace_stereo_preproc.c",
|
||||
"encoder/ixheaace_tns.c",
|
||||
|
|
@ -448,6 +488,14 @@ cc_library_static {
|
|||
"encoder/ixheaace_tns_params.c",
|
||||
"encoder/ixheaace_write_adts_adif.c",
|
||||
"encoder/ixheaace_write_bitstream.c",
|
||||
"encoder/drc_src/impd_drc_api.c",
|
||||
"encoder/drc_src/impd_drc_enc.c",
|
||||
"encoder/drc_src/impd_drc_gain_calculator.c",
|
||||
"encoder/drc_src/impd_drc_gain_enc.c",
|
||||
"encoder/drc_src/impd_drc_mux.c",
|
||||
"encoder/drc_src/impd_drc_tables.c",
|
||||
"encoder/drc_src/impd_drc_uni_drc_eq.c",
|
||||
"encoder/drc_src/impd_drc_uni_drc_filter_bank.c",
|
||||
],
|
||||
|
||||
sanitize: {
|
||||
|
|
|
|||
|
|
@ -26,3 +26,4 @@ include("${XAAC_ROOT}/fuzzer/xaac_dec_fuzzer.cmake")
|
|||
include("${XAAC_ROOT}/encoder/libxaacenc.cmake")
|
||||
include("${XAAC_ROOT}/test/encoder/xaacenc.cmake")
|
||||
include("${XAAC_ROOT}/fuzzer/xaac_enc_fuzzer.cmake")
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@ As the Extended High Efficiency AAC Profile is a logical evolution of the MPEG A
|
|||
|
||||
One of the key features of libxaac (refer to above image) is that it has support for AAC-LD (Low Delay), AAC-ELD (Enhanced Low Delay), and AAC-ELDv2 (Enhanced Low Delay version 2) modes. AAC-LD mode provides low latency encoding, making it suitable for applications such as interactive communication and live audio streaming. It helps to reduce the delay in the encoding process to improve the real-time performance of the system. AAC-ELD mode improves the low-delay performance of HE-AAC by reducing the coding delay while maintaining high audio quality. It was observed that minimum delay it can achieve is 15ms. In order to achieve low delay coding scheme and low bitrate, it uses the Low Delay SBR tool. AAC-ELDv2 is the most advanced version of AAC-based low delay coding. It provides an enhanced version of AAC-ELD, which provides even lower coding delay and higher audio quality.
|
||||
|
||||
MPEG-D USAC, also known as Unified Speech and Audio Coding, is designed to provide high-quality audio coding at low bit rates. MPEG-D USAC combines advanced audio coding techniques with state-of-the-art speech coding algorithms to achieve significant compression gains while maintaining perceptual audio quality. The standard supports a wide range of audio content, including music, speech, and mixed audio, making it versatile for different use cases. With its ability to deliver high-fidelity audio at reduced bit rates, MPEG-D USAC plays a crucial role in optimizing bandwidth usage and enhancing the user experience in the digital audio domain.
|
||||
|
||||
Overall, libxaac, with support for AAC-LD, AAC-ELD, and AAC-ELDv2 modes, is a versatile audio coding technology that can be used for a wide range of applications, such as broadcasting, streaming, and teleconferencing which requires high-quality audio compression with minimal delay.
|
||||
|
||||
Also, the libxaac decoder supports MPEG-D DRC (Dynamic Range Control) for the Extended HE-AAC profile. MPEG-D DRC offers a bitrate efficient representation of dynamically compressed versions of an audio signal. This is achieved by adding a low-bitrate DRC metadata stream to the audio signal. DRC includes dedicated sections for metadata-based loudness leveling, clipping prevention, ducking, and for generating a fade-in and fade-out to supplement the main dynamic range compression functionality. The DRC effects available at the DRC decoder are generated at the DRC encoder side. At the DRC decoder side, the audio signal may be played back without applying DRC, or an appropriate DRC effect is selected and applied based on the given playback scenario. It offers flexible solutions to efficiently support the widespread demand for technologies such as loudness normalization and dynamic range compression for various playback scenarios.
|
||||
|
||||
Also, the libxaac supports MPEG-D DRC (Dynamic Range Control) for the Extended HE-AAC profile in both encoder and decoder. MPEG-D DRC offers a bitrate efficient representation of dynamically compressed versions of an audio signal. This is achieved by adding a low-bitrate DRC metadata stream to the audio signal. DRC includes dedicated sections for metadata-based loudness leveling, clipping prevention, ducking, and for generating a fade-in and fade-out to supplement the main dynamic range compression functionality. The DRC effects available at the DRC decoder are generated at the DRC encoder side. At the DRC decoder side, the audio signal may be played back without applying DRC, or an appropriate DRC effect is selected and applied based on the given playback scenario. It offers flexible solutions to efficiently support the widespread demand for technologies such as loudness normalization and dynamic range compression for various playback scenarios.
|
||||
|
||||
#### Note
|
||||
* MPEG-D USAC (along with MPEG-D DRC) support for libxaac encoder will be coming soon, which will help in improved audio quality at reduced bitrates. USAC technology will provide efficient and high quality compression of speech and audio signals, making it a valuable addition to our libxaac capabilities and features.
|
||||
* The operating points for MPEG-D USAC (along with MPEG-D DRC) in libxaac encoder is currently restricted to 64 kbps and 96 kbps. It is recommended to use the encoder at these operating points only. The support shall be extended to other operating points soon.
|
||||
* Further Quality enhancements for AAC-ELD and AAC-ELDv2 modes may be pushed as quality assessment is in progress.
|
||||
|
||||
# Building the libxaac decoder and encoder
|
||||
|
|
|
|||
|
|
@ -20,29 +20,38 @@
|
|||
|23|AAC-LD|
|
||||
|29|HE-AACv2|
|
||||
|39|AAC-ELD|
|
||||
|42|USAC (support will be added soon)|
|
||||
|42|USAC|
|
||||
|
||||
# Running the libxaac encoder
|
||||
The libxaac encoder can be run by providing command-line parameters(CLI options) directly or by providing a parameter file as a command line argument.
|
||||
The reference paramfile is placed in `encoder\test` directory(paramfilesimple.txt)
|
||||
The configuration file for DRC is placed in `encoder\test` directory(impd_drc_config_params.txt). Please make sure this file is placed in the same directory as the executable.
|
||||
|
||||
# Command line usage :
|
||||
```
|
||||
<exceutable> -ifile:<input_file> -ofile:<out_file> [options]
|
||||
(or)
|
||||
<executable> -paramfile:<paramfile>
|
||||
|
||||
[options] can be,
|
||||
[-br:<bitrate>]
|
||||
[-mps:<use_mps>]
|
||||
[-adts:<use_adts_flag>]
|
||||
[-tns:<use_tns_flag>]
|
||||
[-nf:<use_noise_filling>]
|
||||
[-cmpx_pred:<use_complex_prediction>]
|
||||
[-framesize:<framesize_to_be_used>]
|
||||
[-aot:<audio_object_type>]
|
||||
[-esbr:<esbr_flag>]
|
||||
[-full_bandwidth:<Enable use of full bandwidth of input>]
|
||||
[-full_bandwidth:<enable_full_bandwidth>]
|
||||
[-max_out_buffer_per_ch:<bitreservoir_size>]
|
||||
[-tree_cfg:<tree_config>]
|
||||
[-usac:<usac_encoding_mode>]
|
||||
[-ccfl_idx:<corecoder_framelength_index>]
|
||||
[-pvc_enc:<pvc_enc_flag>]
|
||||
[-harmonic_sbr:<harmonic_sbr_flag>]
|
||||
[-esbr_hq:<esbr_hq_flag>]
|
||||
[-drc:<drc_flag>]
|
||||
[-inter_tes_enc:<inter_tes_enc_flag>]
|
||||
|
||||
where,
|
||||
<paramfile> is the parameter file with multiple commands
|
||||
|
|
@ -52,26 +61,46 @@ where,
|
|||
<use_mps> Valid values are 0 (disable MPS) and 1 (enable MPS). Default is 0.
|
||||
<use_adts_flag> Valid values are 0 ( No ADTS header) and 1 ( generate ADTS header). Default is 0.
|
||||
<use_tns_flag> Valid values are 0 (disable TNS) and 1 (enable TNS). Default is 1.
|
||||
<use_noise_filling> controls usage of noise filling in encoding. Default 0.
|
||||
<use_complex_prediction> controls usage of complex prediction in encoding. Default is 0.
|
||||
<framesize_to_be_used> is the framesize to be used.
|
||||
For AOT 23, 39 (LD core coder profiles) valid values are 480 and 512. Default is 512.
|
||||
For AOT 2, 5, 29 (LC core coder profiles) valid values are 960 and 1024. Default is 1024.
|
||||
<audio_object_type> is the Audio object type
|
||||
2 for AAC-LC
|
||||
5 for HE-AACv1(Legacy SBR)
|
||||
23 for AAC-LD
|
||||
29 for HE-AACv2
|
||||
39 for AAC-ELD
|
||||
Default is 2 for AAC-LC.
|
||||
<esbr_flag> Valid values are 0 (disable eSBR) and 1 (enable eSBR in HE-AACv1 encoding). Default is 0.
|
||||
<full_bandwidth> Enable use of full bandwidth of input. Valid values are 0(disable full bandwidth) and 1(enable full bandwidth). Default is 0.
|
||||
<bitreservoir_size> is the maximum size of bit reservoir to be used.
|
||||
Valid values are from -1 to 6144. -1 will omit use of bit reservoir. Default is 384.
|
||||
For AOT 23, 39 (LD core coder profiles) valid values are 480 and 512. Default is 512.
|
||||
For AOT 2, 5, 29 (LC core coder profiles) valid values are 960 and 1024. Default is 1024.
|
||||
For AOT 42 (USAC profile) valid values are 768 and 1024. Default is 1024.
|
||||
<audio_object_type> is the Audio object type.
|
||||
2 for AAC-LC
|
||||
5 for HE-AACv1(Legacy SBR)
|
||||
23 for AAC-LD
|
||||
29 for HE-AACv2
|
||||
39 for AAC-ELD
|
||||
42 for USAC
|
||||
Default is 2 for AAC-LC.
|
||||
<esbr_flag> Valid values are 0 (disable eSBR) and 1 (enable eSBR). Default is 0 for HE-AACv1 profile (legacy SBR) and 1 for USAC profile.
|
||||
<enable_full_bandwidth> Enable use of full bandwidth of input. Valid values are 0(disable full bandwidth) and 1(enable full bandwidth). Default is 0.
|
||||
<bitreservoir_size> is the maximum size of bit reservoir to be used. Valid values are from -1 to 6144. -1 will omit use of bit reservoir. Default is 384.
|
||||
<tree_config> MPS tree config
|
||||
0 for '212'
|
||||
1 for '5151'
|
||||
2 for '5152'
|
||||
3 for '525'
|
||||
Default '212' for stereo input and '5151' for 6ch input.
|
||||
0 for '212'
|
||||
1 for '5151'
|
||||
2 for '5152'
|
||||
3 for '525'
|
||||
Default 0 for stereo input and 1 for 6ch input.
|
||||
<usac_encoding_mode> USAC encoding mode to be chose
|
||||
0 for 'usac_switched'
|
||||
1 for 'usac_fd'
|
||||
2 for 'usac_td'
|
||||
Default 'usac_fd'
|
||||
<corecoder_framelength_index> is the core coder framelength index for USAC encoder.
|
||||
Valid values are 0, 1, 2, 3, 4. eSBR enabling is implicit
|
||||
0 - Core coder framelength of USAC is 768 and eSBR is disabled
|
||||
1 - Core coder framelength of USAC is 1024 and eSBR is disabled
|
||||
2 - Core coder framelength of USAC is 768 and eSBR ratio 8:3
|
||||
3 - Core coder framelength of USAC is 1024 and eSBR ratio 2:1
|
||||
4 - Core coder framelength of USAC is 1024 and eSBR ratio 4:1
|
||||
<pvc_enc_flag> Valid values are 0 (disable PVC encoding) and 1 (enable PVC encoding). Default is 0.
|
||||
<harmonic_sbr_flag> Valid values are 0 (disable harmonic SBR) and 1 (enable harmonic SBR). Default is 0.
|
||||
<esbr_hq_flag> Valid values are 0 (disable high quality eSBR) and 1 (enable high quality eSBR). Default is 0.
|
||||
<drc_flag> Valid values are 0 (disable DRC encoding) and 1 (enable DRC encoding). Default is 0.
|
||||
<inter_tes_enc_flag> Valid values are 0 (disable inter-TES encoding) and 1 (enable inter-TES encoding). Default is 0.
|
||||
```
|
||||
Sample CLI:
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
#ifndef IMPD_DRC_TABLES_H
|
||||
#define IMPD_DRC_TABLES_H
|
||||
|
||||
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},
|
||||
};
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
210
encoder/drc_src/impd_drc_api.c
Normal file
210
encoder/drc_src/impd_drc_api.c
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
#include "impd_drc_enc.h"
|
||||
|
||||
static IA_ERRORCODE impd_drc_validate_drc_instructions(
|
||||
ia_drc_uni_drc_config_struct *pstr_uni_drc_config) {
|
||||
LOOPIDX i, j;
|
||||
WORD32 profile_found = FALSE;
|
||||
|
||||
for (i = 0; i < pstr_uni_drc_config->drc_instructions_uni_drc_count; i++) {
|
||||
profile_found = FALSE;
|
||||
for (j = 0; j < pstr_uni_drc_config->drc_coefficients_uni_drc_count; j++) {
|
||||
if (pstr_uni_drc_config->str_drc_coefficients_uni_drc[j].drc_location == 1) {
|
||||
profile_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pstr_uni_drc_config->uni_drc_config_ext_present &&
|
||||
pstr_uni_drc_config->str_uni_drc_config_ext.parametric_drc_present &&
|
||||
pstr_uni_drc_config->str_uni_drc_config_ext.str_drc_coeff_parametric_drc.drc_location ==
|
||||
1) {
|
||||
profile_found = TRUE;
|
||||
}
|
||||
if (profile_found == FALSE) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_INVALID_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
IA_ERRORCODE impd_drc_enc_init(VOID *pstr_drc_state, VOID *ptr_drc_scratch,
|
||||
ia_drc_input_config *pstr_inp_config) {
|
||||
IA_ERRORCODE err_code = IA_NO_ERROR;
|
||||
WORD32 bit_count = 0;
|
||||
ia_drc_enc_state *pstr_drc_state_local = pstr_drc_state;
|
||||
|
||||
#ifdef ENABLE_SET_JUMP
|
||||
jmp_buf drc_enc_init_jmp_buf;
|
||||
err_code = setjmp(drc_enc_init_jmp_buf);
|
||||
if (err_code != IA_NO_ERROR) {
|
||||
return IA_EXHEAACE_INIT_FATAL_DRC_INSUFFICIENT_WRITE_BUFFER_SIZE;
|
||||
}
|
||||
#endif // ENABLE_SET_JUMP
|
||||
|
||||
pstr_drc_state_local->drc_scratch_mem = ptr_drc_scratch;
|
||||
pstr_drc_state_local->drc_scratch_used = 0;
|
||||
|
||||
iusace_create_bit_buffer(&pstr_drc_state_local->str_bit_buf_cfg,
|
||||
pstr_drc_state_local->bit_buf_base_cfg,
|
||||
sizeof(pstr_drc_state_local->bit_buf_base_cfg), 1);
|
||||
|
||||
iusace_create_bit_buffer(&pstr_drc_state_local->str_bit_buf_cfg_ext,
|
||||
pstr_drc_state_local->bit_buf_base_cfg_ext,
|
||||
sizeof(pstr_drc_state_local->bit_buf_base_cfg_ext), 1);
|
||||
|
||||
iusace_create_bit_buffer(&pstr_drc_state_local->str_bit_buf_cfg_tmp,
|
||||
pstr_drc_state_local->bit_buf_base_cfg_tmp,
|
||||
sizeof(pstr_drc_state_local->bit_buf_base_cfg_tmp), 1);
|
||||
|
||||
iusace_create_bit_buffer(&pstr_drc_state_local->str_bit_buf_out,
|
||||
pstr_drc_state_local->bit_buf_base_out,
|
||||
sizeof(pstr_drc_state_local->bit_buf_base_out), 1);
|
||||
|
||||
#ifdef ENABLE_SET_JUMP
|
||||
pstr_drc_state_local->str_bit_buf_cfg.impd_drc_jmp_buf = &drc_enc_init_jmp_buf;
|
||||
pstr_drc_state_local->str_bit_buf_cfg_ext.impd_drc_jmp_buf = &drc_enc_init_jmp_buf;
|
||||
pstr_drc_state_local->str_bit_buf_cfg_tmp.impd_drc_jmp_buf = &drc_enc_init_jmp_buf;
|
||||
pstr_drc_state_local->str_bit_buf_out.impd_drc_jmp_buf = &drc_enc_init_jmp_buf;
|
||||
#endif // ENABLE_SET_JUMP
|
||||
|
||||
err_code = impd_drc_gain_enc_init(
|
||||
&pstr_drc_state_local->str_gain_enc, &pstr_inp_config->str_uni_drc_config,
|
||||
&pstr_inp_config->str_enc_loudness_info_set, pstr_inp_config->str_enc_params.frame_size,
|
||||
pstr_inp_config->str_enc_params.sample_rate, pstr_inp_config->str_enc_params.delay_mode,
|
||||
pstr_inp_config->str_enc_params.domain);
|
||||
if (err_code & IA_FATAL_ERROR) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_INVALID_CONFIG;
|
||||
}
|
||||
|
||||
pstr_drc_state_local->str_enc_params = pstr_inp_config->str_enc_params;
|
||||
pstr_drc_state_local->str_uni_drc_config = pstr_inp_config->str_uni_drc_config;
|
||||
pstr_drc_state_local->str_enc_gain_extension = pstr_inp_config->str_enc_gain_extension;
|
||||
|
||||
err_code = impd_drc_validate_drc_instructions(&pstr_inp_config->str_uni_drc_config);
|
||||
if (err_code & IA_FATAL_ERROR) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_INVALID_CONFIG;
|
||||
}
|
||||
|
||||
err_code = impd_drc_write_uni_drc_config(pstr_drc_state_local, &bit_count);
|
||||
if (err_code & IA_FATAL_ERROR) {
|
||||
return err_code;
|
||||
}
|
||||
|
||||
pstr_drc_state_local->drc_config_data_size_bit = bit_count;
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
VOID impd_drc_enc(VOID *pstr_drc_state, FLOAT32 **pptr_input, UWORD32 inp_offset,
|
||||
WORD32 *ptr_bits_written, VOID *pstr_scratch) {
|
||||
LOOPIDX i, j, k;
|
||||
WORD32 band_count = 0;
|
||||
WORD32 stop_sub_band_index;
|
||||
WORD32 num_bits_payload = 0;
|
||||
UWORD8 is_fft_ready[MAX_NUM_CHANNELS] = {0};
|
||||
ia_drc_enc_state *pstr_drc_state_local = pstr_drc_state;
|
||||
ia_drc_gain_enc_struct *pstr_gain_enc = &pstr_drc_state_local->str_gain_enc;
|
||||
ia_drc_uni_drc_config_struct *pstr_uni_drc_config = &pstr_drc_state_local->str_uni_drc_config;
|
||||
ia_drc_compand_struct *pstr_drc_compand;
|
||||
ia_drc_stft_gain_calc_struct *pstr_drc_stft_gain_calc;
|
||||
|
||||
if (pstr_drc_state_local->str_enc_params.gain_sequence_present) {
|
||||
for (i = 0; i < MAX_DRC_COEFF_COUNT; i++) {
|
||||
for (j = 0; j < GAIN_SET_COUNT_MAX; j++) {
|
||||
pstr_drc_stft_gain_calc = &pstr_gain_enc->str_drc_stft_gain_handle[i][j][0];
|
||||
pstr_drc_compand = &pstr_gain_enc->str_drc_compand[i][j];
|
||||
if ((pstr_drc_compand->is_valid == 0) && (pstr_drc_stft_gain_calc->is_valid == 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pstr_drc_compand->is_valid == 0) {
|
||||
if (is_fft_ready[pstr_drc_stft_gain_calc->ch_idx] == 0) {
|
||||
impd_drc_stft_drc_convert_to_fd(
|
||||
pstr_gain_enc, &pptr_input[pstr_drc_stft_gain_calc->ch_idx][inp_offset],
|
||||
pstr_drc_stft_gain_calc->ch_idx, pstr_drc_state_local->str_enc_params.frame_size,
|
||||
pstr_gain_enc->complex_fft_ptr[pstr_drc_stft_gain_calc->ch_idx], pstr_scratch);
|
||||
is_fft_ready[pstr_drc_stft_gain_calc->ch_idx] = 1;
|
||||
}
|
||||
|
||||
for (k = 0; k < pstr_uni_drc_config->str_drc_coefficients_uni_drc[i]
|
||||
.str_gain_set_params[j]
|
||||
.band_count;
|
||||
k++) {
|
||||
if (k == pstr_uni_drc_config->str_drc_coefficients_uni_drc[i]
|
||||
.str_gain_set_params[j]
|
||||
.band_count -
|
||||
1) {
|
||||
stop_sub_band_index = STFT256_HOP_SIZE - 1;
|
||||
} else {
|
||||
stop_sub_band_index = pstr_uni_drc_config->str_drc_coefficients_uni_drc[i]
|
||||
.str_gain_set_params[j]
|
||||
.gain_params[k + 1]
|
||||
.start_sub_band_index -
|
||||
1;
|
||||
}
|
||||
|
||||
impd_drc_stft_drc_gain_calc_process(
|
||||
pstr_gain_enc, i, j, k,
|
||||
pstr_uni_drc_config->str_drc_coefficients_uni_drc[i]
|
||||
.str_gain_set_params[j]
|
||||
.gain_params[k]
|
||||
.start_sub_band_index,
|
||||
stop_sub_band_index, pstr_drc_state_local->str_enc_params.frame_size,
|
||||
pstr_gain_enc->complex_fft_ptr[pstr_drc_stft_gain_calc->ch_idx],
|
||||
pstr_drc_state_local->gain_buffer[band_count + k]);
|
||||
}
|
||||
} else {
|
||||
impd_drc_td_drc_gain_calc_process(pstr_gain_enc, i, j,
|
||||
pstr_drc_state_local->str_enc_params.frame_size,
|
||||
&pptr_input[pstr_drc_compand->ch_idx][inp_offset],
|
||||
pstr_drc_state_local->gain_buffer[band_count]);
|
||||
}
|
||||
|
||||
band_count += pstr_uni_drc_config->str_drc_coefficients_uni_drc[i]
|
||||
.str_gain_set_params[j]
|
||||
.band_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
impd_drc_encode_uni_drc_gain(pstr_gain_enc, pstr_drc_state_local->gain_buffer[0], pstr_scratch);
|
||||
|
||||
if (pstr_drc_state_local->is_first_drc_process_complete == 1) {
|
||||
impd_drc_write_uni_drc_gain(pstr_drc_state_local, &num_bits_payload);
|
||||
}
|
||||
|
||||
*ptr_bits_written = num_bits_payload;
|
||||
}
|
||||
43
encoder/drc_src/impd_drc_api.h
Normal file
43
encoder/drc_src/impd_drc_api.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
typedef struct {
|
||||
WORD32 frame_size;
|
||||
WORD32 sample_rate;
|
||||
WORD32 delay_mode;
|
||||
WORD32 domain;
|
||||
WORD32 parametric_drc_only;
|
||||
WORD32 frame_count;
|
||||
WORD32 gain_sequence_present;
|
||||
} ia_drc_enc_params_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_drc_enc_params_struct str_enc_params;
|
||||
ia_drc_uni_drc_config_struct str_uni_drc_config;
|
||||
ia_drc_loudness_info_set_struct str_enc_loudness_info_set;
|
||||
ia_drc_uni_drc_gain_ext_struct str_enc_gain_extension;
|
||||
} ia_drc_input_config;
|
||||
|
||||
IA_ERRORCODE impd_drc_enc_init(VOID *pstr_drc_state, VOID *ptr_drc_scratch,
|
||||
ia_drc_input_config *pstr_inp_config);
|
||||
|
||||
VOID impd_drc_enc(VOID *pstr_drc_state, FLOAT32 **pptr_input, UWORD32 inp_offset,
|
||||
WORD32 *ptr_bits_written, VOID *pstr_scratch);
|
||||
79
encoder/drc_src/impd_drc_common_enc.h
Normal file
79
encoder/drc_src/impd_drc_common_enc.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define MAX_DRC_PAYLOAD_BYTES (2048)
|
||||
#define MAX_SPEAKER_POS_COUNT (128)
|
||||
#define MAX_DOWNMIX_COEFF_COUNT (32 * 32)
|
||||
#define MAX_CHANNEL_COUNT (128)
|
||||
#define MAX_BAND_COUNT (8)
|
||||
#define MAX_SEQUENCE_COUNT (8)
|
||||
#define MAX_MEASUREMENT_COUNT (16)
|
||||
#define MAX_DOWNMIX_INSTRUCTION_COUNT (16)
|
||||
#define MAX_DRC_COEFF_COUNT (8)
|
||||
#define MAX_DRC_INSTRUCTIONS_COUNT (MAX_DOWNMIX_INSTRUCTION_COUNT + 16)
|
||||
#define MAX_LOUDNESS_INFO_COUNT (MAX_DOWNMIX_INSTRUCTION_COUNT + 16)
|
||||
#define MAX_AUDIO_CODEC_FRAME_SIZE (2048)
|
||||
#define MAX_DRC_CODEC_FRAME_SIZE (MAX_AUDIO_CODEC_FRAME_SIZE / 8)
|
||||
#define MAX_NODE_COUNT (MAX_DRC_CODEC_FRAME_SIZE)
|
||||
#define MAX_CHANNEL_GROUP_COUNT (MAX_SEQUENCE_COUNT)
|
||||
#define MAX_ADDITIONAL_DOWNMIX_ID (8)
|
||||
#define DELAY_MODE_REGULAR_DELAY (0)
|
||||
#define MAX_EXT_COUNT (2)
|
||||
|
||||
#define UNIDRC_GAIN_EXT_TERM (0x0)
|
||||
#define UNIDRC_LOUD_EXT_TERM (0x0)
|
||||
#define UNIDRC_CONF_EXT_TERM (0x0)
|
||||
#define UNIDRC_CONF_EXT_PARAM_DRC (0x1)
|
||||
#define UNIDRC_CONF_EXT_V1 (0x2)
|
||||
#define UNIDRC_LOUD_EXT_EQ (0x1)
|
||||
|
||||
#define MAX_PARAM_DRC_INSTRUCTIONS_COUNT (8)
|
||||
|
||||
#define PARAM_DRC_TYPE_FF (0x0)
|
||||
#define MAX_PARAM_DRC_TYPE_FF_NODE_COUNT (9)
|
||||
|
||||
#define PARAM_DRC_TYPE_LIM (0x1)
|
||||
#define PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT (5)
|
||||
|
||||
#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 QMF64_AUDIO_CODEC_SUBBAND_COUNT (64)
|
||||
#define QMF64_AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR (64)
|
||||
|
||||
#define QMF71_AUDIO_CODEC_SUBBAND_COUNT (71)
|
||||
#define QMF71_AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR (64)
|
||||
|
||||
#define STFT256_AUDIO_CODEC_SUBBAND_COUNT (256)
|
||||
#define STFT256_AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR (256)
|
||||
|
||||
#define TIME_DOMAIN (1)
|
||||
#define SUBBAND_DOMAIN (2)
|
||||
#define SLOPE_FACTOR_DB_TO_LINEAR (0.1151f) /* ln(10) / 20 */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
284
encoder/drc_src/impd_drc_enc.c
Normal file
284
encoder/drc_src/impd_drc_enc.c
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
#include "impd_drc_enc.h"
|
||||
|
||||
static VOID impd_drc_util_stft_read_gain_config(
|
||||
ia_drc_stft_gain_calc_struct *pstr_stft_drc_gain_handle, WORD32 band_count,
|
||||
ia_drc_gain_set_params_struct *str_gain_set_params) {
|
||||
LOOPIDX i, j;
|
||||
WORD32 num_points;
|
||||
|
||||
for (i = 0; i < band_count; i++) {
|
||||
num_points = str_gain_set_params->gain_params[i].nb_points;
|
||||
pstr_stft_drc_gain_handle[i].nb_points = num_points;
|
||||
for (j = 0; j < num_points; j++) {
|
||||
pstr_stft_drc_gain_handle[i].str_segment[2 * (j + 1)].x =
|
||||
str_gain_set_params->gain_params[i].gain_points[j].x;
|
||||
pstr_stft_drc_gain_handle[i].str_segment[2 * (j + 1)].y =
|
||||
str_gain_set_params->gain_params[i].gain_points[j].y;
|
||||
}
|
||||
|
||||
pstr_stft_drc_gain_handle[i].width_db = str_gain_set_params->gain_params[i].width;
|
||||
pstr_stft_drc_gain_handle[i].attack_ms = str_gain_set_params->gain_params[i].attack;
|
||||
pstr_stft_drc_gain_handle[i].release_ms = str_gain_set_params->gain_params[i].decay;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID impd_drc_util_td_read_gain_config(
|
||||
ia_drc_compand_struct *pstr_drc_compand, ia_drc_gain_set_params_struct *str_gain_set_params) {
|
||||
LOOPIDX idx;
|
||||
WORD32 num_points;
|
||||
|
||||
num_points = str_gain_set_params->gain_params[0].nb_points;
|
||||
pstr_drc_compand->nb_points = num_points;
|
||||
for (idx = 0; idx < num_points; idx++) {
|
||||
pstr_drc_compand->str_segment[2 * (idx + 1)].x =
|
||||
str_gain_set_params->gain_params[0].gain_points[idx].x;
|
||||
pstr_drc_compand->str_segment[2 * (idx + 1)].y =
|
||||
str_gain_set_params->gain_params[0].gain_points[idx].y;
|
||||
}
|
||||
|
||||
pstr_drc_compand->width_db = str_gain_set_params->gain_params[0].width;
|
||||
pstr_drc_compand->str_channel_param.attack = str_gain_set_params->gain_params[0].attack;
|
||||
pstr_drc_compand->str_channel_param.decay = str_gain_set_params->gain_params[0].decay;
|
||||
|
||||
pstr_drc_compand->str_channel_param.attack /= 1000.0;
|
||||
pstr_drc_compand->str_channel_param.decay /= 1000.0;
|
||||
}
|
||||
|
||||
IA_ERRORCODE impd_drc_gain_enc_init(ia_drc_gain_enc_struct *pstr_gain_enc,
|
||||
ia_drc_uni_drc_config_struct *pstr_uni_drc_config,
|
||||
ia_drc_loudness_info_set_struct *pstr_loudness_info_set,
|
||||
const WORD32 frame_size, const WORD32 sample_rate,
|
||||
const WORD32 delay_mode, const WORD32 domain) {
|
||||
IA_ERRORCODE err_code = IA_NO_ERROR;
|
||||
LOOPIDX i, j, k, l, m, ch;
|
||||
WORD32 num_gain_values_max;
|
||||
WORD32 params_found;
|
||||
UWORD8 found_ch_idx;
|
||||
UWORD32 ch_idx;
|
||||
|
||||
ia_drc_uni_drc_config_ext_struct *pstr_uni_drc_config_ext =
|
||||
&pstr_uni_drc_config->str_uni_drc_config_ext;
|
||||
ia_drc_coefficients_uni_drc_struct *pstr_drc_coefficients_uni_drc =
|
||||
&pstr_uni_drc_config->str_drc_coefficients_uni_drc[0];
|
||||
ia_drc_coefficients_uni_drc_struct *pstr_drc_coefficients_uni_drc_v1 =
|
||||
&pstr_uni_drc_config_ext->str_drc_coefficients_uni_drc_v1[0];
|
||||
|
||||
if (pstr_uni_drc_config_ext->drc_coefficients_uni_drc_v1_count <= 0) {
|
||||
WORD32 all_band_gain_count = 0;
|
||||
WORD32 gain_set_count = pstr_drc_coefficients_uni_drc->gain_set_count;
|
||||
for (i = 0; i < gain_set_count; i++) {
|
||||
all_band_gain_count += pstr_drc_coefficients_uni_drc->str_gain_set_params[i].band_count;
|
||||
}
|
||||
pstr_gain_enc->n_sequences = all_band_gain_count;
|
||||
} else {
|
||||
pstr_gain_enc->n_sequences = pstr_drc_coefficients_uni_drc_v1->gain_sequence_count;
|
||||
}
|
||||
|
||||
if (pstr_gain_enc->n_sequences > IMPD_DRCMAX_NSEQ) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if ((pstr_uni_drc_config_ext->drc_coefficients_uni_drc_v1_count > 0) &&
|
||||
(pstr_drc_coefficients_uni_drc_v1->drc_frame_size_present)) {
|
||||
pstr_gain_enc->drc_frame_size = pstr_drc_coefficients_uni_drc_v1->drc_frame_size;
|
||||
} else if ((pstr_uni_drc_config->drc_coefficients_uni_drc_count > 0) &&
|
||||
(pstr_drc_coefficients_uni_drc->drc_frame_size_present)) {
|
||||
pstr_gain_enc->drc_frame_size = pstr_drc_coefficients_uni_drc->drc_frame_size;
|
||||
} else {
|
||||
pstr_gain_enc->drc_frame_size = frame_size;
|
||||
}
|
||||
|
||||
if (pstr_gain_enc->drc_frame_size > IMPD_DRCMAX_FRAMESIZE) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
if (pstr_gain_enc->drc_frame_size < 1) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_INVALID_CONFIG;
|
||||
}
|
||||
|
||||
if (!pstr_uni_drc_config->sample_rate_present) {
|
||||
pstr_gain_enc->sample_rate = sample_rate;
|
||||
} else {
|
||||
pstr_gain_enc->sample_rate = pstr_uni_drc_config->sample_rate;
|
||||
}
|
||||
|
||||
pstr_gain_enc->domain = domain;
|
||||
pstr_gain_enc->delay_mode = delay_mode;
|
||||
pstr_gain_enc->delta_tmin_default = impd_drc_get_delta_t_min(pstr_gain_enc->sample_rate);
|
||||
|
||||
if ((pstr_uni_drc_config_ext->drc_coefficients_uni_drc_v1_count > 0) &&
|
||||
(pstr_drc_coefficients_uni_drc_v1->str_gain_set_params[0].time_delta_min_present == 1)) {
|
||||
pstr_gain_enc->delta_tmin =
|
||||
pstr_drc_coefficients_uni_drc_v1->str_gain_set_params[0].delta_tmin;
|
||||
} else if ((pstr_uni_drc_config->drc_coefficients_uni_drc_count > 0) &&
|
||||
(pstr_drc_coefficients_uni_drc->str_gain_set_params[0].time_delta_min_present ==
|
||||
1)) {
|
||||
pstr_gain_enc->delta_tmin = pstr_drc_coefficients_uni_drc->str_gain_set_params[0].delta_tmin;
|
||||
} else {
|
||||
pstr_gain_enc->delta_tmin = impd_drc_get_delta_t_min(pstr_gain_enc->sample_rate);
|
||||
}
|
||||
|
||||
num_gain_values_max = pstr_gain_enc->drc_frame_size / pstr_gain_enc->delta_tmin;
|
||||
pstr_gain_enc->base_ch_count = pstr_uni_drc_config->str_channel_layout.base_ch_count;
|
||||
|
||||
memcpy(&pstr_gain_enc->str_uni_drc_config, pstr_uni_drc_config,
|
||||
sizeof(ia_drc_uni_drc_config_struct));
|
||||
memcpy(&pstr_gain_enc->str_loudness_info_set, pstr_loudness_info_set,
|
||||
sizeof(ia_drc_loudness_info_set_struct));
|
||||
|
||||
k = 0;
|
||||
if (pstr_uni_drc_config->drc_coefficients_uni_drc_count > 0) {
|
||||
for (j = 0; j < pstr_drc_coefficients_uni_drc->gain_set_count; j++) {
|
||||
ch_idx = 0;
|
||||
found_ch_idx = 0;
|
||||
ia_drc_gain_set_params_struct *pstr_gain_set_params =
|
||||
&pstr_drc_coefficients_uni_drc->str_gain_set_params[j];
|
||||
|
||||
for (m = 0; m < pstr_uni_drc_config->drc_instructions_uni_drc_count; m++) {
|
||||
if (pstr_uni_drc_config->str_drc_instructions_uni_drc[m].drc_location ==
|
||||
pstr_drc_coefficients_uni_drc->drc_location) {
|
||||
for (ch = 0; ch < MAX_CHANNEL_COUNT; ch++) {
|
||||
if (pstr_uni_drc_config->str_drc_instructions_uni_drc[m].gain_set_index[ch] == j) {
|
||||
ch_idx = ch;
|
||||
found_ch_idx = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found_ch_idx) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pstr_gain_set_params->band_count > 1) {
|
||||
impd_drc_util_stft_read_gain_config(pstr_gain_enc->str_drc_stft_gain_handle[0][j],
|
||||
pstr_gain_set_params->band_count,
|
||||
pstr_gain_set_params);
|
||||
|
||||
for (l = 0; l < pstr_gain_set_params->band_count; l++) {
|
||||
err_code = impd_drc_stft_drc_gain_calc_init(pstr_gain_enc, 0, j, l);
|
||||
if (err_code & IA_FATAL_ERROR) {
|
||||
return err_code;
|
||||
}
|
||||
pstr_gain_enc->str_drc_stft_gain_handle[0][j][l].ch_idx = ch_idx;
|
||||
pstr_gain_enc->str_drc_stft_gain_handle[0][j][l].is_valid = 1;
|
||||
}
|
||||
} else if (pstr_gain_set_params->band_count == 1) {
|
||||
impd_drc_util_td_read_gain_config(&pstr_gain_enc->str_drc_compand[0][j],
|
||||
pstr_gain_set_params);
|
||||
|
||||
pstr_gain_enc->str_drc_compand[0][j].initial_volume = 0.0f;
|
||||
|
||||
err_code = impd_drc_td_drc_gain_calc_init(pstr_gain_enc, 0, j);
|
||||
if (err_code & IA_FATAL_ERROR) {
|
||||
return err_code;
|
||||
}
|
||||
pstr_gain_enc->str_drc_compand[0][j].ch_idx = ch_idx;
|
||||
pstr_gain_enc->str_drc_compand[0][j].is_valid = 1;
|
||||
}
|
||||
|
||||
for (l = 0; l < pstr_gain_set_params->band_count; l++) {
|
||||
pstr_gain_enc->str_drc_gain_seq_buf[k].str_drc_group.n_gain_values = 1;
|
||||
pstr_gain_enc->str_drc_gain_seq_buf[k].str_gain_set_params =
|
||||
pstr_drc_coefficients_uni_drc->str_gain_set_params[j];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pstr_uni_drc_config_ext->drc_coefficients_uni_drc_v1_count > 0) {
|
||||
for (i = 0; i < pstr_gain_enc->n_sequences; i++) {
|
||||
params_found = 0;
|
||||
|
||||
for (j = 0; j < pstr_drc_coefficients_uni_drc_v1->gain_set_count; j++) {
|
||||
for (l = 0; l < pstr_drc_coefficients_uni_drc_v1->str_gain_set_params[j].band_count;
|
||||
l++) {
|
||||
if (i == pstr_drc_coefficients_uni_drc_v1->str_gain_set_params[j]
|
||||
.gain_params[l]
|
||||
.gain_sequence_index) {
|
||||
pstr_gain_enc->str_drc_gain_seq_buf[i].str_drc_group.n_gain_values = 1;
|
||||
pstr_gain_enc->str_drc_gain_seq_buf[i].str_gain_set_params =
|
||||
pstr_drc_coefficients_uni_drc_v1->str_gain_set_params[j];
|
||||
params_found = 1;
|
||||
}
|
||||
if (params_found == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (params_found == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impd_drc_generate_delta_time_code_table(num_gain_values_max,
|
||||
pstr_gain_enc->str_delta_time_code_table);
|
||||
|
||||
for (i = num_gain_values_max - 1; i >= 0; i--) {
|
||||
pstr_gain_enc->delta_time_quant_table[i] = pstr_gain_enc->delta_tmin * (i + 1);
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
VOID impd_drc_encode_uni_drc_gain(ia_drc_gain_enc_struct *pstr_gain_enc, FLOAT32 *ptr_gain_buffer,
|
||||
VOID *pstr_scratch) {
|
||||
LOOPIDX idx;
|
||||
|
||||
for (idx = 0; idx < pstr_gain_enc->n_sequences; idx++) {
|
||||
impd_drc_quantize_and_encode_drc_gain(
|
||||
pstr_gain_enc, &ptr_gain_buffer[idx * MAX_DRC_FRAME_SIZE],
|
||||
&(pstr_gain_enc->drc_gain_per_sample_with_prev_frame[idx][0]),
|
||||
pstr_gain_enc->str_delta_time_code_table, &(pstr_gain_enc->str_drc_gain_seq_buf[idx]),
|
||||
pstr_scratch);
|
||||
}
|
||||
}
|
||||
|
||||
WORD32 impd_drc_get_delta_t_min(const WORD32 sample_rate) {
|
||||
WORD32 lower_bound;
|
||||
WORD32 result = 1;
|
||||
WORD32 sample_rate_local = sample_rate;
|
||||
|
||||
if (sample_rate_local < 1000) {
|
||||
sample_rate_local = 1000;
|
||||
}
|
||||
lower_bound = (WORD32)((0.0005f * sample_rate_local) + 0.5f);
|
||||
|
||||
while (result <= lower_bound) {
|
||||
result = result << 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
40
encoder/drc_src/impd_drc_enc.h
Normal file
40
encoder/drc_src/impd_drc_enc.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
IA_ERRORCODE impd_drc_gain_enc_init(ia_drc_gain_enc_struct *pstr_gain_enc,
|
||||
ia_drc_uni_drc_config_struct *pstr_uni_drc_config,
|
||||
ia_drc_loudness_info_set_struct *pstr_loudness_info_set,
|
||||
const WORD32 frame_size, const WORD32 sample_rate,
|
||||
const WORD32 delay_mode, const WORD32 domain);
|
||||
|
||||
WORD32 impd_drc_get_delta_t_min(const WORD32 sample_rate);
|
||||
|
||||
VOID impd_drc_encode_uni_drc_gain(ia_drc_gain_enc_struct *pstr_gain_enc, FLOAT32 *ptr_gain_buffer,
|
||||
VOID *pstr_scratch);
|
||||
|
||||
IA_ERRORCODE impd_drc_write_loudness_info_set_extension(
|
||||
ia_drc_enc_state *pstr_drc_state, ia_bit_buf_struct *it_bit_buf,
|
||||
ia_drc_loudness_info_set_extension_struct *pstr_loudness_info_set_extension,
|
||||
WORD32 *ptr_bit_cnt);
|
||||
|
||||
IA_ERRORCODE impd_drc_write_uni_drc_config(ia_drc_enc_state *pstr_drc_state, WORD32 *ptr_bit_cnt);
|
||||
|
||||
VOID impd_drc_write_uni_drc_gain(ia_drc_enc_state *pstr_drc_state, WORD32 *ptr_bit_cnt);
|
||||
518
encoder/drc_src/impd_drc_gain_calculator.c
Normal file
518
encoder/drc_src/impd_drc_gain_calculator.c
Normal file
|
|
@ -0,0 +1,518 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "iusace_config.h"
|
||||
|
||||
#include "iusace_rom.h"
|
||||
#include "iusace_fft.h"
|
||||
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
#include "impd_drc_enc.h"
|
||||
|
||||
static VOID impd_drc_compand_update_volume(ia_drc_compand_chan_param_struct *pstr_channel_param,
|
||||
FLOAT64 in_value) {
|
||||
FLOAT64 delta = in_value - pstr_channel_param->volume;
|
||||
|
||||
if (delta <= 0.0) {
|
||||
pstr_channel_param->volume += delta * pstr_channel_param->decay;
|
||||
} else {
|
||||
pstr_channel_param->volume += delta * pstr_channel_param->attack;
|
||||
}
|
||||
}
|
||||
|
||||
static FLOAT64 impd_drc_compand_get_volume(ia_drc_compand_struct *pstr_drc_compand,
|
||||
FLOAT64 in_lin) {
|
||||
ULOOPIDX idx;
|
||||
FLOAT64 in_log, out_log;
|
||||
ia_drc_compand_segment_struct *pstr_compand_segment;
|
||||
|
||||
if (in_lin < pstr_drc_compand->in_min_lin) {
|
||||
return pstr_drc_compand->out_min_lin;
|
||||
}
|
||||
|
||||
in_log = log(in_lin);
|
||||
|
||||
for (idx = 1; idx < pstr_drc_compand->nb_segments; idx++) {
|
||||
if (in_log <= pstr_drc_compand->str_segment[idx].x) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pstr_compand_segment = &pstr_drc_compand->str_segment[idx - 1];
|
||||
in_log -= pstr_compand_segment->x;
|
||||
out_log = pstr_compand_segment->y +
|
||||
in_log * (pstr_compand_segment->a * in_log + pstr_compand_segment->b);
|
||||
|
||||
return exp(out_log);
|
||||
}
|
||||
|
||||
VOID impd_drc_td_drc_gain_calc_process(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx, WORD32 gain_set_idx,
|
||||
WORD32 num_samples, FLOAT32 *in_buff, FLOAT32 *out_buff) {
|
||||
LOOPIDX idx;
|
||||
FLOAT64 gain;
|
||||
ia_drc_compand_chan_param_struct *pstr_channel_param;
|
||||
ia_drc_compand_struct *pstr_drc_compand =
|
||||
&pstr_drc_gain_enc->str_drc_compand[drc_coefficients_uni_drc_idx][gain_set_idx];
|
||||
|
||||
pstr_channel_param = &pstr_drc_compand->str_channel_param;
|
||||
|
||||
for (idx = 0; idx < num_samples; idx++) {
|
||||
impd_drc_compand_update_volume(pstr_channel_param, fabs((FLOAT64)in_buff[idx] / 32768.0));
|
||||
|
||||
gain = impd_drc_compand_get_volume(pstr_drc_compand, pstr_channel_param->volume);
|
||||
out_buff[idx] = (FLOAT32)(20.0 * log10(gain));
|
||||
}
|
||||
}
|
||||
|
||||
IA_ERRORCODE impd_drc_td_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx,
|
||||
WORD32 gain_set_idx) {
|
||||
ULOOPIDX i, j;
|
||||
UWORD32 num_points;
|
||||
FLOAT64 g1, g2;
|
||||
FLOAT64 x, y, cx, cy, r;
|
||||
FLOAT64 inp_1, inp_2, out_1, out_2, theta, length, radius;
|
||||
ia_drc_compand_struct *pstr_drc_compand;
|
||||
ia_drc_compand_chan_param_struct *pstr_chan_param;
|
||||
|
||||
if ((drc_coefficients_uni_drc_idx >= MAX_DRC_COEFF_COUNT) ||
|
||||
(gain_set_idx >= GAIN_SET_COUNT_MAX)) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_COMPAND_FAILED;
|
||||
}
|
||||
|
||||
pstr_drc_compand =
|
||||
&pstr_drc_gain_enc->str_drc_compand[drc_coefficients_uni_drc_idx][gain_set_idx];
|
||||
|
||||
pstr_drc_compand->nb_segments = (pstr_drc_compand->nb_points + 4) * 2;
|
||||
|
||||
for (i = 0; i < pstr_drc_compand->nb_points; i++) {
|
||||
if (i && pstr_drc_compand->str_segment[2 * ((i - 1) + 1)].x >
|
||||
pstr_drc_compand->str_segment[2 * ((i) + 1)].x) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_COMPAND_FAILED;
|
||||
}
|
||||
pstr_drc_compand->str_segment[2 * (i + 1)].y -= pstr_drc_compand->str_segment[2 * (i + 1)].x;
|
||||
}
|
||||
num_points = pstr_drc_compand->nb_points;
|
||||
|
||||
if (num_points == 0 || pstr_drc_compand->str_segment[2 * ((num_points - 1) + 1)].x) {
|
||||
num_points++;
|
||||
}
|
||||
|
||||
pstr_drc_compand->str_segment[0].x =
|
||||
pstr_drc_compand->str_segment[2].x - 2 * pstr_drc_compand->width_db;
|
||||
pstr_drc_compand->str_segment[0].y = pstr_drc_compand->str_segment[2].y;
|
||||
num_points++;
|
||||
|
||||
radius = pstr_drc_compand->width_db * M_LN10_DIV_20;
|
||||
|
||||
for (i = 2; i < num_points; i++) {
|
||||
g1 = (pstr_drc_compand->str_segment[2 * (i - 1)].y -
|
||||
pstr_drc_compand->str_segment[2 * (i - 2)].y) *
|
||||
(pstr_drc_compand->str_segment[2 * i].x - pstr_drc_compand->str_segment[2 * (i - 1)].x);
|
||||
g2 = (pstr_drc_compand->str_segment[2 * i].y - pstr_drc_compand->str_segment[2 * (i - 1)].y) *
|
||||
(pstr_drc_compand->str_segment[2 * (i - 1)].x -
|
||||
pstr_drc_compand->str_segment[2 * (i - 2)].x);
|
||||
|
||||
if (fabs(g1 - g2)) {
|
||||
continue;
|
||||
}
|
||||
num_points--;
|
||||
|
||||
for (j = --i; j < num_points; j++) {
|
||||
pstr_drc_compand->str_segment[2 * j] = pstr_drc_compand->str_segment[2 * (j + 1)];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < pstr_drc_compand->nb_segments; i += 2) {
|
||||
pstr_drc_compand->str_segment[i].y += pstr_drc_compand->gain_db;
|
||||
pstr_drc_compand->str_segment[i].x *= M_LN10_DIV_20;
|
||||
pstr_drc_compand->str_segment[i].y *= M_LN10_DIV_20;
|
||||
}
|
||||
|
||||
for (i = 4; i < pstr_drc_compand->nb_segments; i += 2) {
|
||||
pstr_drc_compand->str_segment[i - 4].a = 0;
|
||||
pstr_drc_compand->str_segment[i - 4].b =
|
||||
(pstr_drc_compand->str_segment[i - 2].y - pstr_drc_compand->str_segment[i - 4].y) /
|
||||
(pstr_drc_compand->str_segment[i - 2].x - pstr_drc_compand->str_segment[i - 4].x);
|
||||
|
||||
pstr_drc_compand->str_segment[i - 2].a = 0;
|
||||
pstr_drc_compand->str_segment[i - 2].b =
|
||||
(pstr_drc_compand->str_segment[i].y - pstr_drc_compand->str_segment[i - 2].y) /
|
||||
(pstr_drc_compand->str_segment[i].x - pstr_drc_compand->str_segment[i - 2].x);
|
||||
|
||||
theta =
|
||||
atan2(pstr_drc_compand->str_segment[i - 2].y - pstr_drc_compand->str_segment[i - 4].y,
|
||||
pstr_drc_compand->str_segment[i - 2].x - pstr_drc_compand->str_segment[i - 4].x);
|
||||
length =
|
||||
hypot(pstr_drc_compand->str_segment[i - 2].x - pstr_drc_compand->str_segment[i - 4].x,
|
||||
pstr_drc_compand->str_segment[i - 2].y - pstr_drc_compand->str_segment[i - 4].y);
|
||||
|
||||
r = MIN(radius, length);
|
||||
pstr_drc_compand->str_segment[i - 3].x =
|
||||
pstr_drc_compand->str_segment[i - 2].x - r * cos(theta);
|
||||
pstr_drc_compand->str_segment[i - 3].y =
|
||||
pstr_drc_compand->str_segment[i - 2].y - r * sin(theta);
|
||||
|
||||
theta =
|
||||
atan2(pstr_drc_compand->str_segment[i].y - pstr_drc_compand->str_segment[i - 2].y,
|
||||
pstr_drc_compand->str_segment[i - 0].x - pstr_drc_compand->str_segment[i - 2].x);
|
||||
length = hypot(pstr_drc_compand->str_segment[i].x - pstr_drc_compand->str_segment[i - 2].x,
|
||||
pstr_drc_compand->str_segment[i].y - pstr_drc_compand->str_segment[i - 2].y);
|
||||
|
||||
r = MIN(radius, length / 2);
|
||||
x = pstr_drc_compand->str_segment[i - 2].x + r * cos(theta);
|
||||
y = pstr_drc_compand->str_segment[i - 2].y + r * sin(theta);
|
||||
|
||||
cx =
|
||||
(pstr_drc_compand->str_segment[i - 3].x + pstr_drc_compand->str_segment[i - 2].x + x) / 3;
|
||||
cy =
|
||||
(pstr_drc_compand->str_segment[i - 3].y + pstr_drc_compand->str_segment[i - 2].y + y) / 3;
|
||||
|
||||
pstr_drc_compand->str_segment[i - 2].x = x;
|
||||
pstr_drc_compand->str_segment[i - 2].y = y;
|
||||
|
||||
inp_1 = cx - pstr_drc_compand->str_segment[i - 3].x;
|
||||
out_1 = cy - pstr_drc_compand->str_segment[i - 3].y;
|
||||
inp_2 = pstr_drc_compand->str_segment[i - 2].x - pstr_drc_compand->str_segment[i - 3].x;
|
||||
out_2 = pstr_drc_compand->str_segment[i - 2].y - pstr_drc_compand->str_segment[i - 3].y;
|
||||
pstr_drc_compand->str_segment[i - 3].a = (out_2 / inp_2 - out_1 / inp_1) / (inp_2 - inp_1);
|
||||
pstr_drc_compand->str_segment[i - 3].b =
|
||||
out_1 / inp_1 - pstr_drc_compand->str_segment[i - 3].a * inp_1;
|
||||
}
|
||||
pstr_drc_compand->str_segment[i - 3].x = 0;
|
||||
pstr_drc_compand->str_segment[i - 3].y = pstr_drc_compand->str_segment[i - 3].y;
|
||||
|
||||
pstr_drc_compand->in_min_lin = exp(pstr_drc_compand->str_segment[1].x);
|
||||
pstr_drc_compand->out_min_lin = exp(pstr_drc_compand->str_segment[1].y);
|
||||
|
||||
pstr_chan_param = &pstr_drc_compand->str_channel_param;
|
||||
|
||||
if (pstr_chan_param->attack < 1.0 / pstr_drc_gain_enc->sample_rate) {
|
||||
pstr_chan_param->attack = 1.0;
|
||||
} else {
|
||||
pstr_chan_param->attack =
|
||||
1.0 - exp(-1.0 / (pstr_drc_gain_enc->sample_rate * pstr_chan_param->attack));
|
||||
}
|
||||
|
||||
if (pstr_chan_param->decay < 1.0 / pstr_drc_gain_enc->sample_rate) {
|
||||
pstr_chan_param->decay = 1.0;
|
||||
} else {
|
||||
pstr_chan_param->decay =
|
||||
1.0 - exp(-1.0 / (pstr_drc_gain_enc->sample_rate * pstr_chan_param->decay));
|
||||
}
|
||||
pstr_chan_param->volume = EXP10(pstr_drc_compand->initial_volume / 20);
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
static FLOAT32 impd_drc_stft_drc_compand_get_volume(
|
||||
ia_drc_stft_gain_calc_struct *pstr_drc_stft_gain_handle, FLOAT32 in_db) {
|
||||
ULOOPIDX idx;
|
||||
FLOAT32 in_log, out_log;
|
||||
ia_drc_compand_segment_struct *pstr_compand_segment;
|
||||
|
||||
if (in_db < pstr_drc_stft_gain_handle->in_min_db) {
|
||||
return pstr_drc_stft_gain_handle->out_min_db;
|
||||
}
|
||||
|
||||
in_log = (FLOAT32)(in_db * M_LN10_DIV_20);
|
||||
|
||||
for (idx = 1; idx < pstr_drc_stft_gain_handle->nb_segments; idx++) {
|
||||
if (in_log <= pstr_drc_stft_gain_handle->str_segment[idx].x) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pstr_compand_segment = &pstr_drc_stft_gain_handle->str_segment[idx - 1];
|
||||
in_log -= (FLOAT32)(pstr_compand_segment->x);
|
||||
out_log = (FLOAT32)(pstr_compand_segment->y +
|
||||
in_log * (pstr_compand_segment->a * in_log + pstr_compand_segment->b));
|
||||
|
||||
return (FLOAT32)(out_log * M_LOG10_E * 20.0f);
|
||||
}
|
||||
|
||||
VOID impd_drc_stft_drc_gain_calc_process(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx, WORD32 gain_set_idx,
|
||||
WORD32 band_idx, WORD32 start_sub_band_index,
|
||||
WORD32 stop_sub_band_index, UWORD32 num_frames,
|
||||
FLOAT32 *in_buff, FLOAT32 *gain_values) {
|
||||
ULOOPIDX idx;
|
||||
LOOPIDX band;
|
||||
FLOAT32 xg, xl, yl, cdb;
|
||||
FLOAT32 in_real, in_imag;
|
||||
FLOAT32 abs_val_sqr;
|
||||
UWORD32 num_time_slot = num_frames / STFT256_HOP_SIZE;
|
||||
|
||||
ia_drc_stft_gain_calc_struct *pstr_drc_stft_gain_handle =
|
||||
&pstr_drc_gain_enc
|
||||
->str_drc_stft_gain_handle[drc_coefficients_uni_drc_idx][gain_set_idx][band_idx];
|
||||
|
||||
for (idx = 0; idx < num_time_slot; idx++) {
|
||||
abs_val_sqr = 0.0f;
|
||||
for (band = start_sub_band_index; band <= stop_sub_band_index; band++) {
|
||||
in_imag = in_buff[((idx * STFT256_HOP_SIZE + band) << 1) + 1];
|
||||
in_real = in_buff[(idx * STFT256_HOP_SIZE + band) << 1];
|
||||
|
||||
abs_val_sqr += sqrtf(powf(in_real, 2.0f) + powf(in_imag, 2.0f));
|
||||
}
|
||||
|
||||
abs_val_sqr /= (FLOAT32)((stop_sub_band_index - start_sub_band_index + 1) << 4);
|
||||
|
||||
abs_val_sqr = powf(abs_val_sqr, 2.0f);
|
||||
xg = 10.0f * log10f((abs_val_sqr) + 2e-13f);
|
||||
|
||||
xl = -impd_drc_stft_drc_compand_get_volume(pstr_drc_stft_gain_handle, xg);
|
||||
|
||||
if (xl > pstr_drc_stft_gain_handle->yl_z1[band]) {
|
||||
yl = (pstr_drc_stft_gain_handle->alpha_a * pstr_drc_stft_gain_handle->yl_z1[band]) +
|
||||
((1.0f - pstr_drc_stft_gain_handle->alpha_a) * xl);
|
||||
} else {
|
||||
yl = (pstr_drc_stft_gain_handle->alpha_r * pstr_drc_stft_gain_handle->yl_z1[band]) +
|
||||
((1.0f - pstr_drc_stft_gain_handle->alpha_r) * xl);
|
||||
}
|
||||
|
||||
pstr_drc_stft_gain_handle->yl_z1[band] = yl;
|
||||
cdb = -yl;
|
||||
cdb = MAX(IMPD_DRCSPECTRAL_FLOOR, (powf(10.0f, cdb / 20.0f)));
|
||||
cdb = 20.0f * log10f(cdb);
|
||||
|
||||
for (band = 0; band < STFT256_HOP_SIZE; band++) {
|
||||
gain_values[idx * STFT256_HOP_SIZE + band] = cdb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IA_ERRORCODE impd_drc_stft_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx,
|
||||
WORD32 gain_set_idx, WORD32 band_idx) {
|
||||
ULOOPIDX i, j;
|
||||
UWORD32 num_points;
|
||||
FLOAT32 width_e;
|
||||
FLOAT64 g1, g2;
|
||||
FLOAT64 x, y, cx, cy, r;
|
||||
FLOAT64 inp_1, inp_2, out_1, out_2, theta, len;
|
||||
ia_drc_compand_chan_param_struct *pstr_chan_param;
|
||||
ia_drc_stft_gain_calc_struct *pstr_drc_stft_gain_handle;
|
||||
|
||||
if ((drc_coefficients_uni_drc_idx >= MAX_DRC_COEFF_COUNT) ||
|
||||
(gain_set_idx >= GAIN_SET_COUNT_MAX) || (band_idx >= MAX_BAND_COUNT)) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_COMPAND_FAILED;
|
||||
}
|
||||
|
||||
pstr_drc_stft_gain_handle =
|
||||
&pstr_drc_gain_enc
|
||||
->str_drc_stft_gain_handle[drc_coefficients_uni_drc_idx][gain_set_idx][band_idx];
|
||||
|
||||
width_e = (FLOAT32)(pstr_drc_stft_gain_handle->width_db * M_LN10_DIV_20);
|
||||
|
||||
pstr_drc_stft_gain_handle->nb_segments = (pstr_drc_stft_gain_handle->nb_points + 4) * 2;
|
||||
|
||||
for (i = 0; i < pstr_drc_stft_gain_handle->nb_points; i++) {
|
||||
if (i && pstr_drc_stft_gain_handle->str_segment[2 * ((i - 1) + 1)].x >
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i + 1)].x) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_COMPAND_FAILED;
|
||||
}
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i + 1)].y -=
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i + 1)].x;
|
||||
}
|
||||
num_points = pstr_drc_stft_gain_handle->nb_points;
|
||||
|
||||
if (num_points == 0 || pstr_drc_stft_gain_handle->str_segment[2 * ((num_points - 1) + 1)].x) {
|
||||
num_points++;
|
||||
}
|
||||
|
||||
pstr_drc_stft_gain_handle->str_segment[0].x =
|
||||
pstr_drc_stft_gain_handle->str_segment[2].x - pstr_drc_stft_gain_handle->width_db;
|
||||
pstr_drc_stft_gain_handle->str_segment[0].y = pstr_drc_stft_gain_handle->str_segment[2].y;
|
||||
num_points++;
|
||||
|
||||
for (i = 2; i < num_points; i++) {
|
||||
g1 = (pstr_drc_stft_gain_handle->str_segment[2 * (i - 1)].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i - 2)].y) *
|
||||
(pstr_drc_stft_gain_handle->str_segment[2 * i].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i - 1)].x);
|
||||
g2 = (pstr_drc_stft_gain_handle->str_segment[2 * i].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i - 1)].y) *
|
||||
(pstr_drc_stft_gain_handle->str_segment[2 * (i - 1)].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (i - 2)].x);
|
||||
|
||||
if (fabs(g1 - g2)) {
|
||||
continue;
|
||||
}
|
||||
num_points--;
|
||||
|
||||
for (j = --i; j < num_points; j++) {
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * j] =
|
||||
pstr_drc_stft_gain_handle->str_segment[2 * (j + 1)];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < pstr_drc_stft_gain_handle->nb_segments; i += 2) {
|
||||
pstr_drc_stft_gain_handle->str_segment[i].y += pstr_drc_stft_gain_handle->gain_db;
|
||||
pstr_drc_stft_gain_handle->str_segment[i].x *= M_LN10_DIV_20;
|
||||
pstr_drc_stft_gain_handle->str_segment[i].y *= M_LN10_DIV_20;
|
||||
}
|
||||
|
||||
for (i = 4; i < pstr_drc_stft_gain_handle->nb_segments; i += 2) {
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].a = 0;
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].b =
|
||||
(pstr_drc_stft_gain_handle->str_segment[i - 2].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].y) /
|
||||
(pstr_drc_stft_gain_handle->str_segment[i - 2].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].x);
|
||||
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].a = 0;
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].b =
|
||||
(pstr_drc_stft_gain_handle->str_segment[i].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y) /
|
||||
(pstr_drc_stft_gain_handle->str_segment[i].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x);
|
||||
|
||||
theta = atan2(pstr_drc_stft_gain_handle->str_segment[i - 2].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].y,
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].x);
|
||||
len = hypot(pstr_drc_stft_gain_handle->str_segment[i - 2].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].x,
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 4].y);
|
||||
r = MIN(width_e / (2.0f * cos(theta)), len);
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].x =
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x - r * cos(theta);
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].y =
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y - r * sin(theta);
|
||||
|
||||
theta = atan2(pstr_drc_stft_gain_handle->str_segment[i].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y,
|
||||
pstr_drc_stft_gain_handle->str_segment[i].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x);
|
||||
len = hypot(pstr_drc_stft_gain_handle->str_segment[i].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x,
|
||||
pstr_drc_stft_gain_handle->str_segment[i].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y);
|
||||
r = MIN(width_e / (2.0f * cos(theta)), len / 2);
|
||||
x = pstr_drc_stft_gain_handle->str_segment[i - 2].x + r * cos(theta);
|
||||
y = pstr_drc_stft_gain_handle->str_segment[i - 2].y + r * sin(theta);
|
||||
|
||||
cx = (pstr_drc_stft_gain_handle->str_segment[i - 3].x +
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x + x) /
|
||||
3;
|
||||
cy = (pstr_drc_stft_gain_handle->str_segment[i - 3].y +
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y + y) /
|
||||
3;
|
||||
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].x = x;
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y = y;
|
||||
|
||||
inp_1 = cx - pstr_drc_stft_gain_handle->str_segment[i - 3].x;
|
||||
out_1 = cy - pstr_drc_stft_gain_handle->str_segment[i - 3].y;
|
||||
inp_2 = pstr_drc_stft_gain_handle->str_segment[i - 2].x -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].x;
|
||||
out_2 = pstr_drc_stft_gain_handle->str_segment[i - 2].y -
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].y;
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].a =
|
||||
(out_2 / inp_2 - out_1 / inp_1) / (inp_2 - inp_1);
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].b =
|
||||
out_1 / inp_1 - pstr_drc_stft_gain_handle->str_segment[i - 3].a * inp_1;
|
||||
}
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].x = 0;
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 3].y =
|
||||
pstr_drc_stft_gain_handle->str_segment[i - 2].y;
|
||||
|
||||
pstr_drc_stft_gain_handle->in_min_db =
|
||||
(FLOAT32)(pstr_drc_stft_gain_handle->str_segment[1].x * M_LOG10_E * 20.0f);
|
||||
pstr_drc_stft_gain_handle->out_min_db =
|
||||
(FLOAT32)(pstr_drc_stft_gain_handle->str_segment[1].y * M_LOG10_E * 20.0f);
|
||||
|
||||
pstr_chan_param = &pstr_drc_stft_gain_handle->str_channel_param;
|
||||
|
||||
pstr_chan_param->volume = EXP10(pstr_drc_stft_gain_handle->initial_volume / 20.0f);
|
||||
|
||||
for (i = 0; i < STFT256_HOP_SIZE; i++) {
|
||||
pstr_drc_stft_gain_handle->yl_z1[i] = 0.0f;
|
||||
}
|
||||
|
||||
pstr_drc_stft_gain_handle->alpha_a =
|
||||
expf(-1.0f / ((pstr_drc_stft_gain_handle->attack_ms / (FLOAT32)STFT256_HOP_SIZE) *
|
||||
(FLOAT32)pstr_drc_gain_enc->sample_rate * 0.001f));
|
||||
|
||||
pstr_drc_stft_gain_handle->alpha_r =
|
||||
expf(-1.0f / ((pstr_drc_stft_gain_handle->release_ms / (FLOAT32)STFT256_HOP_SIZE) *
|
||||
(FLOAT32)pstr_drc_gain_enc->sample_rate * 0.001f));
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID impd_drc_stft_drc_convert_to_fd(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
FLOAT32 *ptr_input, UWORD32 ch_idx, UWORD32 frame_size,
|
||||
FLOAT32 *ptr_output, VOID *pstr_scratch) {
|
||||
ULOOPIDX i, j;
|
||||
UWORD32 num_time_slot = frame_size / STFT256_HOP_SIZE;
|
||||
FLOAT32 time_sample_vector;
|
||||
iusace_scratch_mem *ptr_scratch = (iusace_scratch_mem *)(pstr_scratch);
|
||||
pFLOAT32 scratch_buff = ptr_scratch->ptr_drc_scratch_buf;
|
||||
|
||||
for (i = 0; i < num_time_slot; i++) {
|
||||
for (j = 0; j < STFT256_HOP_SIZE; j++) {
|
||||
time_sample_vector = (FLOAT32)(ptr_input[i * STFT256_HOP_SIZE + j] / (32768.0));
|
||||
|
||||
scratch_buff[(j << 1)] =
|
||||
(FLOAT32)(pstr_drc_gain_enc->stft_tmp_in_buf_time[ch_idx][j] * iusace_sine_win_256[j]);
|
||||
scratch_buff[(j << 1) + 1] = 0.0f;
|
||||
|
||||
scratch_buff[(STFT256_HOP_SIZE + j) << 1] =
|
||||
(FLOAT32)(iusace_sine_win_256[STFT256_HOP_SIZE - 1 - j] * time_sample_vector);
|
||||
scratch_buff[((STFT256_HOP_SIZE + j) << 1) + 1] = 0.0f;
|
||||
|
||||
pstr_drc_gain_enc->stft_tmp_in_buf_time[ch_idx][j] = time_sample_vector;
|
||||
}
|
||||
|
||||
iusace_complex_fft(scratch_buff, STFT256_HOP_SIZE << 1, ptr_scratch);
|
||||
|
||||
ptr_output[(i * STFT256_HOP_SIZE) << 1] = scratch_buff[0];
|
||||
ptr_output[((i * STFT256_HOP_SIZE) << 1) + 1] = scratch_buff[STFT256_HOP_SIZE << 1];
|
||||
|
||||
for (j = 1; j < STFT256_HOP_SIZE; j++) {
|
||||
ptr_output[(i * STFT256_HOP_SIZE + j) << 1] = scratch_buff[j << 1];
|
||||
ptr_output[((i * STFT256_HOP_SIZE + j) << 1) + 1] = scratch_buff[(j << 1) + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
1003
encoder/drc_src/impd_drc_gain_enc.c
Normal file
1003
encoder/drc_src/impd_drc_gain_enc.c
Normal file
File diff suppressed because it is too large
Load diff
211
encoder/drc_src/impd_drc_gain_enc.h
Normal file
211
encoder/drc_src/impd_drc_gain_enc.h
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "impd_drc_tables.h"
|
||||
|
||||
#define N_UNIDRC_GAIN_MAX (MAX_NODE_COUNT)
|
||||
|
||||
#ifndef M_LOG2_10
|
||||
#define M_LOG2_10 (3.32192809488736234787) /* log_2 10 */
|
||||
#endif
|
||||
|
||||
#ifndef M_LOG10_E
|
||||
#define M_LOG10_E (0.4342944819) /* log_10 e */
|
||||
#endif
|
||||
|
||||
#define M_LN10_DIV_20 (0.115129254649702284201) /* (log_e 10 / 20) */
|
||||
|
||||
#define EXP10(x) (exp2(M_LOG2_10 * x))
|
||||
|
||||
#define MAX_NUM_CHANNELS (32)
|
||||
#define STFT256_HOP_SIZE (256)
|
||||
#define IMPD_DRCSPECTRAL_FLOOR (0.02818383f)
|
||||
|
||||
#define IMPD_DRCMAX_NSEQ (40)
|
||||
#define IMPD_DRCMAX_FRAMESIZE (4096)
|
||||
#define IMPD_DRCCOMPAND_MAX_NB_POINTS (MAX_NUM_CHANNELS << 3)
|
||||
#define IMPD_DRCCOMPAND_MAX_NUM_SEGMENTS ((IMPD_DRCCOMPAND_MAX_NB_POINTS + 4) << 1)
|
||||
|
||||
#define MAX_TIME_DEVIATION_FACTOR (0.25f)
|
||||
#define SLOPE_CHANGE_THR (3.0f)
|
||||
#define SLOPE_QUANT_THR (8.0f)
|
||||
|
||||
#define GAIN_QUANT_STEP_SIZE (0.125f)
|
||||
#define GAIN_QUANT_STEP_SIZE_INV (8.0f)
|
||||
|
||||
#define MAX_DRC_GAIN_DELTA_BEFORE_QUANT (1.0f + 0.5f * GAIN_QUANT_STEP_SIZE)
|
||||
|
||||
#define SCALE_APPROXIMATE_DB \
|
||||
(0.99657842f) /* factor for converting dB to approximate dB: log2(10)*6/20 */
|
||||
|
||||
typedef struct ia_drc_compand_chan_param_struct {
|
||||
FLOAT64 attack;
|
||||
FLOAT64 decay;
|
||||
FLOAT64 volume;
|
||||
} ia_drc_compand_chan_param_struct;
|
||||
|
||||
typedef struct ia_drc_compand_segment_struct {
|
||||
FLOAT64 x, y;
|
||||
FLOAT64 a, b;
|
||||
} ia_drc_compand_segment_struct;
|
||||
|
||||
typedef struct ia_drc_compand_struct {
|
||||
UWORD8 is_valid;
|
||||
UWORD32 ch_idx;
|
||||
UWORD32 nb_points;
|
||||
UWORD32 nb_segments;
|
||||
ia_drc_compand_segment_struct str_segment[IMPD_DRCCOMPAND_MAX_NUM_SEGMENTS];
|
||||
ia_drc_compand_chan_param_struct str_channel_param;
|
||||
FLOAT64 in_min_lin;
|
||||
FLOAT64 out_min_lin;
|
||||
FLOAT64 width_db;
|
||||
FLOAT64 gain_db;
|
||||
FLOAT64 initial_volume;
|
||||
} ia_drc_compand_struct;
|
||||
|
||||
typedef struct ia_drc_stft_gain_calc_struct {
|
||||
UWORD8 is_valid;
|
||||
UWORD32 ch_idx;
|
||||
FLOAT32 theshold;
|
||||
FLOAT32 ratio;
|
||||
FLOAT32 attack_ms;
|
||||
FLOAT32 release_ms;
|
||||
FLOAT32 alpha_a;
|
||||
FLOAT32 alpha_r;
|
||||
FLOAT32 yl_z1[STFT256_HOP_SIZE + 1];
|
||||
|
||||
UWORD32 nb_points;
|
||||
UWORD32 nb_segments;
|
||||
ia_drc_compand_segment_struct str_segment[IMPD_DRCCOMPAND_MAX_NUM_SEGMENTS];
|
||||
ia_drc_compand_chan_param_struct str_channel_param;
|
||||
FLOAT32 in_min_db;
|
||||
FLOAT32 out_min_db;
|
||||
FLOAT32 width_db;
|
||||
FLOAT32 gain_db;
|
||||
FLOAT32 initial_volume;
|
||||
} ia_drc_stft_gain_calc_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 n_gain_values;
|
||||
|
||||
FLOAT32 drc_gain_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 gain_code[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 gain_code_length[IMPD_DRCMAX_FRAMESIZE];
|
||||
FLOAT32 slope_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 slope_code_index[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 ts_gain_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 time_delta_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
|
||||
FLOAT32 drc_gain[IMPD_DRCMAX_FRAMESIZE];
|
||||
FLOAT32 slope[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 ts_gain[IMPD_DRCMAX_FRAMESIZE];
|
||||
|
||||
FLOAT32 gain_prev_node;
|
||||
FLOAT32 drc_gain_quant_prev;
|
||||
|
||||
} ia_drc_group_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 n_gain_values;
|
||||
|
||||
FLOAT32 drc_gain_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 gain_code[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 gain_code_length[IMPD_DRCMAX_FRAMESIZE];
|
||||
FLOAT32 slope_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 slope_code_index[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 ts_gain_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 time_delta_quant[IMPD_DRCMAX_FRAMESIZE];
|
||||
|
||||
WORD32 time_delta_code[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 time_delta_code_index[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 time_delta_code_size[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 slope_code[IMPD_DRCMAX_FRAMESIZE];
|
||||
WORD32 slope_code_size[IMPD_DRCMAX_FRAMESIZE];
|
||||
|
||||
FLOAT32 drc_gain_quant_prev;
|
||||
FLOAT32 drc_gain_quant_next;
|
||||
WORD32 time_quant_next;
|
||||
WORD32 time_quant_prev;
|
||||
WORD32 slope_code_index_next;
|
||||
WORD32 slope_code_index_prev;
|
||||
|
||||
WORD32 coding_mode;
|
||||
} ia_drc_group_for_output_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_drc_gain_set_params_struct str_gain_set_params;
|
||||
ia_drc_group_struct str_drc_group;
|
||||
ia_drc_group_for_output_struct str_drc_group_for_output;
|
||||
} ia_drc_gain_seq_buf_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 n_sequences;
|
||||
WORD32 delta_tmin;
|
||||
WORD32 delta_tmin_default;
|
||||
WORD32 drc_frame_size;
|
||||
WORD32 sample_rate;
|
||||
WORD32 delay_mode;
|
||||
WORD32 domain;
|
||||
WORD32 base_ch_count;
|
||||
ia_drc_uni_drc_config_struct str_uni_drc_config;
|
||||
ia_drc_loudness_info_set_struct str_loudness_info_set;
|
||||
FLOAT32 drc_gain_per_sample_with_prev_frame[IMPD_DRCMAX_NSEQ][3 * IMPD_DRCMAX_FRAMESIZE];
|
||||
ia_drc_gain_seq_buf_struct str_drc_gain_seq_buf[IMPD_DRCMAX_NSEQ];
|
||||
ia_drc_delta_time_code_table_entry_struct
|
||||
str_delta_time_code_table[2 * IMPD_DRCMAX_FRAMESIZE + 1];
|
||||
WORD32 delta_time_quant_table[IMPD_DRCMAX_FRAMESIZE];
|
||||
|
||||
ia_drc_eq_set_struct str_eq_set;
|
||||
ia_drc_filter_banks_struct str_filter_banks;
|
||||
ia_drc_compand_struct str_drc_compand[MAX_DRC_COEFF_COUNT][GAIN_SET_COUNT_MAX];
|
||||
ia_drc_stft_gain_calc_struct str_drc_stft_gain_handle[MAX_DRC_COEFF_COUNT][GAIN_SET_COUNT_MAX]
|
||||
[MAX_BAND_COUNT];
|
||||
FLOAT32 stft_tmp_in_buf_time[MAX_NUM_CHANNELS][STFT256_HOP_SIZE];
|
||||
FLOAT32 complex_fft_ptr[MAX_NUM_CHANNELS][IMPD_DRCMAX_FRAMESIZE << 1];
|
||||
} ia_drc_gain_enc_struct;
|
||||
|
||||
VOID impd_drc_quantize_and_encode_drc_gain(
|
||||
ia_drc_gain_enc_struct *pstr_gain_enc, const FLOAT32 *ptr_drc_gain_per_sample,
|
||||
FLOAT32 *ptr_drc_gain_per_sample_with_prev_frame,
|
||||
ia_drc_delta_time_code_table_entry_struct *pstr_delta_time_code_table,
|
||||
ia_drc_gain_seq_buf_struct *pstr_drc_gain_seq_buf, VOID *pstr_scratch);
|
||||
|
||||
IA_ERRORCODE impd_drc_td_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx,
|
||||
WORD32 gain_set_idx);
|
||||
|
||||
IA_ERRORCODE impd_drc_stft_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx,
|
||||
WORD32 gain_set_idx, WORD32 band_idx);
|
||||
|
||||
VOID impd_drc_td_drc_gain_calc_process(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx, WORD32 gain_set_idx,
|
||||
WORD32 num_samples, FLOAT32 *in_buff, FLOAT32 *out_buff);
|
||||
|
||||
VOID impd_drc_stft_drc_gain_calc_process(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
WORD32 drc_coefficients_uni_drc_idx, WORD32 gain_set_idx,
|
||||
WORD32 band_idx, WORD32 start_sub_band_index,
|
||||
WORD32 stop_sub_band_index, UWORD32 num_frames,
|
||||
FLOAT32 *in_buff, FLOAT32 *gain_values);
|
||||
|
||||
VOID impd_drc_stft_drc_convert_to_fd(ia_drc_gain_enc_struct *pstr_drc_gain_enc,
|
||||
FLOAT32 *ptr_input, UWORD32 ch_idx, UWORD32 frame_size,
|
||||
FLOAT32 *ptr_output, VOID *pstr_scratch);
|
||||
3200
encoder/drc_src/impd_drc_mux.c
Normal file
3200
encoder/drc_src/impd_drc_mux.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,16 +19,17 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#define MIN_DRC_GAIN_CODING_PROFILE0 (-31.875f)
|
||||
#define MAX_DRC_GAIN_CODING_PROFILE0 (31.875f)
|
||||
|
||||
extern const FLOAT64 ixheaace_twid_tbl_fft[514];
|
||||
extern const WORD32 twiddle_tab_fft_32x32[514];
|
||||
extern const FLOAT64 ixheaace_twid_tbl_fft_ntwt3r[1155];
|
||||
extern const FLOAT64 ixheaace_twid_tbl_fft_ntwt3i[1155];
|
||||
extern const FLOAT32 ixheaace_twid_tbl_fft_224[372];
|
||||
extern const FLOAT32 ixheaace_twid_tbl_fft_288[380];
|
||||
extern const FLOAT32 ixheaace_twid_tbl_fft_336[564];
|
||||
extern const FLOAT32 ixheaace_twid_tbl_fft_168[276];
|
||||
#define MIN_DRC_GAIN_CODING_PROFILE1 (-128.0f)
|
||||
#define MAX_DRC_GAIN_CODING_PROFILE1 (0.0f)
|
||||
|
||||
extern const FLOAT32 ixheaace_twiddle_tab_fft_float[514];
|
||||
extern const FLOAT32 ixheaace_twidle_tbl_48[64];
|
||||
extern const FLOAT32 ixheaace_twidle_tbl_24[32];
|
||||
#define MIN_DRC_GAIN_CODING_PROFILE2 (-32.0f)
|
||||
#define MAX_DRC_GAIN_CODING_PROFILE2 (0.0f)
|
||||
|
||||
#define INV_LOG10_2 (3.32192809488736f) /* 1.0 / log10(2.0) */
|
||||
|
||||
IA_ERRORCODE impd_drc_enc_initial_gain(const WORD32 gain_coding_profile, FLOAT32 gain_initial,
|
||||
FLOAT32 *gain_initial_quant, WORD32 *code_size,
|
||||
WORD32 *code);
|
||||
51
encoder/drc_src/impd_drc_struct_def.h
Normal file
51
encoder/drc_src/impd_drc_struct_def.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define MAX_DRC_GAIN_BAND_COUNT (50)
|
||||
#define MAX_DRC_FRAME_SIZE (4096)
|
||||
#define DRC_OUT_BITBUFFER_SIZE (4096)
|
||||
|
||||
typedef struct {
|
||||
ia_drc_enc_params_struct str_enc_params;
|
||||
ia_drc_uni_drc_config_struct str_uni_drc_config;
|
||||
ia_drc_loudness_info_set_struct str_enc_loudness_info_set;
|
||||
ia_drc_uni_drc_gain_ext_struct str_enc_gain_extension;
|
||||
|
||||
ia_drc_gain_enc_struct str_gain_enc;
|
||||
UWORD8 bit_buf_base_cfg[MAX_DRC_PAYLOAD_BYTES];
|
||||
ia_bit_buf_struct str_bit_buf_cfg;
|
||||
WORD32 drc_config_data_size_bit;
|
||||
UWORD8 bit_buf_base_cfg_ext[MAX_DRC_PAYLOAD_BYTES];
|
||||
ia_bit_buf_struct str_bit_buf_cfg_ext;
|
||||
WORD32 drc_config_ext_data_size_bit;
|
||||
UWORD8 bit_buf_base_cfg_tmp[MAX_DRC_PAYLOAD_BYTES];
|
||||
ia_bit_buf_struct str_bit_buf_cfg_tmp;
|
||||
|
||||
UWORD8 drc_payload_data[MAX_DRC_PAYLOAD_BYTES];
|
||||
FLOAT32 gain_buffer[MAX_DRC_GAIN_BAND_COUNT][MAX_DRC_FRAME_SIZE];
|
||||
|
||||
UWORD8 bit_buf_base_out[DRC_OUT_BITBUFFER_SIZE];
|
||||
ia_bit_buf_struct str_bit_buf_out;
|
||||
UWORD8 is_first_drc_process_complete;
|
||||
|
||||
VOID *drc_scratch_mem;
|
||||
WORD32 drc_scratch_used;
|
||||
} ia_drc_enc_state;
|
||||
214
encoder/drc_src/impd_drc_tables.c
Normal file
214
encoder/drc_src/impd_drc_tables.c
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
|
||||
const FLOAT32 impd_drc_downmix_coeff[16] = {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 impd_drc_downmix_coeff_lfe[16] = {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 impd_drc_channel_weight[16] = {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 impd_drc_downmix_coeff_v1[32] = {
|
||||
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 impd_drc_eq_slope_table[16] = {-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 impd_drc_eq_gain_delta_table[32] = {
|
||||
-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 impd_drc_zero_pole_radius_table[128] = {
|
||||
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 impd_drc_zero_pole_angle_table[128] = {
|
||||
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};
|
||||
|
||||
static const ia_drc_delta_gain_code_entry_struct impd_drc_delta_gain_code_table_by_size[25] = {
|
||||
{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}};
|
||||
|
||||
static const ia_drc_delta_gain_code_entry_struct
|
||||
impd_drc_delta_gain_code_table_profile_2_by_size[49] = {
|
||||
{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}};
|
||||
|
||||
static const ia_drc_slope_code_table_entry_struct impd_drc_slope_code_table_entry_by_value[15] = {
|
||||
{6, 0x018, -3.0518f, 0}, {8, 0x042, -1.2207f, 1}, {7, 0x032, -0.4883f, 2},
|
||||
{5, 0x00A, -0.1953f, 3}, {5, 0x009, -0.0781f, 4}, {5, 0x00D, -0.0312f, 5},
|
||||
{2, 0x000, -0.005f, 6}, {1, 0x001, 0.0f, 7}, {4, 0x007, 0.005f, 8},
|
||||
{5, 0x00B, 0.0312f, 9}, {6, 0x011, 0.0781f, 10}, {9, 0x087, 0.1953f, 11},
|
||||
{9, 0x086, 0.4883f, 12}, {7, 0x020, 1.2207f, 13}, {7, 0x033, 3.0518f, 14},
|
||||
};
|
||||
|
||||
static const WORD32 k_num_delta_gain_values_table =
|
||||
sizeof(impd_drc_delta_gain_code_table_by_size) /
|
||||
sizeof(impd_drc_delta_gain_code_table_by_size[0]);
|
||||
|
||||
static const WORD32 k_num_delta_gain_values_table_profile_2 =
|
||||
sizeof(impd_drc_delta_gain_code_table_profile_2_by_size) /
|
||||
sizeof(impd_drc_delta_gain_code_table_profile_2_by_size[0]);
|
||||
|
||||
const ia_drc_slope_code_table_entry_struct *impd_drc_get_slope_code_table_by_value(VOID) {
|
||||
return (&(impd_drc_slope_code_table_entry_by_value[0]));
|
||||
}
|
||||
|
||||
VOID impd_drc_get_delta_gain_code_table(
|
||||
const WORD32 gain_coding_profile,
|
||||
ia_drc_delta_gain_code_entry_struct const **pstr_delta_gain_code_table, WORD32 *num_entries) {
|
||||
if (gain_coding_profile != GAIN_CODING_PROFILE_CLIPPING) {
|
||||
*pstr_delta_gain_code_table = impd_drc_delta_gain_code_table_by_size;
|
||||
*num_entries = k_num_delta_gain_values_table;
|
||||
} else {
|
||||
*pstr_delta_gain_code_table = impd_drc_delta_gain_code_table_profile_2_by_size;
|
||||
*num_entries = k_num_delta_gain_values_table_profile_2;
|
||||
}
|
||||
}
|
||||
|
||||
VOID impd_drc_generate_delta_time_code_table(
|
||||
const WORD32 num_gain_values_max,
|
||||
ia_drc_delta_time_code_table_entry_struct *pstr_delta_time_code_table) {
|
||||
LOOPIDX idx;
|
||||
WORD32 max_val, temp = 1;
|
||||
|
||||
while ((1 << temp) < 2 * num_gain_values_max) {
|
||||
temp++;
|
||||
}
|
||||
pstr_delta_time_code_table[0].size = -1;
|
||||
pstr_delta_time_code_table[0].code = -1;
|
||||
pstr_delta_time_code_table[0].value = -1;
|
||||
pstr_delta_time_code_table[1].size = 2;
|
||||
pstr_delta_time_code_table[1].code = 0x0;
|
||||
pstr_delta_time_code_table[1].value = 1;
|
||||
|
||||
for (idx = 0; idx < 4; idx++) {
|
||||
pstr_delta_time_code_table[idx + 2].size = 4;
|
||||
pstr_delta_time_code_table[idx + 2].code = 0x4 + idx;
|
||||
pstr_delta_time_code_table[idx + 2].value = idx + 2;
|
||||
}
|
||||
for (idx = 0; idx < 8; idx++) {
|
||||
pstr_delta_time_code_table[idx + 6].size = 5;
|
||||
pstr_delta_time_code_table[idx + 6].code = 0x10 + idx;
|
||||
pstr_delta_time_code_table[idx + 6].value = idx + 6;
|
||||
}
|
||||
|
||||
max_val = 2 * num_gain_values_max - 14 + 1;
|
||||
for (idx = 0; idx < max_val; idx++) {
|
||||
pstr_delta_time_code_table[idx + 14].size = 2 + temp;
|
||||
pstr_delta_time_code_table[idx + 14].code = (0x3 << temp) + idx;
|
||||
pstr_delta_time_code_table[idx + 14].value = idx + 14;
|
||||
}
|
||||
}
|
||||
|
||||
FLOAT32 impd_drc_decode_slope_idx_value(const WORD32 slope_code_idx) {
|
||||
const ia_drc_slope_code_table_entry_struct *pstr_slope_code_table =
|
||||
impd_drc_get_slope_code_table_by_value();
|
||||
|
||||
return pstr_slope_code_table[slope_code_idx].value;
|
||||
}
|
||||
|
||||
FLOAT32 impd_drc_decode_slope_idx_magnitude(const WORD32 slope_code_idx) {
|
||||
const ia_drc_slope_code_table_entry_struct *pstr_slope_code_table =
|
||||
impd_drc_get_slope_code_table_by_value();
|
||||
|
||||
return (FLOAT32)fabs((FLOAT64)pstr_slope_code_table[slope_code_idx].value);
|
||||
}
|
||||
62
encoder/drc_src/impd_drc_tables.h
Normal file
62
encoder/drc_src/impd_drc_tables.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
extern const FLOAT32 impd_drc_downmix_coeff[16];
|
||||
extern const FLOAT32 impd_drc_downmix_coeff_lfe[16];
|
||||
extern const FLOAT32 impd_drc_channel_weight[16];
|
||||
extern const FLOAT32 impd_drc_downmix_coeff_v1[32];
|
||||
extern const FLOAT32 impd_drc_eq_slope_table[16];
|
||||
extern const FLOAT32 impd_drc_eq_gain_delta_table[32];
|
||||
extern const FLOAT32 impd_drc_zero_pole_radius_table[128];
|
||||
extern const FLOAT32 impd_drc_zero_pole_angle_table[128];
|
||||
|
||||
typedef struct {
|
||||
WORD32 size;
|
||||
WORD32 code;
|
||||
WORD32 value;
|
||||
} ia_drc_delta_time_code_table_entry_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 size;
|
||||
WORD32 code;
|
||||
FLOAT32 value;
|
||||
WORD32 index;
|
||||
} ia_drc_slope_code_table_entry_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 size;
|
||||
WORD32 code;
|
||||
FLOAT32 value;
|
||||
} ia_drc_delta_gain_code_entry_struct;
|
||||
|
||||
VOID impd_drc_generate_delta_time_code_table(
|
||||
const WORD32 num_gain_values_max,
|
||||
ia_drc_delta_time_code_table_entry_struct *delta_time_code_table_item);
|
||||
|
||||
VOID impd_drc_get_delta_gain_code_table(
|
||||
const WORD32 gain_coding_profile,
|
||||
ia_drc_delta_gain_code_entry_struct const **pstr_delta_gain_code_table, WORD32 *num_entries);
|
||||
|
||||
const ia_drc_slope_code_table_entry_struct *impd_drc_get_slope_code_table_by_value(VOID);
|
||||
|
||||
FLOAT32 impd_drc_decode_slope_idx_value(const WORD32 slope_code_index);
|
||||
|
||||
FLOAT32 impd_drc_decode_slope_idx_magnitude(const WORD32 slope_code_index);
|
||||
599
encoder/drc_src/impd_drc_uni_drc.h
Normal file
599
encoder/drc_src/impd_drc_uni_drc.h
Normal file
|
|
@ -0,0 +1,599 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
/* Defines for bitstream payload */
|
||||
#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_BS_1770_3 2
|
||||
|
||||
#define EFFECT_BIT_NONE (-1) /* this effect bit is virtual */
|
||||
#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_INTERPOLATION_TYPE_SPLINE 0
|
||||
#define GAIN_INTERPOLATION_TYPE_LINEAR 1
|
||||
|
||||
#define LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT 1000 /* infinity as default */
|
||||
#define GAIN_SET_COUNT_MAX 8 /* reduced size */
|
||||
|
||||
#define LEFT_SIDE 0
|
||||
#define RIGHT_SIDE 1
|
||||
#define SPLIT_CHARACTERISTIC_COUNT_MAX 8
|
||||
#define SPLIT_CHARACTERISTIC_MAX_NODE_COUNT 4 /* one side of characteristic */
|
||||
|
||||
#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) /* dB */
|
||||
|
||||
#define SHAPE_FILTER_COUNT_MAX 8
|
||||
|
||||
#define SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE 1583.8931924611f /* 10^3.2 - 1 */
|
||||
|
||||
#define DOWNMIX_INSTRUCTIONS_COUNT_MAX 8 /* reduced size */
|
||||
#define DRC_COEFFICIENTS_UNIDRC_V1_COUNT_MAX 2 /* reduced size */
|
||||
#define DRC_INSTRUCTIONS_UNIDRC_V1_COUNT_MAX 8 /* reduced size */
|
||||
#define SPLIT_CHARACTERISTIC_COUNT_MAX 8 /* reduced size */
|
||||
#define SHAPE_FILTER_COUNT_MAX 8 /* reduced size */
|
||||
#define ADDITIONAL_DOWNMIX_ID_COUNT_MAX MAX_ADDITIONAL_DOWNMIX_ID
|
||||
#define ADDITIONAL_DRC_SET_ID_COUNT_MAX 16
|
||||
#define ADDITIONAL_EQ_SET_ID_COUNT_MAX 8
|
||||
#define LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT 4
|
||||
#define FILTER_ELEMENT_COUNT_MAX 16 /* reduced size */
|
||||
#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_MAX_NODE_COUNT 33
|
||||
#define EQ_SUBBAND_GAIN_COUNT_MAX 135
|
||||
#define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16 /* reduced size */
|
||||
#define FILTER_BLOCK_COUNT_MAX 16
|
||||
#define FILTER_ELEMENT_COUNT_MAX 16 /* reduced size */
|
||||
#define UNIQUE_SUBBAND_GAINS_COUNT_MAX 8 /* reduced size */
|
||||
#define EQ_MAX_CHANNEL_GROUP_COUNT 4 /* reduced size */
|
||||
#define EQ_FILTER_BLOCK_COUNT_MAX 4 /* reduced size */
|
||||
#define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8 /* reduced size */
|
||||
#define EQ_INSTRUCTIONS_COUNT_MAX 8
|
||||
|
||||
#define DRC_COMPLEXITY_LEVEL_MAX 15
|
||||
#define EQ_COMPLEXITY_LEVEL_MAX 15
|
||||
#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
|
||||
|
||||
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[MAX_PARAM_DRC_TYPE_FF_NODE_COUNT];
|
||||
WORD32 node_gain[MAX_PARAM_DRC_TYPE_FF_NODE_COUNT];
|
||||
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_release_threshold;
|
||||
WORD32 gain_smooth_hold_off_count_present;
|
||||
WORD32 gain_smooth_hold_off;
|
||||
WORD32 disable_paramtric_drc;
|
||||
} ia_drc_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_paramtric_drc;
|
||||
} ia_drc_parametric_drc_type_lim_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 parametric_drc_id;
|
||||
WORD32 parametric_drc_look_ahead_present;
|
||||
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_drc_parametric_drc_type_feed_forward_struct str_parametric_drc_type_feed_forward;
|
||||
ia_drc_parametric_drc_type_lim_struct str_parametric_drc_type_lim;
|
||||
WORD32 disable_paramtric_drc;
|
||||
} ia_drc_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_channel_weight[MAX_CHANNEL_COUNT];
|
||||
WORD32 drc_input_loudness_present;
|
||||
FLOAT32 drc_input_loudness;
|
||||
|
||||
/* derived data */
|
||||
WORD32 channel_count_drom_downmix_id;
|
||||
} ia_drc_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_drc_parametric_drc_gain_set_params_struct parametric_drc_gain_set_params[MAX_SEQUENCE_COUNT];
|
||||
} ia_drc_coeff_parametric_drc_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 base_ch_count;
|
||||
WORD32 layout_signaling_present;
|
||||
WORD32 defined_layout;
|
||||
WORD32 speaker_position[MAX_SPEAKER_POS_COUNT];
|
||||
} ia_drc_channel_layout_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 downmix_id;
|
||||
WORD32 target_ch_count;
|
||||
WORD32 target_layout;
|
||||
WORD32 downmix_coefficients_present;
|
||||
FLOAT32 downmix_coeff[MAX_DOWNMIX_COEFF_COUNT];
|
||||
} ia_drc_downmix_instructions_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 x;
|
||||
FLOAT32 y;
|
||||
} ia_drc_gain_points_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 gain_sequence_index;
|
||||
WORD32 drc_characteristic_present;
|
||||
WORD32 drc_characteristic_format_is_cicp;
|
||||
WORD32 drc_characteristic;
|
||||
WORD32 drc_characteristic_left_index;
|
||||
WORD32 drc_characteristic_right_index;
|
||||
WORD32 crossover_freq_index;
|
||||
WORD32 start_sub_band_index;
|
||||
WORD32 nb_points;
|
||||
FLOAT32 width;
|
||||
FLOAT32 attack;
|
||||
FLOAT32 decay;
|
||||
ia_drc_gain_points_struct gain_points[512];
|
||||
} ia_drc_gain_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 ducking_scaling_present;
|
||||
FLOAT32 ducking_scaling;
|
||||
FLOAT32 ducking_scaling_quantized;
|
||||
} ia_drc_ducking_modifiers_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 target_characteristic_left_present[MAX_BAND_COUNT];
|
||||
WORD32 target_characteristic_left_index[MAX_BAND_COUNT];
|
||||
WORD32 target_characteristic_right_present[MAX_BAND_COUNT];
|
||||
WORD32 target_characteristic_right_index[MAX_BAND_COUNT];
|
||||
WORD32 shape_filter_present;
|
||||
WORD32 shape_filter_index;
|
||||
|
||||
WORD32 gain_scaling_present[MAX_BAND_COUNT];
|
||||
FLOAT32 attenuation_scaling[MAX_BAND_COUNT];
|
||||
FLOAT32 amplification_scaling[MAX_BAND_COUNT];
|
||||
WORD32 gain_offset_present[MAX_BAND_COUNT];
|
||||
FLOAT32 gain_offset[MAX_BAND_COUNT];
|
||||
|
||||
} ia_drc_gain_modifiers_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 gain_coding_profile;
|
||||
WORD32 gain_interpolation_type;
|
||||
WORD32 full_frame;
|
||||
WORD32 time_alignment;
|
||||
WORD32 time_delta_min_present;
|
||||
WORD32 delta_tmin;
|
||||
WORD32 band_count;
|
||||
WORD32 drc_band_type;
|
||||
ia_drc_gain_params_struct gain_params[MAX_BAND_COUNT];
|
||||
} ia_drc_gain_set_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 characteristic_format;
|
||||
WORD32 bs_gain;
|
||||
WORD32 bs_io_ratio;
|
||||
WORD32 bs_exp;
|
||||
WORD32 flip_sign;
|
||||
WORD32 characteristic_node_count;
|
||||
FLOAT32 node_level[SPLIT_CHARACTERISTIC_MAX_NODE_COUNT + 1];
|
||||
FLOAT32 node_gain[SPLIT_CHARACTERISTIC_MAX_NODE_COUNT + 1];
|
||||
} ia_drc_split_drc_characteristic_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 corner_freq_index;
|
||||
WORD32 filter_strength_index;
|
||||
} ia_drc_shape_filter_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 lf_cut_filter_present;
|
||||
ia_drc_shape_filter_params_struct str_lf_cut_params;
|
||||
WORD32 lf_boost_filter_present;
|
||||
ia_drc_shape_filter_params_struct str_lf_boost_params;
|
||||
WORD32 hf_cut_filter_present;
|
||||
ia_drc_shape_filter_params_struct str_hf_cut_params;
|
||||
WORD32 hf_boost_filter_present;
|
||||
ia_drc_shape_filter_params_struct str_hf_boost_params;
|
||||
} ia_drc_shape_filter_block_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 drc_location;
|
||||
WORD32 drc_characteristic;
|
||||
} ia_drc_coefficients_basic_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 drc_location;
|
||||
WORD32 drc_frame_size_present;
|
||||
WORD32 drc_frame_size;
|
||||
WORD32 drc_characteristic_left_present;
|
||||
WORD32 characteristic_left_count;
|
||||
ia_drc_split_drc_characteristic_struct
|
||||
str_split_characteristic_left[SPLIT_CHARACTERISTIC_COUNT_MAX + 1];
|
||||
WORD32 drc_characteristic_right_present;
|
||||
WORD32 characteristic_right_count;
|
||||
ia_drc_split_drc_characteristic_struct
|
||||
str_split_characteristic_right[SPLIT_CHARACTERISTIC_COUNT_MAX];
|
||||
WORD32 shape_filters_present;
|
||||
WORD32 shape_filter_count;
|
||||
ia_drc_shape_filter_block_params_struct
|
||||
str_shape_filter_block_params[SHAPE_FILTER_COUNT_MAX + 1];
|
||||
WORD32 gain_sequence_count;
|
||||
WORD32 gain_set_count;
|
||||
ia_drc_gain_set_params_struct str_gain_set_params[GAIN_SET_COUNT_MAX];
|
||||
} ia_drc_coefficients_uni_drc_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 drc_set_id;
|
||||
WORD32 drc_location;
|
||||
WORD32 downmix_id;
|
||||
WORD32 additional_downmix_id_present;
|
||||
WORD32 additional_downmix_id_count;
|
||||
WORD32 additional_downmix_id[MAX_ADDITIONAL_DOWNMIX_ID];
|
||||
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 drc_apply_to_downmix;
|
||||
WORD32 requires_eq;
|
||||
WORD32 downmix_id_present;
|
||||
WORD32 drc_location;
|
||||
WORD32 downmix_id;
|
||||
WORD32 additional_downmix_id_present;
|
||||
WORD32 additional_downmix_id_count;
|
||||
WORD32 additional_downmix_id[MAX_ADDITIONAL_DOWNMIX_ID];
|
||||
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_drc_gain_modifiers_struct str_gain_modifiers[MAX_CHANNEL_GROUP_COUNT];
|
||||
ia_drc_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 drc_instructions_type;
|
||||
WORD32 mae_group_id;
|
||||
WORD32 mae_group_preset_id;
|
||||
|
||||
WORD32 drc_channel_count;
|
||||
WORD32 num_drc_channel_groups;
|
||||
WORD32 gain_set_index_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 band_count_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 gain_coding_profile_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 gain_interpolation_type_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 time_delta_min_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 time_alignment_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
ia_drc_ducking_modifiers_struct
|
||||
str_ducking_modifiers_for_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 channel_group_for_channel[MAX_CHANNEL_COUNT];
|
||||
WORD32 num_channels_per_channel_group[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 gain_element_count;
|
||||
WORD32 multiband_audio_signal_count;
|
||||
WORD32 channel_group_is_parametric_drc[MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 gain_set_idx_for_ch_group_parametric_drc[MAX_CHANNEL_GROUP_COUNT];
|
||||
} ia_drc_instructions_uni_drc;
|
||||
|
||||
typedef struct {
|
||||
WORD32 method_definition;
|
||||
FLOAT32 method_value;
|
||||
WORD32 measurement_system;
|
||||
WORD32 reliability;
|
||||
} ia_drc_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_drc_loudness_measure_struct str_loudness_measure[MAX_MEASUREMENT_COUNT];
|
||||
WORD32 loudness_info_type;
|
||||
WORD32 mae_group_id;
|
||||
WORD32 mae_group_preset_id;
|
||||
} ia_drc_loudness_info_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 loud_eq_set_id;
|
||||
WORD32 drc_location;
|
||||
WORD32 downmix_id_present;
|
||||
WORD32 downmix_id;
|
||||
WORD32 additional_downmix_id_present;
|
||||
WORD32 additional_downmix_id_count;
|
||||
WORD32 additional_downmix_id[ADDITIONAL_DOWNMIX_ID_COUNT_MAX];
|
||||
WORD32 drc_set_id_present;
|
||||
WORD32 drc_set_id;
|
||||
WORD32 additional_drc_set_id_present;
|
||||
WORD32 additional_drc_set_id_count;
|
||||
WORD32 additional_drc_set_id[ADDITIONAL_DRC_SET_ID_COUNT_MAX];
|
||||
WORD32 eq_set_id_present;
|
||||
WORD32 eq_set_id;
|
||||
WORD32 additional_eq_set_id_present;
|
||||
WORD32 additional_eq_set_id_count;
|
||||
WORD32 additional_eq_set_id[ADDITIONAL_EQ_SET_ID_COUNT_MAX];
|
||||
WORD32 loudness_after_drc;
|
||||
WORD32 loudness_after_eq;
|
||||
WORD32 loud_eq_gain_sequence_count;
|
||||
WORD32 gain_sequence_index[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
WORD32 drc_characteristic_format_is_cicp[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
WORD32 drc_characteristic[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
WORD32 drc_characteristic_left_index[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
WORD32 drc_characteristic_right_index[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
WORD32 frequency_range_index[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
FLOAT32 loud_eq_scaling[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
FLOAT32 loud_eq_offset[LOUD_EQ_GAIN_MAX_SEQUENCE_COUNT];
|
||||
} ia_drc_loud_eq_instructions_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 filter_element_index;
|
||||
WORD32 filter_element_gain_present;
|
||||
FLOAT32 filter_element_gain;
|
||||
} ia_drc_filter_element_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 filter_element_count;
|
||||
ia_drc_filter_element_struct filter_element[FILTER_ELEMENT_COUNT_MAX];
|
||||
} ia_drc_filter_block_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_filter_format;
|
||||
WORD32 real_zero_radius_one_count;
|
||||
WORD32 real_zero_count;
|
||||
WORD32 generic_zero_count;
|
||||
WORD32 real_pole_count;
|
||||
WORD32 complex_pole_count;
|
||||
FLOAT32 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_filter_order;
|
||||
WORD32 fir_symmetry;
|
||||
FLOAT32 fir_coefficient[FIR_ORDER_MAX / 2];
|
||||
} ia_drc_unique_td_filter_element_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 n_eq_nodes;
|
||||
FLOAT32 eq_slope[EQ_MAX_NODE_COUNT];
|
||||
WORD32 eq_freq_delta[EQ_MAX_NODE_COUNT];
|
||||
FLOAT32 eq_gain_initial;
|
||||
FLOAT32 eq_gain_delta[EQ_MAX_NODE_COUNT];
|
||||
} ia_drc_eq_subband_gain_spline_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_subband_gain[EQ_SUBBAND_GAIN_COUNT_MAX];
|
||||
} ia_drc_eq_subband_gain_vector_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_delay_max_present;
|
||||
WORD32 eq_delay_max;
|
||||
WORD32 unique_filter_block_count;
|
||||
ia_drc_filter_block_struct str_filter_block[FILTER_BLOCK_COUNT_MAX];
|
||||
WORD32 unique_td_filter_element_count;
|
||||
ia_drc_unique_td_filter_element_struct str_unique_td_filter_element[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_drc_eq_subband_gain_spline_struct str_eq_subband_gain_spline[UNIQUE_SUBBAND_GAIN_COUNT_MAX];
|
||||
ia_drc_eq_subband_gain_vector_struct str_eq_subband_gain_vector[UNIQUE_SUBBAND_GAIN_COUNT_MAX];
|
||||
} ia_drc_eq_coefficients_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 filter_block_count;
|
||||
WORD32 filter_block_index[EQ_FILTER_BLOCK_COUNT_MAX];
|
||||
} ia_drc_filter_block_refs_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_cascade_gain_present[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 eq_cascade_gain[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
ia_drc_filter_block_refs_struct str_filter_block_refs[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 eq_phase_alignment_present;
|
||||
WORD32 eq_phase_alignment[EQ_MAX_CHANNEL_GROUP_COUNT][EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
} ia_drc_td_filter_cascade_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_set_id;
|
||||
WORD32 eq_set_complexity_level;
|
||||
WORD32 downmix_id_present;
|
||||
WORD32 downmix_id;
|
||||
WORD32 eq_apply_to_downmix;
|
||||
WORD32 additional_downmix_id_present;
|
||||
WORD32 additional_downmix_id_count;
|
||||
WORD32 additional_downmix_id[ADDITIONAL_DOWNMIX_ID_COUNT_MAX];
|
||||
WORD32 drc_set_id;
|
||||
WORD32 additional_drc_set_id_present;
|
||||
WORD32 additional_drc_set_id_count;
|
||||
WORD32 additional_drc_set_id[ADDITIONAL_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_channel_group_count;
|
||||
WORD32 eq_channel_group_for_channel[MAX_CHANNEL_COUNT];
|
||||
WORD32 td_filter_cascade_present;
|
||||
ia_drc_td_filter_cascade_struct str_td_filter_cascade;
|
||||
WORD32 subband_gains_present;
|
||||
WORD32 subband_gains_index[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
WORD32 eq_transition_duration_present;
|
||||
FLOAT32 eq_transition_duration;
|
||||
} ia_drc_eq_instructions_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 uni_drc_config_ext_type[MAX_EXT_COUNT];
|
||||
WORD32 ext_bit_size[MAX_EXT_COUNT - 1];
|
||||
/* UNIDRC_CONF_EXT_PARAM_DRC */
|
||||
WORD32 parametric_drc_present;
|
||||
ia_drc_coeff_parametric_drc_struct str_drc_coeff_parametric_drc;
|
||||
WORD32 parametric_drc_instructions_count;
|
||||
ia_drc_parametric_drc_instructions_struct
|
||||
str_parametric_drc_instructions[MAX_PARAM_DRC_INSTRUCTIONS_COUNT];
|
||||
|
||||
/* UNIDRC_CONF_EXT_V1 */
|
||||
WORD32 drc_extension_v1_present;
|
||||
WORD32 downmix_instructions_v1_present;
|
||||
WORD32 downmix_instructions_v1_count;
|
||||
ia_drc_downmix_instructions_struct str_downmix_instructions_v1[DOWNMIX_INSTRUCTIONS_COUNT_MAX];
|
||||
WORD32 drc_coeffs_and_instructions_uni_drc_v1_present;
|
||||
WORD32 drc_coefficients_uni_drc_v1_count;
|
||||
ia_drc_coefficients_uni_drc_struct
|
||||
str_drc_coefficients_uni_drc_v1[DRC_COEFFICIENTS_UNIDRC_V1_COUNT_MAX];
|
||||
WORD32 drc_instructions_uni_drc_v1_count;
|
||||
ia_drc_instructions_uni_drc
|
||||
str_drc_instructions_uni_drc_v1[DRC_INSTRUCTIONS_UNIDRC_V1_COUNT_MAX];
|
||||
WORD32 loud_eq_instructions_present;
|
||||
WORD32 loud_eq_instructions_count;
|
||||
ia_drc_loud_eq_instructions_struct str_loud_eq_instructions[LOUD_EQ_INSTRUCTIONS_COUNT_MAX];
|
||||
WORD32 eq_present;
|
||||
ia_drc_eq_coefficients_struct str_eq_coefficients;
|
||||
WORD32 eq_instructions_count;
|
||||
ia_drc_eq_instructions_struct str_eq_instructions[EQ_INSTRUCTIONS_COUNT_MAX];
|
||||
} ia_drc_uni_drc_config_ext_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 sample_rate_present;
|
||||
WORD32 sample_rate;
|
||||
WORD32 downmix_instructions_count;
|
||||
WORD32 drc_coefficients_uni_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 uni_drc_config_ext_present;
|
||||
ia_drc_uni_drc_config_ext_struct str_uni_drc_config_ext;
|
||||
ia_drc_coefficients_basic_struct str_drc_coefficients_basic[MAX_DRC_COEFF_COUNT];
|
||||
ia_drc_instructions_basic_struct str_drc_instructions_basic[MAX_DRC_INSTRUCTIONS_COUNT];
|
||||
ia_drc_coefficients_uni_drc_struct str_drc_coefficients_uni_drc[MAX_DRC_COEFF_COUNT];
|
||||
ia_drc_instructions_uni_drc str_drc_instructions_uni_drc[MAX_DRC_INSTRUCTIONS_COUNT];
|
||||
ia_drc_channel_layout_struct str_channel_layout;
|
||||
ia_drc_downmix_instructions_struct str_downmix_instructions[MAX_DOWNMIX_INSTRUCTION_COUNT];
|
||||
WORD32 loudness_info_set_present;
|
||||
} ia_drc_uni_drc_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 loudness_info_v1_album_count;
|
||||
WORD32 loudness_info_v1_count;
|
||||
ia_drc_loudness_info_struct str_loudness_info_v1_album[MAX_LOUDNESS_INFO_COUNT];
|
||||
ia_drc_loudness_info_struct str_loudness_info_v1[MAX_LOUDNESS_INFO_COUNT];
|
||||
} ia_drc_loudness_info_set_ext_eq_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 loudness_info_set_ext_type[MAX_EXT_COUNT];
|
||||
WORD32 ext_bit_size[MAX_EXT_COUNT - 1];
|
||||
ia_drc_loudness_info_set_ext_eq_struct str_loudness_info_set_ext_eq;
|
||||
} ia_drc_loudness_info_set_extension_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 loudness_info_album_count;
|
||||
WORD32 loudness_info_count;
|
||||
WORD32 loudness_info_set_ext_present;
|
||||
ia_drc_loudness_info_struct str_loudness_info_album[MAX_LOUDNESS_INFO_COUNT];
|
||||
ia_drc_loudness_info_struct str_loudness_info[MAX_LOUDNESS_INFO_COUNT];
|
||||
ia_drc_loudness_info_set_extension_struct str_loudness_info_set_extension;
|
||||
} ia_drc_loudness_info_set_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 uni_drc_gain_ext_present;
|
||||
WORD32 uni_drc_gain_ext_type[MAX_EXT_COUNT];
|
||||
WORD32 ext_bit_size[MAX_EXT_COUNT - 1];
|
||||
} ia_drc_uni_drc_gain_ext_struct;
|
||||
1439
encoder/drc_src/impd_drc_uni_drc_eq.c
Normal file
1439
encoder/drc_src/impd_drc_uni_drc_eq.c
Normal file
File diff suppressed because it is too large
Load diff
172
encoder/drc_src/impd_drc_uni_drc_eq.h
Normal file
172
encoder/drc_src/impd_drc_uni_drc_eq.h
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define MAX_EQ_CHANNEL_COUNT (8)
|
||||
#define MAX_EQ_AUDIO_DELAY (1024)
|
||||
#define MAX_EQ_FIR_FILTER_SIZE (128)
|
||||
#define MAX_EQ_SUBBAND_COUNT (256)
|
||||
#define MAX_EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT (32)
|
||||
#define MAX_EQ_FILTER_SECTION_COUNT (8)
|
||||
#define MAX_EQ_FILTER_ELEMENT_COUNT (4)
|
||||
#define MAX_MATCHING_PHASE_FILTER_COUNT (32)
|
||||
|
||||
#define EQ_FILTER_DOMAIN_NONE 0
|
||||
#define EQ_FILTER_DOMAIN_TIME (1)
|
||||
#define EQ_FILTER_DOMAIN_SUBBAND (2)
|
||||
|
||||
#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_LOW (20.0f)
|
||||
|
||||
#define FILTER_ELEMENT_FORMAT_POLE_ZERO (0)
|
||||
#define FILTER_ELEMENT_FORMAT_FIR (1)
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI (3.14159265358979323846)
|
||||
#endif
|
||||
|
||||
#define STEP_RATIO_COMPUTED (0.0739601776f)
|
||||
|
||||
typedef struct {
|
||||
WORD32 delay;
|
||||
FLOAT32 state[MAX_EQ_CHANNEL_COUNT][MAX_EQ_AUDIO_DELAY];
|
||||
} ia_drc_audio_delay_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 radius;
|
||||
FLOAT32 coeff[2];
|
||||
} ia_drc_second_order_filter_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 coeff_count;
|
||||
FLOAT32 coeff[MAX_EQ_FIR_FILTER_SIZE];
|
||||
FLOAT32 state[MAX_EQ_CHANNEL_COUNT][MAX_EQ_FIR_FILTER_SIZE];
|
||||
} ia_drc_fir_filter_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 eq_frame_size_subband;
|
||||
WORD32 coeff_count;
|
||||
FLOAT32 subband_coeff[MAX_EQ_SUBBAND_COUNT];
|
||||
} ia_drc_subband_filter_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 filter_format;
|
||||
WORD32 filter_param_count_for_zeros;
|
||||
ia_drc_second_order_filter_params_struct
|
||||
str_second_order_filter_params_for_zeros[MAX_EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT];
|
||||
WORD32 filter_param_count_for_poles;
|
||||
ia_drc_second_order_filter_params_struct
|
||||
str_second_order_filter_params_for_poles[MAX_EQ_INTERMEDIATE_2ND_ORDER_PARAMS_COUNT];
|
||||
ia_drc_fir_filter_struct str_fir_filter;
|
||||
} ia_drc_intermediate_filter_params_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 state_in_1;
|
||||
FLOAT32 state_in_2;
|
||||
FLOAT32 state_out_1;
|
||||
FLOAT32 state_out_2;
|
||||
} ia_drc_filter_section_state_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 var_a1;
|
||||
FLOAT32 var_a2;
|
||||
FLOAT32 var_b1;
|
||||
FLOAT32 var_b2;
|
||||
ia_drc_filter_section_state_struct str_filter_section_state[MAX_EQ_CHANNEL_COUNT];
|
||||
} ia_drc_filter_section_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 member_count;
|
||||
WORD32 member_index[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
} ia_drc_cascade_alignment_group_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 is_valid;
|
||||
WORD32 matches_filter_count;
|
||||
WORD32 matches_filter[MAX_EQ_FILTER_SECTION_COUNT];
|
||||
FLOAT32 gain;
|
||||
WORD32 section_count;
|
||||
ia_drc_filter_section_struct str_filter_section[MAX_EQ_FILTER_SECTION_COUNT];
|
||||
ia_drc_audio_delay_struct str_audio_delay;
|
||||
} ia_drc_phase_alignment_filter_struct;
|
||||
|
||||
typedef ia_drc_phase_alignment_filter_struct ia_drc_matching_phase_filter_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 matches_cascade_index;
|
||||
WORD32 allpass_count;
|
||||
ia_drc_matching_phase_filter_struct str_matching_phase_filter[MAX_MATCHING_PHASE_FILTER_COUNT];
|
||||
} ia_drc_allpass_chain_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 section_count;
|
||||
ia_drc_filter_section_struct str_filter_section[MAX_EQ_FILTER_SECTION_COUNT];
|
||||
WORD32 fir_coeffs_present;
|
||||
ia_drc_fir_filter_struct str_fir_filter;
|
||||
ia_drc_audio_delay_struct str_audio_delay;
|
||||
} ia_drc_pole_zero_filter_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 element_gain_linear;
|
||||
WORD32 format;
|
||||
ia_drc_pole_zero_filter_struct str_pole_zero_filter;
|
||||
ia_drc_fir_filter_struct str_fir_filter;
|
||||
WORD32 phase_alignment_filter_count;
|
||||
ia_drc_phase_alignment_filter_struct str_phase_alignment_filter[MAX_EQ_FILTER_ELEMENT_COUNT];
|
||||
} ia_drc_eq_filter_element_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 element_count;
|
||||
ia_drc_eq_filter_element_struct str_eq_filter_element[MAX_EQ_FILTER_ELEMENT_COUNT];
|
||||
ia_drc_matching_phase_filter_struct str_matching_phase_filter_element_0;
|
||||
} ia_drc_eq_filter_block_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 cascade_gain_linear;
|
||||
WORD32 block_count;
|
||||
ia_drc_eq_filter_block_struct str_eq_filter_block[EQ_FILTER_BLOCK_COUNT_MAX];
|
||||
WORD32 phase_alignment_filter_count;
|
||||
ia_drc_phase_alignment_filter_struct
|
||||
str_phase_alignment_filter[EQ_FILTER_BLOCK_COUNT_MAX * EQ_FILTER_BLOCK_COUNT_MAX];
|
||||
} ia_drc_filter_cascade_t_domain_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 domain;
|
||||
WORD32 audio_channel_count;
|
||||
WORD32 eq_channel_group_count;
|
||||
WORD32 eq_channel_group_for_channel[MAX_EQ_CHANNEL_COUNT];
|
||||
ia_drc_filter_cascade_t_domain_struct str_filter_cascade_t_domain[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
ia_drc_subband_filter_struct str_subband_filter[EQ_MAX_CHANNEL_GROUP_COUNT];
|
||||
} ia_drc_eq_set_struct;
|
||||
|
||||
IA_ERRORCODE impd_drc_derive_eq_set(ia_drc_eq_coefficients_struct *pstr_eq_coefficients,
|
||||
ia_drc_eq_instructions_struct *pstr_eq_instructions,
|
||||
const FLOAT32 audio_sample_rate, const WORD32 drc_frame_size,
|
||||
const WORD32 sub_band_domain_mode,
|
||||
ia_drc_eq_set_struct *pstr_eq_set, VOID *ptr_scratch,
|
||||
WORD32 *scratch_used);
|
||||
|
||||
IA_ERRORCODE impd_drc_get_eq_complexity(ia_drc_eq_set_struct *pstr_eq_set,
|
||||
WORD32 *eq_complexity_level);
|
||||
184
encoder/drc_src/impd_drc_uni_drc_filter_bank.c
Normal file
184
encoder/drc_src/impd_drc_uni_drc_filter_bank.c
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
|
||||
static IA_ERRORCODE impd_drc_filter_bank_complexity(
|
||||
const WORD32 num_bands, ia_drc_filter_bank_struct *pstr_drc_filter_bank) {
|
||||
pstr_drc_filter_bank->complexity = 0;
|
||||
pstr_drc_filter_bank->num_bands = num_bands;
|
||||
switch (num_bands) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
pstr_drc_filter_bank->complexity = 8;
|
||||
break;
|
||||
case 3:
|
||||
pstr_drc_filter_bank->complexity = 18;
|
||||
break;
|
||||
case 4:
|
||||
pstr_drc_filter_bank->complexity = 28;
|
||||
break;
|
||||
default:
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_PARAM_OUT_OF_RANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
IA_ERRORCODE impd_drc_init_all_filter_banks(
|
||||
const ia_drc_coefficients_uni_drc_struct *pstr_drc_coefficients_uni_drc,
|
||||
const ia_drc_instructions_uni_drc *pstr_drc_instructions_uni_drc,
|
||||
ia_drc_filter_banks_struct *pstr_filter_banks, VOID *ptr_scratch) {
|
||||
IA_ERRORCODE err_code = IA_NO_ERROR;
|
||||
LOOPIDX band_idx, group_idx, i, j, k;
|
||||
WORD32 crossover_freq_index, num_ch_in_groups, num_phase_alignment_ch_groups;
|
||||
WORD32 index_found = FALSE;
|
||||
WORD32 group_count[MAX_CHANNEL_GROUP_COUNT + 1] = {0};
|
||||
WORD32 *ptr_cascade_crossover_indices[MAX_CHANNEL_GROUP_COUNT + 1];
|
||||
|
||||
for (i = 0; i < MAX_CHANNEL_GROUP_COUNT + 1; i++) {
|
||||
ptr_cascade_crossover_indices[i] = (WORD32 *)(ptr_scratch);
|
||||
ptr_scratch = (UWORD8 *)ptr_scratch +
|
||||
(MAX_CHANNEL_GROUP_COUNT * 3) * sizeof(ptr_cascade_crossover_indices[i][0]);
|
||||
}
|
||||
|
||||
num_ch_in_groups = 0;
|
||||
for (group_idx = 0; group_idx < pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
group_idx++) {
|
||||
num_ch_in_groups += pstr_drc_instructions_uni_drc->num_channels_per_channel_group[group_idx];
|
||||
}
|
||||
num_phase_alignment_ch_groups = pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
if (num_ch_in_groups < pstr_drc_instructions_uni_drc->drc_channel_count) {
|
||||
num_phase_alignment_ch_groups++;
|
||||
}
|
||||
if (num_phase_alignment_ch_groups > IMPD_DRCMAX_PHASE_ALIGN_CH_GROUP) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
memset(pstr_filter_banks->str_drc_filter_bank, 0,
|
||||
sizeof(pstr_filter_banks->str_drc_filter_bank));
|
||||
pstr_filter_banks->num_phase_alignment_ch_groups = num_phase_alignment_ch_groups;
|
||||
pstr_filter_banks->num_filter_banks = pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
if (pstr_drc_coefficients_uni_drc != NULL) {
|
||||
for (group_idx = 0; group_idx < pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
group_idx++) {
|
||||
err_code = impd_drc_filter_bank_complexity(
|
||||
pstr_drc_coefficients_uni_drc
|
||||
->str_gain_set_params[pstr_drc_instructions_uni_drc
|
||||
->gain_set_index_for_channel_group[group_idx]]
|
||||
.band_count,
|
||||
&(pstr_filter_banks->str_drc_filter_bank[group_idx]));
|
||||
if (err_code) {
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pstr_filter_banks->str_drc_filter_bank->num_bands = 1;
|
||||
}
|
||||
|
||||
if (pstr_drc_coefficients_uni_drc != NULL) {
|
||||
for (group_idx = 0; group_idx < pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
group_idx++) {
|
||||
for (band_idx = 1;
|
||||
band_idx < pstr_drc_coefficients_uni_drc
|
||||
->str_gain_set_params[pstr_drc_instructions_uni_drc
|
||||
->gain_set_index_for_channel_group[group_idx]]
|
||||
.band_count;
|
||||
band_idx++) {
|
||||
crossover_freq_index =
|
||||
pstr_drc_coefficients_uni_drc
|
||||
->str_gain_set_params[pstr_drc_instructions_uni_drc
|
||||
->gain_set_index_for_channel_group[group_idx]]
|
||||
.gain_params[band_idx]
|
||||
.crossover_freq_index;
|
||||
|
||||
for (j = 0; j < num_phase_alignment_ch_groups; j++) {
|
||||
if (j != group_idx) {
|
||||
ptr_cascade_crossover_indices[j][group_count[j]] = crossover_freq_index;
|
||||
group_count[j]++;
|
||||
if (group_count[j] > MAX_CHANNEL_GROUP_COUNT * 3) {
|
||||
return IA_EXHEAACE_CONFIG_FATAL_DRC_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < group_count[0]) {
|
||||
crossover_freq_index = ptr_cascade_crossover_indices[0][i];
|
||||
index_found = FALSE;
|
||||
for (group_idx = 1; group_idx < num_phase_alignment_ch_groups; group_idx++) {
|
||||
index_found = FALSE;
|
||||
for (j = 0; j < group_count[group_idx]; j++) {
|
||||
if (ptr_cascade_crossover_indices[group_idx][j] == crossover_freq_index) {
|
||||
index_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index_found == FALSE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index_found == FALSE) {
|
||||
i++;
|
||||
} else {
|
||||
for (group_idx = 0; group_idx < num_phase_alignment_ch_groups; group_idx++) {
|
||||
for (j = 0; j < group_count[group_idx]; j++) {
|
||||
if (ptr_cascade_crossover_indices[group_idx][j] == crossover_freq_index) {
|
||||
for (k = j + 1; k < group_count[group_idx]; k++) {
|
||||
ptr_cascade_crossover_indices[group_idx][k - 1] =
|
||||
ptr_cascade_crossover_indices[group_idx][k];
|
||||
}
|
||||
group_count[group_idx]--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
for (group_idx = 0; group_idx < num_phase_alignment_ch_groups; group_idx++) {
|
||||
if (group_count[group_idx] > 0) {
|
||||
pstr_filter_banks->str_drc_filter_bank[group_idx].complexity +=
|
||||
(group_count[group_idx] << 1);
|
||||
}
|
||||
}
|
||||
pstr_filter_banks->complexity = 0;
|
||||
for (group_idx = 0; group_idx < pstr_drc_instructions_uni_drc->num_drc_channel_groups;
|
||||
group_idx++) {
|
||||
pstr_filter_banks->complexity +=
|
||||
pstr_drc_instructions_uni_drc->num_channels_per_channel_group[group_idx] *
|
||||
pstr_filter_banks->str_drc_filter_bank[group_idx].complexity;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
39
encoder/drc_src/impd_drc_uni_drc_filter_bank.h
Normal file
39
encoder/drc_src/impd_drc_uni_drc_filter_bank.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define IMPD_DRCMAX_PHASE_ALIGN_CH_GROUP (32)
|
||||
|
||||
typedef struct {
|
||||
WORD32 num_bands;
|
||||
WORD32 complexity;
|
||||
} ia_drc_filter_bank_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 num_filter_banks;
|
||||
WORD32 num_phase_alignment_ch_groups;
|
||||
WORD32 complexity;
|
||||
ia_drc_filter_bank_struct str_drc_filter_bank[IMPD_DRCMAX_PHASE_ALIGN_CH_GROUP];
|
||||
} ia_drc_filter_banks_struct;
|
||||
|
||||
IA_ERRORCODE impd_drc_init_all_filter_banks(
|
||||
const ia_drc_coefficients_uni_drc_struct *pstr_drc_coefficients_uni_drc,
|
||||
const ia_drc_instructions_uni_drc *pstr_drc_instructions_uni_drc,
|
||||
ia_drc_filter_banks_struct *pstr_filter_banks, VOID *ptr_scratch);
|
||||
12
encoder/drc_src/libxaacenc_drc.cmake
Normal file
12
encoder/drc_src/libxaacenc_drc.cmake
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# src files
|
||||
list(
|
||||
APPEND
|
||||
LIBXAACENC_SRCS
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_api.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_enc.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_gain_calculator.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_gain_enc.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_mux.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_tables.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_uni_drc_eq.c"
|
||||
"${XAAC_ROOT}/encoder/drc_src/impd_drc_uni_drc_filter_bank.c")
|
||||
439
encoder/iusace_acelp_enc.c
Normal file
439
encoder/iusace_acelp_enc.c
Normal file
|
|
@ -0,0 +1,439 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
#include "iusace_lpd.h"
|
||||
|
||||
VOID iusace_acelp_encode(FLOAT32 *lp_filt_coeff, FLOAT32 *quant_lp_filt_coeff, FLOAT32 *speech_in,
|
||||
FLOAT32 *wsig_in, FLOAT32 *synth_out, FLOAT32 *wsynth_out,
|
||||
WORD16 acelp_core_mode, ia_usac_lpd_state_struct *lpd_state,
|
||||
WORD32 len_subfrm, FLOAT32 norm_corr, FLOAT32 norm_corr2,
|
||||
WORD32 ol_pitch_lag1, WORD32 ol_pitch_lag2, WORD32 pit_adj,
|
||||
WORD32 *acelp_params, iusace_scratch_mem *pstr_scratch) {
|
||||
WORD32 i, i_subfr, num_bits, t;
|
||||
WORD32 t0, t0_min, t0_max, index, subfrm_flag;
|
||||
WORD32 t0_frac;
|
||||
FLOAT32 temp, energy, max_ener, mean_ener_code;
|
||||
FLOAT32 pitch_gain, code_gain, gain1, gain2;
|
||||
FLOAT32 tgt_cb_corr[5], tgt_cb_corr2[2];
|
||||
FLOAT32 *p_lp_filt_coeff, *p_quant_lp_filt_coeff, weighted_lpc[ORDER + 1];
|
||||
FLOAT32 imp_res[LEN_SUBFR];
|
||||
FLOAT32 code[LEN_SUBFR];
|
||||
WORD16 cb_exc[LEN_SUBFR];
|
||||
FLOAT32 error[ORDER + LEN_SUBFR + 8];
|
||||
FLOAT32 cn[LEN_SUBFR];
|
||||
FLOAT32 xn[LEN_SUBFR];
|
||||
FLOAT32 xn2[LEN_SUBFR];
|
||||
FLOAT32 dn[LEN_SUBFR];
|
||||
FLOAT32 y0[LEN_SUBFR];
|
||||
FLOAT32 y1[LEN_SUBFR];
|
||||
FLOAT32 y2[LEN_SUBFR];
|
||||
WORD32 min_pitch_lag_res1_4;
|
||||
WORD32 min_pitch_lag_res1_2;
|
||||
WORD32 min_pitch_lag_res1;
|
||||
WORD32 max_pitch_lag;
|
||||
FLOAT32 *exc_buf = pstr_scratch->p_acelp_exc_buf;
|
||||
FLOAT32 *exc;
|
||||
FLOAT32 mem_txn, mem_txnq;
|
||||
WORD32 fac_length = len_subfrm / 2;
|
||||
if (lpd_state->mode > 0) {
|
||||
for (i = 0; i < fac_length; i++) {
|
||||
acelp_params[i] = lpd_state->avq_params[i];
|
||||
}
|
||||
acelp_params += fac_length;
|
||||
}
|
||||
|
||||
if (pit_adj == SR_MAX)
|
||||
exc = exc_buf + (2 * len_subfrm) + 41;
|
||||
else
|
||||
exc = exc_buf + (2 * len_subfrm);
|
||||
|
||||
memset(exc_buf, 0, (2 * len_subfrm) * sizeof(exc_buf[0]));
|
||||
memcpy(exc_buf, lpd_state->acelp_exc, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
memcpy(synth_out - 128, &(lpd_state->synth[ORDER]), 128 * sizeof(FLOAT32));
|
||||
memcpy(wsynth_out - 128, &(lpd_state->wsynth[1]), 128 * sizeof(FLOAT32));
|
||||
|
||||
num_bits = ((iusace_acelp_core_numbits_1024[acelp_core_mode] - NBITS_MODE) / 4) - NBITS_LPC;
|
||||
|
||||
if (pit_adj == 0) {
|
||||
min_pitch_lag_res1_4 = TMIN;
|
||||
min_pitch_lag_res1_2 = TFR2;
|
||||
min_pitch_lag_res1 = TFR1;
|
||||
max_pitch_lag = TMAX;
|
||||
} else {
|
||||
i = (((pit_adj * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN;
|
||||
min_pitch_lag_res1_4 = TMIN + i;
|
||||
min_pitch_lag_res1_2 = TFR2 - i;
|
||||
min_pitch_lag_res1 = TFR1;
|
||||
max_pitch_lag = TMAX + (6 * i);
|
||||
}
|
||||
|
||||
ol_pitch_lag1 *= OPL_DECIM;
|
||||
ol_pitch_lag2 *= OPL_DECIM;
|
||||
|
||||
t0_min = ol_pitch_lag1 - 8;
|
||||
|
||||
t = MIN(ol_pitch_lag1, ol_pitch_lag2) - 4;
|
||||
if (t0_min < t) t0_min = t;
|
||||
|
||||
if (t0_min < min_pitch_lag_res1_4) {
|
||||
t0_min = min_pitch_lag_res1_4;
|
||||
}
|
||||
t0_max = t0_min + 15;
|
||||
t = MAX(ol_pitch_lag1, ol_pitch_lag2) + 4;
|
||||
if (t0_max > t) t0_max = t;
|
||||
|
||||
if (t0_max > max_pitch_lag) {
|
||||
t0_max = max_pitch_lag;
|
||||
t0_min = t0_max - 15;
|
||||
}
|
||||
|
||||
max_ener = 0.0;
|
||||
mean_ener_code = 0.0;
|
||||
p_quant_lp_filt_coeff = quant_lp_filt_coeff;
|
||||
for (i_subfr = 0; i_subfr < len_subfrm; i_subfr += LEN_SUBFR) {
|
||||
iusace_compute_lp_residual(p_quant_lp_filt_coeff, &speech_in[i_subfr], &exc[i_subfr],
|
||||
LEN_SUBFR);
|
||||
energy = 0.01f;
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
energy += exc[i + i_subfr] * exc[i + i_subfr];
|
||||
}
|
||||
energy = 10.0f * (FLOAT32)log10(energy / ((FLOAT32)LEN_SUBFR));
|
||||
if (energy < 0.0) {
|
||||
energy = 0.0;
|
||||
}
|
||||
if (energy > max_ener) {
|
||||
max_ener = energy;
|
||||
}
|
||||
mean_ener_code += 0.25f * energy;
|
||||
p_quant_lp_filt_coeff += (ORDER + 1);
|
||||
}
|
||||
|
||||
mean_ener_code -= 5.0f * norm_corr;
|
||||
mean_ener_code -= 5.0f * norm_corr2;
|
||||
|
||||
temp = (mean_ener_code - 18.0f) / 12.0f;
|
||||
index = (WORD32)floor(temp + 0.5);
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (index > 3) {
|
||||
index = 3;
|
||||
}
|
||||
mean_ener_code = (((FLOAT32)index) * 12.0f) + 18.0f;
|
||||
|
||||
while ((mean_ener_code < (max_ener - 27.0)) && (index < 3)) {
|
||||
index++;
|
||||
mean_ener_code += 12.0;
|
||||
}
|
||||
*acelp_params = index;
|
||||
acelp_params++;
|
||||
|
||||
p_lp_filt_coeff = lp_filt_coeff;
|
||||
p_quant_lp_filt_coeff = quant_lp_filt_coeff;
|
||||
for (i_subfr = 0; i_subfr < len_subfrm; i_subfr += LEN_SUBFR) {
|
||||
subfrm_flag = i_subfr;
|
||||
if ((len_subfrm == 256) && (i_subfr == (2 * LEN_SUBFR))) {
|
||||
subfrm_flag = 0;
|
||||
|
||||
t0_min = ol_pitch_lag2 - 8;
|
||||
|
||||
t = MIN(ol_pitch_lag1, ol_pitch_lag2) - 4;
|
||||
if (t0_min < t) t0_min = t;
|
||||
|
||||
if (t0_min < min_pitch_lag_res1_4) {
|
||||
t0_min = min_pitch_lag_res1_4;
|
||||
}
|
||||
t0_max = t0_min + 15;
|
||||
|
||||
t = MAX(ol_pitch_lag1, ol_pitch_lag2) + 4;
|
||||
if (t0_max > t) t0_max = t;
|
||||
|
||||
if (t0_max > max_pitch_lag) {
|
||||
t0_max = max_pitch_lag;
|
||||
t0_min = t0_max - 15;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(xn, &wsig_in[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
|
||||
|
||||
memcpy(error, &synth_out[i_subfr - ORDER], ORDER * sizeof(FLOAT32));
|
||||
memset(error + ORDER, 0, LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_synthesis_tool_float(p_quant_lp_filt_coeff, error + ORDER, error + ORDER, LEN_SUBFR,
|
||||
error, pstr_scratch->p_buf_synthesis_tool);
|
||||
iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
|
||||
iusace_compute_lp_residual(weighted_lpc, error + ORDER, xn2, LEN_SUBFR);
|
||||
|
||||
temp = wsynth_out[i_subfr - 1];
|
||||
iusace_apply_deemph(xn2, TILT_FAC, LEN_SUBFR, &temp);
|
||||
memcpy(y0, xn2, LEN_SUBFR * sizeof(FLOAT32));
|
||||
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
xn[i] -= xn2[i];
|
||||
}
|
||||
iusace_compute_lp_residual(p_quant_lp_filt_coeff, &speech_in[i_subfr], &exc[i_subfr],
|
||||
LEN_SUBFR);
|
||||
|
||||
memset(&code[0], 0, ORDER * sizeof(code[0]));
|
||||
memcpy(code + ORDER, xn, (LEN_SUBFR / 2) * sizeof(FLOAT32));
|
||||
temp = 0.0;
|
||||
iusace_apply_preemph(code + ORDER, TILT_FAC, LEN_SUBFR / 2, &temp);
|
||||
iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
|
||||
iusace_synthesis_tool_float(weighted_lpc, code + ORDER, code + ORDER, LEN_SUBFR / 2, code,
|
||||
pstr_scratch->p_buf_synthesis_tool);
|
||||
iusace_compute_lp_residual(p_quant_lp_filt_coeff, code + ORDER, cn, LEN_SUBFR / 2);
|
||||
memcpy(cn + (LEN_SUBFR / 2), &exc[i_subfr + (LEN_SUBFR / 2)],
|
||||
(LEN_SUBFR / 2) * sizeof(FLOAT32));
|
||||
|
||||
iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
|
||||
memset(imp_res, 0, LEN_SUBFR * sizeof(FLOAT32));
|
||||
memcpy(imp_res, weighted_lpc, (ORDER + 1) * sizeof(FLOAT32));
|
||||
iusace_synthesis_tool_float(p_quant_lp_filt_coeff, imp_res, imp_res, LEN_SUBFR,
|
||||
&imp_res[ORDER + 1], pstr_scratch->p_buf_synthesis_tool);
|
||||
temp = 0.0;
|
||||
iusace_apply_deemph(imp_res, TILT_FAC, LEN_SUBFR, &temp);
|
||||
|
||||
iusace_closed_loop_search(&exc[i_subfr], xn, imp_res, t0_min, t0_max, &t0_frac, subfrm_flag,
|
||||
min_pitch_lag_res1_2, min_pitch_lag_res1, &t0);
|
||||
|
||||
if (subfrm_flag == 0) {
|
||||
if (t0 < min_pitch_lag_res1_2) {
|
||||
index = t0 * 4 + t0_frac - (min_pitch_lag_res1_4 * 4);
|
||||
} else if (t0 < min_pitch_lag_res1) {
|
||||
index = t0 * 2 + (t0_frac >> 1) - (min_pitch_lag_res1_2 * 2) +
|
||||
((min_pitch_lag_res1_2 - min_pitch_lag_res1_4) * 4);
|
||||
} else {
|
||||
index = t0 - min_pitch_lag_res1 + ((min_pitch_lag_res1_2 - min_pitch_lag_res1_4) * 4) +
|
||||
((min_pitch_lag_res1 - min_pitch_lag_res1_2) * 2);
|
||||
}
|
||||
|
||||
t0_min = t0 - 8;
|
||||
if (t0_min < min_pitch_lag_res1_4) {
|
||||
t0_min = min_pitch_lag_res1_4;
|
||||
}
|
||||
t0_max = t0_min + 15;
|
||||
if (t0_max > max_pitch_lag) {
|
||||
t0_max = max_pitch_lag;
|
||||
t0_min = t0_max - 15;
|
||||
}
|
||||
} else {
|
||||
i = t0 - t0_min;
|
||||
index = i * 4 + t0_frac;
|
||||
}
|
||||
*acelp_params = index;
|
||||
acelp_params++;
|
||||
|
||||
iusace_acelp_ltpred_cb_exc(&exc[i_subfr], t0, t0_frac, LEN_SUBFR + 1);
|
||||
iusace_convolve(&exc[i_subfr], imp_res, y1);
|
||||
gain1 = iusace_acelp_tgt_cb_corr2(xn, y1, tgt_cb_corr);
|
||||
iusace_acelp_cb_target_update(xn, xn2, y1, gain1);
|
||||
energy = 0.0;
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
energy += xn2[i] * xn2[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
code[i] = (FLOAT32)(0.18 * exc[i - 1 + i_subfr] + 0.64 * exc[i + i_subfr] +
|
||||
0.18 * exc[i + 1 + i_subfr]);
|
||||
}
|
||||
iusace_convolve(code, imp_res, y2);
|
||||
gain2 = iusace_acelp_tgt_cb_corr2(xn, y2, tgt_cb_corr2);
|
||||
|
||||
iusace_acelp_cb_target_update(xn, xn2, y2, gain2);
|
||||
temp = 0.0;
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
temp += xn2[i] * xn2[i];
|
||||
}
|
||||
|
||||
if (temp < energy) {
|
||||
*acelp_params = 0;
|
||||
memcpy(&exc[i_subfr], code, LEN_SUBFR * sizeof(FLOAT32));
|
||||
memcpy(y1, y2, LEN_SUBFR * sizeof(FLOAT32));
|
||||
pitch_gain = gain2;
|
||||
tgt_cb_corr[0] = tgt_cb_corr2[0];
|
||||
tgt_cb_corr[1] = tgt_cb_corr2[1];
|
||||
} else {
|
||||
*acelp_params = 1;
|
||||
pitch_gain = gain1;
|
||||
}
|
||||
acelp_params++;
|
||||
|
||||
iusace_acelp_cb_target_update(xn, xn2, y1, pitch_gain);
|
||||
iusace_acelp_cb_target_update(cn, cn, &exc[i_subfr], pitch_gain);
|
||||
|
||||
temp = 0.0;
|
||||
iusace_apply_preemph(imp_res, TILT_CODE, LEN_SUBFR, &temp);
|
||||
if (t0_frac > 2) {
|
||||
t0++;
|
||||
}
|
||||
|
||||
for (i = t0; i < LEN_SUBFR; i++) {
|
||||
imp_res[i] += imp_res[i - t0] * PIT_SHARP;
|
||||
}
|
||||
|
||||
iusace_acelp_tgt_ir_corr(xn2, imp_res, dn);
|
||||
|
||||
if (acelp_core_mode == ACELP_CORE_MODE_9k6) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_20, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 4;
|
||||
} else if (acelp_core_mode == ACELP_CORE_MODE_11k2) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_28, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 4;
|
||||
} else if (acelp_core_mode == ACELP_CORE_MODE_12k8) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_36, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 4;
|
||||
} else if (acelp_core_mode == ACELP_CORE_MODE_14k4) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_44, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 4;
|
||||
} else if (acelp_core_mode == ACELP_CORE_MODE_16k) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_52, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 4;
|
||||
} else if (acelp_core_mode == ACELP_CORE_MODE_18k4) {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_64, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 8;
|
||||
} else {
|
||||
iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_64, acelp_params,
|
||||
pstr_scratch->p_acelp_ir_buf);
|
||||
acelp_params += 8;
|
||||
}
|
||||
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
code[i] = (FLOAT32)(cb_exc[i] / 512);
|
||||
}
|
||||
|
||||
temp = 0.0;
|
||||
iusace_apply_preemph(code, TILT_CODE, LEN_SUBFR, &temp);
|
||||
for (i = t0; i < LEN_SUBFR; i++) {
|
||||
code[i] += code[i - t0] * PIT_SHARP;
|
||||
}
|
||||
|
||||
iusace_acelp_tgt_cb_corr1(xn, y1, y2, tgt_cb_corr);
|
||||
iusace_acelp_quant_gain(code, &pitch_gain, &code_gain, tgt_cb_corr, mean_ener_code,
|
||||
acelp_params);
|
||||
acelp_params++;
|
||||
|
||||
temp = 0.0;
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
temp += code[i] * code[i];
|
||||
}
|
||||
temp *= code_gain * code_gain;
|
||||
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
wsynth_out[i + i_subfr] = y0[i] + (pitch_gain * y1[i]) + (code_gain * y2[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < LEN_SUBFR; i++) {
|
||||
exc[i + i_subfr] = pitch_gain * exc[i + i_subfr] + code_gain * code[i];
|
||||
}
|
||||
|
||||
iusace_synthesis_tool_float(p_quant_lp_filt_coeff, &exc[i_subfr], &synth_out[i_subfr],
|
||||
LEN_SUBFR, &synth_out[i_subfr - ORDER],
|
||||
pstr_scratch->p_buf_synthesis_tool);
|
||||
p_lp_filt_coeff += (ORDER + 1);
|
||||
p_quant_lp_filt_coeff += (ORDER + 1);
|
||||
}
|
||||
|
||||
memcpy(lpd_state->acelp_exc, exc - len_subfrm, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->synth, synth_out + len_subfrm - (ORDER + 128),
|
||||
(ORDER + 128) * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->wsynth, wsynth_out + len_subfrm - (1 + 128), (1 + 128) * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->lpc_coeffs_quant, p_quant_lp_filt_coeff - (2 * (ORDER + 1)),
|
||||
(2 * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->lpc_coeffs, p_lp_filt_coeff - (2 * (ORDER + 1)),
|
||||
(2 * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
|
||||
mem_txn = lpd_state->tcx_mem[128 - 1];
|
||||
mem_txnq = lpd_state->tcx_fac;
|
||||
|
||||
p_quant_lp_filt_coeff = quant_lp_filt_coeff;
|
||||
for (i_subfr = 0; i_subfr < (len_subfrm - 2 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
|
||||
iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
|
||||
|
||||
memcpy(error, &speech_in[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(error, TILT_FAC, LEN_SUBFR, &mem_txn);
|
||||
|
||||
memcpy(error, &synth_out[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(error, TILT_FAC, LEN_SUBFR, &mem_txnq);
|
||||
|
||||
p_quant_lp_filt_coeff += (ORDER + 1);
|
||||
}
|
||||
|
||||
lpd_state->tcx_quant[0] = mem_txnq;
|
||||
for (i_subfr = 0; i_subfr < (2 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
|
||||
iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
|
||||
|
||||
memcpy(&(lpd_state->tcx_mem[i_subfr]), &speech_in[i_subfr + (len_subfrm - 2 * LEN_SUBFR)],
|
||||
LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(&(lpd_state->tcx_mem[i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txn);
|
||||
|
||||
memcpy(&(lpd_state->tcx_quant[1 + i_subfr]),
|
||||
&synth_out[i_subfr + (len_subfrm - 2 * LEN_SUBFR)], LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(&(lpd_state->tcx_quant[1 + i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txnq);
|
||||
p_quant_lp_filt_coeff += (ORDER + 1);
|
||||
}
|
||||
lpd_state->tcx_fac = mem_txnq;
|
||||
|
||||
iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
|
||||
|
||||
memcpy(error, &synth_out[len_subfrm - ORDER], ORDER * sizeof(FLOAT32));
|
||||
for (i_subfr = (2 * LEN_SUBFR); i_subfr < (4 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
|
||||
memset(error + ORDER, 0, LEN_SUBFR * sizeof(FLOAT32));
|
||||
|
||||
iusace_synthesis_tool_float(p_quant_lp_filt_coeff, error + ORDER, error + ORDER, LEN_SUBFR,
|
||||
error, pstr_scratch->p_buf_synthesis_tool);
|
||||
memcpy(&(lpd_state->tcx_quant[1 + i_subfr]), error + ORDER, LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(&(lpd_state->tcx_quant[1 + i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txnq);
|
||||
memcpy(error, error + LEN_SUBFR, ORDER * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
lpd_state->mode = 0;
|
||||
|
||||
lpd_state->num_bits = num_bits;
|
||||
}
|
||||
213
encoder/iusace_acelp_rom.c
Normal file
213
encoder/iusace_acelp_rom.c
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
|
||||
const UWORD8 iusace_acelp_ipos[36] = {0, 1, 2, 3, 1, 2, 3, 0, 2, 3, 0, 1, 3, 0, 1, 2, 0, 1,
|
||||
2, 3, 1, 2, 3, 0, 2, 3, 0, 1, 3, 0, 1, 2, 0, 1, 2, 3};
|
||||
|
||||
const FLOAT32 iusace_chebyshev_polyn_grid[101] = {
|
||||
1.00000F, 0.999507F, 0.998027F, 0.995562F, 0.992115F, 0.987688F, 0.982287F,
|
||||
0.975917F, 0.968583F, 0.960294F, 0.951057F, 0.940881F, 0.929776F, 0.917755F,
|
||||
0.904827F, 0.891007F, 0.876307F, 0.860742F, 0.844328F, 0.827081F, 0.809017F,
|
||||
0.790155F, 0.770513F, 0.750111F, 0.728969F, 0.707107F, 0.684547F, 0.661312F,
|
||||
0.637424F, 0.612907F, 0.587785F, 0.562083F, 0.535827F, 0.509041F, 0.481754F,
|
||||
0.453990F, 0.425779F, 0.397148F, 0.368124F, 0.338738F, 0.309017F, 0.278991F,
|
||||
0.248690F, 0.218143F, 0.187381F, 0.156434F, 0.125333F, 0.0941082F, 0.0627904F,
|
||||
0.0314107F, -8.09643e-008F, -0.0314108F, -0.0627906F, -0.0941084F, -0.125333F, -0.156435F,
|
||||
-0.187381F, -0.218143F, -0.248690F, -0.278991F, -0.309017F, -0.338738F, -0.368125F,
|
||||
-0.397148F, -0.425779F, -0.453991F, -0.481754F, -0.509041F, -0.535827F, -0.562083F,
|
||||
-0.587785F, -0.612907F, -0.637424F, -0.661312F, -0.684547F, -0.707107F, -0.728969F,
|
||||
-0.750111F, -0.770513F, -0.790155F, -0.809017F, -0.827081F, -0.844328F, -0.860742F,
|
||||
-0.876307F, -0.891007F, -0.904827F, -0.917755F, -0.929777F, -0.940881F, -0.951057F,
|
||||
-0.960294F, -0.968583F, -0.975917F, -0.982287F, -0.987688F, -0.992115F, -0.995562F,
|
||||
-0.998027F, -0.999507F, -1.00000F};
|
||||
|
||||
const FLOAT32 iusace_ol_corr_weight[518] = {
|
||||
0.221587981217023f, 0.222261823815225f, 0.222935666413414f, 0.223609509011589f,
|
||||
0.224283351609750f, 0.224957194207899f, 0.225631036806034f, 0.226304879404157f,
|
||||
0.226978722002268f, 0.227652564600366f, 0.228326407198452f, 0.229000249796527f,
|
||||
0.229674092394590f, 0.230347934992642f, 0.231021777590682f, 0.231695620188712f,
|
||||
0.232369462786731f, 0.233043305384739f, 0.233717147982738f, 0.234390990580726f,
|
||||
0.235064833178704f, 0.235738675776673f, 0.236412518374633f, 0.237086360972583f,
|
||||
0.237760203570524f, 0.238434046168457f, 0.239107888766381f, 0.239781731364297f,
|
||||
0.240455573962205f, 0.241129416560105f, 0.241803259157998f, 0.242477101755883f,
|
||||
0.243150944353761f, 0.243824786951632f, 0.244498629549496f, 0.245172472147353f,
|
||||
0.245846314745205f, 0.246520157343050f, 0.247193999940890f, 0.247867842538723f,
|
||||
0.248541685136552f, 0.249215527734375f, 0.249889370332193f, 0.250563212930007f,
|
||||
0.251237055527815f, 0.251910898125620f, 0.252584740723420f, 0.253258583321217f,
|
||||
0.253932425919010f, 0.254606268516799f, 0.255280111114586f, 0.255953953712369f,
|
||||
0.256627796310149f, 0.257301638907927f, 0.257975481505702f, 0.258649324103476f,
|
||||
0.259323166701247f, 0.259997009299017f, 0.260670851896785f, 0.261344694494552f,
|
||||
0.262018537092318f, 0.262692379690083f, 0.263366222287848f, 0.263366222287847f,
|
||||
0.264040064885612f, 0.264713907483376f, 0.265387750081140f, 0.266061592678904f,
|
||||
0.266735435276667f, 0.267409277874430f, 0.268083120472194f, 0.268756963069956f,
|
||||
0.269430805667719f, 0.270104648265482f, 0.270778490863244f, 0.271452333461006f,
|
||||
0.272126176058768f, 0.272800018656529f, 0.273473861254291f, 0.274147703852052f,
|
||||
0.274821546449814f, 0.275495389047575f, 0.276169231645336f, 0.276843074243096f,
|
||||
0.277516916840857f, 0.278190759438618f, 0.278864602036378f, 0.279538444634139f,
|
||||
0.280212287231899f, 0.280886129829659f, 0.281559972427420f, 0.282233815025180f,
|
||||
0.282907657622940f, 0.283581500220700f, 0.284255342818460f, 0.284929185416220f,
|
||||
0.285603028013980f, 0.286276870611740f, 0.286950713209500f, 0.287624555807260f,
|
||||
0.288298398405020f, 0.288972241002780f, 0.289646083600540f, 0.290319926198300f,
|
||||
0.290993768796060f, 0.291667611393820f, 0.292341453991580f, 0.293015296589340f,
|
||||
0.293689139187100f, 0.294362981784860f, 0.295036824382620f, 0.295710666980380f,
|
||||
0.296384509578140f, 0.297058352175900f, 0.297732194773660f, 0.298406037371420f,
|
||||
0.299079879969180f, 0.299753722566940f, 0.300427565164700f, 0.301101407762460f,
|
||||
0.301775250360220f, 0.302449092957980f, 0.303122935555740f, 0.303796778153500f,
|
||||
0.304470620751260f, 0.305144463349020f, 0.305818305946780f, 0.306492148544540f,
|
||||
0.307165991142300f, 0.307839833740060f, 0.308513676337820f, 0.309187518935580f,
|
||||
0.309861361533340f, 0.310535204131100f, 0.311209046728860f, 0.311882889326620f,
|
||||
0.312556731924380f, 0.313230574522140f, 0.313904417119900f, 0.314578259717660f,
|
||||
0.315252102315420f, 0.315925944913180f, 0.316599787510940f, 0.317273630108700f,
|
||||
0.317947472706460f, 0.318621315304220f, 0.319295157901980f, 0.319969000499740f,
|
||||
0.320642843097500f, 0.321316685695260f, 0.321990528293020f, 0.322664370890780f,
|
||||
0.323338213488540f, 0.324012056086300f, 0.324685898684060f, 0.325359741281820f,
|
||||
0.326033583879580f, 0.326707426477340f, 0.327381269075100f, 0.328055111672860f,
|
||||
0.328728954270620f, 0.329402796868380f, 0.330083976070000f, 0.330772637748820f,
|
||||
0.331468932014340f, 0.332173013374690f, 0.332885040906940f, 0.333605178435610f,
|
||||
0.334333594719850f, 0.335070463649910f, 0.335815964453310f, 0.336570281911320f,
|
||||
0.337333606586500f, 0.338106135061810f, 0.338888070192030f, 0.339679621368370f,
|
||||
0.340481004796980f, 0.341292443792250f, 0.342114169085970f, 0.342946419153120f,
|
||||
0.343789440555740f, 0.344643488305690f, 0.345508826247860f, 0.346385727465050f,
|
||||
0.347274474706060f, 0.348175360838540f, 0.349088689328410f, 0.350014774747620f,
|
||||
0.350953943312400f, 0.351906533454040f, 0.352872896424760f, 0.353853396941050f,
|
||||
0.354848413867530f, 0.355858340944150f, 0.356883587560250f, 0.357924579578940f,
|
||||
0.358981760215980f, 0.360055590977160f, 0.361146552659300f, 0.362255146419720f,
|
||||
0.363381894919980f, 0.364527343550210f, 0.365692061740660f, 0.366876644368180f,
|
||||
0.368081713265840f, 0.369307918844770f, 0.370555941838460f, 0.371826495180490f,
|
||||
0.373120326028240f, 0.374438217946110f, 0.375780993263580f, 0.377149515625000f,
|
||||
0.378544692749950f, 0.379967479425290f, 0.381418880752330f, 0.382899955675540f,
|
||||
0.384411820822400f, 0.385955654687440f, 0.387532702198100f, 0.389144279704500f,
|
||||
0.390791780440810f, 0.392476680512480f, 0.394200545470490f, 0.395965037542720f,
|
||||
0.397771923602130f, 0.399623083962790f, 0.401520522108530f, 0.403466375474260f,
|
||||
0.405462927418450f, 0.407512620547120f, 0.409618071574760f, 0.411782087938380f,
|
||||
0.414007686416520f, 0.416298114048290f, 0.418656871699000f, 0.421087740681110f,
|
||||
0.423594812914300f, 0.426182525199670f, 0.428855698294360f, 0.431619581609630f,
|
||||
0.434479904523260f, 0.437442935506450f, 0.440515550524830f, 0.443705312500000f,
|
||||
0.447020564029760f, 0.450470536088870f, 0.454065476102870f, 0.457816799652350f,
|
||||
0.461737271191160f, 0.465841220638500f, 0.470144804662100f, 0.474666324087360f,
|
||||
0.479426612408380f, 0.484449515221620f, 0.490000000000000f, 0.500000000000000f,
|
||||
0.500000000000000f, 0.500000000000000f, 0.500000000000000f, 0.500000000000000f,
|
||||
0.500000000000000f, 0.500000000000000f, 0.490000000000000f, 0.484449515221620f,
|
||||
0.479426612408380f, 0.474666324087360f, 0.470144804662100f, 0.465841220638500f,
|
||||
0.461737271191160f, 0.457816799652350f, 0.454065476102870f, 0.450470536088870f,
|
||||
0.447020564029760f, 0.443705312500000f, 0.440515550524830f, 0.437442935506450f,
|
||||
0.434479904523260f, 0.431619581609630f, 0.428855698294360f, 0.426182525199670f,
|
||||
0.423594812914300f, 0.421087740681110f, 0.418656871699000f, 0.416298114048290f,
|
||||
0.414007686416520f, 0.411782087938380f, 0.409618071574760f, 0.407512620547120f,
|
||||
0.405462927418450f, 0.403466375474260f, 0.401520522108530f, 0.399623083962790f,
|
||||
0.397771923602130f, 0.395965037542720f, 0.394200545470490f, 0.392476680512480f,
|
||||
0.390791780440810f, 0.389144279704500f, 0.387532702198100f, 0.385955654687440f,
|
||||
0.384411820822400f, 0.382899955675540f, 0.381418880752330f, 0.379967479425290f,
|
||||
0.378544692749950f, 0.377149515625000f, 0.375780993263580f, 0.374438217946110f,
|
||||
0.373120326028240f, 0.371826495180490f, 0.370555941838460f, 0.369307918844770f,
|
||||
0.368081713265840f, 0.366876644368180f, 0.365692061740660f, 0.364527343550210f,
|
||||
0.363381894919980f, 0.362255146419720f, 0.361146552659300f, 0.360055590977160f,
|
||||
0.358981760215980f, 0.357924579578940f, 0.356883587560250f, 0.355858340944150f,
|
||||
0.354848413867530f, 0.353853396941050f, 0.352872896424760f, 0.351906533454040f,
|
||||
0.350953943312400f, 0.350014774747620f, 0.349088689328410f, 0.348175360838540f,
|
||||
0.347274474706060f, 0.346385727465050f, 0.345508826247860f, 0.344643488305690f,
|
||||
0.343789440555740f, 0.342946419153120f, 0.342114169085970f, 0.341292443792250f,
|
||||
0.340481004796980f, 0.339679621368370f, 0.338888070192030f, 0.338106135061810f,
|
||||
0.337333606586500f, 0.336570281911320f, 0.335815964453310f, 0.335070463649910f,
|
||||
0.334333594719850f, 0.333605178435610f, 0.332885040906940f, 0.332173013374690f,
|
||||
0.331468932014340f, 0.330772637748820f, 0.330083976070000f, 0.329402796868380f,
|
||||
0.328728954270620f, 0.328062306484320f, 0.327402715649920f, 0.328055111672860f,
|
||||
0.327381269075100f, 0.326707426477340f, 0.326033583879580f, 0.325359741281820f,
|
||||
0.324685898684060f, 0.324012056086300f, 0.323338213488540f, 0.322664370890780f,
|
||||
0.321990528293020f, 0.321316685695260f, 0.320642843097500f, 0.319969000499740f,
|
||||
0.319295157901980f, 0.318621315304220f, 0.317947472706460f, 0.317273630108700f,
|
||||
0.316599787510940f, 0.315925944913180f, 0.315252102315420f, 0.314578259717660f,
|
||||
0.313904417119900f, 0.313230574522140f, 0.312556731924380f, 0.311882889326620f,
|
||||
0.311209046728860f, 0.310535204131100f, 0.309861361533340f, 0.309187518935580f,
|
||||
0.308513676337820f, 0.307839833740060f, 0.307165991142300f, 0.306492148544540f,
|
||||
0.305818305946780f, 0.305144463349020f, 0.304470620751260f, 0.303796778153500f,
|
||||
0.303122935555740f, 0.302449092957980f, 0.301775250360220f, 0.301101407762460f,
|
||||
0.300427565164700f, 0.299753722566940f, 0.299079879969180f, 0.298406037371420f,
|
||||
0.297732194773660f, 0.297058352175900f, 0.296384509578140f, 0.295710666980380f,
|
||||
0.295036824382620f, 0.294362981784860f, 0.293689139187100f, 0.293015296589340f,
|
||||
0.292341453991580f, 0.291667611393820f, 0.290993768796060f, 0.290319926198300f,
|
||||
0.289646083600540f, 0.288972241002780f, 0.288298398405020f, 0.287624555807260f,
|
||||
0.286950713209500f, 0.286276870611740f, 0.285603028013980f, 0.284929185416220f,
|
||||
0.284255342818460f, 0.283581500220700f, 0.282907657622940f, 0.282233815025180f,
|
||||
0.281559972427420f, 0.280886129829659f, 0.280212287231899f, 0.279538444634139f,
|
||||
0.278864602036378f, 0.278190759438618f, 0.277516916840857f, 0.276843074243096f,
|
||||
0.276169231645336f, 0.275495389047575f, 0.274821546449814f, 0.274147703852052f,
|
||||
0.273473861254291f, 0.272800018656529f, 0.272126176058768f, 0.271452333461006f,
|
||||
0.270778490863244f, 0.270104648265482f, 0.269430805667719f, 0.268756963069956f,
|
||||
0.268083120472194f, 0.267409277874430f, 0.266735435276667f, 0.266061592678904f,
|
||||
0.265387750081140f, 0.264713907483376f, 0.264040064885612f, 0.263366222287848f,
|
||||
0.262692379690083f, 0.262018537092318f, 0.261344694494552f, 0.260670851896785f,
|
||||
0.259997009299017f, 0.259323166701247f, 0.258649324103476f, 0.257975481505702f,
|
||||
0.257301638907927f, 0.256627796310149f, 0.255953953712369f, 0.255280111114586f,
|
||||
0.254606268516799f, 0.253932425919010f, 0.253258583321217f, 0.252584740723420f,
|
||||
0.251910898125620f, 0.251237055527815f, 0.250563212930007f, 0.249889370332193f,
|
||||
0.249215527734375f, 0.248541685136552f, 0.247867842538723f, 0.247193999940890f,
|
||||
0.246520157343050f, 0.245846314745205f, 0.245172472147353f, 0.244498629549496f,
|
||||
0.243824786951632f, 0.243150944353761f, 0.242477101755883f, 0.241803259157998f,
|
||||
0.241129416560105f, 0.240455573962205f, 0.239781731364297f, 0.239107888766381f,
|
||||
0.238434046168457f, 0.237760203570524f, 0.237086360972583f, 0.236412518374633f,
|
||||
0.235738675776673f, 0.235064833178704f, 0.234390990580726f, 0.233717147982738f,
|
||||
0.233043305384739f, 0.232369462786731f, 0.231695620188712f, 0.231021777590682f,
|
||||
0.230347934992642f, 0.229674092394590f, 0.229000249796527f, 0.228326407198452f,
|
||||
0.227652564600366f, 0.226978722002268f, 0.226304879404157f, 0.225631036806034f,
|
||||
0.224957194207899f, 0.224283351609750f, 0.223609509011589f, 0.222935666413414f,
|
||||
0.222261823815225f, 0.221587981217023f};
|
||||
|
||||
const FLOAT32 iusace_acelp_quant_gain_table[NUM_QUANTIZATION_LEVEL * 2] = {
|
||||
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 FLOAT32 iusace_interp4_1[17] = {0.900000F, 0.818959F, 0.604850F, 0.331379F, 0.083958F,
|
||||
-0.075795F, -0.130717F, -0.105685F, -0.046774F, 0.004467F,
|
||||
0.027789F, 0.025642F, 0.012571F, 0.001927F, -0.001571F,
|
||||
-0.000753F, 0.000000f};
|
||||
1082
encoder/iusace_acelp_tools.c
Normal file
1082
encoder/iusace_acelp_tools.c
Normal file
File diff suppressed because it is too large
Load diff
433
encoder/iusace_arith_enc.c
Normal file
433
encoder/iusace_arith_enc.c
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
#define ARITH_ESCAPE (16)
|
||||
|
||||
static VOID iusace_arith_map_context(WORD32 pres_n, WORD32 prev_n, WORD32 *ptr_c_prev,
|
||||
WORD32 *ptr_c_pres, WORD32 arith_reset_flag) {
|
||||
WORD32 i, k;
|
||||
FLOAT32 ratio;
|
||||
WORD32 c_prev[516];
|
||||
WORD32 c_pres[516];
|
||||
|
||||
if (arith_reset_flag) {
|
||||
memset(ptr_c_pres, 0, 516 * sizeof(WORD32));
|
||||
memset(ptr_c_prev, 0, 516 * sizeof(WORD32));
|
||||
} else {
|
||||
memcpy(&c_prev[2], &ptr_c_prev[2], (prev_n / 2 + 2) * sizeof(WORD32));
|
||||
memcpy(&c_pres[2], &ptr_c_pres[2], (prev_n / 2 + 2) * sizeof(WORD32));
|
||||
|
||||
ratio = (FLOAT32)(prev_n) / (FLOAT32)(pres_n);
|
||||
for (i = 0; i < (pres_n / 2); i++) {
|
||||
k = (WORD32)((FLOAT32)(i)*ratio);
|
||||
ptr_c_pres[2 + i] = c_pres[2 + k];
|
||||
ptr_c_prev[2 + i] = c_prev[2 + k];
|
||||
}
|
||||
|
||||
ptr_c_pres[(pres_n / 2) + 2] = c_pres[(prev_n / 2) + 2];
|
||||
ptr_c_pres[(pres_n / 2) + 3] = c_pres[(prev_n / 2) + 3];
|
||||
ptr_c_prev[(pres_n / 2) + 2] = c_prev[(prev_n / 2) + 2];
|
||||
ptr_c_prev[(pres_n / 2) + 3] = c_prev[(prev_n / 2) + 3];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static WORD32 iusace_arith_get_state(WORD32 *c_pres, WORD32 *c_prev, WORD32 *s, WORD32 idx) {
|
||||
WORD32 s_tmp = *s;
|
||||
|
||||
s_tmp = s_tmp >> 4;
|
||||
s_tmp = s_tmp + (c_prev[idx + 1] << 12);
|
||||
s_tmp = (s_tmp & 0xFFF0) + c_pres[idx - 1];
|
||||
|
||||
*s = s_tmp;
|
||||
|
||||
if (idx > 3) {
|
||||
if ((c_pres[idx - 1] + c_pres[idx - 2] + c_pres[idx - 3]) < 5) {
|
||||
return (s_tmp + 0x10000);
|
||||
}
|
||||
}
|
||||
|
||||
return (s_tmp);
|
||||
}
|
||||
|
||||
static UWORD16 iusace_arith_get_pk(WORD32 c) {
|
||||
WORD32 j;
|
||||
WORD32 i, i_min, i_max;
|
||||
|
||||
i_min = -1;
|
||||
i_max = (sizeof(iusace_ari_lookup_m) / sizeof(iusace_ari_lookup_m[0])) - 1;
|
||||
while ((i_max - i_min) > 1) {
|
||||
i = i_min + ((i_max - i_min) / 2);
|
||||
j = iusace_ari_hash_m[i];
|
||||
if (c < j)
|
||||
i_max = i;
|
||||
else if (c > j)
|
||||
i_min = i;
|
||||
else
|
||||
return (iusace_ari_hash_m_lsb[i]);
|
||||
}
|
||||
|
||||
return (iusace_ari_lookup_m[i_max]);
|
||||
}
|
||||
|
||||
static VOID iusace_copy_bit_buf(ia_bit_buf_struct *it_bit_buff_dest,
|
||||
ia_bit_buf_struct *it_bit_buff_src) {
|
||||
if (it_bit_buff_src != NULL && it_bit_buff_dest != NULL) {
|
||||
it_bit_buff_dest->cnt_bits = it_bit_buff_src->cnt_bits;
|
||||
it_bit_buff_dest->ptr_write_next = it_bit_buff_src->ptr_write_next;
|
||||
it_bit_buff_dest->write_position = it_bit_buff_src->write_position;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static WORD32 iusace_arith_encode_level2(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 bp,
|
||||
WORD32 *ptr_c_pres, WORD32 *ptr_c_prev, WORD32 *quant,
|
||||
WORD32 n, WORD32 nt, WORD32 use_stop) {
|
||||
WORD32 qs[32];
|
||||
iusace_state_arith as, as_stop;
|
||||
|
||||
WORD32 a, b, a1, b1, m;
|
||||
WORD32 s, t, i, l, lev, esc_nb;
|
||||
UWORD16 pki;
|
||||
WORD32 bp_start = bp;
|
||||
WORD32 bp_stop = bp;
|
||||
WORD32 stop = 0;
|
||||
WORD32 sopt;
|
||||
WORD32 a2, b2;
|
||||
ia_bit_buf_struct it_bit_buff_temp;
|
||||
memset(&it_bit_buff_temp, 0, sizeof(it_bit_buff_temp));
|
||||
iusace_copy_bit_buf(&it_bit_buff_temp, pstr_it_bit_buff);
|
||||
|
||||
as.low = 0;
|
||||
as.high = 65535;
|
||||
as.value = 0;
|
||||
|
||||
sopt = ptr_c_prev[0] << 12;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if ((use_stop == 1 || use_stop == 2) && (stop == 0)) {
|
||||
WORD32 j;
|
||||
|
||||
stop = 1;
|
||||
for (j = i; j < n; j++) {
|
||||
if (quant[2 * j] != 0 || quant[2 * j + 1] != 0) {
|
||||
stop = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stop) {
|
||||
s = iusace_arith_get_state(ptr_c_pres, ptr_c_prev, &sopt, i);
|
||||
t = s & 0xFFFFF;
|
||||
|
||||
pki = iusace_arith_get_pk(t);
|
||||
|
||||
if (use_stop == 1) {
|
||||
bp = iusace_arith_encode(pstr_it_bit_buff, bp, &as, ARITH_ESCAPE, iusace_ari_cf_m[pki]);
|
||||
pki = iusace_arith_get_pk(t + (1 << 17));
|
||||
bp = iusace_arith_encode(pstr_it_bit_buff, bp, &as, 0, iusace_ari_cf_m[pki]);
|
||||
|
||||
break;
|
||||
} else {
|
||||
bp_stop = bp;
|
||||
as_stop.low = as.low;
|
||||
as_stop.high = as.high;
|
||||
as_stop.value = as.value;
|
||||
|
||||
bp_stop =
|
||||
iusace_arith_encode(NULL, bp_stop, &as_stop, ARITH_ESCAPE, iusace_ari_cf_m[pki]);
|
||||
|
||||
pki = iusace_arith_get_pk(t + (1 << 17));
|
||||
bp_stop = iusace_arith_encode(NULL, bp_stop, &as_stop, (0), iusace_ari_cf_m[pki]);
|
||||
}
|
||||
}
|
||||
}
|
||||
s = iusace_arith_get_state(ptr_c_pres, ptr_c_prev, &sopt, i);
|
||||
t = s & 0xFFFFF;
|
||||
|
||||
a = quant[2 * i];
|
||||
b = quant[2 * i + 1];
|
||||
a1 = abs(a);
|
||||
b1 = abs(b);
|
||||
|
||||
ptr_c_pres[i] = a1 + b1 + 1;
|
||||
if (ptr_c_pres[i] > 0xF) {
|
||||
ptr_c_pres[i] = 0xF;
|
||||
}
|
||||
|
||||
lev = 0;
|
||||
esc_nb = 0;
|
||||
|
||||
while ((a1) > 3 || (b1) > 3) {
|
||||
pki = iusace_arith_get_pk(t + (esc_nb << 17));
|
||||
|
||||
bp = iusace_arith_encode(pstr_it_bit_buff, bp, &as, ARITH_ESCAPE, iusace_ari_cf_m[pki]);
|
||||
|
||||
qs[lev++] = (a1 & 1) | ((b1 & 1) << 1);
|
||||
a1 >>= 1;
|
||||
b1 >>= 1;
|
||||
esc_nb++;
|
||||
|
||||
if (esc_nb > 7) {
|
||||
esc_nb = 7;
|
||||
}
|
||||
}
|
||||
m = a1 + (b1 << 2);
|
||||
pki = iusace_arith_get_pk(t + (esc_nb << 17));
|
||||
bp = iusace_arith_encode(pstr_it_bit_buff, bp, &as, m, iusace_ari_cf_m[pki]);
|
||||
|
||||
a2 = a1;
|
||||
b2 = b1;
|
||||
|
||||
for (l = lev - 1; l >= 0; l--) {
|
||||
WORD32 lsbidx = (a2 == 0) ? 1 : ((b2 == 0) ? 0 : 2);
|
||||
bp = iusace_arith_encode(pstr_it_bit_buff, bp, &as, qs[l], iusace_ari_cf_r[lsbidx]);
|
||||
|
||||
a2 = (a2 << 1) | (qs[l] & 1);
|
||||
b2 = (b2 << 1) | ((qs[l] >> 1) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (use_stop == 2) {
|
||||
bp = iusace_arith_done(pstr_it_bit_buff, bp, &as);
|
||||
if (stop) {
|
||||
bp_stop = iusace_arith_done(NULL, bp_stop, &as_stop);
|
||||
|
||||
if (bp_stop < bp) {
|
||||
iusace_copy_bit_buf(pstr_it_bit_buff, &it_bit_buff_temp);
|
||||
bp = iusace_arith_encode_level2(pstr_it_bit_buff, bp_start, ptr_c_pres, ptr_c_prev, quant,
|
||||
n, nt, 1);
|
||||
} else {
|
||||
iusace_copy_bit_buf(pstr_it_bit_buff, &it_bit_buff_temp);
|
||||
bp = iusace_arith_encode_level2(pstr_it_bit_buff, bp_start, ptr_c_pres, ptr_c_prev, quant,
|
||||
n, nt, 0);
|
||||
}
|
||||
} else {
|
||||
iusace_copy_bit_buf(pstr_it_bit_buff, &it_bit_buff_temp);
|
||||
bp = iusace_arith_encode_level2(pstr_it_bit_buff, bp_start, ptr_c_pres, ptr_c_prev, quant,
|
||||
n, nt, 0);
|
||||
}
|
||||
} else {
|
||||
bp = iusace_arith_done(pstr_it_bit_buff, bp, &as);
|
||||
|
||||
for (; i < nt; i++) {
|
||||
ptr_c_pres[i] = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (quant[2 * i] != 0) {
|
||||
if (quant[2 * i] > 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
} else {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
|
||||
if (quant[2 * i + 1] != 0) {
|
||||
if (quant[2 * i + 1] > 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
} else {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nt; i++) {
|
||||
ptr_c_prev[i] = ptr_c_pres[i];
|
||||
ptr_c_pres[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
WORD32 iusace_arith_enc_spec(ia_bit_buf_struct *it_bit_buf, WORD32 window_sequence,
|
||||
WORD32 *ptr_x_ac_enc, WORD32 max_spec_coefficients,
|
||||
WORD32 *ptr_c_pres, WORD32 *ptr_c_prev, WORD32 *ptr_size_prev,
|
||||
WORD32 arith_reset_flag, WORD32 ccfl) {
|
||||
LOOPIDX i;
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 size;
|
||||
WORD32 num_wins = (window_sequence == EIGHT_SHORT_SEQUENCE) ? MAX_SHORT_WINDOWS : 1;
|
||||
WORD32 bits_data_written = 0;
|
||||
|
||||
switch (window_sequence) {
|
||||
case ONLY_LONG_SEQUENCE:
|
||||
case LONG_START_SEQUENCE:
|
||||
case STOP_START_SEQUENCE:
|
||||
case LONG_STOP_SEQUENCE:
|
||||
size = ccfl;
|
||||
break;
|
||||
case EIGHT_SHORT_SEQUENCE:
|
||||
size = ccfl >> 3;
|
||||
break;
|
||||
default:
|
||||
size = ccfl >> 3;
|
||||
break;
|
||||
}
|
||||
|
||||
iusace_arith_map_context(size, *ptr_size_prev, ptr_c_pres, ptr_c_prev, arith_reset_flag);
|
||||
|
||||
if (max_spec_coefficients > 0) {
|
||||
for (i = 0; i < num_wins; i++) {
|
||||
bits_data_written = iusace_arith_encode_level2(
|
||||
it_bit_buf, bits_data_written, ptr_c_pres + 2, ptr_c_prev + 2, &ptr_x_ac_enc[i * size],
|
||||
max_spec_coefficients / 2, size / 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (write_flag) {
|
||||
*ptr_size_prev = size;
|
||||
}
|
||||
|
||||
return bits_data_written;
|
||||
}
|
||||
|
||||
WORD32 iusace_tcx_coding(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 tcx_size,
|
||||
WORD32 max_tcx_size, WORD32 *ptr_quant, WORD32 *c_pres, WORD32 *c_prev) {
|
||||
WORD32 bits_written = 0;
|
||||
|
||||
iusace_arith_map_context(tcx_size, max_tcx_size, c_pres, c_prev, 0);
|
||||
|
||||
bits_written =
|
||||
iusace_arith_encode_level2(pstr_it_bit_buff, bits_written, c_pres + 2, c_prev + 2,
|
||||
&ptr_quant[0], tcx_size / 2, tcx_size / 2, 2);
|
||||
|
||||
iusace_arith_map_context(max_tcx_size, tcx_size, c_pres, c_prev, 0);
|
||||
|
||||
return bits_written;
|
||||
}
|
||||
|
||||
WORD32 iusace_arith_done(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 bp, iusace_state_arith *s) {
|
||||
WORD32 low, high;
|
||||
WORD32 bits_to_follow;
|
||||
|
||||
low = s->low;
|
||||
high = s->high;
|
||||
bits_to_follow = s->value + 1;
|
||||
|
||||
if (low < 16384) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
while (bits_to_follow) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
bits_to_follow--;
|
||||
}
|
||||
} else {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
while (bits_to_follow) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
bits_to_follow--;
|
||||
}
|
||||
}
|
||||
|
||||
s->low = low;
|
||||
s->high = high;
|
||||
s->value = bits_to_follow;
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
WORD32 iusace_arith_encode(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 bp, iusace_state_arith *s,
|
||||
WORD32 symbol, UWORD16 const *cum_freq) {
|
||||
WORD32 low, high, range;
|
||||
WORD32 bits_to_follow;
|
||||
|
||||
high = s->high;
|
||||
low = s->low;
|
||||
range = high - low + 1;
|
||||
|
||||
if (symbol > 0) {
|
||||
high = low + ((range * cum_freq[symbol - 1]) >> 14) - 1;
|
||||
}
|
||||
|
||||
low = low + ((range * cum_freq[symbol]) >> 14);
|
||||
|
||||
bits_to_follow = s->value;
|
||||
|
||||
for (;;) {
|
||||
if (high < 32768) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
while (bits_to_follow) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
bits_to_follow--;
|
||||
}
|
||||
} else if (low >= 32768) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
bp++;
|
||||
while (bits_to_follow) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
bp++;
|
||||
bits_to_follow--;
|
||||
}
|
||||
low -= 32768;
|
||||
high -= 32768;
|
||||
} else if (low >= 16384 && high < 49152) {
|
||||
bits_to_follow += 1;
|
||||
low -= 16384;
|
||||
high -= 16384;
|
||||
} else
|
||||
break;
|
||||
|
||||
low += low;
|
||||
high += high + 1;
|
||||
}
|
||||
|
||||
s->low = low;
|
||||
s->high = high;
|
||||
s->value = bits_to_follow;
|
||||
|
||||
return bp;
|
||||
}
|
||||
47
encoder/iusace_arith_enc.h
Normal file
47
encoder/iusace_arith_enc.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
WORD32 low;
|
||||
WORD32 high;
|
||||
WORD32 value;
|
||||
} iusace_state_arith;
|
||||
|
||||
WORD32 iusace_arith_enc_spec(ia_bit_buf_struct *it_bit_buf, WORD32 window_sequence,
|
||||
WORD32 *ptr_x_ac_enc, WORD32 max_spec_coefficients,
|
||||
WORD32 *ptr_c_pres, WORD32 *ptr_c_prev, WORD32 *ptr_size_prev,
|
||||
WORD32 arith_reset_flag, WORD32 ccfl);
|
||||
|
||||
WORD32 iusace_tcx_coding(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 tcx_size,
|
||||
WORD32 max_tcx_size, WORD32 *ptr_quant, WORD32 *c_pres, WORD32 *c_prev);
|
||||
|
||||
WORD32 iusace_arith_done(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 bp, iusace_state_arith *s);
|
||||
|
||||
WORD32 iusace_arith_encode(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 bp, iusace_state_arith *s,
|
||||
WORD32 symbol, UWORD16 const *cum_freq);
|
||||
343
encoder/iusace_avq_enc.c
Normal file
343
encoder/iusace_avq_enc.c
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_avq_enc.h"
|
||||
|
||||
static VOID iusace_gosset_compute_rank_and_sign(WORD32 *x, WORD32 *rank, WORD32 *sign_code) {
|
||||
WORD32 xs[8], a[8], q, d[8], w[8], A, B, idx, tmp, abs_i, abs_j;
|
||||
WORD32 i, j, k;
|
||||
for (i = 0; i < 8; i++) {
|
||||
xs[i] = x[i];
|
||||
}
|
||||
for (k = 0; k < 7; k++) {
|
||||
j = k;
|
||||
for (i = k + 1; i < 8; i++) {
|
||||
abs_j = abs(xs[j]);
|
||||
abs_i = abs(xs[i]);
|
||||
if (abs_i >= abs_j) {
|
||||
if (abs_i > xs[j]) {
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j > k) {
|
||||
tmp = xs[k];
|
||||
xs[k] = xs[j];
|
||||
xs[j] = tmp;
|
||||
}
|
||||
}
|
||||
*sign_code = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (xs[i] < 0) {
|
||||
*sign_code += iusace_pow2_table[i];
|
||||
}
|
||||
}
|
||||
a[0] = xs[0];
|
||||
q = 1;
|
||||
for (i = 1; i < 8; i++) {
|
||||
if (xs[i] != xs[i - 1]) {
|
||||
a[q] = xs[i];
|
||||
q++;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (j = 0; j < q; j++) {
|
||||
if (x[i] == a[j]) {
|
||||
d[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*rank = 0;
|
||||
for (j = 0; j < q; j++) {
|
||||
w[j] = 0;
|
||||
}
|
||||
B = 1;
|
||||
for (i = 7; i >= 0; i--) {
|
||||
idx = d[i];
|
||||
w[idx]++;
|
||||
B *= w[idx];
|
||||
A = 0;
|
||||
for (j = 0; j < idx; j++) {
|
||||
A += w[j];
|
||||
}
|
||||
if (A > 0) {
|
||||
*rank += A * iusace_factorial_table[i] / B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_gosset_compute_base_idx(WORD32 *x, WORD32 ka, WORD32 *idx) {
|
||||
WORD32 rank, offset, code, i, ks;
|
||||
iusace_gosset_compute_rank_and_sign(x, &rank, &code);
|
||||
ks = -1;
|
||||
for (i = iusace_iso_code_index_table[ka]; i < LEN_SIGN_LEADER; i++) {
|
||||
if (code == iusace_iso_code_data_table[i]) {
|
||||
ks = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ks == -1) {
|
||||
ks = 0;
|
||||
}
|
||||
offset = iusace_signed_leader_is[ks];
|
||||
*idx = offset + rank;
|
||||
return;
|
||||
}
|
||||
|
||||
static WORD32 iusace_find_absolute_leader(WORD32 *y) {
|
||||
WORD32 i, s, C[8], nb, pos, ka;
|
||||
long id;
|
||||
for (i = 0; i < 8; i++) {
|
||||
C[i] = y[i] * y[i];
|
||||
}
|
||||
s = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
s += C[i];
|
||||
}
|
||||
s >>= 3;
|
||||
ka = LEN_ABS_LEADER + 1;
|
||||
if (s == 0) {
|
||||
ka = LEN_ABS_LEADER;
|
||||
} else {
|
||||
if (s <= NB_SPHERE) {
|
||||
id = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
id += C[i] * C[i];
|
||||
}
|
||||
id = id >> 3;
|
||||
nb = iusace_da_num_bits[s - 1];
|
||||
pos = iusace_da_pos[s - 1];
|
||||
for (i = 0; i < nb; i++) {
|
||||
if (id == (long)iusace_da_id[pos]) {
|
||||
ka = pos;
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ka);
|
||||
}
|
||||
|
||||
static VOID iusace_nearest_neighbor_2d(FLOAT32 *x, WORD32 *y) {
|
||||
WORD32 i, j;
|
||||
WORD64 sum;
|
||||
FLOAT32 diff[8], em;
|
||||
sum = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (x[i] < 0) {
|
||||
y[i] = -2 * (((WORD32)(1.0 - x[i])) >> 1);
|
||||
} else {
|
||||
y[i] = 2 * (((WORD32)(1.0 + x[i])) >> 1);
|
||||
}
|
||||
sum += y[i];
|
||||
}
|
||||
if (sum % 4) {
|
||||
FLOAT32 s;
|
||||
em = 0;
|
||||
j = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
diff[i] = x[i] - y[i];
|
||||
s = (FLOAT32)fabs(diff[i]);
|
||||
if (em < s) {
|
||||
em = s;
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
if (diff[j] < 0) {
|
||||
y[j] -= 2;
|
||||
} else {
|
||||
y[j] += 2;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_find_nearest_neighbor(FLOAT32 *bk, WORD32 *ck) {
|
||||
WORD32 i, y1[8], y2[8];
|
||||
FLOAT32 e1k, e2k, x1[8], tmp;
|
||||
|
||||
iusace_nearest_neighbor_2d(bk, y1);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
x1[i] = bk[i] - 1.0f;
|
||||
}
|
||||
iusace_nearest_neighbor_2d(x1, y2);
|
||||
for (i = 0; i < 8; i++) {
|
||||
y2[i] += 1;
|
||||
}
|
||||
/* Compute e1k = (Bk - y1k)^2 and e2k = (Bk – y2k)^2 */
|
||||
e1k = e2k = 0.0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
tmp = bk[i] - y1[i];
|
||||
e1k += tmp * tmp;
|
||||
tmp = bk[i] - y2[i];
|
||||
e2k += tmp * tmp;
|
||||
}
|
||||
|
||||
/* Select best lattice point */
|
||||
if (e1k < e2k) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
ck[i] = y1[i];
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 8; i++) {
|
||||
ck[i] = y2[i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_vononoi_idx(WORD32 *kv, WORD32 m, WORD32 *y) {
|
||||
WORD32 i, v[8], tmp, sum, *ptr1, *ptr2;
|
||||
FLOAT32 z[8];
|
||||
for (i = 0; i < 8; i++) {
|
||||
y[i] = kv[7];
|
||||
}
|
||||
z[7] = (FLOAT32)y[7] / m;
|
||||
sum = 0;
|
||||
for (i = 6; i >= 1; i--) {
|
||||
tmp = kv[i] << 1;
|
||||
sum += tmp;
|
||||
y[i] += tmp;
|
||||
z[i] = (FLOAT32)y[i] / m;
|
||||
}
|
||||
y[0] += (4 * kv[0] + sum);
|
||||
z[0] = (FLOAT32)(y[0] - 2) / m;
|
||||
iusace_find_nearest_neighbor(z, v);
|
||||
ptr1 = y;
|
||||
ptr2 = v;
|
||||
for (i = 0; i < 8; i++) {
|
||||
*ptr1++ -= m * *ptr2++;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_compute_coord(WORD32 *y, WORD32 *k) {
|
||||
WORD32 i, tmp, sum;
|
||||
k[7] = y[7];
|
||||
tmp = y[7];
|
||||
sum = 5 * y[7];
|
||||
for (i = 6; i >= 1; i--) {
|
||||
k[i] = (y[i] - tmp) >> 1;
|
||||
sum -= y[i];
|
||||
}
|
||||
k[0] = (y[0] + sum) >> 2;
|
||||
}
|
||||
|
||||
VOID iusace_apply_voronoi_ext(WORD32 *x, WORD32 *n, WORD32 *idx, WORD32 *k) {
|
||||
WORD32 ka, c[8];
|
||||
WORD32 i, r, m, v[8], c_tmp[8], k_mod[8], k_tmp[8], iter, ka_tmp, n_tmp, mask;
|
||||
FLOAT32 sphere;
|
||||
ka = iusace_find_absolute_leader(x);
|
||||
*n = iusace_da_nq[ka];
|
||||
if (*n <= 4) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
c[i] = x[i];
|
||||
}
|
||||
} else {
|
||||
sphere = 0.0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
sphere += (FLOAT32)x[i] * (FLOAT32)x[i];
|
||||
}
|
||||
sphere *= 0.125;
|
||||
r = 1;
|
||||
sphere *= 0.25;
|
||||
while (sphere > 11.0) {
|
||||
r++;
|
||||
sphere *= 0.25;
|
||||
}
|
||||
iusace_compute_coord(x, k_mod);
|
||||
m = 1 << r;
|
||||
mask = m - 1;
|
||||
for (iter = 0; iter < 2; iter++) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
k_tmp[i] = k_mod[i] & mask;
|
||||
}
|
||||
iusace_vononoi_idx(k_tmp, m, v);
|
||||
for (i = 0; i < 8; i++) {
|
||||
c_tmp[i] = (x[i] - v[i]) / m;
|
||||
}
|
||||
ka_tmp = iusace_find_absolute_leader(c_tmp);
|
||||
n_tmp = iusace_da_nq[ka_tmp];
|
||||
if (n_tmp > 4) {
|
||||
r++;
|
||||
m = m << 1;
|
||||
mask = ((mask << 1) + 1);
|
||||
} else {
|
||||
if (n_tmp < 3) {
|
||||
n_tmp = 3;
|
||||
}
|
||||
ka = ka_tmp;
|
||||
*n = n_tmp + 2 * r;
|
||||
for (i = 0; i < 8; i++) {
|
||||
k[i] = k_tmp[i];
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
c[i] = c_tmp[i];
|
||||
}
|
||||
r--;
|
||||
m = m >> 1;
|
||||
mask = mask >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*n > 0) {
|
||||
iusace_gosset_compute_base_idx(c, ka, idx);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_alg_vec_quant(FLOAT32 *ptr_input, WORD32 *ptr_out, WORD32 *ptr_lpc_idx) {
|
||||
WORD32 i, l, nq, pos, c[8], kv[8];
|
||||
FLOAT32 x1[8];
|
||||
WORD32 lpc_index;
|
||||
|
||||
pos = 2;
|
||||
for (l = 0; l < 2; l++) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
x1[i] = ptr_input[l * 8 + i];
|
||||
kv[i] = 0;
|
||||
}
|
||||
|
||||
iusace_find_nearest_neighbor(x1, c);
|
||||
|
||||
iusace_apply_voronoi_ext(c, &nq, &lpc_index, kv);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
ptr_out[l * 8 + i] = c[i];
|
||||
}
|
||||
|
||||
ptr_lpc_idx[l] = nq;
|
||||
|
||||
if (nq > 0) {
|
||||
ptr_lpc_idx[pos++] = lpc_index;
|
||||
for (i = 0; i < 8; i++) {
|
||||
ptr_lpc_idx[pos++] = kv[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
38
encoder/iusace_avq_enc.h
Normal file
38
encoder/iusace_avq_enc.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define NB_SPHERE 32
|
||||
#define LEN_ABS_LEADER 37
|
||||
#define LEN_SIGN_LEADER 226
|
||||
|
||||
VOID iusace_find_nearest_neighbor(FLOAT32 *bk, WORD32 *ck);
|
||||
VOID iusace_apply_voronoi_ext(WORD32 *x, WORD32 *n, WORD32 *idx, WORD32 *k);
|
||||
VOID iusace_alg_vec_quant(FLOAT32 *ptr_input, WORD32 *ptr_out, WORD32 *ptr_lpc_idx);
|
||||
|
||||
extern const WORD32 iusace_pow2_table[8];
|
||||
extern const WORD32 iusace_factorial_table[8];
|
||||
extern const WORD32 iusace_iso_code_index_table[LEN_ABS_LEADER];
|
||||
extern const UWORD8 iusace_iso_code_data_table[LEN_SIGN_LEADER];
|
||||
extern const UWORD32 iusace_signed_leader_is[LEN_SIGN_LEADER];
|
||||
extern const WORD32 iusace_da_nq[], iusace_da_pos[], iusace_da_num_bits[];
|
||||
extern const UWORD32 iusace_da_id[];
|
||||
extern const FLOAT32 iusace_wlsf_factor_table[4];
|
||||
extern const FLOAT32 iusace_dico_lsf_abs_8b_flt[16 * 256];
|
||||
674
encoder/iusace_avq_rom.c
Normal file
674
encoder/iusace_avq_rom.c
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
|
||||
#define NB_SPHERE 32
|
||||
#define LEN_ABS_LEADER 37
|
||||
#define LEN_SIGN_LEADER 226
|
||||
|
||||
const WORD32 iusace_pow2_table[8] = {128, 64, 32, 16, 8, 4, 2, 1};
|
||||
|
||||
const WORD32 iusace_factorial_table[8] = {5040, 720, 120, 24, 6, 2, 1, 1};
|
||||
|
||||
const WORD32 iusace_da_pos[NB_SPHERE] = {0, 2, 5, 8, 13, 18, 20, 22, 23, 25, 26,
|
||||
27, 27, 28, 28, 28, 29, 30, 31, 31, 32, 32,
|
||||
32, 32, 32, 34, 35, 35, 35, 35, 35, 35};
|
||||
|
||||
const WORD32 iusace_da_num_bits[NB_SPHERE] = {2, 3, 3, 5, 5, 2, 2, 1, 2, 1, 1, 0, 1, 0, 0, 1,
|
||||
1, 1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1};
|
||||
|
||||
const WORD32 iusace_da_nq[LEN_ABS_LEADER + 2] = {2, 2, 3, 3, 2, 4, 4, 3, 4, 4, 4, 3, 4,
|
||||
4, 4, 4, 4, 3, 4, 4, 4, 4, 3, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 100};
|
||||
|
||||
const UWORD32 iusace_da_id[LEN_ABS_LEADER] = {
|
||||
0x0001, 0x0004, 0x0008, 0x000B, 0x0020, 0x000C, 0x0015, 0x0024, 0x0010, 0x001F,
|
||||
0x0028, 0x0040, 0x004F, 0x0029, 0x002C, 0x0044, 0x0059, 0x00A4, 0x0060, 0x00A8,
|
||||
0x00C4, 0x012D, 0x0200, 0x0144, 0x0204, 0x0220, 0x0335, 0x04E4, 0x0400, 0x0584,
|
||||
0x0A20, 0x0A40, 0x09C4, 0x12C4, 0x0C20, 0x2000, 0x4E20};
|
||||
|
||||
const UWORD8 iusace_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 iusace_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 iusace_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 FLOAT32 iusace_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 FLOAT32 iusace_wlsf_factor_table[4] = {60.0f, 65.0f, 64.0f, 63.0f};
|
||||
282
encoder/iusace_block_switch.c
Normal file
282
encoder/iusace_block_switch.c
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "iusace_type_def.h"
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
static FLOAT32 iusace_fmult(FLOAT32 a, FLOAT32 b) { return (a * b); }
|
||||
|
||||
static FLOAT32 iusace_fadd(FLOAT32 a, FLOAT32 b) { return (a + b); }
|
||||
|
||||
VOID iusace_init_block_switching(ia_block_switch_ctrl *pstr_blk_switch_ctrl,
|
||||
const WORD32 bit_rate, const WORD32 num_chans) {
|
||||
WORD32 i, w;
|
||||
|
||||
if ((num_chans == 1 && bit_rate > 24000) || (num_chans > 1 && bit_rate / num_chans > 16000)) {
|
||||
pstr_blk_switch_ctrl->inv_attack_ratio = INV_ATTACK_RATIO_HIGH_BR;
|
||||
} else {
|
||||
pstr_blk_switch_ctrl->inv_attack_ratio = INV_ATTACK_RATIO_LOW_BR;
|
||||
}
|
||||
|
||||
for (i = 0; i < BLK_SWITCH_FILT_LEN; i++) {
|
||||
pstr_blk_switch_ctrl->iir_states[i] = 0;
|
||||
}
|
||||
|
||||
/* Clear Filtered Window Energies */
|
||||
for (w = 0; w < MAX_SHORT_WINDOWS; w++) {
|
||||
pstr_blk_switch_ctrl->win_energy_filt[0][w] = 0;
|
||||
pstr_blk_switch_ctrl->win_energy_filt[1][w] = 0;
|
||||
pstr_blk_switch_ctrl->win_energy[0][w] = 0;
|
||||
pstr_blk_switch_ctrl->win_energy[1][w] = 0;
|
||||
}
|
||||
pstr_blk_switch_ctrl->acc_win_energy = 0;
|
||||
|
||||
pstr_blk_switch_ctrl->window_seq = ONLY_LONG_SEQUENCE;
|
||||
pstr_blk_switch_ctrl->next_win_seq = ONLY_LONG_SEQUENCE;
|
||||
|
||||
pstr_blk_switch_ctrl->attack = 0;
|
||||
pstr_blk_switch_ctrl->lastattack = 0;
|
||||
pstr_blk_switch_ctrl->attack_idx = 0;
|
||||
pstr_blk_switch_ctrl->last_attack_idx = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static FLOAT32 iusace_srch_max_with_idx(const FLOAT32 *ptr_in, WORD32 *index) {
|
||||
FLOAT32 max;
|
||||
WORD32 i, idx;
|
||||
|
||||
max = 0;
|
||||
idx = 0;
|
||||
|
||||
for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
|
||||
if (ptr_in[i + 1] > max) {
|
||||
max = ptr_in[i + 1];
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
*index = idx;
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
static VOID iusace_blk_switch_iir_filt(const FLOAT32 *ptr_in, const FLOAT32 *ptr_iir_coeff,
|
||||
const WORD32 w, FLOAT32 *ptr_iir_states,
|
||||
FLOAT32 *energy_accu, WORD32 block_len) {
|
||||
FLOAT32 accu1;
|
||||
|
||||
WORD32 i;
|
||||
|
||||
FLOAT32 accu_unfilt = 0.0f;
|
||||
FLOAT32 accu_filt = 0.0f;
|
||||
FLOAT32 accu2, temp2, temp1;
|
||||
|
||||
FLOAT32 state0 = ptr_iir_states[0];
|
||||
FLOAT32 state1 = ptr_iir_states[1];
|
||||
|
||||
FLOAT32 coeff0 = ptr_iir_coeff[0];
|
||||
FLOAT32 coeff1 = ptr_iir_coeff[1];
|
||||
|
||||
const FLOAT32 *p_time_signal = &ptr_in[(block_len * w)];
|
||||
|
||||
for (i = 0; i < block_len; i++) {
|
||||
accu2 = iusace_fmult(state0, coeff1);
|
||||
accu1 = iusace_fmult(state1, coeff0);
|
||||
accu1 += accu2;
|
||||
|
||||
state0 = p_time_signal[i];
|
||||
state1 = iusace_fmult(state0, coeff1);
|
||||
state1 = (state1 - accu1);
|
||||
|
||||
temp1 = iusace_fmult(state0, state0);
|
||||
temp2 = iusace_fmult(state1, state1);
|
||||
|
||||
accu_unfilt = iusace_fadd(accu_unfilt, temp1);
|
||||
accu_filt = iusace_fadd(accu_filt, temp2);
|
||||
}
|
||||
|
||||
energy_accu[0] = accu_unfilt;
|
||||
energy_accu[1] = accu_filt;
|
||||
|
||||
ptr_iir_states[0] = state0;
|
||||
ptr_iir_states[1] = state1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_calc_window_energy(ia_block_switch_ctrl *ptr_blk_switch_ctrl,
|
||||
const FLOAT32 *ptr_in, FLOAT32 *max, WORD32 ccfl) {
|
||||
WORD32 w;
|
||||
|
||||
FLOAT32 energy_accu[2];
|
||||
*max = 0.0f;
|
||||
|
||||
for (w = 0; w < MAX_SHORT_WINDOWS; w++) {
|
||||
// block length for calculating energy is corecoder frame length / MAX_SHORT_WINDOWS
|
||||
iusace_blk_switch_iir_filt(ptr_in, iusace_iir_hipass_coeffs, w,
|
||||
ptr_blk_switch_ctrl->iir_states, &energy_accu[0], ccfl >> 3);
|
||||
|
||||
ptr_blk_switch_ctrl->win_energy[1][w] = energy_accu[0];
|
||||
ptr_blk_switch_ctrl->win_energy_filt[1][w] = energy_accu[1];
|
||||
|
||||
if (ptr_blk_switch_ctrl->win_energy_filt[1][w] > *max)
|
||||
*max = ptr_blk_switch_ctrl->win_energy_filt[1][w];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_block_switching(ia_block_switch_ctrl *ptr_blk_switch_ctrl, const FLOAT32 *ptr_in,
|
||||
WORD32 ccfl) {
|
||||
WORD32 i;
|
||||
|
||||
FLOAT32 temp1, temp2;
|
||||
FLOAT32 max;
|
||||
FLOAT32 energy, energy_max;
|
||||
|
||||
for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
|
||||
ptr_blk_switch_ctrl->group_len[i] = 0;
|
||||
}
|
||||
|
||||
ptr_blk_switch_ctrl->max_win_energy =
|
||||
iusace_srch_max_with_idx(&ptr_blk_switch_ctrl->win_energy[0][MAX_SHORT_WINDOWS - 1],
|
||||
&ptr_blk_switch_ctrl->attack_idx);
|
||||
|
||||
ptr_blk_switch_ctrl->attack_idx = ptr_blk_switch_ctrl->last_attack_idx;
|
||||
ptr_blk_switch_ctrl->tot_grps_cnt = MAXIMUM_NO_OF_GROUPS;
|
||||
|
||||
for (i = 0; i < MAXIMUM_NO_OF_GROUPS; i++) {
|
||||
ptr_blk_switch_ctrl->group_len[i] =
|
||||
iusace_suggested_grouping_table[ptr_blk_switch_ctrl->attack_idx][i];
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
|
||||
ptr_blk_switch_ctrl->win_energy[0][i] = ptr_blk_switch_ctrl->win_energy[1][i];
|
||||
ptr_blk_switch_ctrl->win_energy_filt[0][i] = ptr_blk_switch_ctrl->win_energy_filt[1][i];
|
||||
}
|
||||
|
||||
iusace_calc_window_energy(ptr_blk_switch_ctrl, ptr_in, &max, ccfl);
|
||||
|
||||
ptr_blk_switch_ctrl->attack = FALSE;
|
||||
|
||||
energy_max = 0.0f;
|
||||
|
||||
energy = ptr_blk_switch_ctrl->win_energy_filt[0][MAX_SHORT_WINDOWS - 1];
|
||||
|
||||
for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
|
||||
temp1 = iusace_fmult(ONE_MINUS_ACC_WINDOW_NRG_FAC, ptr_blk_switch_ctrl->acc_win_energy);
|
||||
temp2 = iusace_fmult(ACC_WINDOW_NRG_FAC, energy);
|
||||
ptr_blk_switch_ctrl->acc_win_energy = iusace_fadd(temp1, temp2);
|
||||
|
||||
temp1 = iusace_fmult(ptr_blk_switch_ctrl->win_energy_filt[1][i],
|
||||
ptr_blk_switch_ctrl->inv_attack_ratio);
|
||||
if (temp1 > ptr_blk_switch_ctrl->acc_win_energy) {
|
||||
ptr_blk_switch_ctrl->attack = TRUE;
|
||||
ptr_blk_switch_ctrl->last_attack_idx = i;
|
||||
}
|
||||
|
||||
energy = ptr_blk_switch_ctrl->win_energy_filt[1][i];
|
||||
if (energy_max < energy) energy_max = energy;
|
||||
}
|
||||
|
||||
if (ccfl == LEN_SUPERFRAME_768) {
|
||||
energy_max = (energy_max * 4) / 3.0f;
|
||||
}
|
||||
if (energy_max < USAC_MIN_ATTACK_NRG) {
|
||||
ptr_blk_switch_ctrl->attack = FALSE;
|
||||
}
|
||||
|
||||
if ((!ptr_blk_switch_ctrl->attack) && (ptr_blk_switch_ctrl->lastattack)) {
|
||||
if (ptr_blk_switch_ctrl->attack_idx == MAX_SHORT_WINDOWS - 1) {
|
||||
ptr_blk_switch_ctrl->attack = TRUE;
|
||||
}
|
||||
ptr_blk_switch_ctrl->lastattack = FALSE;
|
||||
} else {
|
||||
ptr_blk_switch_ctrl->lastattack = ptr_blk_switch_ctrl->attack;
|
||||
}
|
||||
ptr_blk_switch_ctrl->window_seq = ptr_blk_switch_ctrl->next_win_seq;
|
||||
|
||||
if (ptr_blk_switch_ctrl->attack) {
|
||||
ptr_blk_switch_ctrl->next_win_seq = EIGHT_SHORT_SEQUENCE;
|
||||
} else {
|
||||
ptr_blk_switch_ctrl->next_win_seq = ONLY_LONG_SEQUENCE;
|
||||
}
|
||||
if (ptr_blk_switch_ctrl->next_win_seq == EIGHT_SHORT_SEQUENCE) {
|
||||
if (ptr_blk_switch_ctrl->window_seq == ONLY_LONG_SEQUENCE) {
|
||||
ptr_blk_switch_ctrl->window_seq = LONG_START_SEQUENCE;
|
||||
}
|
||||
|
||||
if (ptr_blk_switch_ctrl->window_seq == LONG_STOP_SEQUENCE) {
|
||||
ptr_blk_switch_ctrl->window_seq = EIGHT_SHORT_SEQUENCE;
|
||||
ptr_blk_switch_ctrl->tot_grps_cnt = 3;
|
||||
ptr_blk_switch_ctrl->group_len[0] = 3;
|
||||
ptr_blk_switch_ctrl->group_len[1] = 3;
|
||||
ptr_blk_switch_ctrl->group_len[2] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr_blk_switch_ctrl->next_win_seq == ONLY_LONG_SEQUENCE) {
|
||||
if (ptr_blk_switch_ctrl->window_seq == EIGHT_SHORT_SEQUENCE) {
|
||||
ptr_blk_switch_ctrl->next_win_seq = LONG_STOP_SEQUENCE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_sync_block_switching(ia_block_switch_ctrl *ptr_blk_switch_left_ctrl,
|
||||
ia_block_switch_ctrl *ptr_blk_switch_right_ctrl) {
|
||||
WORD32 i;
|
||||
WORD32 patch_type = ONLY_LONG_SEQUENCE;
|
||||
|
||||
patch_type = iusace_synchronized_block_types[patch_type][ptr_blk_switch_left_ctrl->window_seq];
|
||||
patch_type = iusace_synchronized_block_types[patch_type][ptr_blk_switch_right_ctrl->window_seq];
|
||||
|
||||
ptr_blk_switch_left_ctrl->window_seq = patch_type;
|
||||
ptr_blk_switch_right_ctrl->window_seq = patch_type;
|
||||
|
||||
if (patch_type != EIGHT_SHORT_SEQUENCE) { /* tns_data_long Blocks */
|
||||
ptr_blk_switch_left_ctrl->tot_grps_cnt = 1;
|
||||
ptr_blk_switch_right_ctrl->tot_grps_cnt = 1;
|
||||
ptr_blk_switch_left_ctrl->group_len[0] = 1;
|
||||
ptr_blk_switch_right_ctrl->group_len[0] = 1;
|
||||
|
||||
for (i = 1; i < MAX_SHORT_WINDOWS; i++) {
|
||||
ptr_blk_switch_left_ctrl->group_len[i] = 0;
|
||||
ptr_blk_switch_right_ctrl->group_len[i] = 0;
|
||||
}
|
||||
} else { /* tns_data_short Blocks */
|
||||
if (ptr_blk_switch_left_ctrl->max_win_energy > ptr_blk_switch_right_ctrl->max_win_energy) {
|
||||
ptr_blk_switch_right_ctrl->tot_grps_cnt = ptr_blk_switch_left_ctrl->tot_grps_cnt;
|
||||
for (i = 0; i < ptr_blk_switch_right_ctrl->tot_grps_cnt; i++) {
|
||||
ptr_blk_switch_right_ctrl->group_len[i] = ptr_blk_switch_left_ctrl->group_len[i];
|
||||
}
|
||||
} else {
|
||||
ptr_blk_switch_left_ctrl->tot_grps_cnt = ptr_blk_switch_right_ctrl->tot_grps_cnt;
|
||||
for (i = 0; i < ptr_blk_switch_left_ctrl->tot_grps_cnt; i++) {
|
||||
ptr_blk_switch_left_ctrl->group_len[i] = ptr_blk_switch_right_ctrl->group_len[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
27
encoder/iusace_block_switch.h
Normal file
27
encoder/iusace_block_switch.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
VOID iusace_init_block_switching(ia_block_switch_ctrl *pstr_blk_switch_ctrl,
|
||||
const WORD32 bit_rate, const WORD32 num_chans);
|
||||
VOID iusace_block_switching(ia_block_switch_ctrl *ptr_blk_switch_ctrl, const FLOAT32 *ptr_in,
|
||||
WORD32 ccfl);
|
||||
VOID iusace_sync_block_switching(ia_block_switch_ctrl *ptr_blk_switch_left_ctrl,
|
||||
ia_block_switch_ctrl *ptr_blk_switch_right_ctrl);
|
||||
45
encoder/iusace_block_switch_const.h
Normal file
45
encoder/iusace_block_switch_const.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define TRANS_FAC 8
|
||||
|
||||
#define BLK_SWITCH_WIN 8
|
||||
#define BLK_SWITCH_FILT_LEN 2
|
||||
|
||||
/* Block types */
|
||||
#define LONG_WINDOW 0
|
||||
#define START_WINDOW 1
|
||||
#define SHORT_WINDOW 2
|
||||
#define STOP_WINDOW 3
|
||||
|
||||
/* Window shapes */
|
||||
#define SINE_WINDOW 0
|
||||
#define KBD_WINDOW 1
|
||||
|
||||
#define MAXIMUM_NO_OF_GROUPS 4
|
||||
|
||||
#define ACC_WINDOW_NRG_FAC 0.3f
|
||||
#define ONE_MINUS_ACC_WINDOW_NRG_FAC 0.7f
|
||||
#define INV_ATTACK_RATIO_HIGH_BR 0.1f
|
||||
#define INV_ATTACK_RATIO_LOW_BR 0.056f
|
||||
#define USAC_MIN_ATTACK_NRG 1e+6
|
||||
#define CLIP_ENERGY_VALUE_LONG (1.0e9f)
|
||||
#define CLIP_ENERGY_VALUE_SHORT (15625000.0f)
|
||||
39
encoder/iusace_block_switch_struct_def.h
Normal file
39
encoder/iusace_block_switch_struct_def.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
typedef struct {
|
||||
FLOAT32 inv_attack_ratio;
|
||||
WORD32 window_seq;
|
||||
WORD32 next_win_seq;
|
||||
WORD32 attack;
|
||||
WORD32 lastattack;
|
||||
WORD32 attack_idx;
|
||||
WORD32 last_attack_idx;
|
||||
|
||||
WORD32 tot_grps_cnt;
|
||||
WORD32 group_len[TRANS_FAC];
|
||||
|
||||
FLOAT32 win_energy[2][BLK_SWITCH_WIN];
|
||||
FLOAT32 win_energy_filt[2][BLK_SWITCH_WIN];
|
||||
FLOAT32 iir_states[BLK_SWITCH_FILT_LEN];
|
||||
FLOAT32 max_win_energy;
|
||||
FLOAT32 acc_win_energy;
|
||||
} ia_block_switch_ctrl;
|
||||
|
|
@ -200,3 +200,4 @@
|
|||
|
||||
#define USACE_MAX_SCR_SIZE (733836)
|
||||
#define USACE_SCR_STACK (10 * 1024)
|
||||
#define MAX_USAC_ESBR_BITRATE (96000)
|
||||
|
|
|
|||
|
|
@ -130,3 +130,206 @@ typedef struct {
|
|||
VOID *ptr_drc_scratch_buf;
|
||||
VOID *ptr_stack_mem;
|
||||
} iusace_scratch_mem;
|
||||
|
||||
#define USAC_MAX_ELEMENTS (32)
|
||||
#define USAC_MAX_CONFIG_EXTENSIONS (16)
|
||||
|
||||
#define ID_USAC_SCE 0
|
||||
#define ID_USAC_CPE 1
|
||||
#define ID_USAC_EXT 3
|
||||
|
||||
#define AOT_SBR (5)
|
||||
#define AOT_USAC (42)
|
||||
|
||||
#define ID_EXT_ELE_FILL 0
|
||||
#define ID_EXT_ELE_UNI_DRC 4
|
||||
|
||||
#define ID_CONFIG_EXT_FILL 0
|
||||
#define ID_CONFIG_EXT_DOWNMIX (1)
|
||||
#define ID_CONFIG_EXT_LOUDNESS_INFO (2)
|
||||
#define NUM_COEFF (1024)
|
||||
|
||||
typedef enum {
|
||||
|
||||
USAC_ELEMENT_TYPE_INVALID = -1,
|
||||
USAC_ELEMENT_TYPE_SCE = 0,
|
||||
USAC_ELEMENT_TYPE_CPE = 1,
|
||||
USAC_ELEMENT_TYPE_EXT = 3
|
||||
|
||||
} ia_usac_ele_type;
|
||||
|
||||
typedef struct {
|
||||
UWORD32 harmonic_sbr;
|
||||
UWORD32 bs_inter_tes;
|
||||
UWORD32 bs_pvc;
|
||||
UWORD32 dflt_start_freq;
|
||||
UWORD32 dflt_stop_freq;
|
||||
UWORD32 dflt_header_extra1;
|
||||
UWORD32 dflt_header_extra2;
|
||||
UWORD32 dflt_freq_scale;
|
||||
UWORD32 dflt_alter_scale;
|
||||
UWORD32 dflt_noise_bands;
|
||||
UWORD32 dflt_limiter_bands;
|
||||
UWORD32 dflt_limiter_gains;
|
||||
UWORD32 dflt_interpol_freq;
|
||||
UWORD32 dflt_smoothing_mode;
|
||||
} ia_usac_enc_sbr_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 bs_tree_config;
|
||||
WORD32 bs_freq_res;
|
||||
WORD32 bs_fixed_gain_dmx;
|
||||
WORD32 bs_temp_shape_config;
|
||||
WORD32 bs_decorr_config;
|
||||
WORD32 bs_residual_coding;
|
||||
WORD32 bs_residual_bands;
|
||||
WORD32 bs_low_rate_mode;
|
||||
WORD32 bs_phase_coding;
|
||||
WORD32 bs_quant_coarse_xxx;
|
||||
WORD32 bs_ott_bands_phase;
|
||||
WORD32 bs_ott_bands_phase_present;
|
||||
WORD32 bs_pseudo_lr;
|
||||
WORD32 bs_env_quant_mode;
|
||||
WORD32 bs_high_rate_mode;
|
||||
} ia_usac_enc_mps_config_struct;
|
||||
|
||||
typedef struct {
|
||||
UWORD32 usac_ext_ele_type;
|
||||
UWORD32 usac_ext_ele_cfg_len;
|
||||
UWORD32 usac_ext_ele_dflt_len_present;
|
||||
UWORD32 usac_ext_ele_dflt_len;
|
||||
UWORD32 usac_ext_ele_payload_present;
|
||||
UWORD32 stereo_config_index;
|
||||
UWORD32 tw_mdct;
|
||||
UWORD32 noise_filling;
|
||||
UWORD8 usac_ext_ele_cfg_payload[6144 / 8];
|
||||
ia_usac_enc_sbr_config_struct str_usac_sbr_config;
|
||||
ia_usac_enc_mps_config_struct str_usac_mps212_config;
|
||||
UWORD8 *drc_config_data;
|
||||
} ia_usac_enc_element_config_struct;
|
||||
|
||||
typedef struct {
|
||||
UWORD32 num_elements;
|
||||
UWORD32 num_ext_elements;
|
||||
UWORD32 usac_element_type[USAC_MAX_ELEMENTS];
|
||||
UWORD32 usac_cfg_ext_present;
|
||||
UWORD32 num_config_extensions;
|
||||
UWORD32 usac_config_ext_type[USAC_MAX_CONFIG_EXTENSIONS];
|
||||
UWORD32 usac_config_ext_len[USAC_MAX_CONFIG_EXTENSIONS];
|
||||
UWORD8 *usac_config_ext_buf[USAC_MAX_CONFIG_EXTENSIONS];
|
||||
UWORD8 usac_cfg_ext_info_buf[USAC_MAX_CONFIG_EXTENSIONS][6144 / 8];
|
||||
WORD32 num_out_channels;
|
||||
WORD32 num_signal_grp;
|
||||
WORD32 output_channel_pos[BS_MAX_NUM_OUT_CHANNELS];
|
||||
WORD32 ccfl;
|
||||
ia_usac_enc_element_config_struct str_usac_element_config[USAC_MAX_ELEMENTS];
|
||||
} ia_usac_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 aac_allow_scalefacs;
|
||||
WORD32 aac_scale_facs;
|
||||
WORD32 bit_rate;
|
||||
WORD32 basic_bitrate;
|
||||
WORD32 bw_limit[USAC_MAX_ELEMENTS];
|
||||
WORD32 ccfl;
|
||||
WORD32 ccfl_idx;
|
||||
WORD32 channels;
|
||||
WORD32 codec_mode;
|
||||
WORD32 flag_noiseFilling;
|
||||
WORD32 iframes_interval;
|
||||
UWORD32 num_elements;
|
||||
UWORD32 num_ext_elements;
|
||||
|
||||
WORD32 sample_rate;
|
||||
WORD32 native_sample_rate;
|
||||
WORD32 core_sample_rate;
|
||||
|
||||
WORD32 tns_select;
|
||||
WORD32 ui_pcm_wd_sz;
|
||||
WORD32 use_fill_element;
|
||||
WORD32 window_shape_prev[MAX_TIME_CHANNELS];
|
||||
WORD32 window_shape_prev_copy[MAX_TIME_CHANNELS];
|
||||
WORD32 window_sequence[MAX_TIME_CHANNELS];
|
||||
WORD32 window_sequence_prev[MAX_TIME_CHANNELS];
|
||||
WORD32 window_sequence_prev_copy[MAX_TIME_CHANNELS];
|
||||
WORD32 cmplx_pred_flag;
|
||||
WORD32 wshape_flag;
|
||||
WORD32 delay_total;
|
||||
WORD32 in_frame_length;
|
||||
// eSBR Parameters
|
||||
WORD32 sbr_enable;
|
||||
WORD32 sbr_ratio_idx;
|
||||
WORD32 up_sample_ratio;
|
||||
WORD32 sbr_pvc_active;
|
||||
WORD32 sbr_harmonic;
|
||||
WORD32 hq_esbr;
|
||||
WORD32 sbr_inter_tes_active;
|
||||
// MPS Parameters
|
||||
WORD32 usac212enable;
|
||||
ia_sfb_params_struct str_sfb_prms;
|
||||
// DRC Params
|
||||
FLAG use_drc_element;
|
||||
WORD32 drc_frame_size;
|
||||
ia_drc_input_config str_drc_cfg;
|
||||
} ia_usac_encoder_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 mode;
|
||||
WORD32 num_bits;
|
||||
FLOAT32 lpc_coeffs_quant[2 * (ORDER + 1)];
|
||||
FLOAT32 lpc_coeffs[2 * (ORDER + 1)];
|
||||
FLOAT32 synth[ORDER + 128];
|
||||
FLOAT32 wsynth[1 + 128];
|
||||
FLOAT32 acelp_exc[2 * LEN_FRAME];
|
||||
WORD32 avq_params[FAC_LENGTH];
|
||||
FLOAT32 tcx_mem[128];
|
||||
FLOAT32 tcx_quant[1 + (2 * 128)];
|
||||
FLOAT32 tcx_fac;
|
||||
FLOAT32 mem_wsyn;
|
||||
} ia_usac_lpd_state_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 len_frame;
|
||||
WORD32 len_subfrm;
|
||||
WORD32 num_subfrm;
|
||||
WORD16 acelp_core_mode;
|
||||
WORD32 fscale;
|
||||
FLOAT32 mem_lp_decim2[3];
|
||||
WORD32 decim_frac;
|
||||
FLOAT32 mem_sig_in[4];
|
||||
FLOAT32 mem_preemph;
|
||||
FLOAT32 old_speech_pe[L_OLD_SPEECH_HIGH_RATE + LEN_LPC0];
|
||||
FLOAT32 weighted_sig[128];
|
||||
ia_usac_lpd_state_struct lpd_state;
|
||||
FLOAT32 prev_wsp[MAX_PITCH / OPL_DECIM];
|
||||
FLOAT32 prev_exc[MAX_PITCH + LEN_INTERPOL];
|
||||
FLOAT32 prev_wsyn_mem;
|
||||
FLOAT32 prev_wsp_mem;
|
||||
FLOAT32 prev_xnq_mem;
|
||||
WORD32 prev_ovlp_size;
|
||||
FLOAT32 isf_old[ORDER];
|
||||
FLOAT32 isp_old[ORDER];
|
||||
FLOAT32 isp_old_q[ORDER];
|
||||
FLOAT32 mem_wsp;
|
||||
FLOAT32 ada_w;
|
||||
FLOAT32 ol_gain;
|
||||
WORD16 ol_wght_flg;
|
||||
WORD32 prev_ol_lags[5];
|
||||
WORD32 prev_pitch_med;
|
||||
FLOAT32 prev_hp_wsp[LEN_SUPERFRAME / OPL_DECIM + (MAX_PITCH / OPL_DECIM)];
|
||||
FLOAT32 hp_ol_ltp_mem[3 * 2 + 1];
|
||||
const FLOAT32 *lp_analysis_window;
|
||||
FLOAT32 xn_buffer[128];
|
||||
WORD32 c_prev[(NUM_COEFF / 2) + 4];
|
||||
WORD32 c_pres[(NUM_COEFF / 2) + 4];
|
||||
WORD32 arith_reset_flag;
|
||||
WORD16 prev_mode;
|
||||
WORD32 num_bits_per_supfrm;
|
||||
FLOAT32 fd_synth[2 * LEN_FRAME + 1 + ORDER];
|
||||
FLOAT32 fd_orig[2 * LEN_FRAME + 1 + ORDER];
|
||||
WORD32 low_pass_line;
|
||||
WORD32 last_was_short;
|
||||
WORD32 next_is_short;
|
||||
FLOAT32 gain_tcx;
|
||||
WORD32 max_sfb_short;
|
||||
} ia_usac_td_encoder_struct;
|
||||
|
|
|
|||
534
encoder/iusace_enc_fac.c
Normal file
534
encoder/iusace_enc_fac.c
Normal file
|
|
@ -0,0 +1,534 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_write_bitstream.h"
|
||||
#include "iusace_func_prototypes.h"
|
||||
#include "iusace_avq_enc.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
|
||||
static WORD32 iusace_unary_code(WORD32 idx, WORD16 *ptr_bit_buf) {
|
||||
WORD32 num_bits;
|
||||
|
||||
num_bits = 1;
|
||||
|
||||
idx -= 1;
|
||||
while (idx-- > 0) {
|
||||
*ptr_bit_buf++ = 1;
|
||||
num_bits++;
|
||||
}
|
||||
|
||||
*ptr_bit_buf = 0;
|
||||
|
||||
return (num_bits);
|
||||
}
|
||||
|
||||
static VOID iusace_get_nk_mode(WORD32 mode_lpc, ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
WORD32 *nk_mode, WORD32 lpc_set) {
|
||||
switch (lpc_set) {
|
||||
case 4:
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
*nk_mode = 3;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, mode_lpc, 1);
|
||||
break;
|
||||
case 1:
|
||||
*nk_mode = mode_lpc;
|
||||
if (mode_lpc == 2) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else if (mode_lpc == 1) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
} else if (mode_lpc == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (mode_lpc == 0) {
|
||||
*nk_mode = 0;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else if (mode_lpc == 1) {
|
||||
*nk_mode = 1;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else if (mode_lpc == 2) {
|
||||
*nk_mode = 2;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else {
|
||||
*nk_mode = 2;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_write_qn_data(WORD32 *qn, ia_bit_buf_struct *pstr_it_bit_buff, WORD32 nk_mode,
|
||||
WORD32 num_frames) {
|
||||
WORD32 k, i;
|
||||
switch (nk_mode) {
|
||||
case 1:
|
||||
for (k = 0; k < 2; k++) {
|
||||
for (i = 0; i < qn[k] - 1; i++) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
for (k = 0; k < 2; k++) {
|
||||
WORD32 qn1 = qn[k] - 2;
|
||||
if (qn1 < 0 || qn1 > 3) {
|
||||
qn1 = 3;
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, qn1, 2);
|
||||
}
|
||||
if ((nk_mode == 2) && num_frames != 2) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
if (qn[k] > 4) {
|
||||
for (i = 0; i < qn[k] - 4; i++) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
}
|
||||
if (qn[k] == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (k = 0; k < 2; k++) {
|
||||
if (qn[k] == 5) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else if (qn[k] == 6) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else if (qn[k] == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
} else {
|
||||
WORD32 qn_ext = qn[k] - 4;
|
||||
if (qn_ext > 0) {
|
||||
for (i = 0; i < qn_ext; i++) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 1, 1);
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_write_cb_indices(WORD32 *qn, WORD32 *ptr_params, WORD32 *idx,
|
||||
ia_bit_buf_struct *pstr_it_bit_buff, WORD32 nk_mode,
|
||||
WORD32 num_frames) {
|
||||
WORD32 k;
|
||||
WORD32 j = *idx;
|
||||
|
||||
iusace_write_qn_data(qn, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
if (qn[k] > 0) {
|
||||
WORD32 n, nk, i;
|
||||
if (qn[k] > 4) {
|
||||
nk = (qn[k] - 3) >> 1;
|
||||
n = qn[k] - nk * 2;
|
||||
} else {
|
||||
nk = 0;
|
||||
n = qn[k];
|
||||
}
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, ptr_params[j++], (UWORD8)(4 * n));
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, ptr_params[j++], (UWORD8)nk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*idx = j;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_write_lpc_data(ia_bit_buf_struct *pstr_it_bit_buff, WORD32 *param_lpc,
|
||||
WORD32 first_lpd_flag, WORD32 *mod, WORD32 num_frames) {
|
||||
WORD32 nk_mode = 0;
|
||||
WORD32 j = 0, k;
|
||||
WORD32 mode_lpc = 0;
|
||||
WORD32 qn[2] = {0};
|
||||
|
||||
iusace_get_nk_mode(mode_lpc, pstr_it_bit_buff, &nk_mode, 4);
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, param_lpc[j++], 8);
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
|
||||
iusace_write_cb_indices(qn, param_lpc, &j, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
|
||||
if (first_lpd_flag) {
|
||||
mode_lpc = param_lpc[j++];
|
||||
iusace_get_nk_mode(mode_lpc, pstr_it_bit_buff, &nk_mode, 0);
|
||||
|
||||
if (mode_lpc == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, param_lpc[j++], 8);
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
|
||||
iusace_write_cb_indices(qn, param_lpc, &j, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
}
|
||||
|
||||
mode_lpc = param_lpc[j++];
|
||||
|
||||
if (num_frames == 4 && mod[0] < 3) {
|
||||
iusace_get_nk_mode(mode_lpc, pstr_it_bit_buff, &nk_mode, 2);
|
||||
|
||||
if (mode_lpc == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, param_lpc[j++], 8);
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
|
||||
iusace_write_cb_indices(qn, param_lpc, &j, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
}
|
||||
mode_lpc = param_lpc[j++];
|
||||
if (mod[0] < 2) {
|
||||
iusace_get_nk_mode(mode_lpc, pstr_it_bit_buff, &nk_mode, 1);
|
||||
|
||||
if (mode_lpc != 1) {
|
||||
if (mode_lpc == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, param_lpc[j++], 8);
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
|
||||
iusace_write_cb_indices(qn, param_lpc, &j, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
}
|
||||
} else if (mode_lpc != 1) {
|
||||
if (mode_lpc == 0) {
|
||||
j++;
|
||||
}
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
j += ((qn[0] > 0) ? 9 : 0) + ((qn[1] > 0) ? 9 : 0);
|
||||
}
|
||||
|
||||
mode_lpc = param_lpc[j++];
|
||||
if (num_frames != 2 && mod[2] < 2) {
|
||||
iusace_get_nk_mode(mode_lpc, pstr_it_bit_buff, &nk_mode, 3);
|
||||
if (mode_lpc == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, param_lpc[j++], 8);
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
qn[k] = param_lpc[j++];
|
||||
}
|
||||
iusace_write_cb_indices(qn, param_lpc, &j, pstr_it_bit_buff, nk_mode, num_frames);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_encode_fac_params(WORD32 *mod, WORD32 *n_param_tcx, ia_usac_data_struct *usac_data,
|
||||
WORD32 const usac_independency_flag,
|
||||
ia_bit_buf_struct *pstr_it_bit_buff, WORD32 ch_idx) {
|
||||
WORD32 *total_nbbits = &usac_data->total_nbbits[ch_idx];
|
||||
ia_usac_td_encoder_struct *pstr_td = usac_data->td_encoder[ch_idx];
|
||||
WORD32 codec_mode = pstr_td->acelp_core_mode;
|
||||
WORD16 *bit_buf = usac_data->td_serial_out[ch_idx];
|
||||
WORD32 is_bass_post_filter = 1;
|
||||
WORD32 first_lpd_flag = (usac_data->core_mode_prev[ch_idx] == CORE_MODE_FD);
|
||||
WORD32 *param_lpc = usac_data->param_buf + (NUM_FRAMES * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
WORD32 *param = usac_data->param_buf;
|
||||
WORD32 j, k, n, sfr, lpd_mode, num_bits, sq_bits, *prm;
|
||||
WORD16 first_tcx_flag = 1;
|
||||
WORD32 nbits_fac, nb_bits_lpc;
|
||||
WORD32 core_mode_last = (first_lpd_flag) ? 0 : 1;
|
||||
WORD32 fac_data_present;
|
||||
WORD32 num_frames = NUM_FRAMES;
|
||||
WORD16 *ptr_bit_buf = bit_buf;
|
||||
|
||||
pstr_td->num_bits_per_supfrm = 0;
|
||||
*total_nbbits = 0;
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, pstr_td->acelp_core_mode, 3);
|
||||
|
||||
if (mod[0] == 3) {
|
||||
lpd_mode = 25;
|
||||
} else if ((mod[0] == 2) && (mod[2] == 2)) {
|
||||
lpd_mode = 24;
|
||||
} else {
|
||||
if (mod[0] == 2) {
|
||||
lpd_mode = 16 + mod[2] + 2 * mod[3];
|
||||
} else if (mod[2] == 2) {
|
||||
lpd_mode = 20 + mod[0] + 2 * mod[1];
|
||||
} else {
|
||||
lpd_mode = mod[0] + 2 * mod[1] + 4 * mod[2] + 8 * mod[3];
|
||||
}
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, lpd_mode, 5);
|
||||
pstr_td->num_bits_per_supfrm = 5;
|
||||
*total_nbbits += 5;
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, is_bass_post_filter, 1);
|
||||
*total_nbbits += 1;
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, core_mode_last, 1);
|
||||
*total_nbbits += 1;
|
||||
|
||||
if (((mod[0] == 0) && (mod[-1] != 0)) || ((mod[0] > 0) && (mod[-1] == 0))) {
|
||||
fac_data_present = 1;
|
||||
} else {
|
||||
fac_data_present = 0;
|
||||
}
|
||||
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, fac_data_present, 1);
|
||||
*total_nbbits += 1;
|
||||
|
||||
num_bits = (iusace_acelp_core_numbits_1024[codec_mode] / 4) - 2;
|
||||
|
||||
k = 0;
|
||||
while (k < num_frames) {
|
||||
lpd_mode = mod[k];
|
||||
prm = param + (k * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
j = 0;
|
||||
|
||||
if (((mod[k - 1] == 0) && (mod[k] > 0)) || ((mod[k - 1] > 0) && (mod[k] == 0))) {
|
||||
nbits_fac = iusace_fd_encode_fac(&prm[j], ptr_bit_buf, (pstr_td->len_subfrm) / 2);
|
||||
j += (pstr_td->len_subfrm) / 2;
|
||||
*total_nbbits += nbits_fac;
|
||||
for (WORD32 i = 0; i < nbits_fac; i++) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, ptr_bit_buf[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (lpd_mode == 0) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j++], 2);
|
||||
|
||||
for (sfr = 0; sfr < (pstr_td->num_subfrm); sfr++) {
|
||||
n = 6;
|
||||
if ((sfr == 0) || (((pstr_td->len_subfrm) == 256) && (sfr == 2))) n = 9;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], (UWORD8)n);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 1);
|
||||
j++;
|
||||
if (codec_mode == ACELP_CORE_MODE_9k6) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
} else if (codec_mode == ACELP_CORE_MODE_11k2) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 5);
|
||||
j++;
|
||||
} else if (codec_mode == ACELP_CORE_MODE_12k8) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
} else if (codec_mode == ACELP_CORE_MODE_14k4) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 9);
|
||||
j++;
|
||||
} else if (codec_mode == ACELP_CORE_MODE_16k) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 13);
|
||||
j++;
|
||||
} else if (codec_mode == ACELP_CORE_MODE_18k4) {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 2);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 2);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 2);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 2);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 14);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 14);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 14);
|
||||
j++;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 14);
|
||||
j++;
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j], 7);
|
||||
j++;
|
||||
}
|
||||
*total_nbbits += (num_bits - NBITS_LPC);
|
||||
pstr_td->num_bits_per_supfrm += (num_bits - NBITS_LPC);
|
||||
k++;
|
||||
} else {
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j++], 3);
|
||||
*total_nbbits += 3;
|
||||
pstr_td->num_bits_per_supfrm += 3;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, prm[j++], 7);
|
||||
*total_nbbits += 7;
|
||||
pstr_td->num_bits_per_supfrm += 7;
|
||||
|
||||
if (first_tcx_flag) {
|
||||
first_tcx_flag = 0;
|
||||
if (usac_independency_flag) {
|
||||
pstr_td->arith_reset_flag = 1;
|
||||
memset(pstr_td->c_pres, 0, 516 * sizeof(WORD32));
|
||||
memset(pstr_td->c_prev, 0, 516 * sizeof(WORD32));
|
||||
} else {
|
||||
if (pstr_td->arith_reset_flag) {
|
||||
memset(pstr_td->c_pres, 0, 516 * sizeof(WORD32));
|
||||
memset(pstr_td->c_prev, 0, 516 * sizeof(WORD32));
|
||||
}
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, pstr_td->arith_reset_flag, 1);
|
||||
*total_nbbits += 1;
|
||||
pstr_td->num_bits_per_supfrm += 1;
|
||||
}
|
||||
}
|
||||
|
||||
sq_bits = iusace_tcx_coding(pstr_it_bit_buff, n_param_tcx[k], pstr_td->len_frame, prm + j,
|
||||
pstr_td->c_pres, pstr_td->c_prev);
|
||||
|
||||
*total_nbbits += sq_bits;
|
||||
pstr_td->num_bits_per_supfrm += sq_bits;
|
||||
|
||||
k += (1 << (lpd_mode - 1));
|
||||
}
|
||||
}
|
||||
|
||||
nb_bits_lpc = pstr_it_bit_buff->cnt_bits;
|
||||
|
||||
iusace_write_lpc_data(pstr_it_bit_buff, param_lpc, first_lpd_flag, mod, num_frames);
|
||||
|
||||
nb_bits_lpc = pstr_it_bit_buff->cnt_bits - nb_bits_lpc;
|
||||
*total_nbbits += nb_bits_lpc;
|
||||
pstr_td->num_bits_per_supfrm += nb_bits_lpc;
|
||||
|
||||
if ((core_mode_last == 0) && (fac_data_present == 1)) {
|
||||
WORD32 short_fac_flag = (mod[-1] == -2) ? 1 : 0;
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, short_fac_flag, 1);
|
||||
*total_nbbits += 1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
WORD32 iusace_fd_encode_fac(WORD32 *prm, WORD16 *ptr_bit_buf, WORD32 fac_length) {
|
||||
WORD32 i, j, n, nb, qn, kv[8], nk, fac_bits;
|
||||
WORD32 I;
|
||||
|
||||
fac_bits = 0;
|
||||
|
||||
for (i = 0; i < fac_length; i += 8) {
|
||||
iusace_apply_voronoi_ext(&prm[i], &qn, &I, kv);
|
||||
|
||||
nb = iusace_unary_code(qn, ptr_bit_buf);
|
||||
ptr_bit_buf += nb;
|
||||
|
||||
fac_bits += nb;
|
||||
|
||||
nk = 0;
|
||||
n = qn;
|
||||
if (qn > 4) {
|
||||
nk = (qn - 3) >> 1;
|
||||
n = qn - nk * 2;
|
||||
}
|
||||
|
||||
iusace_write_bits2buf(I, 4 * n, ptr_bit_buf);
|
||||
ptr_bit_buf += 4 * n;
|
||||
for (j = 0; j < 8; j++) {
|
||||
iusace_write_bits2buf(kv[j], nk, ptr_bit_buf);
|
||||
ptr_bit_buf += nk;
|
||||
}
|
||||
|
||||
fac_bits += 4 * qn;
|
||||
}
|
||||
|
||||
return fac_bits;
|
||||
}
|
||||
1333
encoder/iusace_enc_main.c
Normal file
1333
encoder/iusace_enc_main.c
Normal file
File diff suppressed because it is too large
Load diff
793
encoder/iusace_esbr_inter_tes.c
Normal file
793
encoder/iusace_esbr_inter_tes.c
Normal file
|
|
@ -0,0 +1,793 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "ixheaac_basic_ops32.h"
|
||||
#include "ixheaac_basic_ops16.h"
|
||||
#include "ixheaac_basic_ops40.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "ixheaace_bitbuffer.h"
|
||||
#include "ixheaace_sbr_def.h"
|
||||
#include "iusace_esbr_inter_tes.h"
|
||||
#include "iusace_esbr_rom.h"
|
||||
|
||||
VOID ixheaace_init_esbr_inter_tes(ixheaace_str_inter_tes_params *pstr_tes_enc,
|
||||
WORD32 sbr_ratio_index) {
|
||||
WORD32 ts;
|
||||
WORD32 memset_sz = IXHEAACE_QMF_CHANNELS * sizeof(pstr_tes_enc->qmf_buf_real[0][0]);
|
||||
|
||||
switch (sbr_ratio_index) {
|
||||
case USAC_SBR_RATIO_INDEX_2_1:
|
||||
pstr_tes_enc->op_delay = 6;
|
||||
pstr_tes_enc->codec_delay = 32;
|
||||
pstr_tes_enc->sbr_ratio_index = sbr_ratio_index;
|
||||
break;
|
||||
case USAC_SBR_RATIO_INDEX_4_1:
|
||||
pstr_tes_enc->op_delay = 6 * 2;
|
||||
pstr_tes_enc->codec_delay = 64;
|
||||
pstr_tes_enc->sbr_ratio_index = sbr_ratio_index;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&pstr_tes_enc->bw_array_prev[0], 0,
|
||||
IXHEAACE_MAX_NUM_PATCHES * sizeof(pstr_tes_enc->bw_array_prev[0]));
|
||||
memset(&pstr_tes_enc->inv_filt_mode_prev[0], 0,
|
||||
IXHEAACE_MAX_NUM_NOISE_VALUES * sizeof(pstr_tes_enc->inv_filt_mode_prev[0]));
|
||||
|
||||
for (ts = 0;
|
||||
ts < pstr_tes_enc->op_delay + pstr_tes_enc->codec_delay + IXHEAACE_SBR_HF_ADJ_OFFSET;
|
||||
ts++) {
|
||||
memset(pstr_tes_enc->qmf_buf_real[ts], 0, memset_sz);
|
||||
memset(pstr_tes_enc->qmf_buf_imag[ts], 0, memset_sz);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID ixheaace_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[IXHEAACE_TIMESLOT_BUFFER_SIZE],
|
||||
subsample_power_low[IXHEAACE_TIMESLOT_BUFFER_SIZE];
|
||||
FLOAT32 total_power_high = 0.0f;
|
||||
FLOAT32 total_power_low = 0.0f, total_power_high_after = 1.0e-6f;
|
||||
FLOAT32 gain[IXHEAACE_TIMESLOT_BUFFER_SIZE];
|
||||
FLOAT32 gain_adj, gain_adj_2;
|
||||
FLOAT32 gamma = ixheaace_gamma_tab[gamma_idx];
|
||||
WORD32 i, j;
|
||||
WORD32 memcpy_sz = sub_band_start * sizeof(FLOAT32);
|
||||
|
||||
if (gamma > 0) {
|
||||
for (i = 0; i < num_sample; i++) {
|
||||
memcpy(&qmf_real[IXHEAACE_QMF_CHANNELS * i], &qmf_real1[IXHEAACE_QMF_CHANNELS * i],
|
||||
memcpy_sz);
|
||||
memcpy(&qmf_imag[IXHEAACE_QMF_CHANNELS * i], &qmf_imag1[IXHEAACE_QMF_CHANNELS * i],
|
||||
memcpy_sz);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_sample; i++) {
|
||||
j = 0;
|
||||
subsample_power_low[i] = 0.0f;
|
||||
while (j < sub_band_start) {
|
||||
subsample_power_low[i] +=
|
||||
qmf_real[IXHEAACE_QMF_CHANNELS * i + j] * qmf_real[IXHEAACE_QMF_CHANNELS * i + j];
|
||||
subsample_power_low[i] +=
|
||||
qmf_imag[IXHEAACE_QMF_CHANNELS * i + j] * qmf_imag[IXHEAACE_QMF_CHANNELS * i + j];
|
||||
j++;
|
||||
}
|
||||
subsample_power_high[i] = 0.0f;
|
||||
while (j < sub_band_end) {
|
||||
subsample_power_high[i] +=
|
||||
qmf_real[IXHEAACE_QMF_CHANNELS * i + j] * qmf_real[IXHEAACE_QMF_CHANNELS * i + j];
|
||||
subsample_power_high[i] +=
|
||||
qmf_imag[IXHEAACE_QMF_CHANNELS * i + j] * qmf_imag[IXHEAACE_QMF_CHANNELS * i + j];
|
||||
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)));
|
||||
gain[i] = (FLOAT32)(1.0f + gamma * (gain[i] - 1.0f));
|
||||
|
||||
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;
|
||||
|
||||
j = sub_band_start;
|
||||
while (j < sub_band_end) {
|
||||
qmf_real[IXHEAACE_QMF_CHANNELS * i + j] *= gain[i];
|
||||
qmf_imag[IXHEAACE_QMF_CHANNELS * i + j] *= gain[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static WORD32 ixheaace_inter_tes_sound_activity(FLOAT32 qmf_real[][IXHEAACE_QMF_CHANNELS],
|
||||
FLOAT32 qmf_imag[][IXHEAACE_QMF_CHANNELS],
|
||||
FLOAT32 energy[], WORD32 len, WORD32 start,
|
||||
WORD32 stop, WORD32 *is_transient) {
|
||||
WORD32 snd_act = 0, ts, idx;
|
||||
FLOAT32 ene_min = MAX_FLT_VAL, ene_max = 0.0f;
|
||||
|
||||
for (ts = 0; ts < len; ts++) {
|
||||
idx = start;
|
||||
while (idx < stop) {
|
||||
energy[ts] += (qmf_real[ts][idx] * qmf_real[ts][idx]);
|
||||
energy[ts] += (qmf_imag[ts][idx] * qmf_imag[ts][idx]);
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (energy[ts] > ene_max) {
|
||||
ene_max = energy[ts];
|
||||
}
|
||||
if (energy[ts] < ene_min) {
|
||||
ene_min = energy[ts];
|
||||
}
|
||||
}
|
||||
|
||||
snd_act = (ene_max > IXHEAACE_ESBR_TES_ENERGY_MAX_THR) ? 1 : 0;
|
||||
|
||||
if ((ene_max / (ene_min + 1.0e-6f)) > 20) {
|
||||
*is_transient = 1;
|
||||
} else {
|
||||
*is_transient = 0;
|
||||
}
|
||||
return snd_act;
|
||||
}
|
||||
|
||||
static WORD16 ixheaace_find_closest_entry(WORD32 goal_sb, WORD16 *ptr_master_tab,
|
||||
WORD16 num_mf_bands, WORD16 direction) {
|
||||
WORD32 index;
|
||||
|
||||
if (goal_sb <= ptr_master_tab[0]) return ptr_master_tab[0];
|
||||
|
||||
if (goal_sb >= ptr_master_tab[num_mf_bands]) return ptr_master_tab[num_mf_bands];
|
||||
|
||||
if (direction) {
|
||||
index = 0;
|
||||
while (ptr_master_tab[index] < goal_sb) {
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
index = num_mf_bands;
|
||||
while (ptr_master_tab[index] > goal_sb) {
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr_master_tab[index];
|
||||
}
|
||||
|
||||
static VOID ixheaace_esbr_calc_co_variance(ixheaace_str_auto_corr_ele *pstr_auto_corr,
|
||||
FLOAT32 ptr_vec_x_real[][IXHEAACE_QMF_CHANNELS],
|
||||
FLOAT32 ptr_vec_x_imag[][IXHEAACE_QMF_CHANNELS],
|
||||
WORD32 bd, WORD32 len) {
|
||||
WORD32 j = 0;
|
||||
|
||||
FLOAT32 xr_j;
|
||||
FLOAT32 xr_j_minus_1 = ptr_vec_x_real[j - 1][bd];
|
||||
FLOAT32 xr_j_minus_2 = ptr_vec_x_real[j - 2][bd];
|
||||
|
||||
FLOAT32 xi_j;
|
||||
FLOAT32 xi_j_minus_1 = ptr_vec_x_imag[j - 1][bd];
|
||||
FLOAT32 xi_j_minus_2 = ptr_vec_x_imag[j - 2][bd];
|
||||
|
||||
memset(pstr_auto_corr, 0, sizeof(ixheaace_str_auto_corr_ele));
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
xr_j = ptr_vec_x_real[j][bd];
|
||||
xi_j = ptr_vec_x_imag[j][bd];
|
||||
|
||||
pstr_auto_corr->phi_0_1_real += xr_j * xr_j_minus_1 + xi_j * xi_j_minus_1;
|
||||
|
||||
pstr_auto_corr->phi_0_1_imag += xi_j * xr_j_minus_1 - xr_j * xi_j_minus_1;
|
||||
|
||||
pstr_auto_corr->phi_0_2_real += xr_j * xr_j_minus_2 + xi_j * xi_j_minus_2;
|
||||
|
||||
pstr_auto_corr->phi_0_2_imag += xi_j * xr_j_minus_2 - xr_j * xi_j_minus_2;
|
||||
|
||||
pstr_auto_corr->phi_1_1 += xr_j_minus_1 * xr_j_minus_1 + xi_j_minus_1 * xi_j_minus_1;
|
||||
|
||||
pstr_auto_corr->phi_1_2_real += xr_j_minus_1 * xr_j_minus_2 + xi_j_minus_1 * xi_j_minus_2;
|
||||
|
||||
pstr_auto_corr->phi_1_2_imag += xi_j_minus_1 * xr_j_minus_2 - xr_j_minus_1 * xi_j_minus_2;
|
||||
|
||||
pstr_auto_corr->phi_2_2 += xr_j_minus_2 * xr_j_minus_2 + xi_j_minus_2 * xi_j_minus_2;
|
||||
|
||||
xr_j_minus_2 = xr_j_minus_1;
|
||||
xr_j_minus_1 = xr_j;
|
||||
|
||||
xi_j_minus_2 = xi_j_minus_1;
|
||||
xi_j_minus_1 = xi_j;
|
||||
}
|
||||
|
||||
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) *
|
||||
IXHEAACE_SBR_HF_RELAXATION_PARAM;
|
||||
}
|
||||
|
||||
static VOID ixheaace_gausssolve(WORD32 n, FLOAT32 ptr_a[][IXHEAACE_MAXDEG + 1], FLOAT32 ptr_b[],
|
||||
FLOAT32 ptr_y[]) {
|
||||
WORD32 i, j, k, imax;
|
||||
FLOAT32 v;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
imax = i;
|
||||
k = i + 1;
|
||||
while (k < n) {
|
||||
if (fabs(ptr_a[k][i]) > fabs(ptr_a[imax][i])) {
|
||||
imax = k;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
if (imax != i) {
|
||||
v = ptr_b[imax];
|
||||
ptr_b[imax] = ptr_b[i];
|
||||
ptr_b[i] = v;
|
||||
j = i;
|
||||
while (j < n) {
|
||||
v = ptr_a[imax][j];
|
||||
ptr_a[imax][j] = ptr_a[i][j];
|
||||
ptr_a[i][j] = v;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
v = ptr_a[i][i];
|
||||
|
||||
ptr_b[i] /= v;
|
||||
for (j = i; j < n; j++) {
|
||||
ptr_a[i][j] /= v;
|
||||
}
|
||||
|
||||
for (k = i + 1; k < n; k++) {
|
||||
v = ptr_a[k][i];
|
||||
ptr_b[k] -= v * ptr_b[i];
|
||||
for (j = i + 1; j < n; j++) {
|
||||
ptr_a[k][j] -= v * ptr_a[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
ptr_y[i] = ptr_b[i];
|
||||
for (j = i + 1; j < n; j++) {
|
||||
ptr_y[i] -= ptr_a[i][j] * ptr_y[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID ixheaace_polyfit(WORD32 n, FLOAT32 ptr_y[], FLOAT32 ptr_p[]) {
|
||||
WORD32 i, j, k;
|
||||
FLOAT32 ptr_a[IXHEAACE_MAXDEG + 1][IXHEAACE_MAXDEG + 1] = {{0}};
|
||||
FLOAT32 ptr_b[IXHEAACE_MAXDEG + 1] = {0};
|
||||
FLOAT32 v[2 * IXHEAACE_MAXDEG + 1];
|
||||
|
||||
for (k = 0; k < n; k++) {
|
||||
v[0] = 1.0;
|
||||
for (i = 1; i <= 2 * IXHEAACE_MAXDEG; i++) {
|
||||
v[i] = k * v[i - 1];
|
||||
}
|
||||
|
||||
for (i = 0; i <= IXHEAACE_MAXDEG; i++) {
|
||||
ptr_b[i] += v[IXHEAACE_MAXDEG - i] * ptr_y[k];
|
||||
for (j = 0; j <= IXHEAACE_MAXDEG; j++) {
|
||||
ptr_a[i][j] += v[2 * IXHEAACE_MAXDEG - i - j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ixheaace_gausssolve(IXHEAACE_MAXDEG + 1, ptr_a, ptr_b, ptr_p);
|
||||
}
|
||||
|
||||
static VOID ixheaace_esbr_chirp_fac_calc(WORD32 *ptr_inv_filt_mode,
|
||||
WORD32 *ptr_inv_filt_mode_prev, WORD32 num_if_bands,
|
||||
FLOAT32 *ptr_bw_array, FLOAT32 *ptr_bw_array_prev) {
|
||||
WORD32 i;
|
||||
|
||||
for (i = 0; i < num_if_bands; i++) {
|
||||
ptr_bw_array[i] = ixheaace_new_bw_tab[ptr_inv_filt_mode_prev[i]][ptr_inv_filt_mode[i]];
|
||||
|
||||
if (ptr_bw_array[i] < ptr_bw_array_prev[i]) {
|
||||
ptr_bw_array[i] = 0.75000f * ptr_bw_array[i] + 0.25000f * ptr_bw_array_prev[i];
|
||||
} else {
|
||||
ptr_bw_array[i] = 0.90625f * ptr_bw_array[i] + 0.09375f * ptr_bw_array_prev[i];
|
||||
}
|
||||
|
||||
if (ptr_bw_array[i] < 0.015625) {
|
||||
ptr_bw_array[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID ixheaace_pre_processing(FLOAT32 ptr_src_buf_real[][IXHEAACE_QMF_CHANNELS],
|
||||
FLOAT32 ptr_src_buf_imag[][IXHEAACE_QMF_CHANNELS],
|
||||
FLOAT32 ptr_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[IXHEAACE_QMF_CHANNELS];
|
||||
FLOAT32 low_env[IXHEAACE_QMF_CHANNELS];
|
||||
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 += low_env[k];
|
||||
}
|
||||
mean_enrg /= num_bands;
|
||||
|
||||
ixheaace_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++) {
|
||||
low_env_slope[k] = a3 + a2 * k + a1 * k * k + a0 * k * k * k;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_bands; i++) {
|
||||
ptr_gain_vector[i] = (FLOAT32)pow(10, (mean_enrg - low_env_slope[i]) / 20.0f);
|
||||
}
|
||||
}
|
||||
|
||||
static IA_ERRORCODE ixheaace_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],
|
||||
ixheaace_str_inter_tes_params *pstr_tes_enc) {
|
||||
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 = 0;
|
||||
FLOAT32 a0r, a0i, a1r, a1i;
|
||||
FLOAT32 ptr_bw_array[IXHEAACE_MAX_NUM_PATCHES] = {0};
|
||||
|
||||
ixheaace_str_auto_corr_ele str_auto_corr;
|
||||
|
||||
WORD16 *ptr_invf_band_tbl = &pstr_tes_enc->invf_band_tbl[1];
|
||||
WORD32 num_if_bands = pstr_tes_enc->num_if_bands;
|
||||
WORD32 sub_band_start = pstr_tes_enc->sub_band_start;
|
||||
WORD16 *ptr_master_tab = pstr_tes_enc->f_master_tbl;
|
||||
WORD32 num_mf_bands = pstr_tes_enc->num_mf_bands;
|
||||
WORD32 *ptr_inv_filt_mode = pstr_tes_enc->inv_filt_mode;
|
||||
WORD32 *ptr_inv_filt_mode_prev = pstr_tes_enc->inv_filt_mode_prev;
|
||||
WORD32 sbr_patching_mode = 1;
|
||||
WORD32 pre_proc_flag = 0;
|
||||
WORD32 fs = pstr_tes_enc->out_fs;
|
||||
WORD32 cov_count;
|
||||
WORD32 lsb = ptr_master_tab[0];
|
||||
WORD32 usb = ptr_master_tab[num_mf_bands];
|
||||
WORD32 memset_sz = (IXHEAACE_QMF_CHANNELS - usb) * sizeof(FLOAT32);
|
||||
WORD32 xover_offset = sub_band_start - ptr_master_tab[0];
|
||||
FLOAT32 bw = 0.0f;
|
||||
FLOAT32 fac = 0.0f;
|
||||
FLOAT32 gain;
|
||||
FLOAT32 ptr_gain_vector[64];
|
||||
WORD32 slope_length = 0;
|
||||
WORD32 first_slot_offset = pstr_tes_enc->border_vec[0];
|
||||
WORD32 end_slot_offs = 0;
|
||||
FLOAT32 *ptr_bw_array_prev = pstr_tes_enc->bw_array_prev;
|
||||
|
||||
end_slot_offs = pstr_tes_enc->border_vec[pstr_tes_enc->num_env] - 16;
|
||||
|
||||
switch (pstr_tes_enc->sbr_ratio_index) {
|
||||
case USAC_SBR_RATIO_INDEX_2_1:
|
||||
start_sample = first_slot_offset * 2;
|
||||
end_sample = 32 + end_slot_offs * 2;
|
||||
co_var_len = 38;
|
||||
break;
|
||||
case USAC_SBR_RATIO_INDEX_4_1:
|
||||
start_sample = first_slot_offset * 4;
|
||||
end_sample = 64 + end_slot_offs * 4;
|
||||
co_var_len = 76;
|
||||
break;
|
||||
default:
|
||||
start_sample = first_slot_offset * 2;
|
||||
end_sample = 32 + end_slot_offs * 2;
|
||||
co_var_len = 38;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pre_proc_flag) {
|
||||
ixheaace_pre_processing(ptr_src_buf_real, ptr_src_buf_imag, ptr_gain_vector,
|
||||
ptr_master_tab[0], start_sample, end_sample);
|
||||
}
|
||||
|
||||
ixheaace_esbr_chirp_fac_calc(ptr_inv_filt_mode, ptr_inv_filt_mode_prev, num_if_bands,
|
||||
ptr_bw_array, ptr_bw_array_prev);
|
||||
|
||||
for (i = start_sample; i < end_sample; i++) {
|
||||
memset(ptr_dst_buf_real[i] + usb, 0, memset_sz);
|
||||
memset(ptr_dst_buf_imag[i] + usb, 0, memset_sz);
|
||||
}
|
||||
|
||||
if (sbr_patching_mode || !hbe_flag) {
|
||||
FLOAT32 alpha_real[IXHEAACE_QMF_CHANNELS][2] = {{0}},
|
||||
alpha_imag[IXHEAACE_QMF_CHANNELS][2] = {{0}};
|
||||
cov_count = ptr_master_tab[0];
|
||||
|
||||
for (k = 1; k < cov_count; k++) {
|
||||
ixheaace_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 < ptr_master_tab[num_mf_bands]) {
|
||||
for (index = 0; (ptr_master_tab[index] < goal_sb); index++)
|
||||
goal_sb = ptr_master_tab[index];
|
||||
} else {
|
||||
goal_sb = ptr_master_tab[num_mf_bands];
|
||||
}
|
||||
}
|
||||
|
||||
source_start_band = xover_offset + 1;
|
||||
|
||||
sb = lsb + xover_offset;
|
||||
|
||||
patch = 0;
|
||||
while (sb < usb) {
|
||||
if (IXHEAACE_MAX_NUM_PATCHES <= patch) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_NUM_PATCH;
|
||||
}
|
||||
|
||||
num_bands_in_patch = goal_sb - sb;
|
||||
|
||||
if (num_bands_in_patch + source_start_band >= lsb) {
|
||||
patch_stride = sb - source_start_band;
|
||||
patch_stride = patch_stride & ~1;
|
||||
num_bands_in_patch = lsb - (sb - patch_stride);
|
||||
num_bands_in_patch = ixheaace_find_closest_entry(sb + num_bands_in_patch, ptr_master_tab,
|
||||
(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++) {
|
||||
if (k2 < 0 || k2 >= 64) {
|
||||
break;
|
||||
}
|
||||
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++;
|
||||
if (bw_index >= IXHEAACE_MAX_NOISE_COEFFS) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_BANDWIDTH_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
if (bw_index >= IXHEAACE_MAX_NUM_PATCHES) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_BANDWIDTH_INDEX;
|
||||
}
|
||||
bw = ptr_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 = ptr_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;
|
||||
if (NULL == ptr_ph_vocod_buf_real || NULL == ptr_ph_vocod_buf_imag) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_VOCOD_BUF;
|
||||
}
|
||||
|
||||
for (k2 = sub_band_start; k2 < ptr_master_tab[num_mf_bands]; k2++) {
|
||||
ixheaace_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++;
|
||||
if (bw_index >= IXHEAACE_MAX_NOISE_COEFFS) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_BANDWIDTH_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
if (bw_index >= IXHEAACE_MAX_NUM_PATCHES) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_BANDWIDTH_INDEX;
|
||||
}
|
||||
bw = ptr_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;
|
||||
|
||||
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];
|
||||
ptr_dst_buf_real[i][k2] = ptr_ph_vocod_buf_real[i][k2] +
|
||||
((a0r * real1 - a0i * imag1) + (a1r * real2 - a1i * imag2));
|
||||
ptr_dst_buf_imag[i][k2] = ptr_ph_vocod_buf_imag[i][k2] +
|
||||
((a0i * real1 + a0r * imag1) + (a1i * real2 + a1r * imag2));
|
||||
}
|
||||
} 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (patch >= (IXHEAACE_MAX_NUM_PATCHES + 1)) {
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_NUM_PATCH;
|
||||
}
|
||||
for (i = 0; i < num_if_bands; i++) {
|
||||
ptr_bw_array_prev[i] = ptr_bw_array[i];
|
||||
}
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
IA_ERRORCODE ixheaace_process_inter_tes(ixheaace_str_inter_tes_params *pstr_tes_enc,
|
||||
WORD8 *ptr_scr) {
|
||||
WORD32 gi = 0, env, tes_enable = 0, ts, bd, start_ts, stop_ts;
|
||||
WORD32 is_sound_activity[IXHEAACE_MAX_ENVELOPES] = {0},
|
||||
is_transient[IXHEAACE_MAX_ENVELOPES] = {0};
|
||||
WORD32 tes_shape_mode = 0;
|
||||
WORD32 num_samples, num_bands;
|
||||
WORD32 len;
|
||||
IA_ERRORCODE status = IA_NO_ERROR;
|
||||
FLOAT32 energy_high[64] = {0};
|
||||
FLOAT32 energy[64] = {0};
|
||||
FLOAT32 gamma[IXHEAACE_ESBR_NUM_GAMMA_IDXS] = {0};
|
||||
FLOAT32 gamma_min = MAX_FLT_VAL;
|
||||
ixheaace_str_inter_tes_scr *tes_scr = (ixheaace_str_inter_tes_scr *)ptr_scr;
|
||||
num_bands = pstr_tes_enc->sub_band_end - pstr_tes_enc->sub_band_start;
|
||||
|
||||
for (env = 0; env < pstr_tes_enc->num_env; env++) {
|
||||
tes_shape_mode = 0;
|
||||
len = 2 * (pstr_tes_enc->border_vec[env + 1] - pstr_tes_enc->border_vec[env]);
|
||||
is_sound_activity[env] = ixheaace_inter_tes_sound_activity(
|
||||
&pstr_tes_enc
|
||||
->qmf_buf_real[IXHEAACE_SBR_HF_ADJ_OFFSET + 2 * pstr_tes_enc->border_vec[env]],
|
||||
&pstr_tes_enc
|
||||
->qmf_buf_imag[IXHEAACE_SBR_HF_ADJ_OFFSET + 2 * pstr_tes_enc->border_vec[env]],
|
||||
&energy_high[IXHEAACE_SBR_HF_ADJ_OFFSET + 2 * pstr_tes_enc->border_vec[env]], len,
|
||||
pstr_tes_enc->sub_band_start, pstr_tes_enc->sub_band_end, &is_transient[env]);
|
||||
if (1 == is_transient[env] && 1 == is_sound_activity[env]) {
|
||||
tes_enable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (1 == tes_enable) {
|
||||
status = ixheaace_generate_hf(&pstr_tes_enc->qmf_buf_real[IXHEAACE_SBR_HF_ADJ_OFFSET],
|
||||
&pstr_tes_enc->qmf_buf_imag[IXHEAACE_SBR_HF_ADJ_OFFSET], NULL,
|
||||
NULL, &tes_scr->dst_qmf_r[IXHEAACE_SBR_HF_ADJ_OFFSET],
|
||||
&tes_scr->dst_qmf_i[IXHEAACE_SBR_HF_ADJ_OFFSET], pstr_tes_enc);
|
||||
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
for (env = 0; env < pstr_tes_enc->num_env; env++) {
|
||||
if ((1 == is_sound_activity[env]) && (1 == is_transient[env])) {
|
||||
num_samples = (pstr_tes_enc->border_vec[env + 1] - pstr_tes_enc->border_vec[env]) * 2;
|
||||
start_ts = IXHEAACE_SBR_HF_ADJ_OFFSET + pstr_tes_enc->border_vec[env] * 2;
|
||||
stop_ts = start_ts + num_samples;
|
||||
|
||||
for (gi = 0; gi < IXHEAACE_ESBR_NUM_GAMMA_IDXS; gi++) {
|
||||
ixheaace_apply_inter_tes(
|
||||
&tes_scr
|
||||
->dst_qmf_r[IXHEAACE_SBR_HF_ADJ_OFFSET + 2 * pstr_tes_enc->border_vec[env]][0],
|
||||
&tes_scr
|
||||
->dst_qmf_i[IXHEAACE_SBR_HF_ADJ_OFFSET + 2 * pstr_tes_enc->border_vec[env]][0],
|
||||
&pstr_tes_enc->qmf_buf_real[IXHEAACE_SBR_HF_ADJ_OFFSET +
|
||||
2 * pstr_tes_enc->border_vec[env]][0],
|
||||
&pstr_tes_enc->qmf_buf_imag[IXHEAACE_SBR_HF_ADJ_OFFSET +
|
||||
2 * pstr_tes_enc->border_vec[env]][0],
|
||||
num_samples, pstr_tes_enc->sub_band_start, num_bands, gi);
|
||||
for (ts = start_ts; ts < stop_ts; ts++) {
|
||||
energy[ts] = 0.0f;
|
||||
for (bd = pstr_tes_enc->sub_band_start; bd < pstr_tes_enc->sub_band_end; bd++) {
|
||||
energy[ts] += tes_scr->dst_qmf_r[ts][bd] * tes_scr->dst_qmf_r[ts][bd];
|
||||
energy[ts] += tes_scr->dst_qmf_i[ts][bd] * tes_scr->dst_qmf_i[ts][bd];
|
||||
}
|
||||
gamma[gi] += (FLOAT32)fabs(energy[ts] - energy_high[ts]) /
|
||||
(FLOAT32)(pow((energy_high[ts] + 1e-6f), 0.9f));
|
||||
}
|
||||
if (gamma[gi] < gamma_min) {
|
||||
gamma_min = gamma[gi];
|
||||
tes_shape_mode = gi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tes_shape_mode > 0) {
|
||||
pstr_tes_enc->bs_tes_shape[env] = 1;
|
||||
pstr_tes_enc->bs_tes_shape_mode[env] = tes_shape_mode;
|
||||
} else {
|
||||
pstr_tes_enc->bs_tes_shape[env] = 0;
|
||||
pstr_tes_enc->bs_tes_shape_mode[env] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (env = 0; env < pstr_tes_enc->num_env; env++) {
|
||||
pstr_tes_enc->bs_tes_shape[env] = 0;
|
||||
pstr_tes_enc->bs_tes_shape_mode[env] = 0;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
115
encoder/iusace_esbr_inter_tes.h
Normal file
115
encoder/iusace_esbr_inter_tes.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define IXHEAACE_ESBR_TES_ENERGY_MAX_THR (1.0e6f)
|
||||
#define IXHEAACE_TIMESLOT_BUFFER_SIZE (78)
|
||||
#define IXHEAACE_MAX_ENVELOPES (8)
|
||||
#define IXHEAACE_MAX_NOISE_ENVELOPES (2)
|
||||
#define IXHEAACE_MAX_NOISE_COEFFS (5)
|
||||
#define IXHEAACE_MAX_NUM_NOISE_VALUES (IXHEAACE_MAX_NOISE_ENVELOPES * IXHEAACE_MAX_NOISE_COEFFS)
|
||||
#define IXHEAACE_MAX_FREQ_COEFFS (56)
|
||||
#define IXHEAACE_MAX_NUM_PATCHES (6)
|
||||
#define IXHEAACE_MAX_NUM_LIMITERS (12)
|
||||
#define IXHEAACE_MAXDEG (3)
|
||||
#define IXHEAACE_SBR_HF_RELAXATION_PARAM (0.999999f)
|
||||
#define IXHEAACE_ESBR_NUM_GAMMA_IDXS (4)
|
||||
#define IXHEAACE_ESBR_HBE_DELAY_OFFSET (32)
|
||||
#define IXHEAACE_SBR_HF_ADJ_OFFSET (2)
|
||||
#define IXHEAACE_SBR_TES_SHAPE_BITS (1)
|
||||
#define IXHEAACE_SBR_TES_SHAPE_MODE_BITS (2)
|
||||
|
||||
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;
|
||||
} ixheaace_str_auto_corr_ele;
|
||||
|
||||
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[IXHEAACE_MAX_NUM_LIMITERS + 1];
|
||||
WORD16 num_lf_bands;
|
||||
WORD16 num_if_bands;
|
||||
WORD16 *ptr_freq_band_tab[2];
|
||||
WORD16 freq_band_tbl_lo[IXHEAACE_MAX_FREQ_COEFFS / 2 + 1];
|
||||
WORD16 freq_band_tbl_hi[IXHEAACE_MAX_FREQ_COEFFS + 1];
|
||||
WORD16 freq_band_tbl_noise[IXHEAACE_MAX_NOISE_COEFFS + 1];
|
||||
WORD16 f_master_tbl[IXHEAACE_MAX_FREQ_COEFFS + 1];
|
||||
WORD16 qmf_sb_prev;
|
||||
} ia_str_freq_band_data;
|
||||
|
||||
typedef struct {
|
||||
WORD16 frame_class;
|
||||
WORD16 num_env;
|
||||
WORD16 transient_env;
|
||||
WORD16 num_noise_env;
|
||||
WORD16 border_vec[IXHEAACE_MAX_ENVELOPES + 1];
|
||||
WORD16 freq_res[IXHEAACE_MAX_ENVELOPES];
|
||||
WORD16 noise_border_vec[IXHEAACE_MAX_NOISE_ENVELOPES + 1];
|
||||
} ia_str_frame_info;
|
||||
|
||||
typedef struct {
|
||||
WORD32 num_if_bands;
|
||||
WORD32 sub_band_start;
|
||||
WORD32 sub_band_end;
|
||||
WORD32 num_mf_bands;
|
||||
WORD32 sbr_patching_mode;
|
||||
WORD32 pre_proc_flag;
|
||||
WORD32 is_usf_4;
|
||||
WORD32 hbe_flag;
|
||||
WORD32 out_fs;
|
||||
WORD32 num_env;
|
||||
WORD32 op_delay;
|
||||
WORD32 codec_delay;
|
||||
WORD32 sbr_ratio_index;
|
||||
WORD16 invf_band_tbl[MAXIMUM_NUM_NOISE_VALUES + 1];
|
||||
WORD16 f_master_tbl[MAXIMUM_FREQ_COEFFS + 1];
|
||||
WORD32 inv_filt_mode[MAXIMUM_NUM_NOISE_VALUES];
|
||||
WORD32 inv_filt_mode_prev[IXHEAACE_MAX_NUM_NOISE_VALUES];
|
||||
FLOAT32 bw_array_prev[IXHEAACE_MAX_NUM_PATCHES];
|
||||
WORD16 border_vec[IXHEAACE_MAX_ENV + 1];
|
||||
WORD32 bs_tes_shape[IXHEAACE_MAX_ENV + 1];
|
||||
WORD32 bs_tes_shape_mode[IXHEAACE_MAX_ENV + 1];
|
||||
FLOAT32 qmf_buf_real[IXHEAACE_TIMESLOT_BUFFER_SIZE + 2 * IXHEAACE_ESBR_HBE_DELAY_OFFSET]
|
||||
[IXHEAACE_QMF_CHANNELS];
|
||||
FLOAT32 qmf_buf_imag[IXHEAACE_TIMESLOT_BUFFER_SIZE + 2 * IXHEAACE_ESBR_HBE_DELAY_OFFSET]
|
||||
[IXHEAACE_QMF_CHANNELS];
|
||||
} ixheaace_str_inter_tes_params;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 dst_qmf_r[IXHEAACE_TIMESLOT_BUFFER_SIZE][IXHEAACE_QMF_CHANNELS];
|
||||
FLOAT32 dst_qmf_i[IXHEAACE_TIMESLOT_BUFFER_SIZE][IXHEAACE_QMF_CHANNELS];
|
||||
} ixheaace_str_inter_tes_scr;
|
||||
|
||||
VOID ixheaace_init_esbr_inter_tes(ixheaace_str_inter_tes_params *pstr_tes_enc,
|
||||
WORD32 sbr_ratio_index);
|
||||
IA_ERRORCODE ixheaace_process_inter_tes(ixheaace_str_inter_tes_params *pstr_tes_enc,
|
||||
WORD8 *ptr_scr);
|
||||
426
encoder/iusace_esbr_pvc.c
Normal file
426
encoder/iusace_esbr_pvc.c
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "ixheaac_basic_ops32.h"
|
||||
#include "ixheaac_basic_ops16.h"
|
||||
#include "ixheaac_basic_ops40.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
#include "ixheaace_bitbuffer.h"
|
||||
#include "iusace_esbr_pvc.h"
|
||||
#include "ixheaace_common_utils.h"
|
||||
#include "ixheaace_sbr_cmondata.h"
|
||||
|
||||
IA_ERRORCODE ixheaace_pvc_enc_init(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 sbr_pvc_rate) {
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_flag = IXHEAACE_ESBR_PVC_FLAG_PREV_DFLT;
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_id = IXHEAACE_ESBR_PVC_ID_PREV_DFLT;
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_rate = IXHEAACE_ESBR_PVC_RATE_PREV_DFLT;
|
||||
pstr_pvc_enc->pvc_prv_param.start_band = IXHEAACE_ESBR_PVC_STRT_BAND_PREV_DFLT;
|
||||
pstr_pvc_enc->pvc_param.pvc_rate = (UWORD8)sbr_pvc_rate;
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
static VOID ixheaace_pvc_sb_grouping(ixheaace_pvc_enc *pstr_pvc_enc, UWORD8 start_band,
|
||||
FLOAT32 *ptr_qmf_low, FLOAT32 *ptr_sb_grp_energy,
|
||||
WORD32 first_pvc_ts) {
|
||||
WORD32 ksg, ts, band;
|
||||
FLOAT32 tmp_sb_grp_energy;
|
||||
WORD32 lbw, sb;
|
||||
WORD32 nqmf_lb;
|
||||
FLOAT32 *ptr_tmp_qmfl;
|
||||
|
||||
ixheaace_pvc_params *pstr_params = &pstr_pvc_enc->pvc_param;
|
||||
ixheaace_pvc_prv_frm_params *pstr_prv_params = &pstr_pvc_enc->pvc_prv_param;
|
||||
|
||||
nqmf_lb = IXHEAACE_ESBR_PVC_NUM_QMF_BANDS / pstr_params->pvc_rate;
|
||||
lbw = 8 / pstr_params->pvc_rate;
|
||||
|
||||
for (ts = 0; ts < IXHEAACE_ESBR_PVC_NUM_TS; ts++) {
|
||||
sb = start_band - lbw * pstr_params->num_grp_core;
|
||||
ksg = 0;
|
||||
while (ksg < pstr_params->num_grp_core) {
|
||||
tmp_sb_grp_energy = 0.0f;
|
||||
if (sb >= 0) {
|
||||
ptr_tmp_qmfl = &ptr_qmf_low[ts * nqmf_lb + sb];
|
||||
band = 0;
|
||||
while (band < lbw) {
|
||||
tmp_sb_grp_energy += ptr_tmp_qmfl[band];
|
||||
band++;
|
||||
}
|
||||
tmp_sb_grp_energy /= lbw;
|
||||
}
|
||||
|
||||
tmp_sb_grp_energy = max(IXHEAACE_ESBR_PVC_POW_THRS, tmp_sb_grp_energy);
|
||||
ptr_sb_grp_energy[(ts + IXHEAACE_ESBR_PVC_NUM_TS - 1) * 3 + ksg] =
|
||||
10 * (FLOAT32)log10(tmp_sb_grp_energy);
|
||||
sb += lbw;
|
||||
ksg++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pstr_prv_params->pvc_flag == 0) ||
|
||||
((start_band * pstr_params->pvc_rate) !=
|
||||
(pstr_prv_params->start_band * pstr_prv_params->pvc_rate))) {
|
||||
for (ts = 0; ts < IXHEAACE_ESBR_PVC_NUM_TS - 1 + first_pvc_ts; ts++) {
|
||||
memcpy(&ptr_sb_grp_energy[ts * 3],
|
||||
&ptr_sb_grp_energy[(IXHEAACE_ESBR_PVC_NUM_TS - 1 + first_pvc_ts) * 3],
|
||||
pstr_params->num_grp_core * sizeof(ptr_sb_grp_energy[0]));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static IA_ERRORCODE ixheaace_set_pvc_mode_param(ixheaace_pvc_params *pstr_pvc_param,
|
||||
ixheaace_pvc_coef_tabs *pstr_pvc_tabs) {
|
||||
pstr_pvc_param->num_grp_core = IXHEAACE_ESBR_PVC_NUM_BANDS_CORE;
|
||||
pstr_pvc_param->num_pvc_id = IXHEAACE_ESBR_PVC_NUM_PVCID;
|
||||
|
||||
switch (pstr_pvc_param->pvc_mode) {
|
||||
case IXHEAACE_ESBR_PVC_MODE_1:
|
||||
pstr_pvc_param->num_grp_sbr = IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1;
|
||||
pstr_pvc_param->hbw = 8 / pstr_pvc_param->pvc_rate;
|
||||
pstr_pvc_tabs->pvc_pred_coef_kb_012 =
|
||||
(UWORD8 *)ixheaace_pvc_tabs.pvc_prd_coef_kb_012_mode_1;
|
||||
pstr_pvc_tabs->pvc_pred_coef_kb_3 = (UWORD8 *)ixheaace_pvc_tabs.pvc_prd_coef_kb_3_mode_1;
|
||||
pstr_pvc_tabs->pvc_idx_tab = ixheaace_pvc_tabs.pvc_idx_mode_1;
|
||||
pstr_pvc_tabs->scaling_coef = ixheaace_pvc_tabs.pvc_scaling_coef_mode_1;
|
||||
break;
|
||||
|
||||
case IXHEAACE_ESBR_PVC_MODE_2:
|
||||
pstr_pvc_param->num_grp_sbr = IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2;
|
||||
pstr_pvc_param->hbw = 12 / pstr_pvc_param->pvc_rate;
|
||||
pstr_pvc_tabs->pvc_pred_coef_kb_012 =
|
||||
(UWORD8 *)ixheaace_pvc_tabs.pvc_prd_coef_kb_012_mode_2;
|
||||
pstr_pvc_tabs->pvc_pred_coef_kb_3 = (UWORD8 *)ixheaace_pvc_tabs.pvc_prd_coef_kb_3_mode_2;
|
||||
pstr_pvc_tabs->pvc_idx_tab = ixheaace_pvc_tabs.pvc_idx_mode_2;
|
||||
pstr_pvc_tabs->scaling_coef = ixheaace_pvc_tabs.pvc_scaling_coef_mode_2;
|
||||
break;
|
||||
|
||||
default:
|
||||
return IA_EXHEAACE_EXE_NONFATAL_ESBR_INVALID_PVC_MODE;
|
||||
}
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
static VOID ixheaace_pvc_sb_grouping_ref(ixheaace_pvc_params *pstr_pvc_param, UWORD8 start_band,
|
||||
UWORD8 stop_band, FLOAT32 *ptr_qmf_high,
|
||||
FLOAT32 *ptr_sb_grp_energy) {
|
||||
WORD32 ksg, ts, band;
|
||||
UWORD8 min_sb;
|
||||
WORD32 sb, eb;
|
||||
FLOAT32 tmp_sb_grp_energy;
|
||||
|
||||
min_sb = start_band + pstr_pvc_param->num_grp_sbr * pstr_pvc_param->hbw - 1;
|
||||
stop_band = max(stop_band, min_sb);
|
||||
|
||||
for (ts = 0; ts < IXHEAACE_ESBR_PVC_NUM_TS; ts++) {
|
||||
sb = start_band;
|
||||
eb = min((sb + pstr_pvc_param->hbw - 1), (IXHEAACE_ESBR_PVC_NUM_QMF_BANDS - 1));
|
||||
|
||||
for (ksg = 0; ksg < (pstr_pvc_param->num_grp_sbr - 2); ksg++) {
|
||||
tmp_sb_grp_energy = 0.0f;
|
||||
band = sb;
|
||||
while (band <= eb) {
|
||||
tmp_sb_grp_energy += ptr_qmf_high[ts * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS + band];
|
||||
band++;
|
||||
}
|
||||
tmp_sb_grp_energy = tmp_sb_grp_energy / (eb - sb + 1);
|
||||
|
||||
ptr_sb_grp_energy[ts * pstr_pvc_param->num_grp_sbr + ksg] =
|
||||
max(IXHEAACE_ESBR_PVC_POW_THRS, tmp_sb_grp_energy);
|
||||
sb += pstr_pvc_param->hbw;
|
||||
eb = min((sb + pstr_pvc_param->hbw - 1), stop_band);
|
||||
eb = min(eb, (IXHEAACE_ESBR_PVC_NUM_QMF_BANDS - 1));
|
||||
}
|
||||
|
||||
while (ksg < pstr_pvc_param->num_grp_sbr) {
|
||||
tmp_sb_grp_energy = 0.0f;
|
||||
band = sb;
|
||||
while (band <= eb) {
|
||||
tmp_sb_grp_energy += ptr_qmf_high[ts * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS + band];
|
||||
band++;
|
||||
}
|
||||
tmp_sb_grp_energy = tmp_sb_grp_energy / (eb - sb + 1);
|
||||
|
||||
ptr_sb_grp_energy[ts * pstr_pvc_param->num_grp_sbr + ksg] =
|
||||
max(IXHEAACE_ESBR_PVC_POW_THRS, tmp_sb_grp_energy);
|
||||
sb += pstr_pvc_param->hbw;
|
||||
eb = min(stop_band, (IXHEAACE_ESBR_PVC_NUM_QMF_BANDS - 1));
|
||||
ksg++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID ixheaace_pvc_calc_grp_energy_below_sbr(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 ts,
|
||||
FLOAT32 *ptr_sb_grp_ene_blsbr) {
|
||||
WORD32 ksg = 0, idx;
|
||||
ixheaace_pvc_params *pstr_pvc_params = &pstr_pvc_enc->pvc_param;
|
||||
|
||||
memset(ptr_sb_grp_ene_blsbr, 0,
|
||||
pstr_pvc_params->num_grp_core * sizeof(ptr_sb_grp_ene_blsbr[0]));
|
||||
|
||||
while (ksg < pstr_pvc_params->num_grp_core) {
|
||||
for (idx = 0; idx < pstr_pvc_params->time_smth_ts; idx++) {
|
||||
ptr_sb_grp_ene_blsbr[ksg] +=
|
||||
pstr_pvc_enc->sb_grp_energy[ts + IXHEAACE_ESBR_PVC_NUM_TS - 1 - idx][ksg] *
|
||||
pstr_pvc_enc->pvc_tabs.smoothing_coef[idx];
|
||||
}
|
||||
ksg++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID ixheaace_pvc_predict(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 ts,
|
||||
FLOAT32 *ptr_sb_grp_ene_blsbr, FLOAT32 *ptr_sb_grp_energy_high) {
|
||||
ixheaace_pvc_params *pstr_pvc_params = &(pstr_pvc_enc->pvc_param);
|
||||
ixheaace_pvc_coef_tabs *pstr_pvc_tabs = &(pstr_pvc_enc->pvc_tabs);
|
||||
|
||||
WORD32 ksg, kb, idx_tab_1, idx_tab_2;
|
||||
const UWORD8 *ptr_tab;
|
||||
FLOAT32 prod;
|
||||
|
||||
idx_tab_2 = pstr_pvc_params->pvc_id[ts];
|
||||
|
||||
if (idx_tab_2 < pstr_pvc_tabs->pvc_idx_tab[0]) {
|
||||
idx_tab_1 = 0;
|
||||
} else if (idx_tab_2 < pstr_pvc_tabs->pvc_idx_tab[1]) {
|
||||
idx_tab_1 = 1;
|
||||
} else {
|
||||
idx_tab_1 = 2;
|
||||
}
|
||||
|
||||
memset(ptr_sb_grp_energy_high, 0,
|
||||
pstr_pvc_params->num_grp_sbr * sizeof(ptr_sb_grp_energy_high[0]));
|
||||
|
||||
ptr_tab = &(pstr_pvc_tabs->pvc_pred_coef_kb_012[idx_tab_1 * pstr_pvc_params->num_grp_core *
|
||||
pstr_pvc_params->num_grp_sbr]);
|
||||
|
||||
for (kb = 0; kb < pstr_pvc_params->num_grp_core; kb++) {
|
||||
prod = pstr_pvc_tabs->scaling_coef[kb] * ptr_sb_grp_ene_blsbr[kb];
|
||||
for (ksg = 0; ksg < pstr_pvc_params->num_grp_sbr; ksg++) {
|
||||
ptr_sb_grp_energy_high[ksg] += ((FLOAT32)(WORD8)(*(ptr_tab++)) * prod);
|
||||
}
|
||||
}
|
||||
|
||||
ptr_tab = &(pstr_pvc_tabs->pvc_pred_coef_kb_3[idx_tab_2 * pstr_pvc_params->num_grp_sbr]);
|
||||
prod = pstr_pvc_tabs->scaling_coef[pstr_pvc_params->num_grp_core];
|
||||
|
||||
for (ksg = 0; ksg < pstr_pvc_params->num_grp_sbr; ksg++) {
|
||||
ptr_sb_grp_energy_high[ksg] += (FLOAT32)(WORD8)(*(ptr_tab++)) * prod;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID ixheaace_pvc_packing(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 const usac_indep_flag) {
|
||||
UWORD16 *ptr_pvc_bs;
|
||||
ixheaace_pvc_params *pstr_params = &pstr_pvc_enc->pvc_param;
|
||||
ixheaace_pvc_prv_frm_params *pstr_prv_params = &pstr_pvc_enc->pvc_prv_param;
|
||||
ixheaace_pvc_bs_info *pstr_pvc_bs_info = &pstr_pvc_enc->pvc_bs_info;
|
||||
|
||||
ptr_pvc_bs = pstr_pvc_bs_info->pvc_id_bs;
|
||||
|
||||
pstr_pvc_bs_info->ns_mode = pstr_params->ns_mode;
|
||||
|
||||
if ((usac_indep_flag == 1) || (pstr_params->pvc_id[1] != pstr_prv_params->pvc_id)) {
|
||||
pstr_pvc_bs_info->grid_info[0] = 1;
|
||||
*(ptr_pvc_bs++) = pstr_params->pvc_id[0];
|
||||
} else {
|
||||
pstr_pvc_bs_info->grid_info[0] = 0;
|
||||
}
|
||||
|
||||
if (pstr_params->pvc_id[8] == pstr_params->pvc_id[7]) {
|
||||
pstr_pvc_bs_info->div_mode = 0;
|
||||
} else {
|
||||
pstr_pvc_bs_info->div_mode = 4;
|
||||
pstr_pvc_bs_info->num_grid_info = 2;
|
||||
pstr_pvc_bs_info->grid_info[1] = 1;
|
||||
*(ptr_pvc_bs++) = pstr_params->pvc_id[8];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static FLOAT32 ixheaace_pvc_calc_res(FLOAT32 *ptr_org, FLOAT32 *ptr_prd, UWORD8 ng_sb_sbr) {
|
||||
FLOAT32 residual = 0, diff;
|
||||
WORD32 band = 0;
|
||||
|
||||
while (band < ng_sb_sbr) {
|
||||
diff = ptr_org[band] - ptr_prd[band];
|
||||
residual += diff * diff;
|
||||
band++;
|
||||
}
|
||||
residual = (FLOAT32)sqrt(residual);
|
||||
|
||||
return residual;
|
||||
}
|
||||
|
||||
VOID ixheaace_pvc_calc_grp_energy(ixheaace_pvc_enc *pstr_pvc_enc,
|
||||
FLOAT32 *ptr_sb_grp_energy_hi_ref) {
|
||||
WORD32 ts, res_init_flg = 1, pvc_id, i;
|
||||
FLOAT32 res_all[128] = {0}, res_min, sb_grp_energy_blwsbr[3], sb_grp_energy_hi[8], res = 0;
|
||||
UWORD16 *ptr_pvc_id, tmp = 0;
|
||||
|
||||
ptr_pvc_id = pstr_pvc_enc->pvc_param.pvc_id;
|
||||
for (ts = 0; ts < IXHEAACE_ESBR_PVC_NUM_TS; ts++) {
|
||||
ixheaace_pvc_calc_grp_energy_below_sbr(pstr_pvc_enc, ts, sb_grp_energy_blwsbr);
|
||||
for (pvc_id = 0; pvc_id < pstr_pvc_enc->pvc_param.num_pvc_id; pvc_id++) {
|
||||
pstr_pvc_enc->pvc_param.pvc_id[ts] = (UWORD16)pvc_id;
|
||||
ixheaace_pvc_predict(pstr_pvc_enc, ts, sb_grp_energy_blwsbr, sb_grp_energy_hi);
|
||||
|
||||
res = ixheaace_pvc_calc_res(
|
||||
&(ptr_sb_grp_energy_hi_ref[ts * pstr_pvc_enc->pvc_param.num_grp_sbr]), sb_grp_energy_hi,
|
||||
pstr_pvc_enc->pvc_param.num_grp_sbr);
|
||||
if (res_init_flg) {
|
||||
res_all[pvc_id] = res;
|
||||
} else {
|
||||
res_all[pvc_id] += res;
|
||||
}
|
||||
}
|
||||
|
||||
res_init_flg = 0;
|
||||
if ((ts & (IXHEAACE_ESBR_PVC_NTS_GRP_ID - 1)) == (IXHEAACE_ESBR_PVC_NTS_GRP_ID - 1)) {
|
||||
res_min = IXHEAACE_ESBR_PVC_RESIDUAL_VAL;
|
||||
pvc_id = 0;
|
||||
while (pvc_id < pstr_pvc_enc->pvc_param.num_pvc_id) {
|
||||
if (res_all[pvc_id] < res_min) {
|
||||
tmp = (UWORD16)pvc_id;
|
||||
res_min = res_all[pvc_id];
|
||||
}
|
||||
pvc_id++;
|
||||
}
|
||||
for (i = 0; i < IXHEAACE_ESBR_PVC_NTS_GRP_ID; i++) {
|
||||
*(ptr_pvc_id++) = tmp;
|
||||
}
|
||||
res_init_flg = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (ts = 0; ts < 15; ts++) {
|
||||
memcpy(&pstr_pvc_enc->sb_grp_energy[ts][0],
|
||||
&pstr_pvc_enc->sb_grp_energy[ts + IXHEAACE_ESBR_PVC_NUM_TS][0],
|
||||
IXHEAACE_ESBR_PVC_NUM_BANDS_CORE * sizeof(pstr_pvc_enc->sb_grp_energy[ts][0]));
|
||||
}
|
||||
}
|
||||
|
||||
VOID ixheaace_pvc_calc_ref_ene_update_tabs(ixheaace_pvc_enc *pstr_pvc_enc,
|
||||
FLOAT32 *ptr_sb_grp_energy_hi_ref) {
|
||||
WORD32 ts, band;
|
||||
FLOAT32 sum, prev_sum = 0;
|
||||
pstr_pvc_enc->pvc_param.ns_mode = 0;
|
||||
|
||||
switch (pstr_pvc_enc->pvc_param.pvc_mode) {
|
||||
case 1: {
|
||||
pstr_pvc_enc->pvc_param.time_smth_ts = IXHEAACE_ESBR_PVC_NUM_TS;
|
||||
pstr_pvc_enc->pvc_tabs.smoothing_coef = ixheaace_pvc_tabs.pvc_smth_win_ns_16;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
pstr_pvc_enc->pvc_param.time_smth_ts = 12;
|
||||
pstr_pvc_enc->pvc_tabs.smoothing_coef = ixheaace_pvc_tabs.pvc_smth_win_ns_12;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// No assignment
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (ts = 0; ts < IXHEAACE_ESBR_PVC_NUM_TS; ts++) {
|
||||
FLOAT32 *ptr_grp_energy =
|
||||
&(ptr_sb_grp_energy_hi_ref[ts * pstr_pvc_enc->pvc_param.num_grp_sbr]);
|
||||
sum = 0.0f;
|
||||
for (band = 0; band < pstr_pvc_enc->pvc_param.num_grp_sbr; band++) {
|
||||
sum += *ptr_grp_energy;
|
||||
|
||||
*ptr_grp_energy = 10 * (FLOAT32)log10(*ptr_grp_energy);
|
||||
ptr_grp_energy++;
|
||||
}
|
||||
if (ts && (sum > prev_sum * IXHEAACE_ESBR_PVC_NS_MODE_PRD_THRS)) {
|
||||
pstr_pvc_enc->pvc_param.ns_mode = 1;
|
||||
}
|
||||
prev_sum = sum;
|
||||
}
|
||||
|
||||
if (pstr_pvc_enc->pvc_param.ns_mode == 1) {
|
||||
switch (pstr_pvc_enc->pvc_param.pvc_mode) {
|
||||
case 1: {
|
||||
pstr_pvc_enc->pvc_param.time_smth_ts = 4;
|
||||
pstr_pvc_enc->pvc_tabs.smoothing_coef = ixheaace_pvc_tabs.pvc_smth_win_ns_4;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
pstr_pvc_enc->pvc_param.time_smth_ts = 3;
|
||||
pstr_pvc_enc->pvc_tabs.smoothing_coef = ixheaace_pvc_tabs.pvc_smth_win_ns_3;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// No assignment
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IA_ERRORCODE ixheaace_pvc_encode_frame(ixheaace_pvc_enc *pstr_pvc_enc, UWORD8 pvc_mode,
|
||||
FLOAT32 *ptr_qmf_low, FLOAT32 *ptr_qmf_high,
|
||||
UWORD8 start_band, UWORD8 stop_band) {
|
||||
IA_ERRORCODE ret;
|
||||
FLOAT32 sb_grp_energy_hi_ref[IXHEAACE_ESBR_PVC_NUM_TS * 8];
|
||||
|
||||
pstr_pvc_enc->pvc_param.pvc_mode = pvc_mode;
|
||||
/* PVC encoding process */
|
||||
if (pstr_pvc_enc->pvc_param.pvc_mode) {
|
||||
ret = ixheaace_set_pvc_mode_param(&(pstr_pvc_enc->pvc_param), &(pstr_pvc_enc->pvc_tabs));
|
||||
if (IA_NO_ERROR != ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ixheaace_pvc_sb_grouping(pstr_pvc_enc, start_band, ptr_qmf_low,
|
||||
(FLOAT32 *)pstr_pvc_enc->sb_grp_energy, 0);
|
||||
|
||||
ixheaace_pvc_sb_grouping_ref(&(pstr_pvc_enc->pvc_param), start_band, stop_band, ptr_qmf_high,
|
||||
sb_grp_energy_hi_ref);
|
||||
ixheaace_pvc_calc_ref_ene_update_tabs(pstr_pvc_enc, sb_grp_energy_hi_ref);
|
||||
|
||||
ixheaace_pvc_calc_grp_energy(pstr_pvc_enc, sb_grp_energy_hi_ref);
|
||||
|
||||
ixheaace_pvc_packing(pstr_pvc_enc, pstr_pvc_enc->pvc_param.usac_indep_flag);
|
||||
}
|
||||
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_id =
|
||||
(pstr_pvc_enc->pvc_param.pvc_mode == 0)
|
||||
? 0xFF
|
||||
: pstr_pvc_enc->pvc_param.pvc_id[IXHEAACE_ESBR_PVC_NUM_TS - 1];
|
||||
pstr_pvc_enc->pvc_prv_param.start_band = start_band;
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_flag = (pstr_pvc_enc->pvc_param.pvc_mode == 0) ? 0 : 1;
|
||||
pstr_pvc_enc->pvc_prv_param.pvc_rate = pstr_pvc_enc->pvc_param.pvc_rate;
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
131
encoder/iusace_esbr_pvc.h
Normal file
131
encoder/iusace_esbr_pvc.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define IXHEAACE_ESBR_PVC_MOD_NUM_TAB (2)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1 (3)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2 (128)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_PVCID (128)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_TS (16)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_QMF_BANDS (64)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_QMF_BANDS_CORE (64)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_BANDS_CORE (3)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1 (8)
|
||||
#define IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2 (6)
|
||||
|
||||
#define IXHEAACE_ESBR_PVC_POW_THRS (0.1f)
|
||||
#define IXHEAACE_ESBR_PVC_NS_MODE_PRD_THRS (2)
|
||||
|
||||
#define IXHEAACE_ESBR_PVC_RESIDUAL_VAL (1000000.0f)
|
||||
#define IXHEAACE_ESBR_PVC_NTS_GRP_ID (8)
|
||||
|
||||
#define IXHEAACE_ESBR_PVC_DIV_MODE_BITS (3)
|
||||
#define IXHEAACE_ESBR_PVC_NS_MODE_BITS (1)
|
||||
#define IXHEAACE_ESBR_PVC_ID_BITS (7)
|
||||
#define IXHEAACE_ESBR_PVC_GRID_INFO_BITS (1)
|
||||
#define IXHEAACE_ESBR_PVC_REUSE_BITS (1)
|
||||
|
||||
#define IXHEAACE_ESBR_PVC_FLAG_PREV_DFLT (0)
|
||||
#define IXHEAACE_ESBR_PVC_ID_PREV_DFLT (0xFF)
|
||||
#define IXHEAACE_ESBR_PVC_RATE_PREV_DFLT (0xFF)
|
||||
#define IXHEAACE_ESBR_PVC_STRT_BAND_PREV_DFLT (0xFF)
|
||||
|
||||
#define IXHEAACE_ESBR_PVC_MODE_1 (1)
|
||||
#define IXHEAACE_ESBR_PVC_MODE_2 (2)
|
||||
|
||||
typedef struct {
|
||||
const FLOAT32 pvc_smth_win_ns_16[16];
|
||||
const FLOAT32 pvc_smth_win_ns_12[12];
|
||||
const FLOAT32 pvc_smth_win_ns_4[4];
|
||||
const FLOAT32 pvc_smth_win_ns_3[3];
|
||||
const UWORD8 pvc_idx_mode_1[IXHEAACE_ESBR_PVC_MOD_NUM_TAB];
|
||||
const UWORD8 pvc_prd_coef_kb_3_mode_1[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1];
|
||||
const UWORD8 pvc_prd_coef_kb_012_mode_1[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1];
|
||||
const FLOAT32 pvc_scaling_coef_mode_1[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE + 1];
|
||||
const UWORD8 pvc_idx_mode_2[IXHEAACE_ESBR_PVC_MOD_NUM_TAB];
|
||||
const UWORD8 pvc_prd_coef_kb_3_mode_2[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2];
|
||||
const UWORD8 pvc_prd_coef_kb_012_mode_2[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE]
|
||||
[IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2];
|
||||
const FLOAT32 pvc_scaling_coef_mode_2[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE + 1];
|
||||
} ixheaace_pvc_tabs_struct;
|
||||
|
||||
extern const ixheaace_pvc_tabs_struct ixheaace_pvc_tabs;
|
||||
|
||||
typedef struct {
|
||||
UWORD8 pvc_mode;
|
||||
UWORD8 div_mode;
|
||||
UWORD8 ns_mode;
|
||||
UWORD16 pvc_id[IXHEAACE_ESBR_PVC_NUM_TS];
|
||||
UWORD8 time_smth_ts;
|
||||
UWORD8 num_grp_core;
|
||||
UWORD8 num_grp_sbr;
|
||||
UWORD8 hbw;
|
||||
UWORD8 num_pvc_id;
|
||||
UWORD8 pvc_rate;
|
||||
WORD32 usac_indep_flag;
|
||||
} ixheaace_pvc_params;
|
||||
|
||||
typedef struct {
|
||||
UWORD16 pvc_id;
|
||||
UWORD8 start_band;
|
||||
UWORD8 pvc_flag;
|
||||
UWORD8 pvc_mode;
|
||||
UWORD8 pvc_rate;
|
||||
} ixheaace_pvc_prv_frm_params;
|
||||
|
||||
typedef struct {
|
||||
const FLOAT32 *smoothing_coef;
|
||||
const FLOAT32 *scaling_coef;
|
||||
const UWORD8 *pvc_pred_coef_kb_3;
|
||||
const UWORD8 *pvc_pred_coef_kb_012;
|
||||
const UWORD8 *pvc_idx_tab;
|
||||
} ixheaace_pvc_coef_tabs;
|
||||
|
||||
typedef struct {
|
||||
UWORD8 div_mode;
|
||||
UWORD8 grid_info[IXHEAACE_ESBR_PVC_NUM_TS];
|
||||
UWORD8 ns_mode;
|
||||
WORD32 num_grid_info;
|
||||
UWORD16 pvc_id_bs[IXHEAACE_ESBR_PVC_NUM_TS];
|
||||
} ixheaace_pvc_bs_info;
|
||||
|
||||
typedef struct {
|
||||
ixheaace_pvc_bs_info pvc_bs_info;
|
||||
ixheaace_pvc_params pvc_param;
|
||||
ixheaace_pvc_prv_frm_params pvc_prv_param;
|
||||
ixheaace_pvc_coef_tabs pvc_tabs;
|
||||
FLOAT32 sb_grp_energy[IXHEAACE_ESBR_PVC_NUM_TS + 16 - 1][3];
|
||||
} ixheaace_pvc_enc;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 pvc_qmf_low[IXHEAACE_ESBR_PVC_NUM_TS * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS_CORE];
|
||||
FLOAT32 pvc_qmf_high[IXHEAACE_ESBR_PVC_NUM_TS * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS];
|
||||
} ixheaace_pvc_scratch;
|
||||
|
||||
IA_ERRORCODE ixheaace_pvc_enc_init(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 sbr_pvc_rate);
|
||||
|
||||
IA_ERRORCODE ixheaace_pvc_encode_frame(ixheaace_pvc_enc *pstr_pvc_enc, UWORD8 pvc_mode,
|
||||
FLOAT32 *ptr_qmf_low, FLOAT32 *ptr_qmf_high,
|
||||
UWORD8 start_band, UWORD8 stop_band);
|
||||
251
encoder/iusace_esbr_pvc_rom.c
Normal file
251
encoder/iusace_esbr_pvc_rom.c
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_esbr_pvc.h"
|
||||
|
||||
const ixheaace_pvc_tabs_struct ixheaace_pvc_tabs = {
|
||||
{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},
|
||||
{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},
|
||||
{2.9233807677393114e-001f, 2.8099141963307617e-001f, 2.4582604080136389e-001f,
|
||||
1.8084446279162875e-001f},
|
||||
{3.7911649807579761e-001f, 3.5280765527510910e-001f, 2.6807584664909323e-001f},
|
||||
{17, 68},
|
||||
{{0xCB, 0xD1, 0xCC, 0xD2, 0xE2, 0xEB, 0xE7, 0xE8},
|
||||
{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80},
|
||||
{0x84, 0x8C, 0x88, 0x83, 0x90, 0x93, 0x86, 0x80},
|
||||
{0xD7, 0xD8, 0xC0, 0xC7, 0xCF, 0xE5, 0xF1, 0xF6},
|
||||
{0xA5, 0xA6, 0xAA, 0xA8, 0xB0, 0xB1, 0xB8, 0xB8},
|
||||
{0xD7, 0xCB, 0xC1, 0xC3, 0xC5, 0xC9, 0xC9, 0xCE},
|
||||
{0xCA, 0xB5, 0xB8, 0xB3, 0xAC, 0xB6, 0xBB, 0xB8},
|
||||
{0xC1, 0xC4, 0xC3, 0xC5, 0xC6, 0xCA, 0xCA, 0xCB},
|
||||
{0xE0, 0xE1, 0xD8, 0xCD, 0xCB, 0xCB, 0xCE, 0xCC},
|
||||
{0xDB, 0xE1, 0xDF, 0xDB, 0xDC, 0xD9, 0xD9, 0xD6},
|
||||
{0xE0, 0xDE, 0xDD, 0xDD, 0xE0, 0xE3, 0xE5, 0xE6},
|
||||
{0xCA, 0xD2, 0xCD, 0xCE, 0xD5, 0xDB, 0xD9, 0xDB},
|
||||
{0xD2, 0xE0, 0xDB, 0xD5, 0xDB, 0xDE, 0xE3, 0xE1},
|
||||
{0xE5, 0xDB, 0xD0, 0xD2, 0xD8, 0xDD, 0xDB, 0xDD},
|
||||
{0xC0, 0xB5, 0xBF, 0xDD, 0xE3, 0xDC, 0xDC, 0xE4},
|
||||
{0xDB, 0xCE, 0xC6, 0xCF, 0xCF, 0xD1, 0xD3, 0xD4},
|
||||
{0xC9, 0xD7, 0xDA, 0xE2, 0xE9, 0xE7, 0xDF, 0xDC},
|
||||
{0x0A, 0x07, 0x0A, 0x08, 0x19, 0x24, 0x1F, 0x22},
|
||||
{0x1E, 0x1F, 0x11, 0x0E, 0x22, 0x2D, 0x33, 0x32},
|
||||
{0xF0, 0xDA, 0xDC, 0x18, 0x1F, 0x19, 0x0A, 0x1E},
|
||||
{0x09, 0xF8, 0xE6, 0x05, 0x19, 0x11, 0x0E, 0x0B},
|
||||
{0x09, 0x10, 0x0E, 0xE6, 0xF4, 0x20, 0x22, 0xFA},
|
||||
{0xF2, 0xE5, 0xF8, 0x0E, 0x18, 0x15, 0x0D, 0x10},
|
||||
{0x15, 0x13, 0x16, 0x0A, 0x0D, 0x1F, 0x1D, 0x1B},
|
||||
{0xFA, 0xFF, 0xFE, 0xFF, 0x09, 0x11, 0x03, 0x0B},
|
||||
{0xFE, 0xFA, 0xF2, 0xF8, 0x0C, 0x1E, 0x11, 0x12},
|
||||
{0xFA, 0xF8, 0x0B, 0x17, 0x1D, 0x17, 0x0E, 0x16},
|
||||
{0x00, 0xF3, 0xFD, 0x0A, 0x1C, 0x17, 0xFD, 0x08},
|
||||
{0xEA, 0xEA, 0x03, 0x12, 0x1E, 0x14, 0x09, 0x04},
|
||||
{0x02, 0xFE, 0x04, 0xFB, 0x0C, 0x0E, 0x07, 0x02},
|
||||
{0xF6, 0x02, 0x07, 0x0B, 0x17, 0x17, 0x01, 0xFF},
|
||||
{0xF5, 0xFB, 0xFE, 0x04, 0x12, 0x14, 0x0C, 0x0D},
|
||||
{0x10, 0x10, 0x0E, 0x04, 0x07, 0x11, 0x0F, 0x13},
|
||||
{0x0C, 0x0F, 0xFB, 0xF2, 0x0A, 0x12, 0x09, 0x0D},
|
||||
{0x0D, 0x1D, 0xF1, 0xF4, 0x2A, 0x06, 0x3B, 0x32},
|
||||
{0xFC, 0x08, 0x06, 0x02, 0x0E, 0x17, 0x08, 0x0E},
|
||||
{0x07, 0x02, 0xEE, 0xEE, 0x2B, 0xF6, 0x23, 0x13},
|
||||
{0x04, 0x02, 0x05, 0x08, 0x0B, 0x0E, 0xFB, 0xFB},
|
||||
{0x00, 0x04, 0x10, 0x18, 0x22, 0x25, 0x1D, 0x1F},
|
||||
{0xFB, 0x0D, 0x07, 0x00, 0x0C, 0x0F, 0xFC, 0x02},
|
||||
{0x00, 0x00, 0x00, 0x01, 0x05, 0x07, 0x03, 0x05},
|
||||
{0x04, 0x05, 0x08, 0x13, 0xFF, 0xEB, 0x0C, 0x06},
|
||||
{0x05, 0x13, 0x0E, 0x0B, 0x12, 0x15, 0x09, 0x0A},
|
||||
{0x09, 0x03, 0x09, 0x05, 0x12, 0x16, 0x11, 0x12},
|
||||
{0x14, 0x1A, 0x06, 0x01, 0x10, 0x11, 0xFE, 0x02},
|
||||
{0x01, 0x0B, 0x0B, 0x0C, 0x18, 0x21, 0x10, 0x13},
|
||||
{0x12, 0x0D, 0x0A, 0x10, 0x1C, 0x1D, 0x0D, 0x10},
|
||||
{0x03, 0x09, 0x14, 0x15, 0x1B, 0x1A, 0x01, 0xFF},
|
||||
{0x08, 0x12, 0x13, 0x0E, 0x16, 0x1D, 0x14, 0x1B},
|
||||
{0x07, 0x15, 0x1C, 0x1B, 0x20, 0x21, 0x11, 0x0E},
|
||||
{0x12, 0x18, 0x19, 0x17, 0x20, 0x25, 0x1A, 0x1E},
|
||||
{0x0C, 0x1A, 0x1D, 0x22, 0x2F, 0x33, 0x27, 0x28},
|
||||
{0x0E, 0x1A, 0x17, 0x10, 0x0A, 0x0E, 0xFF, 0x06},
|
||||
{0x1A, 0x1C, 0x18, 0x14, 0x1A, 0x16, 0x0A, 0x0E},
|
||||
{0x1E, 0x27, 0x25, 0x26, 0x27, 0x2A, 0x21, 0x21},
|
||||
{0xF1, 0x0A, 0x16, 0x1C, 0x28, 0x25, 0x15, 0x19},
|
||||
{0x08, 0x12, 0x09, 0x08, 0x16, 0x17, 0xEF, 0xF6},
|
||||
{0x0C, 0x0B, 0x00, 0xFC, 0x04, 0x09, 0xFC, 0x03},
|
||||
{0xFB, 0xF1, 0xF8, 0x26, 0x24, 0x18, 0x1D, 0x20},
|
||||
{0xF9, 0x01, 0x0C, 0x0F, 0x07, 0x08, 0x06, 0x07},
|
||||
{0x07, 0x06, 0x08, 0x04, 0x07, 0x0D, 0x07, 0x09},
|
||||
{0xFE, 0x01, 0x06, 0x05, 0x13, 0x1B, 0x14, 0x19},
|
||||
{0x09, 0x0C, 0x0E, 0x01, 0x08, 0x05, 0xFB, 0xFD},
|
||||
{0x07, 0x06, 0x03, 0x0A, 0x16, 0x12, 0x04, 0x07},
|
||||
{0x04, 0x01, 0x00, 0x04, 0x1F, 0x20, 0x0E, 0x0A},
|
||||
{0x03, 0xFF, 0xF6, 0xFB, 0x15, 0x1A, 0x00, 0x03},
|
||||
{0xFC, 0x18, 0x0B, 0x2D, 0x35, 0x23, 0x12, 0x09},
|
||||
{0x02, 0xFE, 0x01, 0xFF, 0x0C, 0x11, 0x0D, 0x0F},
|
||||
{0xFA, 0xE9, 0xD9, 0xFF, 0x0D, 0x05, 0x0D, 0x10},
|
||||
{0xF1, 0xE0, 0xF0, 0x01, 0x06, 0x06, 0x06, 0x10},
|
||||
{0xE9, 0xD4, 0xD7, 0x0F, 0x14, 0x0B, 0x0D, 0x16},
|
||||
{0x00, 0xFF, 0xEE, 0xE5, 0xFF, 0x08, 0x02, 0xF9},
|
||||
{0xE0, 0xDA, 0xE5, 0xFE, 0x09, 0x02, 0xF9, 0x04},
|
||||
{0xE0, 0xE2, 0xF4, 0x09, 0x13, 0x0C, 0x0D, 0x09},
|
||||
{0xFC, 0x02, 0x04, 0xFF, 0x00, 0xFF, 0xF8, 0xF7},
|
||||
{0xFE, 0xFB, 0xED, 0xF2, 0xFE, 0xFE, 0x08, 0x0C},
|
||||
{0xF3, 0xEF, 0xD0, 0xE3, 0x05, 0x11, 0xFD, 0xFF},
|
||||
{0xFA, 0xEF, 0xEA, 0xFE, 0x0D, 0x0E, 0xFE, 0x02},
|
||||
{0xF7, 0xFB, 0xDB, 0xDF, 0x14, 0xDD, 0x07, 0xFE},
|
||||
{0xFE, 0x08, 0x00, 0xDB, 0xE5, 0x1A, 0x13, 0xED},
|
||||
{0xF9, 0xFE, 0xFF, 0xF4, 0xF3, 0x00, 0x05, 0x02},
|
||||
{0xEF, 0xDE, 0xD8, 0xEB, 0xEA, 0xF5, 0x0E, 0x19},
|
||||
{0xFB, 0xFC, 0xFA, 0xEC, 0xEB, 0xED, 0xEE, 0xE8},
|
||||
{0xEE, 0xFC, 0xFD, 0x00, 0x04, 0xFC, 0xF0, 0xF5},
|
||||
{0x00, 0xFA, 0xF4, 0xF1, 0xF5, 0xFA, 0xFB, 0xF9},
|
||||
{0xEB, 0xF0, 0xDF, 0xE3, 0xEF, 0x07, 0x02, 0x05},
|
||||
{0xF7, 0xF0, 0xE6, 0xE7, 0x06, 0x15, 0x06, 0x0C},
|
||||
{0xF1, 0xE4, 0xD8, 0xEA, 0x06, 0xF2, 0x07, 0x09},
|
||||
{0xFF, 0xFE, 0xFE, 0xF9, 0xFF, 0xFF, 0x02, 0xF9},
|
||||
{0xDD, 0xF4, 0xF0, 0xF1, 0xFF, 0xFF, 0xEA, 0xF1},
|
||||
{0xF0, 0xF1, 0xFD, 0x03, 0x03, 0xFE, 0x00, 0x05},
|
||||
{0xF1, 0xF6, 0xE0, 0xDF, 0xF5, 0x01, 0xF4, 0xF8},
|
||||
{0x02, 0x03, 0xE5, 0xDC, 0xE7, 0xFD, 0x02, 0x08},
|
||||
{0xEC, 0xF1, 0xF5, 0xEC, 0xF2, 0xF8, 0xF6, 0xEE},
|
||||
{0xF3, 0xF4, 0xF6, 0xF4, 0xF5, 0xF1, 0xE7, 0xEA},
|
||||
{0xF7, 0xF3, 0xEC, 0xEA, 0xEF, 0xF0, 0xEE, 0xF1},
|
||||
{0xEB, 0xF6, 0xFB, 0xFA, 0xEF, 0xF3, 0xF3, 0xF7},
|
||||
{0x01, 0x03, 0xF1, 0xF6, 0x05, 0xF8, 0xE1, 0xEB},
|
||||
{0xF5, 0xF6, 0xF6, 0xF4, 0xFB, 0xFB, 0xFF, 0x00},
|
||||
{0xF8, 0x01, 0xFB, 0xFA, 0xFF, 0x03, 0xFE, 0x04},
|
||||
{0x04, 0xFB, 0x03, 0xFD, 0xF5, 0xF7, 0xF6, 0xFB},
|
||||
{0x06, 0x09, 0xFB, 0xF4, 0xF9, 0xFA, 0xFC, 0xFF},
|
||||
{0xF5, 0xF6, 0xF1, 0xEE, 0xF5, 0xF8, 0xF5, 0xF9},
|
||||
{0xF5, 0xF9, 0xFA, 0xFC, 0x07, 0x09, 0x01, 0xFB},
|
||||
{0xD7, 0xE9, 0xE8, 0xEC, 0x00, 0x0C, 0xFE, 0xF1},
|
||||
{0xEC, 0x04, 0xE9, 0xDF, 0x03, 0xE8, 0x00, 0xFA},
|
||||
{0xE6, 0xE2, 0xFF, 0x0A, 0x13, 0x01, 0x00, 0xF7},
|
||||
{0xF1, 0xFA, 0xF7, 0xF5, 0x01, 0x06, 0x05, 0x0A},
|
||||
{0xF6, 0xF6, 0xFC, 0xF6, 0xE8, 0x11, 0xF2, 0xFE},
|
||||
{0xFE, 0x08, 0x05, 0x12, 0xFD, 0xD0, 0x0E, 0x07},
|
||||
{0xF1, 0xFE, 0xF7, 0xF2, 0xFB, 0x02, 0xFA, 0xF8},
|
||||
{0xF4, 0xEA, 0xEC, 0xF3, 0xFE, 0x01, 0xF7, 0xF6},
|
||||
{0xFF, 0xFA, 0xFB, 0xF9, 0xFF, 0x01, 0x04, 0x03},
|
||||
{0x00, 0xF9, 0xF4, 0xFC, 0x05, 0xFC, 0xF7, 0xFB},
|
||||
{0xF8, 0xFF, 0xEF, 0xEC, 0xFB, 0x04, 0xF8, 0x03},
|
||||
{0xEB, 0xF1, 0xED, 0xF4, 0x02, 0x0E, 0x0B, 0x04},
|
||||
{0xF7, 0x01, 0xF8, 0xF4, 0xF8, 0xEF, 0xF8, 0x04},
|
||||
{0xEB, 0xF0, 0xF7, 0xFC, 0x10, 0x0D, 0xF8, 0xF8},
|
||||
{0xE8, 0xFE, 0xEE, 0xE8, 0xED, 0xF7, 0xF5, 0xF8},
|
||||
{0xED, 0xEB, 0xE9, 0xEA, 0xF2, 0xF5, 0xF4, 0xF9},
|
||||
{0xEA, 0xF2, 0xEF, 0xEE, 0xF9, 0xFE, 0xFD, 0x02},
|
||||
{0xFA, 0xFD, 0x02, 0x0D, 0xFA, 0xE4, 0x0F, 0x01},
|
||||
{0xFF, 0x08, 0x05, 0xF6, 0xF7, 0xFB, 0xF1, 0xF1},
|
||||
{0xF4, 0xEC, 0xEE, 0xF6, 0xEE, 0xEE, 0xF8, 0x06},
|
||||
{0xE8, 0xFA, 0xF8, 0xE8, 0xF8, 0xE9, 0xEE, 0xF9},
|
||||
{0xE5, 0xE9, 0xF0, 0x00, 0x00, 0xEF, 0xF3, 0xF8},
|
||||
{0xF7, 0xFB, 0xFB, 0xF7, 0xF9, 0xF9, 0xF5, 0xF0},
|
||||
{0xFD, 0xFF, 0xF2, 0xEE, 0xF2, 0xF5, 0xF1, 0xF3}},
|
||||
{{{0x4F, 0x5B, 0x57, 0x52, 0x4D, 0x65, 0x45, 0x57},
|
||||
{0xF3, 0x0F, 0x18, 0x20, 0x19, 0x4F, 0x3D, 0x23},
|
||||
{0x78, 0x57, 0x55, 0x50, 0x50, 0x20, 0x36, 0x37}},
|
||||
{{0x4C, 0x5F, 0x53, 0x37, 0x1E, 0xFD, 0x15, 0x0A},
|
||||
{0x05, 0x0E, 0x28, 0x41, 0x48, 0x6E, 0x54, 0x5B},
|
||||
{0x59, 0x47, 0x40, 0x40, 0x3D, 0x33, 0x3F, 0x39}},
|
||||
{{0x47, 0x5F, 0x57, 0x34, 0x3C, 0x2E, 0x2E, 0x31},
|
||||
{0xFA, 0x13, 0x23, 0x4E, 0x44, 0x7C, 0x34, 0x38},
|
||||
{0x63, 0x43, 0x41, 0x3D, 0x35, 0x19, 0x3D, 0x33}}},
|
||||
{1.0 / 256.0, 1.0 / 256.0, 1.0 / 128.0, 1.0 / 2.0},
|
||||
{16, 52},
|
||||
{{0x26, 0x25, 0x11, 0x0C, 0xFA, 0x15}, {0x1B, 0x18, 0x11, 0x0E, 0x0E, 0x0E},
|
||||
{0x12, 0x10, 0x10, 0x10, 0x11, 0x10}, {0x1E, 0x24, 0x19, 0x15, 0x14, 0x12},
|
||||
{0x24, 0x16, 0x12, 0x13, 0x15, 0x1C}, {0xEA, 0xED, 0xEB, 0xEA, 0xEC, 0xEB},
|
||||
{0xFC, 0xFD, 0xFD, 0xFC, 0xFE, 0xFE}, {0x0F, 0x0C, 0x0B, 0x0A, 0x0B, 0x0B},
|
||||
{0x22, 0x0B, 0x16, 0x18, 0x13, 0x19}, {0x1C, 0x14, 0x1D, 0x20, 0x19, 0x1A},
|
||||
{0x10, 0x08, 0x00, 0xFF, 0x02, 0x05}, {0x06, 0x07, 0x05, 0x03, 0x05, 0x04},
|
||||
{0x2A, 0x1F, 0x12, 0x12, 0x11, 0x18}, {0x19, 0x19, 0x02, 0x04, 0x00, 0x04},
|
||||
{0x18, 0x17, 0x17, 0x15, 0x16, 0x15}, {0x21, 0x1E, 0x1B, 0x19, 0x1C, 0x1B},
|
||||
{0x3C, 0x35, 0x20, 0x1D, 0x30, 0x34}, {0x3A, 0x1F, 0x37, 0x38, 0x33, 0x31},
|
||||
{0x37, 0x34, 0x25, 0x27, 0x35, 0x34}, {0x34, 0x2E, 0x32, 0x31, 0x34, 0x31},
|
||||
{0x36, 0x33, 0x2F, 0x2F, 0x32, 0x2F}, {0x35, 0x20, 0x2F, 0x32, 0x2F, 0x2C},
|
||||
{0x2E, 0x2B, 0x2F, 0x34, 0x36, 0x30}, {0x3F, 0x39, 0x30, 0x28, 0x29, 0x29},
|
||||
{0x3C, 0x30, 0x32, 0x37, 0x39, 0x36}, {0x37, 0x36, 0x30, 0x2B, 0x26, 0x24},
|
||||
{0x44, 0x38, 0x2F, 0x2D, 0x2D, 0x2D}, {0x38, 0x2B, 0x2C, 0x2C, 0x30, 0x2D},
|
||||
{0x37, 0x36, 0x2F, 0x23, 0x2D, 0x32}, {0x3C, 0x39, 0x29, 0x2E, 0x38, 0x37},
|
||||
{0x3B, 0x3A, 0x35, 0x32, 0x31, 0x2D}, {0x32, 0x31, 0x2F, 0x2C, 0x2D, 0x28},
|
||||
{0x2C, 0x31, 0x32, 0x30, 0x32, 0x2D}, {0x35, 0x34, 0x34, 0x34, 0x35, 0x33},
|
||||
{0x34, 0x38, 0x3B, 0x3C, 0x3E, 0x3A}, {0x3E, 0x3C, 0x3B, 0x3A, 0x3C, 0x39},
|
||||
{0x3D, 0x41, 0x46, 0x41, 0x3D, 0x38}, {0x44, 0x41, 0x40, 0x3E, 0x3F, 0x3A},
|
||||
{0x47, 0x47, 0x47, 0x42, 0x44, 0x40}, {0x4C, 0x4A, 0x4A, 0x46, 0x49, 0x45},
|
||||
{0x53, 0x52, 0x52, 0x4C, 0x4E, 0x49}, {0x41, 0x3D, 0x39, 0x2C, 0x2E, 0x2E},
|
||||
{0x2D, 0x37, 0x36, 0x30, 0x28, 0x36}, {0x3B, 0x32, 0x2E, 0x2D, 0x2D, 0x29},
|
||||
{0x40, 0x39, 0x36, 0x35, 0x36, 0x32}, {0x30, 0x2D, 0x2D, 0x2E, 0x31, 0x30},
|
||||
{0x38, 0x3D, 0x3B, 0x37, 0x35, 0x34}, {0x44, 0x3D, 0x3C, 0x38, 0x37, 0x33},
|
||||
{0x3A, 0x36, 0x37, 0x37, 0x39, 0x36}, {0x32, 0x36, 0x37, 0x30, 0x2E, 0x2A},
|
||||
{0x3C, 0x33, 0x33, 0x31, 0x33, 0x30}, {0x30, 0x31, 0x36, 0x37, 0x38, 0x34},
|
||||
{0x26, 0x27, 0x2E, 0x29, 0x1C, 0x16}, {0x14, 0x15, 0x1F, 0x17, 0x15, 0x1C},
|
||||
{0x38, 0x2D, 0x18, 0x13, 0x1E, 0x2B}, {0x30, 0x22, 0x17, 0x1A, 0x26, 0x2B},
|
||||
{0x24, 0x20, 0x1F, 0x10, 0x0C, 0x11}, {0x27, 0x1F, 0x13, 0x17, 0x24, 0x2A},
|
||||
{0x2F, 0x13, 0x18, 0x13, 0x2A, 0x32}, {0x31, 0x1E, 0x1E, 0x1E, 0x21, 0x28},
|
||||
{0x2A, 0x12, 0x19, 0x17, 0x16, 0x24}, {0x27, 0x0F, 0x16, 0x1D, 0x17, 0x1C},
|
||||
{0x2F, 0x26, 0x25, 0x22, 0x20, 0x22}, {0x1E, 0x1B, 0x1E, 0x18, 0x1E, 0x24},
|
||||
{0x31, 0x26, 0x0E, 0x15, 0x15, 0x25}, {0x2D, 0x22, 0x1E, 0x14, 0x10, 0x22},
|
||||
{0x25, 0x1B, 0x18, 0x11, 0x13, 0x1F}, {0x2F, 0x1B, 0x13, 0x1B, 0x18, 0x22},
|
||||
{0x21, 0x24, 0x1D, 0x1C, 0x1D, 0x1B}, {0x23, 0x1E, 0x28, 0x29, 0x27, 0x25},
|
||||
{0x2E, 0x2A, 0x1D, 0x17, 0x26, 0x2D}, {0x31, 0x2C, 0x1A, 0x0E, 0x1A, 0x24},
|
||||
{0x26, 0x16, 0x20, 0x1D, 0x14, 0x1E}, {0x29, 0x20, 0x1B, 0x1B, 0x17, 0x17},
|
||||
{0x1D, 0x06, 0x1A, 0x1E, 0x1B, 0x1D}, {0x2B, 0x23, 0x1F, 0x1F, 0x1D, 0x1C},
|
||||
{0x27, 0x1A, 0x0C, 0x0E, 0x0F, 0x1A}, {0x29, 0x1D, 0x1E, 0x22, 0x22, 0x24},
|
||||
{0x20, 0x21, 0x1B, 0x18, 0x13, 0x21}, {0x27, 0x0E, 0x10, 0x14, 0x10, 0x1A},
|
||||
{0x26, 0x24, 0x25, 0x25, 0x26, 0x28}, {0x1A, 0x24, 0x25, 0x29, 0x26, 0x24},
|
||||
{0x1D, 0x1D, 0x15, 0x12, 0x0F, 0x18}, {0x1E, 0x14, 0x13, 0x12, 0x14, 0x18},
|
||||
{0x16, 0x13, 0x13, 0x1A, 0x1B, 0x1D}, {0x20, 0x27, 0x22, 0x24, 0x1A, 0x19},
|
||||
{0x1F, 0x17, 0x19, 0x18, 0x17, 0x18}, {0x20, 0x1B, 0x1C, 0x1C, 0x1B, 0x1A},
|
||||
{0x23, 0x19, 0x1D, 0x1F, 0x1E, 0x21}, {0x26, 0x1F, 0x1D, 0x1B, 0x19, 0x1A},
|
||||
{0x23, 0x1E, 0x1F, 0x20, 0x1F, 0x1E}, {0x29, 0x20, 0x22, 0x20, 0x20, 0x1F},
|
||||
{0x26, 0x23, 0x21, 0x22, 0x23, 0x23}, {0x29, 0x1F, 0x24, 0x25, 0x26, 0x29},
|
||||
{0x2B, 0x22, 0x25, 0x27, 0x23, 0x21}, {0x29, 0x21, 0x19, 0x0E, 0x22, 0x2D},
|
||||
{0x32, 0x29, 0x1F, 0x1C, 0x1B, 0x21}, {0x1E, 0x1A, 0x1E, 0x24, 0x25, 0x25},
|
||||
{0x24, 0x1D, 0x21, 0x22, 0x22, 0x25}, {0x2C, 0x25, 0x21, 0x22, 0x23, 0x25},
|
||||
{0x24, 0x1E, 0x21, 0x26, 0x2B, 0x2C}, {0x28, 0x24, 0x1B, 0x1F, 0x28, 0x2D},
|
||||
{0x23, 0x13, 0x16, 0x22, 0x22, 0x29}, {0x1B, 0x23, 0x1C, 0x20, 0x14, 0x0D},
|
||||
{0x1E, 0x16, 0x1A, 0x1E, 0x1C, 0x1D}, {0x2B, 0x1C, 0x1D, 0x20, 0x1B, 0x1C},
|
||||
{0x1C, 0x1B, 0x23, 0x1F, 0x19, 0x1E}, {0x21, 0x23, 0x26, 0x20, 0x20, 0x22},
|
||||
{0x1D, 0x0B, 0x19, 0x1E, 0x11, 0x19}, {0x18, 0x17, 0x16, 0x17, 0x14, 0x16},
|
||||
{0x16, 0x19, 0x1C, 0x20, 0x21, 0x22}, {0x30, 0x1E, 0x22, 0x24, 0x25, 0x26},
|
||||
{0x1B, 0x1F, 0x17, 0x1D, 0x1E, 0x21}, {0x32, 0x2B, 0x27, 0x1F, 0x1B, 0x1A},
|
||||
{0x28, 0x20, 0x1A, 0x1B, 0x1F, 0x23}, {0x32, 0x21, 0x20, 0x21, 0x1D, 0x1F},
|
||||
{0x22, 0x18, 0x12, 0x15, 0x1B, 0x20}, {0x27, 0x27, 0x2A, 0x24, 0x21, 0x21},
|
||||
{0x1E, 0x0F, 0x0D, 0x1A, 0x1D, 0x23}, {0x28, 0x25, 0x27, 0x21, 0x17, 0x25},
|
||||
{0x2B, 0x27, 0x23, 0x19, 0x13, 0x14}, {0x25, 0x2B, 0x22, 0x22, 0x20, 0x21},
|
||||
{0x27, 0x1B, 0x16, 0x17, 0x0F, 0x15}, {0x29, 0x26, 0x23, 0x15, 0x1E, 0x28},
|
||||
{0x24, 0x1C, 0x19, 0x1A, 0x18, 0x19}, {0x2D, 0x15, 0x27, 0x2B, 0x24, 0x23},
|
||||
{0x2C, 0x12, 0x1F, 0x23, 0x1F, 0x20}, {0x25, 0x0F, 0x22, 0x27, 0x1F, 0x21}},
|
||||
{{{0x11, 0x27, 0x0F, 0xFD, 0x04, 0xFC},
|
||||
{0x00, 0xBE, 0xE3, 0xF4, 0xDB, 0xF0},
|
||||
{0x09, 0x1E, 0x18, 0x1A, 0x21, 0x1B}},
|
||||
{{0x16, 0x28, 0x2B, 0x29, 0x25, 0x32},
|
||||
{0xF2, 0xE9, 0xE4, 0xE5, 0xE2, 0xD4},
|
||||
{0x0E, 0x0B, 0x0C, 0x0D, 0x0D, 0x0E}},
|
||||
{{0x2E, 0x3C, 0x20, 0x16, 0x1B, 0x1A},
|
||||
{0xE4, 0xC6, 0xE5, 0xF4, 0xDC, 0xDC},
|
||||
{0x0F, 0x1B, 0x18, 0x14, 0x1E, 0x1A}}},
|
||||
{1.0 / 128.0, 1.0 / 128.0, 1.0 / 64.0, 1.0 / 1.0}};
|
||||
32
encoder/iusace_esbr_rom.c
Normal file
32
encoder/iusace_esbr_rom.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "iusace_esbr_rom.h"
|
||||
|
||||
const FLOAT32 ixheaace_gamma_tab[4] = {0.0f, 1.0f, 2.0f, 4.0f};
|
||||
|
||||
const FLOAT32 ixheaace_new_bw_tab[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}};
|
||||
24
encoder/iusace_esbr_rom.h
Normal file
24
encoder/iusace_esbr_rom.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern const FLOAT32 ixheaace_gamma_tab[4];
|
||||
extern const FLOAT32 ixheaace_new_bw_tab[4][4];
|
||||
26
encoder/iusace_fd_enc.h
Normal file
26
encoder/iusace_fd_enc.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
IA_ERRORCODE iusace_fd_encode(ia_sfb_params_struct *pstr_sfb_prms, WORD32 usac_independancy_flag,
|
||||
ia_usac_data_struct *pstr_usac_data,
|
||||
ia_usac_encoder_config_struct *pstr_usac_config,
|
||||
ia_bit_buf_struct *pstr_it_bit_buff, WORD32 nr_core_coder_ch,
|
||||
WORD32 chn, WORD32 ele_id, WORD32 *bit_written);
|
||||
328
encoder/iusace_fd_fac.c
Normal file
328
encoder/iusace_fd_fac.c
Normal file
|
|
@ -0,0 +1,328 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "ixheaace_memory_standards.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_tcx_mdct.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_func_prototypes.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
#include "iusace_lpd.h"
|
||||
#include "iusace_avq_enc.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
||||
static VOID iusace_decode_fd_fac(WORD32 *ptr_fac_prms, WORD32 len_subfrm, WORD32 fac_len,
|
||||
FLOAT32 *ptr_lpc_coeffs, FLOAT32 *zir_sig, FLOAT32 *ptr_fac_dec,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
FLOAT32 *x = pstr_scratch->p_x;
|
||||
FLOAT32 *xn2 = pstr_scratch->p_xn_2;
|
||||
FLOAT32 fac_gain;
|
||||
WORD32 i;
|
||||
const FLOAT32 *sin_window;
|
||||
FLOAT32 *fac_window = pstr_scratch->p_fac_window;
|
||||
FLOAT32 ap[ORDER + 1];
|
||||
|
||||
if (fac_len == 64) {
|
||||
sin_window = iusace_sin_window_128;
|
||||
} else {
|
||||
sin_window = iusace_sin_window_256;
|
||||
}
|
||||
|
||||
if (ptr_lpc_coeffs != NULL && ptr_fac_dec != NULL) {
|
||||
fac_gain = (FLOAT32)pow(10.0f, ((FLOAT32)ptr_fac_prms[0]) / 28.0f);
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
x[i] = (FLOAT32)ptr_fac_prms[i + 1] * fac_gain;
|
||||
}
|
||||
|
||||
iusace_tcx_mdct(x, xn2, fac_len, pstr_scratch);
|
||||
|
||||
iusace_get_weighted_lpc(ptr_lpc_coeffs, ap);
|
||||
|
||||
memset(xn2 + fac_len, 0, fac_len * sizeof(FLOAT32));
|
||||
iusace_synthesis_tool_float(ap, xn2, ptr_fac_dec, 2 * fac_len, xn2 + fac_len,
|
||||
pstr_scratch->p_buf_synthesis_tool);
|
||||
|
||||
if (zir_sig != NULL) {
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
fac_window[i] = sin_window[i] * sin_window[(2 * fac_len) - 1 - i];
|
||||
fac_window[fac_len + i] = 1.0f - (sin_window[fac_len + i] * sin_window[fac_len + i]);
|
||||
}
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
ptr_fac_dec[i] += zir_sig[1 + (len_subfrm / 2) + i] * fac_window[fac_len + i] +
|
||||
zir_sig[1 + (len_subfrm / 2) - 1 - i] * fac_window[fac_len - 1 - i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_fac_apply(FLOAT32 *orig, WORD32 len_subfrm, WORD32 fac_len, WORD32 low_pass_line,
|
||||
WORD32 target_br, FLOAT32 *synth, FLOAT32 *ptr_lpc_coeffs,
|
||||
WORD16 *fac_bits_word, WORD32 *num_fac_bits,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
FLOAT32 *xn2 = pstr_scratch->p_xn2;
|
||||
FLOAT32 *fac_dec = pstr_scratch->p_fac_dec;
|
||||
FLOAT32 *right_fac_spec = pstr_scratch->p_right_fac_spec;
|
||||
FLOAT32 *x2 = pstr_scratch->p_x2;
|
||||
WORD32 *param = pstr_scratch->p_param;
|
||||
FLOAT32 ap[ORDER + 1];
|
||||
FLOAT32 fac_gain;
|
||||
WORD32 i, index;
|
||||
WORD32 num_enc_bits = 0;
|
||||
WORD32 start_right = 2 * len_subfrm - fac_len;
|
||||
|
||||
*num_fac_bits = 0;
|
||||
|
||||
memset(xn2, 0, (FAC_LENGTH + ORDER) * sizeof(FLOAT32));
|
||||
|
||||
memcpy(xn2 + ORDER, &orig[start_right], fac_len * sizeof(FLOAT32));
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
xn2[ORDER + i] -= synth[start_right + i];
|
||||
}
|
||||
|
||||
iusace_get_weighted_lpc(ptr_lpc_coeffs, ap);
|
||||
iusace_compute_lp_residual(ap, xn2 + ORDER, x2, fac_len);
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
x2[i] = x2[i] * (2.0f / (FLOAT32)fac_len);
|
||||
}
|
||||
|
||||
iusace_tcx_mdct(x2, right_fac_spec, fac_len, pstr_scratch);
|
||||
|
||||
memset(&right_fac_spec[low_pass_line], 0, (fac_len - low_pass_line) * sizeof(FLOAT32));
|
||||
|
||||
fac_gain = iusace_calc_sq_gain(right_fac_spec, target_br, fac_len, pstr_scratch->p_sq_gain_en);
|
||||
index = (WORD32)floor(0.5f + (28.0f * (FLOAT32)log10(fac_gain)));
|
||||
if (index < 0) index = 0;
|
||||
if (index > 127) index = 127;
|
||||
param[0] = index;
|
||||
fac_gain = (FLOAT32)pow(10.0f, ((FLOAT32)index) / 28.0f);
|
||||
for (i = 0; i < fac_len; i++) right_fac_spec[i] /= fac_gain;
|
||||
|
||||
for (i = 0; i < fac_len; i += 8) {
|
||||
iusace_find_nearest_neighbor(&right_fac_spec[i], ¶m[i + 1]);
|
||||
}
|
||||
|
||||
iusace_write_bits2buf(index, 7, fac_bits_word);
|
||||
num_enc_bits += 7;
|
||||
num_enc_bits += iusace_fd_encode_fac(¶m[1], &fac_bits_word[7], fac_len);
|
||||
iusace_decode_fd_fac(¶m[0], len_subfrm, fac_len, ptr_lpc_coeffs, NULL, fac_dec,
|
||||
pstr_scratch);
|
||||
*num_fac_bits = num_enc_bits;
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
synth[start_right + i] += fac_dec[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_fd_fac(WORD32 *sfb_offsets, WORD32 sfb_active, FLOAT64 *orig_sig_dbl,
|
||||
WORD32 window_sequence, FLOAT64 *synth_time,
|
||||
ia_usac_td_encoder_struct *pstr_acelp, WORD32 last_subfr_was_acelp,
|
||||
WORD32 next_frm_lpd, WORD16 *fac_prm_out, WORD32 *num_fac_bits,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
const FLOAT32 *sin_window = NULL;
|
||||
LOOPIDX i;
|
||||
FLOAT32 *zir_sig = NULL;
|
||||
FLOAT32 *lpc_coeffs_q = NULL;
|
||||
WORD32 index;
|
||||
WORD32 low_pass_line;
|
||||
WORD32 fac_len;
|
||||
FLOAT64 *left_fac_time_data = pstr_scratch->p_left_fac_time_data;
|
||||
FLOAT32 *left_fac_timedata_flt = pstr_scratch->p_left_fac_timedata_flt;
|
||||
FLOAT32 *left_fac_spec = pstr_scratch->p_left_fac_spec;
|
||||
FLOAT64 *fac_win = pstr_scratch->p_fac_win;
|
||||
WORD32 *fac_prm = pstr_scratch->p_fac_prm;
|
||||
WORD16 *fac_bits_word = pstr_scratch->p_fac_bits_word;
|
||||
FLOAT32 *acelp_folded = pstr_scratch->p_acelp_folded_scratch;
|
||||
|
||||
*num_fac_bits = 0;
|
||||
|
||||
if (window_sequence == EIGHT_SHORT_SEQUENCE)
|
||||
fac_len = (pstr_acelp->len_frame / 16);
|
||||
else
|
||||
fac_len = (pstr_acelp->len_frame / 8);
|
||||
|
||||
low_pass_line = (WORD32)((FLOAT32)sfb_offsets[sfb_active] * (FLOAT32)fac_len /
|
||||
(FLOAT32)pstr_acelp->len_frame);
|
||||
if (last_subfr_was_acelp) {
|
||||
FLOAT32 *tmp_lp_res = pstr_scratch->ptr_tmp_lp_res;
|
||||
FLOAT32 lpc_coeffs[ORDER + 1];
|
||||
FLOAT32 ener, fac_gain;
|
||||
WORD32 left_start;
|
||||
|
||||
switch (fac_len) {
|
||||
case 48:
|
||||
sin_window = iusace_sin_window_96;
|
||||
break;
|
||||
case 64:
|
||||
sin_window = iusace_sin_window_128;
|
||||
break;
|
||||
case 96:
|
||||
sin_window = iusace_sin_window_192;
|
||||
break;
|
||||
case 128:
|
||||
sin_window = iusace_sin_window_256;
|
||||
break;
|
||||
default:
|
||||
return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_FAC_LEN;
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
fac_win[i] = sin_window[i] * sin_window[(2 * fac_len) - 1 - i];
|
||||
fac_win[fac_len + i] = 1.0f - (sin_window[fac_len + i] * sin_window[fac_len + i]);
|
||||
}
|
||||
|
||||
left_start = (pstr_acelp->len_frame / 2) - fac_len - ORDER;
|
||||
|
||||
for (i = 0; i < 2 * fac_len + ORDER; i++) {
|
||||
left_fac_time_data[i] = orig_sig_dbl[left_start + i];
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
left_fac_time_data[fac_len + ORDER + i] =
|
||||
left_fac_time_data[fac_len + ORDER + i] - synth_time[left_start + fac_len + ORDER + i];
|
||||
}
|
||||
|
||||
zir_sig = pstr_acelp->lpd_state.tcx_quant;
|
||||
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
left_fac_time_data[fac_len + i] =
|
||||
left_fac_time_data[fac_len + i] - zir_sig[1 + 128 - ORDER + i];
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
acelp_folded[i] = zir_sig[1 + 128 + i] * (FLOAT32)fac_win[fac_len + i] +
|
||||
zir_sig[1 + 128 - 1 - i] * (FLOAT32)fac_win[fac_len - 1 - i];
|
||||
}
|
||||
|
||||
{
|
||||
FLOAT32 ener_tmp;
|
||||
ener = 0.0f;
|
||||
ener_tmp = 0.0f;
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
ener += (FLOAT32)(left_fac_time_data[i + ORDER + fac_len] *
|
||||
left_fac_time_data[i + ORDER + fac_len]);
|
||||
}
|
||||
ener *= 2.0f;
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
ener_tmp += acelp_folded[i] * acelp_folded[i];
|
||||
}
|
||||
|
||||
if (ener_tmp > ener)
|
||||
fac_gain = (FLOAT32)sqrt(ener / ener_tmp);
|
||||
else
|
||||
fac_gain = 1.0f;
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
left_fac_time_data[i + ORDER + fac_len] -= fac_gain * acelp_folded[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 2 * fac_len + ORDER; i++) {
|
||||
left_fac_timedata_flt[i] = (FLOAT32)left_fac_time_data[i];
|
||||
}
|
||||
|
||||
lpc_coeffs_q = pstr_acelp->lpd_state.lpc_coeffs_quant;
|
||||
lpc_coeffs_q += ORDER + 1;
|
||||
iusace_get_weighted_lpc(lpc_coeffs_q, lpc_coeffs);
|
||||
iusace_compute_lp_residual(lpc_coeffs, left_fac_timedata_flt + ORDER + fac_len, tmp_lp_res,
|
||||
fac_len);
|
||||
FLOAT32 coeff = (2.0f / (FLOAT32)fac_len);
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
tmp_lp_res[i] = tmp_lp_res[i] * coeff;
|
||||
}
|
||||
|
||||
iusace_tcx_mdct(tmp_lp_res, left_fac_spec, fac_len, pstr_scratch);
|
||||
memset(&left_fac_spec[low_pass_line], 0, (fac_len - low_pass_line) * sizeof(FLOAT32));
|
||||
|
||||
fac_gain = iusace_calc_sq_gain(left_fac_spec, 240, fac_len, pstr_scratch->p_sq_gain_en);
|
||||
|
||||
index = (WORD32)floor(0.5f + (28.0f * (FLOAT32)log10(fac_gain)));
|
||||
if (index < 0) index = 0;
|
||||
if (index > 127) index = 127;
|
||||
iusace_write_bits2buf(index, 7, fac_bits_word);
|
||||
*num_fac_bits += 7;
|
||||
fac_gain = (FLOAT32)pow(10.0f, ((FLOAT32)index) / 28.0f);
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
left_fac_spec[i] /= fac_gain;
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i += 8) {
|
||||
iusace_find_nearest_neighbor(&left_fac_spec[i], &fac_prm[i]);
|
||||
}
|
||||
|
||||
*num_fac_bits += iusace_fd_encode_fac(fac_prm, &fac_bits_word[7], fac_len);
|
||||
|
||||
for (i = 0; i < (*num_fac_bits + 7) / 8; i++) {
|
||||
fac_prm_out[i] =
|
||||
(WORD16)((fac_bits_word[8 * i + 0] & 0x1) << 7 | (fac_bits_word[8 * i + 1] & 0x1) << 6 |
|
||||
(fac_bits_word[8 * i + 2] & 0x1) << 5 | (fac_bits_word[8 * i + 3] & 0x1) << 4 |
|
||||
(fac_bits_word[8 * i + 4] & 0x1) << 3 | (fac_bits_word[8 * i + 5] & 0x1) << 2 |
|
||||
(fac_bits_word[8 * i + 6] & 0x1) << 1 | (fac_bits_word[8 * i + 7] & 0x1) << 0);
|
||||
}
|
||||
} else {
|
||||
*num_fac_bits = 0;
|
||||
}
|
||||
|
||||
if (next_frm_lpd) {
|
||||
for (i = 0; i < 1024 / 2 + 1 + ORDER; i++) {
|
||||
pstr_acelp->fd_synth[i] = (FLOAT32)synth_time[pstr_acelp->len_frame - 1 + i - ORDER];
|
||||
pstr_acelp->fd_orig[i] = (FLOAT32)orig_sig_dbl[pstr_acelp->len_frame + i - ORDER];
|
||||
}
|
||||
|
||||
pstr_acelp->low_pass_line = low_pass_line;
|
||||
}
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
104
encoder/iusace_fd_qc_adjthr.h
Normal file
104
encoder/iusace_fd_qc_adjthr.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define RED_EXP_VAL 0.25f
|
||||
#define INV_RED_EXP_VAL (1.0f / RED_EXP_VAL)
|
||||
#define MIN_SNR_LIMIT 0.8f
|
||||
|
||||
#define MAX_SCF_DELTA 60
|
||||
|
||||
#define LOG2_1 1.442695041f
|
||||
#define C1_SF -69.33295f /* -16/3*log(MAX_QUANT+0.5-logCon)/log(2) */
|
||||
#define C2_SF 5.77078f /* 4/log(2) */
|
||||
|
||||
#define PE_C1 3.0f /* log(8.0)/log(2) */
|
||||
#define PE_C2 1.3219281f /* log(2.5)/log(2) */
|
||||
#define PE_C3 0.5593573f /* 1-C2/C1 */
|
||||
|
||||
#define CLIP_SAVE_LO_TO_HI_LONG (CLIP_SAVE_HI_LONG - CLIP_SAVE_LO_LONG)
|
||||
#define CLIP_SAVE_LO_TO_HI_SHORT (CLIP_SAVE_HI_SHORT - CLIP_SAVE_LO_SHORT)
|
||||
#define CLIP_SPEND_LO_TO_HI_LONG (CLIP_SPEND_HI_LONG - CLIP_SPEND_LO_LONG)
|
||||
#define CLIP_SPEND_LO_TO_HI_SHORT (CLIP_SPEND_HI_SHORT - CLIP_SPEND_LO_SHORT)
|
||||
#define MIN_TO_MAX_SAVE_BITS_LONG (MAX_BITS_SAVE_LONG - MIN_BITS_SAVE_LONG)
|
||||
#define MIN_TO_MAX_SAVE_BITS_SHORT (MAX_BITS_SAVE_SHORT - MIN_BITS_SAVE_SHORT)
|
||||
#define MIN_TO_MAX_SPEND_BITS_LONG (MAX_BITS_SPEND_LONG - MIN_BITS_SPEND_LONG)
|
||||
#define MIN_TO_MAX_SPEND_BITS_SHORT (MAX_BITS_SPEND_SHORT - MIN_BITS_SPEND_SHORT)
|
||||
#define BITS_SAVE_RATIO_LONG (MIN_TO_MAX_SAVE_BITS_LONG / CLIP_SAVE_LO_TO_HI_LONG)
|
||||
#define BITS_SAVE_RATIO_SHORT (MIN_TO_MAX_SAVE_BITS_SHORT / CLIP_SAVE_LO_TO_HI_SHORT)
|
||||
#define BITS_SPEND_RATIO_LONG (MIN_TO_MAX_SPEND_BITS_LONG / CLIP_SPEND_LO_TO_HI_LONG)
|
||||
#define BITS_SPEND_RATIO_SHORT (MIN_TO_MAX_SPEND_BITS_SHORT / CLIP_SPEND_LO_TO_HI_SHORT)
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 *sfb_ld_energy;
|
||||
FLOAT32 *sfb_lines;
|
||||
FLOAT32 sfb_pe[MAX_GROUPED_SFB_TEMP];
|
||||
FLOAT32 sfb_const_part[MAX_GROUPED_SFB_TEMP];
|
||||
FLOAT32 num_sfb_active_lines[MAX_GROUPED_SFB_TEMP];
|
||||
FLOAT32 pe;
|
||||
FLOAT32 const_part;
|
||||
FLOAT32 num_active_lines;
|
||||
} ia_qc_pe_chan_data_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_qc_pe_chan_data_struct pe_ch_data[30];
|
||||
FLOAT32 pe;
|
||||
FLOAT32 const_part;
|
||||
FLOAT32 num_active_lines;
|
||||
FLOAT32 offset;
|
||||
} ia_qc_pe_data_struct;
|
||||
|
||||
enum ia_avoid_hole_state { NO_AH = 0, AH_INACTIVE = 1, AH_ACTIVE = 2 };
|
||||
|
||||
typedef enum {
|
||||
SI_ID_BITS = (3),
|
||||
SI_FILL_COUNT_BITS = (4),
|
||||
SI_FILL_ESC_COUNT_BITS = (8),
|
||||
SI_FILL_EXTENTION_BITS = (4),
|
||||
SI_FILL_NIBBLE_BITS = (4),
|
||||
SI_SCE_BITS = (4),
|
||||
SI_CPE_BITS = (5),
|
||||
SI_CPE_MS_MASK_BITS = (2),
|
||||
SI_ICS_INFO_BITS_LONG = (1 + 2 + 6),
|
||||
SI_ICS_INFO_BITS_SHORT = (1 + 2 + 4 + 7),
|
||||
SI_ICS_BITS = (8 + 1 + 1 + 1),
|
||||
} SI_BITS;
|
||||
|
||||
FLOAT32 iusace_bits_to_pe(const FLOAT32 bits);
|
||||
|
||||
VOID iusace_adj_thr_init(ia_adj_thr_elem_struct *pstr_adj_thr_state, const FLOAT32 mean_pe,
|
||||
WORD32 ch_bitrate);
|
||||
|
||||
IA_ERRORCODE iusace_adj_thr(ia_adj_thr_elem_struct *pstr_adj_thr_elem,
|
||||
ia_psy_mod_out_data_struct *pstr_psy_out, FLOAT32 *ch_bit_dist,
|
||||
ia_qc_out_data_struct *pstr_qc_out, const WORD32 avg_bits,
|
||||
const WORD32 bitres_bits, const WORD32 max_bitres_bits,
|
||||
const WORD32 side_info_bits, FLOAT32 *max_bit_fac,
|
||||
WORD32 num_channels, WORD32 chn, iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_calc_form_fac_per_chan(ia_psy_mod_out_data_struct *pstr_psy_out_chan,
|
||||
iusace_scratch_mem *pstr_scratch, WORD32 i_ch);
|
||||
|
||||
VOID iusace_estimate_scfs_chan(ia_psy_mod_out_data_struct *pstr_psy_out,
|
||||
ia_qc_out_chan_struct *str_qc_out_chan, WORD32 num_channels,
|
||||
WORD32 chn, iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_quantize_lines(const WORD32 gain, const WORD32 num_lines, FLOAT32 *ptr_exp_spectrum,
|
||||
WORD16 *ptr_quant_spectrum, FLOAT32 *ptr_mdct_spec);
|
||||
74
encoder/iusace_fd_qc_util.h
Normal file
74
encoder/iusace_fd_qc_util.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef IXHEAACE_MAX_CH_IN_BS_ELE
|
||||
#define IXHEAACE_MAX_CH_IN_BS_ELE (2)
|
||||
#endif
|
||||
|
||||
#define FRAME_LEN_BYTES_MODULO (1)
|
||||
#define FRAME_LEN_BYTES_INT (2)
|
||||
|
||||
typedef struct {
|
||||
WORD32 ch_bitrate;
|
||||
WORD32 avg_bits;
|
||||
WORD32 max_bits;
|
||||
WORD32 bit_res_lvl;
|
||||
WORD32 max_bitres_bits;
|
||||
WORD32 static_bits;
|
||||
FLOAT32 max_bit_fac;
|
||||
WORD32 tot_avg_bits;
|
||||
WORD32 padding;
|
||||
ia_adj_thr_state_struct str_adj_thr;
|
||||
ia_adj_thr_elem_struct str_adj_thr_ele;
|
||||
WORD8 num_ch;
|
||||
} ia_qc_data_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD16 quant_spec[LEN_SUPERFRAME];
|
||||
UWORD16 max_val_in_sfb[LEN_SUPERFRAME];
|
||||
WORD16 scalefactor[LEN_SUPERFRAME];
|
||||
WORD32 global_gain;
|
||||
} ia_qc_out_chan_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_qc_out_chan_struct str_qc_out_chan[IXHEAACE_MAX_CH_IN_BS_ELE];
|
||||
WORD32 static_bits;
|
||||
WORD32 dyn_bits;
|
||||
WORD32 fill_bits;
|
||||
FLOAT32 pe;
|
||||
} ia_qc_out_data_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_qc_data_struct str_qc_data[IXHEAACE_MAX_CH_IN_BS_ELE];
|
||||
ia_qc_out_data_struct str_qc_out;
|
||||
} ia_qc_main_struct;
|
||||
|
||||
VOID iusace_qc_create(ia_qc_main_struct *pstr_qc_data);
|
||||
|
||||
VOID iusace_qc_init(ia_qc_data_struct *pstr_qc_data, const WORD32 max_bits, WORD32 sample_rate,
|
||||
WORD32 bw_limit, WORD32 channels, WORD32 ccfl);
|
||||
|
||||
VOID iusace_adj_bitrate(ia_qc_data_struct *pstr_qc_data, WORD32 bit_rate, WORD32 sample_rate,
|
||||
WORD32 ccfl);
|
||||
|
||||
WORD32 iusace_calc_max_val_in_sfb(WORD32 sfb_count, WORD32 max_sfb_per_grp, WORD32 sfb_per_group,
|
||||
WORD32 *ptr_sfb_offset, WORD16 *ptr_quant_spec);
|
||||
35
encoder/iusace_fd_quant.h
Normal file
35
encoder/iusace_fd_quant.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define MAX_QUANT 8192
|
||||
#define SF_OFFSET 100
|
||||
|
||||
#define sgn(A) ((A) > 0 ? (1) : (-1))
|
||||
|
||||
typedef struct ia_usac_quant_info_struct {
|
||||
WORD32 scale_factor[MAX_SF_BANDS];
|
||||
WORD32 quant_degroup[FRAME_LEN_LONG];
|
||||
WORD32 arith_size_prev;
|
||||
WORD32 reset;
|
||||
WORD32 c_prev[(FRAME_LEN_LONG / 2) + 4];
|
||||
WORD32 c_pres[(FRAME_LEN_LONG / 2) + 4];
|
||||
WORD32 max_spec_coeffs;
|
||||
} ia_usac_quant_info_struct;
|
||||
|
|
@ -22,9 +22,22 @@
|
|||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_rom.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_fft.h"
|
||||
#include "iusace_basic_ops_flt.h"
|
||||
|
|
@ -798,6 +811,42 @@ VOID iusace_complex_fft_p3_no_scratch(FLOAT32 *data, WORD32 nlength) {
|
|||
}
|
||||
}
|
||||
|
||||
static VOID iusace_calc_pre_twid_enc(FLOAT64 *ptr_in, FLOAT32 *fft_ptr, WORD32 npoints,
|
||||
const FLOAT64 *cos_ptr, const FLOAT64 *sin_ptr,
|
||||
const WORD32 tx_flag) {
|
||||
WORD32 i, n;
|
||||
WORD32 b = npoints >> 1;
|
||||
WORD32 a = npoints - b;
|
||||
WORD32 nlength = npoints >> 2;
|
||||
FLOAT64 tempr, tempi;
|
||||
|
||||
if (tx_flag == 0) {
|
||||
FLOAT64 norm;
|
||||
for (i = 0; i < b; i++) {
|
||||
norm = ptr_in[i]; /* reuse MDCT: spectrally reverse all bins */
|
||||
ptr_in[i] = ptr_in[npoints - 1 - i];
|
||||
ptr_in[npoints - 1 - i] = norm;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < nlength; i++) {
|
||||
n = npoints / 2 - 1 - 2 * i;
|
||||
if (i < b / 4) {
|
||||
tempr = ptr_in[a / 2 + n] + ptr_in[npoints + a / 2 - 1 - n];
|
||||
} else {
|
||||
tempr = ptr_in[a / 2 + n] - ptr_in[a / 2 - 1 - n];
|
||||
}
|
||||
n = 2 * i;
|
||||
if (i < a / 4) {
|
||||
tempi = ptr_in[a / 2 + n] - ptr_in[a / 2 - 1 - n];
|
||||
} else {
|
||||
tempi = ptr_in[a / 2 + n] + ptr_in[npoints + a / 2 - 1 - n];
|
||||
}
|
||||
|
||||
fft_ptr[2 * i] = (FLOAT32)(tempr * (*cos_ptr) + tempi * (*sin_ptr));
|
||||
fft_ptr[2 * i + 1] = (FLOAT32)(tempi * (*cos_ptr++) - tempr * (*sin_ptr++));
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_complex_fft(FLOAT32 *data, WORD32 nlength, iusace_scratch_mem *pstr_scratch) {
|
||||
if (nlength & (nlength - 1)) {
|
||||
iusace_complex_fft_p3(data, nlength, pstr_scratch);
|
||||
|
|
@ -806,6 +855,75 @@ VOID iusace_complex_fft(FLOAT32 *data, WORD32 nlength, iusace_scratch_mem *pstr_
|
|||
}
|
||||
}
|
||||
|
||||
static VOID iusace_calc_post_twid_enc(FLOAT64 *ptr_out, FLOAT32 *fft_ptr, WORD32 npoints,
|
||||
const FLOAT64 *cos_ptr, const FLOAT64 *sin_ptr,
|
||||
const WORD32 tx_flag) {
|
||||
WORD32 i;
|
||||
WORD32 nlength = npoints >> 2;
|
||||
FLOAT64 tempr, tempi;
|
||||
|
||||
/* post-twiddle FFT output and then get output data */
|
||||
for (i = 0; i < nlength; i++) {
|
||||
tempr =
|
||||
2 * ((FLOAT64)(fft_ptr[2 * i]) * (*cos_ptr) + (FLOAT64)(fft_ptr[2 * i + 1]) * (*sin_ptr));
|
||||
tempi = 2 * ((FLOAT64)(fft_ptr[2 * i + 1]) * (*cos_ptr++) -
|
||||
(FLOAT64)(fft_ptr[2 * i]) * (*sin_ptr++));
|
||||
|
||||
ptr_out[2 * i] = -tempr;
|
||||
ptr_out[npoints / 2 - 1 - 2 * i] = tempi;
|
||||
ptr_out[npoints / 2 + 2 * i] = -tempi;
|
||||
ptr_out[npoints - 1 - 2 * i] = tempr;
|
||||
}
|
||||
if (tx_flag == 0) {
|
||||
for (i = 0; i < npoints; i += 2) {
|
||||
ptr_out[i] *= -1; /* reuse MDCT: flip signs at odd indices */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_fft_based_mdct(FLOAT64 *ptr_in, FLOAT64 *ptr_out, WORD32 npoints,
|
||||
const WORD32 tx_flag, iusace_scratch_mem *pstr_scratch) {
|
||||
FLOAT32 *ptr_scratch1 = pstr_scratch->p_fft_mdct_buf;
|
||||
const FLOAT64 *cos_ptr = NULL;
|
||||
const FLOAT64 *sin_ptr = NULL;
|
||||
WORD32 nlength = npoints >> 1;
|
||||
WORD32 n_total = npoints << 1;
|
||||
|
||||
memset(ptr_scratch1, 0, ((SIZE_T)n_total << 1) * sizeof(*ptr_scratch1));
|
||||
|
||||
switch (npoints) {
|
||||
case (96):
|
||||
cos_ptr = iexheaac_pre_post_twid_cos_192;
|
||||
sin_ptr = iexheaac_pre_post_twid_sin_192;
|
||||
break;
|
||||
case (128):
|
||||
cos_ptr = iusace_pre_post_twid_cos_256;
|
||||
sin_ptr = iusace_pre_post_twid_sin_256;
|
||||
break;
|
||||
case (768):
|
||||
cos_ptr = iexheaac_pre_post_twid_cos_1536;
|
||||
sin_ptr = iexheaac_pre_post_twid_sin_1536;
|
||||
break;
|
||||
case (1024):
|
||||
cos_ptr = iusace_pre_post_twid_cos_2048;
|
||||
sin_ptr = iusace_pre_post_twid_sin_2048;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pre-twiddle */
|
||||
iusace_calc_pre_twid_enc(ptr_in, ptr_scratch1, npoints << 1, cos_ptr, sin_ptr, tx_flag);
|
||||
|
||||
/* complex FFT */
|
||||
iusace_complex_fft(ptr_scratch1, nlength, pstr_scratch);
|
||||
|
||||
/* post-twiddle */
|
||||
iusace_calc_post_twid_enc(ptr_out, ptr_scratch1, npoints << 1, cos_ptr, sin_ptr, tx_flag);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID iusace_complex_fft_2048(FLOAT32 *ptr_x, FLOAT32 *scratch_fft) {
|
||||
WORD32 i;
|
||||
FLOAT32 re, im, c_v, s_v, tmp_re, tmp_im;
|
||||
|
|
@ -841,3 +959,626 @@ VOID iusace_complex_fft_2048(FLOAT32 *ptr_x, FLOAT32 *scratch_fft) {
|
|||
ptr_im_h += 2;
|
||||
}
|
||||
}
|
||||
static VOID ixheaace_rad2_cplx_fft(FLOAT32 *ptr_real, FLOAT32 *ptr_imag, WORD32 n_points,
|
||||
FLOAT32 *ptr_scratch) {
|
||||
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;
|
||||
WORD32 m_points = n_points;
|
||||
FLOAT32 *ptr_x = ptr_scratch;
|
||||
FLOAT32 *y = ptr_scratch + 2048;
|
||||
FLOAT32 *ptr_y = y;
|
||||
const FLOAT32 *ptr_w;
|
||||
|
||||
dig_rev_shift = ixheaac_norm32(m_points) + 1 - 16;
|
||||
n_stages = 30 - ixheaac_norm32(m_points);
|
||||
not_power_4 = n_stages & 1;
|
||||
|
||||
n_stages = n_stages >> 1;
|
||||
|
||||
ptr_w = ia_fft_twiddle_table_float;
|
||||
|
||||
for (i = 0; i < n_points; i++) {
|
||||
ptr_x[2 * i] = ptr_real[i];
|
||||
ptr_x[2 * i + 1] = ptr_imag[i];
|
||||
}
|
||||
dig_rev_shift = max(dig_rev_shift, 0);
|
||||
for (i = 0; i < n_points; i += 4) {
|
||||
FLOAT32 *inp = ptr_x;
|
||||
FLOAT32 tmk;
|
||||
|
||||
DIG_REV(i, dig_rev_shift, h2);
|
||||
if (not_power_4) {
|
||||
h2 += 1;
|
||||
h2 &= ~1;
|
||||
}
|
||||
inp += (h2);
|
||||
|
||||
x0r = *inp;
|
||||
x0i = *(inp + 1);
|
||||
inp += (n_points >> 1);
|
||||
|
||||
x1r = *inp;
|
||||
x1i = *(inp + 1);
|
||||
inp += (n_points >> 1);
|
||||
|
||||
x2r = *inp;
|
||||
x2i = *(inp + 1);
|
||||
inp += (n_points >> 1);
|
||||
|
||||
x3r = *inp;
|
||||
x3i = *(inp + 1);
|
||||
|
||||
x0r = ia_add_flt(x0r, x2r);
|
||||
x0i = ia_add_flt(x0i, x2i);
|
||||
|
||||
tmk = ia_sub_flt(x0r, x2r);
|
||||
x2r = ia_sub_flt(tmk, x2r);
|
||||
tmk = ia_sub_flt(x0i, x2i);
|
||||
x2i = ia_sub_flt(tmk, x2i);
|
||||
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_add_flt(x1i, x3i);
|
||||
|
||||
tmk = ia_sub_flt(x1r, x3r);
|
||||
x3r = ia_sub_flt(tmk, x3r);
|
||||
tmk = ia_sub_flt(x1i, x3i);
|
||||
x3i = ia_sub_flt(tmk, x3i);
|
||||
|
||||
x0r = ia_add_flt(x0r, x1r);
|
||||
x0i = ia_add_flt(x0i, x1i);
|
||||
|
||||
tmk = ia_sub_flt(x0r, x1r);
|
||||
x1r = ia_sub_flt(tmk, x1r);
|
||||
tmk = ia_sub_flt(x0i, x1i);
|
||||
x1i = ia_sub_flt(tmk, x1i);
|
||||
|
||||
x2r = ia_add_flt(x2r, x3i);
|
||||
x2i = ia_sub_flt(x2i, x3r);
|
||||
|
||||
tmk = ia_sub_flt(x2r, x3i);
|
||||
x3i = ia_sub_flt(tmk, x3i);
|
||||
tmk = ia_add_flt(x2i, x3r);
|
||||
x3r = ia_add_flt(tmk, x3r);
|
||||
|
||||
*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 * n_points;
|
||||
del = 4;
|
||||
nodespacing = 64;
|
||||
in_loop_cnt = n_points >> 4;
|
||||
for (i = n_stages - 1; i > 0; i--) {
|
||||
const FLOAT32 *twiddles = ptr_w;
|
||||
FLOAT32 *data = ptr_y;
|
||||
FLOAT32 w_1, w_2, w_3, w_4, w_5, w_6;
|
||||
WORD32 sec_loop_cnt;
|
||||
|
||||
for (k = in_loop_cnt; k != 0; k--) {
|
||||
x0r = (*data);
|
||||
x0i = (*(data + 1));
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = (*data);
|
||||
x1i = (*(data + 1));
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x2r = (*data);
|
||||
x2i = (*(data + 1));
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x3r = (*data);
|
||||
x3i = (*(data + 1));
|
||||
data -= 3 * (del << 1);
|
||||
|
||||
x0r = ia_add_flt(x0r, x2r);
|
||||
x0i = ia_add_flt(x0i, x2i);
|
||||
x2r = ia_msu_flt(x0r, x2r, 2);
|
||||
x2i = ia_msu_flt(x0i, x2i, 2);
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_add_flt(x1i, x3i);
|
||||
x3r = ia_msu_flt(x1r, x3r, 2);
|
||||
x3i = ia_msu_flt(x1i, x3i, 2);
|
||||
|
||||
x0r = ia_add_flt(x0r, x1r);
|
||||
x0i = ia_add_flt(x0i, x1i);
|
||||
x1r = ia_msu_flt(x0r, x1r, 2);
|
||||
x1i = ia_msu_flt(x0i, x1i, 2);
|
||||
x2r = ia_add_flt(x2r, x3i);
|
||||
x2i = ia_sub_flt(x2i, x3r);
|
||||
x3i = ia_msu_flt(x2r, x3i, 2);
|
||||
x3r = ia_mac_flt(x2i, x3r, 2);
|
||||
|
||||
*data = x0r;
|
||||
*(data + 1) = x0i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x2r;
|
||||
*(data + 1) = x2i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x1r;
|
||||
*(data + 1) = x1i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x3i;
|
||||
*(data + 1) = x3r;
|
||||
data += ((SIZE_T)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);
|
||||
|
||||
for (j = nodespacing; j <= sec_loop_cnt; j += nodespacing) {
|
||||
w_1 = *(twiddles + j);
|
||||
w_4 = *(twiddles + j + 257);
|
||||
w_2 = *(twiddles + ((SIZE_T)j << 1));
|
||||
w_5 = *(twiddles + ((SIZE_T)j << 1) + 257);
|
||||
w_3 = *(twiddles + j + ((SIZE_T)j << 1));
|
||||
w_6 = *(twiddles + j + ((SIZE_T)j << 1) + 257);
|
||||
|
||||
for (k = in_loop_cnt; k != 0; k--) {
|
||||
FLOAT32 tmp;
|
||||
/*x0 is loaded later to avoid register crunch*/
|
||||
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *data;
|
||||
x1i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x2r = *data;
|
||||
x2i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x3r = *data;
|
||||
x3i = *(data + 1);
|
||||
data -= 3 * (del << 1);
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x1r, w_1), ia_mul_flt(x1i, w_4));
|
||||
x1i = ia_mac_flt(ia_mul_flt(x1r, w_4), x1i, w_1);
|
||||
x1r = tmp;
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x2r, w_2), ia_mul_flt(x2i, w_5));
|
||||
x2i = ia_mac_flt(ia_mul_flt(x2r, w_5), x2i, w_2);
|
||||
x2r = tmp;
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x3r, w_3), ia_mul_flt(x3i, w_6));
|
||||
x3i = ia_mac_flt(ia_mul_flt(x3r, w_6), x3i, w_3);
|
||||
x3r = tmp;
|
||||
|
||||
x0r = (*data);
|
||||
x0i = (*(data + 1));
|
||||
|
||||
x0r = ia_add_flt(x0r, (x2r));
|
||||
x0i = ia_add_flt(x0i, (x2i));
|
||||
x2r = ia_msu_flt(x0r, x2r, 2);
|
||||
x2i = ia_msu_flt(x0i, x2i, 2);
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_add_flt(x1i, x3i);
|
||||
x3r = ia_msu_flt(x1r, x3r, 2);
|
||||
x3i = ia_msu_flt(x1i, x3i, 2);
|
||||
|
||||
x0r = ia_add_flt(x0r, (x1r));
|
||||
x0i = ia_add_flt(x0i, (x1i));
|
||||
x1r = ia_msu_flt(x0r, x1r, 2);
|
||||
x1i = ia_msu_flt(x0i, x1i, 2);
|
||||
x2r = ia_add_flt(x2r, (x3i));
|
||||
x2i = ia_sub_flt(x2i, (x3r));
|
||||
x3i = ia_msu_flt(x2r, x3i, 2);
|
||||
x3r = ia_mac_flt(x2i, x3r, 2);
|
||||
|
||||
*data = x0r;
|
||||
*(data + 1) = x0i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x2r;
|
||||
*(data + 1) = x2i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x1r;
|
||||
*(data + 1) = x1i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x3i;
|
||||
*(data + 1) = x3r;
|
||||
data += ((SIZE_T)del << 1);
|
||||
}
|
||||
data -= 2 * n_points;
|
||||
data += 2;
|
||||
}
|
||||
for (; j <= (nodespacing * del) >> 1; j += nodespacing) {
|
||||
w_1 = *(twiddles + j);
|
||||
w_4 = *(twiddles + j + 257);
|
||||
w_2 = *(twiddles + ((SIZE_T)j << 1));
|
||||
w_5 = *(twiddles + ((SIZE_T)j << 1) + 257);
|
||||
w_3 = *(twiddles + j + ((SIZE_T)j << 1) - 256);
|
||||
w_6 = *(twiddles + j + ((SIZE_T)j << 1) + 1);
|
||||
|
||||
for (k = in_loop_cnt; k != 0; k--) {
|
||||
FLOAT32 tmp;
|
||||
/*x0 is loaded later to avoid register crunch*/
|
||||
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *data;
|
||||
x1i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x2r = *data;
|
||||
x2i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x3r = *data;
|
||||
x3i = *(data + 1);
|
||||
data -= 3 * (del << 1);
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x1r, w_1), ia_mul_flt(x1i, w_4));
|
||||
x1i = ia_mac_flt(ia_mul_flt(x1r, w_4), x1i, w_1);
|
||||
x1r = tmp;
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x2r, w_2), ia_mul_flt(x2i, w_5));
|
||||
x2i = ia_mac_flt(ia_mul_flt(x2r, w_5), x2i, w_2);
|
||||
x2r = tmp;
|
||||
|
||||
tmp = ia_add_flt(ia_mul_flt(x3r, w_6), ia_mul_flt(x3i, w_3));
|
||||
x3i = ia_add_flt(ia_negate_flt(ia_mul_flt(x3r, w_3)), ia_mul_flt(x3i, w_6));
|
||||
x3r = tmp;
|
||||
|
||||
x0r = (*data);
|
||||
x0i = (*(data + 1));
|
||||
|
||||
x0r = ia_add_flt(x0r, (x2r));
|
||||
x0i = ia_add_flt(x0i, (x2i));
|
||||
x2r = ia_msu_flt(x0r, x2r, 2);
|
||||
x2i = ia_msu_flt(x0i, x2i, 2);
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_add_flt(x1i, x3i);
|
||||
x3r = ia_msu_flt(x1r, x3r, 2);
|
||||
x3i = ia_msu_flt(x1i, x3i, 2);
|
||||
|
||||
x0r = ia_add_flt(x0r, (x1r));
|
||||
x0i = ia_add_flt(x0i, (x1i));
|
||||
x1r = ia_msu_flt(x0r, x1r, 2);
|
||||
x1i = ia_msu_flt(x0i, x1i, 2);
|
||||
x2r = ia_add_flt(x2r, (x3i));
|
||||
x2i = ia_sub_flt(x2i, (x3r));
|
||||
x3i = ia_msu_flt(x2r, x3i, 2);
|
||||
x3r = ia_mac_flt(x2i, x3r, 2);
|
||||
|
||||
*data = x0r;
|
||||
*(data + 1) = x0i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x2r;
|
||||
*(data + 1) = x2i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x1r;
|
||||
*(data + 1) = x1i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x3i;
|
||||
*(data + 1) = x3r;
|
||||
data += ((SIZE_T)del << 1);
|
||||
}
|
||||
data -= 2 * n_points;
|
||||
data += 2;
|
||||
}
|
||||
for (; j <= sec_loop_cnt * 2; j += nodespacing) {
|
||||
w_1 = *(twiddles + j);
|
||||
w_4 = *(twiddles + j + 257);
|
||||
w_2 = *(twiddles + ((SIZE_T)j << 1) - 256);
|
||||
w_5 = *(twiddles + ((SIZE_T)j << 1) + 1);
|
||||
w_3 = *(twiddles + j + ((SIZE_T)j << 1) - 256);
|
||||
w_6 = *(twiddles + j + ((SIZE_T)j << 1) + 1);
|
||||
|
||||
for (k = in_loop_cnt; k != 0; k--) {
|
||||
FLOAT32 tmp;
|
||||
/*x0 is loaded later to avoid register crunch*/
|
||||
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *data;
|
||||
x1i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x2r = *data;
|
||||
x2i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x3r = *data;
|
||||
x3i = *(data + 1);
|
||||
data -= 3 * (del << 1);
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x1r, w_1), ia_mul_flt(x1i, w_4));
|
||||
x1i = ia_mac_flt(ia_mul_flt(x1r, w_4), x1i, w_1);
|
||||
x1r = tmp;
|
||||
|
||||
tmp = ia_add_flt(ia_mul_flt(x2r, w_5), ia_mul_flt(x2i, w_2));
|
||||
x2i = ia_add_flt(ia_negate_flt(ia_mul_flt(x2r, w_2)), ia_mul_flt(x2i, w_5));
|
||||
x2r = tmp;
|
||||
|
||||
tmp = ia_add_flt(ia_mul_flt(x3r, w_6), ia_mul_flt(x3i, w_3));
|
||||
x3i = ia_add_flt(ia_negate_flt(ia_mul_flt(x3r, w_3)), ia_mul_flt(x3i, w_6));
|
||||
x3r = tmp;
|
||||
|
||||
x0r = (*data);
|
||||
x0i = (*(data + 1));
|
||||
|
||||
x0r = ia_add_flt(x0r, (x2r));
|
||||
x0i = ia_add_flt(x0i, (x2i));
|
||||
x2r = ia_msu_flt(x0r, x2r, 2);
|
||||
x2i = ia_msu_flt(x0i, x2i, 2);
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_add_flt(x1i, x3i);
|
||||
x3r = ia_msu_flt(x1r, x3r, 2);
|
||||
x3i = ia_msu_flt(x1i, x3i, 2);
|
||||
|
||||
x0r = ia_add_flt(x0r, (x1r));
|
||||
x0i = ia_add_flt(x0i, (x1i));
|
||||
x1r = ia_msu_flt(x0r, x1r, 2);
|
||||
x1i = ia_msu_flt(x0i, x1i, 2);
|
||||
x2r = ia_add_flt(x2r, (x3i));
|
||||
x2i = ia_sub_flt(x2i, (x3r));
|
||||
x3i = ia_msu_flt(x2r, x3i, 2);
|
||||
x3r = ia_mac_flt(x2i, x3r, 2);
|
||||
|
||||
*data = x0r;
|
||||
*(data + 1) = x0i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x2r;
|
||||
*(data + 1) = x2i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x1r;
|
||||
*(data + 1) = x1i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x3i;
|
||||
*(data + 1) = x3r;
|
||||
data += ((SIZE_T)del << 1);
|
||||
}
|
||||
data -= 2 * n_points;
|
||||
data += 2;
|
||||
}
|
||||
for (; j < nodespacing * del; j += nodespacing) {
|
||||
w_1 = *(twiddles + j);
|
||||
w_4 = *(twiddles + j + 257);
|
||||
w_2 = *(twiddles + ((SIZE_T)j << 1) - 256);
|
||||
w_5 = *(twiddles + ((SIZE_T)j << 1) + 1);
|
||||
w_3 = *(twiddles + j + ((SIZE_T)j << 1) - 512);
|
||||
w_6 = *(twiddles + j + ((SIZE_T)j << 1) - 512 + 257);
|
||||
|
||||
for (k = in_loop_cnt; k != 0; k--) {
|
||||
FLOAT32 tmp;
|
||||
/*x0 is loaded later to avoid register crunch*/
|
||||
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *data;
|
||||
x1i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x2r = *data;
|
||||
x2i = *(data + 1);
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
x3r = *data;
|
||||
x3i = *(data + 1);
|
||||
data -= 3 * (del << 1);
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x1r, w_1), ia_mul_flt(x1i, w_4));
|
||||
x1i = ia_mac_flt(ia_mul_flt(x1r, w_4), x1i, w_1);
|
||||
x1r = tmp;
|
||||
|
||||
tmp = ia_add_flt(ia_mul_flt(x2r, w_5), ia_mul_flt(x2i, w_2));
|
||||
x2i = ia_add_flt(ia_negate_flt(ia_mul_flt(x2r, w_2)), ia_mul_flt(x2i, w_5));
|
||||
x2r = tmp;
|
||||
|
||||
tmp = ia_add_flt(ia_negate_flt(ia_mul_flt(x3r, w_3)), ia_mul_flt(x3i, w_6));
|
||||
x3i = ia_mac_flt(ia_mul_flt(x3r, w_6), x3i, w_3);
|
||||
x3r = tmp;
|
||||
|
||||
x0r = (*data);
|
||||
x0i = (*(data + 1));
|
||||
|
||||
x0r = ia_add_flt(x0r, (x2r));
|
||||
x0i = ia_add_flt(x0i, (x2i));
|
||||
x2r = ia_msu_flt(x0r, x2r, 2);
|
||||
x2i = ia_msu_flt(x0i, x2i, 2);
|
||||
x1r = ia_add_flt(x1r, x3r);
|
||||
x1i = ia_sub_flt(x1i, x3i);
|
||||
x3r = ia_msu_flt(x1r, x3r, 2);
|
||||
x3i = ia_mac_flt(x1i, x3i, 2);
|
||||
|
||||
x0r = ia_add_flt(x0r, (x1r));
|
||||
x0i = ia_add_flt(x0i, (x1i));
|
||||
x1r = ia_msu_flt(x0r, x1r, 2);
|
||||
x1i = ia_msu_flt(x0i, x1i, 2);
|
||||
x2r = ia_add_flt(x2r, (x3i));
|
||||
x2i = ia_sub_flt(x2i, (x3r));
|
||||
x3i = ia_msu_flt(x2r, x3i, 2);
|
||||
x3r = ia_mac_flt(x2i, x3r, 2);
|
||||
|
||||
*data = x0r;
|
||||
*(data + 1) = x0i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x2r;
|
||||
*(data + 1) = x2i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x1r;
|
||||
*(data + 1) = x1i;
|
||||
data += ((SIZE_T)del << 1);
|
||||
|
||||
*data = x3i;
|
||||
*(data + 1) = x3r;
|
||||
data += ((SIZE_T)del << 1);
|
||||
}
|
||||
data -= 2 * n_points;
|
||||
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 w_1 = *twiddles;
|
||||
FLOAT32 w_4 = *(twiddles + 257);
|
||||
FLOAT32 tmp;
|
||||
twiddles += nodespacing;
|
||||
|
||||
x0r = *ptr_y;
|
||||
x0i = *(ptr_y + 1);
|
||||
ptr_y += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *ptr_y;
|
||||
x1i = *(ptr_y + 1);
|
||||
|
||||
tmp = ia_sub_flt(ia_mul_flt(x1r, w_1), ia_mul_flt(x1i, w_4));
|
||||
x1i = (FLOAT32)ia_mac_flt(ia_mul_flt(x1r, w_4), x1i, w_1);
|
||||
x1r = tmp;
|
||||
|
||||
*ptr_y = ia_sub_flt((x0r), (x1r));
|
||||
*(ptr_y + 1) = ia_sub_flt((x0i), (x1i));
|
||||
ptr_y -= ((SIZE_T)del << 1);
|
||||
|
||||
*ptr_y = ia_add_flt((x0r), (x1r));
|
||||
*(ptr_y + 1) = ia_add_flt((x0i), (x1i));
|
||||
ptr_y += 2;
|
||||
}
|
||||
twiddles = ptr_w;
|
||||
for (j = del / 2; j != 0; j--) {
|
||||
FLOAT32 w_1 = *twiddles;
|
||||
FLOAT32 w_4 = *(twiddles + 257);
|
||||
FLOAT32 tmp;
|
||||
twiddles += nodespacing;
|
||||
|
||||
x0r = *ptr_y;
|
||||
x0i = *(ptr_y + 1);
|
||||
ptr_y += ((SIZE_T)del << 1);
|
||||
|
||||
x1r = *ptr_y;
|
||||
x1i = *(ptr_y + 1);
|
||||
|
||||
tmp = ia_add_flt(ia_mul_flt(x1r, w_4), ia_mul_flt(x1i, w_1));
|
||||
x1i = ia_add_flt(ia_negate_flt(ia_mul_flt(x1r, w_1)), ia_mul_flt(x1i, w_4));
|
||||
x1r = tmp;
|
||||
|
||||
*ptr_y = ia_sub_flt((x0r), (x1r));
|
||||
*(ptr_y + 1) = ia_sub_flt((x0i), (x1i));
|
||||
ptr_y -= ((SIZE_T)del << 1);
|
||||
|
||||
*ptr_y = ia_add_flt((x0r), (x1r));
|
||||
*(ptr_y + 1) = ia_add_flt((x0i), (x1i));
|
||||
ptr_y += 2;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < n_points; i++) {
|
||||
ptr_real[i] = y[2 * i];
|
||||
ptr_imag[i] = y[2 * i + 1];
|
||||
}
|
||||
}
|
||||
static VOID ixheaace_cplx_fft_4(FLOAT32 *x_r, FLOAT32 *x_i) {
|
||||
FLOAT32 x_0, x_1, x_2, x_3;
|
||||
FLOAT32 x_4, x_5, x_6, x_7;
|
||||
FLOAT32 x0r, x1r, x2r, x3r;
|
||||
FLOAT32 x0i, x1i, x2i, x3i;
|
||||
|
||||
// 4 Point FFT
|
||||
x_0 = x_r[0];
|
||||
x_1 = x_i[0];
|
||||
x_2 = x_r[1];
|
||||
x_3 = x_i[1];
|
||||
x_4 = x_r[2];
|
||||
x_5 = x_i[2];
|
||||
x_6 = x_r[3];
|
||||
x_7 = x_i[3];
|
||||
|
||||
x0r = ia_add_flt(x_0, x_4);
|
||||
x0i = ia_add_flt(x_1, x_5);
|
||||
x2r = ia_sub_flt(x_0, x_4);
|
||||
x2i = ia_sub_flt(x_1, x_5);
|
||||
x1r = ia_add_flt(x_2, x_6);
|
||||
x1i = ia_add_flt(x_3, x_7);
|
||||
x3r = ia_sub_flt(x_2, x_6);
|
||||
x3i = ia_sub_flt(x_3, x_7);
|
||||
|
||||
x_r[0] = ia_add_flt(x0r, x1r);
|
||||
x_i[0] = ia_add_flt(x0i, x1i);
|
||||
x_r[2] = ia_sub_flt(x0r, x1r);
|
||||
x_i[2] = ia_sub_flt(x0i, x1i);
|
||||
x_r[1] = ia_add_flt(x2r, x3i);
|
||||
x_i[1] = ia_sub_flt(x2i, x3r);
|
||||
x_r[3] = ia_sub_flt(x2r, x3i);
|
||||
x_i[3] = ia_add_flt(x2i, x3r);
|
||||
return;
|
||||
}
|
||||
VOID iusace_complex_fft_4096(FLOAT32 *ptr_x_r, FLOAT32 *ptr_x_i, FLOAT32 *ptr_scratch_buf) {
|
||||
FLOAT32 *ptr_data_r;
|
||||
FLOAT32 *ptr_data_i;
|
||||
WORD32 fft_len = 4096;
|
||||
FLOAT32 *ptr_fft_interim_buf = &ptr_scratch_buf[2 * fft_len];
|
||||
WORD32 i, j;
|
||||
WORD32 dim2 = fft_len >> 10;
|
||||
WORD32 dim1 = fft_len / dim2;
|
||||
WORD32 fac = 4;
|
||||
|
||||
for (i = 0; i < dim2; i++) {
|
||||
ptr_data_r = &ptr_scratch_buf[(2 * i + 0) * dim1];
|
||||
ptr_data_i = &ptr_scratch_buf[(2 * i + 1) * dim1];
|
||||
for (j = 0; j < dim1; j++) {
|
||||
ptr_data_r[j] = ptr_x_r[(dim2 * j + i)];
|
||||
ptr_data_i[j] = 0;
|
||||
}
|
||||
ixheaace_rad2_cplx_fft(ptr_data_r, ptr_data_i, dim1, ptr_fft_interim_buf);
|
||||
}
|
||||
ptr_data_r = &ptr_scratch_buf[0];
|
||||
ptr_data_i = &ptr_scratch_buf[0];
|
||||
for (i = 0; i < dim1; i++) {
|
||||
FLOAT32 *ptr_cos_val = (FLOAT32 *)&ia_mixed_rad_twiddle_cos[i * dim2 * fac];
|
||||
FLOAT32 *ptr_sin_val = (FLOAT32 *)&ia_mixed_rad_twiddle_sin[i * dim2 * fac];
|
||||
for (j = 0; j < dim2; j++) {
|
||||
FLOAT32 real = ptr_data_r[(2 * j + 0) * dim1 + i];
|
||||
FLOAT32 imag = ptr_data_i[(2 * j + 1) * dim1 + i];
|
||||
FLOAT32 cos_val = ptr_cos_val[j * fac];
|
||||
FLOAT32 sin_val = ptr_sin_val[j * fac];
|
||||
FLOAT32 temp_real = (FLOAT32)(real * cos_val + imag * sin_val);
|
||||
FLOAT32 temp_imag = (FLOAT32)(imag * cos_val - real * sin_val);
|
||||
ptr_fft_interim_buf[(2 * i + 0) * dim2 + j] = temp_real;
|
||||
ptr_fft_interim_buf[(2 * i + 1) * dim2 + j] = temp_imag;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < dim1; i++) {
|
||||
ptr_data_r = &ptr_fft_interim_buf[(2 * i + 0) * dim2];
|
||||
ptr_data_i = &ptr_fft_interim_buf[(2 * i + 1) * dim2];
|
||||
ixheaace_cplx_fft_4(ptr_data_r, ptr_data_i);
|
||||
}
|
||||
ptr_data_r = &ptr_fft_interim_buf[0];
|
||||
ptr_data_i = &ptr_fft_interim_buf[0];
|
||||
for (i = 0; i < dim1; i++) {
|
||||
for (j = 0; j < dim2; j++) {
|
||||
ptr_x_r[(j * dim1 + i)] = ptr_data_r[(2 * i + 0) * dim2 + j];
|
||||
ptr_x_i[(j * dim1 + i)] = ptr_data_i[(2 * i + 1) * dim2 + j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,3 +34,8 @@
|
|||
re = ((a * c) - (b * d)); \
|
||||
im = ((a * d) + (b * c)); \
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_fft_based_mdct(FLOAT64 *ptr_in, FLOAT64 *ptr_out, WORD32 npoints,
|
||||
const WORD32 tx_flag, iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_complex_fft(FLOAT32 *data, WORD32 nlength, iusace_scratch_mem *pstr_scratch);
|
||||
|
|
|
|||
81
encoder/iusace_func_prototypes.h
Normal file
81
encoder/iusace_func_prototypes.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
VOID iusace_write_bits2buf(WORD32 value, WORD32 no_of_bits, WORD16 *bitstream);
|
||||
|
||||
WORD32 iusace_get_num_params(WORD32 *qn);
|
||||
|
||||
VOID iusace_highpass_50hz_12k8(FLOAT32 *signal, WORD32 lg, FLOAT32 *mem, WORD32 fscale);
|
||||
|
||||
IA_ERRORCODE iusace_lpd_frm_enc(ia_usac_data_struct *usac_data, WORD32 *mod_out,
|
||||
WORD32 const usac_independency_flg,
|
||||
WORD32 len_frame,
|
||||
WORD32 i_ch, ia_bit_buf_struct *pstr_it_bit_buff);
|
||||
|
||||
VOID iusace_init_td_data(ia_usac_td_encoder_struct *st, WORD32 len_frame);
|
||||
|
||||
VOID iusace_config_acelp_core_mode(ia_usac_td_encoder_struct *st, WORD32 sampling_rate,
|
||||
WORD32 bitrate);
|
||||
|
||||
VOID iusace_reset_td_enc(ia_usac_td_encoder_struct *st);
|
||||
|
||||
VOID iusace_core_lpd_encode(ia_usac_data_struct *usac_data, FLOAT32 *speech, WORD32 *mode,
|
||||
WORD32 *num_tcx_param, WORD32 ch_idx);
|
||||
|
||||
VOID iusace_encode_fac_params(WORD32 *mod, WORD32 *n_param_tcx, ia_usac_data_struct *usac_data,
|
||||
WORD32 const usac_independency_flag,
|
||||
ia_bit_buf_struct *pstr_it_bit_buff, WORD32 ch_idx);
|
||||
|
||||
VOID iusace_acelp_encode(FLOAT32 *lp_filt_coeff, FLOAT32 *quant_lp_filt_coeff, FLOAT32 *speech_in,
|
||||
FLOAT32 *wsig_in, FLOAT32 *synth_out, FLOAT32 *wsynth_out,
|
||||
WORD16 acelp_core_mode, ia_usac_lpd_state_struct *lpd_state,
|
||||
WORD32 len_subfrm, FLOAT32 norm_corr, FLOAT32 norm_corr2,
|
||||
WORD32 ol_pitch_lag1, WORD32 ol_pitch_lag2, WORD32 pit_adj,
|
||||
WORD32 *acelp_params, iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_tcx_fac_encode(ia_usac_data_struct *usac_data, FLOAT32 *lpc_coeffs,
|
||||
FLOAT32 *lpc_coeffs_quant, FLOAT32 *speech, WORD32 frame_len,
|
||||
WORD32 num_bits_per_supfrm, ia_usac_lpd_state_struct *lpd_state,
|
||||
WORD32 *params, WORD32 *n_param, WORD32 ch_idx, WORD32 k_idx);
|
||||
|
||||
VOID iusace_fac_apply(FLOAT32 *orig, WORD32 len_subfrm, WORD32 fac_len, WORD32 low_pass_line,
|
||||
WORD32 target_br, FLOAT32 *synth, FLOAT32 *ptr_lpc_coeffs,
|
||||
WORD16 *fac_bits_word, WORD32 *num_fac_bits,
|
||||
iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_quantize_lpc_avq(FLOAT32 *ptr_lsf, FLOAT32 *ptr_lsfq, WORD32 lpc0,
|
||||
WORD32 *ptr_lpc_idx, WORD32 *nb_indices, WORD32 *nbbits);
|
||||
|
||||
VOID iusace_lsp_2_lsf_conversion(FLOAT32 *lsp, FLOAT32 *lsf);
|
||||
VOID iusace_lsp_to_lp_conversion(FLOAT32 *lsp, FLOAT32 *lp_flt_coff_a);
|
||||
|
||||
VOID iusace_find_weighted_speech(FLOAT32 *filter_coef, FLOAT32 *speech, FLOAT32 *wsp,
|
||||
FLOAT32 *mem_wsp, WORD32 length);
|
||||
|
||||
IA_ERRORCODE iusace_fd_fac(WORD32 *sfb_offsets, WORD32 sfb_active, FLOAT64 *orig_sig_dbl,
|
||||
WORD32 window_sequence, FLOAT64 *synth_time,
|
||||
ia_usac_td_encoder_struct *pstr_acelp, WORD32 last_subfr_was_acelp,
|
||||
WORD32 next_frm_lpd, WORD16 *fac_prm_out, WORD32 *num_fac_bits,
|
||||
iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
FLOAT32 iusace_cal_segsnr(FLOAT32 *sig1, FLOAT32 *sig2, WORD16 len, WORD16 nseg);
|
||||
|
||||
WORD32 iusace_fd_encode_fac(WORD32 *prm, WORD16 *ptr_bit_buf, WORD32 fac_length);
|
||||
216
encoder/iusace_lpc.c
Normal file
216
encoder/iusace_lpc.c
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
static FLOAT32 iusace_lpc_eval_chebyshev_polyn(FLOAT32 x, FLOAT32 *coefs, WORD32 order) {
|
||||
WORD32 i;
|
||||
FLOAT32 b0, b1, b2, x2;
|
||||
x2 = 2.0f * x;
|
||||
b2 = 1.0f;
|
||||
b1 = x2 + coefs[1];
|
||||
for (i = 2; i < order; i++) {
|
||||
b0 = x2 * b1 - b2 + coefs[i];
|
||||
b2 = b1;
|
||||
b1 = b0;
|
||||
}
|
||||
return (x * b1 - b2 + 0.5f * coefs[order]);
|
||||
}
|
||||
|
||||
VOID iusace_lpc_2_lsp_conversion(FLOAT32 *lpc, FLOAT32 *lsp, FLOAT32 *prev_lsp) {
|
||||
FLOAT32 sum_polyn[(ORDER_BY_2) + 1], diff_polyn[(ORDER_BY_2) + 1];
|
||||
FLOAT32 *p1_lpc, *p2_lpc, *p_sum_polyn, *p_diff_polyn;
|
||||
WORD32 i, j = 0, num_found_freeq = 0, is_first_polyn = 0;
|
||||
FLOAT32 x_low, y_low, x_high, y_high, x_mid, y_mid, x_lin_interp;
|
||||
|
||||
p_sum_polyn = sum_polyn;
|
||||
p_diff_polyn = diff_polyn;
|
||||
*p_sum_polyn++ = 1.0f;
|
||||
*p_diff_polyn++ = 1.0f;
|
||||
sum_polyn[0] = 1.0f;
|
||||
diff_polyn[0] = 1.0f;
|
||||
p1_lpc = lpc + 1;
|
||||
p2_lpc = lpc + ORDER;
|
||||
for (i = 0; i <= ORDER_BY_2 - 1; i++) {
|
||||
*p_sum_polyn = *p1_lpc + *p2_lpc - *(p_sum_polyn - 1);
|
||||
p_sum_polyn++;
|
||||
*p_diff_polyn = *p1_lpc++ - *p2_lpc-- + *(p_diff_polyn - 1);
|
||||
p_diff_polyn++;
|
||||
}
|
||||
p_sum_polyn = sum_polyn;
|
||||
x_low = iusace_chebyshev_polyn_grid[0];
|
||||
y_low = iusace_lpc_eval_chebyshev_polyn(x_low, p_sum_polyn, ORDER_BY_2);
|
||||
|
||||
while ((num_found_freeq < ORDER) && (j < CHEBYSHEV_NUM_POINTS)) {
|
||||
j++;
|
||||
x_high = x_low;
|
||||
y_high = y_low;
|
||||
x_low = iusace_chebyshev_polyn_grid[j];
|
||||
y_low = iusace_lpc_eval_chebyshev_polyn(x_low, p_sum_polyn, ORDER_BY_2);
|
||||
|
||||
if (y_low * y_high <= 0.0) /* if sign change new root exists */
|
||||
{
|
||||
j--;
|
||||
for (i = 0; i < CHEBYSHEV_NUM_ITER; i++) {
|
||||
x_mid = 0.5f * (x_low + x_high);
|
||||
y_mid = iusace_lpc_eval_chebyshev_polyn(x_mid, p_sum_polyn, ORDER_BY_2);
|
||||
if (y_low * y_mid <= 0.0) {
|
||||
y_high = y_mid;
|
||||
x_high = x_mid;
|
||||
} else {
|
||||
y_low = y_mid;
|
||||
x_low = x_mid;
|
||||
}
|
||||
}
|
||||
|
||||
/* linear interpolation for evaluating the root */
|
||||
x_lin_interp = x_low - y_low * (x_high - x_low) / (y_high - y_low);
|
||||
|
||||
lsp[num_found_freeq] = x_lin_interp;
|
||||
num_found_freeq++;
|
||||
|
||||
is_first_polyn = 1 - is_first_polyn;
|
||||
p_sum_polyn = is_first_polyn ? diff_polyn : sum_polyn;
|
||||
|
||||
x_low = x_lin_interp;
|
||||
y_low = iusace_lpc_eval_chebyshev_polyn(x_low, p_sum_polyn, ORDER_BY_2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if ORDER roots found */
|
||||
/* if not use the LSPs from previous frame */
|
||||
if (num_found_freeq < ORDER) {
|
||||
for (i = 0; i < ORDER; i++) lsp[i] = prev_lsp[i];
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_compute_coeff_poly_f(FLOAT32 *lsp, FLOAT32 *poly1, FLOAT32 *poly2) {
|
||||
FLOAT32 b1, b2;
|
||||
FLOAT32 *ptr_lsp;
|
||||
WORD32 i, j;
|
||||
|
||||
ptr_lsp = lsp;
|
||||
poly1[0] = poly2[0] = 1.0f;
|
||||
|
||||
for (i = 1; i <= ORDER_BY_2; i++) {
|
||||
b1 = -2.0f * (*ptr_lsp++);
|
||||
b2 = -2.0f * (*ptr_lsp++);
|
||||
poly1[i] = (b1 * poly1[i - 1]) + (2.0f * poly1[i - 2]);
|
||||
poly2[i] = (b2 * poly2[i - 1]) + (2.0f * poly2[i - 2]);
|
||||
for (j = i - 1; j > 0; j--) {
|
||||
poly1[j] += (b1 * poly1[j - 1]) + poly1[j - 2];
|
||||
poly2[j] += (b2 * poly2[j - 1]) + poly2[j - 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_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;
|
||||
|
||||
iusace_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++);
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_levinson_durbin_algo(FLOAT32 *auto_corr_input, FLOAT32 *lpc) {
|
||||
WORD32 i, j;
|
||||
FLOAT32 lpc_val, sum, sigma;
|
||||
FLOAT32 reflection_coeffs[LEV_DUR_MAX_ORDER];
|
||||
|
||||
lpc[0] = 1.0f;
|
||||
|
||||
reflection_coeffs[0] = -auto_corr_input[1] / auto_corr_input[0];
|
||||
lpc[1] = reflection_coeffs[0];
|
||||
sigma = auto_corr_input[0] + auto_corr_input[1] * reflection_coeffs[0];
|
||||
|
||||
for (i = 2; i <= ORDER; i++) {
|
||||
sum = 0.0f;
|
||||
for (j = 0; j < i; j++) sum += auto_corr_input[i - j] * lpc[j];
|
||||
reflection_coeffs[i - 1] = -sum / sigma;
|
||||
|
||||
sigma = sigma * (1.0f - reflection_coeffs[i - 1] * reflection_coeffs[i - 1]);
|
||||
|
||||
if (sigma <= 1.0E-09f) {
|
||||
for (j = i; j <= ORDER; j++) {
|
||||
reflection_coeffs[j - 1] = 0.0f;
|
||||
lpc[j] = 0.0f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (j = 1; j <= (i / 2); j++) {
|
||||
lpc_val = lpc[j] + reflection_coeffs[i - 1] * lpc[i - j];
|
||||
lpc[i - j] += reflection_coeffs[i - 1] * lpc[j];
|
||||
lpc[j] = lpc_val;
|
||||
}
|
||||
|
||||
lpc[i] = reflection_coeffs[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_get_weighted_lpc(FLOAT32 *lpc, FLOAT32 *weighted_lpc) {
|
||||
WORD32 i;
|
||||
for (i = 0; i <= ORDER; i++) {
|
||||
weighted_lpc[i] = iusace_gamma_table[i] * lpc[i];
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_lsp_2_lsf_conversion(FLOAT32 *lsp, FLOAT32 *lsf) {
|
||||
WORD32 i;
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
lsf[i] = (FLOAT32)(acos(lsp[i]) * LSP_2_LSF_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_lsf_2_lsp_conversion(FLOAT32 *lsf, FLOAT32 *lsp) {
|
||||
WORD32 i;
|
||||
for (i = 0; i < ORDER; i++) lsp[i] = (FLOAT32)cos((FLOAT64)lsf[i] * (FLOAT64)PI_BY_6400);
|
||||
}
|
||||
372
encoder/iusace_lpc_avq.c
Normal file
372
encoder/iusace_lpc_avq.c
Normal file
|
|
@ -0,0 +1,372 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_func_prototypes.h"
|
||||
#include "iusace_avq_enc.h"
|
||||
|
||||
static VOID iusace_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)(iusace_wlsf_factor_table[mode] / (FREQ_DIV / sqrt(d[i] * d[i + 1])));
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_lsf_weight(FLOAT32 *lsf, FLOAT32 *ptr_w) {
|
||||
WORD32 i;
|
||||
FLOAT32 d[ORDER + 1];
|
||||
|
||||
d[0] = lsf[0];
|
||||
d[ORDER] = FREQ_MAX - lsf[ORDER - 1];
|
||||
for (i = 1; i < ORDER; i++) {
|
||||
d[i] = lsf[i] - lsf[i - 1];
|
||||
}
|
||||
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
ptr_w[i] = (1.0f / d[i]) + (1.0f / d[i + 1]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static WORD32 iusace_avq_first_approx_abs(FLOAT32 *lsf, FLOAT32 *lsfq) {
|
||||
WORD32 i, j, index;
|
||||
FLOAT32 w[ORDER];
|
||||
FLOAT32 dist_min, dist, temp;
|
||||
const FLOAT32 *p_dico;
|
||||
|
||||
iusace_lsf_weight(lsf, w);
|
||||
|
||||
dist_min = 1.0e30f;
|
||||
p_dico = iusace_dico_lsf_abs_8b_flt;
|
||||
index = 0;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
dist = 0.0;
|
||||
for (j = 0; j < ORDER; j++) {
|
||||
temp = lsf[j] - *p_dico++;
|
||||
dist += w[j] * temp * temp;
|
||||
}
|
||||
if (dist < dist_min) {
|
||||
dist_min = dist;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < ORDER; j++) {
|
||||
lsfq[j] = iusace_dico_lsf_abs_8b_flt[index * ORDER + j];
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
static WORD32 iusace_avq_first_approx_rel(FLOAT32 *ptr_lsf, FLOAT32 *ptr_lsfq, WORD32 *idx,
|
||||
WORD32 mode) {
|
||||
WORD32 i, num_bits;
|
||||
FLOAT32 w[ORDER], x[ORDER], temp;
|
||||
WORD32 nq, avq[ORDER];
|
||||
FLOAT32 lsf_min;
|
||||
|
||||
iusace_lsf_weight_2st_flt(ptr_lsf, w, 1);
|
||||
|
||||
temp = 0.0f;
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
x[i] = (ptr_lsf[i] - ptr_lsfq[i]) / w[i];
|
||||
temp += x[i] * x[i];
|
||||
}
|
||||
|
||||
if (temp < 8.0f) {
|
||||
idx[0] = 0;
|
||||
idx[1] = 0;
|
||||
if ((mode == 0) || (mode == 3)) {
|
||||
return (10);
|
||||
} else if (mode == 1) {
|
||||
return (2);
|
||||
} else {
|
||||
return (6);
|
||||
}
|
||||
}
|
||||
|
||||
iusace_lsf_weight_2st_flt(ptr_lsfq, w, mode);
|
||||
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
x[i] = (ptr_lsf[i] - ptr_lsfq[i]) / w[i];
|
||||
}
|
||||
|
||||
iusace_alg_vec_quant(x, avq, idx);
|
||||
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
ptr_lsfq[i] += (w[i] * (FLOAT32)avq[i]);
|
||||
}
|
||||
|
||||
num_bits = 0;
|
||||
for (i = 0; i < 2; i++) {
|
||||
nq = idx[i];
|
||||
|
||||
if ((mode == 0) || (mode == 3)) {
|
||||
num_bits += (2 + (nq * 4));
|
||||
if (nq > 6) {
|
||||
num_bits += nq - 3;
|
||||
} else if (nq > 4) {
|
||||
num_bits += nq - 4;
|
||||
} else if (nq == 0) {
|
||||
num_bits += 3;
|
||||
}
|
||||
} else if (mode == 1) {
|
||||
num_bits += nq * 5;
|
||||
if (nq == 0) {
|
||||
num_bits += 1;
|
||||
}
|
||||
} else {
|
||||
num_bits += (2 + (nq * 4));
|
||||
if (nq == 0) {
|
||||
num_bits += 1;
|
||||
} else if (nq > 4) {
|
||||
num_bits += nq - 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lsf_min = LSF_GAP;
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
if (ptr_lsfq[i] < lsf_min) {
|
||||
ptr_lsfq[i] = lsf_min;
|
||||
}
|
||||
|
||||
lsf_min = ptr_lsfq[i] + LSF_GAP;
|
||||
}
|
||||
|
||||
lsf_min = FREQ_MAX - LSF_GAP;
|
||||
for (i = ORDER - 1; i >= 0; i--) {
|
||||
if (ptr_lsfq[i] > lsf_min) {
|
||||
ptr_lsfq[i] = lsf_min;
|
||||
}
|
||||
|
||||
lsf_min = ptr_lsfq[i] - LSF_GAP;
|
||||
}
|
||||
|
||||
return (num_bits);
|
||||
}
|
||||
|
||||
VOID iusace_quantize_lpc_avq(FLOAT32 *ptr_lsf, FLOAT32 *ptr_lsfq, WORD32 lpc0,
|
||||
WORD32 *ptr_lpc_idx, WORD32 *nb_indices, WORD32 *nbbits) {
|
||||
WORD32 i;
|
||||
FLOAT32 lsfq[ORDER];
|
||||
WORD32 *ptr_index, indxt[100], num_bits, nbt, nit;
|
||||
|
||||
ptr_index = &ptr_lpc_idx[0];
|
||||
*nb_indices = 0;
|
||||
*nbbits = 0;
|
||||
|
||||
ptr_index[0] = iusace_avq_first_approx_abs(&ptr_lsf[3 * ORDER], &ptr_lsfq[3 * ORDER]);
|
||||
|
||||
nbt = iusace_avq_first_approx_rel(&ptr_lsf[3 * ORDER], &ptr_lsfq[3 * ORDER], &ptr_index[1], 0);
|
||||
nit = 1 + iusace_get_num_params(&ptr_lpc_idx[1]);
|
||||
|
||||
ptr_index += nit;
|
||||
*nb_indices += nit;
|
||||
*nbbits += 8 + nbt;
|
||||
|
||||
if (lpc0) {
|
||||
*ptr_index = 0;
|
||||
ptr_index++;
|
||||
*nb_indices += 1;
|
||||
*nbbits += 1;
|
||||
|
||||
ptr_index[0] = iusace_avq_first_approx_abs(&ptr_lsf[-ORDER], &ptr_lsfq[-ORDER]);
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[-ORDER], &ptr_lsfq[-ORDER], &ptr_index[1], 0);
|
||||
nbt = 8 + num_bits;
|
||||
nit = 1 + iusace_get_num_params(&ptr_index[1]);
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = ptr_lsfq[3 * ORDER + i];
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[-ORDER], &lsfq[0], indxt, 3);
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 1;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[-ORDER + i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
ptr_index += nit;
|
||||
*nb_indices += nit;
|
||||
*nbbits += nbt;
|
||||
}
|
||||
|
||||
*ptr_index = 0;
|
||||
ptr_index++;
|
||||
*nb_indices += 1;
|
||||
*nbbits += 1;
|
||||
|
||||
ptr_index[0] = iusace_avq_first_approx_abs(&ptr_lsf[ORDER], &ptr_lsfq[ORDER]);
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[ORDER], &ptr_lsfq[ORDER], &ptr_index[1], 0);
|
||||
nbt = 8 + num_bits;
|
||||
nit = 1 + iusace_get_num_params(&ptr_index[1]);
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = ptr_lsfq[3 * ORDER + i];
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[ORDER], &lsfq[0], indxt, 3);
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 1;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[ORDER + i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
ptr_index += nit;
|
||||
*nb_indices += nit;
|
||||
*nbbits += nbt;
|
||||
|
||||
*ptr_index = 0;
|
||||
ptr_index++;
|
||||
*nb_indices += 1;
|
||||
|
||||
ptr_index[0] = iusace_avq_first_approx_abs(&ptr_lsf[0], &ptr_lsfq[0]);
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[0], &ptr_lsfq[0], &ptr_index[1], 0);
|
||||
nbt = 2 + 8 + num_bits;
|
||||
nit = 1 + iusace_get_num_params(&ptr_index[1]);
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = 0.5f * (ptr_lsfq[-ORDER + i] + ptr_lsfq[ORDER + i]);
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[0], lsfq, indxt, 1);
|
||||
|
||||
if (num_bits < 10) {
|
||||
nbt = 2;
|
||||
nit = 0;
|
||||
ptr_index[-1] = 1;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[i] = lsfq[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = ptr_lsfq[ORDER + i];
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[0], lsfq, indxt, 2);
|
||||
num_bits += 1;
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 2;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
ptr_index += nit;
|
||||
*nb_indices += nit;
|
||||
*nbbits += nbt;
|
||||
|
||||
*ptr_index = 0;
|
||||
ptr_index++;
|
||||
*nb_indices += 1;
|
||||
|
||||
ptr_index[0] = iusace_avq_first_approx_abs(&ptr_lsf[2 * ORDER], &ptr_lsfq[2 * ORDER]);
|
||||
|
||||
num_bits =
|
||||
iusace_avq_first_approx_rel(&ptr_lsf[2 * ORDER], &ptr_lsfq[2 * ORDER], &ptr_index[1], 0);
|
||||
nbt = 2 + 8 + num_bits;
|
||||
nit = 1 + iusace_get_num_params(&ptr_index[1]);
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = 0.5f * (ptr_lsfq[ORDER + i] + ptr_lsfq[3 * ORDER + i]);
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[2 * ORDER], lsfq, indxt, 1);
|
||||
num_bits += 1;
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 1;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[2 * ORDER + i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = ptr_lsfq[ORDER + i];
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[2 * ORDER], lsfq, indxt, 2);
|
||||
num_bits += 3;
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 2;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[2 * ORDER + i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < ORDER; i++) lsfq[i] = ptr_lsfq[3 * ORDER + i];
|
||||
|
||||
num_bits = iusace_avq_first_approx_rel(&ptr_lsf[2 * ORDER], lsfq, indxt, 2);
|
||||
num_bits += 3;
|
||||
|
||||
if (num_bits < nbt) {
|
||||
nbt = num_bits;
|
||||
nit = iusace_get_num_params(&indxt[0]);
|
||||
ptr_index[-1] = 3;
|
||||
for (i = 0; i < ORDER; i++) ptr_lsfq[2 * ORDER + i] = lsfq[i];
|
||||
for (i = 0; i < nit; i++) ptr_index[i] = indxt[i];
|
||||
}
|
||||
|
||||
*nb_indices += nit;
|
||||
*nbbits += nbt;
|
||||
|
||||
return;
|
||||
}
|
||||
67
encoder/iusace_lpd.h
Normal file
67
encoder/iusace_lpd.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
VOID iusace_autocorr_plus(FLOAT32 *speech, FLOAT32 *auto_corr_vector, WORD32 window_len,
|
||||
const FLOAT32 *lp_analysis_win, FLOAT32 *temp_aut_corr);
|
||||
VOID iusace_compute_lp_residual(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l);
|
||||
VOID iusace_convolve(FLOAT32 *signal, FLOAT32 *wsynth_filter_ir, FLOAT32 *conv_out);
|
||||
VOID iusace_synthesis_tool_float(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, FLOAT32 *mem,
|
||||
FLOAT32 *buf_synth_tool);
|
||||
VOID iusace_apply_preemph(FLOAT32 *signal, FLOAT32 factor, WORD32 length, FLOAT32 *mem);
|
||||
VOID iusace_apply_deemph(FLOAT32 *signal, FLOAT32 factor, WORD32 length, FLOAT32 *mem);
|
||||
VOID iusace_lpc_2_lsp_conversion(FLOAT32 *lpc, FLOAT32 *lsp, FLOAT32 *prev_lsp);
|
||||
VOID iusace_levinson_durbin_algo(FLOAT32 *auto_corr_input, FLOAT32 *lpc);
|
||||
VOID iusace_get_weighted_lpc(FLOAT32 *lpc, FLOAT32 *weighted_lpc);
|
||||
VOID iusace_lsp_2_lsf_conversion(FLOAT32 *lsp, FLOAT32 *lsf);
|
||||
VOID iusace_lsf_2_lsp_conversion(FLOAT32 *lsf, FLOAT32 *lsp);
|
||||
VOID iusace_open_loop_search(FLOAT32 *wsp, WORD32 min_pitch_lag, WORD32 max_pitch_lag,
|
||||
WORD32 num_frame, WORD32 *ol_pitch_lag,
|
||||
ia_usac_td_encoder_struct *st);
|
||||
WORD32 iusace_get_ol_lag_median(WORD32 prev_ol_lag, WORD32 *prev_ol_lags);
|
||||
VOID iusace_closed_loop_search(FLOAT32 *exc, FLOAT32 *xn, FLOAT32 *wsyn_filt_ir,
|
||||
WORD32 search_range_min, WORD32 search_range_max, WORD32 *pit_frac,
|
||||
WORD32 is_first_subfrm, WORD32 min_pitch_lag_res1_2,
|
||||
WORD32 min_pitch_lag_res_1, WORD32 *pitch_lag_out);
|
||||
VOID iusace_decim2_fir_filter(FLOAT32 *signal, WORD32 length, FLOAT32 *mem,
|
||||
FLOAT32 *scratch_fir_sig_buf);
|
||||
FLOAT32 iusace_calc_sq_gain(FLOAT32 *x, WORD32 num_bits, WORD32 length,
|
||||
FLOAT32 *scratch_sq_gain_en);
|
||||
VOID iusace_lpc_coef_gen(FLOAT32 *lsf_old, FLOAT32 *lsf_new, FLOAT32 *a, WORD32 nb_subfr,
|
||||
WORD32 m);
|
||||
VOID iusace_interpolation_lsp_params(FLOAT32 *lsp_old, FLOAT32 *lsp_new, FLOAT32 *lp_flt_coff_a,
|
||||
WORD32 nb_subfr);
|
||||
|
||||
VOID iusace_acelp_tgt_ir_corr(FLOAT32 *x, FLOAT32 *ir_wsyn, FLOAT32 *corr_out);
|
||||
|
||||
VOID iusace_acelp_tgt_cb_corr1(FLOAT32 *xn, FLOAT32 *y1, FLOAT32 *y2, FLOAT32 *corr_out);
|
||||
|
||||
FLOAT32 iusace_acelp_tgt_cb_corr2(FLOAT32 *xn, FLOAT32 *y1, FLOAT32 *corr_out);
|
||||
|
||||
VOID iusace_acelp_cb_target_update(FLOAT32 *x, FLOAT32 *x2, FLOAT32 *y, FLOAT32 gain);
|
||||
|
||||
VOID iusace_acelp_cb_exc(FLOAT32 *corr_input, FLOAT32 *lp_residual, FLOAT32 *ir_wsyn,
|
||||
WORD16 *alg_cb_exc_out, FLOAT32 *filt_cb_exc, WORD32 num_bits_cb,
|
||||
WORD32 *acelp_param_out, FLOAT32 *scratch_acelp_ir_buf);
|
||||
|
||||
VOID iusace_acelp_ltpred_cb_exc(FLOAT32 *exc, WORD32 t0, WORD32 t0_frac, WORD32 len_subfrm);
|
||||
|
||||
VOID iusace_acelp_quant_gain(FLOAT32 *code, FLOAT32 *pitch_gain, FLOAT32 *code_gain,
|
||||
FLOAT32 *tgt_cb_corr_data, FLOAT32 mean_energy, WORD32 *qunt_idx);
|
||||
818
encoder/iusace_lpd_enc.c
Normal file
818
encoder/iusace_lpd_enc.c
Normal file
|
|
@ -0,0 +1,818 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_psy_utils.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
#include "iusace_lpd.h"
|
||||
#include "iusace_func_prototypes.h"
|
||||
|
||||
VOID iusace_init_td_data(ia_usac_td_encoder_struct *st, WORD32 len_frame) {
|
||||
WORD32 len_window;
|
||||
WORD32 num_frames = NUM_FRAMES;
|
||||
st->len_subfrm = len_frame / num_frames;
|
||||
|
||||
st->len_frame = len_frame;
|
||||
st->num_subfrm = (MAX_NUM_SUBFR * len_frame) / LEN_SUPERFRAME;
|
||||
|
||||
iusace_reset_td_enc(st);
|
||||
st->prev_mode = -1;
|
||||
st->arith_reset_flag = 1;
|
||||
|
||||
if (st->fscale <= FSCALE_DENOM) {
|
||||
len_window = (LEN_LP_WINDOW * len_frame) / LEN_SUPERFRAME;
|
||||
} else {
|
||||
len_window = (LEN_LP_WINDOW_HIGH_RATE * len_frame) / LEN_SUPERFRAME;
|
||||
}
|
||||
|
||||
switch (len_window) {
|
||||
case 512:
|
||||
st->lp_analysis_window = iusace_cos_window_512;
|
||||
break;
|
||||
case 448:
|
||||
st->lp_analysis_window = iusace_cos_window_448;
|
||||
break;
|
||||
case 384:
|
||||
st->lp_analysis_window = iexheaac_cos_window_384;
|
||||
break;
|
||||
default:
|
||||
st->lp_analysis_window = iusace_cos_window_512;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_config_acelp_core_mode(ia_usac_td_encoder_struct *st, WORD32 sampling_rate,
|
||||
WORD32 bitrate) {
|
||||
WORD32 max_bits, coder_bits;
|
||||
const WORD32 *p_acelp_core_numbits_table;
|
||||
|
||||
p_acelp_core_numbits_table = (WORD32 *)iusace_acelp_core_numbits_1024;
|
||||
|
||||
max_bits = (WORD32)((FLOAT32)(bitrate * LEN_SUPERFRAME) / (FLOAT32)sampling_rate);
|
||||
|
||||
for (st->acelp_core_mode = 5; st->acelp_core_mode >= 0; st->acelp_core_mode--) {
|
||||
coder_bits = p_acelp_core_numbits_table[st->acelp_core_mode];
|
||||
if (coder_bits <= max_bits) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (st->acelp_core_mode == -1) {
|
||||
st->acelp_core_mode = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_reset_td_enc(ia_usac_td_encoder_struct *st) {
|
||||
WORD32 i;
|
||||
|
||||
memset(st->old_speech_pe, 0, (ORDER + LEN_NEXT_HIGH_RATE) * sizeof(FLOAT32));
|
||||
memset(st->prev_exc, 0, (MAX_PITCH + LEN_INTERPOL) * sizeof(FLOAT32));
|
||||
memset(st->prev_wsp, 0, (MAX_PITCH / OPL_DECIM) * sizeof(FLOAT32));
|
||||
memset(st->mem_lp_decim2, 0, 3 * sizeof(FLOAT32));
|
||||
memset(st->weighted_sig, 0, 128 * sizeof(FLOAT32));
|
||||
|
||||
st->lpd_state.mode = -1;
|
||||
st->lpd_state.num_bits = 0;
|
||||
memset(st->lpd_state.lpc_coeffs_quant, 0, (2 * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
memset(st->lpd_state.lpc_coeffs, 0, (2 * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
memset(st->lpd_state.synth, 0, (ORDER + 128) * sizeof(FLOAT32));
|
||||
memset(st->lpd_state.wsynth, 0, (1 + 128) * sizeof(FLOAT32));
|
||||
|
||||
memset(st->lpd_state.acelp_exc, 0, (2 * LEN_FRAME) * sizeof(FLOAT32));
|
||||
|
||||
memset(st->lpd_state.tcx_mem, 0, 128 * sizeof(FLOAT32));
|
||||
memset(st->lpd_state.tcx_quant, 0, (1 + 256) * sizeof(FLOAT32));
|
||||
st->lpd_state.tcx_fac = 0.0f;
|
||||
|
||||
memset(st->prev_hp_wsp, 0,
|
||||
(LEN_SUPERFRAME / OPL_DECIM + (MAX_PITCH / OPL_DECIM)) * sizeof(FLOAT32));
|
||||
|
||||
memset(st->hp_ol_ltp_mem, 0, (3 * 2 + 1) * sizeof(FLOAT32));
|
||||
for (i = 0; i < 5; i++) st->prev_ol_lags[i] = 40;
|
||||
st->prev_wsyn_mem = 0.0;
|
||||
st->prev_wsp_mem = 0.0;
|
||||
st->prev_xnq_mem = 0.0;
|
||||
st->mem_wsp = 0.0;
|
||||
st->prev_ovlp_size = 0;
|
||||
st->prev_pitch_med = 40;
|
||||
st->ol_wght_flg = 0;
|
||||
st->ada_w = 0.0;
|
||||
|
||||
memcpy(st->isf_old, iusace_lsf_init, ORDER * sizeof(FLOAT32));
|
||||
memcpy(st->isp_old, iusace_ispold_init, ORDER * sizeof(FLOAT32));
|
||||
memcpy(st->isp_old_q, st->isp_old, ORDER * sizeof(FLOAT32));
|
||||
|
||||
st->mem_preemph = 0.0;
|
||||
memset(st->mem_sig_in, 0, 4 * sizeof(FLOAT32));
|
||||
memset(st->xn_buffer, 0, 128 * sizeof(FLOAT32));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_highpass_prev_wsp(ia_usac_td_encoder_struct *st, FLOAT32 *decim_sig,
|
||||
WORD32 pitch_max) {
|
||||
WORD32 i, k;
|
||||
WORD32 wsp_offset = pitch_max / OPL_DECIM;
|
||||
WORD32 num_frames = (2 * LEN_SUBFR) / OPL_DECIM;
|
||||
FLOAT32 *hp_wsp_mem = st->hp_ol_ltp_mem;
|
||||
FLOAT32 *prev_hp_wsp = st->prev_hp_wsp;
|
||||
for (i = 0; i < 2 * st->len_subfrm / OPL_DECIM; i += num_frames) {
|
||||
FLOAT32 *data_a, *data_b, *hp_wsp, o;
|
||||
FLOAT32 *wsp = decim_sig + ORDER + i;
|
||||
data_a = hp_wsp_mem;
|
||||
data_b = hp_wsp_mem + HP_ORDER;
|
||||
hp_wsp = prev_hp_wsp + wsp_offset;
|
||||
for (k = 0; k < num_frames; k++) {
|
||||
data_b[0] = data_b[1];
|
||||
data_b[1] = data_b[2];
|
||||
data_b[2] = data_b[3];
|
||||
data_b[HP_ORDER] = wsp[k];
|
||||
o = data_b[0] * 0.83787057505665F;
|
||||
o += data_b[1] * -2.50975570071058F;
|
||||
o += data_b[2] * 2.50975570071058F;
|
||||
o += data_b[3] * -0.83787057505665F;
|
||||
o -= data_a[0] * -2.64436711600664F;
|
||||
o -= data_a[1] * 2.35087386625360F;
|
||||
o -= data_a[2] * -0.70001156927424F;
|
||||
data_a[2] = data_a[1];
|
||||
data_a[1] = data_a[0];
|
||||
data_a[0] = o;
|
||||
hp_wsp[k] = o;
|
||||
}
|
||||
memmove(prev_hp_wsp, &prev_hp_wsp[num_frames], wsp_offset * sizeof(FLOAT32));
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_find_weighted_speech(FLOAT32 *filter_coef, FLOAT32 *speech, FLOAT32 *wsp,
|
||||
FLOAT32 *mem_wsp, WORD32 length) {
|
||||
WORD32 i_subfr;
|
||||
FLOAT32 weighted_lpc[ORDER + 1];
|
||||
for (i_subfr = 0; i_subfr < length; i_subfr += LEN_SUBFR) {
|
||||
iusace_get_weighted_lpc(filter_coef, weighted_lpc);
|
||||
iusace_compute_lp_residual(weighted_lpc, &speech[i_subfr], &wsp[i_subfr], LEN_SUBFR);
|
||||
filter_coef += (ORDER + 1);
|
||||
}
|
||||
iusace_apply_deemph(wsp, TILT_FAC, length, mem_wsp);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_get_interpolated_lpc(FLOAT32 *lsp_old, FLOAT32 *lsp_new, FLOAT32 *lpc,
|
||||
WORD32 num_subfrm) {
|
||||
FLOAT32 lsp[ORDER], *p_lpc, inc, fnew, fold;
|
||||
WORD32 i, k;
|
||||
|
||||
inc = 1.0f / (FLOAT32)num_subfrm;
|
||||
p_lpc = lpc;
|
||||
fnew = 0.0f;
|
||||
|
||||
for (k = 0; k < num_subfrm; k++) {
|
||||
fold = 1.0f - fnew;
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
lsp[i] = (FLOAT32)(lsp_old[i] * fold + lsp_new[i] * fnew);
|
||||
}
|
||||
fnew += inc;
|
||||
iusace_lsp_to_lp_conversion(lsp, p_lpc);
|
||||
p_lpc += (ORDER + 1);
|
||||
}
|
||||
|
||||
iusace_lsp_to_lp_conversion(lsp_new, p_lpc);
|
||||
}
|
||||
|
||||
VOID iusace_core_lpd_encode(ia_usac_data_struct *usac_data, FLOAT32 *speech, WORD32 *mode,
|
||||
WORD32 *num_tcx_param, WORD32 ch_idx) {
|
||||
WORD32 first_lpd_flag = (usac_data->core_mode_prev[ch_idx] == CORE_MODE_FD);
|
||||
iusace_scratch_mem *pstr_scratch = &usac_data->str_scratch;
|
||||
WORD32 pit_adj = usac_data->td_encoder[ch_idx]->fscale;
|
||||
WORD32 *num_fac_bits = &usac_data->num_td_fac_bits[ch_idx];
|
||||
WORD16 *serial_fac_out = usac_data->fac_out_stream[ch_idx];
|
||||
WORD32 *lpc_params = usac_data->param_buf + (NUM_FRAMES * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
ia_usac_td_encoder_struct *st = usac_data->td_encoder[ch_idx];
|
||||
WORD32 *acelp_tcx_params = usac_data->param_buf;
|
||||
WORD16 *codec_mode = &st->acelp_core_mode;
|
||||
const FLOAT32 *lp_analysis_window = st->lp_analysis_window;
|
||||
FLOAT32 *lp_filter_coeff = pstr_scratch->p_lp_filter_coeff;
|
||||
FLOAT32 *lp_filter_coeff_q = pstr_scratch->p_lp_filter_coeff_q;
|
||||
|
||||
FLOAT32 *ptr_stack_mem = (FLOAT32 *)pstr_scratch->ptr_stack_mem;
|
||||
|
||||
FLOAT32 *auto_corr_vector = ptr_stack_mem;
|
||||
ptr_stack_mem += (ORDER + 1);
|
||||
memset(auto_corr_vector, 0, sizeof(*auto_corr_vector) * (ORDER + 1));
|
||||
|
||||
FLOAT32 *isp_new = ptr_stack_mem;
|
||||
ptr_stack_mem += ORDER;
|
||||
memset(isp_new, 0, sizeof(*isp_new) * (ORDER));
|
||||
|
||||
FLOAT32 *isp_curr = ptr_stack_mem;
|
||||
ptr_stack_mem += ((NUM_FRAMES + 1) * ORDER);
|
||||
memset(isp_curr, 0, sizeof(*isp_curr) * ((NUM_FRAMES + 1) * ORDER));
|
||||
|
||||
FLOAT32 *isp_curr_q = ptr_stack_mem;
|
||||
ptr_stack_mem += ((NUM_FRAMES + 1) * ORDER);
|
||||
memset(isp_curr_q, 0, sizeof(*isp_curr_q) * ((NUM_FRAMES + 1) * ORDER));
|
||||
|
||||
FLOAT32 *isf_curr = ptr_stack_mem;
|
||||
ptr_stack_mem += ((NUM_FRAMES + 1) * ORDER);
|
||||
memset(isf_curr, 0, sizeof(*isf_curr) * ((NUM_FRAMES + 1) * ORDER));
|
||||
|
||||
FLOAT32 *isf_curr_q = ptr_stack_mem;
|
||||
ptr_stack_mem += ((NUM_FRAMES + 1) * ORDER);
|
||||
memset(isf_curr_q, 0, sizeof(*isf_curr_q) * ((NUM_FRAMES + 1) * ORDER));
|
||||
|
||||
FLOAT32 *auto_corr_lp_filter_coeff = ptr_stack_mem;
|
||||
ptr_stack_mem += (ORDER + 1);
|
||||
memset(auto_corr_lp_filter_coeff, 0, sizeof(*auto_corr_lp_filter_coeff) * (ORDER + 1));
|
||||
|
||||
WORD32 num_indices = 0, num_bits = 0;
|
||||
WORD32 *prm_tcx = pstr_scratch->p_prm_tcx;
|
||||
FLOAT32 *p_wsp_prev_buf;
|
||||
FLOAT32 *wsp_prev_buf = pstr_scratch->p_wsp_prev_buf;
|
||||
memset(lp_filter_coeff, 0, ((NUM_SUBFR_SUPERFRAME + 1) * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
memset(lp_filter_coeff_q, 0, ((NUM_SUBFR_SUPERFRAME + 1) * (ORDER + 1)) * sizeof(FLOAT32));
|
||||
memset(wsp_prev_buf, 0, ((MAX_PITCH1 / OPL_DECIM) + LEN_FRAME) * sizeof(FLOAT32));
|
||||
WORD32 i, j, k, i1, i2;
|
||||
WORD32 *p_params;
|
||||
FLOAT32 energy = 0, max_corr = 0, t0 = 0, *p, *p1;
|
||||
WORD32 ol_pitch_lag[2 * NUM_FRAMES] = {0};
|
||||
FLOAT32 norm_corr[2 * NUM_FRAMES] = {0};
|
||||
WORD32 num_params, pitch_min, pitch_max;
|
||||
|
||||
ia_usac_lpd_state_struct *lpd_state[6], *lpd_state_temp;
|
||||
lpd_state_temp = (ia_usac_lpd_state_struct *)ptr_stack_mem;
|
||||
ptr_stack_mem +=
|
||||
(sizeof(ia_usac_lpd_state_struct) + sizeof(*ptr_stack_mem)) / (sizeof(*ptr_stack_mem));
|
||||
memset(lpd_state_temp, 0, sizeof(*lpd_state_temp));
|
||||
for (j = 0; j < 6; j++) {
|
||||
lpd_state[j] = (ia_usac_lpd_state_struct *)ptr_stack_mem;
|
||||
ptr_stack_mem +=
|
||||
(sizeof(ia_usac_lpd_state_struct) + sizeof(*ptr_stack_mem)) / (sizeof(*ptr_stack_mem));
|
||||
memset(lpd_state[j], 0, sizeof(*lpd_state[0]));
|
||||
}
|
||||
|
||||
WORD32 num_bits_acelp = 0, num_bits_tcx = 0;
|
||||
WORD32 range_pitch_search = 0;
|
||||
WORD32 len_subfrm = 0;
|
||||
WORD32 num_subfrm = 0;
|
||||
WORD32 num_sbfrm_per_supfrm = 0;
|
||||
WORD32 window_len = 0;
|
||||
WORD32 len = (MAX_PITCH / OPL_DECIM);
|
||||
FLOAT32 mem_wsyn;
|
||||
FLOAT32 ssnr_256 = 0.0f, ssnr_512 = 0.0f, ssnr_1024 = 0.0f;
|
||||
FLOAT32 tmp_ssnr = 0.0f;
|
||||
|
||||
len_subfrm = st->len_subfrm;
|
||||
num_subfrm = st->num_subfrm;
|
||||
num_sbfrm_per_supfrm = NUM_FRAMES * num_subfrm;
|
||||
|
||||
if (pit_adj <= FSCALE_DENOM) {
|
||||
window_len = (LEN_LP_WINDOW * len_subfrm) / LEN_FRAME;
|
||||
} else {
|
||||
window_len = (LEN_LP_WINDOW_HIGH_RATE * len_subfrm) / LEN_FRAME;
|
||||
}
|
||||
|
||||
memcpy(pstr_scratch->p_wsig_buf, st->weighted_sig, 128 * sizeof(FLOAT32));
|
||||
|
||||
num_bits_acelp = (iusace_acelp_core_numbits_1024[*codec_mode] - NBITS_MODE) >> 2;
|
||||
|
||||
num_bits_tcx = (WORD32)(0.85f * num_bits_acelp - NBITS_LPC);
|
||||
|
||||
if (pit_adj == 0) {
|
||||
pitch_min = TMIN;
|
||||
pitch_max = TMAX;
|
||||
} else {
|
||||
i = (((pit_adj * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN;
|
||||
pitch_min = TMIN + i;
|
||||
pitch_max = TMAX + (6 * i);
|
||||
}
|
||||
|
||||
p_wsp_prev_buf = wsp_prev_buf + MAX_PITCH1 / OPL_DECIM;
|
||||
memcpy(wsp_prev_buf, st->prev_wsp, (WORD32)((MAX_PITCH / OPL_DECIM) * sizeof(FLOAT32)));
|
||||
|
||||
if (first_lpd_flag) {
|
||||
memcpy(st->isp_old, iusace_ispold_init, ORDER * sizeof(FLOAT32));
|
||||
|
||||
iusace_autocorr_plus(&speech[-(window_len / 2)], auto_corr_vector, window_len,
|
||||
(FLOAT32 *)lp_analysis_window, pstr_scratch->p_buf_aut_corr);
|
||||
|
||||
for (j = 0; j <= ORDER; j++) {
|
||||
auto_corr_vector[j] *= (FLOAT32)iusace_lag_window[j];
|
||||
}
|
||||
|
||||
iusace_levinson_durbin_algo(auto_corr_vector, auto_corr_lp_filter_coeff);
|
||||
iusace_lpc_2_lsp_conversion(auto_corr_lp_filter_coeff, isp_new, st->isp_old);
|
||||
memcpy(st->isp_old, isp_new, ORDER * sizeof(FLOAT32));
|
||||
iusace_lsp_2_lsf_conversion(isp_new, isf_curr);
|
||||
memcpy(st->isf_old, isf_curr, ORDER * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
memcpy(isp_curr, st->isp_old, ORDER * sizeof(FLOAT32));
|
||||
|
||||
for (i = 0; i < NUM_FRAMES; i++) {
|
||||
iusace_autocorr_plus(&speech[((i + 1) * len_subfrm) - (window_len / 2)], auto_corr_vector,
|
||||
window_len, (FLOAT32 *)lp_analysis_window, pstr_scratch->p_buf_aut_corr);
|
||||
|
||||
for (j = 0; j <= ORDER; j++) {
|
||||
auto_corr_vector[j] *= (FLOAT32)iusace_lag_window[j];
|
||||
}
|
||||
|
||||
iusace_levinson_durbin_algo(auto_corr_vector, auto_corr_lp_filter_coeff);
|
||||
iusace_lpc_2_lsp_conversion(auto_corr_lp_filter_coeff, isp_new, st->isp_old);
|
||||
memcpy(&isp_curr[(i + 1) * ORDER], isp_new, ORDER * sizeof(FLOAT32));
|
||||
iusace_interpolation_lsp_params(st->isp_old, isp_new,
|
||||
&lp_filter_coeff[i * num_subfrm * (ORDER + 1)], num_subfrm);
|
||||
iusace_lsp_2_lsf_conversion(&isp_curr[(i + 1) * ORDER], &isf_curr[(i + 1) * ORDER]);
|
||||
memcpy(st->isp_old, isp_new, ORDER * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
memcpy(isf_curr, st->isf_old, ORDER * sizeof(FLOAT32));
|
||||
memcpy(st->isf_old, &isf_curr[NUM_FRAMES * ORDER], ORDER * sizeof(FLOAT32));
|
||||
|
||||
if (!first_lpd_flag) {
|
||||
iusace_lsp_2_lsf_conversion(st->isp_old_q, isf_curr_q);
|
||||
}
|
||||
|
||||
iusace_quantize_lpc_avq(&isf_curr[ORDER], &isf_curr_q[ORDER], first_lpd_flag, &lpc_params[0],
|
||||
&num_indices, &num_bits);
|
||||
|
||||
for (i = 0; i < NUM_FRAMES; i++) {
|
||||
iusace_lsf_2_lsp_conversion(&isf_curr_q[(i + 1) * ORDER], &isp_curr_q[(i + 1) * ORDER]);
|
||||
}
|
||||
|
||||
if (first_lpd_flag) {
|
||||
iusace_lsf_2_lsp_conversion(isf_curr_q, isp_curr_q);
|
||||
memcpy(st->isp_old_q, isp_curr_q, ORDER * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
*num_fac_bits = 0;
|
||||
if (first_lpd_flag) {
|
||||
FLOAT32 *temp_speech = pstr_scratch->p_buf_speech;
|
||||
FLOAT32 *temp_res = pstr_scratch->p_buf_res;
|
||||
FLOAT32 lpc[9 * (ORDER + 1)];
|
||||
FLOAT32 hp_mem[4];
|
||||
FLOAT32 premph_mem = 0.0f;
|
||||
WORD32 fac_length;
|
||||
WORD32 num_bits_fac = (WORD32)((FLOAT32)num_bits_tcx / 2.f);
|
||||
FLOAT32 *temp_signal = pstr_scratch->p_buf_signal;
|
||||
|
||||
if (st->last_was_short) {
|
||||
fac_length = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_length = len_subfrm / 2;
|
||||
}
|
||||
|
||||
iusace_get_interpolated_lpc(st->isp_old_q, st->isp_old_q, lpc, (2 * len_subfrm) / LEN_SUBFR);
|
||||
|
||||
memset(temp_speech, 0, (ORDER + 2 * len_subfrm) * sizeof(FLOAT32));
|
||||
memset(temp_res, 0, (2 * len_subfrm) * sizeof(FLOAT32));
|
||||
|
||||
iusace_fac_apply(&st->fd_orig[1 + ORDER], len_subfrm, fac_length, st->low_pass_line,
|
||||
num_bits_fac, &st->fd_synth[1 + ORDER], lpc, serial_fac_out, num_fac_bits,
|
||||
pstr_scratch);
|
||||
memset(hp_mem, 0, 4 * sizeof(FLOAT32));
|
||||
iusace_highpass_50hz_12k8(st->fd_orig, 2 * len_subfrm + 1 + ORDER, hp_mem, pit_adj);
|
||||
premph_mem = 0.0f;
|
||||
iusace_apply_preemph(st->fd_orig, PREEMPH_FILT_FAC, 2 * len_subfrm + 1 + ORDER, &premph_mem);
|
||||
|
||||
memcpy(temp_signal, st->fd_orig + len_subfrm + 1, (len_subfrm + ORDER) * sizeof(FLOAT32));
|
||||
premph_mem = temp_signal[0];
|
||||
iusace_apply_deemph(temp_signal, PREEMPH_FILT_FAC, len_subfrm + ORDER, &premph_mem);
|
||||
memcpy(st->lpd_state.tcx_mem, &temp_signal[len_subfrm + ORDER - 128], 128 * sizeof(FLOAT32));
|
||||
|
||||
premph_mem = 0.0f;
|
||||
iusace_apply_preemph(st->fd_synth, PREEMPH_FILT_FAC, 2 * len_subfrm + 1 + ORDER, &premph_mem);
|
||||
memcpy(st->lpd_state.synth, st->fd_synth + 2 * len_subfrm - ORDER - 128 + 1 + ORDER,
|
||||
(ORDER + 128) * sizeof(FLOAT32));
|
||||
memcpy(temp_speech + ORDER, st->fd_synth + 1 + ORDER, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
|
||||
premph_mem = 0.0f;
|
||||
iusace_find_weighted_speech(lpc, temp_speech + ORDER, temp_res, &premph_mem, 2 * len_subfrm);
|
||||
st->prev_wsyn_mem = premph_mem;
|
||||
memcpy(st->lpd_state.wsynth, temp_res + 2 * len_subfrm - ORDER - 128,
|
||||
(ORDER + 128) * sizeof(FLOAT32));
|
||||
memcpy(temp_speech + ORDER, st->fd_synth + 1 + ORDER, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
memset(temp_res, 0, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
for (i = 0; i < 2 * len_subfrm; i += LEN_SUBFR) {
|
||||
iusace_compute_lp_residual(lpc, &temp_speech[ORDER + i], &temp_res[i], LEN_SUBFR);
|
||||
}
|
||||
memcpy(st->lpd_state.acelp_exc, temp_res, 2 * len_subfrm * sizeof(FLOAT32));
|
||||
premph_mem = 0.0f;
|
||||
iusace_find_weighted_speech(lp_filter_coeff, st->fd_orig + 1 + ORDER, temp_speech + ORDER,
|
||||
&(st->mem_wsp), 2 * len_subfrm);
|
||||
memcpy(st->weighted_sig, temp_speech + ORDER + 2 * len_subfrm - 128, 128 * sizeof(FLOAT32));
|
||||
memcpy(pstr_scratch->p_wsig_buf, st->weighted_sig, 128 * sizeof(FLOAT32));
|
||||
for (i = 0; i < 2 * len_subfrm; i += len_subfrm) {
|
||||
iusace_decim2_fir_filter(&temp_speech[i + ORDER], len_subfrm, st->mem_lp_decim2,
|
||||
pstr_scratch->p_fir_sig_buf);
|
||||
memcpy(temp_speech + ORDER + i / OPL_DECIM, temp_speech + ORDER + i,
|
||||
(len_subfrm / OPL_DECIM) * sizeof(FLOAT32));
|
||||
}
|
||||
memcpy(wsp_prev_buf, temp_speech + ORDER + 2 * len_subfrm / OPL_DECIM - MAX_PITCH / OPL_DECIM,
|
||||
(WORD32)((MAX_PITCH / OPL_DECIM) * sizeof(FLOAT32)));
|
||||
iusace_highpass_prev_wsp(st, temp_speech, pitch_max);
|
||||
}
|
||||
memcpy(isp_curr_q, st->isp_old_q, ORDER * sizeof(FLOAT32));
|
||||
memcpy(st->isp_old_q, &isp_curr_q[NUM_FRAMES * ORDER], ORDER * sizeof(FLOAT32));
|
||||
|
||||
for (i = 0; i < NUM_FRAMES; i++) {
|
||||
iusace_find_weighted_speech(
|
||||
&lp_filter_coeff[i * (num_sbfrm_per_supfrm / NUM_FRAMES) * (ORDER + 1)],
|
||||
&speech[i * len_subfrm], &pstr_scratch->p_wsig_buf[i * len_subfrm], &(st->mem_wsp),
|
||||
len_subfrm);
|
||||
memcpy(p_wsp_prev_buf, &pstr_scratch->p_wsig_buf[i * len_subfrm],
|
||||
len_subfrm * sizeof(FLOAT32));
|
||||
|
||||
iusace_decim2_fir_filter(p_wsp_prev_buf, len_subfrm, st->mem_lp_decim2,
|
||||
pstr_scratch->p_fir_sig_buf);
|
||||
range_pitch_search = 2 * LEN_SUBFR;
|
||||
if (num_subfrm < 4) {
|
||||
range_pitch_search = 3 * LEN_SUBFR;
|
||||
}
|
||||
|
||||
iusace_open_loop_search(p_wsp_prev_buf, (pitch_min / OPL_DECIM) + 1, pitch_max / OPL_DECIM,
|
||||
range_pitch_search / OPL_DECIM, &ol_pitch_lag[i * 2], st);
|
||||
|
||||
if (st->ol_gain > 0.6) {
|
||||
st->prev_pitch_med = iusace_get_ol_lag_median(ol_pitch_lag[i * 2], st->prev_ol_lags);
|
||||
st->ada_w = 1.0;
|
||||
} else {
|
||||
st->ada_w = st->ada_w * 0.9f;
|
||||
}
|
||||
if (st->ada_w < 0.8) {
|
||||
st->ol_wght_flg = 0;
|
||||
} else {
|
||||
st->ol_wght_flg = 1;
|
||||
}
|
||||
|
||||
max_corr = 0.0f;
|
||||
p = &p_wsp_prev_buf[0];
|
||||
p1 = p_wsp_prev_buf - ol_pitch_lag[i * 2];
|
||||
for (j = 0; j < range_pitch_search / OPL_DECIM; j++) {
|
||||
max_corr += *p++ * *p1++;
|
||||
}
|
||||
|
||||
t0 = 0.01f;
|
||||
p = p_wsp_prev_buf - ol_pitch_lag[i * 2];
|
||||
for (j = 0; j < range_pitch_search / OPL_DECIM; j++, p++) {
|
||||
t0 += *p * *p;
|
||||
}
|
||||
t0 = (FLOAT32)(1.0 / sqrt(t0));
|
||||
norm_corr[i * 2] = max_corr * t0;
|
||||
|
||||
energy = 0.01f;
|
||||
for (j = 0; j < range_pitch_search / OPL_DECIM; j++) {
|
||||
energy += p_wsp_prev_buf[j] * p_wsp_prev_buf[j];
|
||||
}
|
||||
energy = (FLOAT32)(1.0 / sqrt(energy));
|
||||
norm_corr[i * 2] *= energy;
|
||||
|
||||
if (num_subfrm < 4) {
|
||||
ol_pitch_lag[(i * 2) + 1] = ol_pitch_lag[i * 2];
|
||||
norm_corr[(i * 2) + 1] = norm_corr[i * 2];
|
||||
} else {
|
||||
iusace_open_loop_search(p_wsp_prev_buf + ((2 * LEN_SUBFR) / OPL_DECIM),
|
||||
(pitch_min / OPL_DECIM) + 1, pitch_max / OPL_DECIM,
|
||||
(2 * LEN_SUBFR) / OPL_DECIM, &ol_pitch_lag[(i * 2) + 1], st);
|
||||
|
||||
if (st->ol_gain > 0.6) {
|
||||
st->prev_pitch_med =
|
||||
iusace_get_ol_lag_median(ol_pitch_lag[(i * 2) + 1], st->prev_ol_lags);
|
||||
st->ada_w = 1.0;
|
||||
} else {
|
||||
st->ada_w = st->ada_w * 0.9f;
|
||||
}
|
||||
if (st->ada_w < 0.8) {
|
||||
st->ol_wght_flg = 0;
|
||||
} else {
|
||||
st->ol_wght_flg = 1;
|
||||
}
|
||||
max_corr = 0.0f;
|
||||
p = p_wsp_prev_buf + (2 * LEN_SUBFR) / OPL_DECIM;
|
||||
p1 = p_wsp_prev_buf + ((2 * LEN_SUBFR) / OPL_DECIM) - ol_pitch_lag[(i * 2) + 1];
|
||||
for (j = 0; j < (2 * LEN_SUBFR) / OPL_DECIM; j++) {
|
||||
max_corr += *p++ * *p1++;
|
||||
}
|
||||
|
||||
t0 = 0.01f;
|
||||
p = p_wsp_prev_buf + ((2 * LEN_SUBFR) / OPL_DECIM) - ol_pitch_lag[(i * 2) + 1];
|
||||
for (j = 0; j < (2 * LEN_SUBFR) / OPL_DECIM; j++, p++) {
|
||||
t0 += *p * *p;
|
||||
}
|
||||
t0 = (FLOAT32)(1.0 / sqrt(t0));
|
||||
norm_corr[(i * 2) + 1] = max_corr * t0;
|
||||
|
||||
energy = 0.01f;
|
||||
for (j = 0; j < (2 * LEN_SUBFR) / OPL_DECIM; j++) {
|
||||
energy += p_wsp_prev_buf[((2 * LEN_SUBFR) / OPL_DECIM) + j] *
|
||||
p_wsp_prev_buf[((2 * LEN_SUBFR) / OPL_DECIM) + j];
|
||||
}
|
||||
energy = (FLOAT32)(1.0 / sqrt(energy));
|
||||
norm_corr[(i * 2) + 1] *= energy;
|
||||
}
|
||||
|
||||
memmove(wsp_prev_buf, &wsp_prev_buf[len_subfrm / OPL_DECIM],
|
||||
(WORD32)((MAX_PITCH / OPL_DECIM) * sizeof(FLOAT32)));
|
||||
}
|
||||
|
||||
memcpy(lpd_state[0], &st->lpd_state, sizeof(*lpd_state[0]));
|
||||
|
||||
ssnr_1024 = 0;
|
||||
|
||||
for (i1 = 0; i1 < 2; i1++) {
|
||||
ssnr_512 = 0;
|
||||
for (i2 = 0; i2 < 2; i2++) {
|
||||
k = (i1 * 2) + i2;
|
||||
p_params = acelp_tcx_params + (k * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
|
||||
iusace_interpolation_lsp_params(&isp_curr_q[k * ORDER], &isp_curr_q[(k + 1) * ORDER],
|
||||
lp_filter_coeff_q, st->num_subfrm);
|
||||
|
||||
memcpy(lpd_state[k + 1], lpd_state[k], sizeof(*lpd_state[0]));
|
||||
|
||||
iusace_acelp_encode(
|
||||
&lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)], lp_filter_coeff_q,
|
||||
&speech[k * st->len_subfrm], &pstr_scratch->p_wsig_buf[k * st->len_subfrm],
|
||||
&pstr_scratch->p_synth_buf[k * st->len_subfrm],
|
||||
&pstr_scratch->p_wsyn_buf[k * st->len_subfrm], *codec_mode, lpd_state[k + 1],
|
||||
st->len_subfrm, norm_corr[k * 2], norm_corr[(k * 2) + 1], ol_pitch_lag[k * 2],
|
||||
ol_pitch_lag[(k * 2) + 1], pit_adj, p_params, pstr_scratch);
|
||||
|
||||
mem_wsyn = lpd_state[k]->mem_wsyn;
|
||||
|
||||
iusace_find_weighted_speech(&lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
&pstr_scratch->p_synth_buf[k * LEN_FRAME],
|
||||
pstr_scratch->p_temp_wsyn_buf, &mem_wsyn, LEN_FRAME);
|
||||
|
||||
lpd_state[k + 1]->mem_wsyn = mem_wsyn;
|
||||
|
||||
ssnr_256 = iusace_cal_segsnr(&pstr_scratch->p_wsig_buf[k * LEN_FRAME],
|
||||
pstr_scratch->p_temp_wsyn_buf, LEN_FRAME, LEN_SUBFR);
|
||||
|
||||
mode[k] = 0;
|
||||
num_tcx_param[k] = 0;
|
||||
|
||||
iusace_lpc_coef_gen(&isp_curr_q[k * ORDER], &isp_curr_q[(k + 1) * ORDER], lp_filter_coeff_q,
|
||||
st->num_subfrm, ORDER);
|
||||
|
||||
memcpy(lpd_state_temp, lpd_state[k], sizeof(*lpd_state[0]));
|
||||
|
||||
|
||||
iusace_tcx_fac_encode(usac_data,
|
||||
&lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
lp_filter_coeff_q, &speech[k * st->len_subfrm], st->len_subfrm,
|
||||
num_bits_tcx, lpd_state_temp, prm_tcx, &num_params,
|
||||
ch_idx, k);
|
||||
|
||||
mem_wsyn = lpd_state[k]->mem_wsyn;
|
||||
|
||||
iusace_find_weighted_speech(&lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
pstr_scratch->p_synth_tcx_buf, pstr_scratch->p_temp_wsyn_buf,
|
||||
&mem_wsyn, LEN_FRAME);
|
||||
|
||||
lpd_state_temp->mem_wsyn = mem_wsyn;
|
||||
|
||||
tmp_ssnr = iusace_cal_segsnr(&pstr_scratch->p_wsig_buf[k * LEN_FRAME],
|
||||
pstr_scratch->p_temp_wsyn_buf, LEN_FRAME, LEN_SUBFR);
|
||||
|
||||
if (tmp_ssnr > ssnr_256) {
|
||||
ssnr_256 = tmp_ssnr;
|
||||
mode[k] = 1;
|
||||
num_tcx_param[k] = num_params;
|
||||
memcpy(lpd_state[k + 1], lpd_state_temp, sizeof(*lpd_state[0]));
|
||||
|
||||
memcpy(&pstr_scratch->p_synth_buf[(k * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_synth_tcx_buf - 128, (st->len_subfrm + 128) * sizeof(FLOAT32));
|
||||
|
||||
memcpy(&pstr_scratch->p_wsyn_buf[(k * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_wsyn_tcx_buf - 128, (st->len_subfrm + 128) * sizeof(FLOAT32));
|
||||
|
||||
memcpy(p_params, prm_tcx, NUM_TCX20_PRM * sizeof(WORD32));
|
||||
}
|
||||
ssnr_512 += 0.50f * ssnr_256;
|
||||
}
|
||||
|
||||
k = i1 * 2;
|
||||
|
||||
p_params = acelp_tcx_params + (k * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
|
||||
iusace_lpc_coef_gen(&isp_curr_q[2 * i1 * ORDER], &isp_curr_q[(2 * i1 + 2) * ORDER],
|
||||
lp_filter_coeff_q, (num_sbfrm_per_supfrm / 2), ORDER);
|
||||
|
||||
memcpy(lpd_state_temp, lpd_state[2 * i1], sizeof(*lpd_state[0]));
|
||||
iusace_tcx_fac_encode(usac_data,
|
||||
&lp_filter_coeff[2 * i1 * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
lp_filter_coeff_q, &speech[2 * i1 * st->len_subfrm], 2 * st->len_subfrm,
|
||||
2 * num_bits_tcx, lpd_state_temp, prm_tcx, &num_params,
|
||||
ch_idx, 2 * i1);
|
||||
|
||||
mem_wsyn = lpd_state[2 * i1]->mem_wsyn;
|
||||
|
||||
iusace_find_weighted_speech(
|
||||
&lp_filter_coeff[2 * i1 * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
pstr_scratch->p_synth_tcx_buf, pstr_scratch->p_temp_wsyn_buf, &mem_wsyn, LEN_FRAME * 2);
|
||||
|
||||
lpd_state_temp->mem_wsyn = mem_wsyn;
|
||||
|
||||
tmp_ssnr = iusace_cal_segsnr(&pstr_scratch->p_wsig_buf[2 * i1 * LEN_FRAME],
|
||||
pstr_scratch->p_temp_wsyn_buf, LEN_FRAME * 2, LEN_SUBFR);
|
||||
|
||||
if (tmp_ssnr > ssnr_512) {
|
||||
ssnr_512 = tmp_ssnr;
|
||||
for (i = 0; i < 2; i++) {
|
||||
mode[k + i] = 2;
|
||||
num_tcx_param[k + i] = num_params;
|
||||
}
|
||||
memcpy(lpd_state[k + 2], lpd_state_temp, sizeof(*lpd_state[0]));
|
||||
|
||||
memcpy(&pstr_scratch->p_synth_buf[(2 * i1 * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_synth_tcx_buf - 128, ((2 * st->len_subfrm) + 128) * sizeof(FLOAT32));
|
||||
memcpy(&pstr_scratch->p_wsyn_buf[(2 * i1 * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_wsyn_tcx_buf - 128, ((2 * st->len_subfrm) + 128) * sizeof(FLOAT32));
|
||||
memcpy(p_params, prm_tcx, NUM_TCX40_PRM * sizeof(WORD32));
|
||||
}
|
||||
ssnr_1024 += 0.50f * ssnr_512;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
|
||||
p_params = acelp_tcx_params + (k * MAX_NUM_TCX_PRM_PER_DIV);
|
||||
|
||||
iusace_lpc_coef_gen(&isp_curr_q[k * ORDER], &isp_curr_q[(k + 4) * ORDER], lp_filter_coeff_q,
|
||||
num_sbfrm_per_supfrm, ORDER);
|
||||
|
||||
memcpy(lpd_state_temp, lpd_state[k], sizeof(*lpd_state[0]));
|
||||
|
||||
iusace_tcx_fac_encode(usac_data, &lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
lp_filter_coeff_q, &speech[k * st->len_subfrm], 4 * st->len_subfrm,
|
||||
4 * num_bits_tcx, lpd_state_temp, prm_tcx, &num_params,
|
||||
ch_idx, k);
|
||||
|
||||
mem_wsyn = lpd_state[k]->mem_wsyn;
|
||||
|
||||
iusace_find_weighted_speech(&lp_filter_coeff[k * (num_sbfrm_per_supfrm / 4) * (ORDER + 1)],
|
||||
pstr_scratch->p_synth_tcx_buf, pstr_scratch->p_temp_wsyn_buf,
|
||||
&mem_wsyn, LEN_FRAME * 4);
|
||||
|
||||
lpd_state_temp->mem_wsyn = mem_wsyn;
|
||||
|
||||
tmp_ssnr = iusace_cal_segsnr(&pstr_scratch->p_wsig_buf[k * LEN_FRAME],
|
||||
pstr_scratch->p_temp_wsyn_buf, LEN_FRAME * 4, LEN_SUBFR);
|
||||
|
||||
if (tmp_ssnr > ssnr_1024) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
mode[k + i] = 3;
|
||||
num_tcx_param[k + i] = num_params;
|
||||
}
|
||||
memcpy(lpd_state[k + 4], lpd_state_temp, sizeof(*lpd_state[0]));
|
||||
|
||||
memcpy(&pstr_scratch->p_synth_buf[(k * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_synth_tcx_buf - 128, ((4 * st->len_subfrm) + 128) * sizeof(FLOAT32));
|
||||
memcpy(&pstr_scratch->p_wsyn_buf[(k * st->len_subfrm) - 128],
|
||||
pstr_scratch->p_wsyn_tcx_buf - 128, ((4 * st->len_subfrm) + 128) * sizeof(FLOAT32));
|
||||
memcpy(p_params, prm_tcx, NUM_TCX80_PRM * sizeof(WORD32));
|
||||
}
|
||||
memcpy(&st->lpd_state, lpd_state[4], sizeof(*lpd_state[4]));
|
||||
|
||||
memcpy(st->weighted_sig, pstr_scratch->p_wsig_buf + (st->len_frame), 128 * sizeof(FLOAT32));
|
||||
memcpy(st->prev_wsp, wsp_prev_buf, (len * sizeof(FLOAT32)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_lpd_frm_enc(ia_usac_data_struct *usac_data, WORD32 *mod_out,
|
||||
WORD32 const usac_independency_flg,
|
||||
WORD32 len_frame,
|
||||
WORD32 i_ch, ia_bit_buf_struct *pstr_it_bit_buff) {
|
||||
WORD32 i;
|
||||
WORD32 len_next_high_rate = (LEN_NEXT_HIGH_RATE * len_frame) / LEN_SUPERFRAME;
|
||||
WORD32 len_lpc0 = (LEN_LPC0 * len_frame) / LEN_SUPERFRAME;
|
||||
FLOAT32 *input_data = &usac_data->td_in_buf[i_ch][len_next_high_rate];
|
||||
ia_usac_td_encoder_struct *td_encoder = usac_data->td_encoder[i_ch];
|
||||
WORD32 fscale = usac_data->td_encoder[i_ch]->fscale;
|
||||
WORD32 first_lpd_flag = (usac_data->core_mode_prev[i_ch] == CORE_MODE_FD);
|
||||
FLOAT32 *speech_buf = usac_data->speech_buf;
|
||||
FLOAT32 *ptr_scratch_buf = usac_data->str_scratch.p_lpd_frm_enc_scratch;
|
||||
FLOAT32 *speech, *new_speech;
|
||||
WORD32 mode_buf[1 + NUM_FRAMES] = {0}, *mode;
|
||||
WORD32 num_tcx_params[NUM_FRAMES] = {0};
|
||||
WORD32 len_subfrm;
|
||||
|
||||
len_subfrm = td_encoder->len_subfrm;
|
||||
|
||||
if (usac_data->core_mode_prev[i_ch] == CORE_MODE_FD) {
|
||||
iusace_reset_td_enc(usac_data->td_encoder[i_ch]);
|
||||
|
||||
FLOAT32 *in_data = usac_data->td_in_prev_buf[i_ch];
|
||||
FLOAT32 *ptr_speech = usac_data->speech_buf;
|
||||
WORD32 length = len_next_high_rate + len_lpc0;
|
||||
ia_usac_td_encoder_struct *st = usac_data->td_encoder[i_ch];
|
||||
memcpy(ptr_speech, in_data, length * sizeof(FLOAT32));
|
||||
|
||||
iusace_highpass_50hz_12k8(ptr_speech, length, st->mem_sig_in, st->fscale);
|
||||
|
||||
iusace_apply_preemph(ptr_speech, PREEMPH_FILT_FAC, length, &(st->mem_preemph));
|
||||
memcpy(st->old_speech_pe + ORDER, ptr_speech, length * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
if (first_lpd_flag) {
|
||||
td_encoder->prev_mode = -1;
|
||||
}
|
||||
|
||||
mode = mode_buf + 1;
|
||||
mode[-1] = td_encoder->prev_mode;
|
||||
fscale = (fscale * len_subfrm) / LEN_FRAME;
|
||||
|
||||
new_speech = speech_buf + ORDER + (LEN_NEXT_HIGH_RATE * len_subfrm) / LEN_FRAME;
|
||||
speech = speech_buf + ORDER;
|
||||
if (first_lpd_flag) {
|
||||
new_speech += (LEN_LPC0 * len_subfrm) / LEN_FRAME;
|
||||
speech += (LEN_LPC0 * len_subfrm) / LEN_FRAME;
|
||||
}
|
||||
memcpy(new_speech, input_data, td_encoder->len_frame * sizeof(FLOAT32));
|
||||
|
||||
iusace_highpass_50hz_12k8(new_speech, td_encoder->len_frame, td_encoder->mem_sig_in, fscale);
|
||||
iusace_apply_preemph(new_speech, PREEMPH_FILT_FAC, td_encoder->len_frame,
|
||||
&(td_encoder->mem_preemph));
|
||||
|
||||
if (first_lpd_flag) {
|
||||
memcpy(speech_buf, td_encoder->old_speech_pe,
|
||||
((ORDER + (((LEN_NEXT_HIGH_RATE + LEN_LPC0) * len_subfrm) / LEN_FRAME))) *
|
||||
sizeof(FLOAT32));
|
||||
for (i = 0; i < (len_subfrm + 1); i++) {
|
||||
ptr_scratch_buf[i] = speech[-len_subfrm - 1 + i];
|
||||
}
|
||||
iusace_apply_deemph(ptr_scratch_buf, PREEMPH_FILT_FAC, len_subfrm + 1, &ptr_scratch_buf[0]);
|
||||
memcpy(td_encoder->lpd_state.tcx_mem, &ptr_scratch_buf[len_subfrm - 128 + 1],
|
||||
128 * sizeof(FLOAT32));
|
||||
} else {
|
||||
memcpy(speech_buf, td_encoder->old_speech_pe,
|
||||
((ORDER + ((LEN_NEXT_HIGH_RATE * len_subfrm) / LEN_FRAME))) * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
iusace_core_lpd_encode(usac_data, speech, mode, num_tcx_params, i_ch);
|
||||
|
||||
if (first_lpd_flag) {
|
||||
memcpy(td_encoder->old_speech_pe,
|
||||
&speech_buf[(td_encoder->len_frame) + (LEN_LPC0 * len_subfrm) / LEN_FRAME],
|
||||
(ORDER + ((LEN_NEXT_HIGH_RATE * len_subfrm) / LEN_FRAME)) * sizeof(FLOAT32));
|
||||
} else {
|
||||
memcpy(td_encoder->old_speech_pe, &speech_buf[(td_encoder->len_frame)],
|
||||
(ORDER + ((LEN_NEXT_HIGH_RATE * len_subfrm) / LEN_FRAME)) * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
iusace_encode_fac_params(mode, num_tcx_params, usac_data, usac_independency_flg,
|
||||
pstr_it_bit_buff, i_ch);
|
||||
|
||||
td_encoder->prev_mode = (WORD16)mode[3];
|
||||
|
||||
memcpy(mod_out, mode, 4 * sizeof(WORD32));
|
||||
return 0;
|
||||
}
|
||||
417
encoder/iusace_lpd_rom.c
Normal file
417
encoder/iusace_lpd_rom.c
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
|
||||
const WORD32 iusace_acelp_core_numbits_1024[NUM_ACELP_CORE_MODES] = {
|
||||
(WORD32)(9.6 * 80), (WORD32)(11.2 * 80), (WORD32)(12.8 * 80),
|
||||
(WORD32)(14.4 * 80), (WORD32)(16.0 * 80), (WORD32)(18.4 * 80)};
|
||||
|
||||
const FLOAT32 iusace_sin_window_96[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 iusace_sin_window_128[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 iusace_sin_window_192[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 iusace_sin_window_256[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 iusace_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 iusace_ispold_init[ORDER] = {0.982973f, 0.932472f, 0.850217f, 0.739009f,
|
||||
0.602635f, 0.445738f, 0.273663f, 0.092268f,
|
||||
-0.092268f, -0.273663f, -0.445738f, -0.602635f,
|
||||
-0.739009f, -0.850217f, -0.932472f, -0.982973f};
|
||||
|
||||
const FLOAT32 iusace_cos_window_512[512] = {
|
||||
0.003067957f, 0.009203754f, 0.015339206f, 0.021474080f, 0.027608145f, 0.033741172f,
|
||||
0.039872929f, 0.046003181f, 0.052131705f, 0.058258265f, 0.064382628f, 0.070504576f,
|
||||
0.076623864f, 0.082740262f, 0.088853553f, 0.094963498f, 0.101069860f, 0.107172422f,
|
||||
0.113270953f, 0.119365215f, 0.125454977f, 0.131540030f, 0.137620121f, 0.143695027f,
|
||||
0.149764538f, 0.155828401f, 0.161886394f, 0.167938292f, 0.173983872f, 0.180022895f,
|
||||
0.186055154f, 0.192080393f, 0.198098406f, 0.204108968f, 0.210111842f, 0.216106802f,
|
||||
0.222093627f, 0.228072077f, 0.234041959f, 0.240003020f, 0.245955050f, 0.251897812f,
|
||||
0.257831097f, 0.263754666f, 0.269668311f, 0.275571823f, 0.281464934f, 0.287347466f,
|
||||
0.293219149f, 0.299079835f, 0.304929227f, 0.310767144f, 0.316593379f, 0.322407693f,
|
||||
0.328209847f, 0.333999664f, 0.339776874f, 0.345541328f, 0.351292759f, 0.357030958f,
|
||||
0.362755716f, 0.368466824f, 0.374164075f, 0.379847199f, 0.385516047f, 0.391170382f,
|
||||
0.396809995f, 0.402434647f, 0.408044159f, 0.413638324f, 0.419216901f, 0.424779683f,
|
||||
0.430326492f, 0.435857087f, 0.441371262f, 0.446868837f, 0.452349573f, 0.457813293f,
|
||||
0.463259786f, 0.468688816f, 0.474100202f, 0.479493767f, 0.484869242f, 0.490226477f,
|
||||
0.495565265f, 0.500885367f, 0.506186664f, 0.511468828f, 0.516731799f, 0.521975279f,
|
||||
0.527199149f, 0.532403111f, 0.537587047f, 0.542750776f, 0.547894061f, 0.553016722f,
|
||||
0.558118522f, 0.563199341f, 0.568258941f, 0.573297143f, 0.578313768f, 0.583308637f,
|
||||
0.588281572f, 0.593232274f, 0.598160684f, 0.603066623f, 0.607949793f, 0.612810075f,
|
||||
0.617647290f, 0.622461259f, 0.627251804f, 0.632018745f, 0.636761844f, 0.641481042f,
|
||||
0.646176040f, 0.650846660f, 0.655492842f, 0.660114348f, 0.664710999f, 0.669282615f,
|
||||
0.673829019f, 0.678350031f, 0.682845533f, 0.687315345f, 0.691759229f, 0.696177125f,
|
||||
0.700568795f, 0.704934061f, 0.709272802f, 0.713584840f, 0.717870057f, 0.722128212f,
|
||||
0.726359129f, 0.730562747f, 0.734738886f, 0.738887310f, 0.743007958f, 0.747100592f,
|
||||
0.751165152f, 0.755201399f, 0.759209216f, 0.763188422f, 0.767138898f, 0.771060526f,
|
||||
0.774953127f, 0.778816521f, 0.782650590f, 0.786455214f, 0.790230215f, 0.793975472f,
|
||||
0.797690868f, 0.801376164f, 0.805031359f, 0.808656156f, 0.812250614f, 0.815814435f,
|
||||
0.819347501f, 0.822849810f, 0.826321065f, 0.829761207f, 0.833170176f, 0.836547732f,
|
||||
0.839893818f, 0.843208253f, 0.846490920f, 0.849741757f, 0.852960587f, 0.856147349f,
|
||||
0.859301805f, 0.862423956f, 0.865513623f, 0.868570685f, 0.871595085f, 0.874586642f,
|
||||
0.877545297f, 0.880470872f, 0.883363366f, 0.886222541f, 0.889048338f, 0.891840696f,
|
||||
0.894599497f, 0.897324562f, 0.900015891f, 0.902673304f, 0.905296743f, 0.907886088f,
|
||||
0.910441279f, 0.912962198f, 0.915448725f, 0.917900801f, 0.920318305f, 0.922701120f,
|
||||
0.925049245f, 0.927362502f, 0.929640889f, 0.931884289f, 0.934092522f, 0.936265647f,
|
||||
0.938403547f, 0.940506041f, 0.942573190f, 0.944604814f, 0.946600914f, 0.948561370f,
|
||||
0.950486064f, 0.952374995f, 0.954228103f, 0.956045270f, 0.957826436f, 0.959571540f,
|
||||
0.961280465f, 0.962953269f, 0.964589775f, 0.966189981f, 0.967753828f, 0.969281256f,
|
||||
0.970772147f, 0.972226501f, 0.973644257f, 0.975025356f, 0.976369739f, 0.977677345f,
|
||||
0.978948176f, 0.980182111f, 0.981379211f, 0.982539296f, 0.983662426f, 0.984748483f,
|
||||
0.985797524f, 0.986809373f, 0.987784147f, 0.988721669f, 0.989621997f, 0.990485072f,
|
||||
0.991310835f, 0.992099285f, 0.992850423f, 0.993564129f, 0.994240463f, 0.994879305f,
|
||||
0.995480776f, 0.996044695f, 0.996571124f, 0.997060061f, 0.997511446f, 0.997925282f,
|
||||
0.998301566f, 0.998640239f, 0.998941302f, 0.999204755f, 0.999430597f, 0.999618828f,
|
||||
0.999769390f, 0.999882340f, 0.999957621f, 0.999995291f, 0.999995291f, 0.999957621f,
|
||||
0.999882340f, 0.999769390f, 0.999618828f, 0.999430597f, 0.999204755f, 0.998941302f,
|
||||
0.998640239f, 0.998301566f, 0.997925282f, 0.997511446f, 0.997060061f, 0.996571124f,
|
||||
0.996044695f, 0.995480776f, 0.994879305f, 0.994240463f, 0.993564129f, 0.992850423f,
|
||||
0.992099285f, 0.991310835f, 0.990485072f, 0.989621997f, 0.988721669f, 0.987784147f,
|
||||
0.986809373f, 0.985797524f, 0.984748483f, 0.983662426f, 0.982539296f, 0.981379211f,
|
||||
0.980182111f, 0.978948176f, 0.977677345f, 0.976369739f, 0.975025356f, 0.973644257f,
|
||||
0.972226501f, 0.970772147f, 0.969281256f, 0.967753828f, 0.966189981f, 0.964589775f,
|
||||
0.962953269f, 0.961280465f, 0.959571540f, 0.957826436f, 0.956045270f, 0.954228103f,
|
||||
0.952374995f, 0.950486064f, 0.948561370f, 0.946600914f, 0.944604814f, 0.942573190f,
|
||||
0.940506041f, 0.938403547f, 0.936265647f, 0.934092522f, 0.931884289f, 0.929640889f,
|
||||
0.927362502f, 0.925049245f, 0.922701120f, 0.920318305f, 0.917900801f, 0.915448725f,
|
||||
0.912962198f, 0.910441279f, 0.907886088f, 0.905296743f, 0.902673304f, 0.900015891f,
|
||||
0.897324562f, 0.894599497f, 0.891840696f, 0.889048338f, 0.886222541f, 0.883363366f,
|
||||
0.880470872f, 0.877545297f, 0.874586642f, 0.871595085f, 0.868570685f, 0.865513623f,
|
||||
0.862423956f, 0.859301805f, 0.856147349f, 0.852960587f, 0.849741757f, 0.846490920f,
|
||||
0.843208253f, 0.839893818f, 0.836547732f, 0.833170176f, 0.829761207f, 0.826321065f,
|
||||
0.822849810f, 0.819347501f, 0.815814435f, 0.812250614f, 0.808656156f, 0.805031359f,
|
||||
0.801376164f, 0.797690868f, 0.793975472f, 0.790230215f, 0.786455214f, 0.782650590f,
|
||||
0.778816521f, 0.774953127f, 0.771060526f, 0.767138898f, 0.763188422f, 0.759209216f,
|
||||
0.755201399f, 0.751165152f, 0.747100592f, 0.743007958f, 0.738887310f, 0.734738886f,
|
||||
0.730562747f, 0.726359129f, 0.722128212f, 0.717870057f, 0.713584840f, 0.709272802f,
|
||||
0.704934061f, 0.700568795f, 0.696177125f, 0.691759229f, 0.687315345f, 0.682845533f,
|
||||
0.678350031f, 0.673829019f, 0.669282615f, 0.664710999f, 0.660114348f, 0.655492842f,
|
||||
0.650846660f, 0.646176040f, 0.641481042f, 0.636761844f, 0.632018745f, 0.627251804f,
|
||||
0.622461259f, 0.617647290f, 0.612810075f, 0.607949793f, 0.603066623f, 0.598160684f,
|
||||
0.593232274f, 0.588281572f, 0.583308637f, 0.578313768f, 0.573297143f, 0.568258941f,
|
||||
0.563199341f, 0.558118522f, 0.553016722f, 0.547894061f, 0.542750776f, 0.537587047f,
|
||||
0.532403111f, 0.527199149f, 0.521975279f, 0.516731799f, 0.511468828f, 0.506186664f,
|
||||
0.500885367f, 0.495565265f, 0.490226477f, 0.484869242f, 0.479493767f, 0.474100202f,
|
||||
0.468688816f, 0.463259786f, 0.457813293f, 0.452349573f, 0.446868837f, 0.441371262f,
|
||||
0.435857087f, 0.430326492f, 0.424779683f, 0.419216901f, 0.413638324f, 0.408044159f,
|
||||
0.402434647f, 0.396809995f, 0.391170382f, 0.385516047f, 0.379847199f, 0.374164075f,
|
||||
0.368466824f, 0.362755716f, 0.357030958f, 0.351292759f, 0.345541328f, 0.339776874f,
|
||||
0.333999664f, 0.328209847f, 0.322407693f, 0.316593379f, 0.310767144f, 0.304929227f,
|
||||
0.299079835f, 0.293219149f, 0.287347466f, 0.281464934f, 0.275571823f, 0.269668311f,
|
||||
0.263754666f, 0.257831097f, 0.251897812f, 0.245955050f, 0.240003020f, 0.234041959f,
|
||||
0.228072077f, 0.222093627f, 0.216106802f, 0.210111842f, 0.204108968f, 0.198098406f,
|
||||
0.192080393f, 0.186055154f, 0.180022895f, 0.173983872f, 0.167938292f, 0.161886394f,
|
||||
0.155828401f, 0.149764538f, 0.143695027f, 0.137620121f, 0.131540030f, 0.125454977f,
|
||||
0.119365215f, 0.113270953f, 0.107172422f, 0.101069860f, 0.094963498f, 0.088853553f,
|
||||
0.082740262f, 0.076623864f, 0.070504576f, 0.064382628f, 0.058258265f, 0.052131705f,
|
||||
0.046003181f, 0.039872929f, 0.033741172f, 0.027608145f, 0.021474080f, 0.015339206f,
|
||||
0.009203754f, 0.003067957f};
|
||||
|
||||
const FLOAT32 iusace_cos_window_448[448] = {
|
||||
0.003506235f, 0.010518531f, 0.017530311f, 0.024541229f, 0.031550940f, 0.038559098f,
|
||||
0.045565363f, 0.052569386f, 0.059570823f, 0.066569328f, 0.073564567f, 0.080556184f,
|
||||
0.087543838f, 0.094527185f, 0.101505890f, 0.108479597f, 0.115447976f, 0.122410677f,
|
||||
0.129367352f, 0.136317670f, 0.143261284f, 0.150197864f, 0.157127038f, 0.164048493f,
|
||||
0.170961887f, 0.177866876f, 0.184763104f, 0.191650257f, 0.198527992f, 0.205395952f,
|
||||
0.212253809f, 0.219101235f, 0.225937888f, 0.232763439f, 0.239577532f, 0.246379837f,
|
||||
0.253170043f, 0.259947777f, 0.266712755f, 0.273464620f, 0.280203015f, 0.286927640f,
|
||||
0.293638140f, 0.300334215f, 0.307015538f, 0.313681751f, 0.320332527f, 0.326967567f,
|
||||
0.333586514f, 0.340189070f, 0.346774876f, 0.353343636f, 0.359895051f, 0.366428733f,
|
||||
0.372944415f, 0.379441738f, 0.385920405f, 0.392380118f, 0.398820519f, 0.405241311f,
|
||||
0.411642164f, 0.418022811f, 0.424382865f, 0.430722058f, 0.437040091f, 0.443336606f,
|
||||
0.449611336f, 0.455863953f, 0.462094128f, 0.468301624f, 0.474486053f, 0.480647177f,
|
||||
0.486784667f, 0.492898196f, 0.498987496f, 0.505052269f, 0.511092186f, 0.517107010f,
|
||||
0.523096323f, 0.529060006f, 0.534997642f, 0.540908933f, 0.546793640f, 0.552651465f,
|
||||
0.558482170f, 0.564285338f, 0.570060790f, 0.575808167f, 0.581527293f, 0.587217808f,
|
||||
0.592879415f, 0.598511875f, 0.604114890f, 0.609688222f, 0.615231574f, 0.620744705f,
|
||||
0.626227260f, 0.631679058f, 0.637099743f, 0.642489135f, 0.647846937f, 0.653172851f,
|
||||
0.658466637f, 0.663728058f, 0.668956876f, 0.674152792f, 0.679315507f, 0.684444845f,
|
||||
0.689540565f, 0.694602311f, 0.699629962f, 0.704623163f, 0.709581733f, 0.714505374f,
|
||||
0.719393909f, 0.724247098f, 0.729064643f, 0.733846307f, 0.738591909f, 0.743301213f,
|
||||
0.747973979f, 0.752609909f, 0.757208824f, 0.761770546f, 0.766294777f, 0.770781398f,
|
||||
0.775230050f, 0.779640555f, 0.784012794f, 0.788346410f, 0.792641282f, 0.796897233f,
|
||||
0.801113904f, 0.805291235f, 0.809428990f, 0.813526869f, 0.817584813f, 0.821602523f,
|
||||
0.825579822f, 0.829516530f, 0.833412468f, 0.837267399f, 0.841081142f, 0.844853580f,
|
||||
0.848584414f, 0.852273524f, 0.855920792f, 0.859525919f, 0.863088787f, 0.866609156f,
|
||||
0.870086968f, 0.873521984f, 0.876914084f, 0.880263031f, 0.883568645f, 0.886830866f,
|
||||
0.890049458f, 0.893224299f, 0.896355212f, 0.899442017f, 0.902484655f, 0.905482829f,
|
||||
0.908436537f, 0.911345541f, 0.914209783f, 0.917029023f, 0.919803143f, 0.922532082f,
|
||||
0.925215602f, 0.927853703f, 0.930446148f, 0.932992816f, 0.935493588f, 0.937948406f,
|
||||
0.940357089f, 0.942719519f, 0.945035577f, 0.947305143f, 0.949528158f, 0.951704502f,
|
||||
0.953834057f, 0.955916643f, 0.957952261f, 0.959940791f, 0.961882055f, 0.963776052f,
|
||||
0.965622663f, 0.967421770f, 0.969173372f, 0.970877230f, 0.972533405f, 0.974141717f,
|
||||
0.975702107f, 0.977214575f, 0.978678942f, 0.980095208f, 0.981463313f, 0.982783079f,
|
||||
0.984054565f, 0.985277653f, 0.986452281f, 0.987578392f, 0.988655984f, 0.989684880f,
|
||||
0.990665197f, 0.991596758f, 0.992479563f, 0.993313551f, 0.994098663f, 0.994834960f,
|
||||
0.995522261f, 0.996160686f, 0.996750057f, 0.997290432f, 0.997781813f, 0.998224080f,
|
||||
0.998617291f, 0.998961389f, 0.999256313f, 0.999502122f, 0.999698818f, 0.999846339f,
|
||||
0.999944687f, 0.999993861f, 0.999993861f, 0.999944687f, 0.999846339f, 0.999698818f,
|
||||
0.999502122f, 0.999256313f, 0.998961389f, 0.998617291f, 0.998224080f, 0.997781813f,
|
||||
0.997290432f, 0.996750057f, 0.996160686f, 0.995522261f, 0.994834960f, 0.994098663f,
|
||||
0.993313551f, 0.992479563f, 0.991596758f, 0.990665197f, 0.989684880f, 0.988655984f,
|
||||
0.987578392f, 0.986452281f, 0.985277653f, 0.984054565f, 0.982783079f, 0.981463313f,
|
||||
0.980095208f, 0.978678942f, 0.977214575f, 0.975702107f, 0.974141717f, 0.972533405f,
|
||||
0.970877230f, 0.969173372f, 0.967421770f, 0.965622663f, 0.963776052f, 0.961882055f,
|
||||
0.959940791f, 0.957952261f, 0.955916643f, 0.953834057f, 0.951704502f, 0.949528158f,
|
||||
0.947305143f, 0.945035577f, 0.942719519f, 0.940357089f, 0.937948406f, 0.935493588f,
|
||||
0.932992816f, 0.930446148f, 0.927853703f, 0.925215602f, 0.922532082f, 0.919803143f,
|
||||
0.917029023f, 0.914209783f, 0.911345541f, 0.908436537f, 0.905482829f, 0.902484655f,
|
||||
0.899442017f, 0.896355212f, 0.893224299f, 0.890049458f, 0.886830866f, 0.883568645f,
|
||||
0.880263031f, 0.876914084f, 0.873521984f, 0.870086968f, 0.866609156f, 0.863088787f,
|
||||
0.859525919f, 0.855920792f, 0.852273524f, 0.848584414f, 0.844853580f, 0.841081142f,
|
||||
0.837267399f, 0.833412468f, 0.829516530f, 0.825579822f, 0.821602523f, 0.817584813f,
|
||||
0.813526869f, 0.809428990f, 0.805291235f, 0.801113904f, 0.796897233f, 0.792641282f,
|
||||
0.788346410f, 0.784012794f, 0.779640555f, 0.775230050f, 0.770781398f, 0.766294777f,
|
||||
0.761770546f, 0.757208824f, 0.752609909f, 0.747973979f, 0.743301213f, 0.738591909f,
|
||||
0.733846307f, 0.729064643f, 0.724247098f, 0.719393909f, 0.714505374f, 0.709581733f,
|
||||
0.704623163f, 0.699629962f, 0.694602311f, 0.689540565f, 0.684444845f, 0.679315507f,
|
||||
0.674152792f, 0.668956876f, 0.663728058f, 0.658466637f, 0.653172851f, 0.647846937f,
|
||||
0.642489135f, 0.637099743f, 0.631679058f, 0.626227260f, 0.620744705f, 0.615231574f,
|
||||
0.609688222f, 0.604114890f, 0.598511875f, 0.592879415f, 0.587217808f, 0.581527293f,
|
||||
0.575808167f, 0.570060790f, 0.564285338f, 0.558482170f, 0.552651465f, 0.546793640f,
|
||||
0.540908933f, 0.534997642f, 0.529060006f, 0.523096323f, 0.517107010f, 0.511092186f,
|
||||
0.505052269f, 0.498987496f, 0.492898196f, 0.486784667f, 0.480647177f, 0.474486053f,
|
||||
0.468301624f, 0.462094128f, 0.455863953f, 0.449611336f, 0.443336606f, 0.437040091f,
|
||||
0.430722058f, 0.424382865f, 0.418022811f, 0.411642164f, 0.405241311f, 0.398820519f,
|
||||
0.392380118f, 0.385920405f, 0.379441738f, 0.372944415f, 0.366428733f, 0.359895051f,
|
||||
0.353343636f, 0.346774876f, 0.340189070f, 0.333586514f, 0.326967567f, 0.320332527f,
|
||||
0.313681751f, 0.307015538f, 0.300334215f, 0.293638140f, 0.286927640f, 0.280203015f,
|
||||
0.273464620f, 0.266712755f, 0.259947777f, 0.253170043f, 0.246379837f, 0.239577532f,
|
||||
0.232763439f, 0.225937888f, 0.219101235f, 0.212253809f, 0.205395952f, 0.198527992f,
|
||||
0.191650257f, 0.184763104f, 0.177866876f, 0.170961887f, 0.164048493f, 0.157127038f,
|
||||
0.150197864f, 0.143261284f, 0.136317670f, 0.129367352f, 0.122410677f, 0.115447976f,
|
||||
0.108479597f, 0.101505890f, 0.094527185f, 0.087543838f, 0.080556184f, 0.073564567f,
|
||||
0.066569328f, 0.059570823f, 0.052569386f, 0.045565363f, 0.038559098f, 0.031550940f,
|
||||
0.024541229f, 0.017530311f, 0.010518531f, 0.003506235f};
|
||||
|
||||
const FLOAT32 iusace_lag_window[17] = {
|
||||
1.0001f, 0.999566371183f, 0.998266612613f, 0.996104103033f, 0.993084457421f,
|
||||
0.989215493202f, 0.984507262707f, 0.978971838951f, 0.972623467445f, 0.965478420258f,
|
||||
0.957554817200f, 0.948872864246f, 0.939454317093f, 0.929322779179f, 0.918503403664f,
|
||||
0.907022833824f, 0.894909143448f,
|
||||
};
|
||||
|
||||
const FLOAT32 iusace_res_interp_filter1_4[INTER_LP_FIL_LEN + 4] = {
|
||||
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, 0.000000f, 0.000000f, 0.000000f, 0.000000f};
|
||||
|
||||
/* [b,a] = butter(2, 20.0/(sampling_freq/2), 'high') --> {a1, a2, b1, b2}.
|
||||
Coeffs a1 and a2 are sign inversed in the table.
|
||||
*/
|
||||
const FLOAT32 iusace_hp20_filter_coeffs[12][4] = {
|
||||
/* 8000Hz */
|
||||
{1.977786483776763f, -0.978030508491796f, -1.977908496134280f, 0.988954248067140f},
|
||||
|
||||
/* 11025Hz */
|
||||
{1.983881041660839f, -0.984009917549517f, -1.983945479605178f, 0.991972739802589f},
|
||||
|
||||
/* 12000Hz */
|
||||
{1.985190657896261f, -0.985299513128215f, -1.985245085512239f, 0.992622542756119f},
|
||||
|
||||
{1.994446410541927f, -0.994461789075954f, -1.994454099808941f, 0.997227049904470f},
|
||||
{1.995970179642829f, -0.995978283057647f, -1.995974231350238f, 0.997987115675119f},
|
||||
{1.996297601769122f, -0.996304442992686f, -1.996301022380904f, 0.998150511190452f},
|
||||
{1.997223199944181f, -0.997227049911866f, -1.997225124928023f, 0.998612562464012f},
|
||||
|
||||
/* 44100Hz */
|
||||
{1.995970179642829f, -0.995978283057647f, -1.995974231350238f, 0.997987115675119f},
|
||||
|
||||
/* 48000Hz */
|
||||
{1.996297601769122f, -0.996304442992686f, -1.996301022380904f, 0.998150511190452f},
|
||||
|
||||
/* 64000Hz */
|
||||
{1.997223199944181f, -0.997227049911866f, -1.997225124928023f, 0.998612562464012f},
|
||||
|
||||
/* 88200Hz */
|
||||
{1.997985087783538f, -0.997987115677172f, -1.997986101730355f, 0.998993050865178f},
|
||||
|
||||
/* 96000Hz */
|
||||
{1.998148799303698f, -0.998150511191915f, -1.998149655247807f, 0.999074827623903f},
|
||||
|
||||
};
|
||||
|
||||
const FLOAT32 iexheaac_cos_window_384[384] = {
|
||||
0.0081811396f, 0.0163617316f, 0.0245412285f, 0.0327190828f, 0.0408947472f, 0.0490676743f,
|
||||
0.0572373173f, 0.0654031292f, 0.0735645636f, 0.0817210741f, 0.0898721149f, 0.0980171403f,
|
||||
0.1061556053f, 0.1142869650f, 0.1224106752f, 0.1305261922f, 0.1386329728f, 0.1467304745f,
|
||||
0.1548181551f, 0.1628954734f, 0.1709618888f, 0.1790168613f, 0.1870598518f, 0.1950903220f,
|
||||
0.2031077344f, 0.2111115524f, 0.2191012402f, 0.2270762630f, 0.2350360872f, 0.2429801799f,
|
||||
0.2509080094f, 0.2588190451f, 0.2667127575f, 0.2745886182f, 0.2824461001f, 0.2902846773f,
|
||||
0.2981038250f, 0.3059030201f, 0.3136817404f, 0.3214394653f, 0.3291756756f, 0.3368898534f,
|
||||
0.3445814824f, 0.3522500479f, 0.3598950365f, 0.3675159366f, 0.3751122380f, 0.3826834324f,
|
||||
0.3902290129f, 0.3977484745f, 0.4052413140f, 0.4127070298f, 0.4201451222f, 0.4275550934f,
|
||||
0.4349364474f, 0.4422886902f, 0.4496113297f, 0.4569038756f, 0.4641658400f, 0.4713967368f,
|
||||
0.4785960820f, 0.4857633937f, 0.4928981922f, 0.5000000000f, 0.5070683417f, 0.5141027442f,
|
||||
0.5211027367f, 0.5280678507f, 0.5349976199f, 0.5418915806f, 0.5487492713f, 0.5555702330f,
|
||||
0.5623540092f, 0.5691001459f, 0.5758081914f, 0.5824776969f, 0.5891082158f, 0.5956993045f,
|
||||
0.6022505217f, 0.6087614290f, 0.6152315906f, 0.6216605734f, 0.6280479471f, 0.6343932842f,
|
||||
0.6406961599f, 0.6469561525f, 0.6531728430f, 0.6593458151f, 0.6654746558f, 0.6715589548f,
|
||||
0.6775983050f, 0.6835923020f, 0.6895405447f, 0.6954426350f, 0.7012981778f, 0.7071067812f,
|
||||
0.7128680564f, 0.7185816178f, 0.7242470830f, 0.7298640727f, 0.7354322111f, 0.7409511254f,
|
||||
0.7464204462f, 0.7518398075f, 0.7572088465f, 0.7625272039f, 0.7677945237f, 0.7730104534f,
|
||||
0.7781746438f, 0.7832867492f, 0.7883464276f, 0.7933533403f, 0.7983071521f, 0.8032075315f,
|
||||
0.8080541504f, 0.8128466846f, 0.8175848132f, 0.8222682190f, 0.8268965886f, 0.8314696123f,
|
||||
0.8359869839f, 0.8404484011f, 0.8448535652f, 0.8492021815f, 0.8534939589f, 0.8577286100f,
|
||||
0.8619058515f, 0.8660254038f, 0.8700869911f, 0.8740903416f, 0.8780351874f, 0.8819212643f,
|
||||
0.8857483124f, 0.8895160754f, 0.8932243012f, 0.8968727415f, 0.9004611522f, 0.9039892931f,
|
||||
0.9074569281f, 0.9108638249f, 0.9142097557f, 0.9174944964f, 0.9207178273f, 0.9238795325f,
|
||||
0.9269794005f, 0.9300172237f, 0.9329927988f, 0.9359059268f, 0.9387564125f, 0.9415440652f,
|
||||
0.9442686983f, 0.9469301295f, 0.9495281806f, 0.9520626777f, 0.9545334512f, 0.9569403357f,
|
||||
0.9592831702f, 0.9615617977f, 0.9637760658f, 0.9659258263f, 0.9680109353f, 0.9700312532f,
|
||||
0.9719866448f, 0.9738769793f, 0.9757021300f, 0.9774619749f, 0.9791563962f, 0.9807852804f,
|
||||
0.9823485185f, 0.9838460059f, 0.9852776424f, 0.9866433321f, 0.9879429836f, 0.9891765100f,
|
||||
0.9903438286f, 0.9914448614f, 0.9924795346f, 0.9934477790f, 0.9943495298f, 0.9951847267f,
|
||||
0.9959533136f, 0.9966552393f, 0.9972904567f, 0.9978589232f, 0.9983606009f, 0.9987954562f,
|
||||
0.9991634599f, 0.9994645875f, 0.9996988187f, 0.9998661379f, 0.9999665339f, 1.0000000000f,
|
||||
0.9999665339f, 0.9998661379f, 0.9996988187f, 0.9994645875f, 0.9991634599f, 0.9987954562f,
|
||||
0.9983606009f, 0.9978589232f, 0.9972904567f, 0.9966552393f, 0.9959533136f, 0.9951847267f,
|
||||
0.9943495298f, 0.9934477790f, 0.9924795346f, 0.9914448614f, 0.9903438286f, 0.9891765100f,
|
||||
0.9879429836f, 0.9866433321f, 0.9852776424f, 0.9838460059f, 0.9823485185f, 0.9807852804f,
|
||||
0.9791563962f, 0.9774619749f, 0.9757021300f, 0.9738769793f, 0.9719866448f, 0.9700312532f,
|
||||
0.9680109353f, 0.9659258263f, 0.9637760658f, 0.9615617977f, 0.9592831702f, 0.9569403357f,
|
||||
0.9545334512f, 0.9520626777f, 0.9495281806f, 0.9469301295f, 0.9442686983f, 0.9415440652f,
|
||||
0.9387564125f, 0.9359059268f, 0.9329927988f, 0.9300172237f, 0.9269794005f, 0.9238795325f,
|
||||
0.9207178273f, 0.9174944964f, 0.9142097557f, 0.9108638249f, 0.9074569281f, 0.9039892931f,
|
||||
0.9004611522f, 0.8968727415f, 0.8932243012f, 0.8895160754f, 0.8857483124f, 0.8819212643f,
|
||||
0.8780351874f, 0.8740903416f, 0.8700869911f, 0.8660254038f, 0.8619058515f, 0.8577286100f,
|
||||
0.8534939589f, 0.8492021815f, 0.8448535652f, 0.8404484011f, 0.8359869839f, 0.8314696123f,
|
||||
0.8268965886f, 0.8222682190f, 0.8175848132f, 0.8128466846f, 0.8080541504f, 0.8032075315f,
|
||||
0.7983071521f, 0.7933533403f, 0.7883464276f, 0.7832867492f, 0.7781746438f, 0.7730104534f,
|
||||
0.7677945237f, 0.7625272039f, 0.7572088465f, 0.7518398075f, 0.7464204462f, 0.7409511254f,
|
||||
0.7354322111f, 0.7298640727f, 0.7242470830f, 0.7185816178f, 0.7128680564f, 0.7071067812f,
|
||||
0.7012981778f, 0.6954426350f, 0.6895405447f, 0.6835923020f, 0.6775983050f, 0.6715589548f,
|
||||
0.6654746558f, 0.6593458151f, 0.6531728430f, 0.6469561525f, 0.6406961599f, 0.6343932842f,
|
||||
0.6280479471f, 0.6216605734f, 0.6152315906f, 0.6087614290f, 0.6022505217f, 0.5956993045f,
|
||||
0.5891082158f, 0.5824776969f, 0.5758081914f, 0.5691001459f, 0.5623540092f, 0.5555702330f,
|
||||
0.5487492713f, 0.5418915806f, 0.5349976199f, 0.5280678507f, 0.5211027367f, 0.5141027442f,
|
||||
0.5070683417f, 0.5000000000f, 0.4928981922f, 0.4857633937f, 0.4785960820f, 0.4713967368f,
|
||||
0.4641658400f, 0.4569038756f, 0.4496113297f, 0.4422886902f, 0.4349364474f, 0.4275550934f,
|
||||
0.4201451222f, 0.4127070298f, 0.4052413140f, 0.3977484745f, 0.3902290129f, 0.3826834324f,
|
||||
0.3751122380f, 0.3675159366f, 0.3598950365f, 0.3522500479f, 0.3445814824f, 0.3368898534f,
|
||||
0.3291756756f, 0.3214394653f, 0.3136817404f, 0.3059030201f, 0.2981038250f, 0.2902846773f,
|
||||
0.2824461001f, 0.2745886182f, 0.2667127575f, 0.2588190451f, 0.2509080094f, 0.2429801799f,
|
||||
0.2350360872f, 0.2270762630f, 0.2191012402f, 0.2111115524f, 0.2031077344f, 0.1950903220f,
|
||||
0.1870598518f, 0.1790168613f, 0.1709618888f, 0.1628954734f, 0.1548181551f, 0.1467304745f,
|
||||
0.1386329728f, 0.1305261922f, 0.1224106752f, 0.1142869650f, 0.1061556053f, 0.0980171403f,
|
||||
0.0898721149f, 0.0817210741f, 0.0735645636f, 0.0654031292f, 0.0572373173f, 0.0490676743f,
|
||||
0.0408947472f, 0.0327190828f, 0.0245412285f, 0.0163617316f, 0.0081811396f, 0.0000000000f,
|
||||
};
|
||||
39
encoder/iusace_lpd_rom.h
Normal file
39
encoder/iusace_lpd_rom.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
extern const FLOAT32 iusace_lsf_init[ORDER];
|
||||
extern const FLOAT32 iusace_sin_window_96[96];
|
||||
extern const FLOAT32 iusace_sin_window_128[128];
|
||||
extern const FLOAT32 iusace_sin_window_192[192];
|
||||
extern const FLOAT32 iusace_sin_window_256[256];
|
||||
extern const FLOAT32 iusace_res_interp_filter1_4[INTER_LP_FIL_LEN + 4];
|
||||
extern const FLOAT32 iusace_lag_window[17];
|
||||
extern const FLOAT32 iusace_lsf_init[ORDER];
|
||||
extern const FLOAT32 iusace_ispold_init[ORDER];
|
||||
extern const FLOAT32 iusace_cos_window_512[512];
|
||||
extern const FLOAT32 iusace_cos_window_448[448];
|
||||
extern const WORD32 iusace_acelp_core_numbits_1024[NUM_ACELP_CORE_MODES];
|
||||
extern const FLOAT32 iusace_acelp_quant_gain_table[];
|
||||
extern const UWORD8 iusace_acelp_ipos[36];
|
||||
extern const FLOAT32 iexheaac_cos_window_384[384];
|
||||
extern const FLOAT32 iusace_hp20_filter_coeffs[12][4];
|
||||
extern const FLOAT32 iusace_ol_corr_weight[518];
|
||||
extern const FLOAT32 iusace_interp4_1[17];
|
||||
593
encoder/iusace_lpd_utils.c
Normal file
593
encoder/iusace_lpd_utils.c
Normal file
|
|
@ -0,0 +1,593 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_func_prototypes.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
#include "ixheaace_common_utils.h"
|
||||
|
||||
WORD32 ia_get_sample_rate(WORD32 sample_rate) {
|
||||
if (92017 <= sample_rate) {
|
||||
return 11;
|
||||
}
|
||||
if (75132 <= sample_rate) {
|
||||
return 10;
|
||||
}
|
||||
if (55426 <= sample_rate) {
|
||||
return 9;
|
||||
}
|
||||
if (46009 <= sample_rate) {
|
||||
return 8;
|
||||
}
|
||||
if (37566 <= sample_rate) {
|
||||
return 7;
|
||||
}
|
||||
if (27713 <= sample_rate) {
|
||||
return 6;
|
||||
}
|
||||
if (23004 <= sample_rate) {
|
||||
return 5;
|
||||
}
|
||||
if (18783 <= sample_rate) {
|
||||
return 4;
|
||||
}
|
||||
if (13856 <= sample_rate) {
|
||||
return 3;
|
||||
}
|
||||
if (11502 <= sample_rate) {
|
||||
return 2;
|
||||
}
|
||||
if (9391 <= sample_rate) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID iusace_write_bits2buf(WORD32 value, WORD32 no_of_bits, WORD16 *bitstream) {
|
||||
WORD16 *pt_bitstream;
|
||||
WORD32 i;
|
||||
pt_bitstream = bitstream + no_of_bits;
|
||||
for (i = 0; i < no_of_bits; i++) {
|
||||
*--pt_bitstream = (WORD16)(value & MASK);
|
||||
value >>= 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WORD32 iusace_get_num_params(WORD32 *qn) {
|
||||
return 2 + ((qn[0] > 0) ? 9 : 0) + ((qn[1] > 0) ? 9 : 0);
|
||||
}
|
||||
|
||||
FLOAT32 iusace_cal_segsnr(FLOAT32 *sig1, FLOAT32 *sig2, WORD16 len, WORD16 nseg) {
|
||||
FLOAT32 snr = 0.0f;
|
||||
FLOAT32 signal, noise, error, fac;
|
||||
WORD16 i, j;
|
||||
for (i = 0; i < len; i += nseg) {
|
||||
signal = 1e-6f;
|
||||
noise = 1e-6f;
|
||||
for (j = 0; j < nseg; j++) {
|
||||
signal += (*sig1) * (*sig1);
|
||||
error = *sig1++ - *sig2++;
|
||||
noise += error * error;
|
||||
}
|
||||
snr += (FLOAT32)log10((FLOAT64)(signal / noise));
|
||||
}
|
||||
fac = ((FLOAT32)(10 * nseg)) / (FLOAT32)len;
|
||||
snr = fac * snr;
|
||||
if (snr < -99.0f) {
|
||||
snr = -99.0f;
|
||||
}
|
||||
return (snr);
|
||||
}
|
||||
|
||||
VOID iusace_highpass_50hz_12k8(FLOAT32 *signal, WORD32 lg, FLOAT32 *mem, WORD32 fscale) {
|
||||
WORD32 i;
|
||||
WORD32 sr_idx = 0;
|
||||
FLOAT32 x0, x1, x2, y0, y1, y2;
|
||||
const FLOAT32 *a = NULL, *b = NULL;
|
||||
|
||||
y1 = mem[0];
|
||||
y2 = mem[1];
|
||||
x0 = mem[2];
|
||||
x1 = mem[3];
|
||||
sr_idx = ia_get_sample_rate(fscale);
|
||||
a = &iusace_hp20_filter_coeffs[sr_idx][0];
|
||||
b = &iusace_hp20_filter_coeffs[sr_idx][2];
|
||||
|
||||
for (i = 0; i < lg; i++) {
|
||||
x2 = x1;
|
||||
x1 = x0;
|
||||
x0 = signal[i];
|
||||
y0 = (y1 * a[0]) + (y2 * a[1]) + (x0 * b[1]) + (x1 * b[0]) + (x2 * b[1]);
|
||||
signal[i] = y0;
|
||||
y2 = y1;
|
||||
y1 = y0;
|
||||
}
|
||||
|
||||
mem[0] = ((y1 > 1e-10) | (y1 < -1e-10)) ? y1 : 0;
|
||||
mem[1] = ((y2 > 1e-10) | (y2 < -1e-10)) ? y2 : 0;
|
||||
mem[2] = ((x0 > 1e-10) | (x0 < -1e-10)) ? x0 : 0;
|
||||
mem[3] = ((x1 > 1e-10) | (x1 < -1e-10)) ? x1 : 0;
|
||||
}
|
||||
|
||||
VOID iusace_apply_preemph(FLOAT32 *signal, FLOAT32 factor, WORD32 length, FLOAT32 *mem) {
|
||||
WORD32 i;
|
||||
FLOAT32 temp;
|
||||
temp = signal[length - 1];
|
||||
for (i = length - 1; i > 0; i--) {
|
||||
signal[i] = signal[i] - factor * signal[i - 1];
|
||||
}
|
||||
signal[0] -= factor * (*mem);
|
||||
*mem = temp;
|
||||
}
|
||||
|
||||
VOID iusace_apply_deemph(FLOAT32 *signal, FLOAT32 factor, WORD32 length, FLOAT32 *mem) {
|
||||
WORD32 i;
|
||||
signal[0] = signal[0] + factor * (*mem);
|
||||
for (i = 1; i < length; i++) {
|
||||
signal[i] = signal[i] + factor * signal[i - 1];
|
||||
}
|
||||
*mem = signal[length - 1];
|
||||
if ((*mem < 1e-10) & (*mem > -1e-10)) {
|
||||
*mem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_synthesis_tool_float(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l, FLOAT32 *mem,
|
||||
FLOAT32 *scratch_synth_tool) {
|
||||
FLOAT32 s;
|
||||
FLOAT32 *yy;
|
||||
WORD32 i, j;
|
||||
memcpy(scratch_synth_tool, mem, ORDER * sizeof(FLOAT32));
|
||||
yy = &scratch_synth_tool[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;
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_compute_lp_residual(FLOAT32 *a, FLOAT32 *x, FLOAT32 *y, WORD32 l) {
|
||||
FLOAT32 s;
|
||||
WORD32 i;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_convolve(FLOAT32 *signal, FLOAT32 *wsynth_filter_ir, FLOAT32 *conv_out) {
|
||||
FLOAT32 temp;
|
||||
WORD32 i, n;
|
||||
for (n = 0; n < LEN_SUBFR; n += 2) {
|
||||
temp = 0.0f;
|
||||
for (i = 0; i <= n; i++) {
|
||||
temp += signal[i] * wsynth_filter_ir[n - i];
|
||||
}
|
||||
conv_out[n] = temp;
|
||||
temp = 0.0f;
|
||||
for (i = 0; i <= (n + 1); i += 2) {
|
||||
temp += signal[i] * wsynth_filter_ir[(n + 1) - i];
|
||||
temp += signal[i + 1] * wsynth_filter_ir[n - i];
|
||||
}
|
||||
conv_out[n + 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_autocorr_plus(FLOAT32 *speech, FLOAT32 *auto_corr_vector, WORD32 window_len,
|
||||
const FLOAT32 *lp_analysis_win, FLOAT32 *temp_aut_corr) {
|
||||
FLOAT32 val;
|
||||
WORD16 i, j;
|
||||
for (i = 0; i < window_len; i++) {
|
||||
temp_aut_corr[i] = speech[i] * lp_analysis_win[i];
|
||||
}
|
||||
for (i = 0; i <= ORDER; i++) {
|
||||
val = 0.0f;
|
||||
for (j = 0; j < window_len - i; j++) {
|
||||
val += temp_aut_corr[j] * temp_aut_corr[j + i];
|
||||
}
|
||||
auto_corr_vector[i] = val;
|
||||
}
|
||||
if (auto_corr_vector[0] < 1.0) {
|
||||
auto_corr_vector[0] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_get_norm_correlation(FLOAT32 *exc, FLOAT32 *xn, FLOAT32 *wsyn_filt_ir,
|
||||
WORD32 min_interval, WORD32 max_interval,
|
||||
FLOAT32 *norm_corr) {
|
||||
WORD32 i, j, k;
|
||||
FLOAT32 filt_prev_exc[LEN_SUBFR];
|
||||
FLOAT32 energy_filt_exc, corr, norm;
|
||||
k = -min_interval;
|
||||
|
||||
iusace_convolve(&exc[k], wsyn_filt_ir, filt_prev_exc);
|
||||
|
||||
for (i = min_interval; i <= max_interval; i++) {
|
||||
corr = 0.0F;
|
||||
energy_filt_exc = 0.01F;
|
||||
for (j = 0; j < LEN_SUBFR; j++) {
|
||||
corr += xn[j] * filt_prev_exc[j];
|
||||
energy_filt_exc += filt_prev_exc[j] * filt_prev_exc[j];
|
||||
}
|
||||
|
||||
norm = (FLOAT32)(1.0f / sqrt(energy_filt_exc));
|
||||
norm_corr[i - min_interval] = corr * norm;
|
||||
|
||||
if (i != max_interval) {
|
||||
k--;
|
||||
for (j = LEN_SUBFR - 1; j > 0; j--) {
|
||||
filt_prev_exc[j] = filt_prev_exc[j - 1] + exc[k] * wsyn_filt_ir[j];
|
||||
}
|
||||
filt_prev_exc[0] = exc[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static FLOAT32 iusace_corr_interpolate(FLOAT32 *x, WORD32 fraction) {
|
||||
FLOAT32 interpol_value, *x1, *x2;
|
||||
const FLOAT32 *p1_interp4_1_table, *p2_interp4_1_table;
|
||||
if (fraction < 0) {
|
||||
fraction += 4;
|
||||
x--;
|
||||
}
|
||||
x1 = &x[0];
|
||||
x2 = &x[1];
|
||||
p1_interp4_1_table = &iusace_interp4_1[fraction];
|
||||
p2_interp4_1_table = &iusace_interp4_1[4 - fraction];
|
||||
interpol_value = x1[0] * p1_interp4_1_table[0] + x2[0] * p2_interp4_1_table[0];
|
||||
interpol_value += x1[-1] * p1_interp4_1_table[4] + x2[1] * p2_interp4_1_table[4];
|
||||
interpol_value += x1[-2] * p1_interp4_1_table[8] + x2[2] * p2_interp4_1_table[8];
|
||||
interpol_value += x1[-3] * p1_interp4_1_table[12] + x2[3] * p2_interp4_1_table[12];
|
||||
|
||||
return interpol_value;
|
||||
}
|
||||
|
||||
VOID iusace_open_loop_search(FLOAT32 *wsp, WORD32 min_pitch_lag, WORD32 max_pitch_lag,
|
||||
WORD32 num_frame, WORD32 *ol_pitch_lag,
|
||||
ia_usac_td_encoder_struct *st) {
|
||||
WORD32 i, j, k;
|
||||
FLOAT32 r, corr, energy1, energy2, corr_max = -1.0e23f;
|
||||
const FLOAT32 *p1_ol_cw_table, *p2_ol_cw_table;
|
||||
FLOAT32 *data_a, *data_b, *hp_wsp, *p, *p1;
|
||||
|
||||
p1_ol_cw_table = &iusace_ol_corr_weight[453];
|
||||
p2_ol_cw_table = &iusace_ol_corr_weight[259 + max_pitch_lag - st->prev_pitch_med];
|
||||
*ol_pitch_lag = 0;
|
||||
for (i = max_pitch_lag; i > min_pitch_lag; i--) {
|
||||
p = &wsp[0];
|
||||
p1 = &wsp[-i];
|
||||
corr = 0.0;
|
||||
for (j = 0; j < num_frame; j += 2) {
|
||||
corr += p[j] * p1[j];
|
||||
corr += p[j + 1] * p1[j + 1];
|
||||
}
|
||||
corr *= *p1_ol_cw_table--;
|
||||
if ((st->prev_pitch_med > 0) && (st->ol_wght_flg == 1)) {
|
||||
corr *= *p2_ol_cw_table--;
|
||||
}
|
||||
if (corr >= corr_max) {
|
||||
corr_max = corr;
|
||||
*ol_pitch_lag = i;
|
||||
}
|
||||
}
|
||||
data_a = st->hp_ol_ltp_mem;
|
||||
data_b = st->hp_ol_ltp_mem + HP_ORDER;
|
||||
hp_wsp = st->prev_hp_wsp + max_pitch_lag;
|
||||
for (k = 0; k < num_frame; k++) {
|
||||
data_b[0] = data_b[1];
|
||||
data_b[1] = data_b[2];
|
||||
data_b[2] = data_b[3];
|
||||
data_b[HP_ORDER] = wsp[k];
|
||||
r = data_b[0] * 0.83787057505665F;
|
||||
r += data_b[1] * -2.50975570071058F;
|
||||
r += data_b[2] * 2.50975570071058F;
|
||||
r += data_b[3] * -0.83787057505665F;
|
||||
r -= data_a[0] * -2.64436711600664F;
|
||||
r -= data_a[1] * 2.35087386625360F;
|
||||
r -= data_a[2] * -0.70001156927424F;
|
||||
data_a[2] = data_a[1];
|
||||
data_a[1] = data_a[0];
|
||||
data_a[0] = r;
|
||||
hp_wsp[k] = r;
|
||||
}
|
||||
p = &hp_wsp[0];
|
||||
p1 = &hp_wsp[-(*ol_pitch_lag)];
|
||||
corr = 0.0F;
|
||||
energy1 = 0.0F;
|
||||
energy2 = 0.0F;
|
||||
for (j = 0; j < num_frame; j++) {
|
||||
energy1 += p1[j] * p1[j];
|
||||
energy2 += p[j] * p[j];
|
||||
corr += p[j] * p1[j];
|
||||
}
|
||||
st->ol_gain = (FLOAT32)(corr / (sqrt(energy1 * energy2) + 1e-5));
|
||||
memmove(st->prev_hp_wsp, &st->prev_hp_wsp[num_frame], max_pitch_lag * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
WORD32 iusace_get_ol_lag_median(WORD32 prev_ol_lag, WORD32 *prev_ol_lags) {
|
||||
WORD32 sorted_ol_lags_out[NUM_OPEN_LOOP_LAGS + 1] = {0};
|
||||
WORD32 i, j, idx, val;
|
||||
WORD32 num_lags = NUM_OPEN_LOOP_LAGS;
|
||||
for (i = NUM_OPEN_LOOP_LAGS - 1; i > 0; i--) {
|
||||
prev_ol_lags[i] = prev_ol_lags[i - 1];
|
||||
}
|
||||
prev_ol_lags[0] = prev_ol_lag;
|
||||
for (i = 0; i < NUM_OPEN_LOOP_LAGS; i++) {
|
||||
sorted_ol_lags_out[i + 1] = prev_ol_lags[i];
|
||||
}
|
||||
|
||||
idx = (NUM_OPEN_LOOP_LAGS >> 1) + 1;
|
||||
for (;;) {
|
||||
if (idx > 1) {
|
||||
val = sorted_ol_lags_out[--idx];
|
||||
} else {
|
||||
val = sorted_ol_lags_out[num_lags];
|
||||
sorted_ol_lags_out[num_lags] = sorted_ol_lags_out[1];
|
||||
if (--num_lags == 1) {
|
||||
sorted_ol_lags_out[1] = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = idx;
|
||||
j = idx << 1;
|
||||
while (j <= num_lags) {
|
||||
if (j < num_lags && sorted_ol_lags_out[j] < sorted_ol_lags_out[j + 1]) {
|
||||
++j;
|
||||
}
|
||||
if (val < sorted_ol_lags_out[j]) {
|
||||
sorted_ol_lags_out[i] = sorted_ol_lags_out[j];
|
||||
i = j;
|
||||
j *= 2;
|
||||
} else {
|
||||
j = num_lags + 1;
|
||||
}
|
||||
}
|
||||
sorted_ol_lags_out[i] = val;
|
||||
}
|
||||
|
||||
return sorted_ol_lags_out[OPEN_LOOP_LAG_MEDIAN];
|
||||
}
|
||||
|
||||
VOID iusace_closed_loop_search(FLOAT32 *exc, FLOAT32 *xn, FLOAT32 *wsyn_filt_ir,
|
||||
WORD32 search_range_min, WORD32 search_range_max, WORD32 *pit_frac,
|
||||
WORD32 is_first_subfrm, WORD32 min_pitch_lag_res1_2,
|
||||
WORD32 min_pitch_lag_res_1, WORD32 *pitch_lag_out) {
|
||||
WORD32 i, fraction, step;
|
||||
FLOAT32 corr_vector[15 + 2 * LEN_INTERPOL1 + 1] = {0};
|
||||
FLOAT32 corr_max, temp;
|
||||
FLOAT32 *p_norm_corr_vector;
|
||||
WORD32 min_interval, max_interval;
|
||||
min_interval = search_range_min - LEN_INTERPOL1;
|
||||
max_interval = search_range_max + LEN_INTERPOL1;
|
||||
p_norm_corr_vector = &corr_vector[0];
|
||||
iusace_get_norm_correlation(exc, xn, wsyn_filt_ir, min_interval, max_interval,
|
||||
p_norm_corr_vector);
|
||||
|
||||
corr_max = p_norm_corr_vector[LEN_INTERPOL1];
|
||||
*pitch_lag_out = search_range_min;
|
||||
for (i = search_range_min + 1; i <= search_range_max; i++) {
|
||||
if (p_norm_corr_vector[i - search_range_min + LEN_INTERPOL1] > corr_max) {
|
||||
corr_max = p_norm_corr_vector[i - search_range_min + LEN_INTERPOL1];
|
||||
*pitch_lag_out = i;
|
||||
}
|
||||
}
|
||||
if ((is_first_subfrm == 0) && (*pitch_lag_out >= min_pitch_lag_res_1)) {
|
||||
*pit_frac = 0;
|
||||
} else {
|
||||
step = 1;
|
||||
fraction = -3;
|
||||
if (((is_first_subfrm == 0) && (*pitch_lag_out >= min_pitch_lag_res1_2)) ||
|
||||
(min_pitch_lag_res1_2 == TMIN)) {
|
||||
step = 2;
|
||||
fraction = -2;
|
||||
}
|
||||
if (*pitch_lag_out == search_range_min) {
|
||||
fraction = 0;
|
||||
}
|
||||
corr_max = iusace_corr_interpolate(
|
||||
&p_norm_corr_vector[(*pitch_lag_out) - search_range_min + LEN_INTERPOL1], fraction);
|
||||
for (i = (fraction + step); i <= 3; i += step) {
|
||||
temp = iusace_corr_interpolate(
|
||||
&p_norm_corr_vector[(*pitch_lag_out) - search_range_min + LEN_INTERPOL1], i);
|
||||
if (temp > corr_max) {
|
||||
corr_max = temp;
|
||||
fraction = i;
|
||||
}
|
||||
}
|
||||
if (fraction < 0) {
|
||||
fraction += 4;
|
||||
(*pitch_lag_out) -= 1;
|
||||
}
|
||||
*pit_frac = fraction;
|
||||
}
|
||||
}
|
||||
|
||||
VOID iusace_decim2_fir_filter(FLOAT32 *signal, WORD32 length, FLOAT32 *mem,
|
||||
FLOAT32 *scratch_fir_sig_buf) {
|
||||
FLOAT32 *sig_buf = scratch_fir_sig_buf;
|
||||
FLOAT32 temp;
|
||||
WORD32 i, j;
|
||||
memcpy(sig_buf, mem, DECIM2_FIR_FILT_MEM_SIZE * sizeof(FLOAT32));
|
||||
memcpy(sig_buf + DECIM2_FIR_FILT_MEM_SIZE, signal, length * sizeof(FLOAT32));
|
||||
for (i = 0; i < DECIM2_FIR_FILT_MEM_SIZE; i++) {
|
||||
mem[i] = ((signal[length - DECIM2_FIR_FILT_MEM_SIZE + i] > 1e-10) ||
|
||||
(signal[length - DECIM2_FIR_FILT_MEM_SIZE + i] < -1e-10))
|
||||
? signal[length - DECIM2_FIR_FILT_MEM_SIZE + i]
|
||||
: 0;
|
||||
}
|
||||
for (i = 0, j = 0; i < length; i += 2, j++) {
|
||||
temp = sig_buf[i] * 0.13F;
|
||||
temp += sig_buf[i + 1] * 0.23F;
|
||||
temp += sig_buf[i + 2] * 0.28F;
|
||||
#ifdef _WIN32
|
||||
#pragma warning(suppress : 6385)
|
||||
#endif
|
||||
temp += sig_buf[i + 3] * 0.23F;
|
||||
temp += sig_buf[i + 4] * 0.13F;
|
||||
signal[j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
FLOAT32 iusace_calc_sq_gain(FLOAT32 *x, WORD32 num_bits, WORD32 length,
|
||||
FLOAT32 *scratch_sq_gain_en) {
|
||||
WORD32 i, j, k;
|
||||
FLOAT32 gain, ener, temp, target, factor, offset;
|
||||
FLOAT32 *en = scratch_sq_gain_en;
|
||||
|
||||
for (i = 0; i < length; i += 4) {
|
||||
ener = 0.01f;
|
||||
for (j = i; j < i + 4; j++) {
|
||||
ener += x[j] * x[j];
|
||||
}
|
||||
|
||||
temp = (FLOAT32)log10(ener);
|
||||
en[i / 4] = 9.0f + 10.0f * temp;
|
||||
}
|
||||
|
||||
target = (6.0f / 4.0f) * (FLOAT32)(num_bits - (length / 16));
|
||||
|
||||
factor = 128.0f;
|
||||
offset = factor;
|
||||
|
||||
for (k = 0; k < 10; k++) {
|
||||
factor *= 0.5f;
|
||||
offset -= factor;
|
||||
ener = 0.0f;
|
||||
for (i = 0; i < length / 4; i++) {
|
||||
temp = en[i] - offset;
|
||||
|
||||
if (temp > 3.0f) {
|
||||
ener += temp;
|
||||
}
|
||||
}
|
||||
if (ener > target) {
|
||||
offset += factor;
|
||||
}
|
||||
}
|
||||
|
||||
gain = (FLOAT32)pow(10.0f, offset / 20.0f);
|
||||
|
||||
return (gain);
|
||||
}
|
||||
|
||||
VOID iusace_lpc_coef_gen(FLOAT32 *lsf_old, FLOAT32 *lsf_new, FLOAT32 *a, WORD32 nb_subfr,
|
||||
WORD32 m) {
|
||||
FLOAT32 lsf[ORDER] = {0}, *ptr_a;
|
||||
FLOAT32 inc, fnew, fold;
|
||||
WORD32 i = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
iusace_lsp_to_lp_conversion(lsf, ptr_a);
|
||||
ptr_a += (m + 1);
|
||||
iusace_lsp_to_lp_conversion(lsf_old, ptr_a);
|
||||
ptr_a += (m + 1);
|
||||
iusace_lsp_to_lp_conversion(lsf_new, ptr_a);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_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;
|
||||
|
||||
iusace_lsp_to_lp_conversion(lsp, lp_flt_coff_a);
|
||||
|
||||
lp_flt_coff_a += (ORDER + 1);
|
||||
}
|
||||
|
||||
iusace_lsp_to_lp_conversion(lsp_new, lp_flt_coff_a);
|
||||
|
||||
return;
|
||||
}
|
||||
125
encoder/iusace_main.h
Normal file
125
encoder/iusace_main.h
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
WORD32 window_size_samples[MAX_TIME_CHANNELS];
|
||||
WORD32 usac_independency_flag_interval;
|
||||
WORD32 usac_independency_flag_count;
|
||||
WORD32 usac_independency_flag;
|
||||
WORD32 frame_count;
|
||||
WORD32 core_mode[MAX_TIME_CHANNELS];
|
||||
WORD32 core_mode_prev[MAX_TIME_CHANNELS];
|
||||
WORD32 core_mode_prev_copy[MAX_TIME_CHANNELS];
|
||||
WORD32 core_mode_next[MAX_TIME_CHANNELS];
|
||||
WORD32 core_mode_copy[MAX_TIME_CHANNELS];
|
||||
ia_block_switch_ctrl block_switch_ctrl[MAX_TIME_CHANNELS];
|
||||
ia_classification_struct str_sig_class_data;
|
||||
FLOAT32 td_in_buf[MAX_TIME_CHANNELS][LEN_SUPERFRAME + LEN_NEXT_HIGH_RATE];
|
||||
FLOAT32 td_in_prev_buf[MAX_TIME_CHANNELS][LEN_SUPERFRAME + LEN_NEXT_HIGH_RATE + LEN_LPC0];
|
||||
FLOAT32 speech_buf[LEN_TOTAL_HIGH_RATE + LEN_LPC0];
|
||||
FLOAT32 synth_buf[ORDER + LEN_SUPERFRAME];
|
||||
WORD32 param_buf[(NUM_FRAMES * MAX_NUM_TCX_PRM_PER_DIV) + NUM_LPC_PRM];
|
||||
ia_usac_td_encoder_struct *td_encoder[MAX_TIME_CHANNELS];
|
||||
WORD32 total_nbbits[MAX_TIME_CHANNELS];
|
||||
WORD32 FD_nbbits_fac[MAX_TIME_CHANNELS];
|
||||
WORD32 num_td_fac_bits[MAX_TIME_CHANNELS];
|
||||
WORD32 td_bitrate[MAX_TIME_CHANNELS];
|
||||
WORD32 acelp_core_mode[MAX_TIME_CHANNELS];
|
||||
WORD32 max_bitreservoir_bits;
|
||||
WORD32 available_bitreservoir_bits;
|
||||
ia_drc_enc_state str_drc_state;
|
||||
WORD32 num_sbr_bits;
|
||||
ia_ms_info_struct str_ms_info[MAX_TIME_CHANNELS];
|
||||
WORD32 pred_coef_re[MAX_TIME_CHANNELS][MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
pred_coef_im[MAX_TIME_CHANNELS][MAX_SHORT_WINDOWS][MAX_SFB_LONG];
|
||||
WORD32 pred_coef_re_prev[MAX_TIME_CHANNELS][MAX_SFB_LONG],
|
||||
pred_coef_im_prev[MAX_TIME_CHANNELS][MAX_SFB_LONG];
|
||||
/* Temporary buffers for bitstream writing function when computing static bits */
|
||||
WORD32 temp_pred_coef_re_prev[MAX_TIME_CHANNELS][MAX_SFB_LONG],
|
||||
temp_pred_coef_im_prev[MAX_TIME_CHANNELS][MAX_SFB_LONG];
|
||||
WORD32 pred_dir_idx[MAX_TIME_CHANNELS];
|
||||
WORD32 cplx_pred_all[MAX_TIME_CHANNELS];
|
||||
WORD32 cplx_pred_used[MAX_TIME_CHANNELS][MAX_SHORT_WINDOWS][MAX_SFB_LONG];
|
||||
WORD32 delta_code_time[MAX_TIME_CHANNELS];
|
||||
WORD32 complex_coef[MAX_TIME_CHANNELS];
|
||||
FLOAT64 *ptr_dmx_re_save[MAX_TIME_CHANNELS]; /*For saving previous frame MDCT down-mix */
|
||||
FLOAT64 *ptr_dmx_im[MAX_TIME_CHANNELS];
|
||||
FLOAT64 arr_dmx_im[MAX_TIME_CHANNELS][(FRAME_LEN_LONG + FRAME_LEN_LONG / 8)];
|
||||
FLOAT64 arr_dmx_save_float[MAX_TIME_CHANNELS][(FRAME_LEN_LONG + FRAME_LEN_LONG / 8)];
|
||||
FLOAT64 left_chan_save[MAX_TIME_CHANNELS][(FRAME_LEN_LONG + FRAME_LEN_LONG / 8)];
|
||||
FLOAT64 right_chan_save[MAX_TIME_CHANNELS][(FRAME_LEN_LONG + FRAME_LEN_LONG / 8)];
|
||||
|
||||
ia_tns_info *pstr_tns_info[MAX_TIME_CHANNELS];
|
||||
WORD32 common_window[MAX_TIME_CHANNELS];
|
||||
WORD32 noise_offset[MAX_TIME_CHANNELS];
|
||||
WORD32 noise_level[MAX_TIME_CHANNELS];
|
||||
|
||||
ia_usac_quant_info_struct str_quant_info[MAX_TIME_CHANNELS];
|
||||
WORD32 noise_filling[MAX_TIME_CHANNELS];
|
||||
ia_psy_mod_struct str_psy_mod;
|
||||
ia_qc_main_struct str_qc_main;
|
||||
FLOAT64 *ptr_time_data[MAX_TIME_CHANNELS];
|
||||
FLOAT64 *ptr_look_ahead_time_data[MAX_TIME_CHANNELS];
|
||||
FLOAT64 *spectral_line_vector[MAX_TIME_CHANNELS];
|
||||
// Pre-/post- twiddle portions of MDCT use two times ccfl of this buffer, hence size of second
|
||||
// argument is 2 * pstr_config->ccfl
|
||||
FLOAT64 mdst_spectrum[MAX_TIME_CHANNELS][2 * FRAME_LEN_LONG];
|
||||
FLOAT64 *ptr_2frame_time_data[MAX_TIME_CHANNELS];
|
||||
WORD16 td_serial_out[MAX_TIME_CHANNELS][NBITS_MAX];
|
||||
WORD16 fac_out_stream[MAX_TIME_CHANNELS][NBITS_MAX];
|
||||
FLOAT64 overlap_buf[MAX_TIME_CHANNELS][2 * FRAME_LEN_LONG];
|
||||
WORD32 channel_elem_type[MAX_TIME_CHANNELS];
|
||||
WORD32 channel_elem_idx[MAX_TIME_CHANNELS];
|
||||
WORD32 num_ext_elements;
|
||||
WORD32 ext_type[MAX_EXTENSION_PAYLOADS];
|
||||
UWORD8 ext_elem_config_payload[MAX_EXTENSION_PAYLOADS][MAX_EXTENSION_PAYLOAD_LEN];
|
||||
UWORD32 ext_elem_config_len[MAX_EXTENSION_PAYLOADS];
|
||||
iusace_scratch_mem str_scratch;
|
||||
} ia_usac_data_struct;
|
||||
|
||||
typedef struct {
|
||||
ia_usac_lpd_state_struct lpd_state[6];
|
||||
ia_usac_lpd_state_struct flpd_state[6];
|
||||
|
||||
} ia_usac_lpd_scratch;
|
||||
|
||||
IA_ERRORCODE iusace_enc_init(ia_usac_encoder_config_struct *ptr_usac_config,
|
||||
ixheaace_audio_specific_config_struct *pstr_asc,
|
||||
ia_usac_data_struct *pstr_state);
|
||||
|
||||
IA_ERRORCODE iusace_quantize_spec(ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 usac_independancy_flag, WORD32 num_chans,
|
||||
ia_usac_data_struct *ptr_usac_data,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config, WORD32 chn,
|
||||
WORD32 ele_id);
|
||||
|
||||
IA_ERRORCODE iusace_grouping(ia_sfb_params_struct *pstr_sfb_prms, WORD32 num_chans,
|
||||
ia_usac_data_struct *ptr_usac_data,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config, WORD32 chn,
|
||||
WORD32 ele_id);
|
||||
|
||||
IA_ERRORCODE iusace_stereo_proc(ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 usac_independancy_flag, ia_usac_data_struct *ptr_usac_data,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config, WORD32 chn);
|
||||
|
||||
VOID iusace_classification(ia_classification_struct *pstr_sig_class,
|
||||
iusace_scratch_mem *pstr_scratch, WORD32 ccfl);
|
||||
142
encoder/iusace_ms.c
Normal file
142
encoder/iusace_ms.c
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "ixheaac_basic_ops32.h"
|
||||
#include "ixheaac_basic_ops40.h"
|
||||
#include "ixheaac_basic_ops.h"
|
||||
|
||||
VOID iusace_ms_apply(ia_psy_mod_data_struct *pstr_psy_data, FLOAT64 *ptr_spec_left,
|
||||
FLOAT64 *ptr_spec_right, WORD32 *ms_select,
|
||||
WORD32 ms_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG], const WORD32 sfb_count,
|
||||
const WORD32 sfb_per_group, const WORD32 max_sfb_per_grp,
|
||||
const WORD32 *ptr_sfb_offsets, WORD32 chn, FLOAT64 *ptr_ms_spec) {
|
||||
FLOAT32 *ptr_sfb_enegry_left = pstr_psy_data[chn].ptr_sfb_energy_long;
|
||||
FLOAT32 *ptr_sfb_energy_right = pstr_psy_data[chn + 1].ptr_sfb_energy_long;
|
||||
const FLOAT32 *ptr_sfb_energy_mid = pstr_psy_data[chn].ptr_sfb_energy_long_ms;
|
||||
const FLOAT32 *ptr_sfb_energy_side = pstr_psy_data[chn + 1].ptr_sfb_energy_long_ms;
|
||||
FLOAT32 *ptr_sfb_thr_left = pstr_psy_data[chn].ptr_sfb_thr_long;
|
||||
FLOAT32 *ptr_sfb_thr_right = pstr_psy_data[chn + 1].ptr_sfb_thr_long;
|
||||
FLOAT32 *ptr_sfb_spread_energy_left = pstr_psy_data[chn].ptr_sfb_spreaded_energy_long;
|
||||
FLOAT32 *ptr_sfb_spread_energy_right = pstr_psy_data[chn + 1].ptr_sfb_spreaded_energy_long;
|
||||
WORD32 sfb, sfb_offsets, j;
|
||||
WORD32 grp = 0;
|
||||
WORD32 ms_counter = 0;
|
||||
WORD32 lr_counter = 0;
|
||||
|
||||
*ms_select = 0;
|
||||
|
||||
for (sfb = 0; sfb < sfb_count; sfb += sfb_per_group, grp++) {
|
||||
for (sfb_offsets = 0; sfb_offsets < max_sfb_per_grp; sfb_offsets++) {
|
||||
FLOAT32 left_right, mid_side, min_thr;
|
||||
WORD32 use_ms;
|
||||
ms_used[grp][sfb_offsets] = 0;
|
||||
|
||||
min_thr = MIN(ptr_sfb_thr_left[sfb + sfb_offsets], ptr_sfb_thr_right[sfb + sfb_offsets]);
|
||||
|
||||
left_right =
|
||||
(ptr_sfb_thr_left[sfb + sfb_offsets] /
|
||||
MAX(ptr_sfb_enegry_left[sfb + sfb_offsets], ptr_sfb_thr_left[sfb + sfb_offsets])) *
|
||||
(ptr_sfb_thr_right[sfb + sfb_offsets] /
|
||||
max(ptr_sfb_energy_right[sfb + sfb_offsets], ptr_sfb_thr_right[sfb + sfb_offsets]));
|
||||
|
||||
mid_side = (min_thr / max(ptr_sfb_energy_mid[sfb + sfb_offsets], min_thr)) *
|
||||
(min_thr / max(ptr_sfb_energy_side[sfb + sfb_offsets], min_thr));
|
||||
|
||||
use_ms = (mid_side >= left_right);
|
||||
|
||||
if (use_ms) {
|
||||
ms_used[grp][sfb_offsets] = 1;
|
||||
|
||||
for (j = ptr_sfb_offsets[sfb + sfb_offsets]; j < ptr_sfb_offsets[sfb + sfb_offsets + 1];
|
||||
j++) {
|
||||
if (ptr_ms_spec != NULL) {
|
||||
ptr_spec_left[j] = ptr_ms_spec[j];
|
||||
ptr_spec_right[j] = ptr_ms_spec[1024 + j];
|
||||
} else {
|
||||
FLOAT64 tmp = ptr_spec_left[j];
|
||||
|
||||
ptr_spec_left[j] = 0.5f * (ptr_spec_left[j] + ptr_spec_right[j]);
|
||||
|
||||
ptr_spec_right[j] = 0.5f * (tmp - ptr_spec_right[j]);
|
||||
}
|
||||
}
|
||||
|
||||
ptr_sfb_thr_left[sfb + sfb_offsets] = ptr_sfb_thr_right[sfb + sfb_offsets] = min_thr;
|
||||
|
||||
ptr_sfb_enegry_left[sfb + sfb_offsets] = ptr_sfb_energy_mid[sfb + sfb_offsets];
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets] = ptr_sfb_energy_side[sfb + sfb_offsets];
|
||||
|
||||
ptr_sfb_spread_energy_left[sfb + sfb_offsets] =
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets] =
|
||||
min(ptr_sfb_spread_energy_left[sfb + sfb_offsets],
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets]) *
|
||||
0.5f;
|
||||
|
||||
ms_counter++;
|
||||
} else {
|
||||
ms_used[grp][sfb_offsets] = 0;
|
||||
lr_counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ms_counter == 0) {
|
||||
*ms_select = 0;
|
||||
} else {
|
||||
if (lr_counter != 0) {
|
||||
*ms_select = 1;
|
||||
} else {
|
||||
*ms_select = 2;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_calc_ms_band_energy(const FLOAT64 *ptr_spec_left, const FLOAT64 *ptr_spec_right,
|
||||
const WORD32 *ptr_band_offset, const WORD32 num_bands,
|
||||
FLOAT32 *ptr_band_energy_mid, FLOAT32 *ptr_band_energy_side) {
|
||||
WORD32 i, j;
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < num_bands; i++) {
|
||||
ptr_band_energy_mid[i] = 0.0f;
|
||||
ptr_band_energy_side[i] = 0.0f;
|
||||
|
||||
while (j < ptr_band_offset[i + 1]) {
|
||||
FLOAT32 specm, specs;
|
||||
|
||||
specm = (FLOAT32)(0.5f * (ptr_spec_left[j] + ptr_spec_right[j]));
|
||||
specs = (FLOAT32)(0.5f * (ptr_spec_left[j] - ptr_spec_right[j]));
|
||||
|
||||
ptr_band_energy_mid[i] += specm * specm;
|
||||
ptr_band_energy_side[i] += specs * specs;
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
35
encoder/iusace_ms.h
Normal file
35
encoder/iusace_ms.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
typedef struct {
|
||||
WORD32 ms_mask;
|
||||
WORD32 ms_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG];
|
||||
} ia_ms_info_struct;
|
||||
|
||||
VOID iusace_ms_apply(ia_psy_mod_data_struct *pstr_psy_data, FLOAT64 *ptr_spec_left,
|
||||
FLOAT64 *ptr_spec_right, WORD32 *ms_select,
|
||||
WORD32 ms_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG], const WORD32 sfb_count,
|
||||
const WORD32 sfb_per_group, const WORD32 max_sfb_per_grp,
|
||||
const WORD32 *ptr_sfb_offsets, WORD32 chn, FLOAT64 *ptr_ms_spec);
|
||||
|
||||
VOID iusace_calc_ms_band_energy(const FLOAT64 *ptr_spec_left, const FLOAT64 *ptr_spec_right,
|
||||
const WORD32 *ptr_band_offset, const WORD32 num_bands,
|
||||
FLOAT32 *ptr_band_energy_mid, FLOAT32 *ptr_band_energy_side);
|
||||
275
encoder/iusace_psy_mod.c
Normal file
275
encoder/iusace_psy_mod.c
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_type_def.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_psy_utils.h"
|
||||
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "iusace_type_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
|
||||
#include "iusace_ms.h"
|
||||
|
||||
#include "iusace_psy_utils.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "ixheaace_memory_standards.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
|
||||
VOID iusace_psy_mod_init(ia_psy_mod_struct *pstr_psy_mod, WORD32 sample_rate, WORD32 bit_rate,
|
||||
WORD32 band_width, WORD32 num_channels, WORD32 ch, WORD32 ele_id,
|
||||
WORD32 ccfl) {
|
||||
WORD32 i;
|
||||
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
iusace_psy_long_config_init(bit_rate / num_channels, sample_rate, band_width,
|
||||
&(pstr_psy_mod->str_psy_long_config[ele_id]), ccfl);
|
||||
|
||||
iusace_psy_short_config_init(bit_rate / num_channels, sample_rate, band_width,
|
||||
&(pstr_psy_mod->str_psy_short_config[ele_id]), ccfl);
|
||||
|
||||
pstr_psy_mod->str_psy_data[ch].ptr_sfb_thr_long =
|
||||
(FLOAT32 *)pstr_psy_mod->str_psy_data[ch].sfb_thr_short;
|
||||
pstr_psy_mod->str_psy_data[ch].ptr_sfb_energy_long =
|
||||
(FLOAT32 *)pstr_psy_mod->str_psy_data[ch].sfb_energy_short;
|
||||
pstr_psy_mod->str_psy_data[ch].ptr_sfb_spreaded_energy_long =
|
||||
(FLOAT32 *)pstr_psy_mod->str_psy_data[ch].sfb_spreaded_energy_short;
|
||||
|
||||
memcpy(pstr_psy_mod->str_psy_data[ch].sfb_thr_nm1,
|
||||
pstr_psy_mod->str_psy_long_config[ele_id].sfb_thr_quiet,
|
||||
pstr_psy_mod->str_psy_long_config[ele_id].sfb_count * sizeof(FLOAT32));
|
||||
|
||||
ch++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_psy_mod_lb(ia_psy_mod_struct *pstr_psy_mod, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
FLOAT64 *ptr_spec_in, ia_tns_info *pstr_tns_info[MAX_TIME_CHANNELS],
|
||||
WORD32 tns_select, WORD32 i_ch, WORD32 chn, WORD32 channel_type,
|
||||
FLOAT64 *scratch_tns_filter, WORD32 elem_idx, FLOAT64 *ptr_tns_scratch,
|
||||
WORD32 ccfl) {
|
||||
ia_psy_mod_data_struct *pstr_psy_data = &(pstr_psy_mod->str_psy_data[i_ch]);
|
||||
ia_psy_mod_long_config_struct *pstr_psy_config = &(pstr_psy_mod->str_psy_long_config[elem_idx]);
|
||||
WORD32 window_sequence = pstr_sfb_prms->window_sequence[i_ch];
|
||||
WORD32 num_sfb = pstr_sfb_prms->num_sfb[i_ch];
|
||||
ia_tns_info *ptr_tns_info = pstr_tns_info[i_ch];
|
||||
WORD32 sfb, line;
|
||||
WORD32 i;
|
||||
WORD32 frame_len_long = ccfl;
|
||||
FLOAT32 energy_shift = 0.25f;
|
||||
FLOAT32 clip_energy = pstr_psy_config->clip_energy * energy_shift;
|
||||
(VOID) channel_type;
|
||||
|
||||
pstr_psy_data->window_sequence = window_sequence;
|
||||
memset(&ptr_spec_in[pstr_psy_config->low_pass_line], 0,
|
||||
(frame_len_long - pstr_psy_config->low_pass_line) * sizeof(FLOAT64));
|
||||
|
||||
iusace_calc_band_energy(ptr_spec_in, pstr_psy_config->sfb_offset, pstr_psy_config->sfb_active,
|
||||
pstr_psy_data->ptr_sfb_energy_long, pstr_psy_config->sfb_count);
|
||||
|
||||
if (tns_select != 0) {
|
||||
ia_tns_info *ptr_tns_info_ch2 = pstr_tns_info[i_ch - chn];
|
||||
ptr_tns_info->number_of_bands = num_sfb;
|
||||
ptr_tns_info->block_type = window_sequence;
|
||||
ptr_tns_info->spec = ptr_spec_in;
|
||||
iusace_tns_encode(ptr_tns_info_ch2, ptr_tns_info, pstr_psy_data->ptr_sfb_energy_long, 0, chn,
|
||||
pstr_psy_config->low_pass_line, scratch_tns_filter, 0, ptr_tns_scratch);
|
||||
}
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->ptr_sfb_thr_long[i] =
|
||||
pstr_psy_data->ptr_sfb_energy_long[i] * pstr_psy_config->ratio;
|
||||
pstr_psy_data->ptr_sfb_thr_long[i] = MIN(pstr_psy_data->ptr_sfb_thr_long[i], clip_energy);
|
||||
}
|
||||
|
||||
if (tns_select != 0) {
|
||||
if (ptr_tns_info->tns_data_present == 1) {
|
||||
iusace_calc_band_energy(ptr_spec_in, pstr_psy_config->sfb_offset,
|
||||
pstr_psy_config->sfb_active, pstr_psy_data->ptr_sfb_energy_long,
|
||||
pstr_psy_config->sfb_count);
|
||||
}
|
||||
}
|
||||
|
||||
iusace_find_max_spreading(pstr_psy_config->sfb_count, pstr_psy_config->sfb_mask_low_fac,
|
||||
pstr_psy_config->sfb_mask_high_fac, pstr_psy_data->ptr_sfb_thr_long);
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->ptr_sfb_thr_long[i] = MAX(pstr_psy_data->ptr_sfb_thr_long[i],
|
||||
(pstr_psy_config->sfb_thr_quiet[i] * energy_shift));
|
||||
}
|
||||
|
||||
if (pstr_psy_data->window_sequence == LONG_STOP_SEQUENCE) {
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->sfb_thr_nm1[i] = 1.0e20f;
|
||||
}
|
||||
}
|
||||
|
||||
iusace_pre_echo_control(pstr_psy_data->sfb_thr_nm1, pstr_psy_config->sfb_count,
|
||||
pstr_psy_config->max_allowed_inc_fac,
|
||||
pstr_psy_config->min_remaining_thr_fac,
|
||||
pstr_psy_data->ptr_sfb_thr_long);
|
||||
|
||||
if (pstr_psy_data->window_sequence == LONG_START_SEQUENCE) {
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->sfb_thr_nm1[i] = 1.0e20f;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->ptr_sfb_spreaded_energy_long[i] = pstr_psy_data->ptr_sfb_energy_long[i];
|
||||
}
|
||||
iusace_find_max_spreading(
|
||||
pstr_psy_config->sfb_count, pstr_psy_config->sfb_mask_low_fac_spr_ener,
|
||||
pstr_psy_config->sfb_mask_high_fac_spr_ener, pstr_psy_data->ptr_sfb_spreaded_energy_long);
|
||||
|
||||
for (sfb = pstr_psy_config->sfb_count - 1; sfb >= 0; sfb--) {
|
||||
for (line = pstr_psy_config->sfb_offset[sfb + 1] - 1;
|
||||
line >= pstr_psy_config->sfb_offset[sfb]; line--) {
|
||||
if (ptr_spec_in[line] != 0) break;
|
||||
}
|
||||
if (line >= pstr_psy_config->sfb_offset[sfb]) break;
|
||||
}
|
||||
|
||||
pstr_psy_mod->str_psy_out_data[i_ch].max_sfb_per_grp = sfb + 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_psy_mod_sb(ia_psy_mod_struct *pstr_psy_mod, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
FLOAT64 *ptr_spec_in, ia_tns_info *pstr_tns_info[MAX_TIME_CHANNELS],
|
||||
WORD32 tns_select, WORD32 i_ch, WORD32 chn, WORD32 channel_type,
|
||||
FLOAT64 *scratch_tns_filter, WORD32 elem_idx, FLOAT64 *ptr_tns_scratch,
|
||||
WORD32 ccfl) {
|
||||
ia_psy_mod_data_struct *pstr_psy_data = &(pstr_psy_mod->str_psy_data[i_ch]);
|
||||
ia_psy_mod_short_config_struct *pstr_psy_config =
|
||||
&(pstr_psy_mod->str_psy_short_config[elem_idx]);
|
||||
WORD32 max_sfb = 0, sfb, line;
|
||||
WORD32 window_sequence = pstr_sfb_prms->window_sequence[i_ch];
|
||||
WORD32 num_sfb = pstr_sfb_prms->num_sfb[i_ch];
|
||||
ia_tns_info *ptr_tns_info = pstr_tns_info[i_ch];
|
||||
WORD32 i, w;
|
||||
WORD32 frame_len_short = (ccfl * FRAME_LEN_SHORT_128) / FRAME_LEN_LONG;
|
||||
FLOAT32 energy_shift = 0.25f;
|
||||
FLOAT32 clip_energy = pstr_psy_config->clip_energy * energy_shift;
|
||||
(VOID) channel_type;
|
||||
|
||||
pstr_psy_data->window_sequence = window_sequence;
|
||||
|
||||
for (w = 0; w < MAX_SHORT_WINDOWS; w++) {
|
||||
WORD32 w_offset = w * frame_len_short;
|
||||
WORD32 offset;
|
||||
FLOAT64 *pmdct_double = &ptr_spec_in[pstr_psy_config->low_pass_line + w_offset];
|
||||
|
||||
offset = frame_len_short - pstr_psy_config->low_pass_line;
|
||||
|
||||
memset(pmdct_double, 0, sizeof(FLOAT64) * offset);
|
||||
|
||||
iusace_calc_band_energy(ptr_spec_in + w_offset, pstr_psy_config->sfb_offset,
|
||||
pstr_psy_config->sfb_active, pstr_psy_data->sfb_energy_short[w],
|
||||
pstr_psy_config->sfb_count);
|
||||
|
||||
if (tns_select != 0) {
|
||||
ia_tns_info *ptr_tns_info_ch2 = pstr_tns_info[i_ch - chn];
|
||||
ptr_tns_info->number_of_bands = num_sfb;
|
||||
ptr_tns_info->block_type = window_sequence;
|
||||
ptr_tns_info->spec = ptr_spec_in + w_offset;
|
||||
iusace_tns_encode(ptr_tns_info_ch2, ptr_tns_info, pstr_psy_data->sfb_energy_short[w], w,
|
||||
chn, pstr_psy_config->low_pass_line, scratch_tns_filter, 0,
|
||||
ptr_tns_scratch);
|
||||
}
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->sfb_thr_short[w][i] =
|
||||
pstr_psy_data->sfb_energy_short[w][i] * pstr_psy_config->ratio;
|
||||
pstr_psy_data->sfb_thr_short[w][i] = MIN(pstr_psy_data->sfb_thr_short[w][i], clip_energy);
|
||||
}
|
||||
|
||||
if (tns_select != 0) {
|
||||
if (ptr_tns_info->tns_data_present == 1) {
|
||||
iusace_calc_band_energy(ptr_spec_in + w_offset, pstr_psy_config->sfb_offset,
|
||||
pstr_psy_config->sfb_active, pstr_psy_data->sfb_energy_short[w],
|
||||
pstr_psy_config->sfb_count);
|
||||
}
|
||||
}
|
||||
|
||||
iusace_find_max_spreading(pstr_psy_config->sfb_count, pstr_psy_config->sfb_mask_low_fac,
|
||||
pstr_psy_config->sfb_mask_high_fac,
|
||||
pstr_psy_data->sfb_thr_short[w]);
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->sfb_thr_short[w][i] =
|
||||
MAX(pstr_psy_data->sfb_thr_short[w][i], (pstr_psy_config->sfb_thr_quiet[i] * 0.25f));
|
||||
}
|
||||
|
||||
iusace_pre_echo_control(pstr_psy_data->sfb_thr_nm1, pstr_psy_config->sfb_count,
|
||||
pstr_psy_config->max_allowed_inc_fac,
|
||||
pstr_psy_config->min_remaining_thr_fac,
|
||||
pstr_psy_data->sfb_thr_short[w]);
|
||||
|
||||
for (i = 0; i < pstr_psy_config->sfb_count; i++) {
|
||||
pstr_psy_data->sfb_spreaded_energy_short[w][i] = pstr_psy_data->sfb_energy_short[w][i];
|
||||
}
|
||||
iusace_find_max_spreading(
|
||||
pstr_psy_config->sfb_count, pstr_psy_config->sfb_mask_low_fac_spr_ener,
|
||||
pstr_psy_config->sfb_mask_high_fac_spr_ener, pstr_psy_data->sfb_spreaded_energy_short[w]);
|
||||
}
|
||||
|
||||
for (WORD32 wnd = 0; wnd < MAX_SHORT_WINDOWS; wnd++) {
|
||||
for (sfb = pstr_psy_config->sfb_count - 1; sfb >= max_sfb; sfb--) {
|
||||
for (line = pstr_psy_config->sfb_offset[sfb + 1] - 1;
|
||||
line >= pstr_psy_config->sfb_offset[sfb]; line--) {
|
||||
if (ptr_spec_in[wnd * frame_len_short + line] != 0.0) break;
|
||||
}
|
||||
if (line >= pstr_psy_config->sfb_offset[sfb]) break;
|
||||
}
|
||||
max_sfb = MAX(max_sfb, sfb);
|
||||
}
|
||||
max_sfb = max_sfb > 0 ? max_sfb : 0;
|
||||
|
||||
pstr_psy_mod->str_psy_out_data[i_ch].max_sfb_per_grp = max_sfb + 1;
|
||||
|
||||
return;
|
||||
}
|
||||
150
encoder/iusace_psy_mod.h
Normal file
150
encoder/iusace_psy_mod.h
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_NUM_GROUPED_SFB (60)
|
||||
#define MAX_BARK_VALUE (24.0f)
|
||||
#define MASK_LOW_FAC (3.0f)
|
||||
#define MASK_HIGH_FAC (1.5f)
|
||||
#define MASK_LOW_SP_ENERGY_L (3.0f)
|
||||
#define MASK_HIGH_SP_ENERGY_L (2.0f)
|
||||
#define MASK_HIGH_SP_ENERGY_L_LBR (1.5f)
|
||||
#define MASK_LOW_SP_ENERGY_S (2.0f)
|
||||
#define MASK_HIGH_SP_ENERGY_S (1.5f)
|
||||
#define C_RATIO (0.001258925f)
|
||||
|
||||
#define MAXIMUM_SCALE_FACTOR_BAND_LONG 51
|
||||
#define MAXIMUM_SCALE_FACTOR_BAND_SHORT 15
|
||||
|
||||
#define MAX_GROUPED_SFB 51
|
||||
#define MAX_GROUPED_SFB_TEMP 60
|
||||
#define BLOCK_SWITCHING_OFFSET (1 * 1024 + 3 * 128 + 64 + 128)
|
||||
#define MAX_CHANNEL_BITS 6144
|
||||
#define MAX_SFB_SHORT 15
|
||||
|
||||
#define TRANS_FAC 8
|
||||
#ifndef FRAME_LEN_SHORT_128
|
||||
#define FRAME_LEN_SHORT_128 (FRAME_LEN_LONG / TRANS_FAC)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
WORD32 sfb_count;
|
||||
WORD32 sfb_active;
|
||||
WORD32 sfb_offset[MAXIMUM_SCALE_FACTOR_BAND_LONG + 1];
|
||||
FLOAT32 sfb_thr_quiet[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
FLOAT32 max_allowed_inc_fac;
|
||||
FLOAT32 min_remaining_thr_fac;
|
||||
WORD32 low_pass_line;
|
||||
FLOAT32 clip_energy;
|
||||
FLOAT32 ratio;
|
||||
FLOAT32 sfb_mask_low_fac[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
FLOAT32 sfb_mask_high_fac[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
FLOAT32 sfb_mask_low_fac_spr_ener[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
FLOAT32 sfb_mask_high_fac_spr_ener[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
FLOAT32 sfb_min_snr[MAXIMUM_SCALE_FACTOR_BAND_LONG];
|
||||
} ia_psy_mod_long_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 sfb_count;
|
||||
WORD32 sfb_active;
|
||||
WORD32 sfb_offset[MAXIMUM_SCALE_FACTOR_BAND_SHORT + 1];
|
||||
FLOAT32 sfb_thr_quiet[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 max_allowed_inc_fac;
|
||||
FLOAT32 min_remaining_thr_fac;
|
||||
WORD32 low_pass_line;
|
||||
FLOAT32 clip_energy;
|
||||
FLOAT32 ratio;
|
||||
FLOAT32 sfb_mask_low_fac[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 sfb_mask_high_fac[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 sfb_mask_low_fac_spr_ener[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 sfb_mask_high_fac_spr_ener[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 sfb_min_snr[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
} ia_psy_mod_short_config_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 sfb_count;
|
||||
WORD32 max_sfb_per_grp;
|
||||
WORD32 sfb_per_group;
|
||||
WORD32 window_sequence;
|
||||
WORD32 window_shape;
|
||||
WORD32 sfb_offsets[100];
|
||||
FLOAT32 *ptr_sfb_energy;
|
||||
FLOAT32 *ptr_sfb_spread_energy;
|
||||
FLOAT32 *ptr_sfb_thr;
|
||||
FLOAT64 *ptr_spec_coeffs;
|
||||
FLOAT32 sfb_sum_lr_energy;
|
||||
FLOAT32 pe;
|
||||
FLOAT32 sfb_min_snr[100];
|
||||
WORD32 ms_used[100];
|
||||
} ia_psy_mod_out_data_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 window_sequence;
|
||||
FLOAT32 sfb_thr_nm1[MAX_GROUPED_SFB_TEMP];
|
||||
FLOAT32 *ptr_sfb_thr_long;
|
||||
FLOAT32 sfb_thr_short[TRANS_FAC][MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 *ptr_sfb_energy_long;
|
||||
FLOAT32 ptr_sfb_energy_long_ms[MAX_GROUPED_SFB_TEMP];
|
||||
FLOAT32 ptr_sfb_energy_short_ms[TRANS_FAC][MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 sfb_energy_short[TRANS_FAC][MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
FLOAT32 *ptr_sfb_spreaded_energy_long;
|
||||
FLOAT32 sfb_spreaded_energy_short[TRANS_FAC][MAXIMUM_SCALE_FACTOR_BAND_SHORT];
|
||||
} ia_psy_mod_data_struct;
|
||||
|
||||
typedef struct ia_psy_mod_struct {
|
||||
ia_psy_mod_long_config_struct str_psy_long_config[MAX_TIME_CHANNELS];
|
||||
ia_psy_mod_short_config_struct str_psy_short_config[MAX_TIME_CHANNELS];
|
||||
ia_psy_mod_data_struct str_psy_data[MAX_TIME_CHANNELS];
|
||||
ia_psy_mod_out_data_struct str_psy_out_data[MAX_TIME_CHANNELS];
|
||||
FLOAT32 mdct_spec_coeff_buf[MAX_TIME_CHANNELS][1024];
|
||||
} ia_psy_mod_struct;
|
||||
|
||||
typedef struct ia_sfb_params_struct {
|
||||
WORD32 num_sfb[MAX_TIME_CHANNELS];
|
||||
WORD32 max_sfb[MAX_TIME_CHANNELS];
|
||||
WORD32 max_sfb_ste;
|
||||
WORD32 sfb_width_table[MAX_TIME_CHANNELS][MAX_SFB_LONG];
|
||||
WORD32 grouped_sfb_offset[MAX_TIME_CHANNELS][MAX_SF_BANDS + 1];
|
||||
WORD32 sfb_offset[MAX_TIME_CHANNELS][MAX_SF_BANDS + 1];
|
||||
WORD32 num_window_groups[MAX_TIME_CHANNELS];
|
||||
WORD32 window_group_length[MAX_TIME_CHANNELS][8];
|
||||
WORD32 window_shape[MAX_TIME_CHANNELS];
|
||||
WORD32 window_sequence[MAX_TIME_CHANNELS];
|
||||
WORD32 common_win[MAX_TIME_CHANNELS];
|
||||
|
||||
} ia_sfb_params_struct;
|
||||
|
||||
VOID iusace_psy_mod_init(ia_psy_mod_struct *pstr_psy_mod, WORD32 sample_rate, WORD32 bit_rate,
|
||||
WORD32 band_width, WORD32 num_channels, WORD32 ch, WORD32 ele_id,
|
||||
WORD32 ccfl);
|
||||
|
||||
VOID iusace_psy_mod_sb(ia_psy_mod_struct *pstr_psy_mod, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
FLOAT64 *ptr_spec_in, ia_tns_info *pstr_tns_info[MAX_TIME_CHANNELS],
|
||||
WORD32 tns_select, WORD32 i_ch, WORD32 chn, WORD32 channel_type,
|
||||
FLOAT64 *scratch_tns_filter, WORD32 elem_idx, FLOAT64 *ptr_tns_scratch,
|
||||
WORD32 ccfl);
|
||||
|
||||
VOID iusace_psy_mod_lb(ia_psy_mod_struct *pstr_psy_mod, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
FLOAT64 *ptr_spec_in, ia_tns_info *pstr_tns_info[MAX_TIME_CHANNELS],
|
||||
WORD32 tns_select, WORD32 i_ch, WORD32 chn, WORD32 channel_type,
|
||||
FLOAT64 *scratch_tns_filter, WORD32 elem_idx, FLOAT64 *ptr_tns_scratch,
|
||||
WORD32 ccfl);
|
||||
218
encoder/iusace_psy_rom.c
Normal file
218
encoder/iusace_psy_rom.c
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "iusace_type_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_psy_utils.h"
|
||||
|
||||
const WORD16 iusace_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 iexheaac_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 iusace_sfb_96_128[] = {4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128};
|
||||
|
||||
const WORD16 iexheaac_sfb_96_96[] = {4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 96};
|
||||
|
||||
const WORD16 iusace_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 iusace_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 iusace_sfb_64_128[] = {4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128};
|
||||
|
||||
const WORD16 iusace_sfb_64_96[] = {4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 96};
|
||||
|
||||
const WORD16 iusace_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 iexheaac_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 iusace_sfb_48_128[] = {4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128};
|
||||
|
||||
const WORD16 iexheaac_sfb_48_96[] = {4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96};
|
||||
|
||||
const WORD16 iusace_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 iexheaac_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 iusace_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 iexheaac_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 iusace_sfb_24_128[] = {4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128};
|
||||
|
||||
const WORD16 iexheaac_sfb_24_96[] = {4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 96};
|
||||
|
||||
const WORD16 iusace_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 iexheaac_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 iusace_sfb_16_128[] = {4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128};
|
||||
|
||||
const WORD16 iexheaac_sfb_16_96[] = {4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 96};
|
||||
|
||||
const WORD16 iusace_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 iusace_sfb_8_128[] = {4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128};
|
||||
|
||||
const WORD16 iusace_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 iusace_sfb_8_96[] = {4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 96};
|
||||
|
||||
ia_sfb_info_struct iusace_sfb_info_1024[12] = {
|
||||
{8000, 40, 15, iusace_sfb_8_1024, iusace_sfb_8_128, {0}, {0}},
|
||||
{11025, 43, 15, iusace_sfb_16_1024, iusace_sfb_16_128, {0}, {0}},
|
||||
{12000, 43, 15, iusace_sfb_16_1024, iusace_sfb_16_128, {0}, {0}},
|
||||
{16000, 43, 15, iusace_sfb_16_1024, iusace_sfb_16_128, {0}, {0}},
|
||||
{22050, 47, 15, iusace_sfb_24_1024, iusace_sfb_24_128, {0}, {0}},
|
||||
{24000, 47, 15, iusace_sfb_24_1024, iusace_sfb_24_128, {0}, {0}},
|
||||
{32000, 51, 14, iusace_sfb_32_1024, iusace_sfb_48_128, {0}, {0}},
|
||||
{44100, 49, 14, iusace_sfb_48_1024, iusace_sfb_48_128, {0}, {0}},
|
||||
{48000, 49, 14, iusace_sfb_48_1024, iusace_sfb_48_128, {0}, {0}},
|
||||
{64000, 47, 12, iusace_sfb_64_1024, iusace_sfb_64_128, {0}, {0}},
|
||||
{88200, 41, 12, iusace_sfb_64_1024, iusace_sfb_64_128, {0}, {0}},
|
||||
{96000, 41, 12, iusace_sfb_96_1024, iusace_sfb_96_128, {0}, {0}}};
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
ia_sfb_info_struct iusace_sfb_info_768[12] = {{8000,
|
||||
ARRAY_SIZE(iusace_sfb_8_768),
|
||||
ARRAY_SIZE(iusace_sfb_8_96),
|
||||
iusace_sfb_8_768,
|
||||
iusace_sfb_8_96,
|
||||
{0},
|
||||
{0}},
|
||||
{11025,
|
||||
ARRAY_SIZE(iexheaac_sfb_16_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_16_96),
|
||||
iexheaac_sfb_16_768,
|
||||
iexheaac_sfb_16_96,
|
||||
{0},
|
||||
{0}},
|
||||
{12000,
|
||||
ARRAY_SIZE(iexheaac_sfb_16_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_16_96),
|
||||
iexheaac_sfb_16_768,
|
||||
iexheaac_sfb_16_96,
|
||||
{0},
|
||||
{0}},
|
||||
{16000,
|
||||
ARRAY_SIZE(iexheaac_sfb_16_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_16_96),
|
||||
iexheaac_sfb_16_768,
|
||||
iexheaac_sfb_16_96,
|
||||
{0},
|
||||
{0}},
|
||||
{22050,
|
||||
ARRAY_SIZE(iexheaac_sfb_24_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_24_96),
|
||||
iexheaac_sfb_24_768,
|
||||
iexheaac_sfb_24_96,
|
||||
{0},
|
||||
{0}},
|
||||
{24000,
|
||||
ARRAY_SIZE(iexheaac_sfb_24_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_24_96),
|
||||
iexheaac_sfb_24_768,
|
||||
iexheaac_sfb_24_96,
|
||||
{0},
|
||||
{0}},
|
||||
{32000,
|
||||
ARRAY_SIZE(iexheaac_sfb_48_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_48_96),
|
||||
iexheaac_sfb_48_768,
|
||||
iexheaac_sfb_48_96,
|
||||
{0},
|
||||
{0}},
|
||||
{44100,
|
||||
ARRAY_SIZE(iexheaac_sfb_48_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_48_96),
|
||||
iexheaac_sfb_48_768,
|
||||
iexheaac_sfb_48_96,
|
||||
{0},
|
||||
{0}},
|
||||
{48000,
|
||||
ARRAY_SIZE(iexheaac_sfb_48_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_48_96),
|
||||
iexheaac_sfb_48_768,
|
||||
iexheaac_sfb_48_96,
|
||||
{0},
|
||||
{0}},
|
||||
{64000,
|
||||
ARRAY_SIZE(iusace_sfb_64_768),
|
||||
ARRAY_SIZE(iusace_sfb_64_96),
|
||||
iusace_sfb_64_768,
|
||||
iusace_sfb_64_96,
|
||||
{0},
|
||||
{0}},
|
||||
{88200,
|
||||
ARRAY_SIZE(iusace_sfb_64_768),
|
||||
ARRAY_SIZE(iusace_sfb_64_96),
|
||||
iusace_sfb_64_768,
|
||||
iusace_sfb_64_96,
|
||||
{0},
|
||||
{0}},
|
||||
{96000,
|
||||
ARRAY_SIZE(iexheaac_sfb_96_768),
|
||||
ARRAY_SIZE(iexheaac_sfb_96_96),
|
||||
iexheaac_sfb_96_768,
|
||||
iexheaac_sfb_96_96,
|
||||
{0},
|
||||
{0}}};
|
||||
550
encoder/iusace_psy_utils.c
Normal file
550
encoder/iusace_psy_utils.c
Normal file
|
|
@ -0,0 +1,550 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_psy_utils.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_qc_adjthr.h"
|
||||
|
||||
extern ia_sfb_info_struct iusace_sfb_info_1024[12];
|
||||
extern ia_sfb_info_struct iusace_sfb_info_768[12];
|
||||
|
||||
static const FLOAT32 iusace_bark_quiet_thr_val[] = {
|
||||
15.0f, 10.0f, 7.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 5.0f, 10.0f, 20.0f, 30.0f};
|
||||
|
||||
VOID iusace_calc_band_energy(const FLOAT64 *ptr_spec_coeffs, const WORD32 *band_offset,
|
||||
const WORD32 num_bands, FLOAT32 *ptr_band_energy, WORD32 sfb_count) {
|
||||
WORD32 i, j;
|
||||
|
||||
j = 0;
|
||||
memset(ptr_band_energy, 0, sfb_count * sizeof(FLOAT32));
|
||||
for (i = 0; i < num_bands; i++) {
|
||||
while (j < band_offset[i + 1]) {
|
||||
ptr_band_energy[i] += (FLOAT32)(ptr_spec_coeffs[j] * ptr_spec_coeffs[j]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_find_max_spreading(const WORD32 sfb_count, const FLOAT32 *ptr_mask_low_fac,
|
||||
const FLOAT32 *ptr_mask_high_fac, FLOAT32 *ptr_spreaded_enegry) {
|
||||
WORD32 i;
|
||||
|
||||
for (i = 1; i < sfb_count; i++) {
|
||||
ptr_spreaded_enegry[i] =
|
||||
MAX(ptr_spreaded_enegry[i], ptr_mask_high_fac[i] * ptr_spreaded_enegry[i - 1]);
|
||||
}
|
||||
|
||||
for (i = sfb_count - 2; i >= 0; i--) {
|
||||
ptr_spreaded_enegry[i] =
|
||||
MAX(ptr_spreaded_enegry[i], ptr_mask_low_fac[i] * ptr_spreaded_enegry[i + 1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_pre_echo_control(FLOAT32 *ptr_thr_nm1, WORD32 sfb_count, FLOAT32 max_allowed_inc_fac,
|
||||
FLOAT32 min_remaining_thr_fac, FLOAT32 *ptr_threshold) {
|
||||
WORD32 i;
|
||||
FLOAT32 thr1, thr2;
|
||||
|
||||
for (i = 0; i < sfb_count; i++) {
|
||||
thr1 = max_allowed_inc_fac * (ptr_thr_nm1[i]);
|
||||
thr2 = min_remaining_thr_fac * ptr_threshold[i];
|
||||
|
||||
ptr_thr_nm1[i] = ptr_threshold[i];
|
||||
|
||||
if (ptr_threshold[i] > thr1) {
|
||||
ptr_threshold[i] = thr1;
|
||||
}
|
||||
if (thr2 > ptr_threshold[i]) {
|
||||
ptr_threshold[i] = thr2;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_sfb_init(WORD32 sample_rate, WORD32 block_type, WORD32 *ptr_sfb_offset,
|
||||
WORD32 *ptr_sfb_count, WORD32 ccfl) {
|
||||
const WORD16 *ptr_sfb_params = 0;
|
||||
WORD32 start_offset, block_len = 0;
|
||||
const ia_sfb_info_struct *pstr_sfb_info_tbls = &iusace_sfb_info_1024[0];
|
||||
WORD32 sampling_rate_mapped = sample_rate;
|
||||
WORD16 prev_val = 0;
|
||||
if (ccfl == LEN_SUPERFRAME_768) {
|
||||
pstr_sfb_info_tbls = &iusace_sfb_info_768[0];
|
||||
}
|
||||
|
||||
if ((sample_rate >= 0) && (sample_rate < 9391)) {
|
||||
sampling_rate_mapped = 8000;
|
||||
} else if ((sample_rate >= 9391) && (sample_rate < 11502)) {
|
||||
sampling_rate_mapped = 11025;
|
||||
} else if ((sample_rate >= 11502) && (sample_rate < 13856)) {
|
||||
sampling_rate_mapped = 12000;
|
||||
} else if ((sample_rate >= 13856) && (sample_rate < 18783)) {
|
||||
sampling_rate_mapped = 16000;
|
||||
} else if ((sample_rate >= 18783) && (sample_rate < 23004)) {
|
||||
sampling_rate_mapped = 22050;
|
||||
} else if ((sample_rate >= 23004) && (sample_rate < 27713)) {
|
||||
sampling_rate_mapped = 24000;
|
||||
} else if ((sample_rate >= 27713) && (sample_rate < 37566)) {
|
||||
sampling_rate_mapped = 32000;
|
||||
} else if ((sample_rate >= 37566) && (sample_rate < 46009)) {
|
||||
sampling_rate_mapped = 44100;
|
||||
} else if ((sample_rate >= 46009) && (sample_rate < 55426)) {
|
||||
sampling_rate_mapped = 48000;
|
||||
} else if ((sample_rate >= 55426) && (sample_rate < 75132)) {
|
||||
sampling_rate_mapped = 64000;
|
||||
} else if ((sample_rate >= 75132) && (sample_rate < 92017)) {
|
||||
sampling_rate_mapped = 88200;
|
||||
} else if (sample_rate >= 92017) {
|
||||
sampling_rate_mapped = 96000;
|
||||
} else {
|
||||
sampling_rate_mapped = 48000;
|
||||
}
|
||||
|
||||
if (block_type == ONLY_LONG_SEQUENCE) {
|
||||
block_len = ccfl;
|
||||
switch (sampling_rate_mapped) {
|
||||
case 96000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[11].cb_offset_long;
|
||||
break;
|
||||
case 88200:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[10].cb_offset_long;
|
||||
break;
|
||||
case 64000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[9].cb_offset_long;
|
||||
break;
|
||||
case 48000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[8].cb_offset_long;
|
||||
break;
|
||||
case 44100:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[7].cb_offset_long;
|
||||
break;
|
||||
case 32000:
|
||||
case 29400:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[6].cb_offset_long;
|
||||
break;
|
||||
case 24000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[5].cb_offset_long;
|
||||
break;
|
||||
case 22050:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[4].cb_offset_long;
|
||||
break;
|
||||
case 16000:
|
||||
case 14700:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[3].cb_offset_long;
|
||||
break;
|
||||
case 12000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[2].cb_offset_long;
|
||||
break;
|
||||
case 11025:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[1].cb_offset_long;
|
||||
break;
|
||||
case 8000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[0].cb_offset_long;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
block_len = ccfl >> 3;
|
||||
switch (sampling_rate_mapped) {
|
||||
case 96000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[11].cb_offset_short;
|
||||
break;
|
||||
case 88200:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[10].cb_offset_short;
|
||||
break;
|
||||
case 64000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[9].cb_offset_short;
|
||||
break;
|
||||
case 48000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[8].cb_offset_short;
|
||||
break;
|
||||
case 44100:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[7].cb_offset_short;
|
||||
break;
|
||||
case 32000:
|
||||
case 29400:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[6].cb_offset_short;
|
||||
break;
|
||||
case 24000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[5].cb_offset_short;
|
||||
break;
|
||||
case 22050:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[4].cb_offset_short;
|
||||
break;
|
||||
case 16000:
|
||||
case 14700:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[3].cb_offset_short;
|
||||
break;
|
||||
case 12000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[2].cb_offset_short;
|
||||
break;
|
||||
case 11025:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[1].cb_offset_short;
|
||||
break;
|
||||
case 8000:
|
||||
ptr_sfb_params = pstr_sfb_info_tbls[0].cb_offset_short;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr_sfb_count = 0;
|
||||
start_offset = 0;
|
||||
|
||||
do {
|
||||
ptr_sfb_offset[*ptr_sfb_count] = start_offset;
|
||||
if (*ptr_sfb_count == 0)
|
||||
prev_val = 0;
|
||||
else
|
||||
prev_val = ptr_sfb_params[*ptr_sfb_count - 1];
|
||||
start_offset += ptr_sfb_params[*ptr_sfb_count] - prev_val;
|
||||
(*ptr_sfb_count)++;
|
||||
} while (start_offset < block_len);
|
||||
|
||||
ptr_sfb_offset[*ptr_sfb_count] = start_offset;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static FLOAT32 iusace_atan_approx(FLOAT32 val) {
|
||||
if (val < (FLOAT32)1.0) {
|
||||
return (val / ((FLOAT32)1.0f + (FLOAT32)0.280872f * val * val));
|
||||
} else {
|
||||
return ((FLOAT32)1.57079633f - val / ((FLOAT32)0.280872f + val * val));
|
||||
}
|
||||
}
|
||||
|
||||
static FLOAT32 iusace_calc_bark_line_value(WORD32 num_lines, WORD32 fft_line,
|
||||
WORD32 sample_rate) {
|
||||
FLOAT32 center_freq, temp, b_value;
|
||||
|
||||
center_freq = (FLOAT32)fft_line * ((FLOAT32)sample_rate * (FLOAT32)0.5f) / (FLOAT32)num_lines;
|
||||
temp = (FLOAT32)iusace_atan_approx((FLOAT32)1.3333333e-4f * center_freq);
|
||||
b_value = (FLOAT32)13.3f * iusace_atan_approx((FLOAT32)0.00076f * center_freq) +
|
||||
(FLOAT32)3.5f * temp * temp;
|
||||
|
||||
return (b_value);
|
||||
}
|
||||
|
||||
static VOID iusace_bark_values_init(WORD32 sfb_count, WORD32 *ptr_sfb_offset, WORD32 num_lines,
|
||||
WORD32 sample_rate, FLOAT32 *ptr_b_value) {
|
||||
WORD32 i;
|
||||
FLOAT32 b_val0, b_val1;
|
||||
b_val0 = 0.0f;
|
||||
|
||||
for (i = 0; i < sfb_count; i++) {
|
||||
b_val1 = iusace_calc_bark_line_value(num_lines, ptr_sfb_offset[i + 1], sample_rate);
|
||||
ptr_b_value[i] = (b_val0 + b_val1) * (FLOAT32)0.5f;
|
||||
b_val0 = b_val1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_thr_quiet_init(WORD32 sfb_count, WORD32 *ptr_sfb_offset, FLOAT32 *ptr_bark_val,
|
||||
FLOAT32 *ptr_thr_quiet) {
|
||||
WORD32 i;
|
||||
FLOAT32 bark_thr_quiet;
|
||||
|
||||
for (i = 0; i < sfb_count; i++) {
|
||||
WORD32 b_val1, b_val2;
|
||||
|
||||
if (i > 0) {
|
||||
b_val1 = (WORD32)(ptr_bark_val[i] + ptr_bark_val[i - 1]) >> 1;
|
||||
} else {
|
||||
b_val1 = (WORD32)(ptr_bark_val[i]) >> 1;
|
||||
}
|
||||
|
||||
if (i < sfb_count - 1) {
|
||||
b_val2 = (WORD32)(ptr_bark_val[i] + ptr_bark_val[i + 1]) >> 1;
|
||||
} else {
|
||||
b_val2 = (WORD32)(ptr_bark_val[i]);
|
||||
}
|
||||
b_val1 = MIN(b_val1, (WORD32)MAX_BARK_VALUE);
|
||||
b_val2 = MIN(b_val2, (WORD32)MAX_BARK_VALUE);
|
||||
bark_thr_quiet = MIN(iusace_bark_quiet_thr_val[b_val1], iusace_bark_quiet_thr_val[b_val2]);
|
||||
|
||||
ptr_thr_quiet[i] = (FLOAT32)pow(10.0f, (bark_thr_quiet - 20.0f) * (FLOAT32)0.1f) * 16887.8f *
|
||||
(FLOAT32)(ptr_sfb_offset[i + 1] - ptr_sfb_offset[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_spreading_init(WORD32 sfb_count, FLOAT32 *ptr_bark_val,
|
||||
FLOAT32 *ptr_mask_low_fac, FLOAT32 *ptr_mask_high_fac,
|
||||
FLOAT32 *ptr_mask_low_fac_spr_energy,
|
||||
FLOAT32 *ptr_mask_high_fac_spr_energy, const WORD32 bit_rate,
|
||||
WORD32 block_type) {
|
||||
WORD32 i;
|
||||
FLOAT32 mask_low_spr_energy, mask_high_spr_energy;
|
||||
|
||||
if (block_type != EIGHT_SHORT_SEQUENCE) {
|
||||
mask_low_spr_energy = MASK_LOW_SP_ENERGY_L;
|
||||
mask_high_spr_energy = (bit_rate > 22000) ? MASK_HIGH_SP_ENERGY_L : MASK_HIGH_SP_ENERGY_L_LBR;
|
||||
} else {
|
||||
mask_low_spr_energy = MASK_LOW_SP_ENERGY_S;
|
||||
mask_high_spr_energy = MASK_HIGH_SP_ENERGY_S;
|
||||
}
|
||||
|
||||
for (i = 0; i < sfb_count; i++) {
|
||||
if (i > 0) {
|
||||
FLOAT32 db_val;
|
||||
FLOAT32 diff_val = (ptr_bark_val[i] - ptr_bark_val[i - 1]);
|
||||
|
||||
db_val = MASK_HIGH_FAC * diff_val;
|
||||
ptr_mask_high_fac[i] = (FLOAT32)pow(10.0f, -db_val);
|
||||
db_val = MASK_LOW_FAC * diff_val;
|
||||
ptr_mask_low_fac[i - 1] = (FLOAT32)pow(10.0f, -db_val);
|
||||
db_val = mask_high_spr_energy * diff_val;
|
||||
ptr_mask_high_fac_spr_energy[i] = (FLOAT32)pow(10.0f, -db_val);
|
||||
db_val = mask_low_spr_energy * diff_val;
|
||||
ptr_mask_low_fac_spr_energy[i - 1] = (FLOAT32)pow(10.0f, -db_val);
|
||||
} else {
|
||||
ptr_mask_high_fac[i] = 0.0f;
|
||||
ptr_mask_low_fac[sfb_count - 1] = 0.0f;
|
||||
ptr_mask_high_fac_spr_energy[i] = 0.0f;
|
||||
ptr_mask_low_fac_spr_energy[sfb_count - 1] = 0.0f;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_min_snr_init(const WORD32 bit_rate, const WORD32 sample_rate,
|
||||
const WORD32 num_lines, const WORD32 *ptr_sfb_offset,
|
||||
const FLOAT32 *ptr_bark_value, const WORD32 sfb_active,
|
||||
FLOAT32 *ptr_sfb_min_snr) {
|
||||
WORD32 sfb;
|
||||
FLOAT32 bark_fac;
|
||||
FLOAT32 bark_width;
|
||||
FLOAT32 pe_per_window, pe_part;
|
||||
FLOAT32 snr;
|
||||
FLOAT32 b_val0, b_val1;
|
||||
|
||||
if (sfb_active == 0) {
|
||||
bark_fac = 1.0f;
|
||||
} else {
|
||||
bark_fac = (FLOAT32)1.0 / MIN(ptr_bark_value[sfb_active - 1] / MAX_BARK_VALUE, (FLOAT32)1.0);
|
||||
}
|
||||
|
||||
pe_per_window =
|
||||
iusace_bits_to_pe((FLOAT32)bit_rate / (FLOAT32)sample_rate * (FLOAT32)num_lines);
|
||||
|
||||
b_val0 = (FLOAT32)0.0f;
|
||||
|
||||
for (sfb = 0; sfb < sfb_active; sfb++) {
|
||||
b_val1 = (FLOAT32)2.0 * ptr_bark_value[sfb] - b_val0;
|
||||
bark_width = b_val1 - b_val0;
|
||||
b_val0 = b_val1;
|
||||
|
||||
pe_part = pe_per_window * (FLOAT32)0.024f * bark_fac;
|
||||
pe_part *= bark_width;
|
||||
pe_part /= (FLOAT32)(ptr_sfb_offset[sfb + 1] - ptr_sfb_offset[sfb]);
|
||||
snr = (FLOAT32)pow(2.0f, pe_part) - 1.5f;
|
||||
snr = 1.0f / MAX(snr, 1.0f);
|
||||
snr = MIN(snr, 0.8f);
|
||||
snr = MAX(snr, 0.003f);
|
||||
ptr_sfb_min_snr[sfb] = snr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_psy_long_config_init(WORD32 bit_rate, WORD32 sample_rate, WORD32 band_width,
|
||||
ia_psy_mod_long_config_struct *pstr_psy_config, WORD32 ccfl) {
|
||||
WORD32 sfb;
|
||||
FLOAT32 sfb_bark_val[MAX_NUM_GROUPED_SFB];
|
||||
|
||||
iusace_sfb_init(sample_rate, ONLY_LONG_SEQUENCE, pstr_psy_config->sfb_offset,
|
||||
&(pstr_psy_config->sfb_count), ccfl);
|
||||
|
||||
iusace_bark_values_init(pstr_psy_config->sfb_count, pstr_psy_config->sfb_offset,
|
||||
pstr_psy_config->sfb_offset[pstr_psy_config->sfb_count], sample_rate,
|
||||
sfb_bark_val);
|
||||
|
||||
iusace_thr_quiet_init(pstr_psy_config->sfb_count, pstr_psy_config->sfb_offset, sfb_bark_val,
|
||||
pstr_psy_config->sfb_thr_quiet);
|
||||
|
||||
iusace_spreading_init(
|
||||
pstr_psy_config->sfb_count, sfb_bark_val, pstr_psy_config->sfb_mask_low_fac,
|
||||
pstr_psy_config->sfb_mask_high_fac, pstr_psy_config->sfb_mask_low_fac_spr_ener,
|
||||
pstr_psy_config->sfb_mask_high_fac_spr_ener, bit_rate, ONLY_LONG_SEQUENCE);
|
||||
|
||||
pstr_psy_config->ratio = C_RATIO;
|
||||
pstr_psy_config->max_allowed_inc_fac = 2.0f;
|
||||
pstr_psy_config->min_remaining_thr_fac = 0.01f;
|
||||
|
||||
pstr_psy_config->clip_energy = (CLIP_ENERGY_VALUE_LONG * ccfl) / FRAME_LEN_LONG;
|
||||
pstr_psy_config->low_pass_line = (WORD32)((2 * band_width * ccfl) / sample_rate);
|
||||
|
||||
for (sfb = 0; sfb < pstr_psy_config->sfb_count; sfb++) {
|
||||
if (pstr_psy_config->sfb_offset[sfb] >= pstr_psy_config->low_pass_line) break;
|
||||
}
|
||||
pstr_psy_config->sfb_active = sfb;
|
||||
|
||||
iusace_min_snr_init(bit_rate, sample_rate,
|
||||
pstr_psy_config->sfb_offset[pstr_psy_config->sfb_count],
|
||||
pstr_psy_config->sfb_offset, sfb_bark_val, pstr_psy_config->sfb_active,
|
||||
pstr_psy_config->sfb_min_snr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_psy_short_config_init(WORD32 bit_rate, WORD32 sample_rate, WORD32 band_width,
|
||||
ia_psy_mod_short_config_struct *pstr_psy_config, WORD32 ccfl) {
|
||||
WORD32 sfb;
|
||||
WORD32 frame_len_short = (ccfl * FRAME_LEN_SHORT_128) / FRAME_LEN_LONG;
|
||||
FLOAT32 sfb_bark_val[MAX_NUM_GROUPED_SFB];
|
||||
|
||||
iusace_sfb_init(sample_rate, EIGHT_SHORT_SEQUENCE, pstr_psy_config->sfb_offset,
|
||||
&(pstr_psy_config->sfb_count), ccfl);
|
||||
|
||||
iusace_bark_values_init(pstr_psy_config->sfb_count, pstr_psy_config->sfb_offset,
|
||||
pstr_psy_config->sfb_offset[pstr_psy_config->sfb_count], sample_rate,
|
||||
sfb_bark_val);
|
||||
|
||||
iusace_thr_quiet_init(pstr_psy_config->sfb_count, pstr_psy_config->sfb_offset, sfb_bark_val,
|
||||
pstr_psy_config->sfb_thr_quiet);
|
||||
|
||||
iusace_spreading_init(
|
||||
pstr_psy_config->sfb_count, sfb_bark_val, pstr_psy_config->sfb_mask_low_fac,
|
||||
pstr_psy_config->sfb_mask_high_fac, pstr_psy_config->sfb_mask_low_fac_spr_ener,
|
||||
pstr_psy_config->sfb_mask_high_fac_spr_ener, bit_rate, EIGHT_SHORT_SEQUENCE);
|
||||
|
||||
pstr_psy_config->ratio = C_RATIO;
|
||||
pstr_psy_config->max_allowed_inc_fac = 2.0f;
|
||||
pstr_psy_config->min_remaining_thr_fac = 0.01f;
|
||||
|
||||
pstr_psy_config->clip_energy =
|
||||
(CLIP_ENERGY_VALUE_SHORT * frame_len_short) / FRAME_LEN_SHORT_128;
|
||||
pstr_psy_config->low_pass_line = (WORD32)((2 * band_width * frame_len_short) / sample_rate);
|
||||
|
||||
for (sfb = 0; sfb < pstr_psy_config->sfb_count; sfb++) {
|
||||
if (pstr_psy_config->sfb_offset[sfb] >= pstr_psy_config->low_pass_line) break;
|
||||
}
|
||||
pstr_psy_config->sfb_active = sfb;
|
||||
|
||||
iusace_min_snr_init(bit_rate, sample_rate,
|
||||
pstr_psy_config->sfb_offset[pstr_psy_config->sfb_count],
|
||||
pstr_psy_config->sfb_offset, sfb_bark_val, pstr_psy_config->sfb_active,
|
||||
pstr_psy_config->sfb_min_snr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_sfb_params_init(WORD32 sample_rate, WORD32 frame_len, WORD32 *ptr_sfb_width,
|
||||
WORD32 *num_sfb, WORD32 win_seq) {
|
||||
WORD32 i, j, k;
|
||||
ia_sfb_info_struct *ptr_sr_info = NULL;
|
||||
WORD32 sampling_rate_mapped = 0;
|
||||
|
||||
if (frame_len == 1024) {
|
||||
ptr_sr_info = &iusace_sfb_info_1024[0];
|
||||
} else {
|
||||
ptr_sr_info = &iusace_sfb_info_768[0];
|
||||
}
|
||||
|
||||
if ((sample_rate >= 0) && (sample_rate < 9391)) {
|
||||
sampling_rate_mapped = 8000;
|
||||
} else if ((sample_rate >= 9391) && (sample_rate < 11502)) {
|
||||
sampling_rate_mapped = 11025;
|
||||
} else if ((sample_rate >= 11502) && (sample_rate < 13856)) {
|
||||
sampling_rate_mapped = 12000;
|
||||
} else if ((sample_rate >= 13856) && (sample_rate < 18783)) {
|
||||
sampling_rate_mapped = 16000;
|
||||
} else if ((sample_rate >= 18783) && (sample_rate < 23004)) {
|
||||
sampling_rate_mapped = 22050;
|
||||
} else if ((sample_rate >= 23004) && (sample_rate < 27713)) {
|
||||
sampling_rate_mapped = 24000;
|
||||
} else if ((sample_rate >= 27713) && (sample_rate < 37566)) {
|
||||
sampling_rate_mapped = 32000;
|
||||
} else if ((sample_rate >= 37566) && (sample_rate < 46009)) {
|
||||
sampling_rate_mapped = 44100;
|
||||
} else if ((sample_rate >= 46009) && (sample_rate < 55426)) {
|
||||
sampling_rate_mapped = 48000;
|
||||
} else if ((sample_rate >= 55426) && (sample_rate < 75132)) {
|
||||
sampling_rate_mapped = 64000;
|
||||
} else if ((sample_rate >= 75132) && (sample_rate < 92017)) {
|
||||
sampling_rate_mapped = 88200;
|
||||
} else if (sample_rate >= 92017) {
|
||||
sampling_rate_mapped = 96000;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (ptr_sr_info->sample_rate != sampling_rate_mapped) {
|
||||
if (ptr_sr_info->sample_rate == -1) {
|
||||
return -1;
|
||||
}
|
||||
ptr_sr_info++;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < ptr_sr_info->num_sfb_long; i++) {
|
||||
k = ptr_sr_info->cb_offset_long[i];
|
||||
ptr_sr_info->sfb_width_long[i] = k - j;
|
||||
j = k;
|
||||
}
|
||||
j = 0;
|
||||
for (i = 0; i < ptr_sr_info->num_sfb_short; i++) {
|
||||
k = ptr_sr_info->cb_offset_short[i];
|
||||
ptr_sr_info->sfb_width_short[i] = k - j;
|
||||
j = k;
|
||||
}
|
||||
|
||||
switch (win_seq) {
|
||||
case EIGHT_SHORT_SEQUENCE:
|
||||
memcpy(ptr_sfb_width, ptr_sr_info->sfb_width_short, (MAX_SFB_SHORT) * sizeof(WORD32));
|
||||
*num_sfb = ptr_sr_info->num_sfb_short;
|
||||
break;
|
||||
case ONLY_LONG_SEQUENCE:
|
||||
case LONG_START_SEQUENCE:
|
||||
case STOP_START_SEQUENCE:
|
||||
case LONG_STOP_SEQUENCE:
|
||||
default:
|
||||
memcpy(ptr_sfb_width, ptr_sr_info->sfb_width_long, MAX_SFB_LONG * sizeof(WORD32));
|
||||
*num_sfb = ptr_sr_info->num_sfb_long;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
encoder/iusace_psy_utils.h
Normal file
45
encoder/iusace_psy_utils.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
typedef struct {
|
||||
WORD32 sample_rate;
|
||||
WORD32 num_sfb_long;
|
||||
WORD32 num_sfb_short;
|
||||
const WORD16 *cb_offset_long;
|
||||
const WORD16 *cb_offset_short;
|
||||
WORD32 sfb_width_long[MAX_SFB_LONG];
|
||||
WORD32 sfb_width_short[MAX_SFB_SHORT];
|
||||
|
||||
} ia_sfb_info_struct;
|
||||
|
||||
VOID iusace_psy_long_config_init(WORD32 bit_rate, WORD32 sample_rate, WORD32 band_width,
|
||||
ia_psy_mod_long_config_struct *pstr_psy_config, WORD32 ccfl);
|
||||
VOID iusace_psy_short_config_init(WORD32 bit_rate, WORD32 sample_rate, WORD32 band_width,
|
||||
ia_psy_mod_short_config_struct *pstr_psy_config, WORD32 ccfl);
|
||||
VOID iusace_calc_band_energy(const FLOAT64 *ptr_spec_coeffs, const WORD32 *band_offset,
|
||||
const WORD32 num_bands, FLOAT32 *ptr_band_energy, WORD32 sfb_count);
|
||||
VOID iusace_find_max_spreading(const WORD32 sfb_count, const FLOAT32 *ptr_mask_low_fac,
|
||||
const FLOAT32 *ptr_mask_high_fac, FLOAT32 *ptr_spreaded_enegry);
|
||||
VOID iusace_pre_echo_control(FLOAT32 *ptr_thr_nm1, WORD32 sfb_count, FLOAT32 max_allowed_inc_fac,
|
||||
FLOAT32 min_remaining_thr_fac, FLOAT32 *ptr_threshold);
|
||||
|
||||
IA_ERRORCODE iusace_sfb_params_init(WORD32 sample_rate, WORD32 frame_len, WORD32 *ptr_sfb_width,
|
||||
WORD32 *num_sfb, WORD32 win_seq);
|
||||
6863
encoder/iusace_rom.c
6863
encoder/iusace_rom.c
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
extern const UWORD32 iusace_sampl_freq_table[];
|
||||
extern const FLOAT64 iusace_twiddle_table_fft_32x32[514];
|
||||
extern const FLOAT64 iusace_twiddle_table_3pr[1155];
|
||||
extern const FLOAT64 iusace_twiddle_table_3pi[1155];
|
||||
|
|
@ -28,3 +27,104 @@ extern const FLOAT64 iusace_twiddle_cos_2048[1024];
|
|||
extern const FLOAT32 ia_fft_twiddle_table_float[514];
|
||||
extern const FLOAT32 ia_mixed_rad_twiddle_cos[16384];
|
||||
extern const FLOAT32 ia_mixed_rad_twiddle_sin[16384];
|
||||
|
||||
#define WIN_LEN_1024 1024
|
||||
#define WIN_LEN_768 768
|
||||
#define WIN_LEN_128 128
|
||||
#define WIN_LEN_256 256
|
||||
#define WIN_LEN_192 192
|
||||
#define WIN_LEN_96 96
|
||||
|
||||
extern const FLOAT32 iusace_iir_hipass_coeffs[BLK_SWITCH_FILT_LEN];
|
||||
extern const WORD32 iusace_suggested_grouping_table[MAX_SHORT_WINDOWS][MAXIMUM_NO_OF_GROUPS];
|
||||
extern const WORD32 iusace_synchronized_block_types[4][4];
|
||||
|
||||
extern const FLOAT32 iusace_gamma_table[ORDER + 1];
|
||||
extern const FLOAT32 iusace_chebyshev_polyn_grid[101];
|
||||
|
||||
extern const UWORD32 iusace_sampl_freq_idx_table[32];
|
||||
extern const WORD32 iusace_bandwidth_table[8][2];
|
||||
|
||||
extern const WORD32 iusace_huffman_code_table[121][2];
|
||||
|
||||
extern const FLOAT64 iusace_pre_post_twid_cos_2048[512];
|
||||
extern const FLOAT64 iusace_pre_post_twid_sin_2048[512];
|
||||
extern const FLOAT64 iexheaac_pre_post_twid_cos_1536[384];
|
||||
extern const FLOAT64 iexheaac_pre_post_twid_sin_1536[384];
|
||||
extern const FLOAT64 iusace_pre_post_twid_cos_256[64];
|
||||
extern const FLOAT64 iusace_pre_post_twid_sin_256[64];
|
||||
extern const FLOAT64 iexheaac_pre_post_twid_cos_192[48];
|
||||
extern const FLOAT64 iexheaac_pre_post_twid_sin_192[48];
|
||||
extern const FLOAT64 iusace_kbd_win1024[1024];
|
||||
extern const FLOAT64 iusace_kbd_win256[256];
|
||||
extern const FLOAT64 iusace_kbd_win128[128];
|
||||
|
||||
extern const FLOAT64 iexheaac_kbd_win_768[768];
|
||||
extern const FLOAT64 iexheaac_kbd_win_192[192];
|
||||
extern const FLOAT64 iexheaac_kbd_win_96[96];
|
||||
|
||||
extern const FLOAT64 iusace_sine_win_1024[1024];
|
||||
extern const FLOAT64 iexheaac_sine_win_768[768];
|
||||
extern const FLOAT64 iusace_sine_win_256[256];
|
||||
extern const FLOAT64 iusace_sine_win_128[128];
|
||||
extern const FLOAT64 iexheaac_sine_win_192[192];
|
||||
extern const FLOAT64 iexheaac_sine_win_96[96];
|
||||
|
||||
extern const UWORD16 iusace_ari_cf_r[3][4];
|
||||
extern const UWORD16 iusace_ari_lookup_m[742];
|
||||
extern const UWORD32 iusace_ari_hash_m[742];
|
||||
extern const UWORD8 iusace_ari_hash_m_lsb[742];
|
||||
extern const UWORD16 iusace_ari_cf_m[64][17];
|
||||
|
||||
extern const FLOAT32 iusace_pre_post_twid_cos_sin_512[4][512];
|
||||
extern const FLOAT32 iusace_pre_post_twid_cos_sin_256[4][256];
|
||||
extern const FLOAT32 iusace_pre_post_twid_cos_sin_128[4][128];
|
||||
extern const FLOAT32 iusace_pre_post_twid_cos_sin_64[4][64];
|
||||
extern const FLOAT32 iusace_pre_post_twid_cos_sin_32[4][32];
|
||||
|
||||
extern const FLOAT64 iusace_pow_table[9000];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_long_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_long_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_long_sin_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_long_kbd_sin[];
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_longshort_curr[2][2];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_start_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_start_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_start_sin_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_start_kbd_sin[];
|
||||
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_start_curr[2][2];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_sin_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_kbd_sin[];
|
||||
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_stop_cur[2][2];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stopstart_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stopstart_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stopstart_sin_kbd[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stopstart_kbd_sin[];
|
||||
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_stopstart_cur[2][2];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_l_s_start_left_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_l_s_start_left_kbd[];
|
||||
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_stopstart_left_sin[];
|
||||
extern const FLOAT64 iusace_mdst_fcoeff_stop_stopstart_left_kbd[];
|
||||
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_l_s_start_left_prev[2];
|
||||
|
||||
extern const FLOAT64 *const iusace_mdst_fcoeff_stop_stopstart_left_prev[2];
|
||||
|
||||
extern const FLOAT32 ia_rad_3_fft_twiddle_re[1155];
|
||||
|
||||
extern const FLOAT32 ia_rad_3_fft_twiddle_im[1155];
|
||||
|
||||
extern const FLOAT32 ia_fft_mix_rad_twid_tbl_336[564];
|
||||
|
||||
extern const FLOAT32 ia_fft_mix_rad_twid_tbl_168[276];
|
||||
|
|
|
|||
152
encoder/iusace_signal_classifier.h
Normal file
152
encoder/iusace_signal_classifier.h
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define FD_MODE 2
|
||||
#define TD_MODE 0
|
||||
#define MIN_POW -200
|
||||
#define INDEXOFLOWFREQUENCY 160
|
||||
|
||||
#define NFRAMEAHEAD 1
|
||||
#define AVE_TONAL_LENGTH 100
|
||||
#define AVE_TONAL_LENGTH_SHORT 10
|
||||
#define SPECTRAL_TILT_LENGTH 80
|
||||
#define SPECTRAL_TILT_LENGTH_SHORT 20
|
||||
#define SMOOTHING_LENGTH 100
|
||||
|
||||
#define NO_BORDER 0
|
||||
#define BORDER_MUSIC_SPEECH 1
|
||||
#define BORDER_MUSIC_SPEECH_DEFINITE 2
|
||||
#define BORDER_SPEECH_MUSIC 3
|
||||
#define BORDER_SPEECH_MUSIC_DEFINITE 4
|
||||
|
||||
#define TBD 0
|
||||
#define SPEECH_DEFINITE 1
|
||||
#define SPEECH 2
|
||||
#define MUSIC_DEFINITE 3
|
||||
#define MUSIC 4
|
||||
#define LOG_1024_BASE_10 3.01029995664f
|
||||
#define LOG_768_BASE_10 (2.88536122003f)
|
||||
|
||||
typedef struct {
|
||||
WORD32 smoothing_result_buf[100]; /**<buffer of smoothed mode decisions */
|
||||
WORD32 init_result_behind[100]; /**<buffer of past mode decisions */
|
||||
WORD32 init_result_ahead[NFRAMEAHEAD]; /**<buffer of ahead mode decisions */
|
||||
WORD32 flag_border_buf_behind[10]; /**<buffer of past border flags */
|
||||
WORD32 flag_border_buf_ahead[NFRAMEAHEAD]; /**<buffer of ahead border flags */
|
||||
FLOAT32 frame_energy_buf_behind[10]; /**<buffer of past energies */
|
||||
FLOAT32 frame_energy_buf_ahead[NFRAMEAHEAD]; /**<buffer of ahead energies */
|
||||
} ia_classification_buf_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 coding_mode; /**< coding mode of the frame */
|
||||
WORD32 pre_mode; /**< coding mode of the previous frame */
|
||||
|
||||
FLOAT32 input_samples[3840 * 2];
|
||||
WORD32 n_buffer_samples;
|
||||
WORD32 class_buf[10];
|
||||
WORD32 n_buf_class;
|
||||
WORD32 n_class_frames;
|
||||
|
||||
WORD32 is_switch_mode;
|
||||
|
||||
WORD32 framecnt;
|
||||
WORD32 init_flag;
|
||||
WORD32 framecnt_xm;
|
||||
|
||||
ia_classification_buf_struct buffers;
|
||||
FLOAT32 spec_tilt_buf[100]; /* buffer of spectral tilt */
|
||||
WORD32 n_tonal[100]; /* buffer of tonal */
|
||||
WORD32 n_tonal_low_frequency[100];
|
||||
FLOAT32 msd_spec_tilt_buf[5];
|
||||
FLOAT32 msd_spec_tilt_short_buf[5]; /* buffer of the MSD of spectral tilt */
|
||||
FLOAT32 ave_n_tonal_short_buf[5];
|
||||
FLOAT32 ave_n_tonal_buf[5]; /* buffer of the AVE of tonal */
|
||||
} ia_classification_struct;
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 *time_signal; /**<input signals */
|
||||
WORD32 framecnt_xm; /**<frame counter
|
||||
*/
|
||||
WORD32 *n_tonal; /**<buffer of the numbers of tonal
|
||||
*/
|
||||
WORD32 *n_tonal_low_frequency; /**<buffer of the numbers of tonal in the low frequency domain
|
||||
*/
|
||||
FLOAT32 *n_tonal_low_frequency_ratio; /**<the ratio of distribution of the numbers of tonal in
|
||||
the low frequency domain*/
|
||||
FLOAT32 *ave_n_tonal; /**<long - term AVE of tonal
|
||||
*/
|
||||
FLOAT32 *ave_n_tonal_short; /**<short - term AVE of tonal */
|
||||
} ia_tonal_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 framecnt; /**< frame counter*/
|
||||
WORD32 *framecnt_xm; /**< frame counter*/
|
||||
WORD32 *flag_border; /**< flag of current border*/
|
||||
FLOAT32 ave_n_tonal_short; /**< short - term AVE of tonal*/
|
||||
FLOAT32 ave_n_tonal; /**< long - term AVE of tonal*/
|
||||
FLOAT32 *ave_n_tonal_short_buf; /**< buffer of short - term AVE of tonal*/
|
||||
FLOAT32 *ave_n_tonal_buf; /**< buffer long - term AVE of tonal*/
|
||||
FLOAT32 msd_spec_tilt; /**< long - term MSD of spectral tilt*/
|
||||
FLOAT32 msd_spec_tilt_short; /**< short - term MSD of spectral tilt*/
|
||||
FLOAT32 *msd_spec_tilt_buf; /**< buffer of long - term MSD of spectral tilt*/
|
||||
FLOAT32 *msd_spec_tilt_short_buf; /**< buffer of short - term MSD of spectral tilt*/
|
||||
FLOAT32 n_tonal_low_frequency_ratio; /**< the ratio of distribution of the numbers of tonal in
|
||||
the low frequency domain*/
|
||||
FLOAT32 frame_energy; /**< the energy of current frame*/
|
||||
} ia_mode_params_struct;
|
||||
|
||||
typedef struct {
|
||||
WORD32 init_mode_decision_result; /**< initial mode decision */
|
||||
WORD32 *init_result_behind; /**< buffer of past mode decisions */
|
||||
WORD32 *init_result_ahead; /**< buffer of ahead mode decisions */
|
||||
WORD32 flag_border; /**< current flag of border */
|
||||
WORD32 *flag_border_buf_behind; /**< buffer of past flags of border */
|
||||
WORD32 *flag_border_buf_ahead; /**< buffer of ahead flags of border */
|
||||
FLOAT32 frame_energy; /**< the energy of current frame */
|
||||
FLOAT32 *frame_energy_buf_behind; /**< buffer of past frame energies */
|
||||
FLOAT32 *frame_energy_buf_ahead; /**< buffer of ahead frame energies */
|
||||
WORD32 *smoothing_result_buf; /**< buffer of smoothed mode decision */
|
||||
WORD32 flag_speech_definite;
|
||||
WORD32 count_small_energy;
|
||||
WORD32 flag_music_definite;
|
||||
WORD32 num_smoothing;
|
||||
} ia_smooth_params_struct; /**< final mode decision result */
|
||||
|
||||
typedef struct {
|
||||
FLOAT32 *time_signal; /**<input signals */
|
||||
WORD32 framecnt_xm; /**<frame counter */
|
||||
FLOAT32 *spec_tilt_buf; /**<buffer of spectral tilt */
|
||||
FLOAT32 *msd_spec_tilt; /**<long - term MSD of spectral tilt */
|
||||
FLOAT32 *msd_spec_tilt_short; /**<short - term MSD of spectral tilt*/
|
||||
FLOAT32 frame_energy;
|
||||
} ia_spec_tilt_params_struct;
|
||||
|
||||
typedef struct {
|
||||
const FLOAT64 twiddle_table_fft_float[514];
|
||||
const FLOAT64 hanning_window_1024[FRAME_LEN_LONG];
|
||||
const FLOAT64 absolute_threshold_1024[FRAME_LEN_LONG / 2];
|
||||
const FLOAT64 hanning_window_768[LEN_SUPERFRAME_768];
|
||||
const FLOAT64 absolute_threshold_768[LEN_SUPERFRAME_768 / 2];
|
||||
} ia_signal_classifier_tables;
|
||||
|
||||
extern const ia_signal_classifier_tables iusace_classify_arrays;
|
||||
|
||||
VOID iusace_init_classification(ia_classification_struct *pstr_sig_class);
|
||||
844
encoder/iusace_tcx_enc.c
Normal file
844
encoder/iusace_tcx_enc.c
Normal file
|
|
@ -0,0 +1,844 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_fft.h"
|
||||
#include "iusace_tcx_mdct.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_lpd_rom.h"
|
||||
#include "iusace_lpd.h"
|
||||
#include "iusace_avq_enc.h"
|
||||
#include "ixheaace_common_utils.h"
|
||||
|
||||
const UWORD32 iusace_pow10_gain_div28[128] = {
|
||||
1024, 1112, 1207, 1311, 1423, 1545, 1677, 1821, 1977,
|
||||
2146, 2330, 2530, 2747, 2983, 3238, 3516, 3817, 4144,
|
||||
4499, 4885, 5304, 5758, 6252, 6788, 7370, 8001, 8687,
|
||||
9432, 10240, 11118, 12071, 13105, 14228, 15448, 16772, 18210,
|
||||
19770, 21465, 23305, 25302, 27471, 29825, 32382, 35157, 38171,
|
||||
41442, 44994, 48851, 53038, 57584, 62519, 67878, 73696, 80012,
|
||||
86870, 94316, 102400, 111177, 120706, 131052, 142284, 154480, 167720,
|
||||
182096, 197703, 214649, 233047, 253021, 274708, 298254, 323817, 351572,
|
||||
381706, 414422, 449943, 488508, 530378, 575838, 625193, 678779, 736958,
|
||||
800124, 868703, 943161, 1024000, 1111768, 1207059, 1310517, 1422843, 1544797,
|
||||
1677203, 1820958, 1977034, 2146488, 2330466, 2530213, 2747080, 2982536, 3238172,
|
||||
3515720, 3817056, 4144220, 4499426, 4885077, 5303782, 5758375, 6251932, 6787792,
|
||||
7369581, 8001236, 8687031, 9431606, 10240000, 11117682, 12070591, 13105175, 14228434,
|
||||
15447969, 16772032, 18209581, 19770345, 21464883, 23304662, 25302131, 27470805, 29825358,
|
||||
32381723, 35157197};
|
||||
|
||||
static const FLOAT64 iusace_lpc_pre_twid_cos[ORDER + 1] = {1.0,
|
||||
0.99969881867944277,
|
||||
0.99879545613814691,
|
||||
0.99729045666498317,
|
||||
0.99518472640441780,
|
||||
0.99247953486470630,
|
||||
0.98917650991010153,
|
||||
0.98527764316379052,
|
||||
0.98078527933727178,
|
||||
0.97570212991605565,
|
||||
0.97003125425052761,
|
||||
0.96377606826277584,
|
||||
0.95694033551585822,
|
||||
0.94952817722361749,
|
||||
0.94154406823678738,
|
||||
0.93299279849944938,
|
||||
0.92387952832938047};
|
||||
|
||||
static const FLOAT64 iusace_lpc_pre_twid_sin[ORDER + 1] = {0,
|
||||
0.024541229205697054,
|
||||
0.049067675691753569,
|
||||
0.073564563785488826,
|
||||
0.098017143048367339,
|
||||
0.12241067304257494,
|
||||
0.14673047482398086,
|
||||
0.17096188429473480,
|
||||
0.19509032737506427,
|
||||
0.21910124070226658,
|
||||
0.24298017568754085,
|
||||
0.26671274855909161,
|
||||
0.29028467796767482,
|
||||
0.31368175059826858,
|
||||
0.33688984485751389,
|
||||
0.35989503740419343,
|
||||
0.38268344246110436};
|
||||
|
||||
static VOID iusace_lpc_mdct(FLOAT32 *ptr_lpc_coeffs, FLOAT32 *mdct_gains, WORD32 length,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
FLOAT32 *in_out = pstr_scratch->p_in_out_tcx;
|
||||
WORD32 i;
|
||||
|
||||
for (i = 0; i < ORDER + 1; i++) {
|
||||
in_out[2 * i] = (FLOAT32)(ptr_lpc_coeffs[i] * iusace_lpc_pre_twid_cos[i]);
|
||||
in_out[2 * i + 1] = (FLOAT32)(-ptr_lpc_coeffs[i] * iusace_lpc_pre_twid_sin[i]);
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
in_out[2 * i] = 0.f;
|
||||
in_out[2 * i + 1] = 0.f;
|
||||
}
|
||||
|
||||
iusace_complex_fft(in_out, length, pstr_scratch);
|
||||
|
||||
for (i = 0; i < length >> 1; i++) {
|
||||
mdct_gains[i] = (FLOAT32)(1.0f / sqrt(in_out[2 * i] * in_out[2 * i] +
|
||||
in_out[2 * i + 1] * in_out[2 * i + 1]));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UWORD32 iusace_rounded_sqrt(UWORD32 pos_num) {
|
||||
UWORD32 num = pos_num;
|
||||
UWORD32 value = 0;
|
||||
UWORD32 bit_set = 1 << 30;
|
||||
|
||||
while (bit_set > num) {
|
||||
bit_set >>= 2;
|
||||
}
|
||||
while (bit_set) {
|
||||
if (num >= value + bit_set) {
|
||||
num -= value + bit_set;
|
||||
value += bit_set << 1;
|
||||
}
|
||||
value >>= 1;
|
||||
bit_set >>= 2;
|
||||
}
|
||||
num = value + 1;
|
||||
if (num * num - pos_num < pos_num - value * value) {
|
||||
return num;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static VOID iusace_noise_shaping(FLOAT32 *rr, WORD32 lg, FLOAT32 *gain1, FLOAT32 *gain2) {
|
||||
WORD32 i, k;
|
||||
FLOAT32 r, r_prev, g1, g2, a = 0, b = 0;
|
||||
|
||||
k = lg / FDNS_RESOLUTION;
|
||||
|
||||
r_prev = 0;
|
||||
for (i = 0; i < lg; i++) {
|
||||
if ((i % k) == 0) {
|
||||
g1 = gain1[i / k];
|
||||
g2 = gain2[i / k];
|
||||
|
||||
a = 2.0f * g1 * g2 / (g1 + g2);
|
||||
b = (g2 - g1) / (g1 + g2);
|
||||
}
|
||||
|
||||
r = a * rr[i] + b * r_prev;
|
||||
|
||||
rr[i] = r;
|
||||
r_prev = r;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_pre_shaping(FLOAT32 *rr, WORD32 lg, FLOAT32 *gain1, FLOAT32 *gain2) {
|
||||
WORD32 i, k;
|
||||
FLOAT32 r, r_prev, g1, g2, a = 0, b = 0;
|
||||
|
||||
k = lg / FDNS_RESOLUTION;
|
||||
|
||||
r_prev = 0;
|
||||
for (i = 0; i < lg; i++) {
|
||||
if ((i % k) == 0) {
|
||||
g1 = gain1[i / k];
|
||||
g2 = gain2[i / k];
|
||||
|
||||
a = (g1 + g2) / (2.0f * g1 * g2);
|
||||
b = (g1 - g2) / (2.0f * g1 * g2);
|
||||
}
|
||||
|
||||
r = a * rr[i] + b * r_prev;
|
||||
|
||||
r_prev = rr[i];
|
||||
rr[i] = r;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_adapt_lo_freq_emph(FLOAT32 *signal, WORD32 length) {
|
||||
WORD32 i, j, i_max;
|
||||
FLOAT32 max_energy, factor, temp;
|
||||
|
||||
i_max = length >> 2;
|
||||
|
||||
max_energy = 0.01f;
|
||||
for (i = 0; i < i_max; i += 8) {
|
||||
temp = 0.01f;
|
||||
for (j = i; j < i + 8; j++) {
|
||||
temp += signal[j] * signal[j];
|
||||
}
|
||||
if (temp > max_energy) {
|
||||
max_energy = temp;
|
||||
}
|
||||
}
|
||||
|
||||
factor = 10.0f;
|
||||
for (i = 0; i < i_max; i += 8) {
|
||||
temp = 0.01f;
|
||||
for (j = i; j < i + 8; j++) {
|
||||
temp += signal[j] * signal[j];
|
||||
}
|
||||
temp = (FLOAT32)sqrt(sqrt(max_energy / temp));
|
||||
if (temp < factor) {
|
||||
factor = temp;
|
||||
}
|
||||
for (j = i; j < i + 8; j++) {
|
||||
signal[j] *= factor;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_adapt_lo_freq_deemph(FLOAT32 *signal, WORD32 length, FLOAT32 *gains) {
|
||||
WORD32 i, j, i_max;
|
||||
FLOAT32 max_energy, factor, energy, rm;
|
||||
|
||||
i_max = length >> 2;
|
||||
|
||||
max_energy = 0.01f;
|
||||
for (i = 0; i < i_max; i += 8) {
|
||||
energy = 0.01f;
|
||||
for (j = i; j < i + 8; j++) {
|
||||
energy += signal[j] * signal[j];
|
||||
}
|
||||
if (energy > max_energy) {
|
||||
max_energy = energy;
|
||||
}
|
||||
}
|
||||
|
||||
factor = 0.1f;
|
||||
for (i = 0; i < i_max; i += 8) {
|
||||
energy = 0.01f;
|
||||
for (j = i; j < i + 8; j++) {
|
||||
energy += signal[j] * signal[j];
|
||||
}
|
||||
|
||||
rm = (FLOAT32)sqrt(energy / max_energy);
|
||||
if (rm > factor) {
|
||||
factor = rm;
|
||||
}
|
||||
for (j = i; j < i + 8; j++) {
|
||||
signal[j] *= factor;
|
||||
}
|
||||
gains[i / 8] = factor;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tcx_fac_encode(ia_usac_data_struct *usac_data, FLOAT32 *lpc_coeffs,
|
||||
FLOAT32 *lpc_coeffs_quant, FLOAT32 *speech, WORD32 frame_len,
|
||||
WORD32 num_bits_per_supfrm, ia_usac_lpd_state_struct *lpd_state,
|
||||
WORD32 *params, WORD32 *n_param, WORD32 ch_idx, WORD32 k_idx) {
|
||||
ia_usac_td_encoder_struct *st = usac_data->td_encoder[ch_idx];
|
||||
iusace_scratch_mem *pstr_scratch = &usac_data->str_scratch;
|
||||
FLOAT32 *weighted_sig = &pstr_scratch->p_wsig_buf[k_idx * st->len_subfrm];
|
||||
FLOAT32 *wsynth = pstr_scratch->p_wsyn_tcx_buf;
|
||||
FLOAT32 *synth = pstr_scratch->p_synth_tcx_buf;
|
||||
WORD32 i, k, n, mode, i_subfr, lg, lext, index, target_bits;
|
||||
FLOAT32 tmp, gain, fac_ns, energy, gain_tcx, nsfill_en_thres;
|
||||
FLOAT32 *ptr_lp_flt_coeffs, lp_flt_coeffs[ORDER + 1];
|
||||
const FLOAT32 *sine_window_prev, *sine_window;
|
||||
FLOAT32 mem_tcx_q;
|
||||
FLOAT32 *xn;
|
||||
FLOAT32 *xn1 = pstr_scratch->p_xn1_tcx;
|
||||
FLOAT32 *xn_buf = pstr_scratch->p_xn_buf_tcx;
|
||||
FLOAT32 *x = pstr_scratch->p_x_tcx;
|
||||
FLOAT32 *x_tmp = pstr_scratch->p_x_tmp_tcx;
|
||||
FLOAT32 *en = pstr_scratch->p_en_tcx;
|
||||
FLOAT32 sq_gain;
|
||||
FLOAT32 gain_prev, gain_next;
|
||||
FLOAT32 *alfd_gains = pstr_scratch->p_alfd_gains_tcx;
|
||||
FLOAT32 *sq_enc = pstr_scratch->p_sq_enc_tcx;
|
||||
WORD32 *sq_quant = pstr_scratch->p_sq_quant_tcx;
|
||||
FLOAT32 sq_err_energy;
|
||||
WORD32 max_k;
|
||||
FLOAT32 *gain1 = pstr_scratch->p_gain1_tcx;
|
||||
FLOAT32 *gain2 = pstr_scratch->p_gain2_tcx;
|
||||
FLOAT32 *facelp = pstr_scratch->p_facelp_tcx;
|
||||
FLOAT32 *xn2 = pstr_scratch->p_xn2_tcx;
|
||||
FLOAT32 *fac_window = pstr_scratch->p_fac_window_tcx;
|
||||
FLOAT32 *x1 = pstr_scratch->p_x1_tcx;
|
||||
FLOAT32 *x2 = pstr_scratch->p_x2_tcx;
|
||||
WORD32 *y = pstr_scratch->p_y_tcx;
|
||||
|
||||
WORD32 TTT;
|
||||
FLOAT32 corr = 0;
|
||||
WORD32 len_subfrm = st->len_subfrm;
|
||||
WORD32 fac_length = len_subfrm >> 1;
|
||||
WORD32 fac_len_prev, fac_len;
|
||||
|
||||
if (frame_len == 4 * st->len_subfrm) {
|
||||
if (st->last_was_short) {
|
||||
fac_len_prev = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len_prev = st->len_subfrm / 2;
|
||||
}
|
||||
if (st->next_is_short) {
|
||||
fac_len = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len = st->len_subfrm / 2;
|
||||
}
|
||||
} else if (frame_len == 2 * st->len_subfrm) {
|
||||
if (k_idx == 0 && st->last_was_short) {
|
||||
fac_len_prev = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len_prev = st->len_subfrm / 2;
|
||||
}
|
||||
if (k_idx == 2 && st->next_is_short) {
|
||||
fac_len = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len = st->len_subfrm / 2;
|
||||
}
|
||||
} else {
|
||||
if (k_idx == 0 && st->last_was_short) {
|
||||
fac_len_prev = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len_prev = st->len_subfrm / 2;
|
||||
}
|
||||
if (k_idx == 3 && st->next_is_short) {
|
||||
fac_len = (st->len_frame) / 16;
|
||||
} else {
|
||||
fac_len = st->len_subfrm / 2;
|
||||
}
|
||||
}
|
||||
|
||||
memset(xn_buf, 0, (128 + frame_len + 128) * sizeof(FLOAT32));
|
||||
|
||||
mode = frame_len / len_subfrm;
|
||||
|
||||
if (mode > 2) {
|
||||
mode = 3;
|
||||
}
|
||||
|
||||
if (lpd_state->mode == 0) {
|
||||
params += fac_len_prev;
|
||||
}
|
||||
switch (fac_len_prev) {
|
||||
case 64:
|
||||
sine_window_prev = iusace_sin_window_128;
|
||||
break;
|
||||
default:
|
||||
sine_window_prev = iusace_sin_window_256;
|
||||
break;
|
||||
}
|
||||
switch (fac_len) {
|
||||
case 64:
|
||||
sine_window = iusace_sin_window_128;
|
||||
break;
|
||||
default:
|
||||
sine_window = iusace_sin_window_256;
|
||||
break;
|
||||
}
|
||||
|
||||
lg = frame_len;
|
||||
lext = fac_length;
|
||||
xn = xn_buf + fac_length;
|
||||
|
||||
*n_param = lg;
|
||||
|
||||
target_bits = num_bits_per_supfrm - 10;
|
||||
|
||||
for (i = 0; i < fac_length; i++) {
|
||||
xn_buf[i] = lpd_state->tcx_mem[i + 128 - fac_length];
|
||||
}
|
||||
|
||||
memcpy(xn, speech, (frame_len + fac_length) * sizeof(FLOAT32));
|
||||
|
||||
tmp = xn[-1];
|
||||
|
||||
iusace_apply_deemph(xn, TILT_FAC, frame_len, &tmp);
|
||||
|
||||
memcpy(lpd_state->tcx_mem, &xn[frame_len - 128], 128 * sizeof(FLOAT32));
|
||||
|
||||
memcpy(&xn[frame_len], &speech[frame_len], lext * sizeof(FLOAT32));
|
||||
iusace_apply_deemph(&xn[frame_len], TILT_FAC, lext, &tmp);
|
||||
|
||||
for (i = 0; i < ORDER + fac_len_prev; i++) {
|
||||
xn1[i] = xn_buf[fac_length - ORDER + i];
|
||||
}
|
||||
for (i = 0; i < ORDER + fac_len; i++) {
|
||||
xn2[i] = xn_buf[frame_len - ORDER + i];
|
||||
}
|
||||
|
||||
if (lpd_state->mode >= -1) {
|
||||
for (i = 0; i < fac_length - fac_len_prev; i++) {
|
||||
xn_buf[i] = 0.0f;
|
||||
}
|
||||
for (i = fac_length - fac_len_prev; i < (fac_length + fac_len_prev); i++) {
|
||||
xn_buf[i] *= sine_window_prev[i - fac_length + fac_len_prev];
|
||||
}
|
||||
for (i = 0; i < (2 * fac_len); i++) {
|
||||
xn_buf[frame_len + fac_length - fac_len + i] *= sine_window[(2 * fac_len) - 1 - i];
|
||||
}
|
||||
for (i = 0; i < fac_length - fac_len; i++) {
|
||||
xn_buf[frame_len + fac_length + fac_len + i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
iusace_tcx_mdct_main(xn_buf, x, (2 * fac_length), frame_len - (2 * fac_length),
|
||||
(2 * fac_length), pstr_scratch);
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (ORDER + 1), lp_flt_coeffs);
|
||||
iusace_lpc_mdct(lp_flt_coeffs, gain1, ((FDNS_RESOLUTION * len_subfrm) / LEN_FRAME) << 1,
|
||||
pstr_scratch);
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (2 * (ORDER + 1)), lp_flt_coeffs);
|
||||
iusace_lpc_mdct(lp_flt_coeffs, gain2, ((FDNS_RESOLUTION * len_subfrm) / LEN_FRAME) << 1,
|
||||
pstr_scratch);
|
||||
|
||||
iusace_pre_shaping(x, lg, gain1, gain2);
|
||||
|
||||
for (i = 0; i < lg; i++) {
|
||||
x_tmp[i] = x[i];
|
||||
}
|
||||
|
||||
iusace_adapt_lo_freq_emph(x, lg);
|
||||
|
||||
sq_gain = iusace_calc_sq_gain(x, target_bits, lg, pstr_scratch->p_sq_gain_en);
|
||||
|
||||
for (i = 0; i < lg; i++) {
|
||||
sq_enc[i] = x[i] / sq_gain;
|
||||
|
||||
if (sq_enc[i] > 0.f)
|
||||
sq_quant[i] = ((WORD32)(0.5f + sq_enc[i]));
|
||||
else
|
||||
sq_quant[i] = ((WORD32)(-0.5f + sq_enc[i]));
|
||||
}
|
||||
|
||||
for (i = 0; i < lg; i++) {
|
||||
params[i + 2] = sq_quant[i];
|
||||
x[i] = (FLOAT32)sq_quant[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < lg; i++) {
|
||||
en[i] = x[i] * x[i];
|
||||
}
|
||||
if (mode == 3) {
|
||||
tmp = 0.9441f;
|
||||
} else if (mode == 2) {
|
||||
tmp = 0.8913f;
|
||||
} else {
|
||||
tmp = 0.7943f;
|
||||
}
|
||||
energy = 0.0f;
|
||||
for (i = 0; i < lg; i++) {
|
||||
if (en[i] > energy) {
|
||||
energy = en[i];
|
||||
}
|
||||
en[i] = energy;
|
||||
energy *= tmp;
|
||||
}
|
||||
energy = 0.0f;
|
||||
for (i = lg - 1; i >= 0; i--) {
|
||||
if (en[i] > energy) {
|
||||
energy = en[i];
|
||||
}
|
||||
en[i] = energy;
|
||||
energy *= tmp;
|
||||
}
|
||||
|
||||
nsfill_en_thres = 0.707f;
|
||||
|
||||
tmp = 0.0625f;
|
||||
k = 1;
|
||||
for (i = 0; i < lg; i++) {
|
||||
if (en[i] <= nsfill_en_thres) {
|
||||
tmp += sq_enc[i] * sq_enc[i];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
iusace_adapt_lo_freq_deemph(x, lg, alfd_gains);
|
||||
|
||||
energy = 1e-6f;
|
||||
for (i = 0; i < lg; i++) {
|
||||
corr += x_tmp[i] * x[i];
|
||||
energy += x[i] * x[i];
|
||||
}
|
||||
gain_tcx = (corr / energy);
|
||||
|
||||
if (gain_tcx == 0.0f) {
|
||||
gain_tcx = sq_gain;
|
||||
}
|
||||
|
||||
energy = 0.0001f;
|
||||
for (i = 0; i < lg; i++) {
|
||||
tmp = x_tmp[i] - gain_tcx * x[i];
|
||||
energy += tmp * tmp;
|
||||
}
|
||||
|
||||
tmp = (FLOAT32)sqrt((energy * (2.0f / (FLOAT32)lg)) / (FLOAT32)lg);
|
||||
|
||||
for (i = 0; i < frame_len; i++) {
|
||||
wsynth[i] = weighted_sig[i] + tmp;
|
||||
}
|
||||
|
||||
energy = 0.01f;
|
||||
for (i = 0; i < lg; i++) {
|
||||
energy += x[i] * x[i];
|
||||
}
|
||||
|
||||
tmp = (FLOAT32)(2.0f * sqrt(energy) / (FLOAT32)lg);
|
||||
gain = gain_tcx * tmp;
|
||||
|
||||
index = (WORD32)floor(0.5f + (28.0f * (FLOAT32)log10(gain)));
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (index > 127) {
|
||||
index = 127;
|
||||
}
|
||||
params[1] = index;
|
||||
|
||||
gain_tcx = (FLOAT32)pow(10.0f, ((FLOAT32)index) / 28.0f) / tmp;
|
||||
st->gain_tcx = gain_tcx;
|
||||
|
||||
sq_err_energy = 0.f;
|
||||
n = 0;
|
||||
for (k = lg / 2; k < lg;) {
|
||||
tmp = 0.f;
|
||||
|
||||
max_k = MIN(lg, k + 8);
|
||||
for (i = k; i < max_k; i++) {
|
||||
tmp += (FLOAT32)sq_quant[i] * sq_quant[i];
|
||||
}
|
||||
if (tmp == 0.f) {
|
||||
tmp = 0.f;
|
||||
for (i = k; i < max_k; i++) {
|
||||
tmp += sq_enc[i] * sq_enc[i];
|
||||
}
|
||||
|
||||
sq_err_energy += (FLOAT32)log10((tmp / (FLOAT64)8) + 0.000000001);
|
||||
n += 1;
|
||||
}
|
||||
k = max_k;
|
||||
}
|
||||
if (n > 0) {
|
||||
fac_ns = (FLOAT32)pow(10., sq_err_energy / (FLOAT64)(2 * n));
|
||||
} else {
|
||||
fac_ns = 0.f;
|
||||
}
|
||||
|
||||
tmp = 8.0f - (16.0f * fac_ns);
|
||||
|
||||
index = (WORD32)floor(tmp + 0.5);
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (index > 7) {
|
||||
index = 7;
|
||||
}
|
||||
|
||||
params[0] = index;
|
||||
|
||||
iusace_noise_shaping(x, lg, gain1, gain2);
|
||||
|
||||
iusace_tcx_imdct(x, xn_buf, (2 * fac_length), frame_len - (2 * fac_length), (2 * fac_length),
|
||||
pstr_scratch);
|
||||
for (i = 0; i < frame_len + (2 * fac_length); i++) {
|
||||
xn_buf[i] = xn_buf[i] * (2.0f / lg);
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
fac_window[i] = sine_window_prev[i] * sine_window_prev[(2 * fac_len_prev) - 1 - i];
|
||||
fac_window[fac_len_prev + i] =
|
||||
1.0f - (sine_window_prev[fac_len_prev + i] * sine_window_prev[fac_len_prev + i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
xn1[ORDER + i] -= sq_gain * xn_buf[fac_length + i] * sine_window_prev[fac_len_prev + i];
|
||||
}
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
xn2[ORDER + i] -= sq_gain * xn_buf[i + frame_len] * sine_window[(2 * fac_len) - 1 - i];
|
||||
}
|
||||
|
||||
for (i = 0; i < ORDER; i++) {
|
||||
xn1[i] -= lpd_state->tcx_quant[1 + 128 - ORDER + i];
|
||||
xn2[i] -= sq_gain * xn_buf[frame_len - ORDER + i];
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
facelp[i] = lpd_state->tcx_quant[1 + 128 + i] * fac_window[fac_len_prev + i] +
|
||||
lpd_state->tcx_quant[1 + 128 - 1 - i] * fac_window[fac_len_prev - 1 - i];
|
||||
}
|
||||
|
||||
energy = 0.0f;
|
||||
for (i = 0; i < fac_len_prev; i++) energy += xn1[ORDER + i] * xn1[ORDER + i];
|
||||
energy *= 2.0f;
|
||||
tmp = 0.0f;
|
||||
for (i = 0; i < fac_len_prev; i++) tmp += facelp[i] * facelp[i];
|
||||
if (tmp > energy)
|
||||
gain = (FLOAT32)sqrt(energy / tmp);
|
||||
else
|
||||
gain = 1.0f;
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
xn1[ORDER + i] -= gain * facelp[i];
|
||||
}
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (ORDER + 1), lp_flt_coeffs);
|
||||
iusace_compute_lp_residual(lp_flt_coeffs, xn1 + ORDER, x1, fac_len_prev);
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (2 * (ORDER + 1)), lp_flt_coeffs);
|
||||
iusace_compute_lp_residual(lp_flt_coeffs, xn2 + ORDER, x2, fac_len);
|
||||
|
||||
iusace_tcx_mdct(x1, x1, fac_len_prev, pstr_scratch);
|
||||
iusace_tcx_mdct(x2, x2, fac_len, pstr_scratch);
|
||||
|
||||
gain_prev = (FLOAT32)(sq_gain * 0.5f * sqrt(((FLOAT32)fac_len_prev) / (FLOAT32)frame_len));
|
||||
gain_next = (FLOAT32)(sq_gain * 0.5f * sqrt(((FLOAT32)fac_len) / (FLOAT32)frame_len));
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
x1[i] /= gain_prev;
|
||||
}
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
x2[i] /= gain_next;
|
||||
}
|
||||
for (i = 0; i < fac_len_prev / 4; i++) {
|
||||
k = i * lg / (8 * fac_len_prev);
|
||||
x1[i] /= alfd_gains[k];
|
||||
}
|
||||
for (i = 0; i < fac_len / 4; i++) {
|
||||
k = i * lg / (8 * fac_len);
|
||||
x2[i] /= alfd_gains[k];
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i += 8) {
|
||||
iusace_find_nearest_neighbor(&x2[i], &y[i]);
|
||||
}
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
lpd_state->avq_params[i] = y[i];
|
||||
x2[i] = (FLOAT32)y[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len_prev; i += 8) {
|
||||
iusace_find_nearest_neighbor(&x1[i], &y[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
x1[i] = (FLOAT32)y[i];
|
||||
}
|
||||
|
||||
gain_prev = (FLOAT32)(gain_tcx * 0.5f * sqrt(((FLOAT32)fac_len_prev) / (FLOAT32)frame_len));
|
||||
gain_next = (FLOAT32)(gain_tcx * 0.5f * sqrt(((FLOAT32)fac_len) / (FLOAT32)frame_len));
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
x1[i] *= gain_prev;
|
||||
}
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
x2[i] *= gain_next;
|
||||
}
|
||||
for (i = 0; i < fac_len_prev >> 2; i++) {
|
||||
k = i * lg / (fac_len_prev << 3);
|
||||
x1[i] *= alfd_gains[k];
|
||||
}
|
||||
for (i = 0; i < fac_len >> 2; i++) {
|
||||
k = i * lg / (fac_len << 3);
|
||||
x2[i] *= alfd_gains[k];
|
||||
}
|
||||
iusace_tcx_mdct(x1, xn1, fac_len_prev, pstr_scratch);
|
||||
iusace_tcx_mdct(x2, xn2, fac_len, pstr_scratch);
|
||||
|
||||
FLOAT32 coeff1 = (2.0f / (FLOAT32)fac_len_prev), coeff2 = (2.0f / (FLOAT32)fac_len);
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
xn1[i] = xn1[i] * coeff1;
|
||||
}
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
xn2[i] = xn2[i] * coeff2;
|
||||
}
|
||||
|
||||
memset(xn1 + fac_len_prev, 0, fac_len_prev * sizeof(FLOAT32));
|
||||
memset(xn2 + fac_len, 0, fac_len * sizeof(FLOAT32));
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (ORDER + 1), lp_flt_coeffs);
|
||||
iusace_synthesis_tool_float(lp_flt_coeffs, xn1, xn1, 2 * fac_len_prev, xn1 + fac_len_prev,
|
||||
pstr_scratch->p_buf_synthesis_tool);
|
||||
|
||||
iusace_get_weighted_lpc(lpc_coeffs_quant + (2 * (ORDER + 1)), lp_flt_coeffs);
|
||||
iusace_synthesis_tool_float(lp_flt_coeffs, xn2, xn2, fac_len, xn2 + fac_len,
|
||||
pstr_scratch->p_buf_synthesis_tool);
|
||||
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
xn1[i] += facelp[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < frame_len + (fac_length << 1); i++) {
|
||||
xn_buf[i] *= gain_tcx;
|
||||
}
|
||||
|
||||
if (lpd_state->mode >= -1) {
|
||||
for (i = 0; i < (2 * fac_len_prev); i++) {
|
||||
xn_buf[i + fac_length - fac_len_prev] *= sine_window_prev[i];
|
||||
}
|
||||
for (i = 0; i < fac_length - fac_len_prev; i++) {
|
||||
xn_buf[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < (2 * fac_len); i++) {
|
||||
xn_buf[i + frame_len + fac_length - fac_len] *= sine_window[(2 * fac_len) - 1 - i];
|
||||
}
|
||||
for (i = 0; i < fac_length - fac_len; i++) {
|
||||
xn_buf[i + frame_len + fac_length + fac_len] = 0.0f;
|
||||
}
|
||||
|
||||
if (lpd_state->mode != 0) {
|
||||
for (i = 0; i < (2 * fac_length); i++) {
|
||||
xn_buf[i] += lpd_state->tcx_quant[1 + 128 - fac_length + i];
|
||||
}
|
||||
|
||||
mem_tcx_q = lpd_state->tcx_quant[128 - fac_length];
|
||||
} else {
|
||||
for (i = 0; i < fac_len_prev; i++) {
|
||||
params[i - fac_len_prev] = y[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < (2 * fac_len_prev); i++) {
|
||||
xn_buf[i + fac_length] += xn1[i];
|
||||
}
|
||||
mem_tcx_q = lpd_state->tcx_quant[128];
|
||||
}
|
||||
|
||||
memcpy(lpd_state->tcx_quant, xn_buf + frame_len + fac_length - 128 - 1,
|
||||
(1 + 256) * sizeof(FLOAT32));
|
||||
|
||||
for (i = 0; i < fac_len; i++) {
|
||||
xn_buf[i + frame_len + (fac_length - fac_len)] += xn2[i];
|
||||
}
|
||||
|
||||
if (lpd_state->mode > 0) {
|
||||
iusace_apply_preemph(xn_buf, TILT_FAC, fac_length, &mem_tcx_q);
|
||||
|
||||
ptr_lp_flt_coeffs = lpd_state->lpc_coeffs_quant;
|
||||
|
||||
TTT = fac_length % LEN_SUBFR;
|
||||
if (TTT != 0) {
|
||||
memcpy(&(lpd_state->synth[ORDER + 128 - fac_length]), &xn_buf[0], TTT * sizeof(FLOAT32));
|
||||
iusace_compute_lp_residual(ptr_lp_flt_coeffs, &(lpd_state->synth[ORDER + 128 - fac_length]),
|
||||
&(lpd_state->acelp_exc[(2 * len_subfrm) - fac_length]), TTT);
|
||||
|
||||
ptr_lp_flt_coeffs += (ORDER + 1);
|
||||
}
|
||||
|
||||
for (i_subfr = TTT; i_subfr < fac_length; i_subfr += LEN_SUBFR) {
|
||||
memcpy(&(lpd_state->synth[ORDER + 128 - fac_length + i_subfr]), &xn_buf[i_subfr],
|
||||
LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_compute_lp_residual(
|
||||
ptr_lp_flt_coeffs, &(lpd_state->synth[ORDER + 128 - fac_length + i_subfr]),
|
||||
&(lpd_state->acelp_exc[(2 * len_subfrm) - fac_length + i_subfr]), LEN_SUBFR);
|
||||
ptr_lp_flt_coeffs += (ORDER + 1);
|
||||
}
|
||||
|
||||
ptr_lp_flt_coeffs = lpd_state->lpc_coeffs;
|
||||
for (i_subfr = 0; i_subfr < fac_length; i_subfr += LEN_SUBFR) {
|
||||
iusace_get_weighted_lpc(ptr_lp_flt_coeffs, lp_flt_coeffs);
|
||||
iusace_compute_lp_residual(lp_flt_coeffs,
|
||||
&(lpd_state->synth[ORDER + 128 - fac_length + i_subfr]),
|
||||
&(lpd_state->wsynth[1 + 128 - fac_length + i_subfr]), LEN_SUBFR);
|
||||
ptr_lp_flt_coeffs += (ORDER + 1);
|
||||
}
|
||||
tmp = lpd_state->wsynth[0 + 128 - fac_length];
|
||||
iusace_apply_deemph(&(lpd_state->wsynth[1 + 128 - fac_length]), TILT_FAC, fac_length, &tmp);
|
||||
}
|
||||
|
||||
k = ((frame_len / LEN_SUBFR) - 2) * (ORDER + 1);
|
||||
memcpy(lpd_state->lpc_coeffs, lpc_coeffs + k, 2 * (ORDER + 1) * sizeof(FLOAT32));
|
||||
|
||||
memcpy(lpd_state->lpc_coeffs_quant, lpc_coeffs_quant + (2 * (ORDER + 1)),
|
||||
(ORDER + 1) * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->lpc_coeffs_quant + (ORDER + 1), lpd_state->lpc_coeffs_quant,
|
||||
(ORDER + 1) * sizeof(FLOAT32));
|
||||
|
||||
memcpy(synth - 128, &(lpd_state->synth[ORDER]), 128 * sizeof(FLOAT32));
|
||||
lpd_state->tcx_fac = xn[frame_len - 1];
|
||||
|
||||
iusace_apply_preemph(xn, TILT_FAC, frame_len, &mem_tcx_q);
|
||||
for (i_subfr = 0; i_subfr < frame_len; i_subfr += LEN_SUBFR) {
|
||||
memcpy(&synth[i_subfr], &xn[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
|
||||
iusace_compute_lp_residual(lpc_coeffs_quant + (2 * (ORDER + 1)), &synth[i_subfr],
|
||||
&xn[i_subfr], LEN_SUBFR);
|
||||
}
|
||||
memcpy(lpd_state->synth, synth + frame_len - (ORDER + 128), (ORDER + 128) * sizeof(FLOAT32));
|
||||
|
||||
if (frame_len == len_subfrm) {
|
||||
memcpy(x, lpd_state->acelp_exc + len_subfrm, len_subfrm * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->acelp_exc, x, len_subfrm * sizeof(FLOAT32));
|
||||
memcpy(lpd_state->acelp_exc + len_subfrm, xn, len_subfrm * sizeof(FLOAT32));
|
||||
} else {
|
||||
memcpy(lpd_state->acelp_exc, xn + frame_len - (2 * len_subfrm),
|
||||
2 * len_subfrm * sizeof(FLOAT32));
|
||||
}
|
||||
|
||||
memcpy(wsynth - 128, &(lpd_state->wsynth[1]), 128 * sizeof(FLOAT32));
|
||||
|
||||
ptr_lp_flt_coeffs = lpc_coeffs;
|
||||
for (i_subfr = 0; i_subfr < frame_len; i_subfr += LEN_SUBFR) {
|
||||
iusace_get_weighted_lpc(ptr_lp_flt_coeffs, lp_flt_coeffs);
|
||||
iusace_compute_lp_residual(lp_flt_coeffs, &synth[i_subfr], &wsynth[i_subfr], LEN_SUBFR);
|
||||
ptr_lp_flt_coeffs += (ORDER + 1);
|
||||
}
|
||||
tmp = wsynth[-1];
|
||||
iusace_apply_deemph(wsynth, TILT_FAC, frame_len, &tmp);
|
||||
|
||||
memcpy(lpd_state->wsynth, wsynth + frame_len - (1 + 128), (1 + 128) * sizeof(FLOAT32));
|
||||
|
||||
lpd_state->mode = mode;
|
||||
|
||||
lpd_state->num_bits = 10 + target_bits;
|
||||
|
||||
return;
|
||||
}
|
||||
186
encoder/iusace_tcx_mdct.c
Normal file
186
encoder/iusace_tcx_mdct.c
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_rom.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_fft.h"
|
||||
#include "iusace_tcx_mdct.h"
|
||||
|
||||
VOID iusace_tcx_mdct_main(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 l, WORD32 m, WORD32 r,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
WORD32 length = l / 2 + m + r / 2;
|
||||
FLOAT32 *input = pstr_scratch->p_tcx_input;
|
||||
WORD32 i;
|
||||
|
||||
for (i = 0; i < m / 2; i++) {
|
||||
input[m / 2 + r / 2 + i] = -ptr_in[l + m / 2 - 1 - i];
|
||||
}
|
||||
for (i = 0; i < l / 2; i++) {
|
||||
input[m / 2 + r / 2 + m / 2 + i] = ptr_in[i] - ptr_in[l - 1 - i];
|
||||
}
|
||||
for (i = 0; i < m / 2; i++) {
|
||||
input[m / 2 + r / 2 - 1 - i] = -ptr_in[l + m / 2 + i];
|
||||
}
|
||||
for (i = 0; i < r / 2; i++) {
|
||||
input[m / 2 + r / 2 - 1 - m / 2 - i] = -ptr_in[l + m + i] - ptr_in[l + m + r - 1 - i];
|
||||
}
|
||||
|
||||
iusace_tcx_mdct(input, ptr_out, length, pstr_scratch);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tcx_imdct(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 l, WORD32 m, WORD32 r,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
WORD32 length = l / 2 + m + r / 2;
|
||||
FLOAT32 *output = pstr_scratch->p_tcx_output;
|
||||
iusace_tcx_mdct(ptr_in, output, length, pstr_scratch);
|
||||
|
||||
WORD32 i;
|
||||
|
||||
for (i = 0; i < m / 2; i++) {
|
||||
ptr_out[l + m / 2 - 1 - i] = -1.0f * output[m / 2 + r / 2 + i];
|
||||
}
|
||||
for (i = 0; i < l / 2; i++) {
|
||||
ptr_out[i] = output[m / 2 + r / 2 + m / 2 + i];
|
||||
ptr_out[l - 1 - i] = -1.0f * output[m / 2 + r / 2 + m / 2 + i];
|
||||
}
|
||||
for (i = 0; i < m / 2; i++) {
|
||||
ptr_out[l + m / 2 + i] = -1.0f * output[m / 2 + r / 2 - 1 - i];
|
||||
}
|
||||
for (i = 0; i < r / 2; i++) {
|
||||
ptr_out[l + m + i] = -1.0f * output[m / 2 + r / 2 - 1 - m / 2 - i];
|
||||
ptr_out[l + m + r - 1 - i] = -1.0f * output[m / 2 + r / 2 - 1 - m / 2 - i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_get_pre_post_twid(FLOAT32 **ptr_pre_twid_re, FLOAT32 **ptr_pre_twid_im,
|
||||
FLOAT32 **ptr_post_twid_re, FLOAT32 **ptr_post_twid_im,
|
||||
WORD32 length) {
|
||||
switch (length) {
|
||||
case 512:
|
||||
*ptr_pre_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_256[0][0];
|
||||
*ptr_pre_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_256[1][0];
|
||||
*ptr_post_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_256[2][0];
|
||||
*ptr_post_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_256[3][0];
|
||||
break;
|
||||
case 256:
|
||||
*ptr_pre_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_128[0][0];
|
||||
*ptr_pre_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_128[1][0];
|
||||
*ptr_post_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_128[2][0];
|
||||
*ptr_post_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_128[3][0];
|
||||
break;
|
||||
case 128:
|
||||
*ptr_pre_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_64[0][0];
|
||||
*ptr_pre_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_64[1][0];
|
||||
*ptr_post_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_64[2][0];
|
||||
*ptr_post_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_64[3][0];
|
||||
break;
|
||||
case 64:
|
||||
*ptr_pre_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_32[0][0];
|
||||
*ptr_pre_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_32[1][0];
|
||||
*ptr_post_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_32[2][0];
|
||||
*ptr_post_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_32[3][0];
|
||||
break;
|
||||
default:
|
||||
*ptr_pre_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_512[0][0];
|
||||
*ptr_pre_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_512[1][0];
|
||||
*ptr_post_twid_re = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_512[2][0];
|
||||
*ptr_post_twid_im = (FLOAT32 *)&iusace_pre_post_twid_cos_sin_512[3][0];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_pre_twid(FLOAT32 *ptr_twid_re, FLOAT32 *ptr_twid_im, FLOAT32 *ptr_in,
|
||||
WORD32 length) {
|
||||
WORD32 i;
|
||||
for (i = 0; i < length; i++) {
|
||||
FLOAT32 temp = ptr_in[2 * i] * ptr_twid_re[i] - ptr_in[2 * i + 1] * ptr_twid_im[i];
|
||||
|
||||
ptr_in[2 * i + 1] = ptr_in[2 * i] * ptr_twid_im[i] + ptr_in[2 * i + 1] * ptr_twid_re[i];
|
||||
|
||||
ptr_in[2 * i] = temp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_post_twid(FLOAT32 *ptr_twid_re, FLOAT32 *ptr_twid_im, FLOAT32 *ptr_in,
|
||||
WORD32 length) {
|
||||
WORD32 i;
|
||||
for (i = 0; i < length; i++) {
|
||||
FLOAT32 temp = ptr_in[2 * i] * ptr_twid_re[i] - ptr_in[2 * i + 1] * ptr_twid_im[i];
|
||||
|
||||
ptr_in[2 * i + 1] = -ptr_in[2 * i] * ptr_twid_im[i] - ptr_in[2 * i + 1] * ptr_twid_re[i];
|
||||
ptr_in[2 * i] = temp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tcx_mdct(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 length,
|
||||
iusace_scratch_mem *pstr_scratch) {
|
||||
FLOAT32 *ptr_pre_twid_re, *ptr_pre_twid_im;
|
||||
FLOAT32 *ptr_post_twid_re, *ptr_post_twid_im;
|
||||
WORD32 i;
|
||||
FLOAT32 *ptr_real = pstr_scratch->p_temp_mdct;
|
||||
WORD32 len_by_2 = length >> 1;
|
||||
|
||||
iusace_get_pre_post_twid(&ptr_pre_twid_re, &ptr_pre_twid_im, &ptr_post_twid_re,
|
||||
&ptr_post_twid_im, length);
|
||||
|
||||
for (i = 0; i < len_by_2; i++) {
|
||||
ptr_real[2 * i] = ptr_in[2 * i];
|
||||
ptr_real[2 * i + 1] = ptr_in[length - 1 - 2 * i];
|
||||
}
|
||||
|
||||
/* pre twiddle */
|
||||
iusace_pre_twid(ptr_pre_twid_re, ptr_pre_twid_im, ptr_real, len_by_2);
|
||||
|
||||
iusace_complex_fft(ptr_real, len_by_2, pstr_scratch);
|
||||
|
||||
/* post twiddle */
|
||||
iusace_post_twid(ptr_post_twid_re, ptr_post_twid_im, ptr_real, len_by_2);
|
||||
|
||||
for (i = 0; i < len_by_2; i++) {
|
||||
ptr_out[2 * i] = ptr_real[2 * i];
|
||||
ptr_out[length - 1 - 2 * i] = ptr_real[2 * i + 1];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
29
encoder/iusace_tcx_mdct.h
Normal file
29
encoder/iusace_tcx_mdct.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
VOID iusace_tcx_mdct_main(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 l, WORD32 m, WORD32 r,
|
||||
iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_tcx_imdct(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 l, WORD32 m, WORD32 r,
|
||||
iusace_scratch_mem *pstr_scratch);
|
||||
|
||||
VOID iusace_tcx_mdct(FLOAT32 *ptr_in, FLOAT32 *ptr_out, WORD32 length,
|
||||
iusace_scratch_mem *pstr_scratch);
|
||||
533
encoder/iusace_tns_usac.c
Normal file
533
encoder/iusace_tns_usac.c
Normal file
|
|
@ -0,0 +1,533 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "ixheaac_basic_ops32.h"
|
||||
#include "ixheaac_basic_ops40.h"
|
||||
#include "ixheaac_basic_ops.h"
|
||||
|
||||
static const WORD32 iusace_tns_supported_sampling_rates[13] = {
|
||||
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0};
|
||||
|
||||
static const UWORD16 iusace_tns_min_band_number_long[12] = {11, 12, 15, 16, 17, 20,
|
||||
25, 26, 24, 28, 30, 31};
|
||||
|
||||
static const UWORD16 iusace_tns_min_band_number_short[12] = {2, 2, 2, 3, 3, 4,
|
||||
6, 6, 8, 10, 10, 12};
|
||||
|
||||
static const WORD32 iusace_tns_max_bands_table[16][2] = {{31, 9}, /**< 96000 */
|
||||
{31, 9}, /**< 88200 */
|
||||
{34, 10}, /**< 64000 */
|
||||
{40, 14}, /**< 48000 */
|
||||
{42, 14}, /**< 44100 */
|
||||
{51, 14}, /**< 32000 */
|
||||
{47, 15}, /**< 24000 */
|
||||
{47, 15}, /**< 22050 */
|
||||
{43, 15}, /**< 16000 */
|
||||
{43, 15}, /**< 12000 */
|
||||
{43, 15}, /**< 11025 */
|
||||
{40, 15}, /**< 8000 */
|
||||
{40, 15}, /**< 7350 */
|
||||
{0, 0}, {0, 0}, {0, 0}};
|
||||
|
||||
static WORD32 iusace_freq_to_band_mapping(WORD32 freq, WORD32 sample_rate, WORD32 num_bands,
|
||||
const WORD32 *ptr_band_start_offset) {
|
||||
WORD32 line_num, band;
|
||||
|
||||
line_num = (freq * ptr_band_start_offset[num_bands] * 4 / sample_rate + 1) / 2;
|
||||
|
||||
if (line_num >= ptr_band_start_offset[num_bands]) {
|
||||
return num_bands;
|
||||
}
|
||||
|
||||
for (band = 0; band < num_bands; band++) {
|
||||
if (ptr_band_start_offset[band + 1] > line_num) break;
|
||||
}
|
||||
|
||||
if (line_num - ptr_band_start_offset[band] > ptr_band_start_offset[band + 1] - line_num) {
|
||||
band++;
|
||||
}
|
||||
|
||||
return band;
|
||||
};
|
||||
|
||||
static VOID iusace_calc_gauss_win(FLOAT64 *ptr_win, const WORD32 length, const WORD32 sample_rate,
|
||||
const WORD32 win_seq, const FLOAT32 time_resolution) {
|
||||
WORD32 i;
|
||||
FLOAT32 gauss_exp = 3.14159265358979323f * sample_rate * 0.001f * (FLOAT32)time_resolution /
|
||||
(win_seq != EIGHT_SHORT_SEQUENCE ? 1024.0f : 128.0f);
|
||||
|
||||
gauss_exp = -0.5f * gauss_exp * gauss_exp;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
ptr_win[i] = (FLOAT32)exp(gauss_exp * (i + 0.5) * (i + 0.5));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_tns_init(WORD32 sampling_rate, WORD32 bit_rate, ia_tns_info *tns_info,
|
||||
WORD32 num_channels) {
|
||||
WORD32 fs_index = 0;
|
||||
WORD32 lpc_stop_freq = 16000;
|
||||
WORD32 lpc_start_freq_long = 2500, lpc_start_freq_short = 3750;
|
||||
tns_info->threshold = 1.41f;
|
||||
tns_info->tns_time_res_short = 0.6f;
|
||||
tns_info->tns_time_res_long = 0.6f;
|
||||
|
||||
if (sampling_rate == 14700) {
|
||||
sampling_rate = 16000;
|
||||
}
|
||||
if (sampling_rate == 29400) {
|
||||
sampling_rate = 32000;
|
||||
}
|
||||
|
||||
if (bit_rate < 32000) {
|
||||
if (num_channels == 1) {
|
||||
tns_info->threshold = 1.2f;
|
||||
lpc_start_freq_long = 2000;
|
||||
}
|
||||
} else if (bit_rate < 36000) {
|
||||
if (num_channels == 1) {
|
||||
tns_info->tns_time_res_long = 0.8f;
|
||||
} else {
|
||||
tns_info->tns_time_res_long = 0.5f;
|
||||
}
|
||||
tns_info->tns_time_res_short = 0.3f;
|
||||
} else {
|
||||
tns_info->tns_time_res_long = 0.5f;
|
||||
tns_info->tns_time_res_short = 0.3f;
|
||||
}
|
||||
|
||||
/** Determine if sampling rate is supported
|
||||
*/
|
||||
while (sampling_rate != iusace_tns_supported_sampling_rates[fs_index]) {
|
||||
if (!iusace_tns_supported_sampling_rates[fs_index]) {
|
||||
return -1;
|
||||
}
|
||||
fs_index++;
|
||||
}
|
||||
|
||||
tns_info->tns_max_bands_long = iusace_tns_max_bands_table[fs_index][0];
|
||||
tns_info->tns_max_bands_short = iusace_tns_max_bands_table[fs_index][1];
|
||||
tns_info->tns_max_order_long = 15;
|
||||
tns_info->tns_max_order_short = 7;
|
||||
|
||||
tns_info->tns_min_band_number_long = iusace_tns_min_band_number_long[fs_index];
|
||||
tns_info->tns_min_band_number_short = iusace_tns_min_band_number_short[fs_index];
|
||||
|
||||
tns_info->lpc_start_band_long =
|
||||
iusace_freq_to_band_mapping(lpc_start_freq_long, sampling_rate, tns_info->max_sfb_long,
|
||||
tns_info->sfb_offset_table_long);
|
||||
|
||||
tns_info->lpc_start_band_short =
|
||||
iusace_freq_to_band_mapping(lpc_start_freq_short, sampling_rate, tns_info->max_sfb_short,
|
||||
tns_info->sfb_offset_table_short);
|
||||
|
||||
tns_info->lpc_stop_band_long = iusace_freq_to_band_mapping(
|
||||
lpc_stop_freq, sampling_rate, tns_info->max_sfb_long, tns_info->sfb_offset_table_long);
|
||||
|
||||
tns_info->lpc_stop_band_short = iusace_freq_to_band_mapping(
|
||||
lpc_stop_freq, sampling_rate, tns_info->max_sfb_short, tns_info->sfb_offset_table_short);
|
||||
|
||||
iusace_calc_gauss_win(tns_info->win_long, tns_info->tns_max_order_long + 1, sampling_rate,
|
||||
ONLY_LONG_SEQUENCE, tns_info->tns_time_res_long);
|
||||
|
||||
iusace_calc_gauss_win(tns_info->win_short, tns_info->tns_max_order_short + 1, sampling_rate,
|
||||
EIGHT_SHORT_SEQUENCE, tns_info->tns_time_res_short);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID iusace_tns_filter(WORD32 length, FLOAT64 *spec, ia_tns_filter_data *filter,
|
||||
FLOAT64 *scratch_tns_filter) {
|
||||
WORD32 i, j, k = 0;
|
||||
WORD32 order = filter->order;
|
||||
FLOAT64 *a = filter->a_coeffs;
|
||||
FLOAT64 *temp = scratch_tns_filter;
|
||||
|
||||
/** Determine loop parameters for given direction
|
||||
*/
|
||||
if (filter->direction) {
|
||||
/** Startup, initial state is zero
|
||||
*/
|
||||
temp[length - 1] = spec[length - 1];
|
||||
for (i = length - 2; i > (length - 1 - order); i--) {
|
||||
temp[i] = spec[i];
|
||||
k++;
|
||||
for (j = 1; j <= k; j++) {
|
||||
spec[i] += temp[i + j] * a[j];
|
||||
}
|
||||
}
|
||||
|
||||
/** Now filter the rest
|
||||
*/
|
||||
for (i = length - 1 - order; i >= 0; i--) {
|
||||
temp[i] = spec[i];
|
||||
for (j = 1; j <= order; j++) {
|
||||
spec[i] += temp[i + j] * a[j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/** Startup, initial state is zero
|
||||
*/
|
||||
temp[0] = spec[0];
|
||||
for (i = 1; i < order; i++) {
|
||||
temp[i] = spec[i];
|
||||
for (j = 1; j <= i; j++) {
|
||||
spec[i] += temp[i - j] * a[j];
|
||||
}
|
||||
}
|
||||
|
||||
/** Now filter the rest
|
||||
*/
|
||||
for (i = order; i < length; i++) {
|
||||
temp[i] = spec[i];
|
||||
for (j = 1; j <= order; j++) {
|
||||
spec[i] += temp[i - j] * a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static WORD32 iusace_truncate_coeffs(WORD32 f_order, FLOAT64 threshold, FLOAT64 *k_array) {
|
||||
WORD32 i;
|
||||
for (i = f_order; i >= 0; i--) {
|
||||
k_array[i] = (fabs(k_array[i]) > threshold) ? k_array[i] : 0.0;
|
||||
if (k_array[i] != 0.0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID iusace_quantize_reflection_coeffs(WORD32 f_order, WORD32 coeff_res, FLOAT64 *k_array,
|
||||
WORD32 *index_array) {
|
||||
FLOAT64 iqfac, iqfac_m;
|
||||
WORD32 i;
|
||||
|
||||
iqfac = (((SIZE_T)1 << (coeff_res - 1)) - 0.5) / (PI / 2);
|
||||
iqfac_m = (((SIZE_T)1 << (coeff_res - 1)) + 0.5) / (PI / 2);
|
||||
|
||||
/* Quantize and inverse quantize */
|
||||
for (i = 1; i <= f_order; i++) {
|
||||
index_array[i] = (WORD32)(0.5 + (asin(k_array[i]) * ((k_array[i] >= 0) ? iqfac : iqfac_m)));
|
||||
k_array[i] = sin((FLOAT64)index_array[i] / ((index_array[i] >= 0) ? iqfac : iqfac_m));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tns_auto_corr(WORD32 max_order, WORD32 data_size, FLOAT64 *data, FLOAT64 *r_array) {
|
||||
WORD32 i, j;
|
||||
FLOAT64 tmp_var;
|
||||
for (i = 0; i < data_size; i += 2) {
|
||||
const FLOAT64 *input1 = &data[i];
|
||||
FLOAT64 temp1 = *input1;
|
||||
FLOAT64 temp2 = *(input1 + 1);
|
||||
FLOAT64 inp_tmp1 = *input1++;
|
||||
for (j = 0; j <= max_order; j++) {
|
||||
FLOAT64 inp_tmp2;
|
||||
tmp_var = temp1 * inp_tmp1;
|
||||
inp_tmp2 = *input1++;
|
||||
tmp_var += temp2 * inp_tmp2;
|
||||
r_array[j] += tmp_var;
|
||||
j++;
|
||||
tmp_var = temp1 * inp_tmp2;
|
||||
inp_tmp1 = *input1++;
|
||||
tmp_var += temp2 * inp_tmp1;
|
||||
r_array[j] += tmp_var;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static FLOAT64 iusace_levinson_durbin(WORD32 order, WORD32 data_size, FLOAT64 *ptr_data,
|
||||
FLOAT64 *ptr_k, FLOAT64 *ptr_win, FLOAT64 *ptr_scratch) {
|
||||
WORD32 i, j;
|
||||
FLOAT64 *ptr_work_buffer_temp;
|
||||
FLOAT64 *ptr_work_buffer = ptr_scratch;
|
||||
FLOAT64 *ptr_input = ptr_scratch + TNS_MAX_ORDER + 1;
|
||||
memset(ptr_input, 0, (TNS_MAX_ORDER + 1) * sizeof(ptr_input[0]));
|
||||
iusace_tns_auto_corr(order, data_size, ptr_data, ptr_input);
|
||||
|
||||
WORD32 num_of_coeff = order;
|
||||
FLOAT64 *ptr_refl_coeff = ptr_k;
|
||||
ptr_k[0] = 1.0;
|
||||
|
||||
if (ptr_input[0] == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_of_coeff + 1; i++) {
|
||||
ptr_input[i] = ptr_input[i] * ptr_win[i];
|
||||
}
|
||||
|
||||
FLOAT64 tmp_var;
|
||||
ptr_work_buffer[0] = ptr_input[0];
|
||||
|
||||
for (i = 1; i < num_of_coeff; i++) {
|
||||
tmp_var = ptr_input[i];
|
||||
ptr_work_buffer[i] = tmp_var;
|
||||
ptr_work_buffer[i + num_of_coeff - 1] = tmp_var;
|
||||
}
|
||||
ptr_work_buffer[i + num_of_coeff - 1] = ptr_input[i];
|
||||
|
||||
for (i = 0; i < num_of_coeff; i++) {
|
||||
FLOAT64 refc, tmp;
|
||||
tmp = ptr_work_buffer[num_of_coeff + i];
|
||||
if (tmp < 0) {
|
||||
tmp = -tmp;
|
||||
} else {
|
||||
if (ptr_work_buffer[0] < tmp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ptr_work_buffer[0] == 0) {
|
||||
refc = 0;
|
||||
} else {
|
||||
refc = tmp / ptr_work_buffer[0];
|
||||
}
|
||||
|
||||
if (ptr_work_buffer[num_of_coeff + i] > 0) {
|
||||
refc = -refc;
|
||||
}
|
||||
ptr_refl_coeff[i + 1] = refc;
|
||||
ptr_work_buffer_temp = &(ptr_work_buffer[num_of_coeff]);
|
||||
|
||||
for (j = i; j < num_of_coeff; j++) {
|
||||
FLOAT64 accu1, accu2;
|
||||
accu1 = refc * ptr_work_buffer[j - i];
|
||||
accu1 += ptr_work_buffer_temp[j];
|
||||
accu2 = refc * ptr_work_buffer_temp[j];
|
||||
accu2 += ptr_work_buffer[j - i];
|
||||
ptr_work_buffer_temp[j] = accu1;
|
||||
ptr_work_buffer[j - i] = accu2;
|
||||
}
|
||||
}
|
||||
return (ptr_input[0] / ptr_work_buffer[0]);
|
||||
}
|
||||
|
||||
static VOID iusace_step_up(WORD32 f_order, FLOAT64 *ptr_k, FLOAT64 *ptr_a, FLOAT64 *ptr_scratch) {
|
||||
FLOAT64 *ptr_a_temp = ptr_scratch;
|
||||
WORD32 i, order;
|
||||
|
||||
ptr_a[0] = 1.0;
|
||||
ptr_a_temp[0] = 1.0;
|
||||
for (order = 1; order <= f_order; order++) {
|
||||
ptr_a[order] = 0.0;
|
||||
for (i = 1; i <= order; i++) {
|
||||
ptr_a_temp[i] = ptr_a[i] + ptr_k[order] * ptr_a[order - i];
|
||||
}
|
||||
for (i = 1; i <= order; i++) {
|
||||
ptr_a[i] = ptr_a_temp[i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_calc_weighted_spec(FLOAT64 *ptr_spec, FLOAT64 *ptr_wgt_spec,
|
||||
FLOAT32 *ptr_sfb_en, WORD32 *ptr_sfb_offset,
|
||||
WORD32 lpc_start_band, WORD32 lpc_stop_band,
|
||||
FLOAT64 *ptr_scratch) {
|
||||
WORD32 i, sfb;
|
||||
FLOAT32 temp;
|
||||
FLOAT32 *ptr_tns_sfb_mean = (FLOAT32 *)ptr_scratch;
|
||||
memset(ptr_scratch, 0, MAX_NUM_GROUPED_SFB * sizeof(ptr_tns_sfb_mean[0]));
|
||||
WORD32 lpc_stop_line = ptr_sfb_offset[lpc_stop_band];
|
||||
WORD32 lpc_start_line = ptr_sfb_offset[lpc_start_band];
|
||||
|
||||
for (sfb = lpc_start_band; sfb < lpc_stop_band; sfb++) {
|
||||
ptr_tns_sfb_mean[sfb] = (FLOAT32)(1.0 / sqrt(ptr_sfb_en[sfb] + 1e-30f));
|
||||
}
|
||||
|
||||
sfb = lpc_start_band;
|
||||
temp = ptr_tns_sfb_mean[sfb];
|
||||
|
||||
for (i = lpc_start_line; i < lpc_stop_line; i++) {
|
||||
if (ptr_sfb_offset[sfb + 1] == i) {
|
||||
sfb++;
|
||||
|
||||
if (sfb + 1 < lpc_stop_band) {
|
||||
temp = ptr_tns_sfb_mean[sfb];
|
||||
}
|
||||
}
|
||||
ptr_wgt_spec[i] = temp;
|
||||
}
|
||||
|
||||
for (i = lpc_stop_line - 2; i >= lpc_start_line; i--) {
|
||||
ptr_wgt_spec[i] = (ptr_wgt_spec[i] + ptr_wgt_spec[i + 1]) * 0.5f;
|
||||
}
|
||||
|
||||
for (i = lpc_start_line + 1; i < lpc_stop_line; i++) {
|
||||
ptr_wgt_spec[i] = (ptr_wgt_spec[i] + ptr_wgt_spec[i - 1]) * 0.5f;
|
||||
}
|
||||
|
||||
for (i = lpc_start_line; i < lpc_stop_line; i++) {
|
||||
ptr_wgt_spec[i] = ptr_wgt_spec[i] * ptr_spec[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tns_data_sync(ia_tns_info *ptr_tns_dest, ia_tns_info *ptr_tns_src, const WORD32 w,
|
||||
WORD32 order) {
|
||||
ia_tns_window_data *win_data_src = &ptr_tns_src->window_data[w];
|
||||
ia_tns_window_data *win_data_dest = &ptr_tns_dest->window_data[w];
|
||||
WORD32 i;
|
||||
if (fabs(win_data_dest->tns_pred_gain - win_data_src->tns_pred_gain) <
|
||||
((FLOAT32)0.03f * win_data_dest->tns_pred_gain)) {
|
||||
win_data_dest->tns_active = win_data_src->tns_active;
|
||||
|
||||
for (i = 0; i < order; i++) {
|
||||
win_data_dest->tns_filter->k_coeffs[i] = win_data_src->tns_filter->k_coeffs[i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_tns_encode(ia_tns_info *pstr_tns_info_ch2, ia_tns_info *pstr_tns_info,
|
||||
FLOAT32 *ptr_sfb_energy, WORD32 w, WORD32 i_ch, WORD32 low_pass_line,
|
||||
FLOAT64 *ptr_scratch_tns_filter, WORD32 core_mode,
|
||||
FLOAT64 *ptr_tns_scratch) {
|
||||
WORD32 number_of_bands = pstr_tns_info->number_of_bands;
|
||||
WORD32 block_type = pstr_tns_info->block_type;
|
||||
FLOAT64 *ptr_spec = pstr_tns_info->spec;
|
||||
WORD32 start_band, stop_band, order; /**< bands over which to apply TNS */
|
||||
WORD32 length_in_bands; /**< Length to filter, in bands */
|
||||
WORD32 start_index, length;
|
||||
WORD32 nbands;
|
||||
WORD32 coeff_res;
|
||||
FLOAT64 *ptr_weighted_spec = ptr_tns_scratch;
|
||||
memset(ptr_weighted_spec, 0, 4096 * sizeof(ptr_weighted_spec[0]));
|
||||
FLOAT64 *ptr_scratch = ptr_tns_scratch + 4096;
|
||||
FLOAT64 *ptr_window = NULL;
|
||||
WORD32 lpc_start_band, lpc_stop_band;
|
||||
WORD32 *ptr_sfb_offset_table;
|
||||
|
||||
switch (block_type) {
|
||||
case EIGHT_SHORT_SEQUENCE:
|
||||
start_band = pstr_tns_info->tns_min_band_number_short;
|
||||
stop_band = number_of_bands;
|
||||
length_in_bands = stop_band - start_band;
|
||||
order = pstr_tns_info->tns_max_order_short;
|
||||
start_band = MIN(start_band, pstr_tns_info->tns_max_bands_short);
|
||||
stop_band = MIN(stop_band, pstr_tns_info->tns_max_bands_short);
|
||||
coeff_res = 3;
|
||||
ptr_window = pstr_tns_info->win_short;
|
||||
nbands = pstr_tns_info->max_sfb_short;
|
||||
lpc_start_band = pstr_tns_info->lpc_start_band_short;
|
||||
lpc_stop_band = pstr_tns_info->lpc_stop_band_short;
|
||||
if (core_mode == CORE_MODE_FD) {
|
||||
ptr_sfb_offset_table = pstr_tns_info->sfb_offset_table_short;
|
||||
} else {
|
||||
ptr_sfb_offset_table = pstr_tns_info->sfb_offset_table_short_tcx;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
start_band = pstr_tns_info->tns_min_band_number_long;
|
||||
stop_band = number_of_bands;
|
||||
length_in_bands = stop_band - start_band;
|
||||
order = pstr_tns_info->tns_max_order_long;
|
||||
start_band = MIN(start_band, pstr_tns_info->tns_max_bands_long);
|
||||
stop_band = MIN(stop_band, pstr_tns_info->tns_max_bands_long);
|
||||
coeff_res = 4;
|
||||
ptr_window = pstr_tns_info->win_long;
|
||||
nbands = pstr_tns_info->max_sfb_long;
|
||||
lpc_start_band = pstr_tns_info->lpc_start_band_long;
|
||||
lpc_stop_band = pstr_tns_info->lpc_stop_band_long;
|
||||
ptr_sfb_offset_table = pstr_tns_info->sfb_offset_table_long;
|
||||
break;
|
||||
}
|
||||
|
||||
/** Make sure that start and stop bands < max_sfb
|
||||
* Make sure that start and stop bands >= 0
|
||||
*/
|
||||
start_band = MIN(start_band, nbands);
|
||||
stop_band = MIN(stop_band, nbands);
|
||||
start_band = MAX(start_band, 0);
|
||||
stop_band = MAX(stop_band, 0);
|
||||
|
||||
pstr_tns_info->tns_data_present = 0; /**< default TNS not used */
|
||||
|
||||
/** Perform analysis and filtering for each window
|
||||
*/
|
||||
{
|
||||
ia_tns_window_data *window_data = &pstr_tns_info->window_data[w];
|
||||
ia_tns_filter_data *tns_filter = window_data->tns_filter;
|
||||
FLOAT64 *k = tns_filter->k_coeffs; /**< reflection coeffs */
|
||||
FLOAT64 *a = tns_filter->a_coeffs; /**< prediction coeffs */
|
||||
|
||||
iusace_calc_weighted_spec(ptr_spec, ptr_weighted_spec, ptr_sfb_energy, ptr_sfb_offset_table,
|
||||
lpc_start_band, lpc_stop_band, ptr_scratch);
|
||||
|
||||
window_data->n_filt = 0;
|
||||
window_data->coef_res = coeff_res;
|
||||
|
||||
start_index = ptr_sfb_offset_table[lpc_start_band];
|
||||
length =
|
||||
ptr_sfb_offset_table[lpc_stop_band] -
|
||||
ptr_sfb_offset_table[lpc_start_band]; /**< The length of the spectral data to be
|
||||
processed
|
||||
*/
|
||||
|
||||
window_data->tns_pred_gain = iusace_levinson_durbin(
|
||||
order, length, &ptr_weighted_spec[start_index], k, ptr_window, ptr_scratch);
|
||||
|
||||
window_data->tns_active = 0;
|
||||
if (window_data->tns_pred_gain > DEF_TNS_GAIN_THRESH) {
|
||||
window_data->tns_active = 1;
|
||||
}
|
||||
|
||||
if (i_ch == 1) {
|
||||
iusace_tns_data_sync(pstr_tns_info, pstr_tns_info_ch2, w, order);
|
||||
}
|
||||
|
||||
if (window_data->tns_pred_gain > DEF_TNS_GAIN_THRESH) {
|
||||
/** Use TNS
|
||||
*/
|
||||
WORD32 truncated_order;
|
||||
window_data->n_filt++;
|
||||
pstr_tns_info->tns_data_present = 1;
|
||||
tns_filter->direction = 0;
|
||||
tns_filter->coef_compress = 0;
|
||||
tns_filter->length = length_in_bands;
|
||||
iusace_quantize_reflection_coeffs(order, coeff_res, k, tns_filter->index);
|
||||
truncated_order = iusace_truncate_coeffs(order, DEF_TNS_COEFF_THRESH, k);
|
||||
tns_filter->order = truncated_order;
|
||||
iusace_step_up(truncated_order, k, a, ptr_scratch); /**< Compute prediction coefficients */
|
||||
start_index = ptr_sfb_offset_table[start_band];
|
||||
length = MIN(ptr_sfb_offset_table[stop_band], low_pass_line) - start_index;
|
||||
if (block_type == EIGHT_SHORT_SEQUENCE) {
|
||||
length = ptr_sfb_offset_table[stop_band] - start_index;
|
||||
}
|
||||
iusace_tns_filter(length, &ptr_spec[start_index], tns_filter,
|
||||
ptr_scratch_tns_filter); /**< filter */
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
88
encoder/iusace_tns_usac.h
Normal file
88
encoder/iusace_tns_usac.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define LN (2048)
|
||||
#define SN (256)
|
||||
#define LN2 (LN / 2)
|
||||
#define NSHORT (LN / SN)
|
||||
|
||||
#define TNS_MAX_ORDER 31
|
||||
#define DEF_TNS_GAIN_THRESH 1.41
|
||||
#define DEF_TNS_COEFF_THRESH 0.1
|
||||
#define DEF_TNS_RES_OFFSET 3
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
WORD32 order; /**< Filter order */
|
||||
WORD32 direction; /**< Filtering direction */
|
||||
WORD32 coef_compress; /**< Are coeffs compressed? */
|
||||
WORD32 length; /**< Length, in bands */
|
||||
FLOAT64 a_coeffs[TNS_MAX_ORDER + 1]; /**< AR Coefficients */
|
||||
FLOAT64 k_coeffs[TNS_MAX_ORDER + 1]; /**< Reflection Coefficients */
|
||||
WORD32 index[TNS_MAX_ORDER + 1]; /**< Coefficient indices */
|
||||
} ia_tns_filter_data;
|
||||
|
||||
typedef struct {
|
||||
WORD32 n_filt; /**< number of filters */
|
||||
WORD32 coef_res; /**< Coefficient resolution */
|
||||
ia_tns_filter_data tns_filter[3]; /**< TNS filters */
|
||||
FLOAT64 tns_pred_gain;
|
||||
WORD32 tns_active;
|
||||
} ia_tns_window_data;
|
||||
|
||||
typedef struct {
|
||||
WORD32 tns_data_present;
|
||||
WORD32 tns_min_band_number_long;
|
||||
WORD32 tns_min_band_number_short;
|
||||
WORD32 tns_max_bands_long;
|
||||
WORD32 tns_max_bands_short;
|
||||
WORD32 tns_max_order_long;
|
||||
WORD32 tns_max_order_short;
|
||||
WORD32 lpc_start_band_long;
|
||||
WORD32 lpc_start_band_short;
|
||||
WORD32 lpc_stop_band_long;
|
||||
WORD32 lpc_stop_band_short;
|
||||
ia_tns_window_data window_data[NSHORT]; /**< TNS data per window */
|
||||
WORD32 *sfb_offset_table_short; /**< Scalefactor band offset table */
|
||||
WORD32 *sfb_offset_table_short_tcx; /**< Scalefactor band offset table */
|
||||
WORD32 *sfb_offset_table_long; /**< Scalefactor band offset table */
|
||||
WORD32 max_sfb_short; /**< max_sfb */
|
||||
WORD32 max_sfb_long; /**< max_sfb */
|
||||
FLOAT32 threshold;
|
||||
FLOAT32 tns_time_res_short;
|
||||
FLOAT32 tns_time_res_long;
|
||||
FLOAT64 win_short[8];
|
||||
FLOAT64 win_long[16];
|
||||
WORD32 block_type; /**< block type */
|
||||
WORD32 number_of_bands; /**< number of bands per window */
|
||||
FLOAT64 *spec; /**< Spectral data array */
|
||||
} ia_tns_info;
|
||||
|
||||
IA_ERRORCODE iusace_tns_init(WORD32 sampling_rate, WORD32 bit_rate, ia_tns_info *pstr_tns_info,
|
||||
WORD32 num_channels);
|
||||
|
||||
VOID iusace_tns_encode(ia_tns_info *pstr_tns_info_ch2, ia_tns_info *pstr_tns_info,
|
||||
FLOAT32 *ptr_sfb_energy, WORD32 w, WORD32 i_ch, WORD32 low_pass_line,
|
||||
FLOAT64 *ptr_scratch_tns_filter, WORD32 core_mode,
|
||||
FLOAT64 *ptr_tns_scratch);
|
||||
180
encoder/iusace_windowing.c
Normal file
180
encoder/iusace_windowing.c
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
IA_ERRORCODE iusace_calc_window(FLOAT64 **win, WORD32 win_sz, WORD32 win_sel) {
|
||||
switch (win_sel) {
|
||||
case WIN_SEL_0:
|
||||
switch (win_sz) {
|
||||
case WIN_LEN_96:
|
||||
*win = (FLOAT64 *)iexheaac_sine_win_96;
|
||||
break;
|
||||
case WIN_LEN_192:
|
||||
*win = (FLOAT64 *)iexheaac_sine_win_192;
|
||||
break;
|
||||
case WIN_LEN_128:
|
||||
*win = (FLOAT64 *)iusace_sine_win_128;
|
||||
break;
|
||||
case WIN_LEN_256:
|
||||
*win = (FLOAT64 *)iusace_sine_win_256;
|
||||
break;
|
||||
case WIN_LEN_768:
|
||||
*win = (FLOAT64 *)iexheaac_sine_win_768;
|
||||
break;
|
||||
case WIN_LEN_1024:
|
||||
*win = (FLOAT64 *)iusace_sine_win_1024;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WIN_SEL_1:
|
||||
switch (win_sz) {
|
||||
case WIN_LEN_96:
|
||||
*win = (FLOAT64 *)iexheaac_kbd_win_96;
|
||||
break;
|
||||
case WIN_LEN_128:
|
||||
*win = (FLOAT64 *)iusace_sine_win_128;
|
||||
break;
|
||||
case WIN_LEN_192:
|
||||
*win = (FLOAT64 *)iexheaac_kbd_win_192;
|
||||
break;
|
||||
case WIN_LEN_256:
|
||||
*win = (FLOAT64 *)iusace_kbd_win256;
|
||||
break;
|
||||
case WIN_LEN_768:
|
||||
*win = (FLOAT64 *)iexheaac_kbd_win_768;
|
||||
break;
|
||||
case WIN_LEN_1024:
|
||||
*win = (FLOAT64 *)iusace_kbd_win1024;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID iusace_windowing_long(FLOAT64 *ptr_overlap, FLOAT64 *ptr_win_long, FLOAT64 *ptr_win_buf,
|
||||
FLOAT64 *ptr_in_data, WORD32 n_long) {
|
||||
WORD32 i;
|
||||
FLOAT64 *ptr_win = ptr_win_long + n_long - 1;
|
||||
WORD32 data_size = (OVERLAP_WIN_SIZE_576 * n_long) / LEN_SUPERFRAME;
|
||||
|
||||
for (i = 0; i < n_long; i++) {
|
||||
ptr_win_buf[i] = ptr_overlap[i] * ptr_win_long[i];
|
||||
}
|
||||
|
||||
memcpy(ptr_overlap, ptr_overlap + n_long, data_size * sizeof(ptr_overlap[0]));
|
||||
memcpy(ptr_overlap + data_size, ptr_in_data, n_long * sizeof(ptr_overlap[0]));
|
||||
|
||||
for (i = 0; i < n_long; i++) {
|
||||
ptr_win_buf[i + n_long] = ptr_overlap[i] * (*ptr_win--);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_windowing_long_start(FLOAT64 *ptr_overlap, FLOAT64 *ptr_win_long,
|
||||
FLOAT64 *ptr_win_buf, FLOAT64 *ptr_in_data, WORD32 n_long,
|
||||
WORD32 nflat_ls, FLOAT64 *ptr_win_med, WORD32 win_sz) {
|
||||
WORD32 i;
|
||||
FLOAT64 *ptr_win = ptr_win_buf + 2 * n_long - 1;
|
||||
WORD32 data_size = (OVERLAP_WIN_SIZE_576 * n_long) / LEN_SUPERFRAME;
|
||||
|
||||
for (i = 0; i < n_long; i++) {
|
||||
ptr_win_buf[i] = ptr_overlap[i] * ptr_win_long[i];
|
||||
}
|
||||
|
||||
memcpy(ptr_overlap, ptr_overlap + n_long, data_size * sizeof(ptr_overlap[0]));
|
||||
memcpy(ptr_overlap + data_size, ptr_in_data, n_long * sizeof(ptr_overlap[0]));
|
||||
memcpy(ptr_win_buf + n_long, ptr_overlap, nflat_ls * sizeof(ptr_win_buf[0]));
|
||||
|
||||
ptr_win_med = ptr_win_med + win_sz - 1;
|
||||
win_sz = n_long - 2 * nflat_ls;
|
||||
|
||||
for (i = 0; i < win_sz; i++) {
|
||||
ptr_win_buf[i + n_long + nflat_ls] = ptr_overlap[i + nflat_ls] * (*ptr_win_med--);
|
||||
}
|
||||
|
||||
for (i = 0; i < nflat_ls; i++) {
|
||||
*ptr_win-- = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_windowing_long_stop(FLOAT64 *ptr_overlap, FLOAT64 *ptr_win_long, FLOAT64 *ptr_win_buf,
|
||||
FLOAT64 *ptr_in_data, WORD32 n_long, WORD32 nflat_ls,
|
||||
FLOAT64 *ptr_win_med, WORD32 win_sz) {
|
||||
WORD32 i;
|
||||
FLOAT64 *ptr_win = ptr_win_long + n_long - 1;
|
||||
WORD32 data_size = (OVERLAP_WIN_SIZE_576 * n_long) / LEN_SUPERFRAME;
|
||||
|
||||
memset(ptr_win_buf, 0, nflat_ls * sizeof(FLOAT64));
|
||||
for (i = 0; i < win_sz; i++) {
|
||||
ptr_win_buf[i + nflat_ls] = ptr_overlap[i + nflat_ls] * ptr_win_med[i];
|
||||
}
|
||||
|
||||
memcpy(ptr_win_buf + nflat_ls + win_sz, ptr_overlap + nflat_ls + win_sz,
|
||||
nflat_ls * sizeof(ptr_win_buf[0]));
|
||||
memcpy(ptr_overlap, ptr_overlap + n_long, data_size * sizeof(ptr_overlap[0]));
|
||||
memcpy(ptr_overlap + data_size, ptr_in_data, n_long * sizeof(ptr_overlap[0]));
|
||||
|
||||
for (i = 0; i < n_long; i++) {
|
||||
ptr_win_buf[i + n_long] = ptr_overlap[i] * (*ptr_win--);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID iusace_windowing_stop_start(FLOAT64 *ptr_overlap, FLOAT64 *ptr_win_buf, FLOAT64 *ptr_win_med,
|
||||
WORD32 win_sz, WORD32 n_long) {
|
||||
WORD32 i;
|
||||
FLOAT64 *win_gen;
|
||||
WORD32 wsize = (n_long - win_sz) >> 1;
|
||||
win_gen = ptr_win_med;
|
||||
|
||||
for (i = 0; i < win_sz; i++) {
|
||||
ptr_win_buf[wsize + i] = ptr_overlap[wsize + i] * (*win_gen++);
|
||||
}
|
||||
memcpy(ptr_win_buf + wsize, ptr_overlap + wsize, wsize * sizeof(FLOAT64));
|
||||
memcpy(ptr_win_buf + n_long, ptr_overlap + n_long, wsize * sizeof(FLOAT64));
|
||||
|
||||
win_gen = ptr_win_med + win_sz - 1;
|
||||
win_sz = n_long - 2 * wsize;
|
||||
|
||||
for (i = 0; i < win_sz; i++) {
|
||||
ptr_win_buf[n_long + wsize + i] = ptr_overlap[n_long + wsize + i] * (*win_gen--);
|
||||
}
|
||||
return;
|
||||
}
|
||||
34
encoder/iusace_windowing.h
Normal file
34
encoder/iusace_windowing.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
IA_ERRORCODE iusace_calc_window(FLOAT64 **win, WORD32 win_sz, WORD32 win_sel);
|
||||
VOID iusace_windowing_long(FLOAT64 *ptr_out_buf, FLOAT64 *ptr_win_long, FLOAT64 *ptr_win_buf,
|
||||
FLOAT64 *ptr_in_data, WORD32 n_long);
|
||||
VOID iusace_windowing_long_start(FLOAT64 *ptr_out_buf, FLOAT64 *ptr_win_long,
|
||||
FLOAT64 *ptr_win_buf, FLOAT64 *ptr_in_data, WORD32 n_long,
|
||||
WORD32 nflat_ls, FLOAT64 *ptr_win_med, WORD32 win_sz);
|
||||
VOID iusace_windowing_long_stop(FLOAT64 *ptr_out_buf, FLOAT64 *ptr_win_long, FLOAT64 *ptr_win_buf,
|
||||
FLOAT64 *ptr_in_data, WORD32 n_long, WORD32 nflat_ls,
|
||||
FLOAT64 *ptr_win_med, WORD32 win_sz);
|
||||
VOID iusace_windowing_stop_start(FLOAT64 *ptr_out_buf, FLOAT64 *ptr_win_buf, FLOAT64 *ptr_win_med,
|
||||
WORD32 win_sz, WORD32 n_long);
|
||||
WORD32 iusace_fd_mdct(ia_usac_data_struct *pstr_usac_data,
|
||||
ia_usac_encoder_config_struct *pstr_usac_config, WORD32 ch_idx);
|
||||
740
encoder/iusace_write_bitstream.c
Normal file
740
encoder/iusace_write_bitstream.c
Normal file
|
|
@ -0,0 +1,740 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_arith_enc.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
#if DEBUG_DUMP
|
||||
extern FILE *out_file;
|
||||
#endif
|
||||
|
||||
WORD32 iusace_write_scf_data(ia_bit_buf_struct *it_bit_buf, WORD32 max_sfb, WORD32 num_sfb,
|
||||
const WORD32 *ptr_scale_factors, WORD32 num_win_grps,
|
||||
WORD32 global_gain, const WORD32 huff_tab[CODE_BOOK_ALPHA_LAV][2]) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 i, j, bit_count = 0;
|
||||
WORD32 diff, length, codeword;
|
||||
WORD32 index = 0;
|
||||
WORD32 sf_out = 0;
|
||||
WORD32 sf_not_out = 0;
|
||||
WORD32 previous_scale_factor = global_gain;
|
||||
|
||||
for (j = 0; j < num_win_grps; j++) {
|
||||
for (i = 0; i < max_sfb; i++) {
|
||||
if (!((i == 0) && (j == 0))) {
|
||||
diff = ptr_scale_factors[index] - previous_scale_factor;
|
||||
length = huff_tab[diff + 60][0];
|
||||
bit_count += length;
|
||||
previous_scale_factor = ptr_scale_factors[index];
|
||||
if (write_flag == 1) {
|
||||
codeword = huff_tab[diff + 60][1];
|
||||
iusace_write_bits_buf(it_bit_buf, codeword, (UWORD8)length);
|
||||
sf_out++;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
for (; i < num_sfb; i++) {
|
||||
sf_not_out++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return (bit_count);
|
||||
}
|
||||
|
||||
WORD32 iusace_write_ms_data(ia_bit_buf_struct *it_bit_buf, WORD32 ms_mask,
|
||||
WORD32 ms_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG], WORD32 num_win_grps,
|
||||
WORD32 nr_of_sfb) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 i, j;
|
||||
WORD32 ms_mask_write = ms_mask;
|
||||
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, ms_mask_write, 2);
|
||||
bit_count += 2;
|
||||
|
||||
if (ms_mask_write == 1) {
|
||||
for (i = 0; i < num_win_grps; i++) {
|
||||
for (j = 0; j < nr_of_sfb; j++) {
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, ms_used[i][j], 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
|
||||
WORD32 iusace_write_tns_data(ia_bit_buf_struct *it_bit_buf, ia_tns_info *pstr_tns_info,
|
||||
WORD32 window_sequence, WORD32 core_mode) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 num_windows;
|
||||
WORD32 len_tns_nfilt;
|
||||
WORD32 len_tns_length;
|
||||
WORD32 len_tns_order;
|
||||
WORD32 filt;
|
||||
WORD32 res_bits;
|
||||
UWORD32 coeff;
|
||||
WORD32 w;
|
||||
|
||||
if (window_sequence == EIGHT_SHORT_SEQUENCE) {
|
||||
num_windows = MAX_SHORT_WINDOWS;
|
||||
len_tns_nfilt = 1;
|
||||
len_tns_length = 4;
|
||||
len_tns_order = 3;
|
||||
} else {
|
||||
num_windows = 1;
|
||||
len_tns_nfilt = 2;
|
||||
len_tns_length = 6;
|
||||
len_tns_order = 4;
|
||||
}
|
||||
if (core_mode == 1) {
|
||||
num_windows = 1;
|
||||
}
|
||||
|
||||
for (w = 0; w < num_windows; w++) {
|
||||
ia_tns_window_data *ptr_win_data = &pstr_tns_info->window_data[w];
|
||||
WORD32 n_filt = ptr_win_data->n_filt;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, n_filt, (UWORD8)len_tns_nfilt);
|
||||
}
|
||||
bit_count += len_tns_nfilt;
|
||||
if (n_filt) {
|
||||
res_bits = ptr_win_data->coef_res;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, res_bits - DEF_TNS_RES_OFFSET, 1);
|
||||
}
|
||||
bit_count += 1;
|
||||
for (filt = 0; filt < n_filt; filt++) {
|
||||
ia_tns_filter_data *ptr_tns_filt = &ptr_win_data->tns_filter[filt];
|
||||
WORD32 order = ptr_tns_filt->order;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, ptr_tns_filt->length, (UWORD8)len_tns_length);
|
||||
iusace_write_bits_buf(it_bit_buf, order, (UWORD8)len_tns_order);
|
||||
}
|
||||
bit_count += (len_tns_length + len_tns_order);
|
||||
if (order) {
|
||||
WORD32 i;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, ptr_tns_filt->direction, 1);
|
||||
iusace_write_bits_buf(it_bit_buf, ptr_tns_filt->coef_compress, 1);
|
||||
}
|
||||
bit_count += 2;
|
||||
for (i = 1; i <= order; i++) {
|
||||
if (write_flag) {
|
||||
coeff = (UWORD32)(ptr_tns_filt->index[i]) & ((1 << res_bits) - 1);
|
||||
iusace_write_bits_buf(it_bit_buf, coeff, (UWORD8)res_bits);
|
||||
}
|
||||
bit_count += res_bits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
|
||||
static WORD32 iusace_calc_grouping_bits(const WORD32 *ptr_win_grp_len, WORD32 num_win_grps) {
|
||||
WORD32 grouping_bits = 0;
|
||||
WORD32 tmp[8] = {0};
|
||||
WORD32 i, j;
|
||||
WORD32 index = 0;
|
||||
|
||||
for (i = 0; i < num_win_grps; i++) {
|
||||
for (j = 0; j < ptr_win_grp_len[i]; j++) {
|
||||
tmp[index++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < 8; i++) {
|
||||
grouping_bits = grouping_bits << 1;
|
||||
if (tmp[i] == tmp[i - 1]) {
|
||||
grouping_bits++;
|
||||
}
|
||||
}
|
||||
|
||||
return (grouping_bits);
|
||||
}
|
||||
|
||||
WORD32 iusace_write_ics_info(ia_bit_buf_struct *it_bit_buf, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 ch) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 win_seq = 0;
|
||||
WORD32 grouping_bits = 0;
|
||||
WORD32 max_sfb = pstr_sfb_prms->max_sfb[ch];
|
||||
WORD32 window_sequence = pstr_sfb_prms->window_sequence[ch];
|
||||
WORD32 window_shape = pstr_sfb_prms->window_shape[ch];
|
||||
WORD32 num_win_grps = pstr_sfb_prms->num_window_groups[ch];
|
||||
|
||||
switch (window_sequence) {
|
||||
case EIGHT_SHORT_SEQUENCE:
|
||||
win_seq = 2;
|
||||
break;
|
||||
case ONLY_LONG_SEQUENCE:
|
||||
win_seq = 0;
|
||||
break;
|
||||
case LONG_START_SEQUENCE:
|
||||
case STOP_START_SEQUENCE:
|
||||
win_seq = 1;
|
||||
break;
|
||||
case LONG_STOP_SEQUENCE:
|
||||
win_seq = 3;
|
||||
break;
|
||||
default:
|
||||
win_seq = 3;
|
||||
break;
|
||||
}
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, win_seq, 2);
|
||||
bit_count += 2;
|
||||
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, window_shape, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (window_sequence == EIGHT_SHORT_SEQUENCE) {
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, max_sfb, 4);
|
||||
bit_count += 4;
|
||||
|
||||
grouping_bits =
|
||||
iusace_calc_grouping_bits(pstr_sfb_prms->window_group_length[ch], num_win_grps);
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, grouping_bits, 7);
|
||||
bit_count += 7;
|
||||
} else {
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, max_sfb, 6);
|
||||
bit_count += 6;
|
||||
}
|
||||
|
||||
return (bit_count);
|
||||
}
|
||||
|
||||
WORD32 iusace_write_cplx_pred_data(ia_bit_buf_struct *it_bit_buf, WORD32 num_win_grps,
|
||||
WORD32 num_sfb, WORD32 complex_coef,
|
||||
WORD32 pred_coeffs_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 pred_coeffs_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
const WORD32 huff_tab[CODE_BOOK_ALPHA_LAV][2],
|
||||
WORD32 const usac_independency_flg, WORD32 pred_dir,
|
||||
WORD32 cplx_pred_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 cplx_pred_all, WORD32 *ptr_prev_alpha_coeff_re,
|
||||
WORD32 *ptr_prev_alpha_coeff_im, WORD32 *delta_code_time) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 i, j;
|
||||
WORD32 g;
|
||||
WORD32 sfb;
|
||||
const WORD32 sfb_per_pred_band = 2;
|
||||
WORD32 length_temp1_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
length_temp2_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
length_temp1_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
length_temp2_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG];
|
||||
WORD32 code_word_temp1_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
code_word_temp2_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
code_word_temp1_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
code_word_temp2_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG];
|
||||
WORD32 length_tot1 = 0, length_tot2 = 0;
|
||||
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, cplx_pred_all, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (cplx_pred_all == 0) {
|
||||
for (g = 0; g < num_win_grps; g++) {
|
||||
for (sfb = 0; sfb < num_sfb; sfb += sfb_per_pred_band) {
|
||||
iusace_write_bits_buf(it_bit_buf, cplx_pred_used[g][sfb], 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, pred_dir, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, complex_coef, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (complex_coef) {
|
||||
if (!usac_independency_flg) {
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, 1, 1); /* use_prev_frame */
|
||||
bit_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (usac_independency_flg) {
|
||||
*delta_code_time = 0;
|
||||
}
|
||||
|
||||
/* Switching mechanism for delta_code_time */
|
||||
WORD32 prev_pred_coeff_re_temp1 = 0, prev_pred_coeff_re_temp2 = 0;
|
||||
WORD32 diff_pred_coeff_re_temp1 = 0, diff_pred_coeff_re_temp2 = 0;
|
||||
WORD32 prev_pred_coeff_im_temp1 = 0, prev_pred_coeff_im_temp2 = 0;
|
||||
WORD32 diff_pred_coeff_im_temp1 = 0, diff_pred_coeff_im_temp2 = 0;
|
||||
|
||||
for (i = 0; i < num_win_grps; i++) {
|
||||
/* delta_code_time = 0*/
|
||||
prev_pred_coeff_re_temp1 = 0;
|
||||
if (complex_coef == 1) {
|
||||
prev_pred_coeff_im_temp1 = 0;
|
||||
}
|
||||
|
||||
for (j = 0; j < num_sfb; j += 2) {
|
||||
if (!usac_independency_flg) {
|
||||
/* delta_code_time = 1*/
|
||||
if (i > 0) {
|
||||
prev_pred_coeff_re_temp2 = pred_coeffs_re[i - 1][j];
|
||||
if (complex_coef == 1) {
|
||||
prev_pred_coeff_im_temp2 = pred_coeffs_im[i - 1][j];
|
||||
}
|
||||
} else {
|
||||
prev_pred_coeff_re_temp2 = ptr_prev_alpha_coeff_re[j];
|
||||
if (complex_coef == 1) {
|
||||
prev_pred_coeff_im_temp2 = ptr_prev_alpha_coeff_im[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cplx_pred_used[i][j] == 1) {
|
||||
/*Differential Huffman coding of real prediction coefficients*/
|
||||
diff_pred_coeff_re_temp1 =
|
||||
pred_coeffs_re[i][j] - prev_pred_coeff_re_temp1; /* delta_code_time = 0 */
|
||||
prev_pred_coeff_re_temp1 = pred_coeffs_re[i][j]; /* delta_code_time = 0 */
|
||||
if (!usac_independency_flg) {
|
||||
diff_pred_coeff_re_temp2 =
|
||||
pred_coeffs_re[i][j] - prev_pred_coeff_re_temp2; /* delta_code_time = 1 */
|
||||
}
|
||||
|
||||
/* delta_code_time = 0 */
|
||||
length_temp1_re[i][j] = huff_tab[diff_pred_coeff_re_temp1 + 60][0];
|
||||
code_word_temp1_re[i][j] = huff_tab[diff_pred_coeff_re_temp1 + 60][1];
|
||||
|
||||
length_tot1 += length_temp1_re[i][j];
|
||||
|
||||
if (!usac_independency_flg) {
|
||||
/*delta_code_time = 1 */
|
||||
length_temp2_re[i][j] = huff_tab[diff_pred_coeff_re_temp2 + 60][0];
|
||||
code_word_temp2_re[i][j] = huff_tab[diff_pred_coeff_re_temp2 + 60][1];
|
||||
|
||||
length_tot2 += length_temp2_re[i][j];
|
||||
}
|
||||
|
||||
if (complex_coef == 1) {
|
||||
/*Differential Huffman coding of imaginary prediction coefficients*/
|
||||
diff_pred_coeff_im_temp1 =
|
||||
pred_coeffs_im[i][j] - prev_pred_coeff_im_temp1; /* delta_code_time = 0 */
|
||||
prev_pred_coeff_im_temp1 = pred_coeffs_im[i][j]; /* delta_code_time = 0*/
|
||||
|
||||
if (!usac_independency_flg) {
|
||||
diff_pred_coeff_im_temp2 =
|
||||
pred_coeffs_im[i][j] - prev_pred_coeff_im_temp2; /* delta_code_time = 1 */
|
||||
}
|
||||
|
||||
/*delta_code_time = 0*/
|
||||
length_temp1_im[i][j] = huff_tab[diff_pred_coeff_im_temp1 + 60][0];
|
||||
code_word_temp1_im[i][j] = huff_tab[diff_pred_coeff_im_temp1 + 60][1];
|
||||
|
||||
length_tot1 += length_temp1_im[i][j];
|
||||
|
||||
if (!usac_independency_flg) {
|
||||
/*delta_code_time = 1*/
|
||||
length_temp2_im[i][j] = huff_tab[diff_pred_coeff_im_temp2 + 60][0];
|
||||
code_word_temp2_im[i][j] = huff_tab[diff_pred_coeff_im_temp2 + 60][1];
|
||||
|
||||
length_tot2 += length_temp2_im[i][j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pred_coeffs_re[i][j] = 0;
|
||||
/*delta_code_time = 0*/
|
||||
prev_pred_coeff_re_temp1 = pred_coeffs_re[i][j];
|
||||
if (complex_coef == 1) {
|
||||
pred_coeffs_im[i][j] = 0;
|
||||
/*delta_code_time = 0*/
|
||||
prev_pred_coeff_im_temp1 = pred_coeffs_im[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
ptr_prev_alpha_coeff_re[j] = pred_coeffs_re[i][j];
|
||||
if (complex_coef == 1) {
|
||||
ptr_prev_alpha_coeff_im[j] = pred_coeffs_im[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (j = num_sfb; j < MAX_SFB_LONG; j++) {
|
||||
pred_coeffs_re[i][j] = 0;
|
||||
ptr_prev_alpha_coeff_re[j] = 0;
|
||||
if (complex_coef == 1) {
|
||||
pred_coeffs_im[i][j] = 0;
|
||||
ptr_prev_alpha_coeff_im[j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Make a decison on the value of delta_code_time per frame */
|
||||
if (!usac_independency_flg) {
|
||||
// Compare the code-word lengths
|
||||
if (length_tot1 <= length_tot2) {
|
||||
*delta_code_time = 0;
|
||||
} else {
|
||||
*delta_code_time = 1;
|
||||
}
|
||||
|
||||
/* Write the value of delta_code_time to bitstream */
|
||||
if (write_flag) iusace_write_bits_buf(it_bit_buf, *delta_code_time, 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
|
||||
if (*delta_code_time == 0) {
|
||||
for (i = 0; i < num_win_grps; i++) {
|
||||
for (j = 0; j < num_sfb; j += 2) {
|
||||
if (cplx_pred_used[i][j] == 1) {
|
||||
if (write_flag)
|
||||
iusace_write_bits_buf(it_bit_buf, code_word_temp1_re[i][j],
|
||||
(UWORD8)length_temp1_re[i][j]);
|
||||
bit_count += length_temp1_re[i][j];
|
||||
|
||||
if (complex_coef == 1) {
|
||||
if (write_flag)
|
||||
iusace_write_bits_buf(it_bit_buf, code_word_temp1_im[i][j],
|
||||
(UWORD8)length_temp1_im[i][j]);
|
||||
bit_count += length_temp1_im[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < num_win_grps; i++) {
|
||||
for (j = 0; j < num_sfb; j += 2) {
|
||||
if (cplx_pred_used[i][j] == 1) {
|
||||
if (write_flag)
|
||||
iusace_write_bits_buf(it_bit_buf, code_word_temp2_re[i][j],
|
||||
(UWORD8)length_temp2_re[i][j]);
|
||||
bit_count += length_temp2_re[i][j];
|
||||
|
||||
if (complex_coef == 1) {
|
||||
if (write_flag)
|
||||
iusace_write_bits_buf(it_bit_buf, code_word_temp2_im[i][j],
|
||||
(UWORD8)length_temp2_im[i][j]);
|
||||
bit_count += length_temp2_im[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
|
||||
WORD32 iusace_write_cpe(ia_sfb_params_struct *pstr_sfb_prms, ia_bit_buf_struct *it_bit_buf,
|
||||
WORD32 *tns_data_present, WORD32 const usac_independency_flg,
|
||||
ia_usac_encoder_config_struct *pstr_usac_config,
|
||||
ia_usac_data_struct *pstr_usac_data, WORD32 ch) {
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 ms_mask = pstr_usac_data->str_ms_info[ch].ms_mask;
|
||||
WORD32 common_max_sfb = 1;
|
||||
WORD32 tns_active = tns_data_present[0] || tns_data_present[1];
|
||||
ia_tns_info *pstr_tns_info = pstr_usac_data->pstr_tns_info[ch];
|
||||
(VOID) pstr_usac_config;
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, tns_active, 1);
|
||||
bit_count += 1;
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_sfb_prms->common_win[ch], 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (pstr_sfb_prms->max_sfb[ch] != pstr_sfb_prms->max_sfb[ch + 1]) {
|
||||
common_max_sfb = 0;
|
||||
}
|
||||
|
||||
if (pstr_sfb_prms->common_win[ch]) {
|
||||
bit_count += iusace_write_ics_info(it_bit_buf, pstr_sfb_prms, ch);
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, common_max_sfb, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (common_max_sfb == 0) {
|
||||
if (pstr_sfb_prms->window_sequence[ch] != EIGHT_SHORT_SEQUENCE) {
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_sfb_prms->max_sfb[ch + 1], 6);
|
||||
bit_count += 6;
|
||||
} else {
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_sfb_prms->max_sfb[ch + 1], 4);
|
||||
bit_count += 4;
|
||||
}
|
||||
}
|
||||
|
||||
pstr_sfb_prms->max_sfb_ste = MAX(pstr_sfb_prms->max_sfb[ch], pstr_sfb_prms->max_sfb[ch + 1]);
|
||||
|
||||
bit_count +=
|
||||
iusace_write_ms_data(it_bit_buf, ms_mask, pstr_usac_data->str_ms_info[ch].ms_used,
|
||||
pstr_sfb_prms->num_window_groups[ch], pstr_sfb_prms->max_sfb_ste);
|
||||
|
||||
{
|
||||
if (ms_mask == 3) {
|
||||
bit_count += iusace_write_cplx_pred_data(
|
||||
it_bit_buf, pstr_sfb_prms->num_window_groups[ch], pstr_sfb_prms->max_sfb_ste,
|
||||
pstr_usac_data->complex_coef[ch], pstr_usac_data->pred_coef_re[ch],
|
||||
pstr_usac_data->pred_coef_im[ch], iusace_huffman_code_table, usac_independency_flg,
|
||||
pstr_usac_data->pred_dir_idx[ch], pstr_usac_data->cplx_pred_used[ch],
|
||||
pstr_usac_data->cplx_pred_all[ch], pstr_usac_data->pred_coef_re_prev[ch],
|
||||
pstr_usac_data->pred_coef_im_prev[ch], &pstr_usac_data->delta_code_time[ch]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tns_active) {
|
||||
WORD32 common_tns = 0;
|
||||
WORD32 tns_on_lr = 1;
|
||||
WORD32 tns_present_both = tns_data_present[0] && tns_data_present[1];
|
||||
WORD32 tns_data_present1 = tns_data_present[1];
|
||||
|
||||
if (pstr_sfb_prms->common_win[ch]) {
|
||||
iusace_write_bits_buf(it_bit_buf, common_tns, 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, tns_on_lr, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (common_tns) {
|
||||
bit_count +=
|
||||
iusace_write_tns_data(it_bit_buf, pstr_tns_info, pstr_sfb_prms->window_sequence[ch], 0);
|
||||
} else {
|
||||
iusace_write_bits_buf(it_bit_buf, tns_present_both, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (!tns_present_both) {
|
||||
iusace_write_bits_buf(it_bit_buf, tns_data_present1, 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bit_count);
|
||||
}
|
||||
|
||||
WORD32 iusace_write_fd_data(ia_bit_buf_struct *it_bit_buf, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 num_fac_bits, WORD32 usac_independency_flg,
|
||||
ia_usac_data_struct *pstr_usac_data,
|
||||
ia_usac_encoder_config_struct *pstr_usac_config, WORD32 ch_idx,
|
||||
WORD32 ele_id, WORD32 idx) {
|
||||
WORD32 bit_count = 0;
|
||||
WORD32 fac_data_present = (num_fac_bits > 0) ? 1 : 0;
|
||||
WORD16 *ptr_fac_data = pstr_usac_data->fac_out_stream[ch_idx];
|
||||
|
||||
WORD32 is_noise_filling = pstr_usac_data->noise_filling[ele_id];
|
||||
WORD32 common_window = pstr_sfb_prms->common_win[ch_idx];
|
||||
ia_usac_quant_info_struct *pstr_quant_info = &(pstr_usac_data->str_quant_info[idx]);
|
||||
ia_tns_info *pstr_tns_info = pstr_usac_data->pstr_tns_info[ch_idx];
|
||||
WORD32 global_gain = pstr_usac_data->str_quant_info[idx].scale_factor[0];
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, global_gain, 8);
|
||||
bit_count += 8;
|
||||
|
||||
if (is_noise_filling) {
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_usac_data->noise_level[idx], 3);
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_usac_data->noise_offset[idx], 5);
|
||||
bit_count += 8;
|
||||
}
|
||||
|
||||
if (!common_window) {
|
||||
bit_count += iusace_write_ics_info(it_bit_buf, pstr_sfb_prms, ch_idx);
|
||||
}
|
||||
|
||||
#if DEBUG_DUMP
|
||||
WORD32 bit_count_start = bit_count;
|
||||
#endif
|
||||
|
||||
bit_count += iusace_write_scf_data(
|
||||
it_bit_buf, pstr_sfb_prms->max_sfb[ch_idx], pstr_sfb_prms->num_sfb[ch_idx],
|
||||
pstr_quant_info->scale_factor, pstr_sfb_prms->num_window_groups[ch_idx], global_gain,
|
||||
iusace_huffman_code_table);
|
||||
|
||||
#if DEBUG_DUMP
|
||||
WORD32 bit_count_mid_1 = bit_count;
|
||||
#endif
|
||||
|
||||
if (pstr_tns_info != NULL && pstr_tns_info->tns_data_present == 1) {
|
||||
bit_count += iusace_write_tns_data(it_bit_buf, pstr_tns_info,
|
||||
pstr_sfb_prms->window_sequence[ch_idx], 0);
|
||||
}
|
||||
|
||||
if (!usac_independency_flg) {
|
||||
iusace_write_bits_buf(it_bit_buf, pstr_quant_info->reset, 1);
|
||||
bit_count += 1;
|
||||
}
|
||||
|
||||
#if DEBUG_DUMP
|
||||
WORD32 bit_count_mid_2 = bit_count;
|
||||
#endif
|
||||
if (pstr_quant_info->max_spec_coeffs == FRAME_LEN_SHORT_768) {
|
||||
pstr_quant_info->max_spec_coeffs = pstr_quant_info->max_spec_coeffs;
|
||||
}
|
||||
bit_count += iusace_arith_enc_spec(
|
||||
it_bit_buf, pstr_sfb_prms->window_sequence[ch_idx], pstr_quant_info->quant_degroup,
|
||||
pstr_quant_info->max_spec_coeffs, pstr_quant_info->c_pres, pstr_quant_info->c_prev,
|
||||
&(pstr_quant_info->arith_size_prev), usac_independency_flg || pstr_quant_info->reset,
|
||||
pstr_usac_config->ccfl);
|
||||
|
||||
#if DEBUG_DUMP
|
||||
WORD32 bit_count_end = bit_count;
|
||||
#endif
|
||||
|
||||
iusace_write_bits_buf(it_bit_buf, fac_data_present, 1);
|
||||
bit_count += 1;
|
||||
|
||||
if (fac_data_present) {
|
||||
WORD32 i;
|
||||
for (i = 0; i < num_fac_bits; i += 8) {
|
||||
WORD32 bits_to_write = MIN(8, num_fac_bits - i);
|
||||
iusace_write_bits_buf(it_bit_buf, ptr_fac_data[i / 8] >> (8 - bits_to_write),
|
||||
(UWORD8)bits_to_write);
|
||||
}
|
||||
bit_count += num_fac_bits;
|
||||
}
|
||||
|
||||
#if DEBUG_DUMP
|
||||
fprintf(out_file, "%d\t",
|
||||
bit_count - (bit_count_mid_1 - bit_count_start) - (bit_count_end - bit_count_mid_2));
|
||||
#endif
|
||||
|
||||
return (bit_count);
|
||||
}
|
||||
|
||||
WORD32 iusace_count_fd_bits(ia_sfb_params_struct *pstr_sfb_prms,
|
||||
ia_usac_data_struct *pstr_usac_data, WORD32 usac_independency_flg,
|
||||
ia_usac_encoder_config_struct *pstr_usac_config, WORD32 ch_idx,
|
||||
WORD32 idx) {
|
||||
WORD32 bit_count = 0;
|
||||
ia_usac_quant_info_struct *pstr_quant_info = &pstr_usac_data->str_quant_info[idx];
|
||||
WORD32 window_sequence = pstr_sfb_prms->window_sequence[ch_idx];
|
||||
WORD32 global_gain = pstr_quant_info->scale_factor[0];
|
||||
WORD32 max_sfb = pstr_sfb_prms->max_sfb[ch_idx];
|
||||
WORD32 num_sfb = pstr_sfb_prms->num_sfb[ch_idx];
|
||||
WORD32 num_win_grps = pstr_sfb_prms->num_window_groups[ch_idx];
|
||||
|
||||
bit_count += iusace_write_scf_data(NULL, max_sfb, num_sfb, pstr_quant_info->scale_factor,
|
||||
num_win_grps, global_gain, iusace_huffman_code_table);
|
||||
|
||||
WORD32 temp_c_pres[516], temp_c_prev[516], temp_size = pstr_quant_info->arith_size_prev;
|
||||
memcpy(temp_c_pres, pstr_quant_info->c_pres, 516 * sizeof(pstr_quant_info->c_pres[0]));
|
||||
memcpy(temp_c_prev, pstr_quant_info->c_prev, 516 * sizeof(pstr_quant_info->c_prev[0]));
|
||||
bit_count += iusace_arith_enc_spec(
|
||||
NULL, window_sequence, pstr_quant_info->quant_degroup, pstr_quant_info->max_spec_coeffs,
|
||||
temp_c_pres, temp_c_prev, &(temp_size), usac_independency_flg || pstr_quant_info->reset,
|
||||
pstr_usac_config->ccfl);
|
||||
|
||||
return (bit_count);
|
||||
}
|
||||
|
||||
WORD32 iusace_write_fill_ele(ia_bit_buf_struct *it_bit_buf, WORD32 num_bits) {
|
||||
WORD32 write_flag = (it_bit_buf != NULL);
|
||||
WORD32 bit_count = 0;
|
||||
|
||||
if (num_bits <= 8) {
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 0, 1);
|
||||
}
|
||||
bit_count++;
|
||||
num_bits--;
|
||||
} else {
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 1, 1);
|
||||
}
|
||||
bit_count++;
|
||||
num_bits--;
|
||||
|
||||
if (num_bits <= 8) {
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 1, 1);
|
||||
}
|
||||
bit_count++;
|
||||
num_bits--;
|
||||
} else {
|
||||
WORD32 bytes_to_write = 0;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 0, 1);
|
||||
}
|
||||
bit_count++;
|
||||
num_bits--;
|
||||
bytes_to_write = num_bits >> 3;
|
||||
|
||||
if (bytes_to_write > 255) {
|
||||
bytes_to_write -= 3;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 255, 8);
|
||||
}
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, bytes_to_write - 253, 16);
|
||||
}
|
||||
bit_count += 24;
|
||||
num_bits -= 24;
|
||||
} else {
|
||||
bytes_to_write--;
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, bytes_to_write, 8);
|
||||
}
|
||||
bit_count += 8;
|
||||
num_bits -= 8;
|
||||
}
|
||||
|
||||
while (bytes_to_write > 0) {
|
||||
if (write_flag) {
|
||||
iusace_write_bits_buf(it_bit_buf, 0xA9, 8);
|
||||
}
|
||||
bit_count += 8;
|
||||
num_bits -= 8;
|
||||
bytes_to_write--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bit_count;
|
||||
}
|
||||
62
encoder/iusace_write_bitstream.h
Normal file
62
encoder/iusace_write_bitstream.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
WORD32 iusace_write_ics_info(ia_bit_buf_struct *it_bit_buf, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 ch);
|
||||
|
||||
WORD32 iusace_write_cpe(ia_sfb_params_struct *pstr_sfb_prms, ia_bit_buf_struct *it_bit_buf,
|
||||
WORD32 *tns_data_present, WORD32 const usac_independency_flg,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config,
|
||||
ia_usac_data_struct *ptr_usac_data, WORD32 ch);
|
||||
|
||||
WORD32 iusace_write_fd_data(ia_bit_buf_struct *it_bit_buf, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 num_fac_bits, WORD32 usac_independency_flg,
|
||||
ia_usac_data_struct *ptr_usac_data,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config, WORD32 ch_idx,
|
||||
WORD32 ele_id, WORD32 idx);
|
||||
|
||||
WORD32 iusace_count_fd_bits(ia_sfb_params_struct *pstr_sfb_prms,
|
||||
ia_usac_data_struct *ptr_usac_data, WORD32 usac_independency_flg,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config, WORD32 ch_idx,
|
||||
WORD32 idx);
|
||||
|
||||
WORD32 iusace_write_fill_ele(ia_bit_buf_struct *it_bit_buf, WORD32 num_bits);
|
||||
|
||||
WORD32 iusace_write_tns_data(ia_bit_buf_struct *it_bit_buf, ia_tns_info *pstr_tns_info,
|
||||
WORD32 window_sequence, WORD32 core_mode);
|
||||
|
||||
WORD32 iusace_write_cplx_pred_data(ia_bit_buf_struct *it_bit_buf, WORD32 num_win_grps,
|
||||
WORD32 num_sfb, WORD32 complex_coef,
|
||||
WORD32 pred_coeffs_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 pred_coeffs_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
const WORD32 huff_tab[CODE_BOOK_ALPHA_LAV][2],
|
||||
WORD32 const usac_independency_flg, WORD32 pred_dir,
|
||||
WORD32 cplx_pred_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 cplx_pred_all, WORD32 *ptr_prev_alpha_coeff_re,
|
||||
WORD32 *ptr_prev_alpha_coeff_im, WORD32 *delta_code_time);
|
||||
|
||||
WORD32 iusace_write_ms_data(ia_bit_buf_struct *it_bit_buf, WORD32 ms_mask,
|
||||
WORD32 ms_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG], WORD32 num_win_grps,
|
||||
WORD32 nr_of_sfb);
|
||||
|
||||
WORD32 iusace_write_scf_data(ia_bit_buf_struct *it_bit_buf, WORD32 max_sfb, WORD32 num_sfb,
|
||||
const WORD32 *scale_factors, WORD32 num_win_grps, WORD32 global_gain,
|
||||
const WORD32 huff_tab[CODE_BOOK_ALPHA_LAV][2]);
|
||||
|
|
@ -76,7 +76,6 @@ typedef struct {
|
|||
WORD32 num_bit; /* number of bits in buffer */
|
||||
WORD32 size; /* buffer size in bytes */
|
||||
WORD32 current_bit; /* current bit position in bit stream */
|
||||
WORD32 numByte; /* number of bytes read/written (only file) */
|
||||
} ixheaace_bitstream_params;
|
||||
|
||||
/* bits in byte (char) */
|
||||
|
|
@ -115,8 +114,8 @@ typedef struct {
|
|||
|
||||
#define NUM_CHANS_MONO (1)
|
||||
#define NUM_CHANS_STEREO (2)
|
||||
#define MAX_NUM_CHANNELS (6)
|
||||
#define MIN_NUM_CHANNELS (1)
|
||||
#define MAX_NUM_CORE_CODER_CHANNELS (6)
|
||||
#define MIN_NUM_CORE_CODER_CHANNELS (1)
|
||||
/*-------------------------- defines --------------------------------------*/
|
||||
|
||||
#define BUFFERSIZE 1024 /* anc data */
|
||||
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "ixheaace_psy_const.h"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -79,6 +79,7 @@ typedef struct {
|
|||
WORD32 frame_cmd_flag;
|
||||
WORD32 out_bytes_flag;
|
||||
WORD32 user_tns_flag;
|
||||
WORD32 user_esbr_flag;
|
||||
WORD32 aot;
|
||||
WORD32 i_mps_tree_config;
|
||||
WORD32 esbr_flag;
|
||||
|
|
@ -91,6 +92,17 @@ typedef struct {
|
|||
WORD32 i_use_mps;
|
||||
WORD32 i_use_adts;
|
||||
WORD32 i_use_es;
|
||||
WORD32 usac_en;
|
||||
WORD32 codec_mode;
|
||||
WORD32 cplx_pred;
|
||||
WORD32 ccfl_idx;
|
||||
WORD32 pvc_active;
|
||||
WORD32 harmonic_sbr;
|
||||
WORD32 inter_tes_active;
|
||||
ia_drc_input_config str_drc_cfg;
|
||||
FLAG use_drc_element;
|
||||
WORD32 drc_frame_size;
|
||||
WORD32 hq_esbr;
|
||||
FLAG write_program_config_element;
|
||||
ixheaace_aac_enc_config aac_config;
|
||||
} ixheaace_input_config;
|
||||
|
|
|
|||
|
|
@ -37,3 +37,10 @@
|
|||
|
||||
#define IA_LAST_COMP_APIVERSION \
|
||||
IA_MAKE_VERSION_STR(IA_LASTCOMP_APIVERSION_MAJOR, IA_LASTCOMP_APIVERSION_MINOR)
|
||||
|
||||
IA_ERRORCODE ixheaace_usac_encode(FLOAT32 **ptr_input,
|
||||
ia_usac_encoder_config_struct *ptr_usac_config,
|
||||
ia_usac_data_struct *pstr_state,
|
||||
ixheaace_audio_specific_config_struct *pstr_asc,
|
||||
ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ixheaace_pstr_sbr_enc ptr_env_encoder, FLOAT32 **ptr_drc_inp);
|
||||
|
|
|
|||
|
|
@ -20,14 +20,26 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include "iusace_type_def.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
|
||||
/* DRC */
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
#include "iusace_cnst.h"
|
||||
|
||||
#include "ixheaace_api.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "iusace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_rom.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
|
|
@ -48,7 +60,208 @@ static WORD32 ixheaace_spatial_specific_config(ia_bit_buf_struct *pstr_it_bit_bu
|
|||
|
||||
return bit_cnt;
|
||||
}
|
||||
static WORD32 iusace_config_extension(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_usac_config_struct *pstr_usac_config) {
|
||||
WORD32 bit_cnt = 0;
|
||||
UWORD32 i, j;
|
||||
UWORD32 fill_byte_val = 0xa5;
|
||||
|
||||
bit_cnt += iusace_write_escape_value(pstr_it_bit_buff,
|
||||
pstr_usac_config->num_config_extensions - 1, 2, 4, 8);
|
||||
|
||||
for (j = 0; j < pstr_usac_config->num_config_extensions; j++) {
|
||||
bit_cnt += iusace_write_escape_value(pstr_it_bit_buff,
|
||||
pstr_usac_config->usac_config_ext_type[j], 4, 8, 16);
|
||||
|
||||
bit_cnt += iusace_write_escape_value(pstr_it_bit_buff,
|
||||
pstr_usac_config->usac_config_ext_len[j], 4, 8, 16);
|
||||
|
||||
switch (pstr_usac_config->usac_config_ext_type[j]) {
|
||||
case ID_CONFIG_EXT_FILL:
|
||||
for (i = 0; i < pstr_usac_config->usac_config_ext_len[j]; i++) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, fill_byte_val, 8);
|
||||
}
|
||||
break;
|
||||
case ID_CONFIG_EXT_LOUDNESS_INFO:
|
||||
for (i = 0; i < pstr_usac_config->usac_config_ext_len[j]; i++) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
pstr_usac_config->usac_config_ext_buf[j][i], 8);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < pstr_usac_config->usac_config_ext_len[j]; i++) {
|
||||
bit_cnt += iusace_write_bits_buf(
|
||||
pstr_it_bit_buff, (UWORD32)pstr_usac_config->usac_cfg_ext_info_buf[j][i], 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bit_cnt;
|
||||
}
|
||||
|
||||
static WORD32 iusace_sbr_config(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_usac_enc_sbr_config_struct *pstr_usac_sbr_config) {
|
||||
WORD32 bit_cnt = 0;
|
||||
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->harmonic_sbr), 1);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->bs_inter_tes), 1);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->bs_pvc), 1);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_start_freq), 4);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_stop_freq), 4);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_header_extra1), 1);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_header_extra2), 1);
|
||||
|
||||
if (pstr_usac_sbr_config->dflt_header_extra1) {
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_freq_scale), 2);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_alter_scale), 2);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_noise_bands), 2);
|
||||
}
|
||||
|
||||
if (pstr_usac_sbr_config->dflt_header_extra2) {
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_limiter_bands), 2);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_limiter_gains), 2);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_interpol_freq), 1);
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_sbr_config->dflt_smoothing_mode), 1);
|
||||
}
|
||||
|
||||
return bit_cnt;
|
||||
}
|
||||
|
||||
static WORD32 iusace_cpe_config(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_usac_enc_element_config_struct *pstr_usac_enc_conf,
|
||||
WORD32 sbr_ratio_idx, ia_aace_config_struct *pstr_eld_config) {
|
||||
WORD32 bit_count = 0;
|
||||
|
||||
if (sbr_ratio_idx > 0) {
|
||||
bit_count += iusace_sbr_config(pstr_it_bit_buff, &(pstr_usac_enc_conf->str_usac_sbr_config));
|
||||
bit_count +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_enc_conf->stereo_config_index), 2);
|
||||
}
|
||||
|
||||
if (pstr_usac_enc_conf->stereo_config_index > 0) {
|
||||
if (pstr_eld_config->num_sac_cfg_bits) {
|
||||
{
|
||||
bit_count += ixheaace_spatial_specific_config(pstr_it_bit_buff, pstr_eld_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
static WORD32 iusace_ext_element_config(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_usac_enc_element_config_struct *pstr_usac_enc_conf) {
|
||||
WORD32 bit_count = 0;
|
||||
|
||||
bit_count += iusace_write_escape_value(pstr_it_bit_buff, pstr_usac_enc_conf->usac_ext_ele_type,
|
||||
4, 8, 16);
|
||||
bit_count += iusace_write_escape_value(pstr_it_bit_buff,
|
||||
pstr_usac_enc_conf->usac_ext_ele_cfg_len, 4, 8, 16);
|
||||
bit_count += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_usac_enc_conf->usac_ext_ele_dflt_len_present), 1);
|
||||
|
||||
if (pstr_usac_enc_conf->usac_ext_ele_dflt_len_present) {
|
||||
bit_count += iusace_write_escape_value(
|
||||
pstr_it_bit_buff, pstr_usac_enc_conf->usac_ext_ele_dflt_len - 1, 8, 16, 0);
|
||||
}
|
||||
bit_count += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_usac_enc_conf->usac_ext_ele_payload_present), 1);
|
||||
|
||||
switch (pstr_usac_enc_conf->usac_ext_ele_type) {
|
||||
case ID_EXT_ELE_FILL:
|
||||
break;
|
||||
case ID_EXT_ELE_UNI_DRC: {
|
||||
UWORD32 i;
|
||||
for (i = 0; i < pstr_usac_enc_conf->usac_ext_ele_cfg_len; i++) {
|
||||
bit_count +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, pstr_usac_enc_conf->drc_config_data[i], 8);
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
|
||||
static WORD32 iusace_encoder_config(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_usac_config_struct *pstr_usac_cfg, WORD32 sbr_ratio_idx,
|
||||
ia_aace_config_struct *pstr_eld_config) {
|
||||
WORD32 bit_cnt = 0;
|
||||
UWORD32 elem_idx = 0;
|
||||
ia_usac_enc_element_config_struct *pstr_usac_enc_conf;
|
||||
|
||||
bit_cnt +=
|
||||
iusace_write_escape_value(pstr_it_bit_buff, pstr_usac_cfg->num_elements - 1, 4, 8, 16);
|
||||
|
||||
for (elem_idx = 0; elem_idx < pstr_usac_cfg->num_elements; elem_idx++) {
|
||||
unsigned long tmp = pstr_usac_cfg->usac_element_type[elem_idx];
|
||||
pstr_usac_enc_conf = &pstr_usac_cfg->str_usac_element_config[elem_idx];
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, tmp, 2);
|
||||
|
||||
switch (pstr_usac_cfg->usac_element_type[elem_idx]) {
|
||||
case ID_USAC_SCE:
|
||||
bit_cnt += iusace_write_bits_buf(
|
||||
pstr_it_bit_buff, (pstr_usac_enc_conf->tw_mdct),
|
||||
1); // For extended HE AAC profile tw_mdct shall be encoded with 0.
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_enc_conf->noise_filling), 1);
|
||||
if (sbr_ratio_idx > 0) {
|
||||
bit_cnt +=
|
||||
iusace_sbr_config(pstr_it_bit_buff, &(pstr_usac_enc_conf->str_usac_sbr_config));
|
||||
}
|
||||
break;
|
||||
case ID_USAC_CPE:
|
||||
bit_cnt += iusace_write_bits_buf(
|
||||
pstr_it_bit_buff, (pstr_usac_enc_conf->tw_mdct),
|
||||
1); // For extended HE AAC profile tw_mdct shall be encoded with 0.
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_usac_enc_conf->noise_filling), 1);
|
||||
bit_cnt += iusace_cpe_config(pstr_it_bit_buff, pstr_usac_enc_conf, sbr_ratio_idx,
|
||||
pstr_eld_config);
|
||||
break;
|
||||
case ID_USAC_EXT:
|
||||
bit_cnt += iusace_ext_element_config(pstr_it_bit_buff, pstr_usac_enc_conf);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bit_cnt;
|
||||
}
|
||||
|
||||
static UWORD32 ixheaace_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;
|
||||
}
|
||||
static WORD32 sbr_header(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ixheaace_pstr_sbr_hdr_data pstr_sbr_config) {
|
||||
WORD32 bit_cnt = 0;
|
||||
|
|
@ -77,9 +290,9 @@ static WORD32 sbr_header(ia_bit_buf_struct *pstr_it_bit_buff,
|
|||
|
||||
static WORD32 ld_sbr_header(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ixheaace_pstr_sbr_hdr_data pstr_sbr_config,
|
||||
WORD32 channelConfiguration) {
|
||||
WORD32 channel_configuration) {
|
||||
WORD32 num_sbr_header, el, bit_cnt = 0;
|
||||
switch (channelConfiguration) {
|
||||
switch (channel_configuration) {
|
||||
case 1:
|
||||
case 2:
|
||||
num_sbr_header = 1;
|
||||
|
|
@ -107,7 +320,7 @@ static WORD32 ld_sbr_header(ia_bit_buf_struct *pstr_it_bit_buff,
|
|||
|
||||
static WORD32 iaace_get_eld_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_aace_config_struct *pstr_eld_config,
|
||||
WORD32 channelConfiguration) {
|
||||
WORD32 channel_configuration) {
|
||||
WORD32 bit_cnt = 0;
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_eld_config->frame_length_flag), 1);
|
||||
bit_cnt +=
|
||||
|
|
@ -121,7 +334,8 @@ static WORD32 iaace_get_eld_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit
|
|||
if (pstr_eld_config->ld_sbr_present_flag) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_eld_config->ld_sbr_sample_rate), 1);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_eld_config->ld_sbr_crc_flag), 1);
|
||||
bit_cnt += ld_sbr_header(pstr_it_bit_buff, pstr_eld_config->sbr_config, channelConfiguration);
|
||||
bit_cnt +=
|
||||
ld_sbr_header(pstr_it_bit_buff, pstr_eld_config->sbr_config, channel_configuration);
|
||||
}
|
||||
|
||||
if (pstr_eld_config->num_sac_cfg_bits) {
|
||||
|
|
@ -139,7 +353,7 @@ static WORD32 iaace_get_eld_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit
|
|||
|
||||
static WORD32 iaace_ga_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ia_aace_config_struct *pstr_ga_specific_config,
|
||||
WORD32 channelConfiguration, WORD32 aot) {
|
||||
WORD32 channel_configuration, WORD32 aot) {
|
||||
WORD32 bit_cnt = 0;
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_ga_specific_config->frame_length_flag), 1);
|
||||
|
|
@ -149,7 +363,7 @@ static WORD32 iaace_ga_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit_buff
|
|||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, (pstr_ga_specific_config->core_coder_delay), 14);
|
||||
}
|
||||
if (!channelConfiguration) {
|
||||
if (!channel_configuration) {
|
||||
}
|
||||
|
||||
if (AOT_AAC_LD == aot) {
|
||||
|
|
@ -177,7 +391,8 @@ static WORD32 iaace_ga_specific_config_bytes(ia_bit_buf_struct *pstr_it_bit_buff
|
|||
|
||||
WORD32 ixheaace_get_audiospecific_config_bytes(
|
||||
ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ixheaace_audio_specific_config_struct *pstr_audio_specific_config, WORD32 aot) {
|
||||
ixheaace_audio_specific_config_struct *pstr_audio_specific_config, WORD32 aot,
|
||||
WORD32 ccfl_idx) {
|
||||
WORD32 bit_cnt = 0, i;
|
||||
UWORD32 tmp = 0x0f; // initialized to indicate no sampling frequency index field
|
||||
WORD32 ext_aot = -1;
|
||||
|
|
@ -197,8 +412,15 @@ WORD32 ixheaace_get_audiospecific_config_bytes(
|
|||
}
|
||||
}
|
||||
pstr_audio_specific_config->audio_object_type = aot;
|
||||
|
||||
{
|
||||
if (aot == AOT_USAC) {
|
||||
for (i = 0; i < sizeof(iusace_sampl_freq_idx_table) / sizeof(iusace_sampl_freq_idx_table[0]);
|
||||
i++) {
|
||||
if (pstr_audio_specific_config->sampling_frequency == iusace_sampl_freq_idx_table[i]) {
|
||||
tmp = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < sizeof(ia_sampl_freq_table) / sizeof(ia_sampl_freq_table[0]); i++) {
|
||||
if (ia_sampl_freq_table[i] == pstr_audio_specific_config->sampling_frequency) {
|
||||
tmp = i;
|
||||
|
|
@ -227,9 +449,9 @@ WORD32 ixheaace_get_audiospecific_config_bytes(
|
|||
if (pstr_audio_specific_config->samp_freq_index == 0xf) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->sampling_frequency), 24);
|
||||
} else {
|
||||
} else if (AOT_USAC != aot) {
|
||||
pstr_audio_specific_config->sampling_frequency =
|
||||
iusace_sampl_freq_table[pstr_audio_specific_config->samp_freq_index];
|
||||
ia_sampl_freq_table[pstr_audio_specific_config->samp_freq_index];
|
||||
}
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->channel_configuration), 4);
|
||||
|
|
@ -299,6 +521,90 @@ WORD32 ixheaace_get_audiospecific_config_bytes(
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AOT_USAC: {
|
||||
WORD32 sbr_ratio_idx;
|
||||
ia_usac_config_struct *pstr_usac_config = &(pstr_audio_specific_config->str_usac_config);
|
||||
WORD32 ia_ccfl_tbl[5] = {768, 1024, 768, 1024, 1024};
|
||||
pstr_audio_specific_config->core_sbr_framelength_index =
|
||||
ccfl_idx; // 768 core coder frame length without SBR
|
||||
pstr_usac_config->ccfl =
|
||||
ia_ccfl_tbl[pstr_audio_specific_config->core_sbr_framelength_index];
|
||||
tmp = 0x1f;
|
||||
for (i = 0; i < sizeof(ia_usac_sampl_freq_table) / sizeof(ia_usac_sampl_freq_table[0]);
|
||||
i++) {
|
||||
if (ia_usac_sampl_freq_table[i] == pstr_audio_specific_config->sampling_frequency) {
|
||||
tmp = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pstr_audio_specific_config->samp_freq_index = (UWORD32)tmp;
|
||||
|
||||
if (pstr_audio_specific_config->samp_freq_index == 0x1f) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, 0x1f, 5);
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->sampling_frequency), 24);
|
||||
} else {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->samp_freq_index), 5);
|
||||
}
|
||||
|
||||
bit_cnt += iusace_write_bits_buf(
|
||||
pstr_it_bit_buff, (pstr_audio_specific_config->core_sbr_framelength_index), 3);
|
||||
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->channel_configuration), 5);
|
||||
|
||||
if (pstr_audio_specific_config->channel_configuration == 0) {
|
||||
bit_cnt += iusace_write_escape_value(
|
||||
pstr_it_bit_buff, pstr_audio_specific_config->num_audio_channels, 5, 8, 16);
|
||||
|
||||
for (i = 0; i < pstr_audio_specific_config->num_audio_channels; i++) {
|
||||
tmp = pstr_audio_specific_config->output_channel_pos[i];
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, tmp, 5);
|
||||
}
|
||||
}
|
||||
|
||||
sbr_ratio_idx = ixheaace_sbr_ratio(pstr_audio_specific_config->core_sbr_framelength_index);
|
||||
|
||||
bit_cnt += iusace_encoder_config(pstr_it_bit_buff, pstr_usac_config, sbr_ratio_idx,
|
||||
&pstr_audio_specific_config->str_aac_config);
|
||||
|
||||
bit_cnt +=
|
||||
iusace_write_bits_buf(pstr_it_bit_buff, pstr_usac_config->usac_cfg_ext_present, 1);
|
||||
if (pstr_usac_config->usac_cfg_ext_present) {
|
||||
bit_cnt += iusace_config_extension(pstr_it_bit_buff, pstr_usac_config);
|
||||
}
|
||||
|
||||
if (sbr_ratio_idx)
|
||||
pstr_audio_specific_config->sbr_present_flag = 1;
|
||||
else
|
||||
pstr_audio_specific_config->sbr_present_flag = 0;
|
||||
|
||||
pstr_audio_specific_config->ext_audio_object_type = 0;
|
||||
|
||||
if (pstr_audio_specific_config->ext_audio_object_type == AOT_SBR) {
|
||||
pstr_audio_specific_config->ext_sync_word = 0x2b7;
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->ext_sync_word), 11);
|
||||
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->ext_audio_object_type), 5);
|
||||
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->sbr_present_flag), 1);
|
||||
|
||||
if (pstr_audio_specific_config->sbr_present_flag == 1) {
|
||||
bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff,
|
||||
(pstr_audio_specific_config->ext_samp_freq_index), 4);
|
||||
|
||||
if (pstr_audio_specific_config->ext_samp_freq_index == 0xf) {
|
||||
bit_cnt += iusace_write_bits_buf(
|
||||
pstr_it_bit_buff, (pstr_audio_specific_config->ext_sampling_frequency), 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ typedef struct {
|
|||
WORD32 sbr_present_flag;
|
||||
WORD32 cfg_ext_present;
|
||||
WORD32 ext_sync_word;
|
||||
ia_usac_config_struct str_usac_config;
|
||||
ia_aace_config_struct str_aac_config;
|
||||
} ixheaace_audio_specific_config_struct;
|
||||
|
||||
WORD32 ixheaace_get_audiospecific_config_bytes(
|
||||
ia_bit_buf_struct *pstr_it_bit_buff,
|
||||
ixheaace_audio_specific_config_struct *pstr_audio_specific_config, WORD32 aot);
|
||||
ixheaace_audio_specific_config_struct *pstr_audio_specific_config, WORD32 aot,
|
||||
WORD32 ccfl_idx);
|
||||
|
|
@ -21,6 +21,10 @@
|
|||
#include <stdlib.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "ixheaac_basic_ops40.h"
|
||||
#include "ixheaac_basic_ops.h"
|
||||
#include "ixheaace_block_switch.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include <string.h>
|
||||
|
||||
static FLOAT32 iaace_fmult(FLOAT32 a, FLOAT32 b) { return (a * b); }
|
||||
|
|
|
|||
|
|
@ -19,10 +19,14 @@
|
|||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include <string.h>
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#define ia_mul_flt(a, b) ((a) * (b))
|
||||
#define ia_negate_flt(a) (-a)
|
||||
|
||||
#define MASK 0x0001
|
||||
|
||||
#define C70 (-0.1666667014f) //(cos(u) + cos(2 * u) + cos(3 * u)) / 3;
|
||||
#define C71 (0.7901564837f) //(2 * cos(u) - cos(2 * u) - cos(3 * u)) / 3;
|
||||
#define C72 (0.0558542535f) //(cos(u) - 2 * cos(2 * u) + cos(3 * u)) / 3;
|
||||
|
|
|
|||
|
|
@ -55,4 +55,4 @@
|
|||
#define USAC_COMPLEX_PREDECTION_DEFAULT_VALUE (0)
|
||||
#define USAC_TNS_DEFAULT_VALUE (0)
|
||||
#define USAC_FLAG_NOISE_FILLING_DEFAULT_VALUE (0)
|
||||
#define USAC_BITRATE_DEFAULT_VALUE (32000)
|
||||
#define USAC_BITRATE_DEFAULT_VALUE (96000)
|
||||
|
|
|
|||
522
encoder/ixheaace_cplx_pred.c
Normal file
522
encoder/ixheaace_cplx_pred.c
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "iusace_type_def.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
#include "ixheaace_mps_common_define.h"
|
||||
#include "iusace_cnst.h"
|
||||
#include "iusace_fd_quant.h"
|
||||
#include "iusace_bitbuffer.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "impd_drc_uni_drc_eq.h"
|
||||
#include "impd_drc_uni_drc_filter_bank.h"
|
||||
#include "impd_drc_gain_enc.h"
|
||||
#include "impd_drc_struct_def.h"
|
||||
|
||||
#include "ixheaace_memory_standards.h"
|
||||
#include "iusace_tns_usac.h"
|
||||
#include "iusace_psy_mod.h"
|
||||
#include "iusace_config.h"
|
||||
#include "iusace_block_switch_const.h"
|
||||
#include "iusace_block_switch_struct_def.h"
|
||||
#include "iusace_signal_classifier.h"
|
||||
#include "iusace_ms.h"
|
||||
#include "ixheaace_adjust_threshold_data.h"
|
||||
#include "iusace_fd_qc_util.h"
|
||||
#include "ixheaace_sbr_header.h"
|
||||
#include "ixheaace_config.h"
|
||||
#include "ixheaace_asc_write.h"
|
||||
#include "iusace_main.h"
|
||||
#include "iusace_rom.h"
|
||||
|
||||
static VOID iusace_compute_pred_coef(WORD32 num_lines, WORD32 complex_coef,
|
||||
FLOAT64 *ptr_spec_mdct_dmx, FLOAT64 *ptr_spec_mdst_dmx,
|
||||
FLOAT64 *ptr_spec_mdct_mid_side, FLOAT32 *pred_coef_re,
|
||||
FLOAT32 *pred_coef_im, FLOAT32 *pred_coef_q_re,
|
||||
FLOAT32 *pred_coef_q_im, WORD32 *pred_coef_q_int_re,
|
||||
WORD32 *pred_coef_q_int_im) {
|
||||
LOOPIDX bin_idx;
|
||||
FLOAT32 iprod_re = 0.0f, iprod_im = 0.0f;
|
||||
FLOAT32 eps = 1.0e-6f;
|
||||
const FLOAT32 k_delta = 0.1f;
|
||||
const FLOAT32 k_max = 3.0f;
|
||||
WORD32 pred_coef_sign_re, pred_coef_sign_im;
|
||||
FLOAT32 pred_coef_abs_re, pred_coef_abs_im;
|
||||
FLOAT32 abs_dmx = 0.0f;
|
||||
|
||||
for (bin_idx = 0; bin_idx < num_lines; bin_idx++) {
|
||||
/* D = Dr + jDi */
|
||||
/* D*S = (Dr + jDi)*S = Dr*S + j(Di*S) */
|
||||
/* alpha = alpha_r - jalpha_i */
|
||||
if (complex_coef == 1) {
|
||||
iprod_re += (FLOAT32)(ptr_spec_mdct_dmx[bin_idx] * ptr_spec_mdct_mid_side[bin_idx]);
|
||||
iprod_im += (FLOAT32)(ptr_spec_mdst_dmx[bin_idx] * ptr_spec_mdct_mid_side[bin_idx]);
|
||||
abs_dmx += (FLOAT32)(ptr_spec_mdct_dmx[bin_idx] * ptr_spec_mdct_dmx[bin_idx] +
|
||||
ptr_spec_mdst_dmx[bin_idx] * ptr_spec_mdst_dmx[bin_idx]);
|
||||
} else {
|
||||
iprod_re += (FLOAT32)(ptr_spec_mdct_dmx[bin_idx] * ptr_spec_mdct_mid_side[bin_idx]);
|
||||
abs_dmx += (FLOAT32)(ptr_spec_mdct_dmx[bin_idx] * ptr_spec_mdct_dmx[bin_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute real and imaginary parts of prediction coefficient */
|
||||
*pred_coef_re = iprod_re / (abs_dmx + eps);
|
||||
pred_coef_sign_re = *pred_coef_re > 0 ? 1 : -1;
|
||||
pred_coef_abs_re = (FLOAT32)MIN(fabs(*pred_coef_re), k_max);
|
||||
*pred_coef_q_int_re = pred_coef_sign_re * (WORD32)(pred_coef_abs_re / k_delta + 0.5f);
|
||||
*pred_coef_q_re = *pred_coef_q_int_re * k_delta;
|
||||
|
||||
if (complex_coef == 1) {
|
||||
*pred_coef_im = iprod_im / (abs_dmx + eps);
|
||||
pred_coef_sign_im = *pred_coef_im > 0 ? 1 : -1;
|
||||
pred_coef_abs_im = (FLOAT32)MIN(fabs(*pred_coef_im), k_max);
|
||||
*pred_coef_q_int_im = pred_coef_sign_im * (WORD32)(pred_coef_abs_im / k_delta + 0.5f);
|
||||
*pred_coef_q_im = *pred_coef_q_int_im * k_delta;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_compute_res(WORD32 num_lines, WORD32 complex_coef, FLOAT32 pred_coef_q_re,
|
||||
FLOAT32 pred_coef_q_im, FLOAT64 *ptr_spec_mdct_dmx,
|
||||
FLOAT64 *ptr_spec_mdst_dmx, FLOAT64 *ptr_spec_mdct_mid_side,
|
||||
FLOAT64 *ptr_spec_mdct_res) {
|
||||
LOOPIDX i;
|
||||
|
||||
for (i = 0; i < num_lines; i++) {
|
||||
/* DMX = M; E = S - alpha*DMX if pred_dir = 0 */
|
||||
/* DMX = S; E = M - alpha*DMX if pred_dir = 1 */
|
||||
if (complex_coef == 1) {
|
||||
ptr_spec_mdct_res[i] =
|
||||
(FLOAT32)(ptr_spec_mdct_mid_side[i] - pred_coef_q_re * ptr_spec_mdct_dmx[i] -
|
||||
pred_coef_q_im * ptr_spec_mdst_dmx[i]);
|
||||
} else {
|
||||
ptr_spec_mdct_res[i] =
|
||||
(FLOAT32)(ptr_spec_mdct_mid_side[i] - pred_coef_q_re * ptr_spec_mdct_dmx[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID iusace_filter_and_add(const FLOAT64 *ptr_in, const WORD32 length,
|
||||
const FLOAT64 *ptr_filter, FLOAT64 *ptr_out,
|
||||
const WORD32 factor_even) {
|
||||
LOOPIDX i;
|
||||
FLOAT64 s;
|
||||
|
||||
i = 0;
|
||||
s = ptr_filter[6] * ptr_in[2] + ptr_filter[5] * ptr_in[1] + ptr_filter[4] * ptr_in[0] +
|
||||
ptr_filter[3] * ptr_in[0] + ptr_filter[2] * ptr_in[1] + ptr_filter[1] * ptr_in[2] +
|
||||
ptr_filter[0] * ptr_in[3];
|
||||
ptr_out[i] += s * factor_even;
|
||||
i = 1;
|
||||
s = ptr_filter[6] * ptr_in[1] + ptr_filter[5] * ptr_in[0] + ptr_filter[4] * ptr_in[0] +
|
||||
ptr_filter[3] * ptr_in[1] + ptr_filter[2] * ptr_in[2] + ptr_filter[1] * ptr_in[3] +
|
||||
ptr_filter[0] * ptr_in[4];
|
||||
ptr_out[i] += s;
|
||||
i = 2;
|
||||
s = ptr_filter[6] * ptr_in[0] + ptr_filter[5] * ptr_in[0] + ptr_filter[4] * ptr_in[1] +
|
||||
ptr_filter[3] * ptr_in[2] + ptr_filter[2] * ptr_in[3] + ptr_filter[1] * ptr_in[4] +
|
||||
ptr_filter[0] * ptr_in[5];
|
||||
ptr_out[i] += s * factor_even;
|
||||
|
||||
for (i = 3; i < length - 4; i += 2) {
|
||||
s = ptr_filter[6] * ptr_in[i - 3] + ptr_filter[5] * ptr_in[i - 2] +
|
||||
ptr_filter[4] * ptr_in[i - 1] + ptr_filter[3] * ptr_in[i] +
|
||||
ptr_filter[2] * ptr_in[i + 1] + ptr_filter[1] * ptr_in[i + 2] +
|
||||
ptr_filter[0] * ptr_in[i + 3];
|
||||
ptr_out[i] += s;
|
||||
s = ptr_filter[6] * ptr_in[i - 2] + ptr_filter[5] * ptr_in[i - 1] +
|
||||
ptr_filter[4] * ptr_in[i] + ptr_filter[3] * ptr_in[i + 1] +
|
||||
ptr_filter[2] * ptr_in[i + 2] + ptr_filter[1] * ptr_in[i + 3] +
|
||||
ptr_filter[0] * ptr_in[i + 4];
|
||||
ptr_out[i + 1] += s * factor_even;
|
||||
}
|
||||
|
||||
i = length - 3;
|
||||
s = ptr_filter[6] * ptr_in[i - 3] + ptr_filter[5] * ptr_in[i - 2] +
|
||||
ptr_filter[4] * ptr_in[i - 1] + ptr_filter[3] * ptr_in[i] + ptr_filter[2] * ptr_in[i + 1] +
|
||||
ptr_filter[1] * ptr_in[i + 2] + ptr_filter[0] * ptr_in[i + 2];
|
||||
ptr_out[i] += s;
|
||||
i = length - 2;
|
||||
s = ptr_filter[6] * ptr_in[i - 3] + ptr_filter[5] * ptr_in[i - 2] +
|
||||
ptr_filter[4] * ptr_in[i - 1] + ptr_filter[3] * ptr_in[i] + ptr_filter[2] * ptr_in[i + 1] +
|
||||
ptr_filter[1] * ptr_in[i + 1] + ptr_filter[0] * ptr_in[i];
|
||||
ptr_out[i] += s * factor_even;
|
||||
i = length - 1;
|
||||
s = ptr_filter[6] * ptr_in[i - 3] + ptr_filter[5] * ptr_in[i - 2] +
|
||||
ptr_filter[4] * ptr_in[i - 1] + ptr_filter[3] * ptr_in[i] + ptr_filter[2] * ptr_in[i] +
|
||||
ptr_filter[1] * ptr_in[i - 1] + ptr_filter[0] * ptr_in[i - 2];
|
||||
ptr_out[i] += s;
|
||||
}
|
||||
|
||||
static VOID iusace_estimate_dmx_im(const FLOAT64 *ptr_dmx_re, const FLOAT64 *ptr_dmx_re_prev,
|
||||
FLOAT64 *ptr_dmx_im, WORD32 window, const WORD32 w_shape,
|
||||
const WORD32 prev_w_shape, WORD32 num_sbk,
|
||||
WORD32 bins_per_sbk) {
|
||||
LOOPIDX i;
|
||||
const FLOAT64 *ptr_mdst_fcoeff_curr, *ptr_mdst_fcoeff_prev;
|
||||
|
||||
switch (window) {
|
||||
case ONLY_LONG_SEQUENCE:
|
||||
case EIGHT_SHORT_SEQUENCE:
|
||||
ptr_mdst_fcoeff_curr = iusace_mdst_fcoeff_longshort_curr[prev_w_shape][w_shape];
|
||||
ptr_mdst_fcoeff_prev = iusace_mdst_fcoeff_l_s_start_left_prev[prev_w_shape];
|
||||
break;
|
||||
case LONG_START_SEQUENCE:
|
||||
ptr_mdst_fcoeff_curr = iusace_mdst_fcoeff_start_curr[prev_w_shape][w_shape];
|
||||
ptr_mdst_fcoeff_prev = iusace_mdst_fcoeff_l_s_start_left_prev[prev_w_shape];
|
||||
break;
|
||||
case LONG_STOP_SEQUENCE:
|
||||
ptr_mdst_fcoeff_curr = iusace_mdst_fcoeff_stop_cur[prev_w_shape][w_shape];
|
||||
ptr_mdst_fcoeff_prev = iusace_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape];
|
||||
break;
|
||||
case STOP_START_SEQUENCE:
|
||||
ptr_mdst_fcoeff_curr = iusace_mdst_fcoeff_stopstart_cur[prev_w_shape][w_shape];
|
||||
ptr_mdst_fcoeff_prev = iusace_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape];
|
||||
break;
|
||||
default:
|
||||
ptr_mdst_fcoeff_curr = iusace_mdst_fcoeff_stopstart_cur[prev_w_shape][w_shape];
|
||||
ptr_mdst_fcoeff_prev = iusace_mdst_fcoeff_stop_stopstart_left_prev[prev_w_shape];
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_sbk; i++) {
|
||||
iusace_filter_and_add(ptr_dmx_re, bins_per_sbk, ptr_mdst_fcoeff_curr, ptr_dmx_im, 1);
|
||||
|
||||
if (ptr_dmx_re_prev) {
|
||||
iusace_filter_and_add(ptr_dmx_re_prev, bins_per_sbk, ptr_mdst_fcoeff_prev, ptr_dmx_im, -1);
|
||||
}
|
||||
|
||||
ptr_dmx_re_prev = ptr_dmx_re;
|
||||
ptr_dmx_re += bins_per_sbk;
|
||||
ptr_dmx_im += bins_per_sbk;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID iusace_usac_cplx_save_prev(FLOAT64 *ptr_mdct_spec, FLOAT64 *ptr_mdct_spec_prev,
|
||||
WORD32 save_zeros, WORD32 condition_2, WORD32 samp_per_bk,
|
||||
WORD32 bins_per_sbk) {
|
||||
WORD32 offset;
|
||||
|
||||
offset = samp_per_bk - bins_per_sbk;
|
||||
|
||||
if (save_zeros || condition_2) {
|
||||
memset(ptr_mdct_spec_prev + offset, 0, sizeof(FLOAT64) * bins_per_sbk);
|
||||
} else {
|
||||
memcpy(ptr_mdct_spec_prev + offset, ptr_mdct_spec + offset, sizeof(FLOAT64) * bins_per_sbk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static FLOAT64 iusace_compute_ipd(FLOAT64 *ptr_spec_real1, FLOAT64 *ptr_spec_imag1,
|
||||
FLOAT64 *ptr_spec_real2, FLOAT64 *ptr_spec_imag2,
|
||||
WORD32 num_lines) {
|
||||
LOOPIDX i;
|
||||
|
||||
FLOAT64 ipd = 0.0f;
|
||||
FLOAT64 cross_corr_real = 0.0f, cross_corr_imag = 0.0f;
|
||||
|
||||
for (i = 0; i < num_lines; i++) {
|
||||
cross_corr_real +=
|
||||
ptr_spec_real1[i] * ptr_spec_real2[i] + ptr_spec_imag1[i] * ptr_spec_imag2[i];
|
||||
cross_corr_imag +=
|
||||
-ptr_spec_imag2[i] * ptr_spec_real1[i] + ptr_spec_imag1[i] * ptr_spec_real2[i];
|
||||
}
|
||||
|
||||
ipd = (FLOAT64)atan2(cross_corr_imag, cross_corr_real);
|
||||
ipd = ipd > 0 ? ipd : 2. * PI + ipd;
|
||||
|
||||
return ipd;
|
||||
}
|
||||
|
||||
static IA_ERRORCODE iusace_cplx_pred_main(
|
||||
WORD32 num_sfb, WORD32 num_window_groups, FLOAT64 *ptr_spec_mdct_mid,
|
||||
FLOAT64 *ptr_spec_mdct_side, WORD32 pred_coef_q_int_re[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 pred_coef_q_int_im[MAX_SHORT_WINDOWS][MAX_SFB_LONG], WORD32 *pred_dir,
|
||||
ia_usac_data_struct *pstr_usac_data, ia_sfb_params_struct *pstr_sfb_prms,
|
||||
WORD32 usac_independancy_flag, ia_usac_encoder_config_struct *pstr_usac_config,
|
||||
FLOAT64 *ptr_scratch_cmpx_mdct_buf, WORD32 cplx_pred_used[MAX_SHORT_WINDOWS][MAX_SFB_LONG],
|
||||
WORD32 chn, const WORD32 *ptr_sfb_offsets, FLOAT32 nrg_mid, FLOAT32 nrg_side,
|
||||
WORD32 *ms_mask_flag) {
|
||||
LOOPIDX group, sfb, i;
|
||||
FLOAT32 pred_coef_re, pred_coef_im, pred_coef_q_re, pred_coef_q_im = 0.0f;
|
||||
const WORD32 sfb_per_pred_band = 2;
|
||||
WORD32 left = 0, right = 0, save_zeros = 0, condition_2 = 0, samp_per_bk = 0, bins_per_sbk = 0,
|
||||
num_sbk = 0;
|
||||
FLOAT64 *ptr_dmx_re_prev;
|
||||
FLOAT64 *ptr_spec_mdct_res = &ptr_scratch_cmpx_mdct_buf[0];
|
||||
const WORD32 sfb_count = num_window_groups * num_sfb;
|
||||
const WORD32 sfb_per_group = num_sfb;
|
||||
WORD32 sfb_offsets = 0, zero_flag, spec_start, spec_end;
|
||||
|
||||
left = chn, right = chn + 1;
|
||||
|
||||
/* Number of sub-blocks */
|
||||
if (pstr_usac_config->window_sequence[left] == EIGHT_SHORT_SEQUENCE) {
|
||||
num_sbk = MAX_SHORT_WINDOWS;
|
||||
}
|
||||
if (pstr_usac_config->window_sequence[left] == ONLY_LONG_SEQUENCE ||
|
||||
pstr_usac_config->window_sequence[left] == LONG_START_SEQUENCE ||
|
||||
pstr_usac_config->window_sequence[left] == LONG_STOP_SEQUENCE ||
|
||||
pstr_usac_config->window_sequence[left] == STOP_START_SEQUENCE) {
|
||||
num_sbk = 1;
|
||||
}
|
||||
|
||||
if (num_sbk == 0) {
|
||||
return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_NUM_SBK;
|
||||
}
|
||||
|
||||
samp_per_bk = pstr_usac_config->ccfl;
|
||||
bins_per_sbk = samp_per_bk / num_sbk;
|
||||
|
||||
/* Compute prediction direction */
|
||||
if (nrg_mid >= nrg_side) {
|
||||
*pred_dir = 0;
|
||||
} else {
|
||||
*pred_dir = 1;
|
||||
}
|
||||
|
||||
if (pstr_usac_data->complex_coef[chn] == 1) {
|
||||
save_zeros = ((pstr_usac_config->window_sequence[left] == EIGHT_SHORT_SEQUENCE &&
|
||||
pstr_usac_config->window_sequence[right] != EIGHT_SHORT_SEQUENCE) ||
|
||||
(pstr_usac_config->window_sequence[left] != EIGHT_SHORT_SEQUENCE &&
|
||||
pstr_usac_config->window_sequence[right] == EIGHT_SHORT_SEQUENCE));
|
||||
|
||||
condition_2 = (usac_independancy_flag || pstr_usac_data->core_mode_prev[left] ||
|
||||
pstr_usac_data->core_mode_prev[right]);
|
||||
|
||||
/* Compute current frame's MDST down-mix*/
|
||||
ptr_dmx_re_prev = !(usac_independancy_flag) ? pstr_usac_data->ptr_dmx_re_save[chn] : NULL;
|
||||
|
||||
memset(pstr_usac_data->ptr_dmx_im[chn], 0, sizeof(FLOAT64) * FRAME_LEN_LONG);
|
||||
|
||||
iusace_estimate_dmx_im(*pred_dir == 0 ? ptr_spec_mdct_mid : ptr_spec_mdct_side,
|
||||
ptr_dmx_re_prev, pstr_usac_data->ptr_dmx_im[chn],
|
||||
pstr_usac_config->window_sequence[left],
|
||||
pstr_sfb_prms->window_shape[left],
|
||||
pstr_usac_config->window_shape_prev[left], num_sbk, bins_per_sbk);
|
||||
|
||||
/* MCLT of downmix = dmx_re + j*dmx_im */
|
||||
/* Save MDCT down-mix for use as previous frame MDCT down-mix in the next frame */
|
||||
iusace_usac_cplx_save_prev(*pred_dir == 0 ? &ptr_spec_mdct_mid[0] : &ptr_spec_mdct_side[0],
|
||||
pstr_usac_data->ptr_dmx_re_save[chn], save_zeros, condition_2,
|
||||
samp_per_bk, bins_per_sbk);
|
||||
}
|
||||
|
||||
/* Reset buffer to zero */
|
||||
for (group = 0; group < MAX_SHORT_WINDOWS; group++) {
|
||||
memset(pred_coef_q_int_re, 0, MAX_SFB_LONG * sizeof(WORD32));
|
||||
memset(pred_coef_q_int_im, 0, MAX_SFB_LONG * sizeof(WORD32));
|
||||
}
|
||||
|
||||
group = 0;
|
||||
for (sfb = 0; sfb < sfb_count; sfb += sfb_per_group, group++) {
|
||||
for (sfb_offsets = 0; sfb_offsets < sfb_per_group; sfb_offsets += sfb_per_pred_band) {
|
||||
if (cplx_pred_used[group][sfb_offsets] == 1) {
|
||||
zero_flag = (ptr_sfb_offsets[sfb + sfb_offsets + 1] != FRAME_LEN_LONG);
|
||||
spec_start = ptr_sfb_offsets[sfb + sfb_offsets];
|
||||
spec_end = (zero_flag ? ptr_sfb_offsets[sfb + sfb_offsets + 2]
|
||||
: ptr_sfb_offsets[sfb + sfb_offsets + 1]);
|
||||
|
||||
/* Calculate prediction coefficients */
|
||||
iusace_compute_pred_coef(
|
||||
spec_end - spec_start, pstr_usac_data->complex_coef[chn],
|
||||
*pred_dir == 0 ? &ptr_spec_mdct_mid[spec_start] : &ptr_spec_mdct_side[spec_start],
|
||||
pstr_usac_data->complex_coef[chn] == 1 ? &pstr_usac_data->ptr_dmx_im[chn][spec_start]
|
||||
: NULL,
|
||||
*pred_dir == 0 ? &ptr_spec_mdct_side[spec_start] : &ptr_spec_mdct_mid[spec_start],
|
||||
&pred_coef_re, pstr_usac_data->complex_coef[chn] == 1 ? &pred_coef_im : NULL,
|
||||
&pred_coef_q_re, pstr_usac_data->complex_coef[chn] == 1 ? &pred_coef_q_im : NULL,
|
||||
&pred_coef_q_int_re[group][sfb_offsets],
|
||||
pstr_usac_data->complex_coef[chn] == 1 ? &pred_coef_q_int_im[group][sfb_offsets]
|
||||
: NULL);
|
||||
|
||||
/* Calculate residual */
|
||||
iusace_compute_res(
|
||||
spec_end - spec_start, pstr_usac_data->complex_coef[chn], pred_coef_q_re,
|
||||
pstr_usac_data->complex_coef[chn] == 1 ? pred_coef_q_im : 0,
|
||||
*pred_dir == 0 ? &ptr_spec_mdct_mid[spec_start] : &ptr_spec_mdct_side[spec_start],
|
||||
pstr_usac_data->complex_coef[chn] == 1 ? &pstr_usac_data->ptr_dmx_im[chn][spec_start]
|
||||
: NULL,
|
||||
*pred_dir == 0 ? &ptr_spec_mdct_side[spec_start] : &ptr_spec_mdct_mid[spec_start],
|
||||
&ptr_spec_mdct_res[spec_start]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute the prediction gain */
|
||||
FLOAT32 pred_gain = 0.f, nrg_res = 0.f;
|
||||
for (i = 0; i < pstr_usac_config->ccfl; i++) {
|
||||
nrg_res += (FLOAT32)(ptr_spec_mdct_res[i] * ptr_spec_mdct_res[i]);
|
||||
}
|
||||
pred_gain =
|
||||
10.f * log10f((*pred_dir == 0 ? nrg_side : nrg_mid) / nrg_res); /* Prediction gain in dB */
|
||||
|
||||
if (pred_gain > 20.f) /* Retain complex prediction */
|
||||
{
|
||||
if (*pred_dir == 1) {
|
||||
for (i = 0; i < pstr_usac_config->ccfl; i++) {
|
||||
ptr_spec_mdct_mid[i] = ptr_spec_mdct_side[i];
|
||||
ptr_spec_mdct_side[i] = ptr_spec_mdct_res[i];
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < pstr_usac_config->ccfl; i++) {
|
||||
ptr_spec_mdct_side[i] = ptr_spec_mdct_res[i];
|
||||
}
|
||||
}
|
||||
} else /* Use M/S */
|
||||
{
|
||||
*ms_mask_flag = 0;
|
||||
/* Revert spectra to L and R */
|
||||
for (i = 0; i < pstr_usac_config->ccfl; i++) {
|
||||
ptr_spec_mdct_mid[i] = pstr_usac_data->left_chan_save[chn][i];
|
||||
ptr_spec_mdct_side[i] = pstr_usac_data->right_chan_save[chn][i];
|
||||
}
|
||||
}
|
||||
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
|
||||
IA_ERRORCODE iusace_cplx_pred_proc(
|
||||
ia_usac_data_struct *pstr_usac_data, ia_usac_encoder_config_struct *pstr_usac_config,
|
||||
WORD32 usac_independancy_flag, ia_sfb_params_struct *pstr_sfb_prms, WORD32 chn,
|
||||
ia_psy_mod_data_struct *pstr_psy_data, const WORD32 *ptr_sfb_offsets,
|
||||
FLOAT64 *ptr_scratch_cmpx_mdct_buf, FLOAT64 *ptr_ms_spec, FLOAT32 nrg_mid, FLOAT32 nrg_side) {
|
||||
IA_ERRORCODE err_code;
|
||||
FLOAT32 *ptr_sfb_enegry_left = pstr_psy_data[chn].ptr_sfb_energy_long;
|
||||
FLOAT32 *ptr_sfb_energy_right = pstr_psy_data[chn + 1].ptr_sfb_energy_long;
|
||||
const FLOAT32 *ptr_sfb_energy_mid = pstr_psy_data[chn].ptr_sfb_energy_long_ms;
|
||||
const FLOAT32 *ptr_sfb_energy_side = pstr_psy_data[chn + 1].ptr_sfb_energy_long_ms;
|
||||
FLOAT32 *ptr_sfb_thr_left = pstr_psy_data[chn].ptr_sfb_thr_long;
|
||||
FLOAT32 *ptr_sfb_thr_right = pstr_psy_data[chn + 1].ptr_sfb_thr_long;
|
||||
FLOAT32 *ptr_sfb_spread_energy_left = pstr_psy_data[chn].ptr_sfb_spreaded_energy_long;
|
||||
FLOAT32 *ptr_sfb_spread_energy_right = pstr_psy_data[chn + 1].ptr_sfb_spreaded_energy_long;
|
||||
WORD32 sfb, sfb_offsets;
|
||||
WORD32 *ptr_num_sfb = pstr_sfb_prms->num_sfb;
|
||||
WORD32 *ptr_num_window_groups = pstr_sfb_prms->num_window_groups;
|
||||
const WORD32 sfb_count = ptr_num_window_groups[chn] * ptr_num_sfb[chn];
|
||||
const WORD32 sfb_per_group = ptr_num_sfb[chn];
|
||||
WORD32 grp = 0, i, zero_flag;
|
||||
const WORD32 sfb_per_pred_band = 2;
|
||||
FLOAT32 min_thr_1, min_thr_2 = 0.0f;
|
||||
FLOAT32 temp_1 = 0, temp_2 = 0;
|
||||
ia_ms_info_struct *pstr_ms_info = &pstr_usac_data->str_ms_info[chn];
|
||||
|
||||
FLOAT64 ipd;
|
||||
/* Compute IPD between L and R channels */
|
||||
ipd = iusace_compute_ipd(&pstr_usac_data->spectral_line_vector[chn][0],
|
||||
&pstr_usac_data->mdst_spectrum[chn][0],
|
||||
&pstr_usac_data->spectral_line_vector[chn + 1][0],
|
||||
&pstr_usac_data->mdst_spectrum[chn + 1][0], pstr_usac_config->ccfl);
|
||||
|
||||
/* Decide value of complex_coef based on IPD */
|
||||
if ((ipd > (PI / 2 - 5 * PI / 180) && ipd < (PI / 2 + 5 * PI / 180)) ||
|
||||
(ipd > (3 * PI / 2 - 5 * PI / 180) && ipd < (3 * PI / 2 + 5 * PI / 180))) {
|
||||
pstr_usac_data->complex_coef[chn] = 1;
|
||||
} else {
|
||||
pstr_usac_data->complex_coef[chn] = 0;
|
||||
}
|
||||
|
||||
/* Compute M and S spectra */
|
||||
for (i = 0; i < pstr_usac_config->ccfl; i++) {
|
||||
pstr_usac_data->spectral_line_vector[chn][i] = ptr_ms_spec[i];
|
||||
pstr_usac_data->spectral_line_vector[chn + 1][i] = ptr_ms_spec[pstr_usac_config->ccfl + i];
|
||||
}
|
||||
|
||||
err_code = iusace_cplx_pred_main(
|
||||
pstr_sfb_prms->num_sfb[chn], pstr_sfb_prms->num_window_groups[chn],
|
||||
pstr_usac_data->spectral_line_vector[chn], pstr_usac_data->spectral_line_vector[chn + 1],
|
||||
pstr_usac_data->pred_coef_re[chn], pstr_usac_data->pred_coef_im[chn],
|
||||
&pstr_usac_data->pred_dir_idx[chn], pstr_usac_data, pstr_sfb_prms, usac_independancy_flag,
|
||||
pstr_usac_config, ptr_scratch_cmpx_mdct_buf, pstr_usac_data->cplx_pred_used[chn], chn,
|
||||
ptr_sfb_offsets, nrg_mid, nrg_side, &pstr_ms_info->ms_mask);
|
||||
if (err_code != IA_NO_ERROR) {
|
||||
return err_code;
|
||||
}
|
||||
|
||||
if (pstr_ms_info->ms_mask == 3) {
|
||||
/* Compute thresholds required for quantization (similar to that in MS coding) */
|
||||
for (sfb = 0; sfb < sfb_count; sfb += sfb_per_group, grp++) {
|
||||
for (sfb_offsets = 0; sfb_offsets < sfb_per_group; sfb_offsets += sfb_per_pred_band) {
|
||||
if (pstr_usac_data->cplx_pred_used[chn][grp][sfb_offsets] == 1) {
|
||||
zero_flag = (ptr_sfb_offsets[sfb + sfb_offsets + 1] != pstr_usac_config->ccfl);
|
||||
min_thr_1 =
|
||||
MIN(ptr_sfb_thr_left[sfb + sfb_offsets], ptr_sfb_thr_right[sfb + sfb_offsets]);
|
||||
if (zero_flag) {
|
||||
min_thr_2 = MIN(ptr_sfb_thr_left[sfb + sfb_offsets + 1],
|
||||
ptr_sfb_thr_right[sfb + sfb_offsets + 1]);
|
||||
}
|
||||
|
||||
ptr_sfb_thr_left[sfb + sfb_offsets] = ptr_sfb_thr_right[sfb + sfb_offsets] = min_thr_1;
|
||||
ptr_sfb_enegry_left[sfb + sfb_offsets] = ptr_sfb_energy_mid[sfb + sfb_offsets];
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets] = ptr_sfb_energy_side[sfb + sfb_offsets];
|
||||
if (zero_flag) {
|
||||
ptr_sfb_thr_left[sfb + sfb_offsets + 1] = ptr_sfb_thr_right[sfb + sfb_offsets + 1] =
|
||||
min_thr_2;
|
||||
ptr_sfb_enegry_left[sfb + sfb_offsets + 1] =
|
||||
ptr_sfb_energy_mid[sfb + sfb_offsets + 1];
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets + 1] =
|
||||
ptr_sfb_energy_side[sfb + sfb_offsets + 1];
|
||||
}
|
||||
ptr_sfb_spread_energy_left[sfb + sfb_offsets] =
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets] =
|
||||
MIN(ptr_sfb_spread_energy_left[sfb + sfb_offsets],
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets]) *
|
||||
0.5f;
|
||||
if (zero_flag) {
|
||||
ptr_sfb_spread_energy_left[sfb + sfb_offsets + 1] =
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets + 1] =
|
||||
MIN(ptr_sfb_spread_energy_left[sfb + sfb_offsets + 1],
|
||||
ptr_sfb_spread_energy_right[sfb + sfb_offsets + 1]) *
|
||||
0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pstr_usac_data->pred_dir_idx[chn] == 1) {
|
||||
grp = 0;
|
||||
|
||||
for (sfb = 0; sfb < sfb_count; sfb += sfb_per_group, grp++) {
|
||||
for (sfb_offsets = 0; sfb_offsets < sfb_per_group; sfb_offsets += sfb_per_pred_band) {
|
||||
zero_flag = (ptr_sfb_offsets[sfb + sfb_offsets + 1] != pstr_usac_config->ccfl);
|
||||
|
||||
if (pstr_usac_data->cplx_pred_used[chn][grp][sfb_offsets] == 1) {
|
||||
temp_1 = ptr_sfb_enegry_left[sfb + sfb_offsets];
|
||||
ptr_sfb_enegry_left[sfb + sfb_offsets] = ptr_sfb_energy_right[sfb + sfb_offsets];
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets] = temp_1;
|
||||
if (zero_flag) {
|
||||
temp_2 = ptr_sfb_enegry_left[sfb + sfb_offsets + 1];
|
||||
ptr_sfb_enegry_left[sfb + sfb_offsets + 1] =
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets + 1];
|
||||
ptr_sfb_energy_right[sfb + sfb_offsets + 1] = temp_2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return IA_NO_ERROR;
|
||||
}
|
||||
26
encoder/ixheaace_cplx_pred.h
Normal file
26
encoder/ixheaace_cplx_pred.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
IA_ERRORCODE iusace_cplx_pred_proc(
|
||||
ia_usac_data_struct *ptr_usac_data, ia_usac_encoder_config_struct *ptr_usac_config,
|
||||
WORD32 usac_independancy_flag, ia_sfb_params_struct *pstr_sfb_prms, WORD32 chn,
|
||||
ia_psy_mod_data_struct *pstr_psy_data, const WORD32 *ptr_sfb_offsets,
|
||||
FLOAT64 *scratch_cmpx_mdct_temp_buf, FLOAT64 *ptr_ms_spec, FLOAT32 nrg_mid, FLOAT32 nrg_side);
|
||||
|
|
@ -20,14 +20,18 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ixheaac_basic_ops32.h"
|
||||
#include "ixheaac_basic_ops16.h"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
#include "ixheaac_type_def.h"
|
||||
#include "ixheaac_constants.h"
|
||||
#include "ixheaace_aac_constants.h"
|
||||
#include "impd_drc_common_enc.h"
|
||||
#include "impd_drc_uni_drc.h"
|
||||
#include "impd_drc_tables.h"
|
||||
#include "impd_drc_api.h"
|
||||
#include "ixheaace_api.h"
|
||||
#include "ixheaac_error_standards.h"
|
||||
#include "ixheaace_error_codes.h"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue