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