configure.ac: Add checks for Flex/Yacc/Bison and other furry animals, for the new...
[platform/upstream/gst-plugins-good.git] / gst / goom / ppc_zoom_ultimate.s
1 ; PowerPC optimized zoom for Goom
2 ; © 2001-2003 Guillaume Borios
3 ; This Source Code is released under the terms of the General Public License
4
5 ; Change log :
6 ; 21 Dec 2003 : Use of altivec is now determined with a parameter
7
8 ; Section definition : We use a read only section
9 .text
10
11 ; name of the function to call by C program : ppc_zoom
12 ; We declare this label as a global to extend its scope outside this file
13 .globl _ppc_zoom_generic
14 .globl _ppc_zoom_G4
15
16 ; Description :
17 ; This routine dynamically computes and applies a zoom filter
18
19 ; parameters :
20 ; r3  <=> unsigned int sizeX (in pixels)
21 ; r4  <=> unsigned int sizeY (in pixels)
22 ; r5  <=> unsigned int * frompixmap
23 ; r6  <=> unsigned int * topixmap
24 ; r7  <=> unsigned int * brutS
25 ; r8  <=> unsigned int * brutD
26 ; r9  <=> unsigned int buffratio
27 ; r10 <=> int [16][16] precalccoeffs
28
29 ; globals after init
30 ; r5  <=> frompixmap - 1 byte needed for preincremental fetch (replaces r5)
31 ; r6  <=> topixmap - 1 byte needed for preincremental fetch (replaces r6)
32 ; r3 <=> ax = x max in 16th of pixels (replaces old r3)
33 ; r4 <=> ay = y max in 16th of pixels (replaces old r4)
34 ; r20 <=> row size in bytes
35 ; r12 <=> 0xFF00FF (mask for parallel 32 bits pixs computing)
36 ; r30 <=> brutS - 1 byte needed for preincremental fetch (replaces r7)
37 ; r31 <=> brutD - 1 byte needed for preincremental fetch (replaces r8)
38
39 ; ABI notes :
40 ; r1 is the Stack Pointer (SP) => Do not use
41 ; r13..r31 are non-volatiles => Do not use
42
43 _ppc_zoom_generic:
44
45 ; Saves the used non volatile registers in the Mach-O stack s Red-Zone
46 stmw    r18,-56(r1)
47
48 ; init
49 li      r18,0           ; Default value if out of range : 0 (Black)
50 mr      r11,r10
51 lis     r12,0xFF
52 mullw   r2,r3,r4        ; Number of pixels to compute
53 subi    r30,r8,0
54 slwi    r20,r3,2
55 srawi   r19,r20,2
56 ori     r12,r12,0xFF
57 subi    r3,r3,1
58 subi    r4,r4,1
59 mtspr   ctr,r2          ; Init the loop count (one loop per pixel computed)
60 subi    r31,r7,0
61 subi    r6,r6,4
62 slwi    r3,r3,4
63 slwi    r4,r4,4
64
65 ;pre init for loop
66 lwz     r2,0(r31)    ; px
67 lwz     r29,4(r31)   ; py
68 lwz     r8,0(r30)    ; px2
69 lwz     r10,4(r30)   ; py2
70
71 b       L1
72 .align  5
73 L1:
74
75 ; computes dynamically the position to fetch
76 sub     r8,r8,r2
77 sub     r10,r10,r29
78 mullw   r8,r8,r9
79 addi    r31,r31,8
80 mullw   r10,r10,r9
81 addi    r30,r30,8
82
83 srawi   r8,r8,16
84 srawi   r10,r10,16
85 add     r2,r2,r8
86 add     r29,r29,r10
87
88 ; if px>ax or py>ay goto outofrange
89 ; computes the attenuation coeffs and the original point address
90 rlwinm  r10,r2,6,28-6,31-6 ; r10 <- (r2 << 2) & 0x000002D0   (r10=(r2%16)*4*16)
91 cmpl    cr4,0,r2,r3
92 rlwimi  r10, r29, 2, 28-2, 31-2 ; r10 <- ((r29 << 2) & 0x0000002D) | (r10 & !0x0000002D)      (r10=(r10%16)*4 | r10)
93 cmpl    cr7,0,r29,r4
94 srawi   r29,r29,4     ; pos computing
95 bge-    cr4,L4
96 srawi   r2,r2,4       ; pos computing
97 mullw   r29, r29,r19  ; pos computing
98 bge-    cr7,L4
99
100 ; Channels notation : 00112233 (AARRVVBB)
101
102 add     r2,r2,r29               ; pos computing
103 lwzx    r10,r11,r10             ; Loads coefs
104 slwi    r2,r2,2                 ; pos computing
105 add     r2,r2,r5                ; pos computing
106 rlwinm  r21,r10,0,24,31         ; Isolates coef1 (??????11 -> 00000011)
107 lwz     r25,0(r2)               ; Loads col1 -> r25
108 lwz     r26,4(r2)               ; Loads col2 -> r26
109 rlwinm  r22,r10,24,24,31        ; Isolates coef2 (????22?? -> 00000022)
110 rlwinm  r23,r10,16,24,31        ; Isolates coef3 (??33???? -> 00000033)
111 add     r2,r2,r20               ; Adds one line for future load of col3 and col4
112 and     r8, r25,r12             ; Masks col1 channels 1 & 3 : 0x00XX00XX
113 rlwinm  r24,r10,8,24,31         ; Isolates coef4 (44?????? -> 00000044)
114 andi.   r25,r25,0xFF00          ; Masks col1 channel 2 : 0x0000XX00
115 mullw   r8, r8, r21             ; Applies coef1 on col1 channels 1 & 3
116
117
118 ; computes final pixel color
119 and     r10,r26,r12             ; Masks col2 channels 1 & 3 : 0x00XX00XX
120 lwz     r27,0(r2)               ; Loads col3 -> r27
121 mullw   r10,r10,r22             ; Applies coef2 on col2 channels 1 & 3
122 mullw   r25,r25,r21             ; Applies coef1 on col1 channel 2
123 andi.   r29,r26,0xFF00          ; Masks col2 channel 2 : 0x0000XX00
124 mullw   r29,r29,r22             ; Applies coef2 on col2 channel 2
125 lwz     r28,4(r2)               ; Loads col4 -> r28
126 add     r8 ,r8 ,r10             ; Adds col1 & col2 channels 1 & 3
127 and     r10,r27,r12             ; Masks col3 channels 1 & 3 : 0x00XX00XX
128 add     r25,r25,r29             ; Adds col1 & col2 channel 2
129 mullw   r10,r10,r23             ; Applies coef3 on col3 channels 1 & 3
130 andi.   r29,r27,0xFF00          ; Masks col3 channel 2 : 0x0000XX00
131 mullw   r29,r29,r23             ; Applies coef3 on col3 channel 2
132 lwz     r2,0(r31)               ; px
133 add     r7 ,r8 ,r10             ; Adds col3 to (col1 + col2) channels 1 & 3
134 and     r10,r28,r12             ; Masks col4 channels 1 & 3 : 0x00XX00XX
135 mullw   r10,r10,r24             ; Applies coef4 on col4 channels 1 & 3
136 add     r25,r25,r29             ; Adds col 3 to (col1 + col2) channel 2
137 lwz     r8,0(r30)               ; px2
138 andi.   r28,r28,0xFF00          ; Masks col4 channel 2 : 0x0000XX00
139 add     r7 ,r7 ,r10             ; Adds col4 to (col1 + col2 + col3) channels 1 & 3
140 lwz     r10,4(r30)              ; py2
141 mullw   r28,r28,r24             ; Applies coef4 on col4 channel 2
142 srawi   r7, r7, 8               ; (sum of channels 1 & 3) >> 8
143 lwz     r29,4(r31)              ; py
144 add     r25,r25,r28             ; Adds col 4 to (col1 + col2 + col3) channel 2
145 rlwimi  r7, r25, 24, 16, 23     ; (((sum of channels 2) >> 8 ) & 0x0000FF00) | ((sum of channels 1 and 3) & 0xFFFF00FF)
146 stwu    r7,4(r6)                ; Stores the computed pixel
147 bdnz    L1                      ; Iterate again if needed
148 b       L3      ;goto end       ; If not, returns from the function
149
150
151 ; if out of range
152 L4:
153 stwu    r18,4(r6)
154 lwz     r8,0(r30)    ; px2
155 lwz     r10,4(r30)   ; py2
156 lwz     r2,0(r31)    ; px
157 lwz     r29,4(r31)   ; py
158 bdnz    L1
159
160
161 L3:
162
163 ; Restore saved registers and return
164 lmw     r18,-56(r1)
165 blr
166
167
168
169
170
171
172
173
174 _ppc_zoom_G4:
175
176 ; Saves the used non volatile registers in the Mach-O stack s Red-Zone
177 stmw    r17,-60(r1)
178
179 ; init
180 li      r18,0           ; Default value if out of range : 0 (Black)
181 mr      r11,r10
182 lis     r12,0xFF
183 mullw   r2,r3,r4        ; Number of pixels to compute
184 subi    r30,r8,0
185 slwi    r20,r3,2
186 srawi   r19,r20,2
187 ori     r12,r12,0xFF
188 subi    r3,r3,1
189 subi    r4,r4,1
190 mtspr   ctr,r2          ; Init the loop count (one loop per pixel computed)
191 subi    r31,r7,0
192 subi    r6,r6,4
193 slwi    r3,r3,4
194 slwi    r4,r4,4
195
196 ;pre init for loop
197 lwz     r2,0(r31)    ; px
198 lwz     r29,4(r31)   ; py
199 lwz     r8,0(r30)    ; px2
200 lwz     r10,4(r30)   ; py2
201
202 ;*********************
203 lis     r17,0x0F01
204
205 b       L100
206 .align  5
207 L100:
208
209 addi    r6,r6,4
210
211 ; Optimization to ensure the destination buffer
212 ; won't be loaded into the data cache
213 rlwinm. r0,r6,0,27,31
214 bne+    L500
215 dcbz    0,r6
216 ;dcba    0,r6
217 L500:
218
219 ; computes dynamically the position to fetch
220 ;mullw   r8,r8,r29
221 ;mullw   r2,r2,r29
222 ;add     r2,r8,r2
223 ;srawi   r2,r2,17
224
225 sub     r8,r8,r2
226 sub     r10,r10,r29
227 mullw   r8,r8,r9
228 addi    r31,r31,8
229 mullw   r10,r10,r9
230 addi    r30,r30,8
231
232 dst     r30,r17,0
233
234 srawi    r8,r8,16
235 srawi    r10,r10,16
236 add     r2,r2,r8
237 add     r29,r29,r10
238
239 dst     r31,r17,1
240
241 ; if px>ax or py>ay goto outofrange
242 ; computes the attenuation coeffs and the original point address
243 rlwinm  r10,r2,6,28-6,31-6 ; r10 <- (r2 << 2) & 0x000002D0   (r10=(r2%16)*4*16)
244 cmpl    cr4,0,r2,r3
245 rlwimi  r10, r29, 2, 28-2, 31-2 ; r10 <- ((r29 << 2) & 0x0000002D) | (r10 & !0x0000002D)      (r10=(r29%16)*4 | r10)
246 cmpl    cr7,0,r29,r4
247 srawi   r29,r29,4     ; pos computing
248 bge-    cr4,L400
249 srawi   r2,r2,4       ; pos computing
250 mullw   r29, r29,r19  ; pos computing
251 bge-    cr7,L400
252
253 ; Channels notation : 00112233 (AARRVVBB)
254
255 add     r2,r2,r29               ; pos computing
256 lwzx    r10,r11,r10             ; Loads coefs
257 slwi    r2,r2,2                 ; pos computing
258 add     r2,r2,r5                ; pos computing
259 rlwinm  r21,r10,0,24,31         ; Isolates coef1 (??????11 -> 00000011)
260 lwz     r25,0(r2)               ; Loads col1 -> r25
261 lwz     r26,4(r2)               ; Loads col2 -> r26
262 rlwinm  r22,r10,24,24,31        ; Isolates coef2 (????22?? -> 00000022)
263 rlwinm  r23,r10,16,24,31        ; Isolates coef3 (??33???? -> 00000033)
264 add     r2,r2,r20               ; Adds one line for future load of col3 and col4
265 and     r8, r25,r12             ; Masks col1 channels 1 & 3 : 0x00XX00XX
266 rlwinm  r24,r10,8,24,31         ; Isolates coef4 (44?????? -> 00000044)
267 dst     r2,r17,2
268 rlwinm  r25,r25,0,16,23         ; Masks col1 channel 2 : 0x0000XX00
269 ;andi.  r25,r25,0xFF00          ; Masks col1 channel 2 : 0x0000XX00
270 mullw   r8, r8, r21             ; Applies coef1 on col1 channels 1 & 3
271
272
273 ; computes final pixel color
274 and     r10,r26,r12             ; Masks col2 channels 1 & 3 : 0x00XX00XX
275 lwz     r27,0(r2)               ; Loads col3 -> r27
276 mullw   r10,r10,r22             ; Applies coef2 on col2 channels 1 & 3
277 mullw   r25,r25,r21             ; Applies coef1 on col1 channel 2
278 rlwinm  r29,r26,0,16,23         ; Masks col2 channel 2 : 0x0000XX00
279 ;andi.  r29,r26,0xFF00          ; Masks col2 channel 2 : 0x0000XX00
280 mullw   r29,r29,r22             ; Applies coef2 on col2 channel 2
281 lwz     r28,4(r2)               ; Loads col4 -> r28
282 add     r8 ,r8 ,r10             ; Adds col1 & col2 channels 1 & 3
283 and     r10,r27,r12             ; Masks col3 channels 1 & 3 : 0x00XX00XX
284 add     r25,r25,r29             ; Adds col1 & col2 channel 2
285 mullw   r10,r10,r23             ; Applies coef3 on col3 channels 1 & 3
286 rlwinm  r29,r27,0,16,23         ; Masks col3 channel 2 : 0x0000XX00
287 ;andi.  r29,r27,0xFF00          ; Masks col3 channel 2 : 0x0000XX00
288 mullw   r29,r29,r23             ; Applies coef3 on col3 channel 2
289 lwz     r2,0(r31)               ; px
290 add     r7 ,r8 ,r10             ; Adds col3 to (col1 + col2) channels 1 & 3
291 and     r10,r28,r12             ; Masks col4 channels 1 & 3 : 0x00XX00XX
292 mullw   r10,r10,r24             ; Applies coef4 on col4 channels 1 & 3
293 add     r25,r25,r29             ; Adds col 3 to (col1 + col2) channel 2
294 lwz     r8,0(r30)               ; px2
295 rlwinm  r28,r28,0,16,23         ; Masks col4 channel 2 : 0x0000XX00
296 ;andi.  r28,r28,0xFF00          ; Masks col4 channel 2 : 0x0000XX00
297 add     r7 ,r7 ,r10             ; Adds col4 to (col1 + col2 + col3) channels 1 & 3
298 lwz     r10,4(r30)              ; py2
299 mullw   r28,r28,r24             ; Applies coef4 on col4 channel 2
300 srawi   r7, r7, 8               ; (sum of channels 1 & 3) >> 8
301 lwz     r29,4(r31)              ; py
302 add     r25,r25,r28             ; Adds col 4 to (col1 + col2 + col3) channel 2
303 rlwimi  r7, r25, 24, 16, 23     ; (((sum of channels 2) >> 8 ) & 0x0000FF00) | ((sum of channels 1 and 3) & 0xFFFF00FF)
304 stw     r7,0(r6)                ; Stores the computed pixel
305 bdnz    L100                    ; Iterate again if needed
306 b       L300    ;goto end       ; If not, returns from the function
307
308
309 ; if out of range
310 L400:
311 stw     r18,0(r6)
312 lwz     r8,0(r30)    ; px2
313 lwz     r10,4(r30)   ; py2
314 lwz     r2,0(r31)    ; px
315 lwz     r29,4(r31)   ; py
316 bdnz    L100
317
318
319 L300:
320
321 ; Restore saved registers and return
322 lmw     r17,-60(r1)
323 blr