⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g726.c

📁 G.726协议的C源码
💻 C
📖 第 1 页 / 共 5 页
字号:
  {    /* Initialized data */    static short    tab[16] = {14, 14, 24, 39, 40, 41, 58, 100, 141, 179, 219, 280, 358,    440, 529, 696};    short           im, is;    is = (*i >> 4);    im = (is == 0) ? (*i & 15) : ((31 - *i) & 15);    *wi = tab[im];  }				/* ................. end of 40 kbit part				 * .............. */}/* ....................... end of G726_functw() ....................... *//* ----------------------------------------------------------------------        void G726_limb (short *yut, short *yup);        ~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Limit quantizer scale factor. 	Inputs: yut 	Output: yup        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_limb(yut, yup)  short          *yut, *yup;{  short           gell, geul;  geul = ((*yut + 11264) & 16383) >> 13;  gell = ((*yut + 15840) & 16383) >> 13;  if (gell == 1)    *yup = 544;			/* Lower limit is 1.06 */  else if (geul == 0)    *yup = 5120;		/* Upper limit is 10.0 */  else    *yup = *yut;}/* ....................... end of G726_limb() ....................... *//* ----------------------------------------------------------------------        void G726_mix (short *al, short *yu, long *yl, short *y);        ~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Form linear combination of fast and slow  quantizer scale        factors. 	Inputs:    al, yu, yl 	Output:    y        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_mix(al, yu, yl, y)  short          *al, *yu;  long           *yl;  short          *y;{  long            difm, difs, prod;  long            prodm, al1;  long            yu1, dif;  /* Preamble */  al1 = *al;  yu1 = *yu;  /* Compute difference */  dif = (yu1 + 16384 - (*yl >> 6)) & 16383;  difs = (dif >> 13);  /* Compute magnitude of difference */  difm = (difs == 0) ? dif : ((16384 - dif) & 8191);  /* Compute magnitude of product */  prodm = ((difm * al1) >> 6);  /* Convert magnitude to two's complement */  prod = (difs == 0) ? prodm : ((16384 - prodm) & 16383);  *y = (short) (((*yl >> 6) + prod) & 8191);}/* ....................... end of G726_mix() ....................... *//* ----------------------------------------------------------------------        void G726_filta (short *fi, short *dms, short *dmsp);        ~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Update of short term average of f(i). 	Inputs:   fi, dms 	Output:   dmsp        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_filta(fi, dms, dmsp)  short          *fi, *dms, *dmsp;{  short           difs, difsx;  short           dif;  /* Compute difference */  dif = ((*fi << 9) + 8192 - *dms) & 8191;  difs = (dif >> 12);  /* Time constant is 1/32, sign extension */  difsx = (difs == 0) ? (dif >> 5) : ((dif >> 5) + 3840);  *dmsp = (difsx + *dms) & 4095;}/* ....................... end of G726_filta() ....................... *//* ----------------------------------------------------------------------        void G726_filtb (short *fi, short *dml, short *dmlp);        ~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Update of long term average of f(i). 	Inputs:    fi, dml 	Output:    dmlp        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_filtb(fi, dml, dmlp)  short          *fi, *dml, *dmlp;{  long            difs, difsx;  long            fi1;  long            dif, dml1;  /* Preamble */  fi1 = *fi;  dml1 = *dml;  /* Compute difference */  dif = ((fi1 << 11) + 32768 - dml1) & 32767;  difs = (dif >> 14);  /* Time constant is 1/28, sign extension */  difsx = (difs == 0) ? (dif >> 7) : ((dif >> 7) + 16128);  *dmlp = (short) ((difsx + dml1) & 16383);}/* ....................... end of G726_filtb() ....................... *//* ----------------------------------------------------------------------        void G726_filtc (short *ax, short *ap, short *app);        ~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Low pass filter of speed control parameter. 	Inputs:   ax, ap 	Output:   app        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_filtc(ax, ap, app)  short          *ax, *ap, *app;{  short           difs, difsx;  short           dif;  /* Compute difference */  dif = ((*ax << 9) + 2048 - *ap) & 2047;  difs = (dif >> 10);  /* Time constant is 1/16, sign extension */  difsx = (difs == 0) ? (dif >> 4) : ((dif >> 4) + 896);  *app = (difsx + *ap) & 1023;}/* .................... end of G726_filtc() .................... *//* ----------------------------------------------------------------------        void G726_functf (short rate, short *i, short *fi);        ~~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Map quantizer output into the f(i) function. 	Inputs:   i, rate 	Output:   fi        Return value:          none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_functf(rate, i, fi)  short          *i, *fi;  short           rate;{  short           im, is;  if (rate == 4)  {    /* Initialized data */    static short    tab[8] = {0, 0, 0, 1, 1, 1, 3, 7};    is = (*i >> 3);    im = (is == 0) ? (*i & 7) : ((15 - *i) & 7);    *fi = tab[im];  }				/* ................ end of 32 kbit part				 * ................. */  else if (rate == 3)  {    /* Initialized data */    static short    tab[4] = {0, 1, 2, 7};    is = (*i >> 2);    im = (is == 0) ? (*i & 3) : ((7 - *i) & 3);    *fi = tab[im];  }				/* ................ end of 24 kbit part				 * ................. */  else if (rate == 2)  {    /* Initialized data */    static short    tab[2] = {0, 7};    is = (*i >> 1);    im = (is == 0) ? (*i & 1) : ((3 - *i) & 1);    *fi = tab[im];  }				/* ................ end of 16 kbit part				 * ................. */  else  {    /* Initialized data */    static short    tab[16] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6};    is = (*i >> 4);    im = (is == 0) ? (*i & 15) : ((31 - *i) & 15);    *fi = tab[im];  }				/* ................ end of 40 kbit part				 * ................. */}/* ...................... end of G726_functf() ...................... *//* ----------------------------------------------------------------------        void G726_lima (short *ap, short *al);        ~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Limit speed control parameter. 	Inputs:   ap 	Output:   al        Return value:          none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_lima(ap, al)  short          *ap, *al;{  *al = (*ap >= 256) ? 64 : (*ap >> 2);}/* ....................... end of G726_lima() ....................... *//* ----------------------------------------------------------------------        void G726_subtc (short *dmsp, short *dmlp, short *tdp,        ~~~~~~~~~~~~~~~  short *y, short *ax);        Description:        ~~~~~~~~~~~~        Functions of quantizer output sequence  and then perform        threshold comparison for  quantizing speed control parameter.        compute magnitude of the difference of short and  long-term 	Inputs:   dmsp, dmlp, tdp, y 	Output:   ax        Return value:  none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_subtc(dmsp, dmlp, tdp, y, ax)  short          *dmsp, *dmlp, *tdp, *y, *ax;{  long            difm, difs, dthr, dmlp1, dmsp1;  long            dif;  /* Preamble */  dmsp1 = *dmsp;  dmlp1 = *dmlp;  /* Compute difference */  dif = ((dmsp1 << 2) + 32768 - dmlp1) & 32767;  difs = (dif >> 14);  /* Compute magnitude of difference */  difm = (difs == 0) ? dif : ((32768 - dif) & 16383);  /* Compute threshold */  dthr = (dmlp1 >> 3);  /* Quantize speed control parameter */  *ax = (*y >= 1536 && difm < dthr && *tdp == 0) ? 0 : 1;}/* ....................... end of G726_subtc() ....................... *//* ----------------------------------------------------------------------        void G726_triga (short *tr, short *app, short *apr);        ~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Speed control trigger block. 	Inputs: tr, app 	Output: apr        Return value:          none.        ~~~~~~~~~~~~~        Prototype:   in g726.h        ~~~~~~~~~~        History:        ~~~~~~~~        31.Jan.91 v1.0f Release of 1st Fortran version to UGST.        		<tdsindi@venus.cpqd.ansp.br>        13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c)        		<tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void            G726_triga(tr, app, apr)  short          *tr, *app, *apr;{  *apr = (*tr == 0) ? (*app) : 256;}/* ....................... end of G726_triga() ....................... *//* ----------------------------------------------------------------------        void G726_accum (short *wa1, short *wa2, short *wb1,        ~~~~~~~~~~~~~~~  short *wb2, short *wb3, short *wb4,                        short *wb5, short *wb6, short *se, short *sez);        Description:        ~~~~~~~~~~~~        Addition of predictor outputs to form the partial  signal        estimate (from the sixth order predictor)  and the signal        estimate. 	Inputs:   wa1, wa2, wb1, wb2, wb3, wb4, wb5, wb6 	Output:   se, sez

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -