* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv16encoder.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
/* Refine the pitch period in the neighborhood of coarse pitch period
also calculate the pitch predictor tap for single-tap predictor */
pp = refinepitch(dq, cpp, &ppt);
- bs.ppidx = pp - MINPP;
+ bs.ppidx = (int16_t) (pp - MINPP);
/* Vector quantize 3 pitch predictor taps with minimum residual energy */
- bs.bqidx = pitchtapquan(dq, pp, bq, &lg);
+ bs.bqidx = (int16_t) pitchtapquan(dq, pp, bq, &lg);
/* Get coefficients of long-term noise feedback filter */
if (ppt > 1.0)
/* Gain quantization */
lg = (lg < FRSZ) ? 0 : log(lg/FRSZ)/log(2.0);
- bs.gidx = gainquan(&gainq, lg, cs->lgpm, cs->prevlg, cs->level);
+ bs.gidx = (int16_t) gainquan(&gainq, lg, cs->lgpm, cs->prevlg, cs->level);
/* Level estimation */
dummy = estl_alpha;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv16excquan.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
/* The best codevector has been found; assign vq codebook index */
if (sign == 1.0F)
- idx[iv++] = jmin;
+ idx[iv++] = (int16_t) jmin;
else
- idx[iv++] = jmin + CBSZ; /* MSB of index is sign bit */
+ idx[iv++] = (int16_t) (jmin + CBSZ); /* MSB of index is sign bit */
fp3 = &cb[jmin*VDIM]; /* fp3 points to start of best codevector */
for (n = 0; n < VDIM; n++)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv16lspquan.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
#include "bv16externs.h"
#include "bvcommon.h"
-void vqmse(
- Float *xq,
- int16_t *idx,
- Float *x,
- const Float *cb,
- int vdim,
- int cbsz);
+void vqmse(Float *xq,
+ int16_t *idx,
+ Float *x,
+ const Float *cb,
+ int vdim,
+ int cbsz);
-void svqwmse(
- Float *xq,
- int16_t *idx,
- Float *x,
- Float *xa,
- Float *w,
- const Float *cb,
- int vdim,
- int cbsz);
+void svqwmse(Float *xq,
+ int16_t *idx,
+ Float *x,
+ Float *xa,
+ Float *w,
+ const Float *cb,
+ int vdim,
+ int cbsz);
-void lspquan(
- Float *lspq,
- int16_t *lspidx,
- Float *lsp,
- Float *lsppm
-)
+void lspquan(Float *lspq,
+ int16_t *lspidx,
+ Float *lsp,
+ Float *lsppm)
{
Float d[LPCO];
Float w[LPCO];
int i;
int k;
- /* calculate the weights for weighted mean-square error distortion */
+ /* Calculate the weights for weighted mean-square error distortion */
for (i = 0; i < LPCO - 1; i++)
d[i] = lsp[i + 1] - lsp[i]; /* LSP difference vector */
w[0] = 1.0F/d[0];
for (i = 0; i < LPCO; i++)
lspe[i] = lspeq1[i] + lspeq2[i];
- /* update lsp ma predictor memory */
+ /* Update lsp ma predictor memory */
i = LPCO * LSPPORDER - 1;
fp1 = &lsppm[i];
fp2 = &lsppm[i - 1];
fp2--;
}
- /* calculate quantized lsp */
+ /* Calculate quantized lsp */
for (i = 0; i < LPCO; i++)
lspq[i] = lspa[i] + lspeq2[i];
- /* ensure correct ordering of lsp to guarantee lpc filter stability */
+ /* Ensure correct ordering of lsp to guarantee lpc filter stability */
stblz_lsp(lspq, LPCO);
}
-void vqmse(Float *xq, /* VQ output vector (quantized version of input vector) */
- int16_t *idx, /* VQ codebook index for the nearest neighbor */
- Float *x, /* input vector */
- const Float *cb, /* VQ codebook */
- int vdim, /* vector dimension */
- int cbsz) /* codebook size (number of codevectors) */
+void vqmse(Float *xq, /* VQ output vector (quantized version of input vector) */
+ int16_t *idx, /* VQ codebook index for the nearest neighbor */
+ Float *x, /* input vector */
+ const Float *cb, /* VQ codebook */
+ int vdim, /* vector dimension */
+ int cbsz) /* codebook size (number of codevectors) */
{
const Float *fp1;
Float dmin;
if (d < dmin)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
}
}
}
/* Signed WMSE VQ */
-void svqwmse(
- Float *xq, /* VQ output vector (quantized version of input vector) */
- int16_t *idx, /* VQ codebook index for the nearest neighbor */
- Float *x, /* input vector */
- Float *xa, /* approximation prior to current stage */
- Float *w, /* weights for weighted Mean-Square Error */
- const Float *cb, /* VQ codebook */
- int vdim, /* vector dimension */
- int cbsz /* codebook size (number of codevectors) */
-)
+void svqwmse(Float *xq, /* VQ output vector (quantized version of input vector) */
+ int16_t *idx, /* VQ codebook index for the nearest neighbor */
+ Float *x, /* input vector */
+ Float *xa, /* approximation prior to current stage */
+ Float *w, /* weights for weighted Mean-Square Error */
+ const Float *cb, /* VQ codebook */
+ int vdim, /* vector dimension */
+ int cbsz) /* codebook size (number of codevectors) */
{
const Float *fp1;
const Float *fp2;
Float dmin;
Float d;
Float xqc[STBLDIM];
- int j, k, stbl, sign=1;
+ int j;
+ int k;
+ int stbl;
+ int sign = 1;
Float e;
fp1 = cb;
d += w[k]*e*e;
}
- /* check candidate - negative sign */
+ /* Check candidate - negative sign */
if (d < dmin)
{
for (k = 0; k < STBLDIM; k++)
xqc[k] = xa[k] - *fp2++;
- /* check stability - negative sign */
+ /* Check stability - negative sign */
stbl = stblchck(xqc, STBLDIM);
if (stbl > 0)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
sign = -1;
}
}
d += w[k]*e*e;
}
- /* check candidate - positive sign */
+ /* Check candidate - positive sign */
if (d < dmin)
{
for (k = 0; k < STBLDIM; k++)
xqc[k] = xa[k] + *fp2++;
- /* check stability - positive sign */
+ /* Check stability - positive sign */
stbl = stblchck(xqc, STBLDIM);
if (stbl > 0)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
sign = +1;
}
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv32encoder.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
/* Refine the pitch period in the neighborhood of coarse pitch period
also calculate the pitch predictor tap for single-tap predictor */
pp = bv32_refinepitch(dq, cpp, &ppt);
- bs.ppidx = pp - MINPP;
+ bs.ppidx = (int16_t) (pp - MINPP);
/* vq 3 pitch predictor taps with minimum residual energy */
- bs.bqidx = bv32_pitchtapquan(dq, pp, bq);
+ bs.bqidx = (int16_t) bv32_pitchtapquan(dq, pp, bq);
/* get coefficients for long-term noise feedback filter */
if (ppt > 1.0)
/* Log-gain quantization within each sub-frame */
lg = (ee < TMinE) ? MinE : log(ee/SFRSZ)/log(2.0);
- bs.gidx[issf] = bv32_gainquan(gainq + issf, lg, cs->lgpm, cs->prevlg, cs->level);
+ bs.gidx[issf] = (int16_t) bv32_gainquan(gainq + issf, lg, cs->lgpm, cs->prevlg, cs->level);
- /* Level estimation */
+ /* Level Estimation */
bv32_estlevel(cs->prevlg[0], &cs->level, &cs->lmax, &cs->lmin, &cs->lmean, &cs->x1);
/* Scale the excitation codebook */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv32excquan.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
/* THE BEST CODEVECTOR HAS BEEN FOUND; ASSIGN VQ CODEBOOK INDEX */
if (sign == 1.0F)
- idx[iv++] = jmin;
+ idx[iv++] = (int16_t) jmin;
else
- idx[iv++] = jmin + CBSZ; /* MSB of index is sign bit */
+ idx[iv++] = (int16_t) (jmin + CBSZ); /* MSB of index is sign bit */
/* BORROW zbuf[] TO STORE FINAL VQ OUTPUT VECTOR WITH CORRECT SIGN */
fp3 = &cb[jmin*VDIM]; /* fp3 points to start of best codevector */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bv32lspquan.c,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
*/
/*! \file */
if (d < dmin)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
}
}
if (d < dmin)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
}
}
}
if (d < dmin)
{
dmin = d;
- *idx = j;
+ *idx = (int16_t) j;
}
}