...
 
Commits (761)
......@@ -4,3 +4,5 @@
*~
tags
.DS_Store
/tests/dav1d-test-data
*.snap
stages:
- style
- build
- test
style-check:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: style
tags:
- debian
- amd64
script:
- git grep -n -P "\t|\r| $" -- . ':(exclude)*/compat/*' && exit 1
- git grep -n -i "david" -- . ':(exclude)THANKS.md' ':(exclude).gitlab-ci.yml' && exit 1
- git remote rm upstream 2> /dev/null || true
- git remote add upstream https://code.videolan.org/videolan/dav1d.git
- git fetch -q upstream master
- for i in $(git rev-list HEAD ^upstream/master); do
echo "Checking commit message of $i";
msg="$(git log --format=%B -n 1 $i)";
if [ -n "$(echo "$msg" | awk "NR==2")" ]; then
echo "Malformed commit message in $i, second line must be empty";
exit 1;
fi;
if echo "$msg" | head -1 | grep -q '\.$'; then
echo "Malformed commit message in $i, trailing period in subject line";
exit 1;
fi;
done
build-debian:
image: registry.videolan.org:5000/dav1d-debian-unstable:20180927123816
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- debian
- amd64
script:
- meson build --buildtype release --werror
- ninja -C build
- cd build && meson test -v
build-debian-static:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- debian
- amd64
script:
- meson build --buildtype release --default-library static --werror
- ninja -C build
- cd build && meson test -v
build-debian32:
image: registry.videolan.org:5000/dav1d-debian-unstable:20181218135732
stage: build
tags:
- debian
- amd64
script:
- meson build --buildtype release
- ninja -v -C build
--werror
--cross-file /opt/crossfiles/linux32.meson
- ninja -C build
- cd build && meson test -v
build-win32:
image: registry.videolan.org:5000/dav1d-debian-unstable:20180927123816
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- win32
- debian
- amd64
script:
- wineserver -p && wine wineboot
- meson build --buildtype release
--werror
--libdir lib
--prefix "$(pwd)/build/dav1d_install"
--cross-file /opt/crossfiles/i686-w64-mingw32.meson
-Ddefault_library=both
- ninja -v -C build
- ninja -v -C build install
- ninja -C build
- ninja -C build install
- cd build && meson test -v
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- build/dav1d_install/
expire_in: 1 week
build-win32-unaligned-stack:
image: registry.videolan.org:5000/vlc-debian-llvm-mingw:20190218133533
stage: build
tags:
- debian
- amd64
script:
- wineserver -p && wine wineboot
- meson build --buildtype release
--werror
--cross-file /opt/crossfiles/i686-w64-mingw32.meson
-Dstack_alignment=4
- ninja -C build
- cd build && meson test -v
build-win64:
image: registry.videolan.org:5000/dav1d-debian-unstable:20180927123816
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- win64
- debian
- amd64
script:
- wineserver -p && wine wineboot
- meson build --buildtype release
--werror
--libdir lib
--prefix "$(pwd)/build/dav1d_install"
--cross-file /opt/crossfiles/x86_64-w64-mingw32.meson
-Ddefault_library=both
- ninja -v -C build
- ninja -v -C build install
- ninja -C build
- ninja -C build install
- cd build && meson test -v
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- build/dav1d_install/
expire_in: 1 week
build-win-arm32:
image: registry.videolan.org:5000/vlc-debian-llvm-mingw:20190218133533
stage: build
tags:
- debian
- amd64
script:
- meson build --buildtype release
--werror
--libdir lib
--prefix "$(pwd)/build/dav1d_install"
--cross-file /opt/crossfiles/armv7-w64-mingw32.meson
-Ddefault_library=both
- ninja -C build
build-win-arm64:
image: registry.videolan.org:5000/vlc-debian-llvm-mingw:20190218133533
stage: build
tags:
- debian
- amd64
script:
- meson build --buildtype release
--werror
--libdir lib
--prefix "$(pwd)/build/dav1d_install"
--cross-file /opt/crossfiles/aarch64-w64-mingw32.meson
-Ddefault_library=both
- ninja -C build
- ninja -C build install
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- build/dav1d_install/
expire_in: 1 week
build-debian-aarch64:
stage: build
image: registry.videolan.org:5000/dav1d-debian-unstable-aarch64:20181122182457
tags:
- aarch64
- debian
script:
- meson build --buildtype release --werror
- ninja -C build
- cd build && meson test -v
build-debian-aarch64-clang-5:
stage: build
image: registry.videolan.org:5000/dav1d-debian-unstable-aarch64:20181122182457
tags:
- aarch64
- debian
script:
- env CC=clang-5.0 CFLAGS='-integrated-as' meson build --buildtype release
- ninja -C build
- cd build && meson test -v
build-macos:
stage: build
tags:
- macos
script:
- meson build --buildtype release -Ddefault_library=both --werror
- ninja -C build
- cd build && meson test -v
build-debian-werror:
image: registry.videolan.org:5000/dav1d-debian-unstable-aarch64:20181122182457
stage: build
tags:
- aarch64
- debian
script:
- env CC='clang-7' meson build --buildtype debug --werror
- ninja -C build
build-debian-armv7:
stage: build
image: registry.videolan.org:5000/dav1d-debian-unstable-armv7:20190202101732
tags:
- armv7
- debian
script:
- meson build --buildtype release --werror
- ninja -C build
- cd build && meson test -v
build-debian-armv7-clang-5:
stage: build
image: registry.videolan.org:5000/dav1d-debian-unstable-armv7:20190202101732
tags:
- armv7
- debian
script:
- env CC=clang-5.0 CFLAGS='-integrated-as' meson build --buildtype release
- ninja -C build
- cd build && meson test -v
build-ubuntu-snap:
stage: build
image: registry.videolan.org:5000/dav1d-ubuntu-bionic:20190221154127
tags:
- debian
- amd64
script:
- snapcraft snap
- |
if [ "$CI_PROJECT_NAMESPACE" = "videolan" ]; then
echo $SNAP_LOGIN | base64 --decode | snapcraft login --with -
snapcraft push dav1d_*.snap --release edge
snapcraft logout
fi
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- dav1d_*.snap
expire_in: 1 week
allow_failure: true
test-debian:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
script:
- test -d cache || mkdir cache
- test -d cache/dav1d-test-data.git && GIT_DIR=cache/dav1d-test-data.git git fetch --refmap=refs/heads/master:refs/heads/master origin master
- test -d cache/dav1d-test-data.git || git clone --bare https://code.videolan.org/videolan/dav1d-test-data.git cache/dav1d-test-data.git
- git clone cache/dav1d-test-data.git tests/dav1d-test-data
- meson build --buildtype release -Dtestdata_tests=true -Dlogging=false
- ninja -C build
- cd build && time meson test -v
dependencies: []
test-debian-asan:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
ASAN_OPTIONS: 'detect_leaks=0'
script:
- test -d cache || mkdir cache
- test -d cache/dav1d-test-data.git && GIT_DIR=cache/dav1d-test-data.git git fetch --refmap=refs/heads/master:refs/heads/master origin master
- test -d cache/dav1d-test-data.git || git clone --bare https://code.videolan.org/videolan/dav1d-test-data.git cache/dav1d-test-data.git
- git clone cache/dav1d-test-data.git tests/dav1d-test-data
- meson build --buildtype debugoptimized -Dtestdata_tests=true -Dlogging=false -Db_sanitize=address -Dbuild_asm=false
- ninja -C build
- cd build && time meson test -v --setup=sanitizer
dependencies: []
test-debian-msan:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
MSAN_OPTIONS: 'exitcode=1'
script:
- test -d cache || mkdir cache
- test -d cache/dav1d-test-data.git && GIT_DIR=cache/dav1d-test-data.git git fetch --refmap=refs/heads/master:refs/heads/master origin master
- test -d cache/dav1d-test-data.git || git clone --bare https://code.videolan.org/videolan/dav1d-test-data.git cache/dav1d-test-data.git
- git clone cache/dav1d-test-data.git tests/dav1d-test-data
- env CC=clang meson build --buildtype debugoptimized -Dtestdata_tests=true -Dlogging=false -Db_sanitize=memory -Db_lundef=false -Dbuild_asm=false
- ninja -C build
- cd build && time meson test -v --setup=sanitizer
dependencies: []
test-debian-ubsan:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1'
script:
- test -d cache || mkdir cache
- test -d cache/dav1d-test-data.git && GIT_DIR=cache/dav1d-test-data.git git fetch --refmap=refs/heads/master:refs/heads/master origin master
- test -d cache/dav1d-test-data.git || git clone --bare https://code.videolan.org/videolan/dav1d-test-data.git cache/dav1d-test-data.git
- git clone cache/dav1d-test-data.git tests/dav1d-test-data
- env CC=clang meson build --buildtype debugoptimized -Dtestdata_tests=true -Dlogging=false -Db_sanitize=undefined -Db_lundef=false -Dbuild_asm=false
- ninja -C build
- cd build && time meson test -v --setup=sanitizer
dependencies: []
test-win64:
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
script:
- test -d cache || mkdir cache
- test -d cache/dav1d-test-data.git && GIT_DIR=cache/dav1d-test-data.git git fetch --refmap=refs/heads/master:refs/heads/master origin master
- test -d cache/dav1d-test-data.git || git clone --bare https://code.videolan.org/videolan/dav1d-test-data.git cache/dav1d-test-data.git
- git clone cache/dav1d-test-data.git tests/dav1d-test-data
- wineserver -p && wine wineboot
- meson build --buildtype release
-Dtestdata_tests=true
-Dlogging=false
--cross-file /opt/crossfiles/x86_64-w64-mingw32.meson
- ninja -C build
- cd build && time meson test -v
dependencies: []
# dav1d contribution guide
## CoC
The [VideoLAN Code of Conduct](https://wiki.videolan.org/CoC) applies to this project.
The [VideoLAN Code of Conduct](https://wiki.videolan.org/CoC) applies fully to this project.
## ToDo
Todo list can be found [on the wiki](https://code.videolan.org/videolan/dav1d/wikis/task-list).
The todo list can be found [on the wiki](https://code.videolan.org/videolan/dav1d/wikis/task-list).
## Codebase language
......@@ -20,7 +20,7 @@ For the library:
For the tools and utils:
- C *(see above for restrictions)*
- Rust
- C++ only for the MFT.
- C++ is only allowed for the MFT.
If you want to use *Threads* or *Atomic* features, please conform to the **C11**/**POSIX** semantic and use a wrapper for older compilers/platforms *(like done in VLC)*.
......@@ -42,12 +42,15 @@ Please read [How to Write a Git Commit Message](https://chris.beams.io/posts/git
## Submit requests (WIP)
- Code
- Check [code style](https://code.videolan.org/videolan/dav1d/wikis/Coding-style)
- Test
- Try
- Submit patches
- Code,
- [Compile](https://xkcd.com/303/),
- Check your [code style](https://code.videolan.org/videolan/dav1d/wikis/Coding-style),
- Test,
- Try,
- Submit patches through merge requests,
- Check that this passes the CI.
## Patent license
You need to read, understand, and agree to the [AV1 patents license](doc/PATENTS), before committing.
Copyright © 2018, VideoLAN and dav1d authors
Copyright © 2018-2019, VideoLAN and dav1d authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
Changes for 0.0.1:
------------------
Changes for 0.2.2 'Antelope':
----------------------------
Initial release
Changes for 0.2.1 'Antelope':
----------------------------
- SSSE3 optimization for cdef_dir
- AVX-2 improvements of the existing CDEF optimizations
- NEON improvements of the existing CDEF and wiener optimizations
- Clarification about the numbering/versionning scheme
Changes for 0.2.0 'Antelope':
----------------------------
- ARM64 and ARM optimizations using NEON instructions
- SSSE3 optimizations for both 32 and 64bits
- More AVX-2 assembly, reaching almost completion
- Fix installation of includes
- Rewrite inverse transforms to avoid overflows
- Snap packaging for Linux
- Updated API (ABI and API break)
- Fixes for un-decodable samples
Changes for 0.1.0 'Gazelle':
----------------------------
Initial release of dav1d, the fast and small AV1 decoder.
- Support for all features of the AV1 bitstream
- Support for all bitdepth, 8, 10 and 12bits
- Support for all chroma subsamplings 4:2:0, 4:2:2, 4:4:4 *and* grayscale
- Full acceleration for AVX-2 64bits processors, making it the fastest decoder
- Partial acceleration for SSSE3 processors
- Partial acceleration for NEON processors
......@@ -8,28 +8,36 @@ This project is partially funded by the *Alliance for Open Media*/**AOM**.
## Goal and Features
The goal of this project is to provide a decoder for **most platforms**, and achieve the **highest speed** possible to overcome the lack of AV1 hardware decoder.
The goal of this project is to provide a decoder for **most platforms**, and achieve the **highest speed** possible to overcome the temporary lack of AV1 hardware decoder.
It aims to support all features from AV1, including all subsampling and bit-depth parameters.
It supports all features from AV1, including all subsampling and bit-depth parameters.
In the future, this project will host simple tools or simple wrappings *(like, for example, an MFT transform)*.
## License
**dav1d** is released under a very liberal license, a contrario from the other VideoLAN projects, so that it can be embedded anywhere, including non-open-source software; or even drivers, for hybrid decoders.
**dav1d** is released under a very liberal license, a contrario from the other VideoLAN projects, so that it can be embedded anywhere, including non-open-source software; or even drivers, to allow the creation of hybrid decoders.
The reasoning behind this decision is the same as for libvorbis, [RMS on vorbis](https://lwn.net/2001/0301/a/rms-ov-license.php3).
The reasoning behind this decision is the same as for libvorbis, see [RMS on vorbis](https://lwn.net/2001/0301/a/rms-ov-license.php3).
# Roadmap
The plan is the folllowing:
### Reached
1. Complete C implementation of the decoder,
2. Provide a usable API,
3. Port to most platforms,
4. Make it fast, by writing asm.
4. Make it fast on desktop, by writing asm for AVX-2 chips.
By the end of 2018, we hope to have a completely usable version that will be faster than any other software open source implementation.
### On-going
5. Make it fast on mobile, by writing asm for ARMv8 chips,
6. Make it fast on older desktop, by writing asm for SSE chips.
### After
7. Improve C code base with [various tweaks](https://code.videolan.org/videolan/dav1d/wikis/task-list),
8. Accelerate for less common architectures,
9. Use more GPU, when possible.
# Contribute
......@@ -37,9 +45,10 @@ Currently, we are looking for help from:
- C developers,
- asm developers,
- platform-specific developers,
- GPGPU developers,
- testers.
Our contributions guidelines are strict. We want to build a coherent codebase to simplify maintenance and achieve the highest possible speed.
Our contributions guidelines are quite strict. We want to build a coherent codebase to simplify maintenance and achieve the highest possible speed.
Notably, the codebase is in pure C and asm.
......@@ -51,7 +60,7 @@ See the [contributions document](CONTRIBUTING.md).
There is no CLA.
People will keep their copyright and their authorship rights.
People will keep their copyright and their authorship rights, while adhering to the BSD 2-clause license.
VideoLAN will only have the collective work rights.
......@@ -61,10 +70,30 @@ The [VideoLAN Code of Conduct](https://wiki.videolan.org/CoC) applies to this pr
# Compile
1. Install [Meson](https://mesonbuild.com/) (0.47 or higher)
1. Install [Meson](https://mesonbuild.com/) (0.47 or higher), [Ninja](https://ninja-build.org/), and, for x86\* targets, [nasm](https://nasm.us/) (2.13.02 or higher)
2. Run `meson build --buildtype release`
3. Build with `ninja -C build`
# Run tests
1. During initial build dir setup or `meson configure` specify `-Dbuild_tests=true`
2. In the build directory run `meson test` optionally with `-v` for more verbose output, especially useful
for checkasm
# Run testdata based tests
1. Checkout the test data repository
```
git clone https://code.videolan.org/videolan/dav1d-test-data.git tests/dav1d-test-data
```
2. During initial build dir setup or `meson configure` specify `-Dbuild_tests=true` and `-Dtestdata_tests=true`
```
meson .test -Dbuild_tests=true -Dtestdata_tests=true
```
3. In the build directory run `meson test` optionally with `-v` for more verbose output
# Support
This project is partially funded by the *Alliance for Open Media*/**AOM** and is supported by TwoOrioles and VideoLabs.
......@@ -76,7 +105,7 @@ These companies can provide support and integration help, should you need it.
## Why do you not improve libaom rather than starting a new project?
- We believe that libaom is a very good library. It was however developed for research purposes during AV1 design.
- We believe that libaom is a very good library. It was however developed for research purposes during AV1 design.
We think that an implementation written from scratch can achieve faster decoding, in the same way that *ffvp9* was faster than *libvpx*.
## Is dav1d a recursive acronym?
......@@ -93,6 +122,11 @@ We think that an implementation written from scratch can achieve faster decoding
## What about the AV1 patent license?
This project is an implementation of a decoder. It gives you no special rights on the AV1 patents.
- This project is an implementation of a decoder. It gives you no special rights on the AV1 patents.
Please read the [AV1 patent license](doc/PATENTS) that applies to the AV1 specification and codec.
## Will you care about <my_arch>? <my_os>?
- We do, but we don't have either the time or the knowledge. Therefore, patches and contributions welcome.
......@@ -10,7 +10,10 @@ The Alliance for Open Media (AOM) for funding this project.
## Projects
* VideoLAN
* FFmpeg
* libplacebo
## Individual
And all the dav1d Authors (git shortlog -sn)
And all the dav1d Authors (git shortlog -sn), including:
Janne Grunau, Ronald S. Bultje, Martin Storsjö, James Almer, Henrik Gramner, Marvin Scholz, Luc Trudeau, David Michael Barr, Jean-Baptiste Kempf, Hugo Beauzée-Luyssen, Steve Lhomme, Francois Cartegnie, Konstantin Pavlov, Nathan E. Egge, Victorien Le Couviour--Tuffet, Derek Buitenhuis, Liwei Wang, Raphaël Zumer, Michael Bradshaw, Niklas Haas, Xuefeng Jiang, Boyuan Xiao, Kyle Siefring, Matthias Dressel, Rupert Swarbrick, Thierry Foucu, Thomas Daede, Jan Beich, SmilingWolf, Tristan Laurent, Vittorio Giovara, Anisse Astier, Dale Curtis, Fred Barbier, Jean-Yves Avenard, Luca Barbato, Mark Shuttleworth, Nicolas Frattaroli, Rostislav Pehlivanov, Shiz, Steinar Midtskogen, Timo Gurr and skal.
PROJECT_NAME = dav1d
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT@
STRIP_FROM_PATH = @DOXYGEN_STRIP@
OUTPUT_LANGUAGE = English
TAB_SIZE = 4
EXTRACT_ALL = YES
OPTIMIZE_OUTPUT_FOR_C = YES
DOXYFILE_ENCODING = UTF-8
TYPEDEF_HIDES_STRUCT = YES
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
INPUT = @DOXYGEN_INPUT@
FILE_PATTERNS = *.h
GENERATE_HTML = YES
GENERATE_LATEX = NO
......@@ -57,10 +57,10 @@ Alliance for Open Media Patent License 1.0
2. Definitions.
2.1. Affiliate. “Affiliate” means an entity that directly or indirectly
2.1. Affiliate. “Affiliate” means an entity that directly or indirectly
Controls, is Controlled by, or is under common Control of that party.
2.2. Control. “Control” means direct or indirect control of more than 50% of
2.2. Control. “Control” means direct or indirect control of more than 50% of
the voting power to elect directors of that corporation, or for any other
entity, the power to direct management of such entity.
......@@ -70,7 +70,7 @@ Alliance for Open Media Patent License 1.0
2.4. Encoder. "Encoder" means any encoder that produces a bitstream that can
be decoded by a Decoder only to the extent it produces such a bitstream.
2.5. Final Deliverable. “Final Deliverable” means the final version of a
2.5. Final Deliverable. “Final Deliverable” means the final version of a
deliverable approved by the Alliance for Open Media as a Final
Deliverable.
......@@ -79,9 +79,9 @@ Alliance for Open Media Patent License 1.0
Implementation also includes components of an Implementation only to the
extent they are used as part of an Implementation.
2.7. License. “License” means this license.
2.7. License. “License” means this license.
2.8. Licensee. “Licensee” means any person or entity who exercises patent
2.8. Licensee. “Licensee” means any person or entity who exercises patent
rights granted under this License.
2.9. Licensor. "Licensor" means (i) any Licensee that makes, sells, offers
......@@ -98,11 +98,11 @@ Alliance for Open Media Patent License 1.0
as if the Specification was a W3C Recommendation; or (ii) are infringed
by the Reference Implementation.
2.11. Reference Implementation. “Reference Implementation” means an Encoder
2.11. Reference Implementation. “Reference Implementation” means an Encoder
and/or Decoder released by the Alliance for Open Media as a Final
Deliverable.
2.12. Specification. “Specification” means the specification designated by
2.12. Specification. “Specification” means the specification designated by
the Alliance for Open Media as a Final Deliverable for which this
License was issued.
# Copyright © 2018, VideoLAN and dav1d authors
# 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 OWNER 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.
doxygen = find_program('doxygen', required: false)
if doxygen.found()
conf_data = configuration_data()
conf_data.set('DOXYGEN_INPUT', join_paths(meson.source_root(), 'include/dav1d'))
conf_data.set('DOXYGEN_STRIP', join_paths(meson.source_root(), 'include'))
conf_data.set('DOXYGEN_OUTPUT', meson.current_build_dir())
doxyfile = configure_file(input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: conf_data)
custom_target('doc',
build_by_default: false,
command: [doxygen, doxyfile],
output: ['html']
)
endif
......@@ -25,11 +25,35 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_ATTRIBUTES_H__
#define __DAV1D_COMMON_ATTRIBUTES_H__
#ifndef DAV1D_COMMON_ATTRIBUTES_H
#define DAV1D_COMMON_ATTRIBUTES_H
#include "config.h"
#include <stddef.h>
#ifdef __GNUC__
#define ATTR_ALIAS __attribute__((may_alias))
#define ATTR_FORMAT_PRINTF(fmt, attr) __attribute__((__format__(__printf__, fmt, attr)));
#else
#define ATTR_ALIAS
#define ATTR_FORMAT_PRINTF(fmt, attr)
#endif
#if ARCH_X86_64
/* x86-64 needs 32-byte alignment for AVX2. */
#define ALIGN_32_VAL 32
#define ALIGN_16_VAL 16
#elif ARCH_X86_32 || ARCH_ARM || ARCH_AARCH64
/* ARM doesn't benefit from anything more than 16-byte alignment. */
#define ALIGN_32_VAL 16
#define ALIGN_16_VAL 16
#else
/* No need for extra alignment on platforms without assembly. */
#define ALIGN_32_VAL 8
#define ALIGN_16_VAL 8
#endif
/*
* API for variables, struct members (ALIGN()) like:
* uint8_t var[1][2][3][4]
......@@ -51,10 +75,10 @@
* ALIGN_STK_$align(uint8_t, var, 1, [2][3][4])
*/
#define ALIGN_STK_32(type, var, sz1d, sznd) \
ALIGN(type var[sz1d]sznd, 32)
ALIGN(type var[sz1d]sznd, ALIGN_32_VAL)
// as long as stack is itself 16-byte aligned, this works (win64, gcc)
#define ALIGN_STK_16(type, var, sz1d, sznd) \
ALIGN(type var[sz1d]sznd, 16)
ALIGN(type var[sz1d]sznd, ALIGN_16_VAL)
/*
* Forbid inlining of a function:
......@@ -66,6 +90,11 @@
#define NOINLINE __attribute__((noinline))
#endif /* !_MSC_VER */
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
# define dav1d_uninit(x) x=x
#else
# define dav1d_uninit(x) x
#endif
#ifdef _MSC_VER
#include <intrin.h>
......@@ -82,11 +111,20 @@ static inline int clz(const unsigned int mask) {
return (31 - leading_zero);
}
#ifdef _WIN64
static inline int clzll(const unsigned long long mask) {
unsigned long leading_zero = 0;
_BitScanReverse64(&leading_zero, mask);
return (63 - leading_zero);
}
#else /* _WIN64 */
static inline int clzll(const unsigned long long mask) {
if (mask >> 32)
return clz((unsigned)(mask >> 32));
else
return clz((unsigned)mask) + 32;
}
#endif /* _WIN64 */
#else /* !_MSC_VER */
static inline int ctz(const unsigned int mask) {
return __builtin_ctz(mask);
......@@ -101,4 +139,4 @@ static inline int clzll(const unsigned long long mask) {
}
#endif /* !_MSC_VER */
#endif /* __DAV1D_COMMON_ATTRIBUTES_H__ */
#endif /* DAV1D_COMMON_ATTRIBUTES_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_BITDEPTH_H__
#define __DAV1D_COMMON_BITDEPTH_H__ 1
#ifndef DAV1D_COMMON_BITDEPTH_H
#define DAV1D_COMMON_BITDEPTH_H
#include <stdint.h>
#include <string.h>
......@@ -34,6 +34,9 @@
#if !defined(BITDEPTH)
typedef void pixel;
typedef void coef;
#define HIGHBD_DECL_SUFFIX /* nothing */
#define HIGHBD_CALL_SUFFIX /* nothing */
#define HIGHBD_TAIL_SUFFIX /* nothing */
#elif BITDEPTH == 8
typedef uint8_t pixel;
typedef int16_t coef;
......@@ -41,28 +44,37 @@ typedef int16_t coef;
#define pixel_set memset
#define iclip_pixel iclip_u8
#define PIX_HEX_FMT "%02x"
#define bytefn(x) x##_8bpc
#define bitfn(x) x##_8bpc
#define PXSTRIDE(x) x
#elif BITDEPTH == 10 || BITDEPTH == 12
#define highbd_only(x)
#define HIGHBD_DECL_SUFFIX /* nothing */
#define HIGHBD_CALL_SUFFIX /* nothing */
#define HIGHBD_TAIL_SUFFIX /* nothing */
#define bitdepth_from_max(x) 8
#elif BITDEPTH == 16
typedef uint16_t pixel;
typedef int32_t coef;
#define pixel_copy(a, b, c) memcpy(a, b, (c) << 1)
#define iclip_pixel(x) iclip(x, 0, ((1 << BITDEPTH) - 1))
static inline void pixel_set(pixel *const dst, const int val, const int num) {
for (int n = 0; n < num; n++)
dst[n] = val;
}
#define PIX_HEX_FMT "%03x"
#define bytefn(x) x##_16bpc
#if BITDEPTH == 10
#define bitfn(x) x##_10bpc
#else
#define bitfn(x) x##_12bpc
#endif
#define iclip_pixel(x) iclip(x, 0, bitdepth_max)
#define HIGHBD_DECL_SUFFIX , const int bitdepth_max
#define HIGHBD_CALL_SUFFIX , f->bitdepth_max
#define HIGHBD_TAIL_SUFFIX , bitdepth_max
#define bitdepth_from_max(bitdepth_max) (32 - clz(bitdepth_max))
#define bitfn(x) x##_16bpc
#define PXSTRIDE(x) (x >> 1)
#define highbd_only(x) x
#else
#error invalid value for bitdepth
#endif
#define bytefn(x) bitfn(x)
#define bitfn_decls(name, ...) \
name##_8bpc(__VA_ARGS__); \
name##_16bpc(__VA_ARGS__)
#endif /* __DAV1D_COMMON_BITDEPTH_H__ */
#endif /* DAV1D_COMMON_BITDEPTH_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_DUMP_H__
#define __DAV1D_COMMON_DUMP_H__
#ifndef DAV1D_COMMON_DUMP_H
#define DAV1D_COMMON_DUMP_H
#include <stddef.h>
#include <stdint.h>
......@@ -83,4 +83,4 @@ static inline void ac_dump(const int16_t *buf, int w, int h, const char *what)
}
}
#endif /* __DAV1D_COMMON_DUMP_H__ */
#endif /* DAV1D_COMMON_DUMP_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_INTOPS_H__
#define __DAV1D_COMMON_INTOPS_H__
#ifndef DAV1D_COMMON_INTOPS_H
#define DAV1D_COMMON_INTOPS_H
#include <stdint.h>
......@@ -52,6 +52,10 @@ static inline int apply_sign(const int v, const int s) {
return s < 0 ? -v : v;
}
static inline int apply_sign64(const int v, const int64_t s) {
return s < 0 ? -v : v;
}
static inline int ulog2(const unsigned v) {
return 31 - clz(v);
}
......@@ -60,14 +64,6 @@ static inline int u64log2(const uint64_t v) {
return 63 - clzll(v);
}
static inline unsigned rl16(const uint8_t *const ptr) {
return (ptr[1] << 8) | ptr[0];
}
static inline unsigned rl32(const uint8_t *const ptr) {
return (rl16(&ptr[2]) << 16) | rl16(ptr);
}
static inline unsigned inv_recenter(const unsigned r, const unsigned v) {
if (v > (r << 1))
return v;
......@@ -77,4 +73,4 @@ static inline unsigned inv_recenter(const unsigned r, const unsigned v) {
return r - ((v + 1) >> 1);
}
#endif /* __DAV1D_COMMON_INTOPS_H__ */
#endif /* DAV1D_COMMON_INTOPS_H */
......@@ -25,13 +25,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_MEM_H__
#define __DAV1D_COMMON_MEM_H__
#ifndef DAV1D_COMMON_MEM_H
#define DAV1D_COMMON_MEM_H
#include <assert.h>
#include <stdlib.h>
#ifdef HAVE_ALIGNED_MALLOC
#if defined(HAVE_ALIGNED_MALLOC) || defined(HAVE_MEMALIGN)
#include <malloc.h>
#endif
......@@ -47,6 +47,8 @@ static inline void *dav1d_alloc_aligned(size_t sz, size_t align) {
return ptr;
#elif defined(HAVE_ALIGNED_MALLOC)
return _aligned_malloc(sz, align);
#elif defined(HAVE_MEMALIGN)
return memalign(align, sz);
#else
#error Missing aligned alloc implementation
#endif
......@@ -57,6 +59,8 @@ static inline void dav1d_free_aligned(void* ptr) {
free(ptr);
#elif defined(HAVE_ALIGNED_MALLOC)
_aligned_free(ptr);
#elif defined(HAVE_MEMALIGN)
free(ptr);
#endif
}
......@@ -76,4 +80,4 @@ static inline void freep(void *ptr) {
}
}
#endif /* __DAV1D_COMMON_MEM_H__ */
#endif /* DAV1D_COMMON_MEM_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_VALIDATE_H__
#define __DAV1D_COMMON_VALIDATE_H__
#ifndef DAV1D_COMMON_VALIDATE_H
#define DAV1D_COMMON_VALIDATE_H
#include <stdio.h>
#include <stdlib.h>
......@@ -56,4 +56,4 @@
#define validate_input(x) validate_input_or_ret(x, )
#endif /* __DAV1D_COMMON_VALIDATE_H__ */
#endif /* DAV1D_COMMON_VALIDATE_H */
/*
* Copyright © 2018, VideoLAN and dav1d authors
* 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 OWNER 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.
*/
#ifndef GCCVER_STDATOMIC_H_
#define GCCVER_STDATOMIC_H_
#if !defined(__cplusplus)
typedef int atomic_int;
typedef unsigned int atomic_uint;
#define memory_order_relaxed __ATOMIC_RELAXED
#define memory_order_acquire __ATOMIC_ACQUIRE
#define atomic_init(p_a, v) do { *(p_a) = (v); } while(0)
#define atomic_store(p_a, v) __atomic_store_n(p_a, v, __ATOMIC_SEQ_CST)
#define atomic_load(p_a) __atomic_load_n(p_a, __ATOMIC_SEQ_CST)
#define atomic_load_explicit(p_a, mo) __atomic_load_n(p_a, mo)
#define atomic_fetch_add(p_a, inc) __atomic_fetch_add(p_a, inc, __ATOMIC_SEQ_CST)
#define atomic_fetch_sub(p_a, dec) __atomic_fetch_sub(p_a, dec, __ATOMIC_SEQ_CST)
#endif /* !defined(__cplusplus) */
#endif /* GCCVER_STDATOMIC_H_ */
......@@ -50,8 +50,6 @@ extern int optreset;
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
......@@ -93,3 +91,5 @@ extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
#endif /* !defined(__GETOPT_H__) */
/*
* Copyright © 2018, VideoLAN and dav1d authors
* 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 OWNER 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.
*/
#ifndef MSCVER_STDATOMIC_H_
#define MSCVER_STDATOMIC_H_
#if !defined(__cplusplus) && defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4067) /* newline for __has_include_next */
#if defined(__clang__) && __has_include_next(<stdatomic.h>)
/* use the clang stdatomic.h with clang-cl*/
# include_next <stdatomic.h>
#else /* ! stdatomic.h */
#include <windows.h>
#include "common/attributes.h"
typedef volatile LONG __declspec(align(32)) atomic_int;
typedef volatile ULONG __declspec(align(32)) atomic_uint;
typedef enum {
memory_order_relaxed,
memory_order_acquire
} msvc_atomic_memory_order;
#define atomic_init(p_a, v) do { *(p_a) = (v); } while(0)
#define atomic_store(p_a, v) InterlockedExchange((LONG*)p_a, v)
#define atomic_load(p_a) InterlockedCompareExchange((LONG*)p_a, 0, 0)
#define atomic_load_explicit(p_a, mo) atomic_load(p_a)
/*
* TODO use a special call to increment/decrement
* using InterlockedIncrement/InterlockedDecrement
*/
#define atomic_fetch_add(p_a, inc) InterlockedExchangeAdd(p_a, inc)
#define atomic_fetch_sub(p_a, dec) InterlockedExchangeAdd(p_a, -(dec))
#endif /* ! stdatomic.h */
#pragma warning(pop)
#endif /* !defined(__cplusplus) && defined(_MSC_VER) */
#endif /* MSCVER_STDATOMIC_H_ */
......@@ -25,8 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#ifndef DAV1D_COMMON_H
#define DAV1D_COMMON_H
#include <stddef.h>
#include <stdint.h>
#ifndef DAV1D_API
#if defined _WIN32
......@@ -40,4 +43,28 @@
#endif
#endif
#endif // __COMMON_H__
/**
* A reference-counted object wrapper for a user-configurable pointer.
*/
typedef struct Dav1dUserData {
const uint8_t *data; ///< data pointer
struct Dav1dRef *ref; ///< allocation origin
} Dav1dUserData;
/**
* Input packet metadata which are copied from the input data used to
* decode each image into the matching structure of the output image
* returned back to the user. Since these are metadata fields, they
* can be used for other purposes than the documented ones, they will
* still be passed from input data to output picture without being
* used internally.
*/
typedef struct Dav1dDataProps {
int64_t timestamp; ///< container timestamp of input data, INT64_MIN if unknown (default)
int64_t duration; ///< container duration of input data, 0 if unknown (default)
int64_t offset; ///< stream offset of input data, -1 if unknown (default)
size_t size; ///< packet size, default Dav1dData.sz
struct Dav1dUserData user_data; ///< user-configurable data, default NULL members
} Dav1dDataProps;
#endif /* DAV1D_COMMON_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_DATA_H__
#define __DAV1D_DATA_H__
#ifndef DAV1D_DATA_H
#define DAV1D_DATA_H
#include <stddef.h>
#include <stdint.h>
......@@ -34,19 +34,76 @@
#include "common.h"
typedef struct Dav1dData {
uint8_t *data; ///< data pointer
const uint8_t *data; ///< data pointer
size_t sz; ///< data size
struct Dav1dRef *ref; ///< allocation origin
Dav1dDataProps m; ///< user provided metadata passed to the output picture
} Dav1dData;
/**
* Allocate data.
*
* @param data Input context.
* @param sz Size of the data that should be allocated.
*
* @return Pointer to the allocated buffer on success. NULL on error.
*/
DAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);
/**
* Wrap an existing data array.
*
* @param data Input context.
* @param buf The data to be wrapped.
* @param sz Size of the data.
* @param free_callback Function to be called when we release our last
* reference to this data. In this callback, $buf will be
* the $buf argument to this function, and $cookie will
* be the $cookie input argument to this function.
* @param cookie Opaque parameter passed to free_callback().
*
* @return 0 on success. A negative errno value on error.
*/
DAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,
void (*free_callback)(const uint8_t *buf, void *cookie),
void *cookie);
/**
* Wrap a user-provided data pointer into a reference counted object.
*
* data->m.user_data field will initialized to wrap the provided $user_data
* pointer.
*
* $free_callback will be called on the same thread that released the last
* reference. If frame threading is used, make sure $free_callback is
* thread-safe.
*
* @param data Input context.
* @param user_data The user data to be wrapped.
* @param free_callback Function to be called when we release our last
* reference to this data. In this callback, $user_data
* will be the $user_data argument to this function, and
* $cookie will be the $cookie input argument to this
* function.
* @param cookie Opaque parameter passed to $free_callback.
*
* @return 0 on success. A negative errno value on error.
*/
DAV1D_API int dav1d_data_create(Dav1dData *data, size_t sz);
DAV1D_API int dav1d_data_wrap_user_data(Dav1dData *data,
const uint8_t *user_data,
void (*free_callback)(const uint8_t *user_data,
void *cookie),
void *cookie);
/**
* Free data.
* Free the data reference.
*
* The reference count for data->m.user_data will be decremented (if it has been
* initialized with dav1d_data_wrap_user_data). The $data object will be memset
* to 0.
*
* @param data Input context.
*/
DAV1D_API void dav1d_data_unref(Dav1dData *buf);
DAV1D_API void dav1d_data_unref(Dav1dData *data);
#endif /* __DAV1D_DATA_H__ */
#endif /* DAV1D_DATA_H */
......@@ -25,26 +25,49 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_H__
#define __DAV1D_H__
#ifndef DAV1D_H
#define DAV1D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <stdarg.h>
#include "common.h"
#include "picture.h"
#include "data.h"
#include "version.h"
typedef struct Dav1dContext Dav1dContext;
typedef struct Dav1dRef Dav1dRef;
#define DAV1D_MAX_FRAME_THREADS 256
#define DAV1D_MAX_TILE_THREADS 64
typedef struct Dav1dLogger {
void *cookie; ///< Custom data to pass to the callback.
/**
* Logger callback. Default prints to stderr. May be NULL to disable logging.
*
* @param cookie Custom pointer passed to all calls.
* @param format The vprintf compatible format string.
* @param ap List of arguments referenced by the format string.
*/
void (*callback)(void *cookie, const char *format, va_list ap);
} Dav1dLogger;
typedef struct Dav1dSettings {
int n_frame_threads;
int n_tile_threads;
int apply_grain;
int operating_point; ///< select an operating point for scalable AV1 bitstreams (0 - 31)
int all_layers; ///< output all spatial layers of a scalable AV1 biststream
Dav1dPicAllocator allocator;
Dav1dLogger logger;
} Dav1dSettings;
/*
* Init the library.
*/
DAV1D_API void dav1d_init(void);
/**
* Get library version.
*/
......@@ -52,36 +75,131 @@ DAV1D_API const char *dav1d_version(void);
/**
* Initialize settings to default values.
*
* @param s Input settings context.
*/
DAV1D_API void dav1d_default_settings(Dav1dSettings *s);
/**
* Open/allocate decoder instance.
* Allocate and open a decoder instance.
*
* The resulting instance context will be placed in $c_out and can be used in
* iterative calls to dav1d_decode().
* @param c_out The decoder instance to open. *c_out will be set to the
* allocated context.
* @param s Input settings context.
*
* You should free the context using dav1d_close() when you're done decoding.
* @note The context must be freed using dav1d_close() when decoding is
* finished.
*
* This returns < 0 (a negative errno code) on error, or 0 on success.
* @return 0 on success, or < 0 (a negative errno code) on error.
*/
DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
/**
* Decode one input frame. Library takes ownership of the passed-in reference.
* After that, it will return < 0 (a negative errno code, but not -EAGAIN) on
* failure, or 0 on success. If any decoded output frames are available, they
* will be placed in $out. The caller assumes ownership of the returned output
* picture.
*
* To flush the decoder (i.e. all input is finished), feed it NULL input data
* until it returns -EAGAIN.
* Parse a Sequence Header OBU from bitstream data.
*
* @param out Output Sequence Header.
* @param buf The data to be parser.
* @param sz Size of the data.
*
* @return 0 on success, or < 0 (a negative errno code) on error.
*
* @note It is safe to feed this function data containing other OBUs than a
* Sequence Header, as they will simply be ignored. If there is more than
* one Sequence Header OBU present, only the last will be returned.
*/
DAV1D_API int dav1d_decode(Dav1dContext *c, Dav1dData *in, Dav1dPicture *out);
DAV1D_API int dav1d_parse_sequence_header(Dav1dSequenceHeader *out,
const uint8_t *buf, const size_t sz);
/**
* Close decoder instance, free all associated memory, and set $c_out to NULL.
* Feed bitstream data to the decoder.
*
* @param c Input decoder instance.
* @param in Input bitstream data. On success, ownership of the reference is
* passed to the library.
*
* @return
* 0: Success, and the data was consumed.
* -EAGAIN: The data can't be consumed. dav1d_get_picture() should be called
* to get one or more frames before the function can consume new
* data.
* other negative errno codes: Error during decoding or because of invalid
* passed-in arguments.
*/
DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);
/**
* Return a decoded picture.
*
* @param c Input decoder instance.
* @param out Output frame. The caller assumes ownership of the returned
* reference.
*
* @return
* 0: Success, and a frame is returned.
* -EAGAIN: Not enough data to output a frame. dav1d_send_data() should be
* called with new input.
* other negative errno codes: Error during decoding or because of invalid
* passed-in arguments.
*
* @note To drain buffered frames from the decoder (i.e. on end of stream),
* call this function until it returns -EAGAIN.
*
* @code{.c}
* Dav1dData data = { 0 };
* Dav1dPicture p = { 0 };
* int res;
*
* read_data(&data);
* do {
* res = dav1d_send_data(c, &data);
* // Keep going even if the function can't consume the current data
* packet. It eventually will after one or more frames have been
* returned in this loop.
* if (res < 0 && res != -EAGAIN)
* free_and_abort();
* res = dav1d_get_picture(c, &p);
* if (res < 0) {
* if (res != -EAGAIN)
* free_and_abort();
* } else
* output_and_unref_picture(&p);
* // Stay in the loop as long as there's data to consume.
* } while (data.sz || read_data(&data) == SUCCESS);
*
* // Handle EOS by draining all buffered frames.
* do {
* res = dav1d_get_picture(c, &p);
* if (res < 0) {
* if (res != -EAGAIN)
* free_and_abort();
* } else
* output_and_unref_picture(&p);
* } while (res == 0);
* @endcode
*/
DAV1D_API int dav1d_get_picture(Dav1dContext *c, Dav1dPicture *out);
/**
* Close a decoder instance and free all associated memory.
*
* @param c_out The decoder instance to close. *c_out will be set to NULL.
*/
DAV1D_API void dav1d_close(Dav1dContext **c_out);
#endif /* __DAV1D_H__ */
/**
* Flush all delayed frames in decoder and clear internal decoder state,
* to be used when seeking.
*
* @param c Input decoder instance.
*
* @note Decoding will start only after a valid sequence header OBU is
* delivered to dav1d_send_data().
*
*/
DAV1D_API void dav1d_flush(Dav1dContext *c);
# ifdef __cplusplus
}
# endif
#endif /* DAV1D_H */
/*
* Copyright © 2018, VideoLAN and dav1d authors
* Copyright © 2018, Two Orioles, LLC
* 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 OWNER 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