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; }