2 * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
3 * Copyright (c) 2011 Daniel Kang
5 * This file is part of FFmpeg.
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.
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.
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
22 #include "libavutil/cpu.h"
23 #include "libavutil/x86/asm.h"
24 #include "libavcodec/dsputil.h"
25 #include "libavcodec/mpegvideo.h"
26 #include "dsputil_mmx.h"
29 void ff_put_pixels4_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
30 void ff_avg_pixels4_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
31 void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
32 void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
33 static void ff_put_pixels16_mmxext(uint8_t *block, const uint8_t *pixels,
36 ff_put_pixels8_mmxext(block, pixels, line_size, h);
37 ff_put_pixels8_mmxext(block + 8, pixels + 8, line_size, h);
39 static void ff_avg_pixels16_mmxext(uint8_t *block, const uint8_t *pixels,
42 ff_avg_pixels8_mmxext(block, pixels, line_size, h);
43 ff_avg_pixels8_mmxext(block + 8, pixels + 8, line_size, h);
45 void ff_put_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
46 int dstStride, int src1Stride, int h);
47 void ff_avg_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
48 int dstStride, int src1Stride, int h);
49 void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
50 int dstStride, int src1Stride, int h);
51 void ff_avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
52 int dstStride, int src1Stride, int h);
53 void ff_put_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
54 int dstStride, int src1Stride, int h);
55 void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
56 int dstStride, int src1Stride, int h);
57 void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
58 int line_size, int h);
59 void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
60 int line_size, int h);
61 #define ff_put_pixels8_l2_sse2 ff_put_pixels8_l2_mmxext
62 #define ff_avg_pixels8_l2_sse2 ff_avg_pixels8_l2_mmxext
63 #define ff_put_pixels16_l2_sse2 ff_put_pixels16_l2_mmxext
64 #define ff_avg_pixels16_l2_sse2 ff_avg_pixels16_l2_mmxext
66 #define DEF_QPEL(OPNAME)\
67 void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
68 void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
69 void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_ssse3(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
70 void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_l2_mmxext(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
71 void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_mmxext(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
72 void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
73 void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
74 void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_op_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h);\
75 void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h);\
76 void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_v_mmxext(uint8_t *src, int16_t *tmp, int srcStride);\
77 void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, int dstStride);\
78 void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_mmxext(uint8_t *src, int16_t *tmp, int srcStride, int size);\
79 void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(uint8_t *src, int16_t *tmp, int srcStride, int size);\
80 void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_mmxext(uint8_t *dst, int16_t *tmp, int dstStride, int unused, int h);\
81 void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size);\
82 void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h);\
83 void ff_ ## OPNAME ## _pixels8_l2_shift5_mmxext(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h);
88 #define QPEL_H264(OPNAME, OP, MMX)\
89 static av_always_inline void ff_ ## OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
91 src -= 2*srcStride+2;\
93 ff_ ## OPNAME ## h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
98 ff_ ## OPNAME ## h264_qpel4_hv_lowpass_h_mmxext(tmp, dst, dstStride);\
101 static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
103 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
106 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
108 static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){\
109 int w = (size+8)>>2;\
110 src -= 2*srcStride+2;\
112 ff_ ## OPNAME ## h264_qpel8or16_hv1_lowpass_op_mmxext(src, tmp, srcStride, size);\
117 static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
120 ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_mmxext(dst, tmp, dstStride, 0, size);\
126 static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
127 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
129 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
130 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
131 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
134 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
135 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
136 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
139 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
140 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
143 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
144 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
145 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
148 src2 += 8*src2Stride;\
149 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
150 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
153 static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
154 ff_put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\
155 ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
157 static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
158 ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\
161 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
162 ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
165 static av_always_inline void ff_ ## OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
167 ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\
168 ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\
173 #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
175 void ff_avg_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);
176 void ff_put_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);
179 #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
180 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
181 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
182 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
185 src2 += 8*src2Stride;\
186 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
187 ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
189 #endif // ARCH_X86_64
191 #define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
192 QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
193 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
194 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
195 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
198 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
199 ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
202 #define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
203 static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
204 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
206 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
207 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
208 ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
211 static av_always_inline void ff_put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){
213 src -= 2*srcStride+2;
215 ff_put_h264_qpel8or16_hv1_lowpass_op_sse2(src, tmp, srcStride, size);
221 #define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
222 static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
223 ff_put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\
224 ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
226 static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
227 ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\
229 static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
230 ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\
233 #define ff_put_h264_qpel8_h_lowpass_l2_sse2 ff_put_h264_qpel8_h_lowpass_l2_mmxext
234 #define ff_avg_h264_qpel8_h_lowpass_l2_sse2 ff_avg_h264_qpel8_h_lowpass_l2_mmxext
235 #define ff_put_h264_qpel16_h_lowpass_l2_sse2 ff_put_h264_qpel16_h_lowpass_l2_mmxext
236 #define ff_avg_h264_qpel16_h_lowpass_l2_sse2 ff_avg_h264_qpel16_h_lowpass_l2_mmxext
238 #define ff_put_h264_qpel8_v_lowpass_ssse3 ff_put_h264_qpel8_v_lowpass_sse2
239 #define ff_avg_h264_qpel8_v_lowpass_ssse3 ff_avg_h264_qpel8_v_lowpass_sse2
240 #define ff_put_h264_qpel16_v_lowpass_ssse3 ff_put_h264_qpel16_v_lowpass_sse2
241 #define ff_avg_h264_qpel16_v_lowpass_ssse3 ff_avg_h264_qpel16_v_lowpass_sse2
243 #define ff_put_h264_qpel8or16_hv2_lowpass_sse2 ff_put_h264_qpel8or16_hv2_lowpass_mmxext
244 #define ff_avg_h264_qpel8or16_hv2_lowpass_sse2 ff_avg_h264_qpel8or16_hv2_lowpass_mmxext
246 #define H264_MC(OPNAME, SIZE, MMX, ALIGN) \
247 H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\
248 H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
249 H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
250 H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
252 static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
253 ff_put_pixels16_sse2(dst, src, stride, 16);
255 static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
256 ff_avg_pixels16_sse2(dst, src, stride, 16);
258 #define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmxext
259 #define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmxext
261 #define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \
262 static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
263 ff_ ## OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\
266 #define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
267 static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
268 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
271 static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
272 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
275 static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
276 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
279 #define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
280 static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
281 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
282 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
283 ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\
286 static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
287 ff_ ## OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
290 static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
291 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
292 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
293 ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
296 #define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
297 static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
298 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
299 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
300 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
303 static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
304 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
305 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
306 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
309 static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
310 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
311 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
312 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
315 static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
316 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
317 ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
318 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
321 static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
322 DECLARE_ALIGNED(ALIGN, uint16_t, temp)[SIZE*(SIZE<8?12:24)];\
323 ff_ ## OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\
326 static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
327 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
328 uint8_t * const halfHV= temp;\
329 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
330 assert(((int)temp & 7) == 0);\
331 ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
332 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
335 static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
336 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
337 uint8_t * const halfHV= temp;\
338 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
339 assert(((int)temp & 7) == 0);\
340 ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
341 ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
344 static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
345 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
346 uint8_t * const halfHV= temp;\
347 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
348 assert(((int)temp & 7) == 0);\
349 ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
350 ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+2, halfHV, stride, SIZE, SIZE);\
353 static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
354 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
355 uint8_t * const halfHV= temp;\
356 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
357 assert(((int)temp & 7) == 0);\
358 ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
359 ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+3, halfHV, stride, SIZE, SIZE);\
362 #define H264_MC_4816(MMX)\
363 H264_MC(put_, 4, MMX, 8)\
364 H264_MC(put_, 8, MMX, 8)\
365 H264_MC(put_, 16,MMX, 8)\
366 H264_MC(avg_, 4, MMX, 8)\
367 H264_MC(avg_, 8, MMX, 8)\
368 H264_MC(avg_, 16,MMX, 8)\
370 #define H264_MC_816(QPEL, XMM)\
371 QPEL(put_, 8, XMM, 16)\
372 QPEL(put_, 16,XMM, 16)\
373 QPEL(avg_, 8, XMM, 16)\
374 QPEL(avg_, 16,XMM, 16)\
377 #define PAVGB "pavgb"
378 QPEL_H264(put_, PUT_OP, mmxext)
379 QPEL_H264(avg_, AVG_MMXEXT_OP, mmxext)
380 QPEL_H264_V_XMM(put_, PUT_OP, sse2)
381 QPEL_H264_V_XMM(avg_,AVG_MMXEXT_OP, sse2)
382 QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
383 QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, sse2)
384 QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
385 QPEL_H264_H_XMM(avg_,AVG_MMXEXT_OP, ssse3)
386 QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
387 QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, ssse3)
391 H264_MC_816(H264_MC_V, sse2)
392 H264_MC_816(H264_MC_HV, sse2)
393 H264_MC_816(H264_MC_H, ssse3)
394 H264_MC_816(H264_MC_HV, ssse3)
398 #define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \
399 void ff_ ## OP ## _h264_qpel ## NUM ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT \
400 (uint8_t *dst, uint8_t *src, int stride);
402 #define LUMA_MC_ALL(DEPTH, TYPE, OPT) \
403 LUMA_MC_OP(put, 4, DEPTH, TYPE, OPT) \
404 LUMA_MC_OP(avg, 4, DEPTH, TYPE, OPT) \
405 LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
406 LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
407 LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
408 LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
410 #define LUMA_MC_816(DEPTH, TYPE, OPT) \
411 LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
412 LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
413 LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
414 LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
416 LUMA_MC_ALL(10, mc00, mmxext)
417 LUMA_MC_ALL(10, mc10, mmxext)
418 LUMA_MC_ALL(10, mc20, mmxext)
419 LUMA_MC_ALL(10, mc30, mmxext)
420 LUMA_MC_ALL(10, mc01, mmxext)
421 LUMA_MC_ALL(10, mc11, mmxext)
422 LUMA_MC_ALL(10, mc21, mmxext)
423 LUMA_MC_ALL(10, mc31, mmxext)
424 LUMA_MC_ALL(10, mc02, mmxext)
425 LUMA_MC_ALL(10, mc12, mmxext)
426 LUMA_MC_ALL(10, mc22, mmxext)
427 LUMA_MC_ALL(10, mc32, mmxext)
428 LUMA_MC_ALL(10, mc03, mmxext)
429 LUMA_MC_ALL(10, mc13, mmxext)
430 LUMA_MC_ALL(10, mc23, mmxext)
431 LUMA_MC_ALL(10, mc33, mmxext)
433 LUMA_MC_816(10, mc00, sse2)
434 LUMA_MC_816(10, mc10, sse2)
435 LUMA_MC_816(10, mc10, sse2_cache64)
436 LUMA_MC_816(10, mc10, ssse3_cache64)
437 LUMA_MC_816(10, mc20, sse2)
438 LUMA_MC_816(10, mc20, sse2_cache64)
439 LUMA_MC_816(10, mc20, ssse3_cache64)
440 LUMA_MC_816(10, mc30, sse2)
441 LUMA_MC_816(10, mc30, sse2_cache64)
442 LUMA_MC_816(10, mc30, ssse3_cache64)
443 LUMA_MC_816(10, mc01, sse2)
444 LUMA_MC_816(10, mc11, sse2)
445 LUMA_MC_816(10, mc21, sse2)
446 LUMA_MC_816(10, mc31, sse2)
447 LUMA_MC_816(10, mc02, sse2)
448 LUMA_MC_816(10, mc12, sse2)
449 LUMA_MC_816(10, mc22, sse2)
450 LUMA_MC_816(10, mc32, sse2)
451 LUMA_MC_816(10, mc03, sse2)
452 LUMA_MC_816(10, mc13, sse2)
453 LUMA_MC_816(10, mc23, sse2)
454 LUMA_MC_816(10, mc33, sse2)
456 #define QPEL16_OPMC(OP, MC, MMX)\
457 void ff_ ## OP ## _h264_qpel16_ ## MC ## _10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
458 ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
459 ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
462 ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
463 ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
466 #define QPEL16_OP(MC, MMX)\
467 QPEL16_OPMC(put, MC, MMX)\
468 QPEL16_OPMC(avg, MC, MMX)
471 QPEL16_OP(mc00, MMX)\
472 QPEL16_OP(mc01, MMX)\
473 QPEL16_OP(mc02, MMX)\
474 QPEL16_OP(mc03, MMX)\
475 QPEL16_OP(mc10, MMX)\
476 QPEL16_OP(mc11, MMX)\
477 QPEL16_OP(mc12, MMX)\
478 QPEL16_OP(mc13, MMX)\
479 QPEL16_OP(mc20, MMX)\
480 QPEL16_OP(mc21, MMX)\
481 QPEL16_OP(mc22, MMX)\
482 QPEL16_OP(mc23, MMX)\
483 QPEL16_OP(mc30, MMX)\
484 QPEL16_OP(mc31, MMX)\
485 QPEL16_OP(mc32, MMX)\
488 #if ARCH_X86_32 && HAVE_YASM && CONFIG_H264QPEL // ARCH_X86_64 implies SSE2+
492 #endif /* HAVE_YASM */