FreeCalypso > hg > gsm-codec-lib
diff libgsmhr1/enc_out_order.c @ 505:17c0aabae474
libgsmhr1: integrate fillBitAlloc()
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 19 Jun 2024 01:49:03 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmhr1/enc_out_order.c Wed Jun 19 01:49:03 2024 +0000 @@ -0,0 +1,101 @@ +/* + * This module was derived from host.c in the original GSM 06.06 source, + * reduced to just fillBitAlloc() function. + */ + +/*_________________________________________________________________________ + | | + | Include Files | + |_________________________________________________________________________| +*/ + +#include "typedefs.h" +#include "namespace.h" +#include "enc_out_order.h" + +/*************************************************************************** + * + * FUNCTION NAME: fillBitAlloc + * + * PURPOSE: + * + * Arrange speech parameters for encoder output + * + * INPUTS: + * + * The speechcoders codewords: + * iR0 - Frame energy + * piVqIndeces[0:2] - LPC vector quantizer codewords + * iSoftInterp - Soft interpolation bit 1 or 0 + * iVoicing - voicing mode 0,1,2,3 + * piLags[0:3] - Frame and delta lag codewords + * piCodeWrdsA[0:3] - VSELP codevector 1 + * piCodeWrdsB[0:3] - VSELP codevector 2 (n/a for voiced modes) + * piGsp0s[0:3] - GSP0 codewords + * swVadFlag - voice activity detection flag + * swSP - Speech flag + * + * OUTPUTS: + * + * pswBAlloc[0:20] - an array into which the coded data is moved + * + * RETURN VALUE: + * + * none + * + * REFERENCES: Sub-clause 2.1 and 4.1.12 of GSM Recomendation 06.20 + * + **************************************************************************/ + +void fillBitAlloc(int iVoicing, int iR0, int *piVqIndeces, + int iSoftInterp, int *piLags, + int *piCodeWrdsA, int *piCodeWrdsB, + int *piGsp0s, Shortword swVadFlag, + Shortword swSP, Shortword *pswBAlloc) +{ + +/*_________________________________________________________________________ + | | + | Automatic Variables | + |_________________________________________________________________________| +*/ + + int i; + Shortword *pswNxt; + +/*_________________________________________________________________________ + | | + | Executable Code | + |_________________________________________________________________________| +*/ + + pswNxt = pswBAlloc; + *pswNxt++ = iR0; + for (i = 0; i < 3; i++) + *pswNxt++ = *piVqIndeces++; + *pswNxt++ = iSoftInterp; + *pswNxt++ = iVoicing; + + /* check voicing mode */ + if (iVoicing) + { + /* voiced mode */ + for (i = 0; i < N_SUB; i++) + { + *pswNxt++ = *piLags++; + *pswNxt++ = *piCodeWrdsA++; + *pswNxt++ = *piGsp0s++; + } + } + else + { /* unvoiced frame */ + for (i = 0; i < N_SUB; i++) + { + *pswNxt++ = *piCodeWrdsA++; + *pswNxt++ = *piCodeWrdsB++; + *pswNxt++ = *piGsp0s++; + } + } + *pswNxt++ = swVadFlag; + *pswNxt++ = swSP; +}