1/* 2 * Copyright (c) 2016 Clément Bœsch <clement stupeflix.com> 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21#include "libavutil/aarch64/asm.S" 22 23function ff_yuv2planeX_8_neon, export=1 24 ld1 {v0.8B}, [x5] // load 8x8-bit dither 25 cbz w6, 1f // check if offsetting present 26 ext v0.8B, v0.8B, v0.8B, #3 // honor offsetting which can be 0 or 3 only 271: uxtl v0.8H, v0.8B // extend dither to 16-bit 28 ushll v1.4S, v0.4H, #12 // extend dither to 32-bit with left shift by 12 (part 1) 29 ushll2 v2.4S, v0.8H, #12 // extend dither to 32-bit with left shift by 12 (part 2) 30 mov x7, #0 // i = 0 312: mov v3.16B, v1.16B // initialize accumulator part 1 with dithering value 32 mov v4.16B, v2.16B // initialize accumulator part 2 with dithering value 33 mov w8, w1 // tmpfilterSize = filterSize 34 mov x9, x2 // srcp = src 35 mov x10, x0 // filterp = filter 363: ldp x11, x12, [x9], #16 // get 2 pointers: src[j] and src[j+1] 37 add x11, x11, x7, lsl #1 // &src[j ][i] 38 add x12, x12, x7, lsl #1 // &src[j+1][i] 39 ld1 {v5.8H}, [x11] // read 8x16-bit @ src[j ][i + {0..7}]: A,B,C,D,E,F,G,H 40 ld1 {v6.8H}, [x12] // read 8x16-bit @ src[j+1][i + {0..7}]: I,J,K,L,M,N,O,P 41 ld1r {v7.8H}, [x10], #2 // read 1x16-bit coeff X at filter[j ] and duplicate across lanes 42 ld1r {v16.8H}, [x10], #2 // read 1x16-bit coeff Y at filter[j+1] and duplicate across lanes 43 smlal v3.4S, v5.4H, v7.4H // val0 += {A,B,C,D} * X 44 smlal2 v4.4S, v5.8H, v7.8H // val1 += {E,F,G,H} * X 45 smlal v3.4S, v6.4H, v16.4H // val0 += {I,J,K,L} * Y 46 smlal2 v4.4S, v6.8H, v16.8H // val1 += {M,N,O,P} * Y 47 subs w8, w8, #2 // tmpfilterSize -= 2 48 b.gt 3b // loop until filterSize consumed 49 50 sqshrun v3.4h, v3.4s, #16 // clip16(val0>>16) 51 sqshrun2 v3.8h, v4.4s, #16 // clip16(val1>>16) 52 uqshrn v3.8b, v3.8h, #3 // clip8(val>>19) 53 st1 {v3.8b}, [x3], #8 // write to destination 54 subs w4, w4, #8 // dstW -= 8 55 add x7, x7, #8 // i += 8 56 b.gt 2b // loop until width consumed 57 ret 58endfunc 59