enhancer.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /******************************************************************
  2. iLBC Speech Coder ANSI-C Source Code
  3. enhancer.c
  4. Copyright (C) The Internet Society (2004).
  5. All Rights Reserved.
  6. ******************************************************************/
  7. #include <math.h>
  8. #include <string.h>
  9. #include "iLBC_define.h"
  10. #include "constants.h"
  11. #include "filter.h"
  12. /*----------------------------------------------------------------*
  13. * Find index in array such that the array element with said
  14. * index is the element of said array closest to "value"
  15. * according to the squared-error criterion
  16. *---------------------------------------------------------------*/
  17. void NearestNeighbor(
  18. int *index, /* (o) index of array element closest
  19. to value */
  20. float *array, /* (i) data array */
  21. float value,/* (i) value */
  22. int arlength/* (i) dimension of data array */
  23. ){
  24. int i;
  25. float bestcrit,crit;
  26. crit=array[0]-value;
  27. bestcrit=crit*crit;
  28. *index=0;
  29. for (i=1; i<arlength; i++) {
  30. crit=array[i]-value;
  31. crit=crit*crit;
  32. if (crit<bestcrit) {
  33. bestcrit=crit;
  34. *index=i;
  35. }
  36. }
  37. }
  38. /*----------------------------------------------------------------*
  39. * compute cross correlation between sequences
  40. *---------------------------------------------------------------*/
  41. void mycorr1(
  42. float* corr, /* (o) correlation of seq1 and seq2 */
  43. float* seq1, /* (i) first sequence */
  44. int dim1, /* (i) dimension first seq1 */
  45. const float *seq2, /* (i) second sequence */
  46. int dim2 /* (i) dimension seq2 */
  47. ){
  48. int i,j;
  49. for (i=0; i<=dim1-dim2; i++) {
  50. corr[i]=0.0;
  51. for (j=0; j<dim2; j++) {
  52. corr[i] += seq1[i+j] * seq2[j];
  53. }
  54. }
  55. }
  56. /*----------------------------------------------------------------*
  57. * upsample finite array assuming zeros outside bounds
  58. *---------------------------------------------------------------*/
  59. void enh_upsample(
  60. float* useq1, /* (o) upsampled output sequence */
  61. float* seq1,/* (i) unupsampled sequence */
  62. int dim1, /* (i) dimension seq1 */
  63. int hfl /* (i) polyphase filter length=2*hfl+1 */
  64. ){
  65. float *pu,*ps;
  66. int i,j,k,q,filterlength,hfl2;
  67. const float *polyp[ENH_UPS0]; /* pointers to
  68. polyphase columns */
  69. const float *pp;
  70. /* define pointers for filter */
  71. filterlength=2*hfl+1;
  72. if ( filterlength > dim1 ) {
  73. hfl2=(int) (dim1/2);
  74. for (j=0; j<ENH_UPS0; j++) {
  75. polyp[j]=polyphaserTbl+j*filterlength+hfl-hfl2;
  76. }
  77. hfl=hfl2;
  78. filterlength=2*hfl+1;
  79. }
  80. else {
  81. for (j=0; j<ENH_UPS0; j++) {
  82. polyp[j]=polyphaserTbl+j*filterlength;
  83. }
  84. }
  85. /* filtering: filter overhangs left side of sequence */
  86. pu=useq1;
  87. for (i=hfl; i<filterlength; i++) {
  88. for (j=0; j<ENH_UPS0; j++) {
  89. *pu=0.0;
  90. pp = polyp[j];
  91. ps = seq1+i;
  92. for (k=0; k<=i; k++) {
  93. *pu += *ps-- * *pp++;
  94. }
  95. pu++;
  96. }
  97. }
  98. /* filtering: simple convolution=inner products */
  99. for (i=filterlength; i<dim1; i++) {
  100. for (j=0;j<ENH_UPS0; j++){
  101. *pu=0.0;
  102. pp = polyp[j];
  103. ps = seq1+i;
  104. for (k=0; k<filterlength; k++) {
  105. *pu += *ps-- * *pp++;
  106. }
  107. pu++;
  108. }
  109. }
  110. /* filtering: filter overhangs right side of sequence */
  111. for (q=1; q<=hfl; q++) {
  112. for (j=0; j<ENH_UPS0; j++) {
  113. *pu=0.0;
  114. pp = polyp[j]+q;
  115. ps = seq1+dim1-1;
  116. for (k=0; k<filterlength-q; k++) {
  117. *pu += *ps-- * *pp++;
  118. }
  119. pu++;
  120. }
  121. }
  122. }
  123. /*----------------------------------------------------------------*
  124. * find segment starting near idata+estSegPos that has highest
  125. * correlation with idata+centerStartPos through
  126. * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a
  127. * resolution of ENH_UPSO times the original of the original
  128. * sampling rate
  129. *---------------------------------------------------------------*/
  130. void refiner(
  131. float *seg, /* (o) segment array */
  132. float *updStartPos, /* (o) updated start point */
  133. float* idata, /* (i) original data buffer */
  134. int idatal, /* (i) dimension of idata */
  135. int centerStartPos, /* (i) beginning center segment */
  136. float estSegPos,/* (i) estimated beginning other segment */
  137. float period /* (i) estimated pitch period */
  138. ){
  139. int estSegPosRounded,searchSegStartPos,searchSegEndPos,corrdim;
  140. int tloc,tloc2,i,st,en,fraction;
  141. float vect[ENH_VECTL],corrVec[ENH_CORRDIM],maxv;
  142. float corrVecUps[ENH_CORRDIM*ENH_UPS0];
  143. (void)period;
  144. /* defining array bounds */
  145. estSegPosRounded=(int)(estSegPos - 0.5);
  146. searchSegStartPos=estSegPosRounded-ENH_SLOP;
  147. if (searchSegStartPos<0) {
  148. searchSegStartPos=0;
  149. }
  150. searchSegEndPos=estSegPosRounded+ENH_SLOP;
  151. if (searchSegEndPos+ENH_BLOCKL >= idatal) {
  152. searchSegEndPos=idatal-ENH_BLOCKL-1;
  153. }
  154. corrdim=searchSegEndPos-searchSegStartPos+1;
  155. /* compute upsampled correlation (corr33) and find
  156. location of max */
  157. mycorr1(corrVec,idata+searchSegStartPos,
  158. corrdim+ENH_BLOCKL-1,idata+centerStartPos,ENH_BLOCKL);
  159. enh_upsample(corrVecUps,corrVec,corrdim,ENH_FL0);
  160. tloc=0; maxv=corrVecUps[0];
  161. for (i=1; i<ENH_UPS0*corrdim; i++) {
  162. if (corrVecUps[i]>maxv) {
  163. tloc=i;
  164. maxv=corrVecUps[i];
  165. }
  166. }
  167. /* make vector can be upsampled without ever running outside
  168. bounds */
  169. *updStartPos= (float)searchSegStartPos +
  170. (float)tloc/(float)ENH_UPS0+(float)1.0;
  171. tloc2=(int)(tloc/ENH_UPS0);
  172. if (tloc>tloc2*ENH_UPS0) {
  173. tloc2++;
  174. }
  175. st=searchSegStartPos+tloc2-ENH_FL0;
  176. if (st<0) {
  177. memset(vect,0,-st*sizeof(float));
  178. memcpy(&vect[-st],idata, (ENH_VECTL+st)*sizeof(float));
  179. }
  180. else {
  181. en=st+ENH_VECTL;
  182. if (en>idatal) {
  183. memcpy(vect, &idata[st],
  184. (ENH_VECTL-(en-idatal))*sizeof(float));
  185. memset(&vect[ENH_VECTL-(en-idatal)], 0,
  186. (en-idatal)*sizeof(float));
  187. }
  188. else {
  189. memcpy(vect, &idata[st], ENH_VECTL*sizeof(float));
  190. }
  191. }
  192. fraction=tloc2*ENH_UPS0-tloc;
  193. /* compute the segment (this is actually a convolution) */
  194. mycorr1(seg,vect,ENH_VECTL,polyphaserTbl+(2*ENH_FL0+1)*fraction,
  195. 2*ENH_FL0+1);
  196. }
  197. /*----------------------------------------------------------------*
  198. * find the smoothed output data
  199. *---------------------------------------------------------------*/
  200. void smath(
  201. float *odata, /* (o) smoothed output */
  202. float *sseq,/* (i) said second sequence of waveforms */
  203. int hl, /* (i) 2*hl+1 is sseq dimension */
  204. float alpha0/* (i) max smoothing energy fraction */
  205. ){
  206. int i,k;
  207. float w00,w10,w11,A,B,C,*psseq,err,errs;
  208. float surround[BLOCKL_MAX]; /* shape contributed by other than
  209. current */
  210. float wt[2*ENH_HL+1]; /* waveform weighting to get
  211. surround shape */
  212. float denom;
  213. /* create shape of contribution from all waveforms except the
  214. current one */
  215. for (i=1; i<=2*hl+1; i++) {
  216. wt[i-1] = (float)0.5*(1 - (float)cos(2*PI*i/(2*hl+2)));
  217. }
  218. wt[hl]=0.0; /* for clarity, not used */
  219. for (i=0; i<ENH_BLOCKL; i++) {
  220. surround[i]=sseq[i]*wt[0];
  221. }
  222. for (k=1; k<hl; k++) {
  223. psseq=sseq+k*ENH_BLOCKL;
  224. for(i=0;i<ENH_BLOCKL; i++) {
  225. surround[i]+=psseq[i]*wt[k];
  226. }
  227. }
  228. for (k=hl+1; k<=2*hl; k++) {
  229. psseq=sseq+k*ENH_BLOCKL;
  230. for(i=0;i<ENH_BLOCKL; i++) {
  231. surround[i]+=psseq[i]*wt[k];
  232. }
  233. }
  234. /* compute some inner products */
  235. w00 = w10 = w11 = 0.0;
  236. psseq=sseq+hl*ENH_BLOCKL; /* current block */
  237. for (i=0; i<ENH_BLOCKL;i++) {
  238. w00+=psseq[i]*psseq[i];
  239. w11+=surround[i]*surround[i];
  240. w10+=surround[i]*psseq[i];
  241. }
  242. if (fabs(w11) < 1.0) {
  243. w11=1.0;
  244. }
  245. C = (float)sqrt( w00/w11);
  246. /* first try enhancement without power-constraint */
  247. errs=0.0;
  248. psseq=sseq+hl*ENH_BLOCKL;
  249. for (i=0; i<ENH_BLOCKL; i++) {
  250. odata[i]=C*surround[i];
  251. err=psseq[i]-odata[i];
  252. errs+=err*err;
  253. }
  254. /* if constraint violated by first try, add constraint */
  255. if (errs > alpha0 * w00) {
  256. if ( w00 < 1) {
  257. w00=1;
  258. }
  259. denom = (w11*w00-w10*w10)/(w00*w00);
  260. if (denom > 0.0001) { /* eliminates numerical problems
  261. for if smooth */
  262. A = (float)sqrt( (alpha0- alpha0*alpha0/4)/denom);
  263. B = -alpha0/2 - A * w10/w00;
  264. B = B+1;
  265. }
  266. else { /* essentially no difference between cycles;
  267. smoothing not needed */
  268. A= 0.0;
  269. B= 1.0;
  270. }
  271. /* create smoothed sequence */
  272. psseq=sseq+hl*ENH_BLOCKL;
  273. for (i=0; i<ENH_BLOCKL; i++) {
  274. odata[i]=A*surround[i]+B*psseq[i];
  275. }
  276. }
  277. }
  278. /*----------------------------------------------------------------*
  279. * get the pitch-synchronous sample sequence
  280. *---------------------------------------------------------------*/
  281. void getsseq(
  282. float *sseq, /* (o) the pitch-synchronous sequence */
  283. float *idata, /* (i) original data */
  284. int idatal, /* (i) dimension of data */
  285. int centerStartPos, /* (i) where current block starts */
  286. float *period, /* (i) rough-pitch-period array */
  287. float *plocs, /* (i) where periods of period array
  288. are taken */
  289. int periodl, /* (i) dimension period array */
  290. int hl /* (i) 2*hl+1 is the number of sequences */
  291. ){
  292. int i,centerEndPos,q;
  293. float blockStartPos[2*ENH_HL+1];
  294. int lagBlock[2*ENH_HL+1];
  295. float plocs2[ENH_PLOCSL];
  296. float *psseq;
  297. centerEndPos=centerStartPos+ENH_BLOCKL-1;
  298. /* present */
  299. NearestNeighbor(lagBlock+hl,plocs,
  300. (float)0.5*(centerStartPos+centerEndPos),periodl);
  301. blockStartPos[hl]=(float)centerStartPos;
  302. psseq=sseq+ENH_BLOCKL*hl;
  303. memcpy(psseq, idata+centerStartPos, ENH_BLOCKL*sizeof(float));
  304. /* past */
  305. for (q=hl-1; q>=0; q--) {
  306. blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]];
  307. NearestNeighbor(lagBlock+q,plocs,
  308. blockStartPos[q]+
  309. ENH_BLOCKL_HALF-period[lagBlock[q+1]], periodl);
  310. if (blockStartPos[q]-ENH_OVERHANG>=0) {
  311. refiner(sseq+q*ENH_BLOCKL, blockStartPos+q, idata,
  312. idatal, centerStartPos, blockStartPos[q],
  313. period[lagBlock[q+1]]);
  314. } else {
  315. psseq=sseq+q*ENH_BLOCKL;
  316. memset(psseq, 0, ENH_BLOCKL*sizeof(float));
  317. }
  318. }
  319. /* future */
  320. for (i=0; i<periodl; i++) {
  321. plocs2[i]=plocs[i]-period[i];
  322. }
  323. for (q=hl+1; q<=2*hl; q++) {
  324. NearestNeighbor(lagBlock+q,plocs2,
  325. blockStartPos[q-1]+ENH_BLOCKL_HALF,periodl);
  326. blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]];
  327. if (blockStartPos[q]+ENH_BLOCKL+ENH_OVERHANG<idatal) {
  328. refiner(sseq+ENH_BLOCKL*q, blockStartPos+q, idata,
  329. idatal, centerStartPos, blockStartPos[q],
  330. period[lagBlock[q]]);
  331. }
  332. else {
  333. psseq=sseq+q*ENH_BLOCKL;
  334. memset(psseq, 0, ENH_BLOCKL*sizeof(float));
  335. }
  336. }
  337. }
  338. /*----------------------------------------------------------------*
  339. * perform enhancement on idata+centerStartPos through
  340. * idata+centerStartPos+ENH_BLOCKL-1
  341. *---------------------------------------------------------------*/
  342. void enhancer(
  343. float *odata, /* (o) smoothed block, dimension blockl */
  344. float *idata, /* (i) data buffer used for enhancing */
  345. int idatal, /* (i) dimension idata */
  346. int centerStartPos, /* (i) first sample current block
  347. within idata */
  348. float alpha0, /* (i) max correction-energy-fraction
  349. (in [0,1]) */
  350. float *period, /* (i) pitch period array */
  351. float *plocs, /* (i) locations where period array
  352. values valid */
  353. int periodl /* (i) dimension of period and plocs */
  354. ){
  355. float sseq[(2*ENH_HL+1)*ENH_BLOCKL];
  356. /* get said second sequence of segments */
  357. getsseq(sseq,idata,idatal,centerStartPos,period,
  358. plocs,periodl,ENH_HL);
  359. /* compute the smoothed output from said second sequence */
  360. smath(odata,sseq,ENH_HL,alpha0);
  361. }
  362. /*----------------------------------------------------------------*
  363. * cross correlation
  364. *---------------------------------------------------------------*/
  365. float xCorrCoef(
  366. float *target, /* (i) first array */
  367. float *regressor, /* (i) second array */
  368. int subl /* (i) dimension arrays */
  369. ){
  370. int i;
  371. float ftmp1, ftmp2;
  372. ftmp1 = 0.0;
  373. ftmp2 = 0.0;
  374. for (i=0; i<subl; i++) {
  375. ftmp1 += target[i]*regressor[i];
  376. ftmp2 += regressor[i]*regressor[i];
  377. }
  378. if (ftmp1 > 0.0) {
  379. return (float)(ftmp1*ftmp1/ftmp2);
  380. }
  381. else {
  382. return (float)0.0;
  383. }
  384. }
  385. /*----------------------------------------------------------------*
  386. * interface for enhancer
  387. *---------------------------------------------------------------*/
  388. int enhancerInterface(
  389. float *out, /* (o) enhanced signal */
  390. float *in, /* (i) unenhanced signal */
  391. iLBC_Dec_Inst_t *iLBCdec_inst /* (i) buffers etc */
  392. ){
  393. float *enh_buf, *enh_period;
  394. int iblock, isample;
  395. int lag=0, ilag, i, ioffset;
  396. float cc, maxcc;
  397. float ftmp1, ftmp2;
  398. float *inPtr, *enh_bufPtr1, *enh_bufPtr2;
  399. float plc_pred[ENH_BLOCKL];
  400. float lpState[6], downsampled[(ENH_NBLOCKS*ENH_BLOCKL+120)/2];
  401. int inLen=ENH_NBLOCKS*ENH_BLOCKL+120;
  402. int start, plc_blockl, inlag;
  403. enh_buf=iLBCdec_inst->enh_buf;
  404. enh_period=iLBCdec_inst->enh_period;
  405. memmove(enh_buf, &enh_buf[iLBCdec_inst->blockl],
  406. (ENH_BUFL-iLBCdec_inst->blockl)*sizeof(float));
  407. memcpy(&enh_buf[ENH_BUFL-iLBCdec_inst->blockl], in,
  408. iLBCdec_inst->blockl*sizeof(float));
  409. if (iLBCdec_inst->mode==30)
  410. plc_blockl=ENH_BLOCKL;
  411. else
  412. plc_blockl=40;
  413. /* when 20 ms frame, move processing one block */
  414. ioffset=0;
  415. if (iLBCdec_inst->mode==20) ioffset=1;
  416. i=3-ioffset;
  417. memmove(enh_period, &enh_period[i],
  418. (ENH_NBLOCKS_TOT-i)*sizeof(float));
  419. /* Set state information to the 6 samples right before
  420. the samples to be downsampled. */
  421. memcpy(lpState,
  422. enh_buf+(ENH_NBLOCKS_EXTRA+ioffset)*ENH_BLOCKL-126,
  423. 6*sizeof(float));
  424. /* Down sample a factor 2 to save computations */
  425. DownSample(enh_buf+(ENH_NBLOCKS_EXTRA+ioffset)*ENH_BLOCKL-120,
  426. lpFilt_coefsTbl, inLen-ioffset*ENH_BLOCKL,
  427. lpState, downsampled);
  428. /* Estimate the pitch in the down sampled domain. */
  429. for (iblock = 0; iblock<ENH_NBLOCKS-ioffset; iblock++) {
  430. lag = 10;
  431. maxcc = xCorrCoef(downsampled+60+iblock*
  432. ENH_BLOCKL_HALF, downsampled+60+iblock*
  433. ENH_BLOCKL_HALF-lag, ENH_BLOCKL_HALF);
  434. for (ilag=11; ilag<60; ilag++) {
  435. cc = xCorrCoef(downsampled+60+iblock*
  436. ENH_BLOCKL_HALF, downsampled+60+iblock*
  437. ENH_BLOCKL_HALF-ilag, ENH_BLOCKL_HALF);
  438. if (cc > maxcc) {
  439. maxcc = cc;
  440. lag = ilag;
  441. }
  442. }
  443. /* Store the estimated lag in the non-downsampled domain */
  444. enh_period[iblock+ENH_NBLOCKS_EXTRA+ioffset] = (float)lag*2;
  445. }
  446. /* PLC was performed on the previous packet */
  447. if (iLBCdec_inst->prev_enh_pl==1) {
  448. inlag=(int)enh_period[ENH_NBLOCKS_EXTRA+ioffset];
  449. lag = inlag-1;
  450. maxcc = xCorrCoef(in, in+lag, plc_blockl);
  451. for (ilag=inlag; ilag<=inlag+1; ilag++) {
  452. cc = xCorrCoef(in, in+ilag, plc_blockl);
  453. if (cc > maxcc) {
  454. maxcc = cc;
  455. lag = ilag;
  456. }
  457. }
  458. enh_period[ENH_NBLOCKS_EXTRA+ioffset-1]=(float)lag;
  459. /* compute new concealed residual for the old lookahead,
  460. mix the forward PLC with a backward PLC from
  461. the new frame */
  462. inPtr=&in[lag-1];
  463. enh_bufPtr1=&plc_pred[plc_blockl-1];
  464. if (lag>plc_blockl) {
  465. start=plc_blockl;
  466. } else {
  467. start=lag;
  468. }
  469. for (isample = start; isample>0; isample--) {
  470. *enh_bufPtr1-- = *inPtr--;
  471. }
  472. enh_bufPtr2=&enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl];
  473. for (isample = (plc_blockl-1-lag); isample>=0; isample--) {
  474. *enh_bufPtr1-- = *enh_bufPtr2--;
  475. }
  476. /* limit energy change */
  477. ftmp2=0.0;
  478. ftmp1=0.0;
  479. for (i=0;i<plc_blockl;i++) {
  480. ftmp2+=enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl-i]*
  481. enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl-i];
  482. ftmp1+=plc_pred[i]*plc_pred[i];
  483. }
  484. ftmp1=(float)sqrt(ftmp1/(float)plc_blockl);
  485. ftmp2=(float)sqrt(ftmp2/(float)plc_blockl);
  486. if (ftmp1>(float)2.0*ftmp2 && ftmp1>0.0) {
  487. for (i=0;i<plc_blockl-10;i++) {
  488. plc_pred[i]*=(float)2.0*ftmp2/ftmp1;
  489. }
  490. for (i=plc_blockl-10;i<plc_blockl;i++) {
  491. plc_pred[i]*=(float)(i-plc_blockl+10)*
  492. ((float)1.0-(float)2.0*ftmp2/ftmp1)/(float)(10)+
  493. (float)2.0*ftmp2/ftmp1;
  494. }
  495. }
  496. enh_bufPtr1=&enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl];
  497. for (i=0; i<plc_blockl; i++) {
  498. ftmp1 = (float) (i+1) / (float) (plc_blockl+1);
  499. *enh_bufPtr1 *= ftmp1;
  500. *enh_bufPtr1 += ((float)1.0-ftmp1)*
  501. plc_pred[plc_blockl-1-i];
  502. enh_bufPtr1--;
  503. }
  504. }
  505. if (iLBCdec_inst->mode==20) {
  506. /* Enhancer with 40 samples delay */
  507. for (iblock = 0; iblock<2; iblock++) {
  508. enhancer(out+iblock*ENH_BLOCKL, enh_buf,
  509. ENH_BUFL, (5+iblock)*ENH_BLOCKL+40,
  510. ENH_ALPHA0, enh_period, enh_plocsTbl,
  511. ENH_NBLOCKS_TOT);
  512. }
  513. } else if (iLBCdec_inst->mode==30) {
  514. /* Enhancer with 80 samples delay */
  515. for (iblock = 0; iblock<3; iblock++) {
  516. enhancer(out+iblock*ENH_BLOCKL, enh_buf,
  517. ENH_BUFL, (4+iblock)*ENH_BLOCKL,
  518. ENH_ALPHA0, enh_period, enh_plocsTbl,
  519. ENH_NBLOCKS_TOT);
  520. }
  521. }
  522. return (lag*2);
  523. }