1 /* 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include <arm_neon.h> 12 13 #include "./vpx_config.h" 14 #include "./vpx_dsp_rtcd.h" 15 #include "vpx/vpx_integer.h" 16 17 //------------------------------------------------------------------------------ 18 // DC 4x4 19 20 static INLINE uint16x4_t dc_sum_4(const uint8_t *ref) { 21 const uint8x8_t ref_u8 = vld1_u8(ref); 22 const uint16x4_t p0 = vpaddl_u8(ref_u8); 23 return vpadd_u16(p0, p0); 24 } 25 26 static INLINE void dc_store_4x4(uint8_t *dst, ptrdiff_t stride, 27 const uint8x8_t dc) { 28 const uint8x8_t dc_dup = vdup_lane_u8(dc, 0); 29 int i; 30 for (i = 0; i < 4; ++i, dst += stride) { 31 vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(dc_dup), 0); 32 } 33 } 34 35 void vpx_dc_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 36 const uint8_t *above, const uint8_t *left) { 37 const uint8x8_t a = vld1_u8(above); 38 const uint8x8_t l = vld1_u8(left); 39 const uint16x8_t al = vaddl_u8(a, l); 40 uint16x4_t sum; 41 uint8x8_t dc; 42 sum = vpadd_u16(vget_low_u16(al), vget_low_u16(al)); 43 sum = vpadd_u16(sum, sum); 44 dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 3)); 45 dc_store_4x4(dst, stride, dc); 46 } 47 48 void vpx_dc_left_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 49 const uint8_t *above, const uint8_t *left) { 50 const uint16x4_t sum = dc_sum_4(left); 51 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 2)); 52 (void)above; 53 dc_store_4x4(dst, stride, dc); 54 } 55 56 void vpx_dc_top_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 57 const uint8_t *above, const uint8_t *left) { 58 const uint16x4_t sum = dc_sum_4(above); 59 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 2)); 60 (void)left; 61 dc_store_4x4(dst, stride, dc); 62 } 63 64 void vpx_dc_128_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 65 const uint8_t *above, const uint8_t *left) { 66 const uint8x8_t dc = vdup_n_u8(0x80); 67 (void)above; 68 (void)left; 69 dc_store_4x4(dst, stride, dc); 70 } 71 72 //------------------------------------------------------------------------------ 73 // DC 8x8 74 75 static INLINE uint16x4_t dc_sum_8(const uint8_t *ref) { 76 const uint8x8_t ref_u8 = vld1_u8(ref); 77 uint16x4_t sum = vpaddl_u8(ref_u8); 78 sum = vpadd_u16(sum, sum); 79 return vpadd_u16(sum, sum); 80 } 81 82 static INLINE void dc_store_8x8(uint8_t *dst, ptrdiff_t stride, 83 const uint8x8_t dc) { 84 const uint8x8_t dc_dup = vdup_lane_u8(dc, 0); 85 int i; 86 for (i = 0; i < 8; ++i, dst += stride) { 87 vst1_u8(dst, dc_dup); 88 } 89 } 90 91 void vpx_dc_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 92 const uint8_t *above, const uint8_t *left) { 93 const uint8x8_t above_u8 = vld1_u8(above); 94 const uint8x8_t left_u8 = vld1_u8(left); 95 const uint8x16_t above_and_left = vcombine_u8(above_u8, left_u8); 96 const uint16x8_t p0 = vpaddlq_u8(above_and_left); 97 uint16x4_t sum = vadd_u16(vget_low_u16(p0), vget_high_u16(p0)); 98 uint8x8_t dc; 99 sum = vpadd_u16(sum, sum); 100 sum = vpadd_u16(sum, sum); 101 dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 4)); 102 dc_store_8x8(dst, stride, dc); 103 } 104 105 void vpx_dc_left_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 106 const uint8_t *above, const uint8_t *left) { 107 const uint16x4_t sum = dc_sum_8(left); 108 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 3)); 109 (void)above; 110 dc_store_8x8(dst, stride, dc); 111 } 112 113 void vpx_dc_top_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 114 const uint8_t *above, const uint8_t *left) { 115 const uint16x4_t sum = dc_sum_8(above); 116 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 3)); 117 (void)left; 118 dc_store_8x8(dst, stride, dc); 119 } 120 121 void vpx_dc_128_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 122 const uint8_t *above, const uint8_t *left) { 123 const uint8x8_t dc = vdup_n_u8(0x80); 124 (void)above; 125 (void)left; 126 dc_store_8x8(dst, stride, dc); 127 } 128 129 //------------------------------------------------------------------------------ 130 // DC 16x16 131 132 static INLINE uint16x4_t dc_sum_16(const uint8_t *ref) { 133 const uint8x16_t ref_u8 = vld1q_u8(ref); 134 const uint16x8_t p0 = vpaddlq_u8(ref_u8); 135 uint16x4_t sum = vadd_u16(vget_low_u16(p0), vget_high_u16(p0)); 136 sum = vpadd_u16(sum, sum); 137 return vpadd_u16(sum, sum); 138 } 139 140 static INLINE void dc_store_16x16(uint8_t *dst, ptrdiff_t stride, 141 const uint8x8_t dc) { 142 const uint8x16_t dc_dup = vdupq_lane_u8(dc, 0); 143 int i; 144 for (i = 0; i < 16; ++i, dst += stride) { 145 vst1q_u8(dst, dc_dup); 146 } 147 } 148 149 void vpx_dc_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 150 const uint8_t *above, const uint8_t *left) { 151 const uint8x16_t ref0 = vld1q_u8(above); 152 const uint8x16_t ref1 = vld1q_u8(left); 153 const uint16x8_t p0 = vpaddlq_u8(ref0); 154 const uint16x8_t p1 = vpaddlq_u8(ref1); 155 const uint16x8_t p2 = vaddq_u16(p0, p1); 156 uint16x4_t sum = vadd_u16(vget_low_u16(p2), vget_high_u16(p2)); 157 uint8x8_t dc; 158 sum = vpadd_u16(sum, sum); 159 sum = vpadd_u16(sum, sum); 160 dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 5)); 161 dc_store_16x16(dst, stride, dc); 162 } 163 164 void vpx_dc_left_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 165 const uint8_t *above, 166 const uint8_t *left) { 167 const uint16x4_t sum = dc_sum_16(left); 168 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 4)); 169 (void)above; 170 dc_store_16x16(dst, stride, dc); 171 } 172 173 void vpx_dc_top_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 174 const uint8_t *above, 175 const uint8_t *left) { 176 const uint16x4_t sum = dc_sum_16(above); 177 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 4)); 178 (void)left; 179 dc_store_16x16(dst, stride, dc); 180 } 181 182 void vpx_dc_128_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 183 const uint8_t *above, 184 const uint8_t *left) { 185 const uint8x8_t dc = vdup_n_u8(0x80); 186 (void)above; 187 (void)left; 188 dc_store_16x16(dst, stride, dc); 189 } 190 191 //------------------------------------------------------------------------------ 192 // DC 32x32 193 194 static INLINE uint16x4_t dc_sum_32(const uint8_t *ref) { 195 const uint8x16x2_t r = vld2q_u8(ref); 196 const uint16x8_t p0 = vpaddlq_u8(r.val[0]); 197 const uint16x8_t p1 = vpaddlq_u8(r.val[1]); 198 const uint16x8_t p2 = vaddq_u16(p0, p1); 199 uint16x4_t sum = vadd_u16(vget_low_u16(p2), vget_high_u16(p2)); 200 sum = vpadd_u16(sum, sum); 201 return vpadd_u16(sum, sum); 202 } 203 204 static INLINE void dc_store_32x32(uint8_t *dst, ptrdiff_t stride, 205 const uint8x8_t dc) { 206 uint8x16x2_t dc_dup; 207 int i; 208 dc_dup.val[0] = dc_dup.val[1] = vdupq_lane_u8(dc, 0); 209 210 for (i = 0; i < 32; ++i, dst += stride) { 211 vst2q_u8(dst, dc_dup); 212 } 213 } 214 215 void vpx_dc_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 216 const uint8_t *above, const uint8_t *left) { 217 const uint8x16x2_t a = vld2q_u8(above); 218 const uint8x16x2_t l = vld2q_u8(left); 219 const uint16x8_t pa0 = vpaddlq_u8(a.val[0]); 220 const uint16x8_t pl0 = vpaddlq_u8(l.val[0]); 221 const uint16x8_t pa1 = vpaddlq_u8(a.val[1]); 222 const uint16x8_t pl1 = vpaddlq_u8(l.val[1]); 223 const uint16x8_t pa = vaddq_u16(pa0, pa1); 224 const uint16x8_t pl = vaddq_u16(pl0, pl1); 225 const uint16x8_t pal = vaddq_u16(pa, pl); 226 uint16x4_t sum = vadd_u16(vget_low_u16(pal), vget_high_u16(pal)); 227 uint8x8_t dc; 228 sum = vpadd_u16(sum, sum); 229 sum = vpadd_u16(sum, sum); 230 dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 6)); 231 dc_store_32x32(dst, stride, dc); 232 } 233 234 void vpx_dc_left_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 235 const uint8_t *above, 236 const uint8_t *left) { 237 const uint16x4_t sum = dc_sum_32(left); 238 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 5)); 239 (void)above; 240 dc_store_32x32(dst, stride, dc); 241 } 242 243 void vpx_dc_top_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 244 const uint8_t *above, 245 const uint8_t *left) { 246 const uint16x4_t sum = dc_sum_32(above); 247 const uint8x8_t dc = vreinterpret_u8_u16(vrshr_n_u16(sum, 5)); 248 (void)left; 249 dc_store_32x32(dst, stride, dc); 250 } 251 252 void vpx_dc_128_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 253 const uint8_t *above, 254 const uint8_t *left) { 255 const uint8x8_t dc = vdup_n_u8(0x80); 256 (void)above; 257 (void)left; 258 dc_store_32x32(dst, stride, dc); 259 } 260 261 // ----------------------------------------------------------------------------- 262 263 void vpx_d45_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 264 const uint8_t *above, const uint8_t *left) { 265 const uint8x8_t ABCDEFGH = vld1_u8(above); 266 const uint64x1_t A1 = vshr_n_u64(vreinterpret_u64_u8(ABCDEFGH), 8); 267 const uint64x1_t A2 = vshr_n_u64(vreinterpret_u64_u8(ABCDEFGH), 16); 268 const uint8x8_t BCDEFGH0 = vreinterpret_u8_u64(A1); 269 const uint8x8_t CDEFGH00 = vreinterpret_u8_u64(A2); 270 const uint8x8_t avg1 = vhadd_u8(ABCDEFGH, CDEFGH00); 271 const uint8x8_t avg2 = vrhadd_u8(avg1, BCDEFGH0); 272 const uint64x1_t avg2_u64 = vreinterpret_u64_u8(avg2); 273 const uint32x2_t r0 = vreinterpret_u32_u8(avg2); 274 const uint32x2_t r1 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 8)); 275 const uint32x2_t r2 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 16)); 276 const uint32x2_t r3 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 24)); 277 (void)left; 278 vst1_lane_u32((uint32_t *)(dst + 0 * stride), r0, 0); 279 vst1_lane_u32((uint32_t *)(dst + 1 * stride), r1, 0); 280 vst1_lane_u32((uint32_t *)(dst + 2 * stride), r2, 0); 281 vst1_lane_u32((uint32_t *)(dst + 3 * stride), r3, 0); 282 vst1_lane_u8(dst + 3 * stride + 3, ABCDEFGH, 7); 283 } 284 285 static INLINE void d45_store_8(uint8_t **dst, const ptrdiff_t stride, 286 const uint8x8_t above_right, uint8x8_t *row) { 287 *row = vext_u8(*row, above_right, 1); 288 vst1_u8(*dst, *row); 289 *dst += stride; 290 } 291 292 void vpx_d45_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 293 const uint8_t *above, const uint8_t *left) { 294 const uint8x8_t A0 = vld1_u8(above); 295 const uint8x8_t above_right = vdup_lane_u8(A0, 7); 296 const uint8x8_t A1 = vext_u8(A0, above_right, 1); 297 const uint8x8_t A2 = vext_u8(A0, above_right, 2); 298 const uint8x8_t avg1 = vhadd_u8(A0, A2); 299 uint8x8_t row = vrhadd_u8(avg1, A1); 300 (void)left; 301 302 vst1_u8(dst, row); 303 dst += stride; 304 d45_store_8(&dst, stride, above_right, &row); 305 d45_store_8(&dst, stride, above_right, &row); 306 d45_store_8(&dst, stride, above_right, &row); 307 d45_store_8(&dst, stride, above_right, &row); 308 d45_store_8(&dst, stride, above_right, &row); 309 d45_store_8(&dst, stride, above_right, &row); 310 vst1_u8(dst, above_right); 311 } 312 313 static INLINE void d45_store_16(uint8_t **dst, const ptrdiff_t stride, 314 const uint8x16_t above_right, uint8x16_t *row) { 315 *row = vextq_u8(*row, above_right, 1); 316 vst1q_u8(*dst, *row); 317 *dst += stride; 318 } 319 320 void vpx_d45_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 321 const uint8_t *above, const uint8_t *left) { 322 const uint8x16_t A0 = vld1q_u8(above); 323 const uint8x16_t above_right = vdupq_lane_u8(vget_high_u8(A0), 7); 324 const uint8x16_t A1 = vextq_u8(A0, above_right, 1); 325 const uint8x16_t A2 = vextq_u8(A0, above_right, 2); 326 const uint8x16_t avg1 = vhaddq_u8(A0, A2); 327 uint8x16_t row = vrhaddq_u8(avg1, A1); 328 (void)left; 329 330 vst1q_u8(dst, row); 331 dst += stride; 332 d45_store_16(&dst, stride, above_right, &row); 333 d45_store_16(&dst, stride, above_right, &row); 334 d45_store_16(&dst, stride, above_right, &row); 335 d45_store_16(&dst, stride, above_right, &row); 336 d45_store_16(&dst, stride, above_right, &row); 337 d45_store_16(&dst, stride, above_right, &row); 338 d45_store_16(&dst, stride, above_right, &row); 339 d45_store_16(&dst, stride, above_right, &row); 340 d45_store_16(&dst, stride, above_right, &row); 341 d45_store_16(&dst, stride, above_right, &row); 342 d45_store_16(&dst, stride, above_right, &row); 343 d45_store_16(&dst, stride, above_right, &row); 344 d45_store_16(&dst, stride, above_right, &row); 345 d45_store_16(&dst, stride, above_right, &row); 346 vst1q_u8(dst, above_right); 347 } 348 349 void vpx_d45_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 350 const uint8_t *above, const uint8_t *left) { 351 const uint8x16_t A0_0 = vld1q_u8(above); 352 const uint8x16_t A0_1 = vld1q_u8(above + 16); 353 const uint8x16_t above_right = vdupq_lane_u8(vget_high_u8(A0_1), 7); 354 const uint8x16_t A1_0 = vld1q_u8(above + 1); 355 const uint8x16_t A1_1 = vld1q_u8(above + 17); 356 const uint8x16_t A2_0 = vld1q_u8(above + 2); 357 const uint8x16_t A2_1 = vld1q_u8(above + 18); 358 const uint8x16_t avg_0 = vhaddq_u8(A0_0, A2_0); 359 const uint8x16_t avg_1 = vhaddq_u8(A0_1, A2_1); 360 uint8x16_t row_0 = vrhaddq_u8(avg_0, A1_0); 361 uint8x16_t row_1 = vrhaddq_u8(avg_1, A1_1); 362 int i; 363 (void)left; 364 365 vst1q_u8(dst, row_0); 366 dst += 16; 367 vst1q_u8(dst, row_1); 368 dst += stride - 16; 369 370 for (i = 0; i < 30; ++i) { 371 row_0 = vextq_u8(row_0, row_1, 1); 372 row_1 = vextq_u8(row_1, above_right, 1); 373 vst1q_u8(dst, row_0); 374 dst += 16; 375 vst1q_u8(dst, row_1); 376 dst += stride - 16; 377 } 378 379 vst1q_u8(dst, above_right); 380 dst += 16; 381 vst1q_u8(dst, row_1); 382 } 383 384 // ----------------------------------------------------------------------------- 385 386 void vpx_d135_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 387 const uint8_t *above, const uint8_t *left) { 388 const uint8x8_t XA0123 = vld1_u8(above - 1); 389 const uint8x8_t L0123 = vld1_u8(left); 390 const uint8x8_t L3210 = vrev64_u8(L0123); 391 const uint8x8_t L3210XA012 = vext_u8(L3210, XA0123, 4); 392 const uint8x8_t L210XA0123 = vext_u8(L3210, XA0123, 5); 393 const uint8x8_t L10XA0123_ = 394 vreinterpret_u8_u64(vshr_n_u64(vreinterpret_u64_u8(L210XA0123), 8)); 395 const uint8x8_t avg1 = vhadd_u8(L10XA0123_, L3210XA012); 396 const uint8x8_t avg2 = vrhadd_u8(avg1, L210XA0123); 397 const uint64x1_t avg2_u64 = vreinterpret_u64_u8(avg2); 398 const uint32x2_t r3 = vreinterpret_u32_u8(avg2); 399 const uint32x2_t r2 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 8)); 400 const uint32x2_t r1 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 16)); 401 const uint32x2_t r0 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 24)); 402 vst1_lane_u32((uint32_t *)dst, r0, 0); 403 dst += stride; 404 vst1_lane_u32((uint32_t *)dst, r1, 0); 405 dst += stride; 406 vst1_lane_u32((uint32_t *)dst, r2, 0); 407 dst += stride; 408 vst1_lane_u32((uint32_t *)dst, r3, 0); 409 } 410 411 void vpx_d135_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 412 const uint8_t *above, const uint8_t *left) { 413 const uint8x8_t XA0123456 = vld1_u8(above - 1); 414 const uint8x8_t A01234567 = vld1_u8(above); 415 const uint8x8_t A1234567_ = vld1_u8(above + 1); 416 const uint8x8_t L01234567 = vld1_u8(left); 417 const uint8x8_t L76543210 = vrev64_u8(L01234567); 418 const uint8x8_t L6543210X = vext_u8(L76543210, XA0123456, 1); 419 const uint8x8_t L543210XA0 = vext_u8(L76543210, XA0123456, 2); 420 const uint8x16_t L76543210XA0123456 = vcombine_u8(L76543210, XA0123456); 421 const uint8x16_t L6543210XA01234567 = vcombine_u8(L6543210X, A01234567); 422 const uint8x16_t L543210XA01234567_ = vcombine_u8(L543210XA0, A1234567_); 423 const uint8x16_t avg = vhaddq_u8(L76543210XA0123456, L543210XA01234567_); 424 const uint8x16_t row = vrhaddq_u8(avg, L6543210XA01234567); 425 const uint8x8_t row_0 = vget_low_u8(row); 426 const uint8x8_t row_1 = vget_high_u8(row); 427 const uint8x8_t r0 = vext_u8(row_0, row_1, 7); 428 const uint8x8_t r1 = vext_u8(row_0, row_1, 6); 429 const uint8x8_t r2 = vext_u8(row_0, row_1, 5); 430 const uint8x8_t r3 = vext_u8(row_0, row_1, 4); 431 const uint8x8_t r4 = vext_u8(row_0, row_1, 3); 432 const uint8x8_t r5 = vext_u8(row_0, row_1, 2); 433 const uint8x8_t r6 = vext_u8(row_0, row_1, 1); 434 435 vst1_u8(dst, r0); 436 dst += stride; 437 vst1_u8(dst, r1); 438 dst += stride; 439 vst1_u8(dst, r2); 440 dst += stride; 441 vst1_u8(dst, r3); 442 dst += stride; 443 vst1_u8(dst, r4); 444 dst += stride; 445 vst1_u8(dst, r5); 446 dst += stride; 447 vst1_u8(dst, r6); 448 dst += stride; 449 vst1_u8(dst, row_0); 450 } 451 452 static INLINE void d135_store_16x8( 453 uint8_t **dst, const ptrdiff_t stride, const uint8x16_t row_0, 454 const uint8x16_t row_1, const uint8x16_t row_2, const uint8x16_t row_3, 455 const uint8x16_t row_4, const uint8x16_t row_5, const uint8x16_t row_6, 456 const uint8x16_t row_7) { 457 vst1q_u8(*dst, row_0); 458 *dst += stride; 459 vst1q_u8(*dst, row_1); 460 *dst += stride; 461 vst1q_u8(*dst, row_2); 462 *dst += stride; 463 vst1q_u8(*dst, row_3); 464 *dst += stride; 465 vst1q_u8(*dst, row_4); 466 *dst += stride; 467 vst1q_u8(*dst, row_5); 468 *dst += stride; 469 vst1q_u8(*dst, row_6); 470 *dst += stride; 471 vst1q_u8(*dst, row_7); 472 *dst += stride; 473 } 474 475 void vpx_d135_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 476 const uint8_t *above, const uint8_t *left) { 477 const uint8x16_t XA0123456789abcde = vld1q_u8(above - 1); 478 const uint8x16_t A0123456789abcdef = vld1q_u8(above); 479 const uint8x16_t A123456789abcdef_ = vld1q_u8(above + 1); 480 const uint8x16_t L0123456789abcdef = vld1q_u8(left); 481 const uint8x8_t L76543210 = vrev64_u8(vget_low_u8(L0123456789abcdef)); 482 const uint8x8_t Lfedcba98 = vrev64_u8(vget_high_u8(L0123456789abcdef)); 483 const uint8x16_t Lfedcba9876543210 = vcombine_u8(Lfedcba98, L76543210); 484 const uint8x16_t Ledcba9876543210X = 485 vextq_u8(Lfedcba9876543210, XA0123456789abcde, 1); 486 const uint8x16_t Ldcba9876543210XA0 = 487 vextq_u8(Lfedcba9876543210, XA0123456789abcde, 2); 488 const uint8x16_t avg_0 = vhaddq_u8(Lfedcba9876543210, Ldcba9876543210XA0); 489 const uint8x16_t avg_1 = vhaddq_u8(XA0123456789abcde, A123456789abcdef_); 490 const uint8x16_t row_0 = vrhaddq_u8(avg_0, Ledcba9876543210X); 491 const uint8x16_t row_1 = vrhaddq_u8(avg_1, A0123456789abcdef); 492 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 15); 493 const uint8x16_t r_1 = vextq_u8(row_0, row_1, 14); 494 const uint8x16_t r_2 = vextq_u8(row_0, row_1, 13); 495 const uint8x16_t r_3 = vextq_u8(row_0, row_1, 12); 496 const uint8x16_t r_4 = vextq_u8(row_0, row_1, 11); 497 const uint8x16_t r_5 = vextq_u8(row_0, row_1, 10); 498 const uint8x16_t r_6 = vextq_u8(row_0, row_1, 9); 499 const uint8x16_t r_7 = vcombine_u8(vget_high_u8(row_0), vget_low_u8(row_1)); 500 const uint8x16_t r_8 = vextq_u8(row_0, row_1, 7); 501 const uint8x16_t r_9 = vextq_u8(row_0, row_1, 6); 502 const uint8x16_t r_a = vextq_u8(row_0, row_1, 5); 503 const uint8x16_t r_b = vextq_u8(row_0, row_1, 4); 504 const uint8x16_t r_c = vextq_u8(row_0, row_1, 3); 505 const uint8x16_t r_d = vextq_u8(row_0, row_1, 2); 506 const uint8x16_t r_e = vextq_u8(row_0, row_1, 1); 507 508 d135_store_16x8(&dst, stride, r_0, r_1, r_2, r_3, r_4, r_5, r_6, r_7); 509 d135_store_16x8(&dst, stride, r_8, r_9, r_a, r_b, r_c, r_d, r_e, row_0); 510 } 511 512 static INLINE void d135_store_32x2(uint8_t **dst, const ptrdiff_t stride, 513 const uint8x16_t row_0, 514 const uint8x16_t row_1, 515 const uint8x16_t row_2) { 516 uint8_t *dst2 = *dst; 517 vst1q_u8(dst2, row_1); 518 dst2 += 16; 519 vst1q_u8(dst2, row_2); 520 dst2 += 16 * stride - 16; 521 vst1q_u8(dst2, row_0); 522 dst2 += 16; 523 vst1q_u8(dst2, row_1); 524 *dst += stride; 525 } 526 527 void vpx_d135_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 528 const uint8_t *above, const uint8_t *left) { 529 const uint8x16_t LL0123456789abcdef = vld1q_u8(left + 16); 530 const uint8x16_t LU0123456789abcdef = vld1q_u8(left); 531 const uint8x8_t LL76543210 = vrev64_u8(vget_low_u8(LL0123456789abcdef)); 532 const uint8x8_t LU76543210 = vrev64_u8(vget_low_u8(LU0123456789abcdef)); 533 const uint8x8_t LLfedcba98 = vrev64_u8(vget_high_u8(LL0123456789abcdef)); 534 const uint8x8_t LUfedcba98 = vrev64_u8(vget_high_u8(LU0123456789abcdef)); 535 const uint8x16_t LLfedcba9876543210 = vcombine_u8(LLfedcba98, LL76543210); 536 const uint8x16_t LUfedcba9876543210 = vcombine_u8(LUfedcba98, LU76543210); 537 const uint8x16_t LLedcba9876543210Uf = 538 vextq_u8(LLfedcba9876543210, LUfedcba9876543210, 1); 539 const uint8x16_t LLdcba9876543210Ufe = 540 vextq_u8(LLfedcba9876543210, LUfedcba9876543210, 2); 541 const uint8x16_t avg_0 = vhaddq_u8(LLfedcba9876543210, LLdcba9876543210Ufe); 542 const uint8x16_t row_0 = vrhaddq_u8(avg_0, LLedcba9876543210Uf); 543 544 const uint8x16_t XAL0123456789abcde = vld1q_u8(above - 1); 545 const uint8x16_t LUedcba9876543210X = 546 vextq_u8(LUfedcba9876543210, XAL0123456789abcde, 1); 547 const uint8x16_t LUdcba9876543210XA0 = 548 vextq_u8(LUfedcba9876543210, XAL0123456789abcde, 2); 549 const uint8x16_t avg_1 = vhaddq_u8(LUfedcba9876543210, LUdcba9876543210XA0); 550 const uint8x16_t row_1 = vrhaddq_u8(avg_1, LUedcba9876543210X); 551 552 const uint8x16_t AL0123456789abcdef = vld1q_u8(above); 553 const uint8x16_t AL123456789abcdefg = vld1q_u8(above + 1); 554 const uint8x16_t ALfR0123456789abcde = vld1q_u8(above + 15); 555 const uint8x16_t AR0123456789abcdef = vld1q_u8(above + 16); 556 const uint8x16_t AR123456789abcdef_ = vld1q_u8(above + 17); 557 const uint8x16_t avg_2 = vhaddq_u8(XAL0123456789abcde, AL123456789abcdefg); 558 const uint8x16_t row_2 = vrhaddq_u8(avg_2, AL0123456789abcdef); 559 const uint8x16_t avg_3 = vhaddq_u8(ALfR0123456789abcde, AR123456789abcdef_); 560 const uint8x16_t row_3 = vrhaddq_u8(avg_3, AR0123456789abcdef); 561 562 { 563 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 15); 564 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 15); 565 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 15); 566 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 567 } 568 569 { 570 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 14); 571 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 14); 572 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 14); 573 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 574 } 575 576 { 577 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 13); 578 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 13); 579 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 13); 580 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 581 } 582 583 { 584 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 12); 585 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 12); 586 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 12); 587 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 588 } 589 590 { 591 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 11); 592 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 11); 593 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 11); 594 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 595 } 596 597 { 598 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 10); 599 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 10); 600 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 10); 601 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 602 } 603 604 { 605 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 9); 606 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 9); 607 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 9); 608 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 609 } 610 611 { 612 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 8); 613 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 8); 614 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 8); 615 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 616 } 617 618 { 619 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 7); 620 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 7); 621 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 7); 622 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 623 } 624 625 { 626 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 6); 627 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 6); 628 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 6); 629 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 630 } 631 632 { 633 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 5); 634 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 5); 635 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 5); 636 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 637 } 638 639 { 640 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 4); 641 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 4); 642 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 4); 643 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 644 } 645 646 { 647 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 3); 648 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 3); 649 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 3); 650 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 651 } 652 653 { 654 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 2); 655 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 2); 656 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 2); 657 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 658 } 659 660 { 661 const uint8x16_t r_0 = vextq_u8(row_0, row_1, 1); 662 const uint8x16_t r_1 = vextq_u8(row_1, row_2, 1); 663 const uint8x16_t r_2 = vextq_u8(row_2, row_3, 1); 664 d135_store_32x2(&dst, stride, r_0, r_1, r_2); 665 } 666 667 d135_store_32x2(&dst, stride, row_0, row_1, row_2); 668 } 669 670 // ----------------------------------------------------------------------------- 671 672 #if !HAVE_NEON_ASM 673 674 void vpx_v_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 675 const uint8_t *above, const uint8_t *left) { 676 const uint32_t d = *(const uint32_t *)above; 677 int i; 678 (void)left; 679 680 for (i = 0; i < 4; i++, dst += stride) { 681 *(uint32_t *)dst = d; 682 } 683 } 684 685 void vpx_v_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 686 const uint8_t *above, const uint8_t *left) { 687 const uint8x8_t d = vld1_u8(above); 688 int i; 689 (void)left; 690 691 for (i = 0; i < 8; i++, dst += stride) { 692 vst1_u8(dst, d); 693 } 694 } 695 696 void vpx_v_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 697 const uint8_t *above, const uint8_t *left) { 698 const uint8x16_t d = vld1q_u8(above); 699 int i; 700 (void)left; 701 702 for (i = 0; i < 16; i++, dst += stride) { 703 vst1q_u8(dst, d); 704 } 705 } 706 707 void vpx_v_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 708 const uint8_t *above, const uint8_t *left) { 709 const uint8x16_t d0 = vld1q_u8(above); 710 const uint8x16_t d1 = vld1q_u8(above + 16); 711 int i; 712 (void)left; 713 714 for (i = 0; i < 32; i++) { 715 // Note: performance was worse using vst2q_u8 under gcc-4.9 & clang-3.8. 716 // clang-3.8 unrolled the loop fully with no filler so the cause is likely 717 // the latency of the instruction. 718 vst1q_u8(dst, d0); 719 dst += 16; 720 vst1q_u8(dst, d1); 721 dst += stride - 16; 722 } 723 } 724 725 // ----------------------------------------------------------------------------- 726 727 void vpx_h_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 728 const uint8_t *above, const uint8_t *left) { 729 const uint32x2_t zero = vdup_n_u32(0); 730 const uint8x8_t left_u8 = 731 vreinterpret_u8_u32(vld1_lane_u32((const uint32_t *)left, zero, 0)); 732 uint8x8_t d; 733 (void)above; 734 735 d = vdup_lane_u8(left_u8, 0); 736 vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d), 0); 737 dst += stride; 738 d = vdup_lane_u8(left_u8, 1); 739 vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d), 0); 740 dst += stride; 741 d = vdup_lane_u8(left_u8, 2); 742 vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d), 0); 743 dst += stride; 744 d = vdup_lane_u8(left_u8, 3); 745 vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(d), 0); 746 } 747 748 void vpx_h_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 749 const uint8_t *above, const uint8_t *left) { 750 const uint8x8_t left_u8 = vld1_u8(left); 751 uint8x8_t d; 752 (void)above; 753 754 d = vdup_lane_u8(left_u8, 0); 755 vst1_u8(dst, d); 756 dst += stride; 757 d = vdup_lane_u8(left_u8, 1); 758 vst1_u8(dst, d); 759 dst += stride; 760 d = vdup_lane_u8(left_u8, 2); 761 vst1_u8(dst, d); 762 dst += stride; 763 d = vdup_lane_u8(left_u8, 3); 764 vst1_u8(dst, d); 765 dst += stride; 766 d = vdup_lane_u8(left_u8, 4); 767 vst1_u8(dst, d); 768 dst += stride; 769 d = vdup_lane_u8(left_u8, 5); 770 vst1_u8(dst, d); 771 dst += stride; 772 d = vdup_lane_u8(left_u8, 6); 773 vst1_u8(dst, d); 774 dst += stride; 775 d = vdup_lane_u8(left_u8, 7); 776 vst1_u8(dst, d); 777 } 778 779 static INLINE void h_store_16x8(uint8_t **dst, const ptrdiff_t stride, 780 const uint8x8_t left) { 781 const uint8x16_t row_0 = vdupq_lane_u8(left, 0); 782 const uint8x16_t row_1 = vdupq_lane_u8(left, 1); 783 const uint8x16_t row_2 = vdupq_lane_u8(left, 2); 784 const uint8x16_t row_3 = vdupq_lane_u8(left, 3); 785 const uint8x16_t row_4 = vdupq_lane_u8(left, 4); 786 const uint8x16_t row_5 = vdupq_lane_u8(left, 5); 787 const uint8x16_t row_6 = vdupq_lane_u8(left, 6); 788 const uint8x16_t row_7 = vdupq_lane_u8(left, 7); 789 790 vst1q_u8(*dst, row_0); 791 *dst += stride; 792 vst1q_u8(*dst, row_1); 793 *dst += stride; 794 vst1q_u8(*dst, row_2); 795 *dst += stride; 796 vst1q_u8(*dst, row_3); 797 *dst += stride; 798 vst1q_u8(*dst, row_4); 799 *dst += stride; 800 vst1q_u8(*dst, row_5); 801 *dst += stride; 802 vst1q_u8(*dst, row_6); 803 *dst += stride; 804 vst1q_u8(*dst, row_7); 805 *dst += stride; 806 } 807 808 void vpx_h_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 809 const uint8_t *above, const uint8_t *left) { 810 const uint8x16_t left_u8q = vld1q_u8(left); 811 (void)above; 812 813 h_store_16x8(&dst, stride, vget_low_u8(left_u8q)); 814 h_store_16x8(&dst, stride, vget_high_u8(left_u8q)); 815 } 816 817 static INLINE void h_store_32x8(uint8_t **dst, const ptrdiff_t stride, 818 const uint8x8_t left) { 819 const uint8x16_t row_0 = vdupq_lane_u8(left, 0); 820 const uint8x16_t row_1 = vdupq_lane_u8(left, 1); 821 const uint8x16_t row_2 = vdupq_lane_u8(left, 2); 822 const uint8x16_t row_3 = vdupq_lane_u8(left, 3); 823 const uint8x16_t row_4 = vdupq_lane_u8(left, 4); 824 const uint8x16_t row_5 = vdupq_lane_u8(left, 5); 825 const uint8x16_t row_6 = vdupq_lane_u8(left, 6); 826 const uint8x16_t row_7 = vdupq_lane_u8(left, 7); 827 828 vst1q_u8(*dst, row_0); // Note clang-3.8 produced poor code w/vst2q_u8 829 *dst += 16; 830 vst1q_u8(*dst, row_0); 831 *dst += stride - 16; 832 vst1q_u8(*dst, row_1); 833 *dst += 16; 834 vst1q_u8(*dst, row_1); 835 *dst += stride - 16; 836 vst1q_u8(*dst, row_2); 837 *dst += 16; 838 vst1q_u8(*dst, row_2); 839 *dst += stride - 16; 840 vst1q_u8(*dst, row_3); 841 *dst += 16; 842 vst1q_u8(*dst, row_3); 843 *dst += stride - 16; 844 vst1q_u8(*dst, row_4); 845 *dst += 16; 846 vst1q_u8(*dst, row_4); 847 *dst += stride - 16; 848 vst1q_u8(*dst, row_5); 849 *dst += 16; 850 vst1q_u8(*dst, row_5); 851 *dst += stride - 16; 852 vst1q_u8(*dst, row_6); 853 *dst += 16; 854 vst1q_u8(*dst, row_6); 855 *dst += stride - 16; 856 vst1q_u8(*dst, row_7); 857 *dst += 16; 858 vst1q_u8(*dst, row_7); 859 *dst += stride - 16; 860 } 861 862 void vpx_h_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 863 const uint8_t *above, const uint8_t *left) { 864 int i; 865 (void)above; 866 867 for (i = 0; i < 2; i++, left += 16) { 868 const uint8x16_t left_u8 = vld1q_u8(left); 869 h_store_32x8(&dst, stride, vget_low_u8(left_u8)); 870 h_store_32x8(&dst, stride, vget_high_u8(left_u8)); 871 } 872 } 873 874 // ----------------------------------------------------------------------------- 875 876 static INLINE int16x8_t convert_u8_to_s16(uint8x8_t v) { 877 return vreinterpretq_s16_u16(vmovl_u8(v)); 878 } 879 880 void vpx_tm_predictor_4x4_neon(uint8_t *dst, ptrdiff_t stride, 881 const uint8_t *above, const uint8_t *left) { 882 const uint8x8_t top_left = vld1_dup_u8(above - 1); 883 const uint8x8_t left_u8 = vld1_u8(left); 884 const uint8x8_t above_u8 = vld1_u8(above); 885 const int16x4_t left_s16 = vget_low_s16(convert_u8_to_s16(left_u8)); 886 int16x8_t sub, sum; 887 uint32x2_t d; 888 889 sub = vreinterpretq_s16_u16(vsubl_u8(above_u8, top_left)); 890 // Avoid vcombine_s16() which generates lots of redundant code with clang-3.8. 891 sub = vreinterpretq_s16_s64( 892 vdupq_lane_s64(vreinterpret_s64_s16(vget_low_s16(sub)), 0)); 893 894 sum = vcombine_s16(vdup_lane_s16(left_s16, 0), vdup_lane_s16(left_s16, 1)); 895 sum = vaddq_s16(sum, sub); 896 d = vreinterpret_u32_u8(vqmovun_s16(sum)); 897 vst1_lane_u32((uint32_t *)dst, d, 0); 898 dst += stride; 899 vst1_lane_u32((uint32_t *)dst, d, 1); 900 dst += stride; 901 902 sum = vcombine_s16(vdup_lane_s16(left_s16, 2), vdup_lane_s16(left_s16, 3)); 903 sum = vaddq_s16(sum, sub); 904 d = vreinterpret_u32_u8(vqmovun_s16(sum)); 905 vst1_lane_u32((uint32_t *)dst, d, 0); 906 dst += stride; 907 vst1_lane_u32((uint32_t *)dst, d, 1); 908 } 909 910 static INLINE void tm_8_kernel(uint8_t **dst, const ptrdiff_t stride, 911 const int16x8_t left_dup, const int16x8_t sub) { 912 const int16x8_t sum = vaddq_s16(left_dup, sub); 913 const uint8x8_t d = vqmovun_s16(sum); 914 vst1_u8(*dst, d); 915 *dst += stride; 916 } 917 918 void vpx_tm_predictor_8x8_neon(uint8_t *dst, ptrdiff_t stride, 919 const uint8_t *above, const uint8_t *left) { 920 const uint8x8_t top_left = vld1_dup_u8(above - 1); 921 const uint8x8_t above_u8 = vld1_u8(above); 922 const uint8x8_t left_u8 = vld1_u8(left); 923 const int16x8_t left_s16q = convert_u8_to_s16(left_u8); 924 const int16x8_t sub = vreinterpretq_s16_u16(vsubl_u8(above_u8, top_left)); 925 int16x4_t left_s16d = vget_low_s16(left_s16q); 926 int i; 927 928 for (i = 0; i < 2; i++, left_s16d = vget_high_s16(left_s16q)) { 929 int16x8_t left_dup; 930 931 left_dup = vdupq_lane_s16(left_s16d, 0); 932 tm_8_kernel(&dst, stride, left_dup, sub); 933 left_dup = vdupq_lane_s16(left_s16d, 1); 934 tm_8_kernel(&dst, stride, left_dup, sub); 935 left_dup = vdupq_lane_s16(left_s16d, 2); 936 tm_8_kernel(&dst, stride, left_dup, sub); 937 left_dup = vdupq_lane_s16(left_s16d, 3); 938 tm_8_kernel(&dst, stride, left_dup, sub); 939 } 940 } 941 942 static INLINE void tm_16_kernel(uint8_t **dst, const ptrdiff_t stride, 943 const int16x8_t left_dup, const int16x8_t sub0, 944 const int16x8_t sub1) { 945 const int16x8_t sum0 = vaddq_s16(left_dup, sub0); 946 const int16x8_t sum1 = vaddq_s16(left_dup, sub1); 947 const uint8x8_t d0 = vqmovun_s16(sum0); 948 const uint8x8_t d1 = vqmovun_s16(sum1); 949 vst1_u8(*dst, d0); 950 *dst += 8; 951 vst1_u8(*dst, d1); 952 *dst += stride - 8; 953 } 954 955 void vpx_tm_predictor_16x16_neon(uint8_t *dst, ptrdiff_t stride, 956 const uint8_t *above, const uint8_t *left) { 957 const uint8x16_t top_left = vld1q_dup_u8(above - 1); 958 const uint8x16_t above_u8 = vld1q_u8(above); 959 const int16x8_t sub0 = vreinterpretq_s16_u16( 960 vsubl_u8(vget_low_u8(above_u8), vget_low_u8(top_left))); 961 const int16x8_t sub1 = vreinterpretq_s16_u16( 962 vsubl_u8(vget_high_u8(above_u8), vget_high_u8(top_left))); 963 int16x8_t left_dup; 964 int i; 965 966 for (i = 0; i < 2; i++, left += 8) { 967 const uint8x8_t left_u8 = vld1_u8(left); 968 const int16x8_t left_s16q = convert_u8_to_s16(left_u8); 969 const int16x4_t left_low = vget_low_s16(left_s16q); 970 const int16x4_t left_high = vget_high_s16(left_s16q); 971 972 left_dup = vdupq_lane_s16(left_low, 0); 973 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 974 left_dup = vdupq_lane_s16(left_low, 1); 975 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 976 left_dup = vdupq_lane_s16(left_low, 2); 977 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 978 left_dup = vdupq_lane_s16(left_low, 3); 979 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 980 981 left_dup = vdupq_lane_s16(left_high, 0); 982 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 983 left_dup = vdupq_lane_s16(left_high, 1); 984 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 985 left_dup = vdupq_lane_s16(left_high, 2); 986 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 987 left_dup = vdupq_lane_s16(left_high, 3); 988 tm_16_kernel(&dst, stride, left_dup, sub0, sub1); 989 } 990 } 991 992 static INLINE void tm_32_kernel(uint8_t **dst, const ptrdiff_t stride, 993 const int16x8_t left_dup, const int16x8_t sub0, 994 const int16x8_t sub1, const int16x8_t sub2, 995 const int16x8_t sub3) { 996 const int16x8_t sum0 = vaddq_s16(left_dup, sub0); 997 const int16x8_t sum1 = vaddq_s16(left_dup, sub1); 998 const int16x8_t sum2 = vaddq_s16(left_dup, sub2); 999 const int16x8_t sum3 = vaddq_s16(left_dup, sub3); 1000 const uint8x8_t d0 = vqmovun_s16(sum0); 1001 const uint8x8_t d1 = vqmovun_s16(sum1); 1002 const uint8x8_t d2 = vqmovun_s16(sum2); 1003 const uint8x8_t d3 = vqmovun_s16(sum3); 1004 1005 vst1q_u8(*dst, vcombine_u8(d0, d1)); 1006 *dst += 16; 1007 vst1q_u8(*dst, vcombine_u8(d2, d3)); 1008 *dst += stride - 16; 1009 } 1010 1011 void vpx_tm_predictor_32x32_neon(uint8_t *dst, ptrdiff_t stride, 1012 const uint8_t *above, const uint8_t *left) { 1013 const uint8x16_t top_left = vld1q_dup_u8(above - 1); 1014 const uint8x16_t above_low = vld1q_u8(above); 1015 const uint8x16_t above_high = vld1q_u8(above + 16); 1016 const int16x8_t sub0 = vreinterpretq_s16_u16( 1017 vsubl_u8(vget_low_u8(above_low), vget_low_u8(top_left))); 1018 const int16x8_t sub1 = vreinterpretq_s16_u16( 1019 vsubl_u8(vget_high_u8(above_low), vget_high_u8(top_left))); 1020 const int16x8_t sub2 = vreinterpretq_s16_u16( 1021 vsubl_u8(vget_low_u8(above_high), vget_low_u8(top_left))); 1022 const int16x8_t sub3 = vreinterpretq_s16_u16( 1023 vsubl_u8(vget_high_u8(above_high), vget_high_u8(top_left))); 1024 int16x8_t left_dup; 1025 int i, j; 1026 1027 for (j = 0; j < 4; j++, left += 8) { 1028 const uint8x8_t left_u8 = vld1_u8(left); 1029 const int16x8_t left_s16q = convert_u8_to_s16(left_u8); 1030 int16x4_t left_s16d = vget_low_s16(left_s16q); 1031 for (i = 0; i < 2; i++, left_s16d = vget_high_s16(left_s16q)) { 1032 left_dup = vdupq_lane_s16(left_s16d, 0); 1033 tm_32_kernel(&dst, stride, left_dup, sub0, sub1, sub2, sub3); 1034 left_dup = vdupq_lane_s16(left_s16d, 1); 1035 tm_32_kernel(&dst, stride, left_dup, sub0, sub1, sub2, sub3); 1036 left_dup = vdupq_lane_s16(left_s16d, 2); 1037 tm_32_kernel(&dst, stride, left_dup, sub0, sub1, sub2, sub3); 1038 left_dup = vdupq_lane_s16(left_s16d, 3); 1039 tm_32_kernel(&dst, stride, left_dup, sub0, sub1, sub2, sub3); 1040 } 1041 } 1042 } 1043 #endif // !HAVE_NEON_ASM 1044