| 1 |
/* |
| 2 |
* Copyright (c) 2022, 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_tools.cpp |
| 24 |
//! \brief ddi vp tool functions implementation |
| 25 |
//! |
| 26 |
#include <sys/time.h> |
| 27 |
#include "ddi_vp_tools.h" |
| 28 |
#include "media_libva_util_next.h" |
| 29 |
#include "media_libva_interface_next.h" |
| 30 |
|
| 31 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 32 |
VAStatus DdiVpTools::InitDumpConfig(PDDI_VP_CONTEXT vpCtx) |
| 33 |
{ |
| 34 |
VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 35 |
|
| 36 |
DDI_VP_FUNC_ENTER; |
| 37 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 38 |
|
| 39 |
vpCtx->pCurVpDumpDDIParam = nullptr; |
| 40 |
vpCtx->pPreVpDumpDDIParam = nullptr; |
| 41 |
|
| 42 |
// allocate pCurVpDumpDDIParam |
| 43 |
vpCtx->pCurVpDumpDDIParam = MOS_New(DDI_VP_DUMP_PARAM); |
| 44 |
if (vpCtx->pCurVpDumpDDIParam) |
| 45 |
{ |
| 46 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 47 |
{ |
| 48 |
vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex] = MOS_New(VAProcPipelineParameterBuffer); |
| 49 |
if (nullptr == vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex]) |
| 50 |
{ |
| 51 |
MOS_Delete(vpCtx->fpDumpFile); |
| 52 |
vpCtx->fpDumpFile = nullptr; |
| 53 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
// allocate pPreVpDumpDDIParam |
| 58 |
vpCtx->pPreVpDumpDDIParam = MOS_New(DDI_VP_DUMP_PARAM); |
| 59 |
if (vpCtx->pPreVpDumpDDIParam) |
| 60 |
{ |
| 61 |
for (int32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 62 |
{ |
| 63 |
vpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[surfIndex] = MOS_New(VAProcPipelineParameterBuffer); |
| 64 |
if (nullptr == vpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[surfIndex]) |
| 65 |
{ |
| 66 |
MOS_Delete(vpCtx->fpDumpFile); |
| 67 |
vpCtx->fpDumpFile = nullptr; |
| 68 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
vpCtx->fpDumpFile = nullptr; |
| 74 |
return vaStatus; |
| 75 |
} |
| 76 |
|
| 77 |
void DdiVpTools::DestoryDumpConfig(PDDI_VP_CONTEXT vpCtx) |
| 78 |
{ |
| 79 |
DDI_VP_FUNC_ENTER; |
| 80 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx", ); |
| 81 |
|
| 82 |
if (vpCtx->pCurVpDumpDDIParam) |
| 83 |
{ |
| 84 |
for (uint32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 85 |
{ |
| 86 |
if (vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex]) |
| 87 |
{ |
| 88 |
MOS_Delete(vpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[surfIndex]); |
| 89 |
} |
| 90 |
} |
| 91 |
MOS_Delete(vpCtx->pCurVpDumpDDIParam); |
| 92 |
} |
| 93 |
|
| 94 |
if (vpCtx->pPreVpDumpDDIParam) |
| 95 |
{ |
| 96 |
for (uint32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 97 |
{ |
| 98 |
if (vpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[surfIndex]) |
| 99 |
{ |
| 100 |
MOS_Delete(vpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[surfIndex]); |
| 101 |
} |
| 102 |
} |
| 103 |
MOS_Delete(vpCtx->pPreVpDumpDDIParam); |
| 104 |
} |
| 105 |
|
| 106 |
if (vpCtx->fpDumpFile) |
| 107 |
{ |
| 108 |
fclose(vpCtx->fpDumpFile); |
| 109 |
MOS_Delete(vpCtx->fpDumpFile); |
| 110 |
vpCtx->fpDumpFile = nullptr; |
| 111 |
} |
| 112 |
|
| 113 |
return; |
| 114 |
} |
| 115 |
|
| 116 |
bool DdiVpTools::VpCmpDDIDumpParam( |
| 117 |
PDDI_VP_DUMP_PARAM curParams, |
| 118 |
PDDI_VP_DUMP_PARAM preParams) |
| 119 |
{ |
| 120 |
bool ret = true; |
| 121 |
|
| 122 |
DDI_VP_FUNC_ENTER; |
| 123 |
DDI_VP_CHK_NULL(curParams, "nullptr curParams.", false); |
| 124 |
DDI_VP_CHK_NULL(preParams, "nullptr preParams.", false); |
| 125 |
|
| 126 |
if (memcmp(curParams->SrcFormat, preParams->SrcFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_SOURCES) != 0) |
| 127 |
{ |
| 128 |
ret = false; |
| 129 |
} |
| 130 |
|
| 131 |
if (memcmp(curParams->TargetFormat, preParams->TargetFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_TARGETS) != 0) |
| 132 |
{ |
| 133 |
ret = false; |
| 134 |
} |
| 135 |
|
| 136 |
for (uint32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 137 |
{ |
| 138 |
if (memcmp(curParams->pPipelineParamBuffers[surfIndex], preParams->pPipelineParamBuffers[surfIndex], sizeof(VAProcPipelineParameterBuffer)) != 0) |
| 139 |
{ |
| 140 |
ret = false; |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
return ret; |
| 145 |
} |
| 146 |
|
| 147 |
int DdiVpTools::VpParseLogConfig( |
| 148 |
const char *env, |
| 149 |
char *envValue) |
| 150 |
{ |
| 151 |
char *token = nullptr, *value = nullptr, *saveptr = nullptr; |
| 152 |
char oneline[1024] = {}; |
| 153 |
FILE *fp = nullptr; |
| 154 |
|
| 155 |
DDI_VP_FUNC_ENTER; |
| 156 |
DDI_VP_CHK_NULL(env, "nullptr env.", 1); |
| 157 |
|
| 158 |
fp = fopen("/etc/vpddi.conf", "r"); |
| 159 |
while (fp && (fgets(oneline, 1024, fp) != nullptr)) |
| 160 |
{ |
| 161 |
if (strlen(oneline) == 1) |
| 162 |
{ |
| 163 |
continue; |
| 164 |
} |
| 165 |
|
| 166 |
token = strtok_r(oneline, "=\n", &saveptr); |
| 167 |
value = strtok_r(nullptr, "=\n", &saveptr); |
| 168 |
|
| 169 |
if (nullptr == token || nullptr == value) |
| 170 |
{ |
| 171 |
continue; |
| 172 |
} |
| 173 |
|
| 174 |
if (strcmp(token, env) == 0) |
| 175 |
{ |
| 176 |
if (envValue) |
| 177 |
{ |
| 178 |
strncpy(envValue, value, 1024); |
| 179 |
} |
| 180 |
|
| 181 |
fclose(fp); |
| 182 |
fp = nullptr; |
| 183 |
return 0; |
| 184 |
} |
| 185 |
} |
| 186 |
if (fp) |
| 187 |
{ |
| 188 |
fclose(fp); |
| 189 |
fp = nullptr; |
| 190 |
} |
| 191 |
|
| 192 |
// no setting in config file, use env setting |
| 193 |
value = getenv(env); |
| 194 |
if (value) |
| 195 |
{ |
| 196 |
if (envValue) |
| 197 |
{ |
| 198 |
strncpy(envValue, value, 1024); |
| 199 |
} |
| 200 |
|
| 201 |
return 0; |
| 202 |
} |
| 203 |
|
| 204 |
return 1; |
| 205 |
} |
| 206 |
|
| 207 |
void DdiVpTools::VpDumpDeinterlacingParameterBuffer( |
| 208 |
FILE *fpLog, |
| 209 |
VAProcFilterParameterBufferDeinterlacing *deint) |
| 210 |
{ |
| 211 |
DDI_VP_FUNC_ENTER; |
| 212 |
if (deint && fpLog) |
| 213 |
{ |
| 214 |
fprintf(fpLog, "\t type = %d\n", deint->type); |
| 215 |
fprintf(fpLog, "\t algorithm = %d\n", deint->algorithm); |
| 216 |
fprintf(fpLog, "\t flags = %d\n", deint->flags); |
| 217 |
} |
| 218 |
return; |
| 219 |
} |
| 220 |
|
| 221 |
void DdiVpTools::VpDumpColorBalanceParameterBuffer( |
| 222 |
FILE *fpLog, |
| 223 |
VAProcFilterParameterBufferColorBalance *colorbalance, |
| 224 |
uint32_t elementNum) |
| 225 |
{ |
| 226 |
DDI_VP_FUNC_ENTER; |
| 227 |
for (uint32_t i = 0; i < elementNum; i++) |
| 228 |
{ |
| 229 |
if (fpLog && colorbalance) |
| 230 |
{ |
| 231 |
fprintf(fpLog, "\t type = %d\n", colorbalance[i].type); |
| 232 |
fprintf(fpLog, "\t attrib = %d\n", colorbalance[i].attrib); |
| 233 |
fprintf(fpLog, "\t value = %f\n", colorbalance[i].value); |
| 234 |
} |
| 235 |
} |
| 236 |
return; |
| 237 |
} |
| 238 |
|
| 239 |
void DdiVpTools::VpDumpTotalColorCorrectionParameterBuffer( |
| 240 |
FILE *fpLog, |
| 241 |
VAProcFilterParameterBufferTotalColorCorrection *filterParam, |
| 242 |
uint32_t elementNum) |
| 243 |
{ |
| 244 |
DDI_VP_FUNC_ENTER; |
| 245 |
for (uint32_t i = 0; i < elementNum; i++) |
| 246 |
{ |
| 247 |
if (fpLog && filterParam) |
| 248 |
{ |
| 249 |
fprintf(fpLog, "\t type = %d\n", filterParam[i].type); |
| 250 |
fprintf(fpLog, "\t attrib = %d\n", filterParam[i].attrib); |
| 251 |
fprintf(fpLog, "\t value = %f\n", filterParam[i].value); |
| 252 |
} |
| 253 |
} |
| 254 |
return; |
| 255 |
} |
| 256 |
|
| 257 |
void DdiVpTools::VpDumpFilterParameterBuffer( |
| 258 |
FILE *fpLog, |
| 259 |
VAProcFilterParameterBuffer *buffer) |
| 260 |
{ |
| 261 |
DDI_VP_FUNC_ENTER; |
| 262 |
if (fpLog && buffer) |
| 263 |
{ |
| 264 |
fprintf(fpLog, "\t type = %d\n", buffer->type); |
| 265 |
fprintf(fpLog, "\t value = %f\n", buffer->value); |
| 266 |
} |
| 267 |
return; |
| 268 |
} |
| 269 |
|
| 270 |
void DdiVpTools::VpDumpProcFiltersParameterBufferSurface( |
| 271 |
FILE *fpLog, |
| 272 |
VAProcPipelineParameterBuffer *pipelineParameterBuffer, |
| 273 |
MOS_FORMAT srcFormat) |
| 274 |
{ |
| 275 |
DDI_VP_FUNC_ENTER; |
| 276 |
DDI_VP_CHK_NULL(fpLog, "nullptr fpLog", ); |
| 277 |
DDI_VP_CHK_NULL(pipelineParameterBuffer, "nullptr pipelineParameterBuffer", ); |
| 278 |
|
| 279 |
fprintf(fpLog, "\t--VAProcPipelineParameterBuffer\n"); |
| 280 |
fprintf(fpLog, "\t surface = 0x%08x\n", pipelineParameterBuffer->surface); |
| 281 |
fprintf(fpLog, "\t Format = %d\n", (int32_t)(srcFormat)); |
| 282 |
|
| 283 |
if (pipelineParameterBuffer->surface_region) |
| 284 |
{ |
| 285 |
fprintf(fpLog, "\t surface_region\n"); |
| 286 |
fprintf(fpLog, "\t x = %d\n", pipelineParameterBuffer->surface_region->x); |
| 287 |
fprintf(fpLog, "\t y = %d\n", pipelineParameterBuffer->surface_region->y); |
| 288 |
fprintf(fpLog, "\t width = %d\n", pipelineParameterBuffer->surface_region->width); |
| 289 |
fprintf(fpLog, "\t height = %d\n", pipelineParameterBuffer->surface_region->height); |
| 290 |
} |
| 291 |
|
| 292 |
fprintf(fpLog, "\t surface_color_standard = %d\n", pipelineParameterBuffer->surface_color_standard); |
| 293 |
|
| 294 |
if (pipelineParameterBuffer->output_region) |
| 295 |
{ |
| 296 |
fprintf(fpLog, "\t output_region\n"); |
| 297 |
fprintf(fpLog, "\t x = %d\n", pipelineParameterBuffer->output_region->x); |
| 298 |
fprintf(fpLog, "\t y = %d\n", pipelineParameterBuffer->output_region->y); |
| 299 |
fprintf(fpLog, "\t width = %d\n", pipelineParameterBuffer->output_region->width); |
| 300 |
fprintf(fpLog, "\t height = %d\n", pipelineParameterBuffer->output_region->height); |
| 301 |
} |
| 302 |
|
| 303 |
fprintf(fpLog, "\t output_background_color = 0x%08x\n", pipelineParameterBuffer->output_background_color); |
| 304 |
fprintf(fpLog, "\t output_color_standard = %d\n", pipelineParameterBuffer->output_color_standard); |
| 305 |
fprintf(fpLog, "\t pipeline_flags = 0x%08x\n", pipelineParameterBuffer->pipeline_flags); |
| 306 |
fprintf(fpLog, "\t filter_flags = 0x%08x\n", pipelineParameterBuffer->filter_flags); |
| 307 |
return; |
| 308 |
} |
| 309 |
|
| 310 |
void DdiVpTools::VpDumpProcFiltersParameterBuffer( |
| 311 |
FILE *fpLog, |
| 312 |
VADriverContextP vaDrvCtx, |
| 313 |
VABufferID *filters, |
| 314 |
unsigned int filtersNum) |
| 315 |
{ |
| 316 |
VABufferType type = VAPictureParameterBufferType; |
| 317 |
unsigned int size = 0; |
| 318 |
unsigned int elementsNums = 0; |
| 319 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 320 |
void *data = nullptr; |
| 321 |
PDDI_MEDIA_BUFFER filterBuf = nullptr; |
| 322 |
VAProcFilterParameterBufferBase *filterParam = nullptr; |
| 323 |
|
| 324 |
DDI_VP_FUNC_ENTER; |
| 325 |
DDI_VP_CHK_NULL(fpLog, "nullptr fpLog", ); |
| 326 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx", ); |
| 327 |
|
| 328 |
fprintf(fpLog, "\t filtersNum = %d\n", filtersNum); |
| 329 |
fprintf(fpLog, "\t filters = %p\n", filters); |
| 330 |
DDI_VP_CHK_NULL(filters, "nullptr filters", ); |
| 331 |
|
| 332 |
if (filtersNum == 0) |
| 333 |
{ |
| 334 |
return; |
| 335 |
} |
| 336 |
|
| 337 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 338 |
// get buffer type information |
| 339 |
for (int i = 0; i < filtersNum; i++) |
| 340 |
{ |
| 341 |
VABufferID filter = filters[i]; |
| 342 |
filterBuf = MediaLibvaCommonNext::GetBufferFromVABufferID(mediaCtx, filter); |
| 343 |
|
| 344 |
// Map Buffer data to virtual addres space |
| 345 |
MediaLibvaInterfaceNext::MapBuffer(vaDrvCtx, filter, &data); |
| 346 |
|
| 347 |
filterParam = (VAProcFilterParameterBufferBase *)data; |
| 348 |
if (nullptr != filterBuf) |
| 349 |
{ |
| 350 |
fprintf(fpLog, "\t num_elements = %d\n", filterBuf->uiNumElements); |
| 351 |
} |
| 352 |
DDI_VP_CHK_NULL(filterParam, "nullptr filterParam", ); |
| 353 |
|
| 354 |
switch (filterParam->type) |
| 355 |
{ |
| 356 |
case VAProcFilterDeinterlacing: |
| 357 |
VpDumpDeinterlacingParameterBuffer(fpLog, (VAProcFilterParameterBufferDeinterlacing *)data); |
| 358 |
break; |
| 359 |
|
| 360 |
case VAProcFilterColorBalance: |
| 361 |
if (nullptr != filterBuf) |
| 362 |
{ |
| 363 |
VpDumpColorBalanceParameterBuffer(fpLog, (VAProcFilterParameterBufferColorBalance *)data, filterBuf->uiNumElements); |
| 364 |
} |
| 365 |
break; |
| 366 |
|
| 367 |
case VAProcFilterTotalColorCorrection: |
| 368 |
if (nullptr != filterBuf) |
| 369 |
{ |
| 370 |
VpDumpTotalColorCorrectionParameterBuffer(fpLog, (VAProcFilterParameterBufferTotalColorCorrection *)data, filterBuf->uiNumElements); |
| 371 |
} |
| 372 |
break; |
| 373 |
|
| 374 |
case VAProcFilterNoiseReduction: |
| 375 |
VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)data); |
| 376 |
break; |
| 377 |
|
| 378 |
case VAProcFilterSharpening: |
| 379 |
VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)data); |
| 380 |
break; |
| 381 |
|
| 382 |
case VAProcFilterSkinToneEnhancement: |
| 383 |
VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)data); |
| 384 |
break; |
| 385 |
|
| 386 |
default: |
| 387 |
fprintf(fpLog, "\t type = %d\n", filterParam->type); |
| 388 |
break; |
| 389 |
} |
| 390 |
} |
| 391 |
return; |
| 392 |
} |
| 393 |
|
| 394 |
void DdiVpTools::VpDumpProcFiltersParameterBufferFWDReference( |
| 395 |
FILE *fpLog, |
| 396 |
VASurfaceID *forwardReferences, |
| 397 |
uint32_t forwardReferencesNum) |
| 398 |
{ |
| 399 |
DDI_VP_FUNC_ENTER; |
| 400 |
DDI_VP_CHK_NULL(fpLog, "nullptr fpLog", ); |
| 401 |
|
| 402 |
fprintf(fpLog, "\t num_forward_references = 0x%08x\n", forwardReferencesNum); |
| 403 |
|
| 404 |
if (forwardReferencesNum) |
| 405 |
{ |
| 406 |
fprintf(fpLog, "\t forward_references\n"); |
| 407 |
|
| 408 |
if (forwardReferences) |
| 409 |
{ |
| 410 |
/* only dump the first 5 forward references */ |
| 411 |
for (int32_t i = 0; i < forwardReferencesNum && i < 5; i++) |
| 412 |
{ |
| 413 |
fprintf(fpLog, "\t forward_references[%d] = 0x%08x\n", i, forwardReferences[i]); |
| 414 |
} |
| 415 |
} |
| 416 |
else |
| 417 |
{ |
| 418 |
for (int32_t i = 0; i < forwardReferencesNum && i < 5; i++) |
| 419 |
{ |
| 420 |
fprintf(fpLog, "\t forward_references[%d] = (nullptr)\n", i); |
| 421 |
} |
| 422 |
} |
| 423 |
} |
| 424 |
return; |
| 425 |
} |
| 426 |
|
| 427 |
void DdiVpTools::VpDumpProcFiltersParameterBufferBKWReference( |
| 428 |
FILE *fpLog, |
| 429 |
VASurfaceID *backwardReferences, |
| 430 |
uint32_t backwardReferencesNum) |
| 431 |
{ |
| 432 |
DDI_VP_FUNC_ENTER; |
| 433 |
DDI_VP_CHK_NULL(fpLog, "nullptr fpLog", ); |
| 434 |
|
| 435 |
fprintf(fpLog, "\t num_backward_references = 0x%08x\n", backwardReferencesNum); |
| 436 |
|
| 437 |
if (backwardReferencesNum) |
| 438 |
{ |
| 439 |
fprintf(fpLog, "\t backward_references\n"); |
| 440 |
|
| 441 |
if (backwardReferences) |
| 442 |
{ |
| 443 |
/* only dump the first 5 backward references */ |
| 444 |
for (int32_t i = 0; i < backwardReferencesNum && i < 5; i++) |
| 445 |
{ |
| 446 |
fprintf(fpLog, "\t backward_references[%d] = 0x%08x\n", i, backwardReferences[i]); |
| 447 |
} |
| 448 |
} |
| 449 |
else |
| 450 |
{ |
| 451 |
for (int32_t i = 0; i < backwardReferencesNum && i < 5; i++) |
| 452 |
{ |
| 453 |
fprintf(fpLog, "\t backward_references[%d] = (nullptr)\n", i); |
| 454 |
} |
| 455 |
} |
| 456 |
} |
| 457 |
return; |
| 458 |
} |
| 459 |
|
| 460 |
VAStatus DdiVpTools::VpDumpProcPipelineParams( |
| 461 |
VADriverContextP vaDrvCtx, |
| 462 |
PDDI_VP_CONTEXT vpCtx) |
| 463 |
{ |
| 464 |
PDDI_MEDIA_CONTEXT mediaCtx = nullptr; |
| 465 |
FILE *fpLog = nullptr; |
| 466 |
long suffix = 0; |
| 467 |
struct timeval time = {}; |
| 468 |
VPHAL_RENDER_PARAMS *renderParams = nullptr; |
| 469 |
PDDI_MEDIA_SURFACE mediaSrcSurf = nullptr; |
| 470 |
bool dumpToFile = false; |
| 471 |
PDDI_VP_DUMP_PARAM curDDIParam = nullptr; |
| 472 |
PDDI_VP_DUMP_PARAM preDDIParam = nullptr; |
| 473 |
char env_value[1024] = {}; |
| 474 |
VAProcPipelineParameterBuffer *pipelineParameterBuffer = nullptr; |
| 475 |
|
| 476 |
DDI_VP_FUNC_ENTER; |
| 477 |
DDI_VP_CHK_NULL(vaDrvCtx, "nullptr vaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 478 |
DDI_VP_CHK_NULL(vpCtx, "nullptr vpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT); |
| 479 |
DDI_VP_CHK_NULL(vpCtx->pVpHalRenderParams, "nullptr Render Params.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 480 |
DDI_VP_CHK_NULL(vpCtx->pCurVpDumpDDIParam, "nullptr Dump Params.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 481 |
DDI_VP_CHK_NULL(vpCtx->pPreVpDumpDDIParam, "nullptr Dump Params.", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 482 |
|
| 483 |
for (uint32_t index = 0; index < vpCtx->pVpHalRenderParams->uDstCount; index++) |
| 484 |
{ |
| 485 |
vpCtx->pCurVpDumpDDIParam->TargetFormat[index] = vpCtx->pVpHalRenderParams->pTarget[index]->Format; |
| 486 |
} |
| 487 |
|
| 488 |
curDDIParam = vpCtx->pCurVpDumpDDIParam; |
| 489 |
preDDIParam = vpCtx->pPreVpDumpDDIParam; |
| 490 |
|
| 491 |
// If current ddi param is same with the previous, don't dump into file. |
| 492 |
dumpToFile = VpCmpDDIDumpParam(curDDIParam, preDDIParam); |
| 493 |
if (dumpToFile) |
| 494 |
{ |
| 495 |
return VA_STATUS_SUCCESS; |
| 496 |
} |
| 497 |
|
| 498 |
mediaCtx = GetMediaContext(vaDrvCtx); |
| 499 |
renderParams = vpCtx->pVpHalRenderParams; |
| 500 |
|
| 501 |
gettimeofday(&time, nullptr); |
| 502 |
suffix = ((long)time.tv_sec) * 1000 + (long)time.tv_usec / 1000; |
| 503 |
|
| 504 |
if (vpCtx->fpDumpFile == nullptr) |
| 505 |
{ |
| 506 |
const char *traceName = "VPDDI_TRACE"; |
| 507 |
if (VpParseLogConfig(traceName, &env_value[0]) == 0) |
| 508 |
{ |
| 509 |
int32_t tmp = strnlen(env_value, sizeof(env_value)); |
| 510 |
int32_t left = sizeof(env_value) - tmp; |
| 511 |
snprintf(env_value + tmp, left, "%ld", suffix); |
| 512 |
MosUtilities::MosSecureFileOpen(&vpCtx->fpDumpFile, env_value, "w"); |
| 513 |
} |
| 514 |
} |
| 515 |
fpLog = vpCtx->fpDumpFile; |
| 516 |
DDI_VP_CHK_NULL(fpLog, "nullptr fpLog", VA_STATUS_SUCCESS); |
| 517 |
|
| 518 |
fprintf(fpLog, "\t-------------------------------\n"); |
| 519 |
fprintf(fpLog, "\tTargetFormat Count = %d\n", renderParams->uDstCount); |
| 520 |
for (uint32_t dstIndex = 0; dstIndex < renderParams->uDstCount; dstIndex++) |
| 521 |
{ |
| 522 |
fprintf(fpLog, "\tTargetFormat = %d\n", (int32_t)(curDDIParam->TargetFormat[dstIndex])); |
| 523 |
} |
| 524 |
for (uint32_t surfIndex = 0; surfIndex < renderParams->uSrcCount; surfIndex++) |
| 525 |
{ |
| 526 |
pipelineParameterBuffer = curDDIParam->pPipelineParamBuffers[surfIndex]; |
| 527 |
if (pipelineParameterBuffer) |
| 528 |
{ |
| 529 |
VpDumpProcFiltersParameterBufferSurface(fpLog, pipelineParameterBuffer, curDDIParam->SrcFormat[surfIndex]); |
| 530 |
|
| 531 |
VpDumpProcFiltersParameterBuffer(fpLog, vaDrvCtx, pipelineParameterBuffer->filters, pipelineParameterBuffer->num_filters); |
| 532 |
|
| 533 |
VpDumpProcFiltersParameterBufferFWDReference(fpLog, pipelineParameterBuffer->forward_references, pipelineParameterBuffer->num_forward_references); |
| 534 |
|
| 535 |
VpDumpProcFiltersParameterBufferBKWReference(fpLog, pipelineParameterBuffer->backward_references, pipelineParameterBuffer->num_backward_references); |
| 536 |
|
| 537 |
fprintf(fpLog, "\t rotation_state = %d\n", pipelineParameterBuffer->rotation_state); |
| 538 |
if (pipelineParameterBuffer->blend_state) |
| 539 |
{ |
| 540 |
fprintf(fpLog, "\t blend_state\n"); |
| 541 |
fprintf(fpLog, "\t flags = %d\n", pipelineParameterBuffer->blend_state->flags); |
| 542 |
fprintf(fpLog, "\t global_alpha = %f\n", pipelineParameterBuffer->blend_state->global_alpha); |
| 543 |
fprintf(fpLog, "\t min_luma = %f\n", pipelineParameterBuffer->blend_state->min_luma); |
| 544 |
fprintf(fpLog, "\t max_luma = %f\n", pipelineParameterBuffer->blend_state->max_luma); |
| 545 |
} |
| 546 |
|
| 547 |
fprintf(fpLog, "\t mirror_state = %d\n", pipelineParameterBuffer->mirror_state); |
| 548 |
//fprintf(fpLog, "\t additional_outputs = 0x%08x\n", (unsigned int32_t)(*(p->additional_outputs))); |
| 549 |
fprintf(fpLog, "\t num_additional_outputs = %d\n", pipelineParameterBuffer->num_additional_outputs); |
| 550 |
#if (VA_MAJOR_VERSION < 1) |
| 551 |
fprintf(fpLog, "\t chroma_siting_flag = %d\n", pipelineParameterBuffer->input_surface_flag & 0x3); |
| 552 |
#else |
| 553 |
fprintf(fpLog, "\t chroma_siting_flag = %d\n", pipelineParameterBuffer->input_color_properties.chroma_sample_location & 0x3); |
| 554 |
#endif |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
MOS_SecureMemcpy(preDDIParam->SrcFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_SOURCES, curDDIParam->SrcFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_SOURCES); |
| 559 |
MOS_SecureMemcpy(preDDIParam->TargetFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_TARGETS, curDDIParam->TargetFormat, sizeof(MOS_FORMAT) * VPHAL_MAX_TARGETS); |
| 560 |
for (uint32_t surfIndex = 0; surfIndex < VPHAL_MAX_SOURCES; surfIndex++) |
| 561 |
{ |
| 562 |
MOS_SecureMemcpy(preDDIParam->pPipelineParamBuffers[surfIndex], sizeof(VAProcPipelineParameterBuffer), curDDIParam->pPipelineParamBuffers[surfIndex], sizeof(VAProcPipelineParameterBuffer)); |
| 563 |
} |
| 564 |
|
| 565 |
return VA_STATUS_SUCCESS; |
| 566 |
} |
| 567 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |