/*--------------------------------------------------------------------------*/ /* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ /* © 2008 Ericsson AB. and Polycom Inc. */ /* All rights reserved. */ /*--------------------------------------------------------------------------*/ #include "proto.h" #include "cnst.h" #include "rom.h" /*--------------------------------------------------------------------------*/ /* Function flvqdec */ /* ~~~~~~~~~~~~~~~~~ */ /* */ /* Decoding of Fast Lattice Vector Quantization (FLVQ) */ /*--------------------------------------------------------------------------*/ /* short **bitstream (i) bit-stream vector */ /* float *coefsq (o) MLT coefficient vector */ /* float *coefsq_norm (o) normalized MLT coefficient vector */ /* short R (o) bit-allocation vector */ /* short NumSpectumBits (i) number of available bits */ /* short *ynrm (o) norm quantization index vector */ /* short is_transient (i) transient flag */ /*--------------------------------------------------------------------------*/ void flvqdec( short **bitstream, float *coefsq, float *coefsq_norm, short *R, short NumSpectumBits, short *ynrm, short is_transient ) { short i, j, k, v, nb_sfm; short diff; short hcode_l, FlagL, FlagN, FlagC; short idx[NB_SFM], normqlg2[NB_SFM], wnorm[NB_SFM], idxbuf[NB_SFM]; short ycof[STOP_BAND]; short *pbits; short **ppbits; pbits = *bitstream; /*** Unpacking bit stream to flags ***/ FlagL = 0; if ((*pbits++)==G192_BIT1) { FlagL = 1; } FlagN = 0; if ((*pbits++)==G192_BIT1) { FlagN = 1; } FlagC = 0; if ((*pbits++)==G192_BIT1) { FlagC = 1; } /*** Unpacking bit stream and Huffman decoding for indices of quantized norms ***/ if (FlagL==NOALLGROUPS) { nb_sfm = SFM_N; } else { nb_sfm = NB_SFM; } bits2idxn(pbits, NORM0_BITS, ynrm); pbits += NORM0_BITS; if (FlagN==HUFCODE) { hdecnrm(pbits, NB_SFM, &ynrm[1]); hcode_l = 0; for (i=1; iSFM_N) { k = unpackc(R, pbits, FlagC, NUMC_N, SFM_N, NB_SFM, WID_GX, ycof); pbits += k; hcode_l += k; } diff = v - hcode_l; /*** Lattice Vector De-quantization for normalized MLT coefficients ***/ /* First group */ dqcoefs(&ycof[0], ynrm, R, 0, SFM_G1, WID_G1, &coefsq[0], &coefsq_norm[0]); /* Second group */ dqcoefs(&ycof[NUMC_G1], ynrm, R, SFM_G1, SFM_G1G2, WID_G2, &coefsq[NUMC_G1], &coefsq_norm[NUMC_G1]); /* Third group */ dqcoefs(&ycof[NUMC_G1G2], ynrm, R, SFM_G1G2, SFM_N, WID_G3, &coefsq[NUMC_G1G2], &coefsq_norm[NUMC_G1G2]); /* Forth group */ dqcoefs(&ycof[NUMC_N], ynrm, R, SFM_N, NB_SFM, WID_GX, &coefsq[NUMC_N], &coefsq_norm[NUMC_N]); /*** Processing for noise-filling sub-vectors ***/ ppbits = &pbits; dprocnobitsbfm(R, idx, ynrm, ycof, ppbits, coefsq, coefsq_norm, nb_sfm, diff); *bitstream = pbits; return; }