1/* -*-arm64-*- 2 * vim: syntax=arm64asm 3 * 4 * AArch64 NEON optimised SAO functions for HEVC decoding 5 * 6 * Copyright (c) 2020 Josh Dekker <josh@itanimul.li> 7 * 8 * This file is part of FFmpeg. 9 * 10 * FFmpeg is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * FFmpeg is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with FFmpeg; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25#include "libavutil/aarch64/asm.S" 26 27// void sao_band_filter(uint8_t *_dst, uint8_t *_src, 28// ptrdiff_t stride_dst, ptrdiff_t stride_src, 29// int16_t *sao_offset_val, int sao_left_class, 30// int width, int height) 31function ff_hevc_sao_band_filter_8x8_8_neon, export=1 32 sub sp, sp, #64 33 stp xzr, xzr, [sp] 34 stp xzr, xzr, [sp, #16] 35 stp xzr, xzr, [sp, #32] 36 stp xzr, xzr, [sp, #48] 37 mov w8, #4 380: 39 ldrsh x9, [x4, x8, lsl #1] // x9 = sao_offset_val[k+1] 40 subs w8, w8, #1 41 add w10, w8, w5 // x10 = k + sao_left_class 42 and w10, w10, #0x1F 43 strh w9, [sp, x10, lsl #1] 44 bne 0b 45 ld1 {v16.16b-v19.16b}, [sp], #64 46 movi v20.8h, #1 471: // beginning of line 48 mov w8, w6 492: 50 // Simple layout for accessing 16bit values 51 // with 8bit LUT. 52 // 53 // 00 01 02 03 04 05 06 07 54 // +-----------------------------------> 55 // |xDE#xAD|xCA#xFE|xBE#xEF|xFE#xED|.... 56 // +-----------------------------------> 57 // i-0 i-1 i-2 i-3 58 // dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]); 59 ld1 {v2.8b}, [x1] 60 // load src[x] 61 uxtl v0.8h, v2.8b 62 // >> shift 63 ushr v2.8h, v0.8h, #3 // BIT_DEPTH - 3 64 // x2 (access lower short) 65 shl v1.8h, v2.8h, #1 // low (x2, accessing short) 66 // +1 access upper short 67 add v3.8h, v1.8h, v20.8h 68 // shift insert index to upper byte 69 sli v1.8h, v3.8h, #8 70 // table 71 tbx v2.16b, {v16.16b-v19.16b}, v1.16b 72 // src[x] + table 73 add v1.8h, v0.8h, v2.8h 74 // clip + narrow 75 sqxtun v4.8b, v1.8h 76 // store 77 st1 {v4.8b}, [x0] 78 // done 8 pixels 79 subs w8, w8, #8 80 bne 2b 81 // finished line 82 subs w7, w7, #1 83 add x0, x0, x2 // dst += stride_dst 84 add x1, x1, x3 // src += stride_src 85 bne 1b 86 ret 87endfunc 88