Mercurial > hg > dmlib
changeset 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 |
files | tools/lib64fmts.c |
diffstat | 1 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/lib64fmts.c Sun Jun 10 20:00:46 2018 +0300 +++ b/tools/lib64fmts.c Sun Jun 10 20:01:03 2018 +0300 @@ -772,12 +772,24 @@ static int fmtProbeECIPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) { + size_t i, n; + // XXX TODO: Perhaps count statistics about used byte values // and compare to value in buf[2] which is the RLE marker - if (len > 128 && dmCompareAddr16(buf, 0, fmt->addr)) + if (len < 128 || !dmCompareAddr16(buf, 0, fmt->addr)) + return DM_PROBE_SCORE_FALSE; + + for (n = 0, i = 3; i < len; i++) + if (buf[i] == buf[2]) n++; + + if (n > 50) + return DM_PROBE_SCORE_GOOD; + if (n > 25) return DM_PROBE_SCORE_AVG; - else - return DM_PROBE_SCORE_FALSE; + if (n > 10) + return DM_PROBE_SCORE_MAYBE; + + return DM_PROBE_SCORE_FALSE; }