| 1 | /* |
| 2 | * Copyright (c) 2017, Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included |
| 12 | * in all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | */ |
| 22 | //! |
| 23 | //! \file codechal_encode_mpeg2_g8.cpp |
| 24 | //! \brief MPEG2 dual-pipe encoder for GEN8. |
| 25 | //! |
| 26 | |
| 27 | #include "codechal_encode_mpeg2_g8.h" |
| 28 | #include "igcodeckrn_g8.h" |
| 29 | |
| 30 | struct KernelHeaderMpegG8 |
| 31 | { |
| 32 | uint32_t m_kernelCount; |
| 33 | |
| 34 | // MBEnc Norm/Perf/Quality moes for frame |
| 35 | CODECHAL_KERNEL_HEADER m_mpeg2MbEncI; |
| 36 | CODECHAL_KERNEL_HEADER m_mpeg2MbEncP; |
| 37 | CODECHAL_KERNEL_HEADER m_mpeg2MbEncB; |
| 38 | |
| 39 | // ME Downscale |
| 40 | CODECHAL_KERNEL_HEADER m_plyDscalePly; |
| 41 | |
| 42 | // AVC_ME kernels for distortion |
| 43 | CODECHAL_KERNEL_HEADER m_mpeg2AvcMeP; |
| 44 | CODECHAL_KERNEL_HEADER m_mpeg2AvcMeB; |
| 45 | |
| 46 | CODECHAL_KERNEL_HEADER m_mpeg2InitFrameBrc; |
| 47 | CODECHAL_KERNEL_HEADER m_mpeg2FrameEncUpdate; |
| 48 | CODECHAL_KERNEL_HEADER m_mpeg2BrcResetFrame; |
| 49 | |
| 50 | // BRCBlockCopy |
| 51 | CODECHAL_KERNEL_HEADER m_mpeg2BrcBlockCopy; |
| 52 | }; |
| 53 | |
| 54 | enum BindingTableOffsetMeG8 |
| 55 | { |
| 56 | meMvDataSurface = 0, |
| 57 | meDistortionSurface = 2, |
| 58 | meBrcDistortion = 3, |
| 59 | meCurrForFwdRef = 5, |
| 60 | meFwdRefIdx0 = 6, |
| 61 | meCurrForBwdRef = 22, |
| 62 | meBwdRefIdx0 = 23, |
| 63 | meNumSurface = 27, |
| 64 | }; |
| 65 | |
| 66 | enum BindingTableOffsetMbEncG8 |
| 67 | { |
| 68 | mbEncPakObj = 0, |
| 69 | mbEncPakObjPrev = 1, |
| 70 | mbEncCurrentY = 3, |
| 71 | mbEncBrcDistortionSurface = 8, |
| 72 | mbEncCurrentPic = 9, |
| 73 | mbEncForwardPic = 10, |
| 74 | mbEncBackwardPic = 11, |
| 75 | mbEncInterlaceFrameCurrentPic = 14, |
| 76 | mbEncInterlaceFrameBackwardPic = 15, |
| 77 | mbEncMbControl = 18, |
| 78 | mbEncNumBindingTableEntries = 19 |
| 79 | }; |
| 80 | |
| 81 | class MeCurbeG8 |
| 82 | { |
| 83 | public: |
| 84 | struct CurbeData |
| 85 | { |
| 86 | // DW0 |
| 87 | union |
| 88 | { |
| 89 | struct |
| 90 | { |
| 91 | uint32_t m_skipModeEn : MOS_BITFIELD_BIT(0); |
| 92 | uint32_t m_adaptiveEn : MOS_BITFIELD_BIT(1); |
| 93 | uint32_t m_biMixDis : MOS_BITFIELD_BIT(2); |
| 94 | uint32_t m_reserved3 : MOS_BITFIELD_RANGE(3, 4); |
| 95 | uint32_t m_earlyImeSuccessEn : MOS_BITFIELD_BIT(5); |
| 96 | uint32_t m_reserved6 : MOS_BITFIELD_BIT(6); |
| 97 | uint32_t m_t8x8FlagForInterEn : MOS_BITFIELD_BIT(7); |
| 98 | uint32_t m_reserved8 : MOS_BITFIELD_RANGE(8, 23); |
| 99 | uint32_t m_earlyImeStop : MOS_BITFIELD_RANGE(24, 31); |
| 100 | }; |
| 101 | struct |
| 102 | { |
| 103 | uint32_t m_value; |
| 104 | }; |
| 105 | } DW0; |
| 106 | |
| 107 | // DW1 |
| 108 | union |
| 109 | { |
| 110 | struct |
| 111 | { |
| 112 | uint32_t m_maxNumMVs : MOS_BITFIELD_RANGE(0, 5); |
| 113 | uint32_t m_reserved6 : MOS_BITFIELD_RANGE(6, 15); |
| 114 | uint32_t m_biWeight : MOS_BITFIELD_RANGE(16, 21); |
| 115 | uint32_t m_reserved22 : MOS_BITFIELD_RANGE(22, 27); |
| 116 | uint32_t m_uniMixDisable : MOS_BITFIELD_BIT(28); |
| 117 | uint32_t m_reserved29 : MOS_BITFIELD_RANGE(29, 31); |
| 118 | }; |
| 119 | struct |
| 120 | { |
| 121 | uint32_t m_value; |
| 122 | }; |
| 123 | } DW1; |
| 124 | |
| 125 | // DW2 |
| 126 | union |
| 127 | { |
| 128 | struct |
| 129 | { |
| 130 | uint32_t m_maxLenSP : MOS_BITFIELD_RANGE(0, 7); |
| 131 | uint32_t m_maxNumSU : MOS_BITFIELD_RANGE(8, 15); |
| 132 | uint32_t m_reserved16 : MOS_BITFIELD_RANGE(16, 31); |
| 133 | }; |
| 134 | struct |
| 135 | { |
| 136 | uint32_t m_value; |
| 137 | }; |
| 138 | } DW2; |
| 139 | |
| 140 | // DW3 |
| 141 | union |
| 142 | { |
| 143 | struct |
| 144 | { |
| 145 | uint32_t m_srcSize : MOS_BITFIELD_RANGE(0, 1); |
| 146 | uint32_t m_reserved2 : MOS_BITFIELD_RANGE(2, 3); |
| 147 | uint32_t m_mbTypeRemap : MOS_BITFIELD_RANGE(4, 5); |
| 148 | uint32_t m_srcAccess : MOS_BITFIELD_BIT(6); |
| 149 | uint32_t m_refAccess : MOS_BITFIELD_BIT(7); |
| 150 | uint32_t m_searchCtrl : MOS_BITFIELD_RANGE(8, 10); |
| 151 | uint32_t m_dualSearchPathOption : MOS_BITFIELD_BIT(11); |
| 152 | uint32_t m_subPelMode : MOS_BITFIELD_RANGE(12, 13); |
| 153 | uint32_t m_skipType : MOS_BITFIELD_BIT(14); |
| 154 | uint32_t m_disableFieldCacheAlloc : MOS_BITFIELD_BIT(15); |
| 155 | uint32_t m_interChromaMode : MOS_BITFIELD_BIT(16); |
| 156 | uint32_t m_ftEnable : MOS_BITFIELD_BIT(17); |
| 157 | uint32_t m_bmeDisableFBR : MOS_BITFIELD_BIT(18); |
| 158 | uint32_t m_blockBasedSkipEnable : MOS_BITFIELD_BIT(19); |
| 159 | uint32_t m_interSAD : MOS_BITFIELD_RANGE(20, 21); |
| 160 | uint32_t m_intraSAD : MOS_BITFIELD_RANGE(22, 23); |
| 161 | uint32_t m_subMbPartMask : MOS_BITFIELD_RANGE(24, 30); |
| 162 | uint32_t m_reserved31 : MOS_BITFIELD_BIT(31); |
| 163 | }; |
| 164 | struct |
| 165 | { |
| 166 | uint32_t m_value; |
| 167 | }; |
| 168 | } DW3; |
| 169 | |
| 170 | // DW4 |
| 171 | union |
| 172 | { |
| 173 | struct |
| 174 | { |
| 175 | uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 7); |
| 176 | uint32_t m_pictureHeightMinus1 : MOS_BITFIELD_RANGE(8, 15); |
| 177 | uint32_t m_pictureWidth : MOS_BITFIELD_RANGE(16, 23); |
| 178 | uint32_t m_reserved24 : MOS_BITFIELD_RANGE(24, 31); |
| 179 | }; |
| 180 | struct |
| 181 | { |
| 182 | uint32_t m_value; |
| 183 | }; |
| 184 | } DW4; |
| 185 | |
| 186 | // DW5 |
| 187 | union |
| 188 | { |
| 189 | struct |
| 190 | { |
| 191 | uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 7); |
| 192 | uint32_t m_qpPrimeY : MOS_BITFIELD_RANGE(8, 15); |
| 193 | uint32_t m_refWidth : MOS_BITFIELD_RANGE(16, 23); |
| 194 | uint32_t m_refHeight : MOS_BITFIELD_RANGE(24, 31); |
| 195 | |
| 196 | }; |
| 197 | struct |
| 198 | { |
| 199 | uint32_t m_value; |
| 200 | }; |
| 201 | } DW5; |
| 202 | |
| 203 | // DW6 |
| 204 | union |
| 205 | { |
| 206 | struct |
| 207 | { |
| 208 | uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 2); |
| 209 | uint32_t m_meModes : MOS_BITFIELD_RANGE(3, 4); |
| 210 | uint32_t m_reserved5 : MOS_BITFIELD_RANGE(5, 7); |
| 211 | uint32_t m_superCombineDist : MOS_BITFIELD_RANGE(8, 15); |
| 212 | uint32_t m_maxVmvR : MOS_BITFIELD_RANGE(16, 31); |
| 213 | }; |
| 214 | struct |
| 215 | { |
| 216 | uint32_t m_value; |
| 217 | }; |
| 218 | } DW6; |
| 219 | |
| 220 | // DW7 |
| 221 | union |
| 222 | { |
| 223 | struct |
| 224 | { |
| 225 | uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 15); |
| 226 | uint32_t m_mvCostScaleFactor : MOS_BITFIELD_RANGE(16, 17); |
| 227 | uint32_t m_bilinearEnable : MOS_BITFIELD_BIT(18); |
| 228 | uint32_t m_srcFieldPolarity : MOS_BITFIELD_BIT(19); |
| 229 | uint32_t m_weightedSADHAAR : MOS_BITFIELD_BIT(20); |
| 230 | uint32_t m_acOnlyHAAR : MOS_BITFIELD_BIT(21); |
| 231 | uint32_t m_refIDCostMode : MOS_BITFIELD_BIT(22); |
| 232 | uint32_t m_reserved23 : MOS_BITFIELD_BIT(23); |
| 233 | uint32_t m_skipCenterMask : MOS_BITFIELD_RANGE(24, 31); |
| 234 | }; |
| 235 | struct |
| 236 | { |
| 237 | uint32_t m_value; |
| 238 | }; |
| 239 | } DW7; |
| 240 | |
| 241 | // DW8 |
| 242 | union |
| 243 | { |
| 244 | struct |
| 245 | { |
| 246 | uint32_t m_mode0Cost : MOS_BITFIELD_RANGE(0, 7); |
| 247 | uint32_t m_mode1Cost : MOS_BITFIELD_RANGE(8, 15); |
| 248 | uint32_t m_mode2Cost : MOS_BITFIELD_RANGE(16, 23); |
| 249 | uint32_t m_mode3Cost : MOS_BITFIELD_RANGE(24, 31); |
| 250 | }; |
| 251 | struct |
| 252 | { |
| 253 | uint32_t m_value; |
| 254 | }; |
| 255 | } DW8; |
| 256 | |
| 257 | // DW9 |
| 258 | union |
| 259 | { |
| 260 | struct |
| 261 | { |
| 262 | uint32_t m_mode4Cost : MOS_BITFIELD_RANGE(0, 7); |
| 263 | uint32_t m_mode5Cost : MOS_BITFIELD_RANGE(8, 15); |
| 264 | uint32_t m_mode6Cost : MOS_BITFIELD_RANGE(16, 23); |
| 265 | uint32_t m_mode7Cost : MOS_BITFIELD_RANGE(24, 31); |
| 266 | }; |
| 267 | struct |
| 268 | { |
| 269 | uint32_t m_value; |
| 270 | }; |
| 271 | } DW9; |
| 272 | |
| 273 | // DW10 |
| 274 | union |
| 275 | { |
| 276 | struct |
| 277 | { |
| 278 | uint32_t m_mode8Cost : MOS_BITFIELD_RANGE(0, 7); |
| 279 | uint32_t m_mode9Cost : MOS_BITFIELD_RANGE(8, 15); |
| 280 | uint32_t m_refIDCost : MOS_BITFIELD_RANGE(16, 23); |
| 281 | uint32_t m_chromaIntraModeCost : MOS_BITFIELD_RANGE(24, 31); |
| 282 | }; |
| 283 | struct |
| 284 | { |
| 285 | uint32_t m_value; |
| 286 | }; |
| 287 | } DW10; |
| 288 | |
| 289 | // DW11 |
| 290 | union |
| 291 | { |
| 292 | struct |
| 293 | { |
| 294 | uint32_t m_mv0Cost : MOS_BITFIELD_RANGE(0, 7); |
| 295 | uint32_t m_mv1Cost : MOS_BITFIELD_RANGE(8, 15); |
| 296 | uint32_t m_mv2Cost : MOS_BITFIELD_RANGE(16, 23); |
| 297 | uint32_t m_mv3Cost : MOS_BITFIELD_RANGE(24, 31); |
| 298 | }; |
| 299 | struct |
| 300 | { |
| 301 | uint32_t m_value; |
| 302 | }; |
| 303 | } DW11; |
| 304 | |
| 305 | // DW12 |
| 306 | union |
| 307 | { |
| 308 | struct |
| 309 | { |
| 310 | uint32_t m_mv4Cost : MOS_BITFIELD_RANGE(0, 7); |
| 311 | uint32_t m_mv5Cost : MOS_BITFIELD_RANGE(8, 15); |
| 312 | uint32_t m_mv6Cost : MOS_BITFIELD_RANGE(16, 23); |
| 313 | uint32_t m_mv7Cost : MOS_BITFIELD_RANGE(24, 31); |
| 314 | }; |
| 315 | struct |
| 316 | { |
| 317 | uint32_t m_value; |
| 318 | }; |
| 319 | } DW12; |
| 320 | |
| 321 | // DW13 |
| 322 | union |
| 323 | { |
| 324 | struct |
| 325 | { |
| 326 | uint32_t m_numRefIdxL0MinusOne : MOS_BITFIELD_RANGE(0, 7); |
| 327 | uint32_t m_numRefIdxL1MinusOne : MOS_BITFIELD_RANGE(8, 15); |
| 328 | uint32_t m_actualMBWidth : MOS_BITFIELD_RANGE(16, 23); |
| 329 | uint32_t m_actualMBHeight : MOS_BITFIELD_RANGE(24, 31); |
| 330 | }; |
| 331 | struct |
| 332 | { |
| 333 | uint32_t m_value; |
| 334 | }; |
| 335 | } DW13; |
| 336 | |
| 337 | // DW14 |
| 338 | union |
| 339 | { |
| 340 | struct |
| 341 | { |
| 342 | uint32_t m_list0RefID0FieldParity : MOS_BITFIELD_BIT(0); |
| 343 | uint32_t m_list0RefID1FieldParity : MOS_BITFIELD_BIT(1); |
| 344 | uint32_t m_list0RefID2FieldParity : MOS_BITFIELD_BIT(2); |
| 345 | uint32_t m_list0RefID3FieldParity : MOS_BITFIELD_BIT(3); |
| 346 | uint32_t m_list0RefID4FieldParity : MOS_BITFIELD_BIT(4); |
| 347 | uint32_t m_list0RefID5FieldParity : MOS_BITFIELD_BIT(5); |
| 348 | uint32_t m_list0RefID6FieldParity : MOS_BITFIELD_BIT(6); |
| 349 | uint32_t m_list0RefID7FieldParity : MOS_BITFIELD_BIT(7); |
| 350 | uint32_t m_list1RefID0FieldParity : MOS_BITFIELD_BIT(8); |
| 351 | uint32_t m_list1RefID1FieldParity : MOS_BITFIELD_BIT(9); |
| 352 | uint32_t m_reserved10 : MOS_BITFIELD_RANGE(10, 31); |
| 353 | }; |
| 354 | struct |
| 355 | { |
| 356 | uint32_t m_value; |
| 357 | }; |
| 358 | } DW14; |
| 359 | |
| 360 | // DW15 |
| 361 | union |
| 362 | { |
| 363 | struct |
| 364 | { |
| 365 | uint32_t m_prevMvReadPosFactor : MOS_BITFIELD_RANGE(0, 7); |
| 366 | uint32_t m_mvShiftFactor : MOS_BITFIELD_RANGE(8, 15); |
| 367 | uint32_t m_reserved16 : MOS_BITFIELD_RANGE(16, 31); |
| 368 | }; |
| 369 | struct |
| 370 | { |
| 371 | uint32_t m_value; |
| 372 | }; |
| 373 | } DW15; |
| 374 | |
| 375 | struct |
| 376 | { |
| 377 | // DW16 |
| 378 | union |
| 379 | { |
| 380 | struct |
| 381 | { |
| 382 | SearchPathDelta m_spDelta_0; |
| 383 | SearchPathDelta m_spDelta_1; |
| 384 | SearchPathDelta m_spDelta_2; |
| 385 | SearchPathDelta m_spDelta_3; |
| 386 | }; |
| 387 | struct |
| 388 | { |
| 389 | uint32_t m_value; |
| 390 | }; |
| 391 | } DW16; |
| 392 | |
| 393 | // DW17 |
| 394 | union |
| 395 | { |
| 396 | struct |
| 397 | { |
| 398 | SearchPathDelta m_spDelta_4; |
| 399 | SearchPathDelta m_spDelta_5; |
| 400 | SearchPathDelta m_spDelta_6; |
| 401 | SearchPathDelta m_spDelta_7; |
| 402 | }; |
| 403 | struct |
| 404 | { |
| 405 | uint32_t m_value; |
| 406 | }; |
| 407 | } DW17; |
| 408 | |
| 409 | // DW18 |
| 410 | union |
| 411 | { |
| 412 | struct |
| 413 | { |
| 414 | SearchPathDelta m_spDelta_8; |
| 415 | SearchPathDelta m_spDelta_9; |
| 416 | SearchPathDelta m_spDelta_10; |
| 417 | SearchPathDelta m_spDelta_11; |
| 418 | }; |
| 419 | struct |
| 420 | { |
| 421 | uint32_t m_value; |
| 422 | }; |
| 423 | } DW18; |
| 424 | |
| 425 | // DW19 |
| 426 | union |
| 427 | { |
| 428 | struct |
| 429 | { |
| 430 | SearchPathDelta m_spDelta_12; |
| 431 | SearchPathDelta m_spDelta_13; |
| 432 | SearchPathDelta m_spDelta_14; |
| 433 | SearchPathDelta m_spDelta_15; |
| 434 | }; |
| 435 | struct |
| 436 | { |
| 437 | uint32_t m_value; |
| 438 | }; |
| 439 | } DW19; |
| 440 | |
| 441 | // DW20 |
| 442 | union |
| 443 | { |
| 444 | struct |
| 445 | { |
| 446 | SearchPathDelta m_spDelta_16; |
| 447 | SearchPathDelta m_spDelta_17; |
| 448 | SearchPathDelta m_spDelta_18; |
| 449 | SearchPathDelta m_spDelta_19; |
| 450 | }; |
| 451 | struct |
| 452 | { |
| 453 | uint32_t m_value; |
| 454 | }; |
| 455 | } DW20; |
| 456 | |
| 457 | // DW21 |
| 458 | union |
| 459 | { |
| 460 | struct |
| 461 | { |
| 462 | SearchPathDelta m_spDelta_20; |
| 463 | SearchPathDelta m_spDelta_21; |
| 464 | SearchPathDelta m_spDelta_22; |
| 465 | SearchPathDelta m_spDelta_23; |
| 466 | }; |
| 467 | struct |
| 468 | { |
| 469 | uint32_t m_value; |
| 470 | }; |
| 471 | } DW21; |
| 472 | |
| 473 | // DW22 |
| 474 | union |
| 475 | { |
| 476 | struct |
| 477 | { |
| 478 | SearchPathDelta m_spDelta_24; |
| 479 | SearchPathDelta m_spDelta_25; |
| 480 | SearchPathDelta m_spDelta_26; |
| 481 | SearchPathDelta m_spDelta_27; |
| 482 | }; |
| 483 | struct |
| 484 | { |
| 485 | uint32_t m_value; |
| 486 | }; |
| 487 | } DW22; |
| 488 | |
| 489 | // DW23 |
| 490 | union |
| 491 | { |
| 492 | struct |
| 493 | { |
| 494 | SearchPathDelta m_spDelta_28; |
| 495 | SearchPathDelta m_spDelta_29; |
| 496 | SearchPathDelta m_spDelta_30; |
| 497 | SearchPathDelta m_spDelta_31; |
| 498 | }; |
| 499 | struct |
| 500 | { |
| 501 | uint32_t m_value; |
| 502 | }; |
| 503 | } DW23; |
| 504 | |
| 505 | // DW24 |
| 506 | union |
| 507 | { |
| 508 | struct |
| 509 | { |
| 510 | SearchPathDelta m_spDelta_32; |
| 511 | SearchPathDelta m_spDelta_33; |
| 512 | SearchPathDelta m_spDelta_34; |
| 513 | SearchPathDelta m_spDelta_35; |
| 514 | }; |
| 515 | struct |
| 516 | { |
| 517 | uint32_t m_value; |
| 518 | }; |
| 519 | } DW24; |
| 520 | |
| 521 | // DW25 |
| 522 | union |
| 523 | { |
| 524 | struct |
| 525 | { |
| 526 | SearchPathDelta m_spDelta_36; |
| 527 | SearchPathDelta m_spDelta_37; |
| 528 | SearchPathDelta m_spDelta_38; |
| 529 | SearchPathDelta m_spDelta_39; |
| 530 | }; |
| 531 | struct |
| 532 | { |
| 533 | uint32_t m_value; |
| 534 | }; |
| 535 | } DW25; |
| 536 | |
| 537 | // DW26 |
| 538 | union |
| 539 | { |
| 540 | struct |
| 541 | { |
| 542 | SearchPathDelta m_spDelta_40; |
| 543 | SearchPathDelta m_spDelta_41; |
| 544 | SearchPathDelta m_spDelta_42; |
| 545 | SearchPathDelta m_spDelta_43; |
| 546 | }; |
| 547 | struct |
| 548 | { |
| 549 | uint32_t m_value; |
| 550 | }; |
| 551 | } DW26; |
| 552 | |
| 553 | // DW27 |
| 554 | union |
| 555 | { |
| 556 | struct |
| 557 | { |
| 558 | SearchPathDelta m_spDelta_44; |
| 559 | SearchPathDelta m_spDelta_45; |
| 560 | SearchPathDelta m_spDelta_46; |
| 561 | SearchPathDelta m_spDelta_47; |
| 562 | }; |
| 563 | struct |
| 564 | { |
| 565 | uint32_t m_value; |
| 566 | }; |
| 567 | } DW27; |
| 568 | |
| 569 | // DW28 |
| 570 | union |
| 571 | { |
| 572 | struct |
| 573 | { |
| 574 | SearchPathDelta m_spDelta_48; |
| 575 | SearchPathDelta m_spDelta_49; |
| 576 | SearchPathDelta m_spDelta_50; |
| 577 | SearchPathDelta m_spDelta_51; |
| 578 | }; |
| 579 | struct |
| 580 | { |
| 581 | uint32_t m_value; |
| 582 | }; |
| 583 | } DW28; |
| 584 | |
| 585 | // DW29 |
| 586 | union |
| 587 | { |
| 588 | struct |
| 589 | { |
| 590 | SearchPathDelta m_spDelta_52; |
| 591 | SearchPathDelta m_spDelta_53; |
| 592 | SearchPathDelta m_spDelta_54; |
| 593 | SearchPathDelta m_spDelta_55; |
| 594 | }; |
| 595 | struct |
| 596 | { |
| 597 | uint32_t m_value; |
| 598 | }; |
| 599 | } DW29; |
| 600 | } SpDelta; |
| 601 | |
| 602 | // DW30 |
| 603 | union |
| 604 | { |
| 605 | struct |
| 606 | { |
| 607 | uint32_t m_reserved; |
| 608 | }; |
| 609 | struct |
| 610 | { |
| 611 | uint32_t m_value; |
| 612 | }; |
| 613 | } DW30; |
| 614 | |
| 615 | // DW31 |
| 616 | union |
| 617 | { |
| 618 | struct |
| 619 | { |
| 620 | uint32_t m_reserved; |
| 621 | }; |
| 622 | struct |
| 623 | { |
| 624 | uint32_t m_value; |
| 625 | }; |
| 626 | } DW31; |
| 627 | |
| 628 | // DW32 |
| 629 | union |
| 630 | { |
| 631 | struct |
| 632 | { |
| 633 | uint32_t m_4xMeMvOutputDataSurfIndex; |
| 634 | }; |
| 635 | struct |
| 636 | { |
| 637 | uint32_t m_value; |
| 638 | }; |
| 639 | } DW32; |
| 640 | |
| 641 | // DW33 |
| 642 | union |
| 643 | { |
| 644 | struct |
| 645 | { |
| 646 | uint32_t m_16xMeMvInputDataSurfIndex; |
| 647 | }; |
| 648 | struct |
| 649 | { |
| 650 | uint32_t m_value; |
| 651 | }; |
| 652 | } DW33; |
| 653 | |
| 654 | // DW34 |
| 655 | union |
| 656 | { |
| 657 | struct |
| 658 | { |
| 659 | uint32_t m_4xMeOutputDistSurfIndex; |
| 660 | }; |
| 661 | struct |
| 662 | { |
| 663 | uint32_t m_value; |
| 664 | }; |
| 665 | } DW34; |
| 666 | |
| 667 | // DW35 |
| 668 | union |
| 669 | { |
| 670 | struct |
| 671 | { |
| 672 | uint32_t m_4xMeOutputBrcDistSurfIndex; |
| 673 | }; |
| 674 | struct |
| 675 | { |
| 676 | uint32_t m_value; |
| 677 | }; |
| 678 | } DW35; |
| 679 | |
| 680 | // DW36 |
| 681 | union |
| 682 | { |
| 683 | struct |
| 684 | { |
| 685 | uint32_t m_vmeFwdInterPredictionSurfIndex; |
| 686 | }; |
| 687 | struct |
| 688 | { |
| 689 | uint32_t m_value; |
| 690 | }; |
| 691 | } DW36; |
| 692 | |
| 693 | // DW37 |
| 694 | union |
| 695 | { |
| 696 | struct |
| 697 | { |
| 698 | uint32_t m_vmeBwdInterPredictionSurfIndex; |
| 699 | }; |
| 700 | struct |
| 701 | { |
| 702 | uint32_t m_value; |
| 703 | }; |
| 704 | } DW37; |
| 705 | |
| 706 | // DW38 |
| 707 | union |
| 708 | { |
| 709 | struct |
| 710 | { |
| 711 | uint32_t m_reserved; |
| 712 | }; |
| 713 | struct |
| 714 | { |
| 715 | uint32_t m_value; |
| 716 | }; |
| 717 | } DW38; |
| 718 | }m_curbeData; |
| 719 | |
| 720 | //! |
| 721 | //! \brief Constructor |
| 722 | //! |
| 723 | MeCurbeG8(); |
| 724 | |
| 725 | //! |
| 726 | //! \brief Destructor |
| 727 | //! |
| 728 | ~MeCurbeG8(){}; |
| 729 | |
| 730 | static const size_t m_byteSize = sizeof(CurbeData); |
| 731 | |
| 732 | } ; |
| 733 | |
| 734 | class MbEncCurbeG8 |
| 735 | { |
| 736 | public: |
| 737 | struct CurbeData |
| 738 | { |
| 739 | union |
| 740 | { |
| 741 | struct |
| 742 | { |
| 743 | uint32_t m_skipModeEn : MOS_BITFIELD_BIT(0); |
| 744 | uint32_t m_adaptiveEn : MOS_BITFIELD_BIT(1); |
| 745 | uint32_t m_biMixDis : MOS_BITFIELD_BIT(2); |
| 746 | uint32_t m_isInterlacedFrameFlag : MOS_BITFIELD_BIT(3); |
| 747 | uint32_t m_isTopFieldFirst : MOS_BITFIELD_BIT(4); |
| 748 | uint32_t m_earlyImeSuccessEn : MOS_BITFIELD_BIT(5); |
| 749 | uint32_t m_forceToSkip : MOS_BITFIELD_BIT(6); |
| 750 | uint32_t m_t8x8FlagForInterEn : MOS_BITFIELD_BIT(7); |
| 751 | uint32_t m_reserved1 : MOS_BITFIELD_RANGE(8,23); |
| 752 | uint32_t m_earlyImeStop : MOS_BITFIELD_RANGE(24,31); |
| 753 | }; |
| 754 | struct |
| 755 | { |
| 756 | uint32_t m_value; |
| 757 | }; |
| 758 | } DW0; |
| 759 | |
| 760 | union |
| 761 | { |
| 762 | struct |
| 763 | { |
| 764 | uint32_t m_maxNumMVs : MOS_BITFIELD_RANGE(0,5); |
| 765 | uint32_t m_reserved6 : MOS_BITFIELD_RANGE(6,7); |
| 766 | uint32_t m_refIDPolBits : MOS_BITFIELD_RANGE(8,15); |
| 767 | uint32_t m_biWeight : MOS_BITFIELD_RANGE(16,21); |
| 768 | uint32_t m_reserved22 : MOS_BITFIELD_RANGE(22,27); |
| 769 | uint32_t m_uniMixDisable : MOS_BITFIELD_BIT(28); |
| 770 | uint32_t m_refPixBiasEn : MOS_BITFIELD_BIT(29); // m_refPixBiasEn (MBZ) |
| 771 | uint32_t m_reserved30 : MOS_BITFIELD_RANGE(30,31); |
| 772 | }; |
| 773 | struct |
| 774 | { |
| 775 | uint32_t m_value; |
| 776 | }; |
| 777 | } DW1; |
| 778 | |
| 779 | union |
| 780 | { |
| 781 | struct |
| 782 | { |
| 783 | uint32_t m_maxLenSP : MOS_BITFIELD_RANGE(0,7); |
| 784 | uint32_t m_maxNumSU : MOS_BITFIELD_RANGE(8,15); |
| 785 | uint32_t m_start0X : MOS_BITFIELD_RANGE(16,19); |
| 786 | uint32_t m_start0Y : MOS_BITFIELD_RANGE(20,23); |
| 787 | uint32_t m_start1X : MOS_BITFIELD_RANGE(24,27); |
| 788 | uint32_t m_start1Y : MOS_BITFIELD_RANGE(28,31); |
| 789 | }; |
| 790 | struct |
| 791 | { |
| 792 | uint32_t m_value; |
| 793 | }; |
| 794 | } DW2; |
| 795 | |
| 796 | union |
| 797 | { |
| 798 | struct |
| 799 | { |
| 800 | uint32_t m_fieldBias : MOS_BITFIELD_RANGE(0,7); |
| 801 | uint32_t m_oppFieldBias : MOS_BITFIELD_RANGE(8,15); |
| 802 | uint32_t m_fieldSkipThr : MOS_BITFIELD_RANGE(16,31); |
| 803 | }; |
| 804 | struct |
| 805 | { |
| 806 | uint32_t m_value; |
| 807 | }; |
| 808 | } DW3; |
| 809 | |
| 810 | union |
| 811 | { |
| 812 | struct |
| 813 | { |
| 814 | uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0,7); |
| 815 | uint32_t m_picHeightMinus1 : MOS_BITFIELD_RANGE(8,15); |
| 816 | uint32_t m_picWidth : MOS_BITFIELD_RANGE(16,23); |
| 817 | uint32_t m_reserved24 : MOS_BITFIELD_BIT(24); // WalkerType |
| 818 | uint32_t m_motionSeeding : MOS_BITFIELD_BIT(25); |
| 819 | uint32_t m_kernelMBModeDecision : MOS_BITFIELD_BIT(26); |
| 820 | uint32_t m_iFrameMBDistortionDumpEnable : MOS_BITFIELD_BIT(27); |
| 821 | uint32_t m_fieldFlag : MOS_BITFIELD_BIT(28); |
| 822 | uint32_t m_pictureType : MOS_BITFIELD_RANGE(29,30); |
| 823 | uint32_t m_reserved1 : MOS_BITFIELD_BIT(31); |
| 824 | }; |
| 825 | struct |
| 826 | { |
| 827 | uint32_t m_value; |
| 828 | }; |
| 829 | } DW4; |
| 830 | |
| 831 | struct |
| 832 | { |
| 833 | union |
| 834 | { |
| 835 | struct |
| 836 | { |
| 837 | uint32_t m_mv0Cost : MOS_BITFIELD_RANGE(0, 7); |
| 838 | uint32_t m_mv1Cost : MOS_BITFIELD_RANGE(8, 15); |
| 839 | uint32_t m_mv2Cost : MOS_BITFIELD_RANGE(16, 23); |
| 840 | uint32_t m_mv3Cost : MOS_BITFIELD_RANGE(24, 31); |
| 841 | }; |
| 842 | struct |
| 843 | { |
| 844 | uint32_t m_value; |
| 845 | }; |
| 846 | } DW5; |
| 847 | |
| 848 | union |
| 849 | { |
| 850 | struct |
| 851 | { |
| 852 | uint32_t m_mv4Cost : MOS_BITFIELD_RANGE(0, 7); |
| 853 | uint32_t m_mv5Cost : MOS_BITFIELD_RANGE(8, 15); |
| 854 | uint32_t m_mv6Cost : MOS_BITFIELD_RANGE(16, 23); |
| 855 | uint32_t m_mv7Cost : MOS_BITFIELD_RANGE(24, 31); |
| 856 | }; |
| 857 | struct |
| 858 | { |
| 859 | uint32_t m_value; |
| 860 | }; |
| 861 | } DW6; |
| 862 | } MvCost; |
| 863 | |
| 864 | union |
| 865 | { |
| 866 | struct |
| 867 | { |
| 868 | uint32_t m_intraPartMask : MOS_BITFIELD_RANGE(0,4); |
| 869 | uint32_t m_nonSkipZMvAdded : MOS_BITFIELD_BIT(5); |
| 870 | uint32_t m_nonSkipModeAdded : MOS_BITFIELD_BIT(6); |
| 871 | uint32_t m_reserved7 : MOS_BITFIELD_RANGE(7,15); |
| 872 | uint32_t m_mvCostScaleFactor : MOS_BITFIELD_RANGE(16,17); |
| 873 | uint32_t m_bilinearEnable : MOS_BITFIELD_BIT(18); |
| 874 | uint32_t m_srcFieldPolarity : MOS_BITFIELD_BIT(19); |
| 875 | uint32_t m_weightedSADHAAR : MOS_BITFIELD_BIT(20); |
| 876 | uint32_t m_acOnlyHAAR : MOS_BITFIELD_BIT(21); |
| 877 | uint32_t m_refIDCostMode : MOS_BITFIELD_BIT(22); |
| 878 | uint32_t m_idmShapeMode : MOS_BITFIELD_BIT(23); |
| 879 | uint32_t m_skipCenterMask : MOS_BITFIELD_RANGE(24,31); |
| 880 | }; |
| 881 | struct |
| 882 | { |
| 883 | uint32_t m_value; |
| 884 | }; |
| 885 | } DW7; |
| 886 | |
| 887 | union |
| 888 | { |
| 889 | struct |
| 890 | { |
| 891 | uint32_t m_mode8Cost : MOS_BITFIELD_RANGE(0,7); |
| 892 | uint32_t m_mode9Cost : MOS_BITFIELD_RANGE(8,15); |
| 893 | uint32_t m_refIDCost : MOS_BITFIELD_RANGE(16,23); |
| 894 | uint32_t m_chromaIntraModeCost : MOS_BITFIELD_RANGE(24,31); |
| 895 | }; |
| 896 | struct |
| 897 | { |
| 898 | uint32_t m_value; |
| 899 | }; |
| 900 | } DW8; |
| 901 | |
| 902 | union |
| 903 | { |
| 904 | struct |
| 905 | { |
| 906 | uint32_t m_srcSize : MOS_BITFIELD_RANGE(0,1); |
| 907 | uint32_t m_mbQPEnable : MOS_BITFIELD_BIT(2); |
| 908 | uint32_t m_mbSkipEnable : MOS_BITFIELD_BIT(3); |
| 909 | uint32_t m_mbNonSkipEnable : MOS_BITFIELD_BIT(4); |
| 910 | uint32_t m_reserved5 : MOS_BITFIELD_BIT(5); |
| 911 | uint32_t m_srcAccess : MOS_BITFIELD_BIT(6); |
| 912 | uint32_t m_refAccess : MOS_BITFIELD_BIT(7); |
| 913 | uint32_t m_searchCtrl : MOS_BITFIELD_RANGE(8,10); |
| 914 | uint32_t m_dualSearchOpt : MOS_BITFIELD_BIT(11); |
| 915 | uint32_t m_subPelMode : MOS_BITFIELD_RANGE(12,13); |
| 916 | uint32_t m_skipType : MOS_BITFIELD_BIT(14); |
| 917 | uint32_t m_fieldCacheAllocationDis : MOS_BITFIELD_BIT(15); |
| 918 | uint32_t m_interChromaMode : MOS_BITFIELD_BIT(16); |
| 919 | uint32_t m_ftEnable : MOS_BITFIELD_BIT(17); |
| 920 | uint32_t m_bmeDisableFBR : MOS_BITFIELD_BIT(18); |
| 921 | uint32_t m_reserved19 : MOS_BITFIELD_BIT(19); |
| 922 | uint32_t m_interSAD : MOS_BITFIELD_RANGE(20,21); |
| 923 | uint32_t m_intraSAD : MOS_BITFIELD_RANGE(22,23); |
| 924 | uint32_t m_subMbPartMask : MOS_BITFIELD_RANGE(24,30); |
| 925 | uint32_t m_reserved31 : MOS_BITFIELD_BIT(31); |
| 926 | }; |
| 927 | struct |
| 928 | { |
| 929 | uint32_t m_value; |
| 930 | }; |
| 931 | } DW9; |
| 932 | |
| 933 | union |
| 934 | { |
| 935 | struct |
| 936 | { |
| 937 | uint32_t m_dispatchID : MOS_BITFIELD_RANGE(0,7); |
| 938 | uint32_t m_largeMbSizeInWord : MOS_BITFIELD_RANGE(8,15); |
| 939 | uint32_t m_refWidth : MOS_BITFIELD_RANGE(16,23); |
| 940 | uint32_t m_refHeight : MOS_BITFIELD_RANGE(24,31); |
| 941 | }; |
| 942 | struct |
| 943 | { |
| 944 | uint32_t m_value; |
| 945 | }; |
| 946 | } DW10; |
| 947 | |
| 948 | union |
| 949 | { |
| 950 | struct |
| 951 | { |
| 952 | uint32_t m_qpScaleCode : MOS_BITFIELD_RANGE(0,7); |
| 953 | uint32_t m_intraFactor : MOS_BITFIELD_RANGE(8,11); |
| 954 | uint32_t m_intraMulFact : MOS_BITFIELD_RANGE(12,15); |
| 955 | uint32_t m_intraBiasFF : MOS_BITFIELD_RANGE(16,23); |
| 956 | uint32_t m_intraBiasFrame : MOS_BITFIELD_RANGE(24,31); |
| 957 | }; |
| 958 | struct |
| 959 | { |
| 960 | uint32_t m_value; |
| 961 | }; |
| 962 | } DW11; |
| 963 | |
| 964 | union |
| 965 | { |
| 966 | struct |
| 967 | { |
| 968 | uint32_t m_isFastMode : MOS_BITFIELD_RANGE(0,7); |
| 969 | uint32_t m_smallMbSizeInWord : MOS_BITFIELD_RANGE(8,15); |
| 970 | uint32_t m_distScaleFactor : MOS_BITFIELD_RANGE(16,31); |
| 971 | }; |
| 972 | struct |
| 973 | { |
| 974 | uint32_t m_value; |
| 975 | }; |
| 976 | } DW12; |
| 977 | |
| 978 | union |
| 979 | { |
| 980 | struct |
| 981 | { |
| 982 | uint32_t m_panicModeMBThreshold : MOS_BITFIELD_RANGE(0,15); |
| 983 | uint32_t m_targetSizeInWord : MOS_BITFIELD_RANGE(16,23); |
| 984 | uint32_t m_reserved14 : MOS_BITFIELD_RANGE(24,31); |
| 985 | }; |
| 986 | struct |
| 987 | { |
| 988 | uint32_t m_value; |
| 989 | }; |
| 990 | } DW13; |
| 991 | |
| 992 | union |
| 993 | { |
| 994 | struct |
| 995 | { |
| 996 | uint32_t m_forwardHorizontalSearchRange : MOS_BITFIELD_RANGE(0,15); |
| 997 | uint32_t m_forwardVerticalSearchRange : MOS_BITFIELD_RANGE(16,31); |
| 998 | }; |
| 999 | struct |
| 1000 | { |
| 1001 | uint32_t m_value; |
| 1002 | }; |
| 1003 | } DW14; |
| 1004 | |
| 1005 | union |
| 1006 | { |
| 1007 | struct |
| 1008 | { |
| 1009 | uint32_t m_backwardHorizontalSearchRange : MOS_BITFIELD_RANGE(0,15); |
| 1010 | uint32_t m_backwardVerticalSearchRange : MOS_BITFIELD_RANGE(16,31); |
| 1011 | }; |
| 1012 | struct |
| 1013 | { |
| 1014 | uint32_t m_value; |
| 1015 | }; |
| 1016 | } DW15; |
| 1017 | |
| 1018 | struct |
| 1019 | { |
| 1020 | union |
| 1021 | { |
| 1022 | struct |
| 1023 | { |
| 1024 | uint32_t m_meDelta0to3; |
| 1025 | }; |
| 1026 | struct |
| 1027 | { |
| 1028 | uint32_t m_value; |
| 1029 | }; |
| 1030 | } DW16; |
| 1031 | |
| 1032 | union |
| 1033 | { |
| 1034 | struct |
| 1035 | { |
| 1036 | uint32_t m_meDelta4to7; |
| 1037 | }; |
| 1038 | struct |
| 1039 | { |
| 1040 | uint32_t m_value; |
| 1041 | }; |
| 1042 | } DW17; |
| 1043 | |
| 1044 | union |
| 1045 | { |
| 1046 | struct |
| 1047 | { |
| 1048 | uint32_t m_meDelta8to11; |
| 1049 | }; |
| 1050 | struct |
| 1051 | { |
| 1052 | uint32_t m_value; |
| 1053 | }; |
| 1054 | } DW18; |
| 1055 | |
| 1056 | union |
| 1057 | { |
| 1058 | struct |
| 1059 | { |
| 1060 | uint32_t m_meDelta12to15; |
| 1061 | }; |
| 1062 | struct |
| 1063 | { |
| 1064 | uint32_t m_value; |
| 1065 | }; |
| 1066 | } DW19; |
| 1067 | |
| 1068 | union |
| 1069 | { |
| 1070 | struct |
| 1071 | { |
| 1072 | uint32_t m_meDelta16to19; |
| 1073 | }; |
| 1074 | struct |
| 1075 | { |
| 1076 | uint32_t m_value; |
| 1077 | }; |
| 1078 | } DW20; |
| 1079 | |
| 1080 | union |
| 1081 | { |
| 1082 | struct |
| 1083 | { |
| 1084 | uint32_t m_meDelta20to23; |
| 1085 | }; |
| 1086 | struct |
| 1087 | { |
| 1088 | uint32_t m_value; |
| 1089 | }; |
| 1090 | } DW21; |
| 1091 | |
| 1092 | union |
| 1093 | { |
| 1094 | struct |
| 1095 | { |
| 1096 | uint32_t m_meDelta24to27; |
| 1097 | }; |
| 1098 | struct |
| 1099 | { |
| 1100 | uint32_t m_value; |
| 1101 | }; |
| 1102 | } DW22; |
| 1103 | |
| 1104 | union |
| 1105 | { |
| 1106 | struct |
| 1107 | { |
| 1108 | uint32_t m_meDelta28to31; |
| 1109 | }; |
| 1110 | struct |
| 1111 | { |
| 1112 | uint32_t m_value; |
| 1113 | }; |
| 1114 | } DW23; |
| 1115 | |
| 1116 | union |
| 1117 | { |
| 1118 | struct |
| 1119 | { |
| 1120 | uint32_t m_meDelta32to35; |
| 1121 | }; |
| 1122 | struct |
| 1123 | { |
| 1124 | uint32_t m_value; |
| 1125 | }; |
| 1126 | } DW24; |
| 1127 | |
| 1128 | union |
| 1129 | { |
| 1130 | struct |
| 1131 | { |
| 1132 | uint32_t m_meDelta36to39; |
| 1133 | }; |
| 1134 | struct |
| 1135 | { |
| 1136 | uint32_t m_value; |
| 1137 | }; |
| 1138 | } DW25; |
| 1139 | |
| 1140 | union |
| 1141 | { |
| 1142 | struct |
| 1143 | { |
| 1144 | uint32_t m_meDelta40to43; |
| 1145 | }; |
| 1146 | struct |
| 1147 | { |
| 1148 | uint32_t m_value; |
| 1149 | }; |
| 1150 | } DW26; |
| 1151 | |
| 1152 | union |
| 1153 | { |
| 1154 | struct |
| 1155 | { |
| 1156 | uint32_t m_meDelta44to47; |
| 1157 | }; |
| 1158 | struct |
| 1159 | { |
| 1160 | uint32_t m_value; |
| 1161 | }; |
| 1162 | } DW27; |
| 1163 | |
| 1164 | union |
| 1165 | { |
| 1166 | struct |
| 1167 | { |
| 1168 | uint32_t m_meDelta48to51; |
| 1169 | }; |
| 1170 | struct |
| 1171 | { |
| 1172 | uint32_t m_value; |
| 1173 | }; |
| 1174 | } DW28; |
| 1175 | |
| 1176 | union |
| 1177 | { |
| 1178 | struct |
| 1179 | { |
| 1180 | uint32_t m_meDelta52to55; |
| 1181 | }; |
| 1182 | struct |
| 1183 | { |
| 1184 | uint32_t m_value; |
| 1185 | }; |
| 1186 | } DW29; |
| 1187 | |
| 1188 | union |
| 1189 | { |
| 1190 | struct |
| 1191 | { |
| 1192 | uint32_t m_mode0Cost : MOS_BITFIELD_RANGE(0, 7); |
| 1193 | uint32_t m_mode1Cost : MOS_BITFIELD_RANGE(8, 15); |
| 1194 | uint32_t m_mode2Cost : MOS_BITFIELD_RANGE(16, 23); |
| 1195 | uint32_t m_mode3Cost : MOS_BITFIELD_RANGE(24, 31); |
| 1196 | }; |
| 1197 | struct |
| 1198 | { |
| 1199 | uint32_t m_value; |
| 1200 | }; |
| 1201 | } DW30; |
| 1202 | |
| 1203 | union |
| 1204 | { |
| 1205 | struct |
| 1206 | { |
| 1207 | uint32_t m_mode4Cost : MOS_BITFIELD_RANGE(0, 7); |
| 1208 | uint32_t m_mode5Cost : MOS_BITFIELD_RANGE(8, 15); |
| 1209 | uint32_t m_mode6Cost : MOS_BITFIELD_RANGE(16, 23); |
| 1210 | uint32_t m_mode7Cost : MOS_BITFIELD_RANGE(24, 31); |
| 1211 | }; |
| 1212 | struct |
| 1213 | { |
| 1214 | uint32_t m_value; |
| 1215 | }; |
| 1216 | } DW31; |
| 1217 | } VmeSPath0; |
| 1218 | |
| 1219 | struct |
| 1220 | { |
| 1221 | union |
| 1222 | { |
| 1223 | struct |
| 1224 | { |
| 1225 | uint32_t m_meDelta0to3; |
| 1226 | }; |
| 1227 | struct |
| 1228 | { |
| 1229 | uint32_t m_value; |
| 1230 | }; |
| 1231 | } DW32; |
| 1232 | |
| 1233 | union |
| 1234 | { |
| 1235 | struct |
| 1236 | { |
| 1237 | uint32_t m_meDelta4to7; |
| 1238 | }; |
| 1239 | struct |
| 1240 | { |
| 1241 | uint32_t m_value; |
| 1242 | }; |
| 1243 | } DW33; |
| 1244 | |
| 1245 | union |
| 1246 | { |
| 1247 | struct |
| 1248 | { |
| 1249 | uint32_t m_meDelta8to11; |
| 1250 | }; |
| 1251 | struct |
| 1252 | { |
| 1253 | uint32_t m_value; |
| 1254 | }; |
| 1255 | } DW34; |
| 1256 | |
| 1257 | union |
| 1258 | { |
| 1259 | struct |
| 1260 | { |
| 1261 | uint32_t m_meDelta12to15; |
| 1262 | }; |
| 1263 | struct |
| 1264 | { |
| 1265 | uint32_t m_value; |
| 1266 | }; |
| 1267 | } DW35; |
| 1268 | |
| 1269 | union |
| 1270 | { |
| 1271 | struct |
| 1272 | { |
| 1273 | uint32_t m_meDelta16to19; |
| 1274 | }; |
| 1275 | struct |
| 1276 | { |
| 1277 | uint32_t m_value; |
| 1278 | }; |
| 1279 | } DW36; |
| 1280 | |
| 1281 | union |
| 1282 | { |
| 1283 | struct |
| 1284 | { |
| 1285 | uint32_t m_meDelta20to23; |
| 1286 | }; |
| 1287 | struct |
| 1288 | { |
| 1289 | uint32_t m_value; |
| 1290 | }; |
| 1291 | } DW37; |
| 1292 | |
| 1293 | union |
| 1294 | { |
| 1295 | struct |
| 1296 | { |
| 1297 | uint32_t m_meDelta24to27; |
| 1298 | }; |
| 1299 | struct |
| 1300 | { |
| 1301 | uint32_t m_value; |
| 1302 | }; |
| 1303 | } DW38; |
| 1304 | |
| 1305 | union |
| 1306 | { |
| 1307 | struct |
| 1308 | { |
| 1309 | uint32_t m_meDelta28to31; |
| 1310 | }; |
| 1311 | struct |
| 1312 | { |
| 1313 | uint32_t m_value; |
| 1314 | }; |
| 1315 | } DW39; |
| 1316 | |
| 1317 | union |
| 1318 | { |
| 1319 | struct |
| 1320 | { |
| 1321 | uint32_t m_meDelta32to35; |
| 1322 | }; |
| 1323 | struct |
| 1324 | { |
| 1325 | uint32_t m_value; |
| 1326 | }; |
| 1327 | } DW40; |
| 1328 | |
| 1329 | union |
| 1330 | { |
| 1331 | struct |
| 1332 | { |
| 1333 | uint32_t m_meDelta36to39; |
| 1334 | }; |
| 1335 | struct |
| 1336 | { |
| 1337 | uint32_t m_value; |
| 1338 | }; |
| 1339 | } DW41; |
| 1340 | |
| 1341 | union |
| 1342 | { |
| 1343 | struct |
| 1344 | { |
| 1345 | uint32_t m_meDelta40to43; |
| 1346 | }; |
| 1347 | struct |
| 1348 | { |
| 1349 | uint32_t m_value; |
| 1350 | }; |
| 1351 | } DW42; |
| 1352 | |
| 1353 | union |
| 1354 | { |
| 1355 | struct |
| 1356 | { |
| 1357 | uint32_t m_meDelta44to47; |
| 1358 | }; |
| 1359 | struct |
| 1360 | { |
| 1361 | uint32_t m_value; |
| 1362 | }; |
| 1363 | } DW43; |
| 1364 | |
| 1365 | union |
| 1366 | { |
| 1367 | struct |
| 1368 | { |
| 1369 | uint32_t m_meDelta48to51; |
| 1370 | }; |
| 1371 | struct |
| 1372 | { |
| 1373 | uint32_t m_value; |
| 1374 | }; |
| 1375 | } DW44; |
| 1376 | |
| 1377 | union |
| 1378 | { |
| 1379 | struct |
| 1380 | { |
| 1381 | uint32_t m_meDelta52to55; |
| 1382 | }; |
| 1383 | struct |
| 1384 | { |
| 1385 | uint32_t m_value; |
| 1386 | }; |
| 1387 | } DW45; |
| 1388 | |
| 1389 | struct |
| 1390 | { |
| 1391 | union |
| 1392 | { |
| 1393 | struct |
| 1394 | { |
| 1395 | uint32_t m_mv0Cost_Interlaced : MOS_BITFIELD_RANGE(0, 7); |
| 1396 | uint32_t m_mv1Cost_Interlaced : MOS_BITFIELD_RANGE(8, 15); |
| 1397 | uint32_t m_mv2Cost_Interlaced : MOS_BITFIELD_RANGE(16, 23); |
| 1398 | uint32_t m_mv3Cost_Interlaced : MOS_BITFIELD_RANGE(24, 31); |
| 1399 | }; |
| 1400 | struct |
| 1401 | { |
| 1402 | uint32_t m_value; |
| 1403 | }; |
| 1404 | } DW46; |
| 1405 | |
| 1406 | union |
| 1407 | { |
| 1408 | struct |
| 1409 | { |
| 1410 | uint32_t m_mv4Cost_Interlaced : MOS_BITFIELD_RANGE(0, 7); |
| 1411 | uint32_t m_mv5Cost_Interlaced : MOS_BITFIELD_RANGE(8, 15); |
| 1412 | uint32_t m_mv6Cost_Interlaced : MOS_BITFIELD_RANGE(16, 23); |
| 1413 | uint32_t m_mv7Cost_Interlaced : MOS_BITFIELD_RANGE(24, 31); |
| 1414 | }; |
| 1415 | struct |
| 1416 | { |
| 1417 | uint32_t m_value; |
| 1418 | }; |
| 1419 | } DW47; |
| 1420 | } MvCostInterlace; |
| 1421 | } VmeSPath1; |
| 1422 | |
| 1423 | union |
| 1424 | { |
| 1425 | struct |
| 1426 | { |
| 1427 | uint32_t m_batchBufferEnd; |
| 1428 | }; |
| 1429 | struct |
| 1430 | { |
| 1431 | uint32_t m_value; |
| 1432 | }; |
| 1433 | } DW48; |
| 1434 | |
| 1435 | union |
| 1436 | { |
| 1437 | struct |
| 1438 | { |
| 1439 | uint32_t m_pakObjCmds; |
| 1440 | }; |
| 1441 | struct |
| 1442 | { |
| 1443 | uint32_t m_value; |
| 1444 | }; |
| 1445 | } DW49; |
| 1446 | |
| 1447 | union |
| 1448 | { |
| 1449 | struct |
| 1450 | { |
| 1451 | uint32_t m_prevmPakObjCmds; |
| 1452 | }; |
| 1453 | struct |
| 1454 | { |
| 1455 | uint32_t m_value; |
| 1456 | }; |
| 1457 | } DW50; |
| 1458 | |
| 1459 | union |
| 1460 | { |
| 1461 | struct |
| 1462 | { |
| 1463 | uint32_t m_currPicY; |
| 1464 | }; |
| 1465 | struct |
| 1466 | { |
| 1467 | uint32_t m_value; |
| 1468 | }; |
| 1469 | } DW51; |
| 1470 | |
| 1471 | union |
| 1472 | { |
| 1473 | struct |
| 1474 | { |
| 1475 | uint32_t m_currFwdBwdRef; |
| 1476 | }; |
| 1477 | struct |
| 1478 | { |
| 1479 | uint32_t m_value; |
| 1480 | }; |
| 1481 | } DW52; |
| 1482 | |
| 1483 | union |
| 1484 | { |
| 1485 | struct |
| 1486 | { |
| 1487 | uint32_t m_currBwdRef; |
| 1488 | }; |
| 1489 | struct |
| 1490 | { |
| 1491 | uint32_t m_value; |
| 1492 | }; |
| 1493 | } DW53; |
| 1494 | |
| 1495 | union |
| 1496 | { |
| 1497 | struct |
| 1498 | { |
| 1499 | uint32_t m_distSurf4x; |
| 1500 | }; |
| 1501 | struct |
| 1502 | { |
| 1503 | uint32_t m_value; |
| 1504 | }; |
| 1505 | } DW54; |
| 1506 | |
| 1507 | union |
| 1508 | { |
| 1509 | struct |
| 1510 | { |
| 1511 | uint32_t m_mbControl; |
| 1512 | }; |
| 1513 | struct |
| 1514 | { |
| 1515 | uint32_t m_value; |
| 1516 | }; |
| 1517 | } DW55; |
| 1518 | }m_curbeData; |
| 1519 | |
| 1520 | //! |
| 1521 | //! \brief Constructor |
| 1522 | //! |
| 1523 | MbEncCurbeG8(uint8_t codingType); |
| 1524 | |
| 1525 | //! |
| 1526 | //! \brief Destructor |
| 1527 | //! |
| 1528 | ~MbEncCurbeG8(){}; |
| 1529 | |
| 1530 | static const size_t m_byteSize = sizeof(CurbeData); |
| 1531 | }; |
| 1532 | |
| 1533 | MeCurbeG8::MeCurbeG8() |
| 1534 | { |
| 1535 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1536 | |
| 1537 | MOS_ZeroMemory(&m_curbeData, m_byteSize); |
| 1538 | |
| 1539 | m_curbeData.DW0.m_value = 0x00000000; |
| 1540 | m_curbeData.DW1.m_value = 0x00200010; |
| 1541 | m_curbeData.DW2.m_value = 0x00003939; |
| 1542 | m_curbeData.DW3.m_value = 0x77a43000; |
| 1543 | m_curbeData.DW4.m_value = 0x00000000; |
| 1544 | m_curbeData.DW5.m_value = 0x28300000; |
| 1545 | |
| 1546 | m_curbeData.DW32.m_value = 0xffffffff; |
| 1547 | m_curbeData.DW33.m_value = 0xffffffff; |
| 1548 | m_curbeData.DW34.m_value = 0xffffffff; |
| 1549 | m_curbeData.DW35.m_value = 0xffffffff; |
| 1550 | m_curbeData.DW36.m_value = 0xffffffff; |
| 1551 | m_curbeData.DW37.m_value = 0xffffffff; |
| 1552 | m_curbeData.DW38.m_value = 0xffffffff; |
| 1553 | |
| 1554 | } |
| 1555 | |
| 1556 | MbEncCurbeG8::MbEncCurbeG8(uint8_t codingType) |
| 1557 | { |
| 1558 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1559 | |
| 1560 | MOS_ZeroMemory(&m_curbeData, m_byteSize); |
| 1561 | |
| 1562 | m_curbeData.DW0.m_value = 0x00000023; |
| 1563 | switch (codingType) |
| 1564 | { |
| 1565 | case I_TYPE: |
| 1566 | m_curbeData.DW1.m_value = 0x00200020; |
| 1567 | m_curbeData.DW2.m_value = 0x00000000; |
| 1568 | m_curbeData.DW4.m_value = 0x00000000; |
| 1569 | m_curbeData.DW7.m_value = 0x00050066; |
| 1570 | m_curbeData.DW8.m_value = 0x00000000; |
| 1571 | m_curbeData.DW9.m_value = 0x7EA41000; |
| 1572 | m_curbeData.DW10.m_value = 0x0000FF00; |
| 1573 | break; |
| 1574 | case P_TYPE: |
| 1575 | m_curbeData.DW1.m_value = 0x00200020; |
| 1576 | m_curbeData.DW2.m_value = 0x00001009; |
| 1577 | m_curbeData.DW4.m_value = 0x20000000; |
| 1578 | m_curbeData.DW7.m_value = 0x00050066; |
| 1579 | m_curbeData.DW8.m_value = 0x00000041; |
| 1580 | m_curbeData.DW9.m_value = 0x7EA41000; |
| 1581 | m_curbeData.DW10.m_value = 0x2830FF00; |
| 1582 | break; |
| 1583 | case B_TYPE: |
| 1584 | default: |
| 1585 | m_curbeData.DW1.m_value = 0x10200010; |
| 1586 | m_curbeData.DW2.m_value = 0x00001005; |
| 1587 | m_curbeData.DW4.m_value = 0x40000000; |
| 1588 | m_curbeData.DW7.m_value = 0xFF050066; |
| 1589 | m_curbeData.DW8.m_value = 0x00000041; |
| 1590 | m_curbeData.DW9.m_value = 0x7EA01000; |
| 1591 | m_curbeData.DW10.m_value = 0x2020FF00; |
| 1592 | break; |
| 1593 | |
| 1594 | } |
| 1595 | |
| 1596 | m_curbeData.DW3.m_value = 0xFE0C0000; |
| 1597 | m_curbeData.MvCost.DW5.m_value = 0x00000000; |
| 1598 | m_curbeData.MvCost.DW6.m_value = 0x00000000; |
| 1599 | m_curbeData.DW11.m_value = 0x5A325300; |
| 1600 | m_curbeData.DW12.m_value = 0x0000FF00; |
| 1601 | m_curbeData.DW13.m_value = 0x00FF0000; |
| 1602 | |
| 1603 | } |
| 1604 | |
| 1605 | CodechalEncodeMpeg2G8::CodechalEncodeMpeg2G8( |
| 1606 | CodechalHwInterface* hwInterface, |
| 1607 | CodechalDebugInterface* debugInterface, |
| 1608 | PCODECHAL_STANDARD_INFO standardInfo) |
| 1609 | :CodechalEncodeMpeg2(hwInterface, debugInterface, standardInfo) |
| 1610 | { |
| 1611 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1612 | |
| 1613 | pfnGetKernelHeaderAndSize = GetKernelHeaderAndSize; |
| 1614 | |
| 1615 | MOS_STATUS eStatus = CodecHalGetKernelBinaryAndSize( |
| 1616 | (uint8_t *)IGCODECKRN_G8, |
| 1617 | m_kuid, |
| 1618 | &m_kernelBinary, |
| 1619 | &m_combinedKernelSize); |
| 1620 | |
| 1621 | CODECHAL_ENCODE_ASSERT(eStatus == MOS_STATUS_SUCCESS); |
| 1622 | |
| 1623 | m_hwInterface->GetStateHeapSettings()->dwIshSize += |
| 1624 | MOS_ALIGN_CEIL(m_combinedKernelSize, (1 << MHW_KERNEL_OFFSET_SHIFT)); |
| 1625 | |
| 1626 | m_needCheckCpEnabled = true; |
| 1627 | } |
| 1628 | |
| 1629 | MOS_STATUS CodechalEncodeMpeg2G8::Initialize(CodechalSetting * codecHalSettings) |
| 1630 | { |
| 1631 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1632 | |
| 1633 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1634 | |
| 1635 | // common initilization |
| 1636 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodechalEncodeMpeg2::Initialize(codecHalSettings)); |
| 1637 | |
| 1638 | return eStatus; |
| 1639 | } |
| 1640 | |
| 1641 | MOS_STATUS CodechalEncodeMpeg2G8::GetKernelHeaderAndSize( |
| 1642 | void *binary, |
| 1643 | EncOperation operation, |
| 1644 | uint32_t krnStateIdx, |
| 1645 | void *krnHeader, |
| 1646 | uint32_t *krnSize) |
| 1647 | { |
| 1648 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1649 | |
| 1650 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1651 | |
| 1652 | CODECHAL_ENCODE_CHK_NULL_RETURN(binary); |
| 1653 | CODECHAL_ENCODE_CHK_NULL_RETURN(krnHeader); |
| 1654 | CODECHAL_ENCODE_CHK_NULL_RETURN(krnSize); |
| 1655 | |
| 1656 | auto kernelHeaderTable = (KernelHeaderMpegG8 *)binary; |
| 1657 | PCODECHAL_KERNEL_HEADER currKrnHeader; |
| 1658 | |
| 1659 | if (operation == ENC_SCALING4X) |
| 1660 | { |
| 1661 | currKrnHeader = &kernelHeaderTable->m_plyDscalePly; |
| 1662 | } |
| 1663 | else if (operation == ENC_ME) |
| 1664 | { |
| 1665 | currKrnHeader = &kernelHeaderTable->m_mpeg2AvcMeP; |
| 1666 | } |
| 1667 | else if (operation == ENC_BRC) |
| 1668 | { |
| 1669 | currKrnHeader = &kernelHeaderTable->m_mpeg2InitFrameBrc; |
| 1670 | } |
| 1671 | else if (operation == ENC_MBENC) |
| 1672 | { |
| 1673 | currKrnHeader = &kernelHeaderTable->m_mpeg2MbEncI; |
| 1674 | } |
| 1675 | else |
| 1676 | { |
| 1677 | CODECHAL_ENCODE_ASSERTMESSAGE("Unsupported ENC mode requested"); |
| 1678 | eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 1679 | return eStatus; |
| 1680 | } |
| 1681 | |
| 1682 | currKrnHeader += krnStateIdx; |
| 1683 | *((PCODECHAL_KERNEL_HEADER)krnHeader) = *currKrnHeader; |
| 1684 | |
| 1685 | PCODECHAL_KERNEL_HEADER invalidEntry = &(kernelHeaderTable->m_mpeg2BrcResetFrame) + 1; |
| 1686 | PCODECHAL_KERNEL_HEADER nextKrnHeader = (currKrnHeader + 1); |
| 1687 | uint32_t nextKrnOffset = *krnSize; |
| 1688 | |
| 1689 | if (nextKrnHeader < invalidEntry) |
| 1690 | { |
| 1691 | nextKrnOffset = nextKrnHeader->KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT; |
| 1692 | } |
| 1693 | *krnSize = nextKrnOffset - (currKrnHeader->KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); |
| 1694 | |
| 1695 | return eStatus; |
| 1696 | } |
| 1697 | |
| 1698 | MOS_STATUS CodechalEncodeMpeg2G8::InitKernelState() |
| 1699 | { |
| 1700 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1701 | |
| 1702 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1703 | |
| 1704 | // Init kernel state |
| 1705 | CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateMe()); |
| 1706 | CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateMbEnc()); |
| 1707 | CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateBrc()); |
| 1708 | |
| 1709 | return eStatus; |
| 1710 | } |
| 1711 | |
| 1712 | MOS_STATUS CodechalEncodeMpeg2G8::InitKernelStateMe() |
| 1713 | { |
| 1714 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1715 | |
| 1716 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1717 | |
| 1718 | for (uint8_t krnStateIdx = 0; krnStateIdx < 2; krnStateIdx++) |
| 1719 | { |
| 1720 | auto kernelStatePtr = &m_meKernelStates[krnStateIdx]; |
| 1721 | auto kernelSize = m_combinedKernelSize; |
| 1722 | |
| 1723 | CODECHAL_KERNEL_HEADER currKrnHeader; |
| 1724 | CODECHAL_ENCODE_CHK_STATUS_RETURN(pfnGetKernelHeaderAndSize( |
| 1725 | m_kernelBinary, |
| 1726 | ENC_ME, |
| 1727 | krnStateIdx, |
| 1728 | &currKrnHeader, |
| 1729 | &kernelSize)); |
| 1730 | |
| 1731 | kernelStatePtr->KernelParams.iBTCount = meNumSurface; |
| 1732 | kernelStatePtr->KernelParams.iThreadCount = m_hwInterface->GetRenderInterface()->GetHwCaps()->dwMaxThreads; |
| 1733 | kernelStatePtr->KernelParams.iCurbeLength = MeCurbeG8::m_byteSize; |
| 1734 | kernelStatePtr->KernelParams.iBlockWidth = CODECHAL_MACROBLOCK_WIDTH; |
| 1735 | kernelStatePtr->KernelParams.iBlockHeight = CODECHAL_MACROBLOCK_HEIGHT; |
| 1736 | kernelStatePtr->KernelParams.iIdCount = 1; |
| 1737 | |
| 1738 | kernelStatePtr->dwCurbeOffset = m_stateHeapInterface->pStateHeapInterface->GetSizeofCmdInterfaceDescriptorData(); |
| 1739 | kernelStatePtr->KernelParams.pBinary = m_kernelBinary + (currKrnHeader.KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); |
| 1740 | kernelStatePtr->KernelParams.iSize = kernelSize; |
| 1741 | CODECHAL_ENCODE_CHK_STATUS_RETURN(m_stateHeapInterface->pfnCalculateSshAndBtSizesRequested( |
| 1742 | m_stateHeapInterface, |
| 1743 | kernelStatePtr->KernelParams.iBTCount, |
| 1744 | &kernelStatePtr->dwSshSize, |
| 1745 | &kernelStatePtr->dwBindingTableSize)); |
| 1746 | |
| 1747 | CODECHAL_ENCODE_CHK_STATUS_RETURN(m_hwInterface->MhwInitISH(m_stateHeapInterface, kernelStatePtr)); |
| 1748 | } |
| 1749 | |
| 1750 | // Until a better way can be found, maintain old binding table structures |
| 1751 | auto meBindingTable = &m_meBindingTable; |
| 1752 | |
| 1753 | // Mpeg2 uses AVC ME Kernel for P/B distortion calculation |
| 1754 | meBindingTable->dwMEMVDataSurface = meMvDataSurface; |
| 1755 | meBindingTable->dwMECurrForFwdRef = meCurrForFwdRef; |
| 1756 | meBindingTable->dwMECurrForBwdRef = meCurrForBwdRef; |
| 1757 | meBindingTable->dwMEDist = meDistortionSurface; |
| 1758 | meBindingTable->dwMEBRCDist = meBrcDistortion; |
| 1759 | meBindingTable->dwMEFwdRefPicIdx[0] = meFwdRefIdx0; |
| 1760 | meBindingTable->dwMEFwdRefPicIdx[1] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1761 | meBindingTable->dwMEFwdRefPicIdx[2] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1762 | meBindingTable->dwMEFwdRefPicIdx[3] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1763 | meBindingTable->dwMEFwdRefPicIdx[4] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1764 | meBindingTable->dwMEFwdRefPicIdx[5] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1765 | meBindingTable->dwMEFwdRefPicIdx[6] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1766 | meBindingTable->dwMEFwdRefPicIdx[7] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1767 | meBindingTable->dwMEBwdRefPicIdx[0] = meBwdRefIdx0; |
| 1768 | meBindingTable->dwMEBwdRefPicIdx[1] = CODECHAL_INVALID_BINDING_TABLE_IDX; |
| 1769 | |
| 1770 | return eStatus; |
| 1771 | } |
| 1772 | |
| 1773 | MOS_STATUS CodechalEncodeMpeg2G8::InitKernelStateMbEnc() |
| 1774 | { |
| 1775 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1776 | |
| 1777 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1778 | |
| 1779 | for (uint8_t krnStateIdx = 0; krnStateIdx < mbEncKernelIdxNum; krnStateIdx++) |
| 1780 | { |
| 1781 | auto kernelStatePtr = &m_mbEncKernelStates[krnStateIdx]; |
| 1782 | auto kernelSize = m_combinedKernelSize; |
| 1783 | |
| 1784 | CODECHAL_KERNEL_HEADER currKrnHeader; |
| 1785 | CODECHAL_ENCODE_CHK_STATUS_RETURN(pfnGetKernelHeaderAndSize( |
| 1786 | m_kernelBinary, |
| 1787 | ENC_MBENC, |
| 1788 | krnStateIdx, |
| 1789 | &currKrnHeader, |
| 1790 | &kernelSize)); |
| 1791 | |
| 1792 | kernelStatePtr->KernelParams.iBTCount = mbEncNumBindingTableEntries; |
| 1793 | kernelStatePtr->KernelParams.iThreadCount = m_hwInterface->GetRenderInterface()->GetHwCaps()->dwMaxThreads; |
| 1794 | kernelStatePtr->KernelParams.iCurbeLength = MbEncCurbeG8::m_byteSize; |
| 1795 | kernelStatePtr->KernelParams.iBlockWidth = CODECHAL_MACROBLOCK_WIDTH; |
| 1796 | kernelStatePtr->KernelParams.iBlockHeight = CODECHAL_MACROBLOCK_HEIGHT; |
| 1797 | kernelStatePtr->KernelParams.iIdCount = 1; |
| 1798 | |
| 1799 | kernelStatePtr->dwCurbeOffset = m_stateHeapInterface->pStateHeapInterface->GetSizeofCmdInterfaceDescriptorData(); |
| 1800 | kernelStatePtr->KernelParams.pBinary = m_kernelBinary + (currKrnHeader.KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); |
| 1801 | kernelStatePtr->KernelParams.iSize = kernelSize; |
| 1802 | |
| 1803 | CODECHAL_ENCODE_CHK_STATUS_RETURN(m_stateHeapInterface->pfnCalculateSshAndBtSizesRequested( |
| 1804 | m_stateHeapInterface, |
| 1805 | kernelStatePtr->KernelParams.iBTCount, |
| 1806 | &kernelStatePtr->dwSshSize, |
| 1807 | &kernelStatePtr->dwBindingTableSize)); |
| 1808 | |
| 1809 | CODECHAL_ENCODE_CHK_STATUS_RETURN(m_hwInterface->MhwInitISH(m_stateHeapInterface, kernelStatePtr)); |
| 1810 | } |
| 1811 | |
| 1812 | m_mbEncBindingTable.m_mbEncPakObj = mbEncPakObj; |
| 1813 | m_mbEncBindingTable.m_mbEncPakObjPrev = mbEncPakObjPrev; |
| 1814 | m_mbEncBindingTable.m_mbEncCurrentY = mbEncCurrentY; |
| 1815 | m_mbEncBindingTable.m_mbEncBrcDistortionSurface = mbEncBrcDistortionSurface; |
| 1816 | m_mbEncBindingTable.m_mbEncCurrentPic = mbEncCurrentPic; |
| 1817 | m_mbEncBindingTable.m_mbEncForwardPic = mbEncForwardPic; |
| 1818 | m_mbEncBindingTable.m_mbEncBackwardPic = mbEncBackwardPic; |
| 1819 | m_mbEncBindingTable.m_mbEncInterlaceFrameCurrentPic = mbEncInterlaceFrameCurrentPic; |
| 1820 | m_mbEncBindingTable.m_mbEncInterlaceFrameBackwardPic = mbEncInterlaceFrameBackwardPic; |
| 1821 | m_mbEncBindingTable.m_mbEncMbControl = mbEncMbControl; |
| 1822 | |
| 1823 | return eStatus; |
| 1824 | } |
| 1825 | |
| 1826 | MOS_STATUS CodechalEncodeMpeg2G8::SetCurbeMe() |
| 1827 | { |
| 1828 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1829 | |
| 1830 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 1831 | |
| 1832 | MeCurbeG8 cmd; |
| 1833 | |
| 1834 | // r1 |
| 1835 | cmd.m_curbeData.DW3.m_subPelMode = 3; |
| 1836 | if (m_fieldScalingOutputInterleaved) |
| 1837 | { |
| 1838 | cmd.m_curbeData.DW3.m_srcAccess = cmd.m_curbeData.DW3.m_refAccess = |
| 1839 | CodecHal_PictureIsField(m_picParams->m_currOriginalPic) ? 1 : 0; |
| 1840 | cmd.m_curbeData.DW7.m_srcFieldPolarity = |
| 1841 | CodecHal_PictureIsBottomField(m_picParams->m_currOriginalPic) ? 1 : 0; |
| 1842 | } |
| 1843 | |
| 1844 | uint32_t scaleFactor = 4; // Scale factor always 4x, SHME/UHME not supported |
| 1845 | cmd.m_curbeData.DW4.m_pictureHeightMinus1 = |
| 1846 | CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameFieldHeight / scaleFactor) - 1; |
| 1847 | cmd.m_curbeData.DW4.m_pictureWidth = |
| 1848 | CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameWidth / scaleFactor); |
| 1849 | cmd.m_curbeData.DW5.m_qpPrimeY = m_mvCostTableOffset; |
| 1850 | cmd.m_curbeData.DW6.m_meModes = CODECHAL_ENCODE_ME4X_ONLY; |
| 1851 | cmd.m_curbeData.DW6.m_superCombineDist = m_superCombineDistGeneric[m_seqParams->m_targetUsage]; |
| 1852 | cmd.m_curbeData.DW6.m_maxVmvR = m_maxVmvr; |
| 1853 | |
| 1854 | if (!CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) |
| 1855 | { |
| 1856 | cmd.m_curbeData.DW6.m_maxVmvR = cmd.m_curbeData.DW6.m_maxVmvR >> 1; |
| 1857 | } |
| 1858 | |
| 1859 | if (m_pictureCodingType == B_TYPE) |
| 1860 | { |
| 1861 | // This field is irrelevant since we are not using the bi-direct search. |
| 1862 | // set it to 32 |
| 1863 | cmd.m_curbeData.DW1.m_biWeight = 32; |
| 1864 | cmd.m_curbeData.DW13.m_numRefIdxL1MinusOne = 0; // always 0 for MPEG2 |
| 1865 | } |
| 1866 | |
| 1867 | if (m_pictureCodingType == P_TYPE || |
| 1868 | m_pictureCodingType == B_TYPE) |
| 1869 | { |
| 1870 | cmd.m_curbeData.DW13.m_numRefIdxL0MinusOne = 0; // always 0 for MPEG2 |
| 1871 | } |
| 1872 | |
| 1873 | // r3 & r4 |
| 1874 | uint8_t meMethod = (m_pictureCodingType == B_TYPE) ? m_bMeMethodGeneric[m_seqParams->m_targetUsage] : m_meMethodGeneric[m_seqParams->m_targetUsage]; |
| 1875 | uint8_t tableIdx = (m_pictureCodingType == B_TYPE) ? 1 : 0; |
| 1876 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 1877 | &(cmd.m_curbeData.SpDelta), 14 * sizeof(uint32_t), |
| 1878 | CodechalEncoderState::m_encodeSearchPath[tableIdx][meMethod], |
| 1879 | 14 * sizeof(uint32_t))); |
| 1880 | |
| 1881 | // r5 |
| 1882 | cmd.m_curbeData.DW32.m_4xMeMvOutputDataSurfIndex = m_meBindingTable.dwMEMVDataSurface ; |
| 1883 | cmd.m_curbeData.DW34.m_4xMeOutputDistSurfIndex = m_meBindingTable.dwMEDist; |
| 1884 | cmd.m_curbeData.DW35.m_4xMeOutputBrcDistSurfIndex = m_meBindingTable.dwMEBRCDist; |
| 1885 | cmd.m_curbeData.DW36.m_vmeFwdInterPredictionSurfIndex = m_meBindingTable.dwMECurrForFwdRef; |
| 1886 | cmd.m_curbeData.DW37.m_vmeBwdInterPredictionSurfIndex = m_meBindingTable.dwMECurrForBwdRef; |
| 1887 | |
| 1888 | uint32_t krnStateIdx = |
| 1889 | (m_pictureCodingType == P_TYPE) ? CODECHAL_ENCODE_ME_IDX_P : CODECHAL_ENCODE_ME_IDX_B; |
| 1890 | |
| 1891 | if (m_pictureCodingType == B_TYPE && CodecHal_PictureIsInvalid(m_picParams->m_refFrameList[1])) |
| 1892 | { |
| 1893 | krnStateIdx = CODECHAL_ENCODE_ME_IDX_P; |
| 1894 | } |
| 1895 | |
| 1896 | auto kernelState = &m_meKernelStates[krnStateIdx]; |
| 1897 | |
| 1898 | CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData( |
| 1899 | &cmd, |
| 1900 | kernelState->dwCurbeOffset, |
| 1901 | cmd.m_byteSize)); |
| 1902 | return eStatus; |
| 1903 | |
| 1904 | } |
| 1905 | |
| 1906 | MOS_STATUS CodechalEncodeMpeg2G8::SendMeSurfaces( |
| 1907 | PMOS_COMMAND_BUFFER cmdBuffer) |
| 1908 | { |
| 1909 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1910 | |
| 1911 | CODECHAL_ENCODE_CHK_NULL_RETURN(cmdBuffer); |
| 1912 | |
| 1913 | auto meBindingTable = &m_meBindingTable; |
| 1914 | CODECHAL_ENCODE_CHK_NULL_RETURN(meBindingTable); |
| 1915 | PMOS_SURFACE currScaledSurface = m_trackedBuf->Get4xDsSurface(CODEC_CURR_TRACKED_BUFFER); |
| 1916 | PMOS_SURFACE meMvDataBuffer = &m_4xMEMVDataBuffer; |
| 1917 | |
| 1918 | // Reference height and width information should be taken from the current scaled surface rather |
| 1919 | // than from the reference scaled surface in the case of PAFF. |
| 1920 | auto bufWidth = MOS_ALIGN_CEIL(m_downscaledWidthInMb4x * 32, 64); |
| 1921 | auto bufHeight = |
| 1922 | m_downscaledHeightInMb4x * 4 * CODECHAL_ENCODE_ME_DATA_SIZE_MULTIPLIER; |
| 1923 | |
| 1924 | // Force the values |
| 1925 | meMvDataBuffer->dwWidth = bufWidth; |
| 1926 | meMvDataBuffer->dwHeight = bufHeight; |
| 1927 | meMvDataBuffer->dwPitch = bufWidth; |
| 1928 | |
| 1929 | uint32_t krnStateIdx = |
| 1930 | (m_pictureCodingType == P_TYPE) ? CODECHAL_ENCODE_ME_IDX_P : CODECHAL_ENCODE_ME_IDX_B; |
| 1931 | auto kernelState = &m_meKernelStates[krnStateIdx]; |
| 1932 | |
| 1933 | CODECHAL_SURFACE_CODEC_PARAMS surfaceParams; |
| 1934 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 1935 | surfaceParams.bIs2DSurface = true; |
| 1936 | surfaceParams.bMediaBlockRW = true; |
| 1937 | surfaceParams.psSurface = meMvDataBuffer; |
| 1938 | surfaceParams.dwOffset = m_memvBottomFieldOffset; |
| 1939 | surfaceParams.dwCacheabilityControl = |
| 1940 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_MV_DATA_ENCODE].Value; |
| 1941 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMEMVDataSurface; |
| 1942 | surfaceParams.bIsWritable = true; |
| 1943 | surfaceParams.bRenderTarget = true; |
| 1944 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 1945 | m_hwInterface, |
| 1946 | cmdBuffer, |
| 1947 | &surfaceParams, |
| 1948 | kernelState)); |
| 1949 | |
| 1950 | // Insert Distortion buffers only for 4xMe case |
| 1951 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 1952 | surfaceParams.bIs2DSurface = true; |
| 1953 | surfaceParams.bMediaBlockRW = true; |
| 1954 | surfaceParams.psSurface = &m_brcBuffers.sMeBrcDistortionBuffer; |
| 1955 | surfaceParams.dwOffset = m_brcBuffers.dwMeBrcDistortionBottomFieldOffset; |
| 1956 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMEBRCDist; |
| 1957 | surfaceParams.dwCacheabilityControl = |
| 1958 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_BRC_ME_DISTORTION_ENCODE].Value; |
| 1959 | surfaceParams.bIsWritable = true; |
| 1960 | surfaceParams.bRenderTarget = true; |
| 1961 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 1962 | m_hwInterface, |
| 1963 | cmdBuffer, |
| 1964 | &surfaceParams, |
| 1965 | kernelState)); |
| 1966 | |
| 1967 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 1968 | surfaceParams.bIs2DSurface = true; |
| 1969 | surfaceParams.bMediaBlockRW = true; |
| 1970 | surfaceParams.psSurface = &m_4xMEDistortionBuffer; |
| 1971 | surfaceParams.dwOffset = m_meDistortionBottomFieldOffset; |
| 1972 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMEDist; |
| 1973 | surfaceParams.dwCacheabilityControl = |
| 1974 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ME_DISTORTION_ENCODE].Value; |
| 1975 | surfaceParams.bIsWritable = true; |
| 1976 | surfaceParams.bRenderTarget = true; |
| 1977 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 1978 | m_hwInterface, |
| 1979 | cmdBuffer, |
| 1980 | &surfaceParams, |
| 1981 | kernelState)); |
| 1982 | |
| 1983 | bool currFieldPicture = CodecHal_PictureIsField(m_currOriginalPic) ? 1 : 0; |
| 1984 | bool currBottomField = CodecHal_PictureIsBottomField(m_currOriginalPic) ? 1 : 0; |
| 1985 | uint8_t currVDirection = (!currFieldPicture) ? CODECHAL_VDIRECTION_FRAME : |
| 1986 | ((currBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); |
| 1987 | uint32_t refScaledBottomFieldOffset = 0; |
| 1988 | auto refScaledSurface = *currScaledSurface; |
| 1989 | |
| 1990 | // Setup references 1...n |
| 1991 | // LIST 0 references |
| 1992 | CODEC_PICTURE refPic = m_picParams->m_refFrameList[0]; |
| 1993 | // no need to modify index if picture is invalid |
| 1994 | if (refPic.PicFlags != PICTURE_INVALID) |
| 1995 | { |
| 1996 | refPic.FrameIdx = 0; |
| 1997 | } |
| 1998 | |
| 1999 | if (!CodecHal_PictureIsInvalid(refPic) && m_picIdx[refPic.FrameIdx].bValid) |
| 2000 | { |
| 2001 | // Current Picture Y - VME |
| 2002 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 2003 | surfaceParams.bUseAdvState = true; |
| 2004 | surfaceParams.psSurface = currScaledSurface; |
| 2005 | surfaceParams.dwOffset = currBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; |
| 2006 | surfaceParams.dwCacheabilityControl = |
| 2007 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_CURR_ENCODE].Value; |
| 2008 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMECurrForFwdRef; |
| 2009 | surfaceParams.ucVDirection = currVDirection; |
| 2010 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 2011 | m_hwInterface, |
| 2012 | cmdBuffer, |
| 2013 | &surfaceParams, |
| 2014 | kernelState)); |
| 2015 | |
| 2016 | bool refBottomField = (CodecHal_PictureIsBottomField(refPic)) ? 1 : 0; |
| 2017 | uint8_t refPicIdx = m_picIdx[refPic.FrameIdx].ucPicIdx; |
| 2018 | uint8_t scaledIdx = m_refList[refPicIdx]->ucScalingIdx; |
| 2019 | // for 4xMe |
| 2020 | MOS_SURFACE* p4xSurface = m_trackedBuf->Get4xDsSurface(scaledIdx); |
| 2021 | if (p4xSurface != nullptr) |
| 2022 | { |
| 2023 | refScaledSurface.OsResource = p4xSurface->OsResource; |
| 2024 | } |
| 2025 | else |
| 2026 | { |
| 2027 | CODECHAL_ENCODE_ASSERTMESSAGE("NULL pointer of DsSurface"); |
| 2028 | } |
| 2029 | refScaledBottomFieldOffset = refBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; |
| 2030 | |
| 2031 | // L0 Reference Picture Y - VME |
| 2032 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 2033 | surfaceParams.bUseAdvState = true; |
| 2034 | surfaceParams.psSurface = &refScaledSurface; |
| 2035 | surfaceParams.dwOffset = refBottomField ? refScaledBottomFieldOffset : 0; |
| 2036 | surfaceParams.dwCacheabilityControl = |
| 2037 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_REF_ENCODE].Value; |
| 2038 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMEFwdRefPicIdx[0]; |
| 2039 | surfaceParams.ucVDirection = !currFieldPicture ? CODECHAL_VDIRECTION_FRAME : |
| 2040 | ((refBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); |
| 2041 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 2042 | m_hwInterface, |
| 2043 | cmdBuffer, |
| 2044 | &surfaceParams, |
| 2045 | kernelState)); |
| 2046 | } |
| 2047 | |
| 2048 | // Setup references 1...n |
| 2049 | // LIST 1 references |
| 2050 | refPic = m_picParams->m_refFrameList[1]; |
| 2051 | // no need to modify index if picture is invalid |
| 2052 | if (refPic.PicFlags != PICTURE_INVALID) |
| 2053 | { |
| 2054 | refPic.FrameIdx = 1; |
| 2055 | } |
| 2056 | if (!CodecHal_PictureIsInvalid(refPic) && m_picIdx[refPic.FrameIdx].bValid) |
| 2057 | { |
| 2058 | // Current Picture Y - VME |
| 2059 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 2060 | surfaceParams.bUseAdvState = true; |
| 2061 | surfaceParams.psSurface = currScaledSurface; |
| 2062 | surfaceParams.dwOffset = currBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; |
| 2063 | surfaceParams.dwCacheabilityControl = |
| 2064 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_CURR_ENCODE].Value; |
| 2065 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMECurrForBwdRef; |
| 2066 | surfaceParams.ucVDirection = currVDirection; |
| 2067 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 2068 | m_hwInterface, |
| 2069 | cmdBuffer, |
| 2070 | &surfaceParams, |
| 2071 | kernelState)); |
| 2072 | |
| 2073 | bool refBottomField = (CodecHal_PictureIsBottomField(refPic)) ? 1 : 0; |
| 2074 | uint8_t refPicIdx = m_picIdx[refPic.FrameIdx].ucPicIdx; |
| 2075 | uint8_t scaledIdx = m_refList[refPicIdx]->ucScalingIdx; |
| 2076 | |
| 2077 | // for 4xMe |
| 2078 | MOS_SURFACE* p4xSurface = m_trackedBuf->Get4xDsSurface(scaledIdx); |
| 2079 | if (p4xSurface != nullptr) |
| 2080 | { |
| 2081 | refScaledSurface.OsResource = p4xSurface->OsResource; |
| 2082 | } |
| 2083 | else |
| 2084 | { |
| 2085 | CODECHAL_ENCODE_ASSERTMESSAGE("NULL pointer of DsSurface"); |
| 2086 | } |
| 2087 | refScaledBottomFieldOffset = refBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; |
| 2088 | |
| 2089 | // L1 Reference Picture Y - VME |
| 2090 | MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); |
| 2091 | surfaceParams.bUseAdvState = true; |
| 2092 | surfaceParams.psSurface = &refScaledSurface; |
| 2093 | surfaceParams.dwOffset = refBottomField ? refScaledBottomFieldOffset : 0; |
| 2094 | surfaceParams.dwCacheabilityControl = |
| 2095 | m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_REF_ENCODE].Value; |
| 2096 | surfaceParams.dwBindingTableOffset = meBindingTable->dwMEBwdRefPicIdx[0]; |
| 2097 | surfaceParams.ucVDirection = (!currFieldPicture) ? CODECHAL_VDIRECTION_FRAME : |
| 2098 | ((refBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); |
| 2099 | CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalSetRcsSurfaceState( |
| 2100 | m_hwInterface, |
| 2101 | cmdBuffer, |
| 2102 | &surfaceParams, |
| 2103 | kernelState)); |
| 2104 | } |
| 2105 | |
| 2106 | return eStatus; |
| 2107 | } |
| 2108 | |
| 2109 | MOS_STATUS CodechalEncodeMpeg2G8::SetCurbeMbEnc( |
| 2110 | bool mbEncIFrameDistEnabled, |
| 2111 | bool mbQpDataEnabled) |
| 2112 | { |
| 2113 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2114 | |
| 2115 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 2116 | |
| 2117 | uint16_t picWidthInMb = mbEncIFrameDistEnabled ? |
| 2118 | (uint16_t)m_downscaledWidthInMb4x : m_picWidthInMb; |
| 2119 | uint16_t fieldFrameHeightInMb = mbEncIFrameDistEnabled ? |
| 2120 | (uint16_t)m_downscaledFrameFieldHeightInMb4x : m_frameFieldHeightInMb; |
| 2121 | |
| 2122 | MbEncCurbeG8 cmd(m_picParams->m_pictureCodingType); |
| 2123 | |
| 2124 | // Set CURBE data |
| 2125 | cmd.m_curbeData.DW0.m_isInterlacedFrameFlag = |
| 2126 | (CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) ? (m_picParams->m_fieldCodingFlag || m_picParams->m_fieldFrameCodingFlag) : 0; |
| 2127 | cmd.m_curbeData.DW0.m_isTopFieldFirst = cmd.m_curbeData.DW0.m_isInterlacedFrameFlag ? !m_picParams->m_interleavedFieldBFF : 0; |
| 2128 | cmd.m_curbeData.DW0.m_forceToSkip = 0; |
| 2129 | cmd.m_curbeData.DW4.m_fieldFlag = (CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) ? 0 : 1; |
| 2130 | cmd.m_curbeData.DW4.m_picWidth = picWidthInMb; |
| 2131 | cmd.m_curbeData.DW4.m_picHeightMinus1 = fieldFrameHeightInMb - 1; |
| 2132 | |
| 2133 | // This is approximation using first slice |
| 2134 | // MPEG2 quantiser_scale_code legal range is [1, 31] inclusive |
| 2135 | if (m_sliceParams->m_quantiserScaleCode < 1) |
| 2136 | { |
| 2137 | m_sliceParams->m_quantiserScaleCode = 1; |
| 2138 | } |
| 2139 | else if (m_sliceParams->m_quantiserScaleCode > 31) |
| 2140 | { |
| 2141 | m_sliceParams->m_quantiserScaleCode = 31; |
| 2142 | } |
| 2143 | |
| 2144 | cmd.m_curbeData.DW9.m_mbQPEnable = mbQpDataEnabled; |
| 2145 | cmd.m_curbeData.DW11.m_qpScaleCode = m_sliceParams->m_quantiserScaleCode; |
| 2146 | |
| 2147 | if (m_seqParams ->m_rateControlMethod == RATECONTROL_CQP) |
| 2148 | { |
| 2149 | cmd.m_curbeData.DW13.m_panicModeMBThreshold = 0xFFFF; |
| 2150 | } |
| 2151 | |
| 2152 | cmd.m_curbeData.DW14.m_forwardHorizontalSearchRange = 4 << m_picParams->m_fcode00; |
| 2153 | cmd.m_curbeData.DW14.m_forwardVerticalSearchRange = 4 << m_picParams->m_fcode01; |
| 2154 | cmd.m_curbeData.DW15.m_backwardHorizontalSearchRange = 4 << m_picParams->m_fcode10; |
| 2155 | cmd.m_curbeData.DW15.m_backwardVerticalSearchRange = 4 << m_picParams->m_fcode11; |
| 2156 | |
| 2157 | if (m_picParams->m_pictureCodingType == I_TYPE) |
| 2158 | { |
| 2159 | // Modify CURBE for distortion calculation. |
| 2160 | if (mbEncIFrameDistEnabled) |
| 2161 | { |
| 2162 | cmd.m_curbeData.DW4.m_iFrameMBDistortionDumpEnable = true; |
| 2163 | } |
| 2164 | else |
| 2165 | { |
| 2166 | // Make sure the distortion dump flag is disabled for the normal MBEnc case. |
| 2167 | // No need to reset the height and width since they are set |
| 2168 | // correctly above this if-else and not modified after. |
| 2169 | cmd.m_curbeData.DW4.m_iFrameMBDistortionDumpEnable = false; |
| 2170 | } |
| 2171 | } |
| 2172 | else if (m_picParams->m_pictureCodingType == P_TYPE) |
| 2173 | { |
| 2174 | cmd.m_curbeData.DW7.m_skipCenterMask = 0x55; |
| 2175 | |
| 2176 | //Motion vector cost is taken from VME_LUTXY |
| 2177 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2178 | &(cmd.m_curbeData.MvCost), |
| 2179 | sizeof(uint32_t)* 2, |
| 2180 | m_vmeLutXyP, |
| 2181 | sizeof(uint32_t)* 2)); |
| 2182 | |
| 2183 | //VME_SEARCH_PATH |
| 2184 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2185 | &(cmd.m_curbeData.VmeSPath0), |
| 2186 | sizeof(uint32_t)* 16, |
| 2187 | m_vmeSPathP0, |
| 2188 | sizeof(uint32_t)* 16)); |
| 2189 | |
| 2190 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2191 | &(cmd.m_curbeData.VmeSPath1), |
| 2192 | sizeof(uint32_t)* 16, |
| 2193 | m_vmeSPathP1, |
| 2194 | sizeof(uint32_t)* 16)); |
| 2195 | |
| 2196 | //Interlaced motion vector cost is the same as progressive P frame |
| 2197 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2198 | &(cmd.m_curbeData.VmeSPath1.MvCostInterlace), |
| 2199 | sizeof(uint32_t)* 2, |
| 2200 | m_vmeLutXyP, |
| 2201 | sizeof(uint32_t)* 2)); |
| 2202 | |
| 2203 | } |
| 2204 | else// B_TYPE |
| 2205 | { |
| 2206 | cmd.m_curbeData.DW7.m_skipCenterMask = 0xFF; |
| 2207 | |
| 2208 | switch (m_picParams->m_gopRefDist) |
| 2209 | { |
| 2210 | case 3: |
| 2211 | cmd.m_curbeData.DW12.m_distScaleFactor = (m_frameNumB > 1) ? 43 : 21; |
| 2212 | break; |
| 2213 | case 4: |
| 2214 | cmd.m_curbeData.DW12.m_distScaleFactor = (m_frameNumB << 4); |
| 2215 | break; |
| 2216 | default: |
| 2217 | cmd.m_curbeData.DW12.m_distScaleFactor = 32; |
| 2218 | break; |
| 2219 | } |
| 2220 | |
| 2221 | //Motion vector cost is taken from VME_LUTXY |
| 2222 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2223 | &(cmd.m_curbeData.MvCost), sizeof(uint32_t)* 2, |
| 2224 | m_vmeLutXyB, |
| 2225 | sizeof(uint32_t)* 2)); |
| 2226 | |
| 2227 | //VME_SEARCH_PATH |
| 2228 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2229 | &(cmd.m_curbeData.VmeSPath0), |
| 2230 | sizeof(uint32_t)* 16, |
| 2231 | m_vmeSPathB0, |
| 2232 | sizeof(uint32_t)* 16)); |
| 2233 | |
| 2234 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2235 | &(cmd.m_curbeData.VmeSPath1), |
| 2236 | sizeof(uint32_t)* 16, |
| 2237 | m_vmeSPathB1, |
| 2238 | sizeof(uint32_t)* 16)); |
| 2239 | |
| 2240 | //Interlaced motion vector cost is the same as progressive P frame |
| 2241 | CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( |
| 2242 | &(cmd.m_curbeData.VmeSPath1.MvCostInterlace), |
| 2243 | sizeof(uint32_t)* 2, |
| 2244 | m_vmeLutXyP, |
| 2245 | sizeof(uint32_t)* 2)); |
| 2246 | |
| 2247 | } |
| 2248 | |
| 2249 | //ModeCost for P/B pictures |
| 2250 | if (m_picParams->m_pictureCodingType != I_TYPE) |
| 2251 | { |
| 2252 | cmd.m_curbeData.VmeSPath0.DW30.m_value = 0x83; // Setting mode 0 cost to 0x83 (131) |
| 2253 | cmd.m_curbeData.VmeSPath0.DW31.m_value = 0x41414141; // Set mode 4, 5, 6, 7 costs to 0x41 (67) |
| 2254 | } |
| 2255 | |
| 2256 | cmd.m_curbeData.DW48.m_value = 0x05000000; // BB-End Command |
| 2257 | cmd.m_curbeData.DW49.m_value = m_mbEncBindingTable.m_mbEncPakObj; |
| 2258 | cmd.m_curbeData.DW50.m_value = m_mbEncBindingTable.m_mbEncPakObjPrev; |
| 2259 | cmd.m_curbeData.DW51.m_value = m_mbEncBindingTable.m_mbEncCurrentY; |
| 2260 | cmd.m_curbeData.DW52.m_value = m_mbEncBindingTable.m_mbEncCurrentPic; // Also FWD REF & BWD REF too, +1, +2 respectively |
| 2261 | cmd.m_curbeData.DW53.m_value = m_mbEncBindingTable.m_mbEncInterlaceFrameCurrentPic; // Also Int BWD Ref (+1) |
| 2262 | cmd.m_curbeData.DW54.m_value = m_mbEncBindingTable.m_mbEncBrcDistortionSurface; |
| 2263 | cmd.m_curbeData.DW55.m_value = m_mbEncBindingTable.m_mbEncMbControl; |
| 2264 | |
| 2265 | PMHW_KERNEL_STATE kernelState; |
| 2266 | // Initialize DSH kernel region |
| 2267 | if (mbEncIFrameDistEnabled) |
| 2268 | { |
| 2269 | kernelState = &m_brcKernelStates[CODECHAL_ENCODE_BRC_IDX_IFRAMEDIST]; |
| 2270 | } |
| 2271 | else |
| 2272 | { |
| 2273 | // wPictureCodingType: I_TYPE = 1, P_TYPE = 2, B_TYPE = 3 |
| 2274 | // KernelStates are I: 0, P: 1, B: 2 |
| 2275 | // m_mbEncKernelStates: I: m_mbEncKernelStates[0], P: m_mbEncKernelStates[1], B: m_mbEncKernelStates[2] |
| 2276 | uint32_t krnStateIdx = m_pictureCodingType - 1; |
| 2277 | kernelState = &m_mbEncKernelStates[krnStateIdx]; |
| 2278 | } |
| 2279 | CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData( |
| 2280 | &cmd, |
| 2281 | kernelState->dwCurbeOffset, |
| 2282 | cmd.m_byteSize)); |
| 2283 | |
| 2284 | return eStatus; |
| 2285 | |
| 2286 | } |
| 2287 | |
| 2288 | void CodechalEncodeMpeg2G8::UpdateSSDSliceCount() |
| 2289 | { |
| 2290 | CodechalEncodeMpeg2::UpdateSSDSliceCount(); |
| 2291 | |
| 2292 | uint32_t sliceCount; |
| 2293 | if (m_frameHeight * m_frameWidth >= 1280*720) |
| 2294 | { |
| 2295 | sliceCount = 2; |
| 2296 | } |
| 2297 | else |
| 2298 | { |
| 2299 | sliceCount = 1; |
| 2300 | } |
| 2301 | |
| 2302 | if (m_osInterface->pfnSetSliceCount) |
| 2303 | { |
| 2304 | m_osInterface->pfnSetSliceCount(m_osInterface, &sliceCount); |
| 2305 | } |
| 2306 | } |