view libgsmhr1/enc_out_order.c @ 550:de333989a12b

document gsm[e]fr-decode-tw5[-r] utilities
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Oct 2024 02:16:48 +0000
parents 17c0aabae474
children
line wrap: on
line source

/*
 * 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;
}