summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2018-07-21 14:21:54 +0200
committerMarcus Meissner <marcus@jet.franken.de>2018-07-21 14:21:54 +0200
commita23eec970b9b23fd022bd713f7720d6b58f4c6ec (patch)
treeba87715498aa935fae27779aa67538a0cd9f3151
parent2318d4ac43db7b3da31462f48e967c8dedcfcf85 (diff)
downloadlibgphoto2-a23eec970b9b23fd022bd713f7720d6b58f4c6ec.tar.gz
olympus liveview returns the jpeg without header or footer
-rw-r--r--camlibs/ptp2/library.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c
index b90a1964e..9b4bacee5 100644
--- a/camlibs/ptp2/library.c
+++ b/camlibs/ptp2/library.c
@@ -3159,7 +3159,7 @@ enable_liveview:
if (ret != PTP_RC_OK)
value.u32 = 0;
- if (value.u32 != 67109632) {
+ if (value.u32 != 67109632) { /* 0x04000300 */
value.u32 = 67109632;
LOG_ON_PTP_E (ptp_setdevicepropvalue (params, PTP_DPC_OLYMPUS_LiveViewModeOM, &value, PTP_DTC_UINT32));
@@ -3180,38 +3180,8 @@ enable_liveview:
}
}
- /* look for the JPEG SOI marker (0xFFD8) in data */
- jpgStartPtr = (unsigned char*)memchr(ximage, 0xff, size);
- while(jpgStartPtr && ((jpgStartPtr+1) < (ximage + size))) {
- if(*(jpgStartPtr + 1) == 0xd8) { /* SOI found */
- break;
- } else { /* go on looking (starting at next byte) */
- jpgStartPtr++;
- jpgStartPtr = (unsigned char*)memchr(jpgStartPtr, 0xff, ximage + size - jpgStartPtr);
- }
- }
- if(!jpgStartPtr) { /* no SOI -> no JPEG */
- gp_context_error (context, _("Sorry, your Olympus camera does not seem to return a JPEG image in LiveView mode"));
- return GP_ERROR;
- }
- /* if SOI found, start looking for EOI marker (0xFFD9) one byte after SOI
- (just to be sure we will not go beyond the end of the data array) */
- jpgEndPtr = (unsigned char*)memchr(jpgStartPtr+1, 0xff, ximage+size-jpgStartPtr-1);
- while(jpgEndPtr && ((jpgEndPtr+1) < (ximage + size))) {
- if(*(jpgEndPtr + 1) == 0xd9) { /* EOI found */
- jpgEndPtr += 2;
- break;
- } else { /* go on looking (starting at next byte) */
- jpgEndPtr++;
- jpgEndPtr = (unsigned char*)memchr(jpgEndPtr, 0xff, ximage + size - jpgEndPtr);
- }
- }
- if(!jpgEndPtr) { /* no EOI -> no JPEG */
- gp_context_error (context, _("Sorry, your Olympus camera does not seem to return a JPEG image in LiveView mode"));
- return GP_ERROR;
- }
- gp_file_append (file, (char*)jpgStartPtr, jpgEndPtr-jpgStartPtr);
- free (ximage); /* FIXME: perhaps handle the 128 byte header data too. */
+ gp_file_append (file, (char*)ximage, size);
+ free (ximage);
gp_file_set_mime_type (file, GP_MIME_JPEG);
gp_file_set_name (file, "preview.jpg");