highbd_blend_a64_hmask_neon.c (3140B)
1 /* 2 * Copyright (c) 2023, Alliance for Open Media. All rights reserved. 3 * 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. 10 */ 11 12 #include <arm_neon.h> 13 #include <assert.h> 14 15 #include "config/aom_config.h" 16 #include "config/aom_dsp_rtcd.h" 17 18 #include "aom_dsp/arm/blend_neon.h" 19 #include "aom_dsp/arm/mem_neon.h" 20 #include "aom_dsp/blend.h" 21 22 void aom_highbd_blend_a64_hmask_neon(uint8_t *dst_8, uint32_t dst_stride, 23 const uint8_t *src0_8, 24 uint32_t src0_stride, 25 const uint8_t *src1_8, 26 uint32_t src1_stride, const uint8_t *mask, 27 int w, int h, int bd) { 28 (void)bd; 29 30 const uint16_t *src0 = CONVERT_TO_SHORTPTR(src0_8); 31 const uint16_t *src1 = CONVERT_TO_SHORTPTR(src1_8); 32 uint16_t *dst = CONVERT_TO_SHORTPTR(dst_8); 33 34 assert(IMPLIES(src0 == dst, src0_stride == dst_stride)); 35 assert(IMPLIES(src1 == dst, src1_stride == dst_stride)); 36 37 assert(h >= 1); 38 assert(w >= 1); 39 assert(IS_POWER_OF_TWO(h)); 40 assert(IS_POWER_OF_TWO(w)); 41 42 assert(bd == 8 || bd == 10 || bd == 12); 43 44 if (w >= 8) { 45 do { 46 int i = 0; 47 do { 48 uint16x8_t m0 = vmovl_u8(vld1_u8(mask + i)); 49 uint16x8_t s0 = vld1q_u16(src0 + i); 50 uint16x8_t s1 = vld1q_u16(src1 + i); 51 52 uint16x8_t blend = alpha_blend_a64_u16x8(m0, s0, s1); 53 54 vst1q_u16(dst + i, blend); 55 i += 8; 56 } while (i < w); 57 58 src0 += src0_stride; 59 src1 += src1_stride; 60 dst += dst_stride; 61 } while (--h != 0); 62 } else if (w == 4) { 63 const uint16x8_t m0 = vmovl_u8(load_unaligned_dup_u8_4x2(mask)); 64 do { 65 uint16x8_t s0 = load_unaligned_u16_4x2(src0, src0_stride); 66 uint16x8_t s1 = load_unaligned_u16_4x2(src1, src1_stride); 67 68 uint16x8_t blend = alpha_blend_a64_u16x8(m0, s0, s1); 69 70 store_u16x4_strided_x2(dst, dst_stride, blend); 71 72 src0 += 2 * src0_stride; 73 src1 += 2 * src1_stride; 74 dst += 2 * dst_stride; 75 h -= 2; 76 } while (h != 0); 77 } else if (w == 2 && h >= 8) { 78 const uint16x4_t m0 = 79 vget_low_u16(vmovl_u8(load_unaligned_dup_u8_2x4(mask))); 80 do { 81 uint16x4_t s0 = load_unaligned_u16_2x2(src0, src0_stride); 82 uint16x4_t s1 = load_unaligned_u16_2x2(src1, src1_stride); 83 84 uint16x4_t blend = alpha_blend_a64_u16x4(m0, s0, s1); 85 86 store_u16x2_strided_x2(dst, dst_stride, blend); 87 88 src0 += 2 * src0_stride; 89 src1 += 2 * src1_stride; 90 dst += 2 * dst_stride; 91 h -= 2; 92 } while (h != 0); 93 } else { 94 aom_highbd_blend_a64_hmask_c(dst_8, dst_stride, src0_8, src0_stride, src1_8, 95 src1_stride, mask, w, h, bd); 96 } 97 }