home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Multimed
/
Multimed.zip
/
divempeg.zip
/
DIMPSRC.ZIP
/
PVGVIDEO.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-14
|
11KB
|
281 lines
#ifndef PVGVIDEO_H
#define PVGVIDEO_H
#include <os2.h>
/* PVG: Public interface to module video.c */
typedef unsigned int UINT32;
typedef unsigned short UINT16;
typedef unsigned char UINT8;
/* Define Parsing error codes. */
#define SKIP_PICTURE -10
#define SKIP_TO_START_CODE -1
#define PARSE_OK 1
/* Define BOOLEAN, TRUE, and FALSE. */
#define BOOLEAN int
#define TRUE 1
#define FALSE 0
/* Set ring buffer size. */
#define RING_BUF_SIZE 5
/* Macros for picture code type. */
#define I_TYPE 1
#define P_TYPE 2
#define B_TYPE 3
/* Start codes. */
#define SEQ_END_CODE 0x000001b7
#define SEQ_START_CODE 0x000001b3
#define GOP_START_CODE 0x000001b8
#define PICTURE_START_CODE 0x00000100
#define SLICE_MIN_START_CODE 0x00000101
#define SLICE_MAX_START_CODE 0x000001af
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
/* Number of macroblocks to process in one call to mpegVidRsrc. */
#define MB_QUANTUM 1000
/* Macros used with macroblock address decoding. */
#define MB_STUFFING 34
#define MB_ESCAPE 35
/* Lock flags for pict images. */
#define DISPLAY_LOCK 0x01
#define PAST_LOCK 0x02
#define FUTURE_LOCK 0x04
/* Temporary definition of time stamp structure. */
typedef int TimeStamp;
/* Structure with reconstructed pixel values. */
typedef struct pict_image {
unsigned char *luminance; /* Luminance plane. */
unsigned char *Cr; /* Cr plane. */
unsigned char *Cb; /* Cb plane. */
unsigned char *display; /* Display plane. */
int locked; /* Lock flag. */
TimeStamp show_time; /* Presentation time. */
} PictImage;
/* Group of pictures structure. */
typedef struct GoP {
BOOLEAN drop_flag; /* Flag indicating dropped frame. */
unsigned int tc_hours; /* Hour component of time code. */
unsigned int tc_minutes; /* Minute component of time code. */
unsigned int tc_seconds; /* Second component of time code. */
unsigned int tc_pictures; /* Picture counter of time code. */
BOOLEAN closed_gop; /* Indicates no pred. vectors to
previous group of pictures. */
BOOLEAN broken_link; /* B frame unable to be decoded. */
char *ext_data; /* Extension data. */
char *user_data; /* User data. */
} GoP;
/* Picture structure. */
typedef struct pict {
unsigned int temp_ref; /* Temporal reference. */
unsigned int code_type; /* Frame type: P, B, I */
unsigned int vbv_delay; /* Buffer delay. */
BOOLEAN full_pel_forw_vector; /* Forw. vectors specified in full
pixel values flag. */
unsigned int forw_r_size; /* Used for vector decoding. */
unsigned int forw_f; /* Used for vector decoding. */
BOOLEAN full_pel_back_vector; /* Back vectors specified in full
pixel values flag. */
unsigned int back_r_size; /* Used in decoding. */
unsigned int back_f; /* Used in decoding. */
char *extra_info; /* Extra bit picture info. */
char *ext_data; /* Extension data. */
char *user_data; /* User data. */
} Pict;
/* Slice structure. */
typedef struct slice {
unsigned int vert_pos; /* Vertical position of slice. */
unsigned int quant_scale; /* Quantization scale. */
char *extra_info; /* Extra bit slice info. */
} Slice;
/* Macroblock structure. */
typedef struct macroblock {
int mb_address; /* Macroblock address. */
int past_mb_addr; /* Previous mblock address. */
int motion_h_forw_code; /* Forw. horiz. motion vector code. */
unsigned int motion_h_forw_r; /* Used in decoding vectors. */
int motion_v_forw_code; /* Forw. vert. motion vector code. */
unsigned int motion_v_forw_r; /* Used in decdoinge vectors. */
int motion_h_back_code; /* Back horiz. motion vector code. */
unsigned int motion_h_back_r; /* Used in decoding vectors. */
int motion_v_back_code; /* Back vert. motion vector code. */
unsigned int motion_v_back_r; /* Used in decoding vectors. */
unsigned int cbp; /* Coded block pattern. */
BOOLEAN mb_intra; /* Intracoded mblock flag. */
BOOLEAN bpict_past_forw; /* Past B frame forw. vector flag. */
BOOLEAN bpict_past_back; /* Past B frame back vector flag. */
int past_intra_addr; /* Addr of last intracoded mblock. */
int recon_right_for_prev; /* Past right forw. vector. */
int recon_down_for_prev; /* Past down forw. vector. */
int recon_right_back_prev; /* Past right back vector. */
int recon_down_back_prev; /* Past down back vector. */
} Macroblock;
/* Block structure. */
typedef struct block {
short int dct_recon[8][8]; /* Reconstructed dct coeff matrix. */
short int dct_dc_y_past; /* Past lum. dc dct coefficient. */
short int dct_dc_cr_past; /* Past cr dc dct coefficient. */
short int dct_dc_cb_past; /* Past cb dc dct coefficient. */
} Block;
/* Video stream structure. */
typedef struct vid_stream {
unsigned int h_size; /* Horiz. size in pixels. */
unsigned int v_size; /* Vert. size in pixels. */
unsigned int mb_height; /* Vert. size in mblocks. */
unsigned int mb_width; /* Horiz. size in mblocks. */
unsigned char aspect_ratio; /* Code for aspect ratio. */
unsigned char picture_rate; /* Code for picture rate. */
unsigned int bit_rate; /* Bit rate. */
unsigned int vbv_buffer_size; /* Minimum buffer size. */
BOOLEAN const_param_flag; /* Contrained parameter flag. */
unsigned char intra_quant_matrix[8][8]; /* Quantization matrix for
intracoded frames. */
unsigned char non_intra_quant_matrix[8][8]; /* Quanitization matrix for
non intracoded frames. */
char *ext_data; /* Extension data. */
char *user_data; /* User data. */
GoP group; /* Current group of pict. */
Pict picture; /* Current picture. */
Slice slice; /* Current slice. */
Macroblock mblock; /* Current macroblock. */
Block block; /* Current block. */
int state; /* State of decoding. */
int bit_offset; /* Bit offset in stream. */
unsigned int *buffer; /* Pointer to next byte in
buffer. */
int buf_length; /* Length of remaining buffer.*/
unsigned int *buf_start; /* Pointer to buffer start. */
int max_buf_length; /* Max lenght of buffer. */
PictImage *past; /* Past predictive frame. */
PictImage *future; /* Future predictive frame. */
PictImage *current; /* Current frame. */
PictImage *ring[RING_BUF_SIZE]; /* Ring buffer of frames. */
} VidStream;
/* Definition of Contant integer scale factor. */
#define CONST_BITS 13
/* Misc DCT definitions */
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
#define GLOBAL /* a function referenced thru EXTERNs */
typedef short DCTELEM;
typedef DCTELEM DCTBLOCK[DCTSIZE2];
/* PVG: return values of mpegVidRsrc: */
/* (1) When mpegVidRsrc is called the FIRST time: */
/* mpeg stream was valid + info about mpeg-video available */
#define MPEG_INFO 0
/* mpeg stream was not valid */
#define MPEG_INVALID 1
/* NewVidStream was NOT called before */
#define MPEG_NULL 2
/* (2) When mpegVidRsrc is called afterwards: */
/* MB_QUANTUM of macroblocks decoded */
#define MPEG_MB_QUANTUM 3
/* a slice decoded */
#define MPEG_SLICE 4
/* a frame encountered that was labeled as to be skipped */
#define MPEG_FRAME_SKIP 5
/* a frame decoded that must not be displayed yet */
#define MPEG_FRAME_NODISP 6
/* a frame decoded that must be displayed */
#define MPEG_FRAME_DISP 7
/* an error was encountered, but processing can continue */
#define MPEG_ERROR 8
/* end of mpeg-video encountered, display last frame */
#define MPEG_DONE_DISP 9
/* end of mpeg-video encountered, no frame left to display */
#define MPEG_DONE_NODISP 10
/* PVG: Function Prototypes */
VOID EXPENTRY ResetVidStream(VOID);
VidStream * EXPENTRY NewVidStream (char * fname, int bufLength, int loop, int quiet,
int noDisplay, int ditherType);
VOID EXPENTRY DestroyVidStream (VidStream *astream );
int EXPENTRY mpegVidRsrc (TimeStamp time_stamp , VidStream *vid_stream, char **
pditherFlags);
VOID EXPENTRY VidStreamFlags(int type, int loop, int noDisplay);
VOID EXPENTRY TogglePFlag(VOID);
VOID EXPENTRY ToggleBFlag(VOID);
VOID EXPENTRY init_tables(VOID);
#ifdef ANALYSIS
typedef struct {
int frametype;
unsigned int totsize;
unsigned int number;
unsigned int i_mbsize;
unsigned int p_mbsize;
unsigned int b_mbsize;
unsigned int bi_mbsize;
unsigned int i_mbnum;
unsigned int p_mbnum;
unsigned int b_mbnum;
unsigned int bi_mbnum;
unsigned int i_mbcbp[64];
unsigned int p_mbcbp[64];
unsigned int b_mbcbp[64];
unsigned int bi_mbcbp[64];
unsigned int i_mbcoeff[64];
unsigned int p_mbcoeff[64];
unsigned int b_mbcoeff[64];
unsigned int bi_mbcoeff[64];
double tottime;
} Statval;
typedef void FNSTAT ();
typedef FNSTAT * PFNSTAT;
VOID EXPENTRY PassStats(int showEachFlg, PFNSTAT ShowOneStat, PFNSTAT ShowAllStats);
VOID EXPENTRY GetStats(Statval ** stat);
/* ifdef ANALYSIS */
#endif
#endif