Skip to content

Commit

Permalink
Bug 1790165 - Update libjxl to 3e0b08d4ee53a08f9b58739e088c5bdecebae7…
Browse files Browse the repository at this point in the history
…4d r=saschanaz

Differential Revision: https://phabricator.services.mozilla.com/D157018
  • Loading branch information
updatebot-ci committed Sep 10, 2022
1 parent 6fc590a commit 49faa74
Show file tree
Hide file tree
Showing 38 changed files with 1,547 additions and 744 deletions.
4 changes: 2 additions & 2 deletions media/libjxl/moz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ origin:

url: https://github.com/libjxl/libjxl

release: bb8eac5d6acec223e44cf8cc72ae02f0816de311
release: 3e0b08d4ee53a08f9b58739e088c5bdecebae74d (2022-09-09T11:59:45Z).

revision: bb8eac5d6acec223e44cf8cc72ae02f0816de311
revision: 3e0b08d4ee53a08f9b58739e088c5bdecebae74d

license: Apache-2.0

Expand Down
39 changes: 26 additions & 13 deletions third_party/jpeg-xl/.github/workflows/build_test_cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:

jobs:
cross_compile_ubuntu:
name: Cross-compiling ${{ matrix.build_target }} ${{ matrix.lowprecision }}
name: Cross-compiling ${{ matrix.build_target }} ${{ matrix.variant }}
runs-on: [ubuntu-22.04]
container:
image: debian:bullseye
Expand All @@ -29,28 +29,40 @@ jobs:
matrix:
include:
- arch: arm64
lowprecision:
build_target: aarch64-linux-gnu
cmake_args: -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static
cmake_args:
- -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static

- arch: arm64
lowprecision: lowprecision
variant: SVE
build_target: aarch64-linux-gnu
cmake_args: -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static -DCMAKE_CXX_FLAGS=-DJXL_HIGH_PRECISION=0
cmake_args:
- -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static
- -DJPEGXL_ENABLE_OPENEXR=off
- -DJPEGXL_ENABLE_SIZELESS_VECTORS=on
cmake_flags: -march=armv8-a+sve
c_compiler: aarch64-linux-gnu-gcc
cxx_compiler: aarch64-linux-gnu-g++
disable_tests: true

- arch: arm64
variant: lowprecision
build_target: aarch64-linux-gnu
cmake_args:
- -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static
- -DCMAKE_CXX_FLAGS=-DJXL_HIGH_PRECISION=0

- arch: armhf
lowprecision:
build_target: arm-linux-gnueabihf
cmake_args: -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-arm-static
cmake_args: [-DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-arm-static]

- arch: i386
lowprecision:
test_in_pr: true
build_target: i686-linux-gnu

env:
BUILD_DIR: build
WILL_RUN_TESTS: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (matrix.test_in_pr || contains(github.event.pull_request.labels.*.name, 'CI:full'))) }}
WILL_RUN_TESTS: ${{ (github.event_name == 'push' || (github.event_name == 'pull_request' && (matrix.test_in_pr || contains(github.event.pull_request.labels.*.name, 'CI:full')))) && !matrix.disable_tests }}

steps:
- name: Setup apt
Expand Down Expand Up @@ -100,6 +112,7 @@ jobs:
# Toolchain for cross-compiling.
clang-11
g++-aarch64-linux-gnu
libc6-dev-${{ matrix.arch }}-cross
libstdc++-10-dev-${{ matrix.arch }}-cross
libstdc++-10-dev:${{ matrix.arch }}
Expand Down Expand Up @@ -139,19 +152,19 @@ jobs:
)
fi
DEBIAN_FRONTEND=noninteractive apt install -y "${pkgs[@]}"
echo "CC=clang-11" >> $GITHUB_ENV
echo "CXX=clang++-11" >> $GITHUB_ENV
echo "CC=${{ matrix.c_compiler || 'clang-11' }}" >> $GITHUB_ENV
echo "CXX=${{ matrix.cxx_compiler || 'clang++-11' }}" >> $GITHUB_ENV
- name: Checkout the source
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 1
- name: Build
run: |
./ci.sh release \
CMAKE_FLAGS="${{ matrix.cmake_flags }}" ./ci.sh release \
-DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
-DJPEGXL_ENABLE_JNI=OFF \
${{ matrix.cmake_args }}
${{ join(matrix.cmake_args, ' ') }}
env:
SKIP_TEST: 1
BUILD_TARGET: ${{ matrix.build_target }}
Expand Down
1 change: 1 addition & 0 deletions third_party/jpeg-xl/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Martin Strunz
Mathieu Malaterre <[email protected]>
Mikk Leini <[email protected]>
Misaki Kasumi <[email protected]>
Nicholas Hayes <[email protected]>
Petr Diblík
Pieter Wuille
roland-rollo
Expand Down
20 changes: 19 additions & 1 deletion third_party/jpeg-xl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ if(NOT APPLE AND NOT WIN32 AND NOT HAIKU AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86
endif()
endif()

check_cxx_source_compiles(
"int main() {
#if !defined(HWY_DISABLED_TARGETS)
static_assert(false, \"HWY_DISABLED_TARGETS is not defined\");
#endif
return 0;
}"
JXL_HWY_DISABLED_TARGETS_FORCED
)

set(WARNINGS_AS_ERRORS_DEFAULT false)

if((SANITIZER STREQUAL "msan") OR JPEGXL_EMSCRIPTEN)
Expand Down Expand Up @@ -119,7 +129,9 @@ set(JPEGXL_ENABLE_PLUGINS false CACHE BOOL
set(JPEGXL_ENABLE_COVERAGE false CACHE BOOL
"Enable code coverage tracking for libjxl. This also enables debug and disables optimizations.")
set(JPEGXL_ENABLE_PROFILER false CACHE BOOL
"Builds in support for profiling (printed by tools if extra flags given")
"Builds in support for profiling (printed by tools if extra flags given)")
set(JPEGXL_ENABLE_SIZELESS_VECTORS false CACHE BOOL
"Builds in support for SVE/RVV vectorization")
set(JPEGXL_ENABLE_TRANSCODE_JPEG true CACHE BOOL
"Builds in support for decoding transcoded JXL files back to JPEG,\
disabling it makes the decoder reject JXL_DEC_JPEG_RECONSTRUCTION events,\
Expand Down Expand Up @@ -262,6 +274,12 @@ if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

# TODO(eustas): JXL currently compiles, but does not pass tests...
if (NOT JXL_HWY_DISABLED_TARGETS_FORCED AND NOT JPEGXL_ENABLE_SIZELESS_VECTORS)
add_definitions(-DHWY_DISABLED_TARGETS=\(HWY_SVE|HWY_SVE2|HWY_SVE_256|HWY_SVE2_128|HWY_RVV\))
message("Warning: HWY_SVE, HWY_SVE2, HWY_SVE_256, HWY_SVE2_128 and HWY_RVV CPU targets are disabled")
endif()

# In CMake before 3.12 it is problematic to pass repeated flags like -Xclang.
# For this reason we place them in CMAKE_CXX_FLAGS instead.
# See https://gitlab.kitware.com/cmake/cmake/issues/15826
Expand Down
2 changes: 1 addition & 1 deletion third_party/jpeg-xl/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MYDIR=$(dirname $(realpath "$0"))
# Git revisions we use for the given submodules. Update these whenever you
# update a git submodule.
THIRD_PARTY_BROTLI="35ef5c554d888bef217d449346067de05e269b30"
THIRD_PARTY_HIGHWAY="7f2e26854086fba4255220fd6c77e9141f1f87cc"
THIRD_PARTY_HIGHWAY="22e3d7276f4157d4a47586ba9fd91dd6303f441a"
THIRD_PARTY_SKCMS="64374756e03700d649f897dbd98c95e78c30c7da"
THIRD_PARTY_SJPEG="868ab558fad70fcbe8863ba4e85179eeb81cc840"
THIRD_PARTY_ZLIB="cacf7f1d4e3d44d871b605da3b647f07d718623f"
Expand Down
6 changes: 1 addition & 5 deletions third_party/jpeg-xl/lib/extras/codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ Status Encode(const CodecInOut& io, const extras::Codec codec,
format.endianness = JXL_NATIVE_ENDIAN;
encoder = extras::GetPFMEncoder();
}
if (!c_desired.IsSRGB()) {
JXL_WARNING(
"PNM encoder cannot store custom ICC profile; decoder "
"will need hint key=color_space to get the same values");
}
break;
case extras::Codec::kPGX:
encoder = extras::GetPGXEncoder();
Expand All @@ -135,6 +130,7 @@ Status Encode(const CodecInOut& io, const extras::Codec codec,
extras::PackedPixelFile ppf;
JXL_RETURN_IF_ERROR(
ConvertCodecInOutToPackedPixelFile(io, format, c_desired, pool, &ppf));
ppf.info.bits_per_sample = bits_per_sample;
extras::EncodedImage encoded_image;
JXL_RETURN_IF_ERROR(encoder->Encode(ppf, &encoded_image, pool));
JXL_ASSERT(encoded_image.bitstreams.size() == 1);
Expand Down
2 changes: 1 addition & 1 deletion third_party/jpeg-xl/lib/extras/dec/exr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Status DecodeImageEXR(Span<const uint8_t> bytes, const ColorHints& color_hints,

const float intensity_target = OpenEXR::hasWhiteLuminance(input.header())
? OpenEXR::whiteLuminance(input.header())
: kDefaultIntensityTarget;
: 0;

auto image_size = input.displayWindow().size();
// Size is computed as max - min, but both bounds are inclusive.
Expand Down
17 changes: 12 additions & 5 deletions third_party/jpeg-xl/lib/extras/enc/jpg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Status SetChromaSubsampling(const std::string& subsampling,
}

Status EncodeWithLibJpeg(const PackedImage& image, const JxlBasicInfo& info,
const JxlColorEncoding& color_encoding,
const std::vector<uint8_t>& icc,
std::vector<uint8_t> exif, size_t quality,
const std::string& chroma_subsampling,
Expand All @@ -133,6 +134,10 @@ Status EncodeWithLibJpeg(const PackedImage& image, const JxlBasicInfo& info,
if (cinfo.input_components == 3) {
JXL_RETURN_IF_ERROR(SetChromaSubsampling(chroma_subsampling, &cinfo));
}
if (color_encoding.color_space == JXL_COLOR_SPACE_XYB) {
// Tell libjpeg not to convert XYB data to YCbCr.
jpeg_set_colorspace(&cinfo, JCS_RGB);
}
jpeg_set_quality(&cinfo, quality, TRUE);
jpeg_start_compress(&cinfo, TRUE);
if (!icc.empty()) {
Expand Down Expand Up @@ -200,6 +205,7 @@ Status EncodeWithSJpeg(const PackedImage& image, const JxlBasicInfo& info,
}

Status EncodeImageJPG(const PackedImage& image, const JxlBasicInfo& info,
const JxlColorEncoding& color_encoding,
const std::vector<uint8_t>& icc,
std::vector<uint8_t> exif, JpegEncoder encoder,
size_t quality, const std::string& chroma_subsampling,
Expand All @@ -216,9 +222,9 @@ Status EncodeImageJPG(const PackedImage& image, const JxlBasicInfo& info,

switch (encoder) {
case JpegEncoder::kLibJpeg:
JXL_RETURN_IF_ERROR(EncodeWithLibJpeg(image, info, icc, std::move(exif),
quality, chroma_subsampling,
bytes));
JXL_RETURN_IF_ERROR(EncodeWithLibJpeg(image, info, color_encoding, icc,
std::move(exif), quality,
chroma_subsampling, bytes));
break;
case JpegEncoder::kSJpeg:
JXL_RETURN_IF_ERROR(EncodeWithSJpeg(image, info, icc, std::move(exif),
Expand Down Expand Up @@ -281,8 +287,9 @@ class JPEGEncoder : public Encoder {
JXL_RETURN_IF_ERROR(VerifyPackedImage(frame.color, ppf.info));
encoded_image->bitstreams.emplace_back();
JXL_RETURN_IF_ERROR(EncodeImageJPG(
frame.color, ppf.info, icc, ppf.metadata.exif, jpeg_encoder, quality,
chroma_subsampling, pool, &encoded_image->bitstreams.back()));
frame.color, ppf.info, ppf.color_encoding, icc, ppf.metadata.exif,
jpeg_encoder, quality, chroma_subsampling, pool,
&encoded_image->bitstreams.back()));
}
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions third_party/jpeg-xl/lib/extras/enc/pnm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ Status EncodeHeader(const PackedImage& image, size_t bits_per_sample,

Status EncodeImagePNM(const PackedImage& image, size_t bits_per_sample,
std::vector<uint8_t>* bytes) {
// Choose native for PFM; PGM/PPM require big-endian
bool is_little_endian = bits_per_sample > 16 && IsLittleEndian();
if (bits_per_sample <= 16 && image.format.endianness != JXL_BIG_ENDIAN) {
return JXL_FAILURE("PPM/PGM requires big-endian pixel format.");
}
bool is_little_endian =
(image.format.endianness == JXL_LITTLE_ENDIAN ||
(image.format.endianness == JXL_NATIVE_ENDIAN && IsLittleEndian()));
char header[kMaxHeaderSize];
int header_size = 0;
JXL_RETURN_IF_ERROR(EncodeHeader(image, bits_per_sample, is_little_endian,
Expand Down Expand Up @@ -130,7 +134,7 @@ class PPMEncoder : public PNMEncoder {
std::vector<JxlPixelFormat> formats;
for (const uint32_t num_channels : {1, 2, 3, 4}) {
for (const JxlDataType data_type : {JXL_TYPE_UINT8, JXL_TYPE_UINT16}) {
for (JxlEndianness endianness : {JXL_BIG_ENDIAN, JXL_LITTLE_ENDIAN}) {
for (JxlEndianness endianness : {JXL_BIG_ENDIAN}) {
formats.push_back(JxlPixelFormat{/*num_channels=*/num_channels,
/*data_type=*/data_type,
/*endianness=*/endianness,
Expand Down
Loading

0 comments on commit 49faa74

Please sign in to comment.