From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 027BE40A7F for ; Sat, 5 Mar 2022 20:47:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D007B68B083; Sat, 5 Mar 2022 22:47:34 +0200 (EET) Received: from mout6.wup.tal.de (mod.tau.tal.de [195.8.233.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 65B0868B022 for ; Sat, 5 Mar 2022 22:47:28 +0200 (EET) Received: from point.localnet (dslb-092-072-168-032.092.072.pools.vodafone-ip.de [92.72.168.32]) (Authenticated sender: ib@wtal.de) by smtp.tal.de (Postfix) with ESMTPA id 2D69C84CAFC9; Sat, 5 Mar 2022 21:47:27 +0100 (CET) Received: from ib by point.localnet with local (masqmail 0.2.30) id 1nQbJG-1wG-00; Sat, 05 Mar 2022 21:47:26 +0100 Message-ID: <6223cc25.047eb8d4.bm000@wupperonline.de> From: =?ISO-8859-1?Q?Ingo=20Br=FCckl?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 05 Mar 2022 21:46:26 +0100 In-Reply-To: <621758b7.5d043213.bm000@wupperonline.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=21796628737293612474422308 X-Mailer: blueMail/Linux 1.5 Subject: [FFmpeg-devel] [PATCH] Re-enable support for libva v1 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang , Mark Thompson Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --21796628737293612474422308 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit FFmpeg 4.4.1 still supported libva v1, FFmpeg 5.0 does not do that anymore. If dropping support for libva v1 wasn't an intentional decision, it's easy to re-enable it. Ingo --21796628737293612474422308 Content-Type: text/x-diff;; charset=us-ascii Content-Disposition: attachment; filename="0001-Re-enable-support-for-libva-v1.patch" Content-Transfer-Encoding: 7bit >From f8cc63a789eabd8b7381e94767dff850977d0971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Br=C3=BCckl?= Date: Thu, 24 Feb 2022 00:17:11 +0100 Subject: [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in modifiers by using the PRIME_2 memory type, which only exists in v2 of the library. To still support v1 of the library, conditionally compile using VA_CHECK_VERSION() for both the new code and the old code before the commit. --- libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 994b744e4d..799490442e 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc, static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const AVFrame *src, int flags) { +#if VA_CHECK_VERSION(2, 0, 0) VAAPIFramesContext *src_vafc = src_fc->internal->priv; + int use_prime2; +#else + int k; +#endif AVHWFramesContext *dst_fc = (AVHWFramesContext*)dst->hw_frames_ctx->data; AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const VAAPIFormatDescriptor *format_desc; VASurfaceID surface_id; VAStatus vas = VA_STATUS_SUCCESS; - int use_prime2; uint32_t va_fourcc; int err, i, j; +#if !VA_CHECK_VERSION(2, 0, 0) + unsigned long buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &buffer_desc, + } + }; +#endif + desc = (AVDRMFrameDescriptor*)src->data[0]; if (desc->nb_objects != 1) { @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, format_desc = vaapi_format_from_fourcc(va_fourcc); av_assert0(format_desc); +#if VA_CHECK_VERSION(2, 0, 0) use_prime2 = !src_vafc->prime_2_import_unsupported && desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; if (use_prime2) { @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, &surface_id, 1, buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); } +#else + buffer_handle = desc->objects[0].fd; + buffer_desc.pixel_format = va_fourcc; + buffer_desc.width = src_fc->width; + buffer_desc.height = src_fc->height; + buffer_desc.data_size = desc->objects[0].size; + buffer_desc.buffers = &buffer_handle; + buffer_desc.num_buffers = 1; + buffer_desc.flags = 0; + + k = 0; + for (i = 0; i < desc->nb_layers; i++) { + for (j = 0; j < desc->layers[i].nb_planes; j++) { + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; + ++k; + } + } + buffer_desc.num_planes = k; + + if (format_desc->chroma_planes_swapped && + buffer_desc.num_planes == 3) { + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); + } + + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, + &surface_id, 1, + attrs, FF_ARRAY_ELEMS(attrs)); +#endif if (vas != VA_STATUS_SUCCESS) { av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " "object: %d (%s).\n", vas, vaErrorStr(vas)); -- 2.30.2 --21796628737293612474422308 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --21796628737293612474422308--