//------------------------------------------------------------------------------
//
/*
*
* File: APPS/CAMAPP/CCameraWindow.cpp
* Purpose: The implementation of the CCameraWindow class
* Notes:
*
*/
/*********************************************************************
INCLUDE FILES
*********************************************************************/
#include <windows.h>
#include <ddraw.h>
#include <Devload.h>
#include <tchar.h>
#define _COMCTL32_
#include <commctrl.h>
#undef _COMCTL32_
#include <commdlg.h>
#include "bsp.h"
#include "pwingdi.h"
#include "bspcsi.h"
#include "CameraWindow.h"
#include "vdi.h"
#if defined(CAMAPP_FOR_ELVIS) || defined(CAMAPP_FOR_RITA)
#include "ipu_common.h"
#else
#include "display_vf.h"
#endif
#pragma warning(disable: 4100 4189 4101 4505 4706)
/**************************************************************************
MACRO DEFINITIONS
***************************************************************************/
#define CAPTURE_FORMAT_UYVY 1
#define PREVIEW_FORMAT_RGB565 1
#define PREVIEW_ENABLE
#define CAMERA_INIT_POS_X 132
#define CAMERA_INIT_POS_Y 410
#define CAMERA_INIT_POS_WIDTH 459
#define CAMERA_INIT_POS_HEIGHT 275
#define size_2826_PAL sizeof(Tw2826InitData_PAL)/sizeof(BYTE)
#define size_2866_PAL sizeof(Tw2866InitData_PAL)/sizeof(BYTE)
PCS_MSGQUEUE_BUFFER pCsMsgQBuff = new CS_MSGQUEUE_BUFFER;
PCS_VIDEOINFOHEADER display_VideoInfo = new CS_VIDEOINFOHEADER;
//interval(ms) of change resolution
#define INTERVAL 1000
int num = 0;
UINT8 *pbySrcBuffer = NULL;
/**************************************************************************/
//tw2866 PAL configuration
BYTE Tw2866InitData_PAL[]={ 0x00,0x87,0x01,0xf4,0x02,0x64,0x03,0xb4,0x04,0x88
,0x05,0x88,0x06,0x00,0x07,0x22,0x08,0x12,0x09,0x40
,0x0a,0x0a,0x0b,0xd0,0x0c,0x50,0x0d,0x0 ,0x0e,0x07
,0x0f,0x7f,0x10,0x97,0x11,0xf4,0x12,0x64,0x13,0xb4
,0x14,0x88,0x15,0x88,0x16,0x0, 0x17,0x12,0x18,0x17
,0x19,0x20,0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0
,0xed,0x0
,0xee,0x11
,0xef,0x0
,0xf0,0x83
,0xf1,0xb5
,0xf2,0x9
,0xf3,0x0
,0xf4,0xa0
,0xf5,0x0
,0xf6,0x0
,0xf7,0x20
,0xf8,0xc4
,0xf9,0xd1
,0xfa,0x4a
,0xfb,0x23
,0xfc,0xf
,0xfd,0x0
,0xfe,0x0
,0xff,0xc8
,0x4B,0x00
,0x43,0x0a
};
//BYTE Tw2866InitData_PAL[]={ 0x00,0x87,0x01,0xf4,0x02,0x64,0x03,0xb4,0x04,0x88
//,0x05,0x88,0x06,0x00,0x07,0x12,0x08,0x17,0x09,0x20
//,0x0a,0x01,0x0b,0xd0,0x0c,0x50,0x0d,0x0 ,0x0e,0x07
//,0x0f,0x7f,0x10,0x97,0x11,0xf4,0x12,0x64,0x13,0xb4
//,0x14,0x88,0x15,0x88,0x16,0x0, 0x17,0x12,0x18,0x17
//,0x19,0x20,0x1a,0x1 ,0x1b,0xd0,0x1c,0x50,0x1d,0x80
//,0x1e,0x07,0x1f,0x7f,0x20,0x87,0x21,0xf4,0x22,0x64
//,0x23,0xb4,0x24,0x88,0x25,0x88,0x26,0x00,0x27,0x12
//,0x28,0x17,0x29,0x20,0x2a,0x02,0x2b,0xd0,0x2c,0x50
//,0x2d,0x0,0x2e,0x07 ,0x2f,0x7f,0x30,0x97,0x31,0xf4
//,0x32,0x64
//,0x33,0xb4
//,0x34,0x88
//,0x35,0x88
//,0x36,0x0
//,0x37,0x12
//,0x38,0x17
//,0x39,0x20
//,0x3a,0x1
//,0x3b,0xd0
//,0x3c,0x50
//,0x3d,0x0
//,0x3e,0x07
//,0x3f,0x7f
//,0x40,0x0
//,0x41,0xd4
//,0x42,0x80
//,0x43,0x8a
//,0x44,0x0
//,0x45,0x38
//,0x46,0x39
//,0x47,0x39
//,0x48,0x37
//,0x49,0x3b
//,0x4a,0xff
//,0x4b,0x4
//,0x4c,0x0
//,0x4d,0x0
//,0x4e,0x0
//,0x4f,0x0
//,0x50,0x0
//,0x51,0x0
//,0x52,0x0
//,0x53,0x0
//,0x54,0x7
//,0x55,0x0
//,0x56,0x0
//,0x57,0x0
//,0x58,0x0
//,0x59,0x0
//,0x5a,0x7
//,0x5b,0x1
//,0x5c,0x1
//,0x5d,0xe4
//,0x5e,0xe4
//,0x5f,0xe4
//,0x60,0x15
//,0x61,0x3
//,0x62,0x0
//,0x63,0x0
//,0x64,0x0
//,0x65,0x0
//,0x66,0x0
//,0x67,0x0
//,0x68,0x0
//,0x69,0x0
//,0x6a,0x0
//,0x6b,0x0
//,0x6c,0x0
//,0x6d,0x0
//,0x6e,0x21
//,0x6f,0x43
//,0x70,0x8
//,0x71,0x0
//,0x72,0x0
//,0x73,0x1
//,0x74,0x0
//,0x75,0x0
//,0x76,0x0
//,0x77,0x0
//,0x78,0x7
//,0x79,0x0
//,0x7a,0x7
//,0x7b,0x15
//,0x7c,0x15
//,0x7d,0xe4
//,0x7e,0xc0
//,0x7f,0x80
//,0x80,0x0
//,0x81,0x2
//,0x82,0x0
//,0x83,0xcc
//,0x84,0x0
//,0x85,0x80
//,0x86,0x44
//,0x87,0x50
//,0x88,0x22
//,0x89,0x5
//,0x8a,0xd8
//,0x8b,0xbc
//,0x8c,0xb8
//,0x8d,0x44
//,0x8e,0x38
//,0x8f,0x0
//,0x90,0x0
//,0x91,0x78
//,0x92,0x44
//,0x93,0x30
//,0x94,0x14
//,0x95,0xa5
//,0x96,0xe4
//,0x97,0x5
//,0x98,0x0
//,0x99,0x28
//,0x9a,0x44
//,0x9b,0x44
//,0x9c,0x20
//,0x9d,0x90
//,0x9e,0x52
//,0x9f,0xf0
//,0xa0,0x8
//,0xa1,0x8
//,0xa2,0x8
//,0xa3,0x8
//,0xa4,0x1a
//,0xa5,0x1a
//,0xa6,0x1a
//,0xa7,0x1a
//,0xa8,0xaa
//,0xa9,0xaa
//,0xaa,0x0
//,0xab,0xf0
//,0xac,0xf0
//,0xad,0xf0
//,0xae,0xf0
//,0xaf,0x22
//,0xb0,0x22
//,0xb1,0x4a
//,0xb2,0x0
//,0xb3,0x0
//,0xb4,0x0
//,0xb5,0x0
//,0xb6,0x0
//,0xb7,0x0
//,0xb8,0xc3
//,0xb9,0xe9
//,0xba,0x29
//,0xbb,0xa
//,0xbc,0xd2
//,0xbd,0xc3
//,0xbe,0xea
//,0xbf,0x29
//,0xc0,0xb
//,0xc1,0xd3
//,0xc2,0x0
//,0xc3,0x0
//,0xc4,0x0
//,0xc5,0x0
//,0xc6,0x0
//,0xc7,0x0
//,0xc8,0x88
//,0xc9,0x88
//,0xca,0xaa
//,0xcb,0x0
//,0xcc,0xd
//,0xcd,0x8
//,0xce,0x0
//,0xcf,0x80
//,0xd0,0x88
//,0xd1,0x88
//,0xd2,0x3
//,0xd3,0x10
//,0xd4,0x32
//,0xd5,0x54
//,0xd6,0x76
//,0xd7,0x98
//,0xd8,0xba
//,0xd9,0xdc
//,0xda,0xfe
//,0xdb,0xe1
//,0xdc,0x0
//,0xdd,0x0
//,0xde,0x0
//,0xdf,0x80
//,0xe0,0x10
//,0xe1,0xc0
//,0xe2,0xaa
//,0xe3,0xaa
//,0xe4,0x0
//,0xe5,0x11
//,0xe6,0x0
//,0xe7,0x0
//,0xe8,0x11
//,0xe9,0x0
//,0xea,0x0
//,0xeb,0x11
//,0xec,0x0
//,0xed,0x0
//,0xee,0x11
//,0xef,0x0
//,0xf0,0x83
//,0xf1,0xb5
//,0xf2,0x9
//,0xf3,0x0
//,0xf4,0xa0
//,0xf5,0x0
//,0xf6,0x0
//,0xf7,0x20
//,0xf8,0xc4
//,0xf9,0xd1