helly Tue Nov 26 21:38:37 2002 EDT
Modified files: (Branch: PHP_4_3)
/php4/ext/exif exif.c
Log:
MFH: Canon fix
Index: php4/ext/exif/exif.c
diff -u php4/ext/exif/exif.c:1.118.2.1 php4/ext/exif/exif.c:1.118.2.2
--- php4/ext/exif/exif.c:1.118.2.1 Fri Nov 22 16:52:59 2002
+++ php4/ext/exif/exif.c Tue Nov 26 21:38:37 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: exif.c,v 1.118.2.1 2002/11/22 21:52:59 iliaa Exp $ */
+/* $Id: exif.c,v 1.118.2.2 2002/11/27 02:38:37 helly Exp $ */
/* ToDos
*
@@ -109,7 +109,7 @@
};
/* }}} */
-#define EXIF_VERSION "1.4 $Id: exif.c,v 1.118.2.1 2002/11/22 21:52:59 iliaa Exp $"
+#define EXIF_VERSION "1.4 $Id: exif.c,v 1.118.2.2 2002/11/27 02:38:37 helly Exp $"
/* {{{ PHP_MINFO_FUNCTION
*/
@@ -924,7 +924,8 @@
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 @@
} 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 @@
/* {{{ 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_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 @@
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 @@
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 @@
* vim600: sw=4 ts=4 tw=78 fdm=marker
* vim<600: sw=4 ts=4 tw=78
*/
+
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php