Allow movie support to be compiled out

(and therefore remove the libjpeg-turbo dependency)
This commit is contained in:
PJB3005
2026-03-29 03:07:03 +02:00
parent 654a7a6f4c
commit 58ca78ea80
2 changed files with 24 additions and 5 deletions
+13 -3
View File
@@ -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)
+11 -2
View File
@@ -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<u8> 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) {