Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

500 lines
17 KiB

  1. /* *************************************************************************
  2. ** INTEL Corporation Proprietary Information
  3. **
  4. ** This listing is supplied under the terms of a license
  5. ** agreement with INTEL Corporation and may not be copied
  6. ** nor disclosed except in accordance with the terms of
  7. ** that agreement.
  8. **
  9. ** Copyright (c) 1995 Intel Corporation.
  10. ** Copyright (c) 1996 Intel Corporation.
  11. ** All Rights Reserved.
  12. **
  13. ** *************************************************************************
  14. */
  15. ;//
  16. ;// $Author: JMCVEIGH $
  17. ;// $Date: 05 Feb 1997 12:24:16 $
  18. ;// $Archive: S:\h26x\src\dec\d3dec.h_v $
  19. ;// $Header: S:\h26x\src\dec\d3dec.h_v 1.40 05 Feb 1997 12:24:16 JMCVEIGH $
  20. ;// $Log: S:\h26x\src\dec\d3dec.h_v $
  21. ;//
  22. ;// Rev 1.40 05 Feb 1997 12:24:16 JMCVEIGH
  23. ;// Support for latest H.263+ draft bitstream spec.
  24. ;//
  25. ;// Rev 1.39 16 Dec 1996 17:42:44 JMCVEIGH
  26. ;// Flag for improved PB-frame mode.
  27. ;//
  28. ;// Rev 1.38 09 Dec 1996 18:02:08 JMCVEIGH
  29. ;// Added support for arbitrary frame sizes.
  30. ;//
  31. ;// Rev 1.37 26 Sep 1996 09:40:54 BECHOLS
  32. ;// Added Snapshot fields to the Decoder Catalog, and Snapshot constants.
  33. ;//
  34. ;// Rev 1.36 10 Sep 1996 10:31:46 KLILLEVO
  35. ;// changed all GlobalAlloc/GlobalLock calls to HeapAlloc
  36. ;//
  37. ;// Rev 1.35 03 May 1996 13:08:06 CZHU
  38. ;//
  39. ;// Added fields in decoder catalog for RTP packet loss recovery
  40. ;//
  41. ;// Rev 1.34 22 Mar 1996 17:21:40 AGUPTA2
  42. ;// Added bMMXDecoder field in the decoder catalog.
  43. ;//
  44. ;// Rev 1.33 23 Feb 1996 09:46:28 KLILLEVO
  45. ;// fixed decoding of Unrestricted Motion Vector mode
  46. ;//
  47. ;// Rev 1.32 12 Jan 1996 15:00:14 TRGARDOS
  48. ;// Added aspect ration correction logic and code to force
  49. ;// aspect ration correction on based on INI file settings.
  50. ;//
  51. ;// Rev 1.31 11 Jan 1996 14:06:22 RMCKENZX
  52. ;// Added CCOffset320x240 member to the decoder catalog to support stills.
  53. ;//
  54. ;// Rev 1.30 06 Jan 1996 18:39:54 RMCKENZX
  55. ;// Updated copyright
  56. ;//
  57. ;// Rev 1.29 06 Jan 1996 18:35:08 RMCKENZX
  58. ;// Added uIs320x240 to Decoder Catalog to support still frames at
  59. ;// 320x240 resolution
  60. ;//
  61. ;// Rev 1.28 20 Dec 1995 15:59:14 RMCKENZX
  62. ;// Added prototype for FrameMirror to support mirror imaging
  63. ;//
  64. ;// Rev 1.27 18 Dec 1995 12:45:28 RMCKENZX
  65. ;// added copyright notice
  66. ;//
  67. ;// Rev 1.26 13 Dec 1995 11:00:46 RHAZRA
  68. ;// No change.
  69. ;//
  70. ;// Rev 1.25 11 Dec 1995 11:32:06 RHAZRA
  71. ;// 12-10-95 changes: added AP stuff
  72. ;//
  73. ;// Rev 1.24 09 Dec 1995 17:23:44 RMCKENZX
  74. ;// updated to support decoder re-architecture
  75. ;// added X32_uMBInfoStream to decoder catalog &
  76. ;// T_MBInfo structure for PB Frames.
  77. ;// added X32_pN & X32_InverseQuant to catalog for 2nd pass.
  78. ;//
  79. ;// Rev 1.22 26 Oct 1995 11:21:52 CZHU
  80. ;// Added uTempRefPrev to save TR for previous frame
  81. ;//
  82. ;// Rev 1.21 25 Oct 1995 18:09:34 BNICKERS
  83. ;//
  84. ;// Switch to YUV12 color convertors. Clean up archival stuff.
  85. ;//
  86. ;// Rev 1.20 13 Oct 1995 16:05:32 CZHU
  87. ;// First version that supports PB frames. Display B or P frames under
  88. ;// VfW for now.
  89. ;//
  90. ;// Rev 1.19 11 Oct 1995 13:25:50 CZHU
  91. ;// Added code to support PB frame
  92. ;//
  93. ;// Rev 1.18 26 Sep 1995 15:32:36 CZHU
  94. ;//
  95. ;// Adjust tempory buffers for motion compensation
  96. ;//
  97. ;// Rev 1.17 20 Sep 1995 14:47:42 CZHU
  98. ;// Added iNumberOfMBsPerGOB in decoder catalog
  99. ;//
  100. ;// Rev 1.16 11 Sep 1995 16:42:52 CZHU
  101. ;// Added uMBBuffer for storage used for motion compensation
  102. ;//
  103. ;// Rev 1.15 11 Sep 1995 14:31:12 CZHU
  104. ;// Name and type change for MV info
  105. ;//
  106. ;// Rev 1.14 08 Sep 1995 11:47:50 CZHU
  107. ;//
  108. ;// Added MV info, and changed the name for motion vectors
  109. ;//
  110. ;// Rev 1.13 01 Sep 1995 09:49:12 DBRUCKS
  111. ;// checkin partial ajdust pels changes
  112. ;//
  113. ;// Rev 1.12 29 Aug 1995 16:48:12 DBRUCKS
  114. ;// add YVU9_VPITCH
  115. ;//
  116. ;// Rev 1.11 28 Aug 1995 10:15:04 DBRUCKS
  117. ;// update to 5 July Spec and 8/25 Errata
  118. ;//
  119. ;// Rev 1.10 23 Aug 1995 12:25:10 DBRUCKS
  120. ;// Turn on the color converters
  121. ;//
  122. ;// Rev 1.9 14 Aug 1995 16:38:30 DBRUCKS
  123. ;// add hung type and clarify pCurBlock
  124. ;//
  125. ;// Rev 1.8 11 Aug 1995 17:30:00 DBRUCKS
  126. ;// copy source to bitstream
  127. ;//
  128. ;// Rev 1.7 11 Aug 1995 15:13:00 DBRUCKS
  129. ;// ready to integrate block level
  130. ;//
  131. ;// Rev 1.6 04 Aug 1995 15:56:32 TRGARDOS
  132. ;//
  133. ;// Put definition of PITCH into CDRVDEFS.H so that encoder
  134. ;// doesn't get a redefinition of MACRO warning.
  135. ;//
  136. ;// Rev 1.5 03 Aug 1995 10:37:54 TRGARDOS
  137. ;//
  138. ;// Moved picture header structure definition to cdrvsdef.h.
  139. ;//
  140. ;// Rev 1.4 02 Aug 1995 15:31:02 DBRUCKS
  141. ;// added GOB header fields and cleaned up comments
  142. ;//
  143. ;// Rev 1.3 01 Aug 1995 16:24:58 DBRUCKS
  144. ;// add the picture header fields
  145. ;//
  146. ;// Rev 1.2 31 Jul 1995 16:28:12 DBRUCKS
  147. ;// move loacl BITS defs to D3DEC.CPP
  148. ;//
  149. ;// Rev 1.1 31 Jul 1995 15:51:12 CZHU
  150. ;//
  151. ;// added quant field in the BlockActionStream structure.
  152. ;//
  153. ;// Rev 1.0 31 Jul 1995 13:00:06 DBRUCKS
  154. ;// Initial revision.
  155. ;//
  156. ;// Rev 1.2 28 Jul 1995 13:59:54 CZHU
  157. ;//
  158. ;// Added block action stream definition and defines for constants
  159. ;//
  160. ;// Rev 1.1 24 Jul 1995 14:59:30 CZHU
  161. ;//
  162. ;// Defined decoder catalog for H.263. Also defined block action stream
  163. ;//
  164. ;// Rev 1.0 17 Jul 1995 14:46:24 CZHU
  165. ;// Initial revision.
  166. ;//
  167. ;// Rev 1.0 17 Jul 1995 14:14:40 CZHU
  168. ;// Initial revision.
  169. ;////////////////////////////////////////////////////////////////////////////
  170. #ifndef __DECLOCS_H__
  171. #define __DECLOCS_H__
  172. /*
  173. This file declares structs which catalog the locations of various
  174. tables, structures, and arrays needed by the H263 decoder.
  175. */
  176. //#define PITCH 384
  177. #define YVU9_VPITCH 336
  178. #define U_OFFSET 192
  179. #define UMV_EXPAND_Y 16
  180. #define UMV_EXPAND_UV 8 //expanding for Unrestricted MV in each direction
  181. #define Y_START (UMV_EXPAND_Y * PITCH + UMV_EXPAND_Y)
  182. #define UV_START (UMV_EXPAND_UV * PITCH + UMV_EXPAND_UV)
  183. #define INSTANCE_DATA_FIXED_SIZE 512
  184. //#define BLOCK_BUFFER_SIZE 8*8*4*6
  185. //Block stores for the MB are included in MB_MC_BUFFER
  186. #define MB_MC_BUFFER_SIZE PITCH*8
  187. #define BLOCK_BUFFER_OFFSET 6*8
  188. #define LEFT_EDGE 0x1
  189. #define RIGHT_EDGE 0x2
  190. #define TOP_EDGE 0x4
  191. #define BOTTOM_EDGE 0x8
  192. typedef struct {
  193. U32 X32_YPlane; /* X32_-pointer to Y, V, and U planes. */
  194. U32 X32_VPlane; /* Base plus offset is 32-bit aligned for */
  195. U32 X32_UPlane; /* all planes. */
  196. } YUVFrame;
  197. #define SRC_FORMAT_FORBIDDEN 0
  198. #define SRC_FORMAT_SQCIF 1
  199. #define SRC_FORMAT_QCIF 2
  200. #define SRC_FORMAT_CIF 3
  201. #define SRC_FORMAT_4CIF 4
  202. #define SRC_FORMAT_16CIF 5
  203. #define SRC_FORMAT_RES_1 6
  204. #define SRC_FORMAT_RES_2 7
  205. #ifdef H263P
  206. // H.263+ draft, document LBC-96-358
  207. #define SRC_FORMAT_CUSTOM 6 // Replaces SRC_FORMAT_RES_1
  208. #define SRC_FORMAT_EPTYPE 7 // Replaces SRC_FORMAT_RES_2
  209. #define SRC_FORMAT_RESERVED 7 // Reserved value in extened PTYPE
  210. #define PARC_SQUARE 1
  211. #define PARC_CIF 2
  212. #define PARC_10_11 3
  213. #define PARC_16_11 4
  214. #define PARC_40_33 5
  215. #define PARC_EXTENDED 16
  216. #endif
  217. #ifdef LOG_DECODE_TIMINGS_ON // { LOG_DECODE_TIMINGS_ON
  218. /* Decoder Timing Data - per frame
  219. */
  220. typedef struct {
  221. #if defined(DECODE_TIMINGS_ON) || defined(DETAILED_DECODE_TIMINGS_ON) // { #if defined(DECODE_TIMINGS_ON) || defined(DETAILED_DECODE_TIMINGS_ON)
  222. U32 uDecodeFrame;
  223. U32 uBEF;
  224. #endif // } #if defined(DECODE_TIMINGS_ON) || defined(DETAILED_DECODE_TIMINGS_ON)
  225. #ifdef DETAILED_DECODE_TIMINGS_ON // { DETAILED_DECODE_TIMINGS_ON
  226. U32 uHeaders;
  227. U32 uMemcpy;
  228. U32 uFrameCopy;
  229. U32 uOutputCC;
  230. U32 uIDCTandMC;
  231. U32 uDecIDCTCoeffs;
  232. #endif // } DETAILED_DECODE_TIMINGS_ON
  233. } DEC_TIMING_INFO;
  234. #endif // } LOG_DECODE_TIMINGS_ON
  235. typedef struct {
  236. /* Here's the data about the frame shape and location. */
  237. YUVFrame CurrFrame; /* Current frame. */
  238. YUVFrame PrevFrame; /* Previous frame. */
  239. YUVFrame PBFrame; /* frame to hold B blocks for H.263 */
  240. YUVFrame DispFrame; /* current frame being displayed */
  241. YUVFrame PostFrame; /* Buffer for post process and color convert.*/
  242. LPVOID _p16InstPostProcess; /* Segment containing PostFrm. */
  243. U8 * p16InstPostProcess; /* Segment containing PostFrm (aligned) */
  244. U32 uFrameHeight; /* Actual dimensions of image. */
  245. U32 uFrameWidth;
  246. U32 uYActiveHeight; /* Dimensions of image for which blocks are */
  247. U32 uYActiveWidth; /* actually encoded. I.e. height and width */
  248. U32 uUVActiveHeight; /* padded to multiple of eight. */
  249. U32 uUVActiveWidth;
  250. #ifdef H263P
  251. U32 uActualFrameHeight; /* Actual frame dimensions used for display */
  252. U32 uActualFrameWidth; /* purposes one. */
  253. #endif
  254. U32 uSz_VUPlanes; /* Space allocated for V and U planes. */
  255. U32 uSz_YPlane; /* Space allocated for Y plane. */
  256. U32 uSz_YVUPlanes; /* Space allocated for all planes. */
  257. U32 uIs320x240; /* Flag to indicate 320x240 frames (padded
  258. to CIF, used for stills */
  259. /* The data pointed to below is NOT instance specific. On 16-bit Windows
  260. it is copied to the per-instance data segment. On 32-bit Windows, it
  261. is in the one and only data segment, and is just pointed to here. */
  262. U32 uMBBuffer; /* storage for a block */
  263. U32 X16_BlkDir; /* Ptr array of type T_BlkDir */
  264. U32 X16_BlkActionStream; /* Params for each block */
  265. X32 X32_BEFDescr; /* Catalogs eagerness & willingness to BEF */
  266. X32 X32_BEFDescrCopy; /* Address of copy of BEFDescr in BEF seg. */
  267. X32 X32_BEFApplicationList; /* List of blocks to do Block Edge Filter */
  268. U32 X32_BitStream; /* Huffman encoded bitstream for one frame. */
  269. U32 uSizeBitStreamBuffer; /* Number of bytes allocated for this frame. */
  270. U32 uSrcFormat; /* Picture header information */
  271. U32 uPrevSrcFormat;
  272. U32 uTempRef;
  273. U32 uTempRefPrev;
  274. U32 uBFrameTempRef;
  275. U32 uPQuant;
  276. U32 uDBQuant;
  277. U16 bCameraOn;
  278. U16 bSplitScreen;
  279. U16 bFreezeRelease;
  280. U16 bKeyFrame;
  281. U16 bUnrestrictedMotionVectors;
  282. U16 bArithmeticCoding;
  283. U16 bAdvancedPrediction;
  284. U16 bPBFrame;
  285. #ifdef H263P
  286. // H.263+ draft, document LBC-96-358
  287. U16 bImprovedPBFrames;
  288. U16 bAdvancedIntra;
  289. U16 bDeblockingFilter;
  290. U16 bSliceStructured;
  291. U16 bCustomPCF;
  292. U16 bBackChannel;
  293. U16 bScalability;
  294. U16 bTrueBFrame;
  295. U16 bResampling;
  296. U16 bResUpdate;
  297. U32 uPARWidth;
  298. U32 uPARHeight;
  299. #endif
  300. U16 bCPM;
  301. U16 bReadSrcFormat;
  302. I32 iNumberOfMBsPerGOB;
  303. U32 uGroupNumber; /* GOB header information */
  304. U32 uGOBFrameID;
  305. U32 uGQuant;
  306. U16 bFoundGOBFrameID;
  307. U16 bCoded; /* MB header information */
  308. U32 uMBType;
  309. U32 uCBPC;
  310. U32 uCBPY;
  311. U32 uDQuant;
  312. U8 u8CBPB; /* 6 bit to hold CBP for 6 B blocks */
  313. U8 u8Pad;
  314. U16 u16Pad;
  315. I8 i8MVDBx2;
  316. I8 i8MVDBy2;
  317. I8 i8MVD2x2;
  318. I8 i8MVD2y2;
  319. I8 i8MVD3x2;
  320. I8 i8MVD3y2;
  321. I8 i8MVD4x2;
  322. I8 i8MVD4y2;
  323. I8 i8MVDx2; /* horizontal motion- mult by two */
  324. I8 i8MVDy2; /* vertical motion - mult by two for half pel */
  325. U16 bPrevFrameLost; /* Flag affecting temporal filter. */
  326. U32 bGOBHeaderPresent;
  327. U32 Sz_BitStream; /* Space allocated for copy of BitStream. */
  328. U32 Ticker; /* Frame counter. */
  329. U32 bDisplayBFrame; /* flag indicates that B frame displayed */
  330. U16 ColorConvertor; /* Index of color convertor to use. */
  331. U16 CCOutputPitch; /* Pitch for color converted output frame. */
  332. U32 CCOffsetToLine0; /* Offest to first line of color conv frame. */
  333. U32 CCOffset320x240; /* Color Convertor Offset to line 0
  334. for special Still Frame size */
  335. U16 DecoderType; /* Pick from H263, YUV9. */
  336. X16 X16_LumaAdjustment; /* Table to adjust brightness and contrast. */
  337. X16 X16_ChromaAdjustment; /* Table to adjust saturation. */
  338. /* The control code points to the flags with pointer to a BOOL
  339. */
  340. BOOL bAdjustLuma; /* Set if adjusting brightness and contrast. */
  341. BOOL bAdjustChroma; /* Set if adjusting saturation. */
  342. U16 BrightnessSetting; /* Value used to build adjustment tables. */
  343. U16 ContrastSetting; /* Value used to build adjustment tables. */
  344. U16 SaturationSetting; /* Value used to build adjustment tables. */
  345. U16 SuppressChecksum; /* Flag indicates if should skip checksum. */
  346. U16 iAPColorConvPrev;
  347. LPVOID pAPInstPrev; /* Pointer PostFrm for prev AP */
  348. X32 X32_InverseQuant; // NEW
  349. X32 X32_pN; // NEW
  350. X32 X32_uMBInfoStream; // PB-NEW
  351. #ifdef LOG_DECODE_TIMINGS_ON // { LOG_DECODE_TIMINGS_ON
  352. /* Timing Statistics Variables */
  353. X32 X32_DecTimingInfo; /* Offset to */
  354. DEC_TIMING_INFO * pDecTimingInfo; /* pointer, set after locking catalog */
  355. U32 uStatFrameCount; /* statistics frame counter */
  356. /* The following are needed in lower level routines */
  357. int bTimingThisFrame;
  358. U32 uStartLow;
  359. U32 uStartHigh;
  360. #endif // } LOG_DECODE_TIMINGS_ON
  361. //#ifdef LOSS_RECOVERY
  362. I32 iVerifiedBsExt; //flat indicating whether verification is performed
  363. I32 iValidBsExt; //flag indicating valid extension of bitstream
  364. void *pBsTrailer; //point to the trailer of the extended bs
  365. void *pBsInfo; //point to the beginning of the BSINFO stream
  366. U32 uNumOfPackets; //Number of Packets for this frame;
  367. //#endif
  368. /* Options */
  369. int bForceOnAspectRatioCorrection;
  370. int bUseBlockEdgeFilter;
  371. #ifdef USE_MMX // { USE_MMX
  372. BOOL bMMXDecoder;
  373. #endif // } USE_MMX
  374. } T_H263DecoderCatalog;
  375. typedef struct { // NEW
  376. U32 dInverseQuant; // NEW
  377. U32 dTotalRun; // NEW
  378. } T_IQ_INDEX; // NEW
  379. /* MBInfo
  380. *
  381. * A stream of T_MBInfo structs provides a place to hold information
  382. * about the macroblocks gathered during the first pass so it can
  383. * be used during the second pass for B-frame bi-directional motion
  384. * prediction. Each struct deals with one macroblock.
  385. */
  386. typedef struct { // PB-NEW
  387. I8 i8MBType; // AP-NEW added by Raj
  388. I8 i8MVDBx2;
  389. I8 i8MVDBy2;
  390. #ifdef H263P
  391. U8 bForwardPredOnly; /* Flag indicating only forward prediction of B-block */
  392. #endif
  393. } T_MBInfo; // PB-NEW
  394. /* Block Type defines
  395. */
  396. #define BT_INTRA_DC 0 // Intra block without TCOEFF
  397. // assembly code assumes INTRA_DC is zero
  398. #define BT_INTRA 1 // Intra block
  399. #define BT_INTER 2 // Inter block
  400. #define BT_EMPTY 3 // Inter block without TCOEFF
  401. #define BT_ERROR 4
  402. /* T_BlkAction
  403. *
  404. * A stream of T_BlkAction structs provides information about the blocks to
  405. * be processed for a slice. Each struct deals with one block.
  406. */
  407. typedef struct {
  408. U8 u8BlkType; /* block type */
  409. I8 i8MVx2; /* horizontal motion - mult by two for half pel */
  410. I8 i8MVy2; /* vertical motion - mult by two for half pel */
  411. U8 u8Quant; /* quantization level for this block */
  412. U32 pCurBlock; /* current image. */
  413. U32 pRefBlock; /* reference image. */
  414. U32 pBBlock; /* B block image */
  415. U32 uBlkNumber; /* for debugging */
  416. } T_BlkAction;
  417. typedef struct {
  418. X32 X32_BlkAddr; /* Addr of block in current frame buffer. */
  419. } T_BlkDir;
  420. #ifdef WIN32
  421. #else
  422. /* Return offsets for these structures. */
  423. U32 FAR H263DOffset_DequantizerTables ();
  424. /* Return size of fixed-size tables at start of instance data. */
  425. U32 FAR H263DSizeOf_FixedPart();
  426. #endif
  427. extern "C" {
  428. void FAR ASM_CALLTYPE FrameCopy (
  429. HPBYTE InputPlane, /* Address of input data. */
  430. HPBYTE OuptutPlane, /* Address of output data. */
  431. UN FrameHeight, /* Lines to copy. */
  432. UN FrameWidth, /* Columns to copy. */
  433. UN Pitch); /* Pitch. */
  434. void FAR ASM_CALLTYPE FrameMirror (
  435. HPBYTE InputPlane, /* Address of input data. */
  436. HPBYTE OuptutPlane, /* Address of output data. */
  437. UN FrameHeight, /* Lines to copy. */
  438. UN FrameWidth, /* Columns to copy. */
  439. UN Pitch); /* Pitch. */
  440. };
  441. #endif