| 1 |
/* |
| 2 |
* Copyright (c) 2021-2023, 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 ddi_vp_functions.cpp |
| 24 |
//! \brief ddi vp functions implementaion. |
| 25 |
//! |
| 26 |
#include "ddi_vp_functions.h" |
| 27 |
#include "media_libva_util_next.h" |
| 28 |
#include "media_libva_common_next.h" |
| 29 |
#include "media_libva_caps_next.h" |
| 30 |
#include "ddi_vp_tools.h" |
| 31 |
#include "mos_solo_generic.h" |
| 32 |
#include "media_libva_interface_next.h" |
| 33 |
#include "ddi_cp_interface_next.h" |
| 34 |
#include "vp_utils.h" |
| 35 |
#if !defined(ANDROID) && defined(X11_FOUND) |
| 36 |
#include <X11/Xutil.h> |
| 37 |
#include "media_libva_putsurface_linux.h" |
| 38 |
#endif |
| 39 |
|
| 40 |
#define VP_SETTING_MAX_PHASES 1 |
| 41 |
#define VP_SETTING_MEDIA_STATES 32 |
| 42 |
#define VP_SETTING_SAME_SAMPLE_THRESHOLD 1000 |
| 43 |
|
| 44 |
#define VP_MAX_PIC_WIDTH 16384 |
| 45 |
#define VP_MAX_PIC_HEIGHT 16384 |
| 46 |
#define VP_MIN_PIC_WIDTH 16 |
| 47 |
#define VP_MIN_PIC_HEIGHT 16 |
| 48 |
#define QUERY_CAPS_ATTRIBUTE 1 /* query the actual filter caps attribute in vp module */ |
| 49 |
|
| 50 |
// ITU-T H.265 Table E.3: Colour Primaries |
| 51 |
#define COLOUR_PRIMARY_BT2020 9 |
| 52 |
#define COLOUR_PRIMARY_BT709 1 |
| 53 |
#define COLOUR_PRIMARY_BT601 5 |
| 54 |
// ITU-T H.265 Table E.4 Transfer characteristics |
| 55 |
#define TRANSFER_CHARACTERISTICS_BT709 1 |
| 56 |
#define TRANSFER_CHARACTERISTICS_GMAMA2P2 4 |
| 57 |
#define TRANSFER_CHARACTERISTICS_LINEAR 8 |
| 58 |
#define TRANSFER_CHARACTERISTICS_BT2020 14 |
| 59 |
#define TRANSFER_CHARACTERISTICS_ST2084 16 |
| 60 |
|
| 61 |
const VAProcFilterCapColorBalance DdiVpFunctions::m_vpColorBalCap[] = { |
| 62 |
/** \brief Hue. */ |
| 63 |
{VAProcColorBalanceHue, |
| 64 |
{ PROCAMP_HUE_MIN, |
| 65 |
PROCAMP_HUE_MAX, |
| 66 |
PROCAMP_HUE_DEFAULT, |
| 67 |
PROCAMP_HUE_STEP } |
| 68 |
}, |
| 69 |
/** \brief Saturation. */ |
| 70 |
{VAProcColorBalanceSaturation, |
| 71 |
{ PROCAMP_SATURATION_MIN, |
| 72 |
PROCAMP_SATURATION_MAX, |
| 73 |
PROCAMP_SATURATION_DEFAULT, |
| 74 |
PROCAMP_SATURATION_STEP } |
| 75 |
}, |
| 76 |
/** \brief Brightness. */ |
| 77 |
{VAProcColorBalanceBrightness, |
| 78 |
{ PROCAMP_BRIGHTNESS_MIN, |
| 79 |
PROCAMP_BRIGHTNESS_MAX, |
| 80 |
PROCAMP_BRIGHTNESS_DEFAULT, |
| 81 |
PROCAMP_BRIGHTNESS_STEP } |
| 82 |
}, |
| 83 |
/** \brief Contrast. */ |
| 84 |
{VAProcColorBalanceContrast, |
| 85 |
{ PROCAMP_CONTRAST_MIN, |
| 86 |
PROCAMP_CONTRAST_MAX, |
| 87 |
PROCAMP_CONTRAST_DEFAULT, |
| 88 |
PROCAMP_CONTRAST_STEP } |
| 89 |
}, |
| 90 |
/** \brief Automatically adjusted contrast. */ |
| 91 |
{VAProcColorBalanceAutoContrast, |
| 92 |
{ 0.0F, 0.0F, 0.0F, 0.0F } |
| 93 |
} |
| 94 |
}; |
| 95 |
|
| 96 |
const VAProcFilterType DdiVpFunctions::m_vpSupportedFilters[DDI_VP_MAX_NUM_FILTERS] = { |
| 97 |
VAProcFilterNoiseReduction, |
| 98 |
VAProcFilterDeinterlacing, |
| 99 |
VAProcFilterSharpening, |
| 100 |
VAProcFilterColorBalance, |
| 101 |
VAProcFilterSkinToneEnhancement, |
| 102 |
VAProcFilterTotalColorCorrection, |
| 103 |
VAProcFilterHVSNoiseReduction, |
| 104 |
VAProcFilterHighDynamicRangeToneMapping, |
| 105 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 106 |
VAProcFilter3DLUT |
| 107 |
#endif |
| 108 |
}; |
| 109 |
|
| 110 |
VAStatus DdiVpFunctions::CreateContext ( |
| 111 |
VADriverContextP ctx, |
| 112 |
VAConfigID configId, |
| 113 |
int32_t pictureWidth, |
| 114 |
int32_t pictureHeight, |
| 115 |
int32_t flag, |
| 116 |
VASurfaceID *renderTargets, |
| 117 |
int32_t renderTargetsNum, |
| 118 |
VAContextID *ctxID) |
| 119 |
{ |
| 120 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 121 |
|
| 122 |
VAStatus status = VA_STATUS_SUCCESS; |
| 123 |
PDDI_MEDIA_VACONTEXT_HEAP_ELEMENT vaCtxHeapElmt = nullptr; |
| 124 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 125 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 126 |
DDI_VP_FUNC_ENTER; |
| 127 |
|
| 128 |
DDI_UNUSED(configId); |
| 129 |
DDI_UNUSED(pictureWidth); |
| 130 |
DDI_UNUSED(pictureHeight); |
| 131 |
DDI_UNUSED(flag); |
| 132 |
DDI_UNUSED(renderTargets); |
| 133 |
DDI_UNUSED(renderTargetsNum); |
| 134 |
|
| 135 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 136 |
|
| 137 |
*ctxID = VA_INVALID_ID; |
| 138 |
|
| 139 |
mediaCtx = GetMediaContext(ctx); |
| 140 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 141 |
|
| 142 |
// allocate vpCtx |
| 143 |
vpCtx = MOS_New(DDI_VP_CONTEXT); |
| 144 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 145 |
|
| 146 |
// init vpCtx |
| 147 |
status = DdiInitCtx(ctx, vpCtx); |
| 148 |
DDI_CHK_RET(status, "VA_STATUS_ERROR_OPERATION_FAILED"); |
| 149 |
|
| 150 |
MosUtilities::MosLockMutex(&mediaCtx->VpMutex); |
| 151 |
|
| 152 |
// get Free VP context index |
| 153 |
vaCtxHeapElmt = MediaLibvaUtilNext::DdiAllocPVAContextFromHeap(mediaCtx->pVpCtxHeap); |
| 154 |
if (nullptr == vaCtxHeapElmt) |
| 155 |
{ |
| 156 |
MOS_Delete(vpCtx); |
| 157 |
MosUtilities::MosUnlockMutex(&mediaCtx->VpMutex); |
| 158 |
DDI_VP_ASSERTMESSAGE("VP Context number exceeds maximum."); |
| 159 |
return VA_STATUS_ERROR_INVALID_CONTEXT; |
| 160 |
} |
| 161 |
|
| 162 |
// store vpCtx in pMedia |
| 163 |
vaCtxHeapElmt->pVaContext = (void *)vpCtx; |
| 164 |
*ctxID = (VAContextID)(vaCtxHeapElmt->uiVaContextID + DDI_MEDIA_SOFTLET_VACONTEXTID_VP_OFFSET); |
| 165 |
|
| 166 |
// increate VP context number |
| 167 |
mediaCtx->uiNumVPs++; |
| 168 |
|
| 169 |
MosUtilities::MosUnlockMutex(&mediaCtx->VpMutex); |
| 170 |
|
| 171 |
return VA_STATUS_SUCCESS; |
| 172 |
} |
| 173 |
|
| 174 |
VAStatus DdiVpFunctions::DestroyContext ( |
| 175 |
VADriverContextP ctx, |
| 176 |
VAContextID ctxID) |
| 177 |
{ |
| 178 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 179 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 180 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 181 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 182 |
uint32_t vpIndex = 0; |
| 183 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 184 |
|
| 185 |
DDI_VP_FUNC_ENTER; |
| 186 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 187 |
|
| 188 |
// initialize |
| 189 |
mediaCtx = GetMediaContext(ctx); |
| 190 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 191 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(ctx, ctxID, &ctxType); |
| 192 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 193 |
|
| 194 |
MOS_FreeMemory(vpCtx->MosDrvCtx.pPerfData); |
| 195 |
vpCtx->MosDrvCtx.pPerfData = nullptr; |
| 196 |
|
| 197 |
if (vpCtx->pCpDdiInterfaceNext) |
| 198 |
{ |
| 199 |
MOS_Delete(vpCtx->pCpDdiInterfaceNext); |
| 200 |
} |
| 201 |
|
| 202 |
// destroy vphal |
| 203 |
vaStatus = DdiDestroyVpHal(vpCtx); |
| 204 |
|
| 205 |
// Get VP context index |
| 206 |
vpIndex = ctxID & DDI_MEDIA_MASK_VACONTEXTID; |
| 207 |
|
| 208 |
// remove from context array |
| 209 |
MosUtilities::MosLockMutex(&mediaCtx->VpMutex); |
| 210 |
// destroy vp context |
| 211 |
MOS_Delete(vpCtx); |
| 212 |
MediaLibvaUtilNext::DdiReleasePVAContextFromHeap(mediaCtx->pVpCtxHeap, vpIndex); |
| 213 |
|
| 214 |
mediaCtx->uiNumVPs--; |
| 215 |
MosUtilities::MosUnlockMutex(&mediaCtx->VpMutex); |
| 216 |
|
| 217 |
return vaStatus; |
| 218 |
} |
| 219 |
|
| 220 |
VAStatus DdiVpFunctions::CreateBuffer ( |
| 221 |
VADriverContextP ctx, |
| 222 |
VAContextID context, |
| 223 |
VABufferType type, |
| 224 |
uint32_t size, |
| 225 |
uint32_t elementsNum, |
| 226 |
void *data, |
| 227 |
VABufferID *bufId) |
| 228 |
{ |
| 229 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 230 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 231 |
PDDI_MEDIA_BUFFER buf = nullptr; |
| 232 |
PDDI_MEDIA_BUFFER_HEAP_ELEMENT bufferHeapElement = nullptr; |
| 233 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 234 |
PDDI_VP_CONTEXT vpContext = nullptr; |
| 235 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 236 |
void *ctxPtr = nullptr; |
| 237 |
|
| 238 |
DDI_VP_FUNC_ENTER; |
| 239 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 240 |
*bufId = VA_INVALID_ID; |
| 241 |
|
| 242 |
mediaCtx = GetMediaContext(ctx); |
| 243 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 244 |
|
| 245 |
ctxPtr = MediaLibvaCommonNext::GetContextFromContextID(ctx, context, &ctxType); |
| 246 |
DDI_VP_CHK_NULL(ctxPtr, "nullptr ctxPtr", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 247 |
|
| 248 |
vpContext = (PDDI_VP_CONTEXT)ctxPtr; |
| 249 |
|
| 250 |
// only for VAProcFilterParameterBufferType and VAProcPipelineParameterBufferType |
| 251 |
if (type != VAProcFilterParameterBufferType && type != VAProcPipelineParameterBufferType |
| 252 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 253 |
&& type != VAContextParameterUpdateBufferType |
| 254 |
#endif |
| 255 |
) |
| 256 |
{ |
| 257 |
DDI_VP_ASSERTMESSAGE("Unsupported Va Buffer Type."); |
| 258 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 259 |
} |
| 260 |
|
| 261 |
// allocate new buf and init |
| 262 |
buf = MOS_New(DDI_MEDIA_BUFFER); |
| 263 |
DDI_VP_CHK_NULL(buf, "nullptr buf.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 264 |
buf->pMediaCtx = mediaCtx; |
| 265 |
buf->iSize = size * elementsNum; |
| 266 |
buf->uiNumElements = elementsNum; |
| 267 |
buf->uiType = type; |
| 268 |
buf->format = Media_Format_Buffer; |
| 269 |
buf->uiOffset = 0; |
| 270 |
buf->pData = MOS_NewArray(uint8_t, size * elementsNum); |
| 271 |
if (nullptr == buf->pData) |
| 272 |
{ |
| 273 |
MOS_Delete(buf); |
| 274 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 275 |
} |
| 276 |
buf->format = Media_Format_CPU; |
| 277 |
|
| 278 |
bufferHeapElement = MediaLibvaUtilNext::AllocPMediaBufferFromHeap(mediaCtx->pBufferHeap); |
| 279 |
if (nullptr == bufferHeapElement) |
| 280 |
{ |
| 281 |
MOS_DeleteArray(buf->pData); |
| 282 |
MOS_Delete(buf); |
| 283 |
DDI_VP_ASSERTMESSAGE("Invalid buffer index."); |
| 284 |
return VA_STATUS_ERROR_INVALID_BUFFER; |
| 285 |
} |
| 286 |
bufferHeapElement->pBuffer = buf; |
| 287 |
bufferHeapElement->pCtx = (void *)vpContext; |
| 288 |
bufferHeapElement->uiCtxType = DDI_MEDIA_CONTEXT_TYPE_VP; |
| 289 |
*bufId = bufferHeapElement->uiVaBufferID; |
| 290 |
mediaCtx->uiNumBufs++; |
| 291 |
|
| 292 |
// if there is data from client, then dont need to copy data from client |
| 293 |
if (data) |
| 294 |
{ |
| 295 |
// copy client data to new buf |
| 296 |
eStatus = MOS_SecureMemcpy(buf->pData, size * elementsNum, data, size * elementsNum); |
| 297 |
DDI_VP_CHK_CONDITION((eStatus != MOS_STATUS_SUCCESS), "DDI: Failed to copy client data!", VA_STATUS_ERROR_MAX_NUM_EXCEEDED); |
| 298 |
} |
| 299 |
else |
| 300 |
{ |
| 301 |
// do nothing if there is no data from client |
| 302 |
vaStatus = VA_STATUS_SUCCESS; |
| 303 |
} |
| 304 |
|
| 305 |
return vaStatus; |
| 306 |
} |
| 307 |
|
| 308 |
VAStatus DdiVpFunctions::MapBufferInternal( |
| 309 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 310 |
VABufferID bufId, |
| 311 |
void **buf, |
| 312 |
uint32_t flag) |
| 313 |
{ |
| 314 |
DDI_VP_FUNC_ENTER; |
| 315 |
|
| 316 |
return DdiMediaFunctions::MapBufferInternal(mediaCtx, bufId, buf, flag); |
| 317 |
} |
| 318 |
|
| 319 |
VAStatus DdiVpFunctions::UnmapBuffer ( |
| 320 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 321 |
VABufferID bufId) |
| 322 |
{ |
| 323 |
DDI_VP_FUNC_ENTER; |
| 324 |
|
| 325 |
return DdiMediaFunctions::UnmapBuffer(mediaCtx, bufId); |
| 326 |
} |
| 327 |
|
| 328 |
VAStatus DdiVpFunctions::DestroyBuffer( |
| 329 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 330 |
VABufferID bufId) |
| 331 |
{ |
| 332 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 333 |
DDI_MEDIA_BUFFER *mediaBuf = nullptr; |
| 334 |
DDI_VP_FUNC_ENTER; |
| 335 |
|
| 336 |
mediaBuf = MediaLibvaCommonNext::GetBufferFromVABufferID(mediaCtx, bufId); |
| 337 |
DDI_VP_CHK_NULL(mediaBuf, "nullptr mediaBuf", VA_STATUS_ERROR_INVALID_BUFFER); |
| 338 |
|
| 339 |
switch ((int32_t)mediaBuf->uiType) |
| 340 |
{ |
| 341 |
case VAProcPipelineParameterBufferType: |
| 342 |
case VAProcFilterParameterBufferType: |
| 343 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 344 |
case VAContextParameterUpdateBufferType: |
| 345 |
#endif |
| 346 |
MOS_DeleteArray(mediaBuf->pData); |
| 347 |
break; |
| 348 |
default: |
| 349 |
DDI_VP_ASSERTMESSAGE("Unsupported Va Buffer Type."); |
| 350 |
} |
| 351 |
MOS_Delete(mediaBuf); |
| 352 |
|
| 353 |
MediaLibvaInterfaceNext::DestroyBufFromVABufferID(mediaCtx, bufId); |
| 354 |
return vaStatus; |
| 355 |
} |
| 356 |
|
| 357 |
VAStatus DdiVpFunctions::BeginPicture ( |
| 358 |
VADriverContextP ctx, |
| 359 |
VAContextID context, |
| 360 |
VASurfaceID renderTarget) |
| 361 |
{ |
| 362 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 363 |
|
| 364 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 365 |
PDDI_MEDIA_CONTEXT mediaDrvCtx = nullptr; |
| 366 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 367 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 368 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 369 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 370 |
PDDI_MEDIA_SURFACE mediaTgtSurf = nullptr; |
| 371 |
|
| 372 |
DDI_VP_FUNC_ENTER; |
| 373 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 374 |
|
| 375 |
// initialize |
| 376 |
mediaDrvCtx = GetMediaContext(ctx); |
| 377 |
DDI_VP_CHK_NULL(mediaDrvCtx, "nullptr mediaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 378 |
|
| 379 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(ctx, context, &ctxType); |
| 380 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 381 |
|
| 382 |
vpCtx->TargetSurfID = renderTarget; |
| 383 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 384 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 385 |
|
| 386 |
// uDstCount == 0 means no render target is set yet. |
| 387 |
// uDstCount == 1 means 1 render target has been set already. |
| 388 |
// uDstCount == 2 means 2 render targets have been set already. |
| 389 |
DDI_VP_CHK_LESS(vpHalRenderParams->uDstCount, VPHAL_MAX_TARGETS, "Too many render targets for VP.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 390 |
|
| 391 |
vpHalTgtSurf = vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]; |
| 392 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 393 |
|
| 394 |
mediaTgtSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaDrvCtx, renderTarget); |
| 395 |
DDI_VP_CHK_NULL(mediaTgtSurf, "nullptr mediaTgtSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 396 |
mediaTgtSurf->pVpCtx = vpCtx; |
| 397 |
|
| 398 |
// Setup Target VpHal Surface |
| 399 |
vpHalTgtSurf->SurfType = SURF_OUT_RENDERTARGET; |
| 400 |
vpHalTgtSurf->rcSrc.top = 0; |
| 401 |
vpHalTgtSurf->rcSrc.left = 0; |
| 402 |
vpHalTgtSurf->rcSrc.right = mediaTgtSurf->iWidth; |
| 403 |
vpHalTgtSurf->rcSrc.bottom = mediaTgtSurf->iRealHeight; |
| 404 |
vpHalTgtSurf->rcDst.top = 0; |
| 405 |
vpHalTgtSurf->rcDst.left = 0; |
| 406 |
vpHalTgtSurf->rcDst.right = mediaTgtSurf->iWidth; |
| 407 |
vpHalTgtSurf->rcDst.bottom = mediaTgtSurf->iRealHeight; |
| 408 |
vpHalTgtSurf->ExtendedGamut = false; |
| 409 |
|
| 410 |
// Set os resource for VPHal render |
| 411 |
vaStatus = VpSetOsResource(vpCtx, mediaTgtSurf, vpHalRenderParams->uDstCount); |
| 412 |
DDI_CHK_RET(vaStatus, "Call VpSetOsResource failed"); |
| 413 |
|
| 414 |
vpHalTgtSurf->Format = vpHalTgtSurf->OsResource.Format; |
| 415 |
vpHalTgtSurf->TileType = vpHalTgtSurf->OsResource.TileType; |
| 416 |
|
| 417 |
VpSetRenderParams(mediaTgtSurf, vpHalRenderParams, renderTarget); |
| 418 |
|
| 419 |
return VA_STATUS_SUCCESS; |
| 420 |
} |
| 421 |
|
| 422 |
VAStatus DdiVpFunctions::RenderPicture ( |
| 423 |
VADriverContextP ctx, |
| 424 |
VAContextID context, |
| 425 |
VABufferID *buffers, |
| 426 |
int32_t buffersNum) |
| 427 |
{ |
| 428 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 429 |
|
| 430 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 431 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 432 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 433 |
PDDI_MEDIA_BUFFER buf = nullptr; |
| 434 |
void *data = nullptr; |
| 435 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 436 |
int32_t numOfBuffers = buffersNum; |
| 437 |
int32_t priority = 0; |
| 438 |
int32_t priorityIndexInBuffers = -1; |
| 439 |
bool updatePriority = false; |
| 440 |
|
| 441 |
DDI_VP_FUNC_ENTER; |
| 442 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 443 |
|
| 444 |
mediaCtx = GetMediaContext(ctx); |
| 445 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx", VA_STATUS_ERROR_OPERATION_FAILED); |
| 446 |
|
| 447 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(ctx, context, &ctxType); |
| 448 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 449 |
|
| 450 |
//buffersNum check |
| 451 |
DDI_VP_CHK_CONDITION(((numOfBuffers > VPHAL_MAX_SOURCES) || (numOfBuffers <= 0)), |
| 452 |
"numOfBuffers is Invalid.", |
| 453 |
VA_STATUS_ERROR_INVALID_PARAMETER); |
| 454 |
|
| 455 |
priorityIndexInBuffers = MediaLibvaCommonNext::GetGpuPriority(ctx, buffers, numOfBuffers, &updatePriority, &priority); |
| 456 |
if (priorityIndexInBuffers != -1) |
| 457 |
{ |
| 458 |
if (updatePriority) |
| 459 |
{ |
| 460 |
if ((vaStatus = DdiSetGpuPriority(vpCtx, priority)) != VA_STATUS_SUCCESS) |
| 461 |
{ |
| 462 |
return vaStatus; |
| 463 |
} |
| 464 |
} |
| 465 |
MediaLibvaCommonNext::MovePriorityBufferIdToEnd(buffers, priorityIndexInBuffers, numOfBuffers); |
| 466 |
numOfBuffers--; |
| 467 |
} |
| 468 |
if (numOfBuffers == 0) |
| 469 |
{ |
| 470 |
return vaStatus; |
| 471 |
} |
| 472 |
|
| 473 |
for (int32_t i = 0; i < numOfBuffers; i++) |
| 474 |
{ |
| 475 |
buf = MediaLibvaCommonNext::GetBufferFromVABufferID(mediaCtx, buffers[i]); |
| 476 |
DDI_VP_CHK_NULL(buf, "nullptr buf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 477 |
|
| 478 |
MediaLibvaInterfaceNext::MapBuffer(ctx, buffers[i], &data); |
| 479 |
DDI_VP_CHK_NULL(data, "nullptr data.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 480 |
|
| 481 |
switch ((int32_t)buf->uiType) |
| 482 |
{ |
| 483 |
// VP Buffer Types |
| 484 |
case VAProcPipelineParameterBufferType: |
| 485 |
if (VpIsRenderTarget(ctx, vpCtx, (VAProcPipelineParameterBuffer *)data)) |
| 486 |
{ |
| 487 |
vaStatus = VpSetRenderTargetParams(ctx, vpCtx, (VAProcPipelineParameterBuffer *)data); |
| 488 |
} |
| 489 |
else |
| 490 |
{ |
| 491 |
vaStatus = DdiSetProcPipelineParams(ctx, vpCtx, (VAProcPipelineParameterBuffer *)data); |
| 492 |
DDI_CHK_RET(vaStatus, "Unable to set pipeline parameters"); |
| 493 |
} |
| 494 |
break; |
| 495 |
case VAProcFilterParameterBufferType: |
| 496 |
// User is not supposed to pass this buffer type:Refer va_vpp.h |
| 497 |
DDI_VP_ASSERTMESSAGE("Invalid buffer type."); |
| 498 |
vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; |
| 499 |
break; |
| 500 |
|
| 501 |
default: |
| 502 |
DDI_CHK_RET(vaStatus, "Unsupported buffer type!"); |
| 503 |
break; |
| 504 |
} |
| 505 |
MediaLibvaInterfaceNext::UnmapBuffer(ctx, buffers[i]); |
| 506 |
} |
| 507 |
return vaStatus; |
| 508 |
} |
| 509 |
|
| 510 |
VAStatus DdiVpFunctions::EndPicture ( |
| 511 |
VADriverContextP ctx, |
| 512 |
VAContextID context) |
| 513 |
{ |
| 514 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 515 |
|
| 516 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 517 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 518 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 519 |
VpBase *vpHal = nullptr; |
| 520 |
|
| 521 |
DDI_VP_FUNC_ENTER; |
| 522 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 523 |
|
| 524 |
//get VP Context |
| 525 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(ctx, context, &ctxType); |
| 526 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 527 |
|
| 528 |
//Add component tag for VP |
| 529 |
DDI_VP_CHK_NULL(vpCtx->pVpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 530 |
vpCtx->pVpHalRenderParams->Component = COMPONENT_VPCommon; |
| 531 |
|
| 532 |
vpHal = vpCtx->pVpHal; |
| 533 |
DDI_VP_CHK_NULL(vpHal, "nullptr vpHal.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 534 |
eStatus = vpHal->Render(vpCtx->pVpHalRenderParams); |
| 535 |
|
| 536 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 537 |
DdiVpTools::VpDumpProcPipelineParams(ctx, vpCtx); |
| 538 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 539 |
|
| 540 |
VpReportFeatureMode(vpCtx); |
| 541 |
|
| 542 |
// Reset primary surface count for next render call |
| 543 |
vpCtx->iPriSurfs = 0; |
| 544 |
// Reset render target count for next render call |
| 545 |
vpCtx->pVpHalRenderParams->uDstCount = 0; |
| 546 |
|
| 547 |
if (MOS_FAILED(eStatus)) |
| 548 |
{ |
| 549 |
DDI_VP_ASSERTMESSAGE("Failed to call render function."); |
| 550 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 551 |
} |
| 552 |
|
| 553 |
return VA_STATUS_SUCCESS; |
| 554 |
} |
| 555 |
|
| 556 |
VAStatus DdiVpFunctions::CreateConfig ( |
| 557 |
VADriverContextP ctx, |
| 558 |
VAProfile profile, |
| 559 |
VAEntrypoint entrypoint, |
| 560 |
VAConfigAttrib *attribList, |
| 561 |
int32_t attribsNum, |
| 562 |
VAConfigID *configId) |
| 563 |
{ |
| 564 |
VAStatus status = VA_STATUS_SUCCESS; |
| 565 |
|
| 566 |
DDI_VP_FUNC_ENTER; |
| 567 |
// attribList and numAttribs are for future usage. |
| 568 |
DDI_UNUSED(attribList); |
| 569 |
DDI_UNUSED(attribsNum); |
| 570 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 571 |
DDI_VP_CHK_NULL(configId, "nullptr configId", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 572 |
|
| 573 |
PDDI_MEDIA_CONTEXT mediaCtx = GetMediaContext(ctx); |
| 574 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 575 |
DDI_VP_CHK_NULL(mediaCtx->m_capsNext, "nullptr m_caps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 576 |
DDI_VP_CHK_NULL(mediaCtx->m_capsNext->m_capsTable, "nullptr m_capsTable", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 577 |
|
| 578 |
status = mediaCtx->m_capsNext->CreateConfig(profile, entrypoint, attribList, attribsNum, configId); |
| 579 |
DDI_CHK_RET(status, "Create common config failed"); |
| 580 |
|
| 581 |
auto configList = mediaCtx->m_capsNext->GetConfigList(); |
| 582 |
DDI_VP_CHK_NULL(configList, "Get configList failed", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 583 |
|
| 584 |
for(int i = 0; i < configList->size(); i++) |
| 585 |
{ |
| 586 |
if((configList->at(i).profile == profile) && (configList->at(i).entrypoint == entrypoint)) |
| 587 |
{ |
| 588 |
uint32_t curConfigID = ADD_CONFIG_ID_VP_OFFSET(i); |
| 589 |
if(!mediaCtx->m_capsNext->m_capsTable->IsVpConfigId(curConfigID)) |
| 590 |
{ |
| 591 |
DDI_VP_ASSERTMESSAGE("DDI: Invalid configID."); |
| 592 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 593 |
} |
| 594 |
|
| 595 |
*configId = curConfigID; |
| 596 |
return VA_STATUS_SUCCESS; |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; |
| 601 |
} |
| 602 |
|
| 603 |
VAStatus DdiVpFunctions::QueryVideoProcFilters( |
| 604 |
VADriverContextP ctx, |
| 605 |
VAContextID context, |
| 606 |
VAProcFilterType *filters, |
| 607 |
uint32_t *filtersNum) |
| 608 |
{ |
| 609 |
uint32_t maxNumFilters = DDI_VP_MAX_NUM_FILTERS; |
| 610 |
uint32_t i = 0; |
| 611 |
uint32_t supportedFiltersNum = 0; |
| 612 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 613 |
|
| 614 |
DDI_VP_FUNC_ENTER; |
| 615 |
DDI_UNUSED(ctx); |
| 616 |
DDI_UNUSED(context); |
| 617 |
DDI_VP_CHK_NULL(filters, "nullptr filters", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 618 |
DDI_VP_CHK_NULL(filtersNum, "nullptr filtersNum", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 619 |
|
| 620 |
// check if array size is less than VP_MAX_NUM_FILTERS |
| 621 |
if(*filtersNum < maxNumFilters) |
| 622 |
{ |
| 623 |
DDI_VP_NORMALMESSAGE("filtersNum %d < maxNumFilters %d. Probably caused by Libva version upgrade!", *filtersNum, maxNumFilters); |
| 624 |
} |
| 625 |
|
| 626 |
// Set the filters |
| 627 |
while(supportedFiltersNum < *filtersNum && i < DDI_VP_MAX_NUM_FILTERS) |
| 628 |
{ |
| 629 |
uint32_t filterCapsNum = 0; |
| 630 |
vaStatus = QueryVideoProcFilterCaps(ctx, context, m_vpSupportedFilters[i], nullptr, &filterCapsNum); |
| 631 |
if(vaStatus == VA_STATUS_SUCCESS && filterCapsNum != 0) |
| 632 |
{ |
| 633 |
filters[supportedFiltersNum] = m_vpSupportedFilters[i]; |
| 634 |
supportedFiltersNum++; |
| 635 |
} |
| 636 |
i++; |
| 637 |
} |
| 638 |
|
| 639 |
// Tell the app how many valid filters are filled in the array |
| 640 |
*filtersNum = supportedFiltersNum; |
| 641 |
|
| 642 |
return VA_STATUS_SUCCESS; |
| 643 |
} |
| 644 |
|
| 645 |
VAStatus DdiVpFunctions::QueryVideoProcFilterCaps( |
| 646 |
VADriverContextP ctx, |
| 647 |
VAContextID context, |
| 648 |
VAProcFilterType type, |
| 649 |
void *filterCaps, |
| 650 |
uint32_t *filterCapsNum) |
| 651 |
{ |
| 652 |
uint32_t queryCapsNum = 0; /* the filter caps number queried by app layer */ |
| 653 |
uint32_t existCapsNum = 0; /* the actual number of filters in vp module */ |
| 654 |
uint32_t queryFlag = 0; /* QUERY_CAPS_ATTRIBUTE: search caps attribute */ |
| 655 |
PDDI_MEDIA_CONTEXT mediaDrvCtx = nullptr; |
| 656 |
|
| 657 |
DDI_VP_FUNC_ENTER; |
| 658 |
DDI_VP_CHK_NULL (ctx, "nullptr ctx.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 659 |
DDI_VP_CHK_NULL (filterCapsNum, "nullptr filterCapsNum.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 660 |
|
| 661 |
mediaDrvCtx = GetMediaContext(ctx); |
| 662 |
DDI_VP_CHK_NULL (mediaDrvCtx, "nullptr mediaDrvCtx.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 663 |
|
| 664 |
if (*filterCapsNum != 0) |
| 665 |
{ |
| 666 |
/* return filter caps attribute */ |
| 667 |
queryFlag = QUERY_CAPS_ATTRIBUTE; |
| 668 |
/* check filter_caps pointer to fill in the filter_caps */ |
| 669 |
DDI_VP_CHK_NULL (filterCaps, "nullptr filterCaps.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 670 |
} |
| 671 |
|
| 672 |
queryCapsNum = *filterCapsNum; |
| 673 |
|
| 674 |
switch (type) |
| 675 |
{ |
| 676 |
/* Noise reduction filter */ |
| 677 |
case VAProcFilterNoiseReduction: |
| 678 |
{ |
| 679 |
existCapsNum = 1; |
| 680 |
/* set input filter caps number to the actual number of filters in vp module */ |
| 681 |
*filterCapsNum = existCapsNum; |
| 682 |
/* set the actual filter caps attribute in vp module */ |
| 683 |
DDI_CHK_RET(QueryNoiseReductionCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query Noise Reduction Caps Attribute Failed.") |
| 684 |
break; |
| 685 |
} |
| 686 |
/* HVS Noise reduction filter */ |
| 687 |
case VAProcFilterHVSNoiseReduction: |
| 688 |
{ |
| 689 |
existCapsNum = 0; |
| 690 |
*filterCapsNum = existCapsNum; |
| 691 |
if (MEDIA_IS_SKU(&mediaDrvCtx->SkuTable, FtrHVSDenoise)) |
| 692 |
{ |
| 693 |
existCapsNum = 4; |
| 694 |
*filterCapsNum = existCapsNum; |
| 695 |
} |
| 696 |
break; |
| 697 |
} |
| 698 |
/* Deinterlacing filter */ |
| 699 |
case VAProcFilterDeinterlacing: |
| 700 |
{ |
| 701 |
existCapsNum = 3; |
| 702 |
/* set input filter caps number to the actual number of filters in vp module */ |
| 703 |
*filterCapsNum = existCapsNum; |
| 704 |
/* set the actual filter caps attribute in vp module */ |
| 705 |
DDI_CHK_RET(QueryDeinterlacingCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query Deinterlacing filter Caps Attribute Failed."); |
| 706 |
break; |
| 707 |
} |
| 708 |
/* Sharpening filter. */ |
| 709 |
case VAProcFilterSharpening: |
| 710 |
{ |
| 711 |
existCapsNum = 1; |
| 712 |
/* set input filter caps number to the actual number of filters in vp module */ |
| 713 |
*filterCapsNum = existCapsNum; |
| 714 |
/* set the actual filter caps attribute in vp module */ |
| 715 |
DDI_CHK_RET(QuerySharpeningCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query Sharpening filter Cpas Attribute Failed."); |
| 716 |
break; |
| 717 |
} |
| 718 |
/* Color balance parameters. */ |
| 719 |
case VAProcFilterColorBalance: |
| 720 |
{ |
| 721 |
existCapsNum = sizeof(m_vpColorBalCap)/sizeof(VAProcFilterCapColorBalance); |
| 722 |
/* set input filter caps number to the actual number of filters in vp module */ |
| 723 |
*filterCapsNum = existCapsNum; |
| 724 |
/* set the actual filter caps attribute in vp module */ |
| 725 |
DDI_CHK_RET(QueryColorBalanceCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query Color Balance Caps Attribute Failed."); |
| 726 |
break; |
| 727 |
} |
| 728 |
case VAProcFilterSkinToneEnhancement: |
| 729 |
{ |
| 730 |
existCapsNum = 1; |
| 731 |
*filterCapsNum = existCapsNum; |
| 732 |
DDI_CHK_RET(QuerySkinToneEnhancementCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query SkinTone Enhancement Caps Attribute Failed."); |
| 733 |
break; |
| 734 |
} |
| 735 |
case VAProcFilterTotalColorCorrection: |
| 736 |
{ |
| 737 |
existCapsNum = 6; |
| 738 |
*filterCapsNum = existCapsNum; |
| 739 |
DDI_CHK_RET(QueryTotalColorCorrectionCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query Total Color Correction Caps Attribute Failed."); |
| 740 |
break; |
| 741 |
} |
| 742 |
case VAProcFilterHighDynamicRangeToneMapping: |
| 743 |
{ |
| 744 |
existCapsNum = 0; |
| 745 |
*filterCapsNum = existCapsNum; |
| 746 |
if (MEDIA_IS_SKU(&mediaDrvCtx->SkuTable, FtrHDR)) |
| 747 |
{ |
| 748 |
existCapsNum = 1; |
| 749 |
*filterCapsNum = existCapsNum; |
| 750 |
DDI_CHK_RET(QueryHDRToneMappingCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query High Dynamic Range ToneMapping Caps Attribute Failed."); |
| 751 |
} |
| 752 |
break; |
| 753 |
} |
| 754 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 755 |
case VAProcFilter3DLUT: |
| 756 |
{ |
| 757 |
existCapsNum = 0; |
| 758 |
*filterCapsNum = existCapsNum; |
| 759 |
/* 3DLUT is supported in VEBOX on Gen11+*/ |
| 760 |
if (!MEDIA_IS_SKU(&mediaDrvCtx->SkuTable, FtrDisableVEBoxFeatures)) |
| 761 |
{ |
| 762 |
existCapsNum = 3; |
| 763 |
*filterCapsNum = existCapsNum; |
| 764 |
DDI_CHK_RET(QueryLut3DCapsAttrib(queryFlag, queryCapsNum, existCapsNum, filterCaps), "Query 3Dlut Caps Attribute Failed."); |
| 765 |
} |
| 766 |
|
| 767 |
break; |
| 768 |
} |
| 769 |
#endif |
| 770 |
|
| 771 |
case VAProcFilterCount: |
| 772 |
case VAProcFilterNone: |
| 773 |
return VA_STATUS_ERROR_INVALID_VALUE; |
| 774 |
|
| 775 |
default: |
| 776 |
return VA_STATUS_ERROR_UNSUPPORTED_FILTER; |
| 777 |
} |
| 778 |
|
| 779 |
return VA_STATUS_SUCCESS; |
| 780 |
} |
| 781 |
|
| 782 |
VAStatus DdiVpFunctions::QueryVideoProcPipelineCaps( |
| 783 |
VADriverContextP ctx, |
| 784 |
VAContextID context, |
| 785 |
VABufferID *filters, |
| 786 |
uint32_t filtersNum, |
| 787 |
VAProcPipelineCaps *pipelineCaps) |
| 788 |
{ |
| 789 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 790 |
|
| 791 |
DDI_VP_FUNC_ENTER; |
| 792 |
DDI_VP_CHK_NULL(ctx, "nullptr ctx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 793 |
DDI_VP_CHK_NULL(pipelineCaps, "nullptr pipelineCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 794 |
|
| 795 |
if (filtersNum > 0) |
| 796 |
{ |
| 797 |
DDI_VP_CHK_NULL(filters, "nullptr filters", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 798 |
} |
| 799 |
mediaCtx = GetMediaContext(ctx); |
| 800 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 801 |
|
| 802 |
pipelineCaps->pipeline_flags = VA_PROC_PIPELINE_FAST; |
| 803 |
pipelineCaps->filter_flags = 0; |
| 804 |
pipelineCaps->rotation_flags = (1 << VA_ROTATION_NONE) | (1 << VA_ROTATION_90) | (1 << VA_ROTATION_180) | (1 << VA_ROTATION_270); |
| 805 |
pipelineCaps->mirror_flags = VA_MIRROR_HORIZONTAL | VA_MIRROR_VERTICAL; |
| 806 |
pipelineCaps->blend_flags = VA_BLEND_GLOBAL_ALPHA | VA_BLEND_PREMULTIPLIED_ALPHA | VA_BLEND_LUMA_KEY; |
| 807 |
pipelineCaps->num_forward_references = DDI_CODEC_NUM_FWD_REF; |
| 808 |
pipelineCaps->num_backward_references = DDI_CODEC_NUM_BK_REF; |
| 809 |
pipelineCaps->input_color_standards = const_cast<VAProcColorStandardType*>(m_vpInputColorStd); |
| 810 |
pipelineCaps->num_input_color_standards = DDI_VP_NUM_INPUT_COLOR_STD; |
| 811 |
pipelineCaps->output_color_standards = const_cast<VAProcColorStandardType*>(m_vpOutputColorStd); |
| 812 |
pipelineCaps->num_output_color_standards = DDI_VP_NUM_OUT_COLOR_STD; |
| 813 |
|
| 814 |
//Capability of Gen9+ platform |
| 815 |
pipelineCaps->max_input_width = VP_MAX_PIC_WIDTH; |
| 816 |
pipelineCaps->max_input_height = VP_MAX_PIC_HEIGHT; |
| 817 |
pipelineCaps->max_output_width = VP_MAX_PIC_WIDTH; |
| 818 |
pipelineCaps->max_output_height = VP_MAX_PIC_HEIGHT; |
| 819 |
|
| 820 |
pipelineCaps->min_input_width = VP_MIN_PIC_WIDTH; |
| 821 |
pipelineCaps->min_input_height = VP_MIN_PIC_HEIGHT; |
| 822 |
pipelineCaps->min_output_width = VP_MIN_PIC_WIDTH; |
| 823 |
pipelineCaps->min_output_height = VP_MIN_PIC_WIDTH; |
| 824 |
|
| 825 |
|
| 826 |
for (int i = 0; i < filtersNum; i++) { |
| 827 |
void *pData; |
| 828 |
DdiMedia_MapBuffer(ctx, filters[i], &pData); |
| 829 |
DDI_CHK_NULL(pData, "nullptr pData", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 830 |
VAProcFilterParameterBufferBase* base_param = (VAProcFilterParameterBufferBase*) pData; |
| 831 |
if (base_param->type == VAProcFilterDeinterlacing) |
| 832 |
{ |
| 833 |
VAProcFilterParameterBufferDeinterlacing *di_param = (VAProcFilterParameterBufferDeinterlacing *)base_param; |
| 834 |
if (di_param->algorithm == VAProcDeinterlacingMotionAdaptive || |
| 835 |
di_param->algorithm == VAProcDeinterlacingMotionCompensated) |
| 836 |
{ |
| 837 |
pipelineCaps->num_forward_references = 1; |
| 838 |
} |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
return VA_STATUS_SUCCESS; |
| 843 |
} |
| 844 |
|
| 845 |
VAStatus DdiVpFunctions::DdiInitCtx( |
| 846 |
VADriverContextP vaDrvCtx, |
| 847 |
PDDI_VP_CONTEXT vpCtx) |
| 848 |
{ |
| 849 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 850 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 851 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 852 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 853 |
|
| 854 |
DDI_VP_FUNC_ENTER; |
| 855 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 856 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 857 |
|
| 858 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 859 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 860 |
|
| 861 |
// initialize VPHAL |
| 862 |
vpCtx->MosDrvCtx.bufmgr = mediaCtx->pDrmBufMgr; |
| 863 |
vpCtx->MosDrvCtx.fd = mediaCtx->fd; |
| 864 |
vpCtx->MosDrvCtx.iDeviceId = mediaCtx->iDeviceId; |
| 865 |
vpCtx->MosDrvCtx.m_skuTable = mediaCtx->SkuTable; |
| 866 |
vpCtx->MosDrvCtx.m_waTable = mediaCtx->WaTable; |
| 867 |
vpCtx->MosDrvCtx.m_gtSystemInfo = *mediaCtx->pGtSystemInfo; |
| 868 |
vpCtx->MosDrvCtx.m_platform = mediaCtx->platform; |
| 869 |
vpCtx->MosDrvCtx.m_auxTableMgr = mediaCtx->m_auxTableMgr; |
| 870 |
vpCtx->MosDrvCtx.pGmmClientContext = mediaCtx->pGmmClientContext; |
| 871 |
vpCtx->MosDrvCtx.ppMediaMemDecompState = &mediaCtx->pMediaMemDecompState; |
| 872 |
vpCtx->MosDrvCtx.pfnMediaMemoryCopy = mediaCtx->pfnMediaMemoryCopy; |
| 873 |
vpCtx->MosDrvCtx.pfnMediaMemoryCopy2D = mediaCtx->pfnMediaMemoryCopy2D; |
| 874 |
vpCtx->MosDrvCtx.pfnMemoryDecompress = mediaCtx->pfnMemoryDecompress; |
| 875 |
vpCtx->MosDrvCtx.ppMediaCopyState = &mediaCtx->pMediaCopyState; |
| 876 |
|
| 877 |
vpCtx->MosDrvCtx.m_osDeviceContext = mediaCtx->m_osDeviceContext; |
| 878 |
vpCtx->MosDrvCtx.m_apoMosEnabled = true; |
| 879 |
vpCtx->MosDrvCtx.m_userSettingPtr = mediaCtx->m_userSettingPtr; |
| 880 |
|
| 881 |
vpCtx->MosDrvCtx.pPerfData = (PERF_DATA *)MOS_AllocAndZeroMemory(sizeof(PERF_DATA)); |
| 882 |
DDI_VP_CHK_NULL(vpCtx->MosDrvCtx.pPerfData, "nullptr vpCtx->MosDrvCtx.pPerfData", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 883 |
|
| 884 |
// initialize DDI level cp interface |
| 885 |
vpCtx->pCpDdiInterfaceNext = CreateDdiCpNext(&vpCtx->MosDrvCtx); |
| 886 |
if (nullptr == vpCtx->pCpDdiInterfaceNext) |
| 887 |
{ |
| 888 |
FreeVpHalRenderParams(vpCtx, vpHalRenderParams); |
| 889 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 890 |
} |
| 891 |
|
| 892 |
DDI_CHK_RET(DdiInitVpHal(vpCtx), "Call DdiInitVpHal failed"); |
| 893 |
|
| 894 |
// allocate vphal render param |
| 895 |
vpHalRenderParams = MOS_New(VPHAL_RENDER_PARAMS); |
| 896 |
if( nullptr == vpHalRenderParams) |
| 897 |
{ |
| 898 |
FreeVpHalRenderParams(vpCtx, vpHalRenderParams); |
| 899 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 900 |
} |
| 901 |
|
| 902 |
// initialize vphal render params |
| 903 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 904 |
{ |
| 905 |
vpHalRenderParams->pSrc[surfIndex] = MOS_New(VPHAL_SURFACE); |
| 906 |
if( nullptr == vpHalRenderParams->pSrc[surfIndex]) |
| 907 |
{ |
| 908 |
FreeVpHalRenderParams(vpCtx, vpHalRenderParams); |
| 909 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 910 |
} |
| 911 |
} |
| 912 |
|
| 913 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_TARGETS; surfIndex++) |
| 914 |
{ |
| 915 |
vpHalRenderParams->pTarget[surfIndex] = MOS_New(VPHAL_SURFACE); |
| 916 |
if( nullptr == vpHalRenderParams->pTarget[surfIndex]) |
| 917 |
{ |
| 918 |
FreeVpHalRenderParams(vpCtx, vpHalRenderParams); |
| 919 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 920 |
} |
| 921 |
} |
| 922 |
|
| 923 |
// background Colorfill |
| 924 |
vpHalRenderParams->pColorFillParams = MOS_New(VPHAL_COLORFILL_PARAMS); |
| 925 |
if( nullptr == vpHalRenderParams->pColorFillParams) |
| 926 |
{ |
| 927 |
FreeVpHalRenderParams(vpCtx, vpHalRenderParams); |
| 928 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 929 |
} |
| 930 |
|
| 931 |
// reset source surface count |
| 932 |
vpHalRenderParams->uSrcCount = 0; |
| 933 |
vpCtx->MosDrvCtx.wRevision = 0; |
| 934 |
vpCtx->iPriSurfs = 0; |
| 935 |
|
| 936 |
// Add the render param for calculating alpha value. |
| 937 |
// Because can not pass the alpha calculate flag from iVP, |
| 938 |
// need to hardcode here for both Android and Linux. |
| 939 |
vpHalRenderParams->bCalculatingAlpha = true; |
| 940 |
|
| 941 |
// put the render param in vp context |
| 942 |
vpCtx->pVpHalRenderParams = vpHalRenderParams; |
| 943 |
|
| 944 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 945 |
vaStatus = DdiVpTools::InitDumpConfig(vpCtx); |
| 946 |
DDI_CHK_RET(vaStatus, "Init Dump Config failed"); |
| 947 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 948 |
|
| 949 |
return VA_STATUS_SUCCESS; |
| 950 |
} |
| 951 |
|
| 952 |
void DdiVpFunctions::FreeVpHalRenderParams( |
| 953 |
PDDI_VP_CONTEXT vpCtx, |
| 954 |
PVPHAL_RENDER_PARAMS vpHalRenderParams) |
| 955 |
{ |
| 956 |
DDI_VP_FUNC_ENTER; |
| 957 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx", ); |
| 958 |
|
| 959 |
if(vpHalRenderParams) |
| 960 |
{ |
| 961 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 962 |
{ |
| 963 |
MOS_Delete(vpHalRenderParams->pSrc[surfIndex]); |
| 964 |
} |
| 965 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_TARGETS; surfIndex++) |
| 966 |
{ |
| 967 |
MOS_Delete(vpHalRenderParams->pTarget[surfIndex]); |
| 968 |
} |
| 969 |
|
| 970 |
MOS_Delete(vpHalRenderParams->pColorFillParams); |
| 971 |
MOS_Delete(vpHalRenderParams); |
| 972 |
} |
| 973 |
|
| 974 |
if (vpCtx->pCpDdiInterfaceNext) |
| 975 |
{ |
| 976 |
MOS_Delete(vpCtx->pCpDdiInterfaceNext); |
| 977 |
} |
| 978 |
|
| 979 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 980 |
DdiVpTools::DestoryDumpConfig(vpCtx); |
| 981 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 982 |
return; |
| 983 |
} |
| 984 |
|
| 985 |
VAStatus DdiVpFunctions::DdiInitVpHal( |
| 986 |
PDDI_VP_CONTEXT vpCtx) |
| 987 |
{ |
| 988 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 989 |
|
| 990 |
VpBase *vpHal = nullptr; |
| 991 |
VpSettings vpHalSettings = {}; |
| 992 |
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; |
| 993 |
|
| 994 |
DDI_VP_FUNC_ENTER; |
| 995 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 996 |
|
| 997 |
// Create VpHal state |
| 998 |
MOS_STATUS status = MOS_STATUS_UNKNOWN; |
| 999 |
vpHal = VpBase::VphalStateFactory( nullptr, &(vpCtx->MosDrvCtx), &status); |
| 1000 |
if (vpHal && MOS_FAILED(status)) |
| 1001 |
{ |
| 1002 |
MOS_Delete(vpHal); |
| 1003 |
vpHal = nullptr; |
| 1004 |
} |
| 1005 |
if (!vpHal) |
| 1006 |
{ |
| 1007 |
DDI_VP_ASSERTMESSAGE("Failed to create vphal."); |
| 1008 |
MOS_Delete(vpCtx); |
| 1009 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 1010 |
} |
| 1011 |
|
| 1012 |
vpHalSettings.maxPhases = VP_SETTING_MAX_PHASES; |
| 1013 |
vpHalSettings.mediaStates = VP_SETTING_MEDIA_STATES; |
| 1014 |
vpHalSettings.sameSampleThreshold = VP_SETTING_SAME_SAMPLE_THRESHOLD; |
| 1015 |
vpHalSettings.disableDnDi = false; |
| 1016 |
|
| 1017 |
// Allocate resources (state heaps, resources, KDLL) |
| 1018 |
if (MOS_FAILED(vpHal->Allocate(&vpHalSettings))) |
| 1019 |
{ |
| 1020 |
DDI_VP_ASSERTMESSAGE("Failed to allocate resources for vphal."); |
| 1021 |
MOS_Delete(vpHal); |
| 1022 |
vpHal = nullptr; |
| 1023 |
return vaStatus; |
| 1024 |
} |
| 1025 |
|
| 1026 |
vpCtx->pVpHal = vpHal; |
| 1027 |
return VA_STATUS_SUCCESS; |
| 1028 |
} |
| 1029 |
|
| 1030 |
VAStatus DdiVpFunctions::DdiDestroyVpHal(PDDI_VP_CONTEXT vpCtx) |
| 1031 |
{ |
| 1032 |
DDI_VP_FUNC_ENTER; |
| 1033 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1034 |
|
| 1035 |
DdiDestroyRenderParams(vpCtx); |
| 1036 |
|
| 1037 |
// Destroy VPHAL context |
| 1038 |
if (vpCtx) |
| 1039 |
{ |
| 1040 |
vpCtx->MosDrvCtx.m_skuTable.reset(); |
| 1041 |
vpCtx->MosDrvCtx.m_waTable.reset(); |
| 1042 |
if (vpCtx->pVpHal) |
| 1043 |
{ |
| 1044 |
MOS_Delete(vpCtx->pVpHal); |
| 1045 |
vpCtx->pVpHal = nullptr; |
| 1046 |
} |
| 1047 |
|
| 1048 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 1049 |
DdiVpTools::DestoryDumpConfig(vpCtx); |
| 1050 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 1051 |
} |
| 1052 |
|
| 1053 |
return VA_STATUS_SUCCESS; |
| 1054 |
} |
| 1055 |
|
| 1056 |
VAStatus DdiVpFunctions::DdiDestroyRenderParams(PDDI_VP_CONTEXT vpCtx) |
| 1057 |
{ |
| 1058 |
DDI_VP_FUNC_ENTER; |
| 1059 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1060 |
|
| 1061 |
DdiDestroySrcParams(vpCtx); |
| 1062 |
DdiDestroyTargetParams(vpCtx); |
| 1063 |
|
| 1064 |
if (vpCtx->pVpHalRenderParams) |
| 1065 |
{ |
| 1066 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSplitScreenDemoModeParams); |
| 1067 |
MOS_Delete(vpCtx->pVpHalRenderParams->pCompAlpha); |
| 1068 |
if (vpCtx->pVpHalRenderParams->pColorFillParams) |
| 1069 |
{ |
| 1070 |
MOS_Delete(vpCtx->pVpHalRenderParams->pColorFillParams); |
| 1071 |
} |
| 1072 |
MOS_Delete(vpCtx->pVpHalRenderParams); |
| 1073 |
} |
| 1074 |
|
| 1075 |
return VA_STATUS_SUCCESS; |
| 1076 |
} |
| 1077 |
|
| 1078 |
VAStatus DdiVpFunctions::DdiDestroySrcParams(PDDI_VP_CONTEXT vpCtx) |
| 1079 |
{ |
| 1080 |
DDI_VP_FUNC_ENTER; |
| 1081 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1082 |
DDI_VP_CHK_NULL(vpCtx->pVpHalRenderParams, "nullptr vpCtx->pVpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1083 |
|
| 1084 |
for (uint32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 1085 |
{ |
| 1086 |
if (nullptr != vpCtx->pVpHalRenderParams->pSrc[surfIndex]) |
| 1087 |
{ |
| 1088 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pProcampParams); |
| 1089 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pDeinterlaceParams); |
| 1090 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pDenoiseParams); |
| 1091 |
if (vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams) |
| 1092 |
{ |
| 1093 |
if (!vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams->pExtParam) |
| 1094 |
{ |
| 1095 |
DDI_VP_ASSERTMESSAGE("vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams->pExtParam is nullptr."); |
| 1096 |
} |
| 1097 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams); |
| 1098 |
} |
| 1099 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pBlendingParams); |
| 1100 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pLumaKeyParams); |
| 1101 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pColorPipeParams); |
| 1102 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pHDRParams); |
| 1103 |
if (vpCtx->pVpHalRenderParams->pSrc[surfIndex]->p3DLutParams) |
| 1104 |
{ |
| 1105 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->p3DLutParams->pExt3DLutSurface); |
| 1106 |
} |
| 1107 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->p3DLutParams); |
| 1108 |
DdiDestroyVpHalSurface(vpCtx->pVpHalRenderParams->pSrc[surfIndex]); |
| 1109 |
vpCtx->pVpHalRenderParams->pSrc[surfIndex] = nullptr; |
| 1110 |
} |
| 1111 |
} |
| 1112 |
|
| 1113 |
return VA_STATUS_SUCCESS; |
| 1114 |
} |
| 1115 |
|
| 1116 |
VAStatus DdiVpFunctions::DdiDestroyVpHalSurface(PVPHAL_SURFACE surf) |
| 1117 |
{ |
| 1118 |
DDI_VP_FUNC_ENTER; |
| 1119 |
DDI_VP_CHK_NULL(surf, "nullptr surf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1120 |
|
| 1121 |
if (surf->pFwdRef) |
| 1122 |
{ |
| 1123 |
DdiDestroyVpHalSurface(surf->pFwdRef); |
| 1124 |
} |
| 1125 |
if (surf->pBwdRef) |
| 1126 |
{ |
| 1127 |
DdiDestroyVpHalSurface(surf->pBwdRef); |
| 1128 |
} |
| 1129 |
|
| 1130 |
MOS_Delete(surf); |
| 1131 |
return VA_STATUS_SUCCESS; |
| 1132 |
} |
| 1133 |
|
| 1134 |
VAStatus DdiVpFunctions::DdiDestroyTargetParams(PDDI_VP_CONTEXT vpCtx) |
| 1135 |
{ |
| 1136 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 1137 |
PVPHAL_SURFACE targetSurface = nullptr; |
| 1138 |
|
| 1139 |
DDI_VP_FUNC_ENTER; |
| 1140 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1141 |
DDI_VP_CHK_NULL(vpCtx->pVpHalRenderParams, "nullptr vpCtx->pVpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1142 |
|
| 1143 |
vpHalRenderParams = vpCtx->pVpHalRenderParams; |
| 1144 |
for (uint32_t targetIndex = 0; targetIndex < VPHAL_MAX_TARGETS; targetIndex++) |
| 1145 |
{ |
| 1146 |
targetSurface = vpHalRenderParams->pTarget[targetIndex]; |
| 1147 |
if (targetSurface) |
| 1148 |
{ |
| 1149 |
if (targetSurface->OsResource.bo) |
| 1150 |
{ |
| 1151 |
targetSurface->OsResource.bo = nullptr; |
| 1152 |
} |
| 1153 |
if (targetSurface->pProcampParams) |
| 1154 |
{ |
| 1155 |
MOS_Delete(targetSurface->pProcampParams); |
| 1156 |
} |
| 1157 |
if (targetSurface->pDeinterlaceParams) |
| 1158 |
{ |
| 1159 |
MOS_Delete(targetSurface->pDeinterlaceParams); |
| 1160 |
} |
| 1161 |
if (targetSurface->pDenoiseParams) |
| 1162 |
{ |
| 1163 |
MOS_Delete(targetSurface->pDenoiseParams); |
| 1164 |
} |
| 1165 |
if (targetSurface->pHDRParams) |
| 1166 |
{ |
| 1167 |
MOS_Delete(targetSurface->pHDRParams); |
| 1168 |
} |
| 1169 |
|
| 1170 |
MOS_Delete(vpHalRenderParams->pTarget[targetIndex]); |
| 1171 |
} |
| 1172 |
} |
| 1173 |
// reset render target count |
| 1174 |
vpHalRenderParams->uDstCount = 0; |
| 1175 |
|
| 1176 |
return VA_STATUS_SUCCESS; |
| 1177 |
} |
| 1178 |
|
| 1179 |
VAStatus DdiVpFunctions::QueryNoiseReductionCapsAttrib( |
| 1180 |
uint32_t queryFlag, |
| 1181 |
uint32_t queryCapsNum, |
| 1182 |
uint32_t existCapsNum, |
| 1183 |
void *filterCaps) |
| 1184 |
{ |
| 1185 |
VAProcFilterCap *dnCap = nullptr; |
| 1186 |
DDI_VP_FUNC_ENTER; |
| 1187 |
|
| 1188 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1189 |
{ |
| 1190 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1191 |
if (queryCapsNum < existCapsNum) |
| 1192 |
{ |
| 1193 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1194 |
} |
| 1195 |
dnCap = (VAProcFilterCap *)filterCaps; |
| 1196 |
dnCap->range.min_value = NOISEREDUCTION_MIN; |
| 1197 |
dnCap->range.max_value = NOISEREDUCTION_MAX; |
| 1198 |
dnCap->range.default_value = NOISEREDUCTION_DEFAULT; |
| 1199 |
dnCap->range.step = NOISEREDUCTION_STEP; |
| 1200 |
} |
| 1201 |
return VA_STATUS_SUCCESS; |
| 1202 |
} |
| 1203 |
|
| 1204 |
VAStatus DdiVpFunctions::QueryDeinterlacingCapsAttrib( |
| 1205 |
uint32_t queryFlag, |
| 1206 |
uint32_t queryCapsNum, |
| 1207 |
uint32_t existCapsNum, |
| 1208 |
void *filterCaps) |
| 1209 |
{ |
| 1210 |
VAProcFilterCapDeinterlacing *diCap = nullptr; |
| 1211 |
DDI_VP_FUNC_ENTER; |
| 1212 |
|
| 1213 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1214 |
{ |
| 1215 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1216 |
if (queryCapsNum < existCapsNum) |
| 1217 |
{ |
| 1218 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1219 |
} |
| 1220 |
diCap = (VAProcFilterCapDeinterlacing*)filterCaps; |
| 1221 |
diCap[0].type = VAProcDeinterlacingBob; |
| 1222 |
diCap[1].type = VAProcDeinterlacingMotionAdaptive; |
| 1223 |
diCap[2].type = VAProcDeinterlacingMotionCompensated; |
| 1224 |
} |
| 1225 |
return VA_STATUS_SUCCESS; |
| 1226 |
} |
| 1227 |
|
| 1228 |
VAStatus DdiVpFunctions::QuerySharpeningCapsAttrib( |
| 1229 |
uint32_t queryFlag, |
| 1230 |
uint32_t queryCapsNum, |
| 1231 |
uint32_t existCapsNum, |
| 1232 |
void *filterCaps) |
| 1233 |
{ |
| 1234 |
VAProcFilterCap *sharpeningCap = nullptr; |
| 1235 |
DDI_VP_FUNC_ENTER; |
| 1236 |
|
| 1237 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1238 |
{ |
| 1239 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1240 |
if (queryCapsNum < existCapsNum) |
| 1241 |
{ |
| 1242 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1243 |
} |
| 1244 |
|
| 1245 |
sharpeningCap = (VAProcFilterCap*)filterCaps; |
| 1246 |
sharpeningCap->range.min_value = EDGEENHANCEMENT_MIN; |
| 1247 |
sharpeningCap->range.max_value = EDGEENHANCEMENT_MAX; |
| 1248 |
sharpeningCap->range.default_value = EDGEENHANCEMENT_DEFAULT; |
| 1249 |
sharpeningCap->range.step = EDGEENHANCEMENT_STEP; |
| 1250 |
} |
| 1251 |
return VA_STATUS_SUCCESS; |
| 1252 |
} |
| 1253 |
|
| 1254 |
VAStatus DdiVpFunctions::QueryColorBalanceCapsAttrib( |
| 1255 |
uint32_t queryFlag, |
| 1256 |
uint32_t queryCapsNum, |
| 1257 |
uint32_t existCapsNum, |
| 1258 |
void *filterCaps) |
| 1259 |
{ |
| 1260 |
VAProcFilterCapColorBalance *colorBalCap = nullptr; |
| 1261 |
DDI_VP_FUNC_ENTER; |
| 1262 |
|
| 1263 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1264 |
{ |
| 1265 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1266 |
if (queryCapsNum < existCapsNum) |
| 1267 |
{ |
| 1268 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1269 |
} |
| 1270 |
|
| 1271 |
for (uint32_t cnt = 0; cnt < queryCapsNum; cnt++) |
| 1272 |
{ |
| 1273 |
colorBalCap = (VAProcFilterCapColorBalance*)filterCaps + cnt; |
| 1274 |
colorBalCap->type = m_vpColorBalCap[cnt].type; |
| 1275 |
colorBalCap->range.default_value = m_vpColorBalCap[cnt].range.default_value; |
| 1276 |
colorBalCap->range.max_value = m_vpColorBalCap[cnt].range.max_value; |
| 1277 |
colorBalCap->range.min_value = m_vpColorBalCap[cnt].range.min_value; |
| 1278 |
colorBalCap->range.step = m_vpColorBalCap[cnt].range.step; |
| 1279 |
} |
| 1280 |
} |
| 1281 |
return VA_STATUS_SUCCESS; |
| 1282 |
} |
| 1283 |
|
| 1284 |
VAStatus DdiVpFunctions::QuerySkinToneEnhancementCapsAttrib( |
| 1285 |
uint32_t queryFlag, |
| 1286 |
uint32_t queryCapsNum, |
| 1287 |
uint32_t existCapsNum, |
| 1288 |
void *filterCaps) |
| 1289 |
{ |
| 1290 |
VAProcFilterCap *steCap = nullptr; |
| 1291 |
DDI_VP_FUNC_ENTER; |
| 1292 |
|
| 1293 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1294 |
{ |
| 1295 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1296 |
if (queryCapsNum < existCapsNum) |
| 1297 |
{ |
| 1298 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1299 |
} |
| 1300 |
steCap = (VAProcFilterCap *)filterCaps; |
| 1301 |
steCap->range.min_value = STE_MIN; |
| 1302 |
steCap->range.max_value = STE_MAX; |
| 1303 |
steCap->range.default_value = STE_DEFAULT; |
| 1304 |
steCap->range.step = STE_STEP; |
| 1305 |
} |
| 1306 |
return VA_STATUS_SUCCESS; |
| 1307 |
} |
| 1308 |
|
| 1309 |
VAStatus DdiVpFunctions::QueryTotalColorCorrectionCapsAttrib( |
| 1310 |
uint32_t queryFlag, |
| 1311 |
uint32_t queryCapsNum, |
| 1312 |
uint32_t existCapsNum, |
| 1313 |
void *filterCaps) |
| 1314 |
{ |
| 1315 |
VAProcFilterCapTotalColorCorrection *tccCap = nullptr; |
| 1316 |
DDI_VP_FUNC_ENTER; |
| 1317 |
|
| 1318 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1319 |
{ |
| 1320 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1321 |
if (queryCapsNum < existCapsNum) |
| 1322 |
{ |
| 1323 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1324 |
} |
| 1325 |
|
| 1326 |
for (uint32_t cnt = 0; cnt < queryCapsNum; cnt++) |
| 1327 |
{ |
| 1328 |
tccCap = (VAProcFilterCapTotalColorCorrection *)filterCaps + cnt; |
| 1329 |
tccCap->type = (VAProcTotalColorCorrectionType)((uint32_t)VAProcTotalColorCorrectionRed + cnt); |
| 1330 |
tccCap->range.min_value = TCC_MIN; |
| 1331 |
tccCap->range.max_value = TCC_MAX; |
| 1332 |
tccCap->range.default_value = TCC_DEFAULT; |
| 1333 |
tccCap->range.step = TCC_STEP; |
| 1334 |
} |
| 1335 |
} |
| 1336 |
return VA_STATUS_SUCCESS; |
| 1337 |
} |
| 1338 |
|
| 1339 |
VAStatus DdiVpFunctions::QueryHDRToneMappingCapsAttrib( |
| 1340 |
uint32_t queryFlag, |
| 1341 |
uint32_t queryCapsNum, |
| 1342 |
uint32_t existCapsNum, |
| 1343 |
void *filterCaps) |
| 1344 |
{ |
| 1345 |
VAProcFilterCapHighDynamicRange *hdrTmCap = nullptr; |
| 1346 |
DDI_VP_FUNC_ENTER; |
| 1347 |
|
| 1348 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1349 |
{ |
| 1350 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1351 |
if (queryCapsNum < existCapsNum) |
| 1352 |
{ |
| 1353 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1354 |
} |
| 1355 |
hdrTmCap = (VAProcFilterCapHighDynamicRange *)filterCaps; |
| 1356 |
hdrTmCap->metadata_type = VAProcHighDynamicRangeMetadataHDR10; |
| 1357 |
hdrTmCap->caps_flag = VA_TONE_MAPPING_HDR_TO_HDR | VA_TONE_MAPPING_HDR_TO_SDR | VA_TONE_MAPPING_HDR_TO_EDR; |
| 1358 |
|
| 1359 |
} |
| 1360 |
return VA_STATUS_SUCCESS; |
| 1361 |
} |
| 1362 |
|
| 1363 |
VAStatus DdiVpFunctions::QueryLut3DCapsAttrib( |
| 1364 |
uint32_t queryFlag, |
| 1365 |
uint32_t queryCapsNum, |
| 1366 |
uint32_t existCapsNum, |
| 1367 |
void *filterCaps) |
| 1368 |
{ |
| 1369 |
uint32_t channelMapping = 0; |
| 1370 |
VAProcFilterCap3DLUT *lut3DCap = nullptr; |
| 1371 |
DDI_VP_FUNC_ENTER; |
| 1372 |
|
| 1373 |
/* set the actual filter caps attribute in vp module */ |
| 1374 |
if (queryFlag == QUERY_CAPS_ATTRIBUTE) |
| 1375 |
{ |
| 1376 |
DDI_VP_CHK_NULL(filterCaps, "nullptr filterCaps", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1377 |
if (queryCapsNum < existCapsNum) |
| 1378 |
{ |
| 1379 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1380 |
} |
| 1381 |
|
| 1382 |
channelMapping = VA_3DLUT_CHANNEL_RGB_RGB | VA_3DLUT_CHANNEL_YUV_RGB | VA_3DLUT_CHANNEL_VUY_RGB; |
| 1383 |
/* 17^3 */ |
| 1384 |
lut3DCap = (VAProcFilterCap3DLUT *)filterCaps + 0; |
| 1385 |
lut3DCap->lut_size = 17; |
| 1386 |
lut3DCap->lut_stride[0] = 17; |
| 1387 |
lut3DCap->lut_stride[1] = 17; |
| 1388 |
lut3DCap->lut_stride[2] = 32; |
| 1389 |
lut3DCap->bit_depth = 16; |
| 1390 |
lut3DCap->num_channel = 4; |
| 1391 |
lut3DCap->channel_mapping = channelMapping; |
| 1392 |
/* 33^3 */ |
| 1393 |
lut3DCap = (VAProcFilterCap3DLUT *)filterCaps + 1; |
| 1394 |
lut3DCap->lut_size = 33; |
| 1395 |
lut3DCap->lut_stride[0] = 33; |
| 1396 |
lut3DCap->lut_stride[1] = 33; |
| 1397 |
lut3DCap->lut_stride[2] = 64; |
| 1398 |
lut3DCap->bit_depth = 16; |
| 1399 |
lut3DCap->num_channel = 4; |
| 1400 |
lut3DCap->channel_mapping = channelMapping; |
| 1401 |
/* 65^3 */ |
| 1402 |
lut3DCap = (VAProcFilterCap3DLUT *)filterCaps + 2; |
| 1403 |
lut3DCap->lut_size = 65; |
| 1404 |
lut3DCap->lut_stride[0] = 65; |
| 1405 |
lut3DCap->lut_stride[1] = 65; |
| 1406 |
lut3DCap->lut_stride[2] = 128; |
| 1407 |
lut3DCap->bit_depth = 16; |
| 1408 |
lut3DCap->num_channel = 4; |
| 1409 |
lut3DCap->channel_mapping = channelMapping; |
| 1410 |
} |
| 1411 |
return VA_STATUS_SUCCESS; |
| 1412 |
} |
| 1413 |
|
| 1414 |
PVPHAL_RENDER_PARAMS DdiVpFunctions::VpGetRenderParams(PDDI_VP_CONTEXT vpCtx) |
| 1415 |
{ |
| 1416 |
DDI_VP_FUNC_ENTER; |
| 1417 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", nullptr); |
| 1418 |
return vpCtx->pVpHalRenderParams; |
| 1419 |
} |
| 1420 |
|
| 1421 |
VAStatus DdiVpFunctions::VpSetOsResource( |
| 1422 |
PDDI_VP_CONTEXT vpCtx, |
| 1423 |
PDDI_MEDIA_SURFACE boRt, |
| 1424 |
uint32_t targetIndex) |
| 1425 |
{ |
| 1426 |
PMOS_RESOURCE osResource = nullptr; |
| 1427 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 1428 |
|
| 1429 |
DDI_VP_FUNC_ENTER; |
| 1430 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1431 |
DDI_VP_CHK_NULL(boRt, "nullptr boRt.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 1432 |
|
| 1433 |
// get vphal render parameters |
| 1434 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 1435 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1436 |
|
| 1437 |
// set render target os resource information according to target surface |
| 1438 |
osResource = &vpHalRenderParams->pTarget[targetIndex]->OsResource; |
| 1439 |
DDI_VP_CHK_NULL(osResource, "nullptr osResource.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1440 |
|
| 1441 |
osResource->bo = boRt->bo; |
| 1442 |
osResource->bMapped = boRt->bMapped; |
| 1443 |
osResource->Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(boRt->format); |
| 1444 |
osResource->iWidth = boRt->iWidth; |
| 1445 |
osResource->iHeight = boRt->iHeight; |
| 1446 |
osResource->iPitch = boRt->iPitch; |
| 1447 |
osResource->iCount = boRt->iRefCount; |
| 1448 |
osResource->TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(boRt->TileType); |
| 1449 |
osResource->pGmmResInfo = boRt->pGmmResourceInfo; |
| 1450 |
|
| 1451 |
Mos_Solo_SetOsResource(boRt->pGmmResourceInfo, osResource); |
| 1452 |
|
| 1453 |
return VA_STATUS_SUCCESS; |
| 1454 |
} |
| 1455 |
|
| 1456 |
void DdiVpFunctions::VpSetRenderParams( |
| 1457 |
PDDI_MEDIA_SURFACE mediaSurf, |
| 1458 |
PVPHAL_RENDER_PARAMS vpHalRenderParams, |
| 1459 |
VASurfaceID renderTarget) |
| 1460 |
{ |
| 1461 |
DDI_VP_FUNC_ENTER; |
| 1462 |
DDI_VP_CHK_NULL(mediaSurf, "nullptr mediaSurf", ); |
| 1463 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams", ); |
| 1464 |
|
| 1465 |
// reset source surface count |
| 1466 |
vpHalRenderParams->uSrcCount = 0; |
| 1467 |
|
| 1468 |
vpHalRenderParams->bReportStatus = true; |
| 1469 |
vpHalRenderParams->StatusFeedBackID = renderTarget; |
| 1470 |
|
| 1471 |
if (mediaSurf->pSurfDesc && (mediaSurf->pSurfDesc->uiVaMemType == VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR)) |
| 1472 |
{ |
| 1473 |
vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]->b16UsrPtr = VpIs16UsrPtrPitch(mediaSurf->iPitch, mediaSurf->format); |
| 1474 |
} |
| 1475 |
else |
| 1476 |
{ |
| 1477 |
vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]->b16UsrPtr = false; |
| 1478 |
} |
| 1479 |
|
| 1480 |
// increase render target count |
| 1481 |
vpHalRenderParams->uDstCount++; |
| 1482 |
return; |
| 1483 |
} |
| 1484 |
|
| 1485 |
bool DdiVpFunctions::VpIs16UsrPtrPitch(uint32_t pitch, DDI_MEDIA_FORMAT format) |
| 1486 |
{ |
| 1487 |
uint32_t pitchAligned = 64; |
| 1488 |
bool status = false; |
| 1489 |
DDI_VP_FUNC_ENTER; |
| 1490 |
|
| 1491 |
if (Media_Format_YV12 == format) |
| 1492 |
{ |
| 1493 |
pitchAligned = 128; |
| 1494 |
} |
| 1495 |
|
| 1496 |
if (!(pitch % 16) && (pitch % pitchAligned)) |
| 1497 |
{ |
| 1498 |
status = true; |
| 1499 |
} |
| 1500 |
else |
| 1501 |
{ |
| 1502 |
status = false; |
| 1503 |
} |
| 1504 |
|
| 1505 |
DDI_VP_NORMALMESSAGE("[VP] 16Usrptr check, surface pitch is %d, go to %s path.", pitch, status?"16Usrptr":"legacy"); |
| 1506 |
return status; |
| 1507 |
} |
| 1508 |
|
| 1509 |
VAStatus DdiVpFunctions::VpReportFeatureMode(PDDI_VP_CONTEXT vpCtx) |
| 1510 |
{ |
| 1511 |
VP_CONFIG configValues = {}; |
| 1512 |
DDI_VP_FUNC_ENTER; |
| 1513 |
|
| 1514 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1515 |
DDI_VP_CHK_NULL(vpCtx->pVpHal, "nullptr vpHal.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1516 |
|
| 1517 |
VpConfigValuesInit(&configValues); |
| 1518 |
VpHalDdiReportFeatureMode(vpCtx->pVpHal, &configValues); |
| 1519 |
VpFeatureReport(&configValues, vpCtx); |
| 1520 |
|
| 1521 |
return VA_STATUS_SUCCESS; |
| 1522 |
} |
| 1523 |
|
| 1524 |
void DdiVpFunctions::VpConfigValuesInit( |
| 1525 |
PVP_CONFIG configValues) |
| 1526 |
{ |
| 1527 |
DDI_VP_FUNC_ENTER; |
| 1528 |
DDI_VP_CHK_NULL(configValues, "nullptr configValues.",); |
| 1529 |
|
| 1530 |
configValues->dwVpPath = 0; |
| 1531 |
configValues->dwVpComponent = 0; |
| 1532 |
configValues->dwReportedDeinterlaceMode = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1533 |
configValues->dwReportedScalingMode = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1534 |
configValues->dwReportedOutputPipeMode = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1535 |
configValues->dwReportedVEFeatureInUse = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1536 |
configValues->dwVPMMCInUseReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1537 |
configValues->dwRTCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1538 |
configValues->dwRTCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1539 |
configValues->dwCapturePipeInUseReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1540 |
configValues->dwReportedCompositionMode = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1541 |
configValues->dwReportedHdrMode = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1542 |
|
| 1543 |
configValues->dwFFDICompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1544 |
configValues->dwFFDICompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1545 |
configValues->dwFFDNCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1546 |
configValues->dwFFDNCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1547 |
configValues->dwSTMMCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1548 |
configValues->dwSTMMCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1549 |
configValues->dwScalerCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1550 |
configValues->dwScalerCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1551 |
configValues->dwPrimaryCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1552 |
configValues->dwPrimaryCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1553 |
|
| 1554 |
configValues->dwReportedVeboxScalability = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1555 |
configValues->dwReportedVPApogeios = LIBVA_VP_CONFIG_NOT_REPORTED; |
| 1556 |
return; |
| 1557 |
} |
| 1558 |
|
| 1559 |
void DdiVpFunctions::VpHalDdiReportFeatureMode( |
| 1560 |
VpBase *vpHalState, |
| 1561 |
PVP_CONFIG configValues) |
| 1562 |
{ |
| 1563 |
VphalFeatureReport *report = nullptr; |
| 1564 |
DDI_VP_FUNC_ENTER; |
| 1565 |
DDI_VP_CHK_NULL(vpHalState, "nullptr vpHalState.", ); |
| 1566 |
|
| 1567 |
// Get VPHAL feature reporting |
| 1568 |
report = vpHalState->GetRenderFeatureReport(); |
| 1569 |
DDI_VP_CHK_NULL(report, "nullptr report", ); |
| 1570 |
|
| 1571 |
report->SetConfigValues(configValues); |
| 1572 |
return; |
| 1573 |
} |
| 1574 |
|
| 1575 |
void DdiVpFunctions::VpFeatureReport(PVP_CONFIG config, PDDI_VP_CONTEXT vpCtx) |
| 1576 |
{ |
| 1577 |
DDI_VP_FUNC_ENTER; |
| 1578 |
DDI_VP_CHK_NULL(config, "nullptr config.", ); |
| 1579 |
|
| 1580 |
MediaUserSettingSharedPtr userSettingPtr = vpCtx ? vpCtx->MosDrvCtx.m_userSettingPtr : nullptr; |
| 1581 |
|
| 1582 |
ReportUserSetting( |
| 1583 |
userSettingPtr, |
| 1584 |
__VPHAL_VEBOX_OUTPUTPIPE_MODE, |
| 1585 |
config->dwCurrentOutputPipeMode, |
| 1586 |
MediaUserSetting::Group::Sequence); |
| 1587 |
|
| 1588 |
ReportUserSetting( |
| 1589 |
userSettingPtr, |
| 1590 |
__VPHAL_VEBOX_FEATURE_INUSE, |
| 1591 |
config->dwCurrentVEFeatureInUse, |
| 1592 |
MediaUserSetting::Group::Sequence); |
| 1593 |
|
| 1594 |
//VP Primary Surface Compress Mode Report |
| 1595 |
ReportUserSetting( |
| 1596 |
userSettingPtr, |
| 1597 |
__VPHAL_PRIMARY_MMC_COMPRESSMODE, |
| 1598 |
config->dwPrimaryCompressMode, |
| 1599 |
MediaUserSetting::Group::Sequence); |
| 1600 |
//VP RT Compress Mode |
| 1601 |
ReportUserSetting( |
| 1602 |
userSettingPtr, |
| 1603 |
__VPHAL_RT_MMC_COMPRESSMODE, |
| 1604 |
config->dwRTCompressMode, |
| 1605 |
MediaUserSetting::Group::Sequence); |
| 1606 |
|
| 1607 |
//VP RT Cache Usage |
| 1608 |
ReportUserSetting( |
| 1609 |
userSettingPtr, |
| 1610 |
__VPHAL_RT_Cache_Setting, |
| 1611 |
config->dwRTCacheSetting, |
| 1612 |
MediaUserSetting::Group::Sequence); |
| 1613 |
|
| 1614 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 1615 |
//VP RT Old Cache Usage |
| 1616 |
ReportUserSetting( |
| 1617 |
userSettingPtr, |
| 1618 |
__VPHAL_RT_Old_Cache_Setting, |
| 1619 |
config->dwRTOldCacheSetting, |
| 1620 |
MediaUserSetting::Group::Sequence); |
| 1621 |
|
| 1622 |
ReportUserSettingForDebug( |
| 1623 |
userSettingPtr, |
| 1624 |
__VPHAL_VEBOX_HDR_MODE, |
| 1625 |
config->dwCurrentHdrMode, |
| 1626 |
MediaUserSetting::Group::Sequence); |
| 1627 |
|
| 1628 |
//VP MMC In Use |
| 1629 |
ReportUserSettingForDebug( |
| 1630 |
userSettingPtr, |
| 1631 |
__VPHAL_MMC_ENABLE, |
| 1632 |
config->dwVPMMCInUse, |
| 1633 |
MediaUserSetting::Group::Sequence); |
| 1634 |
|
| 1635 |
//VP Primary Surface Compressible |
| 1636 |
ReportUserSettingForDebug( |
| 1637 |
userSettingPtr, |
| 1638 |
__VPHAL_PRIMARY_MMC_COMPRESSIBLE, |
| 1639 |
config->dwPrimaryCompressible, |
| 1640 |
MediaUserSetting::Group::Sequence); |
| 1641 |
|
| 1642 |
//VP RT Compressible |
| 1643 |
ReportUserSettingForDebug( |
| 1644 |
userSettingPtr, |
| 1645 |
__VPHAL_RT_MMC_COMPRESSIBLE, |
| 1646 |
config->dwRTCompressible, |
| 1647 |
MediaUserSetting::Group::Sequence); |
| 1648 |
|
| 1649 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 1650 |
|
| 1651 |
if (config->dwCurrentVeboxScalability != config->dwReportedVeboxScalability) |
| 1652 |
{ |
| 1653 |
ReportUserSetting( |
| 1654 |
userSettingPtr, |
| 1655 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE, |
| 1656 |
config->dwCurrentVeboxScalability, |
| 1657 |
MediaUserSetting::Group::Device); |
| 1658 |
|
| 1659 |
config->dwReportedVeboxScalability = config->dwCurrentVeboxScalability; |
| 1660 |
} |
| 1661 |
|
| 1662 |
if (config->dwCurrentVPApogeios != config->dwReportedVPApogeios) |
| 1663 |
{ |
| 1664 |
ReportUserSetting( |
| 1665 |
userSettingPtr, |
| 1666 |
__MEDIA_USER_FEATURE_VALUE_VPP_APOGEIOS_ENABLE, |
| 1667 |
config->dwCurrentVPApogeios, |
| 1668 |
MediaUserSetting::Group::Sequence); |
| 1669 |
|
| 1670 |
config->dwReportedVPApogeios = config->dwCurrentVPApogeios; |
| 1671 |
} |
| 1672 |
|
| 1673 |
return; |
| 1674 |
} |
| 1675 |
|
| 1676 |
VAStatus DdiVpFunctions::DdiSetGpuPriority( |
| 1677 |
PDDI_VP_CONTEXT vpCtx, |
| 1678 |
int32_t priority) |
| 1679 |
{ |
| 1680 |
PMOS_INTERFACE osInterface = nullptr; |
| 1681 |
DDI_VP_FUNC_ENTER; |
| 1682 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1683 |
|
| 1684 |
//Set the priority for Gpu |
| 1685 |
if(vpCtx->pVpHal) |
| 1686 |
{ |
| 1687 |
osInterface = vpCtx->pVpHal->GetOsInterface(); |
| 1688 |
DDI_VP_CHK_NULL(osInterface, "nullptr osInterface.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 1689 |
osInterface->pfnSetGpuPriority(osInterface, priority); |
| 1690 |
} |
| 1691 |
return VA_STATUS_SUCCESS; |
| 1692 |
} |
| 1693 |
|
| 1694 |
VAStatus DdiVpFunctions::VpSetColorStandardExplictly( |
| 1695 |
PVPHAL_SURFACE vpHalSurf, |
| 1696 |
VAProcColorStandardType colorStandard, |
| 1697 |
VAProcColorProperties colorProperties) |
| 1698 |
{ |
| 1699 |
DDI_VP_FUNC_ENTER; |
| 1700 |
DDI_VP_CHK_NULL(vpHalSurf, "nullptr vpHalSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 1701 |
DDI_VP_CHK_CONDITION((colorStandard != VAProcColorStandardExplicit), "Not Explict color standard, Exit!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1702 |
|
| 1703 |
if (IS_RGB_FORMAT(vpHalSurf->Format)) |
| 1704 |
{ |
| 1705 |
switch (colorProperties.colour_primaries) |
| 1706 |
{ |
| 1707 |
case COLOUR_PRIMARY_BT2020: |
| 1708 |
vpHalSurf->ColorSpace = (colorProperties.color_range & VA_SOURCE_RANGE_REDUCED) ? CSpace_BT2020_stRGB : CSpace_BT2020_RGB; |
| 1709 |
break; |
| 1710 |
case COLOUR_PRIMARY_BT709: |
| 1711 |
case COLOUR_PRIMARY_BT601: |
| 1712 |
vpHalSurf->ColorSpace = (colorProperties.color_range & VA_SOURCE_RANGE_REDUCED) ? CSpace_stRGB : CSpace_sRGB; |
| 1713 |
break; |
| 1714 |
default: |
| 1715 |
vpHalSurf->ColorSpace = CSpace_sRGB; |
| 1716 |
DDI_VP_ASSERTMESSAGE("unknown Color Standard for RGB format."); |
| 1717 |
break; |
| 1718 |
} |
| 1719 |
} |
| 1720 |
|
| 1721 |
if (IS_YUV_FORMAT(vpHalSurf->Format) || IS_ALPHA_YUV_FORMAT(vpHalSurf->Format)) |
| 1722 |
{ |
| 1723 |
switch (colorProperties.colour_primaries) |
| 1724 |
{ |
| 1725 |
case COLOUR_PRIMARY_BT2020: |
| 1726 |
vpHalSurf->ColorSpace = (colorProperties.color_range & VA_SOURCE_RANGE_FULL) ? CSpace_BT2020_FullRange : CSpace_BT2020; |
| 1727 |
break; |
| 1728 |
case COLOUR_PRIMARY_BT709: |
| 1729 |
vpHalSurf->ColorSpace = (colorProperties.color_range & VA_SOURCE_RANGE_FULL) ? CSpace_BT709_FullRange : CSpace_BT709; |
| 1730 |
break; |
| 1731 |
case COLOUR_PRIMARY_BT601: |
| 1732 |
vpHalSurf->ColorSpace = (colorProperties.color_range & VA_SOURCE_RANGE_FULL) ? CSpace_BT601_FullRange : CSpace_BT601; |
| 1733 |
break; |
| 1734 |
default: |
| 1735 |
vpHalSurf->ColorSpace = CSpace_BT601; |
| 1736 |
DDI_VP_ASSERTMESSAGE("unknown Color Standard for YUV format."); |
| 1737 |
break; |
| 1738 |
} |
| 1739 |
} |
| 1740 |
|
| 1741 |
switch (colorProperties.transfer_characteristics) |
| 1742 |
{ |
| 1743 |
case TRANSFER_CHARACTERISTICS_ST2084: |
| 1744 |
vpHalSurf->GammaType = VPHAL_GAMMA_SMPTE_ST2084; |
| 1745 |
break; |
| 1746 |
default: |
| 1747 |
vpHalSurf->GammaType = VPHAL_GAMMA_TRADITIONAL_GAMMA; |
| 1748 |
break; |
| 1749 |
} |
| 1750 |
|
| 1751 |
return VA_STATUS_SUCCESS; |
| 1752 |
} |
| 1753 |
|
| 1754 |
bool DdiVpFunctions::VpIsRenderTarget( |
| 1755 |
VADriverContextP vaDrvCtx, |
| 1756 |
PDDI_VP_CONTEXT vpCtx, |
| 1757 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 1758 |
{ |
| 1759 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 1760 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 1761 |
PDDI_MEDIA_SURFACE mediaSrcSurf = nullptr; |
| 1762 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 1763 |
bool isTarget = false; |
| 1764 |
|
| 1765 |
DDI_VP_FUNC_ENTER; |
| 1766 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1767 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1768 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1769 |
|
| 1770 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 1771 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1772 |
mediaSrcSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->surface); |
| 1773 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1774 |
vpHalRenderParams = vpCtx->pVpHalRenderParams; |
| 1775 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1776 |
|
| 1777 |
if (pipelineParam->pipeline_flags == 0 && vpHalRenderParams->uDstCount >= 1) |
| 1778 |
{ |
| 1779 |
vpHalTgtSurf = vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount - 1]; |
| 1780 |
|
| 1781 |
isTarget = ((vpHalTgtSurf->OsResource.bo != nullptr) && (vpHalTgtSurf->OsResource.bo == mediaSrcSurf->bo)); |
| 1782 |
} |
| 1783 |
|
| 1784 |
return isTarget; |
| 1785 |
} |
| 1786 |
|
| 1787 |
VAStatus DdiVpFunctions::VpSetRenderTargetParams( |
| 1788 |
VADriverContextP vaDrvCtx, |
| 1789 |
PDDI_VP_CONTEXT vpCtx, |
| 1790 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 1791 |
{ |
| 1792 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 1793 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 1794 |
PDDI_MEDIA_SURFACE mediaSrcSurf = nullptr; |
| 1795 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 1796 |
|
| 1797 |
DDI_VP_FUNC_ENTER; |
| 1798 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1799 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1800 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1801 |
|
| 1802 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 1803 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 1804 |
|
| 1805 |
mediaSrcSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->surface); |
| 1806 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1807 |
vpHalRenderParams = vpCtx->pVpHalRenderParams; |
| 1808 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr pVpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1809 |
|
| 1810 |
if(vpHalRenderParams->uDstCount < 1) |
| 1811 |
{ |
| 1812 |
DDI_VP_ASSERTMESSAGE("vpHalRenderParams->uDstCount is lower than 1"); |
| 1813 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 1814 |
} |
| 1815 |
DDI_VP_CHK_NULL(vpHalRenderParams->pTarget, "nullptr vpHalRenderParams->pTarget.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1816 |
vpHalTgtSurf = vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount - 1]; |
| 1817 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 1818 |
|
| 1819 |
// Set src rect |
| 1820 |
SetSrcRect(pipelineParam->surface_region, vpHalTgtSurf, mediaSrcSurf); |
| 1821 |
// Set dest rect |
| 1822 |
SetDestRect(pipelineParam->output_region, vpHalTgtSurf, mediaSrcSurf); |
| 1823 |
|
| 1824 |
if (IsProcmpEnable(vpHalTgtSurf)) |
| 1825 |
{ |
| 1826 |
// correct the ChromaSitting location if Procamp is enabled. |
| 1827 |
#if (VA_MAJOR_VERSION < 1) |
| 1828 |
pipelineParam->output_surface_flag = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 1829 |
#else |
| 1830 |
pipelineParam->output_color_properties.chroma_sample_location = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 1831 |
#endif |
| 1832 |
} |
| 1833 |
|
| 1834 |
#if (VA_MAJOR_VERSION < 1) |
| 1835 |
VpUpdateProcChromaSittingState(vpHalTgtSurf, (uint8_t)(pipelineParam->output_surface_flag & 0xff)); |
| 1836 |
#else |
| 1837 |
VpUpdateProcChromaSittingState(vpHalTgtSurf, pipelineParam->output_color_properties.chroma_sample_location); |
| 1838 |
#endif |
| 1839 |
return VA_STATUS_SUCCESS; |
| 1840 |
} |
| 1841 |
|
| 1842 |
void DdiVpFunctions::SetSrcRect( |
| 1843 |
const VARectangle *surfaceRegion, |
| 1844 |
PVPHAL_SURFACE vpHalTgtSurf, |
| 1845 |
PDDI_MEDIA_SURFACE mediaSrcSurf) |
| 1846 |
{ |
| 1847 |
DDI_VP_FUNC_ENTER; |
| 1848 |
DDI_VP_CHK_NULL(surfaceRegion, "nullptr surfaceRegion", ); |
| 1849 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", ); |
| 1850 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf", ); |
| 1851 |
|
| 1852 |
vpHalTgtSurf->rcSrc.left = surfaceRegion->x; |
| 1853 |
vpHalTgtSurf->rcSrc.top = surfaceRegion->y; |
| 1854 |
vpHalTgtSurf->rcSrc.right = surfaceRegion->x + surfaceRegion->width; |
| 1855 |
vpHalTgtSurf->rcSrc.bottom = surfaceRegion->y + surfaceRegion->height; |
| 1856 |
|
| 1857 |
if (vpHalTgtSurf->rcSrc.top < 0) |
| 1858 |
{ |
| 1859 |
vpHalTgtSurf->rcSrc.top = 0; |
| 1860 |
} |
| 1861 |
|
| 1862 |
if (vpHalTgtSurf->rcSrc.left < 0) |
| 1863 |
{ |
| 1864 |
vpHalTgtSurf->rcSrc.left = 0; |
| 1865 |
} |
| 1866 |
|
| 1867 |
if (vpHalTgtSurf->rcSrc.right > mediaSrcSurf->iWidth) |
| 1868 |
{ |
| 1869 |
vpHalTgtSurf->rcSrc.right = mediaSrcSurf->iWidth; |
| 1870 |
} |
| 1871 |
|
| 1872 |
if (vpHalTgtSurf->rcSrc.bottom > mediaSrcSurf->iHeight) |
| 1873 |
{ |
| 1874 |
vpHalTgtSurf->rcSrc.bottom = mediaSrcSurf->iHeight; |
| 1875 |
} |
| 1876 |
|
| 1877 |
return; |
| 1878 |
} |
| 1879 |
|
| 1880 |
void DdiVpFunctions::SetDestRect( |
| 1881 |
const VARectangle *outputRegion, |
| 1882 |
PVPHAL_SURFACE vpHalTgtSurf, |
| 1883 |
PDDI_MEDIA_SURFACE mediaSrcSurf) |
| 1884 |
{ |
| 1885 |
DDI_VP_FUNC_ENTER; |
| 1886 |
DDI_VP_CHK_NULL(outputRegion, "nullptr outputRegion", ); |
| 1887 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", ); |
| 1888 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf", ); |
| 1889 |
|
| 1890 |
vpHalTgtSurf->rcDst.left = outputRegion->x; |
| 1891 |
vpHalTgtSurf->rcDst.top = outputRegion->y; |
| 1892 |
vpHalTgtSurf->rcDst.right = outputRegion->x + outputRegion->width; |
| 1893 |
vpHalTgtSurf->rcDst.bottom = outputRegion->y + outputRegion->height; |
| 1894 |
if (vpHalTgtSurf->rcDst.top < 0) |
| 1895 |
{ |
| 1896 |
vpHalTgtSurf->rcDst.top = 0; |
| 1897 |
} |
| 1898 |
|
| 1899 |
if (vpHalTgtSurf->rcDst.left < 0) |
| 1900 |
{ |
| 1901 |
vpHalTgtSurf->rcDst.left = 0; |
| 1902 |
} |
| 1903 |
|
| 1904 |
if (vpHalTgtSurf->rcDst.right > mediaSrcSurf->iWidth) |
| 1905 |
{ |
| 1906 |
vpHalTgtSurf->rcDst.right = mediaSrcSurf->iWidth; |
| 1907 |
} |
| 1908 |
|
| 1909 |
if (vpHalTgtSurf->rcDst.bottom > mediaSrcSurf->iHeight) |
| 1910 |
{ |
| 1911 |
vpHalTgtSurf->rcDst.bottom = mediaSrcSurf->iHeight; |
| 1912 |
} |
| 1913 |
|
| 1914 |
return; |
| 1915 |
} |
| 1916 |
|
| 1917 |
bool DdiVpFunctions::IsProcmpEnable(PVPHAL_SURFACE vpHalSrcSurf) |
| 1918 |
{ |
| 1919 |
DDI_VP_FUNC_ENTER; |
| 1920 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1921 |
|
| 1922 |
if ((vpHalSrcSurf->pProcampParams && vpHalSrcSurf->pProcampParams->bEnabled) && |
| 1923 |
(vpHalSrcSurf->pProcampParams->fContrast == 1 && vpHalSrcSurf->pProcampParams->fHue == 0 && vpHalSrcSurf->pProcampParams->fSaturation == 1) && |
| 1924 |
!vpHalSrcSurf->pBlendingParams && !vpHalSrcSurf->pLumaKeyParams && (!vpHalSrcSurf->pIEFParams || !vpHalSrcSurf->pIEFParams->bEnabled) && |
| 1925 |
!vpHalSrcSurf->pDeinterlaceParams && (!vpHalSrcSurf->pDenoiseParams || (!vpHalSrcSurf->pDenoiseParams->bEnableChroma && !vpHalSrcSurf->pDenoiseParams->bEnableLuma)) && |
| 1926 |
(!vpHalSrcSurf->pColorPipeParams || (!vpHalSrcSurf->pColorPipeParams->bEnableACE && !vpHalSrcSurf->pColorPipeParams->bEnableSTE && !vpHalSrcSurf->pColorPipeParams->bEnableTCC)) && |
| 1927 |
!vpHalSrcSurf->pHDRParams) |
| 1928 |
{ |
| 1929 |
return true; |
| 1930 |
} |
| 1931 |
|
| 1932 |
return false; |
| 1933 |
} |
| 1934 |
|
| 1935 |
VAStatus DdiVpFunctions::VpUpdateProcChromaSittingState( |
| 1936 |
PVPHAL_SURFACE vpHalSurf, |
| 1937 |
uint8_t chromasitingState) |
| 1938 |
{ |
| 1939 |
uint32_t chromaSitingFlags = 0; |
| 1940 |
|
| 1941 |
DDI_VP_FUNC_ENTER; |
| 1942 |
DDI_VP_CHK_NULL(vpHalSurf, "nullptr vpHalSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1943 |
|
| 1944 |
// Chroma siting |
| 1945 |
// The lower 4 bits are still used as chroma-siting flag for output/input_surface_flag |
| 1946 |
// Set the vertical chroma siting info at bit 1:0 |
| 1947 |
chromaSitingFlags = chromasitingState & 0x3; |
| 1948 |
|
| 1949 |
switch (chromaSitingFlags) |
| 1950 |
{ |
| 1951 |
case VA_CHROMA_SITING_VERTICAL_TOP: |
| 1952 |
vpHalSurf->ChromaSiting = CHROMA_SITING_VERT_TOP; |
| 1953 |
break; |
| 1954 |
case VA_CHROMA_SITING_VERTICAL_CENTER: |
| 1955 |
vpHalSurf->ChromaSiting = CHROMA_SITING_VERT_CENTER; |
| 1956 |
break; |
| 1957 |
case VA_CHROMA_SITING_VERTICAL_BOTTOM: |
| 1958 |
vpHalSurf->ChromaSiting = CHROMA_SITING_VERT_BOTTOM; |
| 1959 |
break; |
| 1960 |
default: |
| 1961 |
vpHalSurf->ChromaSiting = CHROMA_SITING_NONE; |
| 1962 |
break; |
| 1963 |
} |
| 1964 |
|
| 1965 |
if (vpHalSurf->ChromaSiting != CHROMA_SITING_NONE) |
| 1966 |
{ |
| 1967 |
// Set the horizontal chroma siting info at bit 3:2 |
| 1968 |
chromaSitingFlags = chromasitingState & 0xc; |
| 1969 |
|
| 1970 |
switch (chromaSitingFlags) |
| 1971 |
{ |
| 1972 |
case VA_CHROMA_SITING_HORIZONTAL_LEFT: |
| 1973 |
vpHalSurf->ChromaSiting = vpHalSurf->ChromaSiting | CHROMA_SITING_HORZ_LEFT; |
| 1974 |
break; |
| 1975 |
case VA_CHROMA_SITING_HORIZONTAL_CENTER: |
| 1976 |
vpHalSurf->ChromaSiting = vpHalSurf->ChromaSiting | CHROMA_SITING_HORZ_CENTER; |
| 1977 |
break; |
| 1978 |
default: |
| 1979 |
vpHalSurf->ChromaSiting = CHROMA_SITING_NONE; |
| 1980 |
break; |
| 1981 |
} |
| 1982 |
} |
| 1983 |
|
| 1984 |
return VA_STATUS_SUCCESS; |
| 1985 |
} |
| 1986 |
|
| 1987 |
void DdiVpFunctions::SetSrcSurfaceRect( |
| 1988 |
const VARectangle *surfRegion, |
| 1989 |
PVPHAL_SURFACE vpHalSrcSurf, |
| 1990 |
PDDI_MEDIA_SURFACE mediaSrcSurf) |
| 1991 |
{ |
| 1992 |
DDI_VP_FUNC_ENTER; |
| 1993 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", ); |
| 1994 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf", ); |
| 1995 |
|
| 1996 |
if (surfRegion != nullptr) |
| 1997 |
{ |
| 1998 |
vpHalSrcSurf->rcSrc.top = surfRegion->y; |
| 1999 |
vpHalSrcSurf->rcSrc.left = surfRegion->x; |
| 2000 |
vpHalSrcSurf->rcSrc.right = surfRegion->x + surfRegion->width; |
| 2001 |
vpHalSrcSurf->rcSrc.bottom = surfRegion->y + surfRegion->height; |
| 2002 |
|
| 2003 |
if (vpHalSrcSurf->rcSrc.top < 0) |
| 2004 |
{ |
| 2005 |
vpHalSrcSurf->rcSrc.top = 0; |
| 2006 |
} |
| 2007 |
|
| 2008 |
if (vpHalSrcSurf->rcSrc.left < 0) |
| 2009 |
{ |
| 2010 |
vpHalSrcSurf->rcSrc.left = 0; |
| 2011 |
} |
| 2012 |
|
| 2013 |
if (vpHalSrcSurf->rcSrc.right > mediaSrcSurf->iWidth) |
| 2014 |
{ |
| 2015 |
vpHalSrcSurf->rcSrc.right = mediaSrcSurf->iWidth; |
| 2016 |
} |
| 2017 |
|
| 2018 |
if (vpHalSrcSurf->rcSrc.bottom > mediaSrcSurf->iRealHeight) |
| 2019 |
{ |
| 2020 |
vpHalSrcSurf->rcSrc.bottom = mediaSrcSurf->iRealHeight; |
| 2021 |
} |
| 2022 |
} |
| 2023 |
else |
| 2024 |
{ |
| 2025 |
// nullptr surface_region implies the whole surface |
| 2026 |
vpHalSrcSurf->rcSrc.top = 0; |
| 2027 |
vpHalSrcSurf->rcSrc.left = 0; |
| 2028 |
vpHalSrcSurf->rcSrc.right = mediaSrcSurf->iWidth; |
| 2029 |
vpHalSrcSurf->rcSrc.bottom = mediaSrcSurf->iRealHeight; |
| 2030 |
} |
| 2031 |
return; |
| 2032 |
} |
| 2033 |
|
| 2034 |
VAStatus DdiVpFunctions::SetDestSurfaceRect( |
| 2035 |
const VARectangle *outputRegion, |
| 2036 |
PVPHAL_SURFACE vpHalSrcSurf, |
| 2037 |
PVPHAL_SURFACE vpHalTgtSurf) |
| 2038 |
{ |
| 2039 |
DDI_VP_FUNC_ENTER; |
| 2040 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2041 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2042 |
if (outputRegion != nullptr) |
| 2043 |
{ |
| 2044 |
vpHalSrcSurf->rcDst.top = outputRegion->y; |
| 2045 |
vpHalSrcSurf->rcDst.left = outputRegion->x; |
| 2046 |
vpHalSrcSurf->rcDst.right = outputRegion->x + outputRegion->width; |
| 2047 |
vpHalSrcSurf->rcDst.bottom = outputRegion->y + outputRegion->height; |
| 2048 |
} |
| 2049 |
else |
| 2050 |
{ |
| 2051 |
vpHalSrcSurf->rcDst.top = 0; |
| 2052 |
vpHalSrcSurf->rcDst.left = 0; |
| 2053 |
vpHalSrcSurf->rcDst.right = vpHalTgtSurf->rcDst.right; |
| 2054 |
vpHalSrcSurf->rcDst.bottom = vpHalTgtSurf->rcDst.bottom; |
| 2055 |
} |
| 2056 |
|
| 2057 |
if ((vpHalTgtSurf->rcSrc.right < vpHalSrcSurf->rcDst.right) || |
| 2058 |
(vpHalTgtSurf->rcSrc.bottom < vpHalSrcSurf->rcDst.bottom)) |
| 2059 |
{ |
| 2060 |
DDI_VP_CHK_CONDITION(true, "Invalid color fill parameter!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2061 |
} |
| 2062 |
return VA_STATUS_SUCCESS; |
| 2063 |
} |
| 2064 |
|
| 2065 |
#if (VA_MAJOR_VERSION < 1) |
| 2066 |
VAStatus DdiVpFunctions::DdiGetColorSpace(PVPHAL_SURFACE vpHalSurf, VAProcColorStandardType colorStandard, uint32_t flag) |
| 2067 |
#else |
| 2068 |
VAStatus DdiVpFunctions::DdiGetColorSpace(PVPHAL_SURFACE vpHalSurf, VAProcColorStandardType colorStandard, VAProcColorProperties colorProperties) |
| 2069 |
#endif |
| 2070 |
{ |
| 2071 |
uint8_t colorRange = colorProperties.color_range; |
| 2072 |
|
| 2073 |
DDI_VP_FUNC_ENTER; |
| 2074 |
DDI_VP_CHK_NULL(vpHalSurf, "nullptr vpHalSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2075 |
|
| 2076 |
vpHalSurf->ColorSpace = CSpace_None; |
| 2077 |
|
| 2078 |
// Convert VAProcColorStandardType to VPHAL_CSPACE |
| 2079 |
if (IS_RGB_FORMAT(vpHalSurf->Format) || (vpHalSurf->Format == Format_P8)) |
| 2080 |
{ |
| 2081 |
switch (colorStandard) |
| 2082 |
{ |
| 2083 |
case VAProcColorStandardBT2020: |
| 2084 |
#if (VA_MAJOR_VERSION < 1) |
| 2085 |
if (flag & VA_SOURCE_RANGE_FULL) |
| 2086 |
#else |
| 2087 |
if (colorRange == VA_SOURCE_RANGE_FULL) |
| 2088 |
#endif |
| 2089 |
{ |
| 2090 |
vpHalSurf->ColorSpace = CSpace_BT2020_RGB; |
| 2091 |
} |
| 2092 |
else |
| 2093 |
{ |
| 2094 |
vpHalSurf->ColorSpace = CSpace_BT2020_stRGB; |
| 2095 |
} |
| 2096 |
break; |
| 2097 |
case VAProcColorStandardSTRGB: |
| 2098 |
vpHalSurf->ColorSpace = CSpace_stRGB; |
| 2099 |
break; |
| 2100 |
case VAProcColorStandardExplicit: |
| 2101 |
VpSetColorStandardExplictly(vpHalSurf, colorStandard, colorProperties); |
| 2102 |
break; |
| 2103 |
case VAProcColorStandardSRGB: |
| 2104 |
default: |
| 2105 |
vpHalSurf->ColorSpace = CSpace_sRGB; |
| 2106 |
break; |
| 2107 |
} |
| 2108 |
} |
| 2109 |
else |
| 2110 |
{ |
| 2111 |
// Set colorspace by default to avoid application don't set ColorStandard |
| 2112 |
if (colorStandard == 0) |
| 2113 |
{ |
| 2114 |
VpSetColorSpaceByDefault(vpHalSurf); |
| 2115 |
} |
| 2116 |
else |
| 2117 |
{ |
| 2118 |
VpSetColorSpaceByColorStandard(vpHalSurf, colorStandard, colorProperties, colorRange); |
| 2119 |
} |
| 2120 |
} |
| 2121 |
DDI_VP_CHK_CONDITION((vpHalSurf->ColorSpace == CSpace_None), "Invalid color standard", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2122 |
|
| 2123 |
return VA_STATUS_SUCCESS; |
| 2124 |
} |
| 2125 |
|
| 2126 |
VAStatus DdiVpFunctions::SetBackgroundColorfill( |
| 2127 |
PVPHAL_RENDER_PARAMS vpHalRenderParams, |
| 2128 |
uint32_t outBackGroundcolor) |
| 2129 |
{ |
| 2130 |
DDI_VP_FUNC_ENTER; |
| 2131 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2132 |
|
| 2133 |
if ((outBackGroundcolor >> 24) != 0) |
| 2134 |
{ |
| 2135 |
if (vpHalRenderParams->pColorFillParams == nullptr) |
| 2136 |
{ |
| 2137 |
vpHalRenderParams->pColorFillParams = MOS_New(VPHAL_COLORFILL_PARAMS); |
| 2138 |
} |
| 2139 |
|
| 2140 |
DDI_VP_CHK_NULL(vpHalRenderParams->pColorFillParams, "nullptr pColorFillParams.", VA_STATUS_ERROR_UNKNOWN); |
| 2141 |
|
| 2142 |
// set background colorfill option |
| 2143 |
vpHalRenderParams->pColorFillParams->Color = outBackGroundcolor; |
| 2144 |
vpHalRenderParams->pColorFillParams->bYCbCr = false; |
| 2145 |
vpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; |
| 2146 |
|
| 2147 |
} |
| 2148 |
else |
| 2149 |
{ |
| 2150 |
MOS_Delete(vpHalRenderParams->pColorFillParams); |
| 2151 |
} |
| 2152 |
return VA_STATUS_SUCCESS; |
| 2153 |
} |
| 2154 |
|
| 2155 |
MOS_STATUS DdiVpFunctions::VpHalDdiSetupSplitScreenDemoMode( |
| 2156 |
uint32_t splitDemoPosDdi, |
| 2157 |
uint32_t splitDemoParaDdi, |
| 2158 |
PVPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS *splitScreenDemoModeParams, |
| 2159 |
bool *disableDemoMode, |
| 2160 |
PMOS_INTERFACE osInterface) |
| 2161 |
{ |
| 2162 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2163 |
uint32_t splitScreenDemoPosition = splitDemoPosDdi; |
| 2164 |
uint32_t splitScreenDemoParameters = splitDemoParaDdi; |
| 2165 |
uint32_t ufSplitScreenDemoPosition = 0; |
| 2166 |
uint32_t ufSplitScreenDemoParameters = 0; |
| 2167 |
MediaUserSettingSharedPtr userSetting = nullptr; |
| 2168 |
DDI_VP_FUNC_ENTER; |
| 2169 |
//-------------------------- |
| 2170 |
// Set Demo Mode Parameters |
| 2171 |
//-------------------------- |
| 2172 |
if (*splitScreenDemoModeParams == nullptr) |
| 2173 |
{ |
| 2174 |
*splitScreenDemoModeParams = (PVPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS)MOS_AllocAndZeroMemory(sizeof(VPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS)); |
| 2175 |
DDI_VP_CHK_NULL(*splitScreenDemoModeParams, "nullptr *splitScreenDemoModeParams!", MOS_STATUS_NULL_POINTER); |
| 2176 |
} |
| 2177 |
|
| 2178 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 2179 |
// If it is not enabled from DDI params, check if internal user feature key have settings |
| 2180 |
if (splitScreenDemoPosition == SPLIT_SCREEN_DEMO_DISABLED && splitScreenDemoParameters == 0) |
| 2181 |
{ |
| 2182 |
DDI_VP_CHK_NULL(osInterface, "nullptr osInterface", MOS_STATUS_NULL_POINTER); |
| 2183 |
userSetting = osInterface->pfnGetUserSettingInstance(osInterface); |
| 2184 |
ReadUserSettingForDebug( |
| 2185 |
userSetting, |
| 2186 |
ufSplitScreenDemoPosition, |
| 2187 |
__MEDIA_USER_FEATURE_VALUE_SPLIT_SCREEN_DEMO_POSITION, |
| 2188 |
MediaUserSetting::Group::Device); |
| 2189 |
splitScreenDemoPosition = ufSplitScreenDemoPosition; |
| 2190 |
|
| 2191 |
ReadUserSettingForDebug( |
| 2192 |
userSetting, |
| 2193 |
ufSplitScreenDemoParameters, |
| 2194 |
__MEDIA_USER_FEATURE_VALUE_SPLIT_SCREEN_DEMO_PARAMETERS, |
| 2195 |
MediaUserSetting::Group::Device); |
| 2196 |
splitScreenDemoParameters = ufSplitScreenDemoParameters; |
| 2197 |
} |
| 2198 |
#endif |
| 2199 |
|
| 2200 |
if ((splitScreenDemoPosition > SPLIT_SCREEN_DEMO_DISABLED) && (splitScreenDemoPosition < SPLIT_SCREEN_DEMO_END_POS_LIST)) |
| 2201 |
{ |
| 2202 |
(*splitScreenDemoModeParams)->Position = (VPHAL_SPLIT_SCREEN_DEMO_POSITION)(splitScreenDemoPosition); |
| 2203 |
(*splitScreenDemoModeParams)->bDisableACE = (bool)((splitScreenDemoParameters & 0x0001) > 0); |
| 2204 |
(*splitScreenDemoModeParams)->bDisableAVS = (bool)((splitScreenDemoParameters & 0x0002) > 0); |
| 2205 |
(*splitScreenDemoModeParams)->bDisableDN = (bool)((splitScreenDemoParameters & 0x0004) > 0); |
| 2206 |
(*splitScreenDemoModeParams)->bDisableFMD = (bool)((splitScreenDemoParameters & 0x0008) > 0); |
| 2207 |
(*splitScreenDemoModeParams)->bDisableIEF = (bool)((splitScreenDemoParameters & 0x0010) > 0); |
| 2208 |
(*splitScreenDemoModeParams)->bDisableProcamp = (bool)((splitScreenDemoParameters & 0x0020) > 0); |
| 2209 |
(*splitScreenDemoModeParams)->bDisableSTE = (bool)((splitScreenDemoParameters & 0x0040) > 0); |
| 2210 |
(*splitScreenDemoModeParams)->bDisableTCC = (bool)((splitScreenDemoParameters & 0x0080) > 0); |
| 2211 |
(*splitScreenDemoModeParams)->bDisableIS = (bool)((splitScreenDemoParameters & 0x0100) > 0); |
| 2212 |
(*splitScreenDemoModeParams)->bDisableDrDb = (bool)((splitScreenDemoParameters & 0x0200) > 0); |
| 2213 |
(*splitScreenDemoModeParams)->bDisableDNUV = (bool)((splitScreenDemoParameters & 0x0400) > 0); |
| 2214 |
(*splitScreenDemoModeParams)->bDisableFRC = (bool)((splitScreenDemoParameters & 0x0800) > 0); |
| 2215 |
(*splitScreenDemoModeParams)->bDisableLACE = (bool)((splitScreenDemoParameters & 0x1000) > 0); |
| 2216 |
*disableDemoMode = false; |
| 2217 |
} |
| 2218 |
else |
| 2219 |
{ |
| 2220 |
*disableDemoMode = true; |
| 2221 |
} |
| 2222 |
|
| 2223 |
return eStatus; |
| 2224 |
} |
| 2225 |
|
| 2226 |
VAStatus DdiVpFunctions::DdiUpdateProcPipelineFutureReferenceFrames( |
| 2227 |
PDDI_VP_CONTEXT vpCtx, |
| 2228 |
VADriverContextP vaDrvCtx, |
| 2229 |
PVPHAL_SURFACE vpHalSrcSurf, |
| 2230 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 2231 |
{ |
| 2232 |
PVPHAL_SURFACE surface = nullptr; |
| 2233 |
PDDI_MEDIA_SURFACE refSurfBuffObj = nullptr; |
| 2234 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 2235 |
|
| 2236 |
DDI_VP_FUNC_ENTER; |
| 2237 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2238 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2239 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2240 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2241 |
|
| 2242 |
// initialize |
| 2243 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 2244 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2245 |
|
| 2246 |
surface = vpHalSrcSurf; |
| 2247 |
if (!pipelineParam->backward_references) |
| 2248 |
{ |
| 2249 |
DDI_VP_NORMALMESSAGE("nullptr pipelineParam->forward_references"); |
| 2250 |
return VA_STATUS_SUCCESS; |
| 2251 |
} |
| 2252 |
|
| 2253 |
for (uint32_t i = 0; i < pipelineParam->num_backward_references; i++) |
| 2254 |
{ |
| 2255 |
if (surface->pFwdRef == nullptr) |
| 2256 |
{ |
| 2257 |
surface->pFwdRef = MOS_New(VPHAL_SURFACE); |
| 2258 |
DDI_VP_CHK_NULL(surface->pFwdRef, "nullptr surface->pFwdRef!", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2259 |
|
| 2260 |
surface->pFwdRef->Format = vpHalSrcSurf->Format; |
| 2261 |
surface->pFwdRef->SurfType = vpHalSrcSurf->SurfType; |
| 2262 |
surface->pFwdRef->rcSrc = vpHalSrcSurf->rcSrc; |
| 2263 |
surface->pFwdRef->rcDst = vpHalSrcSurf->rcDst; |
| 2264 |
surface->pFwdRef->ColorSpace = vpHalSrcSurf->ColorSpace; |
| 2265 |
surface->pFwdRef->ExtendedGamut = vpHalSrcSurf->ExtendedGamut; |
| 2266 |
surface->pFwdRef->SampleType = vpHalSrcSurf->SampleType; |
| 2267 |
surface->pFwdRef->ScalingMode = vpHalSrcSurf->ScalingMode; |
| 2268 |
surface->pFwdRef->OsResource = vpHalSrcSurf->OsResource; |
| 2269 |
surface->pFwdRef->dwWidth = vpHalSrcSurf->dwWidth; |
| 2270 |
surface->pFwdRef->dwHeight = vpHalSrcSurf->dwHeight; |
| 2271 |
surface->pFwdRef->dwPitch = vpHalSrcSurf->dwPitch; |
| 2272 |
surface->uFwdRefCount = pipelineParam->num_backward_references - i; |
| 2273 |
} |
| 2274 |
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->backward_references[i]); |
| 2275 |
DDI_VP_CHK_NULL(refSurfBuffObj, "nullptr refSurfBuffObj!", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2276 |
|
| 2277 |
surface->pFwdRef->OsResource.bo = refSurfBuffObj->bo; |
| 2278 |
surface->pFwdRef->OsResource.Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(refSurfBuffObj->format); |
| 2279 |
surface->pFwdRef->OsResource.iWidth = refSurfBuffObj->iWidth; |
| 2280 |
surface->pFwdRef->OsResource.iHeight = refSurfBuffObj->iHeight; |
| 2281 |
surface->pFwdRef->OsResource.iPitch = refSurfBuffObj->iPitch; |
| 2282 |
surface->pFwdRef->OsResource.TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(refSurfBuffObj->TileType); |
| 2283 |
surface->pFwdRef->OsResource.pGmmResInfo = refSurfBuffObj->pGmmResourceInfo; |
| 2284 |
|
| 2285 |
Mos_Solo_SetOsResource(refSurfBuffObj->pGmmResourceInfo, &surface->OsResource); |
| 2286 |
|
| 2287 |
surface->pFwdRef->FrameID = refSurfBuffObj->frame_idx; |
| 2288 |
surface = surface->pFwdRef; |
| 2289 |
} |
| 2290 |
|
| 2291 |
return VA_STATUS_SUCCESS; |
| 2292 |
} |
| 2293 |
|
| 2294 |
VAStatus DdiVpFunctions::DdiUpdateProcPipelinePastReferenceFrames( |
| 2295 |
PDDI_VP_CONTEXT vpCtx, |
| 2296 |
VADriverContextP vaDrvCtx, |
| 2297 |
PVPHAL_SURFACE vpHalSrcSurf, |
| 2298 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 2299 |
{ |
| 2300 |
PVPHAL_SURFACE surface = nullptr; |
| 2301 |
PDDI_MEDIA_SURFACE refSurfBuffObj = nullptr; |
| 2302 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 2303 |
|
| 2304 |
DDI_VP_FUNC_ENTER; |
| 2305 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2306 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2307 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2308 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2309 |
|
| 2310 |
// initialize |
| 2311 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 2312 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2313 |
|
| 2314 |
surface = vpHalSrcSurf; |
| 2315 |
if(!pipelineParam->forward_references) |
| 2316 |
{ |
| 2317 |
DDI_VP_NORMALMESSAGE("nullptr pipelineParam->backward_references"); |
| 2318 |
return VA_STATUS_SUCCESS; |
| 2319 |
} |
| 2320 |
|
| 2321 |
for (uint32_t i = 0; i < pipelineParam->num_forward_references; i++) |
| 2322 |
{ |
| 2323 |
if (surface->pBwdRef == nullptr) |
| 2324 |
{ |
| 2325 |
surface->pBwdRef = MOS_New(VPHAL_SURFACE); |
| 2326 |
DDI_VP_CHK_NULL(surface->pBwdRef, "nullptr surface->pBwdRef!", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2327 |
|
| 2328 |
surface->pBwdRef->Format = vpHalSrcSurf->Format; |
| 2329 |
surface->pBwdRef->SurfType = vpHalSrcSurf->SurfType; |
| 2330 |
surface->pBwdRef->rcSrc = vpHalSrcSurf->rcSrc; |
| 2331 |
surface->pBwdRef->rcDst = vpHalSrcSurf->rcDst; |
| 2332 |
surface->pBwdRef->ColorSpace = vpHalSrcSurf->ColorSpace; |
| 2333 |
surface->pBwdRef->ExtendedGamut = vpHalSrcSurf->ExtendedGamut; |
| 2334 |
surface->pBwdRef->SampleType = vpHalSrcSurf->SampleType; |
| 2335 |
surface->pBwdRef->ScalingMode = vpHalSrcSurf->ScalingMode; |
| 2336 |
surface->pBwdRef->OsResource = vpHalSrcSurf->OsResource; |
| 2337 |
surface->pBwdRef->dwWidth = vpHalSrcSurf->dwWidth; |
| 2338 |
surface->pBwdRef->dwHeight = vpHalSrcSurf->dwHeight; |
| 2339 |
surface->pBwdRef->dwPitch = vpHalSrcSurf->dwPitch; |
| 2340 |
surface->uBwdRefCount = pipelineParam->num_forward_references - i; |
| 2341 |
} |
| 2342 |
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->forward_references[i]); |
| 2343 |
DDI_VP_CHK_NULL(refSurfBuffObj, "nullptr refSurfBuffObj!", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2344 |
|
| 2345 |
surface->pBwdRef->OsResource.bo = refSurfBuffObj->bo; |
| 2346 |
surface->pBwdRef->OsResource.Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(refSurfBuffObj->format); |
| 2347 |
surface->pBwdRef->OsResource.iWidth = refSurfBuffObj->iWidth; |
| 2348 |
surface->pBwdRef->OsResource.iHeight = refSurfBuffObj->iHeight; |
| 2349 |
surface->pBwdRef->OsResource.iPitch = refSurfBuffObj->iPitch; |
| 2350 |
surface->pBwdRef->OsResource.TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(refSurfBuffObj->TileType); |
| 2351 |
surface->pBwdRef->OsResource.pGmmResInfo = refSurfBuffObj->pGmmResourceInfo; |
| 2352 |
|
| 2353 |
Mos_Solo_SetOsResource(refSurfBuffObj->pGmmResourceInfo, &surface->OsResource); |
| 2354 |
|
| 2355 |
surface->pBwdRef->FrameID = refSurfBuffObj->frame_idx; |
| 2356 |
surface = surface->pBwdRef; |
| 2357 |
} |
| 2358 |
|
| 2359 |
return VA_STATUS_SUCCESS; |
| 2360 |
} |
| 2361 |
|
| 2362 |
VAStatus DdiVpFunctions::DdiUpdateFilterParamBuffer( |
| 2363 |
VADriverContextP vaDrvCtx, |
| 2364 |
PDDI_VP_CONTEXT vpCtx, |
| 2365 |
uint32_t surfIndex, |
| 2366 |
int32_t filterType, |
| 2367 |
void *data, |
| 2368 |
uint32_t elementNum, |
| 2369 |
DDI_VP_STATE *vpStateFlags) |
| 2370 |
{ |
| 2371 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 2372 |
DDI_VP_FUNC_ENTER; |
| 2373 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2374 |
DDI_VP_CHK_NULL(vpStateFlags, "nullptr vpStateFlags.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2375 |
|
| 2376 |
switch (filterType) |
| 2377 |
{ |
| 2378 |
case VAProcFilterDeinterlacing: |
| 2379 |
vpStateFlags->bDeinterlaceEnable = true; |
| 2380 |
vaStatus = DdiSetProcFilterDinterlaceParams(vpCtx, surfIndex, (VAProcFilterParameterBufferDeinterlacing *)data); |
| 2381 |
break; |
| 2382 |
case VAProcFilterNoiseReduction: |
| 2383 |
vpStateFlags->bDenoiseEnable = true; |
| 2384 |
vaStatus = DdiSetProcFilterDenoiseParams(vpCtx, surfIndex, (VAProcFilterParameterBuffer *)data); |
| 2385 |
break; |
| 2386 |
case VAProcFilterHVSNoiseReduction: |
| 2387 |
vpStateFlags->bDenoiseEnable = true; |
| 2388 |
vaStatus = DdiSetProcFilterHVSDenoiseParams(vpCtx, surfIndex, (VAProcFilterParameterBufferHVSNoiseReduction *)data); |
| 2389 |
break; |
| 2390 |
case VAProcFilterSharpening: |
| 2391 |
vpStateFlags->bIEFEnable = true; |
| 2392 |
vaStatus = DdiSetProcFilterSharpnessParams(vpCtx, surfIndex, (VAProcFilterParameterBuffer *)data); |
| 2393 |
break; |
| 2394 |
case VAProcFilterColorBalance: |
| 2395 |
vpStateFlags->bProcampEnable = true; |
| 2396 |
vaStatus = DdiSetProcFilterColorBalanceParams(vpCtx, surfIndex, (VAProcFilterParameterBufferColorBalance *)data, elementNum); |
| 2397 |
break; |
| 2398 |
case VAProcFilterSkinToneEnhancement: |
| 2399 |
vaStatus = DdiSetProcFilterSkinToneEnhancementParams(vpCtx, surfIndex, (VAProcFilterParameterBuffer *)data); |
| 2400 |
break; |
| 2401 |
case VAProcFilterTotalColorCorrection: |
| 2402 |
vaStatus = DdiSetProcFilterTotalColorCorrectionParams(vpCtx, surfIndex, (VAProcFilterParameterBufferTotalColorCorrection *)data, elementNum); |
| 2403 |
break; |
| 2404 |
case VAProcFilterHighDynamicRangeToneMapping: |
| 2405 |
vaStatus = DdiSetProcFilterHdrTmParams(vpCtx, surfIndex, (VAProcFilterParameterBufferHDRToneMapping *)data); |
| 2406 |
break; |
| 2407 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 2408 |
case VAProcFilter3DLUT: |
| 2409 |
vaStatus = DdiSetProcFilter3DLutParams(vaDrvCtx, vpCtx, surfIndex, (VAProcFilterParameterBuffer3DLUT *)data); |
| 2410 |
break; |
| 2411 |
#endif |
| 2412 |
case VAProcFilterNone: |
| 2413 |
vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2414 |
break; |
| 2415 |
default: |
| 2416 |
DDI_VP_ASSERTMESSAGE("VAProcFilterType is unknown."); |
| 2417 |
vaStatus = VA_STATUS_ERROR_UNSUPPORTED_FILTER; |
| 2418 |
break; |
| 2419 |
} // switch (type) |
| 2420 |
|
| 2421 |
return vaStatus; |
| 2422 |
} |
| 2423 |
|
| 2424 |
VAStatus DdiVpFunctions::DdiSetProcFilterDinterlaceParams( |
| 2425 |
PDDI_VP_CONTEXT vpCtx, |
| 2426 |
uint32_t surfIndex, |
| 2427 |
VAProcFilterParameterBufferDeinterlacing *diParamBuff) |
| 2428 |
{ |
| 2429 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 2430 |
PVPHAL_SURFACE targetSurf = nullptr; |
| 2431 |
PVPHAL_SURFACE srcSurf = nullptr; |
| 2432 |
VPHAL_DI_MODE diMode; |
| 2433 |
|
| 2434 |
DDI_VP_FUNC_ENTER; |
| 2435 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2436 |
DDI_VP_CHK_NULL(diParamBuff, "nullptr diParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 2437 |
|
| 2438 |
// initialize |
| 2439 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 2440 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2441 |
|
| 2442 |
srcSurf = vpHalRenderParams->pSrc[surfIndex]; |
| 2443 |
DDI_VP_CHK_NULL(srcSurf, "nullptr srcSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2444 |
targetSurf = vpHalRenderParams->pTarget[0]; |
| 2445 |
DDI_VP_CHK_NULL(targetSurf, "nullptr targetSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2446 |
|
| 2447 |
switch (diParamBuff->algorithm) |
| 2448 |
{ |
| 2449 |
case VAProcDeinterlacingBob: |
| 2450 |
diMode = DI_MODE_BOB; |
| 2451 |
break; |
| 2452 |
case VAProcDeinterlacingMotionAdaptive: |
| 2453 |
case VAProcDeinterlacingMotionCompensated: |
| 2454 |
diMode = DI_MODE_ADI; |
| 2455 |
break; |
| 2456 |
case VAProcDeinterlacingWeave: |
| 2457 |
srcSurf->bFieldWeaving = true; |
| 2458 |
return VA_STATUS_SUCCESS; |
| 2459 |
case VAProcDeinterlacingNone: |
| 2460 |
return VA_STATUS_SUCCESS; |
| 2461 |
default: |
| 2462 |
DDI_VP_ASSERTMESSAGE("Deinterlacing type is unsupported."); |
| 2463 |
return VA_STATUS_ERROR_UNIMPLEMENTED; |
| 2464 |
} // switch (diParamBuff->algorithm) |
| 2465 |
|
| 2466 |
if (nullptr == srcSurf->pDeinterlaceParams) |
| 2467 |
{ |
| 2468 |
srcSurf->pDeinterlaceParams = MOS_New(VPHAL_DI_PARAMS); |
| 2469 |
DDI_VP_CHK_NULL(srcSurf->pDeinterlaceParams, "srcSurf->pDeinterlaceParams is nullptr", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2470 |
} |
| 2471 |
|
| 2472 |
if (nullptr == targetSurf->pDeinterlaceParams) |
| 2473 |
{ |
| 2474 |
targetSurf->pDeinterlaceParams = MOS_New(VPHAL_DI_PARAMS); |
| 2475 |
DDI_VP_CHK_NULL(targetSurf->pDeinterlaceParams, "targetSurf->pDeinterlaceParams is nullptr", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2476 |
} |
| 2477 |
//application detect scene change and then pass parameter to driver. |
| 2478 |
if (diParamBuff->flags & VA_DEINTERLACING_SCD_ENABLE) |
| 2479 |
{ |
| 2480 |
diMode = DI_MODE_BOB; |
| 2481 |
srcSurf->pDeinterlaceParams->bSCDEnable = true; |
| 2482 |
} |
| 2483 |
else |
| 2484 |
{ |
| 2485 |
srcSurf->pDeinterlaceParams->bSCDEnable = false; |
| 2486 |
} |
| 2487 |
|
| 2488 |
srcSurf->pDeinterlaceParams->DIMode = diMode; |
| 2489 |
srcSurf->pDeinterlaceParams->bSingleField = (diParamBuff->flags & VA_DEINTERLACING_ONE_FIELD) ? true : false; |
| 2490 |
srcSurf->pDeinterlaceParams->bEnableFMD = (diParamBuff->flags & VA_DEINTERLACING_FMD_ENABLE) ? true : false; |
| 2491 |
|
| 2492 |
//update sample type |
| 2493 |
UpdateSampleType(srcSurf, diParamBuff->flags); |
| 2494 |
|
| 2495 |
if (srcSurf->pDeinterlaceParams->DIMode != DI_MODE_ADI) |
| 2496 |
{ |
| 2497 |
return VA_STATUS_SUCCESS; |
| 2498 |
} |
| 2499 |
|
| 2500 |
//When pBwdRef is not nullptr and uBwdRefCount is nonzero, ADI can use Bwd Ref frame. |
| 2501 |
//Otherwise, ADI shouldn't use Bwd Ref frame. |
| 2502 |
if (srcSurf->uBwdRefCount && srcSurf->pBwdRef != nullptr) |
| 2503 |
{ |
| 2504 |
SetFrameID(vpCtx, srcSurf); |
| 2505 |
} |
| 2506 |
else |
| 2507 |
{ |
| 2508 |
//ADI no reference frame driver only care EVEN/ODD |
| 2509 |
if (diParamBuff->flags & VA_DEINTERLACING_BOTTOM_FIELD) |
| 2510 |
{ |
| 2511 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 2512 |
} |
| 2513 |
else |
| 2514 |
{ |
| 2515 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 2516 |
} |
| 2517 |
} |
| 2518 |
|
| 2519 |
//int32_t overflow process |
| 2520 |
vpCtx->FrameIDTracer.uiFrameIndex = (vpCtx->FrameIDTracer.uiFrameIndex + 1 == INT_MAX) ? 1 : vpCtx->FrameIDTracer.uiFrameIndex + 1; |
| 2521 |
|
| 2522 |
return VA_STATUS_SUCCESS; |
| 2523 |
} |
| 2524 |
|
| 2525 |
void DdiVpFunctions::VpSetColorSpaceByDefault(PVPHAL_SURFACE vpHalSurf) |
| 2526 |
{ |
| 2527 |
DDI_VP_FUNC_ENTER; |
| 2528 |
DDI_VP_CHK_NULL(vpHalSurf, "nullptr vpHalSurf.", ); |
| 2529 |
|
| 2530 |
if ((vpHalSurf->rcSrc.right - vpHalSurf->rcSrc.left) <= 1280 && (vpHalSurf->rcSrc.bottom - vpHalSurf->rcSrc.top) <= 720) |
| 2531 |
{ |
| 2532 |
vpHalSurf->ColorSpace = CSpace_BT601; |
| 2533 |
} //720p |
| 2534 |
else if ((vpHalSurf->rcSrc.right - vpHalSurf->rcSrc.left) <= 1920 && (vpHalSurf->rcSrc.bottom - vpHalSurf->rcSrc.top) <= 1080) |
| 2535 |
{ |
| 2536 |
vpHalSurf->ColorSpace = CSpace_BT709; |
| 2537 |
} //1080p |
| 2538 |
else |
| 2539 |
{ |
| 2540 |
if (vpHalSurf->Format == Format_P010 || vpHalSurf->Format == Format_P016) |
| 2541 |
{ |
| 2542 |
vpHalSurf->ColorSpace = CSpace_BT2020; |
| 2543 |
} |
| 2544 |
else |
| 2545 |
{ |
| 2546 |
vpHalSurf->ColorSpace = CSpace_BT709; |
| 2547 |
} |
| 2548 |
} //4K |
| 2549 |
return; |
| 2550 |
} |
| 2551 |
|
| 2552 |
void DdiVpFunctions::VpSetColorSpaceByColorStandard( |
| 2553 |
PVPHAL_SURFACE vpHalSurf, |
| 2554 |
VAProcColorStandardType colorStandard, |
| 2555 |
VAProcColorProperties colorProperties, |
| 2556 |
uint8_t colorRange) |
| 2557 |
{ |
| 2558 |
DDI_VP_FUNC_ENTER; |
| 2559 |
DDI_VP_CHK_NULL(vpHalSurf, "nullptr vpHalSurf.", ); |
| 2560 |
|
| 2561 |
switch (colorStandard) |
| 2562 |
{ |
| 2563 |
case VAProcColorStandardBT709: |
| 2564 |
#if (VA_MAJOR_VERSION < 1) |
| 2565 |
if (flag & VA_SOURCE_RANGE_FULL) |
| 2566 |
#else |
| 2567 |
if (colorRange == VA_SOURCE_RANGE_FULL) |
| 2568 |
#endif |
| 2569 |
{ |
| 2570 |
vpHalSurf->ColorSpace = CSpace_BT709_FullRange; |
| 2571 |
} |
| 2572 |
else |
| 2573 |
{ |
| 2574 |
vpHalSurf->ColorSpace = CSpace_BT709; |
| 2575 |
} |
| 2576 |
break; |
| 2577 |
case VAProcColorStandardBT601: |
| 2578 |
#if (VA_MAJOR_VERSION < 1) |
| 2579 |
if (flag & VA_SOURCE_RANGE_FULL) |
| 2580 |
#else |
| 2581 |
if (colorRange == VA_SOURCE_RANGE_FULL) |
| 2582 |
#endif |
| 2583 |
{ |
| 2584 |
vpHalSurf->ColorSpace = CSpace_BT601_FullRange; |
| 2585 |
} |
| 2586 |
else |
| 2587 |
{ |
| 2588 |
vpHalSurf->ColorSpace = CSpace_BT601; |
| 2589 |
} |
| 2590 |
break; |
| 2591 |
case VAProcColorStandardBT2020: |
| 2592 |
#if (VA_MAJOR_VERSION < 1) |
| 2593 |
if (flag & VA_SOURCE_RANGE_FULL) |
| 2594 |
#else |
| 2595 |
if (colorRange == VA_SOURCE_RANGE_FULL) |
| 2596 |
#endif |
| 2597 |
{ |
| 2598 |
vpHalSurf->ColorSpace = CSpace_BT2020_FullRange; |
| 2599 |
} |
| 2600 |
else |
| 2601 |
{ |
| 2602 |
vpHalSurf->ColorSpace = CSpace_BT2020; |
| 2603 |
} |
| 2604 |
break; |
| 2605 |
case VAProcColorStandardBT470M: |
| 2606 |
case VAProcColorStandardBT470BG: |
| 2607 |
case VAProcColorStandardSMPTE170M: |
| 2608 |
case VAProcColorStandardSMPTE240M: |
| 2609 |
case VAProcColorStandardGenericFilm: |
| 2610 |
case VAProcColorStandardXVYCC601: |
| 2611 |
case VAProcColorStandardXVYCC709: |
| 2612 |
vpHalSurf->ColorSpace = CSpace_None; |
| 2613 |
break; |
| 2614 |
case VAProcColorStandardExplicit: |
| 2615 |
VpSetColorStandardExplictly(vpHalSurf, colorStandard, colorProperties); |
| 2616 |
break; |
| 2617 |
default: |
| 2618 |
vpHalSurf->ColorSpace = CSpace_BT601; |
| 2619 |
break; |
| 2620 |
} |
| 2621 |
return; |
| 2622 |
} |
| 2623 |
|
| 2624 |
void DdiVpFunctions::UpdateSampleType( |
| 2625 |
PVPHAL_SURFACE srcSurf, |
| 2626 |
uint32_t flags) |
| 2627 |
{ |
| 2628 |
DDI_VP_FUNC_ENTER; |
| 2629 |
DDI_VP_CHK_NULL(srcSurf, "nullptr srcSurf.", ); |
| 2630 |
if (flags & VA_DEINTERLACING_BOTTOM_FIELD_FIRST) |
| 2631 |
{ |
| 2632 |
if (flags & VA_DEINTERLACING_BOTTOM_FIELD) |
| 2633 |
{ |
| 2634 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 2635 |
} |
| 2636 |
else |
| 2637 |
{ |
| 2638 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD; |
| 2639 |
} |
| 2640 |
} |
| 2641 |
else |
| 2642 |
{ |
| 2643 |
if (flags & VA_DEINTERLACING_BOTTOM_FIELD) |
| 2644 |
{ |
| 2645 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD; |
| 2646 |
} |
| 2647 |
else |
| 2648 |
{ |
| 2649 |
srcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 2650 |
} |
| 2651 |
} |
| 2652 |
return; |
| 2653 |
} |
| 2654 |
|
| 2655 |
void DdiVpFunctions::SetFrameID(PDDI_VP_CONTEXT vpCtx, PVPHAL_SURFACE srcSurf) |
| 2656 |
{ |
| 2657 |
DDI_VP_FUNC_ENTER; |
| 2658 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", ); |
| 2659 |
DDI_VP_CHK_NULL(srcSurf, "nullptr srcSurf.", ); |
| 2660 |
|
| 2661 |
srcSurf->uBwdRefCount = 1; |
| 2662 |
|
| 2663 |
//When the bo of the current frame's SRC and reference are same with previous frame's, |
| 2664 |
//we should set the frame ID same as previous frame's setting. |
| 2665 |
if (vpCtx->FrameIDTracer.pLastSrcSurfBo == srcSurf->OsResource.bo && |
| 2666 |
vpCtx->FrameIDTracer.pLastBwdSurfBo == srcSurf->pBwdRef->OsResource.bo && |
| 2667 |
vpCtx->FrameIDTracer.uiLastSampleType != srcSurf->SampleType) |
| 2668 |
{ |
| 2669 |
srcSurf->FrameID = vpCtx->FrameIDTracer.uiLastSrcSurfFrameID; |
| 2670 |
srcSurf->pBwdRef->FrameID = vpCtx->FrameIDTracer.uiLastBwdSurfFrameID; |
| 2671 |
} |
| 2672 |
//Otherwise, we should update the values of frame ID and FrameID tracer. |
| 2673 |
else |
| 2674 |
{ |
| 2675 |
srcSurf->pBwdRef->FrameID = (VP_SETTING_SAME_SAMPLE_THRESHOLD + 1) * vpCtx->FrameIDTracer.uiFrameIndex; |
| 2676 |
srcSurf->FrameID = srcSurf->pBwdRef->FrameID + (VP_SETTING_SAME_SAMPLE_THRESHOLD + 1); |
| 2677 |
|
| 2678 |
vpCtx->FrameIDTracer.pLastSrcSurfBo = srcSurf->OsResource.bo; |
| 2679 |
vpCtx->FrameIDTracer.pLastBwdSurfBo = srcSurf->pBwdRef->OsResource.bo; |
| 2680 |
|
| 2681 |
vpCtx->FrameIDTracer.uiLastSrcSurfFrameID = srcSurf->FrameID; |
| 2682 |
vpCtx->FrameIDTracer.uiLastBwdSurfFrameID = srcSurf->pBwdRef->FrameID; |
| 2683 |
vpCtx->FrameIDTracer.uiLastSampleType = srcSurf->SampleType; |
| 2684 |
} |
| 2685 |
return; |
| 2686 |
} |
| 2687 |
|
| 2688 |
VAStatus DdiVpFunctions::DdiSetProcFilterDenoiseParams( |
| 2689 |
PDDI_VP_CONTEXT vpCtx, |
| 2690 |
uint32_t surfIndex, |
| 2691 |
VAProcFilterParameterBuffer *dnParamBuff) |
| 2692 |
{ |
| 2693 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 2694 |
PVPHAL_SURFACE src = nullptr; |
| 2695 |
|
| 2696 |
DDI_VP_FUNC_ENTER; |
| 2697 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2698 |
|
| 2699 |
// initialize |
| 2700 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 2701 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2702 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 2703 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2704 |
|
| 2705 |
if (nullptr == src->pDenoiseParams) |
| 2706 |
{ |
| 2707 |
src->pDenoiseParams = MOS_New(VPHAL_DENOISE_PARAMS); |
| 2708 |
} |
| 2709 |
DDI_VP_CHK_NULL(src->pDenoiseParams, "MOS_New pDenoiseParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2710 |
|
| 2711 |
// denoise caps range is from 0 to 64, out of range parameter is treated as an error |
| 2712 |
if (dnParamBuff->value < NOISEREDUCTION_MIN || dnParamBuff->value > NOISEREDUCTION_MAX) |
| 2713 |
{ |
| 2714 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2715 |
} |
| 2716 |
|
| 2717 |
src->pDenoiseParams->fDenoiseFactor = dnParamBuff->value; |
| 2718 |
|
| 2719 |
// Luma and chroma denoise should be always enabled when noise reduction is needed |
| 2720 |
src->pDenoiseParams->bEnableLuma = true; |
| 2721 |
src->pDenoiseParams->bEnableChroma = true; |
| 2722 |
src->pDenoiseParams->bAutoDetect = false; |
| 2723 |
src->pDenoiseParams->NoiseLevel = NOISELEVEL_DEFAULT; |
| 2724 |
|
| 2725 |
return VA_STATUS_SUCCESS; |
| 2726 |
} |
| 2727 |
|
| 2728 |
VAStatus DdiVpFunctions::DdiSetProcFilterHVSDenoiseParams( |
| 2729 |
PDDI_VP_CONTEXT vpCtx, |
| 2730 |
uint32_t surfIndex, |
| 2731 |
VAProcFilterParameterBufferHVSNoiseReduction *hvsDnParamBuff) |
| 2732 |
{ |
| 2733 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 2734 |
PVPHAL_SURFACE src = nullptr; |
| 2735 |
|
| 2736 |
DDI_VP_FUNC_ENTER; |
| 2737 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2738 |
DDI_VP_CHK_NULL(hvsDnParamBuff, "nullptr hvsDnParamBuff.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2739 |
|
| 2740 |
// initialize |
| 2741 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 2742 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2743 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 2744 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2745 |
|
| 2746 |
if (nullptr == src->pDenoiseParams) |
| 2747 |
{ |
| 2748 |
src->pDenoiseParams = MOS_New(VPHAL_DENOISE_PARAMS); |
| 2749 |
} |
| 2750 |
DDI_VP_CHK_NULL(src->pDenoiseParams, "MOS_New pDenoiseParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2751 |
|
| 2752 |
// Luma and chroma denoise should be always enabled when noise reduction is needed |
| 2753 |
src->pDenoiseParams->bEnableLuma = true; |
| 2754 |
src->pDenoiseParams->bEnableChroma = true; |
| 2755 |
src->pDenoiseParams->bEnableHVSDenoise = true; |
| 2756 |
|
| 2757 |
SetHVSDnParams(hvsDnParamBuff, src->pDenoiseParams); |
| 2758 |
|
| 2759 |
DDI_VP_NORMALMESSAGE("HVS Denoise is enabled with qp %d, strength %d, mode %d!", src->pDenoiseParams->HVSDenoise.QP, src->pDenoiseParams->HVSDenoise.Strength, src->pDenoiseParams->HVSDenoise.Mode); |
| 2760 |
|
| 2761 |
return VA_STATUS_SUCCESS; |
| 2762 |
} |
| 2763 |
|
| 2764 |
void DdiVpFunctions::SetHVSDnParams( |
| 2765 |
VAProcFilterParameterBufferHVSNoiseReduction *hvsDnParamBuff, |
| 2766 |
PVPHAL_DENOISE_PARAMS denoiseParams) |
| 2767 |
{ |
| 2768 |
DDI_VP_FUNC_ENTER; |
| 2769 |
DDI_VP_CHK_NULL(hvsDnParamBuff, "nullptr vpCtx.",); |
| 2770 |
DDI_VP_CHK_NULL(denoiseParams, "nullptr hvsDnParamBuff.", ); |
| 2771 |
|
| 2772 |
switch (hvsDnParamBuff->mode) |
| 2773 |
{ |
| 2774 |
case VA_PROC_HVS_DENOISE_AUTO_SUBJECTIVE: |
| 2775 |
denoiseParams->HVSDenoise.Mode = HVSDENOISE_AUTO_SUBJECTIVE; |
| 2776 |
denoiseParams->bAutoDetect = true; |
| 2777 |
break; |
| 2778 |
case VA_PROC_HVS_DENOISE_MANUAL: |
| 2779 |
denoiseParams->HVSDenoise.Mode = HVSDENOISE_MANUAL; |
| 2780 |
break; |
| 2781 |
case VA_PROC_HVS_DENOISE_DEFAULT: |
| 2782 |
case VA_PROC_HVS_DENOISE_AUTO_BDRATE: |
| 2783 |
default: |
| 2784 |
denoiseParams->HVSDenoise.Mode = HVSDENOISE_AUTO_BDRATE; |
| 2785 |
denoiseParams->bAutoDetect = true; |
| 2786 |
} // switch (hvsDnParamBuff->mode) |
| 2787 |
|
| 2788 |
if (denoiseParams->HVSDenoise.Mode == HVSDENOISE_AUTO_BDRATE) |
| 2789 |
{ |
| 2790 |
denoiseParams->HVSDenoise.QP = hvsDnParamBuff->qp; |
| 2791 |
if (denoiseParams->HVSDenoise.QP == 0) |
| 2792 |
{ |
| 2793 |
//If didn't set value, HVS Auto Bdrate Mode default qp 27 |
| 2794 |
denoiseParams->HVSDenoise.QP = 27; |
| 2795 |
} |
| 2796 |
} |
| 2797 |
else if (denoiseParams->HVSDenoise.Mode == HVSDENOISE_AUTO_SUBJECTIVE) |
| 2798 |
{ |
| 2799 |
//HVS Subjective Mode default qp 32 |
| 2800 |
denoiseParams->HVSDenoise.QP = 32; |
| 2801 |
} |
| 2802 |
else |
| 2803 |
{ |
| 2804 |
denoiseParams->HVSDenoise.QP = 32; |
| 2805 |
denoiseParams->HVSDenoise.Strength = hvsDnParamBuff->strength; |
| 2806 |
} |
| 2807 |
return; |
| 2808 |
} |
| 2809 |
|
| 2810 |
MOS_STATUS DdiVpFunctions::VpHalDdiInitIEFParams( |
| 2811 |
PVPHAL_IEF_PARAMS iefParams) |
| 2812 |
{ |
| 2813 |
DDI_VP_FUNC_ENTER; |
| 2814 |
DDI_VP_CHK_NULL(iefParams, "nullptr iefParams", MOS_STATUS_INVALID_PARAMETER); |
| 2815 |
|
| 2816 |
// Init default values for flows where user feature key is not available or used |
| 2817 |
iefParams->bSkintoneTuned = true; |
| 2818 |
iefParams->bEmphasizeSkinDetail = false; |
| 2819 |
iefParams->bSmoothMode = false; |
| 2820 |
iefParams->StrongEdgeWeight = IEF_STRONG_EDGE_WEIGHT; |
| 2821 |
iefParams->RegularWeight = IEF_REGULAR_WEIGHT; |
| 2822 |
iefParams->StrongEdgeThreshold = IEF_STRONG_EDGE_THRESHOLD; |
| 2823 |
|
| 2824 |
return MOS_STATUS_SUCCESS; |
| 2825 |
} |
| 2826 |
|
| 2827 |
VAStatus DdiVpFunctions::DdiSetProcFilterSharpnessParams( |
| 2828 |
PDDI_VP_CONTEXT vpCtx, |
| 2829 |
uint32_t surfIndex, |
| 2830 |
VAProcFilterParameterBuffer *sharpParamBuff) |
| 2831 |
{ |
| 2832 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 2833 |
PVPHAL_SURFACE src = nullptr; |
| 2834 |
|
| 2835 |
DDI_VP_FUNC_ENTER; |
| 2836 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2837 |
DDI_VP_CHK_NULL(sharpParamBuff, "nullptr sharpParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 2838 |
|
| 2839 |
// initialize |
| 2840 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 2841 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2842 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 2843 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2844 |
|
| 2845 |
if (nullptr == src->pIEFParams) |
| 2846 |
{ |
| 2847 |
src->pIEFParams = MOS_New(VPHAL_IEF_PARAMS); |
| 2848 |
DDI_VP_CHK_NULL(src->pIEFParams, "MOS_New pIEFParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2849 |
} |
| 2850 |
|
| 2851 |
// out of range parameter is treated as an error |
| 2852 |
if (sharpParamBuff->value < EDGEENHANCEMENT_MIN || sharpParamBuff->value > EDGEENHANCEMENT_MAX) |
| 2853 |
{ |
| 2854 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2855 |
} |
| 2856 |
|
| 2857 |
// sharpness option |
| 2858 |
// setting with hard code in mplayer side. |
| 2859 |
// refer to sharpening section of render_picture_vp() defined in vaapi.c. |
| 2860 |
// change flag and factor for testing. |
| 2861 |
VpHalDdiInitIEFParams(src->pIEFParams); |
| 2862 |
src->bIEF = true; |
| 2863 |
src->pIEFParams->bEnabled = true; |
| 2864 |
src->pIEFParams->fIEFFactor = sharpParamBuff->value; |
| 2865 |
|
| 2866 |
return VA_STATUS_SUCCESS; |
| 2867 |
} |
| 2868 |
|
| 2869 |
VAStatus DdiVpFunctions::DdiSetProcFilterColorBalanceParams( |
| 2870 |
PDDI_VP_CONTEXT vpCtx, |
| 2871 |
uint32_t surfIndex, |
| 2872 |
VAProcFilterParameterBufferColorBalance *colorBalanceParamBuff, |
| 2873 |
uint32_t elementNum) |
| 2874 |
{ |
| 2875 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 2876 |
PVPHAL_SURFACE src = nullptr; |
| 2877 |
bool procamp = false; |
| 2878 |
|
| 2879 |
DDI_VP_FUNC_ENTER; |
| 2880 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 2881 |
DDI_VP_CHK_NULL(colorBalanceParamBuff, "nullptr colorBalanceParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 2882 |
|
| 2883 |
// initialize |
| 2884 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 2885 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2886 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 2887 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 2888 |
|
| 2889 |
for (uint32_t i = 0; i < elementNum; i++) |
| 2890 |
{ |
| 2891 |
if ((VAProcColorBalanceHue == colorBalanceParamBuff[i].attrib) || |
| 2892 |
(VAProcColorBalanceSaturation == colorBalanceParamBuff[i].attrib) || |
| 2893 |
(VAProcColorBalanceBrightness == colorBalanceParamBuff[i].attrib) || |
| 2894 |
(VAProcColorBalanceContrast == colorBalanceParamBuff[i].attrib)) |
| 2895 |
{ |
| 2896 |
procamp = true; |
| 2897 |
break; |
| 2898 |
} |
| 2899 |
} |
| 2900 |
|
| 2901 |
if (nullptr == src->pProcampParams && true == procamp) |
| 2902 |
{ |
| 2903 |
src->pProcampParams = MOS_New(VPHAL_PROCAMP_PARAMS); |
| 2904 |
DDI_VP_CHK_NULL(src->pProcampParams, "MOS_New Source pProcampParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2905 |
} |
| 2906 |
|
| 2907 |
if (nullptr == vpHalRenderParams->pTarget[0]->pProcampParams) |
| 2908 |
{ |
| 2909 |
vpHalRenderParams->pTarget[0]->pProcampParams = MOS_New(VPHAL_PROCAMP_PARAMS); |
| 2910 |
DDI_VP_CHK_NULL(vpHalRenderParams->pTarget[0]->pProcampParams, "MOS_New Target pProcampParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2911 |
} |
| 2912 |
|
| 2913 |
// Needed for ACE |
| 2914 |
if (nullptr == src->pColorPipeParams && SURF_IN_PRIMARY == src->SurfType) |
| 2915 |
{ |
| 2916 |
src->pColorPipeParams = MOS_New(VPHAL_COLORPIPE_PARAMS); |
| 2917 |
DDI_VP_CHK_NULL(src->pColorPipeParams, "MOS_New pColorPipeParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 2918 |
} |
| 2919 |
|
| 2920 |
// set default value |
| 2921 |
if (nullptr != src->pProcampParams) |
| 2922 |
{ |
| 2923 |
src->pProcampParams->fHue = PROCAMP_HUE_DEFAULT; |
| 2924 |
src->pProcampParams->fSaturation = PROCAMP_SATURATION_DEFAULT; |
| 2925 |
src->pProcampParams->fBrightness = PROCAMP_BRIGHTNESS_DEFAULT; |
| 2926 |
src->pProcampParams->fContrast = PROCAMP_CONTRAST_DEFAULT; |
| 2927 |
} |
| 2928 |
|
| 2929 |
for (uint32_t i = 0; i < elementNum; i++) |
| 2930 |
{ |
| 2931 |
DDI_CHK_RET(SetColorBalanceParams(colorBalanceParamBuff, i, src, procamp), "Failed to Set ColorBalanceParams."); |
| 2932 |
} |
| 2933 |
|
| 2934 |
return VA_STATUS_SUCCESS; |
| 2935 |
} |
| 2936 |
|
| 2937 |
VAStatus DdiVpFunctions::SetColorBalanceParams( |
| 2938 |
VAProcFilterParameterBufferColorBalance *colorBalanceParamBuff, |
| 2939 |
uint32_t index, |
| 2940 |
PVPHAL_SURFACE src, |
| 2941 |
bool procamp) |
| 2942 |
{ |
| 2943 |
DDI_VP_FUNC_ENTER; |
| 2944 |
switch (colorBalanceParamBuff[index].attrib) |
| 2945 |
{ |
| 2946 |
case VAProcColorBalanceHue: |
| 2947 |
if (colorBalanceParamBuff[index].value < PROCAMP_HUE_MIN || colorBalanceParamBuff[index].value > PROCAMP_HUE_MAX) |
| 2948 |
{ |
| 2949 |
DDI_VP_ASSERTMESSAGE("%d: Hue is out of bounds.", index); |
| 2950 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2951 |
} |
| 2952 |
if (true == procamp) |
| 2953 |
{ |
| 2954 |
src->pProcampParams->bEnabled = true; |
| 2955 |
src->pProcampParams->fHue = colorBalanceParamBuff[index].value; |
| 2956 |
} |
| 2957 |
break; |
| 2958 |
case VAProcColorBalanceSaturation: |
| 2959 |
if (colorBalanceParamBuff[index].value < PROCAMP_SATURATION_MIN || colorBalanceParamBuff[index].value > PROCAMP_SATURATION_MAX) |
| 2960 |
{ |
| 2961 |
DDI_VP_ASSERTMESSAGE("%d: Saturation is out of bounds.", index); |
| 2962 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2963 |
} |
| 2964 |
if (true == procamp) |
| 2965 |
{ |
| 2966 |
src->pProcampParams->bEnabled = true; |
| 2967 |
src->pProcampParams->fSaturation = colorBalanceParamBuff[index].value; |
| 2968 |
} |
| 2969 |
break; |
| 2970 |
case VAProcColorBalanceBrightness: |
| 2971 |
if (colorBalanceParamBuff[index].value < PROCAMP_BRIGHTNESS_MIN || colorBalanceParamBuff[index].value > PROCAMP_BRIGHTNESS_MAX) |
| 2972 |
{ |
| 2973 |
DDI_VP_ASSERTMESSAGE("%d: Brightness is out of bounds.", index); |
| 2974 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2975 |
} |
| 2976 |
if (true == procamp) |
| 2977 |
{ |
| 2978 |
src->pProcampParams->bEnabled = true; |
| 2979 |
src->pProcampParams->fBrightness = colorBalanceParamBuff[index].value; |
| 2980 |
} |
| 2981 |
break; |
| 2982 |
case VAProcColorBalanceContrast: |
| 2983 |
if (colorBalanceParamBuff[index].value < PROCAMP_CONTRAST_MIN || colorBalanceParamBuff[index].value > PROCAMP_CONTRAST_MAX) |
| 2984 |
{ |
| 2985 |
DDI_VP_ASSERTMESSAGE("%d: Contrast is out of bounds.", index); |
| 2986 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2987 |
} |
| 2988 |
if (true == procamp) |
| 2989 |
{ |
| 2990 |
src->pProcampParams->bEnabled = true; |
| 2991 |
src->pProcampParams->fContrast = colorBalanceParamBuff[index].value; |
| 2992 |
} |
| 2993 |
break; |
| 2994 |
case VAProcColorBalanceAutoContrast: |
| 2995 |
if (SURF_IN_PRIMARY == src->SurfType) |
| 2996 |
{ |
| 2997 |
src->pColorPipeParams->bEnableACE = true; |
| 2998 |
src->pColorPipeParams->dwAceLevel = ACE_LEVEL_DEFAULT; |
| 2999 |
src->pColorPipeParams->dwAceStrength = ACE_STRENGTH_DEFAULT; |
| 3000 |
} |
| 3001 |
break; |
| 3002 |
case VAProcColorBalanceAutoSaturation: |
| 3003 |
case VAProcColorBalanceAutoBrightness: |
| 3004 |
return VA_STATUS_ERROR_UNIMPLEMENTED; |
| 3005 |
case VAProcColorBalanceNone: |
| 3006 |
case VAProcColorBalanceCount: |
| 3007 |
default: |
| 3008 |
DDI_VP_ASSERTMESSAGE("colorBalanceParamBuff[%d].attrib is unknown.", index); |
| 3009 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3010 |
} // switch (attrib) |
| 3011 |
return VA_STATUS_SUCCESS; |
| 3012 |
} |
| 3013 |
|
| 3014 |
VAStatus DdiVpFunctions::DdiSetProcFilterSkinToneEnhancementParams( |
| 3015 |
PDDI_VP_CONTEXT vpCtx, |
| 3016 |
uint32_t surfIndex, |
| 3017 |
VAProcFilterParameterBuffer *steParamBuff) |
| 3018 |
{ |
| 3019 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3020 |
PVPHAL_SURFACE src = nullptr; |
| 3021 |
|
| 3022 |
DDI_VP_FUNC_ENTER; |
| 3023 |
DDI_VP_CHK_NULL(steParamBuff, "Null steParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3024 |
|
| 3025 |
// initialize |
| 3026 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3027 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3028 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 3029 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3030 |
|
| 3031 |
if (SURF_IN_PRIMARY == src->SurfType) |
| 3032 |
{ |
| 3033 |
if (nullptr == src->pColorPipeParams) |
| 3034 |
{ |
| 3035 |
src->pColorPipeParams = MOS_New(VPHAL_COLORPIPE_PARAMS); |
| 3036 |
DDI_VP_CHK_NULL(src->pColorPipeParams, "MOS_New pColorPipeParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3037 |
} |
| 3038 |
|
| 3039 |
// out of range parameter is treated as an error |
| 3040 |
if (steParamBuff->value < STE_MIN || steParamBuff->value > STE_MAX) |
| 3041 |
{ |
| 3042 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3043 |
} |
| 3044 |
|
| 3045 |
src->pColorPipeParams->bEnableSTE = true; |
| 3046 |
src->pColorPipeParams->SteParams.dwSTEFactor = (uint32_t)steParamBuff->value; |
| 3047 |
} |
| 3048 |
|
| 3049 |
return VA_STATUS_SUCCESS; |
| 3050 |
} |
| 3051 |
|
| 3052 |
VAStatus DdiVpFunctions::DdiSetProcFilterTotalColorCorrectionParams( |
| 3053 |
PDDI_VP_CONTEXT vpCtx, |
| 3054 |
uint32_t surfIndex, |
| 3055 |
VAProcFilterParameterBufferTotalColorCorrection *tccParamBuff, |
| 3056 |
uint32_t elementNum) |
| 3057 |
{ |
| 3058 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3059 |
PVPHAL_SURFACE src = nullptr; |
| 3060 |
|
| 3061 |
DDI_VP_FUNC_ENTER; |
| 3062 |
DDI_VP_CHK_NULL(tccParamBuff, "nullptr tccParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3063 |
|
| 3064 |
// initialize |
| 3065 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3066 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3067 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 3068 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3069 |
|
| 3070 |
if (SURF_IN_PRIMARY == src->SurfType) |
| 3071 |
{ |
| 3072 |
if (nullptr == src->pColorPipeParams) |
| 3073 |
{ |
| 3074 |
src->pColorPipeParams = MOS_New(VPHAL_COLORPIPE_PARAMS); |
| 3075 |
DDI_VP_CHK_NULL(src->pColorPipeParams, "MOS_New pColorPipeParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3076 |
} |
| 3077 |
|
| 3078 |
// set default values |
| 3079 |
src->pColorPipeParams->TccParams.Red = (uint8_t)TCC_DEFAULT; |
| 3080 |
src->pColorPipeParams->TccParams.Green = (uint8_t)TCC_DEFAULT; |
| 3081 |
src->pColorPipeParams->TccParams.Blue = (uint8_t)TCC_DEFAULT; |
| 3082 |
src->pColorPipeParams->TccParams.Cyan = (uint8_t)TCC_DEFAULT; |
| 3083 |
src->pColorPipeParams->TccParams.Magenta = (uint8_t)TCC_DEFAULT; |
| 3084 |
src->pColorPipeParams->TccParams.Yellow = (uint8_t)TCC_DEFAULT; |
| 3085 |
|
| 3086 |
for (uint32_t i = 0; i < elementNum; i++) |
| 3087 |
{ |
| 3088 |
if (tccParamBuff[i].value < TCC_MIN || tccParamBuff[i].value > TCC_MAX) |
| 3089 |
{ |
| 3090 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3091 |
} |
| 3092 |
|
| 3093 |
src->pColorPipeParams->bEnableTCC = true; |
| 3094 |
|
| 3095 |
switch (tccParamBuff[i].attrib) |
| 3096 |
{ |
| 3097 |
case VAProcTotalColorCorrectionRed: |
| 3098 |
src->pColorPipeParams->TccParams.Red = (uint8_t)tccParamBuff[i].value; |
| 3099 |
break; |
| 3100 |
|
| 3101 |
case VAProcTotalColorCorrectionGreen: |
| 3102 |
src->pColorPipeParams->TccParams.Green = (uint8_t)tccParamBuff[i].value; |
| 3103 |
break; |
| 3104 |
|
| 3105 |
case VAProcTotalColorCorrectionBlue: |
| 3106 |
src->pColorPipeParams->TccParams.Blue = (uint8_t)tccParamBuff[i].value; |
| 3107 |
break; |
| 3108 |
|
| 3109 |
case VAProcTotalColorCorrectionCyan: |
| 3110 |
src->pColorPipeParams->TccParams.Cyan = (uint8_t)tccParamBuff[i].value; |
| 3111 |
break; |
| 3112 |
|
| 3113 |
case VAProcTotalColorCorrectionMagenta: |
| 3114 |
src->pColorPipeParams->TccParams.Magenta = (uint8_t)tccParamBuff[i].value; |
| 3115 |
break; |
| 3116 |
|
| 3117 |
case VAProcTotalColorCorrectionYellow: |
| 3118 |
src->pColorPipeParams->TccParams.Yellow = (uint8_t)tccParamBuff[i].value; |
| 3119 |
break; |
| 3120 |
|
| 3121 |
case VAProcTotalColorCorrectionNone: |
| 3122 |
case VAProcTotalColorCorrectionCount: |
| 3123 |
default: |
| 3124 |
DDI_VP_ASSERTMESSAGE("tccParamBuff[%d].attrib is unknown.", i); |
| 3125 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3126 |
} |
| 3127 |
} |
| 3128 |
} |
| 3129 |
|
| 3130 |
return VA_STATUS_SUCCESS; |
| 3131 |
} |
| 3132 |
|
| 3133 |
VAStatus DdiVpFunctions::DdiSetProcFilterHdrTmParams( |
| 3134 |
PDDI_VP_CONTEXT vpCtx, |
| 3135 |
uint32_t surfIndex, |
| 3136 |
VAProcFilterParameterBufferHDRToneMapping *hdrTmParamBuff) |
| 3137 |
{ |
| 3138 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3139 |
PVPHAL_SURFACE src = nullptr; |
| 3140 |
VAStatus eStatus; |
| 3141 |
|
| 3142 |
DDI_VP_FUNC_ENTER; |
| 3143 |
DDI_VP_CHK_NULL(hdrTmParamBuff, "nullptr hdrTmParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3144 |
|
| 3145 |
// initialize |
| 3146 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3147 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3148 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 3149 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3150 |
|
| 3151 |
eStatus = VpUpdateProcHdrState(src, &hdrTmParamBuff->data); |
| 3152 |
|
| 3153 |
return eStatus; |
| 3154 |
} |
| 3155 |
|
| 3156 |
VAStatus DdiVpFunctions::VpUpdateProcHdrState( |
| 3157 |
const PVPHAL_SURFACE vpHalSurf, |
| 3158 |
const VAHdrMetaData *hdrMetadata) |
| 3159 |
{ |
| 3160 |
VAHdrMetaDataHDR10 *hdr10MetaData = nullptr; |
| 3161 |
DDI_VP_FUNC_ENTER; |
| 3162 |
DDI_VP_CHK_NULL(vpHalSurf, "Null vpHalSurf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3163 |
|
| 3164 |
// pass HDR metadata |
| 3165 |
if ((hdrMetadata != nullptr) && (hdrMetadata->metadata_size != 0)) |
| 3166 |
{ |
| 3167 |
if (vpHalSurf->pHDRParams == nullptr) |
| 3168 |
{ |
| 3169 |
vpHalSurf->pHDRParams = MOS_New(VPHAL_HDR_PARAMS); |
| 3170 |
DDI_VP_CHK_NULL(vpHalSurf->pHDRParams, "MOS_New VPHAL_HDR_PARAMS failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3171 |
} |
| 3172 |
|
| 3173 |
// HDR10 Meta Data |
| 3174 |
if (hdrMetadata->metadata_type == VAProcHighDynamicRangeMetadataHDR10) |
| 3175 |
{ |
| 3176 |
DDI_VP_NORMALMESSAGE("VpSetHdrParams HDR10 metadata."); |
| 3177 |
hdr10MetaData = (VAHdrMetaDataHDR10 *)hdrMetadata->metadata; |
| 3178 |
if (hdr10MetaData) |
| 3179 |
{ |
| 3180 |
vpHalSurf->pHDRParams->white_point_x = hdr10MetaData->white_point_x; |
| 3181 |
vpHalSurf->pHDRParams->white_point_y = hdr10MetaData->white_point_y; |
| 3182 |
DDI_VP_NORMALMESSAGE("hdr10MetaData white_point_x %d, white_point_y %d.", hdr10MetaData->white_point_x, hdr10MetaData->white_point_y); |
| 3183 |
|
| 3184 |
// From VAAPI defintion which is following video spec, max/min_display_mastering_luminance are in units of 0.0001 candelas per square metre. |
| 3185 |
uint32_t max_display_mastering_luminance = (hdr10MetaData->max_display_mastering_luminance > 655350000 ) ? 655350000 : hdr10MetaData->max_display_mastering_luminance; |
| 3186 |
uint32_t min_display_mastering_luminance = (hdr10MetaData->min_display_mastering_luminance > 655350000 ) ? 655350000 : hdr10MetaData->min_display_mastering_luminance; |
| 3187 |
|
| 3188 |
vpHalSurf->pHDRParams->max_display_mastering_luminance = (uint16_t)(max_display_mastering_luminance / 10000);; |
| 3189 |
vpHalSurf->pHDRParams->min_display_mastering_luminance = (uint16_t)(min_display_mastering_luminance / 10000); |
| 3190 |
DDI_VP_NORMALMESSAGE("hdr10MetaData max_display_mastering_luminance %d, min_display_mastering_luminance %d.", hdr10MetaData->max_display_mastering_luminance, hdr10MetaData->min_display_mastering_luminance); |
| 3191 |
|
| 3192 |
vpHalSurf->pHDRParams->MaxCLL = hdr10MetaData->max_content_light_level; |
| 3193 |
vpHalSurf->pHDRParams->MaxFALL = hdr10MetaData->max_pic_average_light_level; |
| 3194 |
DDI_VP_NORMALMESSAGE("hdr10MetaData MaxCLL %d, MaxFALL %d.", hdr10MetaData->max_content_light_level, hdr10MetaData->max_pic_average_light_level); |
| 3195 |
|
| 3196 |
vpHalSurf->pHDRParams->bAutoMode = false; |
| 3197 |
vpHalSurf->pHDRParams->MaxCLL = (vpHalSurf->pHDRParams->MaxCLL == 0) ? HDR_DEFAULT_MAXCLL : vpHalSurf->pHDRParams->MaxCLL; |
| 3198 |
vpHalSurf->pHDRParams->MaxFALL = (vpHalSurf->pHDRParams->MaxFALL == 0) ? HDR_DEFAULT_MAXFALL : vpHalSurf->pHDRParams->MaxFALL; |
| 3199 |
|
| 3200 |
MOS_SecureMemcpy(vpHalSurf->pHDRParams->display_primaries_x, 3 * sizeof(uint16_t), hdr10MetaData->display_primaries_x, 3 * sizeof(uint16_t)); |
| 3201 |
MOS_SecureMemcpy(vpHalSurf->pHDRParams->display_primaries_y, 3 * sizeof(uint16_t), hdr10MetaData->display_primaries_y, 3 * sizeof(uint16_t)); |
| 3202 |
|
| 3203 |
switch (vpHalSurf->GammaType) |
| 3204 |
{ |
| 3205 |
case VPHAL_GAMMA_SMPTE_ST2084: |
| 3206 |
vpHalSurf->pHDRParams->EOTF = VPHAL_HDR_EOTF_SMPTE_ST2084; |
| 3207 |
break; |
| 3208 |
case VPHAL_GAMMA_BT1886: |
| 3209 |
vpHalSurf->pHDRParams->EOTF = VPHAL_HDR_EOTF_BT1886; |
| 3210 |
break; |
| 3211 |
default: |
| 3212 |
vpHalSurf->pHDRParams->EOTF = VPHAL_HDR_EOTF_TRADITIONAL_GAMMA_SDR; |
| 3213 |
break; |
| 3214 |
} |
| 3215 |
DDI_VP_NORMALMESSAGE("max_display_mastering_luminance %d.", vpHalSurf->pHDRParams->max_display_mastering_luminance); |
| 3216 |
DDI_VP_NORMALMESSAGE("min_display_mastering_luminance %d.", vpHalSurf->pHDRParams->min_display_mastering_luminance); |
| 3217 |
DDI_VP_NORMALMESSAGE("GammaType %d.", vpHalSurf->GammaType); |
| 3218 |
} |
| 3219 |
} |
| 3220 |
} |
| 3221 |
|
| 3222 |
return VA_STATUS_SUCCESS; |
| 3223 |
} |
| 3224 |
|
| 3225 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 3226 |
VAStatus DdiVpFunctions::DdiSetProcFilter3DLutParams( |
| 3227 |
VADriverContextP vaDrvCtx, |
| 3228 |
PDDI_VP_CONTEXT vpCtx, |
| 3229 |
uint32_t surfIndex, |
| 3230 |
VAProcFilterParameterBuffer3DLUT *lut3DParamBuff) |
| 3231 |
{ |
| 3232 |
VAStatus eStatus = VA_STATUS_SUCCESS; |
| 3233 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3234 |
PVPHAL_SURFACE src = nullptr; |
| 3235 |
PDDI_MEDIA_SURFACE media3DLutSurf = nullptr; |
| 3236 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 3237 |
PMOS_RESOURCE osResource = nullptr; |
| 3238 |
|
| 3239 |
DDI_VP_FUNC_ENTER; |
| 3240 |
DDI_VP_CHK_NULL(lut3DParamBuff, "nullptr lut3DParamBuff.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3241 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3242 |
|
| 3243 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 3244 |
|
| 3245 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3246 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3247 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 3248 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3249 |
|
| 3250 |
media3DLutSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, lut3DParamBuff->lut_surface); |
| 3251 |
DDI_VP_CHK_NULL(media3DLutSurf, "nullptr media3DLutSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3252 |
|
| 3253 |
// only primary surface takes effect if 3DLUT filter |
| 3254 |
if (SURF_IN_PRIMARY == src->SurfType) |
| 3255 |
{ |
| 3256 |
if (nullptr == src->p3DLutParams) |
| 3257 |
{ |
| 3258 |
src->p3DLutParams = MOS_New(VPHAL_3DLUT_PARAMS); |
| 3259 |
DDI_VP_CHK_NULL(src->p3DLutParams, "MOS_New p3DLutParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3260 |
} |
| 3261 |
|
| 3262 |
src->p3DLutParams->LutSize = (uint32_t)lut3DParamBuff->lut_size; |
| 3263 |
src->p3DLutParams->BitDepthPerChannel = (uint16_t)lut3DParamBuff->bit_depth; |
| 3264 |
src->p3DLutParams->ByteCountPerEntry = (uint16_t)(lut3DParamBuff->num_channel * (src->p3DLutParams->BitDepthPerChannel / 8)); |
| 3265 |
if (nullptr == src->p3DLutParams->pExt3DLutSurface) |
| 3266 |
{ |
| 3267 |
src->p3DLutParams->pExt3DLutSurface = MOS_New(VPHAL_SURFACE); |
| 3268 |
DDI_VP_CHK_NULL(src->p3DLutParams->pExt3DLutSurface, "MOS_New p3DLutParams failed.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3269 |
} |
| 3270 |
|
| 3271 |
if (src->p3DLutParams->pExt3DLutSurface) |
| 3272 |
{ |
| 3273 |
osResource = &(src->p3DLutParams->pExt3DLutSurface->OsResource); |
| 3274 |
DDI_VP_CHK_NULL(osResource, "nullptr osResource.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3275 |
|
| 3276 |
MediaLibvaCommonNext::MediaSurfaceToMosResource(media3DLutSurf, osResource); |
| 3277 |
Mos_Solo_SetOsResource(media3DLutSurf->pGmmResourceInfo, osResource); |
| 3278 |
} |
| 3279 |
} |
| 3280 |
|
| 3281 |
return eStatus; |
| 3282 |
} |
| 3283 |
#endif |
| 3284 |
|
| 3285 |
|
| 3286 |
VAStatus DdiVpFunctions::DdiClearFilterParamBuffer( |
| 3287 |
PDDI_VP_CONTEXT vpCtx, |
| 3288 |
uint32_t surfIndex, |
| 3289 |
DDI_VP_STATE vpStateFlags) |
| 3290 |
{ |
| 3291 |
DDI_VP_FUNC_ENTER; |
| 3292 |
if (!vpStateFlags.bProcampEnable) |
| 3293 |
{ |
| 3294 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pProcampParams); |
| 3295 |
} |
| 3296 |
if (!vpStateFlags.bDeinterlaceEnable) |
| 3297 |
{ |
| 3298 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pDeinterlaceParams); |
| 3299 |
} |
| 3300 |
if (!vpStateFlags.bDenoiseEnable) |
| 3301 |
{ |
| 3302 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pDenoiseParams); |
| 3303 |
} |
| 3304 |
if (!vpStateFlags.bIEFEnable) |
| 3305 |
{ |
| 3306 |
if (vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams) |
| 3307 |
{ |
| 3308 |
if (!vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams->pExtParam) |
| 3309 |
{ |
| 3310 |
DDI_VP_ASSERTMESSAGE("vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams->pExtParam is nullptr."); |
| 3311 |
} |
| 3312 |
MOS_Delete(vpCtx->pVpHalRenderParams->pSrc[surfIndex]->pIEFParams); |
| 3313 |
} |
| 3314 |
} |
| 3315 |
return VA_STATUS_SUCCESS; |
| 3316 |
} |
| 3317 |
|
| 3318 |
VAStatus DdiVpFunctions::VpSetInterpolationParams( |
| 3319 |
PVPHAL_SURFACE surface, |
| 3320 |
uint32_t interpolationflags) |
| 3321 |
{ |
| 3322 |
DDI_VP_CHK_NULL(surface, "nullptr surface.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3323 |
switch (interpolationflags) |
| 3324 |
{ |
| 3325 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 3326 |
case VA_FILTER_INTERPOLATION_NEAREST_NEIGHBOR: |
| 3327 |
surface->ScalingMode = VPHAL_SCALING_NEAREST; |
| 3328 |
break; |
| 3329 |
case VA_FILTER_INTERPOLATION_BILINEAR: |
| 3330 |
surface->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 3331 |
break; |
| 3332 |
case VA_FILTER_INTERPOLATION_ADVANCED: |
| 3333 |
case VA_FILTER_INTERPOLATION_DEFAULT: |
| 3334 |
#endif |
| 3335 |
default: |
| 3336 |
surface->ScalingMode = VPHAL_SCALING_AVS; |
| 3337 |
break; |
| 3338 |
} |
| 3339 |
|
| 3340 |
return VA_STATUS_SUCCESS; |
| 3341 |
} |
| 3342 |
|
| 3343 |
void DdiVpFunctions::VpUpdateWeaveDI(PVPHAL_SURFACE vpHalSrcSurf, uint32_t filterFlags) |
| 3344 |
{ |
| 3345 |
DDI_VP_FUNC_ENTER; |
| 3346 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", ); |
| 3347 |
if (vpHalSrcSurf->pDeinterlaceParams == nullptr) |
| 3348 |
{ |
| 3349 |
if ((filterFlags & 0x00000004) || ((filterFlags & VA_TOP_FIELD) && vpHalSrcSurf->bFieldWeaving)) |
| 3350 |
{ |
| 3351 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3352 |
if (vpHalSrcSurf->pBwdRef != nullptr) |
| 3353 |
{ |
| 3354 |
vpHalSrcSurf->pBwdRef->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3355 |
} |
| 3356 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 3357 |
vpHalSrcSurf->bFieldWeaving = true; |
| 3358 |
} |
| 3359 |
|
| 3360 |
if ((filterFlags & 0x00000008) || ((filterFlags & VA_BOTTOM_FIELD) && vpHalSrcSurf->bFieldWeaving)) |
| 3361 |
{ |
| 3362 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3363 |
if (vpHalSrcSurf->pBwdRef != nullptr) |
| 3364 |
{ |
| 3365 |
vpHalSrcSurf->pBwdRef->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3366 |
} |
| 3367 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 3368 |
vpHalSrcSurf->bFieldWeaving = true; |
| 3369 |
} |
| 3370 |
} |
| 3371 |
return; |
| 3372 |
} |
| 3373 |
|
| 3374 |
VAStatus DdiVpFunctions::SetSurfaceParamsTopFieldFirst(uint32_t surfaceFlag, PVPHAL_SURFACE vpHalSrcSurf, PVPHAL_SURFACE vpHalTgtSurf) |
| 3375 |
{ |
| 3376 |
DDI_VP_FUNC_ENTER; |
| 3377 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3378 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3379 |
if (surfaceFlag & VA_TOP_FIELD_FIRST) |
| 3380 |
{ |
| 3381 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_INTERLEAVED; |
| 3382 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 3383 |
vpHalSrcSurf->bInterlacedScaling = true; |
| 3384 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3385 |
} |
| 3386 |
else if (surfaceFlag & VA_TOP_FIELD) |
| 3387 |
{ |
| 3388 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_FIELD; |
| 3389 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 3390 |
vpHalTgtSurf->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3391 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3392 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3393 |
} |
| 3394 |
else if (surfaceFlag & VA_BOTTOM_FIELD) |
| 3395 |
{ |
| 3396 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_FIELD; |
| 3397 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD; |
| 3398 |
vpHalTgtSurf->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3399 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3400 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3401 |
} |
| 3402 |
else |
| 3403 |
{ |
| 3404 |
DDI_VP_ASSERTMESSAGE("output_surface_flag need to be set for interlaced scaling."); |
| 3405 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 3406 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_NONE; |
| 3407 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3408 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3409 |
} |
| 3410 |
return VA_STATUS_SUCCESS; |
| 3411 |
} |
| 3412 |
|
| 3413 |
VAStatus DdiVpFunctions::SetSurfaceParamsBottomFieldFirst(uint32_t surfaceFlag, PVPHAL_SURFACE vpHalSrcSurf, PVPHAL_SURFACE vpHalTgtSurf) |
| 3414 |
{ |
| 3415 |
DDI_VP_FUNC_ENTER; |
| 3416 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3417 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3418 |
if (surfaceFlag & VA_BOTTOM_FIELD_FIRST) |
| 3419 |
{ |
| 3420 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_INTERLEAVED; |
| 3421 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 3422 |
vpHalSrcSurf->bInterlacedScaling = true; |
| 3423 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3424 |
} |
| 3425 |
else if (surfaceFlag & VA_TOP_FIELD) |
| 3426 |
{ |
| 3427 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_FIELD; |
| 3428 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD; |
| 3429 |
vpHalTgtSurf->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3430 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3431 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3432 |
} |
| 3433 |
else if (surfaceFlag & VA_BOTTOM_FIELD) |
| 3434 |
{ |
| 3435 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_FIELD; |
| 3436 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 3437 |
vpHalTgtSurf->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3438 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3439 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3440 |
} |
| 3441 |
else |
| 3442 |
{ |
| 3443 |
DDI_VP_ASSERTMESSAGE("output_surface_flag need to be set for interlaced scaling."); |
| 3444 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 3445 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_NONE; |
| 3446 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3447 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3448 |
} |
| 3449 |
return VA_STATUS_SUCCESS; |
| 3450 |
} |
| 3451 |
|
| 3452 |
VAStatus DdiVpFunctions::SetSurfaceParamsTopField(uint32_t surfaceFlag, PVPHAL_SURFACE vpHalSrcSurf, PVPHAL_SURFACE vpHalTgtSurf) |
| 3453 |
{ |
| 3454 |
DDI_VP_FUNC_ENTER; |
| 3455 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3456 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3457 |
if (surfaceFlag & VA_TOP_FIELD_FIRST) |
| 3458 |
{ |
| 3459 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_FIELD_TO_INTERLEAVED; |
| 3460 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3461 |
vpHalTgtSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 3462 |
|
| 3463 |
DDI_VP_CHK_NULL(vpHalSrcSurf->pBwdRef, "No Ref Field!", VA_STATUS_ERROR_UNIMPLEMENTED); |
| 3464 |
vpHalSrcSurf->pBwdRef->InterlacedScalingType = ISCALING_FIELD_TO_INTERLEAVED; |
| 3465 |
vpHalSrcSurf->pBwdRef->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3466 |
|
| 3467 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3468 |
vpHalSrcSurf->bFieldWeaving = true; |
| 3469 |
} |
| 3470 |
else if (surfaceFlag & VA_TOP_FIELD) |
| 3471 |
{ |
| 3472 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_FIELD_TO_FIELD; |
| 3473 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3474 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3475 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3476 |
} |
| 3477 |
else |
| 3478 |
{ |
| 3479 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 3480 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3481 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3482 |
} |
| 3483 |
return VA_STATUS_SUCCESS; |
| 3484 |
} |
| 3485 |
|
| 3486 |
VAStatus DdiVpFunctions::SetSurfaceParamsBottomField(uint32_t surfaceFlag, PVPHAL_SURFACE vpHalSrcSurf, PVPHAL_SURFACE vpHalTgtSurf) |
| 3487 |
{ |
| 3488 |
DDI_VP_FUNC_ENTER; |
| 3489 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3490 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3491 |
if (surfaceFlag & VA_BOTTOM_FIELD_FIRST) |
| 3492 |
{ |
| 3493 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_FIELD_TO_INTERLEAVED; |
| 3494 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3495 |
vpHalTgtSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 3496 |
|
| 3497 |
DDI_VP_CHK_NULL(vpHalSrcSurf->pBwdRef, "No Ref Field!", VA_STATUS_ERROR_UNIMPLEMENTED); |
| 3498 |
vpHalSrcSurf->pBwdRef->InterlacedScalingType = ISCALING_FIELD_TO_INTERLEAVED; |
| 3499 |
vpHalSrcSurf->pBwdRef->SampleType = SAMPLE_SINGLE_TOP_FIELD; |
| 3500 |
|
| 3501 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3502 |
vpHalSrcSurf->bFieldWeaving = true; |
| 3503 |
} |
| 3504 |
else if (surfaceFlag & VA_BOTTOM_FIELD) |
| 3505 |
{ |
| 3506 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_FIELD_TO_FIELD; |
| 3507 |
vpHalSrcSurf->SampleType = SAMPLE_SINGLE_BOTTOM_FIELD; |
| 3508 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3509 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3510 |
} |
| 3511 |
else |
| 3512 |
{ |
| 3513 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 3514 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 3515 |
vpHalSrcSurf->bFieldWeaving = false; |
| 3516 |
} |
| 3517 |
return VA_STATUS_SUCCESS; |
| 3518 |
} |
| 3519 |
|
| 3520 |
void DdiVpFunctions::SetLegacyInterlaceScalingParams(PVPHAL_SURFACE vpHalSrcSurf, uint32_t filterFlags) |
| 3521 |
{ |
| 3522 |
DDI_VP_FUNC_ENTER; |
| 3523 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf", ); |
| 3524 |
|
| 3525 |
if (vpHalSrcSurf->pDeinterlaceParams == nullptr && vpHalSrcSurf->InterlacedScalingType == ISCALING_NONE) |
| 3526 |
{ |
| 3527 |
if (filterFlags & VA_TOP_FIELD) |
| 3528 |
{ |
| 3529 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 3530 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_AVS; |
| 3531 |
vpHalSrcSurf->bInterlacedScaling = true; |
| 3532 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_INTERLEAVED; |
| 3533 |
} |
| 3534 |
else if (filterFlags & VA_BOTTOM_FIELD) |
| 3535 |
{ |
| 3536 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD; |
| 3537 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_AVS; |
| 3538 |
vpHalSrcSurf->bInterlacedScaling = true; |
| 3539 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_INTERLEAVED_TO_INTERLEAVED; |
| 3540 |
} |
| 3541 |
|
| 3542 |
// Kernel does not support 3-plane interlaced AVS, so for 3-plane interlaced scaling, need to use bilinear. |
| 3543 |
if (vpHalSrcSurf->bInterlacedScaling && IS_PL3_FORMAT(vpHalSrcSurf->Format)) |
| 3544 |
{ |
| 3545 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 3546 |
} |
| 3547 |
} |
| 3548 |
return; |
| 3549 |
} |
| 3550 |
|
| 3551 |
VAStatus DdiVpFunctions::VpUpdateProcRotateState(PVPHAL_SURFACE vpHalSrcSurf, uint32_t rotationState) |
| 3552 |
{ |
| 3553 |
DDI_VP_FUNC_ENTER; |
| 3554 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3555 |
|
| 3556 |
switch (rotationState) |
| 3557 |
{ |
| 3558 |
case VA_ROTATION_NONE: |
| 3559 |
vpHalSrcSurf->Rotation = VPHAL_ROTATION_IDENTITY; |
| 3560 |
break; |
| 3561 |
case VA_ROTATION_90: |
| 3562 |
vpHalSrcSurf->Rotation = VPHAL_ROTATION_90; |
| 3563 |
break; |
| 3564 |
case VA_ROTATION_180: |
| 3565 |
vpHalSrcSurf->Rotation = VPHAL_ROTATION_180; |
| 3566 |
break; |
| 3567 |
case VA_ROTATION_270: |
| 3568 |
vpHalSrcSurf->Rotation = VPHAL_ROTATION_270; |
| 3569 |
break; |
| 3570 |
default: |
| 3571 |
DDI_VP_ASSERTMESSAGE("VpUpdateProcRotateState rotationState = %d is out of range.", rotationState); |
| 3572 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3573 |
} |
| 3574 |
|
| 3575 |
return VA_STATUS_SUCCESS; |
| 3576 |
} |
| 3577 |
|
| 3578 |
VAStatus DdiVpFunctions::VpUpdateProcMirrorState(PVPHAL_SURFACE vpHalSrcSurf, uint32_t mirrorState) |
| 3579 |
{ |
| 3580 |
DDI_VP_FUNC_ENTER; |
| 3581 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3582 |
|
| 3583 |
if(mirrorState > VA_MIRROR_VERTICAL) |
| 3584 |
{ |
| 3585 |
DDI_VP_ASSERTMESSAGE("VpUpdateProcMirrorState mirrorState = %d is out of range.", mirrorState); |
| 3586 |
DDI_VP_ASSERTMESSAGE("VpUpdateProcMirrorState reset mirrorState to VA_MIRROR_NONE."); |
| 3587 |
mirrorState = VA_MIRROR_NONE; |
| 3588 |
} |
| 3589 |
|
| 3590 |
// Rotation must be a valid angle |
| 3591 |
switch(vpHalSrcSurf->Rotation) |
| 3592 |
{ |
| 3593 |
case VPHAL_ROTATION_IDENTITY: |
| 3594 |
if(mirrorState == VA_MIRROR_HORIZONTAL) |
| 3595 |
{ |
| 3596 |
vpHalSrcSurf->Rotation = VPHAL_MIRROR_HORIZONTAL; |
| 3597 |
} |
| 3598 |
else if(mirrorState == VA_MIRROR_VERTICAL) |
| 3599 |
{ |
| 3600 |
vpHalSrcSurf->Rotation = VPHAL_MIRROR_VERTICAL; |
| 3601 |
} |
| 3602 |
break; |
| 3603 |
case VPHAL_ROTATION_90: |
| 3604 |
if(mirrorState == VA_MIRROR_HORIZONTAL) |
| 3605 |
{ |
| 3606 |
vpHalSrcSurf->Rotation = VPHAL_ROTATE_90_MIRROR_HORIZONTAL; |
| 3607 |
} |
| 3608 |
else if(mirrorState == VA_MIRROR_VERTICAL) |
| 3609 |
{ |
| 3610 |
vpHalSrcSurf->Rotation = VPHAL_ROTATE_90_MIRROR_VERTICAL; |
| 3611 |
} |
| 3612 |
break; |
| 3613 |
case VPHAL_ROTATION_180: |
| 3614 |
if(mirrorState == VA_MIRROR_HORIZONTAL) |
| 3615 |
{ |
| 3616 |
vpHalSrcSurf->Rotation = VPHAL_MIRROR_VERTICAL; |
| 3617 |
} |
| 3618 |
else if(mirrorState == VA_MIRROR_VERTICAL) |
| 3619 |
{ |
| 3620 |
vpHalSrcSurf->Rotation = VPHAL_MIRROR_HORIZONTAL; |
| 3621 |
} |
| 3622 |
break; |
| 3623 |
case VPHAL_ROTATION_270: |
| 3624 |
if(mirrorState == VA_MIRROR_HORIZONTAL) |
| 3625 |
{ |
| 3626 |
vpHalSrcSurf->Rotation = VPHAL_ROTATE_90_MIRROR_VERTICAL; |
| 3627 |
} |
| 3628 |
else if(mirrorState == VA_MIRROR_VERTICAL) |
| 3629 |
{ |
| 3630 |
vpHalSrcSurf->Rotation = VPHAL_ROTATE_90_MIRROR_HORIZONTAL; |
| 3631 |
} |
| 3632 |
break; |
| 3633 |
default: |
| 3634 |
DDI_VP_ASSERTMESSAGE("VpUpdateProcMirrorState Unexpected Invalid Rotation = %d.", vpHalSrcSurf->Rotation); |
| 3635 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3636 |
|
| 3637 |
} |
| 3638 |
|
| 3639 |
return VA_STATUS_SUCCESS; |
| 3640 |
} |
| 3641 |
|
| 3642 |
VAStatus DdiVpFunctions::DdiSetProcPipelineBlendingParams( |
| 3643 |
PDDI_VP_CONTEXT vpCtx, |
| 3644 |
uint32_t surfIndex, |
| 3645 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 3646 |
{ |
| 3647 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3648 |
PVPHAL_SURFACE src = nullptr; |
| 3649 |
PVPHAL_SURFACE target = nullptr; |
| 3650 |
bool globalAlpha = false; |
| 3651 |
bool preMultAlpha = false; |
| 3652 |
const VABlendState *blendState = nullptr; |
| 3653 |
|
| 3654 |
DDI_VP_FUNC_ENTER; |
| 3655 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3656 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 3657 |
|
| 3658 |
blendState = pipelineParam->blend_state; |
| 3659 |
// initialize |
| 3660 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3661 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3662 |
|
| 3663 |
src = vpHalRenderParams->pSrc[surfIndex]; |
| 3664 |
DDI_VP_CHK_NULL(src, "nullptr src.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3665 |
|
| 3666 |
if (nullptr == vpHalRenderParams->pCompAlpha) |
| 3667 |
{ |
| 3668 |
vpHalRenderParams->pCompAlpha = MOS_New(VPHAL_ALPHA_PARAMS); |
| 3669 |
DDI_VP_CHK_NULL(vpHalRenderParams->pCompAlpha, "nullptr pCompAlpha.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3670 |
} |
| 3671 |
|
| 3672 |
// So far vaapi does not have alpha fill mode API. |
| 3673 |
// And for blending support, we use VPHAL_ALPHA_FILL_MODE_NONE by default. |
| 3674 |
target = vpHalRenderParams->pTarget[0]; |
| 3675 |
DDI_VP_CHK_NULL(target, "nullptr target.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3676 |
|
| 3677 |
//For surface with alpha, we need to bypass SFC that could change the output alpha. |
| 3678 |
if (hasAlphaInSurface(src) && hasAlphaInSurface(target)) |
| 3679 |
{ |
| 3680 |
vpHalRenderParams->pCompAlpha->fAlpha = 0.0f; |
| 3681 |
vpHalRenderParams->pCompAlpha->AlphaMode = VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM; |
| 3682 |
} |
| 3683 |
else |
| 3684 |
{ |
| 3685 |
vpHalRenderParams->pCompAlpha->fAlpha = 1.0f; |
| 3686 |
vpHalRenderParams->pCompAlpha->AlphaMode = VPHAL_ALPHA_FILL_MODE_NONE; |
| 3687 |
} |
| 3688 |
|
| 3689 |
// First, no Blending |
| 3690 |
if (!blendState) |
| 3691 |
{ |
| 3692 |
if (src->pBlendingParams) |
| 3693 |
{ |
| 3694 |
src->pBlendingParams->BlendType = BLEND_NONE; |
| 3695 |
src->pBlendingParams->fAlpha = 1.0; |
| 3696 |
} |
| 3697 |
|
| 3698 |
if (src->pLumaKeyParams) |
| 3699 |
{ |
| 3700 |
src->pLumaKeyParams->LumaLow = 0; |
| 3701 |
src->pLumaKeyParams->LumaHigh = 0; |
| 3702 |
} |
| 3703 |
|
| 3704 |
return VA_STATUS_SUCCESS; |
| 3705 |
} |
| 3706 |
|
| 3707 |
// Then, process all blending types |
| 3708 |
|
| 3709 |
if (blendState->flags & VA_BLEND_GLOBAL_ALPHA) |
| 3710 |
{ |
| 3711 |
globalAlpha = true; |
| 3712 |
} |
| 3713 |
|
| 3714 |
if (blendState->flags & VA_BLEND_PREMULTIPLIED_ALPHA) |
| 3715 |
{ |
| 3716 |
preMultAlpha = true; |
| 3717 |
} |
| 3718 |
|
| 3719 |
if (nullptr == src->pBlendingParams) |
| 3720 |
{ |
| 3721 |
src->pBlendingParams = MOS_New(VPHAL_BLENDING_PARAMS); |
| 3722 |
DDI_VP_CHK_NULL(src->pBlendingParams, "nullptr pBlendingParams.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3723 |
} |
| 3724 |
|
| 3725 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3726 |
// Surfaces contains alpha value, will be devide into premultiplied and non-premultiplied: |
| 3727 |
// For premultiplied surface, will support: |
| 3728 |
// a. per-pixel alpha blending; |
| 3729 |
// b. per-pixel plus per-plane alpha blending; |
| 3730 |
// For non-promultilied surface, will support: |
| 3731 |
// a. per-plane alpha blending; |
| 3732 |
// b. per-pixel alpha blending; |
| 3733 |
// c. NOT support per-pixel plus per-plane alpha blending; |
| 3734 |
// Surfaces NOT contains alpha value, will not be devided into premultiplied or non-premultiplied: |
| 3735 |
// Will only support per-plane alpha blending. |
| 3736 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3737 |
if (hasAlphaInSurface(src)) |
| 3738 |
{ |
| 3739 |
// For premultiplied surface, we just support four blending types until now |
| 3740 |
SetBlendingTypes(preMultAlpha, globalAlpha, src->pBlendingParams, blendState->global_alpha); |
| 3741 |
} |
| 3742 |
else |
| 3743 |
{ |
| 3744 |
if (globalAlpha) // Do per-plane alpha blending for surface which not contain alpha value |
| 3745 |
{ |
| 3746 |
if (blendState->global_alpha < 1.0f) |
| 3747 |
{ |
| 3748 |
src->pBlendingParams->BlendType = BLEND_CONSTANT; |
| 3749 |
src->pBlendingParams->fAlpha = blendState->global_alpha; |
| 3750 |
DDI_VP_ASSERTMESSAGE("BLEND_CONSTANT do not support alpha calculating.\n"); |
| 3751 |
} |
| 3752 |
else |
| 3753 |
{ |
| 3754 |
src->pBlendingParams->BlendType = BLEND_PARTIAL; |
| 3755 |
DDI_VP_NORMALMESSAGE("Because BLEND_CONSTANT do not support alpha calculating, use BLEND_PARTIAL instead.\n"); |
| 3756 |
} |
| 3757 |
|
| 3758 |
// preMultAlpha should not be true for surfaces which do not contain alpha value, |
| 3759 |
// but inorder to make the driver more usable, choose the most reasonable blending mode, but print out a message. |
| 3760 |
if (preMultAlpha) |
| 3761 |
{ |
| 3762 |
DDI_VP_NORMALMESSAGE("Should not set VA_BLEND_PREMULTIPLIED_ALPHA for surface which do not contain alpha value.\n"); |
| 3763 |
} |
| 3764 |
} |
| 3765 |
else |
| 3766 |
{ |
| 3767 |
src->pBlendingParams->BlendType = BLEND_NONE; |
| 3768 |
src->pBlendingParams->fAlpha = 1.0; |
| 3769 |
|
| 3770 |
// preMultAlpha should not be true for surfaces which do not contain alpha value, |
| 3771 |
// but inorder to make the driver more usable, choose the most reasonable blending mode, but print out a message. |
| 3772 |
if (preMultAlpha) |
| 3773 |
{ |
| 3774 |
DDI_VP_NORMALMESSAGE("Should not set VA_BLEND_PREMULTIPLIED_ALPHA for surface which do not contain alpha value.\n"); |
| 3775 |
} |
| 3776 |
} |
| 3777 |
} |
| 3778 |
|
| 3779 |
if (blendState->flags & VA_BLEND_LUMA_KEY) |
| 3780 |
{ |
| 3781 |
if (nullptr == src->pLumaKeyParams) |
| 3782 |
{ |
| 3783 |
src->pLumaKeyParams = MOS_New(VPHAL_LUMAKEY_PARAMS); |
| 3784 |
DDI_VP_CHK_NULL(src->pLumaKeyParams, "nullptr pLumaKeyParams.", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 3785 |
} |
| 3786 |
src->pLumaKeyParams->LumaLow = (int16_t)(pipelineParam->blend_state->min_luma * 255); |
| 3787 |
src->pLumaKeyParams->LumaHigh = (int16_t)(pipelineParam->blend_state->max_luma * 255); |
| 3788 |
} |
| 3789 |
|
| 3790 |
return VA_STATUS_SUCCESS; |
| 3791 |
} |
| 3792 |
|
| 3793 |
void DdiVpFunctions::SetBlendingTypes( |
| 3794 |
bool preMultAlpha, |
| 3795 |
bool globalAlpha, |
| 3796 |
PVPHAL_BLENDING_PARAMS blendingParams, |
| 3797 |
float globalalpha) |
| 3798 |
{ |
| 3799 |
DDI_VP_FUNC_ENTER; |
| 3800 |
DDI_VP_CHK_NULL(blendingParams, "nullptr blendingParams.", ); |
| 3801 |
if (preMultAlpha && !globalAlpha) // Do per-pixel alpha blending for premultiplied surface. |
| 3802 |
{ |
| 3803 |
blendingParams->BlendType = BLEND_PARTIAL; |
| 3804 |
} |
| 3805 |
else if (preMultAlpha && globalAlpha) // Do per-pixel plus per-plane alpha blending For premultiplied surface. |
| 3806 |
{ |
| 3807 |
if (globalalpha < 1.0f) |
| 3808 |
{ |
| 3809 |
blendingParams->BlendType = BLEND_CONSTANT_PARTIAL; |
| 3810 |
} |
| 3811 |
else |
| 3812 |
{ |
| 3813 |
// Optimization when per-plane alpha value is 1.0 |
| 3814 |
blendingParams->BlendType = BLEND_PARTIAL; |
| 3815 |
} |
| 3816 |
blendingParams->fAlpha = globalalpha; |
| 3817 |
} |
| 3818 |
else if (!preMultAlpha && globalAlpha) // Do per-plane alpha blending for non-premultiplied surface, not do per-pixel blending |
| 3819 |
{ |
| 3820 |
blendingParams->BlendType = BLEND_CONSTANT; |
| 3821 |
blendingParams->fAlpha = globalalpha; |
| 3822 |
DDI_VP_ASSERTMESSAGE("BLEND_CONSTANT do not support alpha calculating.\n"); |
| 3823 |
} |
| 3824 |
else if (!preMultAlpha && !globalAlpha) // Do per-pixel alpha blending for non-premultiplied surface |
| 3825 |
{ |
| 3826 |
blendingParams->BlendType = BLEND_SOURCE; |
| 3827 |
DDI_VP_ASSERTMESSAGE("BLEND_SOURCE do not support alpha calculating.\n"); |
| 3828 |
} |
| 3829 |
// Not support per-plane plus per-pixel alpha blending for non-premultiplied surface. |
| 3830 |
return; |
| 3831 |
} |
| 3832 |
|
| 3833 |
bool DdiVpFunctions::hasAlphaInSurface(PVPHAL_SURFACE surface) |
| 3834 |
{ |
| 3835 |
DDI_VP_FUNC_ENTER; |
| 3836 |
DDI_VP_CHK_NULL(surface, "nullptr surface.No surface handle passed in.\n", false); |
| 3837 |
|
| 3838 |
switch (surface->Format) |
| 3839 |
{ |
| 3840 |
case Format_P8: //P8_UNORM: An 8-bit color index which is used to lookup a 32-bit ARGB value in the texture palette. |
| 3841 |
case Format_AI44: |
| 3842 |
case Format_IA44: |
| 3843 |
case Format_A8R8G8B8: |
| 3844 |
case Format_A8B8G8R8: |
| 3845 |
case Format_A8P8: |
| 3846 |
case Format_AYUV: |
| 3847 |
case Format_Y410: |
| 3848 |
case Format_Y416: |
| 3849 |
case Format_R10G10B10A2: |
| 3850 |
case Format_B10G10R10A2: |
| 3851 |
return true; |
| 3852 |
default: |
| 3853 |
return false; |
| 3854 |
} |
| 3855 |
|
| 3856 |
DDI_VP_ASSERTMESSAGE("No surface handle passed in.\n"); |
| 3857 |
return false; |
| 3858 |
} |
| 3859 |
|
| 3860 |
VAStatus DdiVpFunctions::DdiUpdateVphalTargetSurfColorSpace( |
| 3861 |
VADriverContextP vaDrvCtx, |
| 3862 |
PDDI_VP_CONTEXT vpCtx, |
| 3863 |
VAProcPipelineParameterBuffer *pipelineParam, |
| 3864 |
uint32_t targetIndex) |
| 3865 |
{ |
| 3866 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3867 |
PVPHAL_SURFACE vpHalSrcSurf = nullptr; |
| 3868 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 3869 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 3870 |
DDI_UNUSED(vaDrvCtx); |
| 3871 |
|
| 3872 |
DDI_VP_FUNC_ENTER; |
| 3873 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3874 |
|
| 3875 |
// initialize |
| 3876 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3877 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3878 |
vpHalTgtSurf = vpHalRenderParams->pTarget[targetIndex]; |
| 3879 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3880 |
|
| 3881 |
// update target surface color space |
| 3882 |
#if (VA_MAJOR_VERSION < 1) |
| 3883 |
vaStatus = DdiGetColorSpace(vpHalTgtSurf, pipelineParam->output_color_standard, pipelineParam->output_surface_flag); |
| 3884 |
#else |
| 3885 |
vaStatus = DdiGetColorSpace(vpHalTgtSurf, pipelineParam->output_color_standard, pipelineParam->output_color_properties); |
| 3886 |
#endif |
| 3887 |
|
| 3888 |
vpHalSrcSurf = vpHalRenderParams->pSrc[0]; |
| 3889 |
// Not support BT601/BT709 -> BT2020 colorspace conversion, if colorspace is not set, will keep it same with input. |
| 3890 |
if (vpHalSrcSurf != nullptr && |
| 3891 |
pipelineParam->output_color_standard == 0 && |
| 3892 |
IS_COLOR_SPACE_BT2020(vpHalTgtSurf->ColorSpace) && |
| 3893 |
!IS_COLOR_SPACE_BT2020(vpHalSrcSurf->ColorSpace)) |
| 3894 |
{ |
| 3895 |
vpHalTgtSurf->ColorSpace = vpHalSrcSurf->ColorSpace; |
| 3896 |
} |
| 3897 |
|
| 3898 |
// extended gamut? |
| 3899 |
vpHalRenderParams->pTarget[0]->ExtendedGamut = false; |
| 3900 |
|
| 3901 |
return vaStatus; |
| 3902 |
} |
| 3903 |
|
| 3904 |
VAStatus DdiVpFunctions::DdiBeginPictureInt( |
| 3905 |
VADriverContextP vaDrvCtx, |
| 3906 |
PDDI_VP_CONTEXT vpCtx, |
| 3907 |
VASurfaceID vaSurfID) |
| 3908 |
{ |
| 3909 |
PDDI_MEDIA_CONTEXT mediaDrvCtx = nullptr; |
| 3910 |
uint32_t ctxType = 0; |
| 3911 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 3912 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3913 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 3914 |
PDDI_MEDIA_SURFACE mediaTgtSurf = nullptr; |
| 3915 |
|
| 3916 |
DDI_VP_FUNC_ENTER; |
| 3917 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3918 |
|
| 3919 |
// initialize |
| 3920 |
mediaDrvCtx = GetMediaContext(vaDrvCtx); |
| 3921 |
DDI_VP_CHK_NULL(mediaDrvCtx, "nullptr mediaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3922 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3923 |
vpCtx->TargetSurfID = vaSurfID; |
| 3924 |
|
| 3925 |
vpHalRenderParams = VpGetRenderParams(vpCtx); |
| 3926 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3927 |
|
| 3928 |
// uDstCount == 0 means no render target is set yet. |
| 3929 |
// uDstCount == 1 means 1 render target has been set already. |
| 3930 |
// uDstCount == 2 means 2 render targets have been set already. |
| 3931 |
DDI_VP_CHK_LESS(vpHalRenderParams->uDstCount, VPHAL_MAX_TARGETS, "Too many render targets for VP.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3932 |
|
| 3933 |
vpHalTgtSurf = vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]; |
| 3934 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3935 |
mediaTgtSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaDrvCtx, vaSurfID); |
| 3936 |
DDI_VP_CHK_NULL(mediaTgtSurf, "nullptr mediaTgtSurf.", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3937 |
|
| 3938 |
mediaTgtSurf->pVpCtx = vpCtx; |
| 3939 |
|
| 3940 |
// Setup Target VpHal Surface |
| 3941 |
vpHalTgtSurf->SurfType = SURF_OUT_RENDERTARGET; |
| 3942 |
vpHalTgtSurf->rcSrc.top = 0; |
| 3943 |
vpHalTgtSurf->rcSrc.left = 0; |
| 3944 |
vpHalTgtSurf->rcSrc.right = mediaTgtSurf->iWidth; |
| 3945 |
vpHalTgtSurf->rcSrc.bottom = mediaTgtSurf->iRealHeight; |
| 3946 |
vpHalTgtSurf->rcDst.top = 0; |
| 3947 |
vpHalTgtSurf->rcDst.left = 0; |
| 3948 |
vpHalTgtSurf->rcDst.right = mediaTgtSurf->iWidth; |
| 3949 |
vpHalTgtSurf->rcDst.bottom = mediaTgtSurf->iRealHeight; |
| 3950 |
vpHalTgtSurf->ExtendedGamut = false; |
| 3951 |
|
| 3952 |
// Set os resource for VPHal render |
| 3953 |
vaStatus = VpSetOsResource(vpCtx, mediaTgtSurf, vpHalRenderParams->uDstCount); |
| 3954 |
DDI_CHK_RET(vaStatus, "Call VpSetOsResource failed"); |
| 3955 |
|
| 3956 |
vpHalTgtSurf->Format = vpHalTgtSurf->OsResource.Format; |
| 3957 |
|
| 3958 |
vpHalRenderParams->bReportStatus = true; |
| 3959 |
vpHalRenderParams->StatusFeedBackID = vaSurfID; |
| 3960 |
if (mediaTgtSurf->pSurfDesc && (mediaTgtSurf->pSurfDesc->uiVaMemType == VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR)) |
| 3961 |
{ |
| 3962 |
vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]->b16UsrPtr = VpIs16UsrPtrPitch(mediaTgtSurf->iPitch, mediaTgtSurf->format); |
| 3963 |
} |
| 3964 |
else |
| 3965 |
{ |
| 3966 |
vpHalRenderParams->pTarget[vpHalRenderParams->uDstCount]->b16UsrPtr = false; |
| 3967 |
} |
| 3968 |
// increase render target count |
| 3969 |
vpHalRenderParams->uDstCount++; |
| 3970 |
|
| 3971 |
return VA_STATUS_SUCCESS; |
| 3972 |
} |
| 3973 |
|
| 3974 |
VAStatus DdiVpFunctions::DdiSetProcPipelineParams( |
| 3975 |
VADriverContextP vaDrvCtx, |
| 3976 |
PDDI_VP_CONTEXT vpCtx, |
| 3977 |
VAProcPipelineParameterBuffer *pipelineParam) |
| 3978 |
{ |
| 3979 |
PVPHAL_RENDER_PARAMS vpHalRenderParams = nullptr; |
| 3980 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 3981 |
PDDI_MEDIA_SURFACE mediaSrcSurf = nullptr; |
| 3982 |
PDDI_MEDIA_BUFFER filterBuf = nullptr; |
| 3983 |
void * data = nullptr; |
| 3984 |
uint32_t i = 0; |
| 3985 |
PVPHAL_SURFACE vpHalSrcSurf = nullptr; |
| 3986 |
PVPHAL_SURFACE vpHalTgtSurf = nullptr; |
| 3987 |
uint32_t surfIndex = 0; |
| 3988 |
uint32_t scalingflags = 0; |
| 3989 |
uint32_t interpolationflags = 0; |
| 3990 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 3991 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3992 |
DDI_VP_STATE vpStateFlags = {}; |
| 3993 |
PMOS_INTERFACE osInterface = nullptr; |
| 3994 |
VAProcFilterParameterBufferBase *filterParam = nullptr; |
| 3995 |
|
| 3996 |
DDI_VP_FUNC_ENTER; |
| 3997 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 3998 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3999 |
DDI_VP_CHK_NULL(vpCtx->pVpHal, "nullptr vpCtx->pVpHal.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4000 |
DDI_VP_CHK_NULL(pipelineParam, "nullptr pipelineParam.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4001 |
|
| 4002 |
// initialize |
| 4003 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 4004 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4005 |
|
| 4006 |
mediaSrcSurf = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->surface); |
| 4007 |
DDI_VP_CHK_NULL(mediaSrcSurf, "nullptr mediaSrcSurf.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 4008 |
|
| 4009 |
vpHalRenderParams = vpCtx->pVpHalRenderParams; |
| 4010 |
DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4011 |
|
| 4012 |
osInterface = vpCtx->pVpHal->GetOsInterface(); |
| 4013 |
DDI_VP_CHK_NULL(osInterface, "nullptr osInterface.", VA_STATUS_ERROR_INVALID_BUFFER); |
| 4014 |
|
| 4015 |
// increment surface count |
| 4016 |
vpHalRenderParams->uSrcCount++; |
| 4017 |
|
| 4018 |
// check if the surface count exceeded maximum VPHAL surfaces |
| 4019 |
DDI_VP_CHK_CONDITION((vpHalRenderParams->uSrcCount > VPHAL_MAX_SOURCES), |
| 4020 |
"Surface count exceeds maximum!", |
| 4021 |
VA_STATUS_ERROR_MAX_NUM_EXCEEDED); |
| 4022 |
|
| 4023 |
// update surface surfIndex |
| 4024 |
surfIndex = vpHalRenderParams->uSrcCount - 1; |
| 4025 |
|
| 4026 |
vpHalSrcSurf = vpHalRenderParams->pSrc[surfIndex]; |
| 4027 |
DDI_VP_CHK_NULL(vpHalSrcSurf, "nullptr vpHalSrcSurf.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4028 |
|
| 4029 |
vpHalSrcSurf->Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(mediaSrcSurf->format); |
| 4030 |
vpHalSrcSurf->TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(mediaSrcSurf->TileType); |
| 4031 |
|
| 4032 |
DDI_VP_CHK_CONDITION((Format_Invalid == vpHalSrcSurf->Format), "Invalid surface media format!", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4033 |
|
| 4034 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 4035 |
if (vpCtx->pCurVpDumpDDIParam != nullptr && vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex] != nullptr) |
| 4036 |
{ |
| 4037 |
MOS_SecureMemcpy(vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex], sizeof(VAProcPipelineParameterBuffer), pipelineParam, sizeof(VAProcPipelineParameterBuffer)); |
| 4038 |
vpCtx->pCurVpDumpDDIParam->SrcFormat[surfIndex] = vpHalSrcSurf->Format; |
| 4039 |
} |
| 4040 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 4041 |
|
| 4042 |
// Currently we only support 1 primary surface in VP |
| 4043 |
if (vpCtx->iPriSurfs < VP_MAX_PRIMARY_SURFS) |
| 4044 |
{ |
| 4045 |
vpHalSrcSurf->SurfType = SURF_IN_PRIMARY; |
| 4046 |
vpCtx->iPriSurfs++; |
| 4047 |
} |
| 4048 |
else |
| 4049 |
{ |
| 4050 |
vpHalSrcSurf->SurfType = SURF_IN_SUBSTREAM; |
| 4051 |
} |
| 4052 |
|
| 4053 |
// Set workload path using pipeline_flags VA_PROC_PIPELINE_FAST flag |
| 4054 |
if (pipelineParam->pipeline_flags & VA_PROC_PIPELINE_FAST) |
| 4055 |
{ |
| 4056 |
vpHalRenderParams->bForceToRender = true; |
| 4057 |
} |
| 4058 |
|
| 4059 |
// Set src rect |
| 4060 |
SetSrcSurfaceRect(pipelineParam->surface_region, vpHalSrcSurf, mediaSrcSurf); |
| 4061 |
|
| 4062 |
vpHalTgtSurf = vpHalRenderParams->pTarget[0]; |
| 4063 |
DDI_VP_CHK_NULL(vpHalTgtSurf, "nullptr vpHalTgtSurf.", VA_STATUS_ERROR_UNKNOWN); |
| 4064 |
// Set dest rect |
| 4065 |
vaStatus = SetDestSurfaceRect(pipelineParam->output_region, vpHalSrcSurf, vpHalTgtSurf); |
| 4066 |
DDI_CHK_RET(vaStatus, "Failed to Set dest rect!"); |
| 4067 |
|
| 4068 |
//set the frame_id |
| 4069 |
vpHalSrcSurf->FrameID = mediaSrcSurf->frame_idx; |
| 4070 |
|
| 4071 |
//In order to refresh the frame ID in DdiVp_UpdateFilterParamBuffer when run ADI case, |
| 4072 |
//we need to set the OS resource here. |
| 4073 |
vpHalSrcSurf->OsResource.bo = mediaSrcSurf->bo; |
| 4074 |
|
| 4075 |
// csc option |
| 4076 |
//--------------------------------------- |
| 4077 |
// Set color space for src |
| 4078 |
#if (VA_MAJOR_VERSION < 1) |
| 4079 |
vaStatus = DdiGetColorSpace(vpHalSrcSurf, pipelineParam->surface_color_standard, pipelineParam->input_surface_flag); |
| 4080 |
#else |
| 4081 |
vaStatus = DdiGetColorSpace(vpHalSrcSurf, pipelineParam->surface_color_standard, pipelineParam->input_color_properties); |
| 4082 |
#endif |
| 4083 |
DDI_CHK_RET(vaStatus, "Unsupport Color space!"); |
| 4084 |
|
| 4085 |
if (mediaSrcSurf->format == Media_Format_400P) |
| 4086 |
{ |
| 4087 |
vpHalSrcSurf->ColorSpace = CSpace_BT601Gray; |
| 4088 |
} |
| 4089 |
|
| 4090 |
// extended gamut? RGB can't have extended gamut flag |
| 4091 |
vpHalSrcSurf->ExtendedGamut = false; |
| 4092 |
|
| 4093 |
// Background Colorfill |
| 4094 |
// According to libva definition, if alpha in output background color is zero, then colorfill is not needed |
| 4095 |
DDI_CHK_RET(SetBackgroundColorfill(vpHalRenderParams, pipelineParam->output_background_color), "Failed Set Background Colorfill"); |
| 4096 |
|
| 4097 |
// Set Demo Mode option |
| 4098 |
if (vpHalRenderParams->bDisableDemoMode == false) |
| 4099 |
{ |
| 4100 |
eStatus = VpHalDdiSetupSplitScreenDemoMode( |
| 4101 |
0, // No DDI setting on Linux. Set it when Linux DDI supports it |
| 4102 |
0, // No DDI setting on Linux. Set it when Linux DDI supports it |
| 4103 |
&vpHalRenderParams->pSplitScreenDemoModeParams, |
| 4104 |
&vpHalRenderParams->bDisableDemoMode, |
| 4105 |
osInterface); |
| 4106 |
if (MOS_STATUS_SUCCESS != eStatus) |
| 4107 |
{ |
| 4108 |
DDI_VP_ASSERTMESSAGE("Failed to setup Split-Screen Demo Mode."); |
| 4109 |
MOS_FreeMemAndSetNull(vpHalRenderParams->pSplitScreenDemoModeParams); |
| 4110 |
} |
| 4111 |
} |
| 4112 |
|
| 4113 |
// Update fwd and bkward ref frames: Required for Advanced processing - will be supported in the future |
| 4114 |
vpHalSrcSurf->uFwdRefCount = pipelineParam->num_backward_references; |
| 4115 |
|
| 4116 |
vaStatus = DdiUpdateProcPipelineFutureReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam); |
| 4117 |
DDI_CHK_RET(vaStatus, "Failed to update future reference frames!"); |
| 4118 |
|
| 4119 |
vpHalSrcSurf->uBwdRefCount = pipelineParam->num_forward_references; |
| 4120 |
|
| 4121 |
vaStatus = DdiUpdateProcPipelinePastReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam); |
| 4122 |
DDI_CHK_RET(vaStatus, "Failed to update past reference frames!"); |
| 4123 |
|
| 4124 |
// Check if filter values changed,if yes, then reset all filters for this surface |
| 4125 |
|
| 4126 |
// intialize the filter parameter |
| 4127 |
// Parameters once set in the surface will be keep till video complete |
| 4128 |
// so the parameter of rendered surface should be intialized every time |
| 4129 |
if (vpHalRenderParams->bStereoMode) |
| 4130 |
{ |
| 4131 |
vpHalSrcSurf->Rotation = VPHAL_ROTATION_IDENTITY; |
| 4132 |
} |
| 4133 |
|
| 4134 |
// Progressive or interlaced - Check filter_flags |
| 4135 |
// if the deinterlace parameters is not set, manipulate it as a progressive video. |
| 4136 |
if (pipelineParam->filter_flags & VA_TOP_FIELD) |
| 4137 |
{ |
| 4138 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD; |
| 4139 |
} |
| 4140 |
else if (pipelineParam->filter_flags & VA_BOTTOM_FIELD) |
| 4141 |
{ |
| 4142 |
vpHalSrcSurf->SampleType = SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD; |
| 4143 |
} |
| 4144 |
else // VA_FRAME_PICTURE |
| 4145 |
{ |
| 4146 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 4147 |
|
| 4148 |
//if the deinterlace parameters is set, clear it. |
| 4149 |
if (vpHalSrcSurf->pDeinterlaceParams != nullptr) |
| 4150 |
{ |
| 4151 |
MOS_Delete(vpHalSrcSurf->pDeinterlaceParams); |
| 4152 |
} |
| 4153 |
} |
| 4154 |
|
| 4155 |
for (i = 0; i < pipelineParam->num_filters; i++) |
| 4156 |
{ |
| 4157 |
VABufferID filter = pipelineParam->filters[i]; |
| 4158 |
|
| 4159 |
filterBuf = MediaLibvaCommonNext::GetBufferFromVABufferID(mediaCtx, filter); |
| 4160 |
DDI_VP_CHK_NULL(filterBuf, "nullptr filterBuf!", VA_STATUS_ERROR_INVALID_BUFFER); |
| 4161 |
|
| 4162 |
DDI_VP_CHK_CONDITION((VAProcFilterParameterBufferType != filterBuf->uiType), |
| 4163 |
"Invalid parameter buffer type!", |
| 4164 |
VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4165 |
|
| 4166 |
// Map Buffer data to virtual addres space |
| 4167 |
MediaLibvaInterfaceNext::MapBuffer(vaDrvCtx, filter, &data); |
| 4168 |
|
| 4169 |
filterParam = (VAProcFilterParameterBufferBase *)data; |
| 4170 |
|
| 4171 |
// HSBC can only be applied to the primary layer |
| 4172 |
if (!((filterParam->type == VAProcFilterColorBalance) && vpHalSrcSurf->SurfType != SURF_IN_PRIMARY)) |
| 4173 |
{ |
| 4174 |
// Pass the filter type |
| 4175 |
vaStatus = DdiUpdateFilterParamBuffer(vaDrvCtx, vpCtx, surfIndex, filterParam->type, data, filterBuf->uiNumElements, &vpStateFlags); |
| 4176 |
DDI_CHK_RET(vaStatus, "Failed to update parameter buffer!"); |
| 4177 |
} |
| 4178 |
} |
| 4179 |
|
| 4180 |
DdiClearFilterParamBuffer(vpCtx, surfIndex, vpStateFlags); |
| 4181 |
|
| 4182 |
// Use Render to do scaling for resolution larger than 8K |
| 4183 |
if (MEDIA_IS_WA(&mediaCtx->WaTable, WaDisableVeboxFor8K)) |
| 4184 |
{ |
| 4185 |
vpHalRenderParams->bDisableVeboxFor8K = true; |
| 4186 |
} |
| 4187 |
|
| 4188 |
// Scaling algorithm |
| 4189 |
scalingflags = pipelineParam->filter_flags & VA_FILTER_SCALING_MASK; |
| 4190 |
vpHalSrcSurf->ScalingPreference = VPHAL_SCALING_PREFER_SFC; // default |
| 4191 |
// Interpolation method |
| 4192 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 4193 |
interpolationflags = pipelineParam->filter_flags & VA_FILTER_INTERPOLATION_MASK; |
| 4194 |
#endif |
| 4195 |
switch (scalingflags) |
| 4196 |
{ |
| 4197 |
case VA_FILTER_SCALING_FAST: |
| 4198 |
if (vpHalSrcSurf->SurfType == SURF_IN_PRIMARY) |
| 4199 |
{ |
| 4200 |
VpSetInterpolationParams(vpHalSrcSurf, interpolationflags); |
| 4201 |
vpHalSrcSurf->ScalingPreference = VPHAL_SCALING_PREFER_SFC_FOR_VEBOX; |
| 4202 |
} |
| 4203 |
else |
| 4204 |
{ |
| 4205 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 4206 |
} |
| 4207 |
break; |
| 4208 |
case VA_FILTER_SCALING_HQ: |
| 4209 |
if (vpHalSrcSurf->SurfType == SURF_IN_PRIMARY) |
| 4210 |
{ |
| 4211 |
VpSetInterpolationParams(vpHalSrcSurf, interpolationflags); |
| 4212 |
vpHalSrcSurf->ScalingPreference = VPHAL_SCALING_PREFER_COMP; |
| 4213 |
} |
| 4214 |
else |
| 4215 |
{ |
| 4216 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 4217 |
} |
| 4218 |
break; |
| 4219 |
case VA_FILTER_SCALING_DEFAULT: |
| 4220 |
case VA_FILTER_SCALING_NL_ANAMORPHIC: |
| 4221 |
default: |
| 4222 |
if (vpHalSrcSurf->SurfType == SURF_IN_PRIMARY) |
| 4223 |
{ |
| 4224 |
VpSetInterpolationParams(vpHalSrcSurf, interpolationflags); |
| 4225 |
vpHalSrcSurf->ScalingPreference = VPHAL_SCALING_PREFER_SFC; |
| 4226 |
} |
| 4227 |
else |
| 4228 |
{ |
| 4229 |
vpHalSrcSurf->ScalingMode = VPHAL_SCALING_BILINEAR; |
| 4230 |
} |
| 4231 |
break; |
| 4232 |
} |
| 4233 |
//init interlace scaling flag |
| 4234 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 4235 |
vpHalSrcSurf->bFieldWeaving = false; |
| 4236 |
|
| 4237 |
if (vpHalSrcSurf->pDeinterlaceParams == nullptr) |
| 4238 |
{ |
| 4239 |
if (pipelineParam->input_surface_flag & VA_TOP_FIELD_FIRST) |
| 4240 |
{ |
| 4241 |
vaStatus = SetSurfaceParamsTopFieldFirst(pipelineParam->output_surface_flag, vpHalSrcSurf, vpHalTgtSurf); |
| 4242 |
DDI_CHK_RET(vaStatus, "Failed to set params on TopFieldFirst"); |
| 4243 |
} |
| 4244 |
else if (pipelineParam->input_surface_flag & VA_BOTTOM_FIELD_FIRST) |
| 4245 |
{ |
| 4246 |
vaStatus = SetSurfaceParamsBottomFieldFirst(pipelineParam->output_surface_flag, vpHalSrcSurf, vpHalTgtSurf); |
| 4247 |
DDI_CHK_RET(vaStatus, "Failed to set params on BottomFieldFirst"); |
| 4248 |
} |
| 4249 |
else if (pipelineParam->input_surface_flag & VA_TOP_FIELD) |
| 4250 |
{ |
| 4251 |
vaStatus = SetSurfaceParamsTopField(pipelineParam->output_surface_flag, vpHalSrcSurf, vpHalTgtSurf); |
| 4252 |
DDI_CHK_RET(vaStatus, "Failed to set params on TopField"); |
| 4253 |
} |
| 4254 |
else if (pipelineParam->input_surface_flag & VA_BOTTOM_FIELD) |
| 4255 |
{ |
| 4256 |
vaStatus = SetSurfaceParamsBottomField(pipelineParam->output_surface_flag, vpHalSrcSurf, vpHalTgtSurf); |
| 4257 |
DDI_CHK_RET(vaStatus, "Failed to set params on BottomField"); |
| 4258 |
} |
| 4259 |
else |
| 4260 |
{ |
| 4261 |
vpHalSrcSurf->SampleType = SAMPLE_PROGRESSIVE; |
| 4262 |
vpHalSrcSurf->InterlacedScalingType = ISCALING_NONE; |
| 4263 |
vpHalSrcSurf->bInterlacedScaling = false; |
| 4264 |
vpHalSrcSurf->bFieldWeaving = false; |
| 4265 |
} |
| 4266 |
} |
| 4267 |
|
| 4268 |
// For legacy interlace scaling |
| 4269 |
SetLegacyInterlaceScalingParams(vpHalSrcSurf, pipelineParam->filter_flags); |
| 4270 |
|
| 4271 |
// For weave DI |
| 4272 |
VpUpdateWeaveDI(vpHalSrcSurf, pipelineParam->filter_flags); |
| 4273 |
|
| 4274 |
// Rotation |
| 4275 |
vaStatus = VpUpdateProcRotateState(vpHalSrcSurf, pipelineParam->rotation_state); |
| 4276 |
DDI_CHK_RET(vaStatus, "Failed to update rotate state!"); |
| 4277 |
|
| 4278 |
// Mirror |
| 4279 |
vaStatus = VpUpdateProcMirrorState(vpHalSrcSurf, pipelineParam->mirror_state); |
| 4280 |
DDI_CHK_RET(vaStatus, "Failed to update mirror state!"); |
| 4281 |
|
| 4282 |
// Alpha blending |
| 4283 |
// Note: the alpha blending region cannot overlay |
| 4284 |
vaStatus = DdiSetProcPipelineBlendingParams(vpCtx, surfIndex, pipelineParam); |
| 4285 |
DDI_CHK_RET(vaStatus, "Failed to update Alpha Blending parameter!"); |
| 4286 |
|
| 4287 |
if (IsProcmpEnable(vpHalSrcSurf)) |
| 4288 |
{ |
| 4289 |
// correct the ChromaSitting location if Procamp is enabled. |
| 4290 |
#if (VA_MAJOR_VERSION < 1) |
| 4291 |
pipelineParam->input_surface_flag = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 4292 |
pipelineParam->output_surface_flag = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 4293 |
#else |
| 4294 |
pipelineParam->input_color_properties.chroma_sample_location = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 4295 |
pipelineParam->output_color_properties.chroma_sample_location = VA_CHROMA_SITING_HORIZONTAL_LEFT | VA_CHROMA_SITING_VERTICAL_TOP; |
| 4296 |
#endif |
| 4297 |
} |
| 4298 |
|
| 4299 |
#if (VA_MAJOR_VERSION < 1) |
| 4300 |
VpUpdateProcChromaSittingState(vpHalSrcSurf, (uint8_t)(pipelineParam->input_surface_flag & 0xff)); |
| 4301 |
VpUpdateProcChromaSittingState(vpHalTgtSurf, (uint8_t)(pipelineParam->output_surface_flag & 0xff)); |
| 4302 |
#else |
| 4303 |
VpUpdateProcChromaSittingState(vpHalSrcSurf, pipelineParam->input_color_properties.chroma_sample_location); |
| 4304 |
VpUpdateProcChromaSittingState(vpHalTgtSurf, pipelineParam->output_color_properties.chroma_sample_location); |
| 4305 |
#endif |
| 4306 |
// update OsResource for src surface |
| 4307 |
vpHalSrcSurf->OsResource.Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(mediaSrcSurf->format); |
| 4308 |
vpHalSrcSurf->OsResource.iWidth = mediaSrcSurf->iWidth; |
| 4309 |
vpHalSrcSurf->OsResource.iHeight = mediaSrcSurf->iHeight; |
| 4310 |
vpHalSrcSurf->OsResource.iPitch = mediaSrcSurf->iPitch; |
| 4311 |
vpHalSrcSurf->OsResource.iCount = mediaSrcSurf->iRefCount; |
| 4312 |
vpHalSrcSurf->OsResource.bo = mediaSrcSurf->bo; |
| 4313 |
vpHalSrcSurf->OsResource.TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(mediaSrcSurf->TileType); |
| 4314 |
vpHalSrcSurf->OsResource.pGmmResInfo = mediaSrcSurf->pGmmResourceInfo; |
| 4315 |
|
| 4316 |
Mos_Solo_SetOsResource(mediaSrcSurf->pGmmResourceInfo, &vpHalSrcSurf->OsResource); |
| 4317 |
|
| 4318 |
//Set encryption bit for input surface |
| 4319 |
//This setting only used for secure VPP test app which do secure VP and provide secure YUV as input |
| 4320 |
//Since APP cannot set encryption flag, it will set input_surface_flag to ask driver add encryption bit to input surface |
| 4321 |
if (osInterface->osCpInterface->IsHMEnabled() && (pipelineParam->input_surface_flag & VPHAL_SURFACE_ENCRYPTION_FLAG)) |
| 4322 |
{ |
| 4323 |
osInterface->osCpInterface->SetResourceEncryption(&(vpHalSrcSurf->OsResource), true); |
| 4324 |
} |
| 4325 |
|
| 4326 |
// Update the Render Target params - this needs to be done once when Render Target is passed via BeginPicture |
| 4327 |
vaStatus = DdiUpdateVphalTargetSurfColorSpace(vaDrvCtx, vpCtx, pipelineParam, 0); |
| 4328 |
DDI_CHK_RET(vaStatus, "Failed to update vphal target surface color space!"); |
| 4329 |
// Update the Render Target HDR params - this needs to be done once when Render Target is passed via BeginPicture |
| 4330 |
vaStatus = VpUpdateProcHdrState(vpHalTgtSurf, pipelineParam->output_hdr_metadata); |
| 4331 |
DDI_CHK_RET(vaStatus, "Failed to update vphal target surface HDR metadata!"); |
| 4332 |
|
| 4333 |
// Using additional_outputs processing as 1:N case. |
| 4334 |
for (i = 0; i < pipelineParam->num_additional_outputs; i++) |
| 4335 |
{ |
| 4336 |
vaStatus = DdiBeginPictureInt(vaDrvCtx, vpCtx, pipelineParam->additional_outputs[i]); |
| 4337 |
DDI_CHK_RET(vaStatus, "Failed to update vphal target surface buffers!"); |
| 4338 |
vaStatus = DdiUpdateVphalTargetSurfColorSpace(vaDrvCtx, vpCtx, pipelineParam, i + 1); |
| 4339 |
DDI_CHK_RET(vaStatus, "Failed to update vphal target surface color space!"); |
| 4340 |
} |
| 4341 |
|
| 4342 |
// add 16aligned UsrPtr mode support |
| 4343 |
if (mediaSrcSurf->pSurfDesc && (mediaSrcSurf->pSurfDesc->uiVaMemType == VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR)) |
| 4344 |
{ |
| 4345 |
vpHalSrcSurf->b16UsrPtr = VpIs16UsrPtrPitch(mediaSrcSurf->iPitch, mediaSrcSurf->format); // VpIs16UsrPtrPitch define in beginPicture |
| 4346 |
} |
| 4347 |
else |
| 4348 |
{ |
| 4349 |
vpHalSrcSurf->b16UsrPtr = false; |
| 4350 |
} |
| 4351 |
|
| 4352 |
return VA_STATUS_SUCCESS; |
| 4353 |
} |
| 4354 |
|
| 4355 |
VAStatus DdiVpFunctions::StatusCheck( |
| 4356 |
PDDI_MEDIA_CONTEXT mediaCtx, |
| 4357 |
DDI_MEDIA_SURFACE *surface, |
| 4358 |
VASurfaceID surfaceId) |
| 4359 |
{ |
| 4360 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 4361 |
QUERY_STATUS_REPORT_APP tempVpReport = {}; |
| 4362 |
DDI_MEDIA_SURFACE *tempSurface = nullptr; |
| 4363 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 4364 |
DDI_VP_FUNC_ENTER; |
| 4365 |
|
| 4366 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4367 |
DDI_VP_CHK_NULL(surface, "nullptr surface", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4368 |
|
| 4369 |
vpCtx = (PDDI_VP_CONTEXT)surface->pVpCtx; |
| 4370 |
DDI_VP_CHK_NULL(vpCtx , "nullptr vpCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4371 |
DDI_VP_CHK_NULL(vpCtx->pVpHal ,"nullptr vpCtx->pVpHal", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4372 |
|
| 4373 |
MOS_ZeroMemory(&tempVpReport, sizeof(QUERY_STATUS_REPORT_APP)); |
| 4374 |
|
| 4375 |
// Get reported surfaces' count |
| 4376 |
uint32_t tableLen = 0; |
| 4377 |
eStatus = vpCtx->pVpHal->GetStatusReportEntryLength(&tableLen); |
| 4378 |
if(eStatus != MOS_STATUS_SUCCESS) |
| 4379 |
{ |
| 4380 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 4381 |
} |
| 4382 |
if (tableLen > 0 && surface->curStatusReportQueryState == DDI_MEDIA_STATUS_REPORT_QUERY_STATE_PENDING) |
| 4383 |
{ |
| 4384 |
// Query the status for all of surfaces which have finished |
| 4385 |
for(uint32_t i = 0; i < tableLen; i++) |
| 4386 |
{ |
| 4387 |
MOS_ZeroMemory(&tempVpReport, sizeof(QUERY_STATUS_REPORT_APP)); |
| 4388 |
eStatus = vpCtx->pVpHal->GetStatusReport(&tempVpReport, 1); |
| 4389 |
if(eStatus != MOS_STATUS_SUCCESS) |
| 4390 |
{ |
| 4391 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 4392 |
} |
| 4393 |
// StatusFeedBackID is last time submitted Target Surface ID which is set in BeginPicture, |
| 4394 |
// So we can know the report is for which surface here. |
| 4395 |
tempSurface = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, tempVpReport.StatusFeedBackID); |
| 4396 |
DDI_VP_CHK_NULL(tempSurface, "nullptr tempSurface", VA_STATUS_ERROR_OPERATION_FAILED); |
| 4397 |
|
| 4398 |
// Update the status of the surface which is reported. |
| 4399 |
tempSurface->curStatusReport.vpp.status = (uint32_t)tempVpReport.dwStatus; |
| 4400 |
tempSurface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED; |
| 4401 |
|
| 4402 |
if(tempVpReport.StatusFeedBackID == surfaceId) |
| 4403 |
{ |
| 4404 |
break; |
| 4405 |
} |
| 4406 |
} |
| 4407 |
} |
| 4408 |
|
| 4409 |
if (surface->curStatusReportQueryState != DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED) |
| 4410 |
{ |
| 4411 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 4412 |
} |
| 4413 |
|
| 4414 |
if(surface->curStatusReport.vpp.status == VPREP_OK) |
| 4415 |
{ |
| 4416 |
return VA_STATUS_SUCCESS; |
| 4417 |
} |
| 4418 |
else if(surface->curStatusReport.vpp.status == VPREP_NOTREADY) |
| 4419 |
{ |
| 4420 |
return mediaCtx->bMediaResetEnable ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_HW_BUSY; |
| 4421 |
} |
| 4422 |
else |
| 4423 |
{ |
| 4424 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 4425 |
} |
| 4426 |
return VA_STATUS_SUCCESS; |
| 4427 |
} |
| 4428 |
|
| 4429 |
VAStatus DdiVpFunctions::ProcessPipeline( |
| 4430 |
VADriverContextP vaDrvCtx, |
| 4431 |
VAContextID ctxID, |
| 4432 |
VASurfaceID srcSurface, |
| 4433 |
VARectangle *srcRect, |
| 4434 |
VASurfaceID dstSurface, |
| 4435 |
VARectangle *dstRect) |
| 4436 |
{ |
| 4437 |
PERF_UTILITY_AUTO(__FUNCTION__, PERF_VP, PERF_LEVEL_DDI); |
| 4438 |
|
| 4439 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 4440 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 4441 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 4442 |
VAProcPipelineParameterBuffer *inputPipelineParam = nullptr; |
| 4443 |
|
| 4444 |
DDI_VP_FUNC_ENTER; |
| 4445 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4446 |
|
| 4447 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(vaDrvCtx, ctxID, &ctxType); |
| 4448 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4449 |
|
| 4450 |
vaStatus = BeginPicture(vaDrvCtx, ctxID, dstSurface); |
| 4451 |
DDI_CHK_RET(vaStatus, "VP BeginPicture failed"); |
| 4452 |
|
| 4453 |
//Set parameters |
| 4454 |
inputPipelineParam = (VAProcPipelineParameterBuffer*)MOS_AllocAndZeroMemory(sizeof(VAProcPipelineParameterBuffer)); |
| 4455 |
DDI_VP_CHK_NULL(inputPipelineParam, "nullptr inputPipelineParam", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 4456 |
|
| 4457 |
inputPipelineParam->surface_region = srcRect; |
| 4458 |
inputPipelineParam->output_region = dstRect; |
| 4459 |
inputPipelineParam->surface = srcSurface; |
| 4460 |
|
| 4461 |
vaStatus = DdiSetProcPipelineParams(vaDrvCtx, vpCtx, inputPipelineParam); |
| 4462 |
if(vaStatus != VA_STATUS_SUCCESS) |
| 4463 |
{ |
| 4464 |
MOS_FreeMemory(inputPipelineParam); |
| 4465 |
DDI_VP_ASSERTMESSAGE("VP SetProcPipelineParams failed."); |
| 4466 |
return vaStatus; |
| 4467 |
} |
| 4468 |
|
| 4469 |
vaStatus = EndPicture(vaDrvCtx, ctxID); |
| 4470 |
if(vaStatus != VA_STATUS_SUCCESS) |
| 4471 |
{ |
| 4472 |
MOS_FreeMemory(inputPipelineParam); |
| 4473 |
DDI_VP_ASSERTMESSAGE("VP EndPicture failed."); |
| 4474 |
return vaStatus; |
| 4475 |
} |
| 4476 |
|
| 4477 |
MOS_FreeMemory(inputPipelineParam); |
| 4478 |
return vaStatus; |
| 4479 |
} |
| 4480 |
|
| 4481 |
VAStatus DdiVpFunctions::PutSurface( |
| 4482 |
VADriverContextP ctx, |
| 4483 |
VASurfaceID surface, |
| 4484 |
void *draw, |
| 4485 |
int16_t srcx, |
| 4486 |
int16_t srcy, |
| 4487 |
uint16_t srcw, |
| 4488 |
uint16_t srch, |
| 4489 |
int16_t destx, |
| 4490 |
int16_t desty, |
| 4491 |
uint16_t destw, |
| 4492 |
uint16_t desth, |
| 4493 |
VARectangle *cliprects, |
| 4494 |
uint32_t numberCliprects, |
| 4495 |
uint32_t flags) |
| 4496 |
{ |
| 4497 |
void *vpCtx = nullptr; |
| 4498 |
PDDI_MEDIA_CONTEXT mediaDrvCtx = nullptr; |
| 4499 |
uint32_t ctxType = DDI_MEDIA_CONTEXT_TYPE_NONE; |
| 4500 |
DDI_VP_FUNC_ENTER; |
| 4501 |
|
| 4502 |
mediaDrvCtx = GetMediaContext(ctx); |
| 4503 |
DDI_VP_CHK_NULL(mediaDrvCtx, "nullptr mediaDrvCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4504 |
DDI_VP_CHK_NULL(mediaDrvCtx->pSurfaceHeap, "nullptr mediaDrvCtx->pSurfaceHeap", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4505 |
DDI_VP_CHK_NULL(mediaDrvCtx->pVpCtxHeap, "nullptr mediaDrvCtx->pVpCtxHeap", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4506 |
DDI_CHK_LESS((uint32_t)surface, mediaDrvCtx->pSurfaceHeap->uiAllocatedHeapElements, "Invalid surface", VA_STATUS_ERROR_INVALID_SURFACE); |
| 4507 |
|
| 4508 |
if (nullptr != mediaDrvCtx->pVpCtxHeap->pHeapBase) |
| 4509 |
{ |
| 4510 |
vpCtx = MediaLibvaCommonNext::GetContextFromContextID(ctx, (VAContextID)(DDI_MEDIA_SOFTLET_VACONTEXTID_VP_OFFSET), &ctxType); |
| 4511 |
} |
| 4512 |
|
| 4513 |
#if defined(ANDROID) || !defined(X11_FOUND) |
| 4514 |
return VA_STATUS_ERROR_UNIMPLEMENTED; |
| 4515 |
#else |
| 4516 |
if(nullptr == vpCtx) |
| 4517 |
{ |
| 4518 |
VAContextID context = VA_INVALID_ID; |
| 4519 |
VAStatus vaStatus = CreateContext(ctx, 0, 0, 0, 0, 0, 0, &context); |
| 4520 |
DDI_CHK_RET(vaStatus, "Create VP Context failed"); |
| 4521 |
} |
| 4522 |
return PutSurfaceLinuxHW(ctx, surface, draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, cliprects, numberCliprects, flags); |
| 4523 |
#endif |
| 4524 |
|
| 4525 |
return VA_STATUS_SUCCESS; |
| 4526 |
} |
| 4527 |
|
| 4528 |
#if !defined(ANDROID) && defined(X11_FOUND) |
| 4529 |
|
| 4530 |
void DdiVpFunctions::RectInit( |
| 4531 |
RECT *rect, |
| 4532 |
int16_t destx, |
| 4533 |
int16_t desty, |
| 4534 |
uint16_t destw, |
| 4535 |
uint16_t desth) |
| 4536 |
{ |
| 4537 |
DDI_VP_FUNC_ENTER; |
| 4538 |
DDI_VP_CHK_NULL(rect, "nullptr rect", ); |
| 4539 |
|
| 4540 |
rect->left = destx; |
| 4541 |
rect->top = desty; |
| 4542 |
rect->right = destx + destw; |
| 4543 |
rect->bottom = desty + desth; |
| 4544 |
return; |
| 4545 |
} |
| 4546 |
|
| 4547 |
VAStatus DdiVpFunctions::PutSurfaceLinuxHW( |
| 4548 |
VADriverContextP ctx, |
| 4549 |
VASurfaceID surface, |
| 4550 |
void *draw, |
| 4551 |
int16_t srcx, |
| 4552 |
int16_t srcy, |
| 4553 |
uint16_t srcw, |
| 4554 |
uint16_t srch, |
| 4555 |
int16_t destx, |
| 4556 |
int16_t desty, |
| 4557 |
uint16_t destw, |
| 4558 |
uint16_t desth, |
| 4559 |
VARectangle *cliprects, |
| 4560 |
uint32_t numberCliprects, |
| 4561 |
uint32_t flags) |
| 4562 |
{ |
| 4563 |
VpBase *vpHal = nullptr; |
| 4564 |
int32_t ovRenderIndex = 0; |
| 4565 |
VPHAL_SURFACE surf = {}; |
| 4566 |
VPHAL_SURFACE target = {}; |
| 4567 |
VPHAL_RENDER_PARAMS renderParams = {}; |
| 4568 |
VPHAL_COLORFILL_PARAMS colorFill = {}; |
| 4569 |
MOS_STATUS eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 4570 |
RECT srcRect = { 0, 0, 0, 0 }; |
| 4571 |
RECT dstRect = { 0, 0, 0, 0 }; |
| 4572 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 4573 |
PDDI_MEDIA_SURFACE bufferObject = nullptr; |
| 4574 |
uint32_t width = 0,height = 0,pitch = 0; |
| 4575 |
uint32_t drawableTilingMode = 0; |
| 4576 |
uint32_t drawableSwizzleMode = 0; |
| 4577 |
MOS_TILE_TYPE tileType = MOS_TILE_INVALID; |
| 4578 |
uint32_t ctxType = 0; |
| 4579 |
PDDI_VP_CONTEXT vpCtx = nullptr; |
| 4580 |
struct dri_drawable *driDrawable = nullptr; |
| 4581 |
union dri_buffer *buffer = nullptr; |
| 4582 |
GMM_RESCREATE_PARAMS gmmParams = {}; |
| 4583 |
|
| 4584 |
DDI_VP_FUNC_ENTER; |
| 4585 |
|
| 4586 |
mediaCtx = GetMediaContext(ctx); |
| 4587 |
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4588 |
DDI_VP_CHK_NULL(mediaCtx->dri_output, "nullptr mediaDrvCtx->dri_output", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4589 |
DDI_VP_CHK_NULL(mediaCtx->pSurfaceHeap, "nullptr mediaDrvCtx->pSurfaceHeap", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4590 |
DDI_VP_CHK_NULL(mediaCtx->pGmmClientContext, "nullptr mediaCtx->pGmmClientContext", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4591 |
DDI_VP_CHK_NULL(mediaCtx->pVpCtxHeap, "nullptr mediaCtx->pVpCtxHeap", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4592 |
DDI_VP_CHK_NULL(mediaCtx->pVpCtxHeap->pHeapBase, "nullptr mediaCtx->pVpCtxHeap->pHeapBase", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 4593 |
|
| 4594 |
DDI_CHK_LESS((uint32_t)surface, mediaCtx->pSurfaceHeap->uiAllocatedHeapElements, "Invalid surfaceId", VA_STATUS_ERROR_INVALID_SURFACE); |
| 4595 |
|
| 4596 |
struct dri_vtable *const driVtable = &mediaCtx->dri_output->vtable; |
| 4597 |
DDI_VP_CHK_NULL(driVtable, "nullptr driVtable", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4598 |
|
| 4599 |
driDrawable = driVtable->get_drawable(ctx, (Drawable)draw); |
| 4600 |
DDI_VP_CHK_NULL(driDrawable, "nullptr driDrawable", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4601 |
buffer = driVtable->get_rendering_buffer(ctx, driDrawable); |
| 4602 |
DDI_VP_CHK_NULL(buffer, "nullptr buffer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4603 |
|
| 4604 |
bufferObject = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, surface); |
| 4605 |
DDI_VP_CHK_NULL(bufferObject, "nullptr bufferObject", VA_STATUS_ERROR_INVALID_SURFACE); |
| 4606 |
MediaLibvaUtilNext::MediaPrintFps(); |
| 4607 |
pitch = bufferObject->iPitch; |
| 4608 |
|
| 4609 |
vpCtx = (PDDI_VP_CONTEXT)MediaLibvaCommonNext::GetContextFromContextID(ctx, (VAContextID)(DDI_MEDIA_SOFTLET_VACONTEXTID_VP_OFFSET), &ctxType); |
| 4610 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4611 |
vpHal = vpCtx->pVpHal; |
| 4612 |
DDI_VP_CHK_NULL(vpHal, "nullptr vpHal", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 4613 |
|
| 4614 |
renderParams.Component = COMPONENT_LibVA; |
| 4615 |
|
| 4616 |
//Init source rectangle |
| 4617 |
RectInit(&srcRect, srcx, srcy, srcw, srch); |
| 4618 |
RectInit(&dstRect, destx, desty, destw, desth); |
| 4619 |
|
| 4620 |
if (destx + destw > driDrawable->x + driDrawable->width) |
| 4621 |
{ |
| 4622 |
dstRect.right = driDrawable->x + driDrawable->width - destx; |
| 4623 |
if(dstRect.right <= 0) |
| 4624 |
{ |
| 4625 |
return VA_STATUS_SUCCESS; |
| 4626 |
} |
| 4627 |
} |
| 4628 |
if (desty + desth > driDrawable->y + driDrawable->height) |
| 4629 |
{ |
| 4630 |
dstRect.bottom = driDrawable->y + driDrawable->height - desty; |
| 4631 |
if(dstRect.bottom <= 0) |
| 4632 |
{ |
| 4633 |
return VA_STATUS_SUCCESS; |
| 4634 |
} |
| 4635 |
} |
| 4636 |
// Source Surface Information |
| 4637 |
surf.Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(bufferObject->format); // Surface format |
| 4638 |
surf.SurfType = SURF_IN_PRIMARY; // Surface type (context) |
| 4639 |
surf.SampleType = SAMPLE_PROGRESSIVE; |
| 4640 |
surf.ScalingMode = VPHAL_SCALING_AVS; |
| 4641 |
|
| 4642 |
surf.OsResource.Format = MediaLibvaUtilNext::GetFormatFromMediaFormat(bufferObject->format); |
| 4643 |
surf.OsResource.iWidth = bufferObject->iWidth; |
| 4644 |
surf.OsResource.iHeight = bufferObject->iHeight; |
| 4645 |
surf.OsResource.iPitch = bufferObject->iPitch; |
| 4646 |
surf.OsResource.iCount = 0; |
| 4647 |
surf.OsResource.TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(bufferObject->TileType); |
| 4648 |
surf.OsResource.bMapped = bufferObject->bMapped; |
| 4649 |
surf.OsResource.bo = bufferObject->bo; |
| 4650 |
surf.OsResource.pGmmResInfo = bufferObject->pGmmResourceInfo; |
| 4651 |
|
| 4652 |
surf.dwWidth = bufferObject->iWidth; |
| 4653 |
surf.dwHeight = bufferObject->iHeight; |
| 4654 |
surf.dwPitch = bufferObject->iPitch; |
| 4655 |
surf.TileType = MediaLibvaUtilNext::GetTileTypeFromMediaTileType(bufferObject->TileType); |
| 4656 |
surf.ColorSpace = MediaLibvaUtilNext::GetColorSpaceFromMediaFormat(bufferObject->format); |
| 4657 |
surf.ExtendedGamut = false; |
| 4658 |
surf.rcSrc = srcRect; |
| 4659 |
surf.rcDst = dstRect; |
| 4660 |
|
| 4661 |
MOS_LINUX_BO *drawableBo = mos_bo_create_from_name(mediaCtx->pDrmBufMgr, "rendering buffer", buffer->dri2.name); |
| 4662 |
DDI_VP_CHK_NULL(drawableBo, "nullptr drawableBo", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 4663 |
|
| 4664 |
if (!mos_bo_get_tiling(drawableBo, &drawableTilingMode, &drawableSwizzleMode)) |
| 4665 |
{ |
| 4666 |
switch (drawableTilingMode) |
| 4667 |
{ |
| 4668 |
case TILING_Y: |
| 4669 |
tileType = MOS_TILE_Y; |
| 4670 |
break; |
| 4671 |
case TILING_X: |
| 4672 |
tileType = MOS_TILE_X; |
| 4673 |
gmmParams.Flags.Info.TiledX = true; |
| 4674 |
break; |
| 4675 |
case TILING_NONE: |
| 4676 |
tileType = MOS_TILE_LINEAR; |
| 4677 |
gmmParams.Flags.Info.Linear = true; |
| 4678 |
break; |
| 4679 |
default: |
| 4680 |
drawableTilingMode = TILING_NONE; |
| 4681 |
tileType = MOS_TILE_LINEAR; |
| 4682 |
gmmParams.Flags.Info.Linear = true; |
| 4683 |
break; |
| 4684 |
} |
| 4685 |
target.OsResource.TileType = (MOS_TILE_TYPE)drawableTilingMode; |
| 4686 |
} |
| 4687 |
else |
| 4688 |
{ |
| 4689 |
target.OsResource.TileType = (MOS_TILE_TYPE)TILING_NONE; |
| 4690 |
tileType = MOS_TILE_LINEAR; |
| 4691 |
gmmParams.Flags.Info.Linear = true; |
| 4692 |
} |
| 4693 |
gmmParams.Flags.Info.LocalOnly = MEDIA_IS_SKU(&mediaCtx->SkuTable, FtrLocalMemory); |
| 4694 |
|
| 4695 |
target.Format = Format_A8R8G8B8; |
| 4696 |
target.SurfType = SURF_OUT_RENDERTARGET; |
| 4697 |
|
| 4698 |
//init target retangle |
| 4699 |
RectInit(&srcRect, driDrawable->x, driDrawable->y, driDrawable->width, driDrawable->height); |
| 4700 |
RectInit(&dstRect, driDrawable->x, driDrawable->y, driDrawable->width, driDrawable->height); |
| 4701 |
|
| 4702 |
// Create GmmResourceInfo |
| 4703 |
gmmParams.Flags.Gpu.Video = true; |
| 4704 |
gmmParams.BaseWidth = driDrawable->width; |
| 4705 |
gmmParams.BaseHeight = driDrawable->height; |
| 4706 |
gmmParams.ArraySize = 1; |
| 4707 |
gmmParams.Type = RESOURCE_2D; |
| 4708 |
gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 4709 |
//gmmParams.Format = GMM_FORMAT_B8G8R8A8_UNORM_TYPE; |
| 4710 |
target.OsResource.pGmmResInfo = mediaCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); |
| 4711 |
if (nullptr == target.OsResource.pGmmResInfo) |
| 4712 |
{ |
| 4713 |
mos_bo_unreference(drawableBo); |
| 4714 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 4715 |
} |
| 4716 |
|
| 4717 |
target.OsResource.iWidth = driDrawable->width; |
| 4718 |
target.OsResource.iHeight = driDrawable->height; |
| 4719 |
target.OsResource.iPitch = buffer->dri2.pitch; |
| 4720 |
target.OsResource.Format = Format_A8R8G8B8; |
| 4721 |
target.OsResource.iCount = 0; |
| 4722 |
target.OsResource.bo = drawableBo; |
| 4723 |
target.OsResource.pData = (uint8_t *)drawableBo->virt; |
| 4724 |
target.OsResource.TileType = tileType; |
| 4725 |
target.TileType = tileType; |
| 4726 |
target.dwWidth = driDrawable->width; |
| 4727 |
target.dwHeight = driDrawable->height; |
| 4728 |
target.dwPitch = target.OsResource.iPitch; |
| 4729 |
target.ColorSpace = CSpace_sRGB; |
| 4730 |
target.ExtendedGamut = false; |
| 4731 |
target.rcSrc = srcRect; |
| 4732 |
target.rcDst = dstRect; |
| 4733 |
|
| 4734 |
renderParams.uSrcCount = 1; |
| 4735 |
renderParams.uDstCount = 1; |
| 4736 |
renderParams.pSrc[0] = &surf; |
| 4737 |
renderParams.pTarget[0] = ⌖ |
| 4738 |
renderParams.pColorFillParams = &colorFill; |
| 4739 |
renderParams.pColorFillParams->Color = 0xFF000000; |
| 4740 |
renderParams.pColorFillParams->bYCbCr = false; |
| 4741 |
renderParams.pColorFillParams->CSpace = CSpace_sRGB; |
| 4742 |
|
| 4743 |
MosUtilities::MosLockMutex(&mediaCtx->PutSurfaceRenderMutex); |
| 4744 |
eStatus = vpHal->Render(&renderParams); |
| 4745 |
if (MOS_FAILED(eStatus)) |
| 4746 |
{ |
| 4747 |
MosUtilities::MosUnlockMutex(&mediaCtx->PutSurfaceRenderMutex); |
| 4748 |
mos_bo_unreference(drawableBo); |
| 4749 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 4750 |
} |
| 4751 |
|
| 4752 |
MosUtilities::MosUnlockMutex(&mediaCtx->PutSurfaceRenderMutex); |
| 4753 |
mos_bo_unreference(drawableBo); |
| 4754 |
target.OsResource.bo = nullptr; |
| 4755 |
MosUtilities::MosLockMutex(&mediaCtx->PutSurfaceSwapBufferMutex); |
| 4756 |
driVtable->swap_buffer(ctx, driDrawable); |
| 4757 |
MosUtilities::MosUnlockMutex(&mediaCtx->PutSurfaceSwapBufferMutex); |
| 4758 |
|
| 4759 |
mediaCtx->pGmmClientContext->DestroyResInfoObject(target.OsResource.pGmmResInfo); |
| 4760 |
target.OsResource.pGmmResInfo = nullptr; |
| 4761 |
|
| 4762 |
return VA_STATUS_SUCCESS; |
| 4763 |
} |
| 4764 |
#endif // !defined(ANDROID) && defined(X11_FOUND) |