FFmpeg
Loading...
Searching...
No Matches
sw_scale.c
Go to the documentation of this file.
1/*
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#include <string.h>
21
22#include "libavutil/common.h"
24#include "libavutil/mem.h"
26
27#include "libswscale/swscale.h"
29
30#include "checkasm.h"
31
32#define randomize_buffers(buf, size) \
33 do { \
34 int j; \
35 for (j = 0; j < size; j+=4) \
36 AV_WN32(buf + j, rnd()); \
37 } while (0)
38
39static void yuv2planeX_8_ref(const int16_t *filter, int filterSize,
40 const int16_t **src, uint8_t *dest, int dstW,
41 const uint8_t *dither, int offset)
42{
43 // This corresponds to the yuv2planeX_8_c function
44 int i;
45 for (i = 0; i < dstW; i++) {
46 int val = dither[(i + offset) & 7] << 12;
47 int j;
48 for (j = 0; j < filterSize; j++)
49 val += src[j][i] * filter[j];
50
51 dest[i]= av_clip_uint8(val >> 19);
52 }
53}
54
55#define CMP_FUNC(bits) \
56static int cmp_off_by_n_##bits(const uint##bits##_t *ref, const uint##bits##_t *test, \
57 size_t n, int accuracy) \
58{ \
59 for (size_t i = 0; i < n; i++) { \
60 if (abs((int)ref[i] - (int)test[i]) > accuracy) \
61 return 1; \
62 } \
63 return 0; \
64}
65
66CMP_FUNC(8)
67CMP_FUNC(16)
68
69#define SHOW_DIFF_FUNC(bits) \
70static void print_data_##bits(const uint##bits##_t *p, size_t len, size_t offset) \
71{ \
72 size_t i = 0; \
73 for (; i < len; i++) { \
74 if (i % 8 == 0) { \
75 printf("0x%04zx: ", i+offset); \
76 } \
77 printf("0x%02x ", (uint32_t) p[i]); \
78 if (i % 8 == 7) { \
79 printf("\n"); \
80 } \
81 } \
82 if (i % 8 != 0) { \
83 printf("\n"); \
84 } \
85} \
86static size_t show_differences_##bits(const uint##bits##_t *a, const uint##bits##_t *b, \
87 size_t len) \
88{ \
89 for (size_t i = 0; i < len; i++) { \
90 if (a[i] != b[i]) { \
91 size_t offset_of_mismatch = i; \
92 size_t offset; \
93 if (i >= 8) i-=8; \
94 offset = i & (~7); \
95 printf("test a:\n"); \
96 print_data_##bits(&a[offset], 32, offset); \
97 printf("\ntest b:\n"); \
98 print_data_##bits(&b[offset], 32, offset); \
99 printf("\n"); \
100 return offset_of_mismatch; \
101 } \
102 } \
103 return len; \
104}
105
108
109static void check_yuv2yuv1(int accurate)
110{
111 SwsContext *sws;
112 SwsInternal *c;
113 int osi, isi;
114 int dstW, offset;
115 size_t fail_offset;
116 /* Add short widths that split across the SIMD vector tail paths, so that
117 * a single residual vector iteration is exercised on every platform;
118 * such residuals can underflow/overflow the destination buffer. */
119 enum {
120 LARGEST_INPUT_SIZE = 512,
121 /* Leading guard before dst: wide enough to catch a whole-vector
122 * underflow, i.e. the widest single write a current yuv2plane1 may
123 * make while tail-looping. That is the LoongArch LASX 256-bit (32B)
124 * store; LSX, NEON and x86 sse2/avx all write 16B or less. */
125 DEST_GUARD = 32,
126 DEST_SIZE = LARGEST_INPUT_SIZE + 2 * DEST_GUARD,
127 };
128 const int input_sizes[] = {5, 8, 9, 15, 17, 24, 128, 144, 256, 512};
129
130 const int offsets[] = {0, 3, 8, 11, 16, 19};
131 const int OFFSET_SIZES = sizeof(offsets)/sizeof(offsets[0]);
132 const char *accurate_str = (accurate) ? "accurate" : "approximate";
133 uint8_t *dst_ref, *dst_new;
134
135 declare_func(void,
136 const int16_t *src, uint8_t *dest,
137 int dstW, const uint8_t *dither, int offset);
138
139 LOCAL_ALIGNED_16(int16_t, src_pixels, [LARGEST_INPUT_SIZE]);
140 LOCAL_ALIGNED_16(uint8_t, dst0, [DEST_SIZE]);
141 LOCAL_ALIGNED_16(uint8_t, dst1, [DEST_SIZE]);
142 LOCAL_ALIGNED_8(uint8_t, dither, [8]);
143
144 randomize_buffers((uint8_t*)dither, 8);
145 randomize_buffers((uint8_t*)src_pixels, LARGEST_INPUT_SIZE * sizeof(int16_t));
146 sws = sws_alloc_context();
147 if (accurate)
148 sws->flags |= SWS_ACCURATE_RND;
149 if (sws_init_context(sws, NULL, NULL) < 0)
150 fail();
151
152 c = sws_internal(sws);
154 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi) {
155 dstW = input_sizes[isi];
156 for (osi = 0; osi < OFFSET_SIZES; osi++) {
157 offset = offsets[osi];
158 if (check_func(c->yuv2plane1, "yuv2yuv1_%d_%d_%s", offset, dstW, accurate_str)){
159 /* dst0 and dst1 start bit-identical so that any write outside
160 * of the dstW output window shows up as a guard mismatch. */
161 randomize_buffers(dst0, DEST_SIZE);
162 memcpy(dst1, dst0, DEST_SIZE);
163 dst_ref = dst0 + DEST_GUARD;
164 dst_new = dst1 + DEST_GUARD;
165
166 call_ref(src_pixels, dst_ref, dstW, dither, offset);
167 call_new(src_pixels, dst_new, dstW, dither, offset);
168
169 if (cmp_off_by_n_8(dst_ref, dst_new, dstW, accurate ? 0 : 2)) {
170 fail();
171 printf("failed: yuv2yuv1_%d_%di_%s\n", offset, dstW, accurate_str);
172 fail_offset = show_differences_8(dst_ref, dst_new, dstW);
173 printf("failing values: src: 0x%04x dither: 0x%02x dst-c: %02x dst-asm: %02x\n",
174 (int) src_pixels[fail_offset],
175 (int) dither[(fail_offset + offset) & 7],
176 (int) dst_ref[fail_offset],
177 (int) dst_new[fail_offset]);
178 }
179
180 /* The guard regions on either side of the output window must
181 * remain identical between the reference and the tested
182 * implementation from the project-wide 16-byte alignment above
183 * dstW, the longest whole-vector write any current yuv2plane1
184 * may make: x86 sse2/avx store a 16-byte XMM per iteration
185 * and do not round down the tail, so the legal output window
186 * is dstW rounded up to 16, while LoongArch lsx/lasx write
187 * exactly dstW bytes. */
188 const int guard_off = (dstW + 15) & ~15;
189 if (memcmp(dst0, dst1, DEST_GUARD) ||
190 memcmp(dst_ref + guard_off, dst_new + guard_off,
191 DEST_SIZE - DEST_GUARD - guard_off)) {
192 fail();
193 printf("failed: yuv2yuv1_%d_%d_%s wrote outside destination\n",
194 offset, dstW, accurate_str);
195 }
196
197 if (dstW == LARGEST_INPUT_SIZE)
198 bench_new(src_pixels, dst_new, dstW, dither, offset);
199 }
200 }
201 }
202 sws_freeContext(sws);
203}
204
205static void check_yuv2yuvX(int accurate, int bit_depth, int dst_pix_format)
206{
207 SwsContext *sws;
208 SwsInternal *c;
209 int fsi, osi, isi, i, j;
210 int dstW;
211#define LARGEST_FILTER 16
212 // ff_yuv2planeX_8_sse2 can't handle odd filter sizes
213 const int filter_sizes[] = {2, 4, 8, 16};
214 const int FILTER_SIZES = sizeof(filter_sizes)/sizeof(filter_sizes[0]);
215#define LARGEST_INPUT_SIZE 512
216 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
217 const char *accurate_str = (accurate) ? "accurate" : "approximate";
218
219 declare_func(void, const int16_t *filter,
220 int filterSize, const int16_t **src, uint8_t *dest,
221 int dstW, const uint8_t *dither, int offset);
222
223 const int16_t **src;
224 LOCAL_ALIGNED_16(int16_t, src_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
225 LOCAL_ALIGNED_16(int16_t, filter_coeff, [LARGEST_FILTER]);
226 LOCAL_ALIGNED_16(uint16_t, dst0, [LARGEST_INPUT_SIZE]);
227 LOCAL_ALIGNED_16(uint16_t, dst1, [LARGEST_INPUT_SIZE]);
229 union VFilterData{
230 const int16_t *src;
231 uint16_t coeff[8];
232 } *vFilterData;
233 uint8_t d_val = rnd();
234 memset(dither, d_val, LARGEST_INPUT_SIZE);
235 randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t));
236 sws = sws_alloc_context();
237 sws->dst_format = dst_pix_format;
238 if (accurate)
239 sws->flags |= SWS_ACCURATE_RND;
240 if (sws_init_context(sws, NULL, NULL) < 0)
241 fail();
242
243 c = sws_internal(sws);
244 c->dstBpc = bit_depth;
246 for(isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi){
247 dstW = input_sizes[isi];
248 for(osi = 0; osi < 64; osi += 16){
249 if (dstW <= osi)
250 continue;
251 for (fsi = 0; fsi < FILTER_SIZES; ++fsi) {
252 // Generate filter coefficients for the given filter size,
253 // with some properties:
254 // - The coefficients add up to the intended sum (4096, 1<<12)
255 // - The coefficients contain negative values
256 // - The filter intermediates don't overflow for worst case
257 // inputs (all positive coefficients are coupled with
258 // input_max and all negative coefficients with input_min,
259 // or vice versa).
260 // Produce a filter with all coefficients set to
261 // -((1<<12)/(filter_size-1)) except for one (randomly chosen)
262 // which is set to ((1<<13)-1).
263 for (i = 0; i < filter_sizes[fsi]; ++i)
264 filter_coeff[i] = -((1 << 12) / (filter_sizes[fsi] - 1));
265 filter_coeff[rnd() % filter_sizes[fsi]] = (1 << 13) - 1;
266
267 src = av_malloc(sizeof(int16_t*) * filter_sizes[fsi]);
268 vFilterData = av_malloc((filter_sizes[fsi] + 2) * sizeof(union VFilterData));
269 memset(vFilterData, 0, (filter_sizes[fsi] + 2) * sizeof(union VFilterData));
270 for (i = 0; i < filter_sizes[fsi]; ++i) {
271 src[i] = &src_pixels[i * LARGEST_INPUT_SIZE];
272 vFilterData[i].src = src[i] - osi;
273 for(j = 0; j < 4; ++j)
274 vFilterData[i].coeff[j + 4] = filter_coeff[i];
275 }
276 if (check_func(c->yuv2planeX, "yuv2yuvX_%d%s_%d_%d_%d_%s", bit_depth, (bit_depth == 8) ? "" : (isBE(dst_pix_format) ? "BE" : "LE"), filter_sizes[fsi], osi, dstW, accurate_str)) {
277 // use vFilterData for the mmx function
278 const int16_t *filter = c->use_mmx_vfilter ? (const int16_t*)vFilterData : &filter_coeff[0];
279 memset(dst0, 0, LARGEST_INPUT_SIZE * sizeof(dst0[0]));
280 memset(dst1, 0, LARGEST_INPUT_SIZE * sizeof(dst1[0]));
281
282 if (c->dstBpc == 8) {
283 // We can't use call_ref here, because we don't know if use_mmx_vfilter was set for that
284 // function or not, so we can't pass it the parameters correctly.
285
286 yuv2planeX_8_ref(&filter_coeff[0], filter_sizes[fsi], src, (uint8_t*)dst0, dstW - osi, dither, osi);
287 call_new(filter, filter_sizes[fsi], src, (uint8_t*)dst1, dstW - osi, dither, osi);
288
289 if (cmp_off_by_n_8((uint8_t*)dst0, (uint8_t*)dst1, LARGEST_INPUT_SIZE, accurate ? 0 : 2)) {
290 fail();
291 printf("failed: yuv2yuvX_%d_%d_%d_%d_%s\n", bit_depth, filter_sizes[fsi], osi, dstW, accurate_str);
292 show_differences_8((uint8_t*)dst0, (uint8_t*)dst1, LARGEST_INPUT_SIZE);
293 }
294 } else {
295 call_ref(&filter_coeff[0], filter_sizes[fsi], src, (uint8_t*)dst0, dstW - osi, dither, osi);
296 call_new(&filter_coeff[0], filter_sizes[fsi], src, (uint8_t*)dst1, dstW - osi, dither, osi);
297
298 if (cmp_off_by_n_16(dst0, dst1, LARGEST_INPUT_SIZE, accurate ? 0 : 2)) {
299 fail();
300 printf("failed: yuv2yuvX_%d%s_%d_%d_%d_%s\n", bit_depth, isBE(dst_pix_format) ? "BE" : "LE", filter_sizes[fsi], osi, dstW, accurate_str);
301 show_differences_16(dst0, dst1, LARGEST_INPUT_SIZE);
302 }
303 }
304 if (dstW == LARGEST_INPUT_SIZE)
305 bench_new(filter, filter_sizes[fsi], src, (uint8_t*)dst1, dstW - osi, dither, osi);
306
307 }
308 av_freep(&src);
309 av_freep(&vFilterData);
310 }
311 }
312 }
313 sws_freeContext(sws);
314#undef FILTER_SIZES
315}
316
317static void check_yuv2nv12cX(int accurate)
318{
319 SwsContext *sws;
320 SwsInternal *c;
321#define LARGEST_FILTER 16
322 const int filter_sizes[] = {2, 4, 8, 16};
323#define LARGEST_INPUT_SIZE 512
324 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
325 const char *accurate_str = (accurate) ? "accurate" : "approximate";
326
327 declare_func(void, enum AVPixelFormat dstFormat,
328 const uint8_t *chrDither, const int16_t *chrFilter,
329 int chrFilterSize, const int16_t **chrUSrc,
330 const int16_t **chrVSrc, uint8_t *dest, int dstW);
331
332 const int16_t *srcU[LARGEST_FILTER], *srcV[LARGEST_FILTER];
333 LOCAL_ALIGNED_16(int16_t, srcU_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
334 LOCAL_ALIGNED_16(int16_t, srcV_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
335 LOCAL_ALIGNED_16(int16_t, filter_coeff, [LARGEST_FILTER]);
336 LOCAL_ALIGNED_16(uint8_t, dst0, [LARGEST_INPUT_SIZE * 2]);
337 LOCAL_ALIGNED_16(uint8_t, dst1, [LARGEST_INPUT_SIZE * 2]);
339 uint8_t d_val = rnd();
340 memset(dither, d_val, LARGEST_INPUT_SIZE);
341 randomize_buffers((uint8_t*)srcU_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t));
342 randomize_buffers((uint8_t*)srcV_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t));
343 for (int i = 0; i < LARGEST_FILTER; i++) {
344 srcU[i] = &srcU_pixels[i * LARGEST_INPUT_SIZE];
345 srcV[i] = &srcV_pixels[i * LARGEST_INPUT_SIZE];
346 }
347
348 sws = sws_alloc_context();
350 if (accurate)
351 sws->flags |= SWS_ACCURATE_RND;
352 if (sws_init_context(sws, NULL, NULL) < 0)
353 fail();
354
355 c = sws_internal(sws);
357 for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++){
358 const int dstW = input_sizes[isi];
359 for (int fsi = 0; fsi < FF_ARRAY_ELEMS(filter_sizes); fsi++) {
360 const int filter_size = filter_sizes[fsi];
361 for (int i = 0; i < filter_size; i++)
362 filter_coeff[i] = -((1 << 12) / (filter_size - 1));
363 filter_coeff[rnd() % filter_size] = (1 << 13) - 1;
364
365 if (check_func(c->yuv2nv12cX, "yuv2nv12cX_%d_%d_%s", filter_size, dstW, accurate_str)){
366 memset(dst0, 0, LARGEST_INPUT_SIZE * sizeof(dst0[0]));
367 memset(dst1, 0, LARGEST_INPUT_SIZE * sizeof(dst1[0]));
368
369 call_ref(sws->dst_format, dither, &filter_coeff[0], filter_size, srcU, srcV, dst0, dstW);
370 call_new(sws->dst_format, dither, &filter_coeff[0], filter_size, srcU, srcV, dst1, dstW);
371
372 if (cmp_off_by_n_8(dst0, dst1, dstW * 2 * sizeof(dst0[0]), accurate ? 0 : 2)) {
373 fail();
374 printf("failed: yuv2nv12wX_%d_%d_%s\n", filter_size, dstW, accurate_str);
375 show_differences_8(dst0, dst1, dstW * 2 * sizeof(dst0[0]));
376 }
377 if (dstW == LARGEST_INPUT_SIZE)
378 bench_new(sws->dst_format, dither, &filter_coeff[0], filter_size, srcU, srcV, dst1, dstW);
379
380 }
381 }
382 }
383 sws_freeContext(sws);
384}
385#undef LARGEST_FILTER
386#undef LARGEST_INPUT_SIZE
387
388#undef SRC_PIXELS
389#define SRC_PIXELS 512
390
391static void check_hscale(void)
392{
393#define MAX_FILTER_WIDTH 40
394#define FILTER_SIZES 6
395 static const int filter_sizes[FILTER_SIZES] = { 4, 8, 12, 16, 32, 40 };
396
397#define HSCALE_PAIRS 2
398 static const int hscale_pairs[HSCALE_PAIRS][2] = {
399 { 8, 14 },
400 { 8, 18 },
401 };
402
403#define LARGEST_INPUT_SIZE 512
404 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
405
406 int i, j, fsi, hpi, width, dstWi;
407 SwsContext *sws;
408 SwsInternal *c;
409
410 // padded
412 LOCAL_ALIGNED_32(uint32_t, dst0, [SRC_PIXELS]);
413 LOCAL_ALIGNED_32(uint32_t, dst1, [SRC_PIXELS]);
414
415 // padded
417 LOCAL_ALIGNED_32(int32_t, filterPos, [SRC_PIXELS]);
419 LOCAL_ALIGNED_32(int32_t, filterPosAvx, [SRC_PIXELS]);
420
421 // The dst parameter here is either int16_t or int32_t but we use void* to
422 // just cover both cases.
423 declare_func(void, SwsInternal *c, int16_t *dst, int dstW,
424 const uint8_t *src, const int16_t *filter,
425 const int32_t *filterPos, int filterSize);
426
427 sws = sws_alloc_context();
428 if (sws_init_context(sws, NULL, NULL) < 0)
429 fail();
430
431 c = sws_internal(sws);
433
434 for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) {
435 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
436 for (dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
437 width = filter_sizes[fsi];
438
439 c->srcBpc = hscale_pairs[hpi][0];
440 c->dstBpc = hscale_pairs[hpi][1];
441 c->hLumFilterSize = c->hChrFilterSize = width;
442
443 for (i = 0; i < SRC_PIXELS; i++) {
444 filterPos[i] = i;
445 filterPosAvx[i] = i;
446
447 // These filter coefficients are chosen to try break two corner
448 // cases, namely:
449 //
450 // - Negative filter coefficients. The filters output signed
451 // values, and it should be possible to end up with negative
452 // output values.
453 //
454 // - Positive clipping. The hscale filter function has clipping
455 // at (1<<15) - 1
456 //
457 // The coefficients sum to the 1.0 point for the hscale
458 // functions (1 << 14).
459
460 for (j = 0; j < width; j++) {
461 filter[i * width + j] = -((1 << 14) / (width - 1));
462 }
463 filter[i * width + (rnd() % width)] = ((1 << 15) - 1);
464 }
465
466 for (i = 0; i < MAX_FILTER_WIDTH; i++) {
467 // These values should be unused in SIMD implementations but
468 // may still be read, random coefficients here should help show
469 // issues where they are used in error.
470
471 filter[SRC_PIXELS * width + i] = rnd();
472 }
473 sws->dst_w = c->chrDstW = input_sizes[dstWi];
475 memcpy(filterAvx2, filter, sizeof(uint16_t) * (SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH));
476 ff_shuffle_filter_coefficients(c, filterPosAvx, width, filterAvx2, sws->dst_w);
477
478 av_assert0(c->hyScale == c->hcScale);
479 if (check_func(c->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", c->srcBpc, c->dstBpc + 1, width, sws->dst_w)) {
480 memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0]));
481 memset(dst1, 0, SRC_PIXELS * sizeof(dst1[0]));
482
483 call_ref(NULL, (int16_t *)dst0, sws->dst_w, src, filter, filterPos, width);
484 call_new(NULL, (int16_t *)dst1, sws->dst_w, src, filterAvx2, filterPosAvx, width);
485 if (memcmp(dst0, dst1, sws->dst_w * sizeof(dst0[0])))
486 fail();
487 bench_new(NULL, (int16_t *)dst0, sws->dst_w, src, filter, filterPosAvx, width);
488 }
489 }
490 }
491 }
492 sws_freeContext(sws);
493}
494
496{
497 check_hscale();
498 report("hscale");
501 report("yuv2yuv1");
504 report("yuv2yuvX_8");
507 report("yuv2yuvX_9LE");
510 report("yuv2yuvX_9BE");
513 report("yuv2yuvX_10LE");
516 report("yuv2yuvX_10BE");
519 report("yuv2yuvX_12LE");
522 report("yuv2yuvX_12BE");
525 report("yuv2yuvX_14LE");
528 report("yuv2yuvX_14BE");
531 report("yuv2nv12cX");
532}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static double val(void *priv, double ch)
Definition aeval.c:77
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
int32_t
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:135
common internal and external API header
#define av_clip_uint8
Definition common.h:106
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
av_warn_unused_result int sws_init_context(SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
Definition utils.c:1886
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
Definition utils.c:1031
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
Definition utils.c:2252
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition swscale.h:177
static const int offsets[]
Definition hevc_pel.c:34
unsigned offset
Definition libaomenc.c:763
#define FFALIGN(x, a)
Definition macros.h:78
Memory handling functions.
#define LOCAL_ALIGNED_32(t, v,...)
#define LOCAL_ALIGNED_16(t, v,...)
#define LOCAL_ALIGNED_8(t, v,...)
#define av_malloc(s)
Definition ops_static.c:52
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:270
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:154
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:156
@ AV_PIX_FMT_YUV420P14BE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:269
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:268
@ AV_PIX_FMT_YUV420P12BE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:267
@ AV_PIX_FMT_YUV420P10BE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:155
@ AV_PIX_FMT_YUV420P9BE
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition pixfmt.h:153
#define FF_ARRAY_ELEMS(a)
Main external API structure.
Definition swscale.h:227
int dst_format
Destination pixel format.
Definition swscale.h:275
int dst_w
Definition swscale.h:273
unsigned flags
Bitmask of SWS_*.
Definition swscale.h:238
#define FILTER_SIZES
#define LARGEST_INPUT_SIZE
#define LARGEST_FILTER
static const int input_sizes[]
Definition sw_rgb.c:351
static void check_yuv2nv12cX(int accurate)
Definition sw_scale.c:317
#define SRC_PIXELS
Definition sw_scale.c:389
static void check_hscale(void)
Definition sw_scale.c:391
#define MAX_FILTER_WIDTH
static void yuv2planeX_8_ref(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Definition sw_scale.c:39
#define randomize_buffers(buf, size)
Definition sw_scale.c:32
#define HSCALE_PAIRS
static void check_yuv2yuvX(int accurate, int bit_depth, int dst_pix_format)
Definition sw_scale.c:205
static void check_yuv2yuv1(int accurate)
Definition sw_scale.c:109
void checkasm_check_sw_scale(void)
Definition sw_scale.c:495
#define SHOW_DIFF_FUNC(bits)
Definition sw_scale.c:69
#define CMP_FUNC(bits)
Definition sw_scale.c:55
void ff_sws_init_scale(SwsInternal *c)
Definition swscale.c:697
external API header
int ff_shuffle_filter_coefficients(SwsInternal *c, int *filterPos, int filterSize, int16_t *filter, int dstW)
Definition utils.c:96
static SwsInternal * sws_internal(const SwsContext *sws)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
#define av_freep(p)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
#define src
Definition vp8dsp.c:248
#define width
Definition dsp.h:89
static const uint16_t dither[8][8]
Definition vf_gradfun.c:46
static const double coeff[2][5]
static double c[64]