53 changes: 35 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,62 @@ name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-20.04
env:
CC: gcc-10
CXX: g++-10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- name: Set GCC & G++ 10 compiler (on Linux)
if: runner.os == 'Linux'
run: echo "CC=gcc-10" >> $GITHUB_ENV && echo "CXX=g++-10" >> $GITHUB_ENV
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get update || true
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build gcc-10 g++-10
pip install --upgrade pip
pip install setuptools
pip install meson

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@v2
with:
path: ext
key: ${{ runner.os }}-${{ hashFiles('ext/*.cmd') }}
- uses: ilammy/setup-nasm@v1
if: steps.cache-ext.outputs.cache-hit != 'true'
with:
version: 2.15.05
- uses: actions/checkout@v2
- name: Setup aom
- uses: seanmiddleditch/gha-setup-ninja@v3
if: steps.cache-ext.outputs.cache-hit != 'true'
- run: pip install meson
if: steps.cache-ext.outputs.cache-hit != 'true'
- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash aom.cmd
- name: Setup dav1d
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash dav1d.cmd
- name: Setup rav1e
- name: Build rav1e
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash rav1e.cmd
- name: Setup libgav1
- name: Build libgav1
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash libgav1.cmd
- name: Setup libyuv
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash libyuv.cmd

- name: Prepare libavif (cmake)
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON -DAVIF_CODEC_LIBGAV1=ON -DAVIF_LOCAL_LIBGAV1=ON -DAVIF_LOCAL_LIBYUV=ON -DAVIF_BUILD_TESTS=1
- name: Build libavif (make)
working-directory: ./build
run: make -j $(($(nproc) + 1))
- name: Run AVIF Tests
- name: Run AVIF Tests (on Linux)
if: runner.os == 'Linux'
working-directory: ./build
run: ./aviftest ../tests/data
53 changes: 52 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.9.1] - 2021-05-19

### Added
* Added strict mode/flags (enabled by default): `AVIF_STRICT_PIXI_REQUIRED`, `AVIF_STRICT_CLAP_VALID`
* avifdec: Added `--no-strict` to disable all strict flags
* avifdec: Added `-r` (`--raw-color`), which avoids multiplying against AVIF alpha channel before packing into non-alpha formats (JPEG)
* avifenc: Recognize the Y4M format string "C420mpeg2"
* avifenc: Add `--crop` convenient alternative arg to the difficult-to-use `--clap` arg
* avifenc: New default for `--yuv`: `"auto"`, which will use a source JPEG's internal YUV format instead of YUV444, if detected
* Uses: Prevent colorspace conversion when reading from JPEG if possible (tongyuantongyu)
* avifenc/avifdec: Add helpful values/calculations when dumping clap box
* Added avifDiagnostics, which allows for a detailed, freeform error string upon decode error
* Create helper avifCropRect struct and methods for helping to manipulate/populate/validate avifCleanApertureBox
* Added ability to set codec-specific options for color or alpha only
* Support for libaom's ALL_INTRA mode (if available)
* Create avifDecoder.imageCountLimit as a sanity check against malformed files
* SVT: Image sequence encoding support (tongyuantongyu)
* Added rav1e to AppVeyor builds

### Changed
* avifenc/avifdec: Link AOM_LIBRARIES and use CXX if vmaf is present (1480c1)
* Ensure that an AVIF has a ftyp box, and based on ftyp, has other appropriate toplevel boxes present as well
* Avoid linking against libyuv if it is too old / incompatible
* Always require a primary item when decoding items
* Add some strictness around ipma box parsing (version/flags tuples must be unique across ipma boxes in a file)
* Fix alpha grids by properly writing alpha grid metadata payload
* A HandlerBox (hdlr) of type 'pict' must be the first box within the MetaBox (meta)
* Add some typedefs for various flag decls in avif.h to self-document which flags should be used in which function arguments
* When encoding single-frame images using libaom, clean up the encoder immediately after encoding the frame to cut down on resources high watermarks
* Fail on reformat Identity (MC=0) with subsampling (not using YUV444)
* Warn if alpha is limited range (deprecated)
* Validate the first_chunk fields in the stsc box
* In libaom all intra mode, set cq-level for user
* Check the return values of some aom_codec_ calls and add diagnostics output (wantehchang)
* Use aom_codec_set_option() if available (allows for future compat with libaom 3.0+ advanced features)
* rav1e: Use cargo cinstall in local builds to ensure consistency in target output, as cbuild no longer builds directly into target/release
* Tweaks to compiler flags (analyze related)
* Use libyuv BT.709 & 2020 full range YuvConstants (wantehchang)
* Multiply color with alpha for opaque RGB format during conversion (see #520)
* switch docker to ubuntu 20.04, fix tzdata install (paskal)

* Added an "Understanding maxThreads" explanatory comment block in avif.h
* Minor fixes to support AVIF_CODEC_AOM_ENCODE
* Various minor code/comments cleanup
* CI tweaks, macOS build, and caching / speed increases (EwoutH)
* Update aom.cmd: v3.1.0
* Update dav1d.cmd: 0.9.0
* Update libgav1: v0.16.3
* Update libyuv.cmd: 2f0cbb9

## [0.9.0] - 2021-02-22

### Added
Expand Down Expand Up @@ -575,7 +625,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Constants `AVIF_VERSION`, `AVIF_VERSION_MAJOR`, `AVIF_VERSION_MINOR`, `AVIF_VERSION_PATCH`
- `avifVersion()` function

[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.9.0...HEAD
[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.9.1...HEAD
[0.9.1]: https://github.com/AOMediaCodec/libavif/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/AOMediaCodec/libavif/compare/v0.8.4...v0.9.0
[0.8.4]: https://github.com/AOMediaCodec/libavif/compare/v0.8.3...v0.8.4
[0.8.3]: https://github.com/AOMediaCodec/libavif/compare/v0.8.2...v0.8.3
Expand Down
39 changes: 26 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.5)
# and find_package()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

project(libavif LANGUAGES C VERSION 0.9.0)
project(libavif LANGUAGES C VERSION 0.9.1)

# Set C99 as the default
set(CMAKE_C_STANDARD 99)
Expand All @@ -19,7 +19,7 @@ set(CMAKE_C_STANDARD 99)
# Increment MINOR. Set PATCH to 0
# If the source code was changed, but there were no interface changes:
# Increment PATCH.
set(LIBRARY_VERSION_MAJOR 10)
set(LIBRARY_VERSION_MAJOR 11)
set(LIBRARY_VERSION_MINOR 0)
set(LIBRARY_VERSION_PATCH 0)
set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
Expand Down Expand Up @@ -159,6 +159,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
/wd4820 # Disable: bytes padding added after data member
/wd4996 # Disable: potentially unsafe stdlib methods
/wd5045 # Disable: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified

# This tells MSVC to read source code as UTF-8 and assume console can only use ASCII (minimal safe).
# libavif uses ANSI API to print to console, which is not portable between systems using different
# languages and results in mojibake unless we only use codes shared by every code page: ASCII.
Expand Down Expand Up @@ -197,6 +198,7 @@ set(AVIF_SRCS
src/alpha.c
src/avif.c
src/colr.c
src/diag.c
src/io.c
src/mem.c
src/obu.c
Expand All @@ -222,12 +224,19 @@ endif()

find_package(libyuv QUIET) # not required
if(libyuv_FOUND)
message(STATUS "libavif: libyuv found, libyuv-based fast paths enabled.")
set(AVIF_PLATFORM_DEFINITIONS ${AVIF_PLATFORM_DEFINITIONS} -DAVIF_LIBYUV_ENABLED=1)
set(AVIF_PLATFORM_INCLUDES ${AVIF_PLATFORM_INCLUDES} ${LIBYUV_INCLUDE_DIR})
set(AVIF_PLATFORM_LIBRARIES ${AVIF_PLATFORM_LIBRARIES} ${LIBYUV_LIBRARY})
# libyuv 1755 exposed all of the I*Matrix() functions, which libavif relies on.
if(NOT LIBYUV_VERSION)
message(STATUS "libavif: libyuv found, but version unknown; libyuv-based fast paths disabled.")
elseif(LIBYUV_VERSION LESS 1755)
message(STATUS "libavif: libyuv (${LIBYUV_VERSION}) found, but is too old; libyuv-based fast paths disabled.")
else()
message(STATUS "libavif: libyuv (${LIBYUV_VERSION}) found; libyuv-based fast paths enabled.")
set(AVIF_PLATFORM_DEFINITIONS ${AVIF_PLATFORM_DEFINITIONS} -DAVIF_LIBYUV_ENABLED=1)
set(AVIF_PLATFORM_INCLUDES ${AVIF_PLATFORM_INCLUDES} ${LIBYUV_INCLUDE_DIR})
set(AVIF_PLATFORM_LIBRARIES ${AVIF_PLATFORM_LIBRARIES} ${LIBYUV_LIBRARY})
endif()
else()
message(STATUS "libavif: libyuv not found, libyuv-based fast paths disabled.")
message(STATUS "libavif: libyuv not found; libyuv-based fast paths disabled.")
endif()

set(AVIF_CODEC_DEFINITIONS)
Expand Down Expand Up @@ -303,13 +312,13 @@ if(AVIF_CODEC_RAV1E)
)

if(AVIF_LOCAL_RAV1E)
set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/target/release/${CMAKE_STATIC_LIBRARY_PREFIX}rav1e${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/build.libavif/usr/lib/${CMAKE_STATIC_LIBRARY_PREFIX}rav1e${CMAKE_STATIC_LIBRARY_SUFFIX}")
if(NOT EXISTS "${LIB_FILENAME}")
message(FATAL_ERROR "libavif: compiled rav1e library is missing (in ext/rav1e/target/release), bailing out")
message(FATAL_ERROR "libavif: compiled rav1e library is missing (in ext/rav1e/build.libavif/usr/lib), bailing out")
endif()

set(AVIF_CODEC_INCLUDES ${AVIF_CODEC_INCLUDES}
"${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/target/release"
"${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/build.libavif/usr/include/rav1e"
)
set(AVIF_CODEC_LIBRARIES ${AVIF_CODEC_LIBRARIES} ${LIB_FILENAME})
else()
Expand Down Expand Up @@ -389,7 +398,7 @@ if(AVIF_CODEC_AOM)
find_package(aom REQUIRED)
set(AVIF_CODEC_INCLUDES ${AVIF_CODEC_INCLUDES} ${AOM_INCLUDE_DIR})
endif()
set(AVIF_CODEC_LIBRARIES ${AVIF_CODEC_LIBRARIES} ${AOM_LIBRARY})
set(AVIF_CODEC_LIBRARIES ${AVIF_CODEC_LIBRARIES} ${AOM_LIBRARIES})
endif()
endif()

Expand Down Expand Up @@ -447,6 +456,10 @@ if(NOT SKIP_INSTALL_ALL)
include(GNUInstallDirs)
endif()

if(AVIF_CODEC_LIBRARIES MATCHES vmaf)
enable_language(CXX)
endif()

option(AVIF_BUILD_APPS "Build avif apps." OFF)
if(AVIF_BUILD_APPS)
find_package(ZLIB REQUIRED)
Expand All @@ -462,7 +475,7 @@ if(AVIF_BUILD_APPS)
apps/shared/avifutil.c
apps/shared/y4m.c
)
if(AVIF_LOCAL_LIBGAV1)
if(AVIF_LOCAL_LIBGAV1 OR AVIF_CODEC_LIBRARIES MATCHES vmaf)
set_target_properties(avifenc PROPERTIES LINKER_LANGUAGE "CXX")
endif()
target_link_libraries(avifenc avif ${AVIF_PLATFORM_LIBRARIES} ${PNG_LIBRARY} ${ZLIB_LIBRARY} ${JPEG_LIBRARY})
Expand All @@ -481,7 +494,7 @@ if(AVIF_BUILD_APPS)
apps/shared/avifutil.c
apps/shared/y4m.c
)
if(AVIF_LOCAL_LIBGAV1)
if(AVIF_LOCAL_LIBGAV1 OR AVIF_CODEC_LIBRARIES MATCHES vmaf)
set_target_properties(avifdec PROPERTIES LINKER_LANGUAGE "CXX")
endif()
target_link_libraries(avifdec avif ${AVIF_PLATFORM_LIBRARIES} ${PNG_LIBRARY} ${ZLIB_LIBRARY} ${JPEG_LIBRARY})
Expand Down
Loading