2 * Copyright (c) 2000, 2001 Fabrice Bellard
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 * This file is part of Libav.
7 * Libav 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 * Libav 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 Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #define DEF_HPEL(OPNAME, OP) \
25 static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, \
26 const uint8_t *src1, \
27 const uint8_t *src2, \
34 for (i = 0; i < h; i++) { \
36 a = AV_RN4P(&src1[i * src_stride1]); \
37 b = AV_RN4P(&src2[i * src_stride2]); \
38 OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
39 a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
40 b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
41 OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
42 rnd_avg_pixel4(a, b)); \
46 static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, \
47 const uint8_t *src1, \
48 const uint8_t *src2, \
55 for (i = 0; i < h; i++) { \
57 a = AV_RN4P(&src1[i * src_stride1]); \
58 b = AV_RN4P(&src2[i * src_stride2]); \
59 OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
63 static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, \
64 const uint8_t *src1, \
65 const uint8_t *src2, \
72 for (i = 0; i < h; i++) { \
74 a = AV_RN2P(&src1[i * src_stride1]); \
75 b = AV_RN2P(&src2[i * src_stride2]); \
76 OP(*((pixel2 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
80 static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, \
81 const uint8_t *src1, \
82 const uint8_t *src2, \
88 FUNC(OPNAME ## _pixels8_l2)(dst, src1, src2, dst_stride, \
89 src_stride1, src_stride2, h); \
90 FUNC(OPNAME ## _pixels8_l2)(dst + 8 * sizeof(pixel), \
91 src1 + 8 * sizeof(pixel), \
92 src2 + 8 * sizeof(pixel), \
93 dst_stride, src_stride1, \
97 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
98 #define op_put(a, b) a = b
100 DEF_HPEL(put, op_put)