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 #ifndef TRUE 23 #define TRUE (1) 24 #endif 25 #ifndef FALSE 26 #define FALSE (0) 27 #endif 28 29 #ifndef PI 30 #define PI (3.14159265358979323846f) 31 #endif 32 33 #define CORE_MODE_FD (0) 34 #define CORE_MODE_TD (1) 35 #define USAC_SWITCHED (0) 36 #define USAC_ONLY_FD (1) 37 #define USAC_ONLY_TD (2) 38 39 #define TREE_212 (0) 40 #define TREE_5151 (1) 41 #define TREE_5152 (2) 42 #define TREE_525 (3) 43 #define INVALID_TREE_CONFIG (-1) 44 45 #define ONLY_LONG_SEQUENCE (0) 46 #define LONG_START_SEQUENCE (1) 47 48 #define LONG_STOP_SEQUENCE (3) 49 #define STOP_START_SEQUENCE (4) 50 #define NSFB_SHORT (16) 51 #define MAX_SHORT_IN_LONG_BLOCK (8) 52 #define MAX_SHORT_WINDOWS (8) 53 #define MAX_SFB_LONG 51 54 #define FRAME_LEN_LONG 1024 55 #define FRAME_LEN_SHORT_768 (96) 56 #define MAX_TIME_CHANNELS (2) 57 #define MAX_SF_BANDS ((NSFB_SHORT + 1) * MAX_SHORT_IN_LONG_BLOCK) 58 #define MAX_SHIFT_LEN_LONG (4096) 59 #define TD_BUFFER_OFFSET (448 + 64) 60 #define MAX_EXTENSION_PAYLOADS MAX_TIME_CHANNELS 61 #define MAX_EXTENSION_PAYLOAD_LEN 6144 / 8 * MAX_TIME_CHANNELS 62 63 #define WIN_SEL_0 0 64 #define WIN_SEL_1 1 65 66 #define LEN_SUPERFRAME (1024) 67 #define LEN_SUPERFRAME_768 (768) 68 #define LEN_WIN_PLUS (512) 69 #define OVERLAP_WIN_SIZE_576 (576) 70 71 #define ORDER (16) 72 #define ORDER_BY_2 (8) 73 74 #define LEN_FRAME (256) 75 #define NUM_FRAMES (4) 76 #define MAX_NUM_SUBFR (4) 77 #define LEN_SUBFR (64) 78 79 #define N_MAX (LEN_SUPERFRAME) 80 #define FAC_LENGTH (LEN_FRAME / 2) 81 #define NUM_SUBFR_SUPERFRAME (NUM_FRAMES * MAX_NUM_SUBFR) 82 #define FDNS_RESOLUTION (64) 83 84 #define LEN_NEXT_HIGH_RATE (288) 85 #define LEN_LPC0 (256) 86 #define LEN_LP_WINDOW (448) 87 #define LEN_LP_WINDOW_HIGH_RATE (512) 88 89 #define SR_MIN (6000) 90 #define SR_MAX (32000) 91 92 #define FSCALE_DENOM (12800) 93 #define FAC_FSCALE_MAX (24000) 94 95 #define LEN_TOTAL_HIGH_RATE (ORDER + LEN_SUPERFRAME + LEN_NEXT_HIGH_RATE) 96 97 #define FILTER_DELAY (12) 98 99 #define TMIN (34) 100 #define TFR2 (128) 101 #define TFR1 (160) 102 #define TMAX (231) 103 104 #define T_UP_SAMP (4) 105 #define INTER_LP_FIL_ORDER (16) 106 #define INTER_LP_FIL_LEN (T_UP_SAMP * INTER_LP_FIL_ORDER + 1) 107 108 /* upto 410 for 24k sampling rate */ 109 #define MAX_PITCH \ 110 (TMAX + (6 * ((((FAC_FSCALE_MAX * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN))) 111 112 /* upto 536 for 32k sampling rate */ 113 #define MAX_PITCH1 (TMAX + (6 * ((((32000 * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN))) 114 115 #define LEN_INTERPOL (16 + 1) 116 #define OPL_DECIM (2) 117 #define PREEMPH_FILT_FAC (0.68f) 118 #define TILT_FAC (0.68f) 119 #define PIT_SHARP (0.85f) 120 #define TILT_CODE (0.3f) 121 122 /* AMR_WB+ mode relative to AMR-WB core */ 123 #define ACELP_CORE_MODE_9k6 (0) 124 #define ACELP_CORE_MODE_11k2 (1) 125 #define ACELP_CORE_MODE_12k8 (2) 126 #define ACELP_CORE_MODE_14k4 (3) 127 #define ACELP_CORE_MODE_16k (4) 128 #define ACELP_CORE_MODE_18k4 (5) 129 130 #define ACELP_NUM_BITS_20 (20) 131 #define ACELP_NUM_BITS_28 (28) 132 #define ACELP_NUM_BITS_36 (36) 133 #define ACELP_NUM_BITS_44 (44) 134 #define ACELP_NUM_BITS_52 (52) 135 #define ACELP_NUM_BITS_64 (64) 136 #define ACELP_NUM_BITS_72 (72) 137 #define ACELP_NUM_BITS_88 (88) 138 139 #define NUM_ACELP_CORE_MODES (6) 140 #define NBITS_MAX (48 * 80 + 46) 141 142 #define NBITS_MODE (4 * 2) 143 #define NBITS_LPC (46) 144 145 #define NUM_RE8_PRM (LEN_SUPERFRAME + (LEN_SUPERFRAME / 8)) 146 147 #define NUM_TCX80_PRM (FAC_LENGTH + 2 + NUM_RE8_PRM) 148 #define NUM_TCX40_PRM (FAC_LENGTH + 2 + (NUM_RE8_PRM / 2)) 149 #define NUM_TCX20_PRM (FAC_LENGTH + 2 + (320 + 320 / 8)) 150 151 #define NUM_LPC_PRM (256) 152 #define MAX_NUM_TCX_PRM_PER_DIV (NUM_TCX20_PRM) 153 154 #define L_OLD_SPEECH_HIGH_RATE LEN_TOTAL_HIGH_RATE - LEN_SUPERFRAME 155 156 #define HP_ORDER (3) 157 #define LEN_INTERPOL1 (4) 158 159 #define NUM_OPEN_LOOP_LAGS (5) 160 #define OPEN_LOOP_LAG_MEDIAN (3) 161 #define DECIM2_FIR_FILT_MEM_SIZE (3) 162 163 #define NUM_QUANTIZATION_LEVEL (128) 164 #define LEV_DUR_MAX_ORDER (24) 165 #define PI_BY_6400 (PI / 6400.0) 166 #define LEN_FRAME_16K 320 167 #define ORDER_LP_FILT_16K (20) 168 #define LSP_2_LSF_SCALE (6400.0 / PI) 169 #define FREQ_MAX (6400.0f) 170 #define FREQ_DIV (400.0f) 171 #define CHEBYSHEV_NUM_ITER (4) 172 #define CHEBYSHEV_NUM_POINTS (100) 173 #define LSF_GAP (50.0f) 174 175 #define MAX_NUM_PULSES (24) 176 #define NPMAXPT ((MAX_NUM_PULSES + 4 - 1) / 4) 177 #define ACELP_GAIN_TBL_OFFSET (64) 178 #define ACELP_RANGE_GAIN_PT_IDX_SEARCH (NUM_QUANTIZATION_LEVEL - ACELP_GAIN_TBL_OFFSET) 179 #define ACELP_SEARCH_RANGE_QUANTIZER_IDX (128) 180 181 #define MAX_FLT_VAL (3.402823466e+38F) 182 #define MIN_FLT_VAL (1.175494351e-38F) 183 #define MIN_SHRT_VAL (-32768) 184 #define MAX_SHRT_VAL (32767) 185 186 #define LAG_MIN (64) // if 48k is max sr-- corresponding pitch_min/2 187 #define LAG_MAX (408) // if 48k is max sr-- corresponding pitch_max/2 188 #define LEN_CORR_R (LAG_MAX - LAG_MIN + 1) 189 190 #define CODE_BOOK_ALPHA_LAV 121 191 192 #define MDST_TX_FLAG (0) 193 #define MDCT_TX_FLAG (1) 194 195 #define NO_SBR_CCFL_768 (0) 196 #define NO_SBR_CCFL_1024 (1) 197 #define SBR_8_3 (2) 198 #define SBR_2_1 (3) 199 #define SBR_4_1 (4) 200 201 #define USACE_MAX_SCR_SIZE (733836) 202 #define USACE_SCR_STACK (10 * 1024) 203 #define MAX_USAC_ESBR_BITRATE (96000) 204 205 #define MAX_PREROLL_FRAMES (3) 206 #define MAX_OUTPUT_BYTES_PER_CH (768) 207 #define MAXIMUM_VALUE_8BIT (255) 208 #define DEFAULT_RAP_INTERVAL_IN_MS (-1) 209 #define MIN_RAP_INTERVAL_IN_MS (1000) 210 #define MAX_PREROLL_CONFIG_SIZE (1024) 211 #define CC_NUM_PREROLL_FRAMES (1) 212 #define USAC_FIRST_FRAME_FLAG_DEFAULT_VALUE (1) 213