home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / amvideo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-16  |  15.5 KB  |  329 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11.  
  12. // Video related definitions and interfaces for ActiveMovie
  13.  
  14. #ifndef __AMVIDEO__
  15. #define __AMVIDEO__
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif // __cplusplus
  20.  
  21. #include <ddraw.h>
  22.  
  23.  
  24. // This is an interface on the video renderer that provides information about
  25. // DirectDraw with respect to its use by the renderer. For example it allows
  26. // an application to get details of the surface and any hardware capabilities
  27. // that are available. It also allows someone to adjust the surfaces that the
  28. // renderer should use and furthermore even set the DirectDraw instance. We
  29. // allow someone to set the DirectDraw instance because DirectDraw can only
  30. // be opened once per process so it helps resolve conflicts. There is some
  31. // duplication in this interface as the hardware/emulated/FOURCCs available
  32. // can all be found through the IDirectDraw interface, this interface allows
  33. // simple access to that information without calling the DirectDraw provider
  34. // itself. The AMDDS prefix is ActiveMovie DirectDraw Switches abbreviated.
  35.  
  36. #define AMDDS_NONE 0x00             // No use for DCI/DirectDraw
  37. #define AMDDS_DCIPS 0x01            // Use DCI primary surface
  38. #define AMDDS_PS 0x02               // Use DirectDraw primary
  39. #define AMDDS_RGBOVR 0x04           // RGB overlay surfaces
  40. #define AMDDS_YUVOVR 0x08           // YUV overlay surfaces
  41. #define AMDDS_RGBOFF 0x10           // RGB offscreen surfaces
  42. #define AMDDS_YUVOFF 0x20           // YUV offscreen surfaces
  43. #define AMDDS_RGBFLP 0x40           // RGB flipping surfaces
  44. #define AMDDS_YUVFLP 0x80           // YUV flipping surfaces
  45. #define AMDDS_ALL 0xFF              // ALL the previous flags
  46. #define AMDDS_DEFAULT AMDDS_ALL     // Use all available surfaces
  47.  
  48. #define AMDDS_YUV (AMDDS_YUVOFF | AMDDS_YUVOVR | AMDDS_YUVFLP)
  49. #define AMDDS_RGB (AMDDS_RGBOFF | AMDDS_RGBOVR | AMDDS_RGBFLP)
  50. #define AMDDS_PRIMARY (AMDDS_DCIPS | AMDDS_PS)
  51.  
  52. DECLARE_INTERFACE_(IDirectDrawVideo, IUnknown)
  53. {
  54.     // IUnknown methods
  55.  
  56.     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID *ppvObj) PURE;
  57.     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  58.     STDMETHOD_(ULONG,Release)(THIS) PURE;
  59.  
  60.     // IDirectDrawVideo methods
  61.  
  62.     STDMETHOD(GetSwitches)(THIS_ DWORD *pSwitches) PURE;
  63.     STDMETHOD(SetSwitches)(THIS_ DWORD Switches) PURE;
  64.     STDMETHOD(GetCaps)(THIS_ DDCAPS *pCaps) PURE;
  65.     STDMETHOD(GetEmulatedCaps)(THIS_ DDCAPS *pCaps) PURE;
  66.     STDMETHOD(GetSurfaceDesc)(THIS_ DDSURFACEDESC *pSurfaceDesc) PURE;
  67.     STDMETHOD(GetFourCCCodes)(THIS_ DWORD *pCount,DWORD *pCodes) PURE;
  68.     STDMETHOD(SetDirectDraw)(THIS_ LPDIRECTDRAW pDirectDraw) PURE;
  69.     STDMETHOD(GetDirectDraw)(THIS_ LPDIRECTDRAW *ppDirectDraw) PURE;
  70.     STDMETHOD(GetSurfaceType)(THIS_ DWORD *pSurfaceType) PURE;
  71.     STDMETHOD(SetDefault)(THIS) PURE;
  72.     STDMETHOD(UseScanLine)(THIS_ long UseScanLine) PURE;
  73.     STDMETHOD(CanUseScanLine)(THIS_ long *UseScanLine) PURE;
  74.     STDMETHOD(UseOverlayStretch)(THIS_ long UseOverlayStretch) PURE;
  75.     STDMETHOD(CanUseOverlayStretch)(THIS_ long *UseOverlayStretch) PURE;
  76.     STDMETHOD(UseWhenFullScreen)(THIS_ long UseWhenFullScreen) PURE;
  77.     STDMETHOD(WillUseFullScreen)(THIS_ long *UseWhenFullScreen) PURE;
  78. };
  79.  
  80.  
  81. DECLARE_INTERFACE_(IQualProp, IUnknown)
  82. {
  83.     // IUnknown methods
  84.  
  85.     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID *ppvObj) PURE;
  86.     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  87.     STDMETHOD_(ULONG,Release)(THIS) PURE;
  88.  
  89.     // Compare these with the functions in class CGargle in gargle.h
  90.  
  91.     STDMETHOD(get_FramesDroppedInRenderer)(THIS_ int *pcFrames) PURE;  // Out
  92.     STDMETHOD(get_FramesDrawn)(THIS_ int *pcFramesDrawn) PURE;         // Out
  93.     STDMETHOD(get_AvgFrameRate)(THIS_ int *piAvgFrameRate) PURE;       // Out
  94.     STDMETHOD(get_Jitter)(THIS_ int *iJitter) PURE;                    // Out
  95.     STDMETHOD(get_AvgSyncOffset)(THIS_ int *piAvg) PURE;               // Out
  96.     STDMETHOD(get_DevSyncOffset)(THIS_ int *piDev) PURE;               // Out
  97. };
  98.  
  99.  
  100. // This interface allows an application or plug in distributor to control a
  101. // full screen renderer. The Modex renderer supports this interface. When
  102. // connected a renderer should load the display modes it has available
  103. // The number of modes available can be obtained through CountModes. Then
  104. // information on each individual mode is available by calling GetModeInfo
  105. // and IsModeAvailable. An application may enable and disable any modes
  106. // by calling the SetEnabled flag with OATRUE or OAFALSE (not C/C++ TRUE
  107. // and FALSE values) - the current value may be queried by IsModeEnabled
  108.  
  109. // A more generic way of setting the modes enabled that is easier to use
  110. // when writing applications is the clip loss factor. This defines the
  111. // amount of video that can be lost when deciding which display mode to
  112. // use. Assuming the decoder cannot compress the video then playing an
  113. // MPEG file (say 352x288) into a 320x200 display will lose about 25% of
  114. // the image. The clip loss factor specifies the upper range permissible.
  115. // To allow typical MPEG video to be played in 320x200 it defaults to 25%
  116.  
  117. DECLARE_INTERFACE_(IFullScreenVideo, IUnknown)
  118. {
  119.     // IUnknown methods
  120.  
  121.     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID *ppvObj) PURE;
  122.     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  123.     STDMETHOD_(ULONG,Release)(THIS) PURE;
  124.  
  125.     // IFullScreenVideo methods
  126.  
  127.     STDMETHOD(CountModes)(THIS_ long *pModes) PURE;
  128.     STDMETHOD(GetModeInfo)(THIS_ long Mode,long *pWidth,long *pHeight,long *pDepth) PURE;
  129.     STDMETHOD(GetCurrentMode)(THIS_ long *pMode) PURE;
  130.     STDMETHOD(IsModeAvailable)(THIS_ long Mode) PURE;
  131.     STDMETHOD(IsModeEnabled)(THIS_ long Mode) PURE;
  132.     STDMETHOD(SetEnabled)(THIS_ long Mode,long bEnabled) PURE;
  133.     STDMETHOD(GetClipFactor)(THIS_ long *pClipFactor) PURE;
  134.     STDMETHOD(SetClipFactor)(THIS_ long ClipFactor) PURE;
  135.     STDMETHOD(SetMessageDrain)(THIS_ HWND hwnd) PURE;
  136.     STDMETHOD(GetMessageDrain)(THIS_ HWND *hwnd) PURE;
  137.     STDMETHOD(SetMonitor)(THIS_ long Monitor) PURE;
  138.     STDMETHOD(GetMonitor)(THIS_ long *Monitor) PURE;
  139.     STDMETHOD(HideOnDeactivate)(THIS_ long Hide) PURE;
  140.     STDMETHOD(IsHideOnDeactivate)(THIS) PURE;
  141.     STDMETHOD(SetCaption)(THIS_ BSTR strCaption) PURE;
  142.     STDMETHOD(GetCaption)(THIS_ BSTR *pstrCaption) PURE;
  143.     STDMETHOD(SetDefault)(THIS) PURE;
  144. };
  145.  
  146.  
  147. // The SDK base classes contain a base video mixer class. Video mixing in a
  148. // software environment is tricky because we typically have multiple streams
  149. // each sending data at unpredictable times. To work with this we defined a
  150. // pin that is the lead pin, when data arrives on this pin we do a mix. As
  151. // an alternative we may not want to have a lead pin but output samples at
  152. // predefined spaces, like one every 1/15 of a second, this interfaces also
  153. // supports that mode of operations (there is a working video mixer sample)
  154.  
  155. DECLARE_INTERFACE_(IBaseVideoMixer, IUnknown)
  156. {
  157.     STDMETHOD(SetLeadPin)(THIS_ int iPin) PURE;
  158.     STDMETHOD(GetLeadPin)(THIS_ int *piPin) PURE;
  159.     STDMETHOD(GetInputPinCount)(THIS_ int *piPinCount) PURE;
  160.     STDMETHOD(IsUsingClock)(THIS_ int *pbValue) PURE;
  161.     STDMETHOD(SetUsingClock)(THIS_ int bValue) PURE;
  162.     STDMETHOD(GetClockPeriod)(THIS_ int *pbValue) PURE;
  163.     STDMETHOD(SetClockPeriod)(THIS_ int bValue) PURE;
  164. };
  165.  
  166. #define iPALETTE_COLORS 256     // Maximum colours in palette
  167. #define iEGA_COLORS 16          // Number colours in EGA palette
  168. #define iMASK_COLORS 3          // Maximum three components
  169. #define iTRUECOLOR 16           // Minimum true colour device
  170. #define iRED 0                  // Index position for RED mask
  171. #define iGREEN 1                // Index position for GREEN mask
  172. #define iBLUE 2                 // Index position for BLUE mask
  173. #define iPALETTE 8              // Maximum colour depth using a palette
  174. #define iMAXBITS 8              // Maximum bits per colour component
  175.  
  176.  
  177. // Used for true colour images that also have a palette
  178.  
  179. typedef struct tag_TRUECOLORINFO {
  180.     DWORD   dwBitMasks[iMASK_COLORS];
  181.     RGBQUAD bmiColors[iPALETTE_COLORS];
  182. } TRUECOLORINFO;
  183.  
  184.  
  185. // The BITMAPINFOHEADER contains all the details about the video stream such
  186. // as the actual image dimensions and their pixel depth. A source filter may
  187. // also request that the sink take only a section of the video by providing a
  188. // clipping rectangle in rcSource. In the worst case where the sink filter
  189. // forgets to check this on connection it will simply render the whole thing
  190. // which isn't a disaster. Ideally a sink filter will check the rcSource and
  191. // if it doesn't support image extraction and the rectangle is not empty then
  192. // it will reject the connection. A filter should use SetRectEmpty to reset a
  193. // rectangle to all zeroes (and IsRectEmpty to later check the rectangle).
  194. // The rcTarget specifies the destination rectangle for the video, for most
  195. // source filters they will set this to all zeroes, a downstream filter may
  196. // request that the video be placed in a particular area of the buffers it
  197. // supplies in which case it will call QueryAccept with a non empty target
  198.  
  199. typedef struct tagVIDEOINFOHEADER {
  200.  
  201.     RECT            rcSource;          // The bit we really want to use
  202.     RECT            rcTarget;          // Where the video should go
  203.     DWORD           dwBitRate;         // Approximate bit data rate
  204.     DWORD           dwBitErrorRate;    // Bit error rate for this stream
  205.     REFERENCE_TIME  AvgTimePerFrame;   // Average time per frame (100ns units)
  206.  
  207.     BITMAPINFOHEADER bmiHeader;
  208.  
  209. } VIDEOINFOHEADER;
  210.  
  211. // All the image based filters use this to communicate their media types. It's
  212. // centred principally around the BITMAPINFO. This structure always contains a
  213. // BITMAPINFOHEADER followed by a number of other fields depending on what the
  214. // BITMAPINFOHEADER contains. If it contains details of a palettised format it
  215. // will be followed by one or more RGBQUADs defining the palette. If it holds
  216. // details of a true colour format then it may be followed by a set of three
  217. // DWORD bit masks that specify where the RGB data can be found in the image
  218. // (For more information regarding BITMAPINFOs see the Win32 documentation)
  219.  
  220. // The rcSource and rcTarget fields are not for use by filters supplying the
  221. // data. The destination (target) rectangle should be set to all zeroes. The
  222. // source may also be zero filled or set with the dimensions of the video. So
  223. // if the video is 352x288 pixels then set it to (0,0,352,288). These fields
  224. // are mainly used by downstream filters that want to ask the source filter
  225. // to place the image in a different position in an output buffer. So when
  226. // using for example the primary surface the video renderer may ask a filter
  227. // to place the video images in a destination position of (100,100,452,388)
  228. // on the display since that's where the window is positioned on the display
  229.  
  230. typedef struct tagVIDEOINFO {
  231.  
  232.     RECT            rcSource;          // The bit we really want to use
  233.     RECT            rcTarget;          // Where the video should go
  234.     DWORD           dwBitRate;         // Approximate bit data rate
  235.     DWORD           dwBitErrorRate;    // Bit error rate for this stream
  236.     REFERENCE_TIME  AvgTimePerFrame;   // Average time per frame (100ns units)
  237.  
  238.     BITMAPINFOHEADER bmiHeader;
  239.  
  240.     union {
  241.         RGBQUAD         bmiColors[iPALETTE_COLORS];     // Colour palette
  242.         DWORD           dwBitMasks[iMASK_COLORS];       // True colour masks
  243.         TRUECOLORINFO   TrueColorInfo;                  // Both of the above
  244.     };
  245.  
  246. } VIDEOINFO;
  247.  
  248. // These macros define some standard bitmap format sizes
  249.  
  250. #define SIZE_EGA_PALETTE (iEGA_COLORS * sizeof(RGBQUAD))
  251. #define SIZE_PALETTE (iPALETTE_COLORS * sizeof(RGBQUAD))
  252. #define SIZE_MASKS (iMASK_COLORS * sizeof(DWORD))
  253. #define SIZE_PREHEADER (FIELD_OFFSET(VIDEOINFO,bmiHeader))
  254. #define SIZE_VIDEOHEADER (sizeof(BITMAPINFOHEADER) + SIZE_PREHEADER)
  255.  
  256. // DIBSIZE calculates the number of bytes required by an image
  257.  
  258. #define WIDTHBYTES(bits) ((DWORD)(((bits)+31) & (~31)) / 8)
  259. #define DIBWIDTHBYTES(bi) (DWORD)WIDTHBYTES((DWORD)(bi).biWidth * (DWORD)(bi).biBitCount)
  260. #define _DIBSIZE(bi) (DIBWIDTHBYTES(bi) * (DWORD)(bi).biHeight)
  261. #define DIBSIZE(bi) ((bi).biHeight < 0 ? (-1)*(_DIBSIZE(bi)) : _DIBSIZE(bi))
  262.  
  263. // This compares the bit masks between two VIDEOINFOs
  264.  
  265. #define BIT_MASKS_MATCH(pbmi1,pbmi2)                                \
  266.     (((pbmi1)->dwBitMasks[iRED] == (pbmi2)->dwBitMasks[iRED]) &&        \
  267.      ((pbmi1)->dwBitMasks[iGREEN] == (pbmi2)->dwBitMasks[iGREEN]) &&    \
  268.      ((pbmi1)->dwBitMasks[iBLUE] == (pbmi2)->dwBitMasks[iBLUE]))
  269.  
  270. // These zero fill different parts of the VIDEOINFO structure
  271.  
  272. #define RESET_MASKS(pbmi) (ZeroMemory((PVOID)(pbmi)->dwBitFields,SIZE_MASKS))
  273. #define RESET_HEADER(pbmi) (ZeroMemory((PVOID)(pbmi),SIZE_VIDEOHEADER))
  274. #define RESET_PALETTE(pbmi) (ZeroMemory((PVOID)(pbmi)->bmiColors,SIZE_PALETTE));
  275.  
  276. // Other (hopefully) useful bits and bobs
  277.  
  278. #define PALETTISED(pbmi) ((pbmi)->bmiHeader.biBitCount <= iPALETTE)
  279. #define PALETTE_ENTRIES(pbmi) ((DWORD) 1 << (pbmi)->bmiHeader.biBitCount)
  280.  
  281. // Returns the address of the BITMAPINFOHEADER from the VIDEOINFO
  282. #define HEADER(pVideoInfo) (&(((VIDEOINFO *) (pVideoInfo))->bmiHeader))
  283.  
  284.  
  285. // MPEG variant - includes a DWORD length followed by the
  286. // video sequence header after the video header.
  287. //
  288. // The sequence header includes the sequence header start code and the
  289. // quantization matrices associated with the first sequence header in the
  290. // stream so is a maximum of 140 bytes long.
  291.  
  292. typedef struct tagMPEG1VIDEOINFO {
  293.  
  294.     VIDEOINFOHEADER hdr;                    // Compatible with VIDEOINFO
  295.     DWORD           dwStartTimeCode;        // 25-bit Group of pictures time code
  296.                                             // at start of data
  297.     DWORD           cbSequenceHeader;       // Length in bytes of bSequenceHeader
  298.     BYTE            bSequenceHeader[1];     // Sequence header including
  299.                                             // quantization matrices if any
  300. } MPEG1VIDEOINFO;
  301.  
  302. #define MAX_SIZE_MPEG1_SEQUENCE_INFO 140
  303. #define SIZE_MPEG1VIDEOINFO(pv) (FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]) + (pv)->cbSequenceHeader)
  304. #define MPEG1_SEQUENCE_INFO(pv) ((const BYTE *)(pv)->bSequenceHeader)
  305.  
  306.  
  307. // Analog video variant - Use this when the format is FORMAT_AnalogVideo
  308. //
  309. // rcSource defines the portion of the active video signal to use
  310. // rcTarget defines the destination rectangle
  311. //    both of the above are relative to the dwActiveWidth and dwActiveHeight fields
  312. // dwActiveWidth is currently set to 720 for all formats (but could change for HDTV)
  313. // dwActiveHeight is 483 for NTSC and 575 for PAL/SECAM  (but could change for HDTV)
  314.  
  315. typedef struct tagAnalogVideoInfo {
  316.     RECT            rcSource;           // Width max is 720, height varies w/ TransmissionStd
  317.     RECT            rcTarget;           // Where the video should go
  318.     DWORD           dwActiveWidth;      // Always 720 (CCIR-601 active samples per line)
  319.     DWORD           dwActiveHeight;     // 483 for NTSC, 575 for PAL/SECAM
  320.     REFERENCE_TIME  AvgTimePerFrame;    // Normal ActiveMovie units (100 nS)
  321. } ANALOGVIDEOINFO;
  322.  
  323.  
  324. #ifdef __cplusplus
  325. }
  326. #endif // __cplusplus
  327. #endif // __AMVIDEO__
  328.  
  329.