Home | History | Annotate | Download | only in libtests

Lines Matching refs:dp

589 display_init(struct display *dp)
595 memset(dp, 0, sizeof *dp);
596 dp->options = WARNINGS; /* default to !verbose, !quiet */
597 dp->filename = NULL;
598 dp->operation = NULL;
599 dp->original_pp = NULL;
600 dp->original_ip = NULL;
601 dp->original_rows = NULL;
602 dp->read_pp = NULL;
603 dp->read_ip = NULL;
604 buffer_init(&dp->original_file);
607 dp->write_pp = NULL;
608 buffer_init(&dp->written_file);
613 display_clean_read(struct display *dp)
615 if (dp->read_pp != NULL)
616 png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL);
621 display_clean_write(struct display *dp)
623 if (dp->write_pp != NULL)
624 png_destroy_write_struct(&dp->write_pp, NULL);
629 display_clean(struct display *dp)
632 display_clean_write(dp);
634 display_clean_read(dp);
636 dp->original_rowbytes = 0;
637 dp->original_rows = NULL;
638 dp->chunks = 0;
640 png_destroy_read_struct(&dp->original_pp, &dp->original_ip, NULL);
642 dp->results = 0; /* reset for next time */
646 display_destroy(struct display *dp)
650 buffer_destroy(&dp->written_file);
653 buffer_destroy(&dp->original_file);
660 struct display *dp = (struct display*)png_get_error_ptr(pp);
662 if (dp == NULL)
668 return dp;
681 display_log(struct display *dp, error_level level, const char *fmt, ...)
686 dp->results |= 1U << level;
688 if (level > (error_level)(dp->options & LEVEL_MASK))
710 dp->filename != NULL ? dp->filename : "<stdin>", lp, dp->operation);
712 if (dp->transforms != 0)
714 int tr = dp->transforms;
718 if (dp->options & LIST_COMBOS)
762 if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE)))
763 longjmp(dp->error_return, level);
776 struct display *dp = get_dp(pp);
778 display_log(dp, LIBPNG_ERROR, "%s", error);
782 display_cache_file(struct display *dp, const char *filename)
788 dp->filename = filename;
794 display_log(dp, USER_ERROR, "open failed: %s", strerror(errno));
800 ret = buffer_from_file(&dp->original_file, fp);
805 display_log(dp, APP_ERROR, "read failed: %s", strerror(ret));
809 buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
822 display_log(dp, USER_ERROR, "file truncated (%lu bytes)",
838 display_log(dp, INTERNAL_ERROR, "damaged buffer list");
864 read_png(struct display *dp, struct buffer *bp, const char *operation,
873 display_clean_read(dp);
877 dp->operation = operation;
878 dp->transforms = transforms;
881 dp->read_pp = pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp,
884 display_log(dp, LIBPNG_ERROR, "failed to create read struct");
889 dp->read_ip = ip = png_create_info_struct(pp);
891 display_log(dp, LIBPNG_ERROR, "failed to create info struct");
922 update_display(struct display *dp)
931 read_png(dp, &dp->original_file, "original read", 0/*no transform*/);
934 dp->original_pp = pp = dp->read_pp, dp->read_pp = NULL;
935 dp->original_ip = ip = dp->read_ip, dp->read_ip = NULL;
937 dp->original_rowbytes = png_get_rowbytes(pp, ip);
938 if (dp->original_rowbytes == 0)
939 display_log(dp, LIBPNG_BUG, "png_get_rowbytes returned 0");
941 dp->chunks = png_get_valid(pp, ip, 0xffffffff);
942 if ((dp->chunks & PNG_INFO_IDAT) == 0) /* set by png_read_png */
943 display_log(dp, LIBPNG_BUG, "png_read_png did not set IDAT flag");
945 dp->original_rows = png_get_rows(pp, ip);
946 if (dp->original_rows == NULL)
947 display_log(dp, LIBPNG_BUG, "png_read_png did not create row buffers");
950 &dp->width, &dp->height, &dp->bit_depth, &dp->color_type,
951 &dp->interlace_method, &dp->compression_method, &dp->filter_method))
952 display_log(dp, LIBPNG_BUG, "png_get_IHDR failed");
959 png_uint_32 chunks = dp->chunks;
961 int ct = dp->color_type;
962 int bd = dp->bit_depth;
988 dp->active_transforms = active;
989 dp->ignored_transforms = inactive; /* excluding write-only transforms */
994 compare_read(struct display *dp, int applied_transforms)
1003 png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth,
1006 # define C(item) if (item != dp->item) \
1007 display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\
1008 (unsigned long)dp->item, (unsigned long)item), e = #item
1021 display_log(dp, APP_ERROR, "IHDR changed (%s)", e);
1028 png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff);
1030 if (chunks != dp->chunks)
1031 display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx",
1032 (unsigned long)dp->chunks, chunks);
1036 rowbytes = png_get_rowbytes(dp->read_pp, dp->read_ip);
1041 if (rowbytes != dp->original_rowbytes)
1042 display_log(dp, APP_ERROR, "PNG rowbytes changed from %lu to %lu",
1043 (unsigned long)dp->original_rowbytes, (unsigned long)rowbytes);
1049 png_bytepp rows = png_get_rows(dp->read_pp, dp->read_ip);
1065 display_log(dp, LIBPNG_BUG, "png_get_rows returned NULL");
1068 (dp->active_transforms & PNG_TRANSFORM_SHIFT) == 0 ||
1076 png_bytep orig = dp->original_rows[y];
1087 display_log(dp, APP_FAIL,
1104 if (png_get_sBIT(dp->read_pp, dp->read_ip, &sBIT) != PNG_INFO_sBIT)
1105 display_log(dp, INTERNAL_ERROR,
1137 display_log(dp, LIBPNG_ERROR, "invalid colour type %d",
1154 display_log(dp, LIBPNG_BUG,
1165 display_log(dp, INTERNAL_ERROR, "invalid bpp %u for bit_depth %u",
1209 display_log(dp, LIBPNG_BUG, "invalid bit depth %d", bit_depth);
1224 display_log(dp, INTERNAL_ERROR, "mask calculation error %u, %u",
1231 png_bytep orig = dp->original_rows[y];
1242 display_log(dp, APP_FAIL,
1252 display_log(dp, APP_FAIL,
1259 display_log(dp, INTERNAL_ERROR,
1269 buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
1290 display_log(dp, APP_ERROR, "out of memory saving file");
1320 write_png(struct display *dp, png_infop ip, int transforms)
1322 display_clean_write(dp); /* safety */
1324 buffer_start_write(&dp->written_file);
1325 dp->operation = "write";
1326 dp->transforms = transforms;
1328 dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp,
1331 if (dp->write_pp == NULL)
1332 display_log(dp, APP_ERROR, "failed to create write png_struct");
1334 png_set_write_fn(dp->write_pp, &dp->written_file, write_function,
1339 png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff);
1349 int ct = dp->color_type;
1355 png_set_IHDR(dp->write_pp, ip, dp->width, dp->height, dp->bit_depth, ct,
1356 dp->interlace_method, dp->compression_method, dp->filter_method);
1359 png_write_png(dp->write_pp, ip, transforms, NULL/*params*/);
1364 display_clean_write(dp);
1369 skip_transform(struct display *dp, int tr)
1372 if ((dp->options & SKIP_BUGS) != 0 && is_bad_combo(tr))
1377 if ((dp->options & LOG_SKIPPED) != 0)
1379 printf("SKIP: %s transforms ", dp->filename);
1395 display_log(dp, INFORMATION, "%s: skipped known bad combo 0x%x",
1396 dp->filename, tr);
1405 test_one_file(struct display *dp, const char *filename)
1410 dp->operation = "cache file";
1411 dp->transforms = 0;
1412 display_cache_file(dp, filename);
1413 update_display(dp);
1418 if (dp->ignored_transforms != 0)
1420 read_png(dp, &dp->original_file, "ignored transforms",
1421 dp->ignored_transforms);
1424 if (!compare_read(dp, 0/*transforms applied*/))
1433 dp->operation = "write";
1434 write_png(dp, dp->original_ip, 0/*transforms*/);
1435 read_png(dp, &dp->written_file, NULL, 0/*transforms*/);
1436 if (!compare_read(dp, 0/*transforms applied*/))
1448 unsigned int active = dp->active_transforms;
1449 const int exhaustive = (dp->options & EXHAUSTIVE) != 0;
1457 read_png(dp, &dp->original_file, "active transforms", current);
1477 dp->operation = "reversible transforms";
1478 write_png(dp, dp->read_ip, current);
1483 read_png(dp, &dp->written_file, NULL, 0);
1484 if (!compare_read(dp, current/*for the SHIFT/sBIT transform*/))
1520 || skip_transform(dp, next));
1538 if (dp->options & FIND_BAD_COMBOS)
1546 dp->filename, active, bad_combo, bad_combo_list,
1550 printf("%s: no %sbad combos found\n", dp->filename,
1551 (dp->options & SKIP_BUGS) ? "additional " : "");
1557 do_test(struct display *dp, const char *file)
1560 int ret = setjmp(dp->error_return);
1564 test_one_file(dp, file);
1569 display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret);