diff mbox

[FFmpeg-devel,1/2] configure: fix nvenc detection logic

Message ID 20160831144254.4983-1-timo@rothenpieler.org
State Accepted
Commit 20f09020108e4283270d168f4ceed8ed34e11ab6
Headers show

Commit Message

Timo Rothenpieler Aug. 31, 2016, 2:42 p.m. UTC
---
 configure | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

Comments

Carl Eugen Hoyos Aug. 31, 2016, 2:58 p.m. UTC | #1
Hi!

2016-08-31 16:42 GMT+02:00 Timo Rothenpieler <timo@rothenpieler.org>:

> +if enabled x86; then
> +    case $target_os in
> +        mingw32*|mingw64*|win32|win64|linux|cygwin*)
> +            ;;
> +        *)
> +            disable nvenc
> +            ;;
> +    esac
> +else
> +    disable nvenc
>  fi

> +enabled nvenc &&
> +    check_cc -I$source_path <<EOF || disable nvenc

Why is the complicated part above still necessary with
this check?

Carl Eugen
James Almer Aug. 31, 2016, 3:32 p.m. UTC | #2
On 8/31/2016 11:58 AM, Carl Eugen Hoyos wrote:
> Hi!
> 
> 2016-08-31 16:42 GMT+02:00 Timo Rothenpieler <timo@rothenpieler.org>:
> 
>> +if enabled x86; then
>> +    case $target_os in
>> +        mingw32*|mingw64*|win32|win64|linux|cygwin*)
>> +            ;;
>> +        *)
>> +            disable nvenc
>> +            ;;
>> +    esac
>> +else
>> +    disable nvenc
>>  fi
> 
>> +enabled nvenc &&
>> +    check_cc -I$source_path <<EOF || disable nvenc
> 
> Why is the complicated part above still necessary with
> this check?

This test makes sure broken compilers like msvc 2012 don't enable nvenc.
But otherwise, without the above arch and OS checks it would succeed on
pretty much any target since it simply compiles a standalone header.
Carl Eugen Hoyos Aug. 31, 2016, 3:42 p.m. UTC | #3
2016-08-31 17:32 GMT+02:00 James Almer <jamrial@gmail.com>:
> On 8/31/2016 11:58 AM, Carl Eugen Hoyos wrote:
>> 2016-08-31 16:42 GMT+02:00 Timo Rothenpieler <timo@rothenpieler.org>:
>>
>>> +if enabled x86; then
>>> +    case $target_os in
>>> +        mingw32*|mingw64*|win32|win64|linux|cygwin*)
>>> +            ;;
>>> +        *)
>>> +            disable nvenc
>>> +            ;;
>>> +    esac
>>> +else
>>> +    disable nvenc
>>>  fi
>>
>>> +enabled nvenc &&
>>> +    check_cc -I$source_path <<EOF || disable nvenc
>>
>> Why is the complicated part above still necessary with
>> this check?
>
> This test makes sure broken compilers like msvc 2012 don't enable nvenc.

I wonder now if the new check can also test for x86 Windows or Linux.

> But otherwise, without the above arch and OS checks it would succeed on
> pretty much any target since it simply compiles a standalone header.

Thank you.

Carl Eugen
Timo Rothenpieler Aug. 31, 2016, 6:10 p.m. UTC | #4
On 8/31/2016 5:42 PM, Carl Eugen Hoyos wrote:
> 2016-08-31 17:32 GMT+02:00 James Almer <jamrial@gmail.com>:
>> On 8/31/2016 11:58 AM, Carl Eugen Hoyos wrote:
>>> 2016-08-31 16:42 GMT+02:00 Timo Rothenpieler <timo@rothenpieler.org>:
>>>
>>>> +if enabled x86; then
>>>> +    case $target_os in
>>>> +        mingw32*|mingw64*|win32|win64|linux|cygwin*)
>>>> +            ;;
>>>> +        *)
>>>> +            disable nvenc
>>>> +            ;;
>>>> +    esac
>>>> +else
>>>> +    disable nvenc
>>>>  fi
>>>
>>>> +enabled nvenc &&
>>>> +    check_cc -I$source_path <<EOF || disable nvenc
>>>
>>> Why is the complicated part above still necessary with
>>> this check?
>>
>> This test makes sure broken compilers like msvc 2012 don't enable nvenc.
> 
> I wonder now if the new check can also test for x86 Windows or Linux.

That's quite exactly what it's doing.
Those are the targets where nvenc works, provided it's on x86.
Which essentialy is any x86 Linux and Windows system.
I'm wondering about ARM Windows now though.

>> But otherwise, without the above arch and OS checks it would succeed on
>> pretty much any target since it simply compiles a standalone header.
> 
> Thank you.
> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/configure b/configure
index 52931c3..e30ddd2 100755
--- a/configure
+++ b/configure
@@ -3205,7 +3205,7 @@  enable audiotoolbox
 enable d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
 enable xlib
 
-enable vda_framework videotoolbox videotoolbox_encoder
+enable nvenc vda_framework videotoolbox videotoolbox_encoder
 
 # build settings
 SHFLAGS='-shared -Wl,-soname,$$(@F)'
@@ -5992,22 +5992,26 @@  enabled vdpau && enabled xlib &&
     check_lib2 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
     enable vdpau_x11
 
-case $target_os in
-    mingw32*|mingw64*|win32|win64|linux|cygwin*)
-        disabled nvenc || enable nvenc
-        ;;
-    *)
-        disable nvenc
-        ;;
-esac
-
-if enabled nvenc; then
-    {
-        echo '#include "compat/nvenc/nvEncodeAPI.h"'
-        echo 'int main(void) { return 0; }'
-    } | check_cc -I$source_path || disable nvenc
+if enabled x86; then
+    case $target_os in
+        mingw32*|mingw64*|win32|win64|linux|cygwin*)
+            ;;
+        *)
+            disable nvenc
+            ;;
+    esac
+else
+    disable nvenc
 fi
 
+enabled nvenc &&
+    check_cc -I$source_path <<EOF || disable nvenc
+#include "compat/nvenc/nvEncodeAPI.h"
+NV_ENCODE_API_FUNCTION_LIST flist;
+void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_PRESET_HQ_GUID } }; }
+int main(void) { return 0; }
+EOF
+
 # Funny iconv installations are not unusual, so check it after all flags have been set
 disabled iconv || check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || disable iconv