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
22
24
25 #ifndef BIT_DEPTH
27 #endif
28
29 #if BIT_DEPTH == 32
30 # define PIXEL_TYPE SWS_PIXEL_F32
31 # define PIXEL_MAX FLT_MAX
32 # define PIXEL_MIN FLT_MIN
33 # define pixel_t float
34 # define block_t f32block_t
36 #else
37 # error Invalid BIT_DEPTH
38 #endif
39
43
45 {
46 const int size = 1 <<
op->dither.size_log2;
48 /* We special case this value */
51 return 0;
52 }
53
58
59 for (
int y = 0; y <
size; y++) {
60 for (
int x = 0; x <
size; x++)
62 for (
int x =
size; x <
width; x++)
/* pad to block size */
64 }
65
66 return 0;
67 }
68
70 {
72 const int mask = (1 << size_log2) - 1;
73 const int y_line = iter->y;
74 const int row0 = (y_line + 0) &
mask;
75 const int row1 = (y_line + 3) &
mask;
76 const int row2 = (y_line + 2) &
mask;
77 const int row3 = (y_line + 5) &
mask;
78 const int size = 1 << size_log2;
81
88 }
89
91 }
92
93 #define WRAP_DITHER(N) \
94 DECL_IMPL(dither##N) \
95 { \
96 CALL(dither, N); \
97 } \
98 \
99 DECL_ENTRY(dither##N, \
100 .op = SWS_OP_DITHER, \
101 .dither_size = N, \
102 .setup = fn(setup_dither), \
103 .free = av_free, \
104 );
105
115
117 /* Stored in split form for convenience */
121
123 {
125
126 for (
int i = 0;
i < 4;
i++) {
127 for (int j = 0; j < 4; j++)
130 }
131
133 }
134
135 /**
136 * Fully general case for a 5x5 linear affine transformation. Should never be
137 * called without constant `mask`. This function will compile down to the
138 * appropriately optimized version for the required subset of operations when
139 * called with a constant mask.
140 */
142 {
143 const fn(LinCoeffs)
c = *(
const fn(LinCoeffs) *) impl->priv.ptr;
144
151
157
163
169
175 }
176
178 }
179
180 #define WRAP_LINEAR(NAME, MASK) \
181 DECL_IMPL(linear_##NAME) \
182 { \
183 CALL(linear_mask, MASK); \
184 } \
185 \
186 DECL_ENTRY(linear_##NAME, \
187 .op = SWS_OP_LINEAR, \
188 .setup = fn(setup_linear), \
189 .free = av_free, \
190 .linear_mask = (MASK), \
191 );
192
207
210 .entries = {
214
219
229
231 &
fn(op_linear_alpha),
232 &
fn(op_linear_lumalpha),
235 &
fn(op_linear_row0a),
236 &
fn(op_linear_diag3),
237 &
fn(op_linear_diag4),
238 &
fn(op_linear_diagoff3),
239 &
fn(op_linear_matrix3),
240 &
fn(op_linear_affine3),
241 &
fn(op_linear_affine3a),
242 &
fn(op_linear_matrix4),
243 &
fn(op_linear_affine4),
244
246 },
247 };
248
249 #undef PIXEL_TYPE
250 #undef PIXEL_MAX
251 #undef PIXEL_MIN
252 #undef pixel_t
253 #undef block_t
254 #undef px
255
256 #undef FMT_CHAR
257 #undef IS_FLOAT