diff options
| author | Marcus Boerger <helly@php.net> | 2002-11-27 02:38:37 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2002-11-27 02:38:37 +0000 |
| commit | 0394a52b8109c2ca870de18dc25d2ae1e0496140 (patch) | |
| tree | 9a2411e9d32c8e0f4d21caed6127b250e5f056a5 | |
| parent | 5301c168e40b0a387b0f3718db7e6c93c1faa3e6 (diff) | |
| download | php-git-0394a52b8109c2ca870de18dc25d2ae1e0496140.tar.gz | |
MFH: Canon fix
| -rw-r--r-- | ext/exif/exif.c | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 43649cc9ca..c60082574c 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -924,7 +924,8 @@ typedef enum mn_byte_order_t { typedef enum mn_offset_mode_t { MN_OFFSET_NORMAL, - MN_OFFSET_MARKER + MN_OFFSET_MARKER, + MN_OFFSET_GUESS } mn_offset_mode_t; typedef struct { @@ -939,7 +940,8 @@ typedef struct { } marker_note_type; static const marker_note_type marker_note_array[] = { - { tag_table_VND_CANON, "Canon", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL}, + { tag_table_VND_CANON, "Canon", NULL, NULL, 0, 0, MN_ORDER_INTEL, MN_OFFSET_GUESS}, +/* { tag_table_VND_CANON, "Canon", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},*/ { tag_table_VND_CASIO, "CASIO", NULL, NULL, 0, 0, MN_ORDER_MOTOROLA, MN_OFFSET_NORMAL}, { tag_table_VND_FUJI, "FUJIFILM", NULL, "FUJIFILM\x0C\x00\x00\x00", 12, 12, MN_ORDER_INTEL, MN_OFFSET_MARKER}, { tag_table_VND_NIKON, "NIKON", NULL, "Nikon\x00\x01\x00", 8, 8, MN_ORDER_NORMAL, MN_OFFSET_NORMAL}, @@ -991,27 +993,35 @@ static char * exif_get_tagname(int tag_num, char *ret, int len, tag_table_type t /* {{{ exif_char_dump * Do not use! This is a debug function... */ #ifdef EXIF_DEBUG -static unsigned char* exif_char_dump(unsigned char * addr, int len, int hex) +static unsigned char* exif_char_dump(unsigned char * addr, int len, int offset) { - static unsigned char buf[1024+1]; - int c, i, p=0, n = hex ? 5 : 3; - - for(i=0; i<len && p+n<=sizeof(buf); i++) { - if (i%64==0) - buf[p++] = '\n'; + static unsigned char buf[4096+1]; + static unsigned char tmp[20]; + int c, i, p=0, n = 5+31; + + p += sprintf(buf+p, "\nDump Len: %08X (%d)", len, len); + if (len) { + for(i=0; i<len+15 && p+n<=sizeof(buf); i++) { + if (i%16==0) { + p += sprintf(buf+p, "\n%08X: ", i+offset); + } + if (i<len) { c = *addr++; - if (hex) { - sprintf(buf+p, "%02X ", c); - p += 3; + p += sprintf(buf+p, "%02X ", c); + tmp[i%16] = c>=32 ? c : '.'; + tmp[(i%16)+1] = '\0'; } else { - if (c>=32) { - buf[p++] = c; - } else { - buf[p++] = '?'; + p += sprintf(buf+p, " "); + } + if (i%16==15) { + p += sprintf(buf+p, " %s", tmp); + if (i>=len) { + break; + } } } } - buf[sizeof(buf)-1]=0; + buf[sizeof(buf)-1] = '\0'; return buf; } #endif @@ -2642,7 +2652,7 @@ static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_fi static int exif_process_IFD_in_MARKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_len, char *offset_base, size_t IFDlength, size_t displacement TSRMLS_DC) { int de, i=0, section_index = SECTION_MARKERNOTE; - int NumDirEntries, old_motorola_intel; + int NumDirEntries, old_motorola_intel, offset_diff; const marker_note_type *marker_note; char *dir_start; @@ -2664,7 +2674,7 @@ static int exif_process_IFD_in_MARKERNOTE(image_info_type *ImageInfo, char * val dir_start = value_ptr + marker_note->offset; #ifdef EXIF_DEBUG - exif_error_docref(NULL TSRMLS_CC, ImageInfo, E_NOTICE, "process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+marker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, 1)); + exif_error_docref(NULL TSRMLS_CC, ImageInfo, E_NOTICE, "process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+marker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+marker_note->offset+displacement)); #endif ImageInfo->sections_found |= FOUND_MARKERNOTE; @@ -2681,17 +2691,25 @@ static int exif_process_IFD_in_MARKERNOTE(image_info_type *ImageInfo, char * val case MN_ORDER_NORMAL: break; } + + NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); + switch (marker_note->offset_mode) { case MN_OFFSET_MARKER: offset_base = value_ptr; break; + case MN_OFFSET_GUESS: + offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel); +#ifdef EXIF_DEBUG + exif_error_docref(NULL TSRMLS_CC, ImageInfo, E_NOTICE, "Using automatic offset correction: 0x%04X", ((int)dir_start-(int)offset_base+marker_note->offset+displacement) + offset_diff); +#endif + offset_base = value_ptr + offset_diff; + break; default: case MN_OFFSET_NORMAL: break; } - NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); - if ((2+NumDirEntries*12) > value_len) { exif_error_docref("exif_read_data#error_ifd" TSRMLS_CC, ImageInfo, E_WARNING, "illegal IFD size: 2 + x%04X*12 = x%04X > x%04X", NumDirEntries, 2+NumDirEntries*12, value_len); return FALSE; @@ -4086,3 +4104,4 @@ PHP_FUNCTION(exif_imagetype) * vim600: sw=4 ts=4 tw=78 fdm=marker * vim<600: sw=4 ts=4 tw=78 */ + |
