Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | * Half-pel DSP functions. |
||
3 | * Copyright (c) 2000, 2001 Fabrice Bellard |
||
4 | * Copyright (c) 2002-2004 Michael Niedermayer |
||
5 | * |
||
6 | * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer |
||
7 | * |
||
8 | * This file is part of FFmpeg. |
||
9 | * |
||
10 | * FFmpeg is free software; you can redistribute it and/or |
||
11 | * modify it under the terms of the GNU Lesser General Public |
||
12 | * License as published by the Free Software Foundation; either |
||
13 | * version 2.1 of the License, or (at your option) any later version. |
||
14 | * |
||
15 | * FFmpeg is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
18 | * Lesser General Public License for more details. |
||
19 | * |
||
20 | * You should have received a copy of the GNU Lesser General Public |
||
21 | * License along with FFmpeg; if not, write to the Free Software |
||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||
23 | */ |
||
24 | |||
25 | /** |
||
26 | * @file |
||
27 | * Half-pel DSP functions. |
||
28 | */ |
||
29 | |||
30 | #include "bit_depth_template.c" |
||
31 | |||
32 | #include "hpel_template.c" |
||
33 | |||
34 | #define PIXOP2(OPNAME, OP) \ |
||
35 | static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ |
||
36 | int src_stride1, int src_stride2, int h){\ |
||
37 | int i;\ |
||
38 | for(i=0; i |
||
39 | pixel4 a,b;\ |
||
40 | a= AV_RN4P(&src1[i*src_stride1 ]);\ |
||
41 | b= AV_RN4P(&src2[i*src_stride2 ]);\ |
||
42 | OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\ |
||
43 | a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\ |
||
44 | b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\ |
||
45 | OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\ |
||
46 | }\ |
||
47 | }\ |
||
48 | \ |
||
49 | static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
50 | FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ |
||
51 | }\ |
||
52 | \ |
||
53 | static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
54 | FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ |
||
55 | }\ |
||
56 | \ |
||
57 | static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
58 | FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ |
||
59 | }\ |
||
60 | \ |
||
61 | static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
62 | FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ |
||
63 | }\ |
||
64 | \ |
||
65 | static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
66 | FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ |
||
67 | }\ |
||
68 | \ |
||
69 | static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
70 | FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ |
||
71 | }\ |
||
72 | \ |
||
73 | static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
74 | FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ |
||
75 | }\ |
||
76 | \ |
||
77 | static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ |
||
78 | FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ |
||
79 | }\ |
||
80 | \ |
||
81 | static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *_block, const uint8_t *_pixels, ptrdiff_t line_size, int h)\ |
||
82 | {\ |
||
83 | int i, a0, b0, a1, b1;\ |
||
84 | pixel *block = (pixel*)_block;\ |
||
85 | const pixel *pixels = (const pixel*)_pixels;\ |
||
86 | line_size >>= sizeof(pixel)-1;\ |
||
87 | a0= pixels[0];\ |
||
88 | b0= pixels[1] + 2;\ |
||
89 | a0 += b0;\ |
||
90 | b0 += pixels[2];\ |
||
91 | \ |
||
92 | pixels+=line_size;\ |
||
93 | for(i=0; i |
||
94 | a1= pixels[0];\ |
||
95 | b1= pixels[1];\ |
||
96 | a1 += b1;\ |
||
97 | b1 += pixels[2];\ |
||
98 | \ |
||
99 | block[0]= (a1+a0)>>2; /* FIXME non put */\ |
||
100 | block[1]= (b1+b0)>>2;\ |
||
101 | \ |
||
102 | pixels+=line_size;\ |
||
103 | block +=line_size;\ |
||
104 | \ |
||
105 | a0= pixels[0];\ |
||
106 | b0= pixels[1] + 2;\ |
||
107 | a0 += b0;\ |
||
108 | b0 += pixels[2];\ |
||
109 | \ |
||
110 | block[0]= (a1+a0)>>2;\ |
||
111 | block[1]= (b1+b0)>>2;\ |
||
112 | pixels+=line_size;\ |
||
113 | block +=line_size;\ |
||
114 | }\ |
||
115 | }\ |
||
116 | \ |
||
117 | static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ |
||
118 | {\ |
||
119 | /* FIXME HIGH BIT DEPTH */\ |
||
120 | int i;\ |
||
121 | const uint32_t a= AV_RN32(pixels );\ |
||
122 | const uint32_t b= AV_RN32(pixels+1);\ |
||
123 | uint32_t l0= (a&0x03030303UL)\ |
||
124 | + (b&0x03030303UL)\ |
||
125 | + 0x02020202UL;\ |
||
126 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
127 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
128 | uint32_t l1,h1;\ |
||
129 | \ |
||
130 | pixels+=line_size;\ |
||
131 | for(i=0; i |
||
132 | uint32_t a= AV_RN32(pixels );\ |
||
133 | uint32_t b= AV_RN32(pixels+1);\ |
||
134 | l1= (a&0x03030303UL)\ |
||
135 | + (b&0x03030303UL);\ |
||
136 | h1= ((a&0xFCFCFCFCUL)>>2)\ |
||
137 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
138 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
139 | pixels+=line_size;\ |
||
140 | block +=line_size;\ |
||
141 | a= AV_RN32(pixels );\ |
||
142 | b= AV_RN32(pixels+1);\ |
||
143 | l0= (a&0x03030303UL)\ |
||
144 | + (b&0x03030303UL)\ |
||
145 | + 0x02020202UL;\ |
||
146 | h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
147 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
148 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
149 | pixels+=line_size;\ |
||
150 | block +=line_size;\ |
||
151 | }\ |
||
152 | }\ |
||
153 | \ |
||
154 | static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ |
||
155 | {\ |
||
156 | /* FIXME HIGH BIT DEPTH */\ |
||
157 | int j;\ |
||
158 | for(j=0; j<2; j++){\ |
||
159 | int i;\ |
||
160 | const uint32_t a= AV_RN32(pixels );\ |
||
161 | const uint32_t b= AV_RN32(pixels+1);\ |
||
162 | uint32_t l0= (a&0x03030303UL)\ |
||
163 | + (b&0x03030303UL)\ |
||
164 | + 0x02020202UL;\ |
||
165 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
166 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
167 | uint32_t l1,h1;\ |
||
168 | \ |
||
169 | pixels+=line_size;\ |
||
170 | for(i=0; i |
||
171 | uint32_t a= AV_RN32(pixels );\ |
||
172 | uint32_t b= AV_RN32(pixels+1);\ |
||
173 | l1= (a&0x03030303UL)\ |
||
174 | + (b&0x03030303UL);\ |
||
175 | h1= ((a&0xFCFCFCFCUL)>>2)\ |
||
176 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
177 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
178 | pixels+=line_size;\ |
||
179 | block +=line_size;\ |
||
180 | a= AV_RN32(pixels );\ |
||
181 | b= AV_RN32(pixels+1);\ |
||
182 | l0= (a&0x03030303UL)\ |
||
183 | + (b&0x03030303UL)\ |
||
184 | + 0x02020202UL;\ |
||
185 | h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
186 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
187 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
188 | pixels+=line_size;\ |
||
189 | block +=line_size;\ |
||
190 | }\ |
||
191 | pixels+=4-line_size*(h+1);\ |
||
192 | block +=4-line_size*h;\ |
||
193 | }\ |
||
194 | }\ |
||
195 | \ |
||
196 | static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ |
||
197 | {\ |
||
198 | /* FIXME HIGH BIT DEPTH */\ |
||
199 | int j;\ |
||
200 | for(j=0; j<2; j++){\ |
||
201 | int i;\ |
||
202 | const uint32_t a= AV_RN32(pixels );\ |
||
203 | const uint32_t b= AV_RN32(pixels+1);\ |
||
204 | uint32_t l0= (a&0x03030303UL)\ |
||
205 | + (b&0x03030303UL)\ |
||
206 | + 0x01010101UL;\ |
||
207 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
208 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
209 | uint32_t l1,h1;\ |
||
210 | \ |
||
211 | pixels+=line_size;\ |
||
212 | for(i=0; i |
||
213 | uint32_t a= AV_RN32(pixels );\ |
||
214 | uint32_t b= AV_RN32(pixels+1);\ |
||
215 | l1= (a&0x03030303UL)\ |
||
216 | + (b&0x03030303UL);\ |
||
217 | h1= ((a&0xFCFCFCFCUL)>>2)\ |
||
218 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
219 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
220 | pixels+=line_size;\ |
||
221 | block +=line_size;\ |
||
222 | a= AV_RN32(pixels );\ |
||
223 | b= AV_RN32(pixels+1);\ |
||
224 | l0= (a&0x03030303UL)\ |
||
225 | + (b&0x03030303UL)\ |
||
226 | + 0x01010101UL;\ |
||
227 | h0= ((a&0xFCFCFCFCUL)>>2)\ |
||
228 | + ((b&0xFCFCFCFCUL)>>2);\ |
||
229 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ |
||
230 | pixels+=line_size;\ |
||
231 | block +=line_size;\ |
||
232 | }\ |
||
233 | pixels+=4-line_size*(h+1);\ |
||
234 | block +=4-line_size*h;\ |
||
235 | }\ |
||
236 | }\ |
||
237 | \ |
||
238 | CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\ |
||
239 | CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\ |
||
240 | CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\ |
||
241 | av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\ |
||
242 | CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\ |
||
243 | CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\ |
||
244 | CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\ |
||
245 | |||
246 | #define op_avg(a, b) a = rnd_avg_pixel4(a, b) |
||
247 | #define op_put(a, b) a = b |
||
248 | #if BIT_DEPTH == 8 |
||
249 | #define put_no_rnd_pixels8_8_c put_pixels8_8_c |
||
250 | PIXOP2(avg, op_avg) |
||
251 | PIXOP2(put, op_put) |
||
252 | #endif |
||
253 | #undef op_avg |
||
254 | #undef op_put2;>2;> |