Commit ff093712 authored by  jpegxl-bot's avatar jpegxl-bot 🤖

Update JPEG-XL with latest changes.

This includes all changes up to 2019-12-27 17:38:53 +0100.
parents
BasedOnStyle: Google
IncludeCategories:
- Regex: '^<hwy/'
Priority: 2
# Disabled checks:
# - google-readability-todo: We don't use the google TODO format.
#
# - modernize-deprecated-headers: We don't use std:: versions of the standard
# types and functions like size_t or printf, so we should include <stdio.h>
# instead <cstdio>.
# - modernize-return-braced-init-list: this often doesn't improve readability.
# - modernize-use-auto: is too aggressive towards using auto.
# - modernize-use-default-member-init: with a mix of constructors and default
# member initialization this can be confusing if enforced.
# - modernize-use-using: typedefs are ok.
#
# - readability-else-after-return: It doesn't always improve readability.
# - readability-static-accessed-through-instance
# It is often more useful and readable to access a constant of a passed
# variable (like d.N) instead of using the type of the variable that could be
# long and complex.
Checks: >-
clang-*,
-clang-diagnostic-unused-command-line-argument,
google-*,
modernize-*,
performance-*,
readability-*,
-google-readability-todo,
-modernize-deprecated-headers,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-default-member-init,
-modernize-use-using,
-readability-else-after-return,
-readability-static-accessed-through-instance,
WarningsAsErrors: >-
clang-*,
clang-analyzer-*,
-clang-diagnostic-unused-command-line-argument,
google-build-using-namespace,
google-explicit-constructor,
google-readability-namespace-comments
# We are only interested in the headers from this projects, excluding
# third_party/ and build/.
HeaderFilterRegex: '^.*/(jxl|fuif|tools)/.*\.h$'
CheckOptions:
- key: readability-braces-around-statements.ShortStatementLines
value: '2'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '2'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: '1'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: '1'
# Build output directories
/build
/build*
/docker/*.log
# The downloaded corpora files for benchmark.
/third_party/corpora
This diff is collapsed.
[submodule "third_party/brotli"]
path = third_party/brotli
url = https://github.com/google/brotli
[submodule "third_party/lodepng"]
path = third_party/lodepng
url = https://github.com/lvandeve/lodepng
[submodule "third_party/lcms"]
path = third_party/lcms
url = https://github.com/mm2/Little-CMS
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest
[submodule "third_party/gperftools"]
path = third_party/gperftools
url = https://github.com/gperftools/gperftools
[submodule "third_party/brunsli"]
path = third_party/brunsli
url = https://github.com/google/brunsli.git
[submodule "third_party/sjpeg"]
path = third_party/sjpeg
url = https://github.com/webmproject/sjpeg.git
[submodule "third_party/skcms"]
path = third_party/skcms
url = https://skia.googlesource.com/skcms
# Copyright (c) the JPEG XL Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Ubuntu bionic ships with cmake 3.10.
cmake_minimum_required(VERSION 3.10)
# Set compilers to default to Clang is not set.
if ("$ENV{CC}" STREQUAL "")
set(ENV{CC} clang)
endif()
if ("$ENV{CXX}" STREQUAL "")
set(ENV{CXX} clang++)
endif()
# Honor VISIBILITY_INLINES_HIDDEN on all types of targets.
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# Pass CMAKE_EXE_LINKER_FLAGS to CC and CXX compilers when testing if they work.
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
project(JPEGXL LANGUAGES C CXX)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles(
"int main() {
#if !defined(__EMSCRIPTEN__)
static_assert(false, \"__EMSCRIPTEN__ is not defined\");
#endif
return 0;
}"
JPEGXL_EMSCRIPTEN
)
if(JPEGXL_EMSCRIPTEN)
message("-- Compiler is EMSCRIPTEN.")
set(JPEGXL_NOT_EMSCRIPTEN false)
set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_definitions(-DPROFILER_ENABLED=0)
else()
message("-- Compiler is not EMSCRIPTEN.")
set(JPEGXL_NOT_EMSCRIPTEN true)
endif()
### Project build options:
if(NOT APPLE AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"
AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
# Enabled by default except on arm64 and Apple builds.
set(ENABLE_FUZZERS_DEFAULT true)
endif()
if(NOT APPLE AND NOT JPEGXL_EMSCRIPTEN
AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"
AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
# Enabled by default except on arm64 and Apple builds.
set(ENABLE_TCMALLOC_DEFAULT true)
endif()
set(JPEGXL_ENABLE_FUZZERS ${ENABLE_FUZZERS_DEFAULT} CACHE BOOL
"Build JPEGXL fuzzer targets")
set(JPEGXL_ENABLE_BENCHMARK ${JPEGXL_NOT_EMSCRIPTEN} CACHE BOOL
"Build JPEGXL benchmark tools")
set(JPEGXL_ENABLE_SJPEG true CACHE BOOL
"Build JPEGXL with support for encoding with sjpeg")
set(JPEGXL_ENABLE_SKCMS false CACHE BOOL
"Where possible, use skcms instead of lcms2")
set(JPEGXL_ENABLE_VIEWERS ${JPEGXL_NOT_EMSCRIPTEN} CACHE BOOL
"Build JPEGXL viewer tools for evaluation")
set(JPEGXL_ENABLE_TCMALLOC ${ENABLE_TCMALLOC_DEFAULT} CACHE BOOL
"Build JPEGXL using gperftools (tcmalloc) allocator.")
set(JPEGXL_ENABLE_PLUGINS true CACHE BOOL
"Build third-party plugings to support JPEG XL in other applications.")
set(JPEGXL_ENABLE_COVERAGE false CACHE BOOL
"Enable code coverage tracking for libjpegxl. This also enables debug and disables optimizations.")
# Require clang for building.
if(NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang" OR
NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler is not supported.\n"
"Use clang instead:\n CC=clang CXX=clang++ cmake ..")
endif()
if (${CMAKE_C_COMPILER_VERSION} VERSION_LESS 6 OR
${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 6)
message(FATAL_ERROR
"Minimum Clang version required is Clang 6, please update.")
endif()
# CMAKE_EXPORT_COMPILE_COMMANDS is used to generate the compilation database
# used by clang-tidy.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Global compiler flags for all targets here and in subdirectories.
add_definitions(
# Avoid changing the binary based on the current time and date.
-D__DATE__="redacted"
-D__TIMESTAMP__="redacted"
-D__TIME__="redacted"
)
# 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
if (NOT "${JPEGXL_EMSCRIPTEN}")
# Pretty colorful messages within reasonable limits.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Xclang -ferror-limit -Xclang 19 -Xclang -fmessage-length -Xclang 0 \
-Xclang -fdiagnostics-show-option -fcolor-diagnostics")
# Machine flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Xclang -mrelax-all \
-Xclang -mrelocation-model -Xclang pic \
-Xclang -pic-level -Xclang 2 \
-Xclang -mconstructor-aliases \
-Xclang -mpie-copy-relocations \
-Xclang -munwind-tables")
if(WIN32)
# Not supported by clang-cl, but frame pointers are default on Windows
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
endif()
# CPU flags
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mavx2 \
-mfma \
-Xclang -mprefer-vector-width=128 \
-Xclang -target-cpu -Xclang haswell \
-Xclang -target-feature -Xclang +avx2")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Xclang -mprefer-vector-width=128 \
-Xclang -target-cpu -Xclang cortex-a72")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mcpu=cortex-a7 -mfpu=neon-vfpv4")
endif()
endif() # JPEGXL_EMSCRIPTEN
# Force build with optimizations in release mode.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
add_compile_options(
# Ignore this to allow redefining __DATE__ and others.
-Wno-builtin-macro-redefined
# Global warning settings.
-Wall
)
if (NOT WIN32)
add_compile_options(-Werror)
endif ()
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
add_subdirectory(third_party)
set(THREADS_PREFER_PTHREAD_FLAG YES)
find_package(Threads REQUIRED)
# Enable tests regardless of where are they defined.
enable_testing()
include(CTest)
# The jpegxl library definition. This also defines the internal list of flags we
# use in our project (library, tests and tools): JPEGXL_INTERNAL_FLAGS.
include(jpegxl.cmake)
if (NOT "${JPEGXL_EMSCRIPTEN}")
# Other libraries outside the core jpegxl library.
include(jpegxl_extras.cmake)
include(jpegxl_threads.cmake)
# Plugins for third-party software
if (${JPEGXL_ENABLE_PLUGINS})
add_subdirectory(plugins)
endif ()
# Binary tools
add_subdirectory(tools)
# Unittests
cmake_policy(SET CMP0057 NEW) # https://gitlab.kitware.com/cmake/cmake/issues/18198
include(GoogleTest)
# Tests for the jpegxl library.
include(jpegxltests.cmake)
else() # JPEGXL_EMSCRIPTEN
# WASM API facade.
add_executable(jpegxl_emcc jxl/jpegxl_emcc.cc)
target_link_libraries(jpegxl_emcc jpegxl-static)
set_target_properties(jpegxl_emcc PROPERTIES LINK_FLAGS "\
-O3\
-s TOTAL_MEMORY=256MB\
-s EXPORTED_FUNCTIONS='[\
\"_decompress\",\
\"_free\",\
\"_freeImage\",\
\"_getImageWidth\",\
\"_getImageHeight\",\
\"_getImagePixels\",\
\"_malloc\"\
]'\
")
endif () # JPEGXL_EMSCRIPTEN
# How to Contribute
We are currently unable to accept patches to this project, but we'd very much
appreciate if you open a Gitlab issue for any bug reports/feature requests.
We will be happy to investigate and hopefully fix any issues.
# Community Guidelines
This project follows
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
# This files lists individuals who made significant contributions to the JPEG XL
# code base, such as design, adding features, performing experiments, ...
# Small changes such as a small bugfix or fixing spelling errors are not
# included. If you'd like to be included in this file thanks to a significant
# contribution, feel free to send a pull request changing this file.
Alex Deymo
Alexander Rhatushnyak
Evgenii Kliuchnikov
Iulia-Maria Comșa
Jan Wassenberg
Jon Sneyers
Jyrki Alakuijala
Krzysztof Potempa
Lode Vandevenne
Luca Versari
Martin Bruse
Moritz Firsching
Renata Khasanova
Robert Obryk
Sami Boukortt
Sebastian Gomez-Gonzalez
Thomas Fischbacher
Zoltan Szabadka
This diff is collapsed.
## Disclaimer
OSX builds have "best effort" support, i.e. build might not work at all, some
tests may fail and some sub-projects are excluded from build.
This manual outlines OSX specific setup. For general building and testing
instructions see "[README](README.md)" and
"[Building and Testing changes](doc/building_and_testing.md)".
## Dependencies
[Homebrew](https://brew.sh/) is a popular package manager that can be used for
installing dependencies.
Make sure that `brew doctor` does not report serious problems and up-to-date
version of XCode is installed.
Installing (actually, building) `clang` might take a couple hours.
```shell
brew install llvm
```
```shell
brew install clang-format coreutils cmake giflib libjpeg ninja parallel
```
If `git-clang-format` command is not accessible, run
```shell
brew link --overwrite clang-format
```
Before building the project check that `which clang` is
`/usr/local/opt/llvm/bin/clang`, not the one provided by XCode. If not, update
`PATH` environment variable.
Also, `export CMAKE_PREFIX_PATH=/usr/local/opt/giflib` might be necessary for
correct include paths resolving.
# JPEG XL reference implementation
This repository contains a reference implementation of JPEG XL (encoder and
decoder). As [previously announced](https://jpeg.org/items/20190803_press.html),
it is available under a royalty-free and open source license (Apache 2).
**NOTE**
JPEG XL is in the final stages of standardization, but minor changes to the
codestream are still likely. WARNING: until further notice, do not depend on
future decoders being able to decode the output of a current encoder.
## Checking out the code
This repository uses git submodules to handle some third party dependencies
under `third_party/`. To check out these dependencies as well clone the
repository with `--recursive`:
```shell
git clone git@gitlab.com:wg1/jpeg-xl.git --recursive
```
If you didn't check out recursively, and after any update run the following
command to check out the git submodules.
```shell
git submodule update --init --recursive
```
## Minimum build dependencies
Apart from the dependencies in third_party, some of the tools use external
dependencies that need to be installed in your system first. For a Debian/Ubuntu
based Linux distribution install:
```shell
sudo apt install cmake clang-6.0 g++-8 qtbase5-dev libqt5x11extras5-dev \
extra-cmake-modules libgif-dev libjpeg-dev ninja-build
```
For developing changes in JPEG XL, take a look at the
[Building and Testing changes](doc/building_and_testing.md) guide.
Make sure your default "clang" compiler is at least version 6 running
```bash
clang --version
```
If it still shows an old version despite having a clang-6.0 installed, you need
to update the default clang compiler. In Debian-based systems run:
```bash
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 100
```
## Building
The project builds with cmake. We currently support Linux (tested with Debian).
To build the "release" version, you can use the following helper command:
```shell
./ci.sh release
```
This will build and test the project, and leave the binaries in the `build/`
directory. Check out the `tools` subdirectory for command-line tools that
interact with the library. You can set the environment variable SKIP_TEST=1 to
skip the test stage.
There are other build versions with more debug information useful when