#/************************* MPEG-2 NBC Audio Decoder **************************
 *                                                                           *
"This software module was originally developed by 
AT&T, Dolby Laboratories, Fraunhofer Gesellschaft IIS in the course of 
development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 
14496-1,2 and 3. This software module is an implementation of a part of one or more 
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 
Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio 
standards free license to this software module or modifications thereof for use in 
hardware or software products claiming conformance to the MPEG-2 NBC/MPEG-4
Audio  standards. Those intending to use this software module in hardware or 
software products are advised that this use may infringe existing patents. 
The original developer of this software module and his/her company, the subsequent 
editors and their companies, and ISO/IEC have no liability for use of this software 
module or modifications thereof in an implementation. Copyright is not released for 
non MPEG-2 NBC/MPEG-4 Audio conforming products.The original developer
retains full right to use the code for his/her  own purpose, assign or donate the 
code to a third party and to inhibit third party from using the code for non 
MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must
be included in all copies or derivative works." 
Copyright(c)1996.
 *                                                                           *
 ****************************************************************************/
#if 0

#include "bitstream.h"
#incldue "buffers.h"
#include "all.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>

#ifdef WIN32
#include <io.h>
#endif

#define	PATH_LEN    128

static	int	outfd[Chans];
static	char	output_path[PATH_LEN];

void
usage(char *s)
{
  PRINT(SE, "usage:  %s [options] chan_file pcm_file\n", s);
  PRINT(SE, "	options are:\n");
  PRINT(SE, "	-i [prog_tag] ADIF header present (first prog is default)\n");
  PRINT(SE, "	-p profile (Main or LC, Main is default)\n");
  PRINT(SE, "	-s sampling_frequency, Hz (48 kHz is default)\n");
  PRINT(SE, "	-D[a-Z] (enable debugging printouts)\n");
  CommonExit(0,"");
}


/* --- This contains the bitbuffer, from where getxxx() will read --- */
static BsBitStream *myBitBuffer;

  
/* -------------------------------------- */
/* -------------------------------------- */
/* -----  Set the current Bitbuffer ----- */
/* -------------------------------------- */
/* -------------------------------------- */
void
set_aac_bitBuffer(BsBitStream *fixed_stream)
{
  myBitBuffer = fixed_stream;
} 
void
fmtchan(char *p, float *data, int stride)
{
  int i, c;
  float s;

  for(i=0; i<LN2; i++) {
    s = *data++;
    if(s < 0) {
      s -= .5;
      if(s < -0x7fff)
        s = (float) -0x7fff;
    } else {
      s += .5;
      if(s > 0x7fff)
        s = (float) 0x7fff;
    }
    c = (int) s;

    p[0] = (c >> 8) & 0xff;
    p[1] = c & 0xff;

    p += stride;
  }
}

int
getbyte(void)
{

  unsigned long value;
  
  BsGetBit(myBitBuffer,  &value, 8);

  return ((int)value);
}
#endif

