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