/*****************************************************************************
Copyright (c) 2000-2003 Analog Devices.  All Rights Reserved.

Developed by Analog Devices Australia - Unit 3, 97 Lewis Road,
Wantirna, Victoria, Australia, 3152.  Email: ada.info@analog.com

THIS SOFTWARE IS PROPRIETARY & CONFIDENTIAL.  By using this module you
agree to the terms of the associated Analog Devices License Agreement.
******************************************************************************

$RCSfile: JPEG_bitsbuffer.h,v $
$Revision: 1.1 $
$Date: 2008/03/17 14:56:38 $

Project:	JPEG IMAGE CODEC
Title:		User-Defined Typedefs
Author(s):	D. George, A. Sarumpaet, PSSBK Gupta
Revised by:	

Description:
Header for all user-defined modules.
This header file is only for use with the user-defined data buffer module.
It must NOT be included by any JPEG Library module.

The data structures defined here are ONLY referenced in the user-defined 
modules: McuBuffer.c, BitsBuffer.c and MemAlloc.c.

References:
	
******************************************************************************
Tab Setting:			4
Target Processor:		Blackfin
Target Tools Revision:	ccblkfn		C/C++ compiler					6.3.0.0
						easmblkfn	BlackFin assembler				2.2.4.1
						elfar		ELF Librarian/Archive Utility	4.4.1.2
						linker		Linker							2.8.8.2
******************************************************************************

Modification History:
====================
$Log: JPEG_bitsbuffer.h,v $
Revision 1.1  2008/03/17 14:56:38  gstephan
Updates for SDK 3.00

Revision 1.3  2004/08/30 02:17:18  sto
Checkin of all decoder related files from Conrad Jakob

Revision 1.1  2004/06/04 05:24:50  sto
jpeg encoder/decoder integrated

Revision 1.4  2004/05/28 02:50:09  sto
minor clean up

Revision 1.3  2004/05/27 22:43:14  sto
debugged for encoder operation - much cleanup carried out

Revision 1.2  2004/05/24 01:27:05  sto
added BF561 build, some header files moved from decoder/lib to common/lib

Revision 1.1.1.1  2004/05/02 23:42:09  sto
Initial checkin of ADA JPEG decoder ALPHA version

Revision 2.0  2004/02/18 01:01:01  A. Sarumpaet
Merged with decoder structures

Revision 1.3  2003/11/18 01:01:01  D. George
Added DMA support

Revision 1.2  2003/11/06 01:01:01  D. George
Added MemObjHandle typedef, tidied up and moved to standard template.

Revision 1.1  2003/09/18 01:01:01  A. Sarumpaet
New API changes

Revision 1.0  2003/03/10 01:01:01  PSSBK Gupta
Initial code

******************************************************************************/

#ifndef MY_TYPEDEFS_H
#define MY_TYPEDEFS_H

#include <stdio.h>
#include "IMG_common.h"				// for int32 and other typedefs
#include "JPEG_memalloc.h"




/****************************************************************************
 * 		Typedefs/Enumerations												*
 ****************************************************************************/

/* For passing buffers */
typedef struct {
    int     Length;
    uint8   *Pointer;
} tIMG_BufferInfo; 
 
/* Structure for Bits Buffer (Encoder tPutBitsBuffer, renamed) */
typedef struct
{
    // Encoder-only members:
	uint8		*externalBuffer;        // Pointer to output buffer (ENCODER only)
	
	uint8		*desBuffer1;			// aligned to 4
	uint8		*desBuffer2;			// aligned to 4
	int32		externalBufferIndex;    // Pointer to unused part of externalBuffer
	int32		firstOrsecondBuffer;	// A bitsBufferIndex
	int32		nextBuffer;				// Flag to state that Request should use the next buffer.
	int32		numberOfBuffers;		// Number of bits buffers available
	int32		numberOfEmptyBuffers;	// Number of empty bits buffers
	int32		writeBufferCount;		// Buffer count (for dma check)
	int32		numBytes;               // Total number of bytes written TO buffer
	int32		dmaInitiateThreshold;

    // Decoder-only members:
    tIMG_BufferInfo	*ptrFile;			// Pointer to input file
    int         	numBytesBuf_1;		// No of bytes read into buffer 1
    int         	numBytesBuf_2;		// No of bytes read into buffer 2
    int         	end_of_file;		// Set to 1 when end of input file reached

    // Encoder and Decoder Mem Alloc members:
	MemObjHandle	*ThisMemObj;		// memory allocated for tPutBitsBuffer itself
	MemObjHandle	*BufferMemObjs[2];	// for array of buffer memory allocations
	
	int         is_encoder;             // Set to 1 for encoder; 0 for decoder

	MemObjHandle	*DecodeBitStreamMemObj;		// memory allocated for entire Bit Stream Buffer
    uint8       *InputBitstreamFile;
    int         BitStreamFileSize;
    int         InputFilePosition;
} tBitsBuffer;



#endif // MY_TYPEDEFS_H
