diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-04-27 02:28:57 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-04-27 02:28:57 +0200 |
commit | e1265fa32837f457ee2c2fa259d12c9545af4bbf (patch) | |
tree | 64b8d5f1c81c14f019047b0cb00cb77c2dcecf55 /apps/heb_strip_bad_values.c | |
parent | a37beb44d59cca329d0d9345c21505af81030688 (diff) | |
download | ipecamera-e1265fa32837f457ee2c2fa259d12c9545af4bbf.tar.gz ipecamera-e1265fa32837f457ee2c2fa259d12c9545af4bbf.tar.bz2 ipecamera-e1265fa32837f457ee2c2fa259d12c9545af4bbf.tar.xz ipecamera-e1265fa32837f457ee2c2fa259d12c9545af4bbf.zip |
First stand-alone ipecamera implementation
Diffstat (limited to 'apps/heb_strip_bad_values.c')
-rw-r--r-- | apps/heb_strip_bad_values.c | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/apps/heb_strip_bad_values.c b/apps/heb_strip_bad_values.c deleted file mode 100644 index e04a53c..0000000 --- a/apps/heb_strip_bad_values.c +++ /dev/null @@ -1,98 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -int main(int argc, char *argv[]) { - long i, num; - size_t count = 0, total = 0, size; - int offset = 3, toread = 1, toskip = 3; - uint32_t value; - uint32_t *buf; - uint32_t expected = 0; - uint32_t blocks = 0, status_good = 0; - - char fixed[4096]; - struct stat st_buf; - - if ((argc != 2)&&(argc != 5)) { - printf("Usage: %s <file> [offset_dwords read_dwords skip_dwords] \n", argv[0]); - exit(0); - } - - FILE *f = fopen(argv[1], "r"); - if (!f) { - printf("Can't open %s\n", argv[1]); - exit(1); - } - - stat(argv[1], &st_buf); - size = st_buf.st_size / sizeof(uint32_t); - - - buf = malloc(size * sizeof(uint32_t)); - if (!buf) { - printf("Can't allocate %lu bytes of memory\n", size * sizeof(uint32_t)); - exit(1); - } - - if (argc == 5) { - offset = atoi(argv[2]); - toread = atoi(argv[3]); - toskip = atoi(argv[4]); - } - - - num = fread(buf, 4, size, f); - if (num != size) { - printf("Failed to read %lu dwords, only %lu read\n", size, num); - exit(1); - } - fclose(f); - - sprintf(fixed, "%s.fixed", argv[1]); - f = fopen(fixed, "w"); - if (!f) { - printf("Failed to open %s for output\n", fixed); - exit(1); - } - - expected = (buf[offset]>>24) + 2; - for (i = 1; i < size; i += (toread + toskip)) { - total++; - - value = buf[i + offset] >> 24; -// printf("0x%lx: value (%lx) = expected (%lx)\n", i + offset, value, expected); - if (value == expected) { - if (!status_good) { - status_good = 1; - blocks++; - } - fwrite(&buf[i], 4, toread + toskip, f); - expected += 2; - if (expected == 0xb8) - expected = 0; - } else if ((!status_good)&&(value == 0)&&((i + toread + toskip)< size)) { - value = buf[i + offset + toread + toskip] >> 24; - if (value == 2) { - status_good = 1; - blocks++; - fwrite(&buf[i], 4, toread + toskip, f); - expected = 2; - } else { - count++; - } - } else { - printf("0x%lx: value (%x) = expected (%x)\n", (i + offset)*sizeof(uint32_t), value, expected); - status_good = 0; - count++; - } - } - fclose(f); - free(buf); - - printf("%lu of %lu is wrong\n", count, total); - return 0; -} |