/* getvlc.h, variable length code tables                                    */

/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */

/*
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
 * any and all warranties, whether express, implied, or statuary, including any
 * implied warranties or merchantability or of fitness for a particular
 * purpose.  In no event shall the copyright-holder be liable for any
 * incidental, punitive, or consequential damages of any kind whatsoever
 * arising from the use of these programs.
 *
 * This disclaimer of warranty extends to the user of these programs and user's
 * customers, employees, agents, transferees, successors, and assigns.
 *
 * The MPEG Software Simulation Group does not represent or warrant that the
 * programs furnished hereunder are free of infringement of any third-party
 * patents.
 *
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
 * are subject to royalty fees to patent holders.  Many of these patents are
 * general enough such that they are unavoidable regardless of implementation
 * design.
 *
 * MPEG2AVI
 * --------
 *  v0.16B33 the actual table has been moved to vlctable.c
 *   the VLCtab struct and DCTtab struct have been padded to 32-bits
 *   tables have been promoted to multiples of 8
 */

/* NOTE: #define constants such as MACROBLOCK_QUANT are upper case 
   as per C programming convention. However, the MPEG document 
   (ISO/IEC 13818-2) lists them in all lower case (e.g. Annex B) */

/* NOTE: the VLC tables are in a flash format---a transformation
   of the tables in Annex B to a form more convenient towards 
   parallel (more than one-bit-at-a-time) decoding */

#ifndef _GETVLC_H
#define _GETVLC_H 1

#ifndef _VLCTABLE_C
	#ifndef EXTERN
		#define EXTERN extern
	#endif
#else
	#ifndef EXTERN
		#define EXTERN
	#endif
#endif

typedef struct {
  short val, len;
} VLCtab;

typedef struct {
  char run, level, len;
  char unused;
} DCTtab;


/* Table B-5, macroblock_type in spat. scal. I-pictures, codes 0001..1xxx */
 EXTERN VLCtab spIMBtab[16];

/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0010..11xx */
 EXTERN VLCtab spPMBtab0[16];

/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0000010..000111x */
 EXTERN VLCtab spPMBtab1[16];

/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0010..11xx */
 EXTERN VLCtab spBMBtab0[16];

/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0000100..000111x */
 EXTERN VLCtab spBMBtab1[16];

/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 00000100x..000001111 */
 EXTERN VLCtab spBMBtab2[8];

/* Table B-8, macroblock_type in spat. scal. B-pictures, codes 001..1xx */
 EXTERN VLCtab SNRMBtab[8];

/* Table B-10, motion_code, codes 0001 ... 01xx */
 EXTERN VLCtab MVtab0[8];

/* Table B-10, motion_code, codes 0000011 ... 000011x */
 EXTERN VLCtab MVtab1[8];

/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
 EXTERN VLCtab MVtab2[16];

// 8 * 16 bytes

 /* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
 EXTERN VLCtab MBAtab2[128];

// 8 * 16 bytes

/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */
 EXTERN VLCtab CBPtab0[32];

/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */
 EXTERN VLCtab CBPtab1[64];

/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
 EXTERN VLCtab DClumtab0[32];

// 8 * 16 bytes

/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
 EXTERN VLCtab MBAtab1[16];

/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
 EXTERN VLCtab DClumtab1[16];

/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
 EXTERN VLCtab DCchromtab0[32];

/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
 EXTERN VLCtab DCchromtab1[32];

/* Table B-14, DCT coefficients table zero,
 * codes 0100 ... 1xxx (used for first (DC) coefficient)
 */
EXTERN DCTtab DCTtabfirst[16];

/* Table B-14, DCT coefficients table zero,
 * codes 0100 ... 1xxx (used for all other coefficients)
 */
EXTERN DCTtab DCTtabnext[16] ;

// 8 * 16 bytes

/* Table B-15, DCT coefficients table one,
 * codes 000001xx ... 11111111
*/
EXTERN DCTtab DCTtab0a[256] ;

// ---

/* Table B-14, DCT coefficients table zero,
 * codes 000001xx ... 00111xxx
 */
EXTERN DCTtab DCTtab0[64];

/* Table B-14, DCT coefficients table zero,
 * codes 0000001000 ... 0000001111
 */
EXTERN DCTtab DCTtab1[8];

/* Table B-15, DCT coefficients table one,
 * codes 000000100x ... 000000111x
 */
EXTERN DCTtab DCTtab1a[8];

/* Table B-14/15, DCT coefficients table zero / one,
 * codes 000000010000 ... 000000011111
 */
EXTERN DCTtab DCTtab2[16];

/* Table B-14/15, DCT coefficients table zero / one,
 * codes 0000000010000 ... 0000000011111
 */
EXTERN DCTtab DCTtab3[16];

/* Table B-14/15, DCT coefficients table zero / one,
 * codes 00000000010000 ... 00000000011111
 */
EXTERN DCTtab DCTtab4[16];

// 8 * 16 bytes

/* Table B-14/15, DCT coefficients table zero / one,
 * codes 000000000010000 ... 000000000011111
 */
EXTERN DCTtab DCTtab5[16];

/* Table B-14/15, DCT coefficients table zero / one,
 * codes 0000000000010000 ... 0000000000011111
 */
EXTERN DCTtab DCTtab6[16];

/* Table B-3, macroblock_type in P-pictures, codes 001..1xx */
EXTERN VLCtab PMBtab0[8];

/* Table B-3, macroblock_type in P-pictures, codes 000001..00011x */
EXTERN VLCtab PMBtab1[8];

/* Table B-4, macroblock_type in B-pictures, codes 0010..11xx */
 EXTERN VLCtab BMBtab0[16]; 

/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */
 EXTERN VLCtab CBPtab2[8];

/* Table B-4, macroblock_type in B-pictures, codes 000001..00011x */
 EXTERN VLCtab BMBtab1[8];


#endif