Finalized .BPG support.

This commit is contained in:
Dmitry Brant 2016-01-31 21:27:50 -05:00
parent a74c454175
commit 7966d8555f
2 changed files with 15 additions and 42 deletions

33
.gitignore vendored
View file

@ -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

View file

@ -5,6 +5,9 @@
Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org> Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org>
Copyright (C) 2016 Dmitry Brant <me@dmitrybrant.com> Copyright (C) 2016 Dmitry Brant <me@dmitrybrant.com>
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
@ -31,18 +34,20 @@
#include "types.h" #include "types.h"
#include "filegen.h" #include "filegen.h"
#define MAX_BPG_SIZE 0x800000
static void register_header_check_bpg(file_stat_t *file_stat); static void register_header_check_bpg(file_stat_t *file_stat);
const file_hint_t file_hint_bpg= { const file_hint_t file_hint_bpg= {
.extension="bpg", .extension="bpg",
.description="Better Portable Graphics image", .description="Better Portable Graphics image",
.max_filesize=PHOTOREC_MAX_FILE_SIZE, .max_filesize=MAX_BPG_SIZE,
.recover=1, .recover=1,
.enable_by_default=1, .enable_by_default=1,
.register_header_check=&register_header_check_bpg .register_header_check=&register_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 value = 0;
unsigned int b; 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; unsigned int buf_ptr = 6;
// get image width, and throw it away // get image width, and throw it away
int width = getue32(buffer, buffer_size, &buf_ptr); unsigned int width = getue32(buffer, buffer_size, &buf_ptr);
printf(">>>> width...%d\n", width);
// get image height, and throw it away // get image height, and throw it away
int height = getue32(buffer, buffer_size, &buf_ptr); unsigned int height = getue32(buffer, buffer_size, &buf_ptr);
printf(">>>> height...%d\n", height); unsigned int size = getue32(buffer, buffer_size, &buf_ptr);
int size = getue32(buffer, buffer_size, &buf_ptr); if (size == 0) {
printf(">>>> size...%d\n", size); size = MAX_BPG_SIZE;
} else {
size += buf_ptr;
}
reset_file_recovery(file_recovery_new); reset_file_recovery(file_recovery_new);
file_recovery_new->calculated_file_size=size; file_recovery_new->calculated_file_size=size;
file_recovery_new->data_check=&data_check_size; file_recovery_new->data_check=&data_check_size;