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 BLOCK_SWITCH_WINDOWS TRANS_FAC /* number of windows for energy calculation */ 24 #define BLOCK_SWITCH_WINDOW_LEN \ 25 FRAME_LEN_SHORT_128 /* minimal granularity of energy calculation */ 26 27 #define BLK_SWITCH_WIN 8 28 #define BLK_SWITCH_FILT_LEN 2 29 30 /* Block types */ 31 #define LONG_WINDOW 0 32 #define START_WINDOW 1 33 #define SHORT_WINDOW 2 34 #define STOP_WINDOW 3 35 36 /* Window shapes */ 37 #define SINE_WINDOW 0 38 #define KBD_WINDOW 1 39 40 #define MAXIMUM_NO_OF_GROUPS 4 41 42 #define ACC_WINDOW_NRG_FAC 0.3f 43 #define ONE_MINUS_ACC_WINDOW_NRG_FAC 0.7f 44 #define INV_ATTACK_RATIO_HIGH_BR 0.1f 45 #define INV_ATTACK_RATIO_LOW_BR 0.056f 46 #define MIN_ATTACK_NRG (1000000) 47 #define BLK_SWITCH_HIGH_BR_MONO (24000) 48 #define BLK_SWITCH_HIGH_BR_STEREO (16000) 49 50 typedef struct { 51 FLOAT32 inv_attack_ratio; 52 WORD32 win_seq; 53 WORD32 nxt_win_seq; 54 WORD32 attack; 55 WORD32 lastattack; 56 WORD32 attack_idx; 57 WORD32 last_attack_idx; 58 WORD32 total_groups_cnt; 59 WORD32 group_len[TRANS_FAC]; 60 FLOAT32 win_energy[BLK_SWITCH_FILT_LEN][BLK_SWITCH_WIN]; 61 FLOAT32 win_energy_filt[BLK_SWITCH_FILT_LEN][BLK_SWITCH_WIN]; 62 FLOAT32 iir_states[BLK_SWITCH_FILT_LEN]; 63 FLOAT32 max_win_energy; 64 FLOAT32 acc_win_energy; 65 WORD32 win_seq_ld; /* these are used to save window decision for LD. */ 66 WORD32 next_win_seq_ld; /* nxt_win_seq and win_seq are always set to 67 LONG_WINDOW */ 68 } ixheaace_block_switch_control; 69 70 VOID iaace_init_block_switching(ixheaace_block_switch_control *pstr_blk_switch_ctrl, 71 const WORD32 bit_rate, const WORD32 num_chans); 72 73 VOID iaace_block_switching(ixheaace_block_switch_control *pstr_blk_switch_ctrl, 74 const FLOAT32 *ptr_time_signal, WORD32 frame_length, WORD32 num_chans); 75 76 VOID iaace_sync_block_switching(ixheaace_block_switch_control *pstr_blk_switch_left_ctrl, 77 ixheaace_block_switch_control *pstr_blk_switch_right_ctrl, 78 const WORD32 num_channels); 79