#ifndef _HEADERS_H_ #define _HEADERS_H_ #include #include /* for malloc() and abs() */ #include /***************************************************** * Quantization factor definition. You can modify this * to test different level of quatizations ****************************************************/ #define QPI_DEF 16 /***************************************************** * Number of frames to be encoded. You can modify this * to limit encoding duration. ****************************************************/ #define NUM_OF_FRAMES_DEF 10 /***************************************************** * Uncomment the following define to disable output * printing for profiling purposes ****************************************************/ /* #define DISABLE_OUTPUT */ /* Platform-specific type definition */ typedef unsigned char uint8; /* 8-bit unsigned type */ typedef unsigned short uint16; /* 16-bit unsigned (TI's DCT uses this) */ typedef signed short sint16; /* 16-bit signed for DCT coeffs */ typedef signed int sint32; /* 32-bit signed for computations */ typedef unsigned int uint32; /* Memory addressing + offsets & index */ typedef long int vlong; /* This should always be 32-bits */ typedef int vbool; /* A boolean type for C-language */ typedef float vfloat; /* float type to help implementation */ typedef char vchar; /* byte strings for text representation */ /* Picture structure */ typedef struct { uint32 TR; /* Time reference */ uint16 QUANT; /* Quantization factor */ } PictureType; /* Bitstream structure */ typedef struct { uint16 bitcount; sint32 buffer; FILE *file; } BitStreamType; /* Macroblock structure */ typedef struct { sint32 cbp; sint16 *data; /* pointer to the macroblock data. Note that you have to take care of the memory allocation */ } MBType; /* VLC table element structure */ typedef struct { sint16 bitPattern; sint16 bitCount; } structVLC; /* H.263 symbol coding tables */ extern const structVLC mcbpcIntraTable[2][4]; extern const structVLC mcbpcInterTable[5][4]; extern const structVLC cbpyTable[16]; #define V_TRUE 1 #define V_FALSE 0 /* Macro for clipping the pixel values */ #define CLIP(min,value,max) \ if( value < min ) value = min; \ else if( value > max ) value = max; /***************************************************************************** * Function declarations. * * You need to use these functions to implement your encoder. The source code * contain additional functions but your code should only call the functions * listed here. * ****************************************************************************/ /* bitstream.c functions*/ extern void bitstreamInitBuffer(BitStreamType * const stream); extern void bitstreamFlushBufferToFile(BitStreamType * const stream); extern void bitstreamAlign( BitStreamType * const stream ); extern void bitstreamPut(const uint32 number_of_bits, const sint32 val, BitStreamType * const stream); /* code.c functions */ extern void codePictureHeader( const PictureType * const pic, BitStreamType * const stream ); extern void codeIntraMB(const MBType * const MB, BitStreamType * const stream); /* yuv.c functions */ extern FILE* yuvOpenInputFile( const vchar *file_name, sint32 *frame_count); extern vbool yuvReadFrame( FILE * const file, uint8 * const target_buffer ); /* memory.c */ extern void memoryLoadMB(const sint32 yMB, const sint32 xMB, const uint8 * const image, uint8 *mb_data); /* quantize.c */ extern void quantizeIntraMB( const sint32 QP, MBType * const MB ); /* dct.c */ extern void fdct_8x8(uint8 *input_data, sint16 *output_data, sint32 num_fdcts); /* vlc.c */ extern vbool vlcCodeCoefficient( const sint32 last, const sint32 run, const sint32 level, const sint32 sign, BitStreamType * const stream ); #endif