From 856db453f8b22f70cd9ee14a06bed66dc04f0844 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 2 Jan 2015 20:48:20 +0000 Subject: [PATCH] =?UTF-8?q?From:=20Ji=C5=99=C3=AD=20Pinkava=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit camlibs-pentax: fix PEF RAW file header git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15307 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/pentax/library.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/camlibs/pentax/library.c b/camlibs/pentax/library.c index fdd1550b6..80bcee4d9 100644 --- a/camlibs/pentax/library.c +++ b/camlibs/pentax/library.c @@ -185,6 +185,29 @@ save_buffer(pslr_handle_t camhandle, int bufno, CameraFile *file, pslr_status *s bytes = pslr_buffer_read(camhandle, buf, sizeof(buf)); if (bytes == 0) break; + // PEF file got from K100D Super have broken header, WTF? + if (current == 0 && status->image_format == PSLR_IMAGE_FORMAT_RAW && + status->raw_format == PSLR_RAW_FORMAT_PEF) { + const unsigned char correct_header[92] = + { + 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x13, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x0b, 0xe0, 0x01, 0x01, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x07, 0xe8, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x05, + 0x00, 0x00, 0x01, 0x06, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x01, 0x80, 0x23, 0x00, 0x00, 0x01, 0x0f, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, + 0x00, 0xf2, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x14, 0x00, 0x00 + }; + + if (bytes < sizeof(correct_header)) + return GP_ERROR; + memcpy(buf, correct_header, sizeof(correct_header)); + } gp_file_append (file, (char*)buf, bytes); current += bytes; }