diff options
author | Tyler Luu <tluu@ti.com> | 2011-10-12 17:46:32 -0500 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-10-14 16:37:02 -0700 |
commit | bd90094d709a579d8d74c326269e492627be9daa (patch) | |
tree | ae6d24a8c5b4b10b9a406be329a2444f22e28088 | |
parent | 13714f28c615c0cf1be4907aa6fe86f0cb5b28b8 (diff) | |
download | jhead-bd90094d709a579d8d74c326269e492627be9daa.tar.gz |
Fix insertion of GPSProcessingMethod tag
GPSProcessingMethod was not being inserted properly because it
was being treated as STRING format which results in "ASCII" being
taken as the processing method. GPSProcessingMethod is defined as
UNDEFINED format with the value containing a character string in
Exif2.2 standard.
1. Set GPSProcessingMethod to UNDEFINED format as defined in Exif2.2
2. Add handling of ASCII value with UNDEFINED format in writeExifTagAndData.
Handling is similar to STRING format, except we have to account for the
'ASCII\0\0\0' header before the string.
b/5448171
Change-Id: I411a67d7d97e35bee66aa582b25f0f6333c0679a
Signed-off-by: Tyler Luu <tluu@ti.com>
-rw-r--r-- | exif.c | 21 | ||||
-rw-r--r-- | gpsinfo.c | 4 | ||||
-rw-r--r-- | jhead.h | 1 |
3 files changed, 23 insertions, 3 deletions
@@ -1091,6 +1091,15 @@ static void writeExifTagAndData(int tag, components = strlen((char*)value) + 1; // account for null terminator if (components & 1) ++components; // no odd lengths } + if (format == FMT_UNDEFINED && components == -1) { + // check if this UNDEFINED format is actually ASCII (as it usually is) + // if so, we can calculate the size + if(memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0) { + components = sizeof(ExifAsciiPrefix) + + strlen((char*)value + sizeof(ExifAsciiPrefix)) + 1; + if (components & 1) ++components; // no odd lengths + } + } Put32u(Buffer+(*DirIndex) + 4, components); // Components printf("# components: %ld", components); if (format == FMT_STRING) { @@ -1104,6 +1113,18 @@ static void writeExifTagAndData(int tag, strncpy(Buffer+(*DataWriteIndex), (char*)value, components); (*DataWriteIndex) += components; } + } else if ((format == FMT_UNDEFINED) && + (memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0)) { + // short strings can fit right in the long, otherwise have to + // go in the data area + if (components <= 4) { + memcpy(Buffer+(*DirIndex) + 8, (char*)value, components); + } else { + Put32u(Buffer+(*DirIndex) + 8, (*DataWriteIndex)-8); // Pointer + printf("copying %s to %d", (char*)value + sizeof(ExifAsciiPrefix), (*DataWriteIndex)); + memcpy(Buffer+(*DataWriteIndex), (char*)value, components); + (*DataWriteIndex) += components; + } } else if (!valueInString) { Put32u(Buffer+(*DirIndex) + 8, value); // Value } else { @@ -47,14 +47,12 @@ static TagTable_t GpsTags[]= { { 0x18, "GPSDestBearing", FMT_SRATIONAL, 1}, { 0x19, "GPSDestDistanceRef", FMT_STRING, 2}, { 0x1A, "GPSDestDistance", FMT_SRATIONAL, 1}, - { 0x1B, "GPSProcessingMethod", FMT_STRING, -1}, + { 0x1B, "GPSProcessingMethod", FMT_UNDEFINED, -1}, { 0x1C, "GPSAreaInformation", FMT_STRING, -1}, { 0x1D, "GPSDateStamp", FMT_STRING, 11}, { 0x1E, "GPSDifferential", FMT_SSHORT, 1}, }; -static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 }; - #define MAX_GPS_TAG (sizeof(GpsTags) / sizeof(TagTable_t)) #define EXIF_ASCII_PREFIX_LEN (sizeof(ExifAsciiPrefix)) @@ -209,6 +209,7 @@ int IsGpsTag(const char* tag); int GpsTagToFormatType(unsigned short tag); int GpsTagNameToValue(const char* tagName); TagTable_t* GpsTagToTagTableEntry(unsigned short tag); +static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 }; // iptc.c prototpyes void show_IPTC (unsigned char * CharBuf, unsigned int length); |