From: Jiří Pinkava <j-pi@seznam.cz>

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
This commit is contained in:
Marcus Meissner
2015-01-02 20:48:20 +00:00
parent a16e03376f
commit 856db453f8

View File

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