Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions
FrameClassify.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int FrameClassify (iLBC_Enc_Inst_t *iLBCenc_inst, float *residual)
 

Function Documentation

◆ FrameClassify()

int FrameClassify ( iLBC_Enc_Inst_t iLBCenc_inst,
float *  residual 
)

Definition at line 19 of file FrameClassify.c.

23 {
24 float max_ssqEn, fssqEn[NSUB_MAX], bssqEn[NSUB_MAX], *pp;
25 int n, l, max_ssqEn_n;
26 const float ssqEn_win[NSUB_MAX-1]={(float)0.8,(float)0.9,
27 (float)1.0,(float)0.9,(float)0.8};
28 const float sampEn_win[5]={(float)1.0/(float)6.0,
29 (float)2.0/(float)6.0, (float)3.0/(float)6.0,
30 (float)4.0/(float)6.0, (float)5.0/(float)6.0};
31
32 /* init the front and back energies to zero */
33
34 memset(fssqEn, 0, NSUB_MAX*sizeof(float));
35 memset(bssqEn, 0, NSUB_MAX*sizeof(float));
36
37 /* Calculate front of first seqence */
38
39 n=0;
40 pp=residual;
41 for (l=0; l<5; l++) {
42 fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
43 pp++;
44 }
45 for (l=5; l<SUBL; l++) {
46
47
48
49
50
51 fssqEn[n] += (*pp) * (*pp);
52 pp++;
53 }
54
55 /* Calculate front and back of all middle sequences */
56
57 for (n=1; n<iLBCenc_inst->nsub-1; n++) {
58 pp=residual+n*SUBL;
59 for (l=0; l<5; l++) {
60 fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
61 bssqEn[n] += (*pp) * (*pp);
62 pp++;
63 }
64 for (l=5; l<SUBL-5; l++) {
65 fssqEn[n] += (*pp) * (*pp);
66 bssqEn[n] += (*pp) * (*pp);
67 pp++;
68 }
69 for (l=SUBL-5; l<SUBL; l++) {
70 fssqEn[n] += (*pp) * (*pp);
71 bssqEn[n] += sampEn_win[SUBL-l-1] * (*pp) * (*pp);
72 pp++;
73 }
74 }
75
76 /* Calculate back of last seqence */
77
78 n=iLBCenc_inst->nsub-1;
79 pp=residual+n*SUBL;
80 for (l=0; l<SUBL-5; l++) {
81 bssqEn[n] += (*pp) * (*pp);
82 pp++;
83 }
84 for (l=SUBL-5; l<SUBL; l++) {
85 bssqEn[n] += sampEn_win[SUBL-l-1] * (*pp) * (*pp);
86 pp++;
87 }
88
89 /* find the index to the weighted 80 sample with
90 most energy */
91
92 if (iLBCenc_inst->mode==20) l=1;
93 else l=0;
94
95 max_ssqEn=(fssqEn[0]+bssqEn[1])*ssqEn_win[l];
96 max_ssqEn_n=1;
97 for (n=2; n<iLBCenc_inst->nsub; n++) {
98
99
100
101
102
103
104 l++;
105 if ((fssqEn[n-1]+bssqEn[n])*ssqEn_win[l] > max_ssqEn) {
106 max_ssqEn=(fssqEn[n-1]+bssqEn[n]) *
107 ssqEn_win[l];
108 max_ssqEn_n=n;
109 }
110 }
111
112 return max_ssqEn_n;
113 }
#define SUBL
Definition: iLBC_define.h:33
#define NSUB_MAX
Definition: iLBC_define.h:24

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

Referenced by iLBC_encode().