summaryrefslogtreecommitdiffstats
path: root/third_party/aom/av1/common/clpf.c
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-10-15 21:45:30 -0500
committertrav90 <travawine@palemoon.org>2018-10-15 21:45:30 -0500
commit68569dee1416593955c1570d638b3d9250b33012 (patch)
treed960f017cd7eba3f125b7e8a813789ee2e076310 /third_party/aom/av1/common/clpf.c
parent07c17b6b98ed32fcecff15c083ab0fd878de3cf0 (diff)
downloadUXP-68569dee1416593955c1570d638b3d9250b33012.tar
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.gz
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.lz
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.xz
UXP-68569dee1416593955c1570d638b3d9250b33012.zip
Import aom library
This is the reference implementation for the Alliance for Open Media's av1 video code. The commit used was 4d668d7feb1f8abd809d1bca0418570a7f142a36.
Diffstat (limited to 'third_party/aom/av1/common/clpf.c')
-rw-r--r--third_party/aom/av1/common/clpf.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/third_party/aom/av1/common/clpf.c b/third_party/aom/av1/common/clpf.c
new file mode 100644
index 000000000..3637deeea
--- /dev/null
+++ b/third_party/aom/av1/common/clpf.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include "./clpf.h"
+#include "./av1_rtcd.h"
+#include "./cdef.h"
+#include "aom/aom_image.h"
+#include "aom_dsp/aom_dsp_common.h"
+
+int av1_clpf_sample(int X, int A, int B, int C, int D, int E, int F, int G,
+ int H, int s, unsigned int dmp) {
+ int delta = 1 * constrain(A - X, s, dmp) + 3 * constrain(B - X, s, dmp) +
+ 1 * constrain(C - X, s, dmp) + 3 * constrain(D - X, s, dmp) +
+ 3 * constrain(E - X, s, dmp) + 1 * constrain(F - X, s, dmp) +
+ 3 * constrain(G - X, s, dmp) + 1 * constrain(H - X, s, dmp);
+ return (8 + delta - (delta < 0)) >> 4;
+}
+
+int av1_clpf_hsample(int X, int A, int B, int C, int D, int s,
+ unsigned int dmp) {
+ int delta = 1 * constrain(A - X, s, dmp) + 3 * constrain(B - X, s, dmp) +
+ 3 * constrain(C - X, s, dmp) + 1 * constrain(D - X, s, dmp);
+ return (4 + delta - (delta < 0)) >> 3;
+}
+
+void aom_clpf_block_c(uint8_t *dst, const uint16_t *src, int dstride,
+ int sstride, int sizex, int sizey, unsigned int strength,
+ unsigned int damping) {
+ int x, y;
+
+ for (y = 0; y < sizey; y++) {
+ for (x = 0; x < sizex; x++) {
+ const int X = src[y * sstride + x];
+ const int A = src[(y - 2) * sstride + x];
+ const int B = src[(y - 1) * sstride + x];
+ const int C = src[y * sstride + x - 2];
+ const int D = src[y * sstride + x - 1];
+ const int E = src[y * sstride + x + 1];
+ const int F = src[y * sstride + x + 2];
+ const int G = src[(y + 1) * sstride + x];
+ const int H = src[(y + 2) * sstride + x];
+ const int delta =
+ av1_clpf_sample(X, A, B, C, D, E, F, G, H, strength, damping);
+ dst[y * dstride + x] = X + delta;
+ }
+ }
+}
+
+// Identical to aom_clpf_block_c() apart from "dst".
+void aom_clpf_block_hbd_c(uint16_t *dst, const uint16_t *src, int dstride,
+ int sstride, int sizex, int sizey,
+ unsigned int strength, unsigned int damping) {
+ int x, y;
+
+ for (y = 0; y < sizey; y++) {
+ for (x = 0; x < sizex; x++) {
+ const int X = src[y * sstride + x];
+ const int A = src[(y - 2) * sstride + x];
+ const int B = src[(y - 1) * sstride + x];
+ const int C = src[y * sstride + x - 2];
+ const int D = src[y * sstride + x - 1];
+ const int E = src[y * sstride + x + 1];
+ const int F = src[y * sstride + x + 2];
+ const int G = src[(y + 1) * sstride + x];
+ const int H = src[(y + 2) * sstride + x];
+ const int delta =
+ av1_clpf_sample(X, A, B, C, D, E, F, G, H, strength, damping);
+ dst[y * dstride + x] = X + delta;
+ }
+ }
+}
+
+// Vertically restricted filter
+void aom_clpf_hblock_c(uint8_t *dst, const uint16_t *src, int dstride,
+ int sstride, int sizex, int sizey, unsigned int strength,
+ unsigned int damping) {
+ int x, y;
+
+ for (y = 0; y < sizey; y++) {
+ for (x = 0; x < sizex; x++) {
+ const int X = src[y * sstride + x];
+ const int A = src[y * sstride + x - 2];
+ const int B = src[y * sstride + x - 1];
+ const int C = src[y * sstride + x + 1];
+ const int D = src[y * sstride + x + 2];
+ const int delta = av1_clpf_hsample(X, A, B, C, D, strength, damping);
+ dst[y * dstride + x] = X + delta;
+ }
+ }
+}
+
+void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride,
+ int sstride, int sizex, int sizey,
+ unsigned int strength, unsigned int damping) {
+ int x, y;
+
+ for (y = 0; y < sizey; y++) {
+ for (x = 0; x < sizex; x++) {
+ const int X = src[y * sstride + x];
+ const int A = src[y * sstride + x - 2];
+ const int B = src[y * sstride + x - 1];
+ const int C = src[y * sstride + x + 1];
+ const int D = src[y * sstride + x + 2];
+ const int delta = av1_clpf_hsample(X, A, B, C, D, strength, damping);
+ dst[y * dstride + x] = X + delta;
+ }
+ }
+}