From 7966d8555fc0669e2ec965ab4ff4a1d190aca5ec Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Sun, 31 Jan 2016 21:27:50 -0500 Subject: [PATCH] Finalized .BPG support. --- .gitignore | 33 --------------------------------- src/file_bpg.c | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index bce39f2f..00000000 --- a/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -# Generated files -*.o -*.in -*.8 -config/ -config.* -Makefile -.deps/ - -/autom4te.cache -/autoscan.log -/autoscan-*.log -/aclocal.m4 -/compile -/configure -/configure.scan -/depcomp -/install-sh -/missing -/stamp-h1 - -/linux/testdisk.spec -/src/fidentify -/src/moc_qphotorec.cpp -/src/photorec -/src/photorec.ses -/src/qphotorec -/src/rcc_qphotorec.cpp -/src/testdisk - -# OS specific files -*~ -.DS_Store diff --git a/src/file_bpg.c b/src/file_bpg.c index a74e3033..93126522 100644 --- a/src/file_bpg.c +++ b/src/file_bpg.c @@ -4,6 +4,9 @@ Copyright (C) 1998-2007 Christophe GRENIER Copyright (C) 2016 Dmitry Brant + + BPG specification can be found at: + http://bellard.org/bpg/bpg_spec.txt This software is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,18 +34,20 @@ #include "types.h" #include "filegen.h" +#define MAX_BPG_SIZE 0x800000 + static void register_header_check_bpg(file_stat_t *file_stat); const file_hint_t file_hint_bpg= { .extension="bpg", .description="Better Portable Graphics image", - .max_filesize=PHOTOREC_MAX_FILE_SIZE, + .max_filesize=MAX_BPG_SIZE, .recover=1, .enable_by_default=1, .register_header_check=®ister_header_check_bpg }; -static int getue32(const unsigned char *buffer, const unsigned int buffer_size, unsigned int *buf_ptr) +static unsigned int getue32(const unsigned char *buffer, const unsigned int buffer_size, unsigned int *buf_ptr) { unsigned int value = 0; unsigned int b; @@ -66,14 +71,15 @@ static int header_check_bpg(const unsigned char *buffer, const unsigned int buff { unsigned int buf_ptr = 6; // get image width, and throw it away - int width = getue32(buffer, buffer_size, &buf_ptr); - printf(">>>> width...%d\n", width); + unsigned int width = getue32(buffer, buffer_size, &buf_ptr); // get image height, and throw it away - int height = getue32(buffer, buffer_size, &buf_ptr); - printf(">>>> height...%d\n", height); - int size = getue32(buffer, buffer_size, &buf_ptr); - printf(">>>> size...%d\n", size); - + unsigned int height = getue32(buffer, buffer_size, &buf_ptr); + unsigned int size = getue32(buffer, buffer_size, &buf_ptr); + if (size == 0) { + size = MAX_BPG_SIZE; + } else { + size += buf_ptr; + } reset_file_recovery(file_recovery_new); file_recovery_new->calculated_file_size=size; file_recovery_new->data_check=&data_check_size;