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