FrameClassify.c File Reference

#include "iLBC_define.h"

Include dependency graph for FrameClassify.c:

Go to the source code of this file.

Functions

int FrameClassify (iLBC_Enc_Inst_t *iLBCenc_inst, float *residual)


Function Documentation

int FrameClassify ( iLBC_Enc_Inst_t iLBCenc_inst,
float *  residual 
)

Definition at line 19 of file FrameClassify.c.

References iLBC_Enc_Inst_t_::mode, iLBC_Enc_Inst_t_::nsub, NSUB_MAX, and SUBL.

Referenced by iLBC_encode().

00023      {
00024        float max_ssqEn, fssqEn[NSUB_MAX], bssqEn[NSUB_MAX], *pp;
00025        int n, l, max_ssqEn_n;
00026        const float ssqEn_win[NSUB_MAX-1]={(float)0.8,(float)0.9,
00027            (float)1.0,(float)0.9,(float)0.8};
00028        const float sampEn_win[5]={(float)1.0/(float)6.0,
00029            (float)2.0/(float)6.0, (float)3.0/(float)6.0,
00030            (float)4.0/(float)6.0, (float)5.0/(float)6.0};
00031 
00032        /* init the front and back energies to zero */
00033 
00034        memset(fssqEn, 0, NSUB_MAX*sizeof(float));
00035        memset(bssqEn, 0, NSUB_MAX*sizeof(float));
00036 
00037        /* Calculate front of first seqence */
00038 
00039        n=0;
00040        pp=residual;
00041        for (l=0; l<5; l++) {
00042            fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
00043            pp++;
00044        }
00045        for (l=5; l<SUBL; l++) {
00046 
00047 
00048 
00049 
00050 
00051            fssqEn[n] += (*pp) * (*pp);
00052            pp++;
00053        }
00054 
00055        /* Calculate front and back of all middle sequences */
00056 
00057        for (n=1; n<iLBCenc_inst->nsub-1; n++) {
00058            pp=residual+n*SUBL;
00059            for (l=0; l<5; l++) {
00060                fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
00061                bssqEn[n] += (*pp) * (*pp);
00062                pp++;
00063            }
00064            for (l=5; l<SUBL-5; l++) {
00065                fssqEn[n] += (*pp) * (*pp);
00066                bssqEn[n] += (*pp) * (*pp);
00067                pp++;
00068            }
00069            for (l=SUBL-5; l<SUBL; l++) {
00070                fssqEn[n] += (*pp) * (*pp);
00071                bssqEn[n] += sampEn_win[SUBL-l-1] * (*pp) * (*pp);
00072                pp++;
00073            }
00074        }
00075 
00076        /* Calculate back of last seqence */
00077 
00078        n=iLBCenc_inst->nsub-1;
00079        pp=residual+n*SUBL;
00080        for (l=0; l<SUBL-5; l++) {
00081            bssqEn[n] += (*pp) * (*pp);
00082            pp++;
00083        }
00084        for (l=SUBL-5; l<SUBL; l++) {
00085            bssqEn[n] += sampEn_win[SUBL-l-1] * (*pp) * (*pp);
00086            pp++;
00087        }
00088 
00089        /* find the index to the weighted 80 sample with
00090           most energy */
00091 
00092        if (iLBCenc_inst->mode==20) l=1;
00093        else                        l=0;
00094 
00095        max_ssqEn=(fssqEn[0]+bssqEn[1])*ssqEn_win[l];
00096        max_ssqEn_n=1;
00097        for (n=2; n<iLBCenc_inst->nsub; n++) {
00098 
00099 
00100 
00101 
00102 
00103 
00104            l++;
00105            if ((fssqEn[n-1]+bssqEn[n])*ssqEn_win[l] > max_ssqEn) {
00106                max_ssqEn=(fssqEn[n-1]+bssqEn[n]) *
00107                                ssqEn_win[l];
00108                max_ssqEn_n=n;
00109            }
00110        }
00111 
00112        return max_ssqEn_n;
00113    }


Generated on Thu Apr 16 06:31:09 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6