[FFmpeg-devel] [PATCH 1/2] avcodec/nvenc: Include NVENC SDK header

James Almer jamrial at gmail.com
Mon Dec 7 18:53:22 CET 2015


On 12/7/2015 11:14 AM, Timo Rothenpieler wrote:
> Nvidia finaly decided to put a propper MIT license on their nvenc header, so
> it can be included, removing any external dependencies for nvenc and
> making it no longer require the non-free flag.
> 
> nvenc.h is the original nvEncodeApi.h from the NVENC SDK 6.0.1, with a
> slight modification to make it work on cygwin.
> ---
>  configure          |   25 +-
>  libavcodec/nvenc.c |    2 +-
>  libavcodec/nvenc.h | 3122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 3142 insertions(+), 7 deletions(-)
>  create mode 100644 libavcodec/nvenc.h
> 
> diff --git a/configure b/configure
> index a731712..f33b7c4 100755
> --- a/configure
> +++ b/configure
> @@ -279,7 +279,7 @@ External library support:
>    --disable-lzma           disable lzma [autodetect]
>    --enable-decklink        enable Blackmagic DeckLink I/O support [no]
>    --enable-mmal            enable decoding via MMAL [no]
> -  --enable-nvenc           enable NVIDIA NVENC support [no]
> +  --disable-nvenc          disable NVIDIA NVENC support [autodetect]
>    --enable-openal          enable OpenAL 1.1 capture support [no]
>    --enable-opencl          enable OpenCL code
>    --enable-opengl          enable OpenGL rendering [no]
> @@ -1603,6 +1603,7 @@ CONFIG_LIST="
>      memalign_hack
>      memory_poisoning
>      neon_clobber_test
> +    nvenc

You forgot to remove nvenc from EXTERNAL_LIBRARY_LIST

>      pic
>      pod2man
>      raise_major
> @@ -4807,7 +4808,6 @@ die_license_disabled gpl x11grab
>  
>  die_license_disabled nonfree libaacplus
>  die_license_disabled nonfree libfaac
> -die_license_disabled nonfree nvenc
>  enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
>  enabled gpl && die_license_disabled_gpl nonfree openssl
>  
> @@ -5502,10 +5502,6 @@ enabled mmal              && { check_lib interface/mmal/mmal.h mmal_port_connect
>                                      check_lib interface/mmal/mmal.h mmal_port_connect ; }
>                                  check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
>                                 die "ERROR: mmal not found"; }
> -enabled nvenc             && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } &&
> -                             { check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
> -                               die "ERROR: NVENC API version 4 or older is not supported"; } &&
> -                             { [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; }
>  enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
>                                 check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
>                                 die "ERROR: openal not found"; } &&
> @@ -5663,6 +5659,23 @@ if enabled x11grab; then
>      require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
>  fi
>  
> +case $target_os in
> +    mingw32*|mingw64*|win32|win64|linux|cygwin*)
> +        disabled nvenc || enable nvenc
> +        ;;
> +    *)
> +        disable nvenc
> +        ;;
> +esac
> +
> +if enabled nvenc; then
> +    {
> +        echo '#include "nvenc.h"'
> +        echo 'int main(void) { return 0; }'
> +    } | check_cc -I$source_path/libavcodec ||
> +        disable nvenc
> +fi
> +

Is this check even needed when you're checking for compatible OSes above?
Not to mention nvenc.h only includes stdlib.h and then typedefs everything
it needs, which makes me think it should compile for any target out there.

In any case, do instead something like

enabled nvenc &&
    check_cc -I$source_path/libavcodec <<EOF || disable nvenc
#include "nvenc.h"
int x;
EOF

[...]

> diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
> new file mode 100644
> index 0000000..8b67c11
> --- /dev/null
> +++ b/libavcodec/nvenc.h

compat/nvenc/nvenc.h? It's the proper place for non ffmpeg headers, like we
do with Avisynth.
Or maybe both nvenc and the Avisynth stuff could be moved to a new "contrib"
or "thirdparty" folder.



More information about the ffmpeg-devel mailing list