diff options
| author | 2021-12-15 00:02:53 -0800 | |
|---|---|---|
| committer | 2021-12-15 00:02:53 -0800 | |
| commit | 2f32133ad5e13503c56bc5c910407a27cc23908b (patch) | |
| tree | 486a47945aa83e2842f54dce2e9f153d396a1886 | |
| parent | Merge pull request #7565 from liushuyu/fix-linux-decoding (diff) | |
| download | yuzu-2f32133ad5e13503c56bc5c910407a27cc23908b.tar.gz yuzu-2f32133ad5e13503c56bc5c910407a27cc23908b.tar.xz yuzu-2f32133ad5e13503c56bc5c910407a27cc23908b.zip | |
Revert "video_core/codecs: refactor ffmpeg searching and handling in cmake"
| -rwxr-xr-x | .ci/scripts/windows/docker.sh | 5 | ||||
| -rw-r--r-- | .gitmodules | 6 | ||||
| -rw-r--r-- | CMakeLists.txt | 218 | ||||
| -rw-r--r-- | externals/CMakeLists.txt | 5 | ||||
| m--------- | externals/ffmpeg | 0 | ||||
| -rw-r--r-- | externals/ffmpeg/CMakeLists.txt | 209 | ||||
| m--------- | externals/ffmpeg/ffmpeg | 0 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.cpp | 6 |
8 files changed, 222 insertions, 227 deletions
diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh index 584b9b39f..155d8a5c8 100755 --- a/.ci/scripts/windows/docker.sh +++ b/.ci/scripts/windows/docker.sh | |||
| @@ -41,11 +41,12 @@ for i in package/*.exe; do | |||
| 41 | done | 41 | done |
| 42 | 42 | ||
| 43 | pip3 install pefile | 43 | pip3 install pefile |
| 44 | python3 .ci/scripts/windows/scan_dll.py package/*.exe package/imageformats/*.dll "package/" | 44 | python3 .ci/scripts/windows/scan_dll.py package/*.exe "package/" |
| 45 | python3 .ci/scripts/windows/scan_dll.py package/imageformats/*.dll "package/" | ||
| 45 | 46 | ||
| 46 | # copy FFmpeg libraries | 47 | # copy FFmpeg libraries |
| 47 | EXTERNALS_PATH="$(pwd)/build/externals" | 48 | EXTERNALS_PATH="$(pwd)/build/externals" |
| 48 | FFMPEG_DLL_PATH="$(find "${EXTERNALS_PATH}" -maxdepth 1 -type d | grep 'ffmpeg-')/bin" | 49 | FFMPEG_DLL_PATH="$(find ${EXTERNALS_PATH} -maxdepth 1 -type d | grep ffmpeg)/bin" |
| 49 | find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';' | 50 | find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';' |
| 50 | 51 | ||
| 51 | # copy libraries from yuzu.exe path | 52 | # copy libraries from yuzu.exe path |
diff --git a/.gitmodules b/.gitmodules index a9cf9a24a..dc6ed500f 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 | ||
| 37 | [submodule "SDL"] | 40 | [submodule "SDL"] |
| 38 | path = externals/SDL | 41 | path = externals/SDL |
| 39 | url = https://github.com/libsdl-org/SDL.git | 42 | url = https://github.com/libsdl-org/SDL.git |
| 40 | [submodule "externals/cpp-httplib"] | 43 | [submodule "externals/cpp-httplib"] |
| 41 | path = externals/cpp-httplib | 44 | path = externals/cpp-httplib |
| 42 | url = https://github.com/yhirose/cpp-httplib.git | 45 | 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 18d553f4d..a810e11c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -514,7 +514,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | |||
| 514 | endif() | 514 | endif() |
| 515 | if (NOT YUZU_USE_BUNDLED_FFMPEG) | 515 | if (NOT YUZU_USE_BUNDLED_FFMPEG) |
| 516 | # Use system installed FFmpeg | 516 | # Use system installed FFmpeg |
| 517 | find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS}) | 517 | find_package(FFmpeg 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,11 +527,225 @@ 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 or too old, falling back to externals") | 530 | message(WARNING "FFmpeg not found, falling back to externals") |
| 531 | set(YUZU_USE_BUNDLED_FFMPEG ON) | 531 | set(YUZU_USE_BUNDLED_FFMPEG ON) |
| 532 | endif() | 532 | endif() |
| 533 | endif() | 533 | endif() |
| 534 | 534 | ||
| 535 | if (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() | ||
| 745 | endif() | ||
| 746 | |||
| 747 | unset(FFmpeg_COMPONENTS) | ||
| 748 | |||
| 535 | # Prefer the -pthread flag on Linux. | 749 | # Prefer the -pthread flag on Linux. |
| 536 | set(THREADS_PREFER_PTHREAD_FLAG ON) | 750 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 537 | find_package(Threads REQUIRED) | 751 | find_package(Threads REQUIRED) |
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index bbbe6667d..64d1e6aec 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt | |||
| @@ -121,8 +121,3 @@ 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) |
| 123 | endif() | 123 | endif() |
| 124 | |||
| 125 | # FFMpeg | ||
| 126 | if (YUZU_USE_BUNDLED_FFMPEG) | ||
| 127 | add_subdirectory(ffmpeg) | ||
| 128 | endif() | ||
diff --git a/externals/ffmpeg b/externals/ffmpeg new file mode 160000 | |||
| Subproject 79e8d17024e6c6328a40fcee191ffd70798a9c6 | |||
diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt deleted file mode 100644 index 7da89d2c5..000000000 --- a/externals/ffmpeg/CMakeLists.txt +++ /dev/null | |||
| @@ -1,209 +0,0 @@ | |||
| 1 | if (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() | ||
| 192 | else(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) | ||
| 207 | endif(WIN32) | ||
| 208 | |||
| 209 | unset(FFmpeg_COMPONENTS) | ||
diff --git a/externals/ffmpeg/ffmpeg b/externals/ffmpeg/ffmpeg deleted 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 868b82f9b..2a532b883 100644 --- a/src/video_core/command_classes/codecs/codec.cpp +++ b/src/video_core/command_classes/codecs/codec.cpp | |||
| @@ -130,12 +130,6 @@ 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 | } | ||
| 139 | LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type)); | 133 | LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type)); |
| 140 | return true; | 134 | return true; |
| 141 | } | 135 | } |