From: Matthieu C. <ma...@us...> - 2003-08-28 15:44:35
|
Update of /cvsroot/libexif/libmnote/libmnote/canon In directory sc8-pr-cvs1:/tmp/cvs-serv23705/libmnote/canon Modified Files: mnote-canon-data.c mnote-canon-entry.c Log Message: Canon bugfixe Index: mnote-canon-data.c =================================================================== RCS file: /cvsroot/libexif/libmnote/libmnote/canon/mnote-canon-data.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mnote-canon-data.c 26 Aug 2003 20:51:33 -0000 1.5 +++ mnote-canon-data.c 28 Aug 2003 15:43:50 -0000 1.6 @@ -1,7 +1,7 @@ /* mnote-canon-data.c * * Copyright © 2002 Lutz Müller <lu...@us...> - * Copyright © 2003 Matthieu Castet <ma...@us...> + * Copyright © 2003 Matthieu Castet <ma...@us...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -90,14 +90,15 @@ } static void -mnote_canon_data_load_data_entry (MNoteCanonData *note, - MNoteCanonEntry *entry, - const unsigned char *d, - unsigned int size, unsigned int offset, - const unsigned char *exifdata, unsigned int exifsize) +mnote_canon_data_load_data_entry_with_exif (MNoteCanonData *note, + MNoteCanonEntry *entry, + const unsigned char *d, + unsigned int size, unsigned int offset, + const unsigned char *exifdata, + unsigned int exifsize) { unsigned int s, doff, sizetmp = size; - const unsigned char *temp=d; + const unsigned char *temp = d; ExifByteOrder order = mnote_data_get_byte_order ((MNoteData *) note); entry->tag = exif_get_short (d + offset + 0, order); @@ -134,6 +135,46 @@ } +static void +mnote_canon_data_load_data_entry (MNoteCanonData *note, + MNoteCanonEntry *entry, + const unsigned char *d, + unsigned int size, unsigned int offset) +{ + unsigned int s, doff; + ExifByteOrder order = mnote_data_get_byte_order ((MNoteData *) note); + + entry->tag = exif_get_short (d + offset + 0, order); + entry->format = exif_get_short (d + offset + 2, order); + entry->components = exif_get_long (d + offset + 4, order); + + /* + * Size? If bigger than 4 bytes, the actual data is not + * in the entry but somewhere else (offset). + */ + s = exif_format_get_size (entry->format) * entry->components; + if (!s) + return; + if (s > 4) + //FIXME works on g3, but other should send exif data... + doff = exif_get_long (d + offset + 8, order)-0x3B0 ; + else + doff = offset + 8; + +#ifdef DEBUG + printf ("Comp %x %d %d %x %x\n",doff, s,size,d[doff],d[doff+1]); +#endif + /* Sanity check */ + if (size < doff + s) + return; + entry->data = malloc (sizeof (char) * s); + if (!entry->data) + return; + entry->size = s; + memcpy (entry->data, d + doff, s); + +} + static void mnote_canon_data_load_data (MNoteData *ne, const unsigned char *d_exif, unsigned int size_exif) @@ -160,11 +201,14 @@ if (ed) { e = exif_content_get_entry (ed->ifd[EXIF_IFD_EXIF], EXIF_TAG_MAKER_NOTE); - order = exif_data_get_byte_order (ed); if (e) { d = e->data; size = e->size; + order = exif_data_get_byte_order (ed); +#ifdef DEBUG + printf ("Exif data\n"); +#endif } } @@ -173,7 +217,16 @@ #ifdef DEBUG printf ("Parsing %i byte(s) Mnote data...\n", size); #endif - +#ifdef DEBUG + int j; + for (j=0;j<size;j++) + { + if (!(j%16)) printf("\n"); + printf("%02X ",d[j]);} + + printf("\n%d\n",size); + printf("%d\n",order); +#endif /* Read the number of entries */ n = exif_get_short (d ,order); @@ -191,21 +244,17 @@ #endif entry = mnote_canon_entry_new (); mnote_canon_data_add_entry (data, entry); - mnote_canon_data_load_data_entry (data, entry, d, size, - 12 * i, d_exif, size_exif); + if (e) //we have exif data + mnote_canon_data_load_data_entry_with_exif (data, entry, + d, size, 12 * i, + d_exif, size_exif); + else + mnote_canon_data_load_data_entry (data, entry, d, size, + 12 * i); mnote_canon_entry_unref (entry); } exif_data_unref (ed); -#ifdef DEBUG - int j; - for (j=0;j<size;j++) - { - if (!(j%16)) printf("\n"); - printf("%02X ",d[j]);} - printf("\n%d\n",size); - printf("%d",order); -#endif } static unsigned int Index: mnote-canon-entry.c =================================================================== RCS file: /cvsroot/libexif/libmnote/libmnote/canon/mnote-canon-entry.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mnote-canon-entry.c 26 Aug 2003 20:52:33 -0000 1.5 +++ mnote-canon-entry.c 28 Aug 2003 15:43:50 -0000 1.6 @@ -1,7 +1,7 @@ /* mnote-canon-entry.c * * Copyright © 2002 Lutz Müller <lu...@us...> - * Copyright © 2003 Matthieu Castet <ma...@us...> + * Copyright © 2003 Matthieu Castet <ma...@us...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public |