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 #define IXHEAACE_ESBR_PVC_MOD_NUM_TAB (2) 23*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1 (3) 24*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2 (128) 25*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_PVCID (128) 26*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_TS (16) 27*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_QMF_BANDS (64) 28*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_QMF_BANDS_CORE (64) 29*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_BANDS_CORE (3) 30*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1 (8) 31*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2 (6) 32*15dc779aSAndroid Build Coastguard Worker 33*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_POW_THRS (0.1f) 34*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NS_MODE_PRD_THRS (2) 35*15dc779aSAndroid Build Coastguard Worker 36*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_RESIDUAL_VAL (1000000.0f) 37*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NTS_GRP_ID (8) 38*15dc779aSAndroid Build Coastguard Worker 39*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_DIV_MODE_BITS (3) 40*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_NS_MODE_BITS (1) 41*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_ID_BITS (7) 42*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_GRID_INFO_BITS (1) 43*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_REUSE_BITS (1) 44*15dc779aSAndroid Build Coastguard Worker 45*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_FLAG_PREV_DFLT (0) 46*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_ID_PREV_DFLT (0xFF) 47*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_RATE_PREV_DFLT (0xFF) 48*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_STRT_BAND_PREV_DFLT (0xFF) 49*15dc779aSAndroid Build Coastguard Worker 50*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_MODE_1 (1) 51*15dc779aSAndroid Build Coastguard Worker #define IXHEAACE_ESBR_PVC_MODE_2 (2) 52*15dc779aSAndroid Build Coastguard Worker 53*15dc779aSAndroid Build Coastguard Worker typedef struct { 54*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_smth_win_ns_16[16]; 55*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_smth_win_ns_12[12]; 56*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_smth_win_ns_4[4]; 57*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_smth_win_ns_3[3]; 58*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_idx_mode_1[IXHEAACE_ESBR_PVC_MOD_NUM_TAB]; 59*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_prd_coef_kb_3_mode_1[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2] 60*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1]; 61*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_prd_coef_kb_012_mode_1[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1] 62*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_CORE] 63*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE1]; 64*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_scaling_coef_mode_1[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE + 1]; 65*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_idx_mode_2[IXHEAACE_ESBR_PVC_MOD_NUM_TAB]; 66*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_prd_coef_kb_3_mode_2[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_2] 67*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2]; 68*15dc779aSAndroid Build Coastguard Worker const UWORD8 pvc_prd_coef_kb_012_mode_2[IXHEAACE_ESBR_PVC_NUM_TAB_IDX_1] 69*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_CORE] 70*15dc779aSAndroid Build Coastguard Worker [IXHEAACE_ESBR_PVC_NUM_BANDS_SBR_MODE2]; 71*15dc779aSAndroid Build Coastguard Worker const FLOAT32 pvc_scaling_coef_mode_2[IXHEAACE_ESBR_PVC_NUM_BANDS_CORE + 1]; 72*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_tabs_struct; 73*15dc779aSAndroid Build Coastguard Worker 74*15dc779aSAndroid Build Coastguard Worker extern const ixheaace_pvc_tabs_struct ixheaace_pvc_tabs; 75*15dc779aSAndroid Build Coastguard Worker 76*15dc779aSAndroid Build Coastguard Worker typedef struct { 77*15dc779aSAndroid Build Coastguard Worker UWORD8 pvc_mode; 78*15dc779aSAndroid Build Coastguard Worker UWORD8 div_mode; 79*15dc779aSAndroid Build Coastguard Worker UWORD8 ns_mode; 80*15dc779aSAndroid Build Coastguard Worker UWORD16 pvc_id[IXHEAACE_ESBR_PVC_NUM_TS]; 81*15dc779aSAndroid Build Coastguard Worker UWORD8 time_smth_ts; 82*15dc779aSAndroid Build Coastguard Worker UWORD8 num_grp_core; 83*15dc779aSAndroid Build Coastguard Worker UWORD8 num_grp_sbr; 84*15dc779aSAndroid Build Coastguard Worker UWORD8 hbw; 85*15dc779aSAndroid Build Coastguard Worker UWORD8 num_pvc_id; 86*15dc779aSAndroid Build Coastguard Worker UWORD8 pvc_rate; 87*15dc779aSAndroid Build Coastguard Worker WORD32 usac_indep_flag; 88*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_params; 89*15dc779aSAndroid Build Coastguard Worker 90*15dc779aSAndroid Build Coastguard Worker typedef struct { 91*15dc779aSAndroid Build Coastguard Worker UWORD16 pvc_id; 92*15dc779aSAndroid Build Coastguard Worker UWORD8 start_band; 93*15dc779aSAndroid Build Coastguard Worker UWORD8 pvc_flag; 94*15dc779aSAndroid Build Coastguard Worker UWORD8 pvc_mode; 95*15dc779aSAndroid Build Coastguard Worker UWORD8 pvc_rate; 96*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_prv_frm_params; 97*15dc779aSAndroid Build Coastguard Worker 98*15dc779aSAndroid Build Coastguard Worker typedef struct { 99*15dc779aSAndroid Build Coastguard Worker const FLOAT32 *smoothing_coef; 100*15dc779aSAndroid Build Coastguard Worker const FLOAT32 *scaling_coef; 101*15dc779aSAndroid Build Coastguard Worker const UWORD8 *pvc_pred_coef_kb_3; 102*15dc779aSAndroid Build Coastguard Worker const UWORD8 *pvc_pred_coef_kb_012; 103*15dc779aSAndroid Build Coastguard Worker const UWORD8 *pvc_idx_tab; 104*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_coef_tabs; 105*15dc779aSAndroid Build Coastguard Worker 106*15dc779aSAndroid Build Coastguard Worker typedef struct { 107*15dc779aSAndroid Build Coastguard Worker UWORD8 div_mode; 108*15dc779aSAndroid Build Coastguard Worker UWORD8 grid_info[IXHEAACE_ESBR_PVC_NUM_TS]; 109*15dc779aSAndroid Build Coastguard Worker UWORD8 ns_mode; 110*15dc779aSAndroid Build Coastguard Worker WORD32 num_grid_info; 111*15dc779aSAndroid Build Coastguard Worker UWORD16 pvc_id_bs[IXHEAACE_ESBR_PVC_NUM_TS]; 112*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_bs_info; 113*15dc779aSAndroid Build Coastguard Worker 114*15dc779aSAndroid Build Coastguard Worker typedef struct { 115*15dc779aSAndroid Build Coastguard Worker ixheaace_pvc_bs_info pvc_bs_info; 116*15dc779aSAndroid Build Coastguard Worker ixheaace_pvc_params pvc_param; 117*15dc779aSAndroid Build Coastguard Worker ixheaace_pvc_prv_frm_params pvc_prv_param; 118*15dc779aSAndroid Build Coastguard Worker ixheaace_pvc_coef_tabs pvc_tabs; 119*15dc779aSAndroid Build Coastguard Worker FLOAT32 sb_grp_energy[IXHEAACE_ESBR_PVC_NUM_TS + 16 - 1][3]; 120*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_enc; 121*15dc779aSAndroid Build Coastguard Worker 122*15dc779aSAndroid Build Coastguard Worker typedef struct { 123*15dc779aSAndroid Build Coastguard Worker FLOAT32 pvc_qmf_low[IXHEAACE_ESBR_PVC_NUM_TS * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS_CORE]; 124*15dc779aSAndroid Build Coastguard Worker FLOAT32 pvc_qmf_high[IXHEAACE_ESBR_PVC_NUM_TS * IXHEAACE_ESBR_PVC_NUM_QMF_BANDS]; 125*15dc779aSAndroid Build Coastguard Worker } ixheaace_pvc_scratch; 126*15dc779aSAndroid Build Coastguard Worker 127*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ixheaace_pvc_enc_init(ixheaace_pvc_enc *pstr_pvc_enc, WORD32 sbr_pvc_rate); 128*15dc779aSAndroid Build Coastguard Worker 129*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ixheaace_pvc_encode_frame(ixheaace_pvc_enc *pstr_pvc_enc, UWORD8 pvc_mode, 130*15dc779aSAndroid Build Coastguard Worker FLOAT32 *ptr_qmf_low, FLOAT32 *ptr_qmf_high, 131*15dc779aSAndroid Build Coastguard Worker UWORD8 start_band, UWORD8 stop_band); 132