home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / misc / vfwdk / samples / bravado / ct.h < prev    next >
C/C++ Source or Header  |  1993-01-31  |  15KB  |  362 lines

  1. /****************************************************************************
  2.  *
  3.  *   ct.h
  4.  * 
  5.  *   Main include file.  No device specific parameters should appear here.
  6.  *
  7.  *   Microsoft Video for Windows Sample Capture Driver
  8.  *   Chips & Technologies 9001 based frame grabbers.
  9.  *
  10.  *   Copyright (c) 1992-1993 Microsoft Corporation.  All Rights Reserved.
  11.  *
  12.  *    You have a royalty-free right to use, modify, reproduce and 
  13.  *    distribute the Sample Files (and/or any modified version) in 
  14.  *    any way you find useful, provided that you agree that 
  15.  *    Microsoft has no warranty obligations or liability for any 
  16.  *    Sample Application Files which are modified. 
  17.  *
  18.  ***************************************************************************/
  19.  
  20.  // want lots of symbols in DEBUG .sym file..
  21. #ifdef DEBUG
  22.     #define static
  23. #endif
  24.  
  25. #ifdef VCAP_MAIN
  26. #define EXTERNAL
  27. #else
  28. #define EXTERNAL extern
  29. #endif
  30.  
  31. #define DRIVER_VERSION          0x0101
  32.  
  33. #define FRAME_INTERRUPT            1 // 0 = Field interrupts, 1 = Frame 
  34.  
  35. #define MAX_CAPTURE_CHANNELS       1
  36. #define MAX_IN_CHANNELS            1
  37. #define MAX_OUT_CHANNELS           0
  38. #define MAX_DISPLAY_CHANNELS       1
  39.  
  40. #define MAX_ERR_STRING          250     // max length of string table errors
  41.  
  42. #define LimitRange(Val,Low,Hi) (max(Low,(min(Val,Hi))))
  43. #define WidthRect(rect) (rect.right - rect.left + 1)
  44. #define HeightRect(rect) (rect.bottom - rect.top + 1)
  45.  
  46. enum { 
  47.     IMAGE_FORMAT_PAL8,           // Supported data formats
  48.     IMAGE_FORMAT_RGB16,
  49.     IMAGE_FORMAT_RGB24,
  50.     IMAGE_FORMAT_YUV411PACKED,
  51.     IMAGE_FORMAT_YUV411UNPACKED
  52. };
  53.  
  54. #define ckidYUV411Packed         mmioFOURCC('y','u','v','p')
  55. #define ckidYUV411Unpacked       mmioFOURCC('y','u','v','u')
  56.  
  57. /***************************************************************************
  58.  
  59.     typedefs
  60.  
  61.  **************************************************************************/
  62. typedef struct tag_device_init {
  63.    WORD wIOBase;        // I/O Base Address
  64.    BYTE bInterrupt;     // Interrupt in use
  65.    WORD wSegment;       // Memory base segment
  66. } DEVICE_INIT, NEAR *PDEVICE_INIT, FAR *LPDEVICE_INIT;
  67.  
  68. typedef struct tag_combobox_entry {
  69.    WORD wValue;
  70.    char *szText;
  71. } COMBOBOX_ENTRY;
  72.  
  73. typedef struct {
  74.    DWORD      fccType;              // Capture 'vcap' or codec 'vidc'
  75.    DWORD      dwOpenType;           // Channel type IN, OUT, EXTERNAL_IN...
  76.    DWORD      dwOpenFlags;          // Flags passed during channel open
  77.    LPVIDEOHDR lpVHdr;               // Pointer to first buffer header
  78.    DWORD      dwError;              // Last error for this stream
  79. } CHANNEL, *PCHANNEL;
  80.  
  81.  
  82. /***************************************************************************
  83.     globals
  84. ***************************************************************************/
  85. EXTERNAL HANDLE   ghModule;                 // our module handle
  86. EXTERNAL WORD      gwDriverUsage;            // Usage count
  87. EXTERNAL WORD      gwCaptureUsage;           // Usage count
  88. EXTERNAL WORD      gwDisplayUsage;           // Usage count
  89. EXTERNAL WORD      gwVideoInUsage;           // Usage count
  90. EXTERNAL WORD      gwVideoOutUsage;          // Usage count
  91.  
  92. /* globals set by the Configuration dialog */
  93. EXTERNAL WORD   wPCVideoAddress;     // Address of PCVIDEO chip
  94. EXTERNAL WORD PASCAL  gwBaseReg;     // inita.asm
  95. EXTERNAL BYTE PASCAL  gbInt;         // inita.asm
  96. EXTERNAL WORD   gwWaitState;         // both I/O, memory access
  97. EXTERNAL BOOL   gfEurope;            // TRUE if PAL, European standard
  98.  
  99. // The following are controlled by the Video Source dialog
  100. EXTERNAL WORD     gwSourceConnector; // 0 to nConnectors
  101. EXTERNAL WORD     gwVideoCableFormat; // 0=Composite, 1=SVideo, 2=RGB
  102.  
  103. // The following are controlled by the Video Format dialog
  104. EXTERNAL WORD     gwDestFormat;      // one of IMAGE_FORMAT enums
  105. EXTERNAL WORD     gwWidthBytes;      // width of a scan in bytes
  106. EXTERNAL WORD     gwWidth;           // Dimensions of the image
  107. EXTERNAL WORD     gwHeight;          //   we are currently using
  108. EXTERNAL WORD     gwSize40;          // Value * 40 gives capture width
  109. EXTERNAL DWORD    dwVideoClock;      // Video frame counter
  110.  
  111. struct {                             // current palette colors.
  112.     WORD         palVersion;
  113.     WORD         palNumEntries;
  114.     PALETTEENTRY palPalEntry[256];
  115. }   palCurrent;
  116.  
  117. EXTERNAL BOOL           gfEnabled;         // has the card been enabled?
  118. EXTERNAL BOOL           gfVideoInStarted;  // Is the InStream running?
  119. extern   LPVOID PASCAL  glpFrameBuffer;    // Linear memory pointer
  120. EXTERNAL LPBYTE         fpTrans16to8;      // mapc.c
  121. EXTERNAL LPBYTE         fpCopyBuffer;      // When streaming, copy image here
  122. EXTERNAL LPWORD         fpYUVtoRGB16;      // LUT for converting to RGB16
  123.  
  124. EXTERNAL BITMAPINFOHEADER    biSource;     // current source format.
  125. EXTERNAL BITMAPINFOHEADER    biDest;       // current dest format.
  126. EXTERNAL WORD           gwWidthBytesSource; // width of scan in bytes
  127. EXTERNAL WORD           gwWidthBytesDest;   // width of scan in bytes
  128. EXTERNAL RECT           grcDestExtIn;       // Where to digitize incoming video
  129. EXTERNAL RECT           grcSourceIn;        // Source Rect for VideoIn
  130. EXTERNAL RECT           grcDestIn;          // Dest   Rect for VideoIn
  131. EXTERNAL RECT           grcSourceExtOut;    // Source Rect for ExternalOut
  132. EXTERNAL RECT           grcDestExtOut;      // Dest   Rect for ExternalOut
  133.  
  134. #ifdef DEBUG
  135. EXTERNAL WORD     wDebugLevel;              // debug level
  136. #endif
  137.  
  138. /****************************************************************************
  139.  
  140.        strings
  141.  
  142.  ***************************************************************************/
  143. #define BCODE
  144.  
  145. #ifdef VCAP_MAIN
  146.        char BCODE gszIniFile[]                 = "system.ini";
  147.  
  148.        char BCODE gszPortKey[]                 = "PortBase";
  149.        char BCODE gszIntKey[]                  = "Interrupt";
  150.        char BCODE gszMemoryKey[]               = "MemoryBase";
  151.        char BCODE gszWaitStateKey[]            = "WaitStates";
  152.        char BCODE gszBoardTypeKey[]            = "BoardType";
  153.  
  154.        char BCODE gszHueKey[]                  = "Hue";
  155.        char BCODE gszSatKey[]                  = "Saturation";
  156.        char BCODE gszContrastKey[]             = "Contrast";
  157.        char BCODE gszBrightnessKey[]           = "Brightness";
  158.        char BCODE gszRedKey[]                  = "Red";
  159.        char BCODE gszGreenKey[]                = "Green";
  160.        char BCODE gszBlueKey[]                 = "Blue";
  161.        char BCODE gszInputChannelKey[]         = "InputChannel";
  162.        char BCODE gszVideoStandardKey[]        = "VideoStandard";
  163.        char BCODE gszSize40Key[]               = "Size40";
  164.        char BCODE gszVideoFormatKey[]          = "VideoFormat";
  165.        char BCODE gszVideoCableKey[]           = "VideoCable";
  166.  
  167.        char BCODE gszHexFormat[]               = "%X";
  168.        char BCODE gszIntFormat[]               = "%d";
  169.        char BCODE gszNULL[]                    = "";
  170. #else
  171.        extern char BCODE gszDriverName[];
  172.        extern char BCODE gszIniFile[];
  173.  
  174.        extern char BCODE gszPortKey[];
  175.        extern char BCODE gszIntKey[];
  176.        extern char BCODE gszMemoryKey[];
  177.        extern char BCODE gszWaitStateKey[];
  178.        extern char BCODE gszBoardTypeKey[];
  179.  
  180.        extern char BCODE gszHueKey[];
  181.        extern char BCODE gszSatKey[];
  182.        extern char BCODE gszContrastKey[];
  183.        extern char BCODE gszBrightnessKey[];
  184.        extern char BCODE gszRedKey[];
  185.        extern char BCODE gszGreenKey[];
  186.        extern char BCODE gszBlueKey[];
  187.        extern char BCODE gszInputChannelKey[];  
  188.        extern char BCODE gszVideoStandardKey[];      
  189.        extern char BCODE gszSize40Key[];
  190.        extern char BCODE gszVideoFormatKey[];
  191.        extern char BCODE gszVideoCableKey[];
  192.  
  193.        extern char BCODE gszHexFormat[];
  194.        extern char BCODE gszIntFormat[];
  195.        extern char BCODE gszNULL[];
  196. #endif 
  197.  
  198.  
  199. #define IDS_ERRBADPORT      1           // boot time error message
  200. #define IDS_ERRBADCONFIG    2           // config time error message
  201.  
  202. //
  203. //  Product Description strings.  For this driver, all descriptions are
  204. //  the same..
  205. //
  206. #define IDS_VCAPPRODUCT   16
  207. #define IDS_VCAPIN    IDS_VCAPPRODUCT
  208. #define IDS_VCAPOUT   IDS_VCAPPRODUCT
  209.  
  210. /***************************************************************************
  211.     CT_ definitions
  212. ***************************************************************************/
  213. // These follow the Bravado definitions, others may vary
  214. #define CT_COLOR_HUE            0
  215. #define CT_COLOR_BRIGHTNESS     1
  216. #define CT_COLOR_SAT            2
  217. #define CT_COLOR_CONTRAST       3
  218. #define CT_COLOR_RED            4
  219. #define CT_COLOR_GREEN          5
  220. #define CT_COLOR_BLUE           6
  221.  
  222. /***************************************************************************
  223.  
  224.     prototypes
  225.  
  226. ***************************************************************************/
  227.  
  228. //cap.c
  229. DWORD FAR PASCAL InStreamError(LPDWORD lpdwErrorType, LPDWORD lpdwFramesSkipped);
  230. DWORD FAR PASCAL InStreamGetPos( LPMMTIME lpMMTime, DWORD dwSize);
  231. WORD  FAR PASCAL InStreamOpen( LPVIDEO_STREAM_INIT_PARMS lpStreamInitParms );
  232. WORD  FAR PASCAL InStreamClose( void );
  233. WORD  FAR PASCAL InStreamPrepareBuffer( LPVIDEOHDR lpVHdr );
  234. WORD  FAR PASCAL InStreamUnprepareBuffer( LPVIDEOHDR lpVHdr );
  235. WORD  FAR PASCAL InStreamAddBuffer( LPVIDEOHDR lpVHdr );
  236. WORD  FAR PASCAL InStreamStart( void );
  237. WORD  FAR PASCAL InStreamStop( void );
  238. WORD  FAR PASCAL InStreamReset( void );
  239. void  NEAR PASCAL InStreamISR( void );
  240. WORD  FAR PASCAL CaptureFrame( LPVIDEOHDR lpHdr );
  241. void FAR PASCAL videoCallback(WORD msg, DWORD dw1);
  242.  
  243. // config.c
  244. int FAR PASCAL _loadds ConfigDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam);
  245. int FAR PASCAL _loadds VideoSourceDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam);
  246. int FAR PASCAL _loadds VideoFormatDlgProc(HWND hDlg, WORD msg,WORD wParam, LONG lParam);
  247. int FAR PASCAL _loadds VideoMonitorDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam);
  248.  
  249. int  FAR PASCAL Config(HWND hWnd, HANDLE hModule);
  250. void FAR PASCAL ConfigRemove(void);
  251. BOOL FAR PASCAL ConfigCheckAllDeviceInitParms (LPDEVICE_INIT lpDI);
  252. BOOL FAR PASCAL ConfigInit (LPDEVICE_INIT lpDI);
  253. BOOL FAR PASCAL SetFormatFromDIB (LPBITMAPINFOHEADER lpbi);
  254. BOOL FAR PASCAL SetFormat (WORD wBoardType, WORD wZoom, WORD wBitDepth, WORD wIndex);
  255.  
  256. // flat.asm
  257. int FAR PASCAL GetFrameBufferPointer (BYTE bSegment);
  258. int FAR PASCAL FreeFrameBufferSelector (void);
  259.  
  260. // ctdev.c
  261. void FAR PASCAL  CT_WritePCVideo(int nIndex, int nValue);
  262. int FAR PASCAL   CT_ReadPCVideo(int nIndex);
  263. int FAR PASCAL   CT_Init(void);
  264. void FAR PASCAL  CT_Fini(void);
  265. void FAR PASCAL  CT_SetPortAddress(int nPort);
  266. int FAR PASCAL   CT_GetPortAddress(void);
  267. int FAR PASCAL   CT_GetFrameAddress(void);
  268. int FAR PASCAL   CT_SetFrameAddress(int nVidAddr);
  269. int FAR PASCAL   CT_LoadConfiguration(LPSTR lpszFile);
  270. int FAR PASCAL   CT_SaveConfiguration(LPSTR lpszFile);
  271. void FAR PASCAL  CT_SetColor(int nColorReg, int nColorValue);
  272. HBRUSH FAR PASCAL  CT_SetKeyColor(void);
  273. void FAR PASCAL  CT_SetVideoSource(int nSource);
  274. int FAR PASCAL   CT_GetVideoChannelCount (void);
  275. void FAR PASCAL  CT_SetVideoStandard(int nStandard);
  276. BOOL FAR PASCAL  CT_HasSVideo(void);
  277. BOOL FAR PASCAL  CT_SetVideoCableFormat (int nInputMode);
  278. void FAR PASCAL  CT_Acquire(int fAcquire);
  279. void FAR PASCAL  CT_PrivateAcquire(int fAcquire);
  280. void FAR PASCAL  CT_GrabFrame(void);
  281. void FAR PASCAL  CT_OverlayEnable(BOOL fDisplay);
  282. int FAR PASCAL   CT_SetIRQUsed (int nIRQ);
  283. int FAR PASCAL   CT_GetIRQUsed(void);
  284. void FAR PASCAL  CT_IRQEnable(void);
  285. void FAR PASCAL  CT_IRQDisable(void);
  286. void FAR PASCAL  CT_IRQClear (void);
  287. void FAR PASCAL  CT_Update (HWND hWnd, HDC hDC);
  288. void FAR PASCAL  CT_SetDisplayRect (LPRECT lpRectangle);
  289. void FAR PASCAL  CT_SetPanAndScroll (LPRECT lpRectangle);
  290. void FAR PASCAL  CT_WaitVSync (int nSync);
  291.  
  292. // drvproc.c
  293. LRESULT FAR PASCAL _loadds DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2);
  294.  
  295. // flat.asm
  296. LPSTR FAR PASCAL CreatePhysicalSelector( DWORD dwBase, WORD wLimit );
  297.  
  298. // initc.c
  299. int NEAR PASCAL LibMain(HANDLE hModule, WORD wHeapSize, LPSTR lpCmdLine);
  300. int FAR PASCAL HardwareInit(LPDEVICE_INIT lpDI);
  301. void FAR PASCAL HardwareFini (void);
  302. WORD FAR PASCAL ConfigGetSettings(void);
  303. WORD FAR PASCAL ConfigPutSettings(void);
  304. void FAR PASCAL HardErrorMsgBox( WORD wStringId );
  305. int FAR PASCAL GetHardwareSettingsFromINI( LPDEVICE_INIT lpDI );
  306. int FAR PASCAL PutHardwareSettingsToINI( LPDEVICE_INIT lpDI );
  307. int FAR PASCAL InitVerifyConfiguration(LPDEVICE_INIT lpDI);
  308. DWORD FAR PASCAL InitCheckMem (void);
  309.  
  310. // inita.asm
  311. WORD FAR PASCAL IRQEnable(void);
  312. WORD FAR PASCAL IRQDisable(void);
  313.  
  314. // mapa.asm
  315. void NEAR PASCAL mapUnpackedYUVto8( LPSTR fpDst, LPSTR fpSrc, LPSTR fpTrans,
  316.         WORD wWidth, WORD wHeight, WORD dxSrc);
  317. void NEAR PASCAL mapUnpackedYUVtoRGB16( LPSTR fpDst, LPSTR fpSrc, LPWORD fpTrans,
  318.         WORD wWidth, WORD wHeight, WORD dxSrc);
  319. void NEAR PASCAL RectCopyBytes(LPVOID pDst, WORD wDstWidth, 
  320.                                LPVOID pSrc, WORD wSrcWidth,
  321.                                WORD xSrc, WORD ySrc, WORD dxSrc, WORD dySrc);
  322.  
  323. // mapc.c
  324. WORD FAR PASCAL TransInit( void );
  325. void FAR PASCAL TransFini( void );
  326. BOOL FAR PASCAL TransRecalcPal( HPALETTE hPal );
  327. BOOL FAR PASCAL TransSet( LPBYTE );
  328.  
  329. //muldiv.asm
  330. DWORD NEAR PASCAL muldiv32(DWORD,DWORD,DWORD);
  331.  
  332. //vcap.c
  333. DWORD FAR PASCAL GetInSourceRect(LPRECT lprc);
  334. DWORD FAR PASCAL SetInSourceRect(LPRECT lprc);
  335. DWORD FAR PASCAL GetInDestRect(LPRECT lprc);
  336. DWORD FAR PASCAL SetInDestRect(LPRECT lprc);
  337. DWORD FAR PASCAL GetSourceFormat(LPBITMAPINFOHEADER lpbi, WORD wSize);
  338. DWORD FAR PASCAL SetSourceFormat(LPBITMAPINFOHEADER lpbi, WORD wSize);
  339. DWORD FAR PASCAL GetDestFormat(LPBITMAPINFOHEADER lpbi, WORD wSize);
  340. DWORD FAR PASCAL SetDestFormat(LPBITMAPINFOHEADER lpbi, WORD wSize);
  341. DWORD FAR PASCAL GetDestPalette(LPLOGPALETTE lppal, WORD wSize);
  342. DWORD FAR PASCAL SetDestPalette(LPLOGPALETTE lppal, LPBYTE lpXlat);
  343. DWORD FAR PASCAL SetExtOutSourceRect(LPRECT lprc);
  344. DWORD FAR PASCAL SetExtOutDestRect(LPRECT lprc);
  345.  
  346. //vmsg.c
  347. PCHANNEL NEAR PASCAL VideoOpen(LPVIDEO_OPEN_PARMS lpOpenParms);
  348. DWORD NEAR PASCAL VideoClose(PCHANNEL pChannel);
  349. DWORD NEAR PASCAL VideoConfigureStorageMessage(PCHANNEL pChannel, UINT msg, LONG lParam1, LONG lParam2);
  350. DWORD NEAR PASCAL VideoConfigureMessage(PCHANNEL pChannel, UINT msg, LONG lParam1, LONG lParam2);
  351. DWORD NEAR PASCAL VideoStreamMessage(PCHANNEL pChannel, UINT msg, LONG lParam1, LONG lParam2);
  352. DWORD NEAR PASCAL VideoProcessMessage(PCHANNEL pChannel, UINT msg, LONG lParam1, LONG lParam2);
  353.  
  354. //yuv.c
  355. void FAR PASCAL CT_RGB2YUV(LPSTR lpRGBBuf, LPSTR lpYUVBuf, long nLineLen, int nBitsPerPix);
  356. void FAR PASCAL CT_YUV2RGB(LPSTR lpYUVBuf, LPSTR lpRGBBuf, int nLineLen, int nBitsPerPix);
  357. void FAR PASCAL CT_YUV2RGBNoInterp(BYTE huge *lpYUVBuf, BYTE huge *lpRGBBuf, 
  358.         int nLineLen, int nBitsPerPix);
  359. void FAR PASCAL CT_PackYUV(LPSTR lpUnpackedBuf, LPSTR lpPackedBuf, int nLineLen);
  360. void FAR PASCAL CT_UnpackYUV(LPSTR lpPackedBuf, LPSTR lpUnpackedBuf, int nLineLen);
  361.  
  362.