Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libswscale/ops_tmpl_common.c
Line
Count
Source
1
/**
2
 * Copyright (C) 2025 Niklas Haas
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
#include "ops_backend.h"
22
23
#ifndef BIT_DEPTH
24
#  error Should only be included from ops_tmpl_*.c!
25
#endif
26
27
#define WRAP_CONVERT_UINT(N)                                                    \
28
0
DECL_PATTERN(convert_uint##N)                                                   \
29
0
{                                                                               \
30
0
    u##N##block_t xu, yu, zu, wu;                                               \
31
0
                                                                                \
32
0
    SWS_LOOP                                                                    \
33
0
    for (int i = 0; i < SWS_BLOCK_SIZE; i++) {                                  \
34
0
        if (X)                                                                  \
35
0
            xu[i] = x[i];                                                       \
36
0
        if (Y)                                                                  \
37
0
            yu[i] = y[i];                                                       \
38
0
        if (Z)                                                                  \
39
0
            zu[i] = z[i];                                                       \
40
0
        if (W)                                                                  \
41
0
            wu[i] = w[i];                                                       \
42
0
    }                                                                           \
43
0
                                                                                \
44
0
    CONTINUE(u##N##block_t, xu, yu, zu, wu);                                    \
45
0
}                                                                               \
Unexecuted instantiation: ops_backend.c:convert_uint16_u8
Unexecuted instantiation: ops_backend.c:convert_uint32_u8
Unexecuted instantiation: ops_backend.c:convert_uint8_u16
Unexecuted instantiation: ops_backend.c:convert_uint32_u16
Unexecuted instantiation: ops_backend.c:convert_uint8_u32
Unexecuted instantiation: ops_backend.c:convert_uint16_u32
Unexecuted instantiation: ops_backend.c:convert_uint8_f32
Unexecuted instantiation: ops_backend.c:convert_uint16_f32
Unexecuted instantiation: ops_backend.c:convert_uint32_f32
Unexecuted instantiation: ops_backend.c:convert_uint32_u32
46
                                                                                \
47
WRAP_COMMON_PATTERNS(convert_uint##N,                                           \
48
    .op = SWS_OP_CONVERT,                                                       \
49
    .convert.to = SWS_PIXEL_U##N,                                               \
50
);
51
52
#if BIT_DEPTH != 8
53
WRAP_CONVERT_UINT(8)
54
#endif
55
56
#if BIT_DEPTH != 16
57
WRAP_CONVERT_UINT(16)
58
#endif
59
60
#if BIT_DEPTH != 32 || defined(IS_FLOAT)
61
WRAP_CONVERT_UINT(32)
62
#endif
63
64
DECL_PATTERN(clear)
65
0
{
66
0
    SWS_LOOP
67
0
    for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
68
0
        if (!X)
69
0
            x[i] = impl->priv.px[0];
70
0
        if (!Y)
71
0
            y[i] = impl->priv.px[1];
72
0
        if (!Z)
73
0
            z[i] = impl->priv.px[2];
74
0
        if (!W)
75
0
            w[i] = impl->priv.px[3];
76
0
    }
77
78
0
    CONTINUE(block_t, x, y, z, w);
79
0
}
Unexecuted instantiation: ops_backend.c:clear_u8
Unexecuted instantiation: ops_backend.c:clear_u16
Unexecuted instantiation: ops_backend.c:clear_u32
Unexecuted instantiation: ops_backend.c:clear_f32
80
81
#define WRAP_CLEAR(X, Y, Z, W)                                                  \
82
0
DECL_IMPL(clear##_##X##Y##Z##W)                                                 \
83
0
{                                                                               \
84
0
    CALL(clear, X, Y, Z, W);                                                    \
85
0
}                                                                               \
Unexecuted instantiation: ops_backend.c:clear_1110_u8
Unexecuted instantiation: ops_backend.c:clear_0111_u8
Unexecuted instantiation: ops_backend.c:clear_0011_u8
Unexecuted instantiation: ops_backend.c:clear_1011_u8
Unexecuted instantiation: ops_backend.c:clear_1001_u8
Unexecuted instantiation: ops_backend.c:clear_1100_u8
Unexecuted instantiation: ops_backend.c:clear_0101_u8
Unexecuted instantiation: ops_backend.c:clear_1010_u8
Unexecuted instantiation: ops_backend.c:clear_1000_u8
Unexecuted instantiation: ops_backend.c:clear_0100_u8
Unexecuted instantiation: ops_backend.c:clear_0010_u8
Unexecuted instantiation: ops_backend.c:clear_1110_u16
Unexecuted instantiation: ops_backend.c:clear_0111_u16
Unexecuted instantiation: ops_backend.c:clear_0011_u16
Unexecuted instantiation: ops_backend.c:clear_1011_u16
Unexecuted instantiation: ops_backend.c:clear_1001_u16
Unexecuted instantiation: ops_backend.c:clear_1100_u16
Unexecuted instantiation: ops_backend.c:clear_0101_u16
Unexecuted instantiation: ops_backend.c:clear_1010_u16
Unexecuted instantiation: ops_backend.c:clear_1000_u16
Unexecuted instantiation: ops_backend.c:clear_0100_u16
Unexecuted instantiation: ops_backend.c:clear_0010_u16
Unexecuted instantiation: ops_backend.c:clear_1110_u32
Unexecuted instantiation: ops_backend.c:clear_0111_u32
Unexecuted instantiation: ops_backend.c:clear_0011_u32
Unexecuted instantiation: ops_backend.c:clear_1011_u32
Unexecuted instantiation: ops_backend.c:clear_1001_u32
Unexecuted instantiation: ops_backend.c:clear_1100_u32
Unexecuted instantiation: ops_backend.c:clear_0101_u32
Unexecuted instantiation: ops_backend.c:clear_1010_u32
Unexecuted instantiation: ops_backend.c:clear_1000_u32
Unexecuted instantiation: ops_backend.c:clear_0100_u32
Unexecuted instantiation: ops_backend.c:clear_0010_u32
Unexecuted instantiation: ops_backend.c:clear_1110_f32
Unexecuted instantiation: ops_backend.c:clear_0111_f32
Unexecuted instantiation: ops_backend.c:clear_0011_f32
Unexecuted instantiation: ops_backend.c:clear_1011_f32
Unexecuted instantiation: ops_backend.c:clear_1001_f32
Unexecuted instantiation: ops_backend.c:clear_1100_f32
Unexecuted instantiation: ops_backend.c:clear_0101_f32
Unexecuted instantiation: ops_backend.c:clear_1010_f32
Unexecuted instantiation: ops_backend.c:clear_1000_f32
Unexecuted instantiation: ops_backend.c:clear_0100_f32
Unexecuted instantiation: ops_backend.c:clear_0010_f32
86
                                                                                \
87
DECL_ENTRY(clear##_##X##Y##Z##W,                                                \
88
    .setup = ff_sws_setup_q4,                                                   \
89
    .op = SWS_OP_CLEAR,                                                         \
90
    .flexible = true,                                                           \
91
    .unused = { !X, !Y, !Z, !W },                                               \
92
);
93
94
WRAP_CLEAR(1, 1, 1, 0) /* rgba alpha */
95
WRAP_CLEAR(0, 1, 1, 1) /* argb alpha */
96
WRAP_CLEAR(1, 0, 1, 1) /* ya alpha */
97
98
WRAP_CLEAR(0, 0, 1, 1) /* vuya chroma */
99
WRAP_CLEAR(1, 0, 0, 1) /* yuva chroma */
100
WRAP_CLEAR(1, 1, 0, 0) /* ayuv chroma */
101
WRAP_CLEAR(0, 1, 0, 1) /* uyva chroma */
102
WRAP_CLEAR(1, 0, 1, 0) /* xvyu chroma */
103
104
WRAP_CLEAR(1, 0, 0, 0) /* gray -> yuva */
105
WRAP_CLEAR(0, 1, 0, 0) /* gray -> ayuv */
106
WRAP_CLEAR(0, 0, 1, 0) /* gray -> vuya */
107
108
DECL_PATTERN(min)
109
0
{
110
0
    SWS_LOOP
111
0
    for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
112
0
        if (X)
113
0
            x[i] = FFMIN(x[i], impl->priv.px[0]);
114
0
        if (Y)
115
0
            y[i] = FFMIN(y[i], impl->priv.px[1]);
116
0
        if (Z)
117
0
            z[i] = FFMIN(z[i], impl->priv.px[2]);
118
0
        if (W)
119
0
            w[i] = FFMIN(w[i], impl->priv.px[3]);
120
0
    }
121
122
0
    CONTINUE(block_t, x, y, z, w);
123
0
}
Unexecuted instantiation: ops_backend.c:min_u8
Unexecuted instantiation: ops_backend.c:min_u16
Unexecuted instantiation: ops_backend.c:min_u32
Unexecuted instantiation: ops_backend.c:min_f32
124
125
DECL_PATTERN(max)
126
0
{
127
0
    SWS_LOOP
128
0
    for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
129
0
        if (X)
130
0
            x[i] = FFMAX(x[i], impl->priv.px[0]);
131
0
        if (Y)
132
0
            y[i] = FFMAX(y[i], impl->priv.px[1]);
133
0
        if (Z)
134
0
            z[i] = FFMAX(z[i], impl->priv.px[2]);
135
0
        if (W)
136
0
            w[i] = FFMAX(w[i], impl->priv.px[3]);
137
0
    }
138
139
0
    CONTINUE(block_t, x, y, z, w);
140
0
}
Unexecuted instantiation: ops_backend.c:max_u8
Unexecuted instantiation: ops_backend.c:max_u16
Unexecuted instantiation: ops_backend.c:max_u32
Unexecuted instantiation: ops_backend.c:max_f32
141
142
WRAP_COMMON_PATTERNS(min,
143
    .op = SWS_OP_MIN,
144
    .setup = ff_sws_setup_q4,
145
    .flexible = true,
146
);
147
148
WRAP_COMMON_PATTERNS(max,
149
    .op = SWS_OP_MAX,
150
    .setup = ff_sws_setup_q4,
151
    .flexible = true,
152
);
153
154
DECL_PATTERN(scale)
155
0
{
156
0
    const pixel_t scale = impl->priv.px[0];
157
158
0
    SWS_LOOP
159
0
    for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
160
0
        if (X)
161
0
            x[i] *= scale;
162
0
        if (Y)
163
0
            y[i] *= scale;
164
0
        if (Z)
165
0
            z[i] *= scale;
166
0
        if (W)
167
0
            w[i] *= scale;
168
0
    }
169
170
0
    CONTINUE(block_t, x, y, z, w);
171
0
}
Unexecuted instantiation: ops_backend.c:scale_u8
Unexecuted instantiation: ops_backend.c:scale_u16
Unexecuted instantiation: ops_backend.c:scale_u32
Unexecuted instantiation: ops_backend.c:scale_f32
172
173
WRAP_COMMON_PATTERNS(scale,
174
    .op = SWS_OP_SCALE,
175
    .setup = ff_sws_setup_q,
176
    .flexible = true,
177
);
178
179
static void fn(process)(const SwsOpExec *exec, const void *priv,
180
                        const int bx_start, const int y_start,
181
                        int bx_end, int y_end)
182
0
{
183
0
    const SwsOpChain *chain = priv;
184
0
    const SwsOpImpl *impl = chain->impl;
185
0
    u32block_t x, y, z, w; /* allocate enough space for any intermediate */
186
187
0
    SwsOpIter iterdata;
188
0
    SwsOpIter *iter = &iterdata; /* for CONTINUE() macro to work */
189
190
0
    for (iter->y = y_start; iter->y < y_end; iter->y++) {
191
0
        for (int i = 0; i < 4; i++) {
192
0
            iter->in[i]  = exec->in[i]  + (iter->y - y_start) * exec->in_stride[i];
193
0
            iter->out[i] = exec->out[i] + (iter->y - y_start) * exec->out_stride[i];
194
0
        }
195
196
0
        for (int block = bx_start; block < bx_end; block++) {
197
0
            iter->x = block * SWS_BLOCK_SIZE;
198
0
            CONTINUE(block_t, (void *) x, (void *) y, (void *) z, (void *) w);
199
0
        }
200
0
    }
201
0
}
Unexecuted instantiation: ops_backend.c:process_u8
Unexecuted instantiation: ops_backend.c:process_u16
Unexecuted instantiation: ops_backend.c:process_u32
Unexecuted instantiation: ops_backend.c:process_f32