From patchwork Tue Aug 30 20:02:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 341 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.71.11 with SMTP id u11csp1748123vsa; Tue, 30 Aug 2016 13:02:41 -0700 (PDT) X-Received: by 10.28.163.199 with SMTP id m190mr16663377wme.5.1472587361486; Tue, 30 Aug 2016 13:02:41 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id xs9si39769808wjc.193.2016.08.30.13.02.40; Tue, 30 Aug 2016 13:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E3833689D2A; Tue, 30 Aug 2016 23:02:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3233E689CE1 for ; Tue, 30 Aug 2016 23:02:25 +0300 (EEST) Received: by mail-oi0-f65.google.com with SMTP id s207so2763883oie.0 for ; Tue, 30 Aug 2016 13:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=c0ue1Q3gjgQ1ixH5UeQPxcXrEIMvLE/LcAZR35gmEOY=; b=NiyBsyFsiWbSWTqsOmLtlqw4Nu1GF4JHVPmGEGDdnGMPTqB20IyzruDshJLzz1GtI4 Td0pR5XXJgQAvOpEe8Vgat8o5jV/XG/k6r+tgKO7nq0vZBQY1ledImJRLOgXkBlU8Yje BiQ+uNo+9J+L+haAcz3qP+B8rui2ycq6ezvrZZNLOGctOucYAU7eq/m0bf1lhOdYcyWJ H8QiFIQtA25SklsFXIZd0DvmEDYjfxqKm8Fumh0fOtJrkXVXicODuhu1dToniHY2honb 1F7nN6J3qy+2b7Ql6zo8q+6I89AFKbrXGmfSFMRPgyknmBcVjDizL9lR2OQD7yjfKeiX oGUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=c0ue1Q3gjgQ1ixH5UeQPxcXrEIMvLE/LcAZR35gmEOY=; b=ibzrck8sPNtl+hcaRj4LArEa8eKHtiMvu0VD55yJUaFnicKJQd688h075rWjhqKSJi EoJfDHFw89i4HESkpD6ltKWxoOlrgf4XU0RVROM+Xd1S475/ED9VlhBvRjWVesEk3JDQ bXrbMmiI7l9aa+hIoCv7zr4RW3GCcBlLSoqAggdtIYoIY+abB+38tYdIZEdCe8NvjK+G q1v/tjK0ZXz/KwyM1ykx1HtApY9DXgfzHu/sRMh371uuQ6YvqUrRhU//8FhXirQ1OUYt BumiKFUL3iN5KWm7b/m24xKPOw2SfL1B6qqpasLrI9bPz10ynrifvglTIpiFmWambiQg IROQ== X-Gm-Message-State: AE9vXwPYdPbIVS8y5mlpVE3UFV39gYUZRK0sn6Z+LOfOTt9ijymuFnh8/HwUXRXkHt1zMg== X-Received: by 10.157.39.137 with SMTP id c9mr6158408otb.3.1472587349987; Tue, 30 Aug 2016 13:02:29 -0700 (PDT) Received: from [192.168.1.33] ([181.22.13.137]) by smtp.googlemail.com with ESMTPSA id m66sm771286oia.25.2016.08.30.13.02.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Aug 2016 13:02:29 -0700 (PDT) To: FFmpeg development discussions and patches References: <20160830110040.31400-1-timo@rothenpieler.org> From: James Almer Message-ID: <014a0fec-defa-6c51-1001-6279c76c48a4@gmail.com> Date: Tue, 30 Aug 2016 17:02:20 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160830110040.31400-1-timo@rothenpieler.org> Subject: Re: [FFmpeg-devel] [PATCH] configure: improve logic and checks for nvenc X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 8/30/2016 8:00 AM, Timo Rothenpieler wrote: > --- > configure | 37 +++++++++++++++++++++++++------------ > 1 file changed, 25 insertions(+), 12 deletions(-) > > diff --git a/configure b/configure > index 52931c3..bcfc9a8 100755 > --- a/configure > +++ b/configure > @@ -5992,20 +5992,33 @@ 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 > +if ! enabled x86; then > + enabled nvenc && die "NVENC is only supported on x86" > + disable nvenc > +elif ! disabled nvenc; then > { > echo '#include "compat/nvenc/nvEncodeAPI.h"' > - echo 'int main(void) { return 0; }' > - } | check_cc -I$source_path || disable nvenc > + echo 'NV_ENCODE_API_FUNCTION_LIST flist;' > + echo 'void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_PRESET_HQ_GUID } }; }' This will most likely prevent nvenc from being enabled for msvc 2012, but not old mingw32, which is failing with the error: src/libavcodec/nvenc.c:115:52: error: 'ENOBUFS' undeclared here (not in a function) { NV_ENC_ERR_NOT_ENOUGH_BUFFER, AVERROR(ENOBUFS), "not enough buffer" }, I think the easiest solution would be using AVERROR_BUFFER_TOO_SMALL if ENOBUFS is not defined. That or just disable nvenc if using mingw32 toolchains by checking "enabled libc_mingw32", since disabling for target-os == mingw32 would also affect mingw-w64. gcc-asan fails with /usr/bin/ld: libavcodec/libavcodec.a(nvenc.o): undefined reference to symbol 'dlsym@@GLIBC_2.2.5' /usr/lib/../lib/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status I have no idea how to deal with this. > + echo 'int main(void) { f(); return 0; }' > + } | check_cc -I$source_path > + nvenc_check_res=$? > + > + if [ $nvenc_check_res != 0 ] && enabled nvenc; then > + die "NVENC enabled but test-compile failed" > + fi > + > + case $target_os in > + mingw32*|mingw64*|win32|win64|linux|cygwin*) > + [ $nvenc_check_res = 0 ] && enable nvenc > + ;; > + *) > + enabled nvenc && die "NVENC is only supported on Windows and Linux" > + disable nvenc > + ;; > + esac > + > + unset nvenc_check_res This test is different from other automatically detected features, and also unnecessarily complex. You should force enable nvenc earlier in the script like with other similar features (including hardware codecs and accelerators), then disable it on unsupported platforms and old/broken compilers with the corresponding checks and tests. Something like this: ------ ------ Is IMO much simpler. diff --git a/configure b/configure index 52931c3..a09aa6e 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,25 @@ 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 <