2 * thirdpel DSP functions
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * thirdpel DSP functions
28 #include "libavutil/attributes.h"
32 #include "pel_template.c"
34 static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
35 int stride, int width, int height)
39 put_pixels2_8_c(dst, src, stride, height);
42 put_pixels4_8_c(dst, src, stride, height);
45 put_pixels8_8_c(dst, src, stride, height);
48 put_pixels16_8_c(dst, src, stride, height);
53 static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
54 int stride, int width, int height)
58 for (i = 0; i < height; i++) {
59 for (j = 0; j < width; j++)
60 dst[j] = ((2 * src[j] + src[j + 1] + 1) *
67 static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
68 int stride, int width, int height)
72 for (i = 0; i < height; i++) {
73 for (j = 0; j < width; j++)
74 dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
81 static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
82 int stride, int width, int height)
86 for (i = 0; i < height; i++) {
87 for (j = 0; j < width; j++)
88 dst[j] = ((2 * src[j] + src[j + stride] + 1) *
95 static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
96 int stride, int width, int height)
100 for (i = 0; i < height; i++) {
101 for (j = 0; j < width; j++)
102 dst[j] = ((4 * src[j] + 3 * src[j + 1] +
103 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
110 static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
111 int stride, int width, int height)
115 for (i = 0; i < height; i++) {
116 for (j = 0; j < width; j++)
117 dst[j] = ((3 * src[j] + 2 * src[j + 1] +
118 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
125 static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
126 int stride, int width, int height)
130 for (i = 0; i < height; i++) {
131 for (j = 0; j < width; j++)
132 dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
139 static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
140 int stride, int width, int height)
144 for (i = 0; i < height; i++) {
145 for (j = 0; j < width; j++)
146 dst[j] = ((3 * src[j] + 4 * src[j + 1] +
147 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
154 static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
155 int stride, int width, int height)
159 for (i = 0; i < height; i++) {
160 for (j = 0; j < width; j++)
161 dst[j] = ((2 * src[j] + 3 * src[j + 1] +
162 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
169 static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
170 int stride, int width, int height)
174 avg_pixels2_8_c(dst, src, stride, height);
177 avg_pixels4_8_c(dst, src, stride, height);
180 avg_pixels8_8_c(dst, src, stride, height);
183 avg_pixels16_8_c(dst, src, stride, height);
188 static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
189 int stride, int width, int height)
193 for (i = 0; i < height; i++) {
194 for (j = 0; j < width; j++)
196 (((2 * src[j] + src[j + 1] + 1) *
197 683) >> 11) + 1) >> 1;
203 static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
204 int stride, int width, int height)
208 for (i = 0; i < height; i++) {
209 for (j = 0; j < width; j++)
211 (((src[j] + 2 * src[j + 1] + 1) *
212 683) >> 11) + 1) >> 1;
218 static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
219 int stride, int width, int height)
223 for (i = 0; i < height; i++) {
224 for (j = 0; j < width; j++)
226 (((2 * src[j] + src[j + stride] + 1) *
227 683) >> 11) + 1) >> 1;
233 static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
234 int stride, int width, int height)
238 for (i = 0; i < height; i++) {
239 for (j = 0; j < width; j++)
241 (((4 * src[j] + 3 * src[j + 1] +
242 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
243 2731) >> 15) + 1) >> 1;
249 static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
250 int stride, int width, int height)
254 for (i = 0; i < height; i++) {
255 for (j = 0; j < width; j++)
257 (((3 * src[j] + 2 * src[j + 1] +
258 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
259 2731) >> 15) + 1) >> 1;
265 static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
266 int stride, int width, int height)
270 for (i = 0; i < height; i++) {
271 for (j = 0; j < width; j++)
273 (((src[j] + 2 * src[j + stride] + 1) *
274 683) >> 11) + 1) >> 1;
280 static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
281 int stride, int width, int height)
285 for (i = 0; i < height; i++) {
286 for (j = 0; j < width; j++)
288 (((3 * src[j] + 4 * src[j + 1] +
289 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
290 2731) >> 15) + 1) >> 1;
296 static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
297 int stride, int width, int height)
301 for (i = 0; i < height; i++) {
302 for (j = 0; j < width; j++)
304 (((2 * src[j] + 3 * src[j + 1] +
305 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
306 2731) >> 15) + 1) >> 1;
312 av_cold void ff_tpeldsp_init(TpelDSPContext *c)
314 c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
315 c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
316 c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
317 c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
318 c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
319 c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
320 c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
321 c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
322 c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
324 c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
325 c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
326 c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
327 c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
328 c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
329 c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
330 c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
331 c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
332 c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;