Go to the documentation of this file.
27 #undef HAVE_AV_CONFIG_H
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) \
51 (x) == AV_PIX_FMT_MONOBLACK || \
52 (x) == AV_PIX_FMT_MONOWHITE))
64 int stride1,
int stride2,
int w,
int h)
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];
84 for (y = 0; y <
h; y++) {
85 for (x = 0; x <
w; x++) {
103 static int doTest(
const uint8_t *
const ref[4],
int refStride[4],
int w,
int h,
105 int srcW,
int srcH,
int dstW,
int dstH,
int flags,
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};
119 uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
131 for (p = 0; p < 4; p++)
136 fprintf(stderr,
"av_image_fill_linesizes failed\n");
139 for (p = 0; p < 4; p++) {
140 srcStride[p] =
FFALIGN(srcStride[p], 16);
143 if (srcStride[p] && !
src[p]) {
152 fprintf(stderr,
"Failed to get %s ---> %s\n",
159 (uint8_t *
const *)
src, srcStride);
169 fprintf(stderr,
"av_image_fill_linesizes failed\n");
173 for (
i = 0;
i < 4;
i++) {
180 dstStride[
i] =
FFALIGN(dstStride[
i], 16);
183 if (dstStride[
i] && !dst[
i]) {
193 fprintf(stderr,
"Failed to alloc %s ---> %s\n",
206 av_opt_set(dstContext,
"alphablend",
"none", 0);
210 fprintf(stderr,
"Failed to init %s ---> %s\n",
216 printf(
" %s %dx%d -> %s %3dx%3d flags=%2d",
222 sws_scale(dstContext, (
const uint8_t *
const*)
src, srcStride, 0,
srcH, dst, dstStride);
224 for (
i = 0;
i < 4 && dstStride[
i];
i++)
226 dstStride[
i] *
dstH);
228 if (
r && crc ==
r->crc) {
234 for (
i = 0;
i < 4;
i++) {
235 refStride[
i] =
FFALIGN(refStride[
i], 16);
238 if (refStride[
i] && !
out[
i]) {
248 fprintf(stderr,
"Failed to get %s ---> %s\n",
250 desc_yuva420p->
name);
254 sws_scale(outContext, (
const uint8_t *
const *) dst, dstStride, 0,
dstH,
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);
266 (
w + 1) >> 1, (
h + 1) >> 1);
268 (
w + 1) >> 1, (
h + 1) >> 1);
283 for (
i = 0;
i < 4;
i++)
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);
297 printf(
" CRC=%08x SSD=%5"PRId64
",%5"PRId64
",%5"PRId64
",%5"PRId64
"\n",
298 crc, ssdY, ssdU, ssdV, ssdA);
303 for (
i = 0;
i < 4;
i++)
310 static void selfTest(
const uint8_t *
const ref[4],
int refStride[4],
348 for (k = 0;
flags[k] && !res; k++)
349 for (
i = 0;
dstW[
i] && !res;
i++)
350 for (j = 0;
dstH[j] && !res; j++)
363 static int fileTest(
const uint8_t *
const ref[4],
int refStride[4],
364 int w,
int h, FILE *
fp,
370 while (fgets(buf,
sizeof(buf),
fp)) {
374 int srcW = 0, srcH = 0;
377 int dstW = 0, dstH = 0;
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);
387 srcStr[0] = dstStr[0] = 0;
388 ret = sscanf(buf,
"%20s -> %20s\n", srcStr, dstStr);
395 srcW > 8192
U || srcH > 8192
U || dstW > 8192
U || dstH > 8192
U) {
396 fprintf(stderr,
"malformed input file\n");
408 srcFormat, dstFormat,
409 srcW, srcH, dstW, dstH,
flags,
419 int main(
int argc,
char **argv)
424 const uint8_t *
const rgb_src[4] = { rgb_data,
NULL,
NULL,
NULL };
425 int rgb_stride[4] = { 4 *
W, 0, 0, 0 };
436 if (!rgb_data || !
data)
439 for (
i = 1;
i < argc;
i += 2) {
440 if (!strcmp(argv[
i],
"-help") || !strcmp(argv[
i],
"--help")) {
442 "swscale [options...]\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"
451 " Only test the specified destination pixel format\n"
453 " Only test the specified source pixel format\n"
454 " -cpuflags <cpuflags>\n"
455 " Uses the specified cpuflags in teh tests\n"
459 if (argv[
i][0] !=
'-' ||
i + 1 == argc)
461 if (!strcmp(argv[
i],
"-ref")) {
462 fp = fopen(argv[
i + 1],
"r");
464 fprintf(stderr,
"could not open '%s'\n", argv[
i + 1]);
467 }
else if (!strcmp(argv[
i],
"-cpuflags")) {
471 fprintf(stderr,
"invalid cpu flags %s\n", argv[
i + 1]);
475 }
else if (!strcmp(argv[
i],
"-src")) {
478 fprintf(stderr,
"invalid pixel format %s\n", argv[
i + 1]);
481 }
else if (!strcmp(argv[
i],
"-dst")) {
484 fprintf(stderr,
"invalid pixel format %s\n", argv[
i + 1]);
487 }
else if (!strcmp(argv[
i],
"-p")) {
488 prob = atof(argv[
i + 1]);
491 fprintf(stderr,
"bad option or argument missing (%s) see -help\n", argv[
i]);
503 for (y = 0; y <
H; y++)
504 for (x = 0; x <
W * 4; x++)
507 if (res < 0 || res !=
H) {
static void error(const char *err)
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
AVPixelFormat
Pixel format.
int dstW
Width of destination luma/alpha planes.
#define sws_isSupportedOutput(x)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static void selfTest(const uint8_t *const ref[4], int refStride[4], int w, int h, enum AVPixelFormat srcFormat_in, enum AVPixelFormat dstFormat_in)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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.
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.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
@ AV_PIX_FMT_NB
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
#define SWS_FAST_BILINEAR
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.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
enum AVPixelFormat srcFormat
Source pixel format.
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.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
#define SWS_FULL_CHR_H_INP
static enum AVPixelFormat pix_fmt
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2, int stride1, int stride2, int w, int h)
enum AVPixelFormat dstFormat
Destination pixel format.
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
static uint64_t getSSD0(int ref, const uint8_t *src1, int stride1, int w, int h)
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)
Context structure for the Lagged Fibonacci PRNG.
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.
#define SWS_FULL_CHR_H_INT
int srcH
Height of source luma/alpha planes.
printf("static const uint8_t my_array[100] = {\n")
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define sws_isSupportedInput(x)
int srcW
Width of source luma/alpha planes.
#define i(width, name, range_min, range_max)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static uint64_t ff_sfc64_get(FFSFC64 *s)
av_warn_unused_result int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
int main(int argc, char **argv)
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static int ref[MAX_W *MAX_W]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define flags(name, subs,...)
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)
int dstH
Height of destination luma/alpha planes.