Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.6.3

- Bump the version of libavif in deps.sh to v1.4.0.
- Bump the version of libheif in deps.sh to v1.21.2.
- Bump the version of libwebp2 in deps.sh to 8720150.
- Bump the version of libjxl in deps.sh to v0.11.2.
- Bump the version of openjpeg in deps.sh to v2.5.4.
- Bump the version of FFmpeg in deps.sh to n8.1.
- Bump the version of basis_universal in deps.sh to v2.10.
- Bump the version of libjpeg-turbo in deps.sh to 3.1.3.
- Bump the version of mozjpeg in deps.sh to 0826579.
- Disable multithreading at encoding and decoding with libheif.

## v0.6.2

- Minor fix for avifssim and avifiq in CodecFromName().
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.20)
project(
codec-compare-gen
LANGUAGES CXX
VERSION 0.6.2)
VERSION 0.6.3)
set(CMAKE_CXX_STANDARD 17)

option(BUILD_SHARED_LIBS "Build the shared codec-compare-gen library" ON)
Expand Down
57 changes: 27 additions & 30 deletions deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ NPROC=$(nproc)
mkdir third_party
pushd third_party

git clone https://github.com/AOMediaCodec/libavif.git
git clone -b v1.4.0 --depth 1 https://github.com/AOMediaCodec/libavif.git
pushd libavif
git checkout 1aadfad932c98c069a1204261b1856f81f3bc199 # v1.3.0
git checkout d145e1a32af2915779b27e3b0521b6db08dd6bb8 # v1.4.0
cmake -S . -B build \
-DAVIF_BUILD_APPS=ON \
-DAVIF_BUILD_EXAMPLES=OFF \
Expand All @@ -45,12 +45,9 @@ pushd third_party

# AVM symbols conflict with AOM so another build of libavif is required.
# See https://gitlab.com/AOMediaCodec/avm/-/issues/150.
git clone https://github.com/AOMediaCodec/libavif.git libavif_avm
git clone -b v1.4.0 --depth 1 https://github.com/AOMediaCodec/libavif.git libavif_avm
pushd libavif_avm
git checkout 1aadfad932c98c069a1204261b1856f81f3bc199 # v1.3.0
# From https://github.com/AOMediaCodec/libavif/pull/2624.
sed -i'' -e 's|set(CONFIG_ML_PART_SPLIT 0 CACHE INTERNAL "")|include_directories(${CMAKE_CURRENT_BINARY_DIR}/flatbuffers/include/)|' "cmake/Modules/LocalAom.cmake"
sed -i'' -e 's|set_property(TARGET aom PROPERTY AVIF_LOCAL ON)|if(AVIF_CODEC_AVM)\ntarget_link_libraries(aom PRIVATE tensorflow-lite)\nendif()\nset_property(TARGET aom PROPERTY AVIF_LOCAL ON)|' "cmake/Modules/LocalAom.cmake"
git checkout d145e1a32af2915779b27e3b0521b6db08dd6bb8 # v1.4.0
cmake -S . -B build \
-DAVIF_BUILD_APPS=ON \
-DAVIF_BUILD_EXAMPLES=OFF \
Expand All @@ -61,13 +58,14 @@ pushd third_party
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DBUILD_SHARED_LIBS=ON
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build build -j${NPROC}
popd

git clone https://github.com/strukturag/libheif.git
git clone -b v1.21.2 --depth 1 https://github.com/strukturag/libheif.git
pushd libheif
git checkout 35dad50a9145332a7bfdf1ff6aef6801fb613d68 # v1.20.2
git checkout 62f1b8c76ed4d8305071fdacbe74ef9717bacac5 # v1.21.2
# Reuse the libaom and dav1d dependencies from libavif.
# pushd third-party
# chmod +x *.cmd
Expand All @@ -85,13 +83,15 @@ pushd third_party
-DDAV1D_INCLUDE_DIR=../libavif/build/_deps/dav1d-src/include/ \
-DDAV1D_LIBRARY=../libavif/build/_deps/dav1d-build/src/libdav1d.a \
-DWITH_LIBSHARPYUV=OFF \
-DENABLE_MULTITHREADING_SUPPORT=OFF \
-DENABLE_PARALLEL_TILE_DECODING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DBUILD_SHARED_LIBS=ON
cmake --build build -j${NPROC}
popd

git clone https://chromium.googlesource.com/webm/libwebp
git clone -b v1.6.0 --depth 1 https://chromium.googlesource.com/webm/libwebp
pushd libwebp
git checkout b7e29b9d75bd31422b00c2a446d49d7af06c328d # v1.6.0
cmake -S . -B build \
Expand All @@ -108,7 +108,7 @@ pushd third_party

git clone https://chromium.googlesource.com/codecs/libwebp2
pushd libwebp2
git checkout aa3651e5c43a2c22d75ba500e01a016c49fb0bdf
git checkout 8720150cdc4c5c51a11a809a93110f38035b6048
cmake -S . -B build \
-DCMAKE_PREFIX_PATH="../libwebp/src/;../libwebp/build/" \
-DWP2_BUILD_TESTS=OFF \
Expand All @@ -119,9 +119,9 @@ pushd third_party
cmake --build build -j${NPROC}
popd

git clone https://github.com/libjxl/libjxl.git
git clone -b v0.11.2 --depth 1 https://github.com/libjxl/libjxl.git
pushd libjxl
git checkout 794a5dcf0d54f9f0b20d288a12e87afb91d20dfc # v0.11.1
git checkout 332feb17d17311c748445f7ee75c4fb55cc38530 # v0.11.2
./deps.sh
# DEVTOOLS=ON for Butteraugli and SSIMULACRA2 metric binaries. See
# https://github.com/cloudinary/ssimulacra2/blob/d2be72505ddc5c92aeb30f4a7f3ab53db45b314b/build_ssimulacra_from_libjxl_repo
Expand All @@ -139,9 +139,9 @@ pushd third_party
cmake --build build -j${NPROC}
popd

git clone -b v2.5.3 --depth 1 https://github.com/uclouvain/openjpeg.git
git clone -b v2.5.4 --depth 1 https://github.com/uclouvain/openjpeg.git
pushd openjpeg
git checkout 210a8a5690d0da66f02d49420d7176a21ef409dc # v2.5.3
git checkout 6c4a29b00211eb0430fa0e5e890f1ce5c80f409f # v2.5.4
cmake -S . -B build \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -151,25 +151,21 @@ pushd third_party
popd

# FFV1 is part of FFmpeg.
git clone -b n7.1.1 --depth 1 https://github.com/FFmpeg/FFmpeg.git
git clone -b n8.1 --depth 1 https://github.com/FFmpeg/FFmpeg.git
pushd FFmpeg
# n8.0 leads to "error while loading shared libraries: libswresample.so.6:
# cannot open shared object file: No such file or directory"
git checkout db69d06eeeab4f46da15030a80d539efb4503ca8 # n7.1.1
git checkout 9047fa1b084f76b1b4d065af2d743df1b40dfb56 # n8.1
./configure --prefix=build --enable-shared --disable-static
make libavcodec -j${NPROC}
make install libavcodec -j${NPROC}
popd

git clone -b v1_60 --depth 1 https://github.com/BinomialLLC/basis_universal.git
git clone -b v2_1_0 --depth 1 https://github.com/BinomialLLC/basis_universal.git
pushd basis_universal
git checkout 323239a6a5ffa57d6570cfc403be99156e33a8b0 # v1.60
# Remove errors about ambiguous calls.
sed -i'' -e 's|safe_shift_left(uint32_t|safe_shift_left_u32(uint32_t|' "transcoder/basisu_containers.h"
git checkout 45d5f41015eecd9570d5a3f89ab9cc0037a25063 # v2.10
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release -DSSE=TRUE \
-DCMAKE_BUILD_TYPE=Release -DBASISU_SSE=TRUE \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DBUILD_SHARED_LIBS=ON -DSTATIC=OFF
-DBUILD_SHARED_LIBS=ON -DBASISU_STATIC=OFF
cmake --build build -j${NPROC}
popd

Expand All @@ -179,9 +175,9 @@ pushd third_party
cargo build --release
popd

git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git libjpeg_turbo
git clone -b 3.1.3 --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git libjpeg_turbo
pushd libjpeg_turbo
git checkout 7723f50f3f66b9da74376e6d8badb6162464212c # 3.1.1
git checkout af9c1c268520a29adf98cad5138dafe612b3d318 # 3.1.3
cmake -S . -B build
cmake --build build -j${NPROC}
popd
Expand All @@ -197,8 +193,9 @@ pushd third_party

git clone https://github.com/mozilla/mozjpeg.git
pushd mozjpeg
git checkout 6c9f0897afa1c2738d7222a0a9ab49e8b536a267 # 4.1.5
cmake -S . -B build -DWITH_TURBOJPEG=OFF
git checkout 08265790774cd0714832c9e675522acbe5581437 # 5.0.X
cmake -S . -B build -DWITH_TURBOJPEG=OFF \
-DBUILD_SHARED_LIBS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build build -j${NPROC}
popd

Expand Down
22 changes: 19 additions & 3 deletions src/codec_avif_libheif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ using HeifEncoder =
std::unique_ptr<heif_encoder, decltype(&heif_encoder_release)>;
using HeifImageHandle =
std::unique_ptr<heif_image_handle, decltype(&heif_image_handle_release)>;
using HeifDecodingOptions =
std::unique_ptr<heif_decoding_options,
decltype(&heif_decoding_options_free)>;

Status ArgbBufferToHeifImage(const WP2::ArgbBuffer& wp2_image,
HeifImage* image_ptr, bool quiet) {
Expand Down Expand Up @@ -153,7 +156,7 @@ StatusOr<WP2::Data> EncodeAvifLibheif(const TaskInput& input,
input.codec_settings.chroma_subsampling == Subsampling::k444,
quiet);
} else {
// Default seems to be 4:2:0.
// Default seems to be full-range YUV 4:2:0 with CICP set to 1/13/6.
// TODO: b/451945988 - Support lossy 4:4:4.
CHECK_OR_RETURN(
input.codec_settings.chroma_subsampling == Subsampling::kDefault ||
Expand All @@ -167,7 +170,11 @@ StatusOr<WP2::Data> EncodeAvifLibheif(const TaskInput& input,
err = heif_encoder_set_parameter_integer(encoder, "speed",
input.codec_settings.effort);
CHECK_OR_RETURN(err.code == heif_error_Ok, quiet)
<< "heif_encoder_set_parameter_integer for speed failed: " << err.message;
<< "heif_encoder_set_param for speed failed: " << err.message;

err = heif_encoder_set_parameter_integer(encoder, "threads", 1);
CHECK_OR_RETURN(err.code == heif_error_Ok, quiet)
<< "heif_encoder_set_param for threads failed: " << err.message;

// TODO: b/451945988 - Support sequences.
CHECK_OR_RETURN(original_image.size() == 1, quiet);
Expand Down Expand Up @@ -197,6 +204,8 @@ StatusOr<std::pair<Image, double>> DecodeAvifLibheif(
CHECK_OR_RETURN(context != nullptr, quiet) << "heif_context_alloc failed";
const HeifContext context_ptr(context, &heif_context_free);

heif_context_set_max_decoding_threads(context, 0);

heif_error err = heif_context_read_from_memory_without_copy(
context, encoded_image.bytes, encoded_image.size, nullptr);
CHECK_OR_RETURN(err.code == heif_error_Ok, quiet)
Expand All @@ -217,9 +226,16 @@ StatusOr<std::pair<Image, double>> DecodeAvifLibheif(
const heif_chroma chroma =
has_alpha ? heif_chroma_interleaved_RGBA : heif_chroma_interleaved_RGB;

heif_decoding_options* options = heif_decoding_options_alloc();
CHECK_OR_RETURN(options != nullptr, quiet)
<< "heif_decoding_options_alloc failed";
const HeifDecodingOptions options_ptr(options, &heif_decoding_options_free);
options->num_codec_threads = 1;
options->ignore_transformations = true; // There should be no transformation.

heif_image* decoded = nullptr;
err =
heif_decode_image(handle, &decoded, heif_colorspace_RGB, chroma, nullptr);
heif_decode_image(handle, &decoded, heif_colorspace_RGB, chroma, options);
CHECK_OR_RETURN(err.code == heif_error_Ok && decoded != nullptr, quiet)
<< "heif_decode_image failed: " << err.message;
const HeifImage decoded_ptr(decoded, &heif_image_release);
Expand Down
2 changes: 1 addition & 1 deletion src/codec_basis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ StatusOr<WP2::Data> EncodeBasis(const TaskInput& input,
params.m_source_images.resize(1);
params.m_source_images.back().init(pixels.GetRow8(0), pixels.width(),
pixels.height(), num_channels);
params.m_etc1s_quality_level = input.codec_settings.quality;
params.m_quality_level = input.codec_settings.quality;
params.m_mip_gen = false;
params.m_multithreading = false;

Expand Down
2 changes: 1 addition & 1 deletion src/result_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Status TasksToJson(const std::string& batch_pretty_name, CodecSettings settings,
" && mv third_party/libavif_avm third_party/libavif"
: "";
const std::string build_cmd =
"git clone -b v0.6.2 --depth 1"
"git clone -b v0.6.3 --depth 1"
" https://github.com/webmproject/codec-compare-gen.git"
" && cd codec-compare-gen && ./deps.sh" +
deps_extra_step +
Expand Down