1
0

duck_dxl.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. #ifndef _duck_dxl_h
  2. #define _duck_dxl_h
  3. #include "duck_bmp.h"
  4. /******************************************************************************\
  5. <table BGCOLOR=#FFC0C0 border=1 WIDTH=100% ><tr><td><b>
  6. duck_dxl.h </b></td><td><b> TrueMotion include file for decompression libraries </b>
  7. </td></tr><tr><td>&nbsp</td><td> Version: 6.0.0
  8. </td></tr><tr><td>&nbsp</td><td> Updated: $Date: 2011/06/29 19:50:29 $
  9. </td></tr><tr><td>&nbsp</td><td> Copyright (c) 1994-98, The Duck Corp. All rights reserved.
  10. </td></tr><tr><td>Important Objects</td><td>The On2 Decompression services tries to abstract the various objects
  11. used to decompress and render both audio and video. This allows the overall API to flex and accomodate new
  12. decompression schemes and new destinations.
  13. </td></tr><tr><td>DXL_XIMAGE_HANDLE</td><td>Abstract container object used to organize and control compressed
  14. video.
  15. </td></tr><tr><td>DXL_VSCREEN_HANDLE</td><td>Abstract container object used to organize and control display of
  16. uncompressed video to a surface.
  17. </td></tr><tr><td>DXL_XAUDIOSRC_HANDLE</td><td>Abstract container object used to organize and control
  18. compressed audio.
  19. </td></tr><tr><td>DXL_AUDIODST_HANDLE</td><td>Abstract container object used to organize and control
  20. rendering / playing of uncompressed audio.
  21. </td></tr>
  22. </table>
  23. ******************************************************************************/
  24. #if defined(__cplusplus)
  25. extern "C" {
  26. #endif
  27. /* enumerated data types */
  28. typedef enum BLITQUALITY {
  29. DXBLIT_SAME = 0, /* Blit directly, w/o stretching */
  30. DXBLIT_R1,
  31. DXBLIT_R2,
  32. DXBLIT_STRETCH, /* double horizontally, skip lines vertically */
  33. DXBLIT_R3,
  34. DXBLIT_STRETCH_BRIGHT, /* double horizontally, interpolate vertically */
  35. DXBLIT_R4,
  36. DXBLIT_R5,
  37. DXBLIT_R6,
  38. DXBLIT_NONE,
  39. DXBLITMAX
  40. } dxvBlitQuality ;
  41. typedef enum BITDEPTH {
  42. DXRGBNULL = 0,
  43. DXRGB8 = 1,
  44. DXRGB16_555 = 2,
  45. DXRGB24 = 3,
  46. DXRGB_UNUSED = 4,
  47. DXRGB16VESA = 5,
  48. DXRGB8VESA = 6,
  49. DXRGB16_565 = 7,
  50. DXYUY2 = 8,
  51. DXYVU9 = 9,
  52. DXYV12 = 10,
  53. DXUYVY = 11,
  54. DXRGB32 = 12,
  55. DXRGB16VESA_565 = 13,
  56. DXHALFTONE8 =14,
  57. DXI420 = 15,
  58. DXYVYU = 16,
  59. DXMAX
  60. } dxvBitDepth ;
  61. #define DXRGB16 DXRGB16_555
  62. #define DXRGB24CHAR DXRGB24
  63. typedef enum OFFSETXY {
  64. DXL_ABSOLUTE = 0,
  65. DXL_RELATIVE
  66. } dxvOffsetMode;
  67. typedef enum IMAGETYPE {
  68. DXL_INTRAFRAME = 0,
  69. DXL_INTERFRAME,
  70. DXL_SPRITE
  71. } dxvImageType;
  72. typedef enum DXL_ERR{
  73. DXL_LOW_ERR = -32000,
  74. DXL_HARDWARE_ERROR = -16002,
  75. DXL_HARDWARE_NOT_INITED = -16001,
  76. DXL_HARDWARE_BUFFER_FULL = -16000,
  77. DXL_INVALID_REQUEST = -9,
  78. DXL_VERSION_CONFLICT = -8,
  79. DXL_INVALID_DATA = -7,
  80. DXL_INVALID_BLIT = -6,
  81. DXL_BAD_DATA = -5,
  82. DXL_ALLOC_FAILED = -4,
  83. DXL_NULL_FRAME = -3,
  84. DXL_NULLSOURCE = -2,
  85. DXL_NOTINUSE = -1,
  86. DXL_OK = 0,
  87. DXL_HOLD_FRAME = 1
  88. } dxvError ;
  89. typedef enum BGMODE /* sprite drawing modes
  90. v1.0.2 supports NORM & NO_BACKGROUND */{
  91. NORM = 0, /* normal sprite mode, blend edges w/background */
  92. NO_BACKGROUND = 1,/* transparant sprite mode 1,
  93. sets all background data transparant no blending */
  94. NORM_TRANS = 2, /* transparant sprite mode 2,
  95. blend edges (alphas) w/separate background buffer,
  96. set sprite background to trans */
  97. RGB_OPAQUE = 3, /* blend edges to sprColor, set background to sprColor*/
  98. RGB_TRANS = 4 /* blend edges w/sprColor, set background to trans */
  99. } dxvBackgroundMode ;
  100. /*********************************************************/
  101. /* definition of data handles */
  102. typedef struct vScreen *DXL_VSCREEN_HANDLE;
  103. typedef struct tXImage *DXL_XIMAGE_HANDLE;
  104. /* main video decompression init, exit and query */
  105. /*@
  106. @Name DXL_InitVideo
  107. @Description Initialize Video decompression services
  108. @Return value DXL_OK on success. -1 unable to initialize library, insufficient memory available.
  109. @*/
  110. int DXL_InitVideo(
  111. int maxScreens, /* max Number of VScreens to allow. Outdated. Please pass zero ! */
  112. int maxImages /* max Number of xImages to allow. Outdated. Please pass zero ! */
  113. );
  114. /*@
  115. @Name DXL_ExitVideo
  116. @Description Exit and de-initialize video decompression library. Release any allocated data structures.
  117. Always destroy xImages before calling this routine to avoid memory leaks.
  118. @Return value none
  119. @*/
  120. void DXL_ExitVideo(void);
  121. /*get pointer to NULL terminated
  122. array of supported fourCCs */
  123. unsigned long *DXL_GetFourCCList(void);
  124. /*@
  125. @Name DXL_CreateXImage
  126. @Description Create an xImage (decompressor) object, based on the compressed data provided.
  127. @Return value returns a DXL_XIMAGE_HANDLE object ... also known as an xImage, or compressed image
  128. @*/
  129. DXL_XIMAGE_HANDLE DXL_CreateXImage(
  130. unsigned char *data /* compressed data */
  131. );
  132. /*@
  133. @Name DXL_SetXImageCSize
  134. @Description Set the size of the current compressed frame
  135. @Return value echo back the compressed image size
  136. @*/
  137. int DXL_SetXImageCSize(
  138. DXL_XIMAGE_HANDLE xImage, /* compressed image handle */
  139. int compressedSize /* compressed image size */
  140. );
  141. /*@
  142. @Name DXL_CreateXImageOfType
  143. @Description Create an xImage (decompressor) object of a requested type based on a FOURCC.
  144. Allocates buffers and initializes structures needed to decompress a source-compressed xImage.
  145. @Return value Handle to xImage created by this call , null if cannot create.
  146. @*/
  147. DXL_XIMAGE_HANDLE DXL_CreateXImageOfType(
  148. unsigned char *data, /* pointer to compressed image data */
  149. unsigned long fccType /* FOURCC code indicating type of compressed image data */
  150. );
  151. /*@
  152. @Name DXL_CreateXImageFromBMI
  153. @Description Create an xImage (decompressor) object of a requested type based on a FOURCC.
  154. Allocates buffers and initializes structures needed to decompress a source-compressed xImage.
  155. @Return value Handle to xImage created by this call , null if cannot create.
  156. @*/
  157. DXL_XIMAGE_HANDLE DXL_CreateXImageFromBMI(
  158. unsigned char *data, /* pointer to compressed image data */
  159. unsigned long biCompression, /* biCompression from BMIH */
  160. DK_BITMAPINFOHEADER *srcAndDst /* BMI data from AVI file or elsewhere */
  161. );
  162. /*@
  163. @Name DXL_DestroyXImage
  164. @Description destroy the specified xImage
  165. @Return value void
  166. @*/
  167. void DXL_DestroyXImage(
  168. DXL_XIMAGE_HANDLE src /* handle to compressed image */
  169. );
  170. /*@
  171. @Name DXL_AlterXImageData
  172. @Description Provides a compressed source with new data to decompress. New xImage attributes can be
  173. queried any time after changing the address of the compressed data with this function.
  174. @Return value DXL_OK on success or negative error code. -3 indicates that the pointer was passed in as null.
  175. Some compression applications (such as Adobe Premiere) use this to indicate that the new frame is the same as
  176. the previous frame, and the previous frame is to be held.
  177. @*/
  178. int DXL_AlterXImageData(
  179. DXL_XIMAGE_HANDLE src, /* handle to compressed image source (xImage) */
  180. unsigned char *ptrData /* pointer to compressed video data to be associated with xImage */
  181. );
  182. /*@
  183. @Name DXL_AlterXImage
  184. @Description Explicitly alter attributes of an xImage. The use of this funtion
  185. may affect the state of the xImage's frame buffer. During interframe compression, this can result
  186. in corruption of the decompressed image. Make sure to use this function only prior to decompressing a keyframe.
  187. @Return value handle to compressed image, or null if error.
  188. @*/
  189. DXL_XIMAGE_HANDLE DXL_AlterXImage(
  190. DXL_XIMAGE_HANDLE xImage, /* handle to compressed image */
  191. unsigned char *ptrData, /* pointer to compressed video data. */
  192. int xImType, /* new xImage type (DXL_INTRAFRAME, DXL_INTERFRAME). */
  193. dxvBitDepth bitDepth , /* bitdepth of decompressed data */
  194. int maxWidth, /* width of decompressed image */
  195. int maxHeight /* height of decompressed image */
  196. );
  197. /*@
  198. @Name DXL_GetXImageCSize
  199. @Description Get xImage compressed size
  200. @Return value returns the compressed size
  201. @*/
  202. long DXL_GetXImageCSize(
  203. DXL_XIMAGE_HANDLE src /* handle to compressed image */
  204. );
  205. /*@
  206. @Name DXL_GetXImageXYWH
  207. @Description get application specified x,y offset, and overall decompressed width and height.
  208. x and y offsets are legacy fields, ignore.
  209. @Return value DXL_OK on success, or negative error code.
  210. @*/
  211. int DXL_GetXImageXYWH(
  212. DXL_XIMAGE_HANDLE src, /* the xImage Handle. */
  213. int *x,int *y,int *w, int *h /* x,y,w,h - addresses for offsets and dimensions. */
  214. );
  215. /*@
  216. @Name DXL_IsXImageKeyFrame
  217. @Description Check keyframe status of current image.
  218. Use DXL_AlterXImageData to set the current frame and the use this call to detect keyframe status.
  219. @Return value return 1 if this xImage is a keyFrame, 0 if not a keyframe.
  220. @*/
  221. int DXL_IsXImageKeyFrame(
  222. DXL_XIMAGE_HANDLE src /* handle to compressed image */
  223. );
  224. /*@
  225. @Name DXL_dxImageToVScreen
  226. @Description Decompress and blit as a single process, according to current source and destination attributes.
  227. Passing 0 can be used to skip a blit in order to reduce CPU load as needed (synchronization).
  228. @Return value DXL_OK on success. 1 means place-holder frame. Negative means error.
  229. @*/
  230. int DXL_dxImageToVScreen(
  231. DXL_XIMAGE_HANDLE xImage, /* Handle to compresse image source (xImage). */
  232. DXL_VSCREEN_HANDLE dst /* Handle to destination surface (vScreen). Null means decompress without blit. */
  233. );
  234. /* compatibility check prior between
  235. decompressor and destination */
  236. int DXL_CheckdxImageToVScreen(
  237. DXL_XIMAGE_HANDLE src,
  238. DXL_VSCREEN_HANDLE dst
  239. );
  240. /* blit from xImage internal "working area" to vScreen */
  241. int DXL_BlitXImageToVScreen(
  242. DXL_XIMAGE_HANDLE src,
  243. DXL_VSCREEN_HANDLE dst
  244. );
  245. /* vscreen management functions */
  246. /*@
  247. @Name DXL_CreateVScreen
  248. @Description Create a virtual screen for rendering, storing decompressed video.
  249. @Return value returns a DXL_VSCREEN_HANDLE, or null if none available.
  250. @*/
  251. DXL_VSCREEN_HANDLE DXL_CreateVScreen(
  252. unsigned char *addr, /* The address where pixel data should be written */
  253. dxvBitDepth colorMode, /* Determines the colorspace and color depth of VScreen */
  254. short bytePitch, /* Offset from one raster to the next measured in bytes. */
  255. short height /* Number of rasters in a VScreen */
  256. );
  257. /*@
  258. @Name DXL_AlterVScreen
  259. @Description Alter address and attributes associated with a vscreen.
  260. @Return value 0 for success or negatibe error code.
  261. @*/
  262. int DXL_AlterVScreen(
  263. DXL_VSCREEN_HANDLE dst, /* handle to a VScreen */
  264. unsigned char *addr, /* The address where pixel data should be written, or null for no change. */
  265. dxvBitDepth colorMode, /* Determines the colorspace and color depth of VScreen, or -1 for no change. */
  266. int bytePitch, /* offset from one raster to the next measured in bytes, or 0 for no change. */
  267. int height /* number of rasters in a VScreen, or 0 for no change. */
  268. );
  269. void DXL_VScreenSetInfoDotsFlag(DXL_VSCREEN_HANDLE vScreen, int showDots);
  270. /* alter clipping rectangle of vScreen */
  271. /* not supported by all decompressors */
  272. int DXL_AlterVScreenClip(
  273. DXL_VSCREEN_HANDLE dst,
  274. int x,int y,
  275. int w,int h
  276. );
  277. /* alter viewport rectangle of vScreen */
  278. /* width/height not supported by all decompressors */
  279. int DXL_AlterVScreenView(
  280. DXL_VSCREEN_HANDLE dst,
  281. int x,int y,
  282. int w,int h
  283. );
  284. /*@
  285. @Name DXL_DestroyVScreen
  286. @Description Destroy a vScreen object/struct.
  287. @Return value None
  288. @*/
  289. void DXL_DestroyVScreen(
  290. DXL_VSCREEN_HANDLE dst /* handle to virtual screen destination */
  291. );
  292. /*@
  293. @Name DXL_SetVScreenBlitQuality
  294. @Description set blit-quality of a vScreen same (normal), stretch (black lined)
  295. stretch bright (stretched w/interpolation)
  296. @Return value return prior blit-quality value.
  297. @*/
  298. int DXL_SetVScreenBlitQuality(
  299. DXL_VSCREEN_HANDLE dest, /* handle to vScreen */
  300. dxvBlitQuality bq /* new blit-quality value */
  301. );
  302. /*@
  303. @Name DXL_GetVScreenBlitQuality
  304. @Description Get vScreens current blit-quality. Blit-quality determines if and how stretching should occur during the blit.
  305. @Return value returns member of enum called dxvBlitQuality, blit-quality value.
  306. BLIT_SAME is direct transfer; BLIT_STRETCH does double wide pixels and raster skipping; BLIT_STRETCH_BRIGHT stretches in both horizontal and vertical directions.
  307. @*/
  308. dxvBlitQuality DXL_GetVScreenBlitQuality(
  309. DXL_VSCREEN_HANDLE /* handle to vScreen. */
  310. );
  311. /* alter spite background associated with a vscreen */
  312. /* used only by SegaSaturn for hardware sprite support */
  313. int DXL_AlterVScreenBackground(
  314. DXL_VSCREEN_HANDLE ,
  315. unsigned char *,
  316. dxvBitDepth bd ,int ,int ,int ,int
  317. );
  318. /* set DOS VESA mode for vScreen (DOS only) */
  319. int DXL_AlterVScreenVESAMode(
  320. DXL_VSCREEN_HANDLE ,
  321. int vesaMode
  322. );
  323. /* set physical screen to vScreen's vesa mode */
  324. int DXL_ActivateVScreenVESAMode(DXL_VSCREEN_HANDLE);
  325. /* get vScreen (generally physical) vesa mode */
  326. int DXL_GetVScreenVESAMode(DXL_VSCREEN_HANDLE );
  327. /* copy one vScreen to another */
  328. /* provides support for offscreen compositing,
  329. 16 bit and 8 bit modes only */
  330. int DXL_BlitVScreenToVScreen(
  331. DXL_VSCREEN_HANDLE fromVScreen,
  332. DXL_VSCREEN_HANDLE toVScreen
  333. );
  334. /* get attributes of the vScreen */
  335. int DXL_GetVScreenAttributes(
  336. DXL_VSCREEN_HANDLE vScreen,
  337. void **addr,
  338. dxvBlitQuality *bq,
  339. dxvBitDepth *bd,
  340. short *pitch,
  341. short *height
  342. );
  343. char *DXL_GetXImageStats(DXL_XIMAGE_HANDLE xImage,char *storage);
  344. /* get vScreen's current viewport rectangle
  345. a viewport represents an x,y, offset and
  346. a clipping width and height */
  347. int DXL_GetVScreenView(
  348. DXL_VSCREEN_HANDLE dst,
  349. int *x,int *y,int *w,int *h
  350. );
  351. /* get vScreen's current clipping rectangle */
  352. int DXL_GetVScreenClip(
  353. DXL_VSCREEN_HANDLE dst,
  354. int *x,int *y,int *w,int *h
  355. );
  356. /* provide Color lookup tables for 8 bit support */
  357. int DXL_SetVScreenCLUTs(
  358. DXL_VSCREEN_HANDLE vScr,
  359. unsigned char *clpt,
  360. unsigned char *clpt2,
  361. int exp
  362. );
  363. /* return the palette currently used */
  364. int DXL_GetBitDepthPalette(dxvBitDepth colorMode,
  365. unsigned char **pal);
  366. /* relinquish color lookup table structures */
  367. void DXL_ResetVScreenCLUTs(
  368. DXL_VSCREEN_HANDLE vScr
  369. );
  370. /* check to see if a blit mode is supported */
  371. int DXL_CheckVScreenBlit(DXL_VSCREEN_HANDLE dst,unsigned long fourcc);
  372. int DXL_CheckVScreenXImageBlit(DXL_VSCREEN_HANDLE dst,DXL_XIMAGE_HANDLE src);
  373. /* windows 95 dll system abstraction functions */
  374. /* set memory allocator function */
  375. void DXV_Setmalloc(
  376. void *(*mallocFuncPtr)(unsigned int size)
  377. );
  378. /* set cleared memory allocator function */
  379. void DXV_Setcalloc(
  380. void *(*callocFuncPtr)(unsigned int size, unsigned int number)
  381. );
  382. /*set memory free function */
  383. void DXV_Setfree(
  384. void (*freeFuncPtr)(void *)
  385. );
  386. /* pass a parameter to the decompressor */
  387. void DXL_SetParameter(
  388. DXL_XIMAGE_HANDLE src,
  389. int Command,
  390. unsigned long Parameter
  391. );
  392. /* can only have a max of 32 cpu specific features */
  393. typedef enum tCPU_FEATURES
  394. {
  395. NO_FEATURES = 0,
  396. MMX_SUPPORTED = 1
  397. } CPU_FEATURES;
  398. CPU_FEATURES DXL_GetCPUFeatures(void);
  399. unsigned long DXL_GetXImageFOURCC(DXL_XIMAGE_HANDLE src);
  400. /* pass a parameter to the decompressor */
  401. void DXL_SetParameter(
  402. DXL_XIMAGE_HANDLE src,
  403. int Command,
  404. unsigned long Parameter
  405. );
  406. /* Temporary hack to dxv to allow calls to get info (jbb) */
  407. typedef struct tFrameInfo
  408. {
  409. int KeyFrame;
  410. int Version;
  411. int Quality;
  412. int vp30Flag;
  413. } FrameInfo;
  414. /* define this in case we need to interogate before bailing out */
  415. typedef struct bmiChunk_t
  416. {
  417. unsigned long biCompression;
  418. unsigned char biBitCount;
  419. unsigned char biPlanes;
  420. dxvBitDepth bd;
  421. } BMIMapping;
  422. extern BMIMapping DXL_BMIMap[];
  423. #if !defined(DXL_MKFOURCC)
  424. #define DXL_MKFOURCC( ch0, ch1, ch2, ch3 ) \
  425. ( (unsigned long)(unsigned char)(ch0) | ( (unsigned long)(unsigned char)(ch1) << 8 ) | \
  426. ( (unsigned long)(unsigned char)(ch2) << 16 ) | ( (unsigned long)(unsigned char)(ch3) << 24 ) )
  427. #endif
  428. /* src xImage must actually be a DXL_CODEC_HANDLE */
  429. /* you will need a dxvvfw.lib in order to utilize this prototype for now */
  430. int DXL_ReportBestBMIMatch(DXL_XIMAGE_HANDLE src, BMIMapping** map, int *maxMaps, int doConsoleReport);
  431. /* have DXV print DXV/ICM mapping to HTML table */
  432. void DXL_ReportBMIMapping(char *filename);
  433. void vp31_GetInfo(unsigned char * source, FrameInfo * frameInfo);
  434. #if defined(__cplusplus)
  435. }
  436. #endif
  437. #endif /* include guards */