void sid_lsfq_decode( int *index, /* (i) : quantized indices */ FLOAT *lspq, /* (o) : quantized lsp vector */ FLOAT freq_prev[MA_NP][M] /* (i) : memory of predictor */ ) { int i; FLOAT lsfq[M], tmpbuf[M]; /* get the lsf error vector */ copy(lspcb1[PtrTab_1[index[1]]], tmpbuf, M); for (i=0; i<M/2; i++) tmpbuf[i] = tmpbuf[i]+ lspcb2[PtrTab_2[0][index[2]]][i]; for (i=M/2; i<M; i++) tmpbuf[i] = tmpbuf[i]+ lspcb2[PtrTab_2[1][index[2]]][i]; /* 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[index[0]], freq_prev, noise_fg_sum[index[0]]); /* 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]); }
/*-----------------------------------------------------------------* * 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; }