...
 
Commits (20)
......@@ -10,9 +10,9 @@ style-check:
- 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
- for i in $(git ls-files -- . ':(exclude)*/compat/*'); do
- git grep -I -n -P "\t|\r| $" -- . ':(exclude)*/compat/*' && exit 1
- git grep -I -n -i "david" -- . ':(exclude)THANKS.md' ':(exclude).gitlab-ci.yml' && exit 1
- git grep -I -l -z "" -- . ':(exclude)*/compat/*' | while IFS= read -r -d '' i; do
if [ -n "$(tail -c 1 "$i")" ]; then
echo "No newline at end of $i";
exit 1;
......@@ -55,6 +55,7 @@ build-debian-static:
- meson build --buildtype release --default-library static --werror
- ninja -C build
- cd build && meson test -v
- nm -A -g src/libdav1d.a | grep " [ABCDGRST] " | (! grep -v " _*dav1d_")
build-debian32:
image: registry.videolan.org:5000/dav1d-debian-unstable:20181218135732
......@@ -86,6 +87,7 @@ build-win32:
- ninja -C build
- ninja -C build install
- cd build && meson test -v
- i686-w64-mingw32-nm -A -g src/libdav1d.a | grep " [ABCDGRST] " | (! grep -E -v " \.| _*dav1d_")
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
......@@ -124,6 +126,7 @@ build-win64:
- ninja -C build
- ninja -C build install
- cd build && meson test -v
- x86_64-w64-mingw32-nm -A -g src/libdav1d.a | grep " [ABCDGRST] " | (! grep -E -v " \.| _*dav1d_")
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
......@@ -144,6 +147,7 @@ build-win-arm32:
--cross-file /opt/crossfiles/armv7-w64-mingw32.meson
-Ddefault_library=both
- ninja -C build
- armv7-w64-mingw32-nm -A -g build/src/libdav1d.a | grep " [ABCDGRST] " | (! grep -E -v " \.| _*dav1d_")
build-win-arm64:
image: registry.videolan.org:5000/vlc-debian-llvm-mingw:20190218133533
......@@ -160,6 +164,7 @@ build-win-arm64:
-Ddefault_library=both
- ninja -C build
- ninja -C build install
- aarch64-w64-mingw32-nm -A -g build/src/libdav1d.a | grep " [ABCDGRST] " | (! grep -E -v " \.| _*dav1d_")
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
......
Changes for 0.3.1 'Sailfish':
------------------------------
- Fix a buffer overflow in frame-threading mode on SSSE3 CPUs
- Reduce binary size, notably on Windows
- SSSE3 optimizations for ipred_filter
- ARM optimizations for MSAC
Changes for 0.3.0 'Sailfish':
------------------------------
......
......@@ -34,10 +34,12 @@
#ifdef __GNUC__
#define ATTR_ALIAS __attribute__((may_alias))
#define ATTR_FORMAT_PRINTF(fmt, attr) __attribute__((__format__(__printf__, fmt, attr)));
#define ATTR_FORMAT_PRINTF(fmt, attr) __attribute__((__format__(__printf__, fmt, attr)))
#define COLD __attribute__((cold))
#else
#define ATTR_ALIAS
#define ATTR_FORMAT_PRINTF(fmt, attr)
#define COLD
#endif
#if ARCH_X86_64
......
......@@ -28,6 +28,7 @@
#ifndef DAV1D_COMMON_H
#define DAV1D_COMMON_H
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
......@@ -47,6 +48,12 @@
#endif
#endif
#if EPERM > 0
#define DAV1D_ERR(e) (-(e)) ///< Negate POSIX error code.
#else
#define DAV1D_ERR(e) (e)
#endif
/**
* A reference-counted object wrapper for a user-configurable pointer.
*/
......
......@@ -62,7 +62,7 @@ DAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);
* 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.
* @return 0 on success. A negative DAV1D_ERR 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),
......@@ -87,7 +87,7 @@ DAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,
* function.
* @param cookie Opaque parameter passed to $free_callback.
*
* @return 0 on success. A negative errno value on error.
* @return 0 on success. A negative DAV1D_ERR value on error.
*/
DAV1D_API int dav1d_data_wrap_user_data(Dav1dData *data,
const uint8_t *user_data,
......
......@@ -90,7 +90,7 @@ DAV1D_API void dav1d_default_settings(Dav1dSettings *s);
* @note The context must be freed using dav1d_close() when decoding is
* finished.
*
* @return 0 on success, or < 0 (a negative errno code) on error.
* @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.
*/
DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
......@@ -101,7 +101,7 @@ DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
* @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.
* @return 0 on success, or < 0 (a negative DAV1D_ERR 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
......@@ -119,11 +119,11 @@ DAV1D_API int dav1d_parse_sequence_header(Dav1dSequenceHeader *out,
*
* @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_ERR(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 DAV1D_ERR codes: Error during decoding or because of invalid
* passed-in arguments.
*/
DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);
......@@ -136,10 +136,10 @@ DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);
*
* @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.
* DAV1D_ERR(EAGAIN): Not enough data to output a frame. dav1d_send_data()
* should be called with new input.
* other negative DAV1D_ERR 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.
......
......@@ -109,7 +109,7 @@ typedef struct Dav1dPicAllocator {
*
* @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.
* @return 0 on success. A negative DAV1D_ERR value on error.
*/
int (*alloc_picture_callback)(Dav1dPicture *pic, void *cookie);
/**
......
......@@ -23,14 +23,14 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
project('dav1d', ['c'],
version: '0.3.0',
version: '0.3.1',
default_options: ['c_std=c99',
'warning_level=2',
'buildtype=release',
'b_ndebug=if-release'],
meson_version: '>= 0.47.0')
dav1d_soname_version = '1.0.1'
dav1d_soname_version = '1.1.0'
dav1d_api_version_array = dav1d_soname_version.split('.')
dav1d_api_version_major = dav1d_api_version_array[0]
dav1d_api_version_minor = dav1d_api_version_array[1]
......@@ -81,6 +81,8 @@ cdata.set10('CONFIG_LOG', get_option('logging'))
# Arguments in test_args will be used even on feature tests
test_args = []
optional_arguments = []
# Define _POSIX_C_SOURCE to POSIX.1–2001 (IEEE Std 1003.1-2001)
test_args += '-D_POSIX_C_SOURCE=200112L'
add_project_arguments('-D_POSIX_C_SOURCE=200112L', language: 'c')
......@@ -96,10 +98,12 @@ if host_machine.system() == 'windows'
cdata.set('fseeko', '_fseeki64')
cdata.set('ftello', '_ftelli64')
endif
endif
# On Windows, we use a compatibility layer to emulate pthread
if host_machine.system() == 'windows'
if (host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc')
optional_arguments += '-mcmodel=small'
endif
# On Windows, we use a compatibility layer to emulate pthread
thread_dependency = []
thread_compat_dep = declare_dependency(sources : files('src/win32/thread.c'))
else
......@@ -176,7 +180,7 @@ endif
# Compiler flags that should be set
# But when the compiler does not supports them
# it is not an error and silently tolerated
optional_arguments = [
optional_arguments += [
'-Wundef',
'-Werror=vla',
'-Wno-maybe-uninitialized',
......
......@@ -27,7 +27,7 @@
*/
#include "src/arm/asm.S"
#include "src/arm/32/util.S"
#include "util.S"
.macro avg dst0, dst1, t0, t1, t2, t3
vld1.16 {\t0,\t1}, [r2, :128]!
......
......@@ -27,7 +27,7 @@
*/
#include "src/arm/asm.S"
#include "src/arm/64/util.S"
#include "util.S"
.macro avg dst, t0, t1
ld1 {\t0\().8h}, [x2], 16
......@@ -703,7 +703,7 @@ endfunc
function \op\()_8tap_\type\()_8bpc_neon, export=1
mov x8, \type_h
mov x9, \type_v
b \op\()_8tap\()_neon
b \op\()_8tap_neon
endfunc
.endm
......
/*
* Copyright © 2019, 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"
#include "util.S"
#define BUF_POS 0
#define BUF_END 8
#define DIF 16
#define RNG 24
#define CNT 28
#define ALLOW_UPDATE_CDF 32
const coeffs
.short 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0
.short 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
endconst
const bits
.short 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80
.short 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000
endconst
.macro ld1_n d0, d1, src, sz, n
.if \n <= 8
ld1 {\d0\sz}, [\src]
.else
ld1 {\d0\sz, \d1\sz}, [\src]
.endif
.endm
.macro st1_n s0, s1, dst, sz, n
.if \n <= 8
st1 {\s0\sz}, [\dst]
.else
st1 {\s0\sz, \s1\sz}, [\dst]
.endif
.endm
.macro ushr_n d0, d1, s0, s1, shift, sz, n
ushr \d0\sz, \s0\sz, \shift
.if \n == 16
ushr \d1\sz, \s1\sz, \shift
.endif
.endm
.macro add_n d0, d1, s0, s1, s2, s3, sz, n
add \d0\sz, \s0\sz, \s2\sz
.if \n == 16
add \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro sub_n d0, d1, s0, s1, s2, s3, sz, n
sub \d0\sz, \s0\sz, \s2\sz
.if \n == 16
sub \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro and_n d0, d1, s0, s1, s2, s3, sz, n
and \d0\sz, \s0\sz, \s2\sz
.if \n == 16
and \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro cmhs_n d0, d1, s0, s1, s2, s3, sz, n
cmhs \d0\sz, \s0\sz, \s2\sz
.if \n == 16
cmhs \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro urhadd_n d0, d1, s0, s1, s2, s3, sz, n
urhadd \d0\sz, \s0\sz, \s2\sz
.if \n == 16
urhadd \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro sshl_n d0, d1, s0, s1, s2, s3, sz, n
sshl \d0\sz, \s0\sz, \s2\sz
.if \n == 16
sshl \d1\sz, \s1\sz, \s3\sz
.endif
.endm
.macro umull_n d0, d1, d2, d3, s0, s1, s2, s3, n
umull \d0\().4s, \s0\().4h, \s2\().4h
.if \n >= 8
umull2 \d1\().4s, \s0\().8h, \s2\().8h
.endif
.if \n == 16
umull \d2\().4s, \s1\().4h, \s3\().4h
umull2 \d3\().4s, \s1\().8h, \s3\().8h
.endif
.endm
.macro shrn_n d0, d1, s0, s1, s2, s3, shift, n
shrn \d0\().4h, \s0\().4s, \shift
.if \n >= 8
shrn2 \d0\().8h, \s1\().4s, \shift
.endif
.if \n == 16
shrn \d1\().4h, \s2\().4s, \shift
shrn2 \d1\().8h, \s3\().4s, \shift
.endif
.endm
.macro str_n idx0, idx1, dstreg, dstoff, n
str q\idx0, [\dstreg, \dstoff]
.if \n == 16
str q\idx1, [\dstreg, \dstoff + 16]
.endif
.endm
// unsigned dav1d_msac_decode_symbol_adapt4_neon(MsacContext *s, uint16_t *cdf,
// size_t n_symbols);
function msac_decode_symbol_adapt4_neon, export=1
.macro decode_update sz, szb, n
sub sp, sp, #48
add x8, x0, #RNG
ld1_n v0, v1, x1, \sz, \n // cdf
ld1r {v4\sz}, [x8] // rng
movrel x9, coeffs, 32
sub x9, x9, x2, lsl #1
ushr_n v2, v3, v0, v1, #6, \sz, \n // cdf >> EC_PROB_SHIFT
str h4, [sp, #14] // store original u = s->rng
ushr v4\sz, v4\sz, #8 // r = rng >> 8
umull_n v16, v17, v18, v19, v4, v4, v2, v3, \n // r * (cdf >> EC_PROB_SHIFT)
ld1_n v4, v5, x9, \sz, \n // EC_MIN_PROB * (n_symbols - ret)
shrn_n v2, v3, v16, v17, v18, v19, #1, \n // v >>= 7 - EC_PROB_SHIFT
add x8, x0, #DIF + 6
add_n v4, v5, v2, v3, v4, v5, \sz, \n // v += EC_MIN_PROB * (n_symbols - ret)
ld1r {v6.8h}, [x8] // dif >> (EC_WIN_SIZE - 16)
movrel x8, bits
str_n 4, 5, sp, #16, \n // store v values to allow indexed access
ld1_n v16, v17, x8, .8h, \n
cmhs_n v2, v3, v6, v6, v4, v5, .8h, \n // c >= v
and_n v6, v7, v2, v3, v16, v17, .16b, \n // One bit per halfword set in the mask
.if \n == 16
add v6.8h, v6.8h, v7.8h
.endif
addv h6, v6.8h // Aggregate mask bits
ldr w4, [x0, #ALLOW_UPDATE_CDF]
umov w3, v6.h[0]
rbit w3, w3
clz w15, w3 // ret
cbz w4, L(renorm)
// update_cdf
ldrh w3, [x1, x2, lsl #1] // count = cdf[n_symbols]
movi v5\szb, #0xff
cmp x2, #4 // set C if n_symbols >= 4 (n_symbols > 3)
mov w14, #4
lsr w4, w3, #4 // count >> 4
urhadd_n v4, v5, v5, v5, v2, v3, \sz, \n // i >= val ? -1 : 32768
adc w4, w4, w14 // (count >> 4) + (n_symbols > 3) + 4
neg w4, w4 // -rate
sub_n v4, v5, v4, v5, v0, v1, \sz, \n // (32768 - cdf[i]) or (-1 - cdf[i])
dup v6.8h, w4 // -rate
sub w3, w3, w3, lsr #5 // count + (count >= 32)
sub_n v0, v1, v0, v1, v2, v3, \sz, \n // cdf + (i >= val ? 1 : 0)
sshl_n v4, v5, v4, v5, v6, v6, \sz, \n // ({32768,-1} - cdf[i]) >> rate
add w3, w3, #1 // count + (count < 32)
add_n v0, v1, v0, v1, v4, v5, \sz, \n // cdf + (32768 - cdf[i]) >> rate
st1_n v0, v1, x1, \sz, \n
strh w3, [x1, x2, lsl #1]
.endm
decode_update .4h, .8b, 4
L(renorm):
add x8, sp, #16
add x8, x8, w15, uxtw #1
ldrh w3, [x8] // v
ldurh w4, [x8, #-2] // u
ldr w6, [x0, #CNT]
ldr x7, [x0, #DIF]
sub w4, w4, w3 // rng = u - v
clz w5, w4 // clz(rng)
eor w5, w5, #16 // d = clz(rng) ^ 16
mvn x7, x7 // ~dif
add x7, x7, x3, lsl #48 // ~dif + (v << 48)
lsl w4, w4, w5 // rng << d
subs w6, w6, w5 // cnt -= d
lsl x7, x7, x5 // (~dif + (v << 48)) << d
str w4, [x0, #RNG]
mvn x7, x7 // ~dif
b.ge 9f
// refill
ldr x3, [x0, #BUF_POS]
ldr x4, [x0, #BUF_END]
add x5, x3, #8
cmp x5, x4
b.gt 2f
ldr x3, [x3] // next_bits
add w8, w6, #23 // shift_bits = cnt + 23
add w6, w6, #16 // cnt += 16
rev x3, x3 // next_bits = bswap(next_bits)
sub x5, x5, x8, lsr #3 // buf_pos -= shift_bits >> 3
and w8, w8, #24 // shift_bits &= 24
lsr x3, x3, x8 // next_bits >>= shift_bits
sub w8, w8, w6 // shift_bits -= 16 + cnt
str x5, [x0, #BUF_POS]
lsl x3, x3, x8 // next_bits <<= shift_bits
mov w4, #48
sub w6, w4, w8 // cnt = cnt + 64 - shift_bits
eor x7, x7, x3 // dif ^= next_bits
b 9f
2: // refill_eob
mov w14, #40
sub w5, w14, w6 // c = 40 - cnt
3:
cmp x3, x4
b.ge 4f
ldrb w8, [x3], #1
lsl x8, x8, x5
eor x7, x7, x8
subs w5, w5, #8
b.ge 3b
4: // refill_eob_end
str x3, [x0, #BUF_POS]
sub w6, w14, w5 // cnt = 40 - c
9:
str w6, [x0, #CNT]
str x7, [x0, #DIF]
mov w0, w15
add sp, sp, #48
ret
endfunc
function msac_decode_symbol_adapt8_neon, export=1
decode_update .8h, .16b, 8
b L(renorm)
endfunc
function msac_decode_symbol_adapt16_neon, export=1
decode_update .8h, .16b, 16
b L(renorm)
endfunc
......@@ -24,7 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "common/attributes.h"
#include "src/cpu.h"
#include "src/cdef.h"
......@@ -72,7 +71,7 @@ DEFINE_FILTER(4, 4, 8)
#endif
void bitfn(dav1d_cdef_dsp_init_arm)(Dav1dCdefDSPContext *const c) {
COLD void bitfn(dav1d_cdef_dsp_init_arm)(Dav1dCdefDSPContext *const c) {
const unsigned flags = dav1d_get_cpu_flags();
if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
......
......@@ -27,6 +27,8 @@
#include "config.h"
#include "common/attributes.h"
#include "src/arm/cpu.h"
#if defined(HAVE_GETAUXVAL) && ARCH_ARM
......@@ -73,7 +75,7 @@ static unsigned parse_proc_cpuinfo(const char *flag) {
}
#endif
unsigned dav1d_get_cpu_flags_arm(void) {
COLD unsigned dav1d_get_cpu_flags_arm(void) {
unsigned flags = 0;
#if ARCH_AARCH64
flags |= DAV1D_ARM_CPU_FLAG_NEON;
......
......@@ -33,7 +33,7 @@ decl_loopfilter_sb_fn(dav1d_lpf_v_sb_y_neon);
decl_loopfilter_sb_fn(dav1d_lpf_h_sb_uv_neon);
decl_loopfilter_sb_fn(dav1d_lpf_v_sb_uv_neon);
void bitfn(dav1d_loop_filter_dsp_init_arm)(Dav1dLoopFilterDSPContext *const c) {
COLD void bitfn(dav1d_loop_filter_dsp_init_arm)(Dav1dLoopFilterDSPContext *const c) {
const unsigned flags = dav1d_get_cpu_flags();
if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
......
......@@ -27,8 +27,6 @@
#include "src/cpu.h"
#include "src/looprestoration.h"
#include "common/attributes.h"
#include "src/tables.h"
#if BITDEPTH == 8
......@@ -258,7 +256,7 @@ static void sgr_filter_neon(pixel *const dst, const ptrdiff_t dst_stride,
#endif // ARCH_AARCH64
#endif // BITDEPTH == 8
void bitfn(dav1d_loop_restoration_dsp_init_arm)(Dav1dLoopRestorationDSPContext *const c) {
COLD void bitfn(dav1d_loop_restoration_dsp_init_arm)(Dav1dLoopRestorationDSPContext *const c) {
const unsigned flags = dav1d_get_cpu_flags();
if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
......
......@@ -254,7 +254,7 @@ static int cdef_find_dir_c(const pixel *img, const ptrdiff_t stride,
return best_dir;
}
void bitfn(dav1d_cdef_dsp_init)(Dav1dCdefDSPContext *const c) {
COLD void bitfn(dav1d_cdef_dsp_init)(Dav1dCdefDSPContext *const c) {
c->dir = cdef_find_dir_c;
c->fb[0] = cdef_filter_block_8x8_c;
c->fb[1] = cdef_filter_block_4x8_c;
......
......@@ -4181,7 +4181,7 @@ int dav1d_cdf_thread_alloc(CdfThreadContext *const cdf,
{
cdf->ref = dav1d_ref_create(sizeof(CdfContext) +
(t != NULL) * sizeof(atomic_uint));
if (!cdf->ref) return -ENOMEM;
if (!cdf->ref) return DAV1D_ERR(ENOMEM);
cdf->data.cdf = cdf->ref->data;
if (t) {
cdf->progress = (atomic_uint *) &cdf->data.cdf[1];
......
......@@ -32,7 +32,7 @@
static unsigned flags_mask = -1;
unsigned dav1d_get_cpu_flags(void) {
COLD unsigned dav1d_get_cpu_flags(void) {
static unsigned flags;
static uint8_t checked = 0;
......@@ -49,6 +49,6 @@ unsigned dav1d_get_cpu_flags(void) {
return flags & flags_mask;
}
void dav1d_set_cpu_flags_mask(const unsigned mask) {
COLD void dav1d_set_cpu_flags_mask(const unsigned mask) {
flags_mask = mask;
}
......@@ -30,6 +30,8 @@
#include "config.h"
#include "common/attributes.h"
#include "dav1d/common.h"
#if ARCH_AARCH64 || ARCH_ARM
......
......@@ -58,12 +58,12 @@ int dav1d_data_wrap_internal(Dav1dData *const buf, const uint8_t *const ptr,
void *cookie),
void *const cookie)
{
validate_input_or_ret(buf != NULL, -EINVAL);
validate_input_or_ret(ptr != NULL, -EINVAL);
validate_input_or_ret(free_callback != NULL, -EINVAL);
validate_input_or_ret(buf != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(ptr != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(free_callback != NULL, DAV1D_ERR(EINVAL));
buf->ref = dav1d_ref_wrap(ptr, free_callback, cookie);
if (!buf->ref) return -ENOMEM;
if (!buf->ref) return DAV1D_ERR(ENOMEM);
buf->data = ptr;
buf->sz = buf->m.size = sz;
dav1d_data_props_set_defaults(&buf->m);
......@@ -77,11 +77,11 @@ int dav1d_data_wrap_user_data_internal(Dav1dData *const buf,
void *cookie),
void *const cookie)
{
validate_input_or_ret(buf != NULL, -EINVAL);
validate_input_or_ret(free_callback != NULL, -EINVAL);
validate_input_or_ret(buf != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(free_callback != NULL, DAV1D_ERR(EINVAL));
buf->m.user_data.ref = dav1d_ref_wrap(user_data, free_callback, cookie);
if (!buf->m.user_data.ref) return -ENOMEM;
if (!buf->m.user_data.ref) return DAV1D_ERR(ENOMEM);
buf->m.user_data.data = user_data;
return 0;
......
......@@ -231,7 +231,7 @@ static void find_matching_ref(const Dav1dTileContext *const t,
have_top && t->bx + bw4 < t->ts->tiling.col_end &&
(intra_edge_flags & EDGE_I444_TOP_HAS_RIGHT);
#define bs(rp) dav1d_block_dimensions[sbtype_to_bs[(rp)->sb_type]]
#define bs(rp) dav1d_block_dimensions[dav1d_sbtype_to_bs[(rp)->sb_type]]
#define matches(rp) ((rp)->ref[0] == ref + 1 && (rp)->ref[1] == -1)
if (have_top) {
......@@ -1243,11 +1243,11 @@ static int decode_b(Dav1dTileContext *const t,
candidate_mv mvstack[8];
int n_mvs;
mv mvlist[2][2];
av1_find_ref_mvs(mvstack, &n_mvs, mvlist, NULL,
(int[2]) { -1, -1 }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
dav1d_find_ref_mvs(mvstack, &n_mvs, mvlist, NULL,
(int[2]) { -1, -1 }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
if (mvlist[0][0].y | mvlist[0][0].x)
b->mv[0] = mvlist[0][0];
......@@ -1388,11 +1388,11 @@ static int decode_b(Dav1dTileContext *const t,
candidate_mv mvstack[8];
int n_mvs, ctx;
mv mvlist[2][2];
av1_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], b->ref[1] }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
dav1d_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], b->ref[1] }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
b->mv[0] = mvstack[0].this_mv;
b->mv[1] = mvstack[0].comp_mv;
......@@ -1468,11 +1468,11 @@ static int decode_b(Dav1dTileContext *const t,
candidate_mv mvstack[8];
int n_mvs, ctx;
mv mvlist[2][2];
av1_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], b->ref[1] }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
dav1d_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], b->ref[1] }, f->bw, f->bh,
bs, bp, t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
b->inter_mode = dav1d_msac_decode_symbol_adapt8(&ts->msac,
ts->cdf.m.comp_inter_mode[ctx],
......@@ -1645,11 +1645,11 @@ static int decode_b(Dav1dTileContext *const t,
candidate_mv mvstack[8];
int n_mvs, ctx;
mv mvlist[2][2];
av1_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], -1 }, f->bw, f->bh, bs, bp,
t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
dav1d_find_ref_mvs(mvstack, &n_mvs, mvlist, &ctx,
(int[2]) { b->ref[0], -1 }, f->bw, f->bh, bs, bp,
t->by, t->bx, ts->tiling.col_start,
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
// mode parsing and mv derivation from ref_mvs
if ((seg && (seg->skip || seg->globalmv)) ||
......@@ -2463,9 +2463,9 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
{
return 1;
}
av1_init_ref_mv_tile_row(f->libaom_cm,
ts->tiling.col_start, ts->tiling.col_end,
t->by, imin(t->by + sb_step, f->bh));
dav1d_init_ref_mv_tile_row(f->libaom_cm,
ts->tiling.col_start, ts->tiling.col_end,
t->by, imin(t->by + sb_step, f->bh));
}
memset(t->pal_sz_uv[1], 0, sizeof(*t->pal_sz_uv));
const int sb128y = t->by >> 5;
......@@ -2566,7 +2566,7 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
int dav1d_decode_frame(Dav1dFrameContext *const f) {
const Dav1dContext *const c = f->c;
int retval = -ENOMEM;
int retval = DAV1D_ERR(ENOMEM);
if (f->n_tc > 1) {
if (f->frame_hdr->tiling.cols * f->sbh > f->tile_thread.titsati_sz) {
......@@ -2765,20 +2765,20 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
if ((f->frame_hdr->frame_type & 1) || f->frame_hdr->allow_intrabc) {
f->mvs = f->mvs_ref->data;
const int order_hint_n_bits = f->seq_hdr->order_hint * f->seq_hdr->order_hint_n_bits;
const int ret = av1_init_ref_mv_common(f->libaom_cm, f->bw >> 1, f->bh >> 1,
f->b4_stride, f->seq_hdr->sb128,
f->mvs, f->ref_mvs,
f->cur.frame_hdr->frame_offset,
f->refpoc,
f->refrefpoc, f->frame_hdr->gmv,
f->frame_hdr->hp, f->frame_hdr->force_integer_mv,
f->frame_hdr->use_ref_frame_mvs,
order_hint_n_bits);
const int ret = dav1d_init_ref_mv_common(f->libaom_cm, f->bw >> 1, f->bh >> 1,
f->b4_stride, f->seq_hdr->sb128,
f->mvs, f->ref_mvs,
f->cur.frame_hdr->frame_offset,
f->refpoc,
f->refrefpoc, f->frame_hdr->gmv,
f->frame_hdr->hp, f->frame_hdr->force_integer_mv,
f->frame_hdr->use_ref_frame_mvs,
order_hint_n_bits);
if (ret < 0) goto error;
if (c->n_fc == 1 && f->frame_hdr->use_ref_frame_mvs)
av1_init_ref_mv_tile_row(f->libaom_cm, 0, f->bw, 0, f->bh);
dav1d_init_ref_mv_tile_row(f->libaom_cm, 0, f->bw, 0, f->bh);
}
retval = -EINVAL;
retval = DAV1D_ERR(EINVAL);
// setup dequant tables
init_quant_tables(f->seq_hdr, f->frame_hdr, f->frame_hdr->quant.yac, f->dq);
......@@ -3115,7 +3115,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
default:
dav1d_log(c, "Compiled without support for %d-bit decoding\n",
8 + 2 * f->seq_hdr->hbd);
res = -ENOPROTOOPT;
res = DAV1D_ERR(ENOPROTOOPT);
goto error;
}
}
......@@ -3142,7 +3142,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
if (f->frame_hdr->primary_ref_frame != DAV1D_PRIMARY_REF_NONE) {
const int pri_ref = f->frame_hdr->refidx[f->frame_hdr->primary_ref_frame];
if (!c->refs[pri_ref].p.p.data[0]) {
res = -EINVAL;
res = DAV1D_ERR(EINVAL);
goto error;
}
}
......@@ -3158,7 +3158,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
{
for (int j = 0; j < i; j++)
dav1d_thread_picture_unref(&f->refp[j]);
res = -EINVAL;
res = DAV1D_ERR(EINVAL);
goto error;
}
dav1d_thread_picture_ref(&f->refp[i], &c->refs[refidx].p);
......@@ -3255,7 +3255,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->mvs_ref = dav1d_ref_create(f->sb128h * 32 * f->b4_stride *
sizeof(*f->mvs));
if (!f->mvs_ref) {
res = -ENOMEM;
res = DAV1D_ERR(ENOMEM);
goto error;
}
f->mvs = f->mvs_ref->data;
......@@ -3318,7 +3318,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
// actually gets set elsewhere)
f->cur_segmap_ref = dav1d_ref_create(f->b4_stride * 32 * f->sb128h);
if (!f->cur_segmap_ref) {
res = -ENOMEM;
res = DAV1D_ERR(ENOMEM);
goto error;
}
f->cur_segmap = f->cur_segmap_ref->data;
......@@ -3332,7 +3332,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
// We need to make a new map. Allocate one here and zero it out.
f->cur_segmap_ref = dav1d_ref_create(f->b4_stride * 32 * f->sb128h);
if (!f->cur_segmap_ref) {
res = -ENOMEM;
res = DAV1D_ERR(ENOMEM);
goto error;
}
f->cur_segmap = f->cur_segmap_ref->data;
......
......@@ -725,7 +725,7 @@ static void pal_pred_c(pixel *dst, const ptrdiff_t stride,
}
}
void bitfn(dav1d_intra_pred_dsp_init)(Dav1dIntraPredDSPContext *const c) {
COLD void bitfn(dav1d_intra_pred_dsp_init)(Dav1dIntraPredDSPContext *const c) {
c->intra_pred[DC_PRED ] = ipred_dc_c;
c->intra_pred[DC_128_PRED ] = ipred_dc_128_c;
c->intra_pred[TOP_DC_PRED ] = ipred_dc_top_c;
......
......@@ -50,7 +50,7 @@ inv_txfm_add_c(pixel *dst, const ptrdiff_t stride,
const int has_dconly HIGHBD_DECL_SUFFIX)
{
int i, j;
assert((h >= 4 || h <= 64) && (w >= 4 || w <= 64));
assert((h >= 4 && h <= 64) && (w >= 4 && w <= 64));
const int is_rect2 = w * 2 == h || h * 2 == w;
const int bitdepth = bitdepth_from_max(bitdepth_max);
const int rnd = (1 << shift) >> 1;
......@@ -193,7 +193,7 @@ static void inv_txfm_add_wht_wht_4x4_c(pixel *dst, const ptrdiff_t stride,
memset(coeff, 0, sizeof(*coeff) * 4 * 4);
}
void bitfn(dav1d_itx_dsp_init)(Dav1dInvTxfmDSPContext *const c) {
COLD void bitfn(dav1d_itx_dsp_init)(Dav1dInvTxfmDSPContext *const c) {
#define assign_itx_all_fn64(w, h, pfx) \
c->itxfm_add[pfx##TX_##w##X##h][DCT_DCT ] = \
inv_txfm_add_dct_dct_##w##x##h##_c
......
......@@ -46,23 +46,23 @@
#include "src/wedge.h"
#include "src/film_grain.h"
static void init_internal(void) {
static COLD void init_internal(void) {
dav1d_init_wedge_masks();
dav1d_init_interintra_masks();
dav1d_init_qm_tables();
}
const char *dav1d_version(void) {
COLD const char *dav1d_version(void) {
return DAV1D_VERSION;
}
void dav1d_default_settings(Dav1dSettings *const s) {
COLD void dav1d_default_settings(Dav1dSettings *const s) {
s->n_frame_threads = 1;
s->n_tile_threads = 1;
s->apply_grain = 1;
s->allocator.cookie = NULL;
s->allocator.alloc_picture_callback = default_picture_allocator;
s->allocator.release_picture_callback = default_picture_release;
s->allocator.alloc_picture_callback = dav1d_default_picture_alloc;
s->allocator.release_picture_callback = dav1d_default_picture_release;
s->logger.cookie = NULL;
s->logger.callback = dav1d_log_default_callback;
s->operating_point = 0;
......@@ -71,24 +71,26 @@ void dav1d_default_settings(Dav1dSettings *const s) {
static void close_internal(Dav1dContext **const c_out, int flush);
int dav1d_open(Dav1dContext **const c_out,
const Dav1dSettings *const s)
{
COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) {
static pthread_once_t initted = PTHREAD_ONCE_INIT;
pthread_once(&initted, init_internal);
validate_input_or_ret(c_out != NULL, -EINVAL);
validate_input_or_ret(s != NULL, -EINVAL);
validate_input_or_ret(c_out != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(s != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(s->n_tile_threads >= 1 &&
s->n_tile_threads <= DAV1D_MAX_TILE_THREADS, -EINVAL);
s->n_tile_threads <= DAV1D_MAX_TILE_THREADS, DAV1D_ERR(EINVAL));
validate_input_or_ret(s->n_frame_threads >= 1 &&
s->n_frame_threads <= DAV1D_MAX_FRAME_THREADS, -EINVAL);
s->n_frame_threads <= DAV1D_MAX_FRAME_THREADS, DAV1D_ERR(EINVAL));
validate_input_or_ret(s->allocator.alloc_picture_callback != NULL,
-EINVAL);
DAV1D_ERR(EINVAL));
validate_input_or_ret(s->allocator.release_picture_callback != NULL,
-EINVAL);
DAV1D_ERR(EINVAL));
validate_input_or_ret(s->operating_point >= 0 &&
s->operating_point <= 31, -EINVAL);
s->operating_point <= 31, DAV1D_ERR(EINVAL));
pthread_attr_t thread_attr;
if (pthread_attr_init(&thread_attr)) return DAV1D_ERR(ENOMEM);
pthread_attr_setstacksize(&thread_attr, 1024 * 1024);
Dav1dContext *const c = *c_out = dav1d_alloc_aligned(sizeof(*c), 32);
if (!c) goto error;
......@@ -151,7 +153,7 @@ int dav1d_open(Dav1dContext **const c_out,
goto error;
}
t->tile_thread.fttd = &f->tile_thread;
if (pthread_create(&t->tile_thread.td.thread, NULL, dav1d_tile_task, t)) {
if (pthread_create(&t->tile_thread.td.thread, &thread_attr, dav1d_tile_task, t)) {
pthread_cond_destroy(&t->tile_thread.td.cond);
pthread_mutex_destroy(&t->tile_thread.td.lock);
goto error;
......@@ -159,7 +161,7 @@ int dav1d_open(Dav1dContext **const c_out,
t->tile_thread.td.inited = 1;
}
}
f->libaom_cm = av1_alloc_ref_mv_common();
f->libaom_cm = dav1d_alloc_ref_mv_common();
if (!f->libaom_cm) goto error;
if (c->n_fc > 1) {
if (pthread_mutex_init(&f->frame_thread.td.lock, NULL)) goto error;
......@@ -167,7 +169,7 @@ int dav1d_open(Dav1dContext **const c_out,
pthread_mutex_destroy(&f->frame_thread.td.lock);
goto error;
}
if (pthread_create(&f->frame_thread.td.thread, NULL, dav1d_frame_task, f)) {
if (pthread_create(&f->frame_thread.td.thread, &thread_attr, dav1d_frame_task, f)) {
pthread_cond_destroy(&f->frame_thread.td.cond);
pthread_mutex_destroy(&f->frame_thread.td.lock);
goto error;
......@@ -182,11 +184,14 @@ int dav1d_open(Dav1dContext **const c_out,
c->intra_edge.root[BL_64X64] = &c->intra_edge.branch_sb64[0].node;
dav1d_init_mode_tree(c->intra_edge.root[BL_64X64], c->intra_edge.tip_sb64, 0);
pthread_attr_destroy(&thread_attr);
return 0;
error:
if (c) close_internal(c_out, 0);
return -ENOMEM;
pthread_attr_destroy(&thread_attr);
return DAV1D_ERR(ENOMEM);
}
static void dummy_free(const uint8_t *const data, void *const user_data) {
......@@ -199,7 +204,7 @@ int dav1d_parse_sequence_header(Dav1dSequenceHeader *const out,
Dav1dData buf = { 0 };
int res;
validate_input_or_ret(out != NULL, -EINVAL);
validate_input_or_ret(out != NULL, DAV1D_ERR(EINVAL));
Dav1dSettings s;
dav1d_default_settings(&s);
......@@ -224,7 +229,7 @@ int dav1d_parse_sequence_header(Dav1dSequenceHeader *const out,
}
if (!c->seq_hdr) {
res = -EINVAL;
res = DAV1D_ERR(EINVAL);
goto error;
}
......@@ -240,14 +245,14 @@ error:
int dav1d_send_data(Dav1dContext *const c, Dav1dData *const in)
{
validate_input_or_ret(c != NULL, -EINVAL);
validate_input_or_ret(in != NULL, -EINVAL);
validate_input_or_ret(in->data == NULL || in->sz, -EINVAL);
validate_input_or_ret(c != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(in != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(in->data == NULL || in->sz, DAV1D_ERR(EINVAL));
c->drain = 0;
if (c->in.data)
return -EAGAIN;
return DAV1D_ERR(EAGAIN);
dav1d_data_move_ref(&c->in, in);
return 0;
......@@ -336,22 +341,22 @@ static int drain_picture(Dav1dContext *const c, Dav1dPicture *const out) {
}
} while (++drain_count < c->n_fc);
return -EAGAIN;
return DAV1D_ERR(EAGAIN);
}
int dav1d_get_picture(Dav1dContext *const c, Dav1dPicture *const out)
{
int res;
validate_input_or_ret(c != NULL, -EINVAL);
validate_input_or_ret(out != NULL, -EINVAL);
validate_input_or_ret(c != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(out != NULL, DAV1D_ERR(EINVAL));
const int drain = c->drain;
c->drain = 1;
Dav1dData *const in = &c->in;
if (!in->data) {
if (c->n_fc == 1) return -EAGAIN;
if (c->n_fc == 1) return DAV1D_ERR(EAGAIN);
return drain_picture(c, out);
}
......@@ -377,7 +382,7 @@ int dav1d_get_picture(Dav1dContext *const c, Dav1dPicture *const out)
if (c->n_fc > 1 && drain)
return drain_picture(c, out);
return -EAGAIN;
return DAV1D_ERR(EAGAIN);
}
void dav1d_flush(Dav1dContext *const c) {
......@@ -425,12 +430,12 @@ void dav1d_flush(Dav1dContext *const c) {
c->frame_thread.next = 0;
}
void dav1d_close(Dav1dContext **const c_out) {
COLD void dav1d_close(Dav1dContext **const c_out) {
validate_input(c_out != NULL);
close_internal(c_out, 1);
}
static void close_internal(Dav1dContext **const c_out, int flush) {
static COLD void close_internal(Dav1dContext **const c_out, int flush) {
Dav1dContext *const c = *c_out;
if (!c) return;
......@@ -502,7 +507,7 @@ static void close_internal(Dav1dContext **const c_out, int flush) {
free(f->lf.lr_mask);
free(f->lf.level);
free(f->lf.tx_lpf_right_edge[0]);
if (f->libaom_cm) av1_free_ref_mv_common(f->libaom_cm);
if (f->libaom_cm) dav1d_free_ref_mv_common(f->libaom_cm);
dav1d_free_aligned(f->lf.cdef_line);
dav1d_free_aligned(f->lf.lr_lpf_line);
}
......
......@@ -36,14 +36,14 @@
#include "src/internal.h"
#include "src/log.h"
void dav1d_log_default_callback(void *const cookie,
const char *const format, va_list ap)
COLD void dav1d_log_default_callback(void *const cookie,
const char *const format, va_list ap)
{
vfprintf(stderr, format, ap);
}
#if CONFIG_LOG
void dav1d_log(Dav1dContext *const c, const char *const format, ...) {
COLD void dav1d_log(Dav1dContext *const c, const char *const format, ...) {
validate_input(c != NULL);
if (!c->logger.callback)
......
......@@ -244,7 +244,7 @@ static void loop_filter_v_sb128uv_c(pixel *dst, const ptrdiff_t stride,
}
}
void bitfn(dav1d_loop_filter_dsp_init)(Dav1dLoopFilterDSPContext *const c) {
COLD void bitfn(dav1d_loop_filter_dsp_init)(Dav1dLoopFilterDSPContext *const c) {
c->loop_filter_sb[0][0] = loop_filter_h_sb128y_c;
c->loop_filter_sb[0][1] = loop_filter_v_sb128y_c;
c->loop_filter_sb[1][0] = loop_filter_h_sb128uv_c;
......
......@@ -573,7 +573,7 @@ static void selfguided_c(pixel *p, const ptrdiff_t p_stride,
}
}
void bitfn(dav1d_loop_restoration_dsp_init)(Dav1dLoopRestorationDSPContext *const c) {
COLD void bitfn(dav1d_loop_restoration_dsp_init)(Dav1dLoopRestorationDSPContext *const c) {
c->wiener = wiener_c;
c->selfguided = selfguided_c;
......
......@@ -912,7 +912,7 @@ static void resize_c(pixel *dst, const ptrdiff_t dst_stride,
} while (--h);
}
void bitfn(dav1d_mc_dsp_init)(Dav1dMCDSPContext *const c) {
COLD void bitfn(dav1d_mc_dsp_init)(Dav1dMCDSPContext *const c) {
#define init_mc_fns(type, name) do { \
c->mc [type] = put_##name##_c; \
c->mc_scaled [type] = put_##name##_scaled_c; \
......
......@@ -28,43 +28,43 @@
# libdav1d source files
libdav1d_sources = files(
'picture.c',
'cdf.c',
'cpu.c',
'data.c',
'ref.c',
'log.c',
'getbits.c',
'obu.c',
'decode.c',
'cdf.c',
'msac.c',
'tables.c',
'scan.c',
'dequant_tables.c',
'getbits.c',
'intra_edge.c',
'lf_mask.c',
'log.c',
'msac.c',
'obu.c',
'picture.c',
'qm.c',
'ref.c',
'ref_mvs.c',
'scan.c',
'tables.c',
'warpmv.c',
'wedge.c',
'qm.c',
)
# libdav1d bitdepth source files
# These files are compiled for each bitdepth with
# `BITDEPTH` defined to the currently built bitdepth.
libdav1d_tmpl_sources = files(
'cdef_apply_tmpl.c',
'cdef_tmpl.c',
'film_grain_tmpl.c',
'ipred_prepare_tmpl.c',
'ipred_tmpl.c',
'itx_tmpl.c',
'lf_apply_tmpl.c',
'loopfilter_tmpl.c',
'mc_tmpl.c',
'cdef_apply_tmpl.c',
'cdef_tmpl.c',
'lr_apply_tmpl.c',
'looprestoration_tmpl.c',
'lr_apply_tmpl.c',
'mc_tmpl.c',
'recon_tmpl.c',
'film_grain_tmpl.c',
)
# libdav1d entrypoint source files
......@@ -96,6 +96,7 @@ if is_asm_enabled
'arm/64/loopfilter.S',
'arm/64/looprestoration.S',
'arm/64/mc.S',
'arm/64/msac.S',
)
elif host_machine.cpu_family().startswith('arm')
libdav1d_sources += files(
......@@ -127,15 +128,15 @@ if is_asm_enabled
if dav1d_bitdepths.contains('8')
libdav1d_sources_asm += files(
'x86/cdef.asm',
'x86/cdef_sse.asm',
'x86/ipred.asm',
'x86/ipred_ssse3.asm',
'x86/itx.asm',
'x86/itx_ssse3.asm',
'x86/loopfilter.asm',
'x86/looprestoration.asm',
'x86/looprestoration_ssse3.asm',
'x86/mc.asm',
'x86/cdef_sse.asm',
'x86/ipred_ssse3.asm',
'x86/itx_ssse3.asm',
'x86/looprestoration_ssse3.asm',
'x86/mc_ssse3.asm',
)
endif
......
......@@ -55,7 +55,17 @@ int dav1d_msac_decode_subexp(MsacContext *s, int ref, int n, unsigned k);
int dav1d_msac_decode_uniform(MsacContext *s, unsigned n);
/* Supported n_symbols ranges: adapt4: 1-5, adapt8: 1-8, adapt16: 4-16 */
#if ARCH_X86_64 && HAVE_ASM
#if ARCH_AARCH64 && HAVE_ASM
unsigned dav1d_msac_decode_symbol_adapt4_neon(MsacContext *s, uint16_t *cdf,
size_t n_symbols);
unsigned dav1d_msac_decode_symbol_adapt8_neon(MsacContext *s, uint16_t *cdf,
size_t n_symbols);
unsigned dav1d_msac_decode_symbol_adapt16_neon(MsacContext *s, uint16_t *cdf,
size_t n_symbols);
#define dav1d_msac_decode_symbol_adapt4 dav1d_msac_decode_symbol_adapt4_neon
#define dav1d_msac_decode_symbol_adapt8 dav1d_msac_decode_symbol_adapt8_neon
#define dav1d_msac_decode_symbol_adapt16 dav1d_msac_decode_symbol_adapt16_neon
#elif ARCH_X86_64 && HAVE_ASM
unsigned dav1d_msac_decode_symbol_adapt4_sse2(MsacContext *s, uint16_t *cdf,
size_t n_symbols);
unsigned dav1d_msac_decode_symbol_adapt8_sse2(MsacContext *s, uint16_t *cdf,
......
......@@ -284,7 +284,7 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
error:
dav1d_log(c, "Error parsing sequence header\n");
return -EINVAL;
return DAV1D_ERR(EINVAL);
}
static int read_frame_size(Dav1dContext *const c, GetBits *const gb,
......@@ -756,7 +756,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
// segmentation data from the reference frame.
assert(hdr->primary_ref_frame != DAV1D_PRIMARY_REF_NONE);
const int pri_ref = hdr->refidx[hdr->primary_ref_frame];
if (!c->refs[pri_ref].p.p.frame_hdr) return -EINVAL;
if (!c->refs[pri_ref].p.p.frame_hdr) return DAV1D_ERR(EINVAL);
hdr->segmentation.seg_data =
c->refs[pri_ref].p.p.frame_hdr->segmentation.seg_data;
}
......@@ -818,7 +818,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
hdr->loopfilter.mode_ref_deltas = default_mode_ref_deltas;
} else {
const int ref = hdr->refidx[hdr->primary_ref_frame];
if (!c->refs[ref].p.p.frame_hdr) return -EINVAL;
if (!c->refs[ref].p.p.frame_hdr) return DAV1D_ERR(EINVAL);
hdr->loopfilter.mode_ref_deltas =
c->refs[ref].p.p.frame_hdr->loopfilter.mode_ref_deltas;
}
......@@ -922,7 +922,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
int off_before_idx[2], off_after_idx;
off_before_idx[0] = 0;
for (int i = 0; i < 7; i++) {
if (!c->refs[hdr->refidx[i]].p.p.data[0]) return -EINVAL;
if (!c->refs[hdr->refidx[i]].p.p.data[0]) return DAV1D_ERR(EINVAL);
const unsigned refpoc = c->refs[hdr->refidx[i]].p.p.frame_hdr->frame_offset;
const int diff = get_poc_diff(seqhdr->order_hint_n_bits, refpoc, poc);
......@@ -999,7 +999,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
ref_gmv = &dav1d_default_wm_params;
} else {
const int pri_ref = hdr->refidx[hdr->primary_ref_frame];
if (!c->refs[pri_ref].p.p.frame_hdr) return -EINVAL;
if (!c->refs[pri_ref].p.p.frame_hdr) return DAV1D_ERR(EINVAL);
ref_gmv = &c->refs[pri_ref].p.p.frame_hdr->gmv[i];
}
int32_t *const mat = hdr->gmv[i].matrix;
......@@ -1122,7 +1122,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
error:
dav1d_log(c, "Error parsing frame header\n");
return -EINVAL;
return DAV1D_ERR(EINVAL);
}
static void parse_tile_hdr(Dav1dContext *const c, GetBits *const gb) {
......@@ -1227,7 +1227,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
switch (type) {
case OBU_SEQ_HDR: {
Dav1dRef *ref = dav1d_ref_create(sizeof(Dav1dSequenceHeader));
if (!ref) return -ENOMEM;
if (!ref) return DAV1D_ERR(ENOMEM);
Dav1dSequenceHeader *seq_hdr = ref->data;
memset(seq_hdr, 0, sizeof(*seq_hdr));
if ((res = parse_seq_hdr(c, &gb, seq_hdr)) < 0) {
......@@ -1236,7 +1236,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
}
if (check_for_overrun(c, &gb, init_bit_pos, len)) {
dav1d_ref_dec(&ref);
return -EINVAL;
return DAV1D_ERR(EINVAL);
}
// If we have read a sequence header which is different from
// the old one, this is a new video sequence and can't use any
......@@ -1273,7 +1273,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
if (!c->seq_hdr) goto error;
if (!c->frame_hdr_ref) {
c->frame_hdr_ref = dav1d_ref_create(sizeof(Dav1dFrameHeader));
if (!c->frame_hdr_ref) return -ENOMEM;
if (!c->frame_hdr_ref) return DAV1D_ERR(ENOMEM);
}
// ensure that the reference is writable
assert(dav1d_ref_is_writable(c->frame_hdr_ref));
......@@ -1295,7 +1295,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
dav1d_get_bits(&gb, 1);
if (check_for_overrun(c, &gb, init_bit_pos, len)) {
c->frame_hdr = NULL;
return -EINVAL;
return DAV1D_ERR(EINVAL);
}
break;
......@@ -1326,7 +1326,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
// Align to the next byte boundary and check for overrun.
dav1d_bytealign_get_bits(&gb);
if (check_for_overrun(c, &gb, init_bit_pos, len))
return -EINVAL;
return DAV1D_ERR(EINVAL);
// The current bit position is a multiple of 8 (because we
// just aligned it) and less than 8*pkt_bytelen because
// otherwise the overrun check would have fired.
......@@ -1362,7 +1362,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
switch (meta_type) {
case OBU_META_HDR_CLL:
ref = dav1d_ref_create(sizeof(Dav1dContentLightLevel));
if (!ref) return -ENOMEM;
if (!ref) return DAV1D_ERR(ENOMEM);
content_light = ref->data;
memset(content_light, 0, sizeof(*content_light));