summaryrefslogtreecommitdiff
path: root/exif.c
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-10-12 17:46:32 -0500
committerIliyan Malchev <malchev@google.com>2011-10-14 16:37:02 -0700
commitbd90094d709a579d8d74c326269e492627be9daa (patch)
treeae6d24a8c5b4b10b9a406be329a2444f22e28088 /exif.c
parent13714f28c615c0cf1be4907aa6fe86f0cb5b28b8 (diff)
downloadjhead-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>
Diffstat (limited to 'exif.c')
-rw-r--r--exif.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/exif.c b/exif.c
index a70b310..a0056e0 100644
--- a/exif.c
+++ b/exif.c
@@ -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 {