/*******************************************************************
                    MPEG-2 Video Interface
 *******************************************************************/
#ifndef MPEG2VIDEO_H
#define MPEG2VIDEO_H

#include <windows.h>

#include "video_stream.h"
#include "sequence_header.h"
#include "picture_header.h"
#include "frame.h"
#include "gop.h"
#include "picture.h"
#include "mc.h"
#include "idct.h"
#include "out_buffer.h"
#include "resize.h"

typedef struct {
	VIDEO_STREAM                bitstream;
	SEQUENCE_HEADER             seq;
	PICTURE_HEADER              pic;
	READ_PICTURE_HEADER_OPTION  pic_opt;

	FIND_GOP                    fg;
	GOP                         current;
	
	MC_BUFFER                   dec_buf;
	DECODE_PICTURE_PARAMETER    dec_prm;

	int                         remap;
	int                         resize;
	int                         field_order;
	int                         field_mode;

	H_RESIZE_PARAMETER         *hrs_prm;
	
	BGR_CONVERSION_PARAMETER    bgr_prm;

	OUTPUT_PARAMETER            fwd_prm;
	OUTPUT_PARAMETER            cur_prm;
	OUTPUT_PARAMETER            bwd_prm;

	OUT_BUFFER                  out_buf;

	__int64                     total;
	int                         rate;
	int                         scale;

	CRITICAL_SECTION            lock;
	
} MPEG2VIDEO;
	
#ifdef __cplusplus
extern "C" {
#endif

#ifndef MPEG2VIDEO_C	
extern int open_mpeg2video(char *path, MPEG2VIDEO *out);
extern int close_mpeg2video(MPEG2VIDEO *p);
extern OUT_BUFFER_ELEMENT *read_frame(MPEG2VIDEO *in, __int64 frame);
#endif

#ifdef __cplusplus
}
#endif

#endif