Lines Matching refs:dp

578 display_init(struct display *dp)  in display_init()  argument
584 memset(dp, 0, sizeof *dp); in display_init()
585 dp->options = WARNINGS; /* default to !verbose, !quiet */ in display_init()
586 dp->filename = NULL; in display_init()
587 dp->operation = NULL; in display_init()
588 dp->original_pp = NULL; in display_init()
589 dp->original_ip = NULL; in display_init()
590 dp->original_rows = NULL; in display_init()
591 dp->read_pp = NULL; in display_init()
592 dp->read_ip = NULL; in display_init()
593 buffer_init(&dp->original_file); in display_init()
596 dp->write_pp = NULL; in display_init()
597 buffer_init(&dp->written_file); in display_init()
602 display_clean_read(struct display *dp) in display_clean_read() argument
604 if (dp->read_pp != NULL) in display_clean_read()
605 png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL); in display_clean_read()
610 display_clean_write(struct display *dp) in display_clean_write() argument
612 if (dp->write_pp != NULL) in display_clean_write()
613 png_destroy_write_struct(&dp->write_pp, NULL); in display_clean_write()
618 display_clean(struct display *dp) in display_clean() argument
621 display_clean_write(dp); in display_clean()
623 display_clean_read(dp); in display_clean()
625 dp->original_rowbytes = 0; in display_clean()
626 dp->original_rows = NULL; in display_clean()
627 dp->chunks = 0; in display_clean()
629 png_destroy_read_struct(&dp->original_pp, &dp->original_ip, NULL); in display_clean()
631 dp->results = 0; /* reset for next time */ in display_clean()
635 display_destroy(struct display *dp) in display_destroy() argument
639 buffer_destroy(&dp->written_file); in display_destroy()
642 buffer_destroy(&dp->original_file); in display_destroy()
649 struct display *dp = (struct display*)png_get_error_ptr(pp); in get_dp() local
651 if (dp == NULL) in get_dp()
657 return dp; in get_dp()
670 display_log(struct display *dp, error_level level, const char *fmt, ...) in display_log() argument
675 dp->results |= 1U << level; in display_log()
677 if (level > (error_level)(dp->options & LEVEL_MASK)) in display_log()
699 dp->filename != NULL ? dp->filename : "<stdin>", lp, dp->operation); in display_log()
701 if (dp->transforms != 0) in display_log()
703 int tr = dp->transforms; in display_log()
707 if (dp->options & LIST_COMBOS) in display_log()
751 if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE))) in display_log()
752 longjmp(dp->error_return, level); in display_log()
765 struct display *dp = get_dp(pp); in display_error() local
767 display_log(dp, LIBPNG_ERROR, "%s", error); in display_error()
771 display_cache_file(struct display *dp, const char *filename) in display_cache_file() argument
777 dp->filename = filename; in display_cache_file()
783 display_log(dp, USER_ERROR, "open failed: %s", strerror(errno)); in display_cache_file()
789 ret = buffer_from_file(&dp->original_file, fp); in display_cache_file()
794 display_log(dp, APP_ERROR, "read failed: %s", strerror(ret)); in display_cache_file()
798 buffer_read(struct display *dp, struct buffer *bp, png_bytep data, in buffer_read() argument
811 display_log(dp, USER_ERROR, "file truncated (%lu bytes)", in buffer_read()
827 display_log(dp, INTERNAL_ERROR, "damaged buffer list"); in buffer_read()
853 read_png(struct display *dp, struct buffer *bp, const char *operation, in read_png() argument
862 display_clean_read(dp); in read_png()
866 dp->operation = operation; in read_png()
867 dp->transforms = transforms; in read_png()
870 dp->read_pp = pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp, in read_png()
873 display_log(dp, LIBPNG_ERROR, "failed to create read struct"); in read_png()
878 dp->read_ip = ip = png_create_info_struct(pp); in read_png()
880 display_log(dp, LIBPNG_ERROR, "failed to create info struct"); in read_png()
911 update_display(struct display *dp) in update_display() argument
920 read_png(dp, &dp->original_file, "original read", 0/*no transform*/); in update_display()
923 dp->original_pp = pp = dp->read_pp, dp->read_pp = NULL; in update_display()
924 dp->original_ip = ip = dp->read_ip, dp->read_ip = NULL; in update_display()
926 dp->original_rowbytes = png_get_rowbytes(pp, ip); in update_display()
927 if (dp->original_rowbytes == 0) in update_display()
928 display_log(dp, LIBPNG_BUG, "png_get_rowbytes returned 0"); in update_display()
930 dp->chunks = png_get_valid(pp, ip, 0xffffffff); in update_display()
931 if ((dp->chunks & PNG_INFO_IDAT) == 0) /* set by png_read_png */ in update_display()
932 display_log(dp, LIBPNG_BUG, "png_read_png did not set IDAT flag"); in update_display()
934 dp->original_rows = png_get_rows(pp, ip); in update_display()
935 if (dp->original_rows == NULL) in update_display()
936 display_log(dp, LIBPNG_BUG, "png_read_png did not create row buffers"); in update_display()
939 &dp->width, &dp->height, &dp->bit_depth, &dp->color_type, in update_display()
940 &dp->interlace_method, &dp->compression_method, &dp->filter_method)) in update_display()
941 display_log(dp, LIBPNG_BUG, "png_get_IHDR failed"); in update_display()
948 png_uint_32 chunks = dp->chunks; in update_display()
950 int ct = dp->color_type; in update_display()
951 int bd = dp->bit_depth; in update_display()
977 dp->active_transforms = active; in update_display()
978 dp->ignored_transforms = inactive; /* excluding write-only transforms */ in update_display()
983 compare_read(struct display *dp, int applied_transforms) in compare_read() argument
992 png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth, in compare_read()
995 # define C(item) if (item != dp->item) \ in compare_read()
996 display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\ in compare_read()
997 (unsigned long)dp->item, (unsigned long)item), e = #item in compare_read()
1010 display_log(dp, APP_ERROR, "IHDR changed (%s)", e); in compare_read()
1017 png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff); in compare_read()
1019 if (chunks != dp->chunks) in compare_read()
1020 display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx", in compare_read()
1021 (unsigned long)dp->chunks, chunks); in compare_read()
1025 rowbytes = png_get_rowbytes(dp->read_pp, dp->read_ip); in compare_read()
1030 if (rowbytes != dp->original_rowbytes) in compare_read()
1031 display_log(dp, APP_ERROR, "PNG rowbytes changed from %lu to %lu", in compare_read()
1032 (unsigned long)dp->original_rowbytes, (unsigned long)rowbytes); in compare_read()
1038 png_bytepp rows = png_get_rows(dp->read_pp, dp->read_ip); in compare_read()
1054 display_log(dp, LIBPNG_BUG, "png_get_rows returned NULL"); in compare_read()
1057 (dp->active_transforms & PNG_TRANSFORM_SHIFT) == 0 || in compare_read()
1065 png_bytep orig = dp->original_rows[y]; in compare_read()
1076 display_log(dp, APP_FAIL, in compare_read()
1092 if (png_get_sBIT(dp->read_pp, dp->read_ip, &sBIT) != PNG_INFO_sBIT) in compare_read()
1093 display_log(dp, INTERNAL_ERROR, in compare_read()
1125 display_log(dp, LIBPNG_ERROR, "invalid colour type %d", in compare_read()
1142 display_log(dp, LIBPNG_BUG, in compare_read()
1153 display_log(dp, INTERNAL_ERROR, "invalid bpp %u for bit_depth %u", in compare_read()
1197 display_log(dp, LIBPNG_BUG, "invalid bit depth %d", bit_depth); in compare_read()
1212 display_log(dp, INTERNAL_ERROR, "mask calculation error %u, %u", in compare_read()
1219 png_bytep orig = dp->original_rows[y]; in compare_read()
1230 display_log(dp, APP_FAIL, in compare_read()
1240 display_log(dp, APP_FAIL, in compare_read()
1253 buffer_write(struct display *dp, struct buffer *buffer, png_bytep data, in buffer_write() argument
1274 display_log(dp, APP_ERROR, "out of memory saving file"); in buffer_write()
1304 write_png(struct display *dp, png_infop ip, int transforms) in write_png() argument
1306 display_clean_write(dp); /* safety */ in write_png()
1308 buffer_start_write(&dp->written_file); in write_png()
1309 dp->operation = "write"; in write_png()
1310 dp->transforms = transforms; in write_png()
1312 dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp, in write_png()
1315 if (dp->write_pp == NULL) in write_png()
1316 display_log(dp, APP_ERROR, "failed to create write png_struct"); in write_png()
1318 png_set_write_fn(dp->write_pp, &dp->written_file, write_function, in write_png()
1323 png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff); in write_png()
1333 int ct = dp->color_type; in write_png()
1339 png_set_IHDR(dp->write_pp, ip, dp->width, dp->height, dp->bit_depth, ct, in write_png()
1340 dp->interlace_method, dp->compression_method, dp->filter_method); in write_png()
1343 png_write_png(dp->write_pp, ip, transforms, NULL/*params*/); in write_png()
1348 display_clean_write(dp); in write_png()
1353 skip_transform(struct display *dp, int tr) in skip_transform() argument
1356 if ((dp->options & SKIP_BUGS) != 0 && is_bad_combo(tr)) in skip_transform()
1361 if ((dp->options & LOG_SKIPPED) != 0) in skip_transform()
1363 printf("SKIP: %s transforms ", dp->filename); in skip_transform()
1379 display_log(dp, INFORMATION, "%s: skipped known bad combo 0x%x", in skip_transform()
1380 dp->filename, tr); in skip_transform()
1389 test_one_file(struct display *dp, const char *filename) in test_one_file() argument
1394 dp->operation = "cache file"; in test_one_file()
1395 dp->transforms = 0; in test_one_file()
1396 display_cache_file(dp, filename); in test_one_file()
1397 update_display(dp); in test_one_file()
1402 if (dp->ignored_transforms != 0) in test_one_file()
1404 read_png(dp, &dp->original_file, "ignored transforms", in test_one_file()
1405 dp->ignored_transforms); in test_one_file()
1408 if (!compare_read(dp, 0/*transforms applied*/)) in test_one_file()
1417 dp->operation = "write"; in test_one_file()
1418 write_png(dp, dp->original_ip, 0/*transforms*/); in test_one_file()
1419 read_png(dp, &dp->written_file, NULL, 0/*transforms*/); in test_one_file()
1420 if (!compare_read(dp, 0/*transforms applied*/)) in test_one_file()
1432 unsigned int active = dp->active_transforms; in test_one_file()
1433 const int exhaustive = (dp->options & EXHAUSTIVE) != 0; in test_one_file()
1441 read_png(dp, &dp->original_file, "active transforms", current); in test_one_file()
1461 dp->operation = "reversible transforms"; in test_one_file()
1462 write_png(dp, dp->read_ip, current); in test_one_file()
1467 read_png(dp, &dp->written_file, NULL, 0); in test_one_file()
1468 if (!compare_read(dp, current/*for the SHIFT/sBIT transform*/)) in test_one_file()
1504 || skip_transform(dp, next)); in test_one_file()
1522 if (dp->options & FIND_BAD_COMBOS) in test_one_file()
1530 dp->filename, active, bad_combo, bad_combo_list, in test_one_file()
1534 printf("%s: no %sbad combos found\n", dp->filename, in test_one_file()
1535 (dp->options & SKIP_BUGS) ? "additional " : ""); in test_one_file()
1541 do_test(struct display *dp, const char *file) in do_test() argument
1544 int ret = setjmp(dp->error_return); in do_test()
1548 test_one_file(dp, file); in do_test()
1553 display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret); in do_test()