summaryrefslogtreecommitdiffstats
path: root/third_party/aom/av1/common/clpf_simd.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/aom/av1/common/clpf_simd.h')
-rw-r--r--third_party/aom/av1/common/clpf_simd.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/third_party/aom/av1/common/clpf_simd.h b/third_party/aom/av1/common/clpf_simd.h
index a615b5ed3..c7ffc569a 100644
--- a/third_party/aom/av1/common/clpf_simd.h
+++ b/third_party/aom/av1/common/clpf_simd.h
@@ -10,10 +10,20 @@
*/
#include "./av1_rtcd.h"
-#include "./cdef_simd.h"
#include "aom_ports/bitops.h"
#include "aom_ports/mem.h"
+// sign(a-b) * min(abs(a-b), max(0, threshold - (abs(a-b) >> adjdamp)))
+SIMD_INLINE v128 constrain16(v128 a, v128 b, unsigned int threshold,
+ unsigned int adjdamp) {
+ v128 diff = v128_sub_16(a, b);
+ const v128 sign = v128_shr_n_s16(diff, 15);
+ diff = v128_abs_s16(diff);
+ const v128 s =
+ v128_ssub_u16(v128_dup_16(threshold), v128_shr_u16(diff, adjdamp));
+ return v128_xor(v128_add_16(sign, v128_min_s16(diff, s)), sign);
+}
+
// sign(a - b) * min(abs(a - b), max(0, strength - (abs(a - b) >> adjdamp)))
SIMD_INLINE v128 constrain(v256 a, v256 b, unsigned int strength,
unsigned int adjdamp) {