Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2018-09-05 00:32:00 +0300
committerRonald S. Bultje <rsbultje@gmail.com>2018-09-22 14:59:19 +0300
commite2892ffa2dd1e893d0229c5fcbe0bbbee8e11c20 (patch)
tree9ba42513c2916db89d47f8b34fa0141d6aeb4dde /include
parentd32eb2d935a31288c34ccaa42b09bc60eacdfd68 (diff)
Initial decoder implementation.
With minor contributions from: - Jean-Baptiste Kempf <jb@videolan.org> - Marvin Scholz <epirat07@gmail.com> - Hugo Beauzée-Luyssen <hugo@videolan.org>
Diffstat (limited to 'include')
-rw-r--r--include/common/attributes.h54
-rw-r--r--include/common/bitdepth.h68
-rw-r--r--include/common/dump.h75
-rw-r--r--include/common/intops.h78
-rw-r--r--include/common/mem.h76
-rw-r--r--include/common/validate.h59
-rw-r--r--include/dav1d/common.h43
-rw-r--r--include/dav1d/data.h52
-rw-r--r--include/dav1d/dav1d.h87
-rw-r--r--include/dav1d/picture.h145
10 files changed, 737 insertions, 0 deletions
diff --git a/include/common/attributes.h b/include/common/attributes.h
new file mode 100644
index 0000000..b2315bc
--- /dev/null
+++ b/include/common/attributes.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_ATTRIBUTES_H__
+#define __DAV1D_COMMON_ATTRIBUTES_H__
+
+#include <stddef.h>
+
+/*
+ * API for variables, struct members (ALIGN()) like:
+ * uint8_t var[1][2][3][4]
+ * becomes:
+ * ALIGN(uint8_t var[1][2][3][4], alignment).
+ */
+#define ALIGN(line, align) \
+ line __attribute__((aligned(align)))
+
+/*
+ * API for stack alignment (ALIGN_STK_$align()) of variables like:
+ * uint8_t var[1][2][3][4]
+ * becomes:
+ * ALIGN_STK_$align(uint8_t, var, 1, [2][3][4])
+ */
+#define ALIGN_STK_32(type, var, sz1d, sznd) \
+ ALIGN(type var[sz1d]sznd, 32)
+// as long as stack is itself 16-byte aligned, this works (win64, gcc)
+#define ALIGN_STK_16(type, var, sz1d, sznd) \
+ ALIGN(type var[sz1d]sznd, 16)
+
+#endif /* __DAV1D_COMMON_ATTRIBUTES_H__ */
diff --git a/include/common/bitdepth.h b/include/common/bitdepth.h
new file mode 100644
index 0000000..467d892
--- /dev/null
+++ b/include/common/bitdepth.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_BITDEPTH_H__
+#define __DAV1D_COMMON_BITDEPTH_H__ 1
+
+#include <stdint.h>
+#include <string.h>
+
+#if !defined(BITDEPTH)
+typedef void pixel;
+typedef void coef;
+#elif BITDEPTH == 8
+typedef uint8_t pixel;
+typedef int16_t coef;
+#define pixel_copy memcpy
+#define pixel_set memset
+#define iclip_pixel iclip_u8
+#define PIX_HEX_FMT "%02x"
+#define bytefn(x) x##_8bpc
+#define bitfn(x) x##_8bpc
+#define PXSTRIDE(x) x
+#elif BITDEPTH == 10 || BITDEPTH == 12
+typedef uint16_t pixel;
+typedef int32_t coef;
+#define pixel_copy(a, b, c) memcpy(a, b, (c) << 1)
+#define iclip_pixel(x) iclip(x, 0, ((1 << BITDEPTH) - 1))
+static inline void pixel_set(pixel *const dst, const int val, const int num) {
+ for (int n = 0; n < num; n++)
+ dst[n] = val;
+}
+#define PIX_HEX_FMT "%03x"
+#define bytefn(x) x##_16bpc
+#if BITDEPTH == 10
+#define bitfn(x) x##_10bpc
+#else
+#define bitfn(x) x##_12bpc
+#endif
+#define PXSTRIDE(x) (x >> 1)
+#else
+#error invalid value for bitdepth
+#endif
+
+#endif /* __DAV1D_COMMON_BITDEPTH_H__ */
diff --git a/include/common/dump.h b/include/common/dump.h
new file mode 100644
index 0000000..a73824f
--- /dev/null
+++ b/include/common/dump.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_DUMP_H__
+#define __DAV1D_COMMON_DUMP_H__
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include "common/bitdepth.h"
+
+static inline void append_plane_to_file(const pixel *buf, ptrdiff_t stride,
+ int w, int h, const char *const file)
+{
+ FILE *const f = fopen(file, "ab");
+ while (h--) {
+ fwrite(buf, w * sizeof(pixel), 1, f);
+ buf += PXSTRIDE(stride);
+ }
+ fclose(f);
+}
+
+static inline void hex_dump(const pixel *buf, ptrdiff_t stride,
+ int w, int h, const char *what)
+{
+ printf("%s\n", what);
+ while (h--) {
+ int x;
+ for (x = 0; x < w; x++)
+ printf(" " PIX_HEX_FMT, buf[x]);
+ buf += PXSTRIDE(stride);
+ printf("\n");
+ }
+}
+
+static inline void coef_dump(const coef *buf, const int w, const int h,
+ const int len, const char *what)
+{
+ int y;
+ printf("%s\n", what);
+ for (y = 0; y < h; y++) {
+ int x;
+ for (x = 0; x < w; x++)
+ printf(" %*d", len, buf[x]);
+ buf += w;
+ printf("\n");
+ }
+}
+
+#endif /* __DAV1D_COMMON_DUMP_H__ */
diff --git a/include/common/intops.h b/include/common/intops.h
new file mode 100644
index 0000000..a739709
--- /dev/null
+++ b/include/common/intops.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_INTOPS_H__
+#define __DAV1D_COMMON_INTOPS_H__
+
+#include <stdint.h>
+
+static inline int imax(const int a, const int b) {
+ return a > b ? a : b;
+}
+
+static inline int imin(const int a, const int b) {
+ return a < b ? a : b;
+}
+
+static inline int iclip(const int v, const int min, const int max) {
+ return v < min ? min : v > max ? max : v;
+}
+
+static inline int iclip_u8(const int v) {
+ return iclip(v, 0, 255);
+}
+
+static inline int apply_sign(const int v, const int s) {
+ return s < 0 ? -v : v;
+}
+
+static inline int ulog2(const unsigned v) {
+ return 31 - __builtin_clz(v);
+}
+
+static inline int u64log2(const uint64_t v) {
+ return 63 - __builtin_clzll(v);
+}
+
+static inline unsigned rl16(const uint8_t *const ptr) {
+ return (ptr[1] << 8) | ptr[0];
+}
+
+static inline unsigned rl32(const uint8_t *const ptr) {
+ return (rl16(&ptr[2]) << 16) | rl16(ptr);
+}
+
+static inline unsigned inv_recenter(const unsigned r, const unsigned v) {
+ if (v > (r << 1))
+ return v;
+ else if ((v & 1) == 0)
+ return (v >> 1) + r;
+ else
+ return r - ((v + 1) >> 1);
+}
+
+#endif /* __DAV1D_COMMON_INTOPS_H__ */
diff --git a/include/common/mem.h b/include/common/mem.h
new file mode 100644
index 0000000..d266c5d
--- /dev/null
+++ b/include/common/mem.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_MEM_H__
+#define __DAV1D_COMMON_MEM_H__
+
+#include <assert.h>
+#include <stdlib.h>
+#include <malloc.h>
+
+/*
+ * Allocate 32-byte aligned memory. The return value can be released
+ * by calling the standard free() function.
+ */
+static inline void *dav1d_alloc_aligned(size_t sz, size_t align) {
+#ifdef HAVE_POSIX_MEMALIGN
+ void *ptr;
+ assert(!(align & (align - 1)));
+ if (posix_memalign(&ptr, align, sz)) return NULL;
+ return ptr;
+#elif defined(HAVE_ALIGNED_MALLOC)
+ return _aligned_malloc(sz, align);
+#else
+#error Missing aligned alloc implementation
+#endif
+}
+
+static inline void dav1d_free_aligned(void* ptr) {
+#ifdef HAVE_POSIX_MEMALIGN
+ free(ptr);
+#elif defined(HAVE_ALIGNED_MALLOC)
+ _aligned_free(ptr);
+#endif
+}
+
+static inline void dav1d_freep_aligned(void* ptr) {
+ void **mem = (void **) ptr;
+ if (*mem) {
+ dav1d_free_aligned(*mem);
+ *mem = NULL;
+ }
+}
+
+static inline void freep(void *ptr) {
+ void **mem = (void **) ptr;
+ if (*mem) {
+ free(*mem);
+ *mem = NULL;
+ }
+}
+
+#endif /* __DAV1D_COMMON_MEM_H__ */
diff --git a/include/common/validate.h b/include/common/validate.h
new file mode 100644
index 0000000..310266d
--- /dev/null
+++ b/include/common/validate.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_COMMON_VALIDATE_H__
+#define __DAV1D_COMMON_VALIDATE_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(NDEBUG)
+#define debug_abort()
+#else
+#define debug_abort abort
+#endif
+
+#define validate_input_or_ret_with_msg(x, r, msg...) \
+ if (!(x)) { \
+ fprintf(stderr, "Input validation check \'%s\' failed in %s!\n", \
+ #x, __PRETTY_FUNCTION__); \
+ fprintf(stderr, msg); \
+ debug_abort(); \
+ return r; \
+ }
+
+#define validate_input_or_ret(x, r) \
+ if (!(x)) { \
+ fprintf(stderr, "Input validation check \'%s\' failed in %s!\n", \
+ #x, __PRETTY_FUNCTION__); \
+ debug_abort(); \
+ return r; \
+ }
+
+#define validate_input(x) validate_input_or_ret(x, )
+
+#endif /* __DAV1D_COMMON_VALIDATE_H__ */
diff --git a/include/dav1d/common.h b/include/dav1d/common.h
new file mode 100644
index 0000000..f85f5b1
--- /dev/null
+++ b/include/dav1d/common.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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 __COMMON_H__
+#define __COMMON_H__
+
+#ifndef DAV1D_API
+ #if defined _WIN32
+ #define DAV1D_API __declspec(dllexport)
+ #else
+ #if __GNUC__ >= 4
+ #define DAV1D_API __attribute__ ((visibility ("default")))
+ #else
+ #define DAV1D_API
+ #endif
+ #endif
+#endif
+
+#endif // __COMMON_H__
diff --git a/include/dav1d/data.h b/include/dav1d/data.h
new file mode 100644
index 0000000..9a351ea
--- /dev/null
+++ b/include/dav1d/data.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_DATA_H__
+#define __DAV1D_DATA_H__
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "common.h"
+
+typedef struct Dav1dData {
+ uint8_t *data; ///< data pointer
+ size_t sz; ///< data size
+ struct Dav1dRef *ref; ///< allocation origin
+} Dav1dData;
+
+/**
+ * Allocate data.
+ */
+DAV1D_API int dav1d_data_create(Dav1dData *data, size_t sz);
+
+/**
+ * Free data.
+ */
+DAV1D_API void dav1d_data_unref(Dav1dData *buf);
+
+#endif /* __DAV1D_DATA_H__ */
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h
new file mode 100644
index 0000000..9ce476d
--- /dev/null
+++ b/include/dav1d/dav1d.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_H__
+#define __DAV1D_H__
+
+#include "common.h"
+#include "picture.h"
+#include "data.h"
+
+typedef struct Dav1dContext Dav1dContext;
+typedef struct Dav1dRef Dav1dRef;
+
+typedef struct Dav1dSettings {
+ int n_frame_threads;
+ int n_tile_threads;
+} Dav1dSettings;
+
+/*
+ * Init the library.
+ */
+DAV1D_API void dav1d_init(void);
+
+/**
+ * Get library version.
+ */
+DAV1D_API const char *dav1d_version(void);
+
+/**
+ * Initialize settings to default values.
+ */
+DAV1D_API void dav1d_default_settings(Dav1dSettings *s);
+
+/**
+ * Open/allocate decoder instance.
+ *
+ * The resulting instance context will be placed in $c_out and can be used in
+ * iterative calls to dav1d_decode().
+ *
+ * You should free the context using dav1d_close() when you're done decoding.
+ *
+ * This returns < 0 (a negative errno code) on error, or 0 on success.
+ */
+DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
+
+/**
+ * Decode one input frame. Library takes ownership of the passed-in reference.
+ * After that, it will return < 0 (a negative errno code, but not -EAGAIN) on
+ * failure, or 0 on success. If any decoded output frames are available, they
+ * will be placed in $out. The caller assumes ownership of the returned output
+ * picture.
+ *
+ * To flush the decoder (i.e. all input is finished), feed it NULL input data
+ * until it returns -EAGAIN.
+ */
+DAV1D_API int dav1d_decode(Dav1dContext *c, Dav1dData *in, Dav1dPicture *out);
+
+/**
+ * Close decoder instance, free all associated memory.
+ */
+DAV1D_API void dav1d_close(Dav1dContext *c);
+
+#endif /* __DAV1D_H__ */
diff --git a/include/dav1d/picture.h b/include/dav1d/picture.h
new file mode 100644
index 0000000..1b3da29
--- /dev/null
+++ b/include/dav1d/picture.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * 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_PICTURE_H__
+#define __DAV1D_PICTURE_H__
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "common.h"
+
+enum Dav1dPixelLayout {
+ DAV1D_PIXEL_LAYOUT_I400, ///< monochrome
+ DAV1D_PIXEL_LAYOUT_I420, ///< 4:2:0 planar
+ DAV1D_PIXEL_LAYOUT_I422, ///< 4:2:2 planar
+ DAV1D_PIXEL_LAYOUT_I444, ///< 4:4:4 planar
+};
+
+enum Dav1dColorPrimaries {
+ DAV1D_COLOR_PRI_BT709 = 1,
+ DAV1D_COLOR_PRI_UNKNOWN = 2,
+ DAV1D_COLOR_PRI_BT470M = 4,
+ DAV1D_COLOR_PRI_BT470BG = 5,
+ DAV1D_COLOR_PRI_BT601 = 6,
+ DAV1D_COLOR_PRI_SMPTE240 = 7,
+ DAV1D_COLOR_PRI_FILM = 8,
+ DAV1D_COLOR_PRI_BT2020 = 9,
+ DAV1D_COLOR_PRI_XYZ = 10,
+ DAV1D_COLOR_PRI_SMPTE431 = 11,
+ DAV1D_COLOR_PRI_SMPTE432 = 12,
+ DAV1D_COLOR_PRI_EBU3213 = 22,
+};
+
+enum Dav1dTransferCharacteristics {
+ DAV1D_TRC_BT709 = 1,
+ DAV1D_TRC_UNKNOWN = 2,
+ DAV1D_TRC_BT470M = 4,
+ DAV1D_TRC_BT470BG = 5,
+ DAV1D_TRC_BT601 = 6,
+ DAV1D_TRC_SMPTE240 = 7,
+ DAV1D_TRC_LINEAR = 8,
+ DAV1D_TRC_LOG100 = 9, ///< logarithmic (100:1 range)
+ DAV1D_TRC_LOG100_SQRT10 = 10, ///< lograithmic (100*sqrt(10):1 range)
+ DAV1D_TRC_IEC61966 = 11,
+ DAV1D_TRC_BT1361 = 12,
+ DAV1D_TRC_SRGB = 13,
+ DAV1D_TRC_BT2020_10BIT = 14,
+ DAV1D_TRC_BT2020_12BIT = 15,
+ DAV1D_TRC_SMPTE2084 = 16, ///< PQ
+ DAV1D_TRC_SMPTE428 = 17,
+ DAV1D_TRC_HLG = 18, ///< hybrid log/gamma (BT.2100 / ARIB STD-B67)
+};
+
+enum Dav1dMatrixCoefficients {
+ DAV1D_MC_IDENTITY = 0,
+ DAV1D_MC_BT709 = 1,
+ DAV1D_MC_UNKNOWN = 2,
+ DAV1D_MC_FCC = 4,
+ DAV1D_MC_BT470BG = 5,
+ DAV1D_MC_BT601 = 6,
+ DAV1D_MC_SMPTE240 = 7,
+ DAV1D_MC_SMPTE_YCGCO = 8,
+ DAV1D_MC_BT2020_NCL = 9,
+ DAV1D_MC_BT2020_CL = 10,
+ DAV1D_MC_SMPTE2085 = 11,
+ DAV1D_MC_CHROMAT_NCL = 12, ///< Chromaticity-derived
+ DAV1D_MC_CHROMAT_CL = 13,
+ DAV1D_MC_ICTCP = 14,
+};
+
+enum Dav1dChromaSamplePosition {
+ DAV1D_CHR_UNKNOWN = 0,
+ DAV1D_CHR_VERTICAL = 1, ///< Horizontally co-located with luma(0, 0)
+ ///< sample, between two vertical samples
+ DAV1D_CHR_COLOCATED = 2, ///< Co-located with luma(0, 0) sample
+};
+
+typedef struct Dav1dPictureParameters {
+ int w; ///< width (in pixels)
+ int h; ///< height (in pixels)
+ enum Dav1dPixelLayout layout; ///< format of the picture
+ int bpc; ///< bits per pixel component (8 or 10)
+
+ enum Dav1dColorPrimaries pri; ///< color primaries (av1)
+ enum Dav1dTransferCharacteristics trc; ///< transfer characteristics (av1)
+ enum Dav1dMatrixCoefficients mtrx; ///< matrix coefficients (av1)
+ enum Dav1dChromaSamplePosition chr; ///< chroma sample position (av1)
+ /**
+ * 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).
+ */
+ int fullrange;
+} Dav1dPictureParameters;
+
+typedef struct Dav1dPicture {
+ /**
+ * Pointers to planar image data (Y is [0], U is [1], V is [2]). The data
+ * should be bytes (for 8 bpc) or words (for 10 bpc). In case of words
+ * containing 10 bpc image data, the pixels should be located in the LSB
+ * bits, so that values range between [0, 1023]; the upper bits should be
+ * zero'ed out.
+ */
+ void *data[3];
+ struct Dav1dRef *ref; ///< allocation origin
+
+ /**
+ * Number of bytes between 2 lines in data[] for luma [0] or chroma [1].
+ */
+ ptrdiff_t stride[2];
+
+ Dav1dPictureParameters p;
+
+ int poc; ///< frame number
+} Dav1dPicture;
+
+/**
+ * Release reference to a picture.
+ */
+DAV1D_API void dav1d_picture_unref(Dav1dPicture *p);
+
+#endif /* __DAV1D_PICTURE_H__ */