2 * Blackfin Pixel Operations
3 * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/bfin/asm.h"
24 DEFUN(put_pixels_clamped,mL1,
25 (int16_t *block, uint8_t *dest, int line_size)):
32 R2 += -4; // line_size
38 LSETUP (ppc$0,ppc$1) LC0=P0;
39 ppc$0: R2 = MIN(R2, R5) (V);
41 R3 = MIN(R3, R5) (V) || R0 = [I0++];
42 R6 = BYTEPACK (R2,R3) || R1 = [I0++];
43 R2 = MAX(R0, R4) (V) || [I1++] = R6;
46 R3 = MIN(R3, R5) (V) || R0 = [I0++];
47 R6 = BYTEPACK (R2,R3) || R1 = [I0++];
48 ppc$1: R2 = Max(R0, R4) (V) || [I1++M1] = R6;
52 DEFUN_END(put_pixels_clamped)
54 DEFUN(add_pixels_clamped,mL1,
55 (int16_t *block, uint8_t *dest, int line_size)):
59 R2 += -4; // line_size
66 R0 = [I3++] || R2 = [I1];
67 R2 = R2 << 8 || R0.H = W[I3--] || R3 = [I1++];
68 R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
69 R6 = BYTEOP3P(R1:0, R3:2) (LO) || R1.H = W[I3++] || R2 = [I1];
71 LSETUP(apc$2,apc$3) LC1 = P0;
72 apc$2: R7 = BYTEOP3P(R1:0, R3:2) (HI, R) || R0 = [I3++] || R3 = [I1++M0];
73 R2 = R2 << 8 || R0.H = W[I3--];
74 R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
75 R6 = R6 + R7 (S) || R1.H = W[I3];
76 R6 = BYTEOP3P(R1:0, R3:2) (LO) || I3+=M3 || [I2++]=R6;
77 R7 = BYTEOP3P(R1:0, R3:2) (HI, R) || R0 = [I3++] || R2 = [I1];
78 R2 = R2 << 8 || R0.H = W[I3--] || R3 = [I1++];
79 R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
80 R6 = R6 + R7 (S) || R1.H = W[I3++];
81 apc$3: R6 = BYTEOP3P(R1:0, R3:2) (LO) || [I2++M0] = R6 || R2 = [I1];
85 DEFUN_END(add_pixels_clamped)
87 DEFUN(diff_pixels,mL1,
88 (int16_t *block, uint8_t *s1, uint8_t *s2, int stride)):
100 LSETUP(.LS0,.LE0) LC0=P0;
101 DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
103 .LS0: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
104 (R5,R4) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
105 (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || [I3++] = R4;
106 DISALGNEXCPT || R2 = [I1++] || [I3++] = R5;
113 DEFUN_END(diff_pixels)
116 for (i = 0; i < 16; i++) {
117 for (j = 0; j < 16; j++) {
124 (uint8_t *p, int stride)):
138 LSETUP(LS$PS,LE$PS) LC0=P0;
139 DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
141 LS$PS: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
142 (R5,R4) = BYTEOP16P (R3:2,R1:0) || R0 = [I0++] || R2 = [I1++];
145 (R5,R4) = BYTEOP16P (R3:2,R1:0) (R)|| R1 = [I0++] || R3 = [I1++];
148 (R5,R4) = BYTEOP16P (R3:2,R1:0) || R0 = [I0++m0] || R2 = [I1++m0];
151 (R5,R4) = BYTEOP16P (R3:2,R1:0) (R)|| R0 = [I0++] || R2 = [I1++];
163 DEFUN(get_pixels,mL1,
164 (int16_t *av_restrict block, const uint8_t *pixels, int line_size)):
171 LSETUP(gp8$0,gp8$1) LC0=P0;
173 DISALGNEXCPT || R0 = [I0++];
174 DISALGNEXCPT || R1 = [I0++];
176 gp8$0: (R7,R6) = byteunpack R1:0 || R0 = [I0++M0];
177 (R5,R4) = byteunpack R1:0 (R) || R0 = [I0++] || [I3++]=R6;
178 DISALGNEXCPT || R1 = [I0++] || [I3++]=R7;
185 DEFUN_END(get_pixels)
188 /* sad = sad16x16 (ubyte *mb, ubyte *refwin, srcwidth, refwinwidth, h) */
190 DEFUN(z_sad16x16,mL1,
191 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h)):
197 R0 = [sp+20]; // rwidth
198 P2 = [sp+24]; // height
205 DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
206 LSETUP (s$16, e$16) LC0=P2;
207 s$16: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
208 SAA (R1:0,R3:2) || R0 = [I0++] || R2 = [I1++];
209 SAA (R1:0,R3:2) (R) || R1 = [I0++] || R3 = [I1++];
210 SAA (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M1];
211 e$16: SAA (R1:0,R3:2) (R) || R0 = [I0++] || R2 = [I1++];
213 R3=A1.L+A1.H, R2=A0.L+A0.H ;
217 DEFUN_END(z_sad16x16)
219 /* sad = sad8x8 (ubyte *mb, ubyte *refwin, int srcwidth, int refwinwidth, int h) */
222 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h)):
227 r0 = [sp+12]; // rwidth
228 P2 = [sp+16]; //height
235 LSETUP (s$8, e$8) LC0=P2;
236 DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
237 DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
238 s$8: SAA (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M1];
239 SAA (R1:0,R3:2) (R) || R0 = [I0++] || R2 = [I1++];
240 e$8: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
242 R3=A1.L+A1.H, R2=A0.L+A0.H ;
248 (uint8_t * pix, int line_size)):
251 // Fetch the input arguments.
253 P0 = R1; // line_size
254 P5 = 16; // loop ctr.
256 M0 = P0; // M0 = line_size-16;
257 // Now for the real work.
259 lsetup(_pix_norm1_blkfn_loopStart, _pix_norm1_blkfn_loopEnd) LC1 = P5;
261 DISALGNEXCPT || r0 = [i0++];
263 _pix_norm1_blkfn_loopStart:
264 // following unpacks pix1[0..15] pix1+line_size[0..15]
265 DISALGNEXCPT || r1 = [i0++];
267 (r5, r4) = byteunpack r1:0 || r0 = [i0++];
268 a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
269 a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
270 (r5, r4) = byteunpack r1:0(r) || r1 = [i0++];
271 a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
272 a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
273 (r5, r4) = byteunpack r1:0 || r0 = [i0++M0];
274 a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
275 a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
276 (r5, r4) = byteunpack r1:0(r) || r0 = [i0++];
277 a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
278 _pix_norm1_blkfn_loopEnd:
279 a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
282 // Clean up at the end:
292 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
298 r2=[fp+20]; // line_size
303 LSETUP(.S40,.E40) LC0=P0;
304 DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
306 .S40: DISALGNEXCPT || R1 = [I0++M0] || R3 = [I1++M0];
307 (R7,R6) = BYTEOP16M (R1:0,R3:2);
308 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
309 .E40: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
319 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
325 r2=[fp+20]; // line_size
330 LSETUP(.S80,.E80) LC0=P0;
331 DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
333 .S80: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
334 (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
335 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
336 a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
337 (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || R2 = [I1++];
338 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
339 .E80: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
349 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
355 r2=[fp+20]; // line_size
360 DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
361 LSETUP(.S160,.E160) LC0=P0;
363 .S160: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
364 (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++] || R2 = [I1++];
365 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
366 a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
367 (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R1 = [I0++] || R3 = [I1++];
368 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
369 a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
370 (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
371 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
372 a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
373 (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || R2 = [I1++];
374 a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
375 .E160: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);