From 58ca78ea80e449784cbea6500fffee270d354b0f Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Sun, 29 Mar 2026 03:07:03 +0200 Subject: [PATCH] Allow movie support to be compiled out (and therefore remove the libjpeg-turbo dependency) --- CMakeLists.txt | 16 +++++++++++++--- src/d/actor/d_a_movie_player.cpp | 13 +++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fea651943..797b055c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) option(DUSK_BUILD_WARNINGS "If off, compiler warnings will be suppressed") option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled with optimizations on Debug, intending to make the game run at 30 FPS. Note for MSVC: you will need to remove '/RTC1' from your debug flags in CMake.") +option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) if (CMAKE_SYSTEM_NAME STREQUAL Linux) # -Wno-multichar: Multi-character constants ('ABCD') are implementation-defined but all compilers @@ -52,7 +53,10 @@ endif () include(FetchContent) -include(ExternalProject) + +if (DUSK_MOVIE_SUPPORT) + include(ExternalProject) +endif () message(STATUS "dusk: Fetching cxxopts") FetchContent_Declare( @@ -63,7 +67,9 @@ FetchContent_Declare( FetchContent_MakeAvailable(cxxopts) -include(cmake/libjpeg.cmake) +if (DUSK_MOVIE_SUPPORT) + include(cmake/libjpeg.cmake) +endif () include(files.cmake) # TODO: version handling for res includes @@ -109,7 +115,11 @@ add_library(game SHARED ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${J src/dusk/imgui/ImGuiStubLog.cpp src/dusk/imgui/ImGuiAudio.cpp) -target_link_libraries(game PRIVATE game_debug cxxopts::cxxopts libjpeg-turbo-lib) +target_link_libraries(game PRIVATE game_debug cxxopts::cxxopts) +if (DUSK_MOVIE_SUPPORT) + target_link_libraries(game PRIVATE libjpeg-turbo-lib) + target_compile_definitions(game PRIVATE MOVIE_SUPPORT=1) +endif () target_compile_definitions(game PRIVATE TARGET_PC AVOID_UB=1 VERSION=0 NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0 DUSK_TP_VERSION="${DUSK_TP_VERSION}" DUSK_GAME_NAME="${DUSK_GAME_NAME}" DUSK_GAME_VERSION="${DUSK_GAME_VERSION}") add_executable(dusk src/dusk/main.cpp) diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 2cbfc8dc82..d117dd3fa0 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -31,7 +31,10 @@ #include "dusk/layout.hpp" #include "JSystem/JAudio2/JASCriticalSection.h" + +#if MOVIE_SUPPORT #include "turbojpeg.h" +#endif inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { return *(BE(s32)*)readBuf->ptr; @@ -2582,6 +2585,7 @@ static void __THPHuffDecodeDCTCompV(__REGISTER THPFileInfo* info, THPCoeff* bloc } #else // !TARGET_PC +#if MOVIE_SUPPORT static std::vector FixedJpegData; static tjhandle JpegDecompressHandle; @@ -2673,6 +2677,11 @@ static s32 THPVideoDecode(void* file, size_t fileSize, void* tileY, void* tileU, return 0; } +#else // MOVIE_SUPPORT +static s32 THPVideoDecode(void*, size_t, void*, void*, void*, void*) { + return 1; // Immediate error. +} +#endif #endif static BOOL THPInit() { @@ -3767,7 +3776,7 @@ static BOOL daMP_THPPlayerOpen(char const* filename, BOOL onMemory) { } static BOOL daMP_THPPlayerClose() { -#if TARGET_PC +#if TARGET_PC && MOVIE_SUPPORT tj3Destroy(JpegDecompressHandle); JpegDecompressHandle = nullptr; @@ -4311,7 +4320,7 @@ static BOOL daMP_ActivePlayer_Init(char const* moviePath) { daMP_THPPlayerSetBuffer((u8*)daMP_buffer); -#if TARGET_PC +#if TARGET_PC && MOVIE_SUPPORT assert(JpegDecompressHandle == nullptr); JpegDecompressHandle = tj3Init(TJINIT_DECOMPRESS); if (JpegDecompressHandle == nullptr) {