#ifndef _FLOW_H_
#define _FLOW_H_
/**
 * \file flow.h
 * \brief The header for flow.c
 *
 *
 *  \ingroup corefiles
 * \date May 13, 2009
 * \author: Alexander Pimenov
 */
#ifdef __cplusplus
	extern "C" {
#endif

#include "geometry.h"
#include "stdint.h"

#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif

/**
 * \brief This macro stores the value that denotes the unknown flow
 */
#define FLOW_UNKNOWN_X INT16_MAX
#define FLOW_UNKNOWN_Y INT16_MAX

/**
 * \brief This macro is used to access the element of the flow
 */
#define FELEM(flowBuf, X, Y)  (flowBuf)->data[(flowBuf)->w * (Y) + (X)]

/**
 * \brief A buffer that stores the optical flow
 * */

typedef struct FlowBuffer_TAG {
	int h;              /**< Height of the buffer */
	int w;              /**< Width of the buffer */
	vector2Ds16 *data;    /**< The data of the flow vectors. */
} FlowBuffer;

FlowBuffer *flowBufferCreate(int h, int w);
void flowBufferDelete(FlowBuffer *toDelete);

uint32_t flowCountDensity(FlowBuffer *flow);

#ifdef __cplusplus
	} // 	extern "C"
#endif
#endif
