FFmpeg
swscale.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-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 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <inttypes.h>
25 #include <stdarg.h>
26 
27 #undef HAVE_AV_CONFIG_H
28 #include "libavutil/cpu.h"
29 #include "libavutil/imgutils.h"
30 #include "libavutil/mem.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/crc.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/lfg.h"
36 #include "libavutil/sfc64.h"
37 
38 #include "libswscale/swscale.h"
39 
40 /* HACK Duplicated from swscale_internal.h.
41  * Should be removed when a cleaner pixel format system exists. */
42 #define isGray(x) \
43  ((x) == AV_PIX_FMT_GRAY8 || \
44  (x) == AV_PIX_FMT_YA8 || \
45  (x) == AV_PIX_FMT_GRAY16BE || \
46  (x) == AV_PIX_FMT_GRAY16LE || \
47  (x) == AV_PIX_FMT_YA16BE || \
48  (x) == AV_PIX_FMT_YA16LE)
49 #define hasChroma(x) \
50  (!(isGray(x) || \
51  (x) == AV_PIX_FMT_MONOBLACK || \
52  (x) == AV_PIX_FMT_MONOWHITE))
53 
55 {
57  return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
58 }
59 
60 static double prob = 1;
62 
63 static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
64  int stride1, int stride2, int w, int h)
65 {
66  int x, y;
67  uint64_t ssd = 0;
68 
69  for (y = 0; y < h; y++) {
70  for (x = 0; x < w; x++) {
71  int d = src1[x + y * stride1] - src2[x + y * stride2];
72  ssd += d * d;
73  }
74  }
75  return ssd;
76 }
77 
78 static uint64_t getSSD0(int ref, const uint8_t *src1, int stride1,
79  int w, int h)
80 {
81  int x, y;
82  uint64_t ssd = 0;
83 
84  for (y = 0; y < h; y++) {
85  for (x = 0; x < w; x++) {
86  int d = src1[x + y * stride1] - ref;
87  ssd += d * d;
88  }
89  }
90  return ssd;
91 }
92 
93 struct Results {
94  uint64_t ssdY;
95  uint64_t ssdU;
96  uint64_t ssdV;
97  uint64_t ssdA;
98  uint32_t crc;
99 };
100 
101 // test by ref -> src -> dst -> out & compare out against ref
102 // ref & out are YV12
103 static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
104  enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat,
105  int srcW, int srcH, int dstW, int dstH, int flags,
106  struct Results *r)
107 {
109  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat);
110  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat);
111  static enum AVPixelFormat cur_srcFormat;
112  static int cur_srcW, cur_srcH;
113  static const uint8_t *src[4];
114  static int srcStride[4];
115  uint8_t *dst[4] = { 0 };
116  uint8_t *out[4] = { 0 };
117  int dstStride[4] = {0};
118  int i;
119  uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
120  struct SwsContext *dstContext = NULL, *outContext = NULL;
121  uint32_t crc = 0;
122  int res = 0;
123 
124  if (ff_sfc64_get(&prng_state) > UINT64_MAX * prob)
125  return 0;
126 
127  if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
128  struct SwsContext *srcContext = NULL;
129  int p;
130 
131  for (p = 0; p < 4; p++)
132  av_freep(&src[p]);
133 
134  res = av_image_fill_linesizes(srcStride, srcFormat, srcW);
135  if (res < 0) {
136  fprintf(stderr, "av_image_fill_linesizes failed\n");
137  goto end;
138  }
139  for (p = 0; p < 4; p++) {
140  srcStride[p] = FFALIGN(srcStride[p], 16);
141  if (srcStride[p])
142  src[p] = av_mallocz(srcStride[p] * srcH + 16);
143  if (srcStride[p] && !src[p]) {
144  perror("Malloc");
145  res = -1;
146  goto end;
147  }
148  }
149  srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
151  if (!srcContext) {
152  fprintf(stderr, "Failed to get %s ---> %s\n",
153  desc_yuva420p->name,
154  desc_src->name);
155  res = -1;
156  goto end;
157  }
158  sws_scale(srcContext, ref, refStride, 0, h,
159  (uint8_t * const *) src, srcStride);
160  sws_freeContext(srcContext);
161 
162  cur_srcFormat = srcFormat;
163  cur_srcW = srcW;
164  cur_srcH = srcH;
165  }
166 
167  res = av_image_fill_linesizes(dstStride, dstFormat, dstW);
168  if (res < 0) {
169  fprintf(stderr, "av_image_fill_linesizes failed\n");
170  goto end;
171  }
172 
173  for (i = 0; i < 4; i++) {
174  /* Image buffers passed into libswscale can be allocated any way you
175  * prefer, as long as they're aligned enough for the architecture, and
176  * they're freed appropriately (such as using av_free for buffers
177  * allocated with av_malloc). */
178  /* An extra 16 bytes is being allocated because some scalers may write
179  * out of bounds. */
180  dstStride[i] = FFALIGN(dstStride[i], 16);
181  if (dstStride[i])
182  dst[i] = av_mallocz(dstStride[i] * dstH + 16);
183  if (dstStride[i] && !dst[i]) {
184  perror("Malloc");
185  res = -1;
186 
187  goto end;
188  }
189  }
190 
191  dstContext = sws_alloc_context();
192  if (!dstContext) {
193  fprintf(stderr, "Failed to alloc %s ---> %s\n",
194  desc_src->name, desc_dst->name);
195  res = -1;
196  goto end;
197  }
198 
199  av_opt_set_int(dstContext, "sws_flags", flags, 0);
200  av_opt_set_int(dstContext, "srcw", srcW, 0);
201  av_opt_set_int(dstContext, "srch", srcH, 0);
202  av_opt_set_int(dstContext, "dstw", dstW, 0);
203  av_opt_set_int(dstContext, "dsth", dstH, 0);
204  av_opt_set_int(dstContext, "src_format", srcFormat, 0);
205  av_opt_set_int(dstContext, "dst_format", dstFormat, 0);
206  av_opt_set(dstContext, "alphablend", "none", 0);
207 
208  if (sws_init_context(dstContext, NULL, NULL) < 0) {
209  sws_freeContext(dstContext);
210  fprintf(stderr, "Failed to init %s ---> %s\n",
211  desc_src->name, desc_dst->name);
212  res = -1;
213  goto end;
214  }
215 
216  printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
217  desc_src->name, srcW, srcH,
218  desc_dst->name, dstW, dstH,
219  flags);
220  fflush(stdout);
221 
222  sws_scale(dstContext, (const uint8_t * const*)src, srcStride, 0, srcH, dst, dstStride);
223 
224  for (i = 0; i < 4 && dstStride[i]; i++)
225  crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
226  dstStride[i] * dstH);
227 
228  if (r && crc == r->crc) {
229  ssdY = r->ssdY;
230  ssdU = r->ssdU;
231  ssdV = r->ssdV;
232  ssdA = r->ssdA;
233  } else {
234  for (i = 0; i < 4; i++) {
235  refStride[i] = FFALIGN(refStride[i], 16);
236  if (refStride[i])
237  out[i] = av_mallocz(refStride[i] * h);
238  if (refStride[i] && !out[i]) {
239  perror("Malloc");
240  res = -1;
241  goto end;
242  }
243  }
244  outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
246  NULL, NULL, NULL);
247  if (!outContext) {
248  fprintf(stderr, "Failed to get %s ---> %s\n",
249  desc_dst->name,
250  desc_yuva420p->name);
251  res = -1;
252  goto end;
253  }
254  sws_scale(outContext, (const uint8_t * const *) dst, dstStride, 0, dstH,
255  out, refStride);
256 
257  ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
259  //FIXME check that output is really gray
260  ssdU = getSSD(ref[1], out[1], refStride[1], refStride[1],
261  (w + 1) >> 1, (h + 1) >> 1);
262  ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
263  (w + 1) >> 1, (h + 1) >> 1);
264  } else {
265  ssdU = getSSD0(128, out[1], refStride[1],
266  (w + 1) >> 1, (h + 1) >> 1);
267  ssdV = getSSD0(128, out[2], refStride[2],
268  (w + 1) >> 1, (h + 1) >> 1);
269  }
270  if (isALPHA(srcFormat) && isALPHA(dstFormat)) {
271  ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
272  } else {
273  ssdA = getSSD0(0xFF, out[3], refStride[3], w, h);
274  }
275 
276  ssdY /= w * h;
277  ssdU /= w * h / 4;
278  ssdV /= w * h / 4;
279  ssdA /= w * h;
280 
281  sws_freeContext(outContext);
282 
283  for (i = 0; i < 4; i++)
284  if (refStride[i])
285  av_free(out[i]);
286  }
287 
288  if(r){
289  if(ssdY>r->ssdY*1.02+1 || ssdU>r->ssdU*1.02+1 || ssdV>r->ssdV*1.02+1|| ssdA>r->ssdA*1.02+1)
290  printf("WORSE SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
291  r->ssdY, r->ssdU, r->ssdV, r->ssdA);
292  else if(ssdY>r->ssdY || ssdU>r->ssdU || ssdV>r->ssdV|| ssdA>r->ssdA)
293  printf("worse SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
294  r->ssdY, r->ssdU, r->ssdV, r->ssdA);
295  }
296 
297  printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
298  crc, ssdY, ssdU, ssdV, ssdA);
299 
300 end:
301  sws_freeContext(dstContext);
302 
303  for (i = 0; i < 4; i++)
304  if (dstStride[i])
305  av_free(dst[i]);
306 
307  return !!res;
308 }
309 
310 static void selfTest(const uint8_t * const ref[4], int refStride[4],
311  int w, int h,
312  enum AVPixelFormat srcFormat_in,
313  enum AVPixelFormat dstFormat_in)
314 {
315  const int flags[] = { SWS_FAST_BILINEAR,
319  const int srcW = w;
320  const int srcH = h;
321  const int dstW[] = { srcW - srcW / 3, srcW, srcW + srcW / 3, 0 };
322  const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
324  const AVPixFmtDescriptor *desc_src, *desc_dst;
325 
326  for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
330  continue;
331 
332  desc_src = av_pix_fmt_desc_get(srcFormat);
333 
334  for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
336  int i, j, k;
337  int res = 0;
338 
341  continue;
342 
343  desc_dst = av_pix_fmt_desc_get(dstFormat);
344 
345  printf("%s -> %s\n", desc_src->name, desc_dst->name);
346  fflush(stdout);
347 
348  for (k = 0; flags[k] && !res; k++)
349  for (i = 0; dstW[i] && !res; i++)
350  for (j = 0; dstH[j] && !res; j++)
351  res = doTest(ref, refStride, w, h,
353  srcW, srcH, dstW[i], dstH[j], flags[k],
354  NULL);
355  if (dstFormat_in != AV_PIX_FMT_NONE)
356  break;
357  }
358  if (srcFormat_in != AV_PIX_FMT_NONE)
359  break;
360  }
361 }
362 
363 static int fileTest(const uint8_t * const ref[4], int refStride[4],
364  int w, int h, FILE *fp,
365  enum AVPixelFormat srcFormat_in,
366  enum AVPixelFormat dstFormat_in)
367 {
368  char buf[256];
369 
370  while (fgets(buf, sizeof(buf), fp)) {
371  struct Results r;
372  enum AVPixelFormat srcFormat;
373  char srcStr[21];
374  int srcW = 0, srcH = 0;
375  enum AVPixelFormat dstFormat;
376  char dstStr[21];
377  int dstW = 0, dstH = 0;
378  int flags;
379  int ret;
380 
381  ret = sscanf(buf,
382  " %20s %dx%d -> %20s %dx%d flags=%d CRC=%x"
383  " SSD=%"SCNu64 ", %"SCNu64 ", %"SCNu64 ", %"SCNu64 "\n",
384  srcStr, &srcW, &srcH, dstStr, &dstW, &dstH,
385  &flags, &r.crc, &r.ssdY, &r.ssdU, &r.ssdV, &r.ssdA);
386  if (ret != 12) {
387  srcStr[0] = dstStr[0] = 0;
388  ret = sscanf(buf, "%20s -> %20s\n", srcStr, dstStr);
389  }
390 
391  srcFormat = av_get_pix_fmt(srcStr);
392  dstFormat = av_get_pix_fmt(dstStr);
393 
394  if (srcFormat == AV_PIX_FMT_NONE || dstFormat == AV_PIX_FMT_NONE ||
395  srcW > 8192U || srcH > 8192U || dstW > 8192U || dstH > 8192U) {
396  fprintf(stderr, "malformed input file\n");
397  return -1;
398  }
399  if ((srcFormat_in != AV_PIX_FMT_NONE && srcFormat_in != srcFormat) ||
400  (dstFormat_in != AV_PIX_FMT_NONE && dstFormat_in != dstFormat))
401  continue;
402  if (ret != 12) {
403  printf("%s", buf);
404  continue;
405  }
406 
407  doTest(ref, refStride, w, h,
408  srcFormat, dstFormat,
409  srcW, srcH, dstW, dstH, flags,
410  &r);
411  }
412 
413  return 0;
414 }
415 
416 #define W 96
417 #define H 96
418 
419 int main(int argc, char **argv)
420 {
421  enum AVPixelFormat srcFormat = AV_PIX_FMT_NONE;
422  enum AVPixelFormat dstFormat = AV_PIX_FMT_NONE;
423  uint8_t *rgb_data = av_malloc(W * H * 4);
424  const uint8_t * const rgb_src[4] = { rgb_data, NULL, NULL, NULL };
425  int rgb_stride[4] = { 4 * W, 0, 0, 0 };
426  uint8_t *data = av_malloc(4 * W * H);
427  const uint8_t * const src[4] = { data, data + W * H, data + W * H * 2, data + W * H * 3 };
428  int stride[4] = { W, W, W, W };
429  int x, y;
430  struct SwsContext *sws;
431  AVLFG rand;
432  int res = -1;
433  int i;
434  FILE *fp = NULL;
435 
436  if (!rgb_data || !data)
437  return -1;
438 
439  for (i = 1; i < argc; i += 2) {
440  if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) {
441  fprintf(stderr,
442  "swscale [options...]\n"
443  " -help\n"
444  " This text\n"
445  " -ref <file>\n"
446  " Uses file as reference to compae tests againsts. Tests that have become worse will contain the string worse or WORSE\n"
447  " -p <number between 0.0 and 1.0>\n"
448  " The percentage of tests or comparissions to perform. Doing all tests will take long and generate over a hundread MB text output\n"
449  " It is often convenient to perform a random subset\n"
450  " -dst <pixfmt>\n"
451  " Only test the specified destination pixel format\n"
452  " -src <pixfmt>\n"
453  " Only test the specified source pixel format\n"
454  " -cpuflags <cpuflags>\n"
455  " Uses the specified cpuflags in teh tests\n"
456  );
457  goto error;
458  }
459  if (argv[i][0] != '-' || i + 1 == argc)
460  goto bad_option;
461  if (!strcmp(argv[i], "-ref")) {
462  fp = fopen(argv[i + 1], "r");
463  if (!fp) {
464  fprintf(stderr, "could not open '%s'\n", argv[i + 1]);
465  goto error;
466  }
467  } else if (!strcmp(argv[i], "-cpuflags")) {
468  unsigned flags = av_get_cpu_flags();
469  int ret = av_parse_cpu_caps(&flags, argv[i + 1]);
470  if (ret < 0) {
471  fprintf(stderr, "invalid cpu flags %s\n", argv[i + 1]);
472  return ret;
473  }
475  } else if (!strcmp(argv[i], "-src")) {
476  srcFormat = av_get_pix_fmt(argv[i + 1]);
477  if (srcFormat == AV_PIX_FMT_NONE) {
478  fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
479  return -1;
480  }
481  } else if (!strcmp(argv[i], "-dst")) {
482  dstFormat = av_get_pix_fmt(argv[i + 1]);
483  if (dstFormat == AV_PIX_FMT_NONE) {
484  fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
485  return -1;
486  }
487  } else if (!strcmp(argv[i], "-p")) {
488  prob = atof(argv[i + 1]);
489  } else {
490 bad_option:
491  fprintf(stderr, "bad option or argument missing (%s) see -help\n", argv[i]);
492  goto error;
493  }
494  }
495 
496  ff_sfc64_init(&prng_state, 0, 0, 0, 12);
497 
498  sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
500 
501  av_lfg_init(&rand, 1);
502 
503  for (y = 0; y < H; y++)
504  for (x = 0; x < W * 4; x++)
505  rgb_data[ x + y * 4 * W] = av_lfg_get(&rand);
506  res = sws_scale(sws, rgb_src, rgb_stride, 0, H / 12, (uint8_t * const *) src, stride);
507  if (res < 0 || res != H) {
508  res = -1;
509  goto error;
510  }
511  sws_freeContext(sws);
512  av_free(rgb_data);
513 
514  if(fp) {
515  res = fileTest(src, stride, W, H, fp, srcFormat, dstFormat);
516  fclose(fp);
517  } else {
519  res = 0;
520  }
521 error:
522  av_free(data);
523 
524  return res;
525 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
av_force_cpu_flags
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
Definition: cpu.c:75
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
r
const char * r
Definition: vf_curves.c:126
opt.h
SwsContext::dstW
int dstW
Width of destination luma/alpha planes.
Definition: swscale_internal.h:514
out
FILE * out
Definition: movenc.c:54
sws_isSupportedOutput
#define sws_isSupportedOutput(x)
av_lfg_init
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition: lfg.c:32
selfTest
static void selfTest(const uint8_t *const ref[4], int refStride[4], int w, int h, enum AVPixelFormat srcFormat_in, enum AVPixelFormat dstFormat_in)
Definition: swscale.c:310
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2968
prob
static double prob
Definition: swscale.c:60
src1
const pixel * src1
Definition: h264pred_template.c:421
Results::crc
uint32_t crc
Definition: swscale.c:98
pixdesc.h
W
#define W
Definition: swscale.c:416
w
uint8_t w
Definition: llviddspenc.c:38
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
Results::ssdA
uint64_t ssdA
Definition: swscale.c:97
data
const char data[16]
Definition: mxf.c:148
ff_sfc64_init
static void ff_sfc64_init(FFSFC64 *s, uint64_t seeda, uint64_t seedb, uint64_t seedc, int rounds)
Initialize sfc64 with up to 3 seeds.
Definition: sfc64.h:75
sws_scale
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
swscale wrapper, so we don't need to export the SwsContext.
Definition: swscale.c:1205
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:103
prng_state
FFSFC64 prng_state
Definition: swscale.c:61
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
AV_PIX_FMT_NB
@ AV_PIX_FMT_NB
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
Definition: pixfmt.h:446
crc.h
SWS_FAST_BILINEAR
#define SWS_FAST_BILINEAR
Definition: swscale.h:65
SWS_BITEXACT
#define SWS_BITEXACT
Definition: swscale.h:91
FFSFC64
Definition: sfc64.h:37
av_parse_cpu_caps
int av_parse_cpu_caps(unsigned *flags, const char *s)
Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
Definition: cpu.c:113
hasChroma
#define hasChroma(x)
Definition: swscale.c:49
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:497
SWS_POINT
#define SWS_POINT
Definition: swscale.h:69
Results::ssdU
uint64_t ssdU
Definition: swscale.c:95
SwsContext::srcFormat
enum AVPixelFormat srcFormat
Source pixel format.
Definition: swscale_internal.h:331
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
av_lfg_get
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition: lfg.h:53
SWS_FULL_CHR_H_INP
#define SWS_FULL_CHR_H_INP
Definition: swscale.h:88
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
lfg.h
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
sfc64.h
getSSD
static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2, int stride1, int stride2, int w, int h)
Definition: swscale.c:63
SwsContext::dstFormat
enum AVPixelFormat dstFormat
Destination pixel format.
Definition: swscale_internal.h:330
Results
Definition: swscale.c:93
NULL
#define NULL
Definition: coverity.c:32
Results::ssdV
uint64_t ssdV
Definition: swscale.c:96
H
#define H
Definition: swscale.c:417
sws_alloc_context
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
Definition: utils.c:1180
fp
#define fp
Definition: regdef.h:44
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:634
getSSD0
static uint64_t getSSD0(int ref, const uint8_t *src1, int stride1, int w, int h)
Definition: swscale.c:78
SWS_X
#define SWS_X
Definition: swscale.h:68
doTest
static int doTest(const uint8_t *const ref[4], int refStride[4], int w, int h, enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat, int srcW, int srcH, int dstW, int dstH, int flags, struct Results *r)
Definition: swscale.c:103
AVLFG
Context structure for the Lagged Fibonacci PRNG.
Definition: lfg.h:33
sws_getContext
struct SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
Definition: utils.c:2094
cpu.h
SWS_FULL_CHR_H_INT
#define SWS_FULL_CHR_H_INT
Definition: swscale.h:86
SwsContext::srcH
int srcH
Height of source luma/alpha planes.
Definition: swscale_internal.h:322
printf
printf("static const uint8_t my_array[100] = {\n")
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:455
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
SWS_ACCURATE_RND
#define SWS_ACCURATE_RND
Definition: swscale.h:90
sws_isSupportedInput
#define sws_isSupportedInput(x)
SwsContext::srcW
int srcW
Width of source luma/alpha planes.
Definition: swscale_internal.h:321
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
src2
const pixel * src2
Definition: h264pred_template.c:422
av_always_inline
#define av_always_inline
Definition: attributes.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AV_CRC_32_IEEE
@ AV_CRC_32_IEEE
Definition: crc.h:52
ff_sfc64_get
static uint64_t ff_sfc64_get(FFSFC64 *s)
Definition: sfc64.h:41
stride
#define stride
Definition: h264pred_template.c:537
ret
ret
Definition: filter_design.txt:187
sws_init_context
av_warn_unused_result int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
Definition: utils.c:2036
U
#define U(x)
Definition: vpx_arith.h:37
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2900
Results::ssdY
uint64_t ssdY
Definition: swscale.c:94
isALPHA
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
Definition: swscale.c:54
main
int main(int argc, char **argv)
Definition: swscale.c:419
sws_freeContext
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
Definition: utils.c:2425
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:392
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
desc
const char * desc
Definition: libsvtav1.c:83
avutil.h
mem.h
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
d
d
Definition: ffmpeg_filter.c:424
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
fileTest
static int fileTest(const uint8_t *const ref[4], int refStride[4], int w, int h, FILE *fp, enum AVPixelFormat srcFormat_in, enum AVPixelFormat dstFormat_in)
Definition: swscale.c:363
h
h
Definition: vp9dsp_template.c:2038
SWS_BILINEAR
#define SWS_BILINEAR
Definition: swscale.h:66
SWS_AREA
#define SWS_AREA
Definition: swscale.h:70
SwsContext
Definition: swscale_internal.h:299
SwsContext::dstH
int dstH
Height of destination luma/alpha planes.
Definition: swscale_internal.h:323
SWS_BICUBIC
#define SWS_BICUBIC
Definition: swscale.h:67
swscale.h