xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_psy_configuration.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker  */
20*15dc779aSAndroid Build Coastguard Worker 
21*15dc779aSAndroid Build Coastguard Worker #pragma once
22*15dc779aSAndroid Build Coastguard Worker 
23*15dc779aSAndroid Build Coastguard Worker #define db_lin_scale(a) pow(10.0f, (a) * (FLOAT32)0.1f)
24*15dc779aSAndroid Build Coastguard Worker 
25*15dc779aSAndroid Build Coastguard Worker #ifndef C_RATIO
26*15dc779aSAndroid Build Coastguard Worker #define C_RATIO 0.001258925f /* pow(10.0f, -(29.0f/10.0f)) */
27*15dc779aSAndroid Build Coastguard Worker #endif
28*15dc779aSAndroid Build Coastguard Worker 
29*15dc779aSAndroid Build Coastguard Worker #define SNR_FLOAT .0001f /* 0.0001 ie. pow(10.0f, -(40.0f/10.0f)) */
30*15dc779aSAndroid Build Coastguard Worker 
31*15dc779aSAndroid Build Coastguard Worker #define MAX_BARK_VALUE (24.0f)
32*15dc779aSAndroid Build Coastguard Worker #define MASK_LOW_FAC (3.0f)
33*15dc779aSAndroid Build Coastguard Worker #define MASK_HIGH_FAC (1.5f)
34*15dc779aSAndroid Build Coastguard Worker #define MASK_LOW_SP_ENERGY_L (3.0f)
35*15dc779aSAndroid Build Coastguard Worker #define MASK_HIGH_SP_ENERGY_L (2.0f)
36*15dc779aSAndroid Build Coastguard Worker #define MASK_HIGH_SP_ENERGY_L_LBR (1.5f)
37*15dc779aSAndroid Build Coastguard Worker #define MASK_LOW_SP_ENERGY_S (2.0f)
38*15dc779aSAndroid Build Coastguard Worker #define MASK_HIGH_SP_ENERGY_S (1.5f)
39*15dc779aSAndroid Build Coastguard Worker #define MASK_HIGH_SP_BITRATE_THRESH (22000)
40*15dc779aSAndroid Build Coastguard Worker 
41*15dc779aSAndroid Build Coastguard Worker typedef struct {
42*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_cnt;
43*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_active;
44*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_offsets[MAXIMUM_SCALE_FACTOR_BAND_LONG + 1];
45*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_threshold_quiet[MAXIMUM_SCALE_FACTOR_BAND_LONG];
46*15dc779aSAndroid Build Coastguard Worker   FLOAT32 min_remaining_threshold_factor;
47*15dc779aSAndroid Build Coastguard Worker   WORD32 lowpass_line;
48*15dc779aSAndroid Build Coastguard Worker   FLOAT32 clip_energy;
49*15dc779aSAndroid Build Coastguard Worker   FLOAT32 ratio_float;
50*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_low_factor[MAXIMUM_SCALE_FACTOR_BAND_LONG];
51*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_high_factor[MAXIMUM_SCALE_FACTOR_BAND_LONG];
52*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_low_factor_spread_nrg[MAXIMUM_SCALE_FACTOR_BAND_LONG];
53*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_high_factor_spread_nrg[MAXIMUM_SCALE_FACTOR_BAND_LONG];
54*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_min_snr[MAXIMUM_SCALE_FACTOR_BAND_LONG];
55*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_config str_tns_conf;
56*15dc779aSAndroid Build Coastguard Worker } ixheaace_psy_configuration_long;
57*15dc779aSAndroid Build Coastguard Worker 
58*15dc779aSAndroid Build Coastguard Worker typedef struct {
59*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_cnt;
60*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_active;
61*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_offsets[MAXIMUM_SCALE_FACTOR_BAND_SHORT + 1];
62*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_threshold_quiet[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
63*15dc779aSAndroid Build Coastguard Worker   FLOAT32 min_remaining_threshold_factor;
64*15dc779aSAndroid Build Coastguard Worker   WORD32 lowpass_line;
65*15dc779aSAndroid Build Coastguard Worker   FLOAT32 clip_energy;
66*15dc779aSAndroid Build Coastguard Worker   FLOAT32 ratio_float;
67*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_low_factor[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
68*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_high_factor[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
69*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_low_factor_spread_nrg[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
70*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_mask_high_factor_spread_nrg[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
71*15dc779aSAndroid Build Coastguard Worker   FLOAT32 sfb_min_snr[MAXIMUM_SCALE_FACTOR_BAND_SHORT];
72*15dc779aSAndroid Build Coastguard Worker   ixheaace_temporal_noise_shaping_config str_tns_conf;
73*15dc779aSAndroid Build Coastguard Worker } ixheaace_psy_configuration_short;
74*15dc779aSAndroid Build Coastguard Worker 
75*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ia_enhaacplus_enc_init_psy_configuration(
76*15dc779aSAndroid Build Coastguard Worker     WORD32 bit_rate, WORD32 sample_rate, WORD32 bandwidth, WORD32 aot,
77*15dc779aSAndroid Build Coastguard Worker     ixheaace_psy_configuration_long *pstr_psy_conf, ixheaace_aac_tables *pstr_aac_tables,
78*15dc779aSAndroid Build Coastguard Worker     WORD32 long_frame_len);
79*15dc779aSAndroid Build Coastguard Worker 
80*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ia_enhaacplus_enc_init_psy_configuration_short(
81*15dc779aSAndroid Build Coastguard Worker     WORD32 bit_rate, WORD32 sample_rate, WORD32 bandwidth, WORD32 aot,
82*15dc779aSAndroid Build Coastguard Worker     ixheaace_psy_configuration_short *pstr_psy_conf, ixheaace_aac_tables *pstr_aac_tables,
83*15dc779aSAndroid Build Coastguard Worker     WORD32 long_frame_len);
84