8bed5c041023249ae9484489ddb385e3ea23fbf7
[ffmpeg.git] / libavcodec / bfin / hpel_pixels_bfin.S
1 /*
2  * Blackfin Pixel Operations
3  * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include "config_bfin.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
101
102
103
104
105 DEFUN(put_pixels8uc_nornd,mL1,
106         (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
107                  int line_size, int h)):
108         i3=r0;        // dest
109         i0=r1;        // src0
110         i1=r2;        // src1
111         r2=[sp+12];   // line_size
112         p0=[sp+16];   // h
113         [--sp] = (r7:6);
114         r2+=-4;
115         m3=r2;
116         r2+=-4;
117         m0=r2;
118         LSETUP(pp8$2,pp8$3) LC0=P0;
119         DISALGNEXCPT                || R0 = [I0++]  || R2  =[I1++];
120
121 pp8$2:  DISALGNEXCPT                || R1 = [I0++]  || R3  =[I1++];
122         R6 = BYTEOP1P(R1:0,R3:2)(T)  || R0 = [I0++M0]|| R2  =[I1++M0];
123         R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]  || [I3++] = R6 ;
124 pp8$3:  DISALGNEXCPT                || R2 = [I1++]  || [I3++M3] = R7;
125
126         (r7:6) = [sp++];
127         RTS;
128 DEFUN_END(put_pixels8uc_nornd)
129
130 DEFUN(put_pixels16uc_nornd,mL1,
131         (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
132                  int line_size, int h)):
133         i3=r0;        // dest
134         i0=r1;        // src0
135         i1=r2;        // src1
136         r2=[sp+12];   // line_size
137         p0=[sp+16];   // h
138
139         [--sp] = (r7:6);
140         r2+=-12;
141         m3=r2;        // line_size
142         r2+=-4;
143         m0=r2;
144
145         LSETUP(pp16$2,pp16$3) LC0=P0;
146         DISALGNEXCPT                || R0 = [I0++]   || R2  =[I1++];
147
148 pp16$2:
149         DISALGNEXCPT                || R1 = [I0++]   || R3  =[I1++];
150         R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++]   || R2  =[I1++];
151         R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++]   || R3  =[I1++];
152         [I3++] = R6;
153
154         R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++M0] || R2  =[I1++M0];
155         R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]   || [I3++] = R7 ;
156         [I3++] = R6;
157 pp16$3: DISALGNEXCPT                || R2 = [I1++]   || [I3++M3] = R7;
158
159         (r7:6) = [sp++];
160
161         RTS;
162 DEFUN_END(put_pixels16uc_nornd)
163
164 DEFUN(z_put_pixels16_xy2,mL1,
165         (uint8_t *block, const uint8_t *s0,
166                  int dest_size, int line_size, int h)):
167         link 0;
168         [--sp] = (r7:4);
169         i3=r0;        // dest
170         i0=r1;        // src0--> pixels
171         i1=r1;        // src1--> pixels + line_size
172         r2+=-12;
173         m2=r2;        // m2=dest_width-4
174         r2=[fp+20];
175         m3=r2;        // line_size
176         p0=[fp+24];   // h
177         r2+=-16;
178         i1+=m3;       /* src1 + line_size */
179         m0=r2;        /* line-size - 20 */
180
181         B0 = I0;
182         B1 = I1;
183         B3 = I3;
184
185         DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
186
187         LSETUP(LS$16E,LE$16E) LC0=P0;
188 LS$16E: DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
189         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++] || R2  =[I1++];
190         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R1 = [I0++] || [I3++] = R4 ;
191         DISALGNEXCPT                       || R3 = [I1++] || [I3++] = R5;
192         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++M0]|| R2  = [I1++M0];
193         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++] || [I3++] = R4 ;
194 LE$16E: DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
195
196         M1 = 1;
197         I3 = B3;
198         I1 = B1;
199         I0 = B0;
200
201         I0 += M1;
202         I1 += M1;
203
204         DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
205         LSETUP(LS$16O,LE$16O) LC0=P0;
206 LS$16O: DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
207         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++] || R2  =[I1++];
208         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R1 = [I0++] || R6  =[I3++];
209         R4 = R4 +|+ R6                       || R7 = [I3--];
210         R5 = R5 +|+ R7                       || [I3++] = R4;
211         DISALGNEXCPT                       || R3  =[I1++] || [I3++] = R5;
212         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++M0]|| R2  = [I1++M0];
213         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++] || R6 = [I3++];
214         R4 = R4 +|+ R6                       || R7 = [I3--];
215         R5 = R5 +|+ R7                       || [I3++] = R4;
216 LE$16O: DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
217
218         (r7:4) = [sp++];
219         unlink;
220         rts;
221 DEFUN_END(z_put_pixels16_xy2)
222
223 DEFUN(z_put_pixels8_xy2,mL1,
224         (uint8_t *block, const uint8_t *s0,
225                  int dest_size, int line_size, int h)):
226         link 0;
227         [--sp] = (r7:4);
228         i3=r0;        // dest
229         i0=r1;        // src0--> pixels
230         i1=r1;        // src1--> pixels + line_size
231         r2+=-4;
232         m2=r2;        // m2=dest_width-4
233         r2=[fp+20];
234         m3=r2;        // line_size
235         p0=[fp+24];   // h
236         r2+=-8;
237         i1+=m3;       /* src1 + line_size */
238         m0=r2;        /* line-size - 20 */
239
240         b0 = I0;
241         b1 = I1;
242         b3 = I3;
243
244         LSETUP(LS$8E,LE$8E) LC0=P0;
245         DISALGNEXCPT                       || R0 = [I0++]   || R2  =[I1++];
246 LS$8E:  DISALGNEXCPT                       || R1 = [I0++]   || R3  =[I1++];
247         R4 = BYTEOP2P (R3:2,R1:0) (RNDL)   || R0 = [I0++M0] || R2  =[I1++M0];
248         R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++]   || [I3++] = R4 ;
249 LE$8E:  DISALGNEXCPT                       || R2 = [I1++]   || [I3++M2] = R5;
250
251         M1 = 1;
252         I3 = b3;
253         I1 = b1;
254         I0 = b0;
255
256         I0 += M1;
257         I1 += M1;
258
259         LSETUP(LS$8O,LE$8O) LC0=P0;
260         DISALGNEXCPT                       || R0 = [I0++]   || R2  =[I1++];
261 LS$8O:  DISALGNEXCPT                       || R1 = [I0++]   || R3  =[I1++];
262         R4 = BYTEOP2P (R3:2,R1:0) (RNDH)   || R0 = [I0++M0] || R2  =[I1++M0];
263         R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++]   || R6  =[I3++];
264         R4 = R4 +|+ R6                                      || R7 = [I3--];
265         R5 = R5 +|+ R7                                      || [I3++] = R4;
266 LE$8O:  DISALGNEXCPT                       || R2  =[I1++]   || [I3++M2] = R5;
267
268         (r7:4) = [sp++];
269         unlink;
270         rts;
271 DEFUN_END(z_put_pixels8_xy2)