00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined(_ILBC_ILBC_H_)
00025 #define _ILBC_ILBC_H_
00026
00027 #define ILBC_BLOCK_LEN_20MS 160
00028 #define ILBC_BLOCK_LEN_30MS 240
00029 #define ILBC_BLOCK_LEN_MAX 240
00030
00031 #define ILBC_NO_OF_BYTES_20MS 38
00032 #define ILBC_NO_OF_BYTES_30MS 50
00033 #define ILBC_NO_OF_BYTES_MAX 50
00034
00035 #define ILBC_NUM_SUB_MAX 6
00036
00037 #define SUBL 40
00038
00039 #define ENH_BLOCKL 80
00040 #define ENH_NBLOCKS_TOT 8
00041 #define ENH_BUFL (ENH_NBLOCKS_TOT*ENH_BLOCKL)
00042
00043 #define ILBC_LPC_FILTERORDER 10
00044 #define LPC_LOOKBACK 60
00045
00046 #define CB_NSTAGES 3
00047
00048 #define STATE_BITS 3
00049 #define BYTE_LEN 8
00050 #define ILBC_ULP_CLASSES 3
00051
00052 typedef struct
00053 {
00054 int lsf_bits[6][ILBC_ULP_CLASSES + 2];
00055 int start_bits[ILBC_ULP_CLASSES + 2];
00056 int startfirst_bits[ILBC_ULP_CLASSES + 2];
00057 int scale_bits[ILBC_ULP_CLASSES + 2];
00058 int state_bits[ILBC_ULP_CLASSES + 2];
00059 int extra_cb_index[CB_NSTAGES][ILBC_ULP_CLASSES + 2];
00060 int extra_cb_gain[CB_NSTAGES][ILBC_ULP_CLASSES + 2];
00061 int cb_index[ILBC_NUM_SUB_MAX][CB_NSTAGES][ILBC_ULP_CLASSES + 2];
00062 int cb_gain[ILBC_NUM_SUB_MAX][CB_NSTAGES][ILBC_ULP_CLASSES + 2];
00063 } ilbc_ulp_inst_t;
00064
00065
00066 typedef struct
00067 {
00068
00069 int mode;
00070
00071
00072 int blockl;
00073 int nsub;
00074 int nasub;
00075 int no_of_bytes;
00076 int lpc_n;
00077 int state_short_len;
00078 const ilbc_ulp_inst_t *ULP_inst;
00079
00080
00081 float anaMem[ILBC_LPC_FILTERORDER];
00082
00083
00084 float lsfold[ILBC_LPC_FILTERORDER];
00085 float lsfdeqold[ILBC_LPC_FILTERORDER];
00086
00087
00088 float lpc_buffer[LPC_LOOKBACK + ILBC_BLOCK_LEN_MAX];
00089
00090
00091 float hpimem[4];
00092 } ilbc_encode_state_t;
00093
00094
00095 typedef struct
00096 {
00097
00098 int mode;
00099
00100
00101 int blockl;
00102 int nsub;
00103 int nasub;
00104 int no_of_bytes;
00105 int lpc_n;
00106 int state_short_len;
00107 const ilbc_ulp_inst_t *ULP_inst;
00108
00109
00110 float syntMem[ILBC_LPC_FILTERORDER];
00111
00112
00113 float lsfdeqold[ILBC_LPC_FILTERORDER];
00114
00115
00116 int last_lag;
00117
00118
00119 int prevLag, consPLICount, prevPLI, prev_enh_pl;
00120 float prevLpc[ILBC_LPC_FILTERORDER + 1];
00121 float prevResidual[ILBC_NUM_SUB_MAX*SUBL];
00122 float per;
00123 unsigned long seed;
00124
00125
00126 float old_syntdenum[(ILBC_LPC_FILTERORDER + 1)*ILBC_NUM_SUB_MAX];
00127
00128
00129 float hpomem[4];
00130
00131
00132 int use_enhancer;
00133 float enh_buf[ENH_BUFL];
00134 float enh_period[ENH_NBLOCKS_TOT];
00135 } ilbc_decode_state_t;
00136
00137 ilbc_encode_state_t *ilbc_encode_init(ilbc_encode_state_t *s,
00138 int mode);
00139
00140 int ilbc_encode(ilbc_encode_state_t *s,
00141 uint8_t bytes[],
00142 const int16_t amp[],
00143 int len);
00144
00145 ilbc_decode_state_t *ilbc_decode_init(ilbc_decode_state_t *s,
00146 int mode,
00147 int use_enhancer);
00148
00149
00150 int ilbc_decode(ilbc_decode_state_t *s,
00151 int16_t amp[],
00152 const uint8_t bytes[],
00153 int len);
00154
00155 int ilbc_fillin(ilbc_decode_state_t *s,
00156 int16_t amp[],
00157 int len);
00158
00159 #endif