/*
 *******************************************************************************
 *  Copyright (c) 2010-2022 VATICS(KNERON) Inc. All rights reserved.
 *
 *  +-----------------------------------------------------------------+
 *  | THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED |
 *  | AND COPIED IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH  |
 *  | A LICENSE AND WITH THE INCLUSION OF THE THIS COPY RIGHT NOTICE. |
 *  | THIS SOFTWARE OR ANY OTHER COPIES OF THIS SOFTWARE MAY NOT BE   |
 *  | PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. THE   |
 *  | OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.        |
 *  |                                                                 |
 *  | THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT   |
 *  | ANY PRIOR NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY |
 *  | VATICS(KNERON) INC.                                             |
 *  +-----------------------------------------------------------------+
 *
 *******************************************************************************
 */
#ifndef VIDEO_MONO_MD_PROCESS_H
#define VIDEO_MONO_MD_PROCESS_H

#ifdef __cplusplus
extern "C" {
#endif




typedef struct VMF_MONO_MD_HANDLE_T VMF_MONO_MD_HANDLE_T;
#define VMF_MAX_MONO_MD_WINDOW_SIZE (32)


/**
 * A enumeration for mono motion detection type
 */
typedef enum
{	
	//! Motion detection type: window
	VMF_MONO_MD_CONFIG_WINDOW = 0,
	//! Reserved
	VMF_MONO_MD_RESERVED,
} VMF_MONO_MD_TYPE;

/**
 * A structure for mono motion detection window
 */
typedef struct
{
	//! Motion window enable flag, 0: diable, 1: enable
	unsigned int bEnable;   
	 //! Horizontal start position of window
	unsigned int dwStartX; 
	//! Vertical start position of window
	unsigned int dwStartY; 
	//! Window width 
	unsigned int dwWidth;
	//! Window height   
	unsigned int dwHeight;  
	//! Window Threshold: 0~100%
	unsigned int dwWindowThr; 
	//! Window Object size: 0~100%
	unsigned int dwObjectSize;
} VMF_MONO_MD_WINDOW_T;


/**
 * A structure for mono motion detection configuration
 */
typedef struct
{
	//! Motion detection type
	//VMF_MD_TYPE eMdType;
	//! Motion detection configuration data: window data
	void *pMdData;
	//! Motion detection data size 
	//! Window mode: support max 32 window
	unsigned int dwDataSize;
} VMF_MONO_MD_CONFIG_T;




/**
 * A structure for VMF mono motion detect initial config
 */
typedef struct
{
	VMF_MONO_MD_TYPE eMdType;	
	VMF_MONO_MD_CONFIG_T* ptMdconfig;
	
	//! input info
	unsigned int dwInputWidth;
	unsigned int dwInputHeight;
	const char* pszResourceDir;
} VMF_MONO_MD_INITOPT_T;


/**
 * A structure for mono motion detection In and Out information
 */
typedef struct
{
	//! Input
	unsigned char* pbyMonoBuffer;

	//! Output
	unsigned char abMotionTrigger[VMF_MAX_MONO_MD_WINDOW_SIZE]; 
} VMF_MONO_MD_STATES_T;


/**
 * @brief Function to initialize VMF_MONO_MD_HANDLE_T.
 *
 * @param[in] ptInitOpt A pointer to the VMF_MONO_MD_INITOPT_T structure.
 * @return The handle of VMF_MONO_MD_HANDLE_T.
 */
VMF_MONO_MD_HANDLE_T* VMF_Mono_MD_Init(const VMF_MONO_MD_INITOPT_T* ptInitOpt);

/**
 * @brief Function to process on md.
 *
 * @param[in] ptHandle The handle of VMF_MONO_MD_HANDLE_T.
 * @param[in] ptMdStates A pointer to VMF_MONO_MD_STATES_T structure 
 * @return Success: 0  Fail: negative integer.
 */
int VMF_Mono_MD_Process(VMF_MONO_MD_HANDLE_T* ptHandle, VMF_MONO_MD_STATES_T* ptMonoMdStates);

/**
 * @brief Function to release VMF MONO MD.
 *
 * @param[in] ptHandle The handle of VMF_MONO_MD_HANDLE_T.
 * @return Success: 0  Fail: negative integer.
 */
int VMF_Mono_MD_Release(VMF_MONO_MD_HANDLE_T* ptHandle);

/**
 * @brief Function to config md trigger information.
 *
 * @param[in] ptHandle The handle of VMF_MONO_MD_HANDLE_T.
 * @param[in] ptMdconfig The pointer of VMF_MONO_MD_CONFIG_T.
 * @return Success: 0  Fail: negative integer.
 */
int VMF_Mono_MD_Config_Windows(VMF_MONO_MD_HANDLE_T *ptHandle, VMF_MONO_MD_CONFIG_T* ptMonoMdconfig);


#ifdef __cplusplus
}
#endif


#endif



