ppsspp: add upstream patch for FFmpeg 6

The bundled FFmpeg is used by default anyway, but this fixes
compilation with FFmpeg 6 when opting in.

Emily edfb47e9 9e941963

+176 -5
+170
pkgs/by-name/pp/ppsspp/fix-ffmpeg-6.patch
··· 1 + Backported from <https://github.com/hrydgard/ppsspp/commit/930b7f644d74c74d9e58bf8e5300bf9ea9fb78a9>. 2 + 3 + Original author: Andrew Udvare <audvare@gmail.com> 4 + 5 + diff --git a/CMakeLists.txt b/CMakeLists.txt 6 + index bfd5e69035..f7c43800fa 100644 7 + --- a/CMakeLists.txt 8 + +++ b/CMakeLists.txt 9 + @@ -117,6 +117,7 @@ 10 + endif() 11 + 12 + include(ccache) 13 + +include(CheckCXXSourceCompiles) 14 + include(GNUInstallDirs) 15 + 16 + add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/") 17 + @@ -949,6 +950,23 @@ 18 + endif() 19 + 20 + find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale) 21 + + # Check if we need to use avcodec_(alloc|free)_frame instead of av_frame_(alloc|free) 22 + + # Check if we need to use const AVCodec 23 + + set(CMAKE_REQUIRED_LIBRARIES avcodec;avformat) 24 + + set(CMAKE_REQUIRED_FLAGS "-pedantic -Wall -Werror -Wno-unused-variable") 25 + + check_cxx_source_compiles("extern \"C\" { 26 + + #include <libavcodec/avcodec.h> 27 + + #include <libavformat/avformat.h> 28 + + } 29 + + static AVCodecContext *s_codec_context = NULL; 30 + + int main() { 31 + + const AVCodec *codec = avcodec_find_encoder(s_codec_context->codec_id); 32 + + return 0; 33 + + } 34 + + " HAVE_LIBAVCODEC_CONST_AVCODEC FAIL_REGEX "invalid conversion") 35 + + 36 + + # Check if we need to use avcodec_alloc_context3 instead of stream->codec 37 + + # Check if we need to use av_frame_get_buffer instead of avcodec_default_get_buffer 38 + endif(USE_FFMPEG) 39 + 40 + find_package(ZLIB) 41 + @@ -2020,6 +2038,7 @@ 42 + Core/ELF/PrxDecrypter.h 43 + Core/ELF/ParamSFO.cpp 44 + Core/ELF/ParamSFO.h 45 + + Core/FFMPEGCompat.h 46 + Core/FileSystems/tlzrc.cpp 47 + Core/FileSystems/BlobFileSystem.cpp 48 + Core/FileSystems/BlobFileSystem.h 49 + @@ -2354,6 +2373,9 @@ 50 + 51 + if(FFmpeg_FOUND) 52 + target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1) 53 + + if (HAVE_LIBAVCODEC_CONST_AVCODEC) 54 + + target_compile_definitions(${CoreLibName} PRIVATE HAVE_LIBAVCODEC_CONST_AVCODEC=1) 55 + + endif() 56 + set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true) 57 + target_include_directories(${CoreLibName} BEFORE PUBLIC ${FFmpeg_INCLUDE_avcodec}) 58 + target_link_libraries(${CoreLibName} 59 + diff --git a/Core/AVIDump.cpp b/Core/AVIDump.cpp 60 + index 7c9576d292..aa81165031 100644 61 + --- a/Core/AVIDump.cpp 62 + +++ b/Core/AVIDump.cpp 63 + @@ -45,9 +45,7 @@ 64 + #define av_frame_free avcodec_free_frame 65 + #endif 66 + 67 + -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100) 68 + -#define AVCodec const AVCodec 69 + -#endif 70 + +#include "FFMPEGCompat.h" 71 + 72 + static AVFormatContext *s_format_context = nullptr; 73 + static AVCodecContext *s_codec_context = nullptr; 74 + diff --git a/Core/FFMPEGCompat.h b/Core/FFMPEGCompat.h 75 + new file mode 100644 76 + index 0000000000..fed3b1c853 77 + --- /dev/null 78 + +++ b/Core/FFMPEGCompat.h 79 + @@ -1,0 +1,8 @@ 80 + +#ifndef FFMPEG_COMPAT_H 81 + +#define FFMPEG_COMPAT_H 82 + + 83 + +#ifdef HAVE_LIBAVCODEC_CONST_AVCODEC 84 + +#define AVCodec const AVCodec 85 + +#endif 86 + + 87 + +#endif // FFMPEG_COMPAT_H 88 + diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp 89 + index fe0e8a54de..f83d9ffdf1 100644 90 + --- a/Core/HLE/sceAtrac.cpp 91 + +++ b/Core/HLE/sceAtrac.cpp 92 + @@ -129,10 +129,7 @@ 93 + #include "libavcodec/avcodec.h" 94 + #include "libavutil/version.h" 95 + } 96 + - 97 + -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100) 98 + -#define AVCodec const AVCodec 99 + -#endif 100 + +#include "Core/FFMPEGCompat.h" 101 + 102 + #endif // USE_FFMPEG 103 + 104 + diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp 105 + index d050d62f3d..8be78c73e0 100644 106 + --- a/Core/HLE/sceMpeg.cpp 107 + +++ b/Core/HLE/sceMpeg.cpp 108 + @@ -113,9 +113,7 @@ 109 + #include "libswscale/swscale.h" 110 + #include "libavcodec/avcodec.h" 111 + } 112 + -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100) 113 + -#define AVCodec const AVCodec 114 + -#endif 115 + +#include "Core/FFMPEGCompat.h" 116 + static AVPixelFormat pmp_want_pix_fmt; 117 + 118 + #endif 119 + diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp 120 + index 0ed957edfd..7e8b37d4dc 100644 121 + --- a/Core/HW/MediaEngine.cpp 122 + +++ b/Core/HW/MediaEngine.cpp 123 + @@ -56,9 +56,7 @@ 124 + 125 + #ifdef USE_FFMPEG 126 + 127 + -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100) 128 + -#define AVCodec const AVCodec 129 + -#endif 130 + +#include "Core/FFMPEGCompat.h" 131 + 132 + static AVPixelFormat getSwsFormat(int pspFormat) 133 + { 134 + diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp 135 + index 7994a7f402..80397bf6da 100644 136 + --- a/Core/HW/SimpleAudioDec.cpp 137 + +++ b/Core/HW/SimpleAudioDec.cpp 138 + @@ -33,6 +33,7 @@ 139 + #include "libavutil/samplefmt.h" 140 + #include "libavcodec/avcodec.h" 141 + } 142 + +#include "Core/FFMPEGCompat.h" 143 + 144 + #endif // USE_FFMPEG 145 + 146 + diff --git a/Core/HW/SimpleAudioDec.h b/Core/HW/SimpleAudioDec.h 147 + index 52a78bf3b4..9bf2427a4a 100644 148 + --- a/Core/HW/SimpleAudioDec.h 149 + +++ b/Core/HW/SimpleAudioDec.h 150 + @@ -33,10 +33,6 @@ 151 + #include "libavutil/version.h" 152 + }; 153 + 154 + -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100) 155 + -#define AVCodec const AVCodec 156 + -#endif 157 + - 158 + #endif 159 + 160 + // Wraps FFMPEG for audio decoding in a nice interface. 161 + @@ -90,6 +86,9 @@ 162 + int wanted_resample_freq; // wanted resampling rate/frequency 163 + 164 + AVFrame *frame_; 165 + +#if HAVE_LIBAVCODEC_CONST_AVCODEC // USE_FFMPEG is implied 166 + + const 167 + +#endif 168 + AVCodec *codec_; 169 + AVCodecContext *codecCtx_; 170 + SwrContext *swrCtx_;
+6 -2
pkgs/by-name/pp/ppsspp/package.nix
··· 4 4 cmake, 5 5 copyDesktopItems, 6 6 fetchFromGitHub, 7 - ffmpeg, 7 + ffmpeg_6, 8 8 glew, 9 9 libffi, 10 10 libsForQt5, ··· 48 48 hash = "sha256-I84zJqEE1X/eo/ukeGA2iZe3lWKvilk+RNGUzl2wZXY="; 49 49 }; 50 50 51 + patches = lib.optionals useSystemFfmpeg [ 52 + ./fix-ffmpeg-6.patch 53 + ]; 54 + 51 55 postPatch = '' 52 56 substituteInPlace git-version.cmake --replace unknown ${finalAttrs.src.rev} 53 57 substituteInPlace UI/NativeApp.cpp --replace /usr/share $out/share ··· 69 73 zlib 70 74 ] 71 75 ++ lib.optionals useSystemFfmpeg [ 72 - ffmpeg 76 + ffmpeg_6 73 77 ] 74 78 ++ lib.optionals useSystemSnappy [ 75 79 snappy
-3
pkgs/top-level/all-packages.nix
··· 2673 2673 2674 2674 ppsspp-sdl = let 2675 2675 argset = { 2676 - ffmpeg = ffmpeg_4; 2677 2676 enableQt = false; 2678 2677 enableVulkan = true; 2679 2678 forceWayland = false; ··· 2683 2682 2684 2683 ppsspp-sdl-wayland = let 2685 2684 argset = { 2686 - ffmpeg = ffmpeg_4; 2687 2685 enableQt = false; 2688 2686 enableVulkan = false; # https://github.com/hrydgard/ppsspp/issues/13845 2689 2687 forceWayland = true; ··· 2693 2691 2694 2692 ppsspp-qt = let 2695 2693 argset = { 2696 - ffmpeg = ffmpeg_4; 2697 2694 enableQt = true; 2698 2695 enableVulkan = false; # https://github.com/hrydgard/ppsspp/issues/11628 2699 2696 forceWayland = false;