summaryrefslogtreecommitdiffstats
path: root/src/file_mrw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_mrw.c')
-rw-r--r--src/file_mrw.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/file_mrw.c b/src/file_mrw.c
index 2a478d7..4b5edd2 100644
--- a/src/file_mrw.c
+++ b/src/file_mrw.c
@@ -33,7 +33,6 @@
#include "log.h"
static void register_header_check_mrw(file_stat_t *file_stat);
-static int header_check_mrw(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
const file_hint_t file_hint_mrw= {
.extension="mrw",
@@ -45,13 +44,6 @@ const file_hint_t file_hint_mrw= {
.register_header_check=&register_header_check_mrw
};
-static const unsigned char mrw_header[4]= { 0x00,'M','R','M'}; /* Minolta Raw */
-
-static void register_header_check_mrw(file_stat_t *file_stat)
-{
- register_header_check(0, mrw_header,sizeof(mrw_header), &header_check_mrw, file_stat);
-}
-
struct hdr {
uint32_t fourcc;
uint32_t size;
@@ -79,28 +71,29 @@ struct prd {
/* Minolta */
static int header_check_mrw(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
- if(memcmp(buffer,mrw_header,sizeof(mrw_header))==0)
- {
- const unsigned char prd_header[4]= { 0x00,'P','R','D'};
- const struct hdr *mrmhdr = (const struct hdr*)buffer;
- if(memcmp(mrmhdr->data,prd_header,sizeof(prd_header))==0)
- {
- const struct hdr *prdhdr = (const struct hdr*)&mrmhdr->data;
- /* Picture Raw Dimensions */
- const struct prd *prd = (const struct prd*)&prdhdr->data;
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_mrw.extension;
- file_recovery_new->calculated_file_size= be32(mrmhdr->size)+ 8 +
- ((uint64_t)be16(prd->ccd.x) * be16(prd->ccd.y) * prd->datasize + 8 - 1) / 8;
- file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size;
- /*
- log_debug("size=%lu x=%lu y=%lu datasize=%lu\n", be32(mrmhdr->size),
- be16(prd->ccd.x), be16(prd->ccd.y), prd->datasize);
- log_debug("mrw_file_size %lu\n", (long unsigned)file_recovery_new->calculated_file_size);
- */
- return 1;
- }
- }
- return 0;
+ const unsigned char prd_header[4]= { 0x00,'P','R','D'};
+ const struct hdr *mrmhdr = (const struct hdr*)buffer;
+ const struct hdr *prdhdr = (const struct hdr*)&mrmhdr->data;
+ /* Picture Raw Dimensions */
+ const struct prd *prd = (const struct prd*)&prdhdr->data;
+ if(memcmp(mrmhdr->data,prd_header,sizeof(prd_header))!=0)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_mrw.extension;
+ file_recovery_new->calculated_file_size= be32(mrmhdr->size)+ 8 +
+ ((uint64_t)be16(prd->ccd.x) * be16(prd->ccd.y) * prd->datasize + 8 - 1) / 8;
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ /*
+ log_debug("size=%lu x=%lu y=%lu datasize=%lu\n", be32(mrmhdr->size),
+ be16(prd->ccd.x), be16(prd->ccd.y), prd->datasize);
+ log_debug("mrw_file_size %lu\n", (long unsigned)file_recovery_new->calculated_file_size);
+ */
+ return 1;
+}
+
+static void register_header_check_mrw(file_stat_t *file_stat)
+{
+ static const unsigned char mrw_header[4]= { 0x00,'M','R','M'}; /* Minolta Raw */
+ register_header_check(0, mrw_header,sizeof(mrw_header), &header_check_mrw, file_stat);
}