...
 
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`
......@@ -74,11 +83,15 @@ The [VideoLAN Code of Conduct](https://wiki.videolan.org/CoC) applies to this pr
# 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
......@@ -92,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?
......@@ -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 */
......@@ -23,10 +23,10 @@
* (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_
#ifndef MSCVER_STDATOMIC_H_
#define MSCVER_STDATOMIC_H_
#if !defined(__cplusplus) && defined(_MSC_VER)
#pragma warning(push)
......@@ -37,34 +37,34 @@
# 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_ */
#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,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].
......@@ -82,13 +106,20 @@ typedef struct Dav1dPicAllocator {
* a custom pointer that will be passed to
* release_picture_callback().
* @param cookie Custom pointer passed to all calls.
*
* @return 0 on success. A negative errno value on error.
*
* @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 */
/*
* 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.
*/
#ifndef DAV1D_VERSION_H
#define DAV1D_VERSION_H
#define DAV1D_VERSION_MAJOR @DAV1D_VERSION_MAJOR@
#define DAV1D_VERSION_MINOR @DAV1D_VERSION_MINOR@
#define DAV1D_VERSION_PATCH @DAV1D_VERSION_PATCH@
#define DAV1D_VERSION "@DAV1D_VERSION_MAJOR@.@DAV1D_VERSION_MINOR@.@DAV1D_VERSION_PATCH@"
#define DAV1D_VERSION_INT (@DAV1D_VERSION_MAJOR@ << 16 | @DAV1D_VERSION_MINOR@ << 8 | @DAV1D_VERSION_PATCH@)
#endif /* DAV1D_VERSION_H */
......@@ -22,16 +22,15 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Revision file (version.h) generation
# Revision file (vcs_version.h) generation
dav1d_git_dir = join_paths(dav1d_src_root, '.git')
rev_target = vcs_tag(command: [
'git', '--git-dir', dav1d_git_dir,
'describe', '--tags', '--long',
'--match', '?.*.*', '--always'
],
input: 'version.h.in',
output: 'version.h'
input: 'vcs_version.h.in',
output: 'vcs_version.h'
)
# Install include/dav1d headers
install_subdir('dav1d', install_dir: 'include')
subdir('dav1d')
/* auto-generated, do not edit */
#define DAV1D_VERSION "@VCS_TAG@"
#define DAV1D_VERSION_VCS "@VCS_TAG@"
# 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
......@@ -23,14 +23,15 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
project('dav1d', ['c'],
version: '0.1.0',
version: '0.2.0',
default_options: ['c_std=c99',
'warning_level=2',
'buildtype=release',
'b_ndebug=if-release'],
meson_version: '>= 0.47.0')
dav1d_version_array = meson.project_version().split('.')
dav1d_soname_version = '1.0.0'
dav1d_version_array = dav1d_soname_version.split('.')
dav1d_version_major = dav1d_version_array[0]
dav1d_version_minor = dav1d_version_array[1]
dav1d_version_revision = dav1d_version_array[2]
......@@ -45,7 +46,7 @@ cdata = configuration_data()
cdata_asm = configuration_data()
# Include directories
dav1d_inc_dirs = include_directories(['.', 'include', 'include/dav1d'])
dav1d_inc_dirs = include_directories(['.', 'include/dav1d', 'include'])
......@@ -70,6 +71,8 @@ if is_asm_enabled and get_option('b_sanitize') == 'memory'
error('asm causes false positive with memory sanitizer. Use \'-Dbuild_asm=false\'.')
endif
# Logging option
cdata.set10('CONFIG_LOG', get_option('logging'))
#
# OS/Compiler checks and defines
......@@ -87,6 +90,12 @@ if host_machine.system() == 'windows'
cdata.set('UNICODE', 1) # Define to 1 for Unicode (Wide Chars) APIs
cdata.set('_UNICODE', 1) # Define to 1 for Unicode (Wide Chars) APIs
cdata.set('__USE_MINGW_ANSI_STDIO', 1) # Define to force use of MinGW printf
if cc.has_function('fseeko', prefix : '#include <stdio.h>', args : test_args)
cdata.set('_FILE_OFFSET_BITS', 64) # Not set by default by Meson on Windows
else
cdata.set('fseeko', '_fseeki64')
cdata.set('ftello', '_ftelli64')
endif
endif
# On Windows, we use a compatibility layer to emulate pthread
......@@ -122,6 +131,10 @@ if cc.check_header('unistd.h')
cdata.set('HAVE_UNISTD_H', 1)
endif
if cc.check_header('io.h')
cdata.set('HAVE_IO_H', 1)
endif
# Function checks
......@@ -147,6 +160,9 @@ if (host_machine.cpu_family() == 'aarch64' or
if cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
cdata.set('HAVE_GETAUXVAL', 1)
endif
if cc.has_function('elf_aux_info', prefix : '#include <sys/auxv.h>', args : test_args)
cdata.set('HAVE_ELF_AUX_INFO', 1)
endif
endif
# Compiler flag tests
......@@ -164,9 +180,17 @@ optional_arguments = [
'-Wundef',
'-Werror=vla',
'-Wno-maybe-uninitialized',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Werror=missing-prototypes',
'-Wshorten-64-to-32',
]
if cc.get_id() == 'msvc'
optional_arguments += [
'-wd4028', # parameter different from declaration
'-wd4996' # use of POSIX functions
]
endif
if (get_option('buildtype') != 'debug' and get_option('buildtype') != 'plain')
optional_arguments += '-fomit-frame-pointer'
......@@ -191,30 +215,37 @@ stackalign_flag = []
stackrealign_flag = []
if host_machine.cpu_family().startswith('x86')
if cc.has_argument('-mpreferred-stack-boundary=5')
stackalign_flag = ['-mpreferred-stack-boundary=5']
stackrealign_flag = ['-mincoming-stack-boundary=4']
cdata_asm.set('STACK_ALIGNMENT', 32)
cdata.set('STACK_ALIGNMENT', 32)
elif cc.has_argument('-mpreferred-stack-boundary=4')
stackalign_flag = ['-mpreferred-stack-boundary=4']
stackrealign_flag = ['-mincoming-stack-boundary=4']
cdata_asm.set('STACK_ALIGNMENT', 16)
cdata.set('STACK_ALIGNMENT', 16)
elif cc.has_argument('-mstack-alignment=32')
stackalign_flag = ['-mstack-alignment=32']
stackrealign_flag = ['-mstackrealign']
cdata_asm.set('STACK_ALIGNMENT', 32)
cdata.set('STACK_ALIGNMENT', 32)
if get_option('stack_alignment') > 0
stack_alignment = get_option('stack_alignment')
elif host_machine.cpu_family() == 'x86_64'
if cc.has_argument('-mpreferred-stack-boundary=5')
stackalign_flag = ['-mpreferred-stack-boundary=5']
stackrealign_flag = ['-mincoming-stack-boundary=4']
stack_alignment = 32
elif cc.has_argument('-mstack-alignment=32')
stackalign_flag = ['-mstack-alignment=32']
stackrealign_flag = ['-mstackrealign']
stack_alignment = 32
else
stack_alignment = 16
endif
else
if host_machine.cpu_family() == 'x86_64'
cdata_asm.set('STACK_ALIGNMENT', 16)
cdata.set('STACK_ALIGNMENT', 16)
if host_machine.system() == 'linux' or host_machine.system() == 'darwin'
stack_alignment = 16
elif cc.has_argument('-mpreferred-stack-boundary=4')
stackalign_flag = ['-mpreferred-stack-boundary=4']
stackrealign_flag = ['-mincoming-stack-boundary=2']
stack_alignment = 16
elif cc.has_argument('-mstack-alignment=16')
stackalign_flag = ['-mstack-alignment=16']
stackrealign_flag = ['-mstackrealign']
stack_alignment = 16
else
cdata_asm.set('STACK_ALIGNMENT', 4)
cdata.set('STACK_ALIGNMENT', 4)
stack_alignment = 4
endif
endif
cdata_asm.set('STACK_ALIGNMENT', stack_alignment)
cdata.set('STACK_ALIGNMENT', stack_alignment)
endif
cdata.set10('ARCH_AARCH64', host_machine.cpu_family() == 'aarch64')
......@@ -230,6 +261,23 @@ if (is_asm_enabled and
'''
have_as_func = cc.compiles(as_func_code)
cdata.set10('HAVE_AS_FUNC', have_as_func)
# fedora package build infrastructure uses a gcc specs file to enable
# '-fPIE' by default. The chosen way only adds '-fPIE' to the C compiler
# with integrated preprocessor. It is not added to the standalone
# preprocessor or the preprocessing stage of '.S' files. So we have to
# compile code to check if we have to define PIC for the arm asm to
# avoid absolute relocations when building for example checkasm.
check_pic_code = '''
#if defined(PIC)
#error "PIC already defined"
#elif !(defined(__PIC__) || defined(__pic__))
#error "no pic"
#endif
'''
if cc.compiles(check_pic_code)
cdata.set('PIC', '3')
endif
endif
if host_machine.cpu_family().startswith('x86')
......@@ -239,13 +287,12 @@ if host_machine.cpu_family().startswith('x86')
cdata.set10('ARCH_X86_64', true)
cdata_asm.set10('ARCH_X86_32', false)
cdata.set10('ARCH_X86_32', false)
cdata_asm.set10('PIC', true)
else
cdata_asm.set10('ARCH_X86_64', false)
cdata.set10('ARCH_X86_64', false)
cdata_asm.set10('ARCH_X86_32', true)
cdata.set10('ARCH_X86_32', true)
cdata_asm.set10('PIC', true)
endif
else
cdata.set10('ARCH_X86', false)
......@@ -281,8 +328,8 @@ if is_asm_enabled and host_machine.cpu_family().startswith('x86')
nasm_r = run_command(nasm, '-v')
out = nasm_r.stdout().strip().split()
if out[1].to_lower() == 'version'
if out[2].version_compare('<2.13')
error('nasm 2.13 or later is required, found nasm @0@'.format(out[2]))
if out[2].version_compare('<2.13.02')
error('nasm 2.13.02 or later is required, found nasm @0@'.format(out[2]))
endif
else
error('unexpected nasm version string: @0@'.format(nasm_r.stdout()))
......
......@@ -20,6 +20,11 @@ option('build_tests',
value: true,
description: 'Build dav1d tests')
option('logging',
type: 'boolean',
value: true,
description: 'Print error log messages using the provided callback function')
option('testdata_tests',
type: 'boolean',
value: false,
......@@ -30,3 +35,7 @@ option('fuzzing_engine',
choices : ['none', 'libfuzzer', 'oss-fuzz'],
value: 'none',
description: 'Select the fuzzing engine')
option('stack_alignment',
type: 'integer',
value: 0)
name: dav1d
base: core18
version: git
version-script: git describe HEAD --always
summary: AV1 decoder from VideoLAN
description: |
A small and fast AV1 decoder from the people who brought you VLC.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots
apps:
dav1d:
command: usr/bin/dav1d
plugs: [ 'home' ]
parts:
dav1d:
plugin: meson
source: .
build-packages: [ 'nasm' ]
meson-parameters:
- --prefix=/usr
- --buildtype=release
/*
* Copyright © 2018, VideoLAN and dav1d authors
* Copyright © 2019, Martin Storsjo
* 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.
*/
#include "src/arm/asm.S"
// void dav1d_wiener_filter_h_neon(int16_t *dst, const pixel (*left)[4],
// const pixel *src, ptrdiff_t stride,
// const int16_t fh[7], const intptr_t w,
// int h, enum LrEdgeFlags edges);
function wiener_filter_h_neon, export=1
push {r4-r11,lr}
vpush {q4}
ldrd r4, r5, [sp, #52]
ldrd r6, r7, [sp, #60]
mov r8, r5
vld1.16 {q0}, [r4]
movw r9, #(1 << 14) - (1 << 2)
vdup.16 q14, r9
vmov.s16 q15, #2048
// Calculate mid_stride
add r10, r5, #7
bic r10, r10, #7
lsl r10, r10, #1
// Clear the last unused element of q0, to allow filtering a single
// pixel with one plain vmul+vpadd.
mov r12, #0
vmov.16 d1[3], r12
// Set up pointers for reading/writing alternate rows
add r12, r0, r10
lsl r10, r10, #1
add lr, r2, r3
lsl r3, r3, #1