Lines Matching refs:dp

545 display_init(struct display *dp)  in display_init()  argument
551 memset(dp, 0, sizeof *dp); in display_init()
552 dp->options = WARNINGS; /* default to !verbose, !quiet */ in display_init()
553 dp->filename = NULL; in display_init()
554 dp->operation = NULL; in display_init()
555 dp->original_pp = NULL; in display_init()
556 dp->original_ip = NULL; in display_init()
557 dp->original_rows = NULL; in display_init()
558 dp->read_pp = NULL; in display_init()
559 dp->read_ip = NULL; in display_init()
560 buffer_init(&dp->original_file); in display_init()
563 dp->write_pp = NULL; in display_init()
564 buffer_init(&dp->written_file); in display_init()
569 display_clean_read(struct display *dp) in display_clean_read() argument
571 if (dp->read_pp != NULL) in display_clean_read()
572 png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL); in display_clean_read()
577 display_clean_write(struct display *dp) in display_clean_write() argument
579 if (dp->write_pp != NULL) in display_clean_write()
580 png_destroy_write_struct(&dp->write_pp, NULL); in display_clean_write()
585 display_clean(struct display *dp) in display_clean() argument
588 display_clean_write(dp); in display_clean()
590 display_clean_read(dp); in display_clean()
592 dp->original_rowbytes = 0; in display_clean()
593 dp->original_rows = NULL; in display_clean()
594 dp->chunks = 0; in display_clean()
596 png_destroy_read_struct(&dp->original_pp, &dp->original_ip, NULL); in display_clean()
598 dp->results = 0; /* reset for next time */ in display_clean()
605 struct display *dp = (struct display*)png_get_error_ptr(pp); in get_dp() local
607 if (dp == NULL) in get_dp()
613 return dp; in get_dp()
626 display_log(struct display *dp, error_level level, const char *fmt, ...) in display_log() argument
631 dp->results |= 1U << level; in display_log()
633 if (level > (error_level)(dp->options & LEVEL_MASK)) in display_log()
655 dp->filename != NULL ? dp->filename : "<stdin>", lp, dp->operation); in display_log()
657 if (dp->transforms != 0) in display_log()
659 int tr = dp->transforms; in display_log()
679 if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE))) in display_log()
680 longjmp(dp->error_return, level); in display_log()
693 struct display *dp = get_dp(pp); in display_error() local
695 display_log(dp, LIBPNG_ERROR, "%s", error); in display_error()
699 display_cache_file(struct display *dp, const char *filename) in display_cache_file() argument
705 dp->filename = filename; in display_cache_file()
711 display_log(dp, USER_ERROR, "open failed: %s", strerror(errno)); in display_cache_file()
717 ret = buffer_from_file(&dp->original_file, fp); in display_cache_file()
722 display_log(dp, APP_ERROR, "read failed: %s", strerror(ret)); in display_cache_file()
726 buffer_read(struct display *dp, struct buffer *bp, png_bytep data, in buffer_read() argument
739 display_log(dp, USER_ERROR, "file truncated (%lu bytes)", in buffer_read()
755 display_log(dp, INTERNAL_ERROR, "damaged buffer list"); in buffer_read()
781 read_png(struct display *dp, struct buffer *bp, const char *operation, in read_png() argument
790 display_clean_read(dp); in read_png()
794 dp->operation = operation; in read_png()
795 dp->transforms = transforms; in read_png()
798 dp->read_pp = pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp, in read_png()
801 display_log(dp, LIBPNG_ERROR, "failed to create read struct"); in read_png()
806 dp->read_ip = ip = png_create_info_struct(pp); in read_png()
808 display_log(dp, LIBPNG_ERROR, "failed to create info struct"); in read_png()
839 update_display(struct display *dp) in update_display() argument
848 read_png(dp, &dp->original_file, "original read", 0/*no transform*/); in update_display()
851 dp->original_pp = pp = dp->read_pp, dp->read_pp = NULL; in update_display()
852 dp->original_ip = ip = dp->read_ip, dp->read_ip = NULL; in update_display()
854 dp->original_rowbytes = png_get_rowbytes(pp, ip); in update_display()
855 if (dp->original_rowbytes == 0) in update_display()
856 display_log(dp, LIBPNG_BUG, "png_get_rowbytes returned 0"); in update_display()
858 dp->chunks = png_get_valid(pp, ip, 0xffffffff); in update_display()
859 if ((dp->chunks & PNG_INFO_IDAT) == 0) /* set by png_read_png */ in update_display()
860 display_log(dp, LIBPNG_BUG, "png_read_png did not set IDAT flag"); in update_display()
862 dp->original_rows = png_get_rows(pp, ip); in update_display()
863 if (dp->original_rows == NULL) in update_display()
864 display_log(dp, LIBPNG_BUG, "png_read_png did not create row buffers"); in update_display()
867 &dp->width, &dp->height, &dp->bit_depth, &dp->color_type, in update_display()
868 &dp->interlace_method, &dp->compression_method, &dp->filter_method)) in update_display()
869 display_log(dp, LIBPNG_BUG, "png_get_IHDR failed"); in update_display()
876 png_uint_32 chunks = dp->chunks; in update_display()
878 int ct = dp->color_type; in update_display()
879 int bd = dp->bit_depth; in update_display()
905 dp->active_transforms = active; in update_display()
906 dp->ignored_transforms = inactive; /* excluding write-only transforms */ in update_display()
909 display_log(dp, INTERNAL_ERROR, "bad transform table"); in update_display()
914 compare_read(struct display *dp, int applied_transforms) in compare_read() argument
923 png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth, in compare_read()
926 # define C(item) if (item != dp->item) \ in compare_read()
927 display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\ in compare_read()
928 (unsigned long)dp->item, (unsigned long)item), e = #item in compare_read()
941 display_log(dp, APP_ERROR, "IHDR changed (%s)", e); in compare_read()
948 png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff); in compare_read()
950 if (chunks != dp->chunks) in compare_read()
951 display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx", in compare_read()
952 (unsigned long)dp->chunks, chunks); in compare_read()
956 rowbytes = png_get_rowbytes(dp->read_pp, dp->read_ip); in compare_read()
961 if (rowbytes != dp->original_rowbytes) in compare_read()
962 display_log(dp, APP_ERROR, "PNG rowbytes changed from %lu to %lu", in compare_read()
963 (unsigned long)dp->original_rowbytes, (unsigned long)rowbytes); in compare_read()
969 png_bytepp rows = png_get_rows(dp->read_pp, dp->read_ip); in compare_read()
985 display_log(dp, LIBPNG_BUG, "png_get_rows returned NULL"); in compare_read()
988 (dp->active_transforms & PNG_TRANSFORM_SHIFT) == 0 || in compare_read()
996 png_bytep orig = dp->original_rows[y]; in compare_read()
1007 display_log(dp, APP_FAIL, in compare_read()
1023 if (png_get_sBIT(dp->read_pp, dp->read_ip, &sBIT) != PNG_INFO_sBIT) in compare_read()
1024 display_log(dp, INTERNAL_ERROR, in compare_read()
1056 display_log(dp, LIBPNG_ERROR, "invalid colour type %d", in compare_read()
1073 display_log(dp, LIBPNG_BUG, in compare_read()
1084 display_log(dp, INTERNAL_ERROR, "invalid bpp %u for bit_depth %u", in compare_read()
1128 display_log(dp, LIBPNG_BUG, "invalid bit depth %d", bit_depth); in compare_read()
1143 display_log(dp, INTERNAL_ERROR, "mask calculation error %u, %u", in compare_read()
1150 png_bytep orig = dp->original_rows[y]; in compare_read()
1161 display_log(dp, APP_FAIL, in compare_read()
1171 display_log(dp, APP_FAIL, in compare_read()
1184 buffer_write(struct display *dp, struct buffer *buffer, png_bytep data, in buffer_write() argument
1205 display_log(dp, APP_ERROR, "out of memory saving file"); in buffer_write()
1235 write_png(struct display *dp, png_infop ip, int transforms) in write_png() argument
1237 display_clean_write(dp); /* safety */ in write_png()
1239 buffer_start_write(&dp->written_file); in write_png()
1240 dp->operation = "write"; in write_png()
1241 dp->transforms = transforms; in write_png()
1243 dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp, in write_png()
1246 if (dp->write_pp == NULL) in write_png()
1247 display_log(dp, APP_ERROR, "failed to create write png_struct"); in write_png()
1249 png_set_write_fn(dp->write_pp, &dp->written_file, write_function, in write_png()
1254 png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff); in write_png()
1264 int ct = dp->color_type; in write_png()
1270 png_set_IHDR(dp->write_pp, ip, dp->width, dp->height, dp->bit_depth, ct, in write_png()
1271 dp->interlace_method, dp->compression_method, dp->filter_method); in write_png()
1274 png_write_png(dp->write_pp, ip, transforms, NULL/*params*/); in write_png()
1279 display_clean_write(dp); in write_png()
1284 skip_transform(struct display *dp, int tr) in skip_transform() argument
1287 if ((dp->options & SKIP_BUGS) != 0 && is_bad_combo(tr)) in skip_transform()
1292 if ((dp->options & LOG_SKIPPED) != 0) in skip_transform()
1294 printf("SKIP: %s transforms ", dp->filename); in skip_transform()
1310 display_log(dp, INFORMATION, "%s: skipped known bad combo 0x%x", in skip_transform()
1311 dp->filename, tr); in skip_transform()
1320 test_one_file(struct display *dp, const char *filename) in test_one_file() argument
1325 dp->operation = "cache file"; in test_one_file()
1326 dp->transforms = 0; in test_one_file()
1327 display_cache_file(dp, filename); in test_one_file()
1328 update_display(dp); in test_one_file()
1333 if (dp->ignored_transforms != 0) in test_one_file()
1335 read_png(dp, &dp->original_file, "ignored transforms", in test_one_file()
1336 dp->ignored_transforms); in test_one_file()
1339 if (!compare_read(dp, 0/*transforms applied*/)) in test_one_file()
1348 dp->operation = "write"; in test_one_file()
1349 write_png(dp, dp->original_ip, 0/*transforms*/); in test_one_file()
1350 read_png(dp, &dp->written_file, NULL, 0/*transforms*/); in test_one_file()
1351 if (!compare_read(dp, 0/*transforms applied*/)) in test_one_file()
1363 unsigned int active = dp->active_transforms; in test_one_file()
1364 const int exhaustive = (dp->options & EXHAUSTIVE) != 0; in test_one_file()
1372 read_png(dp, &dp->original_file, "active transforms", current); in test_one_file()
1392 dp->operation = "reversible transforms"; in test_one_file()
1393 write_png(dp, dp->read_ip, current); in test_one_file()
1398 read_png(dp, &dp->written_file, NULL, 0); in test_one_file()
1399 if (!compare_read(dp, current/*for the SHIFT/sBIT transform*/)) in test_one_file()
1435 || skip_transform(dp, next)); in test_one_file()
1453 if (dp->options & FIND_BAD_COMBOS) in test_one_file()
1461 dp->filename, active, bad_combo, bad_combo_list, in test_one_file()
1465 printf("%s: no %sbad combos found\n", dp->filename, in test_one_file()
1466 (dp->options & SKIP_BUGS) ? "additional " : ""); in test_one_file()
1472 do_test(struct display *dp, const char *file) in do_test() argument
1475 int ret = setjmp(dp->error_return); in do_test()
1479 test_one_file(dp, file); in do_test()
1484 display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret); in do_test()