Coverage Report

Created: 2026-10-28 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/tpeldsp.c
Line
Count
Source
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
39.7k
{
37
39.7k
    switch (width) {
38
4.62k
    case 2:
39
4.62k
        put_pixels2_8_c(dst, src, stride, height);
40
4.62k
        break;
41
10.7k
    case 4:
42
10.7k
        put_pixels4_8_c(dst, src, stride, height);
43
10.7k
        break;
44
17.6k
    case 8:
45
17.6k
        put_pixels8_8_c(dst, src, stride, height);
46
17.6k
        break;
47
6.73k
    case 16:
48
6.73k
        put_pixels16_8_c(dst, src, stride, height);
49
6.73k
        break;
50
39.7k
    }
51
39.7k
}
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
10.2k
{
56
10.2k
    int i, j;
57
58
95.2k
    for (i = 0; i < height; i++) {
59
804k
        for (j = 0; j < width; j++)
60
719k
            dst[j] = ((2 * src[j] + src[j + 1] + 1) *
61
719k
                      683) >> 11;
62
84.9k
        src += stride;
63
84.9k
        dst += stride;
64
84.9k
    }
65
10.2k
}
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
16.0k
{
70
16.0k
    int i, j;
71
72
127k
    for (i = 0; i < height; i++) {
73
1.12M
        for (j = 0; j < width; j++)
74
1.01M
            dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
75
1.01M
                      683) >> 11;
76
111k
        src += stride;
77
111k
        dst += stride;
78
111k
    }
79
16.0k
}
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
8.36k
{
84
8.36k
    int i, j;
85
86
81.7k
    for (i = 0; i < height; i++) {
87
697k
        for (j = 0; j < width; j++)
88
623k
            dst[j] = ((2 * src[j] + src[j + stride] + 1) *
89
623k
                      683) >> 11;
90
73.4k
        src += stride;
91
73.4k
        dst += stride;
92
73.4k
    }
93
8.36k
}
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
6.37k
{
98
6.37k
    int i, j;
99
100
62.8k
    for (i = 0; i < height; i++) {
101
445k
        for (j = 0; j < width; j++)
102
389k
            dst[j] = ((4 * src[j]          + 3 * src[j + 1] +
103
389k
                       3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
104
389k
                      2731) >> 15;
105
56.4k
        src += stride;
106
56.4k
        dst += stride;
107
56.4k
    }
108
6.37k
}
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
9.37k
{
113
9.37k
    int i, j;
114
115
96.7k
    for (i = 0; i < height; i++) {
116
725k
        for (j = 0; j < width; j++)
117
638k
            dst[j] = ((3 * src[j]          + 2 * src[j + 1] +
118
638k
                       4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
119
638k
                      2731) >> 15;
120
87.3k
        src += stride;
121
87.3k
        dst += stride;
122
87.3k
    }
123
9.37k
}
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
21.0k
{
128
21.0k
    int i, j;
129
130
219k
    for (i = 0; i < height; i++) {
131
1.98M
        for (j = 0; j < width; j++)
132
1.78M
            dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
133
1.78M
                      683) >> 11;
134
198k
        src += stride;
135
198k
        dst += stride;
136
198k
    }
137
21.0k
}
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
14.2k
{
142
14.2k
    int i, j;
143
144
153k
    for (i = 0; i < height; i++) {
145
1.70M
        for (j = 0; j < width; j++)
146
1.56M
            dst[j] = ((3 * src[j]          + 4 * src[j + 1] +
147
1.56M
                       2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
148
1.56M
                      2731) >> 15;
149
138k
        src += stride;
150
138k
        dst += stride;
151
138k
    }
152
14.2k
}
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
14.5k
{
157
14.5k
    int i, j;
158
159
156k
    for (i = 0; i < height; i++) {
160
1.66M
        for (j = 0; j < width; j++)
161
1.52M
            dst[j] = ((2 * src[j]          + 3 * src[j + 1] +
162
1.52M
                       3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
163
1.52M
                      2731) >> 15;
164
141k
        src += stride;
165
141k
        dst += stride;
166
141k
    }
167
14.5k
}
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
7.36k
{
172
7.36k
    switch (width) {
173
0
    case 2:
174
0
        avg_pixels2_8_c(dst, src, stride, height);
175
0
        break;
176
0
    case 4:
177
0
        avg_pixels4_8_c(dst, src, stride, height);
178
0
        break;
179
4.91k
    case 8:
180
4.91k
        avg_pixels8_8_c(dst, src, stride, height);
181
4.91k
        break;
182
2.45k
    case 16:
183
2.45k
        avg_pixels16_8_c(dst, src, stride, height);
184
2.45k
        break;
185
7.36k
    }
186
7.36k
}
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
3.45k
{
191
3.45k
    int i, j;
192
193
40.3k
    for (i = 0; i < height; i++) {
194
479k
        for (j = 0; j < width; j++)
195
442k
            dst[j] = (dst[j] +
196
442k
                      (((2 * src[j] + src[j + 1] + 1) *
197
442k
                        683) >> 11) + 1) >> 1;
198
36.8k
        src += stride;
199
36.8k
        dst += stride;
200
36.8k
    }
201
3.45k
}
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
2.25k
{
206
2.25k
    int i, j;
207
208
26.2k
    for (i = 0; i < height; i++) {
209
312k
        for (j = 0; j < width; j++)
210
288k
            dst[j] = (dst[j] +
211
288k
                      (((src[j] + 2 * src[j + 1] + 1) *
212
288k
                        683) >> 11) + 1) >> 1;
213
24.0k
        src += stride;
214
24.0k
        dst += stride;
215
24.0k
    }
216
2.25k
}
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
4.51k
{
221
4.51k
    int i, j;
222
223
52.7k
    for (i = 0; i < height; i++) {
224
626k
        for (j = 0; j < width; j++)
225
578k
            dst[j] = (dst[j] +
226
578k
                      (((2 * src[j] + src[j + stride] + 1) *
227
578k
                        683) >> 11) + 1) >> 1;
228
48.1k
        src += stride;
229
48.1k
        dst += stride;
230
48.1k
    }
231
4.51k
}
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
6.89k
{
236
6.89k
    int i, j;
237
238
80.3k
    for (i = 0; i < height; i++) {
239
955k
        for (j = 0; j < width; j++)
240
882k
            dst[j] = (dst[j] +
241
882k
                      (((4 * src[j]          + 3 * src[j + 1] +
242
882k
                         3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
243
882k
                        2731) >> 15) + 1) >> 1;
244
73.5k
        src += stride;
245
73.5k
        dst += stride;
246
73.5k
    }
247
6.89k
}
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
4.78k
{
252
4.78k
    int i, j;
253
254
55.8k
    for (i = 0; i < height; i++) {
255
663k
        for (j = 0; j < width; j++)
256
612k
            dst[j] = (dst[j] +
257
612k
                      (((3 * src[j]          + 2 * src[j + 1] +
258
612k
                         4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
259
612k
                        2731) >> 15) + 1) >> 1;
260
51.0k
        src += stride;
261
51.0k
        dst += stride;
262
51.0k
    }
263
4.78k
}
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
2.24k
{
268
2.24k
    int i, j;
269
270
26.1k
    for (i = 0; i < height; i++) {
271
311k
        for (j = 0; j < width; j++)
272
287k
            dst[j] = (dst[j] +
273
287k
                      (((src[j] + 2 * src[j + stride] + 1) *
274
287k
                        683) >> 11) + 1) >> 1;
275
23.9k
        src += stride;
276
23.9k
        dst += stride;
277
23.9k
    }
278
2.24k
}
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
2.08k
{
283
2.08k
    int i, j;
284
285
24.3k
    for (i = 0; i < height; i++) {
286
289k
        for (j = 0; j < width; j++)
287
266k
            dst[j] = (dst[j] +
288
266k
                      (((3 * src[j]          + 4 * src[j + 1] +
289
266k
                         2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
290
266k
                        2731) >> 15) + 1) >> 1;
291
22.2k
        src += stride;
292
22.2k
        dst += stride;
293
22.2k
    }
294
2.08k
}
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
2.28k
{
299
2.28k
    int i, j;
300
301
26.6k
    for (i = 0; i < height; i++) {
302
316k
        for (j = 0; j < width; j++)
303
292k
            dst[j] = (dst[j] +
304
292k
                      (((2 * src[j]          + 3 * src[j + 1] +
305
292k
                         3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
306
292k
                        2731) >> 15) + 1) >> 1;
307
24.3k
        src += stride;
308
24.3k
        dst += stride;
309
24.3k
    }
310
2.28k
}
311
312
av_cold void ff_tpeldsp_init(TpelDSPContext *c)
313
2.44k
{
314
2.44k
    c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
315
2.44k
    c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
316
2.44k
    c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
317
2.44k
    c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
318
2.44k
    c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
319
2.44k
    c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
320
2.44k
    c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
321
2.44k
    c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
322
2.44k
    c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
323
324
2.44k
    c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
325
2.44k
    c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
326
2.44k
    c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
327
2.44k
    c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
328
2.44k
    c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
329
2.44k
    c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
330
2.44k
    c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
331
2.44k
    c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
332
2.44k
    c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
333
2.44k
}