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

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().

00087     {
00088        float scale;
00089 
00090        /* obtain correct scale factor */
00091 
00092        scale=(float)fabs(maxIn);
00093 
00094        if (scale<0.1) {
00095            scale=(float)0.1;
00096        }
00097 
00098        /* select the quantization table and return the decoded value */
00099 
00100        if (cblen==8) {
00101            return scale*gain_sq3Tbl[index];
00102        } else if (cblen==16) {
00103            return scale*gain_sq4Tbl[index];
00104        }
00105        else if (cblen==32) {
00106            return scale*gain_sq5Tbl[index];
00107        }
00108 
00109        return 0.0;
00110    }

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().

00032     {
00033        int i, tindex;
00034        float minmeasure,measure, *cb, scale;
00035 
00036        /* ensure a lower bound on the scaling factor */
00037 
00038        scale=maxIn;
00039 
00040        if (scale<0.1) {
00041            scale=(float)0.1;
00042        }
00043 
00044        /* select the quantization table */
00045 
00046        if (cblen == 8) {
00047            cb = gain_sq3Tbl;
00048        } else if (cblen == 16) {
00049            cb = gain_sq4Tbl;
00050        } else  {
00051            cb = gain_sq5Tbl;
00052        }
00053 
00054        /* select the best index in the quantization table */
00055 
00056        minmeasure=10000000.0;
00057        tindex=0;
00058        for (i=0; i<cblen; i++) {
00059 
00060 
00061 
00062 
00063 
00064            measure=(in-scale*cb[i])*(in-scale*cb[i]);
00065 
00066            if (measure<minmeasure) {
00067                tindex=i;
00068                minmeasure=measure;
00069            }
00070        }
00071        *index=tindex;
00072 
00073        /* return the quantized value */
00074 
00075        return scale*cb[tindex];
00076    }


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