MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vaapi_decode_make_config

Function vaapi_decode_make_config

libavcodec/vaapi_decode.c:478–666  ·  view source on GitHub ↗

* Set *va_config and the frames_ref fields from the current codec parameters * in avctx. */

Source from the content-addressed store, hash-verified

476 * in avctx.
477 */
478static int vaapi_decode_make_config(AVCodecContext *avctx,
479 AVBufferRef *device_ref,
480 VAConfigID *va_config,
481 AVBufferRef *frames_ref)
482{
483 AVVAAPIHWConfig *hwconfig = NULL;
484 AVHWFramesConstraints *constraints = NULL;
485 VAStatus vas;
486 int err, i, j;
487 const AVCodecDescriptor *codec_desc;
488 VAProfile *profile_list = NULL, matched_va_profile, va_profile;
489 int profile_count, exact_match, matched_ff_profile, codec_profile;
490
491 AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data;
492 AVVAAPIDeviceContext *hwctx = device->hwctx;
493
494 codec_desc = avcodec_descriptor_get(avctx->codec_id);
495 if (!codec_desc) {
496 err = AVERROR(EINVAL);
497 goto fail;
498 }
499
500 profile_count = vaMaxNumProfiles(hwctx->display);
501 profile_list = av_malloc_array(profile_count,
502 sizeof(VAProfile));
503 if (!profile_list) {
504 err = AVERROR(ENOMEM);
505 goto fail;
506 }
507
508 vas = vaQueryConfigProfiles(hwctx->display,
509 profile_list, &profile_count);
510 if (vas != VA_STATUS_SUCCESS) {
511 av_log(avctx, AV_LOG_ERROR, "Failed to query profiles: "
512 "%d (%s).\n", vas, vaErrorStr(vas));
513 err = AVERROR(ENOSYS);
514 goto fail;
515 }
516
517 matched_va_profile = VAProfileNone;
518 exact_match = 0;
519
520 for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
521 int profile_match = 0;
522 if (avctx->codec_id != vaapi_profile_map[i].codec_id)
523 continue;
524 if (avctx->profile == vaapi_profile_map[i].codec_profile ||
525 vaapi_profile_map[i].codec_profile == AV_PROFILE_UNKNOWN)
526 profile_match = 1;
527
528 va_profile = vaapi_profile_map[i].profile_parser ?
529 vaapi_profile_map[i].profile_parser(avctx) :
530 vaapi_profile_map[i].va_profile;
531 codec_profile = vaapi_profile_map[i].codec_profile;
532
533 for (j = 0; j < profile_count; j++) {
534 if (va_profile == profile_list[j]) {
535 exact_match = profile_match;

Callers 2

ff_vaapi_decode_initFunction · 0.85

Calls 8

avcodec_descriptor_getFunction · 0.85
av_malloc_arrayFunction · 0.85
av_logFunction · 0.85
av_freepFunction · 0.85

Tested by

no test coverage detected