void WebRtcIlbcfix_GetCbVec( int16_t *cbvec, /* (o) Constructed codebook vector */ int16_t *mem, /* (i) Codebook buffer */ int16_t index, /* (i) Codebook index */ int16_t lMem, /* (i) Length of codebook buffer */ int16_t cbveclen /* (i) Codebook vector length */ ){ int16_t k, base_size; int16_t lag; /* Stack based */ int16_t tempbuff2[SUBL+5]; /* Determine size of codebook sections */ base_size=lMem-cbveclen+1; if (cbveclen==SUBL) { base_size+=WEBRTC_SPL_RSHIFT_W16(cbveclen,1); } /* No filter -> First codebook section */ if (index<lMem-cbveclen+1) { /* first non-interpolated vectors */ k=index+cbveclen; /* get vector */ WEBRTC_SPL_MEMCPY_W16(cbvec, mem+lMem-k, cbveclen); } else if (index < base_size) { /* Calculate lag */ k=(int16_t)WEBRTC_SPL_MUL_16_16(2, (index-(lMem-cbveclen+1)))+cbveclen; lag=WEBRTC_SPL_RSHIFT_W16(k, 1); WebRtcIlbcfix_CreateAugmentedVec(lag, mem+lMem, cbvec); } /* Higher codebbok section based on filtering */ else { int16_t memIndTest; /* first non-interpolated vectors */ if (index-base_size<lMem-cbveclen+1) { /* Set up filter memory, stuff zeros outside memory buffer */ memIndTest = lMem-(index-base_size+cbveclen); WebRtcSpl_MemSetW16(mem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN); WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); /* do filtering to get the codebook vector */ WebRtcSpl_FilterMAFastQ12( &mem[memIndTest+4], cbvec, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, cbveclen); } /* interpolated vectors */ else { /* Stuff zeros outside memory buffer */ memIndTest = lMem-cbveclen-CB_FILTERLEN; WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); /* do filtering */ WebRtcSpl_FilterMAFastQ12( &mem[memIndTest+7], tempbuff2, (int16_t*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, (int16_t)(cbveclen+5)); /* Calculate lag index */ lag = (cbveclen<<1)-20+index-base_size-lMem-1; WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); } } }
void WebRtcIlbcfix_EncodeImpl( WebRtc_UWord16 *bytes, /* (o) encoded data bits iLBC */ const WebRtc_Word16 *block, /* (i) speech vector to encode */ iLBC_Enc_Inst_t *iLBCenc_inst /* (i/o) the general encoder state */ ){ int n, meml_gotten, Nfor, Nback; WebRtc_Word16 diff, start_pos; int index; int subcount, subframe; WebRtc_Word16 start_count, end_count; WebRtc_Word16 *residual; WebRtc_Word32 en1, en2; WebRtc_Word16 scale, max; WebRtc_Word16 *syntdenum; WebRtc_Word16 *decresidual; WebRtc_Word16 *reverseResidual; WebRtc_Word16 *reverseDecresidual; /* Stack based */ WebRtc_Word16 weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; WebRtc_Word16 dataVec[BLOCKL_MAX + LPC_FILTERORDER]; WebRtc_Word16 memVec[CB_MEML+CB_FILTERLEN]; WebRtc_Word16 bitsMemory[sizeof(iLBC_bits)/sizeof(WebRtc_Word16)]; iLBC_bits *iLBCbits_inst = (iLBC_bits*)bitsMemory; #ifdef SPLIT_10MS WebRtc_Word16 *weightdenumbuf = iLBCenc_inst->weightdenumbuf; WebRtc_Word16 last_bit; #endif WebRtc_Word16 *data = &dataVec[LPC_FILTERORDER]; WebRtc_Word16 *mem = &memVec[CB_HALFFILTERLEN]; /* Reuse som buffers to save stack memory */ residual = &iLBCenc_inst->lpc_buffer[LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl]; syntdenum = mem; /* syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX] and mem are used non overlapping in the code */ decresidual = residual; /* Already encoded residual is overwritten by the decoded version */ reverseResidual = data; /* data and reverseResidual are used non overlapping in the code */ reverseDecresidual = reverseResidual; /* Already encoded residual is overwritten by the decoded version */ #ifdef SPLIT_10MS WebRtcSpl_MemSetW16 ( (WebRtc_Word16 *) iLBCbits_inst, 0, (WebRtc_Word16) (sizeof(iLBC_bits) / sizeof(WebRtc_Word16)) ); start_pos = iLBCenc_inst->start_pos; diff = iLBCenc_inst->diff; if (iLBCenc_inst->section != 0){ WEBRTC_SPL_MEMCPY_W16 (weightdenum, weightdenumbuf, SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); /* Un-Packetize the frame into parameters */ last_bit = WebRtcIlbcfix_UnpackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); if (last_bit) return; /* adjust index */ WebRtcIlbcfix_IndexConvDec (iLBCbits_inst->cb_index); if (iLBCenc_inst->section == 1){ /* Save first 80 samples of a 160/240 sample frame for 20/30msec */ WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples, block, 80); } else{ // iLBCenc_inst->section == 2 AND mode = 30ms /* Save second 80 samples of a 240 sample frame for 30msec */ WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples + 80, block, 80); } } else{ // iLBCenc_inst->section == 0 /* form a complete frame of 160/240 for 20msec/30msec mode */ WEBRTC_SPL_MEMCPY_W16 (data + (iLBCenc_inst->mode * 8) - 80, block, 80); WEBRTC_SPL_MEMCPY_W16 (data, iLBCenc_inst->past_samples, (iLBCenc_inst->mode * 8) - 80); iLBCenc_inst->Nfor_flag = 0; iLBCenc_inst->Nback_flag = 0; #else /* copy input block to data*/ WEBRTC_SPL_MEMCPY_W16(data,block,iLBCenc_inst->blockl); #endif /* high pass filtering of input signal and scale down the residual (*0.5) */ WebRtcIlbcfix_HpInput(data, (WebRtc_Word16*)WebRtcIlbcfix_kHpInCoefs, iLBCenc_inst->hpimemy, iLBCenc_inst->hpimemx, iLBCenc_inst->blockl); /* LPC of hp filtered input data */ WebRtcIlbcfix_LpcEncode(syntdenum, weightdenum, iLBCbits_inst->lsf, data, iLBCenc_inst); /* Set up state */ WEBRTC_SPL_MEMCPY_W16(dataVec, iLBCenc_inst->anaMem, LPC_FILTERORDER); /* inverse filter to get residual */ for (n=0; n<iLBCenc_inst->nsub; n++ ) { WebRtcSpl_FilterMAFastQ12( &data[n*SUBL], &residual[n*SUBL], &syntdenum[n*(LPC_FILTERORDER+1)], LPC_FILTERORDER+1, SUBL); } /* Copy the state for next frame */ WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->anaMem, &data[iLBCenc_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); /* find state location */ iLBCbits_inst->startIdx = WebRtcIlbcfix_FrameClassify(iLBCenc_inst,residual); /* check if state should be in first or last part of the two subframes */ index = (iLBCbits_inst->startIdx-1)*SUBL; max=WebRtcSpl_MaxAbsValueW16(&residual[index], 2*SUBL); scale=WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max,max)); /* Scale to maximum 25 bits so that the MAC won't cause overflow */ scale = scale - 25; if(scale < 0) { scale = 0; } diff = STATE_LEN - iLBCenc_inst->state_short_len; en1=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], iLBCenc_inst->state_short_len, scale); index += diff; en2=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], iLBCenc_inst->state_short_len, scale); if (en1 > en2) { iLBCbits_inst->state_first = 1; start_pos = (iLBCbits_inst->startIdx-1)*SUBL; } else { iLBCbits_inst->state_first = 0; start_pos = (iLBCbits_inst->startIdx-1)*SUBL + diff; } /* scalar quantization of state */ WebRtcIlbcfix_StateSearch(iLBCenc_inst, iLBCbits_inst, &residual[start_pos], &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)]); WebRtcIlbcfix_StateConstruct(iLBCbits_inst->idxForMax, iLBCbits_inst->idxVec, &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], &decresidual[start_pos], iLBCenc_inst->state_short_len ); /* predictive quantization in state */ if (iLBCbits_inst->state_first) { /* put adaptive part in the end */ /* setup memory */ WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-iLBCenc_inst->state_short_len)); WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCenc_inst->state_short_len, decresidual+start_pos, iLBCenc_inst->state_short_len); /* encode subframes */ WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, &residual[start_pos+iLBCenc_inst->state_short_len], mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, &weightdenum[iLBCbits_inst->startIdx*(LPC_FILTERORDER+1)], 0); /* construct decoded vector */ WebRtcIlbcfix_CbConstruct(&decresidual[start_pos+iLBCenc_inst->state_short_len], iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff ); } else { /* put adaptive part in the beginning */ /* create reversed vectors for prediction */ WebRtcSpl_MemCpyReversedOrder(&reverseResidual[diff-1], &residual[(iLBCbits_inst->startIdx+1)*SUBL-STATE_LEN], diff); /* setup memory */ meml_gotten = iLBCenc_inst->state_short_len; WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[start_pos], meml_gotten); WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-iLBCenc_inst->state_short_len)); /* encode subframes */ WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, reverseResidual, mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], 0); /* construct decoded vector */ WebRtcIlbcfix_CbConstruct(reverseDecresidual, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff ); /* get decoded residual from reversed vector */ WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], reverseDecresidual, diff); } #ifdef SPLIT_10MS iLBCenc_inst->start_pos = start_pos; iLBCenc_inst->diff = diff; iLBCenc_inst->section++; /* adjust index */ WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); /* Packetize the parameters into the frame */ WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); return; } #endif /* forward prediction of subframes */ Nfor = iLBCenc_inst->nsub-iLBCbits_inst->startIdx-1; /* counter for predicted subframes */ #ifdef SPLIT_10MS if (iLBCenc_inst->mode == 20) { subcount = 1; } if (iLBCenc_inst->mode == 30) { if (iLBCenc_inst->section == 1) { subcount = 1; } if (iLBCenc_inst->section == 2) { subcount = 3; } } #else subcount=1; #endif if( Nfor > 0 ){ /* setup memory */ WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, decresidual+(iLBCbits_inst->startIdx-1)*SUBL, STATE_LEN); #ifdef SPLIT_10MS if (iLBCenc_inst->Nfor_flag > 0) { for (subframe = 0; subframe < WEBRTC_SPL_MIN (Nfor, 2); subframe++) { /* update memory */ WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, &decresidual[(iLBCbits_inst->startIdx + 1 + subframe) * SUBL], SUBL); } } iLBCenc_inst->Nfor_flag++; if (iLBCenc_inst->mode == 20) { start_count = 0; end_count = Nfor; } if (iLBCenc_inst->mode == 30) { if (iLBCenc_inst->section == 1) { start_count = 0; end_count = WEBRTC_SPL_MIN (Nfor, 2); } if (iLBCenc_inst->section == 2) { start_count = WEBRTC_SPL_MIN (Nfor, 2); end_count = Nfor; } } #else start_count = 0; end_count = (WebRtc_Word16)Nfor; #endif /* loop over subframes to encode */ for (subframe = start_count; subframe < end_count; subframe++){ /* encode subframe */ WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &residual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], mem, MEM_LF_TBL, SUBL, &weightdenum[(iLBCbits_inst->startIdx+1+subframe)*(LPC_FILTERORDER+1)], (WebRtc_Word16)subcount); /* construct decoded vector */ WebRtcIlbcfix_CbConstruct(&decresidual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], iLBCbits_inst->cb_index+subcount*CB_NSTAGES, iLBCbits_inst->gain_index+subcount*CB_NSTAGES, mem, MEM_LF_TBL, SUBL ); /* update memory */ WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, (CB_MEML-SUBL)); WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, &decresidual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], SUBL); subcount++; } } #ifdef SPLIT_10MS if ((iLBCenc_inst->section == 1) && (iLBCenc_inst->mode == 30) && (Nfor > 0) && (end_count == 2)) { iLBCenc_inst->section++; /* adjust index */ WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); /* Packetize the parameters into the frame */ WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); return; } #endif /* backward prediction of subframes */ Nback = iLBCbits_inst->startIdx-1; if( Nback > 0 ){ /* create reverse order vectors (The decresidual does not need to be copied since it is contained in the same vector as the residual) */ WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nback*SUBL); /* setup memory */ meml_gotten = SUBL*(iLBCenc_inst->nsub+1-iLBCbits_inst->startIdx); if( meml_gotten > CB_MEML ) { meml_gotten=CB_MEML; } WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[Nback*SUBL], meml_gotten); WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-meml_gotten)); #ifdef SPLIT_10MS if (iLBCenc_inst->Nback_flag > 0) { for (subframe = 0; subframe < WEBRTC_SPL_MAX (2 - Nfor, 0); subframe++) { /* update memory */ WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, &reverseDecresidual[subframe * SUBL], SUBL); } } iLBCenc_inst->Nback_flag++; if (iLBCenc_inst->mode == 20) { start_count = 0; end_count = Nback; } if (iLBCenc_inst->mode == 30) { if (iLBCenc_inst->section == 1) { start_count = 0; end_count = WEBRTC_SPL_MAX (2 - Nfor, 0); } if (iLBCenc_inst->section == 2) { start_count = WEBRTC_SPL_MAX (2 - Nfor, 0); end_count = Nback; } } #else start_count = 0; end_count = (WebRtc_Word16)Nback; #endif /* loop over subframes to encode */ for (subframe = start_count; subframe < end_count; subframe++){ /* encode subframe */ WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &reverseResidual[subframe*SUBL], mem, MEM_LF_TBL, SUBL, &weightdenum[(iLBCbits_inst->startIdx-2-subframe)*(LPC_FILTERORDER+1)], (WebRtc_Word16)subcount); /* construct decoded vector */ WebRtcIlbcfix_CbConstruct(&reverseDecresidual[subframe*SUBL], iLBCbits_inst->cb_index+subcount*CB_NSTAGES, iLBCbits_inst->gain_index+subcount*CB_NSTAGES, mem, MEM_LF_TBL, SUBL ); /* update memory */ WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, (CB_MEML-SUBL)); WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, &reverseDecresidual[subframe*SUBL], SUBL); subcount++; } /* get decoded residual from reversed vector */ WebRtcSpl_MemCpyReversedOrder(&decresidual[SUBL*Nback-1], reverseDecresidual, SUBL*Nback); } /* end encoding part */ /* adjust index */ WebRtcIlbcfix_IndexConvEnc(iLBCbits_inst->cb_index); /* Packetize the parameters into the frame */ #ifdef SPLIT_10MS if( (iLBCenc_inst->mode==30) && (iLBCenc_inst->section==1) ){ WebRtcIlbcfix_PackBits(iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); } else{ WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); } #else WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); #endif #ifndef WEBRTC_BIG_ENDIAN /* Swap bytes for LITTLE ENDIAN since the packbits() function assumes BIG_ENDIAN machine */ #ifdef SPLIT_10MS if (( (iLBCenc_inst->section == 1) && (iLBCenc_inst->mode == 20) ) || ( (iLBCenc_inst->section == 2) && (iLBCenc_inst->mode == 30) )){ WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); } #else WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); #endif #endif #ifdef SPLIT_10MS if (subcount == (iLBCenc_inst->nsub - 1)) { iLBCenc_inst->section = 0; } else { iLBCenc_inst->section++; WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); } #endif }
void WebRtcIlbcfix_Refiner( WebRtc_Word16 *updStartPos, /* (o) updated start point (Q-2) */ WebRtc_Word16 *idata, /* (i) original data buffer */ WebRtc_Word16 idatal, /* (i) dimension of idata */ WebRtc_Word16 centerStartPos, /* (i) beginning center segment */ WebRtc_Word16 estSegPos, /* (i) estimated beginning other segment (Q-2) */ WebRtc_Word16 *surround, /* (i/o) The contribution from this sequence summed with earlier contributions */ WebRtc_Word16 gain /* (i) Gain to use for this sequence */ ){ WebRtc_Word16 estSegPosRounded,searchSegStartPos,searchSegEndPos,corrdim; WebRtc_Word16 tloc,tloc2,i,st,en,fraction; WebRtc_Word32 maxtemp, scalefact; WebRtc_Word16 *filtStatePtr, *polyPtr; /* Stack based */ WebRtc_Word16 filt[7]; WebRtc_Word32 corrVecUps[ENH_CORRDIM*ENH_UPS0]; WebRtc_Word32 corrVecTemp[ENH_CORRDIM]; WebRtc_Word16 vect[ENH_VECTL]; WebRtc_Word16 corrVec[ENH_CORRDIM]; /* defining array bounds */ estSegPosRounded=WEBRTC_SPL_RSHIFT_W16((estSegPos - 2),2); searchSegStartPos=estSegPosRounded-ENH_SLOP; if (searchSegStartPos<0) { searchSegStartPos=0; } searchSegEndPos=estSegPosRounded+ENH_SLOP; if(searchSegEndPos+ENH_BLOCKL >= idatal) { searchSegEndPos=idatal-ENH_BLOCKL-1; } corrdim=searchSegEndPos-searchSegStartPos+1; /* compute upsampled correlation and find location of max */ WebRtcIlbcfix_MyCorr(corrVecTemp,idata+searchSegStartPos, (WebRtc_Word16)(corrdim+ENH_BLOCKL-1),idata+centerStartPos,ENH_BLOCKL); /* Calculate the rescaling factor for the correlation in order to put the correlation in a WebRtc_Word16 vector instead */ maxtemp=WebRtcSpl_MaxAbsValueW32(corrVecTemp, (WebRtc_Word16)corrdim); scalefact=WebRtcSpl_GetSizeInBits(maxtemp)-15; if (scalefact>0) { for (i=0;i<corrdim;i++) { corrVec[i]=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(corrVecTemp[i], scalefact); } } else { for (i=0;i<corrdim;i++) { corrVec[i]=(WebRtc_Word16)corrVecTemp[i]; } } /* In order to guarantee that all values are initialized */ for (i=corrdim;i<ENH_CORRDIM;i++) { corrVec[i]=0; } /* Upsample the correlation */ WebRtcIlbcfix_EnhUpsample(corrVecUps,corrVec); /* Find maximum */ tloc=WebRtcSpl_MaxIndexW32(corrVecUps, (WebRtc_Word16) (ENH_UPS0*corrdim)); /* make vector can be upsampled without ever running outside bounds */ *updStartPos = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(searchSegStartPos,4) + tloc + 4; tloc2 = WEBRTC_SPL_RSHIFT_W16((tloc+3), 2); st=searchSegStartPos+tloc2-ENH_FL0; /* initialize the vector to be filtered, stuff with zeros when data is outside idata buffer */ if(st<0){ WebRtcSpl_MemSetW16(vect, 0, (WebRtc_Word16)(-st)); WEBRTC_SPL_MEMCPY_W16(&vect[-st], idata, (ENH_VECTL+st)); } else{ en=st+ENH_VECTL; if(en>idatal){ WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], (ENH_VECTL-(en-idatal))); WebRtcSpl_MemSetW16(&vect[ENH_VECTL-(en-idatal)], 0, (WebRtc_Word16)(en-idatal)); } else { WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); } } /* Calculate which of the 4 fractions to use */ fraction=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(tloc2,ENH_UPS0)-tloc; /* compute the segment (this is actually a convolution) */ filtStatePtr = filt + 6; polyPtr = (WebRtc_Word16*)WebRtcIlbcfix_kEnhPolyPhaser[fraction]; for (i=0;i<7;i++) { *filtStatePtr-- = *polyPtr++; } WebRtcSpl_FilterMAFastQ12( &vect[6], vect, filt, ENH_FLO_MULT2_PLUS1, ENH_BLOCKL); /* Add the contribution from this vector (scaled with gain) to the total surround vector */ WebRtcSpl_AddAffineVectorToVector( surround, vect, gain, (WebRtc_Word32)32768, 16, ENH_BLOCKL); return; }