Re: [libav-devel] [PATCH 5/5] h264dec: add a CUVID hwaccel

2017-07-22 Thread Anton Khirnov
Quoting Luca Barbato (2017-07-21 19:28:29)
> On 21/07/2017 15:19, Anton Khirnov wrote:
> > Some parts of the code are based on a patch by
> > Timo Rothenpieler 
> > ---
> 
> Seems fine, once I manage to boot the desktop I can test it.
> 
> lu
> 
> PS: Do you have plans for hevc as well?

Sure, adding all the other codecs should be simple.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 5/5] h264dec: add a CUVID hwaccel

2017-07-21 Thread Luca Barbato
On 21/07/2017 15:19, Anton Khirnov wrote:
> Some parts of the code are based on a patch by
> Timo Rothenpieler 
> ---

Seems fine, once I manage to boot the desktop I can test it.

lu

PS: Do you have plans for hevc as well?



___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 5/5] h264dec: add a CUVID hwaccel

2017-07-21 Thread Anton Khirnov
Some parts of the code are based on a patch by
Timo Rothenpieler 
---
 Changelog   |   1 +
 avtools/avconv.h|   1 +
 avtools/avconv_opt.c|   4 +
 configure   |   9 +-
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/cuvid.c  | 410 
 libavcodec/cuvid.h  |  61 +++
 libavcodec/cuvid_h264.c | 177 +
 libavcodec/h264_slice.c |   6 +-
 10 files changed, 670 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/cuvid.c
 create mode 100644 libavcodec/cuvid.h
 create mode 100644 libavcodec/cuvid_h264.c

diff --git a/Changelog b/Changelog
index adcca3f..f3c8f7a 100644
--- a/Changelog
+++ b/Changelog
@@ -17,6 +17,7 @@ version :
 - ClearVideo decoder (I-frames only)
 - support for decoding through D3D11VA in avconv
 - Cinepak encoder
+- NVIDIA CUVID-accelerated H.264 decoding
 
 
 version 12:
diff --git a/avtools/avconv.h b/avtools/avconv.h
index 4c69933..b5843fb 100644
--- a/avtools/avconv.h
+++ b/avtools/avconv.h
@@ -58,6 +58,7 @@ enum HWAccelID {
 HWACCEL_QSV,
 HWACCEL_VAAPI,
 HWACCEL_D3D11VA,
+HWACCEL_CUVID,
 };
 
 typedef struct HWAccel {
diff --git a/avtools/avconv_opt.c b/avtools/avconv_opt.c
index 575ce12..df69336 100644
--- a/avtools/avconv_opt.c
+++ b/avtools/avconv_opt.c
@@ -80,6 +80,10 @@ const HWAccel hwaccels[] = {
 { "vaapi", hwaccel_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI,
   AV_HWDEVICE_TYPE_VAAPI },
 #endif
+#if CONFIG_CUVID
+{ "cuvid", hwaccel_decode_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA,
+   AV_HWDEVICE_TYPE_CUDA },
+#endif
 { 0 },
 };
 int hwaccel_lax_profile_check = 0;
diff --git a/configure b/configure
index d92ce33..d31403c 100755
--- a/configure
+++ b/configure
@@ -237,6 +237,7 @@ External library support:
 
   The following libraries provide various hardware acceleration features:
   --enable-cudaNvidia CUDA (dynamically linked)
+  --enable-cuvid   Nvidia CUVID video decode acceleration
   --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
   --enable-dxva2   Microsoft DirectX 9 video acceleration [auto]
   --enable-libmfx  Intel MediaSDK (AKA Quick Sync Video)
@@ -1266,6 +1267,7 @@ EXTRALIBS_LIST="
 
 HWACCEL_LIBRARY_NONFREE_LIST="
 cuda
+cuvid
 libnpp
 "
 HWACCEL_LIBRARY_LIST="
@@ -2189,6 +2191,8 @@ vda_extralibs="-framework CoreFoundation -framework 
VideoDecodeAcceleration -fra
 
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
+h264_cuvid_hwaccel_deps="cuvid CUVIDH264PICPARAMS"
+h264_cuvid_hwaccel_select="h264_decoder"
 h264_d3d11va_hwaccel_deps="d3d11va"
 h264_d3d11va_hwaccel_select="h264_decoder"
 h264_d3d11va2_hwaccel_deps="d3d11va"
@@ -2554,7 +2558,7 @@ avdevice_extralibs="libm_extralibs"
 avformat_extralibs="libm_extralibs"
 avfilter_extralibs="pthreads_extralibs libm_extralibs"
 avresample_extralibs="libm_extralibs"
-avutil_extralibs="clock_gettime_extralibs cuda_extralibs libm_extralibs 
libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs 
vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs 
wincrypt_extralibs"
+avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs 
libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs 
user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs 
vdpau_x11_extralibs wincrypt_extralibs"
 swscale_extralibs="libm_extralibs"
 
 # programs
@@ -4692,6 +4696,8 @@ check_lib psapi"windows.h psapi.h"
GetProcessMemoryInfo -lpsapi
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 
+check_type "cuviddec.h" "CUVIDH264PICPARAMS"
+
 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" 
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
@@ -4751,6 +4757,7 @@ done
 enabled avisynth  && require_header avisynth/avisynth_c.h
 enabled avxsynth  && require_header avxsynth/avxsynth_c.h
 enabled cuda  && require cuda cuda.h cuInit -lcuda
+enabled cuvid && require cuvid cuviddec.h cuvidCreateDecoder 
-lnvcuvid
 enabled frei0r&& require_header frei0r.h
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled libbs2b   && require_pkg_config libbs2b libbs2b bs2b.h 
bs2b_open
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2b91588..66f6f9e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -625,6 +625,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)   += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)   += adpcmenc.o adpcm_data.o
 
 # hardware accelerators
+OBJS-$(CONFIG_CUVID)  += cuvid.o
 OBJS-$(CONFIG_D3D11VA)+= dxva2.o
 OBJS-$(CONFIG_DXVA2)