107 int n, k, meml_gotten, Nfor, Nback, i, pos;
112 unsigned char *pbytes;
113 int diff, start_pos, state_first;
115 int index, ulp, firstpart;
116 int subcount, subframe;
126 data, (*iLBCenc_inst).hpimem);
134 LPCencode(syntdenum, weightdenum, lsf_i, data, iLBCenc_inst);
139 for (n=0; n<iLBCenc_inst->
nsub; n++) {
141 SUBL, &residual[n*SUBL], iLBCenc_inst->
anaMem);
153 index = (start-1)*
SUBL;
160 en1 += residual[index+i]*residual[index+i];
163 index = (start-1)*
SUBL+diff;
165 en2 += residual[index+i]*residual[index+i];
171 start_pos = (start-1)*
SUBL;
174 start_pos = (start-1)*
SUBL + diff;
197 decresidual+start_pos,
203 iCBSearch(iLBCenc_inst, extra_cb_index, extra_gain_index,
219 extra_cb_index, extra_gain_index,
228 for (k=0; k<diff; k++) {
229 reverseResidual[k] = residual[(start+1)*
SUBL-1
236 for (k=0; k<meml_gotten; k++) {
237 mem[
CB_MEML-1-k] = decresidual[start_pos + k];
239 memset(mem, 0, (
CB_MEML-k)*
sizeof(
float));
244 iCBSearch(iLBCenc_inst, extra_cb_index, extra_gain_index,
258 for (k=0; k<diff; k++) {
259 decresidual[start_pos-1-k] = reverseDecresidual[k];
274 Nfor = iLBCenc_inst->
nsub-start-1;
288 for (subframe=0; subframe<Nfor; subframe++) {
293 gain_index+subcount*CB_NSTAGES,
294 &residual[(start+1+subframe)*
SUBL],
296 memLfTbl[subcount], SUBL, CB_NSTAGES,
297 &weightdenum[(start+1+subframe)*
299 weightState, subcount+1);
304 cb_index+subcount*CB_NSTAGES,
305 gain_index+subcount*CB_NSTAGES,
307 memLfTbl[subcount], SUBL, CB_NSTAGES);
311 memmove(mem, mem+SUBL, (
CB_MEML-SUBL)*
sizeof(
float));
318 &decresidual[(start+1+subframe)*SUBL],
336 for (n=0; n<Nback; n++) {
337 for (k=0; k<
SUBL; k++) {
338 reverseResidual[n*SUBL+k] =
339 residual[(start-1)*SUBL-1-n*SUBL-k];
340 reverseDecresidual[n*SUBL+k] =
341 decresidual[(start-1)*SUBL-1-n*SUBL-k];
347 meml_gotten = SUBL*(iLBCenc_inst->
nsub+1-start);
353 for (k=0; k<meml_gotten; k++) {
354 mem[
CB_MEML-1-k] = decresidual[(start-1)*SUBL + k];
356 memset(mem, 0, (
CB_MEML-k)*
sizeof(
float));
361 for (subframe=0; subframe<Nback; subframe++) {
365 iCBSearch(iLBCenc_inst, cb_index+subcount*CB_NSTAGES,
371 gain_index+subcount*CB_NSTAGES,
372 &reverseResidual[subframe*SUBL],
374 memLfTbl[subcount], SUBL, CB_NSTAGES,
375 &weightdenum[(start-2-subframe)*
377 weightState, subcount+1);
382 cb_index+subcount*CB_NSTAGES,
383 gain_index+subcount*CB_NSTAGES,
385 memLfTbl[subcount], SUBL, CB_NSTAGES);
389 memmove(mem, mem+SUBL, (
CB_MEML-SUBL)*
sizeof(
float));
391 &reverseDecresidual[subframe*SUBL],
401 for (i=0; i<SUBL*Nback; i++) {
402 decresidual[SUBL*Nback - i - 1] =
403 reverseDecresidual[i];
418 for (ulp=0; ulp<3; ulp++) {
427 packsplit(&lsf_i[k], &firstpart, &lsf_i[k],
432 dopack( &pbytes, firstpart,
443 dopack( &pbytes, firstpart,
446 packsplit(&state_first, &firstpart, &state_first,
451 dopack( &pbytes, firstpart,
454 packsplit(&idxForMax, &firstpart, &idxForMax,
459 dopack( &pbytes, firstpart,
463 packsplit(idxVec+k, &firstpart, idxVec+k,
468 dopack( &pbytes, firstpart,
486 dopack( &pbytes, firstpart,
492 packsplit(extra_gain_index+k, &firstpart,
498 dopack( &pbytes, firstpart,
505 for (i=0; i<iLBCenc_inst->
nasub; i++) {
507 packsplit(cb_index+i*CB_NSTAGES+k, &firstpart,
508 cb_index+i*CB_NSTAGES+k,
513 dopack( &pbytes, firstpart,
519 for (i=0; i<iLBCenc_inst->
nasub; i++) {
521 packsplit(gain_index+i*CB_NSTAGES+k, &firstpart,
522 gain_index+i*CB_NSTAGES+k,
532 dopack( &pbytes, firstpart,
541 dopack( &pbytes, 0, 1, &pos);
void LPCencode(float *syntdenum, float *weightdenum, int *lsf_index, float *data, iLBC_Enc_Inst_t *iLBCenc_inst)
float anaMem[LPC_FILTERORDER]
int extra_cb_index[CB_NSTAGES][ULP_CLASSES+2]
void iCBSearch(iLBC_Enc_Inst_t *iLBCenc_inst, int *index, int *gain_index, float *intarget, float *mem, int lMem, int lTarget, int nStages, float *weightDenum, float *weightState, int block)
void packsplit(int *index, int *firstpart, int *rest, int bitno_firstpart, int bitno_total)
const iLBC_ULP_Inst_t * ULP_inst
void iCBConstruct(float *decvector, int *index, int *gain_index, float *mem, int lMem, int veclen, int nStages)
int cb_index[NSUB_MAX][CB_NSTAGES][ULP_CLASSES+2]
void StateConstructW(int idxForMax, int *idxVec, float *syntDenum, float *out, int len)
void index_conv_enc(int *index)
int lsf_bits[6][ULP_CLASSES+2]
int scale_bits[ULP_CLASSES+2]
int cb_gain[NSUB_MAX][CB_NSTAGES][ULP_CLASSES+2]
int state_bits[ULP_CLASSES+2]
int extra_cb_gain[CB_NSTAGES][ULP_CLASSES+2]
void StateSearchW(iLBC_Enc_Inst_t *iLBCenc_inst, float *residual, float *syntDenum, float *weightDenum, int *idxForMax, int *idxVec, int len, int state_first)
int startfirst_bits[ULP_CLASSES+2]
void anaFilter(float *In, float *a, int len, float *Out, float *mem)
int FrameClassify(iLBC_Enc_Inst_t *iLBCenc_inst, float *residual)
void dopack(unsigned char **bitstream, int index, int bitno, int *pos)
int start_bits[ULP_CLASSES+2]