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 #include <math.h> 22*15dc779aSAndroid Build Coastguard Worker #include <stdlib.h> 23*15dc779aSAndroid Build Coastguard Worker #include <string.h> 24*15dc779aSAndroid Build Coastguard Worker #include "ixheaac_type_def.h" 25*15dc779aSAndroid Build Coastguard Worker #include "ixheaac_error_standards.h" 26*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_error_codes.h" 27*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_common_fix.h" 28*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_defines.h" 29*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_common_define.h" 30*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_bitbuffer.h" 31*15dc779aSAndroid Build Coastguard Worker 32*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_static_gain.h" 33*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_bitstream.h" 34*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_struct_def.h" 35*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_sac_polyphase.h" 36*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_sac_nlc_enc.h" 37*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_sac_hybfilter.h" 38*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_spatial_bitstream.h" 39*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_param_extract.h" 40*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_tree.h" 41*15dc779aSAndroid Build Coastguard Worker #include "ixheaace_mps_rom.h" 42*15dc779aSAndroid Build Coastguard Worker ixheaace_mps_212_static_gain_init(ixheaace_mps_pstr_static_gain pstr_static_gain,const ixheaace_mps_pstr_static_gain_config pstr_static_gain_config)43*15dc779aSAndroid Build Coastguard WorkerIA_ERRORCODE ixheaace_mps_212_static_gain_init( 44*15dc779aSAndroid Build Coastguard Worker ixheaace_mps_pstr_static_gain pstr_static_gain, 45*15dc779aSAndroid Build Coastguard Worker const ixheaace_mps_pstr_static_gain_config pstr_static_gain_config) { 46*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE error = IA_NO_ERROR; 47*15dc779aSAndroid Build Coastguard Worker FLOAT32 pre_gain_factor; 48*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->fixed_gain_dmx = pstr_static_gain_config->fixed_gain_dmx; 49*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->pre_gain_factor_db = pstr_static_gain_config->pre_gain_factor_db; 50*15dc779aSAndroid Build Coastguard Worker 51*15dc779aSAndroid Build Coastguard Worker if ((pstr_static_gain->pre_gain_factor_db < -20) || 52*15dc779aSAndroid Build Coastguard Worker (pstr_static_gain->pre_gain_factor_db > 20)) { 53*15dc779aSAndroid Build Coastguard Worker return IA_EXHEAACE_CONFIG_NONFATAL_MPS_INVALID_CONFIG; 54*15dc779aSAndroid Build Coastguard Worker } 55*15dc779aSAndroid Build Coastguard Worker 56*15dc779aSAndroid Build Coastguard Worker if (pstr_static_gain->pre_gain_factor_db) { 57*15dc779aSAndroid Build Coastguard Worker pre_gain_factor = pre_gain_factor_table_flt_new[pstr_static_gain->pre_gain_factor_db + 20]; 58*15dc779aSAndroid Build Coastguard Worker } else { 59*15dc779aSAndroid Build Coastguard Worker pre_gain_factor = 1.0f; 60*15dc779aSAndroid Build Coastguard Worker } 61*15dc779aSAndroid Build Coastguard Worker 62*15dc779aSAndroid Build Coastguard Worker if (pstr_static_gain->fixed_gain_dmx) { 63*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->post_gain = dmx_gain_table_flt[pstr_static_gain->fixed_gain_dmx - 1]; 64*15dc779aSAndroid Build Coastguard Worker } else { 65*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->post_gain = 1.0f; 66*15dc779aSAndroid Build Coastguard Worker } 67*15dc779aSAndroid Build Coastguard Worker 68*15dc779aSAndroid Build Coastguard Worker memset(pstr_static_gain->pre_gain, 0, sizeof(pstr_static_gain->pre_gain)); 69*15dc779aSAndroid Build Coastguard Worker 70*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->pre_gain[0] = pre_gain_factor; 71*15dc779aSAndroid Build Coastguard Worker pstr_static_gain->pre_gain[1] = pre_gain_factor; 72*15dc779aSAndroid Build Coastguard Worker 73*15dc779aSAndroid Build Coastguard Worker return error; 74*15dc779aSAndroid Build Coastguard Worker } 75