]> git.sesse.net Git - ffmpeg/blob - libavcodec/hpel_template.c
dsputil: Move thirdpel-related bits into their own context
[ffmpeg] / libavcodec / hpel_template.c
1 /*
2  * Copyright (c) 2000, 2001 Fabrice Bellard
3  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of Libav.
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include "pixels.h"
23
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,     \
28                                                int dst_stride,          \
29                                                int src_stride1,         \
30                                                int src_stride2,         \
31                                                int h)                   \
32 {                                                                       \
33     int i;                                                              \
34     for (i = 0; i < h; i++) {                                           \
35         pixel4 a, b;                                                    \
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));                                       \
43     }                                                                   \
44 }                                                                       \
45                                                                         \
46 static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst,            \
47                                                const uint8_t *src1,     \
48                                                const uint8_t *src2,     \
49                                                int dst_stride,          \
50                                                int src_stride1,         \
51                                                int src_stride2,         \
52                                                int h)                   \
53 {                                                                       \
54     int i;                                                              \
55     for (i = 0; i < h; i++) {                                           \
56         pixel4 a, b;                                                    \
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));   \
60     }                                                                   \
61 }                                                                       \
62                                                                         \
63 static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst,            \
64                                                const uint8_t *src1,     \
65                                                const uint8_t *src2,     \
66                                                int dst_stride,          \
67                                                int src_stride1,         \
68                                                int src_stride2,         \
69                                                int h)                   \
70 {                                                                       \
71     int i;                                                              \
72     for (i = 0; i < h; i++) {                                           \
73         pixel4 a, b;                                                    \
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));   \
77     }                                                                   \
78 }                                                                       \
79                                                                         \
80 static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst,           \
81                                                 const uint8_t *src1,    \
82                                                 const uint8_t *src2,    \
83                                                 int dst_stride,         \
84                                                 int src_stride1,        \
85                                                 int src_stride2,        \
86                                                 int h)                  \
87 {                                                                       \
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,                \
94                                 src_stride2, h);                        \
95 }                                                                       \
96
97 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
98 #define op_put(a, b) a = b
99 DEF_HPEL(avg, op_avg)
100 DEF_HPEL(put, op_put)
101 #undef op_avg
102 #undef op_put