1 // Copyright (c) 2017-2019 Intel Corporation 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in all 11 // copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 // SOFTWARE. 20 21 //#include "mfx_common.h" 22 #ifndef __MFX_H264_ENCODE_STRUCT_VAAPI__H 23 #define __MFX_H264_ENCODE_STRUCT_VAAPI__H 24 25 #include "mfx_common.h" 26 27 #if defined (MFX_VA_LINUX) 28 29 #include "mfx_platform_headers.h" 30 31 32 #define D3DDDIFMT_INTELENCODE_BITSTREAMDATA (D3DDDIFORMAT)164 // D3DDDIFMT_DXVA_RESERVED14 33 #define D3DDDIFMT_INTELENCODE_MBDATA (D3DDDIFORMAT)165 // D3DDDIFMT_DXVA_RESERVED15 34 #define D3DDDIFMT_INTELENCODE_MBSEGMENTMAP (D3DDDIFORMAT)181 35 36 typedef struct tagENCODE_COMP_BUFFER_INFO 37 { 38 D3DFORMAT Type; 39 D3DFORMAT CompressedFormats; 40 USHORT CreationWidth; 41 USHORT CreationHeight; 42 UCHAR NumBuffer; 43 UCHAR AllocationType; 44 } ENCODE_COMP_BUFFER_INFO; 45 46 typedef enum tagENCODE_FUNC 47 { 48 ENCODE_ENC = 0x0001, 49 ENCODE_PAK = 0x0002, 50 ENCODE_ENC_PAK = 0x0004, 51 } ENCODE_FUNC; 52 53 //////////////////////////////////////////////////////////////////////////////// 54 // this enumeration is used to define frame encoding type 55 /////////////////////////////////////////////////////////////////////////////// 56 enum 57 { 58 CODING_TYPE_I = 1, 59 CODING_TYPE_P = 2, 60 CODING_TYPE_B = 3, 61 }; 62 63 enum 64 { 65 SLICE_TYPE_P = 0, 66 SLICE_TYPE_B = 1, 67 SLICE_TYPE_I = 2 68 }; 69 70 //////////////////////////////////////////////////////////////////////////////// 71 // this enumeration is used to define Intra MB mode 72 /////////////////////////////////////////////////////////////////////////////// 73 enum //for IntraMbMode Field 74 { 75 INTRA_MB_MODE_16x16 = 0, 76 INTRA_MB_MODE_8x8 = 1, 77 INTRA_MB_MODE_4x4 = 2, 78 INTRA_MB_MODE_IPCM = 3, 79 }; 80 81 //////////////////////////////////////////////////////////////////////////////// 82 // this enumeration is used to define Intra MB Type 83 /////////////////////////////////////////////////////////////////////////////// 84 enum //Intra MbType 85 { 86 MBTYPE_I_4x4 = 0, 87 MBTYPE_I_8x8 = 0, 88 MBTYPE_I_16x16_000 = 1, 89 MBTYPE_I_16x16_100 = 2, 90 MBTYPE_I_16x16_200 = 3, 91 MBTYPE_I_16x16_300 = 4, 92 MBTYPE_I_16x16_010 = 5, 93 MBTYPE_I_16x16_110 = 6, 94 MBTYPE_I_16x16_210 = 7, 95 MBTYPE_I_16x16_310 = 8, 96 MBTYPE_I_16x16_020 = 0, 97 MBTYPE_I_16x16_120 = 0xA, 98 MBTYPE_I_16x16_220 = 0xB, 99 MBTYPE_I_16x16_320 = 0xC, 100 MBTYPE_I_16x16_001 = 0xD, 101 MBTYPE_I_16x16_101 = 0xE, 102 MBTYPE_I_16x16_201 = 0xF, 103 MBTYPE_I_16x16_301 = 0x10, 104 MBTYPE_I_16x16_011 = 0x11, 105 MBTYPE_I_16x16_111 = 0x12, 106 MBTYPE_I_16x16_211 = 0x13, 107 MBTYPE_I_16x16_311 = 0x14, 108 MBTYPE_I_16x16_021 = 0x15, 109 MBTYPE_I_16x16_121 = 0x16, 110 MBTYPE_I_16x16_221 = 0x17, 111 MBTYPE_I_16x16_321 = 0x18, 112 MBTYPE_I_IPCM = 0x19, 113 }; 114 115 //////////////////////////////////////////////////////////////////////////////// 116 // this enumeration is used to define Inter MB Type 117 /////////////////////////////////////////////////////////////////////////////// 118 enum //Inter MbType 119 { 120 MBTYPE_BP_L0_16x16 = 1, 121 MBTYPE_B_L1_16x16 = 2, 122 MBTYPE_B_Bi_16x16 = 3, 123 MBTYPE_BP_L0_L0_16x8 = 4, 124 MBTYPE_BP_L0_L0_8x16 = 5, 125 MBTYPE_B_L1_L1_16x8 = 6, 126 MBTYPE_B_L1_L1_8x16 = 7, 127 MBTYPE_B_L0_L1_16x8 = 8, 128 MBTYPE_B_L0_L1_8x16 = 9, 129 MBTYPE_B_L1_L0_16x8 = 0xA, 130 MBTYPE_B_L1_L0_8x16 = 0xB, 131 MBTYPE_B_L0_Bi_16x8 = 0xC, 132 MBTYPE_B_L0_Bi_8x16 = 0xD, 133 MBTYPE_B_L1_Bi_16x8 = 0xE, 134 MBTYPE_B_L1_Bi_8x16 = 0xF, 135 MBTYPE_B_Bi_L0_16x8 = 0x10, 136 MBTYPE_B_Bi_L0_8x16 = 0x11, 137 MBTYPE_B_Bi_L1_16x8 = 0x12, 138 MBTYPE_B_Bi_L1_8x16 = 0x13, 139 MBTYPE_B_Bi_Bi_16x8 = 0x14, 140 MBTYPE_B_Bi_Bi_8x16 = 0x15, 141 MBTYPE_BP_8x8 = 0x16, 142 }; 143 //////////////////////////////////////////////////////////////////////////////// 144 // this enumeration is used to define MB Type for MPEG2 145 /////////////////////////////////////////////////////////////////////////////// 146 enum 147 { 148 MBTYPE_I = 0x1A, 149 MBTYPE_P_FWD_SKIP = 0x01, 150 MBTYPE_B_BWD_SKIP = 0x02, 151 MBTYPE_B_Bi_SKIP = 0x03, 152 MBTYPE_P_0MV = 0x01, 153 MBTYPE_P_FRM_FRM = 0x01, 154 MBTYPE_P_FRM_FLD = 0x04, 155 MBTYPE_P_FRM_DUALPRIME = 0x19, 156 MBTYPE_P_FLD_1_16x16 = 0x01, 157 MBTYPE_P_FLD_2_16x8 = 0x04, 158 MBTYPE_P_FLD_DUALPRIME = 0x19, 159 MBTYPE_B_FRM_FRM_FWD = 0x01, 160 MBTYPE_B_FRM_FRM_BWD = 0x02, 161 MBTYPE_B_FRM_FRM_Bi = 0x03, 162 MBTYPE_B_FRM_FLD_FWD = 0x04, 163 MBTYPE_B_FRM_FLD_BWD = 0x03, 164 MBTYPE_B_FRM_FLD_Bi = 0x14, 165 MBTYPE_B_FLD_1_16x16_FWD = 0x01, 166 MBTYPE_B_FLD_1_16x16_BWD = 0x02, 167 MBTYPE_B_FLD_1_16x16_Bi = 0x03, 168 MBTYPE_B_FLD_2_16x8_FWD = 0x04, 169 MBTYPE_B_FLD_2_16x8_BWD = 0x06, 170 MBTYPE_B_FLD_2_16x8_Bi = 0x14, 171 }; 172 173 //////////////////////////////////////////////////////////////////////////////// 174 // this enumeration is used to define Inter MB block size 175 /////////////////////////////////////////////////////////////////////////////// 176 enum 177 { 178 INTER_MB_MODE_16x16 = 0, 179 INTER_MB_MODE_16x8 = 1, 180 INTER_MB_MODE_8x16 = 2, 181 INTER_MB_MODE_8x8 = 3, 182 }; 183 184 //////////////////////////////////////////////////////////////////////////////// 185 // this enumeration is used to define inter MB sub partition shape in a 8x8 block 186 /////////////////////////////////////////////////////////////////////////////// 187 enum 188 { 189 SUB_MB_SHAPE_8x8 = 0, 190 SUB_MB_SHAPE_8x4 = 1, 191 SUB_MB_SHAPE_4x8 = 2, 192 SUB_MB_SHAPE_4x4 = 3, 193 }; 194 195 //////////////////////////////////////////////////////////////////////////////// 196 // this enumeration is used to define the Inter MB prediction type 197 /////////////////////////////////////////////////////////////////////////////// 198 enum 199 { 200 SUB_MB_PRED_MODE_L0 = 0, 201 SUB_MB_PRED_MODE_L1 = 1, 202 SUB_MB_PRED_MODE_Bi = 2, 203 }; 204 205 //////////////////////////////////////////////////////////////////////////////// 206 // this structure is used to define the control structure for VME. 207 // in Linux this structure is a proxy between MediaSDK and libVA 208 /////////////////////////////////////////////////////////////////////////////// 209 210 typedef struct tagENCODE_CAPS 211 { 212 union 213 { 214 struct 215 { 216 UINT CodingLimitSet : 1; 217 UINT NoFieldFrame : 1; 218 UINT NoCabacSupport : 1; 219 UINT NoGapInFrameCount : 1; 220 UINT NoGapInPicOrder : 1; 221 UINT NoUnpairedField : 1; 222 UINT BitDepth8Only : 1; 223 UINT ConsecutiveMBs : 1; 224 UINT SliceStructure : 3; 225 UINT SliceIPOnly : 1; 226 UINT SliceIPBOnly : 1; 227 UINT NoWeightedPred : 1; 228 UINT NoMinorMVs : 1; 229 UINT ClosedGopOnly : 1; 230 UINT NoFrameCropping : 1; 231 UINT FrameLevelRateCtrl : 1; 232 UINT HeaderInsertion : 1; 233 UINT RawReconRefToggle : 1; // doesn't shpport change reference frame (original vs. recon) at a per frame basis. 234 UINT NoPAFF : 1; // doesn't support change frame/field coding at per frame basis. 235 UINT NoInterlacedField : 1; 236 UINT BRCReset : 1; 237 UINT EnhancedEncInput : 1; 238 UINT RollingIntraRefresh : 1; 239 UINT UserMaxFrameSizeSupport : 1; 240 UINT LayerLevelRateCtrl : 1; 241 UINT SliceLevelRateCtrl : 1; 242 UINT VCMBitrateControl : 1; 243 UINT NoESS : 1; 244 UINT Color420Only : 1; 245 UINT ICQBRCSupport : 1; 246 }; 247 UINT CodingLimits; 248 }; 249 union 250 { 251 struct 252 { 253 USHORT EncFunc : 1; 254 USHORT PakFunc : 1; 255 USHORT EncodeFunc : 1; // Enc+Pak 256 USHORT InputAnalysisFunc : 1; // Reserved for now 257 USHORT reserved :12; 258 }; 259 USHORT CodingFunction; 260 }; 261 UINT vaTrellisQuantization; 262 UINT vaRollingIntraRefresh; 263 UINT vaBufferMaxFrameSize; 264 UINT MaxPicWidth; 265 UINT MaxPicHeight; 266 UCHAR MaxNum_Reference; 267 UCHAR MaxNum_SPS_id; 268 UCHAR MaxNum_PPS_id; 269 UCHAR MaxNum_Reference1; 270 UCHAR MaxNum_QualityLayer; 271 UCHAR MaxNum_DependencyLayer; 272 UCHAR MaxNum_DQLayer; 273 UCHAR MaxNum_TemporalLayer; 274 UCHAR MBBRCSupport; 275 276 UCHAR TrelisQuantization; 277 union { 278 struct { 279 UCHAR MaxNumOfROI : 5; // [0..16] 280 UCHAR : 1; 281 UCHAR ROIBRCPriorityLevelSupport : 1; 282 UCHAR ROIBRCDeltaQPLevelSupport : 1; 283 }; 284 UCHAR ROICaps; 285 }; 286 287 union { 288 struct { 289 UINT RoundingOffset : 1; 290 UINT SkipFrame : 1; 291 UINT MbQpDataSupport : 1; 292 UINT SliceLevelWeightedPred : 1; 293 UINT LumaWeightedPred : 1; 294 UINT ChromaWeightedPred : 1; 295 UINT QVBRBRCSupport : 1; 296 UINT SliceLevelReportSupport : 1; 297 UINT HMEOffsetSupport : 1; 298 UINT DirtyRectSupport : 1; 299 UINT MoveRectSupport : 1; 300 UINT FrameSizeToleranceSupport : 1; // eFrameSizeTolerance_Low (Sliding window) supported 301 UINT HWCounterAutoIncrementSupport : 2; 302 UINT MBControlSupport : 1; 303 UINT ForceReparationCheckSupport : 1; 304 UINT CustomRoundingControl : 1; 305 UINT LLCStreamingBufferSupport : 1; 306 UINT DDRStreamingBufferSupport : 1; 307 UINT LowDelayBRCSupport : 1; // eFrameSizeTolerance_ExtremelyLow (Low delay) supported 308 UINT MaxNumDeltaQPMinus1 : 4; 309 UINT TCBRCSupport : 1; 310 UINT HRDConformanceSupport : 1; 311 UINT PollingModeSupport : 1; 312 UINT : 5; 313 }; 314 UINT CodingLimits2; 315 }; 316 UCHAR MaxNum_WeightedPredL0; 317 UCHAR MaxNum_WeightedPredL1; 318 } ENCODE_CAPS; 319 320 // We cannot modify ENCODE_CAPS structure, but need to add new features 321 struct MFX_ENCODE_CAPS 322 { 323 ENCODE_CAPS ddi_caps; 324 //bitrate control capabilities provided by MSDK 325 bool CQPSupport; 326 bool CBRSupport; 327 bool VBRSupport; 328 bool AVBRSupport; 329 330 bool AdaptiveMaxFrameSizeSupport; 331 }; 332 333 // this enumeration is used to define the block size for intra prediction. they 334 // are used as bit flags to control what block size will be checked for intra 335 // prediction. 336 /////////////////////////////////////////////////////////////////////////////// 337 enum 338 { 339 ENC_INTRA_BLOCK_NONE = 0, 340 ENC_INTRA_BLOCK_4x4 = (1 << 0), 341 ENC_INTRA_BLOCK_8x8 = (1 << 1), 342 ENC_INTRA_BLOCK_16x16 = (1 << 2), 343 ENC_INTRA_BLOCK_PCM = (1 << 3), 344 ENC_INTRA_BLOCK_NOPCM = (ENC_INTRA_BLOCK_4x4 | 345 ENC_INTRA_BLOCK_8x8 | 346 ENC_INTRA_BLOCK_16x16), 347 ENC_INTRA_BLOCK_ALL = (ENC_INTRA_BLOCK_4x4 | 348 ENC_INTRA_BLOCK_8x8 | 349 ENC_INTRA_BLOCK_16x16| 350 ENC_INTRA_BLOCK_PCM), 351 }; 352 353 354 //////////////////////////////////////////////////////////////////////////////// 355 // this enumeration is used to define the cost type used in intra/inter prediction. 356 /////////////////////////////////////////////////////////////////////////////// 357 enum 358 { 359 ENC_COST_TYPE_NONE = 0, 360 ENC_COST_TYPE_SAD = (1 << 0), //sum of absolute difference 361 ENC_COST_TYPE_SSD = (1 << 1), //sum of squared difference 362 ENC_COST_TYPE_SATD_HADAMARD = (1 << 2), //sum of absolute hadamard transformed difference 363 ENC_COST_TYPE_SATD_HARR = (1 << 3), //sum of absolute harr transformed difference 364 ENC_COST_TYPE_PROPRIETARY = (1 << 4), //propriteary cost type 365 }; 366 367 368 //////////////////////////////////////////////////////////////////////////////// 369 // this enumeration is used to define the entropy coding type used for RDO 370 // intra/inter prediction. 371 /////////////////////////////////////////////////////////////////////////////// 372 enum 373 { 374 ENC_ENTROPY_CODING_VLC = 0, //vlc 375 ENC_ENTROPY_CODING_CABAC = 1, //cabac 376 }; 377 378 //////////////////////////////////////////////////////////////////////////////// 379 // this enumeration is used to define the integer pel search algorithm. 380 /////////////////////////////////////////////////////////////////////////////// 381 enum 382 { 383 ENC_INTER_SEARCH_TYPE_NONE = 0, 384 ENC_INTER_SEARCH_TYPE_FULL = (1 << 0), 385 ENC_INTER_SEARCH_TYPE_UMH = (1 << 1), 386 ENC_INTER_SEARCH_TYPE_LOG = (1 << 2), 387 ENC_INTER_SEARCH_TYPE_TTS = (1 << 3), 388 ENC_INTER_SEARCH_TYPE_SQUARE = (1 << 4), 389 ENC_INTER_SEARCH_TYPE_DIAMOND = (1 << 5), 390 ENC_INTER_SEARCH_TYPE_PROPRIETARY = (1 << 6), 391 }; 392 393 //////////////////////////////////////////////////////////////////////////////// 394 // this enumeration is used to define the inter prediction block size. they are 395 // used as bit flags to control what block size should be checked in inter 396 // prediction. 397 // this also controls how many MV can exist in one MB. 398 /////////////////////////////////////////////////////////////////////////////// 399 enum 400 { 401 ENC_INTER_BLOCK_SIZE_NONE = 0, 402 ENC_INTER_BLOCK_SIZE_16x16 = (1 << 0), 403 ENC_INTER_BLOCK_SIZE_16x8 = (1 << 1), 404 ENC_INTER_BLOCK_SIZE_8x16 = (1 << 2), 405 ENC_INTER_BLOCK_SIZE_8x8 = (1 << 3), 406 ENC_INTER_BLOCK_SIZE_8x4 = (1 << 4), 407 ENC_INTER_BLOCK_SIZE_4x8 = (1 << 5), 408 ENC_INTER_BLOCK_SIZE_4x4 = (1 << 6), 409 410 //all possible size 411 ENC_INTER_BLOCK_SIZE_ALL = (ENC_INTER_BLOCK_SIZE_16x16 | 412 ENC_INTER_BLOCK_SIZE_16x8 | 413 ENC_INTER_BLOCK_SIZE_8x16 | 414 ENC_INTER_BLOCK_SIZE_8x8 | 415 ENC_INTER_BLOCK_SIZE_8x4 | 416 ENC_INTER_BLOCK_SIZE_4x8 | 417 ENC_INTER_BLOCK_SIZE_4x4), 418 419 //blocks are bigger than or equal 8x8 420 ENC_INTER_BLOCK_SIZE_NO_MINOR = (ENC_INTER_BLOCK_SIZE_16x16 | 421 ENC_INTER_BLOCK_SIZE_16x8 | 422 ENC_INTER_BLOCK_SIZE_8x16 | 423 ENC_INTER_BLOCK_SIZE_8x8), 424 425 //VC-1 4-MV mode, for P frame only 426 ENC_INTER_BLOCK_SIZE_VC1_4MV = (ENC_INTER_BLOCK_SIZE_16x16 | 427 ENC_INTER_BLOCK_SIZE_8x8), 428 429 //VC-1 1-MV mode, for P and B frame 430 ENC_INTER_BLOCK_SIZE_VC1_1MV = ENC_INTER_BLOCK_SIZE_16x16, 431 432 //MPEG2 1-MV mode, for P and B frame 433 ENC_INTER_BLOCK_SIZE_MPEG_1MV = ENC_INTER_BLOCK_SIZE_16x16, 434 435 }; 436 437 438 //////////////////////////////////////////////////////////////////////////////// 439 // this enumeration is used to define the interpolation methods used to get the 440 // sub pixels. 441 // 442 // WMV4TAP: for 1/2 pel [-1, 9, 9, -1]/16 443 // for 1/4 pel [-4, 53, 18, -3]/64 444 // for 3/4 pel [-3, 18, 53, -4]/64 445 // 446 // VME4TAP: for 1/2 pel [-1, 5, 5, -1]/8 447 // for 1/4 pel [-1, 13, 5, -1]/16 448 // for 3/4 pel [-1, 5, 13, -1]/16 449 // 450 // BILINEAR: for 1/2 pel [0, 1, 1, 0]/2 451 // for 1/4 pel [0, 3, 1, 0]/4 452 // for 3/4 pel [0, 1, 3, 0]/4 453 // 454 // AVC6TAP: for 1/2 pel [1, -5, 20, 20, -5, 1]/32 455 // for 1/4 pel [1, -5, 52, 20, -5, 1]/64 456 // for 3/4 pel [1, -5, 20, 52, -5, 1]/64 457 // 458 /////////////////////////////////////////////////////////////////////////////// 459 enum 460 { 461 ENC_INTERPOLATION_TYPE_NONE = 0, 462 ENC_INTERPOLATION_TYPE_VME4TAP = (1 << 0), 463 ENC_INTERPOLATION_TYPE_BILINEAR = (1 << 1), 464 ENC_INTERPOLATION_TYPE_WMV4TAP = (1 << 2), 465 ENC_INTERPOLATION_TYPE_AVC6TAP = (1 << 3), 466 }; 467 468 //////////////////////////////////////////////////////////////////////////////// 469 // this enumeration is used to define the MV precision. 470 /////////////////////////////////////////////////////////////////////////////// 471 enum 472 { 473 ENC_MV_PRECISION_NONE = 0, 474 ENC_MV_PRECISION_INTEGER = (1 << 0), 475 ENC_MV_PRECISION_HALFPEL = (1 << 1), 476 ENC_MV_PRECISION_QUARTERPEL = (1 << 2), 477 }; 478 479 typedef struct tagENCODE_ENC_CTRL_CAPS 480 { 481 //DW 0 482 UINT IntraPredBlockSize : 4; 483 UINT IntraPredCostType : 5; 484 UINT InterPredBlockSize : 8; 485 UINT MVPrecision : 4; 486 UINT MBZ0 : 11; 487 488 //DW 1 489 UINT MECostType : 5; 490 UINT MESearchType : 8; 491 UINT MBZ1 : 19; 492 493 //DW 2 494 UINT MVSearchWindowX : 16; 495 UINT MVSearchWindowY : 16; 496 497 //DW 3 498 UINT MEInterpolationMethod : 4; 499 UINT MaxMVs : 6; 500 UINT SkipCheck : 1; 501 UINT DirectCheck : 1; 502 UINT BiDirSearch : 1; 503 UINT MBAFF : 1; 504 UINT FieldPrediction : 1; 505 UINT RefOppositeField : 1; 506 UINT ChromaInME : 1; 507 UINT WeightedPrediction : 1; 508 UINT RateDistortionOpt : 1; 509 UINT MVPrediction : 1; 510 UINT DirectVME : 1; 511 UINT MBZ2 : 5; 512 UINT MAD : 1; 513 UINT MBZ3 : 5; 514 515 } ENCODE_ENC_CTRL_CAPS; 516 517 518 //////////////////////////////////////////////////////////////////////////////// 519 // this structure is used to define the sequence level parameters 520 /////////////////////////////////////////////////////////////////////////////// 521 typedef enum tagENCODE_ARGB_COLOR 522 { 523 eColorSpace_P709 = 0, 524 eColorSpace_P601 = 1, 525 eColorSpace_P2020 = 2 526 }ENCODE_ARGB_COLOR; 527 528 typedef enum tagENCODE_FRAME_SIZE_TOLERANCE 529 { 530 eFrameSizeTolerance_Normal = 0,//default 531 eFrameSizeTolerance_Low = 1,//Sliding Window 532 eFrameSizeTolerance_ExtremelyLow = 2//low delay 533 }ENCODE_FRAME_SIZE_TOLERANCE; 534 535 typedef enum tagENCODE_SCENARIO 536 { 537 eScenario_Unknown = 0, 538 eScenario_DisplayRemoting = 1, 539 eScenario_VideoConference = 2, 540 eScenario_Archive = 3, 541 eScenario_LiveStreaming = 4, 542 eScenario_VideoCapture = 5, 543 eScenario_VideoSurveillance = 6 544 } ENCODE_SCENARIO; 545 546 typedef enum tagENCODE_CONTENT 547 { 548 eContent_Unknown = 0, 549 eContent_FullScreenVideo = 1, 550 eContent_NonVideoScreen = 2 551 } ENCODE_CONTENT; 552 553 typedef struct tagENCODE_SET_SEQUENCE_PARAMETERS_H264 554 { 555 USHORT FrameWidth; 556 USHORT FrameHeight; 557 UCHAR Profile; 558 UCHAR Level; 559 560 USHORT GopPicSize; 561 UCHAR GopRefDist; 562 UCHAR GopOptFlag : 2; 563 UCHAR Reserved2 : 6; 564 565 UCHAR TargetUsage; 566 UCHAR RateControlMethod; 567 UINT TargetBitRate; 568 UINT MaxBitRate; 569 UINT MinBitRate; 570 USHORT FramesPer100Sec; 571 ULONG InitVBVBufferFullnessInBit; 572 ULONG VBVBufferSizeInBit; 573 UCHAR NumRefFrames; 574 575 UCHAR seq_parameter_set_id; 576 UCHAR chroma_format_idc; 577 UCHAR bit_depth_luma_minus8; 578 UCHAR bit_depth_chroma_minus8; 579 UCHAR log2_max_frame_num_minus4; 580 UCHAR pic_order_cnt_type; 581 UCHAR log2_max_pic_order_cnt_lsb_minus4; 582 UCHAR num_ref_frames_in_pic_order_cnt_cycle; 583 INT offset_for_non_ref_pic; 584 INT offset_for_top_to_bottom_field; 585 INT offset_for_ref_frame[256]; 586 USHORT frame_crop_left_offset; 587 USHORT frame_crop_right_offset; 588 USHORT frame_crop_top_offset; 589 USHORT frame_crop_bottom_offset; 590 USHORT seq_scaling_matrix_present_flag : 1; 591 USHORT seq_scaling_list_present_flag : 1; 592 USHORT delta_pic_order_always_zero_flag : 1; 593 USHORT frame_mbs_only_flag : 1; 594 USHORT direct_8x8_inference_flag : 1; 595 USHORT vui_parameters_present_flag : 1; 596 USHORT frame_cropping_flag : 1; 597 USHORT EnableSliceLevelRateCtrl : 1; 598 USHORT MBZ1 : 8; 599 600 union 601 { 602 struct 603 { 604 UINT bResetBRC : 1; 605 UINT bNoAccelerationSPSInsertion : 1; 606 UINT GlobalSearch : 2; 607 UINT LocalSearch : 4; 608 UINT EarlySkip : 2; 609 UINT Trellis : 2; 610 UINT MBBRC : 4; 611 UINT bReserved :16; 612 }; 613 614 UINT sFlags; 615 }; 616 617 UINT UserMaxFrameSize; 618 USHORT ICQQualityFactor; 619 620 ENCODE_ARGB_COLOR ARGB_input_color; 621 ENCODE_SCENARIO scenario_info; 622 ENCODE_CONTENT content_info; 623 ENCODE_FRAME_SIZE_TOLERANCE frame_size_tolerance; 624 625 } ENCODE_SET_SEQUENCE_PARAMETERS_H264; 626 627 typedef struct tagENCODE_SET_SEQUENCE_PARAMETERS_MPEG2 628 { 629 USHORT FrameWidth; 630 USHORT FrameHeight; 631 UCHAR Profile; 632 UCHAR Level; 633 UCHAR ChromaFormat; 634 UCHAR TargetUsage; 635 636 637 // ENC + PAK related parameters 638 union 639 { 640 USHORT AratioFrate; 641 struct 642 { 643 USHORT AspectRatio : 4; 644 USHORT FrameRateCode : 4; 645 USHORT FrameRateExtN : 3; 646 USHORT FrameRateExtD : 5; 647 }; 648 }; 649 650 UINT bit_rate; // bits/sec 651 UINT vbv_buffer_size; // 16 Kbit 652 653 UCHAR progressive_sequence : 1; 654 UCHAR low_delay : 1; 655 UCHAR bResetBRC : 1; 656 UCHAR bNoSPSInsertion : 1; 657 UCHAR Reserved : 4; 658 UCHAR RateControlMethod; 659 USHORT Reserved16bits; 660 UINT MaxBitRate; 661 UINT MinBitRate; 662 UINT UserMaxFrameSize; 663 UINT InitVBVBufferFullnessInBit; 664 USHORT AVBRAccuracy; 665 USHORT AVBRConvergence; 666 } ENCODE_SET_SEQUENCE_PARAMETERS_MPEG2; 667 668 669 /* H.264/AVC picture entry data structure */ 670 typedef struct _ENCODE_PICENTRY { 671 union { 672 struct { 673 UCHAR Index7Bits : 7; 674 UCHAR AssociatedFlag : 1; 675 }; 676 UCHAR bPicEntry; 677 }; 678 } ENCODE_PICENTRY; /* 1 byte */ 679 680 typedef struct tagENCODE_RECT 681 { 682 USHORT Top; // [0..(FrameHeight+ M-1)/M -1] 683 USHORT Bottom; // [0..(FrameHeight+ M-1)/M -1] 684 USHORT Left; // [0..(FrameWidth+15)/16-1] 685 USHORT Right; // [0..(FrameWidth+15)/16-1] 686 } ENCODE_RECT; 687 688 typedef struct tagENCODE_ROI 689 { 690 ENCODE_RECT Roi; 691 CHAR PriorityLevelOrDQp; // [-3..3] or [-51..51] 692 } ENCODE_ROI; 693 694 typedef struct tagMOVE_RECT 695 { 696 USHORT SourcePointX; 697 USHORT SourcePointY; 698 ENCODE_RECT DestRect; 699 } MOVE_RECT; 700 701 702 typedef struct tagENCODE_SET_PICTURE_PARAMETERS_H264 703 { 704 ENCODE_PICENTRY CurrOriginalPic; 705 ENCODE_PICENTRY CurrReconstructedPic; 706 UCHAR CodingType; 707 708 UCHAR FieldCodingFlag : 1; 709 UCHAR FieldFrameCodingFlag : 1; 710 UCHAR MBZ0 : 2; 711 UCHAR InterleavedFieldBFF : 1; 712 UCHAR ProgressiveField : 1; 713 UCHAR MBZ1 : 2; 714 715 UCHAR NumSlice; 716 CHAR QpY; 717 ENCODE_PICENTRY RefFrameList[16]; 718 UINT UsedForReferenceFlags; 719 INT CurrFieldOrderCnt[2]; 720 INT FieldOrderCntList[16][2]; 721 USHORT frame_num; 722 BOOL bLastPicInSeq; 723 BOOL bLastPicInStream; 724 union 725 { 726 struct 727 { 728 UINT bUseRawPicForRef : 1; 729 UINT bDisableHeaderPacking : 1; 730 UINT bEnableDVMEChromaIntraPrediction : 1; 731 UINT bEnableDVMEReferenceLocationDerivation : 1; 732 UINT bEnableDVMWSkipCentersDerivation : 1; 733 UINT bEnableDVMEStartCentersDerivation : 1; 734 UINT bEnableDVMECostCentersDerivation : 1; 735 UINT bDisableSubMBPartition : 1; 736 UINT bEmulationByteInsertion : 1; 737 UINT bEnableRollingIntraRefresh : 2; 738 UINT bReserved : 21; 739 740 }; 741 BOOL UserFlags; 742 }; 743 UINT StatusReportFeedbackNumber; 744 UCHAR bIdrPic; 745 UCHAR pic_parameter_set_id; 746 UCHAR seq_parameter_set_id; 747 UCHAR num_ref_idx_l0_active_minus1; 748 UCHAR num_ref_idx_l1_active_minus1; 749 CHAR chroma_qp_index_offset; 750 CHAR second_chroma_qp_index_offset; 751 USHORT entropy_coding_mode_flag : 1; 752 USHORT pic_order_present_flag : 1; 753 USHORT weighted_pred_flag : 1; 754 USHORT weighted_bipred_idc : 2; 755 USHORT constrained_intra_pred_flag : 1; 756 USHORT transform_8x8_mode_flag : 1; 757 USHORT pic_scaling_matrix_present_flag : 1; 758 USHORT pic_scaling_list_present_flag : 1; 759 USHORT RefPicFlag : 1; 760 USHORT BRCPrecision : 2; 761 USHORT MBZ2 : 4; 762 USHORT IntraInsertionLocation; 763 USHORT IntraInsertionSize; 764 CHAR QpDeltaForInsertedIntra; 765 UINT SliceSizeInBytes; 766 767 } ENCODE_SET_PICTURE_PARAMETERS_H264; 768 769 typedef struct tagENCODE_SET_PICTURE_PARAMETERS_MPEG2 770 { 771 ENCODE_PICENTRY CurrOriginalPic; 772 ENCODE_PICENTRY CurrReconstructedPic; 773 UCHAR picture_coding_type; 774 UCHAR FieldCodingFlag : 1; 775 UCHAR FieldFrameCodingFlag : 1; 776 UCHAR MBZ0 : 2; 777 UCHAR InterleavedFieldBFF : 1; 778 UCHAR ProgressiveField : 1; 779 UCHAR MBZ1 : 2; 780 UCHAR NumSlice; 781 UCHAR bPicBackwardPrediction; 782 UCHAR bBidirectionalAveragingMode; 783 UCHAR bPic4MVallowed; 784 ENCODE_PICENTRY RefFrameList[2]; 785 union 786 { 787 struct 788 { 789 UINT bUseRawPicForRef : 1; 790 UINT bDisableHeaderPacking : 1; 791 UINT bEnableDVMEChromaIntraPrediction : 1; 792 UINT bEnableDVMEReferenceLocationDerivation : 1; 793 UINT bEnableDVMESkipCentersDerivation : 1; 794 UINT bEnableDVMEStartCentersDerivation : 1; 795 UINT bEnableDVMECostCentersDerivation : 1; 796 UINT bReserved : 25; 797 }; 798 BOOL UserFlags; 799 }; 800 UINT StatusReportFeedbackNumber; 801 UINT alternate_scan : 1; 802 UINT intra_vlc_format : 1; 803 UINT q_scale_type : 1; 804 UINT concealment_motion_vectors : 1; 805 UINT frame_pred_frame_dct : 1; 806 807 808 809 UINT DisableMismatchControl : 1; 810 UINT intra_dc_precision : 2; 811 UINT f_code00 : 4; 812 UINT f_code01 : 4; 813 UINT f_code10 : 4; 814 UINT f_code11 : 4; 815 816 817 UINT Reserved1 : 8; 818 819 // ENC + PAK related parameters 820 BOOL bLastPicInStream; 821 BOOL bNewGop; 822 823 USHORT GopPicSize; 824 UCHAR GopRefDist; 825 UCHAR GopOptFlag : 2; 826 UCHAR : 6; 827 828 UINT time_code : 25; 829 UINT : 7; 830 831 USHORT temporal_reference : 10; 832 USHORT : 6; 833 834 USHORT vbv_delay; 835 836 UINT repeat_first_field : 1; 837 UINT composite_display_flag : 1; 838 UINT v_axis : 1; 839 UINT field_sequence : 3; 840 UINT sub_carrier : 1; 841 UINT burst_amplitude : 7; 842 UINT sub_carrier_phase : 8; 843 UINT : 10; 844 845 846 } ENCODE_SET_PICTURE_PARAMETERS_MPEG2; 847 848 typedef struct tagENCODE_SET_SLICE_HEADER_H264 849 { 850 UINT NumMbsForSlice; 851 ENCODE_PICENTRY RefPicList[2][32]; 852 SHORT Weights[2][32][3][2]; 853 UINT first_mb_in_slice; 854 855 UCHAR slice_type; 856 UCHAR pic_parameter_set_id; 857 USHORT direct_spatial_mv_pred_flag : 1; 858 USHORT num_ref_idx_active_override_flag : 1; 859 USHORT long_term_reference_flag : 1; 860 USHORT MBZ0 : 13; 861 USHORT idr_pic_id; 862 USHORT pic_order_cnt_lsb; 863 INT delta_pic_order_cnt_bottom; 864 INT delta_pic_order_cnt[2]; 865 UCHAR num_ref_idx_l0_active_minus1; 866 UCHAR num_ref_idx_l1_active_minus1; 867 UCHAR luma_log2_weight_denom; 868 UCHAR chroma_log2_weight_denom; 869 UCHAR cabac_init_idc; 870 CHAR slice_qp_delta; 871 UCHAR disable_deblocking_filter_idc; 872 CHAR slice_alpha_c0_offset_div2; 873 CHAR slice_beta_offset_div2; 874 UINT slice_id; 875 876 } ENCODE_SET_SLICE_HEADER_H264; 877 878 typedef struct tagENCODE_PACKEDHEADER_DATA 879 { 880 UCHAR * pData; 881 UINT BufferSize; 882 UINT DataLength; 883 UINT DataOffset; 884 UINT SkipEmulationByteCount; 885 UINT Reserved; 886 } ENCODE_PACKEDHEADER_DATA; 887 888 typedef struct tagENCODE_SET_SLICE_HEADER_MPEG2 889 { 890 USHORT NumMbsForSlice; 891 USHORT FirstMbX; 892 USHORT FirstMbY; 893 USHORT IntraSlice; 894 UCHAR quantiser_scale_code; 895 } ENCODE_SET_SLICE_HEADER_MPEG2; 896 897 typedef struct 898 { 899 SHORT x; 900 SHORT y; 901 } ENC_MV, ENCODE_MV_DATA; 902 903 typedef struct tagENCODE_ENC_MB_DATA_MPEG2 904 { 905 struct 906 { 907 UINT InterMBMode : 2; 908 UINT SkipMbFlag : 1; 909 UINT MBZ1 : 5; 910 UINT macroblock_type : 5; 911 UINT macroblock_intra : 1; 912 UINT FieldMBFlag : 1; 913 UINT dct_type : 1; 914 UINT MBZ2 : 1; 915 UINT CbpDcV : 1; 916 UINT CbpDcU : 1; 917 UINT CbpDcY : 1; 918 UINT MvFormat : 3; 919 UINT MBZ3 : 1; 920 UINT PackedMvNum : 3; 921 UINT MBZ4 : 5; 922 }; 923 924 struct 925 { 926 UINT MbX : 16; 927 UINT MbY : 16; 928 }; 929 930 struct 931 { 932 UINT coded_block_pattern : 12; 933 UINT MBZ5 : 4; 934 UINT TargetSizeInWord : 8; 935 UINT MaxSizeInWord : 8; 936 }; 937 938 struct 939 { 940 UINT QpScaleCode : 5; 941 UINT MBZ6 : 11; 942 UINT MvFieldSelect : 4; 943 UINT MBZ7 : 4; 944 UINT FirstMbInSG : 1; 945 UINT MbSkipConvDisable : 1; 946 UINT LastMbInSG : 1; 947 UINT EnableCoeffClamp : 1; 948 UINT MBZ8 : 2; 949 UINT FirstMbInSlice : 1; 950 UINT LastMbInSlice : 1; 951 }; 952 953 ENC_MV MVL0[2]; 954 ENC_MV MVL1[2]; 955 UINT reserved[8]; 956 } ENCODE_ENC_MB_DATA_MPEG2; 957 958 typedef struct tagENCODE_ENC_MV_H264 959 { 960 ENC_MV MVL0[16]; 961 ENC_MV MVL1[16]; 962 } ENCODE_ENC_MV_H264; 963 964 typedef struct tagENCODE_MBDATA_LAYOUT 965 { 966 UCHAR MB_CODE_size; 967 UINT MB_CODE_offset; 968 UINT MB_CODE_BottomField_offset; 969 UINT MB_CODE_stride; 970 UCHAR MV_number; 971 UINT MV_offset; 972 UINT MV_BottomField_offset; 973 UINT MV_stride; 974 975 } ENCODE_MBDATA_LAYOUT; 976 977 enum 978 { 979 ENCODE_ENC_ID = 0x100, 980 ENCODE_PAK_ID = 0x101, 981 ENCODE_ENC_PAK_ID = 0x102, 982 ENCODE_VPP_ID = 0x103, // reserved for now 983 984 ENCODE_FORMAT_COUNT_ID = 0x104, 985 ENCODE_FORMATS_ID = 0x105, 986 ENCODE_ENC_CTRL_CAPS_ID = 0x106, 987 ENCODE_ENC_CTRL_GET_ID = 0x107, 988 ENCODE_ENC_CTRL_SET_ID = 0x108, 989 MBDATA_LAYOUT_ID = 0x109, 990 ENCODE_INSERT_DATA_ID = 0x120, 991 ENCODE_QUERY_STATUS_ID = 0x121 992 }; 993 994 #endif /* __MFX_H264_ENCODE_STRUCT_VAAPI__H */ 995 #endif /* MFX_VA_LINUX */ 996 /* EOF */ 997