Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <stdlib.h> |
| 13 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | #include "./aom_config.h" |
| 15 | #include "./aom_dsp_rtcd.h" |
| 16 | #include "aom_dsp/aom_dsp_common.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 17 | #include "aom_ports/mem.h" |
| 18 | |
| 19 | static INLINE int8_t signed_char_clamp(int t) { |
| 20 | return (int8_t)clamp(t, -128, 127); |
| 21 | } |
| 22 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | static INLINE int16_t signed_char_clamp_high(int t, int bd) { |
| 24 | switch (bd) { |
| 25 | case 10: return (int16_t)clamp(t, -128 * 4, 128 * 4 - 1); |
| 26 | case 12: return (int16_t)clamp(t, -128 * 16, 128 * 16 - 1); |
| 27 | case 8: |
| 28 | default: return (int16_t)clamp(t, -128, 128 - 1); |
| 29 | } |
| 30 | } |
Yaowu Xu | 6d0ed3e | 2018-02-12 10:38:16 -0800 | [diff] [blame] | 31 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | // should we apply any filter at all: 11111111 yes, 00000000 no |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 33 | static INLINE int8_t filter_mask2(uint8_t limit, uint8_t blimit, uint8_t p1, |
| 34 | uint8_t p0, uint8_t q0, uint8_t q1) { |
| 35 | int8_t mask = 0; |
| 36 | mask |= (abs(p1 - p0) > limit) * -1; |
| 37 | mask |= (abs(q1 - q0) > limit) * -1; |
| 38 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1; |
| 39 | return ~mask; |
| 40 | } |
Yaowu Xu | 6d0ed3e | 2018-02-12 10:38:16 -0800 | [diff] [blame] | 41 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 42 | static INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit, uint8_t p3, |
| 43 | uint8_t p2, uint8_t p1, uint8_t p0, uint8_t q0, |
| 44 | uint8_t q1, uint8_t q2, uint8_t q3) { |
| 45 | int8_t mask = 0; |
| 46 | mask |= (abs(p3 - p2) > limit) * -1; |
| 47 | mask |= (abs(p2 - p1) > limit) * -1; |
| 48 | mask |= (abs(p1 - p0) > limit) * -1; |
| 49 | mask |= (abs(q1 - q0) > limit) * -1; |
| 50 | mask |= (abs(q2 - q1) > limit) * -1; |
| 51 | mask |= (abs(q3 - q2) > limit) * -1; |
| 52 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1; |
| 53 | return ~mask; |
| 54 | } |
| 55 | |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 56 | static INLINE int8_t filter_mask3_chroma(uint8_t limit, uint8_t blimit, |
| 57 | uint8_t p2, uint8_t p1, uint8_t p0, |
| 58 | uint8_t q0, uint8_t q1, uint8_t q2) { |
| 59 | int8_t mask = 0; |
| 60 | mask |= (abs(p2 - p1) > limit) * -1; |
| 61 | mask |= (abs(p1 - p0) > limit) * -1; |
| 62 | mask |= (abs(q1 - q0) > limit) * -1; |
| 63 | mask |= (abs(q2 - q1) > limit) * -1; |
| 64 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1; |
| 65 | return ~mask; |
| 66 | } |
| 67 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 68 | static INLINE int8_t flat_mask3_chroma(uint8_t thresh, uint8_t p2, uint8_t p1, |
| 69 | uint8_t p0, uint8_t q0, uint8_t q1, |
| 70 | uint8_t q2) { |
| 71 | int8_t mask = 0; |
| 72 | mask |= (abs(p1 - p0) > thresh) * -1; |
| 73 | mask |= (abs(q1 - q0) > thresh) * -1; |
| 74 | mask |= (abs(p2 - p0) > thresh) * -1; |
| 75 | mask |= (abs(q2 - q0) > thresh) * -1; |
| 76 | return ~mask; |
| 77 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 78 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 79 | static INLINE int8_t flat_mask4(uint8_t thresh, uint8_t p3, uint8_t p2, |
| 80 | uint8_t p1, uint8_t p0, uint8_t q0, uint8_t q1, |
| 81 | uint8_t q2, uint8_t q3) { |
| 82 | int8_t mask = 0; |
| 83 | mask |= (abs(p1 - p0) > thresh) * -1; |
| 84 | mask |= (abs(q1 - q0) > thresh) * -1; |
| 85 | mask |= (abs(p2 - p0) > thresh) * -1; |
| 86 | mask |= (abs(q2 - q0) > thresh) * -1; |
| 87 | mask |= (abs(p3 - p0) > thresh) * -1; |
| 88 | mask |= (abs(q3 - q0) > thresh) * -1; |
| 89 | return ~mask; |
| 90 | } |
| 91 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 92 | // is there high edge variance internal edge: 11111111 yes, 00000000 no |
| 93 | static INLINE int8_t hev_mask(uint8_t thresh, uint8_t p1, uint8_t p0, |
| 94 | uint8_t q0, uint8_t q1) { |
| 95 | int8_t hev = 0; |
| 96 | hev |= (abs(p1 - p0) > thresh) * -1; |
| 97 | hev |= (abs(q1 - q0) > thresh) * -1; |
| 98 | return hev; |
| 99 | } |
| 100 | |
| 101 | static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1, |
| 102 | uint8_t *op0, uint8_t *oq0, uint8_t *oq1) { |
| 103 | int8_t filter1, filter2; |
| 104 | |
| 105 | const int8_t ps1 = (int8_t)*op1 ^ 0x80; |
| 106 | const int8_t ps0 = (int8_t)*op0 ^ 0x80; |
| 107 | const int8_t qs0 = (int8_t)*oq0 ^ 0x80; |
| 108 | const int8_t qs1 = (int8_t)*oq1 ^ 0x80; |
| 109 | const uint8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1); |
| 110 | |
| 111 | // add outer taps if we have high edge variance |
| 112 | int8_t filter = signed_char_clamp(ps1 - qs1) & hev; |
| 113 | |
| 114 | // inner taps |
| 115 | filter = signed_char_clamp(filter + 3 * (qs0 - ps0)) & mask; |
| 116 | |
| 117 | // save bottom 3 bits so that we round one side +4 and the other +3 |
| 118 | // if it equals 4 we'll set to adjust by -1 to account for the fact |
| 119 | // we'd round 3 the other way |
| 120 | filter1 = signed_char_clamp(filter + 4) >> 3; |
| 121 | filter2 = signed_char_clamp(filter + 3) >> 3; |
| 122 | |
| 123 | *oq0 = signed_char_clamp(qs0 - filter1) ^ 0x80; |
| 124 | *op0 = signed_char_clamp(ps0 + filter2) ^ 0x80; |
| 125 | |
| 126 | // outer tap adjustments |
| 127 | filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev; |
| 128 | |
| 129 | *oq1 = signed_char_clamp(qs1 - filter) ^ 0x80; |
| 130 | *op1 = signed_char_clamp(ps1 + filter) ^ 0x80; |
| 131 | } |
| 132 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 133 | void aom_lpf_horizontal_4_c(uint8_t *s, int p /* pitch */, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 134 | const uint8_t *blimit, const uint8_t *limit, |
| 135 | const uint8_t *thresh) { |
| 136 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 137 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 138 | |
| 139 | // loop filter designed to work using chars so that we can make maximum use |
| 140 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 141 | for (i = 0; i < count; ++i) { |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 142 | const uint8_t p1 = s[-2 * p], p0 = s[-p]; |
| 143 | const uint8_t q0 = s[0 * p], q1 = s[1 * p]; |
| 144 | const int8_t mask = filter_mask2(*limit, *blimit, p1, p0, q0, q1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 145 | filter4(mask, *thresh, s - 2 * p, s - 1 * p, s, s + 1 * p); |
| 146 | ++s; |
| 147 | } |
| 148 | } |
| 149 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 150 | void aom_lpf_horizontal_4_dual_c(uint8_t *s, int p, const uint8_t *blimit0, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 151 | const uint8_t *limit0, const uint8_t *thresh0, |
| 152 | const uint8_t *blimit1, const uint8_t *limit1, |
| 153 | const uint8_t *thresh1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 154 | aom_lpf_horizontal_4_c(s, p, blimit0, limit0, thresh0); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 155 | aom_lpf_horizontal_4_c(s + 4, p, blimit1, limit1, thresh1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 158 | void aom_lpf_vertical_4_c(uint8_t *s, int pitch, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 159 | const uint8_t *limit, const uint8_t *thresh) { |
| 160 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 161 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 162 | |
| 163 | // loop filter designed to work using chars so that we can make maximum use |
| 164 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 165 | for (i = 0; i < count; ++i) { |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 166 | const uint8_t p1 = s[-2], p0 = s[-1]; |
| 167 | const uint8_t q0 = s[0], q1 = s[1]; |
| 168 | const int8_t mask = filter_mask2(*limit, *blimit, p1, p0, q0, q1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 169 | filter4(mask, *thresh, s - 2, s - 1, s, s + 1); |
| 170 | s += pitch; |
| 171 | } |
| 172 | } |
| 173 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 174 | void aom_lpf_vertical_4_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 175 | const uint8_t *limit0, const uint8_t *thresh0, |
| 176 | const uint8_t *blimit1, const uint8_t *limit1, |
| 177 | const uint8_t *thresh1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 178 | aom_lpf_vertical_4_c(s, pitch, blimit0, limit0, thresh0); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 179 | aom_lpf_vertical_4_c(s + 4 * pitch, pitch, blimit1, limit1, thresh1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 182 | static INLINE void filter6(int8_t mask, uint8_t thresh, int8_t flat, |
| 183 | uint8_t *op2, uint8_t *op1, uint8_t *op0, |
| 184 | uint8_t *oq0, uint8_t *oq1, uint8_t *oq2) { |
| 185 | if (flat && mask) { |
| 186 | const uint8_t p2 = *op2, p1 = *op1, p0 = *op0; |
| 187 | const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2; |
| 188 | |
| 189 | // 5-tap filter [1, 2, 2, 2, 1] |
| 190 | *op1 = ROUND_POWER_OF_TWO(p2 * 3 + p1 * 2 + p0 * 2 + q0, 3); |
| 191 | *op0 = ROUND_POWER_OF_TWO(p2 + p1 * 2 + p0 * 2 + q0 * 2 + q1, 3); |
| 192 | *oq0 = ROUND_POWER_OF_TWO(p1 + p0 * 2 + q0 * 2 + q1 * 2 + q2, 3); |
| 193 | *oq1 = ROUND_POWER_OF_TWO(p0 + q0 * 2 + q1 * 2 + q2 * 3, 3); |
| 194 | } else { |
| 195 | filter4(mask, thresh, op1, op0, oq0, oq1); |
| 196 | } |
| 197 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 198 | |
Cheng Chen | 60f5961 | 2017-05-25 15:08:41 -0700 | [diff] [blame] | 199 | static INLINE void filter8(int8_t mask, uint8_t thresh, int8_t flat, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 200 | uint8_t *op3, uint8_t *op2, uint8_t *op1, |
| 201 | uint8_t *op0, uint8_t *oq0, uint8_t *oq1, |
| 202 | uint8_t *oq2, uint8_t *oq3) { |
| 203 | if (flat && mask) { |
| 204 | const uint8_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0; |
| 205 | const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3; |
| 206 | |
| 207 | // 7-tap filter [1, 1, 1, 2, 1, 1, 1] |
| 208 | *op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3); |
| 209 | *op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3); |
| 210 | *op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3); |
| 211 | *oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3); |
| 212 | *oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3); |
| 213 | *oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3); |
| 214 | } else { |
| 215 | filter4(mask, thresh, op1, op0, oq0, oq1); |
| 216 | } |
| 217 | } |
| 218 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 219 | void aom_lpf_horizontal_6_c(uint8_t *s, int p, const uint8_t *blimit, |
| 220 | const uint8_t *limit, const uint8_t *thresh) { |
| 221 | int i; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 222 | int count = 4; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 223 | |
| 224 | // loop filter designed to work using chars so that we can make maximum use |
| 225 | // of 8 bit simd instructions. |
| 226 | for (i = 0; i < count; ++i) { |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 227 | const uint8_t p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p]; |
| 228 | const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p]; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 229 | |
| 230 | const int8_t mask = |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 231 | filter_mask3_chroma(*limit, *blimit, p2, p1, p0, q0, q1, q2); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 232 | const int8_t flat = flat_mask3_chroma(1, p2, p1, p0, q0, q1, q2); |
| 233 | filter6(mask, *thresh, flat, s - 3 * p, s - 2 * p, s - 1 * p, s, s + 1 * p, |
| 234 | s + 2 * p); |
| 235 | ++s; |
| 236 | } |
| 237 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 238 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 239 | void aom_lpf_horizontal_8_c(uint8_t *s, int p, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 240 | const uint8_t *limit, const uint8_t *thresh) { |
| 241 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 242 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 243 | |
| 244 | // loop filter designed to work using chars so that we can make maximum use |
| 245 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 246 | for (i = 0; i < count; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 247 | const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p]; |
| 248 | const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p]; |
| 249 | |
| 250 | const int8_t mask = |
| 251 | filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3); |
| 252 | const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3); |
| 253 | filter8(mask, *thresh, flat, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s, |
| 254 | s + 1 * p, s + 2 * p, s + 3 * p); |
| 255 | ++s; |
| 256 | } |
| 257 | } |
| 258 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 259 | void aom_lpf_horizontal_8_dual_c(uint8_t *s, int p, const uint8_t *blimit0, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 260 | const uint8_t *limit0, const uint8_t *thresh0, |
| 261 | const uint8_t *blimit1, const uint8_t *limit1, |
| 262 | const uint8_t *thresh1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 263 | aom_lpf_horizontal_8_c(s, p, blimit0, limit0, thresh0); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 264 | aom_lpf_horizontal_8_c(s + 4, p, blimit1, limit1, thresh1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 267 | void aom_lpf_vertical_6_c(uint8_t *s, int pitch, const uint8_t *blimit, |
| 268 | const uint8_t *limit, const uint8_t *thresh) { |
| 269 | int i; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 270 | int count = 4; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 271 | |
| 272 | for (i = 0; i < count; ++i) { |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 273 | const uint8_t p2 = s[-3], p1 = s[-2], p0 = s[-1]; |
| 274 | const uint8_t q0 = s[0], q1 = s[1], q2 = s[2]; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 275 | const int8_t mask = |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 276 | filter_mask3_chroma(*limit, *blimit, p2, p1, p0, q0, q1, q2); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 277 | const int8_t flat = flat_mask3_chroma(1, p2, p1, p0, q0, q1, q2); |
| 278 | filter6(mask, *thresh, flat, s - 3, s - 2, s - 1, s, s + 1, s + 2); |
| 279 | s += pitch; |
| 280 | } |
| 281 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 282 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 283 | void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 284 | const uint8_t *limit, const uint8_t *thresh) { |
| 285 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 286 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 287 | |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 288 | for (i = 0; i < count; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 289 | const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1]; |
| 290 | const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3]; |
| 291 | const int8_t mask = |
| 292 | filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3); |
| 293 | const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3); |
| 294 | filter8(mask, *thresh, flat, s - 4, s - 3, s - 2, s - 1, s, s + 1, s + 2, |
| 295 | s + 3); |
| 296 | s += pitch; |
| 297 | } |
| 298 | } |
| 299 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 300 | void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 301 | const uint8_t *limit0, const uint8_t *thresh0, |
| 302 | const uint8_t *blimit1, const uint8_t *limit1, |
| 303 | const uint8_t *thresh1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 304 | aom_lpf_vertical_8_c(s, pitch, blimit0, limit0, thresh0); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 305 | aom_lpf_vertical_8_c(s + 4 * pitch, pitch, blimit1, limit1, thresh1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 308 | static INLINE void filter14(int8_t mask, uint8_t thresh, int8_t flat, |
| 309 | int8_t flat2, uint8_t *op6, uint8_t *op5, |
| 310 | uint8_t *op4, uint8_t *op3, uint8_t *op2, |
| 311 | uint8_t *op1, uint8_t *op0, uint8_t *oq0, |
| 312 | uint8_t *oq1, uint8_t *oq2, uint8_t *oq3, |
| 313 | uint8_t *oq4, uint8_t *oq5, uint8_t *oq6) { |
| 314 | if (flat2 && flat && mask) { |
| 315 | const uint8_t p6 = *op6, p5 = *op5, p4 = *op4, p3 = *op3, p2 = *op2, |
| 316 | p1 = *op1, p0 = *op0; |
| 317 | const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3, q4 = *oq4, |
| 318 | q5 = *oq5, q6 = *oq6; |
| 319 | |
| 320 | // 13-tap filter [1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1] |
| 321 | *op5 = ROUND_POWER_OF_TWO(p6 * 7 + p5 * 2 + p4 * 2 + p3 + p2 + p1 + p0 + q0, |
| 322 | 4); |
| 323 | *op4 = ROUND_POWER_OF_TWO( |
| 324 | p6 * 5 + p5 * 2 + p4 * 2 + p3 * 2 + p2 + p1 + p0 + q0 + q1, 4); |
| 325 | *op3 = ROUND_POWER_OF_TWO( |
| 326 | p6 * 4 + p5 + p4 * 2 + p3 * 2 + p2 * 2 + p1 + p0 + q0 + q1 + q2, 4); |
| 327 | *op2 = ROUND_POWER_OF_TWO( |
| 328 | p6 * 3 + p5 + p4 + p3 * 2 + p2 * 2 + p1 * 2 + p0 + q0 + q1 + q2 + q3, |
| 329 | 4); |
| 330 | *op1 = ROUND_POWER_OF_TWO(p6 * 2 + p5 + p4 + p3 + p2 * 2 + p1 * 2 + p0 * 2 + |
| 331 | q0 + q1 + q2 + q3 + q4, |
| 332 | 4); |
| 333 | *op0 = ROUND_POWER_OF_TWO(p6 + p5 + p4 + p3 + p2 + p1 * 2 + p0 * 2 + |
| 334 | q0 * 2 + q1 + q2 + q3 + q4 + q5, |
| 335 | 4); |
| 336 | *oq0 = ROUND_POWER_OF_TWO(p5 + p4 + p3 + p2 + p1 + p0 * 2 + q0 * 2 + |
| 337 | q1 * 2 + q2 + q3 + q4 + q5 + q6, |
| 338 | 4); |
| 339 | *oq1 = ROUND_POWER_OF_TWO(p4 + p3 + p2 + p1 + p0 + q0 * 2 + q1 * 2 + |
| 340 | q2 * 2 + q3 + q4 + q5 + q6 * 2, |
| 341 | 4); |
| 342 | *oq2 = ROUND_POWER_OF_TWO( |
| 343 | p3 + p2 + p1 + p0 + q0 + q1 * 2 + q2 * 2 + q3 * 2 + q4 + q5 + q6 * 3, |
| 344 | 4); |
| 345 | *oq3 = ROUND_POWER_OF_TWO( |
| 346 | p2 + p1 + p0 + q0 + q1 + q2 * 2 + q3 * 2 + q4 * 2 + q5 + q6 * 4, 4); |
| 347 | *oq4 = ROUND_POWER_OF_TWO( |
| 348 | p1 + p0 + q0 + q1 + q2 + q3 * 2 + q4 * 2 + q5 * 2 + q6 * 5, 4); |
| 349 | *oq5 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + q2 + q3 + q4 * 2 + q5 * 2 + q6 * 7, |
| 350 | 4); |
| 351 | } else { |
| 352 | filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3); |
| 353 | } |
| 354 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 355 | |
| 356 | static void mb_lpf_horizontal_edge_w(uint8_t *s, int p, const uint8_t *blimit, |
| 357 | const uint8_t *limit, |
| 358 | const uint8_t *thresh, int count) { |
| 359 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 360 | int step = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 361 | |
| 362 | // loop filter designed to work using chars so that we can make maximum use |
| 363 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 364 | for (i = 0; i < step * count; ++i) { |
Yaowu Xu | cbfffa8 | 2018-02-12 15:04:57 -0800 | [diff] [blame] | 365 | const uint8_t p6 = s[-7 * p], p5 = s[-6 * p], p4 = s[-5 * p], |
| 366 | p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p]; |
Ryan Lei | dd6fa06 | 2017-04-13 12:05:33 -0700 | [diff] [blame] | 367 | const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p], |
Yaowu Xu | cbfffa8 | 2018-02-12 15:04:57 -0800 | [diff] [blame] | 368 | q4 = s[4 * p], q5 = s[5 * p], q6 = s[6 * p]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 369 | const int8_t mask = |
| 370 | filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3); |
| 371 | const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 372 | const int8_t flat2 = flat_mask4(1, p6, p5, p4, p0, q0, q4, q5, q6); |
| 373 | |
| 374 | filter14(mask, *thresh, flat, flat2, s - 7 * p, s - 6 * p, s - 5 * p, |
| 375 | s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s, s + 1 * p, |
| 376 | s + 2 * p, s + 3 * p, s + 4 * p, s + 5 * p, s + 6 * p); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 377 | ++s; |
| 378 | } |
| 379 | } |
| 380 | |
Ryan | 2680275 | 2018-02-20 10:29:05 -0800 | [diff] [blame] | 381 | void aom_lpf_horizontal_14_c(uint8_t *s, int p, const uint8_t *blimit, |
James Zern | 1dbe80b | 2017-11-22 20:59:44 -0800 | [diff] [blame] | 382 | const uint8_t *limit, const uint8_t *thresh) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 383 | mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1); |
| 384 | } |
| 385 | |
Cheng Chen | 85fea90 | 2018-05-17 18:58:20 -0700 | [diff] [blame] | 386 | void aom_lpf_horizontal_14_dual_c(uint8_t *s, int p, const uint8_t *blimit0, |
| 387 | const uint8_t *limit0, const uint8_t *thresh0, |
| 388 | const uint8_t *blimit1, const uint8_t *limit1, |
| 389 | const uint8_t *thresh1) { |
| 390 | mb_lpf_horizontal_edge_w(s, p, blimit0, limit0, thresh0, 1); |
| 391 | mb_lpf_horizontal_edge_w(s + 4, p, blimit1, limit1, thresh1, 1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | static void mb_lpf_vertical_edge_w(uint8_t *s, int p, const uint8_t *blimit, |
| 395 | const uint8_t *limit, const uint8_t *thresh, |
| 396 | int count) { |
| 397 | int i; |
| 398 | |
| 399 | for (i = 0; i < count; ++i) { |
Yaowu Xu | cbfffa8 | 2018-02-12 15:04:57 -0800 | [diff] [blame] | 400 | const uint8_t p6 = s[-7], p5 = s[-6], p4 = s[-5], p3 = s[-4], p2 = s[-3], |
| 401 | p1 = s[-2], p0 = s[-1]; |
Ryan Lei | dd6fa06 | 2017-04-13 12:05:33 -0700 | [diff] [blame] | 402 | const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3], q4 = s[4], |
Yaowu Xu | cbfffa8 | 2018-02-12 15:04:57 -0800 | [diff] [blame] | 403 | q5 = s[5], q6 = s[6]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 404 | const int8_t mask = |
| 405 | filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3); |
| 406 | const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 407 | const int8_t flat2 = flat_mask4(1, p6, p5, p4, p0, q0, q4, q5, q6); |
| 408 | |
| 409 | filter14(mask, *thresh, flat, flat2, s - 7, s - 6, s - 5, s - 4, s - 3, |
| 410 | s - 2, s - 1, s, s + 1, s + 2, s + 3, s + 4, s + 5, s + 6); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 411 | s += p; |
| 412 | } |
| 413 | } |
| 414 | |
Ryan | 2680275 | 2018-02-20 10:29:05 -0800 | [diff] [blame] | 415 | void aom_lpf_vertical_14_c(uint8_t *s, int p, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 416 | const uint8_t *limit, const uint8_t *thresh) { |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 417 | mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 4); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Cheng Chen | 85fea90 | 2018-05-17 18:58:20 -0700 | [diff] [blame] | 420 | void aom_lpf_vertical_14_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, |
| 421 | const uint8_t *limit0, const uint8_t *thresh0, |
| 422 | const uint8_t *blimit1, const uint8_t *limit1, |
| 423 | const uint8_t *thresh1) { |
| 424 | mb_lpf_vertical_edge_w(s, pitch, blimit0, limit0, thresh0, 4); |
| 425 | mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1, 4); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 426 | } |
| 427 | |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 428 | // Should we apply any filter at all: 11111111 yes, 00000000 no ? |
| 429 | static INLINE int8_t highbd_filter_mask2(uint8_t limit, uint8_t blimit, |
| 430 | uint16_t p1, uint16_t p0, uint16_t q0, |
| 431 | uint16_t q1, int bd) { |
| 432 | int8_t mask = 0; |
| 433 | int16_t limit16 = (uint16_t)limit << (bd - 8); |
| 434 | int16_t blimit16 = (uint16_t)blimit << (bd - 8); |
| 435 | mask |= (abs(p1 - p0) > limit16) * -1; |
| 436 | mask |= (abs(q1 - q0) > limit16) * -1; |
| 437 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit16) * -1; |
| 438 | return ~mask; |
| 439 | } |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 440 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 441 | // Should we apply any filter at all: 11111111 yes, 00000000 no ? |
| 442 | static INLINE int8_t highbd_filter_mask(uint8_t limit, uint8_t blimit, |
| 443 | uint16_t p3, uint16_t p2, uint16_t p1, |
| 444 | uint16_t p0, uint16_t q0, uint16_t q1, |
| 445 | uint16_t q2, uint16_t q3, int bd) { |
| 446 | int8_t mask = 0; |
| 447 | int16_t limit16 = (uint16_t)limit << (bd - 8); |
| 448 | int16_t blimit16 = (uint16_t)blimit << (bd - 8); |
| 449 | mask |= (abs(p3 - p2) > limit16) * -1; |
| 450 | mask |= (abs(p2 - p1) > limit16) * -1; |
| 451 | mask |= (abs(p1 - p0) > limit16) * -1; |
| 452 | mask |= (abs(q1 - q0) > limit16) * -1; |
| 453 | mask |= (abs(q2 - q1) > limit16) * -1; |
| 454 | mask |= (abs(q3 - q2) > limit16) * -1; |
| 455 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit16) * -1; |
| 456 | return ~mask; |
| 457 | } |
| 458 | |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 459 | static INLINE int8_t highbd_filter_mask3_chroma(uint8_t limit, uint8_t blimit, |
| 460 | uint16_t p2, uint16_t p1, |
| 461 | uint16_t p0, uint16_t q0, |
| 462 | uint16_t q1, uint16_t q2, |
| 463 | int bd) { |
| 464 | int8_t mask = 0; |
| 465 | int16_t limit16 = (uint16_t)limit << (bd - 8); |
| 466 | int16_t blimit16 = (uint16_t)blimit << (bd - 8); |
| 467 | mask |= (abs(p2 - p1) > limit16) * -1; |
| 468 | mask |= (abs(p1 - p0) > limit16) * -1; |
| 469 | mask |= (abs(q1 - q0) > limit16) * -1; |
| 470 | mask |= (abs(q2 - q1) > limit16) * -1; |
| 471 | mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit16) * -1; |
| 472 | return ~mask; |
| 473 | } |
| 474 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 475 | static INLINE int8_t highbd_flat_mask3_chroma(uint8_t thresh, uint16_t p2, |
| 476 | uint16_t p1, uint16_t p0, |
| 477 | uint16_t q0, uint16_t q1, |
| 478 | uint16_t q2, int bd) { |
| 479 | int8_t mask = 0; |
| 480 | int16_t thresh16 = (uint16_t)thresh << (bd - 8); |
| 481 | mask |= (abs(p1 - p0) > thresh16) * -1; |
| 482 | mask |= (abs(q1 - q0) > thresh16) * -1; |
| 483 | mask |= (abs(p2 - p0) > thresh16) * -1; |
| 484 | mask |= (abs(q2 - q0) > thresh16) * -1; |
| 485 | return ~mask; |
| 486 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 487 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 488 | static INLINE int8_t highbd_flat_mask4(uint8_t thresh, uint16_t p3, uint16_t p2, |
| 489 | uint16_t p1, uint16_t p0, uint16_t q0, |
| 490 | uint16_t q1, uint16_t q2, uint16_t q3, |
| 491 | int bd) { |
| 492 | int8_t mask = 0; |
| 493 | int16_t thresh16 = (uint16_t)thresh << (bd - 8); |
| 494 | mask |= (abs(p1 - p0) > thresh16) * -1; |
| 495 | mask |= (abs(q1 - q0) > thresh16) * -1; |
| 496 | mask |= (abs(p2 - p0) > thresh16) * -1; |
| 497 | mask |= (abs(q2 - q0) > thresh16) * -1; |
| 498 | mask |= (abs(p3 - p0) > thresh16) * -1; |
| 499 | mask |= (abs(q3 - q0) > thresh16) * -1; |
| 500 | return ~mask; |
| 501 | } |
| 502 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 503 | // Is there high edge variance internal edge: |
| 504 | // 11111111_11111111 yes, 00000000_00000000 no ? |
| 505 | static INLINE int16_t highbd_hev_mask(uint8_t thresh, uint16_t p1, uint16_t p0, |
| 506 | uint16_t q0, uint16_t q1, int bd) { |
| 507 | int16_t hev = 0; |
| 508 | int16_t thresh16 = (uint16_t)thresh << (bd - 8); |
| 509 | hev |= (abs(p1 - p0) > thresh16) * -1; |
| 510 | hev |= (abs(q1 - q0) > thresh16) * -1; |
| 511 | return hev; |
| 512 | } |
| 513 | |
| 514 | static INLINE void highbd_filter4(int8_t mask, uint8_t thresh, uint16_t *op1, |
| 515 | uint16_t *op0, uint16_t *oq0, uint16_t *oq1, |
| 516 | int bd) { |
| 517 | int16_t filter1, filter2; |
| 518 | // ^0x80 equivalent to subtracting 0x80 from the values to turn them |
| 519 | // into -128 to +127 instead of 0 to 255. |
| 520 | int shift = bd - 8; |
| 521 | const int16_t ps1 = (int16_t)*op1 - (0x80 << shift); |
| 522 | const int16_t ps0 = (int16_t)*op0 - (0x80 << shift); |
| 523 | const int16_t qs0 = (int16_t)*oq0 - (0x80 << shift); |
| 524 | const int16_t qs1 = (int16_t)*oq1 - (0x80 << shift); |
| 525 | const uint16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd); |
| 526 | |
| 527 | // Add outer taps if we have high edge variance. |
| 528 | int16_t filter = signed_char_clamp_high(ps1 - qs1, bd) & hev; |
| 529 | |
| 530 | // Inner taps. |
| 531 | filter = signed_char_clamp_high(filter + 3 * (qs0 - ps0), bd) & mask; |
| 532 | |
| 533 | // Save bottom 3 bits so that we round one side +4 and the other +3 |
| 534 | // if it equals 4 we'll set to adjust by -1 to account for the fact |
| 535 | // we'd round 3 the other way. |
| 536 | filter1 = signed_char_clamp_high(filter + 4, bd) >> 3; |
| 537 | filter2 = signed_char_clamp_high(filter + 3, bd) >> 3; |
| 538 | |
| 539 | *oq0 = signed_char_clamp_high(qs0 - filter1, bd) + (0x80 << shift); |
| 540 | *op0 = signed_char_clamp_high(ps0 + filter2, bd) + (0x80 << shift); |
| 541 | |
| 542 | // Outer tap adjustments. |
| 543 | filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev; |
| 544 | |
| 545 | *oq1 = signed_char_clamp_high(qs1 - filter, bd) + (0x80 << shift); |
| 546 | *op1 = signed_char_clamp_high(ps1 + filter, bd) + (0x80 << shift); |
| 547 | } |
| 548 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 549 | void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int p /* pitch */, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 550 | const uint8_t *blimit, const uint8_t *limit, |
| 551 | const uint8_t *thresh, int bd) { |
| 552 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 553 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 554 | |
| 555 | // loop filter designed to work using chars so that we can make maximum use |
| 556 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 557 | for (i = 0; i < count; ++i) { |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 558 | const uint16_t p1 = s[-2 * p]; |
| 559 | const uint16_t p0 = s[-p]; |
| 560 | const uint16_t q0 = s[0 * p]; |
| 561 | const uint16_t q1 = s[1 * p]; |
| 562 | const int8_t mask = |
| 563 | highbd_filter_mask2(*limit, *blimit, p1, p0, q0, q1, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 564 | highbd_filter4(mask, *thresh, s - 2 * p, s - 1 * p, s, s + 1 * p, bd); |
| 565 | ++s; |
| 566 | } |
| 567 | } |
| 568 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 569 | void aom_highbd_lpf_horizontal_4_dual_c( |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 570 | uint16_t *s, int p, const uint8_t *blimit0, const uint8_t *limit0, |
| 571 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 572 | const uint8_t *thresh1, int bd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 573 | aom_highbd_lpf_horizontal_4_c(s, p, blimit0, limit0, thresh0, bd); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 574 | aom_highbd_lpf_horizontal_4_c(s + 4, p, blimit1, limit1, thresh1, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 577 | void aom_highbd_lpf_vertical_4_c(uint16_t *s, int pitch, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 578 | const uint8_t *limit, const uint8_t *thresh, |
| 579 | int bd) { |
| 580 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 581 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 582 | |
| 583 | // loop filter designed to work using chars so that we can make maximum use |
| 584 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 585 | for (i = 0; i < count; ++i) { |
Ryan Lei | 392d0ff | 2017-02-09 13:05:42 -0800 | [diff] [blame] | 586 | const uint16_t p1 = s[-2], p0 = s[-1]; |
| 587 | const uint16_t q0 = s[0], q1 = s[1]; |
| 588 | const int8_t mask = |
| 589 | highbd_filter_mask2(*limit, *blimit, p1, p0, q0, q1, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 590 | highbd_filter4(mask, *thresh, s - 2, s - 1, s, s + 1, bd); |
| 591 | s += pitch; |
| 592 | } |
| 593 | } |
| 594 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 595 | void aom_highbd_lpf_vertical_4_dual_c( |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 596 | uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, |
| 597 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 598 | const uint8_t *thresh1, int bd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 599 | aom_highbd_lpf_vertical_4_c(s, pitch, blimit0, limit0, thresh0, bd); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 600 | aom_highbd_lpf_vertical_4_c(s + 4 * pitch, pitch, blimit1, limit1, thresh1, |
| 601 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 602 | } |
| 603 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 604 | static INLINE void highbd_filter6(int8_t mask, uint8_t thresh, int8_t flat, |
| 605 | uint16_t *op2, uint16_t *op1, uint16_t *op0, |
| 606 | uint16_t *oq0, uint16_t *oq1, uint16_t *oq2, |
| 607 | int bd) { |
| 608 | if (flat && mask) { |
| 609 | const uint16_t p2 = *op2, p1 = *op1, p0 = *op0; |
| 610 | const uint16_t q0 = *oq0, q1 = *oq1, q2 = *oq2; |
| 611 | |
| 612 | // 5-tap filter [1, 2, 2, 2, 1] |
| 613 | *op1 = ROUND_POWER_OF_TWO(p2 * 3 + p1 * 2 + p0 * 2 + q0, 3); |
| 614 | *op0 = ROUND_POWER_OF_TWO(p2 + p1 * 2 + p0 * 2 + q0 * 2 + q1, 3); |
| 615 | *oq0 = ROUND_POWER_OF_TWO(p1 + p0 * 2 + q0 * 2 + q1 * 2 + q2, 3); |
| 616 | *oq1 = ROUND_POWER_OF_TWO(p0 + q0 * 2 + q1 * 2 + q2 * 3, 3); |
| 617 | } else { |
| 618 | highbd_filter4(mask, thresh, op1, op0, oq0, oq1, bd); |
| 619 | } |
| 620 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 621 | |
Cheng Chen | 60f5961 | 2017-05-25 15:08:41 -0700 | [diff] [blame] | 622 | static INLINE void highbd_filter8(int8_t mask, uint8_t thresh, int8_t flat, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 623 | uint16_t *op3, uint16_t *op2, uint16_t *op1, |
| 624 | uint16_t *op0, uint16_t *oq0, uint16_t *oq1, |
| 625 | uint16_t *oq2, uint16_t *oq3, int bd) { |
| 626 | if (flat && mask) { |
| 627 | const uint16_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0; |
| 628 | const uint16_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3; |
| 629 | |
| 630 | // 7-tap filter [1, 1, 1, 2, 1, 1, 1] |
| 631 | *op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3); |
| 632 | *op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3); |
| 633 | *op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3); |
| 634 | *oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3); |
| 635 | *oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3); |
| 636 | *oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3); |
| 637 | } else { |
| 638 | highbd_filter4(mask, thresh, op1, op0, oq0, oq1, bd); |
| 639 | } |
| 640 | } |
| 641 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 642 | void aom_highbd_lpf_horizontal_8_c(uint16_t *s, int p, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 643 | const uint8_t *limit, const uint8_t *thresh, |
| 644 | int bd) { |
| 645 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 646 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 647 | |
| 648 | // loop filter designed to work using chars so that we can make maximum use |
| 649 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 650 | for (i = 0; i < count; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 651 | const uint16_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p]; |
| 652 | const uint16_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p]; |
| 653 | |
| 654 | const int8_t mask = |
| 655 | highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 656 | const int8_t flat = |
| 657 | highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 658 | highbd_filter8(mask, *thresh, flat, s - 4 * p, s - 3 * p, s - 2 * p, |
| 659 | s - 1 * p, s, s + 1 * p, s + 2 * p, s + 3 * p, bd); |
| 660 | ++s; |
| 661 | } |
| 662 | } |
| 663 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 664 | void aom_highbd_lpf_horizontal_6_c(uint16_t *s, int p, const uint8_t *blimit, |
| 665 | const uint8_t *limit, const uint8_t *thresh, |
| 666 | int bd) { |
| 667 | int i; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 668 | int count = 4; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 669 | |
| 670 | // loop filter designed to work using chars so that we can make maximum use |
| 671 | // of 8 bit simd instructions. |
| 672 | for (i = 0; i < count; ++i) { |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 673 | const uint16_t p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p]; |
| 674 | const uint16_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p]; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 675 | |
| 676 | const int8_t mask = |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 677 | highbd_filter_mask3_chroma(*limit, *blimit, p2, p1, p0, q0, q1, q2, bd); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 678 | const int8_t flat = highbd_flat_mask3_chroma(1, p2, p1, p0, q0, q1, q2, bd); |
| 679 | highbd_filter6(mask, *thresh, flat, s - 3 * p, s - 2 * p, s - 1 * p, s, |
| 680 | s + 1 * p, s + 2 * p, bd); |
| 681 | ++s; |
| 682 | } |
| 683 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 684 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 685 | void aom_highbd_lpf_horizontal_8_dual_c( |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 686 | uint16_t *s, int p, const uint8_t *blimit0, const uint8_t *limit0, |
| 687 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 688 | const uint8_t *thresh1, int bd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 689 | aom_highbd_lpf_horizontal_8_c(s, p, blimit0, limit0, thresh0, bd); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 690 | aom_highbd_lpf_horizontal_8_c(s + 4, p, blimit1, limit1, thresh1, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 691 | } |
| 692 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 693 | void aom_highbd_lpf_vertical_6_c(uint16_t *s, int pitch, const uint8_t *blimit, |
| 694 | const uint8_t *limit, const uint8_t *thresh, |
| 695 | int bd) { |
| 696 | int i; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 697 | int count = 4; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 698 | |
| 699 | for (i = 0; i < count; ++i) { |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 700 | const uint16_t p2 = s[-3], p1 = s[-2], p0 = s[-1]; |
| 701 | const uint16_t q0 = s[0], q1 = s[1], q2 = s[2]; |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 702 | const int8_t mask = |
Ryan | 0c90a5b | 2018-01-02 10:10:45 -0800 | [diff] [blame] | 703 | highbd_filter_mask3_chroma(*limit, *blimit, p2, p1, p0, q0, q1, q2, bd); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 704 | const int8_t flat = highbd_flat_mask3_chroma(1, p2, p1, p0, q0, q1, q2, bd); |
| 705 | highbd_filter6(mask, *thresh, flat, s - 3, s - 2, s - 1, s, s + 1, s + 2, |
| 706 | bd); |
| 707 | s += pitch; |
| 708 | } |
| 709 | } |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 710 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 711 | void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 712 | const uint8_t *limit, const uint8_t *thresh, |
| 713 | int bd) { |
| 714 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 715 | int count = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 716 | |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 717 | for (i = 0; i < count; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 718 | const uint16_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1]; |
| 719 | const uint16_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3]; |
| 720 | const int8_t mask = |
| 721 | highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 722 | const int8_t flat = |
| 723 | highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 724 | highbd_filter8(mask, *thresh, flat, s - 4, s - 3, s - 2, s - 1, s, s + 1, |
| 725 | s + 2, s + 3, bd); |
| 726 | s += pitch; |
| 727 | } |
| 728 | } |
| 729 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 730 | void aom_highbd_lpf_vertical_8_dual_c( |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 731 | uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, |
| 732 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 733 | const uint8_t *thresh1, int bd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 734 | aom_highbd_lpf_vertical_8_c(s, pitch, blimit0, limit0, thresh0, bd); |
Yi Luo | 771a80a | 2017-11-27 15:31:31 -0800 | [diff] [blame] | 735 | aom_highbd_lpf_vertical_8_c(s + 4 * pitch, pitch, blimit1, limit1, thresh1, |
| 736 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 737 | } |
| 738 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 739 | static INLINE void highbd_filter14(int8_t mask, uint8_t thresh, int8_t flat, |
| 740 | int8_t flat2, uint16_t *op6, uint16_t *op5, |
| 741 | uint16_t *op4, uint16_t *op3, uint16_t *op2, |
| 742 | uint16_t *op1, uint16_t *op0, uint16_t *oq0, |
| 743 | uint16_t *oq1, uint16_t *oq2, uint16_t *oq3, |
| 744 | uint16_t *oq4, uint16_t *oq5, uint16_t *oq6, |
| 745 | int bd) { |
| 746 | if (flat2 && flat && mask) { |
| 747 | const uint16_t p6 = *op6; |
| 748 | const uint16_t p5 = *op5; |
| 749 | const uint16_t p4 = *op4; |
| 750 | const uint16_t p3 = *op3; |
| 751 | const uint16_t p2 = *op2; |
| 752 | const uint16_t p1 = *op1; |
| 753 | const uint16_t p0 = *op0; |
| 754 | const uint16_t q0 = *oq0; |
| 755 | const uint16_t q1 = *oq1; |
| 756 | const uint16_t q2 = *oq2; |
| 757 | const uint16_t q3 = *oq3; |
| 758 | const uint16_t q4 = *oq4; |
| 759 | const uint16_t q5 = *oq5; |
| 760 | const uint16_t q6 = *oq6; |
| 761 | |
| 762 | // 13-tap filter [1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1] |
| 763 | *op5 = ROUND_POWER_OF_TWO(p6 * 7 + p5 * 2 + p4 * 2 + p3 + p2 + p1 + p0 + q0, |
| 764 | 4); |
| 765 | *op4 = ROUND_POWER_OF_TWO( |
| 766 | p6 * 5 + p5 * 2 + p4 * 2 + p3 * 2 + p2 + p1 + p0 + q0 + q1, 4); |
| 767 | *op3 = ROUND_POWER_OF_TWO( |
| 768 | p6 * 4 + p5 + p4 * 2 + p3 * 2 + p2 * 2 + p1 + p0 + q0 + q1 + q2, 4); |
| 769 | *op2 = ROUND_POWER_OF_TWO( |
| 770 | p6 * 3 + p5 + p4 + p3 * 2 + p2 * 2 + p1 * 2 + p0 + q0 + q1 + q2 + q3, |
| 771 | 4); |
| 772 | *op1 = ROUND_POWER_OF_TWO(p6 * 2 + p5 + p4 + p3 + p2 * 2 + p1 * 2 + p0 * 2 + |
| 773 | q0 + q1 + q2 + q3 + q4, |
| 774 | 4); |
| 775 | *op0 = ROUND_POWER_OF_TWO(p6 + p5 + p4 + p3 + p2 + p1 * 2 + p0 * 2 + |
| 776 | q0 * 2 + q1 + q2 + q3 + q4 + q5, |
| 777 | 4); |
| 778 | *oq0 = ROUND_POWER_OF_TWO(p5 + p4 + p3 + p2 + p1 + p0 * 2 + q0 * 2 + |
| 779 | q1 * 2 + q2 + q3 + q4 + q5 + q6, |
| 780 | 4); |
| 781 | *oq1 = ROUND_POWER_OF_TWO(p4 + p3 + p2 + p1 + p0 + q0 * 2 + q1 * 2 + |
| 782 | q2 * 2 + q3 + q4 + q5 + q6 * 2, |
| 783 | 4); |
| 784 | *oq2 = ROUND_POWER_OF_TWO( |
| 785 | p3 + p2 + p1 + p0 + q0 + q1 * 2 + q2 * 2 + q3 * 2 + q4 + q5 + q6 * 3, |
| 786 | 4); |
| 787 | *oq3 = ROUND_POWER_OF_TWO( |
| 788 | p2 + p1 + p0 + q0 + q1 + q2 * 2 + q3 * 2 + q4 * 2 + q5 + q6 * 4, 4); |
| 789 | *oq4 = ROUND_POWER_OF_TWO( |
| 790 | p1 + p0 + q0 + q1 + q2 + q3 * 2 + q4 * 2 + q5 * 2 + q6 * 5, 4); |
| 791 | *oq5 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + q2 + q3 + q4 * 2 + q5 * 2 + q6 * 7, |
| 792 | 4); |
| 793 | } else { |
| 794 | highbd_filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3, |
| 795 | bd); |
| 796 | } |
| 797 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 798 | |
| 799 | static void highbd_mb_lpf_horizontal_edge_w(uint16_t *s, int p, |
| 800 | const uint8_t *blimit, |
| 801 | const uint8_t *limit, |
| 802 | const uint8_t *thresh, int count, |
| 803 | int bd) { |
| 804 | int i; |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 805 | int step = 4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 806 | |
| 807 | // loop filter designed to work using chars so that we can make maximum use |
| 808 | // of 8 bit simd instructions. |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 809 | for (i = 0; i < step * count; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 810 | const uint16_t p3 = s[-4 * p]; |
| 811 | const uint16_t p2 = s[-3 * p]; |
| 812 | const uint16_t p1 = s[-2 * p]; |
| 813 | const uint16_t p0 = s[-p]; |
| 814 | const uint16_t q0 = s[0 * p]; |
| 815 | const uint16_t q1 = s[1 * p]; |
| 816 | const uint16_t q2 = s[2 * p]; |
| 817 | const uint16_t q3 = s[3 * p]; |
| 818 | const int8_t mask = |
| 819 | highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 820 | const int8_t flat = |
| 821 | highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 822 | |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 823 | const int8_t flat2 = |
| 824 | highbd_flat_mask4(1, s[-7 * p], s[-6 * p], s[-5 * p], p0, q0, s[4 * p], |
| 825 | s[5 * p], s[6 * p], bd); |
| 826 | |
| 827 | highbd_filter14(mask, *thresh, flat, flat2, s - 7 * p, s - 6 * p, s - 5 * p, |
| 828 | s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s, s + 1 * p, |
| 829 | s + 2 * p, s + 3 * p, s + 4 * p, s + 5 * p, s + 6 * p, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 830 | ++s; |
| 831 | } |
| 832 | } |
| 833 | |
Ryan | 2680275 | 2018-02-20 10:29:05 -0800 | [diff] [blame] | 834 | void aom_highbd_lpf_horizontal_14_c(uint16_t *s, int p, const uint8_t *blimit, |
James Zern | 684b7bd | 2017-11-28 12:55:51 -0800 | [diff] [blame] | 835 | const uint8_t *limit, const uint8_t *thresh, |
| 836 | int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 837 | highbd_mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1, bd); |
| 838 | } |
| 839 | |
Cheng Chen | 85fea90 | 2018-05-17 18:58:20 -0700 | [diff] [blame] | 840 | void aom_highbd_lpf_horizontal_14_dual_c( |
| 841 | uint16_t *s, int p, const uint8_t *blimit0, const uint8_t *limit0, |
| 842 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 843 | const uint8_t *thresh1, int bd) { |
| 844 | highbd_mb_lpf_horizontal_edge_w(s, p, blimit0, limit0, thresh0, 1, bd); |
| 845 | highbd_mb_lpf_horizontal_edge_w(s + 4, p, blimit1, limit1, thresh1, 1, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | static void highbd_mb_lpf_vertical_edge_w(uint16_t *s, int p, |
| 849 | const uint8_t *blimit, |
| 850 | const uint8_t *limit, |
| 851 | const uint8_t *thresh, int count, |
| 852 | int bd) { |
| 853 | int i; |
| 854 | |
| 855 | for (i = 0; i < count; ++i) { |
| 856 | const uint16_t p3 = s[-4]; |
| 857 | const uint16_t p2 = s[-3]; |
| 858 | const uint16_t p1 = s[-2]; |
| 859 | const uint16_t p0 = s[-1]; |
| 860 | const uint16_t q0 = s[0]; |
| 861 | const uint16_t q1 = s[1]; |
| 862 | const uint16_t q2 = s[2]; |
| 863 | const uint16_t q3 = s[3]; |
| 864 | const int8_t mask = |
| 865 | highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
| 866 | const int8_t flat = |
| 867 | highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd); |
Ola Hugosson | 4ce8521 | 2017-09-12 14:53:13 +0200 | [diff] [blame] | 868 | const int8_t flat2 = |
| 869 | highbd_flat_mask4(1, s[-7], s[-6], s[-5], p0, q0, s[4], s[5], s[6], bd); |
| 870 | |
| 871 | highbd_filter14(mask, *thresh, flat, flat2, s - 7, s - 6, s - 5, s - 4, |
| 872 | s - 3, s - 2, s - 1, s, s + 1, s + 2, s + 3, s + 4, s + 5, |
| 873 | s + 6, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 874 | s += p; |
| 875 | } |
| 876 | } |
| 877 | |
Ryan | 2680275 | 2018-02-20 10:29:05 -0800 | [diff] [blame] | 878 | void aom_highbd_lpf_vertical_14_c(uint16_t *s, int p, const uint8_t *blimit, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 879 | const uint8_t *limit, const uint8_t *thresh, |
| 880 | int bd) { |
Ryan Lei | 17905ed | 2017-05-23 18:28:51 -0700 | [diff] [blame] | 881 | highbd_mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 4, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 882 | } |
| 883 | |
Cheng Chen | 85fea90 | 2018-05-17 18:58:20 -0700 | [diff] [blame] | 884 | void aom_highbd_lpf_vertical_14_dual_c( |
| 885 | uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, |
| 886 | const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, |
| 887 | const uint8_t *thresh1, int bd) { |
| 888 | highbd_mb_lpf_vertical_edge_w(s, pitch, blimit0, limit0, thresh0, 4, bd); |
| 889 | highbd_mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1, |
| 890 | 4, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 891 | } |