summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2021-10-17 17:34:01 +0200
committerMarcus Meissner <marcus@jet.franken.de>2021-10-17 17:34:01 +0200
commit334dd3132e9e8c6aa29e30653b406d9a907a3e4a (patch)
treec06cea10912795bee877095d0314d76321db61a8
parent0e30b685a3acbfd805fd8fd9a37d6c117007736d (diff)
downloadlibgphoto2-334dd3132e9e8c6aa29e30653b406d9a907a3e4a.tar.gz
only ovbrwrite the PEF header for the K100D.
see https://github.com/gphoto/gphoto2/issues/459
-rw-r--r--camlibs/pentax/library.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/camlibs/pentax/library.c b/camlibs/pentax/library.c
index b4cebf359..67d620c5d 100644
--- a/camlibs/pentax/library.c
+++ b/camlibs/pentax/library.c
@@ -261,27 +261,29 @@ save_buffer(pslr_handle_t camhandle, int bufno, pslr_buffer_type buftype, uint32
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 && (buftype == PSLR_BUF_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));
+ if (((ipslr_handle_t*)camhandle)->model->id == 0x12b9c) {
+ // PEF file got from K100D Super have broken header, WTF?
+ if (current == 0 && (buftype == PSLR_BUF_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;