summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liushuyu2021-12-15 01:10:07 -0700
committerGravatar liushuyu2021-12-15 20:57:01 -0700
commit3f765ea9a4598a5b68e8210aec75067f901172b9 (patch)
treebb3ed9be9344d37bbdf4eb7456813246bda3da1f
parentMerge pull request #7588 from Wunkolo/gibibibi-bytes (diff)
downloadyuzu-3f765ea9a4598a5b68e8210aec75067f901172b9.tar.gz
yuzu-3f765ea9a4598a5b68e8210aec75067f901172b9.tar.xz
yuzu-3f765ea9a4598a5b68e8210aec75067f901172b9.zip
video_core/codecs: (re-spin) refactor ffmpeg searching and handling
-rwxr-xr-x.ci/scripts/windows/docker.sh5
-rw-r--r--.gitmodules6
-rw-r--r--CMakeLists.txt218
-rw-r--r--externals/CMakeLists.txt5
m---------externals/ffmpeg0
-rw-r--r--externals/ffmpeg/CMakeLists.txt209
m---------externals/ffmpeg/ffmpeg0
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp6
8 files changed, 227 insertions, 222 deletions
diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh
index 155d8a5c8..584b9b39f 100755
--- a/.ci/scripts/windows/docker.sh
+++ b/.ci/scripts/windows/docker.sh
@@ -41,12 +41,11 @@ for i in package/*.exe; do
41done 41done
42 42
43pip3 install pefile 43pip3 install pefile
44python3 .ci/scripts/windows/scan_dll.py package/*.exe "package/" 44python3 .ci/scripts/windows/scan_dll.py package/*.exe package/imageformats/*.dll "package/"
45python3 .ci/scripts/windows/scan_dll.py package/imageformats/*.dll "package/"
46 45
47# copy FFmpeg libraries 46# copy FFmpeg libraries
48EXTERNALS_PATH="$(pwd)/build/externals" 47EXTERNALS_PATH="$(pwd)/build/externals"
49FFMPEG_DLL_PATH="$(find ${EXTERNALS_PATH} -maxdepth 1 -type d | grep ffmpeg)/bin" 48FFMPEG_DLL_PATH="$(find "${EXTERNALS_PATH}" -maxdepth 1 -type d | grep 'ffmpeg-')/bin"
50find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';' 49find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';'
51 50
52# copy libraries from yuzu.exe path 51# copy libraries from yuzu.exe path
diff --git a/.gitmodules b/.gitmodules
index dc6ed500f..a9cf9a24a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -34,12 +34,12 @@
34[submodule "opus"] 34[submodule "opus"]
35 path = externals/opus/opus 35 path = externals/opus/opus
36 url = https://github.com/xiph/opus.git 36 url = https://github.com/xiph/opus.git
37[submodule "ffmpeg"]
38 path = externals/ffmpeg
39 url = https://git.ffmpeg.org/ffmpeg.git
40[submodule "SDL"] 37[submodule "SDL"]
41 path = externals/SDL 38 path = externals/SDL
42 url = https://github.com/libsdl-org/SDL.git 39 url = https://github.com/libsdl-org/SDL.git
43[submodule "externals/cpp-httplib"] 40[submodule "externals/cpp-httplib"]
44 path = externals/cpp-httplib 41 path = externals/cpp-httplib
45 url = https://github.com/yhirose/cpp-httplib.git 42 url = https://github.com/yhirose/cpp-httplib.git
43[submodule "externals/ffmpeg/ffmpeg"]
44 path = externals/ffmpeg/ffmpeg
45 url = https://git.ffmpeg.org/ffmpeg.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a810e11c2..18d553f4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -514,7 +514,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
514endif() 514endif()
515if (NOT YUZU_USE_BUNDLED_FFMPEG) 515if (NOT YUZU_USE_BUNDLED_FFMPEG)
516 # Use system installed FFmpeg 516 # Use system installed FFmpeg
517 find_package(FFmpeg QUIET COMPONENTS ${FFmpeg_COMPONENTS}) 517 find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS})
518 518
519 if (FFmpeg_FOUND) 519 if (FFmpeg_FOUND)
520 # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. 520 # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries.
@@ -527,225 +527,11 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
527 set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) 527 set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE)
528 endforeach() 528 endforeach()
529 else() 529 else()
530 message(WARNING "FFmpeg not found, falling back to externals") 530 message(WARNING "FFmpeg not found or too old, falling back to externals")
531 set(YUZU_USE_BUNDLED_FFMPEG ON) 531 set(YUZU_USE_BUNDLED_FFMPEG ON)
532 endif() 532 endif()
533endif() 533endif()
534 534
535if (YUZU_USE_BUNDLED_FFMPEG)
536 if (NOT WIN32)
537 # TODO(lat9nq): Move this to externals/ffmpeg/CMakeLists.txt (and move externals/ffmpeg to
538 # externals/ffmpeg/ffmpeg)
539
540 # Build FFmpeg from externals
541 message(STATUS "Using FFmpeg from externals")
542
543 # FFmpeg has source that requires one of nasm or yasm to assemble it.
544 # REQUIRED throws an error if not found here during configuration rather than during compilation.
545 find_program(ASSEMBLER NAMES nasm yasm)
546 if ("${ASSEMBLER}" STREQUAL "ASSEMBLER-NOTFOUND")
547 message(FATAL_ERROR "One of either `nasm` or `yasm` not found but is required.")
548 endif()
549
550 find_program(AUTOCONF autoconf)
551 if ("${AUTOCONF}" STREQUAL "AUTOCONF-NOTFOUND")
552 message(FATAL_ERROR "Required program `autoconf` not found.")
553 endif()
554
555 set(FFmpeg_PREFIX ${PROJECT_SOURCE_DIR}/externals/ffmpeg)
556 set(FFmpeg_BUILD_DIR ${PROJECT_BINARY_DIR}/externals/ffmpeg)
557 set(FFmpeg_MAKEFILE ${FFmpeg_BUILD_DIR}/Makefile)
558 make_directory(${FFmpeg_BUILD_DIR})
559
560 # Read version string from external
561 file(READ ${FFmpeg_PREFIX}/RELEASE FFmpeg_VERSION)
562 set(FFmpeg_FOUND NO)
563 if (NOT FFmpeg_VERSION STREQUAL "")
564 set(FFmpeg_FOUND YES)
565 endif()
566
567 unset(FFmpeg_LIBRARIES CACHE)
568 foreach(COMPONENT ${FFmpeg_COMPONENTS})
569 set(FFmpeg_${COMPONENT}_PREFIX "${FFmpeg_BUILD_DIR}/lib${COMPONENT}")
570 set(FFmpeg_${COMPONENT}_LIB_NAME "lib${COMPONENT}.a")
571 set(FFmpeg_${COMPONENT}_LIBRARY "${FFmpeg_${COMPONENT}_PREFIX}/${FFmpeg_${COMPONENT}_LIB_NAME}")
572
573 set(FFmpeg_LIBRARIES
574 ${FFmpeg_LIBRARIES}
575 ${FFmpeg_${COMPONENT}_LIBRARY}
576 CACHE PATH "Paths to FFmpeg libraries" FORCE)
577 endforeach()
578
579 Include(FindPkgConfig REQUIRED)
580 pkg_check_modules(LIBVA libva)
581 pkg_check_modules(CUDA cuda)
582 pkg_check_modules(FFNVCODEC ffnvcodec)
583 pkg_check_modules(VDPAU vdpau)
584
585 set(FFmpeg_HWACCEL_LIBRARIES)
586 set(FFmpeg_HWACCEL_FLAGS)
587 set(FFmpeg_HWACCEL_INCLUDE_DIRS)
588 set(FFmpeg_HWACCEL_LDFLAGS)
589
590 if(LIBVA_FOUND)
591 pkg_check_modules(LIBDRM libdrm REQUIRED)
592 find_package(X11 REQUIRED)
593 pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
594 pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
595 list(APPEND FFmpeg_HWACCEL_LIBRARIES
596 ${LIBDRM_LIBRARIES}
597 ${X11_LIBRARIES}
598 ${LIBVA-DRM_LIBRARIES}
599 ${LIBVA-X11_LIBRARIES}
600 ${LIBVA_LIBRARIES})
601 set(FFmpeg_HWACCEL_FLAGS
602 --enable-hwaccel=h264_vaapi
603 --enable-hwaccel=vp8_vaapi
604 --enable-hwaccel=vp9_vaapi
605 --enable-libdrm)
606 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
607 ${LIBDRM_INCLUDE_DIRS}
608 ${X11_INCLUDE_DIRS}
609 ${LIBVA-DRM_INCLUDE_DIRS}
610 ${LIBVA-X11_INCLUDE_DIRS}
611 ${LIBVA_INCLUDE_DIRS}
612 )
613 message(STATUS "VA-API found")
614 else()
615 set(FFmpeg_HWACCEL_FLAGS --disable-vaapi)
616 endif()
617
618 if (FFNVCODEC_FOUND AND CUDA_FOUND)
619 list(APPEND FFmpeg_HWACCEL_FLAGS
620 --enable-cuvid
621 --enable-ffnvcodec
622 --enable-nvdec
623 --enable-hwaccel=h264_nvdec
624 --enable-hwaccel=vp8_nvdec
625 --enable-hwaccel=vp9_nvdec
626 --extra-cflags=-I${CUDA_INCLUDE_DIRS}
627 )
628 list(APPEND FFmpeg_HWACCEL_LIBRARIES
629 ${FFNVCODEC_LIBRARIES}
630 ${CUDA_LIBRARIES}
631 )
632 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
633 ${FFNVCODEC_INCLUDE_DIRS}
634 ${CUDA_INCLUDE_DIRS}
635 )
636 list(APPEND FFmpeg_HWACCEL_LDFLAGS
637 ${FFNVCODEC_LDFLAGS}
638 ${CUDA_LDFLAGS}
639 )
640 message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found")
641 endif()
642
643 if (VDPAU_FOUND)
644 list(APPEND FFmpeg_HWACCEL_FLAGS
645 --enable-vdpau
646 --enable-hwaccel=h264_vdpau
647 --enable-hwaccel=vp9_vdpau
648 )
649 list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
650 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
651 list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
652 message(STATUS "vdpau libraries version ${VDPAU_VERSION} found")
653 else()
654 list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
655 endif()
656
657 # `configure` parameters builds only exactly what yuzu needs from FFmpeg
658 # `--disable-vdpau` is needed to avoid linking issues
659 add_custom_command(
660 OUTPUT
661 ${FFmpeg_MAKEFILE}
662 COMMAND
663 /bin/bash ${FFmpeg_PREFIX}/configure
664 --disable-avdevice
665 --disable-avfilter
666 --disable-avformat
667 --disable-doc
668 --disable-everything
669 --disable-ffmpeg
670 --disable-ffprobe
671 --disable-network
672 --disable-postproc
673 --disable-swresample
674 --enable-decoder=h264
675 --enable-decoder=vp8
676 --enable-decoder=vp9
677 --cc="${CMAKE_C_COMPILER}"
678 --cxx="${CMAKE_CXX_COMPILER}"
679 ${FFmpeg_HWACCEL_FLAGS}
680 WORKING_DIRECTORY
681 ${FFmpeg_BUILD_DIR}
682 )
683 unset(FFmpeg_HWACCEL_FLAGS)
684
685 # Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
686 # with context of the jobserver. Also helps ninja users.
687 execute_process(
688 COMMAND
689 nproc
690 OUTPUT_VARIABLE
691 SYSTEM_THREADS)
692
693 set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
694 add_custom_command(
695 OUTPUT
696 ${FFmpeg_BUILD_LIBRARIES}
697 COMMAND
698 make -j${SYSTEM_THREADS}
699 WORKING_DIRECTORY
700 ${FFmpeg_BUILD_DIR}
701 )
702
703 set(FFmpeg_INCLUDE_DIR
704 "${FFmpeg_PREFIX};${FFmpeg_BUILD_DIR};${FFmpeg_HWACCEL_INCLUDE_DIRS}"
705 CACHE PATH "Path to FFmpeg headers" FORCE)
706
707 set(FFmpeg_LDFLAGS
708 "${FFmpeg_HWACCEL_LDFLAGS}"
709 CACHE STRING "FFmpeg linker flags" FORCE)
710
711 # ALL makes this custom target build every time
712 # but it won't actually build if the DEPENDS parameter is up to date
713 add_custom_target(ffmpeg-configure ALL DEPENDS ${FFmpeg_MAKEFILE})
714 add_custom_target(ffmpeg-build ALL DEPENDS ${FFmpeg_BUILD_LIBRARIES} ffmpeg-configure)
715 link_libraries(${FFmpeg_LIBVA_LIBRARIES})
716 set(FFmpeg_LIBRARIES ${FFmpeg_BUILD_LIBRARIES} ${FFmpeg_HWACCEL_LIBRARIES}
717 CACHE PATH "Paths to FFmpeg libraries" FORCE)
718 unset(FFmpeg_BUILD_LIBRARIES)
719 unset(FFmpeg_HWACCEL_FLAGS)
720 unset(FFmpeg_HWACCEL_INCLUDE_DIRS)
721 unset(FFmpeg_HWACCEL_LDFLAGS)
722 unset(FFmpeg_HWACCEL_LIBRARIES)
723
724 if (FFmpeg_FOUND)
725 message(STATUS "Found FFmpeg version ${FFmpeg_VERSION}")
726 else()
727 message(FATAL_ERROR "FFmpeg not found")
728 endif()
729 else() # WIN32
730 # Use yuzu FFmpeg binaries
731 set(FFmpeg_EXT_NAME "ffmpeg-4.4")
732 set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}")
733 download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "")
734 set(FFmpeg_FOUND YES)
735 set(FFmpeg_INCLUDE_DIR "${FFmpeg_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE)
736 set(FFmpeg_LIBRARY_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE)
737 set(FFmpeg_LDFLAGS "" CACHE STRING "FFmpeg linker flags" FORCE)
738 set(FFmpeg_DLL_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE)
739 set(FFmpeg_LIBRARIES
740 ${FFmpeg_LIBRARY_DIR}/swscale.lib
741 ${FFmpeg_LIBRARY_DIR}/avcodec.lib
742 ${FFmpeg_LIBRARY_DIR}/avutil.lib
743 CACHE PATH "Paths to FFmpeg libraries" FORCE)
744 endif()
745endif()
746
747unset(FFmpeg_COMPONENTS)
748
749# Prefer the -pthread flag on Linux. 535# Prefer the -pthread flag on Linux.
750set(THREADS_PREFER_PTHREAD_FLAG ON) 536set(THREADS_PREFER_PTHREAD_FLAG ON)
751find_package(Threads REQUIRED) 537find_package(Threads REQUIRED)
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 64d1e6aec..bbbe6667d 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -121,3 +121,8 @@ if (NOT opus_FOUND)
121 message(STATUS "opus 1.3 or newer not found, falling back to externals") 121 message(STATUS "opus 1.3 or newer not found, falling back to externals")
122 add_subdirectory(opus EXCLUDE_FROM_ALL) 122 add_subdirectory(opus EXCLUDE_FROM_ALL)
123endif() 123endif()
124
125# FFMpeg
126if (YUZU_USE_BUNDLED_FFMPEG)
127 add_subdirectory(ffmpeg)
128endif()
diff --git a/externals/ffmpeg b/externals/ffmpeg
deleted file mode 160000
Subproject 79e8d17024e6c6328a40fcee191ffd70798a9c6
diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt
new file mode 100644
index 000000000..7da89d2c5
--- /dev/null
+++ b/externals/ffmpeg/CMakeLists.txt
@@ -0,0 +1,209 @@
1if (NOT WIN32)
2 # Build FFmpeg from externals
3 message(STATUS "Using FFmpeg from externals")
4
5 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
6 # FFmpeg has source that requires one of nasm or yasm to assemble it.
7 # REQUIRED throws an error if not found here during configuration rather than during compilation.
8 find_program(ASSEMBLER NAMES nasm yasm)
9 if ("${ASSEMBLER}" STREQUAL "ASSEMBLER-NOTFOUND")
10 message(FATAL_ERROR "One of either `nasm` or `yasm` not found but is required.")
11 endif()
12 endif()
13
14 find_program(AUTOCONF autoconf)
15 if ("${AUTOCONF}" STREQUAL "AUTOCONF-NOTFOUND")
16 message(FATAL_ERROR "Required program `autoconf` not found.")
17 endif()
18
19 set(FFmpeg_PREFIX ${PROJECT_SOURCE_DIR}/externals/ffmpeg/ffmpeg)
20 set(FFmpeg_BUILD_DIR ${PROJECT_BINARY_DIR}/externals/ffmpeg-build)
21 set(FFmpeg_MAKEFILE ${FFmpeg_BUILD_DIR}/Makefile)
22 make_directory(${FFmpeg_BUILD_DIR})
23
24 # Read version string from external
25 file(READ ${FFmpeg_PREFIX}/RELEASE FFmpeg_VERSION)
26 set(FFmpeg_FOUND NO)
27 if (NOT FFmpeg_VERSION STREQUAL "")
28 set(FFmpeg_FOUND YES)
29 endif()
30
31 unset(FFmpeg_LIBRARIES CACHE)
32 foreach(COMPONENT ${FFmpeg_COMPONENTS})
33 set(FFmpeg_${COMPONENT}_PREFIX "${FFmpeg_BUILD_DIR}/lib${COMPONENT}")
34 set(FFmpeg_${COMPONENT}_LIB_NAME "lib${COMPONENT}.a")
35 set(FFmpeg_${COMPONENT}_LIBRARY "${FFmpeg_${COMPONENT}_PREFIX}/${FFmpeg_${COMPONENT}_LIB_NAME}")
36
37 set(FFmpeg_LIBRARIES
38 ${FFmpeg_LIBRARIES}
39 ${FFmpeg_${COMPONENT}_LIBRARY}
40 CACHE PATH "Paths to FFmpeg libraries" FORCE)
41 endforeach()
42
43 Include(FindPkgConfig REQUIRED)
44 pkg_check_modules(LIBVA libva)
45 pkg_check_modules(CUDA cuda)
46 pkg_check_modules(FFNVCODEC ffnvcodec)
47 pkg_check_modules(VDPAU vdpau)
48
49 set(FFmpeg_HWACCEL_LIBRARIES)
50 set(FFmpeg_HWACCEL_FLAGS)
51 set(FFmpeg_HWACCEL_INCLUDE_DIRS)
52 set(FFmpeg_HWACCEL_LDFLAGS)
53
54 if(LIBVA_FOUND)
55 pkg_check_modules(LIBDRM libdrm REQUIRED)
56 find_package(X11 REQUIRED)
57 pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
58 pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
59 list(APPEND FFmpeg_HWACCEL_LIBRARIES
60 ${LIBDRM_LIBRARIES}
61 ${X11_LIBRARIES}
62 ${LIBVA-DRM_LIBRARIES}
63 ${LIBVA-X11_LIBRARIES}
64 ${LIBVA_LIBRARIES})
65 set(FFmpeg_HWACCEL_FLAGS
66 --enable-hwaccel=h264_vaapi
67 --enable-hwaccel=vp8_vaapi
68 --enable-hwaccel=vp9_vaapi
69 --enable-libdrm)
70 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
71 ${LIBDRM_INCLUDE_DIRS}
72 ${X11_INCLUDE_DIRS}
73 ${LIBVA-DRM_INCLUDE_DIRS}
74 ${LIBVA-X11_INCLUDE_DIRS}
75 ${LIBVA_INCLUDE_DIRS}
76 )
77 message(STATUS "VA-API found")
78 else()
79 set(FFmpeg_HWACCEL_FLAGS --disable-vaapi)
80 endif()
81
82 if (FFNVCODEC_FOUND)
83 list(APPEND FFmpeg_HWACCEL_FLAGS
84 --enable-cuvid
85 --enable-ffnvcodec
86 --enable-nvdec
87 --enable-hwaccel=h264_nvdec
88 --enable-hwaccel=vp8_nvdec
89 --enable-hwaccel=vp9_nvdec
90 )
91 list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES})
92 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS})
93 list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS})
94 message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found")
95 # ffnvenc could load CUDA libraries at the runtime using dlopen/dlsym or LoadLibrary/GetProcAddress
96 # here we handle the hard-linking senario where CUDA is linked during compilation
97 if (CUDA_FOUND)
98 list(APPEND FFmpeg_HWACCEL_FLAGS --extra-cflags=-I${CUDA_INCLUDE_DIRS})
99 list(APPEND FFmpeg_HWACCEL_LIBRARIES ${CUDA_LIBRARIES})
100 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
101 list(APPEND FFmpeg_HWACCEL_LDFLAGS ${CUDA_LDFLAGS})
102 message(STATUS "CUDA libraries found, hard-linking will be performed")
103 endif(CUDA_FOUND)
104 endif()
105
106 if (VDPAU_FOUND)
107 list(APPEND FFmpeg_HWACCEL_FLAGS
108 --enable-vdpau
109 --enable-hwaccel=h264_vdpau
110 --enable-hwaccel=vp9_vdpau
111 )
112 list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
113 list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
114 list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
115 message(STATUS "vdpau libraries version ${VDPAU_VERSION} found")
116 else()
117 list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
118 endif()
119
120 # `configure` parameters builds only exactly what yuzu needs from FFmpeg
121 # `--disable-vdpau` is needed to avoid linking issues
122 add_custom_command(
123 OUTPUT
124 ${FFmpeg_MAKEFILE}
125 COMMAND
126 /bin/bash ${FFmpeg_PREFIX}/configure
127 --disable-avdevice
128 --disable-avfilter
129 --disable-avformat
130 --disable-doc
131 --disable-everything
132 --disable-ffmpeg
133 --disable-ffprobe
134 --disable-network
135 --disable-postproc
136 --disable-swresample
137 --enable-decoder=h264
138 --enable-decoder=vp8
139 --enable-decoder=vp9
140 --cc="${CMAKE_C_COMPILER}"
141 --cxx="${CMAKE_CXX_COMPILER}"
142 ${FFmpeg_HWACCEL_FLAGS}
143 WORKING_DIRECTORY
144 ${FFmpeg_BUILD_DIR}
145 )
146 unset(FFmpeg_HWACCEL_FLAGS)
147
148 # Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
149 # with context of the jobserver. Also helps ninja users.
150 execute_process(
151 COMMAND
152 nproc
153 OUTPUT_VARIABLE
154 SYSTEM_THREADS)
155
156 set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
157 add_custom_command(
158 OUTPUT
159 ${FFmpeg_BUILD_LIBRARIES}
160 COMMAND
161 make -j${SYSTEM_THREADS}
162 WORKING_DIRECTORY
163 ${FFmpeg_BUILD_DIR}
164 )
165
166 set(FFmpeg_INCLUDE_DIR
167 "${FFmpeg_PREFIX};${FFmpeg_BUILD_DIR};${FFmpeg_HWACCEL_INCLUDE_DIRS}"
168 CACHE PATH "Path to FFmpeg headers" FORCE)
169
170 set(FFmpeg_LDFLAGS
171 "${FFmpeg_HWACCEL_LDFLAGS}"
172 CACHE STRING "FFmpeg linker flags" FORCE)
173
174 # ALL makes this custom target build every time
175 # but it won't actually build if the DEPENDS parameter is up to date
176 add_custom_target(ffmpeg-configure ALL DEPENDS ${FFmpeg_MAKEFILE})
177 add_custom_target(ffmpeg-build ALL DEPENDS ${FFmpeg_BUILD_LIBRARIES} ffmpeg-configure)
178 link_libraries(${FFmpeg_LIBVA_LIBRARIES})
179 set(FFmpeg_LIBRARIES ${FFmpeg_BUILD_LIBRARIES} ${FFmpeg_HWACCEL_LIBRARIES}
180 CACHE PATH "Paths to FFmpeg libraries" FORCE)
181 unset(FFmpeg_BUILD_LIBRARIES)
182 unset(FFmpeg_HWACCEL_FLAGS)
183 unset(FFmpeg_HWACCEL_INCLUDE_DIRS)
184 unset(FFmpeg_HWACCEL_LDFLAGS)
185 unset(FFmpeg_HWACCEL_LIBRARIES)
186
187 if (FFmpeg_FOUND)
188 message(STATUS "Found FFmpeg version ${FFmpeg_VERSION}")
189 else()
190 message(FATAL_ERROR "FFmpeg not found")
191 endif()
192else(WIN32)
193 # Use yuzu FFmpeg binaries
194 set(FFmpeg_EXT_NAME "ffmpeg-4.4")
195 set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}")
196 download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "")
197 set(FFmpeg_FOUND YES)
198 set(FFmpeg_INCLUDE_DIR "${FFmpeg_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE)
199 set(FFmpeg_LIBRARY_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE)
200 set(FFmpeg_LDFLAGS "" CACHE STRING "FFmpeg linker flags" FORCE)
201 set(FFmpeg_DLL_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE)
202 set(FFmpeg_LIBRARIES
203 ${FFmpeg_LIBRARY_DIR}/swscale.lib
204 ${FFmpeg_LIBRARY_DIR}/avcodec.lib
205 ${FFmpeg_LIBRARY_DIR}/avutil.lib
206 CACHE PATH "Paths to FFmpeg libraries" FORCE)
207endif(WIN32)
208
209unset(FFmpeg_COMPONENTS)
diff --git a/externals/ffmpeg/ffmpeg b/externals/ffmpeg/ffmpeg
new file mode 160000
Subproject dc91b913b6260e85e1304c74ff7bb3c22a8c9fb
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index 2a532b883..868b82f9b 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -130,6 +130,12 @@ bool Codec::CreateGpuAvDevice() {
130 } 130 }
131 if (config->methods & HW_CONFIG_METHOD && config->device_type == type) { 131 if (config->methods & HW_CONFIG_METHOD && config->device_type == type) {
132 av_codec_ctx->pix_fmt = config->pix_fmt; 132 av_codec_ctx->pix_fmt = config->pix_fmt;
133 if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) {
134 // skip zero-copy decoders, we don't currently support them
135 LOG_DEBUG(Service_NVDRV, "Skipping decoder {} with unsupported capability {}.",
136 av_hwdevice_get_type_name(type), config->methods);
137 continue;
138 }
133 LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type)); 139 LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
134 return true; 140 return true;
135 } 141 }