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 8B65943BA3 for ; Wed, 20 Jul 2022 10:57:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1FDE468B61D; Wed, 20 Jul 2022 13:56:57 +0300 (EEST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C18168B5C5 for ; Wed, 20 Jul 2022 13:56:49 +0300 (EEST) Received: by mail-wm1-f45.google.com with SMTP id i132-20020a1c3b8a000000b003a2fa488efdso1086659wma.4 for ; Wed, 20 Jul 2022 03:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QpwykVC8oN/WPk5bg/oQwdRcYHl9HLc+vi/99eUa/fI=; b=lkIT+rmDluec/TlF0CiHC5eHKyzbOQMBYG2jSQ2BFeIusZlSVQ//pOBemGr0eQ5krx Vb48pLC0u4SHMnlhRcz1yfNpBBl/0EgTL3Ql7SINjiXk+F7zBxfyyLjhrj9FWwTUxpV/ iOCu7sWLtOj69AeXdHw32WYJnPlBTEtUfCydaQfoXo/9kh2OycVxJ23YGo+fBz64j7Fr Bn8oIMqz+lfN/jcx4BuA6+0bZEihvd2YXqZwkyl9reZ3Wzi61fNxNckYlZVrvqZdgncE AxhBU62DpwWZBCwoHO2YuiT5RsKBjrL142xUt1RLm2a1a7kZ6nUrfZ3S32tEg8ZKNeJ2 jxZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QpwykVC8oN/WPk5bg/oQwdRcYHl9HLc+vi/99eUa/fI=; b=W+tnoE/XATQldzPr++EcUHpc/RT/x6VJSpcLiOOiAaJphpOhT2rNoTAW2nwGrAZxlK nr3rS9K6fS1cYAnCReY4zHIUvMl5O18XxuX0pxdikoqDzPAnBQOoX+BzVOwdFSvjVpav QBQldzoo3UqNopUaZYfD2fKFfg3BdTG7547c2fLN5c6RvZw4BYAqDZQT2hD8sGRP+fE+ nZbeAC4fkDfk6bvLQY/ucU4B25JVR9z2N3JXcYzwGkL+ndad9Xua6km2Vu8eGa5RgT43 NEQdBrKcJkXB5AWHHhb4bOGMdP4B4HLCHlmaGCwELTtYaoJhuBEeCm1c9yl+qM+mgP8S xP6Q== X-Gm-Message-State: AJIora+LDANm0AaoZ8HfRjQPFF3Jk6+AhJpGYWcjFEmjmWraeykoAq7K fonz4aLogzCLlQtgR94pu3Uj9n65B5tTRw== X-Google-Smtp-Source: AGRyM1tp/iq/NGgkOMFSJtc/7UNNDFagk9AkD3zqhvsjjujeQM483eIfY4zYNIqXst+JJpXD8cZHdA== X-Received: by 2002:a05:600c:1e29:b0:3a3:d15:e6fb with SMTP id ay41-20020a05600c1e2900b003a30d15e6fbmr3397286wmb.5.1658314608297; Wed, 20 Jul 2022 03:56:48 -0700 (PDT) Received: from localhost ([2a00:5f00:102:0:a792:c012:897f:7da6]) by smtp.gmail.com with UTF8SMTPSA id c14-20020a5d4cce000000b0021d82a6095bsm15650632wrt.95.2022.07.20.03.56.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jul 2022 03:56:47 -0700 (PDT) From: Emil Velikov To: ffmpeg-devel@ffmpeg.org Date: Wed, 20 Jul 2022 11:56:44 +0100 Message-Id: <20220720105646.716398-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220720105646.716398-1-emil.l.velikov@gmail.com> References: <20220720105646.716398-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] hwcontext_vaapi: do not link against libva-x11.so 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: Mark Thompson , emil.l.velikov@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Emil Velikov There is an internal ABI between libva.so the libva-XXX.so libraries. With a recent change, the internal va_fool API was removed breaking the ABI. So if libva.so and libva-x11.so are from different version, the whole stack will crash. Instead we can dlopen() the libva-x11 library and gracefully error out. Signed-off-by: Emil Velikov --- v2: add libdl dependency --- configure | 3 ++- libavutil/hwcontext_vaapi.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 18d9b61a99..605afd58a7 100755 --- a/configure +++ b/configure @@ -3816,7 +3816,8 @@ swscale_suggest="libm stdatomic" avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs" avfilter_extralibs="pthreads_extralibs" -avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs" +avutil_deps="libdl" +avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vdpau_x11_extralibs" # programs ffmpeg_deps="avcodec avfilter avformat" diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index c3a98bc4b1..e44d324928 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -18,8 +18,16 @@ #include "config.h" +#if CONFIG_VAAPI_1 +# define VA_ABI ".2" +#else +# define VA_ABI ".1" +#endif + #if HAVE_VAAPI_X11 # include +# include +# define VA_X11_LIB "libva-x11.so" VA_ABI #endif #if HAVE_VAAPI_DRM # include @@ -54,6 +62,7 @@ typedef struct VAAPIDevicePriv { #if HAVE_VAAPI_X11 + void *libva_x11; Display *x11_display; #endif @@ -1565,6 +1574,8 @@ static void vaapi_device_free(AVHWDeviceContext *ctx) vaTerminate(hwctx->display); #if HAVE_VAAPI_X11 + if (priv->libva_x11) + dlclose(priv->libva_x11); if (priv->x11_display) XCloseDisplay(priv->x11_display); #endif @@ -1723,14 +1734,35 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, #if HAVE_VAAPI_X11 if (!display && try_x11) { + VADisplay (*GetDisplay)(Display *dpy); + + priv->libva_x11 = dlopen(VA_X11_LIB, RTLD_NOW | RTLD_LOCAL); + if (!priv->libva_x11) { + av_log(ctx, AV_LOG_ERROR, "Cannot open %s library %s.\n", + VA_X11_LIB, dlerror()); + return AVERROR_UNKNOWN; + } + + GetDisplay = dlsym(priv->libva_x11, "vaGetDisplay"); + if (!GetDisplay) { + av_log(ctx, AV_LOG_ERROR, "Cannot retrieve %s entrypoint %s.\n", + "vaGetDisplay", dlerror()); + // Always dlclose after the dlerror(). The former can alter the + // error string returned by the latter. + dlclose(priv->libva_x11); + return AVERROR_UNKNOWN; + } + // Try to open the device as an X11 display. priv->x11_display = XOpenDisplay(device); if (!priv->x11_display) { + dlclose(priv->libva_x11); av_log(ctx, AV_LOG_VERBOSE, "Cannot open X11 display " "%s.\n", XDisplayName(device)); } else { - display = vaGetDisplay(priv->x11_display); + display = GetDisplay(priv->x11_display); if (!display) { + dlclose(priv->libva_x11); av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display " "from X11 display %s.\n", XDisplayName(device)); return AVERROR_UNKNOWN; -- 2.37.0 _______________________________________________ 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".