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

Go to the source code of this file.

Functions

float gaindequant (int index, float maxIn, int cblen)
 
float gainquant (float in, float maxIn, int cblen, int *index)
 

Function Documentation

◆ gaindequant()

float gaindequant ( int  index,
float  maxIn,
int  cblen 
)

Definition at line 83 of file gainquant.c.

References gain_sq3Tbl, gain_sq4Tbl, and gain_sq5Tbl.

Referenced by iCBConstruct().

87  {
88  float scale;
89 
90  /* obtain correct scale factor */
91 
92  scale=(float)fabs(maxIn);
93 
94  if (scale<0.1) {
95  scale=(float)0.1;
96  }
97 
98  /* select the quantization table and return the decoded value */
99 
100  if (cblen==8) {
101  return scale*gain_sq3Tbl[index];
102  } else if (cblen==16) {
103  return scale*gain_sq4Tbl[index];
104  }
105  else if (cblen==32) {
106  return scale*gain_sq5Tbl[index];
107  }
108 
109  return 0.0;
110  }
float gain_sq4Tbl[16]
Definition: constants.c:160
float gain_sq3Tbl[8]
Definition: constants.c:150
float gain_sq5Tbl[32]
Definition: constants.c:168

◆ gainquant()

float gainquant ( float  in,
float  maxIn,
int  cblen,
int *  index 
)

Definition at line 27 of file gainquant.c.

References gain_sq3Tbl, gain_sq4Tbl, and gain_sq5Tbl.

Referenced by iCBSearch().

32  {
33  int i, tindex;
34  float minmeasure,measure, *cb, scale;
35 
36  /* ensure a lower bound on the scaling factor */
37 
38  scale=maxIn;
39 
40  if (scale<0.1) {
41  scale=(float)0.1;
42  }
43 
44  /* select the quantization table */
45 
46  if (cblen == 8) {
47  cb = gain_sq3Tbl;
48  } else if (cblen == 16) {
49  cb = gain_sq4Tbl;
50  } else {
51  cb = gain_sq5Tbl;
52  }
53 
54  /* select the best index in the quantization table */
55 
56  minmeasure=10000000.0;
57  tindex=0;
58  for (i=0; i<cblen; i++) {
59 
60 
61 
62 
63 
64  measure=(in-scale*cb[i])*(in-scale*cb[i]);
65 
66  if (measure<minmeasure) {
67  tindex=i;
68  minmeasure=measure;
69  }
70  }
71  *index=tindex;
72 
73  /* return the quantized value */
74 
75  return scale*cb[tindex];
76  }
FILE * in
Definition: utils/frame.c:33
float gain_sq4Tbl[16]
Definition: constants.c:160
float gain_sq3Tbl[8]
Definition: constants.c:150
float gain_sq5Tbl[32]
Definition: constants.c:168