[FFmpeg-cvslog] hwcontext_vaapi: Add option to specify connection type
Mark Thompson
git at videolan.org
Mon Jun 3 01:05:42 EEST 2019
ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Mon May 6 15:31:18 2019 +0100| [d2141a9b652c52350b5a4519ec34c59f5531fad1] | committer: Mark Thompson
hwcontext_vaapi: Add option to specify connection type
Can be set to "drm" or "x11" to force a specific connection type.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2141a9b652c52350b5a4519ec34c59f5531fad1
---
libavutil/hwcontext_vaapi.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 8624369bb9..561b82fcce 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1469,6 +1469,8 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
{
VAAPIDevicePriv *priv;
VADisplay display = NULL;
+ const AVDictionaryEntry *ent;
+ int try_drm, try_x11, try_all;
priv = av_mallocz(sizeof(*priv));
if (!priv)
@@ -1479,8 +1481,26 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
ctx->user_opaque = priv;
ctx->free = vaapi_device_free;
+ ent = av_dict_get(opts, "connection_type", NULL, 0);
+ if (ent) {
+ try_all = try_drm = try_x11 = 0;
+ if (!strcmp(ent->value, "drm")) {
+ try_drm = 1;
+ } else if (!strcmp(ent->value, "x11")) {
+ try_x11 = 1;
+ } else {
+ av_log(ctx, AV_LOG_ERROR, "Invalid connection type %s.\n",
+ ent->value);
+ return AVERROR(EINVAL);
+ }
+ } else {
+ try_all = 1;
+ try_drm = HAVE_VAAPI_DRM;
+ try_x11 = HAVE_VAAPI_X11;
+ }
+
#if HAVE_VAAPI_X11
- if (!display && !(device && device[0] == '/')) {
+ if (!display && try_x11) {
// Try to open the device as an X11 display.
priv->x11_display = XOpenDisplay(device);
if (!priv->x11_display) {
@@ -1501,7 +1521,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
#endif
#if HAVE_VAAPI_DRM
- if (!display) {
+ if (!display && try_drm) {
// Try to open the device as a DRM path.
// Default to using the first render node if the user did not
// supply a path.
@@ -1525,8 +1545,12 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
#endif
if (!display) {
- av_log(ctx, AV_LOG_ERROR, "No VA display found for "
- "device: %s.\n", device ? device : "");
+ if (device)
+ av_log(ctx, AV_LOG_ERROR, "No VA display found for "
+ "device %s.\n", device);
+ else
+ av_log(ctx, AV_LOG_ERROR, "No VA display found for "
+ "any default device.\n");
return AVERROR(EINVAL);
}
More information about the ffmpeg-cvslog
mailing list