arm: hpeldsp: Move half-pel assembly from dsputil to hpeldsp
[ffmpeg.git] / libavcodec / arm / hpeldsp_armv6.S
1 /*
2  * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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/arm/asm.S"
22
23 .macro  call_2x_pixels  type, subp
24 function ff_\type\()_pixels16\subp\()_armv6, export=1
25         push            {r0-r3, lr}
26         bl              ff_\type\()_pixels8\subp\()_armv6
27         pop             {r0-r3, lr}
28         add             r0,  r0,  #8
29         add             r1,  r1,  #8
30         b               ff_\type\()_pixels8\subp\()_armv6
31 endfunc
32 .endm
33
34 call_2x_pixels          avg
35 call_2x_pixels          put, _x2
36 call_2x_pixels          put, _y2
37 call_2x_pixels          put, _x2_no_rnd
38 call_2x_pixels          put, _y2_no_rnd
39
40 function ff_put_pixels16_armv6, export=1
41         push            {r4-r11}
42 1:
43         ldr             r5,  [r1, #4]
44         ldr             r6,  [r1, #8]
45         ldr             r7,  [r1, #12]
46         ldr_post        r4,  r1,  r2
47         strd            r6,  r7,  [r0, #8]
48         ldr             r9,  [r1, #4]
49         strd_post       r4,  r5,  r0,  r2
50         ldr             r10, [r1, #8]
51         ldr             r11, [r1, #12]
52         ldr_post        r8,  r1,  r2
53         strd            r10, r11, [r0, #8]
54         subs            r3,  r3,  #2
55         strd_post       r8,  r9,  r0,  r2
56         bne             1b
57
58         pop             {r4-r11}
59         bx              lr
60 endfunc
61
62 function ff_put_pixels8_armv6, export=1
63         push            {r4-r7}
64 1:
65         ldr             r5,  [r1, #4]
66         ldr_post        r4,  r1,  r2
67         ldr             r7,  [r1, #4]
68         strd_post       r4,  r5,  r0,  r2
69         ldr_post        r6,  r1,  r2
70         subs            r3,  r3,  #2
71         strd_post       r6,  r7,  r0,  r2
72         bne             1b
73
74         pop             {r4-r7}
75         bx              lr
76 endfunc
77
78 function ff_put_pixels8_x2_armv6, export=1
79         push            {r4-r11, lr}
80         mov             r12, #1
81         orr             r12, r12, r12, lsl #8
82         orr             r12, r12, r12, lsl #16
83 1:
84         ldr             r4,  [r1]
85         subs            r3,  r3,  #2
86         ldr             r5,  [r1, #4]
87         ldr             r7,  [r1, #5]
88         lsr             r6,  r4,  #8
89         ldr_pre         r8,  r1,  r2
90         orr             r6,  r6,  r5,  lsl #24
91         ldr             r9,  [r1, #4]
92         ldr             r11, [r1, #5]
93         lsr             r10, r8,  #8
94         add             r1,  r1,  r2
95         orr             r10, r10, r9,  lsl #24
96         eor             r14, r4,  r6
97         uhadd8          r4,  r4,  r6
98         eor             r6,  r5,  r7
99         uhadd8          r5,  r5,  r7
100         and             r14, r14, r12
101         and             r6,  r6,  r12
102         uadd8           r4,  r4,  r14
103         eor             r14, r8,  r10
104         uadd8           r5,  r5,  r6
105         eor             r6,  r9,  r11
106         uhadd8          r8,  r8,  r10
107         and             r14, r14, r12
108         uhadd8          r9,  r9,  r11
109         and             r6,  r6,  r12
110         uadd8           r8,  r8,  r14
111         strd_post       r4,  r5,  r0,  r2
112         uadd8           r9,  r9,  r6
113         strd_post       r8,  r9,  r0,  r2
114         bne             1b
115
116         pop             {r4-r11, pc}
117 endfunc
118
119 function ff_put_pixels8_y2_armv6, export=1
120         push            {r4-r11}
121         mov             r12, #1
122         orr             r12, r12, r12, lsl #8
123         orr             r12, r12, r12, lsl #16
124         ldr             r4,  [r1]
125         ldr             r5,  [r1, #4]
126         ldr_pre         r6,  r1,  r2
127         ldr             r7,  [r1, #4]
128 1:
129         subs            r3,  r3,  #2
130         uhadd8          r8,  r4,  r6
131         eor             r10, r4,  r6
132         uhadd8          r9,  r5,  r7
133         eor             r11, r5,  r7
134         and             r10, r10, r12
135         ldr_pre         r4,  r1,  r2
136         uadd8           r8,  r8,  r10
137         and             r11, r11, r12
138         uadd8           r9,  r9,  r11
139         ldr             r5,  [r1, #4]
140         uhadd8          r10, r4,  r6
141         eor             r6,  r4,  r6
142         uhadd8          r11, r5,  r7
143         and             r6,  r6,  r12
144         eor             r7,  r5,  r7
145         uadd8           r10, r10, r6
146         and             r7,  r7,  r12
147         ldr_pre         r6,  r1,  r2
148         uadd8           r11, r11, r7
149         strd_post       r8,  r9,  r0,  r2
150         ldr             r7,  [r1, #4]
151         strd_post       r10, r11, r0,  r2
152         bne             1b
153
154         pop             {r4-r11}
155         bx              lr
156 endfunc
157
158 function ff_put_pixels8_x2_no_rnd_armv6, export=1
159         push            {r4-r9, lr}
160 1:
161         subs            r3,  r3,  #2
162         ldr             r4,  [r1]
163         ldr             r5,  [r1, #4]
164         ldr             r7,  [r1, #5]
165         ldr_pre         r8,  r1,  r2
166         ldr             r9,  [r1, #4]
167         ldr             r14, [r1, #5]
168         add             r1,  r1,  r2
169         lsr             r6,  r4,  #8
170         orr             r6,  r6,  r5,  lsl #24
171         lsr             r12, r8,  #8
172         orr             r12, r12, r9,  lsl #24
173         uhadd8          r4,  r4,  r6
174         uhadd8          r5,  r5,  r7
175         uhadd8          r8,  r8,  r12
176         uhadd8          r9,  r9,  r14
177         stm             r0,  {r4,r5}
178         add             r0,  r0,  r2
179         stm             r0,  {r8,r9}
180         add             r0,  r0,  r2
181         bne             1b
182
183         pop             {r4-r9, pc}
184 endfunc
185
186 function ff_put_pixels8_y2_no_rnd_armv6, export=1
187         push            {r4-r9, lr}
188         ldr             r4,  [r1]
189         ldr             r5,  [r1, #4]
190         ldr_pre         r6,  r1,  r2
191         ldr             r7,  [r1, #4]
192 1:
193         subs            r3,  r3,  #2
194         uhadd8          r8,  r4,  r6
195         ldr_pre         r4,  r1,  r2
196         uhadd8          r9,  r5,  r7
197         ldr             r5,  [r1, #4]
198         uhadd8          r12, r4,  r6
199         ldr_pre         r6,  r1,  r2
200         uhadd8          r14, r5,  r7
201         ldr             r7,  [r1, #4]
202         stm             r0,  {r8,r9}
203         add             r0,  r0,  r2
204         stm             r0,  {r12,r14}
205         add             r0,  r0,  r2
206         bne             1b
207
208         pop             {r4-r9, pc}
209 endfunc
210
211 function ff_avg_pixels8_armv6, export=1
212         pld             [r1, r2]
213         push            {r4-r10, lr}
214         mov             lr,  #1
215         orr             lr,  lr,  lr,  lsl #8
216         orr             lr,  lr,  lr,  lsl #16
217         ldrd            r4,  r5,  [r0]
218         ldr             r10, [r1, #4]
219         ldr_post        r9,  r1,  r2
220         subs            r3,  r3,  #2
221 1:
222         pld             [r1, r2]
223         eor             r8,  r4,  r9
224         uhadd8          r4,  r4,  r9
225         eor             r12, r5,  r10
226         ldrd_reg        r6,  r7,  r0,  r2
227         uhadd8          r5,  r5,  r10
228         and             r8,  r8,  lr
229         ldr             r10, [r1, #4]
230         and             r12, r12, lr
231         uadd8           r4,  r4,  r8
232         ldr_post        r9,  r1,  r2
233         eor             r8,  r6,  r9
234         uadd8           r5,  r5,  r12
235         pld             [r1, r2,  lsl #1]
236         eor             r12, r7,  r10
237         uhadd8          r6,  r6,  r9
238         strd_post       r4,  r5,  r0,  r2
239         uhadd8          r7,  r7,  r10
240         beq             2f
241         and             r8,  r8,  lr
242         ldrd_reg        r4,  r5,  r0,  r2
243         uadd8           r6,  r6,  r8
244         ldr             r10, [r1, #4]
245         and             r12, r12, lr
246         subs            r3,  r3,  #2
247         uadd8           r7,  r7,  r12
248         ldr_post        r9,  r1,  r2
249         strd_post       r6,  r7,  r0,  r2
250         b               1b
251 2:
252         and             r8,  r8,  lr
253         and             r12, r12, lr
254         uadd8           r6,  r6,  r8
255         uadd8           r7,  r7,  r12
256         strd_post       r6,  r7,  r0,  r2
257
258         pop             {r4-r10, pc}
259 endfunc