From c8ada8ce9281c29ebd8f771b28858b23669dd2c8 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 2 Mar 2018 18:00:36 -0500 Subject: Add -f -r options to glitch --- bin/glitch.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/glitch.c b/bin/glitch.c index 66e9e56c..ea9c083d 100644 --- a/bin/glitch.c +++ b/bin/glitch.c @@ -265,6 +265,8 @@ enum PACKED Filter { static struct { bool brokenPaeth; + bool filt; + bool recon; uint8_t declareFilter; uint8_t applyFilter; enum Filter declareFilters[255]; @@ -347,7 +349,11 @@ static struct Bytes origBytes(uint32_t y, size_t i) { static void reconData(void) { for (uint32_t y = 0; y < header.height; ++y) { for (size_t i = 0; i < lineSize(); ++i) { - lines[y]->data[i] = recon(lines[y]->type, origBytes(y, i)); + if (options.filt) { + lines[y]->data[i] = filt(lines[y]->type, origBytes(y, i)); + } else { + lines[y]->data[i] = recon(lines[y]->type, origBytes(y, i)); + } } lines[y]->type = NONE; } @@ -360,7 +366,11 @@ static void filterData(void) { enum Filter minType = NONE; for (enum Filter type = NONE; type < FILTER_COUNT; ++type) { for (size_t i = 0; i < lineSize(); ++i) { - filter[type][i] = filt(type, origBytes(y, i)); + if (options.recon) { + filter[type][i] = recon(type, origBytes(y, i)); + } else { + filter[type][i] = filt(type, origBytes(y, i)); + } heuristic[type] += abs((int8_t)filter[type][i]); } if (heuristic[type] < heuristic[minType]) minType = type; @@ -447,7 +457,7 @@ int main(int argc, char *argv[]) { char *output = NULL; int opt; - while (0 < (opt = getopt(argc, argv, "a:cd:o:p"))) { + while (0 < (opt = getopt(argc, argv, "a:cd:fo:pr"))) { switch (opt) { case 'a': { options.applyFilter = parseFilters(options.applyFilters, optarg); @@ -456,8 +466,10 @@ int main(int argc, char *argv[]) { case 'd': { options.declareFilter = parseFilters(options.declareFilters, optarg); } break; + case 'f': options.filt = true; break; case 'o': output = optarg; break; case 'p': options.brokenPaeth = true; break; + case 'r': options.recon = true; break; default: return EX_USAGE; } } -- cgit 1.4.1