Coverage Report

Created: 2025-12-31 07:57

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
51.0k
{
37
51.0k
    switch (width) {
38
6.24k
    case 2:
39
6.24k
        put_pixels2_8_c(dst, src, stride, height);
40
6.24k
        break;
41
15.6k
    case 4:
42
15.6k
        put_pixels4_8_c(dst, src, stride, height);
43
15.6k
        break;
44
21.5k
    case 8:
45
21.5k
        put_pixels8_8_c(dst, src, stride, height);
46
21.5k
        break;
47
7.64k
    case 16:
48
7.64k
        put_pixels16_8_c(dst, src, stride, height);
49
7.64k
        break;
50
51.0k
    }
51
51.0k
}
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
12.0k
{
56
12.0k
    int i, j;
57
58
105k
    for (i = 0; i < height; i++) {
59
871k
        for (j = 0; j < width; j++)
60
777k
            dst[j] = ((2 * src[j] + src[j + 1] + 1) *
61
777k
                      683) >> 11;
62
93.8k
        src += stride;
63
93.8k
        dst += stride;
64
93.8k
    }
65
12.0k
}
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
18.3k
{
70
18.3k
    int i, j;
71
72
143k
    for (i = 0; i < height; i++) {
73
1.21M
        for (j = 0; j < width; j++)
74
1.09M
            dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
75
1.09M
                      683) >> 11;
76
124k
        src += stride;
77
124k
        dst += stride;
78
124k
    }
79
18.3k
}
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
10.6k
{
84
10.6k
    int i, j;
85
86
101k
    for (i = 0; i < height; i++) {
87
830k
        for (j = 0; j < width; j++)
88
739k
            dst[j] = ((2 * src[j] + src[j + stride] + 1) *
89
739k
                      683) >> 11;
90
90.4k
        src += stride;
91
90.4k
        dst += stride;
92
90.4k
    }
93
10.6k
}
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
8.46k
{
98
8.46k
    int i, j;
99
100
84.4k
    for (i = 0; i < height; i++) {
101
590k
        for (j = 0; j < width; j++)
102
514k
            dst[j] = ((4 * src[j]          + 3 * src[j + 1] +
103
514k
                       3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
104
514k
                      2731) >> 15;
105
75.9k
        src += stride;
106
75.9k
        dst += stride;
107
75.9k
    }
108
8.46k
}
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
13.0k
{
113
13.0k
    int i, j;
114
115
135k
    for (i = 0; i < height; i++) {
116
966k
        for (j = 0; j < width; j++)
117
844k
            dst[j] = ((3 * src[j]          + 2 * src[j + 1] +
118
844k
                       4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
119
844k
                      2731) >> 15;
120
122k
        src += stride;
121
122k
        dst += stride;
122
122k
    }
123
13.0k
}
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
28.1k
{
128
28.1k
    int i, j;
129
130
289k
    for (i = 0; i < height; i++) {
131
2.44M
        for (j = 0; j < width; j++)
132
2.18M
            dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
133
2.18M
                      683) >> 11;
134
261k
        src += stride;
135
261k
        dst += stride;
136
261k
    }
137
28.1k
}
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
16.4k
{
142
16.4k
    int i, j;
143
144
171k
    for (i = 0; i < height; i++) {
145
1.87M
        for (j = 0; j < width; j++)
146
1.71M
            dst[j] = ((3 * src[j]          + 4 * src[j + 1] +
147
1.71M
                       2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
148
1.71M
                      2731) >> 15;
149
155k
        src += stride;
150
155k
        dst += stride;
151
155k
    }
152
16.4k
}
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
15.8k
{
157
15.8k
    int i, j;
158
159
167k
    for (i = 0; i < height; i++) {
160
1.74M
        for (j = 0; j < width; j++)
161
1.59M
            dst[j] = ((2 * src[j]          + 3 * src[j + 1] +
162
1.59M
                       3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
163
1.59M
                      2731) >> 15;
164
151k
        src += stride;
165
151k
        dst += stride;
166
151k
    }
167
15.8k
}
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.69k
{
172
7.69k
    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
5.12k
    case 8:
180
5.12k
        avg_pixels8_8_c(dst, src, stride, height);
181
5.12k
        break;
182
2.56k
    case 16:
183
2.56k
        avg_pixels16_8_c(dst, src, stride, height);
184
2.56k
        break;
185
7.69k
    }
186
7.69k
}
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.76k
{
191
3.76k
    int i, j;
192
193
43.8k
    for (i = 0; i < height; i++) {
194
521k
        for (j = 0; j < width; j++)
195
481k
            dst[j] = (dst[j] +
196
481k
                      (((2 * src[j] + src[j + 1] + 1) *
197
481k
                        683) >> 11) + 1) >> 1;
198
40.1k
        src += stride;
199
40.1k
        dst += stride;
200
40.1k
    }
201
3.76k
}
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.10k
{
206
2.10k
    int i, j;
207
208
24.6k
    for (i = 0; i < height; i++) {
209
292k
        for (j = 0; j < width; j++)
210
269k
            dst[j] = (dst[j] +
211
269k
                      (((src[j] + 2 * src[j + 1] + 1) *
212
269k
                        683) >> 11) + 1) >> 1;
213
22.4k
        src += stride;
214
22.4k
        dst += stride;
215
22.4k
    }
216
2.10k
}
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
5.32k
{
221
5.32k
    int i, j;
222
223
62.1k
    for (i = 0; i < height; i++) {
224
738k
        for (j = 0; j < width; j++)
225
681k
            dst[j] = (dst[j] +
226
681k
                      (((2 * src[j] + src[j + stride] + 1) *
227
681k
                        683) >> 11) + 1) >> 1;
228
56.8k
        src += stride;
229
56.8k
        dst += stride;
230
56.8k
    }
231
5.32k
}
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
7.05k
{
236
7.05k
    int i, j;
237
238
82.2k
    for (i = 0; i < height; i++) {
239
977k
        for (j = 0; j < width; j++)
240
902k
            dst[j] = (dst[j] +
241
902k
                      (((4 * src[j]          + 3 * src[j + 1] +
242
902k
                         3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
243
902k
                        2731) >> 15) + 1) >> 1;
244
75.2k
        src += stride;
245
75.2k
        dst += stride;
246
75.2k
    }
247
7.05k
}
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
5.06k
{
252
5.06k
    int i, j;
253
254
59.0k
    for (i = 0; i < height; i++) {
255
701k
        for (j = 0; j < width; j++)
256
647k
            dst[j] = (dst[j] +
257
647k
                      (((3 * src[j]          + 2 * src[j + 1] +
258
647k
                         4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
259
647k
                        2731) >> 15) + 1) >> 1;
260
53.9k
        src += stride;
261
53.9k
        dst += stride;
262
53.9k
    }
263
5.06k
}
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.22k
{
268
2.22k
    int i, j;
269
270
25.9k
    for (i = 0; i < height; i++) {
271
308k
        for (j = 0; j < width; j++)
272
284k
            dst[j] = (dst[j] +
273
284k
                      (((src[j] + 2 * src[j + stride] + 1) *
274
284k
                        683) >> 11) + 1) >> 1;
275
23.7k
        src += stride;
276
23.7k
        dst += stride;
277
23.7k
    }
278
2.22k
}
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.19k
{
283
2.19k
    int i, j;
284
285
25.5k
    for (i = 0; i < height; i++) {
286
304k
        for (j = 0; j < width; j++)
287
280k
            dst[j] = (dst[j] +
288
280k
                      (((3 * src[j]          + 4 * src[j + 1] +
289
280k
                         2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
290
280k
                        2731) >> 15) + 1) >> 1;
291
23.3k
        src += stride;
292
23.3k
        dst += stride;
293
23.3k
    }
294
2.19k
}
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.38k
{
299
2.38k
    int i, j;
300
301
27.8k
    for (i = 0; i < height; i++) {
302
331k
        for (j = 0; j < width; j++)
303
305k
            dst[j] = (dst[j] +
304
305k
                      (((2 * src[j]          + 3 * src[j + 1] +
305
305k
                         3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
306
305k
                        2731) >> 15) + 1) >> 1;
307
25.4k
        src += stride;
308
25.4k
        dst += stride;
309
25.4k
    }
310
2.38k
}
311
312
av_cold void ff_tpeldsp_init(TpelDSPContext *c)
313
2.69k
{
314
2.69k
    c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
315
2.69k
    c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
316
2.69k
    c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
317
2.69k
    c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
318
2.69k
    c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
319
2.69k
    c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
320
2.69k
    c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
321
2.69k
    c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
322
2.69k
    c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
323
324
2.69k
    c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
325
2.69k
    c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
326
2.69k
    c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
327
2.69k
    c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
328
2.69k
    c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
329
2.69k
    c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
330
2.69k
    c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
331
2.69k
    c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
332
2.69k
    c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
333
2.69k
}