/*
// ================================================================
// BitStream.h MMX VERSION
// Ubi Sound Studios
// 18/03/1997
// Guillaume Michel
// ================================================================
// Bitstream can be on file or in memory
*/

#ifndef _BITSTREAM_
#define _BITSTREAM_

// main structure
typedef struct SND_tdstBitStream {
	// pour mmx
	unsigned long  _bit_count;
	unsigned long  _end_buf;
	unsigned long  _save_mm0;
	unsigned long  _save_mm0_2;
	unsigned long  _bOk;
	unsigned long  _buf_pointer;
	
	unsigned char	*pucBuffer;
	tdhSndFile		*pFile;

	unsigned long	ulDataOffset;
	unsigned long	ulFinalSize; // Size of the sound after decompression
	unsigned long	ulDolbyMark; // if == 'SURR' then the file is dolby surround one

} SND_tdstBitStream;

// ALLOCATING, OPENING, FREEING...
SndBool SND_fn_bAllocateBitStream(SND_tdstBitStream* pBitStream);
SndBool SND_fn_bFreeBitStream(SND_tdstBitStream* pBitStream);
SndBool SND_fn_bInitBitStream(SND_tdstBitStream* pBitStream);

SndBool SND_fn_bOpenBitStreamFile(SND_tdstBitStream* pBitStream, char* pFilename, unsigned long ulOffset);
SndBool SND_fn_bOpenBitStreamMem(SND_tdstBitStream* pBitStream,unsigned char* pBuffer, unsigned long ulSize);

// CLOSING
SndBool SND_fn_bCloseBitStream(SND_tdstBitStream* pBitStream);

// READING
SndBool SND_fn_bGet1Bit( SND_tdstBitStream* pBitStream,unsigned short *puwValue);
SndBool SND_fn_bGetNBits(SND_tdstBitStream* pBitStream,unsigned short *puwValue, unsigned char ucNbBits);
SndBool SND_fn_bSeekSynch(SND_tdstBitStream* pBitStream);

#endif
 