27 #undef HAVE_AV_CONFIG_H
39 ((x) == AV_PIX_FMT_GRAY8 || \
40 (x) == AV_PIX_FMT_YA8 || \
41 (x) == AV_PIX_FMT_GRAY16BE || \
42 (x) == AV_PIX_FMT_GRAY16LE || \
43 (x) == AV_PIX_FMT_YA16BE || \
44 (x) == AV_PIX_FMT_YA16LE)
45 #define hasChroma(x) \
47 (x) == AV_PIX_FMT_MONOBLACK || \
48 (x) == AV_PIX_FMT_MONOWHITE))
50 ((x) == AV_PIX_FMT_BGR32 || \
51 (x) == AV_PIX_FMT_BGR32_1 || \
52 (x) == AV_PIX_FMT_RGB32 || \
53 (x) == AV_PIX_FMT_RGB32_1 || \
54 (x) == AV_PIX_FMT_YUVA420P)
57 int stride2,
int w,
int h)
62 for (y = 0; y < h; y++) {
63 for (x = 0; x < w; x++) {
64 int d = src1[x + y * stride1] - src2[x + y * stride2];
83 int srcW,
int srcH,
int dstW,
int dstH,
int flags,
90 static int cur_srcW, cur_srcH;
92 static int srcStride[4];
95 int dstStride[4] = {0};
97 uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
102 if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
106 for (p = 0; p < 4; p++)
110 for (p = 0; p < 4; p++) {
111 srcStride[p] =
FFALIGN(srcStride[p], 16);
113 src[p] =
av_mallocz(srcStride[p] * srcH + 16);
114 if (srcStride[p] && !src[p]) {
123 fprintf(stderr,
"Failed to get %s ---> %s\n",
129 sws_scale(srcContext, (
const uint8_t *
const*)ref, refStride, 0, h, src, srcStride);
138 for (i = 0; i < 4; i++) {
145 dstStride[i] =
FFALIGN(dstStride[i], 16);
147 dst[i] =
av_mallocz(dstStride[i] * dstH + 16);
148 if (dstStride[i] && !dst[i]) {
156 dstContext =
sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
159 fprintf(stderr,
"Failed to get %s ---> %s\n",
165 printf(
" %s %dx%d -> %s %3dx%3d flags=%2d",
166 desc_src->
name, srcW, srcH,
167 desc_dst->
name, dstW, dstH,
171 sws_scale(dstContext, (
const uint8_t *
const*)src, srcStride, 0, srcH, dst, dstStride);
173 for (i = 0; i < 4 && dstStride[i]; i++)
175 dstStride[i] * dstH);
177 if (r && crc == r->
crc) {
183 for (i = 0; i < 4; i++) {
184 refStride[i] =
FFALIGN(refStride[i], 16);
187 if (refStride[i] && !out[i]) {
197 fprintf(stderr,
"Failed to get %s ---> %s\n",
199 desc_yuva420p->
name);
203 sws_scale(outContext, (
const uint8_t *
const*)dst, dstStride, 0, dstH, out, refStride);
205 ssdY =
getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
208 ssdU =
getSSD(ref[1], out[1], refStride[1], refStride[1],
209 (w + 1) >> 1, (h + 1) >> 1);
210 ssdV =
getSSD(ref[2], out[2], refStride[2], refStride[2],
211 (w + 1) >> 1, (h + 1) >> 1);
214 ssdA =
getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
223 for (i = 0; i < 4; i++)
228 printf(
" CRC=%08x SSD=%5"PRId64
",%5"PRId64
",%5"PRId64
",%5"PRId64
"\n",
229 crc, ssdY, ssdU, ssdV, ssdA);
234 for (i = 0; i < 4; i++)
249 const int dstW[] = { srcW - srcW / 3,
srcW, srcW + srcW / 3, 0 };
250 const int dstH[] = { srcH - srcH / 3,
srcH, srcH + srcH / 3, 0 };
273 printf(
"%s -> %s\n", desc_src->
name, desc_dst->
name);
276 for (k = 0; flags[k] && !res; k++)
277 for (i = 0; dstW[i] && !res; i++)
278 for (j = 0; dstH[j] && !res; j++)
279 res =
doTest(ref, refStride, w, h,
280 srcFormat, dstFormat,
281 srcW, srcH, dstW[i], dstH[j], flags[k],
297 while (fgets(buf,
sizeof(buf), fp)) {
309 " %12s %dx%d -> %12s %dx%d flags=%d CRC=%x"
310 " SSD=%"SCNd64
", %"SCNd64
", %"SCNd64
", %"SCNd64
"\n",
311 srcStr, &srcW, &srcH, dstStr, &dstW, &dstH,
314 srcStr[0] = dstStr[0] = 0;
315 ret = sscanf(buf,
"%12s -> %12s\n", srcStr, dstStr);
322 srcW > 8192
U || srcH > 8192
U || dstW > 8192
U || dstH > 8192
U) {
323 fprintf(stderr,
"malformed input file\n");
334 doTest(ref, refStride, w, h,
335 srcFormat, dstFormat,
336 srcW, srcH, dstW, dstH, flags,
346 int main(
int argc,
char **argv)
352 int rgb_stride[4] = { 4 *
W, 0, 0, 0 };
363 if (!rgb_data || !data)
366 for (i = 1; i < argc; i += 2) {
367 if (argv[i][0] !=
'-' || i + 1 == argc)
369 if (!strcmp(argv[i],
"-ref")) {
370 fp = fopen(argv[i + 1],
"r");
372 fprintf(stderr,
"could not open '%s'\n", argv[i + 1]);
375 }
else if (!strcmp(argv[i],
"-src")) {
378 fprintf(stderr,
"invalid pixel format %s\n", argv[i + 1]);
381 }
else if (!strcmp(argv[i],
"-dst")) {
384 fprintf(stderr,
"invalid pixel format %s\n", argv[i + 1]);
389 fprintf(stderr,
"bad option or argument missing (%s)\n", argv[i]);
399 for (y = 0; y <
H; y++)
400 for (x = 0; x <
W * 4; x++)
402 sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
407 res =
fileTest(src, stride, W, H, fp, srcFormat, dstFormat);
410 selfTest(src, stride, W, H, srcFormat, dstFormat);