/**************************************************************************
 * File: datafile.h           DATAFILE.h
 * Programmer: Justin Miller Cornell id# 356452
 * Project: Dissolve Detection
 *
 * Purpose: 
 * Limitations: 
 * This File: 
 *   -
 *   -
 * Last Sanity Check: never.
 *
 * ToDo: Make more stable.  Fix interface. 
 *
 * See Also: 
 *
 * Copyright (c) 1995 Cornell University.  All Rights Reserved.
 *************************************************************************/
#define NO_DIFFPGM
#define NO_TWOPASS
#define NO_RESOLVE_EDGES
#define NO_CENSUS



#ifndef DATAFILE_H
#define DATAFILE_H
/* TYPE DEFINITIONS*/
typedef struct {
#ifndef NO_FRAME_NUMS
  int frame_num;
#endif
  float frac;
  float forward;
  float reverse;
  float max_forward;
  float max_reverse;
  float percent;
  float threshold;
  float bestthresh;
  float x;
  float y;
  float histHorz;
  float histVert;
#ifndef NO_CENSUS
  float census_first;
  float census_fx;
  float census_fy;
  float census_second;
  float census_sx;
  float census_sy;
#endif
#ifndef NO_RESOLVE_EDGES
  float resolveFAvg;
  float resolveRAvg;
#endif
} comp;


typedef struct {
  int start;
  int middle;
  int end;
  int type;
  float strength;
  float neighbors;
  int corr;
  int corrtype;
} tranStruct;

#define TYPE_CLASSES 5
#define TYPE_NOMATCH -1
#define TYPE_SUPRESS 0     /* only used for input to thresher*/
#define TYPE_CUT     1
#define TYPE_DISS    2
#define TYPE_FADE    3
#define TYPE_WIPE    4
#define CORR_NONE    -1
#define CORR_MISSED  -255

typedef struct {
  int nstreams;
  int nframes;
  float noise;
  float diss;
  float tran;
  int supp;
  int regn;
  int diffused;
  int nbad;
  int inOccur[TYPE_CLASSES];     /* number of each type in input*/
  int outOccur[TYPE_CLASSES];    /* number of each type in output*/
  int matrix[TYPE_CLASSES][TYPE_CLASSES];
  int correct[TYPE_CLASSES];
  int fpositive[TYPE_CLASSES];
  int fnegative[TYPE_CLASSES];
} analysis;

typedef struct {
  int n;
  analysis *data;
} analysis_set;

/* MAGIC NUMBERS*/
#define DATA_SPAN  7
#define DATA_FRAC  0
#define DATA_TIE   1
#define DATA_X     2
#define DATA_Y     3
#define DATA_POUT  4
#define DATA_PON   5
#define DATA_BEST  6

/* PROCEDURES*/
void fprintArrEntry(FILE *file,comp *arr, int n);
void fprintArr(FILE *file, comp *arr, int nlines);
void scanArr(comp *arr, int n, FILE *file);
int initArr(comp **arr, FILE *file);
void loadArr(comp *arr, int nlines, FILE *file);
int threshArr(comp *arr, int N, int suppress, int region, 
	      float trans, float diss, tranStruct **transforms);
comp *catArr(comp **Arrays, int *lArrays, int nArrays, int *nArrs, 
	      int padding);
void fprintTrans(FILE *file, tranStruct *trans, int N);
void fprintTransN(FILE *file, tranStruct *trans, int N);
void scanTrans(tranStruct *trans, int N, FILE *file);
int initTrans(tranStruct **trans, FILE *file);
void loadTrans(tranStruct *trans, int nlines, FILE *file);
void divTrans(tranStruct *trans, int nlines, int stepsize);
tranStruct *catTrans(tranStruct **Arrays, int *lArrays, int *dArrays,
		     int nArrays, int *nTrans, int padding);
analysis new_analysis(void);
analysis compareTrans(tranStruct *reality, int nreality,
		      tranStruct *result, int nresult);
void print_analysis(analysis val, FILE *file);
int nbad_analysis(analysis *valp);
int skipComments(FILE *file, char delimiter);
void subdivide_dissolves(comp *arr,int arrsize, double noise,
			 tranStruct *results, int nresults);
void find_wipes(comp *arr, tranStruct *results, int nresults, 
		double wipeThresh);

#endif
