Merge commit '502512ea0f179165782777265f441d4061ff6012'
[ffmpeg.git] / libavcodec / bfin / pixels.S
1 /*
2  * Blackfin Pixel Operations
3  * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include "libavutil/bfin/asm.h"
23
24 /*
25   motion compensation
26   primitives
27
28      * Halfpel motion compensation with rounding (a+b+1)>>1.
29      * This is an array[4][4] of motion compensation funcions for 4
30      * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
31      * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
32      * @param block destination where the result is stored
33      * @param pixels source
34      * @param line_size number of bytes in a horizontal line of block
35      * @param h height
36
37 */
38
39 DEFUN(put_pixels8uc,mL1,
40         (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
41                  int dest_size, int line_size, int h)):
42         i3=r0;        // dest
43         i0=r1;        // src0
44         i1=r2;        // src1
45         r0=[sp+12];   // dest_size
46         r2=[sp+16];   // line_size
47         p0=[sp+20];   // h
48         [--sp] = (r7:6);
49         r0+=-4;
50         m3=r0;
51         r2+=-8;
52         m0=r2;
53         LSETUP(pp8$0,pp8$1) LC0=P0;
54         DISALGNEXCPT                || R0 = [I0++]  || R2  =[I1++];
55
56 pp8$0:  DISALGNEXCPT                || R1 = [I0++]  || R3  =[I1++];
57         R6 = BYTEOP1P(R1:0,R3:2)    || R0 = [I0++M0]|| R2  =[I1++M0];
58         R7 = BYTEOP1P(R1:0,R3:2)(R) || R0 = [I0++]  || [I3++] = R6 ;
59 pp8$1:  DISALGNEXCPT                || R2 = [I1++]  || [I3++M3] = R7;
60
61         (r7:6) = [sp++];
62         RTS;
63 DEFUN_END(put_pixels8uc)
64
65 DEFUN(put_pixels16uc,mL1,
66         (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
67                  int dest_size, int line_size, int h)):
68         link 0;
69         [--sp] = (r7:6);
70         i3=r0;        // dest
71         i0=r1;        // src0
72         i1=r2;        // src1
73         r0=[fp+20];   // dest_size
74         r2=[fp+24];   // line_size
75         p0=[fp+28];   // h
76
77
78         r0+=-12;
79         m3=r0;        // line_size
80         r2+=-16;
81         m0=r2;
82
83         LSETUP(pp16$0,pp16$1) LC0=P0;
84          DISALGNEXCPT                || R0 = [I0++]   || R2  =[I1++];
85
86 pp16$0:  DISALGNEXCPT                || R1 = [I0++]   || R3  =[I1++];
87          R6 = BYTEOP1P(R1:0,R3:2)    || R0 = [I0++]   || R2  =[I1++];
88          R7 = BYTEOP1P(R1:0,R3:2)(R) || R1 = [I0++]   || R3  =[I1++];
89          [I3++] = R6;
90          R6 = BYTEOP1P(R1:0,R3:2)    || R0 = [I0++M0] || R2  =[I1++M0];
91          R7 = BYTEOP1P(R1:0,R3:2)(R) || R0 = [I0++]   || [I3++] = R7 ;
92          [I3++] = R6;
93 pp16$1:  DISALGNEXCPT                || R2 = [I1++]   || [I3++M3] = R7;
94
95         (r7:6) = [sp++];
96         unlink;
97         RTS;
98 DEFUN_END(put_pixels16uc)
99
100 DEFUN(z_put_pixels16_xy2,mL1,
101         (uint8_t *block, const uint8_t *s0,
102                  int dest_size, int line_size, int h)):
103         link 0;
104         [--sp] = (r7:4);
105         i3=r0;        // dest
106         i0=r1;        // src0--> pixels
107         i1=r1;        // src1--> pixels + line_size
108         r2+=-12;
109         m2=r2;        // m2=dest_width-4
110         r2=[fp+20];
111         m3=r2;        // line_size
112         p0=[fp+24];   // h
113         r2+=-16;
114         i1+=m3;       /* src1 + line_size */
115         m0=r2;        /* line-size - 20 */
116
117         B0 = I0;
118         B1 = I1;
119         B3 = I3;
120
121         DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
122
123         LSETUP(LS$16E,LE$16E) LC0=P0;
124 LS$16E: DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
125         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++] || R2  =[I1++];
126         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R1 = [I0++] || [I3++] = R4 ;
127         DISALGNEXCPT                       || R3 = [I1++] || [I3++] = R5;
128         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++M0]|| R2  = [I1++M0];
129         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++] || [I3++] = R4 ;
130 LE$16E: DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
131
132         M1 = 1;
133         I3 = B3;
134         I1 = B1;
135         I0 = B0;
136
137         I0 += M1;
138         I1 += M1;
139
140         DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
141         LSETUP(LS$16O,LE$16O) LC0=P0;
142 LS$16O: DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
143         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++] || R2  =[I1++];
144         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R1 = [I0++] || R6  =[I3++];
145         R4 = R4 +|+ R6                       || R7 = [I3--];
146         R5 = R5 +|+ R7                       || [I3++] = R4;
147         DISALGNEXCPT                       || R3  =[I1++] || [I3++] = R5;
148         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++M0]|| R2  = [I1++M0];
149         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++] || R6 = [I3++];
150         R4 = R4 +|+ R6                       || R7 = [I3--];
151         R5 = R5 +|+ R7                       || [I3++] = R4;
152 LE$16O: DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
153
154         (r7:4) = [sp++];
155         unlink;
156         rts;
157 DEFUN_END(z_put_pixels16_xy2)
158
159 DEFUN(z_put_pixels8_xy2,mL1,
160         (uint8_t *block, const uint8_t *s0,
161                  int dest_size, int line_size, int h)):
162         link 0;
163         [--sp] = (r7:4);
164         i3=r0;        // dest
165         i0=r1;        // src0--> pixels
166         i1=r1;        // src1--> pixels + line_size
167         r2+=-4;
168         m2=r2;        // m2=dest_width-4
169         r2=[fp+20];
170         m3=r2;        // line_size
171         p0=[fp+24];   // h
172         r2+=-8;
173         i1+=m3;       /* src1 + line_size */
174         m0=r2;        /* line-size - 20 */
175
176         b0 = I0;
177         b1 = I1;
178         b3 = I3;
179
180         LSETUP(LS$8E,LE$8E) LC0=P0;
181         DISALGNEXCPT                       || R0 = [I0++]   || R2  =[I1++];
182 LS$8E:  DISALGNEXCPT                       || R1 = [I0++]   || R3  =[I1++];
183         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++M0] || R2  =[I1++M0];
184         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++]   || [I3++] = R4 ;
185 LE$8E:  DISALGNEXCPT                       || R2 = [I1++]   || [I3++M2] = R5;
186
187         M1 = 1;
188         I3 = b3;
189         I1 = b1;
190         I0 = b0;
191
192         I0 += M1;
193         I1 += M1;
194
195         LSETUP(LS$8O,LE$8O) LC0=P0;
196         DISALGNEXCPT                       || R0 = [I0++]   || R2  =[I1++];
197 LS$8O:  DISALGNEXCPT                       || R1 = [I0++]   || R3  =[I1++];
198         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++M0] || R2  =[I1++M0];
199         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++]   || R6  =[I3++];
200         R4 = R4 +|+ R6                                      || R7 = [I3--];
201         R5 = R5 +|+ R7                                      || [I3++] = R4;
202 LE$8O:  DISALGNEXCPT                       || R2  =[I1++]   || [I3++M2] = R5;
203
204         (r7:4) = [sp++];
205         unlink;
206         rts;
207 DEFUN_END(z_put_pixels8_xy2)