2 * Copyright (c) 2017 Meng Wang <wangmeng.kids@bytedance.com>
4 * This file is part of FFmpeg.
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.
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.
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
22 #include "libavutil/arm/asm.S"
25 function ff_hevc_sao_band_filter_neon_8, export=1
27 ldr r5, [sp, #28] // width
28 ldr r4, [sp, #32] // height
29 ldr r8, [sp, #36] // offset_table
31 mov r12, r4 // r12 = height
32 mov r6, r0 // r6 = r0 = dst
33 mov r7, r1 // r7 = r1 = src
41 vld1.8 {d16}, [r1], r3
42 vshr.u8 d17, d16, #3 // index = [src>>3]
43 vshll.u8 q9, d17, #1 // lowIndex = 2*index
44 vadd.u16 q11, q9, q15 // highIndex = (2*index+1) << 8
45 vshl.u16 q10, q11, #8 // q10: highIndex; q9: lowIndex;
46 vadd.u16 q10, q9 // combine high and low index;
47 // Look-up Table Round 1; index range: 0-15
48 vtbx.8 d24, {q0-q1}, d20
49 vtbx.8 d25, {q0-q1}, d21
50 // Look-up Table Round 2; index range: 16-31
51 vsub.u8 q10, q14 // Look-up with 8bit
52 vtbx.8 d24, {q2-q3}, d20
53 vtbx.8 d25, {q2-q3}, d21
54 vaddw.u8 q13, q12, d16
67 vld1.32 {d16[0]}, [r1], r3
68 vshr.u8 d17, d16, #3 // src>>3
69 vshll.u8 q9, d17, #1 // lowIndex = 2*index
70 vadd.u16 q11, q9, q15 // highIndex = (2*index+1) << 8
71 vshl.u16 q10, q11, #8 // q10: highIndex; q9: lowIndex;
72 vadd.u16 q10, q9 // combine high and low index;
73 // Look-up Table Round 1; index range: 0-15
74 vtbx.8 d24, {q0-q1}, d20
75 vtbx.8 d25, {q0-q1}, d21
76 // Look-up Table Round 2; index range: 16-32
77 vsub.u8 q10, q14 // Look-up with 8bit
78 vtbx.8 d24, {q2-q3}, d20
79 vtbx.8 d25, {q2-q3}, d21
80 vaddw.u8 q13, q12, d16
82 vst1.32 d14[0], [r0], r2
91 function ff_hevc_sao_edge_filter_neon_8, export=1
93 ldr r5, [sp, #32] // width
94 ldr r4, [sp, #36] // height
95 ldr r8, [sp, #40] // a_stride
96 ldr r9, [sp, #44] // b_stride
97 ldr r10, [sp, #48] // sao_offset_val
98 ldr r11, [sp, #52] // edge_idx
100 mov r12, r4 // r12 = height
101 mov r6, r0 // r6 = r0 = dst
102 mov r7, r1 // r7 = r1 = src
103 vld1.8 {d0}, [r11] // edge_idx tabel load in d0 5x8bit
104 vld1.16 {q1}, [r10] // sao_offset_val table load in q1, 5x16bit
108 add r10, r8 // src[x + a_stride]
110 add r11, r9 // src[x + b_stride]
115 vld1.8 {d16}, [r1], r3 // src[x] 8x8bit
116 vld1.8 {d17}, [r10], r3 // src[x + a_stride]
117 vld1.8 {d18}, [r11], r3 // src[x + b_stride]
121 vadd.u8 d8, d9 // diff0
122 vcgt.u8 d10, d16, d18
124 vclt.u8 d10, d16, d18
125 vadd.u8 d10, d11 // diff1
128 vtbx.8 d9, {d0}, d8 // offset_val
129 vshll.u8 q6, d9, #1 // lowIndex
131 vshl.u16 q10, q7, #8 // highIndex
132 vadd.u16 q10, q6 // combine lowIndex and highIndex, offset_val
133 vtbx.8 d22, {q1}, d20
134 vtbx.8 d23, {q1}, d21
135 vaddw.u8 q12, q11, d16
148 vld1.32 {d16[0]}, [r1], r3
149 vld1.32 {d17[0]}, [r10], r3 // src[x + a_stride]
150 vld1.32 {d18[0]}, [r11], r3 // src[x + b_stride]
154 vadd.u8 d8, d9 // diff0
155 vcgt.u8 d10, d16, d18
157 vclt.u8 d10, d16, d18
158 vadd.u8 d10, d11 // diff1
161 vtbx.8 d9, {d0}, d8 // offset_val
162 vshll.u8 q6, d9, #1 // lowIndex
164 vshl.u16 q10, q7, #8 // highIndex
165 vadd.u16 q10, q6 // combine lowIndex and highIndex, offset_val
166 vtbx.8 d22, {q1}, d20
167 vtbx.8 d23, {q1}, d21
168 vaddw.u8 q12, q11, d16
170 vst1.32 d26[0], [r0], r2