Beispiel #1
0
/*-----------------------------------------------------------------*
 * Functions lsfq_noise                                            *
 *           ~~~~~~~~~~                                            *
 * Input:                                                          *
 *   lsp[]         : unquantized lsp vector                        *
 *   freq_prev[][] : memory of the lsf predictor                   *
 *                                                                 *
 * Output:                                                         *
 *                                                                 *
 *   lspq[]        : quantized lsp vector                          * 
 *   ana[]         : indices                                       *
 *                                                                 *
 *-----------------------------------------------------------------*/
void lsfq_noise(float * lsp, float * lspq, float freq_prev[MA_NP][M], int *ana)
{
	int i, MS[MODE] = { 32, 16 }, Clust[MODE], mode;
	float lsf[M], lsfq[M], weight[M], tmpbuf[M], errlsf[M * MODE];

	/* convert lsp to lsf */
	for (i = 0; i < M; i++)
		lsf[i] = (float) acos(lsp[i]);

	/* spacing to ~100Hz */
	if (lsf[0] < L_LIMIT)
		lsf[0] = L_LIMIT;
	for (i = 0; i < M - 1; i++) {
		if (lsf[i + 1] - lsf[i] < 2 * GAP3)
			lsf[i + 1] = lsf[i] + 2 * GAP3;
	}
	if (lsf[M - 1] > M_LIMIT)
		lsf[M - 1] = M_LIMIT;
	if (lsf[M - 1] < lsf[M - 2])
		lsf[M - 2] = lsf[M - 1] - GAP3;

	/* get the lsf weighting */
	get_wegt(lsf, weight);

    /**********************/
	/* quantize the lsf's */
    /**********************/
	/* get the prediction error vector */
	for (mode = 0; mode < MODE; mode++)
		lsp_prev_extract(lsf, errlsf + mode * M, noise_fg[mode],
				 freq_prev, noise_fg_sum_inv[mode]);

	/* quantize the lsf and get the corresponding indices */
	Qnt_e(errlsf, weight, MODE, tmpbuf, &mode, 1, Clust, MS);
	ana[0] = (int)mode;
	ana[1] = (int)Clust[0];
	ana[2] = (int)Clust[1];

	/* guarantee minimum distance of 0.0012 between tmpbuf[j]
	   and tmpbuf[j+1] */
	lsp_expand_1_2(tmpbuf, (float) 0.0012);

	/* compute the quantized lsf vector */
	lsp_prev_compose(tmpbuf, lsfq, noise_fg[mode], freq_prev,
			 noise_fg_sum[mode]);

	/* update the prediction memory */
	lsp_prev_update(tmpbuf, freq_prev);

	/* lsf stability check */
	lsp_stability(lsfq);

	/* convert lsf to lsp */
	for (i = 0; i < M; i++)
		lspq[i] = (float) cos(lsfq[i]);

	return;
}
Beispiel #2
0
/*----------------------------------------------------------------------------
 * lsp_qua_cs - lsp quantizer
 *----------------------------------------------------------------------------
 */
static void lsp_qua_cs(struct lsp_cod_state_t * state,
 GFLOAT  *flsp_in,       /*  input : Original LSP parameters      */
 GFLOAT  *lspq_out,       /*  output: Quantized LSP parameters     */
 int  *code             /*  output: codes of the selected LSP    */
)
{
   GFLOAT        wegt[M];   /* weight coef. */

   get_wegt( flsp_in, wegt );

   relspwed( flsp_in, wegt, lspq_out, lspcb1, lspcb2, fg,
            state->freq_prev, fg_sum, fg_sum_inv, code);
}