/*******************************************************************
                YUV frame treating interface
 *******************************************************************/

#ifndef FRAME_H
#define FRAME_H

#define UCHAR_CLIP_TABLE_OFFSET 384

typedef struct {

	int width;
	int height;

	int in_offset;
	int in_step;
	
	int out_step;

	int yo; /* Y offset                    */
	
	int yg; /* Y gain                      */

	int bu; /* U(B-Y) to Bule coefficient  */

	int gu; /* U(B-Y) to Green coefficient */
	int gv; /* V(R-Y) to Green coefficient */

	int rv; /* V(R-Y) to Red coefficient   */

} BGR_CONVERSION_PARAMETER;

typedef struct {
	int height;
	int width;

	unsigned char *p;

	unsigned char *y;
	unsigned char *u;
	unsigned char *v;
} FRAME;

/* typedef void (__stdcall * FRAME2BGR)(FRAME *, unsigned char *, int); */
typedef void (* UPSAMPLE_CHROMA)(FRAME *);

#ifdef __cplusplus
extern "C" {
#endif

#ifndef FRAME_C
extern const unsigned char uchar_clip_table[1024];

extern FRAME *new_frame(int width, int height);
extern void delete_frame(FRAME *p);
extern FRAME *copy_frame(FRAME *in);

extern void __stdcall yuv444_to_bgr(FRAME *top, FRAME *bottom, unsigned char *out, BGR_CONVERSION_PARAMETER *prm);

extern void upsample_chroma_444(FRAME *p);
extern void upsample_chroma_422(FRAME *p);
extern void upsample_chroma_420i(FRAME *p);
extern void upsample_chroma_420p(FRAME *p);

extern void upsample_chroma_422_mmx(FRAME *p);
extern void upsample_chroma_420i_mmx(FRAME *p);
extern void upsample_chroma_420p_mmx(FRAME *p);

/* extern void __stdcall yuv444_to_bgr_mmx(FRAME *in, unsigned char *out, int out_step); */
#endif
	
#ifdef __cplusplus
}
#endif

#endif