1 /*
2 * Copyright (c) 2017-2021, 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_g10.cpp
24 //! \brief This file implements the C++ class/interface for gen10 media capbilities.
25 //!
26
27 #include "codec_def_encode_hevc_g10.h"
28 #include "media_libva_util.h"
29 #include "media_libva.h"
30 #include "media_libva_caps_cp_interface.h"
31 #include "media_libva_caps_g10.h"
32 #include "media_libva_caps_factory.h"
33
34 const VAImageFormat m_supportedImageformatsG10[] =
35 { {VA_FOURCC_BGRA, VA_LSB_FIRST, 32, 32, 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff}, /* [31:0] B:G:R:A 8:8:8:8 little endian */
36 {VA_FOURCC_ARGB, VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, /* [31:0] A:R:G:B 8:8:8:8 little endian */
37 {VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff}, /* [31:0] R:G:B:A 8:8:8:8 little endian */
38 {VA_FOURCC_ABGR, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, /* [31:0] A:B:G:R 8:8:8:8 little endian */
39 {VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x0000ff00, 0x00ff0000, 0xff000000, 0}, /* [31:0] B:G:R:x 8:8:8:8 little endian */
40 {VA_FOURCC_XRGB, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0}, /* [31:0] x:R:G:B 8:8:8:8 little endian */
41 {VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0xff000000, 0x00ff0000, 0x0000ff00, 0}, /* [31:0] R:G:B:x 8:8:8:8 little endian */
42 {VA_FOURCC_XBGR, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0}, /* [31:0] x:B:G:R 8:8:8:8 little endian */
43 {VA_FOURCC_A2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0x30000000}, /* [31:0] A:R:G:B 2:10:10:10 little endian */
44 {VA_FOURCC_A2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0x30000000}, /* [31:0] A:B:G:R 2:10:10:10 little endian */
45 {VA_FOURCC_X2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0}, /* [31:0] X:R:G:B 2:10:10:10 little endian */
46 {VA_FOURCC_X2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0}, /* [31:0] X:B:G:R 2:10:10:10 little endian */
47 {VA_FOURCC_RGB565, VA_LSB_FIRST, 16, 16, 0xf800, 0x07e0, 0x001f, 0}, /* [15:0] R:G:B 5:6:5 little endian */
48 {VA_FOURCC_AYUV, VA_LSB_FIRST, 32, 0,0,0,0,0},
49 {VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0},
50 {VA_FOURCC_NV12, VA_LSB_FIRST, 12, 0,0,0,0,0},
51 {VA_FOURCC_NV21, VA_LSB_FIRST, 12, 0,0,0,0,0},
52 {VA_FOURCC_YUY2, VA_LSB_FIRST, 16, 0,0,0,0,0},
53 {VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0},
54 {VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0},
55 {VA_FOURCC_I420, VA_LSB_FIRST, 12, 0,0,0,0,0},
56 {VA_FOURCC_411P, VA_LSB_FIRST, 12, 0,0,0,0,0},
57 {VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0},
58 {VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0},
59 {VA_FOURCC_444P, VA_LSB_FIRST, 24, 0,0,0,0,0},
60 {VA_FOURCC_IMC3, VA_LSB_FIRST, 16, 0,0,0,0,0},
61 {VA_FOURCC_P010, VA_LSB_FIRST, 24, 0,0,0,0,0}
62 };
63
QueryImageFormats(VAImageFormat * formatList,int32_t * numFormats)64 VAStatus MediaLibvaCapsG10::QueryImageFormats(VAImageFormat *formatList, int32_t *numFormats)
65 {
66 DDI_CHK_NULL(formatList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
67 DDI_CHK_NULL(numFormats, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
68 int32_t num = 0;
69 uint32_t maxNum = GetImageFormatsMaxNum();
70
71 memset(formatList, 0, sizeof(m_supportedImageformatsG10));
72 for (uint32_t idx = 0; idx < maxNum; idx++)
73 {
74 formatList[num].fourcc = m_supportedImageformatsG10[idx].fourcc;
75 formatList[num].byte_order = m_supportedImageformatsG10[idx].byte_order;
76 formatList[num].bits_per_pixel = m_supportedImageformatsG10[idx].bits_per_pixel;
77 formatList[num].depth = m_supportedImageformatsG10[idx].depth;
78 formatList[num].red_mask = m_supportedImageformatsG10[idx].red_mask;
79 formatList[num].green_mask = m_supportedImageformatsG10[idx].green_mask;
80 formatList[num].blue_mask = m_supportedImageformatsG10[idx].blue_mask;
81 formatList[num].alpha_mask = m_supportedImageformatsG10[idx].alpha_mask;
82 num++;
83 }
84 *numFormats = num;
85
86 return VA_STATUS_SUCCESS;
87 }
88
GetImageFormatsMaxNum()89 uint32_t MediaLibvaCapsG10::GetImageFormatsMaxNum()
90 {
91 return sizeof(m_supportedImageformatsG10)/sizeof(m_supportedImageformatsG10[0]);
92 }
93
IsImageSupported(uint32_t fourcc)94 bool MediaLibvaCapsG10::IsImageSupported(uint32_t fourcc)
95 {
96 uint32_t maxNum = GetImageFormatsMaxNum();
97 for (int32_t idx = 0; idx < maxNum; idx++)
98 {
99 if (m_supportedImageformatsG10[idx].fourcc == fourcc)
100 {
101 return true;
102 }
103 }
104
105 return false;
106 }
107
PopulateColorMaskInfo(VAImageFormat * vaImgFmt)108 VAStatus MediaLibvaCapsG10::PopulateColorMaskInfo(VAImageFormat *vaImgFmt)
109 {
110 uint32_t maxNum = GetImageFormatsMaxNum();
111
112 DDI_CHK_NULL(vaImgFmt, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
113
114 for (int32_t idx = 0; idx < maxNum; idx++)
115 {
116 if (m_supportedImageformatsG10[idx].fourcc == vaImgFmt->fourcc)
117 {
118 vaImgFmt->red_mask = m_supportedImageformatsG10[idx].red_mask;
119 vaImgFmt->green_mask = m_supportedImageformatsG10[idx].green_mask;
120 vaImgFmt->blue_mask = m_supportedImageformatsG10[idx].blue_mask;
121 vaImgFmt->alpha_mask = m_supportedImageformatsG10[idx].alpha_mask;
122
123 return VA_STATUS_SUCCESS;
124 }
125 }
126
127 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
128 }
129
GetPlatformSpecificAttrib(VAProfile profile,VAEntrypoint entrypoint,VAConfigAttribType type,uint32_t * value)130 VAStatus MediaLibvaCapsG10::GetPlatformSpecificAttrib(VAProfile profile,
131 VAEntrypoint entrypoint,
132 VAConfigAttribType type,
133 uint32_t *value)
134 {
135 DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
136 VAStatus status = VA_STATUS_SUCCESS;
137 *value = VA_ATTRIB_NOT_SUPPORTED;
138 switch ((int)type)
139 {
140 case VAConfigAttribEncMaxRefFrames:
141 {
142 if (entrypoint == VAEntrypointEncSliceLP || !IsHevcProfile(profile))
143 {
144 status = VA_STATUS_ERROR_INVALID_PARAMETER;
145 }
146 else
147 {
148 *value = ENCODE_DP_HEVC_NUM_MAX_VME_L0_REF_G10 | (ENCODE_DP_HEVC_NUM_MAX_VME_L1_REF_G10 << 16);;
149 }
150 break;
151 }
152 case VAConfigAttribDecProcessing:
153 {
154 #ifdef _DECODE_PROCESSING_SUPPORTED
155 if (IsAvcProfile(profile) || IsHevcProfile(profile))
156 {
157 *value = VA_DEC_PROCESSING;
158 }
159 else
160 #endif
161 {
162 *value = VA_DEC_PROCESSING_NONE;
163 }
164 break;
165 }
166 case VAConfigAttribEncIntraRefresh:
167 {
168 if(IsAvcProfile(profile))
169 {
170 *value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN |
171 VA_ENC_INTRA_REFRESH_ROLLING_ROW;
172 }
173 else
174 {
175 *value = VA_ENC_INTRA_REFRESH_NONE;
176 }
177 break;
178 }
179 case VAConfigAttribEncROI:
180 {
181 VAConfigAttribValEncROI roi_attr = { .value = 0 };
182
183 if (entrypoint == VAEntrypointEncSliceLP)
184 {
185 status = VA_STATUS_ERROR_INVALID_PARAMETER;
186 }
187 else if (IsAvcProfile(profile))
188 {
189 // the capacity is differnt for CQP and BRC mode, set it as larger one here
190 roi_attr.bits.num_roi_regions = ENCODE_DP_AVC_MAX_ROI_NUM_BRC;
191 roi_attr.bits.roi_rc_priority_support = 0;
192 roi_attr.bits.roi_rc_qp_delta_support = 1;
193 }
194
195 *value = roi_attr.value;
196 break;
197 }
198 case VAConfigAttribCustomRoundingControl:
199 {
200 *value = 0;
201 break;
202 }
203 case VAConfigAttribEncMaxSlices:
204 {
205 if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile))
206 {
207 *value = CODECHAL_HEVC_MAX_NUM_SLICES_LVL_5;
208 }
209 else
210 {
211 *value =0;
212 status = VA_STATUS_ERROR_INVALID_PARAMETER;
213 }
214 break;
215 }
216 case VAConfigAttribMaxPictureWidth:
217 {
218 if(profile == VAProfileJPEGBaseline)
219 {
220 *value = ENCODE_JPEG_MAX_PIC_WIDTH;
221 }
222 else if(IsHevcProfile(profile) || IsAvcProfile(profile) || IsVp8Profile(profile))
223 {
224 *value = CODEC_4K_MAX_PIC_WIDTH;
225 }
226 else
227 {
228 *value = CODEC_MAX_PIC_WIDTH;
229 }
230 break;
231 }
232 case VAConfigAttribMaxPictureHeight:
233 {
234 if(profile == VAProfileJPEGBaseline)
235 {
236 *value = ENCODE_JPEG_MAX_PIC_HEIGHT;
237 }
238 else if(IsHevcProfile(profile) || IsAvcProfile(profile) || IsVp8Profile(profile))
239 {
240 *value = CODEC_4K_MAX_PIC_HEIGHT;
241 }
242 else
243 {
244 *value = CODEC_MAX_PIC_HEIGHT;
245 }
246 break;
247 }
248 default:
249 status = VA_STATUS_ERROR_INVALID_PARAMETER;
250 break;
251 }
252 return status;
253 }
254
LoadHevcEncLpProfileEntrypoints()255 VAStatus MediaLibvaCapsG10::LoadHevcEncLpProfileEntrypoints()
256 {
257 VAStatus status = VA_STATUS_SUCCESS;
258
259 #ifdef _HEVC_ENCODE_VDENC_SUPPORTED
260 AttribMap *attributeList = nullptr;
261
262 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain)
263 || MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10))
264 {
265 status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointEncSliceLP, &attributeList);
266 DDI_CHK_RET(status, "Failed to initialize Caps!");
267 }
268
269 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain))
270 {
271 uint32_t configStartIdx = m_encConfigs.size();
272 AddEncConfig(VA_RC_CQP);
273 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))
274 {
275 for (int32_t j = 3; j < 7; j++)
276 {
277 AddEncConfig(m_encRcMode[j]);
278 AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
279 }
280 }
281 AddProfileEntry(VAProfileHEVCMain, VAEntrypointEncSliceLP, attributeList,
282 configStartIdx, m_encConfigs.size() - configStartIdx);
283 }
284
285 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10))
286 {
287 uint32_t configStartIdx = m_encConfigs.size();
288 AddEncConfig(VA_RC_CQP);
289 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))
290 {
291 for (int32_t j = 3; j < 7; j++)
292 {
293 AddEncConfig(m_encRcMode[j]);
294 AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
295 }
296 }
297 AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSliceLP, attributeList,
298 configStartIdx, m_encConfigs.size() - configStartIdx);
299 }
300 #endif
301 return status;
302 }
303
LoadVp9EncProfileEntrypoints()304 VAStatus MediaLibvaCapsG10::LoadVp9EncProfileEntrypoints()
305 {
306 VAStatus status = VA_STATUS_SUCCESS;
307
308 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
309 AttribMap *attributeList;
310 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc) &&
311 MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))
312 {
313 status = CreateEncAttributes(VAProfileVP9Profile0, VAEntrypointEncSliceLP, &attributeList);
314 DDI_CHK_RET(status, "Failed to initialize Caps!");
315
316 uint32_t configStartIdx = m_encConfigs.size();
317 AddEncConfig(VA_RC_CQP);
318 AddEncConfig(VA_RC_CBR);
319 AddEncConfig(VA_RC_VBR);
320 AddProfileEntry(VAProfileVP9Profile0, VAEntrypointEncSliceLP, attributeList,
321 configStartIdx, m_encConfigs.size() - configStartIdx);
322 }
323 #endif
324 return status;
325 }
326
LoadProfileEntrypoints()327 VAStatus MediaLibvaCapsG10::LoadProfileEntrypoints()
328 {
329 VAStatus status = VA_STATUS_SUCCESS;
330 status = LoadAvcDecProfileEntrypoints();
331 DDI_CHK_RET(status, "Failed to initialize Caps!");
332 status = LoadAvcEncProfileEntrypoints();
333 DDI_CHK_RET(status, "Failed to initialize Caps!");
334 status = LoadAvcEncLpProfileEntrypoints();
335 DDI_CHK_RET(status, "Failed to initialize Caps!");
336 status = LoadMpeg2DecProfileEntrypoints();
337 DDI_CHK_RET(status, "Failed to initialize Caps!");
338 status = LoadMpeg2EncProfileEntrypoints();
339 DDI_CHK_RET(status, "Failed to initialize Caps!");
340 status = LoadVc1DecProfileEntrypoints();
341 DDI_CHK_RET(status, "Failed to initialize Caps!");
342 status = LoadJpegDecProfileEntrypoints();
343 DDI_CHK_RET(status, "Failed to initialize Caps!");
344 status = LoadJpegEncProfileEntrypoints();
345 DDI_CHK_RET(status, "Failed to initialize Caps!");
346 status = LoadHevcDecProfileEntrypoints();
347 DDI_CHK_RET(status, "Failed to initialize Caps!");
348 status = LoadHevcEncProfileEntrypoints();
349 DDI_CHK_RET(status, "Failed to initialize Caps!");
350 status = LoadHevcEncLpProfileEntrypoints();
351 DDI_CHK_RET(status, "Failed to initialize Caps!");
352 status = LoadVp8DecProfileEntrypoints();
353 DDI_CHK_RET(status, "Failed to initialize Caps!");
354 status = LoadVp8EncProfileEntrypoints();
355 DDI_CHK_RET(status, "Failed to initialize Caps!");
356 status = LoadVp9DecProfileEntrypoints();
357 DDI_CHK_RET(status, "Failed to initialize Caps!");
358 status = LoadVp9EncProfileEntrypoints();
359 DDI_CHK_RET(status, "Failed to initialize Caps!");
360 #if !defined(_FULL_OPEN_SOURCE) && defined(ENABLE_KERNELS)
361 status = LoadNoneProfileEntrypoints();
362 DDI_CHK_RET(status, "Failed to initialize Caps!");
363 #endif
364 status = m_CapsCp->LoadCpProfileEntrypoints();
365 DDI_CHK_RET(status, "Failed to initialize CP Caps!");
366 return status;
367 }
CheckEncodeResolution(VAProfile profile,uint32_t width,uint32_t height)368 VAStatus MediaLibvaCapsG10::CheckEncodeResolution(
369 VAProfile profile,
370 uint32_t width,
371 uint32_t height)
372 {
373 switch (profile)
374 {
375 case VAProfileJPEGBaseline:
376 if (width > m_encJpegMaxWidth
377 || width < m_encJpegMinWidth
378 || height > m_encJpegMaxHeight
379 || height < m_encJpegMinHeight)
380 {
381 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
382 }
383 break;
384 case VAProfileMPEG2Simple:
385 case VAProfileMPEG2Main:
386 if( width > CODEC_MAX_PIC_WIDTH
387 || width < m_encMinWidth
388 || height > CODEC_MAX_PIC_HEIGHT
389 || height < m_encMinHeight)
390 {
391 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
392 }
393 break;
394 case VAProfileHEVCMain:
395 case VAProfileHEVCMain10:
396 if (width > m_maxHevcEncWidth
397 || width < m_encMinWidth
398 || height > m_maxHevcEncHeight
399 || height < m_encMinHeight)
400 {
401 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
402 }
403 break;
404 case VAProfileVP9Profile0:
405 if ((width > m_encMax4kWidth) ||
406 (width < m_encMinWidth) ||
407 (height > m_encMax4kHeight) ||
408 (height < m_encMinHeight) ||
409 (width % 8) ||
410 (height % 8))
411 {
412 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
413 }
414 break;
415 default:
416 if (width > m_encMax4kWidth
417 || width < m_encMinWidth
418 || height > m_encMax4kHeight
419 || height < m_encMinHeight)
420 {
421 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
422 }
423 break;
424 }
425 return VA_STATUS_SUCCESS;
426 }
427
CheckDecodeResolution(int32_t codecMode,VAProfile profile,uint32_t width,uint32_t height)428 VAStatus MediaLibvaCapsG10::CheckDecodeResolution(
429 int32_t codecMode,
430 VAProfile profile,
431 uint32_t width,
432 uint32_t height)
433 {
434
435 uint32_t maxWidth, maxHeight;
436 switch (codecMode)
437 {
438 case CODECHAL_DECODE_MODE_MPEG2VLD:
439 maxWidth = m_decMpeg2MaxWidth;
440 maxHeight = m_decMpeg2MaxHeight;
441 break;
442 case CODECHAL_DECODE_MODE_VC1VLD:
443 maxWidth = m_decVc1MaxWidth;
444 maxHeight = m_decVc1MaxHeight;
445 break;
446 case CODECHAL_DECODE_MODE_JPEG:
447 maxWidth = m_decJpegMaxWidth;
448 maxHeight = m_decJpegMaxHeight;
449 break;
450 case CODECHAL_DECODE_MODE_HEVCVLD:
451 maxWidth = m_decHevcMaxWidth;
452 maxHeight = m_decHevcMaxHeight;
453 break;
454 case CODECHAL_DECODE_MODE_VP9VLD:
455 maxWidth = m_decVp9MaxWidth;
456 maxHeight = m_decVp9MaxHeight;
457 break;
458 default:
459 maxWidth = m_decDefaultMaxWidth;
460 maxHeight = m_decDefaultMaxHeight;
461 break;
462 }
463
464 uint32_t alignedHeight;
465 if (profile == VAProfileVC1Advanced)
466 {
467 alignedHeight = MOS_ALIGN_CEIL(height,32);
468 }
469 else
470 {
471 alignedHeight = height;
472 }
473
474 if (width > maxWidth || alignedHeight > maxHeight)
475 {
476 return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
477 }
478 else
479 {
480 return VA_STATUS_SUCCESS;
481 }
482 }
483
QueryAVCROIMaxNum(uint32_t rcMode,bool isVdenc,uint32_t * maxNum,bool * isRoiInDeltaQP)484 VAStatus MediaLibvaCapsG10::QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP)
485 {
486 DDI_CHK_NULL(maxNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
487 DDI_CHK_NULL(isRoiInDeltaQP, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
488
489 if(isVdenc)
490 {
491 *maxNum = ENCODE_VDENC_AVC_MAX_ROI_NUMBER;
492 }
493 else
494 {
495 switch (rcMode)
496 {
497 case VA_RC_CQP:
498 *maxNum = ENCODE_DP_AVC_MAX_ROI_NUMBER;
499 break;
500 default:
501 *maxNum = ENCODE_DP_AVC_MAX_ROI_NUM_BRC;
502 break;
503 }
504 }
505
506 *isRoiInDeltaQP = true;
507 return VA_STATUS_SUCCESS;
508 }
509
LoadAvcEncProfileEntrypoints()510 VAStatus MediaLibvaCapsG10::LoadAvcEncProfileEntrypoints()
511 {
512 VAStatus status = VA_STATUS_SUCCESS;
513
514 #if defined (_AVC_ENCODE_VME_SUPPORTED) || defined (_AVC_ENCODE_VDENC_SUPPORTED)
515 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVC))
516 {
517 AttribMap *attributeList;
518 VAProfile profile[3] = {
519 VAProfileH264Main,
520 VAProfileH264High,
521 VAProfileH264ConstrainedBaseline};
522
523 uint32_t configStartIdx;
524
525 for (int32_t i = 0; i < 3; i++)
526 {
527 status = CreateEncAttributes(profile[i],
528 VAEntrypointEncSlice,
529 &attributeList);
530
531 DDI_CHK_RET(status, "Failed to initialize Caps!");
532 configStartIdx = m_encConfigs.size();
533 int32_t maxRcMode = 7;
534 for (int32_t j = 0; j < maxRcMode; j++)
535 {
536 AddEncConfig(m_encRcMode[j]);
537 }
538 AddProfileEntry(profile[i], VAEntrypointEncSlice, attributeList,
539 configStartIdx, m_encConfigs.size() - configStartIdx);
540 }
541 }
542 #endif
543 return status;
544 }
545
LoadHevcEncProfileEntrypoints()546 VAStatus MediaLibvaCapsG10::LoadHevcEncProfileEntrypoints()
547 {
548 VAStatus status = VA_STATUS_SUCCESS;
549
550 #ifdef _HEVC_ENCODE_VME_SUPPORTED
551 AttribMap *attributeList = nullptr;
552
553 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC)
554 || MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit))
555 {
556 status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointEncSlice, &attributeList);
557 DDI_CHK_RET(status, "Failed to initialize Caps!");
558 DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
559
560 uint32_t configStartIdx = m_encConfigs.size();
561 AddEncConfig(VA_RC_CQP);
562 for (int32_t j = 3; j < 7; j++)
563 {
564 AddEncConfig(m_encRcMode[j]);
565 AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
566 }
567
568 AddProfileEntry(VAProfileHEVCMain, VAEntrypointEncSlice, attributeList,
569 configStartIdx, m_encConfigs.size() - configStartIdx);
570
571 if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit))
572 {
573 configStartIdx = m_encConfigs.size();
574 AddEncConfig(VA_RC_CQP);
575 for (int32_t j = 3; j < 7; j++)
576 {
577 AddEncConfig(m_encRcMode[j]);
578 AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
579 }
580 AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSlice, attributeList,
581 configStartIdx, m_encConfigs.size() - configStartIdx);
582 }
583 }
584
585 #endif
586 return status;
587 }
588
589