1 /*
2 * Copyright (c) 2021-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 media_libva_caps_next.cpp
24 //! \brief This file implements the base C++ class/interface for media capbilities.
25 //!
26
27 #include "media_libva_caps_next.h"
28
MediaLibvaCapsNext(DDI_MEDIA_CONTEXT * mediaCtx)29 MediaLibvaCapsNext::MediaLibvaCapsNext(DDI_MEDIA_CONTEXT *mediaCtx)
30 {
31 DDI_FUNC_ENTER;
32 DDI_CHK_NULL(mediaCtx, "Media context is null", );
33 m_mediaCtx = mediaCtx;
34
35 m_capsTable = MOS_New(MediaCapsTableSpecific, mediaCtx->m_hwInfo->GetDeviceInfo());
36 DDI_CHK_NULL(m_capsTable, "Caps table is null", );
37 }
38
~MediaLibvaCapsNext()39 MediaLibvaCapsNext::~MediaLibvaCapsNext()
40 {
41 DDI_FUNC_ENTER;
42 MOS_Delete(m_capsTable);
43 m_capsTable = nullptr;
44 }
45
CreateCaps(DDI_MEDIA_CONTEXT * mediaCtx)46 MediaLibvaCapsNext* MediaLibvaCapsNext::CreateCaps(DDI_MEDIA_CONTEXT *mediaCtx)
47 {
48 DDI_FUNC_ENTER;
49
50 if(mediaCtx != nullptr)
51 {
52 MediaLibvaCapsNext *caps = MOS_New(MediaLibvaCapsNext, mediaCtx);
53 return caps;
54 }
55 else
56 {
57 return nullptr;
58 }
59 }
60
Init()61 VAStatus MediaLibvaCapsNext::Init()
62 {
63 DDI_FUNC_ENTER;
64
65 return m_capsTable->Init(m_mediaCtx);
66 }
67
GetConfigList()68 ConfigList* MediaLibvaCapsNext::GetConfigList()
69 {
70 return m_capsTable->GetConfigList();
71 }
72
GetAttribValue(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttribType type,uint32_t * value)73 VAStatus MediaLibvaCapsNext::GetAttribValue(
74 VAProfile profile,
75 VAEntrypoint entrypoint,
76 VAConfigAttribType type,
77 uint32_t *value)
78 {
79 DDI_FUNC_ENTER;
80
81 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
82 DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
83
84 AttribList *attribList = nullptr;
85 attribList = m_capsTable->QuerySupportedAttrib(profile, entrypoint);
86 DDI_CHK_NULL(attribList, "AttribList in null, not supported attribute", VA_STATUS_ERROR_INVALID_PARAMETER);
87
88 for (int i = 0; i < attribList->size(); i++)
89 {
90 if(attribList->at(i).type == type)
91 {
92 *value = attribList->at(i).value;
93 return VA_STATUS_SUCCESS;
94 }
95 }
96 return VA_STATUS_ERROR_INVALID_CONFIG;
97 }
98
GetImageFormatsMaxNum()99 uint32_t MediaLibvaCapsNext::GetImageFormatsMaxNum()
100 {
101 DDI_FUNC_ENTER;
102 DDI_CHK_NULL(m_capsTable, "Caps table is null", 0);
103
104 return m_capsTable->GetImageFormatsMaxNum();
105 }
106
QueryConfigProfiles(VAProfile * profileList,int32_t * profilesNum)107 VAStatus MediaLibvaCapsNext::QueryConfigProfiles(
108 VAProfile *profileList,
109 int32_t *profilesNum)
110 {
111 DDI_FUNC_ENTER;
112
113 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
114 DDI_CHK_NULL(profileList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
115 DDI_CHK_NULL(profilesNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
116
117 return m_capsTable->QueryConfigProfiles(profileList, profilesNum);
118 }
119
QueryConfigAttributes(VAConfigID configId,VAProfile * profile,VAEntrypoint * entrypoint,VAConfigAttrib * attribList,int32_t * numAttribs)120 VAStatus MediaLibvaCapsNext::QueryConfigAttributes(
121 VAConfigID configId,
122 VAProfile *profile,
123 VAEntrypoint *entrypoint,
124 VAConfigAttrib *attribList,
125 int32_t *numAttribs)
126 {
127 DDI_FUNC_ENTER;
128
129 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
130 DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
131 DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
132 DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
133 DDI_CHK_NULL(numAttribs, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
134
135 VAStatus status = VA_STATUS_SUCCESS;
136 ConfigLinux *configItem = nullptr;
137 configItem = m_capsTable->QueryConfigItemFromIndex(configId);
138 DDI_CHK_NULL(configItem, "QueryConfigItemFromIndex failed", VA_STATUS_ERROR_INVALID_PARAMETER);
139
140 *profile = configItem->profile;
141 *entrypoint = configItem->entrypoint;
142 *numAttribs = configItem->numAttribs;
143 for (int i = 0; i < configItem->numAttribs; ++i)
144 {
145 if (configItem->attribList[i].value != VA_ATTRIB_NOT_SUPPORTED)
146 {
147 attribList[i] = configItem->attribList[i];
148 }
149 }
150 return VA_STATUS_SUCCESS;
151 }
152
CheckAttribList(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttrib * attrib,int32_t numAttribs)153 VAStatus MediaLibvaCapsNext::CheckAttribList(
154 VAProfile profile,
155 VAEntrypoint entrypoint,
156 VAConfigAttrib *attrib,
157 int32_t numAttribs)
158 {
159 DDI_FUNC_ENTER;
160
161 VAStatus status = VA_STATUS_SUCCESS;
162 AttribList *supportedAttribList = nullptr;
163 supportedAttribList = m_capsTable->QuerySupportedAttrib(profile, entrypoint);
164 DDI_CHK_NULL(supportedAttribList, "AttribList in null, not supported attribute", VA_STATUS_ERROR_INVALID_PARAMETER);
165
166 for(int32_t j = 0; j < numAttribs; j ++)
167 {
168 bool isValidAttrib = false;
169
170 // temp solution for MV tools, after tool change, it should be removed
171 if(attrib[j].type == VAConfigAttribEncDynamicScaling ||
172 attrib[j].type == VAConfigAttribEncRateControlExt ||
173 attrib[j].type == VAConfigAttribEncTileSupport)
174 {
175 if(attrib[j].value == VA_ATTRIB_NOT_SUPPORTED)
176 {
177 isValidAttrib = true;
178 continue;
179 }
180 }
181
182 bool findSameType = false;
183 for(int i = 0; i < supportedAttribList->size(); i++)
184 {
185 // Same attribute type
186 findSameType = true;
187 if(supportedAttribList->at(i).type == attrib[j].type)
188 {
189 if(attrib[j].value == CONFIG_ATTRIB_NONE)
190 {
191 isValidAttrib = true;
192 continue;
193 }
194
195 if(attrib[j].type == VAConfigAttribRTFormat ||
196 attrib[j].type == VAConfigAttribDecSliceMode ||
197 attrib[j].type == VAConfigAttribDecJPEG ||
198 attrib[j].type == VAConfigAttribRateControl ||
199 attrib[j].type == VAConfigAttribEncPackedHeaders ||
200 attrib[j].type == VAConfigAttribEncIntraRefresh ||
201 attrib[j].type == VAConfigAttribFEIFunctionType ||
202 attrib[j].type == VAConfigAttribEncryption)
203 {
204 if((supportedAttribList->at(i).value & attrib[j].value) == attrib[j].value)
205 {
206 isValidAttrib = true;
207 continue;
208 }
209 else if(attrib[j].type == VAConfigAttribRTFormat)
210 {
211 return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
212 }
213 }
214 else if(supportedAttribList->at(i).value == attrib[j].value)
215 {
216 isValidAttrib = true;
217 continue;
218 }
219 else if(attrib[j].type == VAConfigAttribEncSliceStructure)
220 {
221 if((supportedAttribList->at(i).value & attrib[j].value) == attrib[j].value)
222 {
223 isValidAttrib = true;
224 continue;
225 }
226
227 if(supportedAttribList->at(i).value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS)
228 {
229 if( (attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS) ||
230 (attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS) ||
231 (attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) ||
232 (attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS))
233 {
234 isValidAttrib = true;
235 continue;
236 }
237 }
238 else if (supportedAttribList->at(i).value &
239 (VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE))
240 {
241 if((attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) ||
242 (attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) ||
243 (attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS))
244 {
245 isValidAttrib = true;
246 continue;
247 }
248 }
249 }
250 else if((attrib[j].type == VAConfigAttribMaxPictureWidth) ||
251 (attrib[j].type == VAConfigAttribMaxPictureHeight) ||
252 (attrib[j].type == VAConfigAttribEncROI) ||
253 (attrib[j].type == VAConfigAttribEncDirtyRect))
254 {
255 if(attrib[j].value <= supportedAttribList->at(i).value)
256 {
257 isValidAttrib = true;
258 continue;
259 }
260 }
261 else if(attrib[j].type == VAConfigAttribEncMaxRefFrames)
262 {
263 if( ((attrib[j].value & 0xffff) <= (supportedAttribList->at(i).value & 0xffff)) &&
264 (attrib[j].value <= supportedAttribList->at(i).value)) //high16 bit can compare with this way
265 {
266 isValidAttrib = true;
267 continue;
268 }
269 }
270 else if(attrib[j].type == VAConfigAttribEncJPEG)
271 {
272 VAConfigAttribValEncJPEG jpegValue, jpegSetValue;
273 jpegValue.value = attrib[j].value;
274 jpegSetValue.value = supportedAttribList->at(i).value;
275
276 if( (jpegValue.bits.max_num_quantization_tables <= jpegSetValue.bits.max_num_quantization_tables) &&
277 (jpegValue.bits.max_num_huffman_tables <= jpegSetValue.bits.max_num_huffman_tables) &&
278 (jpegValue.bits.max_num_scans <= jpegSetValue.bits.max_num_scans) &&
279 (jpegValue.bits.max_num_components <= jpegSetValue.bits.max_num_components))
280 {
281 isValidAttrib = true;
282 continue;
283 }
284 }
285 }
286 }
287
288 // should be removed after msdk remove VAConfigAttribSpatialResidual attributes for VPP
289 if(!findSameType)
290 {
291 if((profile == VAProfileNone) &&
292 (entrypoint == VAEntrypointVideoProc) &&
293 (attrib[j].type == VAConfigAttribSpatialClipping))
294 {
295 isValidAttrib = true;
296 continue;
297 }
298 else if((profile == VAProfileNone) &&
299 (attrib[j].type == VAConfigAttribStats))
300 {
301 isValidAttrib = true;
302 continue;
303 }
304 }
305
306 if(!isValidAttrib)
307 {
308 return VA_STATUS_ERROR_INVALID_VALUE;
309 }
310 }
311
312 return VA_STATUS_SUCCESS;
313 }
314
CreateConfig(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttrib * attribList,int32_t numAttribs,VAConfigID * configId)315 VAStatus MediaLibvaCapsNext::CreateConfig(
316 VAProfile profile,
317 VAEntrypoint entrypoint,
318 VAConfigAttrib *attribList,
319 int32_t numAttribs,
320 VAConfigID *configId)
321 {
322 VAStatus status = VA_STATUS_SUCCESS;
323 DDI_FUNC_ENTER;
324
325 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
326 DDI_CHK_NULL(configId, "nullptr configId", VA_STATUS_ERROR_INVALID_PARAMETER);
327
328 status = m_capsTable->CreateConfig(profile, entrypoint, attribList, numAttribs, configId);
329 if(status != VA_STATUS_SUCCESS)
330 {
331 DDI_ASSERTMESSAGE("Query Supported Attrib Failed");
332 return status;
333 }
334
335 return CheckAttribList(profile, entrypoint, attribList, numAttribs);
336 }
337
DestroyConfig(VAConfigID configId)338 VAStatus MediaLibvaCapsNext::DestroyConfig(VAConfigID configId)
339 {
340 DDI_FUNC_ENTER;
341
342 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
343
344 return m_capsTable->DestroyConfig(configId);
345 }
346
GetConfigAttributes(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttrib * attribList,int32_t numAttribs)347 VAStatus MediaLibvaCapsNext::GetConfigAttributes(
348 VAProfile profile,
349 VAEntrypoint entrypoint,
350 VAConfigAttrib *attribList,
351 int32_t numAttribs)
352 {
353 DDI_FUNC_ENTER;
354
355 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
356 DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
357
358 AttribList *supportedAttribList = nullptr;
359 supportedAttribList = m_capsTable->QuerySupportedAttrib(profile, entrypoint);
360 DDI_CHK_NULL(supportedAttribList, "AttribList in null, not supported attribute", VA_STATUS_ERROR_INVALID_PARAMETER);
361
362 for (int32_t j = 0; j < numAttribs; j++)
363 {
364 //For unknown attribute, set to VA_ATTRIB_NOT_SUPPORTED
365 attribList[j].value = VA_ATTRIB_NOT_SUPPORTED;
366
367 for(int32_t i = 0; i < supportedAttribList->size(); i++)
368 {
369 if(attribList[j].type == supportedAttribList->at(i).type)
370 {
371 attribList[j].value = supportedAttribList->at(i).value;
372 break;
373 }
374 else
375 {
376 GetGeneralConfigAttrib(&attribList[j]);
377 }
378 }
379 }
380 return VA_STATUS_SUCCESS;
381 }
382
GetGeneralConfigAttrib(VAConfigAttrib * attrib)383 VAStatus MediaLibvaCapsNext::GetGeneralConfigAttrib(VAConfigAttrib *attrib)
384 {
385 static const std::map<VAConfigAttribType, uint32_t> generalAttribMap = {
386 #if VA_CHECK_VERSION(1, 10, 0)
387 {VAConfigAttribContextPriority, CONTEXT_PRIORITY_MAX},
388 #endif
389 };
390
391 DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
392 if (generalAttribMap.find(attrib->type) != generalAttribMap.end())
393 {
394 attrib->value = CONTEXT_PRIORITY_MAX;
395 }
396
397 return VA_STATUS_SUCCESS;
398 }
399
QueryConfigEntrypoints(VAProfile profile,VAEntrypoint * entrypointList,int32_t * entrypointNum)400 VAStatus MediaLibvaCapsNext::QueryConfigEntrypoints(
401 VAProfile profile,
402 VAEntrypoint *entrypointList,
403 int32_t *entrypointNum)
404 {
405 DDI_FUNC_ENTER;
406
407 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
408 DDI_CHK_NULL(entrypointList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
409 DDI_CHK_NULL(entrypointNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
410
411 EntrypointMap *entryMap = nullptr;
412 VAStatus status = VA_STATUS_SUCCESS;
413
414 entryMap = m_capsTable->QueryConfigEntrypointsMap(profile);
415 DDI_CHK_NULL(entryMap, "QueryConfigEntrypointsMap failed", VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
416
417 int i = 0;
418 for (auto it = entryMap->begin(); it!=entryMap->end(); ++it)
419 {
420 entrypointList[i] = (VAEntrypoint)(it->first);
421 i++;
422 }
423
424 *entrypointNum = entryMap->size();
425 return VA_STATUS_SUCCESS;
426 }
427
QuerySurfaceAttributes(VAConfigID configId,VASurfaceAttrib * attribList,uint32_t * numAttribs)428 VAStatus MediaLibvaCapsNext::QuerySurfaceAttributes(
429 VAConfigID configId,
430 VASurfaceAttrib *attribList,
431 uint32_t *numAttribs)
432 {
433 DDI_FUNC_ENTER;
434
435 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
436 DDI_CHK_NULL(numAttribs, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
437
438 if (attribList == nullptr)
439 {
440 *numAttribs = DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES;
441 return VA_STATUS_SUCCESS;
442 }
443
444 ProfileSurfaceAttribInfo *surfaceAttribInfo = nullptr;
445 VAStatus status = VA_STATUS_SUCCESS;
446
447 surfaceAttribInfo = m_capsTable->QuerySurfaceAttributesFromConfigId(configId);
448 DDI_CHK_NULL(surfaceAttribInfo, "QuerySurfaceAttributesFromConfigId failed", VA_STATUS_ERROR_INVALID_PARAMETER);
449
450 VASurfaceAttrib *attribs = (VASurfaceAttrib *)MOS_AllocAndZeroMemory(DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES * sizeof(*attribs));
451 if (attribs == nullptr)
452 {
453 return VA_STATUS_ERROR_ALLOCATION_FAILED;
454 }
455
456 int i = 0;
457 for (uint32_t j = 0; j < surfaceAttribInfo->size(); j++)
458 {
459 attribs[i].type = surfaceAttribInfo->at(j).type1;
460 attribs[i].flags = surfaceAttribInfo->at(j).flags;
461 attribs[i].value.type = surfaceAttribInfo->at(j).value.type;
462 if(attribs[i].value.type == VAGenericValueTypeInteger)
463 {
464 attribs[i].value.value.i = surfaceAttribInfo->at(j).value.value.i;
465 }
466 else if(attribs[i].value.type == VAGenericValueTypePointer)
467 {
468 attribs[i].value.value.p = surfaceAttribInfo->at(j).value.value.p;
469 }
470 else
471 {
472 DDI_ASSERTMESSAGE("Invalid VAGenericValueType");
473 MOS_FreeMemory(attribs);
474 return VA_STATUS_ERROR_UNIMPLEMENTED;
475 }
476 ++i;
477 }
478
479 if (i > *numAttribs)
480 {
481 *numAttribs = i;
482 MOS_FreeMemory(attribs);
483 return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
484 }
485
486 *numAttribs = i;
487 MOS_SecureMemcpy(attribList, i * sizeof(*attribs), attribs, i * sizeof(*attribs));
488 MOS_FreeMemory(attribs);
489
490 return status;
491 }
492
QueryImageFormats(VAImageFormat * formatList,int32_t * numFormats)493 VAStatus MediaLibvaCapsNext::QueryImageFormats(
494 VAImageFormat *formatList,
495 int32_t *numFormats)
496 {
497 DDI_FUNC_ENTER;
498
499 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
500 DDI_CHK_NULL(formatList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
501 DDI_CHK_NULL(numFormats, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
502
503 int num = 0;
504 auto imgTbl = m_capsTable->GetImgTable();
505 MOS_ZeroMemory(formatList, sizeof(VAImageFormat) * imgTbl->size());
506
507 for(auto imgTblIter : *imgTbl)
508 {
509 formatList[num].fourcc = imgTblIter.first;
510 auto imageFormatInfo = imgTblIter.second;
511 DDI_CHK_NULL(imageFormatInfo, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
512
513 formatList[num].byte_order = imageFormatInfo->byte_order;
514 formatList[num].bits_per_pixel = imageFormatInfo->bits_per_pixel;
515 formatList[num].depth = imageFormatInfo->depth;
516 formatList[num].red_mask = imageFormatInfo->red_mask;
517 formatList[num].green_mask = imageFormatInfo->green_mask;
518 formatList[num].blue_mask = imageFormatInfo->blue_mask;
519 formatList[num].alpha_mask = imageFormatInfo->alpha_mask;
520
521 num++;
522 }
523
524 *numFormats = num;
525 return VA_STATUS_SUCCESS;
526 }
527
PopulateColorMaskInfo(VAImageFormat * vaImgFmt)528 VAStatus MediaLibvaCapsNext::PopulateColorMaskInfo(VAImageFormat *vaImgFmt)
529 {
530 DDI_FUNC_ENTER;
531
532 DDI_CHK_NULL(m_capsTable, "Caps table is null", VA_STATUS_ERROR_INVALID_PARAMETER);
533 DDI_CHK_NULL(vaImgFmt, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
534
535 auto imgTbl = m_capsTable->GetImgTable();
536
537 if(imgTbl->find(vaImgFmt->fourcc) == imgTbl->end())
538 {
539 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
540 }
541
542 auto imageFormatInfo = imgTbl->at(vaImgFmt->fourcc);
543 DDI_CHK_NULL(imageFormatInfo, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
544
545 vaImgFmt->red_mask = imageFormatInfo->red_mask;
546 vaImgFmt->green_mask = imageFormatInfo->green_mask;
547 vaImgFmt->blue_mask = imageFormatInfo->blue_mask;
548 vaImgFmt->alpha_mask = imageFormatInfo->alpha_mask;
549
550 return VA_STATUS_SUCCESS;
551 }
552
553
QueryDisplayAttributes(VADisplayAttribute * attribList,int32_t * attributesNum)554 VAStatus MediaLibvaCapsNext::QueryDisplayAttributes(
555 VADisplayAttribute *attribList,
556 int32_t *attributesNum)
557 {
558 DDI_FUNC_ENTER;
559
560 DDI_CHK_NULL(attribList, "Null attribList", VA_STATUS_ERROR_INVALID_PARAMETER);
561 DDI_CHK_NULL(attributesNum, "Null attribs", VA_STATUS_ERROR_INVALID_PARAMETER);
562 VADisplayAttribute * attrib = attribList;
563 *attributesNum = 0;
564
565 attrib->type = VADisplayAttribCopy;
566 (*attributesNum) ++;
567
568 #if VA_CHECK_VERSION(1, 15, 0)
569 attrib ++;
570
571 attrib->type = VADisplayPCIID;
572 (*attributesNum) ++;
573 #endif
574
575 return GetDisplayAttributes(attribList, *attributesNum);
576 }
577
GetDisplayAttributes(VADisplayAttribute * attribList,int32_t attributesNum)578 VAStatus MediaLibvaCapsNext::GetDisplayAttributes(
579 VADisplayAttribute *attribList,
580 int32_t attributesNum)
581 {
582 DDI_FUNC_ENTER;
583 DDI_CHK_NULL(attribList, "Null attribList", VA_STATUS_ERROR_INVALID_PARAMETER);
584
585 for(auto i = 0; i < attributesNum; i ++)
586 {
587 switch(attribList->type)
588 {
589 case VADisplayAttribCopy:
590 attribList->min_value = attribList->value = attribList->max_value = 0;
591 attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE;
592 break;
593 #if VA_CHECK_VERSION(1, 15, 0)
594 case VADisplayPCIID:
595 attribList->min_value = attribList->value = attribList->max_value = (m_mediaCtx->iDeviceId & 0xffff) | 0x80860000;
596 attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE;
597 break;
598 #endif
599 default:
600 attribList->min_value = VA_ATTRIB_NOT_SUPPORTED;
601 attribList->max_value = VA_ATTRIB_NOT_SUPPORTED;
602 attribList->value = VA_ATTRIB_NOT_SUPPORTED;
603 attribList->flags = VA_DISPLAY_ATTRIB_NOT_SUPPORTED;
604 break;
605 }
606 attribList ++;
607 }
608 return VA_STATUS_SUCCESS;
609 }
610