commit | 39682be5977c83dc7540e9feeca347ccfd51fd9f | [log] [tgz] |
---|---|---|
author | Vignesh Venkatasubramanian <vigneshv@google.com> | Fri Apr 07 12:12:41 2023 -0700 |
committer | Vignesh Venkatasubramanian <vigneshvg@users.noreply.github.com> | Mon Apr 10 10:09:20 2023 -0700 |
tree | e80b4aa6300ceb5b4040b7fe2b256cbe3c4b0700 | |
parent | 60ba714e351056384faa9e1db42ae86000f2a909 [diff] |
Use a single decoder instance for grid images When decoding AVIF images with grid cells, use a single decoder instance for all the cells instead of creating a decoder instance for each cell. This is okay to do since each cell must be a key frame. So they can be decoded with a single decoder instance. This change also requires each decoded cell to be copied over to the output image right away instead of being done in the end. There are some edge cases where we will still need multiple decoder instances: * For animated AVIF, we will need two instances (one for the color planes and one for the alpha plane since they are both encoded as separate video sequences). * For grid images with multiple layers. In this case, each grid will need its own decoder instance since there would be multiple layers in each grid. * For grid images where the operating point of all the grids are not the same. This is a bit of a peculiar edge case that is very unlikely to happen in practice. However, the spec does not disallow this as far as i can tell. So to be safe, we will use multiple decoder instances in this case as well. This is better because of the following reasons: * Eliminates the cost of creating and shutting down several decoders (and threads when threading is enabled). * The underlying decoder is likely to re-use its internal frame buffer and not create a new one for each cell (unless the cell dimensions vary). On android, with 2 threads on a set of 2x2 grid images the newer implementation is about 5-10% faster when using dav1d and 25-30% faster when using libgav1. On android, for a 5x4 grid image [1], dav1d is about 30% faster and libgav1 is about 40% faster. On desktop, both are about 10% faster. The performance improvement gets better as the number of cells increase. [1] https://github.com/AOMediaCodec/av1-avif/raw/master/testFiles/Microsoft/Summer_in_Tomsk_720p_5x4_grid.avif
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:
AVIF_CODEC_AOM
- requires CMake, NASMAVIF_CODEC_DAV1D
- requires Meson, Ninja, NASMAVIF_CODEC_LIBGAV1
- requires CMake, NinjaAVIF_CODEC_RAV1E
- requires cargo (Rust), NASMThese 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. 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.