Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libswscale/swscale_internal.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
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
#ifndef SWSCALE_SWSCALE_INTERNAL_H
22
#define SWSCALE_SWSCALE_INTERNAL_H
23
24
#include <stdatomic.h>
25
#include <assert.h>
26
27
#include "config.h"
28
#include "swscale.h"
29
#include "graph.h"
30
31
#include "libavutil/avassert.h"
32
#include "libavutil/common.h"
33
#include "libavutil/frame.h"
34
#include "libavutil/intreadwrite.h"
35
#include "libavutil/log.h"
36
#include "libavutil/mem_internal.h"
37
#include "libavutil/pixfmt.h"
38
#include "libavutil/pixdesc.h"
39
#include "libavutil/slicethread.h"
40
#include "libavutil/half2float.h"
41
42
#if HAVE_ALTIVEC
43
#define SWSINTERNAL_ADDITIONAL_ASM_SIZE (7*16 + 2*8 + /* alignment */ 16)
44
#endif
45
#ifndef SWSINTERNAL_ADDITIONAL_ASM_SIZE
46
0
#define SWSINTERNAL_ADDITIONAL_ASM_SIZE 0
47
#endif
48
49
#define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
50
51
0
#define YUVRGB_TABLE_HEADROOM 512
52
0
#define YUVRGB_TABLE_LUMA_HEADROOM 512
53
54
0
#define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
55
56
#define SWS_MAX_THREADS 8192 /* sanity clamp */
57
58
#if HAVE_BIGENDIAN
59
#define ALT32_CORR (-1)
60
#else
61
0
#define ALT32_CORR   1
62
#endif
63
64
#if ARCH_X86_64
65
#   define APCK_PTR2  8
66
#   define APCK_COEF 16
67
#   define APCK_SIZE 24
68
#else
69
#   define APCK_PTR2  4
70
#   define APCK_COEF  8
71
0
#   define APCK_SIZE 16
72
#endif
73
74
0
#define RETCODE_USE_CASCADE -12345
75
76
typedef struct SwsInternal SwsInternal;
77
78
static inline SwsInternal *sws_internal(const SwsContext *sws)
79
0
{
80
0
    return (SwsInternal *) sws;
81
0
}
Unexecuted instantiation: swscale.c:sws_internal
Unexecuted instantiation: utils.c:sws_internal
Unexecuted instantiation: vscale.c:sws_internal
Unexecuted instantiation: yuv2rgb.c:sws_internal
Unexecuted instantiation: alphablend.c:sws_internal
Unexecuted instantiation: graph.c:sws_internal
Unexecuted instantiation: hscale_fast_bilinear.c:sws_internal
Unexecuted instantiation: input.c:sws_internal
Unexecuted instantiation: options.c:sws_internal
Unexecuted instantiation: output.c:sws_internal
Unexecuted instantiation: rgb2rgb.c:sws_internal
Unexecuted instantiation: slice.c:sws_internal
Unexecuted instantiation: swscale_unscaled.c:sws_internal
Unexecuted instantiation: gamma.c:sws_internal
Unexecuted instantiation: hscale.c:sws_internal
82
83
typedef struct Range {
84
    unsigned int start;
85
    unsigned int len;
86
} Range;
87
88
typedef struct RangeList {
89
    Range          *ranges;
90
    unsigned int nb_ranges;
91
    int             ranges_allocated;
92
} RangeList;
93
94
int ff_range_add(RangeList *r, unsigned int start, unsigned int len);
95
96
typedef int (*SwsFunc)(SwsInternal *c, const uint8_t *const src[],
97
                       const int srcStride[], int srcSliceY, int srcSliceH,
98
                       uint8_t *const dst[], const int dstStride[]);
99
100
typedef void (*SwsColorFunc)(const SwsInternal *c, uint8_t *dst, int dst_stride,
101
                             const uint8_t *src, int src_stride, int w, int h);
102
103
typedef struct SwsLuts {
104
    uint16_t *in;
105
    uint16_t *out;
106
} SwsLuts;
107
108
typedef struct SwsColorXform {
109
    SwsLuts gamma;
110
    int16_t mat[3][3];
111
} SwsColorXform;
112
113
/**
114
 * Write one line of horizontally scaled data to planar output
115
 * without any additional vertical scaling (or point-scaling).
116
 *
117
 * @param src     scaled source data, 15 bits for 8-10-bit output,
118
 *                19 bits for 16-bit output (in int32_t)
119
 * @param dest    pointer to the output plane. For >8-bit
120
 *                output, this is in uint16_t
121
 * @param dstW    width of destination in pixels
122
 * @param dither  ordered dither array of type int16_t and size 8
123
 * @param offset  Dither offset
124
 */
125
typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
126
                               const uint8_t *dither, int offset);
127
128
/**
129
 * Write one line of horizontally scaled data to planar output
130
 * with multi-point vertical scaling between input pixels.
131
 *
132
 * @param filter        vertical luma/alpha scaling coefficients, 12 bits [0,4096]
133
 * @param src           scaled luma (Y) or alpha (A) source data, 15 bits for
134
 *                      8-10-bit output, 19 bits for 16-bit output (in int32_t)
135
 * @param filterSize    number of vertical input lines to scale
136
 * @param dest          pointer to output plane. For >8-bit
137
 *                      output, this is in uint16_t
138
 * @param dstW          width of destination pixels
139
 * @param offset        Dither offset
140
 */
141
typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
142
                               const int16_t **src, uint8_t *dest, int dstW,
143
                               const uint8_t *dither, int offset);
144
145
/**
146
 * Write one line of horizontally scaled chroma to interleaved output
147
 * with multi-point vertical scaling between input pixels.
148
 *
149
 * @param dstFormat     destination pixel format
150
 * @param chrDither     ordered dither array of type uint8_t and size 8
151
 * @param chrFilter     vertical chroma scaling coefficients, 12 bits [0,4096]
152
 * @param chrUSrc       scaled chroma (U) source data, 15 bits for 8-10-bit
153
 *                      output, 19 bits for 16-bit output (in int32_t)
154
 * @param chrVSrc       scaled chroma (V) source data, 15 bits for 8-10-bit
155
 *                      output, 19 bits for 16-bit output (in int32_t)
156
 * @param chrFilterSize number of vertical chroma input lines to scale
157
 * @param dest          pointer to the output plane. For >8-bit
158
 *                      output, this is in uint16_t
159
 * @param dstW          width of chroma planes
160
 */
161
typedef void (*yuv2interleavedX_fn)(enum AVPixelFormat dstFormat,
162
                                    const uint8_t *chrDither,
163
                                    const int16_t *chrFilter,
164
                                    int chrFilterSize,
165
                                    const int16_t **chrUSrc,
166
                                    const int16_t **chrVSrc,
167
                                    uint8_t *dest, int dstW);
168
169
/**
170
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
171
 * output without any additional vertical scaling (or point-scaling). Note
172
 * that this function may do chroma scaling, see the "uvalpha" argument.
173
 *
174
 * @param c       SWS scaling context
175
 * @param lumSrc  scaled luma (Y) source data, 15 bits for 8-10-bit output,
176
 *                19 bits for 16-bit output (in int32_t)
177
 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
178
 *                19 bits for 16-bit output (in int32_t)
179
 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
180
 *                19 bits for 16-bit output (in int32_t)
181
 * @param alpSrc  scaled alpha (A) source data, 15 bits for 8-10-bit output,
182
 *                19 bits for 16-bit output (in int32_t)
183
 * @param dest    pointer to the output plane. For 16-bit output, this is
184
 *                uint16_t
185
 * @param dstW    width of lumSrc and alpSrc in pixels, number of pixels
186
 *                to write into dest[]
187
 * @param uvalpha chroma scaling coefficient for the second line of chroma
188
 *                pixels, either 2048 or 0. If 0, one chroma input is used
189
 *                for 2 output pixels (or if the SWS_FULL_CHR_H_INT flag
190
 *                is set, it generates 1 output pixel). If 2048, two chroma
191
 *                input pixels should be averaged for 2 output pixels (this
192
 *                only happens if SWS_FULL_CHR_H_INT is not set)
193
 * @param y       vertical line number for this output. This does not need
194
 *                to be used to calculate the offset in the destination,
195
 *                but can be used to generate comfort noise using dithering
196
 *                for some output formats.
197
 */
198
typedef void (*yuv2packed1_fn)(SwsInternal *c, const int16_t *lumSrc,
199
                               const int16_t *chrUSrc[2],
200
                               const int16_t *chrVSrc[2],
201
                               const int16_t *alpSrc, uint8_t *dest,
202
                               int dstW, int uvalpha, int y);
203
/**
204
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
205
 * output by doing bilinear scaling between two input lines.
206
 *
207
 * @param c       SWS scaling context
208
 * @param lumSrc  scaled luma (Y) source data, 15 bits for 8-10-bit output,
209
 *                19 bits for 16-bit output (in int32_t)
210
 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
211
 *                19 bits for 16-bit output (in int32_t)
212
 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
213
 *                19 bits for 16-bit output (in int32_t)
214
 * @param alpSrc  scaled alpha (A) source data, 15 bits for 8-10-bit output,
215
 *                19 bits for 16-bit output (in int32_t)
216
 * @param dest    pointer to the output plane. For 16-bit output, this is
217
 *                uint16_t
218
 * @param dstW    width of lumSrc and alpSrc in pixels, number of pixels
219
 *                to write into dest[]
220
 * @param yalpha  luma/alpha scaling coefficients for the second input line.
221
 *                The first line's coefficients can be calculated by using
222
 *                4096 - yalpha
223
 * @param uvalpha chroma scaling coefficient for the second input line. The
224
 *                first line's coefficients can be calculated by using
225
 *                4096 - uvalpha
226
 * @param y       vertical line number for this output. This does not need
227
 *                to be used to calculate the offset in the destination,
228
 *                but can be used to generate comfort noise using dithering
229
 *                for some output formats.
230
 */
231
typedef void (*yuv2packed2_fn)(SwsInternal *c, const int16_t *lumSrc[2],
232
                               const int16_t *chrUSrc[2],
233
                               const int16_t *chrVSrc[2],
234
                               const int16_t *alpSrc[2],
235
                               uint8_t *dest,
236
                               int dstW, int yalpha, int uvalpha, int y);
237
/**
238
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
239
 * output by doing multi-point vertical scaling between input pixels.
240
 *
241
 * @param c             SWS scaling context
242
 * @param lumFilter     vertical luma/alpha scaling coefficients, 12 bits [0,4096]
243
 * @param lumSrc        scaled luma (Y) source data, 15 bits for 8-10-bit output,
244
 *                      19 bits for 16-bit output (in int32_t)
245
 * @param lumFilterSize number of vertical luma/alpha input lines to scale
246
 * @param chrFilter     vertical chroma scaling coefficients, 12 bits [0,4096]
247
 * @param chrUSrc       scaled chroma (U) source data, 15 bits for 8-10-bit output,
248
 *                      19 bits for 16-bit output (in int32_t)
249
 * @param chrVSrc       scaled chroma (V) source data, 15 bits for 8-10-bit output,
250
 *                      19 bits for 16-bit output (in int32_t)
251
 * @param chrFilterSize number of vertical chroma input lines to scale
252
 * @param alpSrc        scaled alpha (A) source data, 15 bits for 8-10-bit output,
253
 *                      19 bits for 16-bit output (in int32_t)
254
 * @param dest          pointer to the output plane. For 16-bit output, this is
255
 *                      uint16_t
256
 * @param dstW          width of lumSrc and alpSrc in pixels, number of pixels
257
 *                      to write into dest[]
258
 * @param y             vertical line number for this output. This does not need
259
 *                      to be used to calculate the offset in the destination,
260
 *                      but can be used to generate comfort noise using dithering
261
 *                      or some output formats.
262
 */
263
typedef void (*yuv2packedX_fn)(SwsInternal *c, const int16_t *lumFilter,
264
                               const int16_t **lumSrc, int lumFilterSize,
265
                               const int16_t *chrFilter,
266
                               const int16_t **chrUSrc,
267
                               const int16_t **chrVSrc, int chrFilterSize,
268
                               const int16_t **alpSrc, uint8_t *dest,
269
                               int dstW, int y);
270
271
/**
272
 * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
273
 * output by doing multi-point vertical scaling between input pixels.
274
 *
275
 * @param c             SWS scaling context
276
 * @param lumFilter     vertical luma/alpha scaling coefficients, 12 bits [0,4096]
277
 * @param lumSrc        scaled luma (Y) source data, 15 bits for 8-10-bit output,
278
 *                      19 bits for 16-bit output (in int32_t)
279
 * @param lumFilterSize number of vertical luma/alpha input lines to scale
280
 * @param chrFilter     vertical chroma scaling coefficients, 12 bits [0,4096]
281
 * @param chrUSrc       scaled chroma (U) source data, 15 bits for 8-10-bit output,
282
 *                      19 bits for 16-bit output (in int32_t)
283
 * @param chrVSrc       scaled chroma (V) source data, 15 bits for 8-10-bit output,
284
 *                      19 bits for 16-bit output (in int32_t)
285
 * @param chrFilterSize number of vertical chroma input lines to scale
286
 * @param alpSrc        scaled alpha (A) source data, 15 bits for 8-10-bit output,
287
 *                      19 bits for 16-bit output (in int32_t)
288
 * @param dest          pointer to the output planes. For 16-bit output, this is
289
 *                      uint16_t
290
 * @param dstW          width of lumSrc and alpSrc in pixels, number of pixels
291
 *                      to write into dest[]
292
 * @param y             vertical line number for this output. This does not need
293
 *                      to be used to calculate the offset in the destination,
294
 *                      but can be used to generate comfort noise using dithering
295
 *                      or some output formats.
296
 */
297
typedef void (*yuv2anyX_fn)(SwsInternal *c, const int16_t *lumFilter,
298
                            const int16_t **lumSrc, int lumFilterSize,
299
                            const int16_t *chrFilter,
300
                            const int16_t **chrUSrc,
301
                            const int16_t **chrVSrc, int chrFilterSize,
302
                            const int16_t **alpSrc, uint8_t **dest,
303
                            int dstW, int y);
304
305
/**
306
 * Unscaled conversion of luma/alpha plane to YV12 for horizontal scaler.
307
 */
308
typedef void (*planar1_YV12_fn)(uint8_t *dst, const uint8_t *src, const uint8_t *src2,
309
                                const uint8_t *src3, int width, uint32_t *pal,
310
                                void *opaque);
311
312
/**
313
 * Unscaled conversion of chroma plane to YV12 for horizontal scaler.
314
 */
315
typedef void (*planar2_YV12_fn)(uint8_t *dst, uint8_t *dst2, const uint8_t *src,
316
                                const uint8_t *src2, const uint8_t *src3,
317
                                int width, uint32_t *pal, void *opaque);
318
319
/**
320
 * Unscaled conversion of arbitrary planar data (e.g. RGBA) to YV12, through
321
 * conversion using the given color matrix.
322
 */
323
typedef void (*planarX_YV12_fn)(uint8_t *dst, const uint8_t *src[4], int width,
324
                                int32_t *rgb2yuv, void *opaque);
325
326
typedef void (*planarX2_YV12_fn)(uint8_t *dst, uint8_t *dst2,
327
                                 const uint8_t *src[4], int width,
328
                                 int32_t *rgb2yuv, void *opaque);
329
330
struct SwsSlice;
331
struct SwsFilterDescriptor;
332
333
/* This struct should be aligned on at least a 32-byte boundary. */
334
struct SwsInternal {
335
    /* Currently active user-facing options. Also contains AVClass */
336
    SwsContext opts;
337
338
    /* Parent context (for slice contexts) */
339
    SwsContext *parent;
340
341
    AVSliceThread      *slicethread;
342
    SwsContext        **slice_ctx;
343
    int                *slice_err;
344
    int              nb_slice_ctx;
345
346
    /* Scaling graph, reinitialized dynamically as needed. */
347
    SwsGraph *graph[2]; /* top, bottom fields */
348
349
    // values passed to current sws_receive_slice() call
350
    int dst_slice_start;
351
    int dst_slice_height;
352
353
    /**
354
     * Note that src, dst, srcStride, dstStride will be copied in the
355
     * sws_scale() wrapper so they can be freely modified here.
356
     */
357
    SwsFunc convert_unscaled;
358
    int chrSrcW;                  ///< Width  of source      chroma     planes.
359
    int chrSrcH;                  ///< Height of source      chroma     planes.
360
    int chrDstW;                  ///< Width  of destination chroma     planes.
361
    int chrDstH;                  ///< Height of destination chroma     planes.
362
    int lumXInc, chrXInc;
363
    int lumYInc, chrYInc;
364
    int dstFormatBpp;             ///< Number of bits per pixel of the destination pixel format.
365
    int srcFormatBpp;             ///< Number of bits per pixel of the source      pixel format.
366
    int dstBpc, srcBpc;
367
    int chrSrcHSubSample;         ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source      image.
368
    int chrSrcVSubSample;         ///< Binary logarithm of vertical   subsampling factor between luma/alpha and chroma planes in source      image.
369
    int chrDstHSubSample;         ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
370
    int chrDstVSubSample;         ///< Binary logarithm of vertical   subsampling factor between luma/alpha and chroma planes in destination image.
371
    int vChrDrop;                 ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
372
    int sliceDir;                 ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
373
374
    AVFrame *frame_src;
375
    AVFrame *frame_dst;
376
377
    RangeList src_ranges;
378
379
    /* The cascaded_* fields allow splitting a scaler task into multiple
380
     * sequential steps, this is for example used to limit the maximum
381
     * downscaling factor that needs to be supported in one scaler.
382
     */
383
    SwsContext *cascaded_context[3];
384
    int cascaded_tmpStride[2][4];
385
    uint8_t *cascaded_tmp[2][4];
386
    int cascaded_mainindex;
387
388
    double gamma_value;
389
    int is_internal_gamma;
390
    uint16_t *gamma;
391
    uint16_t *inv_gamma;
392
393
    int numDesc;
394
    int descIndex[2];
395
    int numSlice;
396
    struct SwsSlice *slice;
397
    struct SwsFilterDescriptor *desc;
398
399
    uint32_t pal_yuv[256];
400
    uint32_t pal_rgb[256];
401
402
    float uint2float_lut[256];
403
404
    /**
405
     * @name Scaled horizontal lines ring buffer.
406
     * The horizontal scaler keeps just enough scaled lines in a ring buffer
407
     * so they may be passed to the vertical scaler. The pointers to the
408
     * allocated buffers for each line are duplicated in sequence in the ring
409
     * buffer to simplify indexing and avoid wrapping around between lines
410
     * inside the vertical scaler code. The wrapping is done before the
411
     * vertical scaler is called.
412
     */
413
    //@{
414
    int lastInLumBuf;             ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
415
    int lastInChrBuf;             ///< Last scaled horizontal chroma     line from source in the ring buffer.
416
    //@}
417
418
    uint8_t *formatConvBuffer;
419
    int needAlpha;
420
421
    /**
422
     * @name Horizontal and vertical filters.
423
     * To better understand the following fields, here is a pseudo-code of
424
     * their usage in filtering a horizontal line:
425
     * @code
426
     * for (i = 0; i < width; i++) {
427
     *     dst[i] = 0;
428
     *     for (j = 0; j < filterSize; j++)
429
     *         dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
430
     *     dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
431
     * }
432
     * @endcode
433
     */
434
    //@{
435
    int16_t *hLumFilter;          ///< Array of horizontal filter coefficients for luma/alpha planes.
436
    int16_t *hChrFilter;          ///< Array of horizontal filter coefficients for chroma     planes.
437
    int16_t *vLumFilter;          ///< Array of vertical   filter coefficients for luma/alpha planes.
438
    int16_t *vChrFilter;          ///< Array of vertical   filter coefficients for chroma     planes.
439
    int32_t *hLumFilterPos;       ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
440
    int32_t *hChrFilterPos;       ///< Array of horizontal filter starting positions for each dst[i] for chroma     planes.
441
    int32_t *vLumFilterPos;       ///< Array of vertical   filter starting positions for each dst[i] for luma/alpha planes.
442
    int32_t *vChrFilterPos;       ///< Array of vertical   filter starting positions for each dst[i] for chroma     planes.
443
    int hLumFilterSize;           ///< Horizontal filter size for luma/alpha pixels.
444
    int hChrFilterSize;           ///< Horizontal filter size for chroma     pixels.
445
    int vLumFilterSize;           ///< Vertical   filter size for luma/alpha pixels.
446
    int vChrFilterSize;           ///< Vertical   filter size for chroma     pixels.
447
    //@}
448
449
    int lumMmxextFilterCodeSize;  ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes.
450
    int chrMmxextFilterCodeSize;  ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
451
    uint8_t *lumMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
452
    uint8_t *chrMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
453
454
    int canMMXEXTBeUsed;
455
    int warned_unuseable_bilinear;
456
457
    int dstY;                     ///< Last destination vertical line output from last slice.
458
    void *yuvTable;             // pointer to the yuv->rgb table start so it can be freed()
459
    // alignment ensures the offset can be added in a single
460
    // instruction on e.g. ARM
461
    DECLARE_ALIGNED(16, int, table_gV)[256 + 2*YUVRGB_TABLE_HEADROOM];
462
    uint8_t *table_rV[256 + 2*YUVRGB_TABLE_HEADROOM];
463
    uint8_t *table_gU[256 + 2*YUVRGB_TABLE_HEADROOM];
464
    uint8_t *table_bU[256 + 2*YUVRGB_TABLE_HEADROOM];
465
    DECLARE_ALIGNED(16, int32_t, input_rgb2yuv_table)[16+40*4]; // This table can contain both C and SIMD formatted values, the C vales are always at the XY_IDX points
466
0
#define RY_IDX 0
467
0
#define GY_IDX 1
468
0
#define BY_IDX 2
469
0
#define RU_IDX 3
470
0
#define GU_IDX 4
471
0
#define BU_IDX 5
472
0
#define RV_IDX 6
473
0
#define GV_IDX 7
474
0
#define BV_IDX 8
475
0
#define RGB2YUV_SHIFT 15
476
477
    int *dither_error[4];
478
479
    //Colorspace stuff
480
    int contrast, brightness, saturation;    // for sws_getColorspaceDetails
481
    int srcColorspaceTable[4];
482
    int dstColorspaceTable[4];
483
    int src0Alpha;
484
    int dst0Alpha;
485
    int srcXYZ;
486
    int dstXYZ;
487
    int yuv2rgb_y_offset;
488
    int yuv2rgb_y_coeff;
489
    int yuv2rgb_v2r_coeff;
490
    int yuv2rgb_v2g_coeff;
491
    int yuv2rgb_u2g_coeff;
492
    int yuv2rgb_u2b_coeff;
493
494
#define RED_DITHER            "0*8"
495
#define GREEN_DITHER          "1*8"
496
#define BLUE_DITHER           "2*8"
497
#define Y_COEFF               "3*8"
498
#define VR_COEFF              "4*8"
499
#define UB_COEFF              "5*8"
500
#define VG_COEFF              "6*8"
501
#define UG_COEFF              "7*8"
502
#define Y_OFFSET              "8*8"
503
#define U_OFFSET              "9*8"
504
#define V_OFFSET              "10*8"
505
#define LUM_MMX_FILTER_OFFSET "11*8"
506
#define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
507
#define DSTW_OFFSET           "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
508
#define ESP_OFFSET            "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
509
#define VROUNDER_OFFSET       "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
510
#define U_TEMP                "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
511
#define V_TEMP                "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
512
#define Y_TEMP                "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
513
#define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
514
#define UV_OFF_PX             "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
515
#define UV_OFF_BYTE           "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
516
#define DITHER16              "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
517
#define DITHER32              "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
518
#define DITHER32_INT          (11*8+4*4*MAX_FILTER_SIZE*3+80) // value equal to above, used for checking that the struct hasn't been changed by mistake
519
520
    DECLARE_ALIGNED(8, uint64_t, redDither);
521
    DECLARE_ALIGNED(8, uint64_t, greenDither);
522
    DECLARE_ALIGNED(8, uint64_t, blueDither);
523
524
    DECLARE_ALIGNED(8, uint64_t, yCoeff);
525
    DECLARE_ALIGNED(8, uint64_t, vrCoeff);
526
    DECLARE_ALIGNED(8, uint64_t, ubCoeff);
527
    DECLARE_ALIGNED(8, uint64_t, vgCoeff);
528
    DECLARE_ALIGNED(8, uint64_t, ugCoeff);
529
    DECLARE_ALIGNED(8, uint64_t, yOffset);
530
    DECLARE_ALIGNED(8, uint64_t, uOffset);
531
    DECLARE_ALIGNED(8, uint64_t, vOffset);
532
    int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
533
    int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
534
    int dstW_mmx;
535
    DECLARE_ALIGNED(8, uint64_t, esp);
536
    DECLARE_ALIGNED(8, uint64_t, vRounder);
537
    DECLARE_ALIGNED(8, uint64_t, u_temp);
538
    DECLARE_ALIGNED(8, uint64_t, v_temp);
539
    DECLARE_ALIGNED(8, uint64_t, y_temp);
540
    int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
541
    // alignment of these values is not necessary, but merely here
542
    // to maintain the same offset across x8632 and x86-64. Once we
543
    // use proper offset macros in the asm, they can be removed.
544
    DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes
545
    DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes
546
    DECLARE_ALIGNED(8, uint16_t, dither16)[8];
547
    DECLARE_ALIGNED(8, uint32_t, dither32)[8];
548
549
    const uint8_t *chrDither8, *lumDither8;
550
551
    int use_mmx_vfilter;
552
553
/* pre defined color-spaces gamma */
554
0
#define XYZ_GAMMA (2.6)
555
0
#define RGB_GAMMA (2.2)
556
    SwsColorFunc  xyz12Torgb48;
557
    SwsColorFunc  rgb48Toxyz12;
558
    SwsColorXform xyz2rgb;
559
    SwsColorXform rgb2xyz;
560
561
    /* function pointers for swscale() */
562
    yuv2planar1_fn yuv2plane1;
563
    yuv2planarX_fn yuv2planeX;
564
    yuv2interleavedX_fn yuv2nv12cX;
565
    yuv2packed1_fn yuv2packed1;
566
    yuv2packed2_fn yuv2packed2;
567
    yuv2packedX_fn yuv2packedX;
568
    yuv2anyX_fn yuv2anyX;
569
570
    /// Opaque data pointer passed to all input functions.
571
    void *input_opaque;
572
573
    planar1_YV12_fn lumToYV12;
574
    planar1_YV12_fn alpToYV12;
575
    planar2_YV12_fn chrToYV12;
576
577
    /**
578
     * Functions to read planar input, such as planar RGB, and convert
579
     * internally to Y/UV/A.
580
     */
581
    /** @{ */
582
    planarX_YV12_fn  readLumPlanar;
583
    planarX_YV12_fn  readAlpPlanar;
584
    planarX2_YV12_fn readChrPlanar;
585
    /** @} */
586
587
    /**
588
     * Scale one horizontal line of input data using a bilinear filter
589
     * to produce one line of output data. Compared to SwsInternal->hScale(),
590
     * please take note of the following caveats when using these:
591
     * - Scaling is done using only 7 bits instead of 14-bit coefficients.
592
     * - You can use no more than 5 input pixels to produce 4 output
593
     *   pixels. Therefore, this filter should not be used for downscaling
594
     *   by more than ~20% in width (because that equals more than 5/4th
595
     *   downscaling and thus more than 5 pixels input per 4 pixels output).
596
     * - In general, bilinear filters create artifacts during downscaling
597
     *   (even when <20%), because one output pixel will span more than one
598
     *   input pixel, and thus some pixels will need edges of both neighbor
599
     *   pixels to interpolate the output pixel. Since you can use at most
600
     *   two input pixels per output pixel in bilinear scaling, this is
601
     *   impossible and thus downscaling by any size will create artifacts.
602
     * To enable this type of scaling, set SWS_FAST_BILINEAR
603
     * in SwsInternal->flags.
604
     */
605
    /** @{ */
606
    void (*hyscale_fast)(SwsInternal *c,
607
                         int16_t *dst, int dstWidth,
608
                         const uint8_t *src, int srcW, int xInc);
609
    void (*hcscale_fast)(SwsInternal *c,
610
                         int16_t *dst1, int16_t *dst2, int dstWidth,
611
                         const uint8_t *src1, const uint8_t *src2,
612
                         int srcW, int xInc);
613
    /** @} */
614
615
    /**
616
     * Scale one horizontal line of input data using a filter over the input
617
     * lines, to produce one (differently sized) line of output data.
618
     *
619
     * @param dst        pointer to destination buffer for horizontally scaled
620
     *                   data. If the number of bits per component of one
621
     *                   destination pixel (SwsInternal->dstBpc) is <= 10, data
622
     *                   will be 15 bpc in 16 bits (int16_t) width. Else (i.e.
623
     *                   SwsInternal->dstBpc == 16), data will be 19bpc in
624
     *                   32 bits (int32_t) width.
625
     * @param dstW       width of destination image
626
     * @param src        pointer to source data to be scaled. If the number of
627
     *                   bits per component of a source pixel (SwsInternal->srcBpc)
628
     *                   is 8, this is 8bpc in 8 bits (uint8_t) width. Else
629
     *                   (i.e. SwsInternal->dstBpc > 8), this is native depth
630
     *                   in 16 bits (uint16_t) width. In other words, for 9-bit
631
     *                   YUV input, this is 9bpc, for 10-bit YUV input, this is
632
     *                   10bpc, and for 16-bit RGB or YUV, this is 16bpc.
633
     * @param filter     filter coefficients to be used per output pixel for
634
     *                   scaling. This contains 14bpp filtering coefficients.
635
     *                   Guaranteed to contain dstW * filterSize entries.
636
     * @param filterPos  position of the first input pixel to be used for
637
     *                   each output pixel during scaling. Guaranteed to
638
     *                   contain dstW entries.
639
     * @param filterSize the number of input coefficients to be used (and
640
     *                   thus the number of input pixels to be used) for
641
     *                   creating a single output pixel. Is aligned to 4
642
     *                   (and input coefficients thus padded with zeroes)
643
     *                   to simplify creating SIMD code.
644
     */
645
    /** @{ */
646
    void (*hyScale)(SwsInternal *c, int16_t *dst, int dstW,
647
                    const uint8_t *src, const int16_t *filter,
648
                    const int32_t *filterPos, int filterSize);
649
    void (*hcScale)(SwsInternal *c, int16_t *dst, int dstW,
650
                    const uint8_t *src, const int16_t *filter,
651
                    const int32_t *filterPos, int filterSize);
652
    /** @} */
653
654
    /**
655
     * Color range conversion functions if needed.
656
     * If SwsInternal->dstBpc is > 14:
657
     * - int16_t *dst (data is 15 bpc)
658
     * - uint16_t coeff
659
     * - int32_t offset
660
     * Otherwise (SwsInternal->dstBpc is <= 14):
661
     * - int32_t *dst (data is 19 bpc)
662
     * - uint32_t coeff
663
     * - int64_t offset
664
     */
665
    /** @{ */
666
    void (*lumConvertRange)(int16_t *dst, int width,
667
                            uint32_t coeff, int64_t offset);
668
    void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width,
669
                            uint32_t coeff, int64_t offset);
670
    /** @} */
671
672
    uint32_t lumConvertRange_coeff;
673
    uint32_t chrConvertRange_coeff;
674
    int64_t  lumConvertRange_offset;
675
    int64_t  chrConvertRange_offset;
676
677
    int needs_hcscale; ///< Set if there are chroma planes to be converted.
678
679
    // scratch buffer for converting packed rgb0 sources
680
    // filled with a copy of the input frame + fully opaque alpha,
681
    // then passed as input to further conversion
682
    uint8_t     *rgb0_scratch;
683
    unsigned int rgb0_scratch_allocated;
684
685
    // scratch buffer for converting XYZ sources
686
    // filled with the input converted to rgb48
687
    // then passed as input to further conversion
688
    uint8_t     *xyz_scratch;
689
    unsigned int xyz_scratch_allocated;
690
691
    unsigned int dst_slice_align;
692
    atomic_int   stride_unaligned_warned;
693
    atomic_int   data_unaligned_warned;
694
    int          color_conversion_warned;
695
696
    Half2FloatTables *h2f_tables;
697
698
    // Hardware specific private data
699
    void *hw_priv; /* refstruct */
700
701
    int is_legacy_init;
702
};
703
//FIXME check init (where 0)
704
705
static_assert(offsetof(SwsInternal, redDither) + DITHER32_INT == offsetof(SwsInternal, dither32),
706
              "dither32 must be at the same offset as redDither + DITHER32_INT");
707
708
#if ARCH_X86_64
709
/* x86 yuv2gbrp uses the SwsInternal for yuv coefficients
710
   if struct offsets change the asm needs to be updated too */
711
static_assert(offsetof(SwsInternal, yuv2rgb_y_offset) == 40348,
712
              "yuv2rgb_y_offset must be updated in x86 asm");
713
#endif
714
715
SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c);
716
int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4],
717
                             int fullRange, int brightness,
718
                             int contrast, int saturation);
719
void ff_yuv2rgb_init_tables_ppc(SwsInternal *c, const int inv_table[4],
720
                                int brightness, int contrast, int saturation);
721
722
void ff_updateMMXDitherTables(SwsInternal *c, int dstY);
723
724
void ff_update_palette(SwsInternal *c, const uint32_t *pal);
725
726
av_cold void ff_sws_init_range_convert(SwsInternal *c);
727
av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c);
728
av_cold void ff_sws_init_range_convert_loongarch(SwsInternal *c);
729
av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c);
730
av_cold void ff_sws_init_range_convert_x86(SwsInternal *c);
731
732
av_cold void ff_sws_init_xyzdsp(SwsInternal *c);
733
av_cold void ff_sws_init_xyzdsp_aarch64(SwsInternal *c);
734
735
av_cold int ff_sws_fill_xyztables(SwsInternal *c);
736
737
SwsFunc ff_yuv2rgb_init_x86(SwsInternal *c);
738
SwsFunc ff_yuv2rgb_init_ppc(SwsInternal *c);
739
SwsFunc ff_yuv2rgb_init_loongarch(SwsInternal *c);
740
SwsFunc ff_yuv2rgb_init_aarch64(SwsInternal *c);
741
742
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
743
0
{
744
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
745
0
    av_assert0(desc);
746
0
    return desc->comp[0].depth == 16;
747
0
}
Unexecuted instantiation: swscale.c:is16BPS
Unexecuted instantiation: utils.c:is16BPS
Unexecuted instantiation: vscale.c:is16BPS
Unexecuted instantiation: yuv2rgb.c:is16BPS
Unexecuted instantiation: alphablend.c:is16BPS
Unexecuted instantiation: graph.c:is16BPS
Unexecuted instantiation: hscale_fast_bilinear.c:is16BPS
Unexecuted instantiation: input.c:is16BPS
Unexecuted instantiation: options.c:is16BPS
Unexecuted instantiation: output.c:is16BPS
Unexecuted instantiation: rgb2rgb.c:is16BPS
Unexecuted instantiation: slice.c:is16BPS
Unexecuted instantiation: swscale_unscaled.c:is16BPS
Unexecuted instantiation: gamma.c:is16BPS
Unexecuted instantiation: hscale.c:is16BPS
748
749
static av_always_inline int is32BPS(enum AVPixelFormat pix_fmt)
750
0
{
751
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
752
0
    av_assert0(desc);
753
0
    return desc->comp[0].depth == 32;
754
0
}
Unexecuted instantiation: swscale.c:is32BPS
Unexecuted instantiation: utils.c:is32BPS
Unexecuted instantiation: vscale.c:is32BPS
Unexecuted instantiation: yuv2rgb.c:is32BPS
Unexecuted instantiation: alphablend.c:is32BPS
Unexecuted instantiation: graph.c:is32BPS
Unexecuted instantiation: hscale_fast_bilinear.c:is32BPS
Unexecuted instantiation: input.c:is32BPS
Unexecuted instantiation: options.c:is32BPS
Unexecuted instantiation: output.c:is32BPS
Unexecuted instantiation: rgb2rgb.c:is32BPS
Unexecuted instantiation: slice.c:is32BPS
Unexecuted instantiation: swscale_unscaled.c:is32BPS
Unexecuted instantiation: gamma.c:is32BPS
Unexecuted instantiation: hscale.c:is32BPS
755
756
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
757
0
{
758
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
759
0
    av_assert0(desc);
760
0
    return desc->comp[0].depth >= 9 && desc->comp[0].depth <= 14;
761
0
}
Unexecuted instantiation: swscale.c:isNBPS
Unexecuted instantiation: utils.c:isNBPS
Unexecuted instantiation: vscale.c:isNBPS
Unexecuted instantiation: yuv2rgb.c:isNBPS
Unexecuted instantiation: alphablend.c:isNBPS
Unexecuted instantiation: graph.c:isNBPS
Unexecuted instantiation: hscale_fast_bilinear.c:isNBPS
Unexecuted instantiation: input.c:isNBPS
Unexecuted instantiation: options.c:isNBPS
Unexecuted instantiation: output.c:isNBPS
Unexecuted instantiation: rgb2rgb.c:isNBPS
Unexecuted instantiation: slice.c:isNBPS
Unexecuted instantiation: swscale_unscaled.c:isNBPS
Unexecuted instantiation: gamma.c:isNBPS
Unexecuted instantiation: hscale.c:isNBPS
762
763
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
764
0
{
765
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
766
0
    av_assert0(desc);
767
0
    return desc->flags & AV_PIX_FMT_FLAG_BE;
768
0
}
Unexecuted instantiation: swscale.c:isBE
Unexecuted instantiation: utils.c:isBE
Unexecuted instantiation: vscale.c:isBE
Unexecuted instantiation: yuv2rgb.c:isBE
Unexecuted instantiation: alphablend.c:isBE
Unexecuted instantiation: graph.c:isBE
Unexecuted instantiation: hscale_fast_bilinear.c:isBE
Unexecuted instantiation: input.c:isBE
Unexecuted instantiation: options.c:isBE
Unexecuted instantiation: output.c:isBE
Unexecuted instantiation: rgb2rgb.c:isBE
Unexecuted instantiation: slice.c:isBE
Unexecuted instantiation: swscale_unscaled.c:isBE
Unexecuted instantiation: gamma.c:isBE
Unexecuted instantiation: hscale.c:isBE
769
770
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
771
0
{
772
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
773
0
    av_assert0(desc);
774
0
    return !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
775
0
}
Unexecuted instantiation: swscale.c:isYUV
Unexecuted instantiation: utils.c:isYUV
Unexecuted instantiation: vscale.c:isYUV
Unexecuted instantiation: yuv2rgb.c:isYUV
Unexecuted instantiation: alphablend.c:isYUV
Unexecuted instantiation: graph.c:isYUV
Unexecuted instantiation: hscale_fast_bilinear.c:isYUV
Unexecuted instantiation: input.c:isYUV
Unexecuted instantiation: options.c:isYUV
Unexecuted instantiation: output.c:isYUV
Unexecuted instantiation: rgb2rgb.c:isYUV
Unexecuted instantiation: slice.c:isYUV
Unexecuted instantiation: swscale_unscaled.c:isYUV
Unexecuted instantiation: gamma.c:isYUV
Unexecuted instantiation: hscale.c:isYUV
776
777
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
778
0
{
779
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
780
0
    av_assert0(desc);
781
0
    return ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && isYUV(pix_fmt));
782
0
}
Unexecuted instantiation: swscale.c:isPlanarYUV
Unexecuted instantiation: utils.c:isPlanarYUV
Unexecuted instantiation: vscale.c:isPlanarYUV
Unexecuted instantiation: yuv2rgb.c:isPlanarYUV
Unexecuted instantiation: alphablend.c:isPlanarYUV
Unexecuted instantiation: graph.c:isPlanarYUV
Unexecuted instantiation: hscale_fast_bilinear.c:isPlanarYUV
Unexecuted instantiation: input.c:isPlanarYUV
Unexecuted instantiation: options.c:isPlanarYUV
Unexecuted instantiation: output.c:isPlanarYUV
Unexecuted instantiation: rgb2rgb.c:isPlanarYUV
Unexecuted instantiation: slice.c:isPlanarYUV
Unexecuted instantiation: swscale_unscaled.c:isPlanarYUV
Unexecuted instantiation: gamma.c:isPlanarYUV
Unexecuted instantiation: hscale.c:isPlanarYUV
783
784
/*
785
 * Identity semi-planar YUV formats. Specifically, those are YUV formats
786
 * where the second and third components (U & V) are on the same plane.
787
 */
788
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
789
0
{
790
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
791
0
    av_assert0(desc);
792
0
    return (isPlanarYUV(pix_fmt) && desc->comp[1].plane == desc->comp[2].plane);
793
0
}
Unexecuted instantiation: swscale.c:isSemiPlanarYUV
Unexecuted instantiation: utils.c:isSemiPlanarYUV
Unexecuted instantiation: vscale.c:isSemiPlanarYUV
Unexecuted instantiation: yuv2rgb.c:isSemiPlanarYUV
Unexecuted instantiation: alphablend.c:isSemiPlanarYUV
Unexecuted instantiation: graph.c:isSemiPlanarYUV
Unexecuted instantiation: hscale_fast_bilinear.c:isSemiPlanarYUV
Unexecuted instantiation: input.c:isSemiPlanarYUV
Unexecuted instantiation: options.c:isSemiPlanarYUV
Unexecuted instantiation: output.c:isSemiPlanarYUV
Unexecuted instantiation: rgb2rgb.c:isSemiPlanarYUV
Unexecuted instantiation: slice.c:isSemiPlanarYUV
Unexecuted instantiation: swscale_unscaled.c:isSemiPlanarYUV
Unexecuted instantiation: gamma.c:isSemiPlanarYUV
Unexecuted instantiation: hscale.c:isSemiPlanarYUV
794
795
static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
796
0
{
797
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
798
0
    av_assert0(desc);
799
0
    return (desc->flags & AV_PIX_FMT_FLAG_RGB);
800
0
}
Unexecuted instantiation: swscale.c:isRGB
Unexecuted instantiation: utils.c:isRGB
Unexecuted instantiation: vscale.c:isRGB
Unexecuted instantiation: yuv2rgb.c:isRGB
Unexecuted instantiation: alphablend.c:isRGB
Unexecuted instantiation: graph.c:isRGB
Unexecuted instantiation: hscale_fast_bilinear.c:isRGB
Unexecuted instantiation: input.c:isRGB
Unexecuted instantiation: options.c:isRGB
Unexecuted instantiation: output.c:isRGB
Unexecuted instantiation: rgb2rgb.c:isRGB
Unexecuted instantiation: slice.c:isRGB
Unexecuted instantiation: swscale_unscaled.c:isRGB
Unexecuted instantiation: gamma.c:isRGB
Unexecuted instantiation: hscale.c:isRGB
801
802
static av_always_inline int isGray(enum AVPixelFormat pix_fmt)
803
0
{
804
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
805
0
    av_assert0(desc);
806
0
    return !(desc->flags & AV_PIX_FMT_FLAG_PAL) &&
807
0
           !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
808
0
           desc->nb_components <= 2 &&
809
0
           pix_fmt != AV_PIX_FMT_MONOBLACK &&
810
0
           pix_fmt != AV_PIX_FMT_MONOWHITE;
811
0
}
Unexecuted instantiation: swscale.c:isGray
Unexecuted instantiation: utils.c:isGray
Unexecuted instantiation: vscale.c:isGray
Unexecuted instantiation: yuv2rgb.c:isGray
Unexecuted instantiation: alphablend.c:isGray
Unexecuted instantiation: graph.c:isGray
Unexecuted instantiation: hscale_fast_bilinear.c:isGray
Unexecuted instantiation: input.c:isGray
Unexecuted instantiation: options.c:isGray
Unexecuted instantiation: output.c:isGray
Unexecuted instantiation: rgb2rgb.c:isGray
Unexecuted instantiation: slice.c:isGray
Unexecuted instantiation: swscale_unscaled.c:isGray
Unexecuted instantiation: gamma.c:isGray
Unexecuted instantiation: hscale.c:isGray
812
813
static av_always_inline int isRGBinInt(enum AVPixelFormat pix_fmt)
814
0
{
815
0
    return pix_fmt == AV_PIX_FMT_RGB48BE     ||
816
0
           pix_fmt == AV_PIX_FMT_RGB48LE     ||
817
0
           pix_fmt == AV_PIX_FMT_RGB32       ||
818
0
           pix_fmt == AV_PIX_FMT_RGB32_1     ||
819
0
           pix_fmt == AV_PIX_FMT_RGB24       ||
820
0
           pix_fmt == AV_PIX_FMT_RGB565BE    ||
821
0
           pix_fmt == AV_PIX_FMT_RGB565LE    ||
822
0
           pix_fmt == AV_PIX_FMT_RGB555BE    ||
823
0
           pix_fmt == AV_PIX_FMT_RGB555LE    ||
824
0
           pix_fmt == AV_PIX_FMT_RGB444BE    ||
825
0
           pix_fmt == AV_PIX_FMT_RGB444LE    ||
826
0
           pix_fmt == AV_PIX_FMT_RGB8        ||
827
0
           pix_fmt == AV_PIX_FMT_RGB4        ||
828
0
           pix_fmt == AV_PIX_FMT_RGB4_BYTE   ||
829
0
           pix_fmt == AV_PIX_FMT_RGBA64BE    ||
830
0
           pix_fmt == AV_PIX_FMT_RGBA64LE    ||
831
0
           pix_fmt == AV_PIX_FMT_MONOBLACK   ||
832
0
           pix_fmt == AV_PIX_FMT_MONOWHITE;
833
0
}
Unexecuted instantiation: swscale.c:isRGBinInt
Unexecuted instantiation: utils.c:isRGBinInt
Unexecuted instantiation: vscale.c:isRGBinInt
Unexecuted instantiation: yuv2rgb.c:isRGBinInt
Unexecuted instantiation: alphablend.c:isRGBinInt
Unexecuted instantiation: graph.c:isRGBinInt
Unexecuted instantiation: hscale_fast_bilinear.c:isRGBinInt
Unexecuted instantiation: input.c:isRGBinInt
Unexecuted instantiation: options.c:isRGBinInt
Unexecuted instantiation: output.c:isRGBinInt
Unexecuted instantiation: rgb2rgb.c:isRGBinInt
Unexecuted instantiation: slice.c:isRGBinInt
Unexecuted instantiation: swscale_unscaled.c:isRGBinInt
Unexecuted instantiation: gamma.c:isRGBinInt
Unexecuted instantiation: hscale.c:isRGBinInt
834
835
static av_always_inline int isBGRinInt(enum AVPixelFormat pix_fmt)
836
0
{
837
0
    return pix_fmt == AV_PIX_FMT_BGR48BE     ||
838
0
           pix_fmt == AV_PIX_FMT_BGR48LE     ||
839
0
           pix_fmt == AV_PIX_FMT_BGR32       ||
840
0
           pix_fmt == AV_PIX_FMT_BGR32_1     ||
841
0
           pix_fmt == AV_PIX_FMT_BGR24       ||
842
0
           pix_fmt == AV_PIX_FMT_BGR565BE    ||
843
0
           pix_fmt == AV_PIX_FMT_BGR565LE    ||
844
0
           pix_fmt == AV_PIX_FMT_BGR555BE    ||
845
0
           pix_fmt == AV_PIX_FMT_BGR555LE    ||
846
0
           pix_fmt == AV_PIX_FMT_BGR444BE    ||
847
0
           pix_fmt == AV_PIX_FMT_BGR444LE    ||
848
0
           pix_fmt == AV_PIX_FMT_BGR8        ||
849
0
           pix_fmt == AV_PIX_FMT_BGR4        ||
850
0
           pix_fmt == AV_PIX_FMT_BGR4_BYTE   ||
851
0
           pix_fmt == AV_PIX_FMT_BGRA64BE    ||
852
0
           pix_fmt == AV_PIX_FMT_BGRA64LE    ||
853
0
           pix_fmt == AV_PIX_FMT_MONOBLACK   ||
854
0
           pix_fmt == AV_PIX_FMT_MONOWHITE;
855
0
}
Unexecuted instantiation: swscale.c:isBGRinInt
Unexecuted instantiation: utils.c:isBGRinInt
Unexecuted instantiation: vscale.c:isBGRinInt
Unexecuted instantiation: yuv2rgb.c:isBGRinInt
Unexecuted instantiation: alphablend.c:isBGRinInt
Unexecuted instantiation: graph.c:isBGRinInt
Unexecuted instantiation: hscale_fast_bilinear.c:isBGRinInt
Unexecuted instantiation: input.c:isBGRinInt
Unexecuted instantiation: options.c:isBGRinInt
Unexecuted instantiation: output.c:isBGRinInt
Unexecuted instantiation: rgb2rgb.c:isBGRinInt
Unexecuted instantiation: slice.c:isBGRinInt
Unexecuted instantiation: swscale_unscaled.c:isBGRinInt
Unexecuted instantiation: gamma.c:isBGRinInt
Unexecuted instantiation: hscale.c:isBGRinInt
856
857
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
858
0
{
859
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
860
0
    av_assert0(desc);
861
0
    return !!(desc->flags & AV_PIX_FMT_FLAG_BAYER);
862
0
}
Unexecuted instantiation: swscale.c:isBayer
Unexecuted instantiation: utils.c:isBayer
Unexecuted instantiation: vscale.c:isBayer
Unexecuted instantiation: yuv2rgb.c:isBayer
Unexecuted instantiation: alphablend.c:isBayer
Unexecuted instantiation: graph.c:isBayer
Unexecuted instantiation: hscale_fast_bilinear.c:isBayer
Unexecuted instantiation: input.c:isBayer
Unexecuted instantiation: options.c:isBayer
Unexecuted instantiation: output.c:isBayer
Unexecuted instantiation: rgb2rgb.c:isBayer
Unexecuted instantiation: slice.c:isBayer
Unexecuted instantiation: swscale_unscaled.c:isBayer
Unexecuted instantiation: gamma.c:isBayer
Unexecuted instantiation: hscale.c:isBayer
863
864
static av_always_inline int isBayer16BPS(enum AVPixelFormat pix_fmt)
865
0
{
866
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
867
0
    av_assert0(desc);
868
0
    return desc->comp[1].depth == 8;
869
0
}
Unexecuted instantiation: swscale.c:isBayer16BPS
Unexecuted instantiation: utils.c:isBayer16BPS
Unexecuted instantiation: vscale.c:isBayer16BPS
Unexecuted instantiation: yuv2rgb.c:isBayer16BPS
Unexecuted instantiation: alphablend.c:isBayer16BPS
Unexecuted instantiation: graph.c:isBayer16BPS
Unexecuted instantiation: hscale_fast_bilinear.c:isBayer16BPS
Unexecuted instantiation: input.c:isBayer16BPS
Unexecuted instantiation: options.c:isBayer16BPS
Unexecuted instantiation: output.c:isBayer16BPS
Unexecuted instantiation: rgb2rgb.c:isBayer16BPS
Unexecuted instantiation: slice.c:isBayer16BPS
Unexecuted instantiation: swscale_unscaled.c:isBayer16BPS
Unexecuted instantiation: gamma.c:isBayer16BPS
Unexecuted instantiation: hscale.c:isBayer16BPS
870
871
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
872
0
{
873
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
874
0
    av_assert0(desc);
875
0
    return (desc->flags & AV_PIX_FMT_FLAG_RGB) ||
876
0
            pix_fmt == AV_PIX_FMT_MONOBLACK || pix_fmt == AV_PIX_FMT_MONOWHITE;
877
0
}
Unexecuted instantiation: swscale.c:isAnyRGB
Unexecuted instantiation: utils.c:isAnyRGB
Unexecuted instantiation: vscale.c:isAnyRGB
Unexecuted instantiation: yuv2rgb.c:isAnyRGB
Unexecuted instantiation: alphablend.c:isAnyRGB
Unexecuted instantiation: graph.c:isAnyRGB
Unexecuted instantiation: hscale_fast_bilinear.c:isAnyRGB
Unexecuted instantiation: input.c:isAnyRGB
Unexecuted instantiation: options.c:isAnyRGB
Unexecuted instantiation: output.c:isAnyRGB
Unexecuted instantiation: rgb2rgb.c:isAnyRGB
Unexecuted instantiation: slice.c:isAnyRGB
Unexecuted instantiation: swscale_unscaled.c:isAnyRGB
Unexecuted instantiation: gamma.c:isAnyRGB
Unexecuted instantiation: hscale.c:isAnyRGB
878
879
static av_always_inline int isFloat(enum AVPixelFormat pix_fmt)
880
0
{
881
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
882
0
    av_assert0(desc);
883
0
    return desc->flags & AV_PIX_FMT_FLAG_FLOAT;
884
0
}
Unexecuted instantiation: swscale.c:isFloat
Unexecuted instantiation: utils.c:isFloat
Unexecuted instantiation: vscale.c:isFloat
Unexecuted instantiation: yuv2rgb.c:isFloat
Unexecuted instantiation: alphablend.c:isFloat
Unexecuted instantiation: graph.c:isFloat
Unexecuted instantiation: hscale_fast_bilinear.c:isFloat
Unexecuted instantiation: input.c:isFloat
Unexecuted instantiation: options.c:isFloat
Unexecuted instantiation: output.c:isFloat
Unexecuted instantiation: rgb2rgb.c:isFloat
Unexecuted instantiation: slice.c:isFloat
Unexecuted instantiation: swscale_unscaled.c:isFloat
Unexecuted instantiation: gamma.c:isFloat
Unexecuted instantiation: hscale.c:isFloat
885
886
static av_always_inline int isFloat16(enum AVPixelFormat pix_fmt)
887
0
{
888
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
889
0
    av_assert0(desc);
890
0
    return (desc->flags & AV_PIX_FMT_FLAG_FLOAT) && desc->comp[0].depth == 16;
891
0
}
Unexecuted instantiation: swscale.c:isFloat16
Unexecuted instantiation: utils.c:isFloat16
Unexecuted instantiation: vscale.c:isFloat16
Unexecuted instantiation: yuv2rgb.c:isFloat16
Unexecuted instantiation: alphablend.c:isFloat16
Unexecuted instantiation: graph.c:isFloat16
Unexecuted instantiation: hscale_fast_bilinear.c:isFloat16
Unexecuted instantiation: input.c:isFloat16
Unexecuted instantiation: options.c:isFloat16
Unexecuted instantiation: output.c:isFloat16
Unexecuted instantiation: rgb2rgb.c:isFloat16
Unexecuted instantiation: slice.c:isFloat16
Unexecuted instantiation: swscale_unscaled.c:isFloat16
Unexecuted instantiation: gamma.c:isFloat16
Unexecuted instantiation: hscale.c:isFloat16
892
893
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
894
0
{
895
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
896
0
    av_assert0(desc);
897
0
    if (pix_fmt == AV_PIX_FMT_PAL8)
898
0
        return 1;
899
0
    return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
900
0
}
Unexecuted instantiation: swscale.c:isALPHA
Unexecuted instantiation: utils.c:isALPHA
Unexecuted instantiation: vscale.c:isALPHA
Unexecuted instantiation: yuv2rgb.c:isALPHA
Unexecuted instantiation: alphablend.c:isALPHA
Unexecuted instantiation: graph.c:isALPHA
Unexecuted instantiation: hscale_fast_bilinear.c:isALPHA
Unexecuted instantiation: input.c:isALPHA
Unexecuted instantiation: options.c:isALPHA
Unexecuted instantiation: output.c:isALPHA
Unexecuted instantiation: rgb2rgb.c:isALPHA
Unexecuted instantiation: slice.c:isALPHA
Unexecuted instantiation: swscale_unscaled.c:isALPHA
Unexecuted instantiation: gamma.c:isALPHA
Unexecuted instantiation: hscale.c:isALPHA
901
902
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
903
0
{
904
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
905
0
    av_assert0(desc);
906
0
    return (desc->nb_components >= 2 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) ||
907
0
            pix_fmt == AV_PIX_FMT_PAL8 ||
908
0
            pix_fmt == AV_PIX_FMT_MONOBLACK || pix_fmt == AV_PIX_FMT_MONOWHITE;
909
0
}
Unexecuted instantiation: swscale.c:isPacked
Unexecuted instantiation: utils.c:isPacked
Unexecuted instantiation: vscale.c:isPacked
Unexecuted instantiation: yuv2rgb.c:isPacked
Unexecuted instantiation: alphablend.c:isPacked
Unexecuted instantiation: graph.c:isPacked
Unexecuted instantiation: hscale_fast_bilinear.c:isPacked
Unexecuted instantiation: input.c:isPacked
Unexecuted instantiation: options.c:isPacked
Unexecuted instantiation: output.c:isPacked
Unexecuted instantiation: rgb2rgb.c:isPacked
Unexecuted instantiation: slice.c:isPacked
Unexecuted instantiation: swscale_unscaled.c:isPacked
Unexecuted instantiation: gamma.c:isPacked
Unexecuted instantiation: hscale.c:isPacked
910
911
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
912
0
{
913
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
914
0
    av_assert0(desc);
915
0
    return (desc->nb_components >= 2 && (desc->flags & AV_PIX_FMT_FLAG_PLANAR));
916
0
}
Unexecuted instantiation: swscale.c:isPlanar
Unexecuted instantiation: utils.c:isPlanar
Unexecuted instantiation: vscale.c:isPlanar
Unexecuted instantiation: yuv2rgb.c:isPlanar
Unexecuted instantiation: alphablend.c:isPlanar
Unexecuted instantiation: graph.c:isPlanar
Unexecuted instantiation: hscale_fast_bilinear.c:isPlanar
Unexecuted instantiation: input.c:isPlanar
Unexecuted instantiation: options.c:isPlanar
Unexecuted instantiation: output.c:isPlanar
Unexecuted instantiation: rgb2rgb.c:isPlanar
Unexecuted instantiation: slice.c:isPlanar
Unexecuted instantiation: swscale_unscaled.c:isPlanar
Unexecuted instantiation: gamma.c:isPlanar
Unexecuted instantiation: hscale.c:isPlanar
917
918
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
919
0
{
920
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
921
0
    av_assert0(desc);
922
0
    return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) == AV_PIX_FMT_FLAG_RGB);
923
0
}
Unexecuted instantiation: swscale.c:isPackedRGB
Unexecuted instantiation: utils.c:isPackedRGB
Unexecuted instantiation: vscale.c:isPackedRGB
Unexecuted instantiation: yuv2rgb.c:isPackedRGB
Unexecuted instantiation: alphablend.c:isPackedRGB
Unexecuted instantiation: graph.c:isPackedRGB
Unexecuted instantiation: hscale_fast_bilinear.c:isPackedRGB
Unexecuted instantiation: input.c:isPackedRGB
Unexecuted instantiation: options.c:isPackedRGB
Unexecuted instantiation: output.c:isPackedRGB
Unexecuted instantiation: rgb2rgb.c:isPackedRGB
Unexecuted instantiation: slice.c:isPackedRGB
Unexecuted instantiation: swscale_unscaled.c:isPackedRGB
Unexecuted instantiation: gamma.c:isPackedRGB
Unexecuted instantiation: hscale.c:isPackedRGB
924
925
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
926
0
{
927
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
928
0
    av_assert0(desc);
929
0
    return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) ==
930
0
            (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB));
931
0
}
Unexecuted instantiation: swscale.c:isPlanarRGB
Unexecuted instantiation: utils.c:isPlanarRGB
Unexecuted instantiation: vscale.c:isPlanarRGB
Unexecuted instantiation: yuv2rgb.c:isPlanarRGB
Unexecuted instantiation: alphablend.c:isPlanarRGB
Unexecuted instantiation: graph.c:isPlanarRGB
Unexecuted instantiation: hscale_fast_bilinear.c:isPlanarRGB
Unexecuted instantiation: input.c:isPlanarRGB
Unexecuted instantiation: options.c:isPlanarRGB
Unexecuted instantiation: output.c:isPlanarRGB
Unexecuted instantiation: rgb2rgb.c:isPlanarRGB
Unexecuted instantiation: slice.c:isPlanarRGB
Unexecuted instantiation: swscale_unscaled.c:isPlanarRGB
Unexecuted instantiation: gamma.c:isPlanarRGB
Unexecuted instantiation: hscale.c:isPlanarRGB
932
933
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
934
0
{
935
0
    switch (pix_fmt) {
936
0
    case AV_PIX_FMT_PAL8:
937
0
    case AV_PIX_FMT_BGR4_BYTE:
938
0
    case AV_PIX_FMT_BGR8:
939
0
    case AV_PIX_FMT_GRAY8:
940
0
    case AV_PIX_FMT_RGB4_BYTE:
941
0
    case AV_PIX_FMT_RGB8:
942
0
        return 1;
943
0
    default:
944
0
        return 0;
945
0
    }
946
0
}
Unexecuted instantiation: swscale.c:usePal
Unexecuted instantiation: utils.c:usePal
Unexecuted instantiation: vscale.c:usePal
Unexecuted instantiation: yuv2rgb.c:usePal
Unexecuted instantiation: alphablend.c:usePal
Unexecuted instantiation: graph.c:usePal
Unexecuted instantiation: hscale_fast_bilinear.c:usePal
Unexecuted instantiation: input.c:usePal
Unexecuted instantiation: options.c:usePal
Unexecuted instantiation: output.c:usePal
Unexecuted instantiation: rgb2rgb.c:usePal
Unexecuted instantiation: slice.c:usePal
Unexecuted instantiation: swscale_unscaled.c:usePal
Unexecuted instantiation: gamma.c:usePal
Unexecuted instantiation: hscale.c:usePal
947
948
/*
949
 * Identity formats where the data is in the high bits, and the low bits are shifted away.
950
 */
951
static av_always_inline int isDataInHighBits(enum AVPixelFormat pix_fmt)
952
0
{
953
0
    int i;
954
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
955
0
    av_assert0(desc);
956
0
    if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL))
957
0
        return 0;
958
0
    for (i = 0; i < desc->nb_components; i++) {
959
0
        if (!desc->comp[i].shift)
960
0
            return 0;
961
0
        if ((desc->comp[i].shift + desc->comp[i].depth) & 0x7)
962
0
            return 0;
963
0
    }
964
0
    return 1;
965
0
}
Unexecuted instantiation: swscale.c:isDataInHighBits
Unexecuted instantiation: utils.c:isDataInHighBits
Unexecuted instantiation: vscale.c:isDataInHighBits
Unexecuted instantiation: yuv2rgb.c:isDataInHighBits
Unexecuted instantiation: alphablend.c:isDataInHighBits
Unexecuted instantiation: graph.c:isDataInHighBits
Unexecuted instantiation: hscale_fast_bilinear.c:isDataInHighBits
Unexecuted instantiation: input.c:isDataInHighBits
Unexecuted instantiation: options.c:isDataInHighBits
Unexecuted instantiation: output.c:isDataInHighBits
Unexecuted instantiation: rgb2rgb.c:isDataInHighBits
Unexecuted instantiation: slice.c:isDataInHighBits
Unexecuted instantiation: swscale_unscaled.c:isDataInHighBits
Unexecuted instantiation: gamma.c:isDataInHighBits
Unexecuted instantiation: hscale.c:isDataInHighBits
966
967
/*
968
 * Identity formats where the chroma planes are swapped (CrCb order).
969
 */
970
static av_always_inline int isSwappedChroma(enum AVPixelFormat pix_fmt)
971
0
{
972
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
973
0
    av_assert0(desc);
974
0
    if (!isYUV(pix_fmt))
975
0
        return 0;
976
0
    if ((desc->flags & AV_PIX_FMT_FLAG_ALPHA) && desc->nb_components < 4)
977
0
        return 0;
978
0
    if (desc->nb_components < 3)
979
0
        return 0;
980
0
    if (!isPlanarYUV(pix_fmt) || isSemiPlanarYUV(pix_fmt))
981
0
        return desc->comp[1].offset > desc->comp[2].offset;
982
0
    else
983
0
        return desc->comp[1].plane > desc->comp[2].plane;
984
0
}
Unexecuted instantiation: swscale.c:isSwappedChroma
Unexecuted instantiation: utils.c:isSwappedChroma
Unexecuted instantiation: vscale.c:isSwappedChroma
Unexecuted instantiation: yuv2rgb.c:isSwappedChroma
Unexecuted instantiation: alphablend.c:isSwappedChroma
Unexecuted instantiation: graph.c:isSwappedChroma
Unexecuted instantiation: hscale_fast_bilinear.c:isSwappedChroma
Unexecuted instantiation: input.c:isSwappedChroma
Unexecuted instantiation: options.c:isSwappedChroma
Unexecuted instantiation: output.c:isSwappedChroma
Unexecuted instantiation: rgb2rgb.c:isSwappedChroma
Unexecuted instantiation: slice.c:isSwappedChroma
Unexecuted instantiation: swscale_unscaled.c:isSwappedChroma
Unexecuted instantiation: gamma.c:isSwappedChroma
Unexecuted instantiation: hscale.c:isSwappedChroma
985
986
extern const uint64_t ff_dither4[2];
987
extern const uint64_t ff_dither8[2];
988
989
extern const uint8_t ff_dither_2x2_4[3][8];
990
extern const uint8_t ff_dither_2x2_8[3][8];
991
extern const uint8_t ff_dither_4x4_16[5][8];
992
extern const uint8_t ff_dither_8x8_32[9][8];
993
extern const uint8_t ff_dither_8x8_73[9][8];
994
extern const uint8_t ff_dither_8x8_128[9][8];
995
extern const uint8_t ff_dither_8x8_220[9][8];
996
997
extern const int32_t ff_yuv2rgb_coeffs[11][4];
998
999
extern const AVClass ff_sws_context_class;
1000
1001
int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter,
1002
                               SwsFilter *dstFilter);
1003
1004
/**
1005
 * Set c->convert_unscaled to an unscaled converter if one exists for the
1006
 * specific source and destination formats, bit depths, flags, etc.
1007
 */
1008
void ff_get_unscaled_swscale(SwsInternal *c);
1009
void ff_get_unscaled_swscale_ppc(SwsInternal *c);
1010
void ff_get_unscaled_swscale_arm(SwsInternal *c);
1011
void ff_get_unscaled_swscale_aarch64(SwsInternal *c);
1012
1013
void ff_sws_init_scale(SwsInternal *c);
1014
1015
void ff_sws_init_input_funcs(SwsInternal *c,
1016
                             planar1_YV12_fn *lumToYV12,
1017
                             planar1_YV12_fn *alpToYV12,
1018
                             planar2_YV12_fn *chrToYV12,
1019
                             planarX_YV12_fn *readLumPlanar,
1020
                             planarX_YV12_fn *readAlpPlanar,
1021
                             planarX2_YV12_fn *readChrPlanar);
1022
void ff_sws_init_output_funcs(SwsInternal *c,
1023
                              yuv2planar1_fn *yuv2plane1,
1024
                              yuv2planarX_fn *yuv2planeX,
1025
                              yuv2interleavedX_fn *yuv2nv12cX,
1026
                              yuv2packed1_fn *yuv2packed1,
1027
                              yuv2packed2_fn *yuv2packed2,
1028
                              yuv2packedX_fn *yuv2packedX,
1029
                              yuv2anyX_fn *yuv2anyX);
1030
void ff_sws_init_swscale_ppc(SwsInternal *c);
1031
void ff_sws_init_swscale_vsx(SwsInternal *c);
1032
void ff_sws_init_swscale_x86(SwsInternal *c);
1033
void ff_sws_init_swscale_aarch64(SwsInternal *c);
1034
void ff_sws_init_swscale_arm(SwsInternal *c);
1035
void ff_sws_init_swscale_loongarch(SwsInternal *c);
1036
void ff_sws_init_swscale_riscv(SwsInternal *c);
1037
1038
int ff_sws_init_altivec_bufs(SwsInternal *c);
1039
void ff_sws_free_altivec_bufs(SwsInternal *c);
1040
1041
void ff_hyscale_fast_c(SwsInternal *c, int16_t *dst, int dstWidth,
1042
                       const uint8_t *src, int srcW, int xInc);
1043
void ff_hcscale_fast_c(SwsInternal *c, int16_t *dst1, int16_t *dst2,
1044
                       int dstWidth, const uint8_t *src1,
1045
                       const uint8_t *src2, int srcW, int xInc);
1046
int ff_init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
1047
                           int16_t *filter, int32_t *filterPos,
1048
                           int numSplits);
1049
void ff_hyscale_fast_mmxext(SwsInternal *c, int16_t *dst,
1050
                            int dstWidth, const uint8_t *src,
1051
                            int srcW, int xInc);
1052
void ff_hcscale_fast_mmxext(SwsInternal *c, int16_t *dst1, int16_t *dst2,
1053
                            int dstWidth, const uint8_t *src1,
1054
                            const uint8_t *src2, int srcW, int xInc);
1055
1056
int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
1057
                          const int srcStride[], int srcSliceY, int srcSliceH,
1058
                          uint8_t *const dst[], const int dstStride[]);
1059
1060
void ff_copyPlane(const uint8_t *src, int srcStride,
1061
                  int srcSliceY, int srcSliceH, int width,
1062
                  uint8_t *dst, int dstStride);
1063
1064
static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
1065
                               int alpha, int bits, const int big_endian)
1066
0
{
1067
0
    uint8_t *ptr = plane + stride * y;
1068
0
    int v = alpha ? 0xFFFF>>(16-bits) : (1<<(bits-1));
1069
0
    if (big_endian != HAVE_BIGENDIAN)
1070
0
        v = av_bswap16(v);
1071
0
    for (int i = 0; i < height; i++) {
1072
0
        for (int j = 0; j < width; j++)
1073
0
            AV_WN16(ptr + 2 * j, v);
1074
0
        ptr += stride;
1075
0
    }
1076
0
}
Unexecuted instantiation: swscale.c:fillPlane16
Unexecuted instantiation: utils.c:fillPlane16
Unexecuted instantiation: vscale.c:fillPlane16
Unexecuted instantiation: yuv2rgb.c:fillPlane16
Unexecuted instantiation: alphablend.c:fillPlane16
Unexecuted instantiation: graph.c:fillPlane16
Unexecuted instantiation: hscale_fast_bilinear.c:fillPlane16
Unexecuted instantiation: input.c:fillPlane16
Unexecuted instantiation: options.c:fillPlane16
Unexecuted instantiation: output.c:fillPlane16
Unexecuted instantiation: rgb2rgb.c:fillPlane16
Unexecuted instantiation: slice.c:fillPlane16
Unexecuted instantiation: swscale_unscaled.c:fillPlane16
Unexecuted instantiation: gamma.c:fillPlane16
Unexecuted instantiation: hscale.c:fillPlane16
1077
1078
static inline void fillPlane32(uint8_t *plane, int stride, int width, int height, int y,
1079
                               int alpha, int bits, const int big_endian, int is_float)
1080
0
{
1081
0
    uint8_t *ptr = plane + stride * y;
1082
0
    uint32_t v;
1083
0
    uint32_t onef32 = 0x3f800000;
1084
0
    if (is_float)
1085
0
        v = alpha ? onef32 : 0;
1086
0
    else
1087
0
        v = alpha ? 0xFFFFFFFF>>(32-bits) : (1<<(bits-1));
1088
0
    if (big_endian != HAVE_BIGENDIAN)
1089
0
        v = av_bswap32(v);
1090
1091
0
    for (int i = 0; i < height; i++) {
1092
0
        for (int j = 0; j < width; j++)
1093
0
            AV_WN32(ptr + 4 * j, v);
1094
0
        ptr += stride;
1095
0
    }
1096
0
}
Unexecuted instantiation: swscale.c:fillPlane32
Unexecuted instantiation: utils.c:fillPlane32
Unexecuted instantiation: vscale.c:fillPlane32
Unexecuted instantiation: yuv2rgb.c:fillPlane32
Unexecuted instantiation: alphablend.c:fillPlane32
Unexecuted instantiation: graph.c:fillPlane32
Unexecuted instantiation: hscale_fast_bilinear.c:fillPlane32
Unexecuted instantiation: input.c:fillPlane32
Unexecuted instantiation: options.c:fillPlane32
Unexecuted instantiation: output.c:fillPlane32
Unexecuted instantiation: rgb2rgb.c:fillPlane32
Unexecuted instantiation: slice.c:fillPlane32
Unexecuted instantiation: swscale_unscaled.c:fillPlane32
Unexecuted instantiation: gamma.c:fillPlane32
Unexecuted instantiation: hscale.c:fillPlane32
1097
1098
1099
#define MAX_SLICE_PLANES 4
1100
1101
/// Slice plane
1102
typedef struct SwsPlane
1103
{
1104
    int available_lines;    ///< max number of lines that can be hold by this plane
1105
    int sliceY;             ///< index of first line
1106
    int sliceH;             ///< number of lines
1107
    uint8_t **line;         ///< line buffer
1108
    uint8_t **tmp;          ///< Tmp line buffer used by mmx code
1109
} SwsPlane;
1110
1111
/**
1112
 * Struct which defines a slice of an image to be scaled or an output for
1113
 * a scaled slice.
1114
 * A slice can also be used as intermediate ring buffer for scaling steps.
1115
 */
1116
typedef struct SwsSlice
1117
{
1118
    int width;              ///< Slice line width
1119
    int h_chr_sub_sample;   ///< horizontal chroma subsampling factor
1120
    int v_chr_sub_sample;   ///< vertical chroma subsampling factor
1121
    int is_ring;            ///< flag to identify if this slice is a ring buffer
1122
    int should_free_lines;  ///< flag to identify if there are dynamic allocated lines
1123
    enum AVPixelFormat fmt; ///< planes pixel format
1124
    SwsPlane plane[MAX_SLICE_PLANES];   ///< color planes
1125
} SwsSlice;
1126
1127
/**
1128
 * Struct which holds all necessary data for processing a slice.
1129
 * A processing step can be a color conversion or horizontal/vertical scaling.
1130
 */
1131
typedef struct SwsFilterDescriptor
1132
{
1133
    SwsSlice *src;  ///< Source slice
1134
    SwsSlice *dst;  ///< Output slice
1135
1136
    int alpha;      ///< Flag for processing alpha channel
1137
    void *instance; ///< Filter instance data
1138
1139
    /// Function for processing input slice sliceH lines starting from line sliceY
1140
    int (*process)(SwsInternal *c, struct SwsFilterDescriptor *desc, int sliceY, int sliceH);
1141
} SwsFilterDescriptor;
1142
1143
// warp input lines in the form (src + width*i + j) to slice format (line[i][j])
1144
// relative=true means first line src[x][0] otherwise first line is src[x][lum/crh Y]
1145
int ff_init_slice_from_src(SwsSlice * s, uint8_t *const src[4], const int stride[4],
1146
                           int srcW, int lumY, int lumH, int chrY, int chrH, int relative);
1147
1148
// Initialize scaler filter descriptor chain
1149
int ff_init_filters(SwsInternal *c);
1150
1151
// Free all filter data
1152
int ff_free_filters(SwsInternal *c);
1153
1154
/*
1155
 function for applying ring buffer logic into slice s
1156
 It checks if the slice can hold more @lum lines, if yes
1157
 do nothing otherwise remove @lum least used lines.
1158
 It applies the same procedure for @chr lines.
1159
*/
1160
int ff_rotate_slice(SwsSlice *s, int lum, int chr);
1161
1162
/// initializes gamma conversion descriptor
1163
int ff_init_gamma_convert(SwsFilterDescriptor *desc, SwsSlice * src, uint16_t *table);
1164
1165
/// initializes lum pixel format conversion descriptor
1166
int ff_init_desc_fmt_convert(SwsFilterDescriptor *desc, SwsSlice * src, SwsSlice *dst, uint32_t *pal);
1167
1168
/// initializes lum horizontal scaling descriptor
1169
int ff_init_desc_hscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint16_t *filter, int * filter_pos, int filter_size, int xInc);
1170
1171
/// initializes chr pixel format conversion descriptor
1172
int ff_init_desc_cfmt_convert(SwsFilterDescriptor *desc, SwsSlice * src, SwsSlice *dst, uint32_t *pal);
1173
1174
/// initializes chr horizontal scaling descriptor
1175
int ff_init_desc_chscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint16_t *filter, int * filter_pos, int filter_size, int xInc);
1176
1177
int ff_init_desc_no_chr(SwsFilterDescriptor *desc, SwsSlice * src, SwsSlice *dst);
1178
1179
/// initializes vertical scaling descriptors
1180
int ff_init_vscale(SwsInternal *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst);
1181
1182
/// setup vertical scaler functions
1183
void ff_init_vscale_pfn(SwsInternal *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn yuv2planeX,
1184
    yuv2interleavedX_fn yuv2nv12cX, yuv2packed1_fn yuv2packed1, yuv2packed2_fn yuv2packed2,
1185
    yuv2packedX_fn yuv2packedX, yuv2anyX_fn yuv2anyX, int use_mmx);
1186
1187
void ff_sws_slice_worker(void *priv, int jobnr, int threadnr,
1188
                         int nb_jobs, int nb_threads);
1189
1190
int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[],
1191
               int srcSliceY, int srcSliceH, uint8_t *const dst[],
1192
               const int dstStride[], int dstSliceY, int dstSliceH);
1193
1194
1195
//number of extra lines to process
1196
#define MAX_LINES_AHEAD 4
1197
1198
//shuffle filter and filterPos for hyScale and hcScale filters in avx2
1199
int ff_shuffle_filter_coefficients(SwsInternal *c, int* filterPos, int filterSize, int16_t *filter, int dstW);
1200
#endif /* SWSCALE_SWSCALE_INTERNAL_H */