Source code of Windows XP (NT5)
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.

842 lines
29 KiB

  1. //------------------------------------------------------------------------------
  2. // File: DXVA.h
  3. //
  4. // Desc: DirectX Video Acceleration header file.
  5. //
  6. // Copyright (c) 1999 - 2002, Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #ifndef __DIRECTX_VA__
  9. #define __DIRECTX_VA__
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. DEFINE_GUID(DXVA_ModeNone, 0x1b81be00, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  14. DEFINE_GUID(DXVA_ModeH261_A, 0x1b81be01, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  15. DEFINE_GUID(DXVA_ModeH261_B, 0x1b81be02, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  16. DEFINE_GUID(DXVA_ModeH263_A, 0x1b81be03, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  17. DEFINE_GUID(DXVA_ModeH263_B, 0x1b81be04, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  18. DEFINE_GUID(DXVA_ModeH263_C, 0x1b81be05, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  19. DEFINE_GUID(DXVA_ModeH263_D, 0x1b81be06, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  20. DEFINE_GUID(DXVA_ModeH263_E, 0x1b81be07, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  21. DEFINE_GUID(DXVA_ModeH263_F, 0x1b81be08, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  22. DEFINE_GUID(DXVA_ModeMPEG1_A, 0x1b81be09, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  23. DEFINE_GUID(DXVA_ModeMPEG2_A, 0x1b81be0A, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  24. DEFINE_GUID(DXVA_ModeMPEG2_B, 0x1b81be0B, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  25. DEFINE_GUID(DXVA_ModeMPEG2_C, 0x1b81be0C, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  26. DEFINE_GUID(DXVA_ModeMPEG2_D, 0x1b81be0D, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  27. DEFINE_GUID(DXVA_ModeWMV8_A, 0x1b81be80, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  28. DEFINE_GUID(DXVA_ModeWMV8_B, 0x1b81be81, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  29. DEFINE_GUID(DXVA_ModeWMV9_A, 0x1b81be90, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  30. DEFINE_GUID(DXVA_ModeWMV9_B, 0x1b81be91, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  31. DEFINE_GUID(DXVA_ModeWMV9_Ai, 0x1b81be92, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  32. DEFINE_GUID(DXVA_ModeWMV9_Bi, 0x1b81be93, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  33. DEFINE_GUID(DXVA_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
  34. #define DXVA_RESTRICTED_MODE_UNRESTRICTED 0xFFFF
  35. #define DXVA_RESTRICTED_MODE_H261_A 1
  36. #define DXVA_RESTRICTED_MODE_H261_B 2
  37. #define DXVA_RESTRICTED_MODE_H263_A 3
  38. #define DXVA_RESTRICTED_MODE_H263_B 4
  39. #define DXVA_RESTRICTED_MODE_H263_C 5
  40. #define DXVA_RESTRICTED_MODE_H263_D 6
  41. #define DXVA_RESTRICTED_MODE_H263_E 7
  42. #define DXVA_RESTRICTED_MODE_H263_F 8
  43. #define DXVA_RESTRICTED_MODE_MPEG1_A 9
  44. #define DXVA_RESTRICTED_MODE_MPEG2_A 0xA
  45. #define DXVA_RESTRICTED_MODE_MPEG2_B 0xB
  46. #define DXVA_RESTRICTED_MODE_MPEG2_C 0xC
  47. #define DXVA_RESTRICTED_MODE_MPEG2_D 0xD
  48. #define DXVA_RESTRICTED_MODE_WMV8_A 0x80
  49. #define DXVA_RESTRICTED_MODE_WMV8_B 0x81
  50. #define DXVA_RESTRICTED_MODE_WMV9_A 0x90
  51. #define DXVA_RESTRICTED_MODE_WMV9_B 0x91
  52. #define DXVA_RESTRICTED_MODE_WMV9_Ai 0x92
  53. #define DXVA_RESTRICTED_MODE_WMV9_Bi 0x93
  54. #define DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED 0
  55. #define DXVA_PICTURE_DECODE_BUFFER 1
  56. #define DXVA_MACROBLOCK_CONTROL_BUFFER 2
  57. #define DXVA_RESIDUAL_DIFFERENCE_BUFFER 3
  58. #define DXVA_DEBLOCKING_CONTROL_BUFFER 4
  59. #define DXVA_INVERSE_QUANTIZATION_MATRIX_BUFFER 5
  60. #define DXVA_SLICE_CONTROL_BUFFER 6
  61. #define DXVA_BITSTREAM_DATA_BUFFER 7
  62. #define DXVA_AYUV_BUFFER 8
  63. #define DXVA_IA44_SURFACE_BUFFER 9
  64. #define DXVA_DPXD_SURFACE_BUFFER 10
  65. #define DXVA_HIGHLIGHT_BUFFER 11
  66. #define DXVA_DCCMD_SURFACE_BUFFER 12
  67. #define DXVA_ALPHA_BLEND_COMBINATION_BUFFER 13
  68. #define DXVA_PICTURE_RESAMPLE_BUFFER 14
  69. #define DXVA_READ_BACK_BUFFER 15
  70. #define DXVA_NUM_TYPES_COMP_BUFFERS 16
  71. /* values for bDXVA_Func */
  72. #define DXVA_PICTURE_DECODING_FUNCTION 1
  73. #define DXVA_ALPHA_BLEND_DATA_LOAD_FUNCTION 2
  74. #define DXVA_ALPHA_BLEND_COMBINATION_FUNCTION 3
  75. #define DXVA_PICTURE_RESAMPLE_FUNCTION 4
  76. /* values returned from Execute command in absence of read-back */
  77. #define DXVA_EXECUTE_RETURN_OK 0
  78. #define DXVA_EXECUTE_RETURN_DATA_ERROR_MINOR 1
  79. #define DXVA_EXECUTE_RETURN_DATA_ERROR_SIGNIF 2
  80. #define DXVA_EXECUTE_RETURN_DATA_ERROR_SEVERE 3
  81. #define DXVA_EXECUTE_RETURN_OTHER_ERROR_SEVERE 4
  82. #pragma pack(push, BeforeDXVApacking, 1)
  83. typedef struct _DXVA_ConnectMode {
  84. GUID guidMode;
  85. WORD wRestrictedMode;
  86. } DXVA_ConnectMode, *LPDXVA_ConnectMode;
  87. typedef DWORD DXVA_ConfigQueryOrReplyFunc, *LPDXVA_ConfigQueryOrReplyFunc;
  88. #define DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY 0xFFFFF1
  89. #define DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY 0xFFFFF5
  90. #define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_OK_COPY 0xFFFFF8
  91. #define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_OK_PLUS 0xFFFFF9
  92. #define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_LOCK_OK_COPY 0xFFFFFC
  93. #define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_FALSE_PLUS 0xFFFFFB
  94. #define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_LOCK_FALSE_PLUS 0xFFFFFF
  95. #define readDXVA_QueryOrReplyFuncFlag(ptr) ((*(ptr)) >> 8)
  96. #define readDXVA_QueryOrReplyFuncFlag_ACCEL(ptr) (((*(ptr)) >> 11) & 1)
  97. #define readDXVA_QueryOrReplyFuncFlag_LOCK(ptr) (((*(ptr)) >> 10) & 1)
  98. #define readDXVA_QueryOrReplyFuncFlag_BAD(ptr) (((*(ptr)) >> 9) & 1)
  99. #define readDXVA_QueryOrReplyFuncFlag_PLUS(ptr) (((*(ptr)) >> 8) & 1)
  100. #define readDXVA_QueryOrReplyFuncFunc(ptr) ((*(ptr)) & 0xFF)
  101. #define writeDXVA_QueryOrReplyFunc(ptr, flg, fnc) ((*(ptr)) = ((flg) << 8) | (fnc))
  102. #define setDXVA_QueryOrReplyFuncFlag(ptr, flg) ((*(ptr)) |= ((flg) << 8))
  103. #define setDXVA_QueryOrReplyFuncFunc(ptr, fnc) ((*(ptr)) |= (fnc));
  104. typedef DWORD DXVA_EncryptProtocolFunc, *LPDXVA_EncryptProtocolFunc;
  105. #define DXVA_ENCRYPTPROTOCOLFUNCFLAG_HOST 0xFFFF00
  106. #define DXVA_ENCRYPTPROTOCOLFUNCFLAG_ACCEL 0xFFFF08
  107. #define readDXVA_EncryptProtocolFuncFlag(ptr) ((*(ptr)) >> 8)
  108. #define readDXVA_EncryptProtocolFuncFlag_ACCEL(ptr) (((*(ptr)) >> 11) & 1)
  109. #define readDXVA_EncryptProtocolFuncFunc(ptr) ((*(ptr)) & 0xFF)
  110. #define writeDXVA_EncryptProtocolFunc(ptr, flg, fnc) ((*(ptr)) = ((flg) << 8) | (fnc))
  111. #define setDXVA_EncryptProtocolFuncFlag(ptr, flg) ((*(ptr)) |= ((flg) << 8))
  112. #define setDXVA_EncryptProtocolFuncFunc(ptr, fnc) ((*(ptr)) |= (fnc));
  113. typedef struct _DXVA_EncryptProtocolHeader {
  114. DXVA_EncryptProtocolFunc dwFunction;
  115. DWORD ReservedBits[3];
  116. GUID guidEncryptProtocol;
  117. } DXVA_EncryptProtocolHeader, *LPDXVA_EncryptProtocolHeader;
  118. typedef struct _DXVA_ConfigPictureDecode {
  119. // Operation Indicated
  120. DXVA_ConfigQueryOrReplyFunc dwFunction;
  121. // Alignment
  122. DWORD dwReservedBits[3];
  123. // Encryption GUIDs
  124. GUID guidConfigBitstreamEncryption;
  125. GUID guidConfigMBcontrolEncryption;
  126. GUID guidConfigResidDiffEncryption;
  127. // Bitstream Processing Indicator
  128. BYTE bConfigBitstreamRaw;
  129. // Macroblock Control Config
  130. BYTE bConfigMBcontrolRasterOrder;
  131. // Host Resid Diff Config
  132. BYTE bConfigResidDiffHost;
  133. BYTE bConfigSpatialResid8;
  134. BYTE bConfigResid8Subtraction;
  135. BYTE bConfigSpatialHost8or9Clipping;
  136. BYTE bConfigSpatialResidInterleaved;
  137. BYTE bConfigIntraResidUnsigned;
  138. // Accelerator Resid Diff Config
  139. BYTE bConfigResidDiffAccelerator;
  140. BYTE bConfigHostInverseScan;
  141. BYTE bConfigSpecificIDCT;
  142. BYTE bConfig4GroupedCoefs;
  143. } DXVA_ConfigPictureDecode, *LPDXVA_ConfigPictureDecode;
  144. /* Picture Decoding Parameters */
  145. typedef struct _DXVA_PictureParameters {
  146. WORD wDecodedPictureIndex;
  147. WORD wDeblockedPictureIndex;
  148. WORD wForwardRefPictureIndex;
  149. WORD wBackwardRefPictureIndex;
  150. WORD wPicWidthInMBminus1;
  151. WORD wPicHeightInMBminus1;
  152. BYTE bMacroblockWidthMinus1;
  153. BYTE bMacroblockHeightMinus1;
  154. BYTE bBlockWidthMinus1;
  155. BYTE bBlockHeightMinus1;
  156. BYTE bBPPminus1;
  157. BYTE bPicStructure;
  158. BYTE bSecondField;
  159. BYTE bPicIntra;
  160. BYTE bPicBackwardPrediction;
  161. BYTE bBidirectionalAveragingMode;
  162. BYTE bMVprecisionAndChromaRelation;
  163. BYTE bChromaFormat;
  164. BYTE bPicScanFixed;
  165. BYTE bPicScanMethod;
  166. BYTE bPicReadbackRequests;
  167. BYTE bRcontrol;
  168. BYTE bPicSpatialResid8;
  169. BYTE bPicOverflowBlocks;
  170. BYTE bPicExtrapolation;
  171. BYTE bPicDeblocked;
  172. BYTE bPicDeblockConfined;
  173. BYTE bPic4MVallowed;
  174. BYTE bPicOBMC;
  175. BYTE bPicBinPB;
  176. BYTE bMV_RPS;
  177. BYTE bReservedBits;
  178. WORD wBitstreamFcodes;
  179. WORD wBitstreamPCEelements;
  180. BYTE bBitstreamConcealmentNeed;
  181. BYTE bBitstreamConcealmentMethod;
  182. } DXVA_PictureParameters, *LPDXVA_PictureParameters;
  183. /* Picture Resampling */
  184. typedef struct _DXVA_PicResample {
  185. WORD wPicResampleSourcePicIndex;
  186. WORD wPicResampleDestPicIndex;
  187. WORD wPicResampleRcontrol;
  188. BYTE bPicResampleExtrapWidth;
  189. BYTE bPicResampleExtrapHeight;
  190. DWORD dwPicResampleSourceWidth;
  191. DWORD dwPicResampleSourceHeight;
  192. DWORD dwPicResampleDestWidth;
  193. DWORD dwPicResampleDestHeight;
  194. DWORD dwPicResampleFullDestWidth;
  195. DWORD dwPicResampleFullDestHeight;
  196. } DXVA_PicResample, *LPDXVA_PicResample;
  197. #define DXVA_CHROMA_FORMAT_420 1
  198. #define DXVA_CHROMA_FORMAT_422 2
  199. #define DXVA_CHROMA_FORMAT_444 3
  200. #define DXVA_PICTURE_STRUCTURE_TOP_FIELD 1
  201. #define DXVA_PICTURE_STRUCTURE_BOTTOM_FIELD 2
  202. #define DXVA_PICTURE_STRUCTURE_FRAME 3
  203. #define DXVA_BIDIRECTIONAL_AVERAGING_MPEG2_ROUND 0
  204. #define DXVA_BIDIRECTIONAL_AVERAGING_H263_TRUNC 1
  205. #define DXVA_MV_PRECISION_AND_CHROMA_RELATION_MPEG2 0
  206. #define DXVA_MV_PRECISION_AND_CHROMA_RELATION_H263 1
  207. #define DXVA_MV_PRECISION_AND_CHROMA_RELATION_H261 2
  208. #define DXVA_SCAN_METHOD_ZIG_ZAG 0
  209. #define DXVA_SCAN_METHOD_ALTERNATE_VERTICAL 1
  210. #define DXVA_SCAN_METHOD_ALTERNATE_HORIZONTAL 2
  211. #define DXVA_SCAN_METHOD_ARBITRARY 3
  212. #define DXVA_BITSTREAM_CONCEALMENT_NEED_UNLIKELY 0
  213. #define DXVA_BITSTREAM_CONCEALMENT_NEED_MILD 1
  214. #define DXVA_BITSTREAM_CONCEALMENT_NEED_LIKELY 2
  215. #define DXVA_BITSTREAM_CONCEALMENT_NEED_SEVERE 3
  216. #define DXVA_BITSTREAM_CONCEALMENT_METHOD_UNSPECIFIED 0
  217. #define DXVA_BITSTREAM_CONCEALMENT_METHOD_INTRA 1
  218. #define DXVA_BITSTREAM_CONCEALMENT_METHOD_FORWARD 2
  219. #define DXVA_BITSTREAM_CONCEALMENT_METHOD_BACKWARD 3
  220. /* Buffer Description Data */
  221. typedef struct _DXVA_BufferDescription {
  222. DWORD dwTypeIndex;
  223. DWORD dwBufferIndex;
  224. DWORD dwDataOffset;
  225. DWORD dwDataSize;
  226. DWORD dwFirstMBaddress;
  227. DWORD dwNumMBsInBuffer;
  228. DWORD dwWidth;
  229. DWORD dwHeight;
  230. DWORD dwStride;
  231. DWORD dwReservedBits;
  232. } DXVA_BufferDescription, *LPDXVA_BufferDescription;
  233. /* Off-Host IDCT Coefficient Data Structures */
  234. typedef struct _DXVA_TCoef4Group {
  235. BYTE TCoefIDX[4];
  236. SHORT TCoefValue[4];
  237. } DXVA_TCoef4Group, *LPDXVA_TCoef4Group;
  238. typedef struct _DXVA_TCoefSingle {
  239. WORD wIndexWithEOB;
  240. SHORT TCoefValue;
  241. } DXVA_TCoefSingle, *LPDXVA_TCoefSingle;
  242. /* Macros for Reading EOB and Index Values */
  243. #define readDXVA_TCoefSingleIDX(ptr) ((ptr)->wIndexWithEOB >> 1)
  244. #define readDXVA_TCoefSingleEOB(ptr) ((ptr)->wIndexWithEOB & 1)
  245. /* Macro for Writing EOB and Index Values */
  246. #define writeDXVA_TCoefSingleIndexWithEOB(ptr, idx, eob) ((ptr)->wIndexWithEOB = ((idx) << 1) | (eob))
  247. #define setDXVA_TCoefSingleIDX(ptr, idx) ((ptr)->wIndexWithEOB |= ((idx) << 1))
  248. #define setDXVA_TCoefSingleEOB(ptr) ((ptr)->wIndexWithEOB |= 1)
  249. /* Spatial-Domain Residual Difference Blocks */
  250. #define DXVA_USUAL_BLOCK_WIDTH 8
  251. #define DXVA_USUAL_BLOCK_HEIGHT 8
  252. #define DXVA_USUAL_BLOCK_SIZE (DXVA_USUAL_BLOCK_WIDTH * DXVA_USUAL_BLOCK_HEIGHT)
  253. typedef SHORT DXVA_Sample16[DXVA_USUAL_BLOCK_SIZE];
  254. typedef signed char DXVA_Sample8 [DXVA_USUAL_BLOCK_SIZE];
  255. /* Deblocking Filter Control Structure */
  256. typedef BYTE DXVA_DeblockingEdgeControl;
  257. typedef DXVA_DeblockingEdgeControl * LPDXVA_DeblockingEdgeControl;
  258. /* Macros for Reading STRENGTH and FilterOn */
  259. #define readDXVA_EdgeFilterStrength(ptr) ((*(ptr)) >> 1)
  260. #define readDXVA_EdgeFilterOn(ptr) ((*(ptr)) & 1)
  261. /* Macro for Writing STRENGTH and FilterOn */
  262. #define writeDXVA_DeblockingEdgeControl(ptr, str, fon) ((*(ptr)) = ((str) << 1) | (fon))
  263. #define setDXVA_EdgeFilterStrength(ptr, str) ((*(ptr)) |= ((str) << 1))
  264. #define setDXVA_EdgeFilterOn(ptr) ((*(ptr)) |= 1)
  265. /* Macroblock Control Command Data Structures */
  266. typedef struct _DXVA_MVvalue {
  267. SHORT horz, vert;
  268. } DXVA_MVvalue, *LPDXVA_MVvalue;
  269. /* Inverse Quantization Matrices */
  270. typedef struct _DXVA_QmatrixData {
  271. BYTE bNewQmatrix[4]; /* intra Y, inter Y, intra chroma, inter chroma */
  272. WORD Qmatrix[4][DXVA_USUAL_BLOCK_WIDTH * DXVA_USUAL_BLOCK_HEIGHT];
  273. } DXVA_QmatrixData, *LPDXVA_QmatrixData;
  274. /* Slice Control Buffer Data */
  275. typedef struct _DXVA_SliceInfo {
  276. WORD wHorizontalPosition;
  277. WORD wVerticalPosition;
  278. DWORD dwSliceBitsInBuffer;
  279. DWORD dwSliceDataLocation;
  280. BYTE bStartCodeBitOffset;
  281. BYTE bReservedBits;
  282. WORD wMBbitOffset;
  283. WORD wNumberMBsInSlice;
  284. WORD wQuantizerScaleCode;
  285. WORD wBadSliceChopping;
  286. } DXVA_SliceInfo, *LPDXVA_SliceInfo;
  287. #define DXVA_NumMV_OBMC_off_BinPBwith4MV_off 4
  288. #define DXVA_NumMV_OBMC_off_BinPBwith4MV_on (4+1)
  289. #define DXVA_NumMV_OBMC_on__BinPB_off (10)
  290. #define DXVA_NumMV_OBMC_on__BinPB_on (11) /* not current standards */
  291. #define DXVA_NumBlocksPerMB_420 (4+2+0)
  292. #define DXVA_NumBlocksPerMB_422 (4+2+2)
  293. #define DXVA_NumBlocksPerMB_444 (4+4+4)
  294. /* Basic form for I pictures */
  295. /* Host Residual Differences */
  296. typedef struct _DXVA_MBctrl_I_HostResidDiff_1 {
  297. WORD wMBaddress;
  298. WORD wMBtype;
  299. DWORD dwMB_SNL;
  300. WORD wPatternCode;
  301. WORD wPC_Overflow; /* zero if not overflow format */
  302. DWORD dwReservedBits2;
  303. } DXVA_MBctrl_I_HostResidDiff_1;
  304. /* Basic form for I pictures */
  305. /* Off-Host IDCT, 4:2:0 sampling */
  306. typedef struct _DXVA_MBctrl_I_OffHostIDCT_1 {
  307. WORD wMBaddress;
  308. WORD wMBtype;
  309. DWORD dwMB_SNL;
  310. WORD wPatternCode;
  311. BYTE bNumCoef[DXVA_NumBlocksPerMB_420];
  312. } DXVA_MBctrl_I_OffHostIDCT_1;
  313. /* Basic form for P and B pictures */
  314. /* Should also be used for concealment MVs in MPEG-2 I pictures */
  315. /* Without OBMC, without BinPB and 4MV together, without MV RPS */
  316. /* Host Residual Differences */
  317. typedef struct _DXVA_MBctrl_P_HostResidDiff_1 {
  318. WORD wMBaddress;
  319. WORD wMBtype;
  320. DWORD dwMB_SNL;
  321. WORD wPatternCode;
  322. WORD wPC_Overflow; /* zero if not overflow format */
  323. DWORD dwReservedBits2;
  324. DXVA_MVvalue MVector[DXVA_NumMV_OBMC_off_BinPBwith4MV_off];
  325. } DXVA_MBctrl_P_HostResidDiff_1;
  326. /* Basic form for P and B pictures */
  327. /* Without OBMC, without BinPB and 4MV together, without MV RPS */
  328. /* Off-Host IDCT, 4:2:0 sampling */
  329. typedef struct _DXVA_MBctrl_P_OffHostIDCT_1 {
  330. WORD wMBaddress;
  331. WORD wMBtype;
  332. DWORD dwMB_SNL;
  333. WORD wPatternCode;
  334. BYTE bNumCoef[DXVA_NumBlocksPerMB_420];
  335. DXVA_MVvalue MVector[DXVA_NumMV_OBMC_off_BinPBwith4MV_off];
  336. } DXVA_MBctrl_P_OffHostIDCT_1;
  337. /* How to load alpha blending graphic data */
  338. typedef struct _DXVA_ConfigAlphaLoad {
  339. // Operation Indicated
  340. DXVA_ConfigQueryOrReplyFunc dwFunction;
  341. // Alignment
  342. DWORD dwReservedBits[3];
  343. BYTE bConfigDataType;
  344. } DXVA_ConfigAlphaLoad, *LPDXVA_ConfigAlphaLoad;
  345. #define DXVA_CONFIG_DATA_TYPE_IA44 0
  346. #define DXVA_CONFIG_DATA_TYPE_AI44 1
  347. #define DXVA_CONFIG_DATA_TYPE_DPXD 2
  348. #define DXVA_CONFIG_DATA_TYPE_AYUV 3
  349. /* How to combine alpha blending graphic data */
  350. typedef struct _DXVA_ConfigAlphaCombine {
  351. // Operation Indicated
  352. DXVA_ConfigQueryOrReplyFunc dwFunction;
  353. // Alignment
  354. DWORD dwReservedBits[3];
  355. BYTE bConfigBlendType;
  356. BYTE bConfigPictureResizing;
  357. BYTE bConfigOnlyUsePicDestRectArea;
  358. BYTE bConfigGraphicResizing;
  359. BYTE bConfigWholePlaneAlpha;
  360. } DXVA_ConfigAlphaCombine, *LPDXVA_ConfigAlphaCombine;
  361. #define DXVA_CONFIG_BLEND_TYPE_FRONT_BUFFER 0
  362. #define DXVA_CONFIG_BLEND_TYPE_BACK_HARDWARE 1
  363. /* AYUV sample for 16-entry YUV palette or graphic surface */
  364. typedef struct _DXVA_AYUVsample2 {
  365. BYTE bCrValue;
  366. BYTE bCbValue;
  367. BYTE bY_Value;
  368. BYTE bSampleAlpha8;
  369. } DXVA_AYUVsample2, *LPDXVA_AYUVsample2;
  370. /* Macros for IA44 alpha blending surface samples */
  371. typedef BYTE DXVA_IA44sample, *LPDXVA_IA44sample;
  372. #define readDXVA_IA44index(ptr) (((*(ptr)) & 0xF0) >> 4)
  373. #define readDXVA_IA44alpha(ptr) ((*(ptr)) & 0x0F)
  374. #define writeDXVA_IA44(ptr, idx, alpha) ((*(ptr)) = (((idx) << 4) | (alpha)))
  375. #define setDXVA_IA44index(ptr, idx) ((*(ptr)) |= ((idx) << 4))
  376. #define setDXVA_IA44alpha(ptr, alpha) ((*(ptr)) |= (alpha))
  377. /* Macros for AI44 alpha blending surface samples */
  378. typedef BYTE DXVA_AI44sample, *LPDXVA_AI44sample;
  379. #define readDXVA_AI44index(ptr) ((*(ptr)) & 0x0F)
  380. #define readDXVA_AI44alpha(ptr) (((*(ptr)) & 0xF0) >> 4)
  381. #define writeDXVA_AI44(ptr, idx, alpha) ((*(ptr)) = (((alpha) << 4) | (idx)))
  382. #define setDXVA_AI44index(ptr, idx) ((*(ptr)) |= (idx))
  383. #define setDXVA_AI44alpha(ptr, alpha) ((*(ptr)) |= ((alpha) << 4))
  384. /* Highlight data structure */
  385. typedef struct _DXVA_Highlight {
  386. WORD wHighlightActive;
  387. WORD wHighlightIndices;
  388. WORD wHighlightAlphas;
  389. RECT HighlightRect;
  390. } DXVA_Highlight, *LPDXVA_Highlight;
  391. typedef BYTE DXVA_DPXD, *LPDXVA_DPXD;
  392. typedef WORD DXVA_DCCMD, *LPDXVA_DCCMD;
  393. /* Alpha blend combination */
  394. typedef struct _DXVA_BlendCombination {
  395. WORD wPictureSourceIndex;
  396. WORD wBlendedDestinationIndex;
  397. RECT PictureSourceRect16thPel;
  398. RECT PictureDestinationRect;
  399. RECT GraphicSourceRect;
  400. RECT GraphicDestinationRect;
  401. WORD wBlendDelay;
  402. BYTE bBlendOn;
  403. BYTE bWholePlaneAlpha;
  404. DXVA_AYUVsample2 OutsideYUVcolor;
  405. } DXVA_BlendCombination, *LPDXVA_BlendCombination;
  406. #pragma pack(push, 16)
  407. typedef DXVA_MBctrl_I_HostResidDiff_1 *
  408. LPDXVA_MBctrl_I_HostResidDiff_1;
  409. typedef DXVA_MBctrl_I_OffHostIDCT_1 *
  410. LPDXVA_MBctrl_I_OffHostIDCT_1;
  411. typedef DXVA_MBctrl_P_HostResidDiff_1 *
  412. LPDXVA_MBctrl_P_HostResidDiff_1;
  413. typedef DXVA_MBctrl_P_OffHostIDCT_1 *
  414. LPDXVA_MBctrl_P_OffHostIDCT_1;
  415. #pragma pack(pop)
  416. /*
  417. * Other forms of pictures are constructed in the obvious way
  418. * from the above by adjusting the number of residual difference
  419. * blocks, the number of motion vectors per macroblock, etc.
  420. */
  421. #define readDXVA_MBskipsFollowing(ptr) (((ptr)->dwMB_SNL & 0xFF000000) >> 24)
  422. #define readDXVA_MBdataLocation(ptr) (((ptr)->dwMB_SNL & 0x00FFFFFF))
  423. #define writeDXVA_MB_SNL(ptr, skips, dloc) ((ptr)->dwMB_SNL = (((skips) << 24) | (dloc)))
  424. #define setDXVA_MBskipsFollowing(ptr, skips) ((ptr)->dwMB_SNL |= ((skips) << 24))
  425. #define setDXVA_MBdataLocation(ptr, dloc) ((ptr)->dwMB_SNL |= (dloc))
  426. #define readDXVA_MvertFieldSel_3(ptr) (((ptr)->wMBtype & 0x8000) >> 15)
  427. #define readDXVA_MvertFieldSel_2(ptr) (((ptr)->wMBtype & 0x4000) >> 14)
  428. #define readDXVA_MvertFieldSel_1(ptr) (((ptr)->wMBtype & 0x2000) >> 13)
  429. #define readDXVA_MvertFieldSel_0(ptr) (((ptr)->wMBtype & 0x1000) >> 12)
  430. #define readDXVA_ReservedBits(ptr) (((ptr)->wMBtype & 0x0800) >> 11)
  431. #define readDXVA_HostResidDiff(ptr) (((ptr)->wMBtype & 0x0400) >> 10)
  432. #define readDXVA_MotionType(ptr) (((ptr)->wMBtype & 0x0300) >> 8)
  433. #define readDXVA_MBscanMethod(ptr) (((ptr)->wMBtype & 0x00C0) >> 6)
  434. #define readDXVA_FieldResidual(ptr) (((ptr)->wMBtype & 0x0020) >> 5)
  435. #define readDXVA_H261LoopFilter(ptr) (((ptr)->wMBtype & 0x0010) >> 4)
  436. #define readDXVA_Motion4MV(ptr) (((ptr)->wMBtype & 0x0008) >> 3)
  437. #define readDXVA_MotionBackward(ptr) (((ptr)->wMBtype & 0x0004) >> 2)
  438. #define readDXVA_MotionForward(ptr) (((ptr)->wMBtype & 0x0002) >> 1)
  439. #define readDXVA_IntraMacroblock(ptr) (((ptr)->wMBtype & 0x0001))
  440. #define setDXVA_MvertFieldSel_3(ptr) ((ptr)->wMBtype |= 0x8000)
  441. #define setDXVA_MvertFieldSel_2(ptr) ((ptr)->wMBtype |= 0x4000)
  442. #define setDXVA_MvertFieldSel_1(ptr) ((ptr)->wMBtype |= 0x2000)
  443. #define setDXVA_MvertFieldSel_0(ptr) ((ptr)->wMBtype |= 0x1000)
  444. #define setDXVA_ReservedBits(ptr) ((ptr)->wMBtype |= 0x0800)
  445. #define setDXVA_HostResidDiff(ptr) ((ptr)->wMBtype |= 0x0400)
  446. #define setDXVA_MotionType(ptr, value) ((ptr)->wMBtype |= ((value) << 8))
  447. #define setDXVA_MBscanMethod(ptr, value) ((ptr)->wMBtype |= ((value) << 6))
  448. #define setDXVA_FieldResidual(ptr) ((ptr)->wMBtype |= 0x0020)
  449. #define setDXVA_H261LoopFilter(ptr) ((ptr)->wMBtype |= 0x0010)
  450. #define setDXVA_Motion4MV(ptr) ((ptr)->wMBtype |= 0x0008)
  451. #define setDXVA_MotionBackward(ptr) ((ptr)->wMBtype |= 0x0004)
  452. #define setDXVA_MotionForward(ptr) ((ptr)->wMBtype |= 0x0002)
  453. #define setDXVA_IntraMacroblock(ptr) ((ptr)->wMBtype |= 0x0001)
  454. #define readDXVA_Y___0coded(ptr) (((ptr)->wPatternCode & 0x0800) >> 11)
  455. #define readDXVA_Y___1coded(ptr) (((ptr)->wPatternCode & 0x0400) >> 10)
  456. #define readDXVA_Y___2coded(ptr) (((ptr)->wPatternCode & 0x0200) >> 9)
  457. #define readDXVA_Y___3coded(ptr) (((ptr)->wPatternCode & 0x0100) >> 8)
  458. #define readDXVA_Cb__4coded(ptr) (((ptr)->wPatternCode & 0x0080) >> 7)
  459. #define readDXVA_Cr__5coded(ptr) (((ptr)->wPatternCode & 0x0040) >> 6)
  460. #define readDXVA_Cb__6coded(ptr) (((ptr)->wPatternCode & 0x0020) >> 5)
  461. #define readDXVA_Cr__7coded(ptr) (((ptr)->wPatternCode & 0x0010) >> 4)
  462. #define readDXVA_Cb__8coded(ptr) (((ptr)->wPatternCode & 0x0008) >> 3)
  463. #define readDXVA_Cb__9coded(ptr) (((ptr)->wPatternCode & 0x0004) >> 2)
  464. #define readDXVA_Cr_10coded(ptr) (((ptr)->wPatternCode & 0x0002) >> 1)
  465. #define readDXVA_Cr_11coded(ptr) (((ptr)->wPatternCode & 0x0001))
  466. #define readDXVA_Y___0oflow(ptr) (((ptr)->wPC_Overflow & 0x0800) >> 11)
  467. #define readDXVA_Y___1oflow(ptr) (((ptr)->wPC_Overflow & 0x0400) >> 10)
  468. #define readDXVA_Y___2oflow(ptr) (((ptr)->wPC_Overflow & 0x0200) >> 9)
  469. #define readDXVA_Y___3oflow(ptr) (((ptr)->wPC_Overflow & 0x0100) >> 8)
  470. #define readDXVA_Cb__4oflow(ptr) (((ptr)->wPC_Overflow & 0x0080) >> 7)
  471. #define readDXVA_Cr__5oflow(ptr) (((ptr)->wPC_Overflow & 0x0040) >> 6)
  472. #define readDXVA_Cb__6oflow(ptr) (((ptr)->wPC_Overflow & 0x0020) >> 5)
  473. #define readDXVA_Cr__7oflow(ptr) (((ptr)->wPC_Overflow & 0x0010) >> 4)
  474. #define readDXVA_Cb__8oflow(ptr) (((ptr)->wPC_Overflow & 0x0008) >> 3)
  475. #define readDXVA_Cb__9oflow(ptr) (((ptr)->wPC_Overflow & 0x0004) >> 2)
  476. #define readDXVA_Cr_10oflow(ptr) (((ptr)->wPC_Overflow & 0x0002) >> 1)
  477. #define readDXVA_Cr_11oflow(ptr) (((ptr)->wPC_Overflow & 0x0001))
  478. #pragma pack(pop, BeforeDXVApacking)
  479. // -------------------------------------------------------------------------
  480. //
  481. // The definitions that follow describe the video de-interlace interface
  482. // between the VMR and the graphics device driver. This interface is not
  483. // accessable via the IAMVideoAccelerator interface.
  484. //
  485. // -------------------------------------------------------------------------
  486. //
  487. typedef LONGLONG REFERENCE_TIME;
  488. DEFINE_GUID(DXVA_DeinterlaceBobDevice,
  489. 0x335aa36e,0x7884,0x43a4,0x9c,0x91,0x7f,0x87,0xfa,0xf3,0xe3,0x7e);
  490. DEFINE_GUID(DXVA_DeinterlaceContainerDevice,
  491. 0x0e85cb93,0x3046,0x4ff0,0xae,0xcc,0xd5,0x8c,0xb5,0xf0,0x35,0xfd);
  492. #if !defined(VALID_POOL)
  493. typedef DWORD D3DFORMAT;
  494. enum {
  495. D3DPOOL_DEFAULT = 0,
  496. D3DPOOL_MANAGED = 1,
  497. D3DPOOL_SYSTEMMEM = 2,
  498. D3DPOOL_SCRATCH = 3,
  499. D3DPOOL_LOCALVIDMEM = 4,
  500. D3DPOOL_NONLOCALVIDMEM = 5,
  501. D3DPOOL_FORCE_DWORD = 0x7fffffff
  502. };
  503. #endif
  504. // -------------------------------------------------------------------------
  505. // data structures shared by User mode and Kernel mode.
  506. // -------------------------------------------------------------------------
  507. //
  508. typedef enum _DXVA_SampleFormat {
  509. DXVA_SamplePreviousFrame = 1,
  510. DXVA_SampleProgressiveFrame = 2,
  511. DXVA_SampleFieldInterleavedEvenFirst = 3,
  512. DXVA_SampleFieldInterleavedOddFirst = 4,
  513. DXVA_SampleFieldSingleEven = 5,
  514. DXVA_SampleFieldSingleOdd = 6,
  515. } DXVA_SampleFormat;
  516. typedef struct _DXVA_Frequency {
  517. DWORD Numerator;
  518. DWORD Denominator;
  519. } DXVA_Frequency;
  520. typedef struct _DXVA_VideoDesc {
  521. DWORD Size;
  522. DWORD SampleWidth;
  523. DWORD SampleHeight;
  524. DXVA_SampleFormat SampleFormat;
  525. D3DFORMAT d3dFormat;
  526. DXVA_Frequency InputSampleFreq;
  527. DXVA_Frequency OutputFrameFreq;
  528. } DXVA_VideoDesc, *LPDXVA_VideoDesc;
  529. typedef enum _DXVA_VideoProcessCaps {
  530. DXVA_VideoProcess_None = 0x0000,
  531. DXVA_VideoProcess_YUV2RGB = 0x0001,
  532. DXVA_VideoProcess_StretchX = 0x0002,
  533. DXVA_VideoProcess_StretchY = 0x0004,
  534. DXVA_VideoProcess_AlphaBlend = 0x0008
  535. } DXVA_VideoProcessCaps;
  536. typedef enum _DXVA_DeinterlaceTech {
  537. // the algorithm is unknown or proprietary
  538. DXVA_DeinterlaceTech_Unknown = 0x0000,
  539. // the algorithm creates the missing lines by repeating
  540. // the line either above or below it - this method will look very jaggy and
  541. // isn't recommended
  542. DXVA_DeinterlaceTech_BOBLineReplicate = 0x0001,
  543. // the algorithm creates the missing lines by vertically stretching each
  544. // video field by a factor of two. Slight vertical adjustments are made to
  545. // ensure that the resulting image does not "bob" up and down.
  546. // The algorithm creates the missing lines by vertically stretching each
  547. // video field by a factor of two, for example by averaging two lines or
  548. // using a [-1, 9, 9, -1]/16 filter across four lines.
  549. // Slight vertical adjustments are made to ensure that the resulting image
  550. // does not "bob" up and down.
  551. DXVA_DeinterlaceTech_BOBVerticalStretch = 0x0002,
  552. // the pixels in the missing line are recreated by a median filtering operation
  553. DXVA_DeinterlaceTech_MedianFiltering = 0x0004,
  554. // the pixels in the missing line are recreated by an edge filter.
  555. // In this process, spatial directional filters are applied to determine
  556. // the orientation of edges in the picture content, and missing
  557. // pixels are created by filtering along (rather than across) the
  558. // detected edges.
  559. DXVA_DeinterlaceTech_EdgeFiltering = 0x0010,
  560. // the pixels in the missing line are recreated by switching on a field by
  561. // field basis between using either spatial or temporal interpolation
  562. // depending on the amount of motion.
  563. DXVA_DeinterlaceTech_FieldAdaptive = 0x0020,
  564. // the pixels in the missing line are recreated by switching on a pixel by pixel
  565. // basis between using either spatial or temporal interpolation depending on
  566. // the amount of motion..
  567. DXVA_DeinterlaceTech_PixelAdaptive = 0x0040,
  568. // Motion Vector Steering identifies objects within a sequence of video
  569. // fields. The missing pixels are recreated after first aligning the
  570. // movement axes of the individual objects in the scene to make them
  571. // parallel with the time axis.
  572. DXVA_DeinterlaceTech_MotionVectorSteered = 0x0080
  573. } DXVA_DeinterlaceTech;
  574. typedef struct _DXVA_VideoSample {
  575. REFERENCE_TIME rtStart;
  576. REFERENCE_TIME rtEnd;
  577. DXVA_SampleFormat SampleFormat;
  578. VOID* lpDDSSrcSurface;
  579. } DXVA_VideoSample, *LPDXVA_VideoSample;
  580. typedef struct _DXVA_DeinterlaceCaps {
  581. DWORD Size;
  582. DWORD NumPreviousOutputFrames;
  583. DWORD InputPool;
  584. DWORD NumForwardRefSamples;
  585. DWORD NumBackwardRefSamples;
  586. D3DFORMAT d3dOutputFormat;
  587. DXVA_VideoProcessCaps VideoProcessingCaps;
  588. DXVA_DeinterlaceTech DeinterlaceTechnology;
  589. } DXVA_DeinterlaceCaps, *LPDXVA_DeinterlaceCaps;
  590. // -------------------------------------------------------------------------
  591. // Data types used with RenderMoComp in kernel mode
  592. // -------------------------------------------------------------------------
  593. //
  594. // Function codes for RenderMoComp
  595. #define MAX_DEINTERLACE_SURFACES 32
  596. typedef struct _DXVA_DeinterlaceBlt {
  597. DWORD Size;
  598. REFERENCE_TIME rtTarget;
  599. RECT DstRect;
  600. RECT SrcRect;
  601. DWORD NumSourceSurfaces;
  602. FLOAT Alpha;
  603. DXVA_VideoSample Source[MAX_DEINTERLACE_SURFACES];
  604. } DXVA_DeinterlaceBlt;
  605. #define DXVA_DeinterlaceBltFnCode 0x01
  606. // lpInput => DXVA_DeinterlaceBlt*
  607. // lpOuput => NULL /* not currently used */
  608. #define MAX_DEINTERLACE_DEVICE_GUIDS 32
  609. typedef struct _DXVA_DeinterlaceQueryAvailableModes {
  610. DWORD Size;
  611. DWORD NumGuids;
  612. GUID Guids[MAX_DEINTERLACE_DEVICE_GUIDS];
  613. } DXVA_DeinterlaceQueryAvailableModes;
  614. #define DXVA_DeinterlaceQueryAvailableModesFnCode 0x01
  615. // lpInput => DXVA_VideoDesc*
  616. // lpOuput => DXVA_DeinterlaceQueryAvailableModes*
  617. typedef struct _DXVA_DeinterlaceQueryModeCaps {
  618. DWORD Size;
  619. GUID Guid;
  620. DXVA_VideoDesc VideoDesc;
  621. } DXVA_DeinterlaceQueryModeCaps;
  622. #define DXVA_DeinterlaceQueryModeCapsFnCode 0x02
  623. // lpInput => DXVA_DeinterlaceQueryModeCaps*
  624. // lpOuput => DXVA_DeinterlaceCaps*
  625. #ifdef __cplusplus
  626. }
  627. #endif
  628. #endif /* __DIRECTX_VA__ */