1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 /* 12 * settings.h 13 * 14 * Declaration of #defines used in the iSAC codec 15 * 16 */ 17 18 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ 19 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ 20 21 22 /* sampling frequency (Hz) */ 23 #define FS 16000 24 /* 1.5 times Sampling frequency */ 25 #define FS_1_HALF (uint32_t) 24000 26 /* Three times Sampling frequency */ 27 #define FS3 (uint32_t) 48000 28 /* Eight times Sampling frequency */ 29 #define FS8 (uint32_t) 128000 30 31 /* number of samples per frame (either 480 (30ms) or 960 (60ms)) */ 32 #define INITIAL_FRAMESAMPLES 960 33 34 /* miliseconds */ 35 #define FRAMESIZE 30 36 /* number of samples per frame processed in the encoder (30ms) */ 37 #define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ 38 #define FRAMESAMPLES_HALF 240 39 /* max number of samples per frame (= 60 ms frame) */ 40 #define MAX_FRAMESAMPLES 960 41 /* number of samples per 10ms frame */ 42 #define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */ 43 /* Number of samples per 1 ms */ 44 #define SAMPLES_PER_MSEC 16 45 /* number of subframes */ 46 #define SUBFRAMES 6 47 /* length of a subframe */ 48 #define UPDATE 80 49 /* length of half a subframe (low/high band) */ 50 #define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */ 51 /* samples of look ahead (in a half-band, so actually half the samples of look ahead @ FS) */ 52 #define QLOOKAHEAD 24 /* 3 ms */ 53 54 /* order of AR model in spectral entropy coder */ 55 #define AR_ORDER 6 56 #define MAX_ORDER 13 57 #define LEVINSON_MAX_ORDER 12 58 59 /* window length (masking analysis) */ 60 #define WINLEN 256 61 /* order of low-band pole filter used to approximate masking curve */ 62 #define ORDERLO 12 63 /* order of hi-band pole filter used to approximate masking curve */ 64 #define ORDERHI 6 65 66 #define KLT_NUM_AVG_GAIN 0 67 #define KLT_NUM_AVG_SHAPE 0 68 #define KLT_NUM_MODELS 3 69 #define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */ 70 71 #define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */ 72 #define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */ 73 74 75 76 /* order for post_filter_bank */ 77 #define POSTQORDER 3 78 /* order for pre-filterbank */ 79 #define QORDER 3 80 /* for decimator */ 81 #define ALLPASSSECTIONS 2 82 /* The number of composite all-pass filter factors */ 83 #define NUMBEROFCOMPOSITEAPSECTIONS 4 84 85 /* The number of all-pass filter factors in an upper or lower channel*/ 86 #define NUMBEROFCHANNELAPSECTIONS 2 87 88 89 90 #define DPMIN_Q10 -10240 /* -10.00 in Q10 */ 91 #define DPMAX_Q10 10240 /* 10.00 in Q10 */ 92 #define MINBITS_Q10 10240 /* 10.0 in Q10 */ 93 94 95 /* array size for byte stream in number of Word16. */ 96 #define STREAM_MAXW16 300 /* The old maximum size still needed for the decoding */ 97 #define STREAM_MAXW16_30MS 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */ 98 #define STREAM_MAXW16_60MS 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */ 99 100 101 /* storage size for bit counts */ 102 //#define BIT_COUNTER_SIZE 30 103 /* maximum order of any AR model or filter */ 104 #define MAX_AR_MODEL_ORDER 12 105 106 /* Maximum number of iterations allowed to limit payload size */ 107 #define MAX_PAYLOAD_LIMIT_ITERATION 1 108 109 /* Bandwidth estimator */ 110 111 #define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */ 112 #define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */ 113 #define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */ 114 #define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */ 115 #define DELAY_CORRECTION_MAX 717 116 #define DELAY_CORRECTION_MED 819 117 #define Thld_30_60 18000 118 #define Thld_60_30 27000 119 120 /* assumed header size; we don't know the exact number (header compression may be used) */ 121 #define HEADER_SIZE 35 /* bytes */ 122 #define INIT_FRAME_LEN 60 123 #define INIT_BN_EST 20000 124 #define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */ 125 #define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */ 126 127 /* 8738 in Q18 is ~ 1/30 */ 128 /* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT (INIT_FRAME_LEN)) */ 129 #define INIT_HDR_RATE 4666 130 /* number of packets in a row for a high rate burst */ 131 #define BURST_LEN 3 132 /* ms, max time between two full bursts */ 133 #define BURST_INTERVAL 800 134 /* number of packets in a row for initial high rate burst */ 135 #define INIT_BURST_LEN 5 136 /* bits/s, rate for the first BURST_LEN packets */ 137 #define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */ 138 139 140 /* For pitch analysis */ 141 #define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */ 142 #define PITCH_MAX_LAG 140 /* 57 Hz */ 143 #define PITCH_MIN_LAG 20 /* 400 Hz */ 144 #define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */ 145 #define OFFSET_Q8 768 /* 256 * 3 */ 146 147 #define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */ 148 #define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */ 149 #define PITCH_CORR_LEN2 60 /* 15 ms */ 150 #define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */ 151 #define PITCH_SUBFRAMES 4 152 #define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */ 153 154 /* For pitch filter */ 155 #define PITCH_BUFFSIZE 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */ 156 #define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */ 157 #define PITCH_FRACS 8 158 #define PITCH_FRACORDER 9 159 #define PITCH_DAMPORDER 5 160 161 162 /* Order of high pass filter */ 163 #define HPORDER 2 164 165 166 /* PLC */ 167 #define DECAY_RATE 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/ 168 #define PLC_WAS_USED 1 169 #define PLC_NOT_USED 3 170 #define RECOVERY_OVERLAP 80 171 #define RESAMP_RES 256 172 #define RESAMP_RES_BIT 8 173 174 175 176 /* Define Error codes */ 177 /* 6000 General */ 178 #define ISAC_MEMORY_ALLOCATION_FAILED 6010 179 #define ISAC_MODE_MISMATCH 6020 180 #define ISAC_DISALLOWED_BOTTLENECK 6030 181 #define ISAC_DISALLOWED_FRAME_LENGTH 6040 182 /* 6200 Bandwidth estimator */ 183 #define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 184 /* 6400 Encoder */ 185 #define ISAC_ENCODER_NOT_INITIATED 6410 186 #define ISAC_DISALLOWED_CODING_MODE 6420 187 #define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 188 #define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 189 #define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 190 /* 6600 Decoder */ 191 #define ISAC_DECODER_NOT_INITIATED 6610 192 #define ISAC_EMPTY_PACKET 6620 193 #define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 194 #define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 195 #define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 196 #define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 197 #define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 198 #define ISAC_RANGE_ERROR_DECODE_LPC 6680 199 #define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 200 #define ISAC_LENGTH_MISMATCH 6730 201 /* 6800 Call setup formats */ 202 #define ISAC_INCOMPATIBLE_FORMATS 6810 203 204 205 #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ */ 206