Commits (200)
......@@ -5,3 +5,4 @@
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:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- debian
......@@ -14,7 +40,7 @@ build-debian:
- cd build && meson test -v
build-debian-static:
image: registry.videolan.org:5000/dav1d-debian-unstable:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: build
tags:
- debian
......@@ -24,12 +50,27 @@ build-debian-static:
- 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
--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:20181114201132
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
......@@ -38,18 +79,36 @@ build-win32:
-Ddefault_library=both
- 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:20181114201132
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
......@@ -58,6 +117,43 @@ build-win64:
-Ddefault_library=both
- 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:
......@@ -105,14 +201,57 @@ build-debian-werror:
- 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:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
script:
......@@ -120,19 +259,19 @@ test-debian:
- 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
- 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:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
......@@ -142,19 +281,19 @@ test-debian-asan:
- 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 -Db_sanitize=address -Dbuild_asm=false
- 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:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
......@@ -164,19 +303,19 @@ test-debian-msan:
- 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 -Db_sanitize=memory -Db_lundef=false -Dbuild_asm=false
- 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:20181114201132
image: registry.videolan.org:5000/dav1d-debian-unstable:20190215130514
stage: test
tags:
- debian
- amd64
cache:
key: testdata.git
key: testdata.git-20190215
paths:
- cache/dav1d-test-data.git/
variables:
......@@ -186,7 +325,31 @@ test-debian-ubsan:
- 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 -Db_sanitize=undefined -Db_lundef=false -Dbuild_asm=false
- 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.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':
----------------------------
......
......@@ -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,7 +70,7 @@ 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), [Ninja](https://ninja-build.org/), and, for x86* targets, [nasm](https://nasm.us/) (2.13 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`
......@@ -79,6 +88,10 @@ The [VideoLAN Code of Conduct](https://wiki.videolan.org/CoC) applies to this pr
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
......@@ -109,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, James Almer, Marvin Scholz, Henrik Gramner, Martin Storsjö, Luc Trudeau, David Michael Barr, Hugo Beauzée-Luyssen, Steve Lhomme, Jean-Baptiste Kempf, Derek Buitenhuis, Nathan E. Egge, Raphaël Zumer, Francois Cartegnie, Niklas Haas, Konstantin Pavlov, Boyuan Xiao, Raphael Zumer and Michael Bradshaw.
......@@ -25,8 +25,8 @@
* 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"
......@@ -34,19 +34,22 @@
#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
#if ARCH_X86_64
/* x86-64 needs 32-byte alignment for AVX2. */
#define ALIGN_32_VAL 32
#define ALIGN_16_VAL 16
#elif ARCH_ARM || ARCH_AARCH64
// ARM doesn't benefit from anything more than 16 byte alignment.
#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.
/* No need for extra alignment on platforms without assembly. */
#define ALIGN_32_VAL 8
#define ALIGN_16_VAL 8
#endif
......@@ -136,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>
......@@ -77,4 +77,4 @@ static inline void pixel_set(pixel *const dst, const int val, const int num) {
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>
......@@ -73,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,8 +25,8 @@
* 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>
......@@ -80,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 */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_COMMON_H__
#define __DAV1D_COMMON_H__
#ifndef DAV1D_COMMON_H
#define DAV1D_COMMON_H
#include <stddef.h>
#include <stdint.h>
......@@ -43,6 +43,14 @@
#endif
#endif
/**
* 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
......@@ -56,6 +64,7 @@ typedef struct Dav1dDataProps {
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__
#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>
......@@ -37,7 +37,7 @@ typedef struct Dav1dData {
const uint8_t *data; ///< data pointer
size_t sz; ///< data size
struct Dav1dRef *ref; ///< allocation origin
Dav1dDataProps m;
Dav1dDataProps m; ///< user provided metadata passed to the output picture
} Dav1dData;
/**
......@@ -58,21 +58,52 @@ DAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);
* @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 $user_data
* will be the $user_data input argument to this function.
* @param user_data Opaque parameter passed to free_callback().
* 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 *user_data),
void *user_data);
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_wrap_user_data(Dav1dData *data,
const uint8_t *user_data,
void (*free_callback)(const uint8_t *user_data,
void *cookie),
void *cookie);
/**
* 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 *data);
#endif /* __DAV1D_DATA_H__ */
#endif /* DAV1D_DATA_H */
......@@ -25,18 +25,20 @@
* 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;
......@@ -44,13 +46,26 @@ 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;
Dav1dPicAllocator allocator;
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;
/**
......@@ -58,6 +73,16 @@ typedef struct Dav1dSettings {
*/
DAV1D_API const char *dav1d_version(void);
/**
* Get library version based on version control system.
*/
DAV1D_API const char *dav1d_version_vcs(void);
/**
* Get library version as unsigned int.
*/
DAV1D_API unsigned int dav1d_version_int(void);
/**
* Initialize settings to default values.
*
......@@ -187,4 +212,4 @@ DAV1D_API void dav1d_flush(Dav1dContext *c);
}
# endif
#endif /* __DAV1D_H__ */
#endif /* DAV1D_H */
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_HEADERS_H__
#define __DAV1D_HEADERS_H__
#ifndef DAV1D_HEADERS_H
#define DAV1D_HEADERS_H
// Constants from Section 3. "Symbols and abbreviated terms"
#define DAV1D_MAX_CDEF_STRENGTHS 8
......@@ -160,6 +160,22 @@ enum Dav1dChromaSamplePosition {
DAV1D_CHR_COLOCATED = 2, ///< Co-located with luma(0, 0) sample
};
typedef struct Dav1dContentLightLevel {
int max_content_light_level;
int max_frame_average_light_level;
} Dav1dContentLightLevel;
typedef struct Dav1dMasteringDisplay {
///< 0.16 fixed point
uint16_t primaries[3][2];
///< 0.16 fixed point
uint16_t white_point[2];
///< 24.8 fixed point
uint32_t max_luminance;
///< 18.14 fixed point
uint32_t min_luminance;
} Dav1dMasteringDisplay;
typedef struct Dav1dSequenceHeader {
/**
* Stream profile, 0 for 8-10 bits/component 4:2:0 or monochrome;
......@@ -178,6 +194,14 @@ typedef struct Dav1dSequenceHeader {
enum Dav1dTransferCharacteristics trc; ///< transfer characteristics (av1)
enum Dav1dMatrixCoefficients mtrx; ///< matrix coefficients (av1)
enum Dav1dChromaSamplePosition chr; ///< chroma sample position (av1)
/**
* 0, 1 and 2 mean 8, 10 or 12 bits/component, respectively. This is not
* exactly the same as 'hbd' from the spec; the spec's hbd distinguishes
* between 8 (0) and 10-12 (1) bits/component, and another element
* (twelve_bit) to distinguish between 10 and 12 bits/component. To get
* the spec's hbd, use !!our_hbd, and to get twelve_bit, use hbd == 2.
*/
int hbd;
/**
* Pixel data uses JPEG pixel range ([0,255] for 8bits) instead of
* MPEG pixel range ([16,235] for 8bits luma, [16,240] for 8bits chroma).
......@@ -191,9 +215,6 @@ typedef struct Dav1dSequenceHeader {
int idc;
int tier;
int decoder_model_param_present;
int decoder_buffer_delay;
int encoder_buffer_delay;
int low_delay_mode;
int display_model_param_present;
} operating_points[DAV1D_MAX_OPERATING_POINTS];
......@@ -230,18 +251,22 @@ typedef struct Dav1dSequenceHeader {
int super_res;
int cdef;
int restoration;
/**
* 0, 1 and 2 mean 8, 10 or 12 bits/component, respectively. This is not
* exactly the same as 'hbd' from the spec; the spec's hbd distinguishes
* between 8 (0) and 10-12 (1) bits/component, and another element
* (twelve_bit) to distinguish between 10 and 12 bits/component. To get
* the spec's hbd, use !!our_hbd, and to get twelve_bit, use hbd == 2.
*/
int hbd;
int ss_hor, ss_ver, monochrome;
int color_description_present;
int separate_uv_delta_q;
int film_grain_present;
// Dav1dSequenceHeaders of the same sequence are required to be
// bit-identical until this offset. See 7.5 "Ordering of OBUs":
// Within a particular coded video sequence, the contents of
// sequence_header_obu must be bit-identical each time the
// sequence header appears except for the contents of
// operating_parameters_info.
struct Dav1dSequenceHeaderOperatingParameterInfo {
int decoder_buffer_delay;
int encoder_buffer_delay;
int low_delay_mode;
} operating_parameter_info[DAV1D_MAX_OPERATING_POINTS];
} Dav1dSequenceHeader;
typedef struct Dav1dSegmentationData {
......@@ -382,4 +407,4 @@ typedef struct Dav1dFrameHeader {
Dav1dWarpedMotionParams gmv[DAV1D_REFS_PER_FRAME];
} Dav1dFrameHeader;
#endif /* __DAV1D_HEADERS_H__ */
#endif /* DAV1D_HEADERS_H */
# Copyright © 2019, 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.
# installed version.h header generation
version_h_data = configuration_data()
version_h_data.set('DAV1D_VERSION_MAJOR', dav1d_version_major)
version_h_data.set('DAV1D_VERSION_MINOR', dav1d_version_minor)
version_h_data.set('DAV1D_VERSION_PATCH', dav1d_version_revision)
version_h_target = configure_file(input: 'version.h.in',
output: 'version.h',
configuration: version_h_data)
# install headers
install_headers('common.h',
'data.h',
'dav1d.h',
'headers.h',
'picture.h',
version_h_target,
subdir : 'dav1d')
......@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DAV1D_PICTURE_H__
#define __DAV1D_PICTURE_H__
#ifndef DAV1D_PICTURE_H
#define DAV1D_PICTURE_H
#include <stddef.h>
#include <stdint.h>
......@@ -34,6 +34,11 @@
#include "common.h"
#include "headers.h"
/* Number of bytes to align AND pad picture memory buffers by, so that SIMD
* implementations can over-read by a few bytes, and use aligned read/write
* instructions. */
#define DAV1D_PICTURE_ALIGNMENT 32
typedef struct Dav1dPictureParameters {
int w; ///< width (in pixels)
int h; ///< height (in pixels)
......@@ -61,7 +66,21 @@ typedef struct Dav1dPicture {
Dav1dPictureParameters p;
Dav1dDataProps m;
struct Dav1dRef *frame_hdr_ref, *seq_hdr_ref, *ref; ///< allocation origins
/**
* High Dynamic Range Content Light Level metadata applying to this picture,
* as defined in section 5.8.3 and 6.7.3
*/
Dav1dContentLightLevel *content_light;
/**
* High Dynamic Range Mastering Display Color Volume metadata applying to
* this picture, as defined in section 5.8.4 and 6.7.4
*/
Dav1dMasteringDisplay *mastering_display;
struct Dav1dRef *frame_hdr_ref, *seq_hdr_ref; ///< Frame parameter allocation origins
struct Dav1dRef *content_light_ref, *mastering_display_ref; ///< Metadata allocation origins
struct Dav1dRef *ref; ///< Frame data allocation origin
void *allocator_data; ///< pointer managed by the allocator
} Dav1dPicture;
......@@ -71,10 +90,15 @@ typedef struct Dav1dPicAllocator {
/**
* Allocate the picture buffer based on the Dav1dPictureParameters.
*
* The data[0], data[1] and data[2] must be 32 byte aligned and with a
* pixel width/height multiple of 128 pixels.
* The data[0], data[1] and data[2] must be DAV1D_PICTURE_ALIGNMENT byte
* aligned and with a pixel width/height multiple of 128 pixels. Any
* allocated memory area should also be padded by DAV1D_PICTURE_ALIGNMENT
* bytes.
* data[1] and data[2] must share the same stride[1].
*
* This function will be called on the main thread (the thread which calls
* dav1d_get_picture()).
*
* @param pic The picture to allocate the buffer for. The callback needs to
* fill the picture data[0], data[1], data[2], stride[0] and
* stride[1].
......@@ -83,12 +107,19 @@ typedef struct Dav1dPicAllocator {
* release_picture_callback().
* @param cookie Custom pointer passed to all calls.
*
* @note No fields other than data, stride and allocator_data must be filled
* by this callback.
* @return 0 on success. A negative errno value on error.
*/
int (*alloc_picture_callback)(Dav1dPicture *pic, void *cookie);
/**
* Release the picture buffer.
*
* If frame threading is used, this function may be called by the main
* thread (the thread which calls dav1d_get_picture()) or any of the frame
* threads and thus must be thread-safe. If frame threading is not used,
* this function will only be called on the main thread.
*
* @param pic The picture that was filled by alloc_picture_callback().
* @param cookie Custom pointer passed to all calls.
*/
......@@ -100,4 +131,4 @@ typedef struct Dav1dPicAllocator {
*/
DAV1D_API void dav1d_picture_unref(Dav1dPicture *p);
#endif /* __DAV1D_PICTURE_H__ */
#endif /* DAV1D_PICTURE_H */