]> git.sesse.net Git - ffmpeg/commitdiff
hwcontext_vaapi: Add option to set driver name
authorMark Thompson <sw@jkqxz.net>
Wed, 14 Nov 2018 21:25:00 +0000 (21:25 +0000)
committerMark Thompson <sw@jkqxz.net>
Sun, 2 Jun 2019 22:03:27 +0000 (23:03 +0100)
For example: -init_hw_device vaapi:/dev/dri/renderD128,driver=foo

This may be more convenient that using the environment variable, and allows
loading different drivers for different devices in the same process.

libavutil/hwcontext_vaapi.c

index 941c257b1b36fa9117ff5ac992be72335db88204..f05b9ee9cff4ed7012a4ce43c3d3eeeae8ca3dfe 100644 (file)
@@ -1598,6 +1598,23 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
         return AVERROR(EINVAL);
     }
 
+    ent = av_dict_get(opts, "driver", NULL, 0);
+    if (ent) {
+#if VA_CHECK_VERSION(0, 38, 0)
+        VAStatus vas;
+        vas = vaSetDriverName(display, ent->value);
+        if (vas != VA_STATUS_SUCCESS) {
+            av_log(ctx, AV_LOG_ERROR, "Failed to set driver name to "
+                   "%s: %d (%s).\n", ent->value, vas, vaErrorStr(vas));
+            vaTerminate(display);
+            return AVERROR_EXTERNAL;
+        }
+#else
+        av_log(ctx, AV_LOG_WARNING, "Driver name setting is not "
+               "supported with this VAAPI version.\n");
+#endif
+    }
+
     return vaapi_device_connect(ctx, display);
 }