
		/* function prototypes */
void		PaintImage();
void		UpdateDisplay();
int			OpenVideoFile(char *,int *, int *);
int			ReadVideoFrame(int,unsigned char *);
void		CloseVideoFile();
int			ReadFiles();
void		InitializeDataVariables();
LRESULT		CALLBACK RecordBiteInfo(HWND,UINT,WPARAM,LPARAM); /* record bite info dialogue */
LRESULT		CALLBACK ChangeFFSpeed(HWND,UINT,WPARAM,LPARAM); /* change FF speed */
void RegionGrow(double *,unsigned char *,int,int,int,int,int,int,int *,int *);
void SegmentRegions();

#define TIMER_SECOND		1								/* ID of timer used during playback */

		/* global variables */
HINSTANCE	  hInst;				/* pointer to program instance (need for dialog boxes) */
HWND		  MainWnd;				/* main window */
char		  MasterFilename[320];	/* file that contains:  [name of data file] [name of video file] [sync_offset] */
char		  DataFilename[320];	/* file that contains the grid scale data */
char		  VideoFilename[320];	/* file that contains the video */
char		  CurrentPath[320];		/* path where files were last read/saved */
int			  VideoLoaded;			/* 0=>no; 1=>yes (file exists and is opened in ffmpeg library) */
int			  VideoSyncOffset;		/* milliseconds between data[0] and first video frame */
unsigned char *disp_image;			/* image from video to display */
int			  DISPLAY_ROWS;			/* size of video image */
int			  DISPLAY_COLS;			/* size of video image */
char		  NameList[999][320];	/* master list of data filenames, lets user scroll through them */
int			  TotalFilenames;		/* 0=>no master list available; otherwise the total count */

int			  TimeIndex;			/* index of data currently being displayed (units are samples @ 10 Hz) */
int			  Playing;				/* 0=>no; 1=>yes (video is playing, using timer to repeatedly move TimeIndex) */
int			  PlayJump;				/* amount of samples to jump during each timer */
int			  FFspeed;				/* user-definable amount of frames to skip per iteration during fast forward */
int			  PlayDelay;			/* user-definable amount of ms to wait between frames during playing */

#define MAX_DATA	36000			/* one hour at 10 Hz */
#define	GRID_ROWS	7				/* #sensels in grid scale, height direction */
#define	GRID_COLS	11				/* #sensels in grid scale, width direction */
double		  *Data;				/* index order is r0c0t0 r0c1t0 r0c2t0 ... r1c0t0 r1c1t0 ... all of t=0 then start t=1 ... */
int			  TotalData;			/* total #time_samples in the data file */
int			  DataLoaded;			/* 0=>no; 1=>yes (file exists and has been read) */
double		  GridZero[GRID_ROWS*GRID_COLS];	/* A/D reading of zero weight, per cell.  Taken from median of first 3 seconds of data. */
double		  GridFactor[GRID_ROWS*GRID_COLS];	/* A/D reading factor to scale to grams.  Read from cells.txt calibration file. */
double		  *SmoothedData;		/* index order is r0c0t0 r0c1t0 r0c2t0 ... r1c0t0 r1c1t0 ... all of t=0 then start t=1 ... */
int			  ViewSmoothed;			/* 0=>no, 1=>smoothed */
int			  DataDisplayWidth;		/* #pixels horizontal for displaying data; used to control scroll bar */
#define	SENSEL_SIZE  100			/* #pixels per sensel in the grid display */

#define	MAX_REGIONS	(GRID_ROWS*GRID_COLS)
unsigned char Regions[MAX_REGIONS];	/* segmentation image (value is region label, 0 => background) */
int			  TotalRegions;			/* number of unique labels in segmentation image (excluding background) */
double		  RegionWeight[MAX_REGIONS];	/* total weight in each region */

int			  DisplayWeights;		/* 0=>no; 1=>yes */
int			  DisplayPlots;			/* 0=>no; 1=>yes */
int			  DisplayRegions;		/* 0=>no; 1=>yes */

