521 {
522 float *enh_buf, *enh_period;
523 int iblock, isample;
524 int lag=0, ilag, i, ioffset;
525 float cc, maxcc;
526 float ftmp1, ftmp2;
527 float *inPtr, *enh_bufPtr1, *enh_bufPtr2;
529
532 int start, plc_blockl, inlag;
533
536
537 memmove(enh_buf, &enh_buf[iLBCdec_inst->
blockl],
539
541 iLBCdec_inst->
blockl*
sizeof(
float));
542
543 if (iLBCdec_inst->
mode==30)
545 else
546 plc_blockl=40;
547
548
549 ioffset=0;
550 if (iLBCdec_inst->
mode==20) ioffset=1;
551
552 i=3-ioffset;
553 memmove(enh_period, &enh_period[i],
555
556
557
558
559
560
561
562
563
564 memcpy(lpState,
566 6*sizeof(float));
567
568
569
572 lpState, downsampled);
573
574
575 for (iblock = 0; iblock<
ENH_NBLOCKS-ioffset; iblock++) {
576
577 lag = 10;
581 for (ilag=11; ilag<60; ilag++) {
585
586 if (cc > maxcc) {
587 maxcc = cc;
588 lag = ilag;
589 }
590 }
591
592
594
595
596 }
597
598
599
601
603
604 lag = inlag-1;
606 for (ilag=inlag; ilag<=inlag+1; ilag++) {
608
609
610
611
612
613
614 if (cc > maxcc) {
615 maxcc = cc;
616 lag = ilag;
617 }
618 }
619
621
622
623
624
625
627
628 enh_bufPtr1=&plc_pred[plc_blockl-1];
629
630 if (lag>plc_blockl) {
631 start=plc_blockl;
632 } else {
633 start=lag;
634 }
635
636 for (isample = start; isample>0; isample--) {
637 *enh_bufPtr1-- = *inPtr--;
638 }
639
641 for (isample = (plc_blockl-1-lag); isample>=0; isample--) {
642 *enh_bufPtr1-- = *enh_bufPtr2--;
643 }
644
645
646 ftmp2=0.0;
647 ftmp1=0.0;
648 for (i=0;i<plc_blockl;i++) {
651 ftmp1+=plc_pred[i]*plc_pred[i];
652 }
653 ftmp1=(float)sqrt(ftmp1/(float)plc_blockl);
654 ftmp2=(float)sqrt(ftmp2/(float)plc_blockl);
655 if (ftmp1>(float)2.0*ftmp2 && ftmp1>0.0) {
656 for (i=0;i<plc_blockl-10;i++) {
657 plc_pred[i]*=(float)2.0*ftmp2/ftmp1;
658 }
659 for (i=plc_blockl-10;i<plc_blockl;i++) {
660 plc_pred[i]*=(float)(i-plc_blockl+10)*
661 ((float)1.0-(float)2.0*ftmp2/ftmp1)/(float)(10)+
662
663
664
665
666
667 (float)2.0*ftmp2/ftmp1;
668 }
669 }
670
672 for (i=0; i<plc_blockl; i++) {
673 ftmp1 = (float) (i+1) / (float) (plc_blockl+1);
674 *enh_bufPtr1 *= ftmp1;
675 *enh_bufPtr1 += ((float)1.0-ftmp1)*
676 plc_pred[plc_blockl-1-i];
677 enh_bufPtr1--;
678 }
679 }
680
681 if (iLBCdec_inst->
mode==20) {
682
683 for (iblock = 0; iblock<2; iblock++) {
688 }
689 }
else if (iLBCdec_inst->
mode==30) {
690
691 for (iblock = 0; iblock<3; iblock++) {
696 }
697 }
698
699 return (lag*2);
700 }
float lpFilt_coefsTbl[FILTERORDER_DS]
float enh_plocsTbl[ENH_NBLOCKS_TOT]
float xCorrCoef(float *target, float *regressor, int subl)
void enhancer(float *odata, float *idata, int idatal, int centerStartPos, float alpha0, float *period, float *plocs, int periodl)
void DownSample(float *In, float *Coef, int lengthIn, float *state, float *Out)
#define ENH_NBLOCKS_EXTRA
float enh_period[ENH_NBLOCKS_TOT]