FFmpeg
tpeldsp.c
Go to the documentation of this file.
1 /*
2  * thirdpel DSP functions
3  *
4  * This file is part of FFmpeg.
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 /**
22  * @file
23  * thirdpel DSP functions
24  */
25 
26 #include <stdint.h>
27 
28 #include "libavutil/attributes.h"
29 #include "tpeldsp.h"
30 
31 #define BIT_DEPTH 8
32 #include "pel_template.c"
33 
34 static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
35  int stride, int width, int height)
36 {
37  switch (width) {
38  case 2:
39  put_pixels2_8_c(dst, src, stride, height);
40  break;
41  case 4:
42  put_pixels4_8_c(dst, src, stride, height);
43  break;
44  case 8:
45  put_pixels8_8_c(dst, src, stride, height);
46  break;
47  case 16:
48  put_pixels16_8_c(dst, src, stride, height);
49  break;
50  }
51 }
52 
53 static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
54  int stride, int width, int height)
55 {
56  int i, j;
57 
58  for (i = 0; i < height; i++) {
59  for (j = 0; j < width; j++)
60  dst[j] = ((2 * src[j] + src[j + 1] + 1) *
61  683) >> 11;
62  src += stride;
63  dst += stride;
64  }
65 }
66 
67 static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
68  int stride, int width, int height)
69 {
70  int i, j;
71 
72  for (i = 0; i < height; i++) {
73  for (j = 0; j < width; j++)
74  dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
75  683) >> 11;
76  src += stride;
77  dst += stride;
78  }
79 }
80 
81 static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
82  int stride, int width, int height)
83 {
84  int i, j;
85 
86  for (i = 0; i < height; i++) {
87  for (j = 0; j < width; j++)
88  dst[j] = ((2 * src[j] + src[j + stride] + 1) *
89  683) >> 11;
90  src += stride;
91  dst += stride;
92  }
93 }
94 
95 static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
96  int stride, int width, int height)
97 {
98  int i, j;
99 
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) *
104  2731) >> 15;
105  src += stride;
106  dst += stride;
107  }
108 }
109 
110 static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
111  int stride, int width, int height)
112 {
113  int i, j;
114 
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) *
119  2731) >> 15;
120  src += stride;
121  dst += stride;
122  }
123 }
124 
125 static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
126  int stride, int width, int height)
127 {
128  int i, j;
129 
130  for (i = 0; i < height; i++) {
131  for (j = 0; j < width; j++)
132  dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
133  683) >> 11;
134  src += stride;
135  dst += stride;
136  }
137 }
138 
139 static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
140  int stride, int width, int height)
141 {
142  int i, j;
143 
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) *
148  2731) >> 15;
149  src += stride;
150  dst += stride;
151  }
152 }
153 
154 static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
155  int stride, int width, int height)
156 {
157  int i, j;
158 
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) *
163  2731) >> 15;
164  src += stride;
165  dst += stride;
166  }
167 }
168 
169 static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
170  int stride, int width, int height)
171 {
172  switch (width) {
173  case 2:
174  avg_pixels2_8_c(dst, src, stride, height);
175  break;
176  case 4:
177  avg_pixels4_8_c(dst, src, stride, height);
178  break;
179  case 8:
180  avg_pixels8_8_c(dst, src, stride, height);
181  break;
182  case 16:
183  avg_pixels16_8_c(dst, src, stride, height);
184  break;
185  }
186 }
187 
188 static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
189  int stride, int width, int height)
190 {
191  int i, j;
192 
193  for (i = 0; i < height; i++) {
194  for (j = 0; j < width; j++)
195  dst[j] = (dst[j] +
196  (((2 * src[j] + src[j + 1] + 1) *
197  683) >> 11) + 1) >> 1;
198  src += stride;
199  dst += stride;
200  }
201 }
202 
203 static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
204  int stride, int width, int height)
205 {
206  int i, j;
207 
208  for (i = 0; i < height; i++) {
209  for (j = 0; j < width; j++)
210  dst[j] = (dst[j] +
211  (((src[j] + 2 * src[j + 1] + 1) *
212  683) >> 11) + 1) >> 1;
213  src += stride;
214  dst += stride;
215  }
216 }
217 
218 static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
219  int stride, int width, int height)
220 {
221  int i, j;
222 
223  for (i = 0; i < height; i++) {
224  for (j = 0; j < width; j++)
225  dst[j] = (dst[j] +
226  (((2 * src[j] + src[j + stride] + 1) *
227  683) >> 11) + 1) >> 1;
228  src += stride;
229  dst += stride;
230  }
231 }
232 
233 static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
234  int stride, int width, int height)
235 {
236  int i, j;
237 
238  for (i = 0; i < height; i++) {
239  for (j = 0; j < width; j++)
240  dst[j] = (dst[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;
244  src += stride;
245  dst += stride;
246  }
247 }
248 
249 static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
250  int stride, int width, int height)
251 {
252  int i, j;
253 
254  for (i = 0; i < height; i++) {
255  for (j = 0; j < width; j++)
256  dst[j] = (dst[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;
260  src += stride;
261  dst += stride;
262  }
263 }
264 
265 static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
266  int stride, int width, int height)
267 {
268  int i, j;
269 
270  for (i = 0; i < height; i++) {
271  for (j = 0; j < width; j++)
272  dst[j] = (dst[j] +
273  (((src[j] + 2 * src[j + stride] + 1) *
274  683) >> 11) + 1) >> 1;
275  src += stride;
276  dst += stride;
277  }
278 }
279 
280 static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
281  int stride, int width, int height)
282 {
283  int i, j;
284 
285  for (i = 0; i < height; i++) {
286  for (j = 0; j < width; j++)
287  dst[j] = (dst[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;
291  src += stride;
292  dst += stride;
293  }
294 }
295 
296 static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
297  int stride, int width, int height)
298 {
299  int i, j;
300 
301  for (i = 0; i < height; i++) {
302  for (j = 0; j < width; j++)
303  dst[j] = (dst[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;
307  src += stride;
308  dst += stride;
309  }
310 }
311 
313 {
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;
323 
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;
333 }
pel_template.c
avg_tpel_pixels_mc20_c
static void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:203
stride
int stride
Definition: mace.c:144
avg_tpel_pixels_mc22_c
static void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:296
put_tpel_pixels_mc02_c
static void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:125
avg_tpel_pixels_mc01_c
static void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:218
avg_tpel_pixels_mc02_c
static void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:265
put_tpel_pixels_mc12_c
static void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:110
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
TpelDSPContext
thirdpel DSP context
Definition: tpeldsp.h:42
ff_tpeldsp_init
av_cold void ff_tpeldsp_init(TpelDSPContext *c)
Definition: tpeldsp.c:312
put_tpel_pixels_mc22_c
static void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:154
avg_tpel_pixels_mc12_c
static void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:249
put_tpel_pixels_mc01_c
static void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:81
put_tpel_pixels_mc11_c
static void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:95
avg_tpel_pixels_mc00_c
static void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:169
src
#define src
Definition: vp8dsp.c:255
put_tpel_pixels_mc00_c
static void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:34
tpeldsp.h
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
avg_tpel_pixels_mc10_c
static void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:188
avg_tpel_pixels_mc21_c
static void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:280
put_tpel_pixels_mc20_c
static void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:67
height
#define height
attributes.h
i
int i
Definition: input.c:407
uint8_t
uint8_t
Definition: audio_convert.c:194
avg_tpel_pixels_mc11_c
static void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:233
put_tpel_pixels_mc21_c
static void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:139
put_tpel_pixels_mc10_c
static void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height)
Definition: tpeldsp.c:53