commit | 094e6166339bc317d54b42460232c28193ea4daf | [log] [tgz] |
---|---|---|
author | Vignesh Venkatasubramanian <vigneshv@google.com> | Wed May 17 15:24:35 2023 -0700 |
committer | Vignesh Venkatasubramanian <vigneshvg@users.noreply.github.com> | Mon May 22 13:58:32 2023 -0700 |
tree | c33759b5ebc2b09fdbc999e68e0ebc304fa32e48 | |
parent | cf0505a8612456178aa4e9b8321314a23e52f7cd [diff] |
Use global configs for keyframe interval Instead of computing the required keyframe interval in libavif code and passing the "force keyframe" flag on individual frames, use each encoder's global configuration parameter to set the maximum keyframe interval. For libaom: `kf_max_dist`. For rav1e: `key_frame_interval`. For svt-av1: `intra_period_length` and `force_key_frames`. Here's the output obtained from various encoders for encoding an animated file with 10 frames with different values for --keyframe. Each line is read as follows: --keyframe value: list of key frames before => list of keyframes after. aom: --keyframe 0: same before and after. --keyframe 1: same before and after. --keyframe 2: 1,2,3,4,5,6,7,8,9,10 => 1,3,5,7,9 (the old behavior was not incorrect, but new one is exact). --keyframe 5: 1,2,6,7 =>1,6 (the old behavior was not incorrect, but new one is exact). rav1e: * no changes. same output before and after. svt-av1: --keyframe 0: same before and after. --keyframe 1: 1 => 1,2,3,4,5,6,7,8,9,10 (old behavior was incorrect). --keyframe 2: 1 => 1,3,5,7,9 (old behavior was incorrect). --keyframe 5: 1 => 1,6 (old behavior was incorrect). To sum up: * svt-av1 was not producing the intended output with --keyframe before this change. * libaom had some weirdness in keyframe spacing when using the force keyframe flag on each frame and that weirdness goes away when using the kf_max_dist configuration (see: https://bugs.chromium.org/p/aomedia/issues/detail?id=3445). The `AVIF_ADD_IMAGE_FLAG_FORCE_KEYFRAME` flag is retained in the codebase since there are some follow-up changes that will make use of the flag to synchronize keyframe placement between the color and alpha plane encoders (Issue #841).
This library aims to be a friendly, portable C implementation of the AV1 Image File Format, as described here:
https://aomediacodec.github.io/av1-avif/
It is a work-in-progress, but can already encode and decode all AOM supported YUV formats and bit depths (with alpha).
For now, it is recommended that you check out/use tagged releases instead of just using the master branch. I will regularly create new versions as bugfixes and features are added.
Please see the examples in the “examples” directory. If you're already building libavif
, enable the CMake option AVIF_BUILD_EXAMPLES
in order to build and run the examples too.
Building libavif requires CMake.
No AV1 codecs are enabled by default. Enable them by enabling any of the following CMake options (e.g. -DAVIF_CODEC_AOM=ON
):
AVIF_CODEC_AOM
for libaom (encoder and decoder)AVIF_CODEC_DAV1D
for dav1d (decoder)AVIF_CODEC_LIBGAV1
for libgav1 (decoder)AVIF_CODEC_RAV1E
for rav1e (encoder)AVIF_CODEC_SVT
for SVT-AV1 (encoder)These libraries (in their C API form) must be externally available (discoverable via CMake‘s FIND_LIBRARY
) to use them, or if libavif is a child CMake project, the appropriate CMake target must already exist by the time libavif’s CMake scripts are executed.
The ext/
subdirectory contains a handful of basic scripts which each pull down a known-good copy of an AV1 codec and make a local static library build. Most scripts require CMake, Ninja and NASM. dav1d uses Meson instead of CMake, and rav1e uses cargo (Rust). Check each library's documentation for an exact list of requirements.
If you want to statically link any codec into your local (static) build of libavif, building using one of these scripts and then enabling the associated AVIF_LOCAL_*
is a convenient method, but you must make sure to disable BUILD_SHARED_LIBS
in CMake to instruct it to make a static libavif library.
If you want to build/install shared libraries for AV1 codecs, you can still peek inside of each script to see where the current known-good SHA is for each codec.
A few tests written in C can be built by enabling the AVIF_BUILD_TESTS
CMake option.
The remaining tests can be built by enabling the AVIF_BUILD_TESTS
and AVIF_ENABLE_GTEST
CMake options. They require GoogleTest to be built locally with ext/googletest.cmd or installed on the system.
If you're building on Windows with Visual Studio 2022 and want to try out libavif without going through the build process, static library builds for both Debug and Release are available on AppVeyor.
libavif is written in C99.
Use clang-format to format the C sources from the top-level folder:
clang-format -style=file -i \ apps/*.c apps/shared/avifexif.* apps/shared/avifjpeg.* \ apps/shared/avifpng.* apps/shared/avifutil.* apps/shared/y4m.* \ examples/*.c include/avif/*.h src/*.c tests/*.c \ tests/gtest/*.h tests/gtest/*.cc tests/oss-fuzz/*.cc
Use cmake-format to format the CMakeLists.txt files from the top-level folder:
cmake-format -i \ CMakeLists.txt \ tests/CMakeLists.txt \ cmake/Modules/Find*.cmake \ contrib/CMakeLists.txt \ contrib/gdk-pixbuf/CMakeLists.txt \ android_jni/avifandroidjni/src/main/jni/CMakeLists.txt
Released under the BSD License.
Copyright 2019 Joe Drago. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.