]> git.sesse.net Git - ffmpeg/commitdiff
ffmpeg_hw: Treat empty device string as no device setting
authorMark Thompson <sw@jkqxz.net>
Mon, 6 May 2019 14:30:24 +0000 (15:30 +0100)
committerMark Thompson <sw@jkqxz.net>
Sun, 2 Jun 2019 21:58:22 +0000 (22:58 +0100)
The implementation will use some default in this case.  The empty string
is not a meaningful device for any existing hardware type, and indeed
OpenCL treats it identically to no device already to work around the lack
of this setting on the command line.

fftools/ffmpeg_hw.c

index d454ae7179726880abaa197b0289f5cb110c78d8..962d8f7d5a4fb21e4b717738fad4e1641e43c66e 100644 (file)
@@ -155,10 +155,12 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
         ++p;
         q = strchr(p, ',');
         if (q) {
-            device = av_strndup(p, q - p);
-            if (!device) {
-                err = AVERROR(ENOMEM);
-                goto fail;
+            if (q - p > 0) {
+                device = av_strndup(p, q - p);
+                if (!device) {
+                    err = AVERROR(ENOMEM);
+                    goto fail;
+                }
             }
             err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
             if (err < 0) {
@@ -168,7 +170,8 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
         }
 
         err = av_hwdevice_ctx_create(&device_ref, type,
-                                     device ? device : p, options, 0);
+                                     q ? device : p[0] ? p : NULL,
+                                     options, 0);
         if (err < 0)
             goto fail;