From cabf934909ecc4f6c128ff7e4a420e3052497795 Mon Sep 17 00:00:00 2001 From: Eden Abitbol <eden.abitbol@savoirfairelinux.com> Date: Mon, 8 Jul 2019 15:10:34 -0400 Subject: [PATCH] ffnvcodec: Add nvcodec windows support Add fetch_and_patch script for ffnvcodec. fetch_and_patch script copies needed headers to contrib include directory. Patch file to adapt ffmpeg configure script for ffnvcodec package inclusion. On linux pkg_config is used. On windows the files need to be included manually. config script includes path for ffnvcodec files and corresponding flags are set. Change-Id: Ia9daca2a49316a4373652acb718930d02f85e3f6 Reviewed-by: Philippe Gorley <philippe.gorley@savoirfairelinux.com> --- MSVC/config.h | 3 ++ MSVC/ring-daemon.vcxproj | 11 ++----- MSVC/ring-daemon.vcxproj.filters | 15 ++++++---- contrib/src/fetch_all.bat | 2 ++ contrib/src/ffmpeg/fetch_and_patch.bat | 1 + .../ffmpeg/windows-configure-ffnvcodec.patch | 29 +++++++++++++++++++ contrib/src/ffmpeg/windows-configure-make.sh | 13 ++++++++- contrib/src/ffnvcodec/fetch_and_patch.bat | 28 ++++++++++++++++++ 8 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 contrib/src/ffmpeg/windows-configure-ffnvcodec.patch create mode 100644 contrib/src/ffnvcodec/fetch_and_patch.bat diff --git a/MSVC/config.h b/MSVC/config.h index f5222f2dbf..c9469ef608 100644 --- a/MSVC/config.h +++ b/MSVC/config.h @@ -7,6 +7,9 @@ systems. This function is required for `alloca.c' support on those systems. /* Define to 1 if using `alloca.c'. */ /* #undef C_ALLOCA */ +/* Define to 1 if you want hardware acceleration support. */ +#define RING_ACCEL 1 + /* Define to 1 if you have `alloca', as a function or macro. */ #define HAVE_ALLOCA 1 diff --git a/MSVC/ring-daemon.vcxproj b/MSVC/ring-daemon.vcxproj index 89c807d78b..eb9501c101 100644 --- a/MSVC/ring-daemon.vcxproj +++ b/MSVC/ring-daemon.vcxproj @@ -767,10 +767,7 @@ <ClCompile Include="..\src\media\socket_pair.cpp" /> <ClCompile Include="..\src\media\srtp.c" /> <ClCompile Include="..\src\media\system_codec_container.cpp" /> - <ClCompile Include="..\src\media\video\accel.cpp"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseLib|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseLib_win32|x64'">true</ExcludedFromBuild> - </ClCompile> + <ClCompile Include="..\src\media\video\accel.cpp" /> <ClCompile Include="..\src\media\video\filter_transpose.cpp" /> <ClCompile Include="..\src\media\video\sinkclient.cpp" /> <ClCompile Include="..\src\media\video\uwpvideo\video_device_impl.cpp"> @@ -931,10 +928,7 @@ <ClInclude Include="..\src\media\socket_pair.h" /> <ClInclude Include="..\src\media\srtp.h" /> <ClInclude Include="..\src\media\system_codec_container.h" /> - <ClInclude Include="..\src\media\video\accel.h"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseLib|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseLib_win32|x64'">true</ExcludedFromBuild> - </ClInclude> + <ClInclude Include="..\src\media\video\accel.h" /> <ClInclude Include="..\src\media\video\filter_transpose.h" /> <ClInclude Include="..\src\media\video\shm_header.h" /> <ClInclude Include="..\src\media\video\sinkclient.h" /> @@ -999,6 +993,7 @@ <ClInclude Include="..\src\utf8_utils.h" /> <ClInclude Include="..\src\windirent.h" /> <ClInclude Include="..\src\winsyslog.h" /> + <ClInclude Include="config.h" /> </ItemGroup> <ItemGroup> <None Include="..\src\jamidht\eth\libdevcore\Makefile.am" /> diff --git a/MSVC/ring-daemon.vcxproj.filters b/MSVC/ring-daemon.vcxproj.filters index 5a0f068fa3..4c833a9232 100644 --- a/MSVC/ring-daemon.vcxproj.filters +++ b/MSVC/ring-daemon.vcxproj.filters @@ -367,9 +367,6 @@ <ClCompile Include="..\src\jamidht\p2p.cpp"> <Filter>Source Files\jamidht</Filter> </ClCompile> - <ClCompile Include="..\src\media\video\accel.cpp"> - <Filter>Source Files\media\video</Filter> - </ClCompile> <ClCompile Include="..\src\security\diffie-hellman.cpp"> <Filter>Source Files\security</Filter> </ClCompile> @@ -409,6 +406,9 @@ <ClCompile Include="..\src\media\video\filter_transpose.cpp"> <Filter>Source Files\media\video</Filter> </ClCompile> + <ClCompile Include="..\src\media\video\accel.cpp"> + <Filter>Source Files\media\video</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\src\account.h"> @@ -711,9 +711,6 @@ <ClInclude Include="..\src\media\audio\sound\tonelist.h"> <Filter>Source Files\media\audio\sound</Filter> </ClInclude> - <ClInclude Include="..\src\media\video\accel.h"> - <Filter>Source Files\media\video</Filter> - </ClInclude> <ClInclude Include="..\src\media\video\shm_header.h"> <Filter>Source Files\media\video</Filter> </ClInclude> @@ -840,6 +837,12 @@ <ClInclude Include="..\src\media\video\filter_transpose.h"> <Filter>Source Files\media\video</Filter> </ClInclude> + <ClInclude Include="config.h"> + <Filter>Source Files</Filter> + </ClInclude> + <ClInclude Include="..\src\media\video\accel.h"> + <Filter>Source Files\media\video</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="..\src\jamidht\eth\libdevcore\Makefile.am"> diff --git a/contrib/src/fetch_all.bat b/contrib/src/fetch_all.bat index f708de0d99..347537c589 100644 --- a/contrib/src/fetch_all.bat +++ b/contrib/src/fetch_all.bat @@ -21,6 +21,7 @@ if "%1"=="uwp" ( :uwpDeps set DEPENDENCIES=( ^ +ffnvcodec, ^ ffmpeg, ^ argon2, ^ zlib ^ @@ -45,6 +46,7 @@ goto fetch :win32Deps set DEPENDENCIES=( ^ +ffnvcodec, ^ ffmpeg, ^ argon2, ^ zlib ^ diff --git a/contrib/src/ffmpeg/fetch_and_patch.bat b/contrib/src/ffmpeg/fetch_and_patch.bat index dd55796210..53213d8ace 100644 --- a/contrib/src/ffmpeg/fetch_and_patch.bat +++ b/contrib/src/ffmpeg/fetch_and_patch.bat @@ -31,5 +31,6 @@ set UNIXPATH=%ROOTPATH%%UNIXPATH:C:/=% bash -c "%PATCH_CMD% %UNIXPATH%ffmpeg/change-RTCP-ratio.patch" git apply --reject --whitespace=fix %SRC%\ffmpeg\windows-configure.patch +git apply --reject --whitespace=fix %SRC%\ffmpeg\windows-configure-ffnvcodec.patch cd %SRC% \ No newline at end of file diff --git a/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch b/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch new file mode 100644 index 0000000000..4be2ddf5a1 --- /dev/null +++ b/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch @@ -0,0 +1,29 @@ +From 63d0edcee2744317fc0befad53000c206eb5ee31 Mon Sep 17 00:00:00 2001 +From: Eden Abitbol <eden.abitbol@savoirfairelinux.com> +Date: Tue, 9 Jul 2019 10:52:29 -0400 +Subject: [PATCH] Remove ffnvcodec linux style package check for windows + support. + +--- + configure | 7 ------- + 1 file changed, 7 deletions(-) + +--- a/configure ++++ b/configure +@@ -5897,13 +5897,6 @@ check_type "va/va.h va/va_enc_vp9.h" "VAEncPictureParameterBufferVP9" + + check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC" + +-if ! disabled ffnvcodec; then +- check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.2" \ +- "ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h" "" || \ +- { test_pkg_config ffnvcodec_tmp "ffnvcodec < 8.1" "" "" && check_pkg_config ffnvcodec "ffnvcodec >= 8.0.14.2" \ +- "ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h" ""; } +-fi +- + check_cpp_condition winrt windows.h "!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)" + + if ! disabled w32threads && ! enabled pthreads; then +-- +2.22.0.windows.1 + diff --git a/contrib/src/ffmpeg/windows-configure-make.sh b/contrib/src/ffmpeg/windows-configure-make.sh index 3070c729b2..df50a11a42 100644 --- a/contrib/src/ffmpeg/windows-configure-make.sh +++ b/contrib/src/ffmpeg/windows-configure-make.sh @@ -142,7 +142,7 @@ if [ "$1" == "uwp" ]; then OUTDIR=Output/Windows10/x86 fi elif [ "$1" == "win32" ]; then - EXTRACFLAGS='-MD -D_WINDLL -I../../../../../msvc/include -I../../../../../msvc/include/opus -I../../../../../msvc/include/vpx' + EXTRACFLAGS='-MD -D_WINDLL -I../../../../../msvc/include -I../../../../../msvc/include/opus -I../../../../../msvc/include/vpx -I../../../../../msvc/include/ffnvcodec' FFMPEGCONF+=' --enable-libvpx --enable-encoder=libvpx_vp8 @@ -152,6 +152,17 @@ elif [ "$1" == "win32" ]; then --enable-indev=dshow --enable-indev=gdigrab --enable-dxva2' + FFMPEGCONF+=' + --enable-ffnvcodec + --enable-cuvid + --enable-nvdec + --enable-nvenc + --enable-hwaccel=h264_nvdec + --enable-hwaccel=hevc_nvdec + --enable-hwaccel=vp8_nvdec + --enable-hwaccel=mjpeg_nvdec + --enable-encoder=h264_nvenc + --enable-encoder=hevc_nvenc' if [ "$2" == "x64" ]; then echo "configure and make ffmpeg for win32-x64..." EXTRALDFLAGS='-APPCONTAINER:NO -MACHINE:x64 Ole32.lib Kernel32.lib Gdi32.lib User32.lib Strmiids.lib OleAut32.lib Shlwapi.lib Vfw32.lib Secur32.lib libopus.lib libx264.lib libvpx.lib -LIBPATH:../../../../../msvc/lib/x64' diff --git a/contrib/src/ffnvcodec/fetch_and_patch.bat b/contrib/src/ffnvcodec/fetch_and_patch.bat new file mode 100644 index 0000000000..6c4bcfb9c4 --- /dev/null +++ b/contrib/src/ffnvcodec/fetch_and_patch.bat @@ -0,0 +1,28 @@ +set BUILD=%SRC%..\build + +mkdir %BUILD% +cd %BUILD% + +set FFNVCODEC_VERSION=5eeca8cc95267d55030e98a051effa47c45f13f3 +set FFNVCODEC_GITURL=https://github.com/FFmpeg/nv-codec-headers/archive/%FFNVCODEC_VERSION%.tar.gz + +if %USE_CACHE%==1 ( + copy %CACHE_DIR%\%FFNVCODEC_VERSION%.tar.gz %cd% +) else ( + wget --no-check-certificate %FFNVCODEC_GITURL% +) + +7z -y x %FFNVCODEC_VERSION%.tar.gz && 7z -y x %FFNVCODEC_VERSION%.tar +del %FFNVCODEC_VERSION%.tar && del %FFNVCODEC_VERSION%.tar.gz && del pax_global_header +rename nv-codec-headers-%FFNVCODEC_VERSION% ffnvcodec + +cd ffnvcodec\include\ffnvcodec + +mkdir ..\..\..\..\msvc\include + +mkdir ..\..\..\..\msvc\include\ffnvcodec + +xcopy /S /Y *.h ..\..\..\..\msvc\include\ffnvcodec + +cd %SRC% + -- GitLab