From 69eaa89e22185dba0c16bbce6e200426c7c566e9 Mon Sep 17 00:00:00 2001 From: atinfinity Date: Sun, 31 Jan 2016 01:56:45 +0900 Subject: [PATCH 1/2] fixed to use NVCUVID in 'cudacodec' module. --- cmake/OpenCVDetectCUDA.cmake | 13 ++++++++++++- modules/gpu/CMakeLists.txt | 9 ++++++--- modules/gpu/src/precomp.hpp | 4 +++- modules/gpu/src/video_writer.cpp | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index cca125034a..d2548f9af5 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -35,7 +35,18 @@ if(CUDA_FOUND) if(WITH_NVCUVID) find_cuda_helper_libs(nvcuvid) - set(HAVE_NVCUVID 1) + + if(WIN32) + find_cuda_helper_libs(nvcuvenc) + endif() + + if(CUDA_nvcuvid_LIBRARY) + set(HAVE_NVCUVID 1) + endif() + + if(CUDA_nvcuvenc_LIBRARY) + set(HAVE_NVCUVENC 1) + endif() endif() message(STATUS "CUDA detected: " ${CUDA_VERSION}) diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 6de3e0efab..caec0efa5a 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -54,11 +54,14 @@ if(HAVE_CUDA) endif() if(WITH_NVCUVID) - set(cuda_link_libs ${cuda_link_libs} ${CUDA_CUDA_LIBRARY} ${CUDA_nvcuvid_LIBRARY}) + if(HAVE_NVCUVID) + set(cuda_link_libs ${cuda_link_libs} ${CUDA_CUDA_LIBRARY} ${CUDA_nvcuvid_LIBRARY}) + endif() if(WIN32) - find_cuda_helper_libs(nvcuvenc) - set(cuda_link_libs ${cuda_link_libs} ${CUDA_nvcuvenc_LIBRARY}) + if(HAVE_NVCUVENC) + set(cuda_link_libs ${cuda_link_libs} ${CUDA_nvcuvenc_LIBRARY}) + endif() endif() if(WITH_FFMPEG) diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index 785783b5e2..a4f75db19a 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -98,7 +98,9 @@ #include #ifdef WIN32 - #include + #ifdef HAVE_NVCUVENC + #include + #endif #endif #endif diff --git a/modules/gpu/src/video_writer.cpp b/modules/gpu/src/video_writer.cpp index 0937ad1f27..bf51c25408 100644 --- a/modules/gpu/src/video_writer.cpp +++ b/modules/gpu/src/video_writer.cpp @@ -42,7 +42,7 @@ #include "precomp.hpp" -#if !defined(HAVE_CUDA) || defined(CUDA_DISABLER) || !defined(HAVE_NVCUVID) || !defined(WIN32) +#if !defined(HAVE_CUDA) || defined(CUDA_DISABLER) || !defined(HAVE_NVCUVENC) || !defined(WIN32) class cv::gpu::VideoWriter_GPU::Impl { From cf43790a27f1815e2ae3ed63f16e5d8a77e100b5 Mon Sep 17 00:00:00 2001 From: atinfinity Date: Mon, 1 Feb 2016 21:15:28 +0900 Subject: [PATCH 2/2] added cmakedefine to cmake/templates/cvconfig.h.in --- cmake/templates/cvconfig.h.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index d1c9e65d3d..caea7da3e7 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -109,6 +109,9 @@ /* NVidia Video Decoding API*/ #cmakedefine HAVE_NVCUVID +/* NVidia Video Encoding API*/ +#cmakedefine HAVE_NVCUVENC + /* OpenCL Support */ #cmakedefine HAVE_OPENCL #cmakedefine HAVE_OPENCL_STATIC