FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h264qpel_template.c
Go to the documentation of this file.
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3  * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
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/common.h"
23 #include "bit_depth_template.c"
24 #include "hpel_template.c"
25 
26 static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
27 {
28  int i;
29  for(i=0; i<h; i++)
30  {
31  AV_WN2P(dst , AV_RN2P(src ));
32  dst+=dstStride;
33  src+=srcStride;
34  }
35 }
36 
37 static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
38 {
39  int i;
40  for(i=0; i<h; i++)
41  {
42  AV_WN4P(dst , AV_RN4P(src ));
43  dst+=dstStride;
44  src+=srcStride;
45  }
46 }
47 
48 static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
49 {
50  int i;
51  for(i=0; i<h; i++)
52  {
53  AV_WN4P(dst , AV_RN4P(src ));
54  AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
55  dst+=dstStride;
56  src+=srcStride;
57  }
58 }
59 
60 static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
61 {
62  int i;
63  for(i=0; i<h; i++)
64  {
65  AV_WN4P(dst , AV_RN4P(src ));
66  AV_WN4P(dst+ 4*sizeof(pixel), AV_RN4P(src+ 4*sizeof(pixel)));
67  AV_WN4P(dst+ 8*sizeof(pixel), AV_RN4P(src+ 8*sizeof(pixel)));
68  AV_WN4P(dst+12*sizeof(pixel), AV_RN4P(src+12*sizeof(pixel)));
69  dst+=dstStride;
70  src+=srcStride;
71  }
72 }
73 
74 #define H264_LOWPASS(OPNAME, OP, OP2) \
75 static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
76  const int h=2;\
77  INIT_CLIP\
78  int i;\
79  pixel *dst = (pixel*)p_dst;\
80  pixel *src = (pixel*)p_src;\
81  dstStride >>= sizeof(pixel)-1;\
82  srcStride >>= sizeof(pixel)-1;\
83  for(i=0; i<h; i++)\
84  {\
85  OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
86  OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
87  dst+=dstStride;\
88  src+=srcStride;\
89  }\
90 }\
91 \
92 static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
93  const int w=2;\
94  INIT_CLIP\
95  int i;\
96  pixel *dst = (pixel*)p_dst;\
97  pixel *src = (pixel*)p_src;\
98  dstStride >>= sizeof(pixel)-1;\
99  srcStride >>= sizeof(pixel)-1;\
100  for(i=0; i<w; i++)\
101  {\
102  const int srcB= src[-2*srcStride];\
103  const int srcA= src[-1*srcStride];\
104  const int src0= src[0 *srcStride];\
105  const int src1= src[1 *srcStride];\
106  const int src2= src[2 *srcStride];\
107  const int src3= src[3 *srcStride];\
108  const int src4= src[4 *srcStride];\
109  OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
110  OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
111  dst++;\
112  src++;\
113  }\
114 }\
115 \
116 static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
117  const int h=2;\
118  const int w=2;\
119  const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
120  INIT_CLIP\
121  int i;\
122  pixel *dst = (pixel*)p_dst;\
123  pixel *src = (pixel*)p_src;\
124  dstStride >>= sizeof(pixel)-1;\
125  srcStride >>= sizeof(pixel)-1;\
126  src -= 2*srcStride;\
127  for(i=0; i<h+5; i++)\
128  {\
129  tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
130  tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
131  tmp+=tmpStride;\
132  src+=srcStride;\
133  }\
134  tmp -= tmpStride*(h+5-2);\
135  for(i=0; i<w; i++)\
136  {\
137  const int tmpB= tmp[-2*tmpStride] - pad;\
138  const int tmpA= tmp[-1*tmpStride] - pad;\
139  const int tmp0= tmp[0 *tmpStride] - pad;\
140  const int tmp1= tmp[1 *tmpStride] - pad;\
141  const int tmp2= tmp[2 *tmpStride] - pad;\
142  const int tmp3= tmp[3 *tmpStride] - pad;\
143  const int tmp4= tmp[4 *tmpStride] - pad;\
144  OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
145  OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
146  dst++;\
147  tmp++;\
148  }\
149 }\
150 static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
151  const int h=4;\
152  INIT_CLIP\
153  int i;\
154  pixel *dst = (pixel*)p_dst;\
155  pixel *src = (pixel*)p_src;\
156  dstStride >>= sizeof(pixel)-1;\
157  srcStride >>= sizeof(pixel)-1;\
158  for(i=0; i<h; i++)\
159  {\
160  OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
161  OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
162  OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
163  OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
164  dst+=dstStride;\
165  src+=srcStride;\
166  }\
167 }\
168 \
169 static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
170  const int w=4;\
171  INIT_CLIP\
172  int i;\
173  pixel *dst = (pixel*)p_dst;\
174  pixel *src = (pixel*)p_src;\
175  dstStride >>= sizeof(pixel)-1;\
176  srcStride >>= sizeof(pixel)-1;\
177  for(i=0; i<w; i++)\
178  {\
179  const int srcB= src[-2*srcStride];\
180  const int srcA= src[-1*srcStride];\
181  const int src0= src[0 *srcStride];\
182  const int src1= src[1 *srcStride];\
183  const int src2= src[2 *srcStride];\
184  const int src3= src[3 *srcStride];\
185  const int src4= src[4 *srcStride];\
186  const int src5= src[5 *srcStride];\
187  const int src6= src[6 *srcStride];\
188  OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
189  OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
190  OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
191  OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
192  dst++;\
193  src++;\
194  }\
195 }\
196 \
197 static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
198  const int h=4;\
199  const int w=4;\
200  const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
201  INIT_CLIP\
202  int i;\
203  pixel *dst = (pixel*)p_dst;\
204  pixel *src = (pixel*)p_src;\
205  dstStride >>= sizeof(pixel)-1;\
206  srcStride >>= sizeof(pixel)-1;\
207  src -= 2*srcStride;\
208  for(i=0; i<h+5; i++)\
209  {\
210  tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
211  tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
212  tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
213  tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
214  tmp+=tmpStride;\
215  src+=srcStride;\
216  }\
217  tmp -= tmpStride*(h+5-2);\
218  for(i=0; i<w; i++)\
219  {\
220  const int tmpB= tmp[-2*tmpStride] - pad;\
221  const int tmpA= tmp[-1*tmpStride] - pad;\
222  const int tmp0= tmp[0 *tmpStride] - pad;\
223  const int tmp1= tmp[1 *tmpStride] - pad;\
224  const int tmp2= tmp[2 *tmpStride] - pad;\
225  const int tmp3= tmp[3 *tmpStride] - pad;\
226  const int tmp4= tmp[4 *tmpStride] - pad;\
227  const int tmp5= tmp[5 *tmpStride] - pad;\
228  const int tmp6= tmp[6 *tmpStride] - pad;\
229  OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
230  OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
231  OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
232  OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
233  dst++;\
234  tmp++;\
235  }\
236 }\
237 \
238 static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
239  const int h=8;\
240  INIT_CLIP\
241  int i;\
242  pixel *dst = (pixel*)p_dst;\
243  pixel *src = (pixel*)p_src;\
244  dstStride >>= sizeof(pixel)-1;\
245  srcStride >>= sizeof(pixel)-1;\
246  for(i=0; i<h; i++)\
247  {\
248  OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
249  OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
250  OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
251  OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
252  OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
253  OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
254  OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
255  OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
256  dst+=dstStride;\
257  src+=srcStride;\
258  }\
259 }\
260 \
261 static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
262  const int w=8;\
263  INIT_CLIP\
264  int i;\
265  pixel *dst = (pixel*)p_dst;\
266  pixel *src = (pixel*)p_src;\
267  dstStride >>= sizeof(pixel)-1;\
268  srcStride >>= sizeof(pixel)-1;\
269  for(i=0; i<w; i++)\
270  {\
271  const int srcB= src[-2*srcStride];\
272  const int srcA= src[-1*srcStride];\
273  const int src0= src[0 *srcStride];\
274  const int src1= src[1 *srcStride];\
275  const int src2= src[2 *srcStride];\
276  const int src3= src[3 *srcStride];\
277  const int src4= src[4 *srcStride];\
278  const int src5= src[5 *srcStride];\
279  const int src6= src[6 *srcStride];\
280  const int src7= src[7 *srcStride];\
281  const int src8= src[8 *srcStride];\
282  const int src9= src[9 *srcStride];\
283  const int src10=src[10*srcStride];\
284  OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
285  OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
286  OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
287  OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
288  OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
289  OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
290  OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
291  OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
292  dst++;\
293  src++;\
294  }\
295 }\
296 \
297 static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
298  const int h=8;\
299  const int w=8;\
300  const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
301  INIT_CLIP\
302  int i;\
303  pixel *dst = (pixel*)p_dst;\
304  pixel *src = (pixel*)p_src;\
305  dstStride >>= sizeof(pixel)-1;\
306  srcStride >>= sizeof(pixel)-1;\
307  src -= 2*srcStride;\
308  for(i=0; i<h+5; i++)\
309  {\
310  tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
311  tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
312  tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
313  tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
314  tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
315  tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
316  tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
317  tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
318  tmp+=tmpStride;\
319  src+=srcStride;\
320  }\
321  tmp -= tmpStride*(h+5-2);\
322  for(i=0; i<w; i++)\
323  {\
324  const int tmpB= tmp[-2*tmpStride] - pad;\
325  const int tmpA= tmp[-1*tmpStride] - pad;\
326  const int tmp0= tmp[0 *tmpStride] - pad;\
327  const int tmp1= tmp[1 *tmpStride] - pad;\
328  const int tmp2= tmp[2 *tmpStride] - pad;\
329  const int tmp3= tmp[3 *tmpStride] - pad;\
330  const int tmp4= tmp[4 *tmpStride] - pad;\
331  const int tmp5= tmp[5 *tmpStride] - pad;\
332  const int tmp6= tmp[6 *tmpStride] - pad;\
333  const int tmp7= tmp[7 *tmpStride] - pad;\
334  const int tmp8= tmp[8 *tmpStride] - pad;\
335  const int tmp9= tmp[9 *tmpStride] - pad;\
336  const int tmp10=tmp[10*tmpStride] - pad;\
337  OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
338  OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
339  OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
340  OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
341  OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
342  OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
343  OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
344  OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
345  dst++;\
346  tmp++;\
347  }\
348 }\
349 \
350 static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
351  FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
352  FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
353  src += 8*srcStride;\
354  dst += 8*dstStride;\
355  FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
356  FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
357 }\
358 \
359 static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
360  FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
361  FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
362  src += 8*srcStride;\
363  dst += 8*dstStride;\
364  FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
365  FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
366 }\
367 \
368 static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
369  FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
370  FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
371  src += 8*srcStride;\
372  dst += 8*dstStride;\
373  FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
374  FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
375 }\
376 
377 #define H264_MC(OPNAME, SIZE) \
378 static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
379  FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
380 }\
381 \
382 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
383  uint8_t half[SIZE*SIZE*sizeof(pixel)];\
384  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
385  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
386 }\
387 \
388 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
389  FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
390 }\
391 \
392 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
393  uint8_t half[SIZE*SIZE*sizeof(pixel)];\
394  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
395  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
396 }\
397 \
398 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
399  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
400  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
401  uint8_t half[SIZE*SIZE*sizeof(pixel)];\
402  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
403  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
404  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
405 }\
406 \
407 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
408  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
409  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
410  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
411  FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
412 }\
413 \
414 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
415  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
416  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
417  uint8_t half[SIZE*SIZE*sizeof(pixel)];\
418  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
419  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
420  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
421 }\
422 \
423 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
424  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
425  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
426  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
427  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
428  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
429  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
430  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
431  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
432 }\
433 \
434 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
435  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
436  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
437  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
438  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
439  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
440  FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
441  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
442  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
443 }\
444 \
445 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
446  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
447  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
448  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
449  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
450  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
451  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
452  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
453  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
454 }\
455 \
456 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
457  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
458  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
459  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
460  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
461  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
462  FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
463  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
464  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
465 }\
466 \
467 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
468  pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
469  FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
470 }\
471 \
472 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
473  pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
474  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
475  uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
476  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
477  FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
478  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
479 }\
480 \
481 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
482  pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
483  uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
484  uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
485  FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
486  FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
487  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
488 }\
489 \
490 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
491  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
492  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
493  pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
494  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
495  uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
496  FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
497  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
498  FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
499  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
500 }\
501 \
502 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
503  uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
504  uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
505  pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
506  uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
507  uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
508  FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
509  FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
510  FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
511  FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
512 }\
513 
514 #define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
515 //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
516 #define op_put(a, b) a = CLIP(((b) + 16)>>5)
517 #define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
518 #define op2_put(a, b) a = CLIP(((b) + 512)>>10)
519 
520 H264_LOWPASS(put_ , op_put, op2_put)
521 H264_LOWPASS(avg_ , op_avg, op2_avg)
522 H264_MC(put_, 2)
523 H264_MC(put_, 4)
524 H264_MC(put_, 8)
525 H264_MC(put_, 16)
526 H264_MC(avg_, 4)
527 H264_MC(avg_, 8)
528 H264_MC(avg_, 16)
529 
530 #undef op_avg
531 #undef op_put
532 #undef op2_avg
533 #undef op2_put
534 
535 #if BIT_DEPTH == 8
536 # define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
537 # define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
538 # define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
539 # define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
540 #elif BIT_DEPTH == 9
541 # define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
542 # define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
543 # define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
544 # define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
545 #elif BIT_DEPTH == 10
546 # define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
547 # define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
548 # define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
549 # define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
550 #elif BIT_DEPTH == 12
551 # define put_h264_qpel8_mc00_12_c ff_put_pixels8x8_12_c
552 # define avg_h264_qpel8_mc00_12_c ff_avg_pixels8x8_12_c
553 # define put_h264_qpel16_mc00_12_c ff_put_pixels16x16_12_c
554 # define avg_h264_qpel16_mc00_12_c ff_avg_pixels16x16_12_c
555 #elif BIT_DEPTH == 14
556 # define put_h264_qpel8_mc00_14_c ff_put_pixels8x8_14_c
557 # define avg_h264_qpel8_mc00_14_c ff_avg_pixels8x8_14_c
558 # define put_h264_qpel16_mc00_14_c ff_put_pixels16x16_14_c
559 # define avg_h264_qpel16_mc00_14_c ff_avg_pixels16x16_14_c
560 #endif