Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 1746:dd57dd9430cb
Improve ECI packed format probing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 10 Jun 2018 20:01:03 +0300 |
parents | 2dbb2b63f6b3 |
children | 5e928618fdc8 |
comparison
equal
deleted
inserted
replaced
1745:2dbb2b63f6b3 | 1746:dd57dd9430cb |
---|---|
770 } | 770 } |
771 | 771 |
772 | 772 |
773 static int fmtProbeECIPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) | 773 static int fmtProbeECIPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
774 { | 774 { |
775 size_t i, n; | |
776 | |
775 // XXX TODO: Perhaps count statistics about used byte values | 777 // XXX TODO: Perhaps count statistics about used byte values |
776 // and compare to value in buf[2] which is the RLE marker | 778 // and compare to value in buf[2] which is the RLE marker |
777 if (len > 128 && dmCompareAddr16(buf, 0, fmt->addr)) | 779 if (len < 128 || !dmCompareAddr16(buf, 0, fmt->addr)) |
780 return DM_PROBE_SCORE_FALSE; | |
781 | |
782 for (n = 0, i = 3; i < len; i++) | |
783 if (buf[i] == buf[2]) n++; | |
784 | |
785 if (n > 50) | |
786 return DM_PROBE_SCORE_GOOD; | |
787 if (n > 25) | |
778 return DM_PROBE_SCORE_AVG; | 788 return DM_PROBE_SCORE_AVG; |
779 else | 789 if (n > 10) |
780 return DM_PROBE_SCORE_FALSE; | 790 return DM_PROBE_SCORE_MAYBE; |
791 | |
792 return DM_PROBE_SCORE_FALSE; | |
781 } | 793 } |
782 | 794 |
783 | 795 |
784 static int fmtDecodeECIPacked(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | 796 static int fmtDecodeECIPacked(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) |
785 { | 797 { |