diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 4d89ce320f..5acce1915c 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -128,12 +128,13 @@ jobs: -I.\apps\shared -I.\include -I.\third_party\iccjpeg -external:W0 -external:I.\ext\libpng - -external:I.\ext\libjpeg + -external:I.\ext\libjpeg-turbo + -external:I.\ext\libjpeg-turbo\build.libavif -external:I.\ext\zlib -external:I.\build\ext\libpng -external:I.\build\ext\zlib /link - build\ext\libjpeg\jpeg.lib + ext\libjpeg-turbo\build.libavif\jpeg-static.lib build\ext\libpng\libpng16_static.lib build\ext\zlib\zlibstatic.lib build\avif.lib diff --git a/.gitignore b/.gitignore index 0604ad53ed..96978dafd1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /ext/gpac /ext/libargparse /ext/libjpeg +/ext/libjpeg-turbo /ext/libgav1 /ext/libpng /ext/libwebp diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4c5d9f47..bb627bfbe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fix ID selection for artificial grid alpha item when decoding a grid of tiles which each have an associated auxiliary alpha image item (https://crbug.com/oss-fuzz/65657). +* ext/libjpeg.cmd now pulls libjpeg-turbo instead of libjpeg and AVIF_JPEG=LOCAL + now expects the library dependency in ext/libjpeg-turbo/build.libavif. ## [1.0.3] - 2023-12-03 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e41df1c66..330afc96bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -866,7 +866,7 @@ if(WIN32) avif_exclude_safe(minigzip) endif() if(AVIF_LOCAL_JPEG) - avif_set_folder_safe(jpeg "ext/libjpeg") + avif_set_folder_safe(JPEG::JPEG "ext/libjpeg-turbo") endif() if(AVIF_LOCAL_LIBXML2) avif_set_folder_safe(xml2 "ext/libxml2") diff --git a/cmake/Modules/LocalJpeg.cmake b/cmake/Modules/LocalJpeg.cmake index 6dfb6f7b5c..b91b0740e5 100644 --- a/cmake/Modules/LocalJpeg.cmake +++ b/cmake/Modules/LocalJpeg.cmake @@ -1,7 +1,18 @@ -add_subdirectory(${AVIF_SOURCE_DIR}/ext/libjpeg EXCLUDE_FROM_ALL) +set(LIB_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo/build.libavif") +if(MSVC) + set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg-static${CMAKE_STATIC_LIBRARY_SUFFIX}") +else() + set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() +if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") +endif() -set_property(TARGET jpeg PROPERTY AVIF_LOCAL ON) -set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg") -target_include_directories(jpeg INTERFACE ${JPEG_INCLUDE_DIR}) +add_library(JPEG::JPEG STATIC IMPORTED GLOBAL) +set_target_properties(JPEG::JPEG PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) +set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo") +target_include_directories(JPEG::JPEG INTERFACE "${JPEG_INCLUDE_DIR}") -add_library(JPEG::JPEG ALIAS jpeg) +# Also add the build directory path because it contains jconfig.h, +# which is included by jpeglib.h. +target_include_directories(JPEG::JPEG INTERFACE "${LIB_DIR}") diff --git a/ext/libjpeg.cmd b/ext/libjpeg.cmd index fdc37f1cc1..1cc5a47d22 100755 --- a/ext/libjpeg.cmd +++ b/ext/libjpeg.cmd @@ -1,7 +1,10 @@ : # If you want to use a local build of jpeg, you must clone the repos in this directory first, -: # then enable CMake's AVIF_LOCAL_JPEG. -: # This git tag isn't likely to move much, as libjpeg isn't actively developed anymore. +: # then set CMake's AVIF_JPEG=LOCAL. +: # The git tag below is known to work, and will occasionally be updated. Feel free to use a more recent commit. : # The odd choice of comment style in this file is to try to share this script between *nix and win32. -git clone --depth 1 https://github.com/joedrago/libjpeg.git +git clone -b 3.0.2 --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git + +cmake -S libjpeg-turbo -B libjpeg-turbo/build.libavif -G Ninja -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DWITH_TURBOJPEG=OFF +cmake --build libjpeg-turbo/build.libavif --parallel diff --git a/ext/zlibpng.cmd b/ext/zlibpng.cmd index bd16df8a0e..c257731242 100755 --- a/ext/zlibpng.cmd +++ b/ext/zlibpng.cmd @@ -1,5 +1,5 @@ : # If you want to use a local build of zlib/libpng, you must clone the repos in this directory first, -: # then enable CMake's AVIF_LOCAL_ZLIBPNG. +: # then set CMake's AVIF_ZLIBPNG=LOCAL. : # The git tags below are known to work, and will occasionally be updated. Feel free to use a more recent commit. : # The odd choice of comment style in this file is to try to share this script between *nix and win32.