Fixes for exif tag insertion

1. Change ExposureTime tag to rational format as defined by
Exif2.2 standard
2. Update # of components for types with unknown length of -1
after parsing through list

Change-Id: Ib1f65f677b2d8acad310ba8cba46efb3e21920a4
Signed-off-by: Tyler Luu <tluu@ti.com>
diff --git a/exif.c b/exif.c
index a0056e0..60aec70 100644
--- a/exif.c
+++ b/exif.c
@@ -231,7 +231,7 @@
   { TAG_CFA_PATTERN1,           "CFAPattern", 0, 0},
   { TAG_BATTERY_LEVEL,          "BatteryLevel", 0, 0},
   { TAG_COPYRIGHT,              "Copyright", FMT_STRING, -1},
-  { TAG_EXPOSURETIME,           "ExposureTime", FMT_USHORT, 1},
+  { TAG_EXPOSURETIME,           "ExposureTime", FMT_SRATIONAL, 1},
   { TAG_FNUMBER,                "FNumber", FMT_SRATIONAL, 1},
   { TAG_IPTC_NAA,               "IPTC/NAA", 0, 0},
   { TAG_EXIF_OFFSET,            "ExifOffset", 0, 0},
@@ -1085,6 +1085,8 @@
                                 char* Buffer,
                                 int* DirIndex,
                                 int* DataWriteIndex) {
+    void* componentsPosition = NULL; // for saving component position
+
     Put16u(Buffer+ (*DirIndex), tag);                    // Tag
     Put16u(Buffer+(*DirIndex) + 2, format);              // Format
     if (format == FMT_STRING && components == -1) {
@@ -1101,6 +1103,7 @@
         }
     }
     Put32u(Buffer+(*DirIndex) + 4, components);         // Components
+    componentsPosition = Buffer+(*DirIndex) + 4; // components # can change for lists
     printf("# components: %ld", components);
     if (format == FMT_STRING) {
         // short strings can fit right in the long, otherwise have to
@@ -1161,6 +1164,7 @@
             }
             curElement = strtok(NULL, ",");
         }
+        if (components == -1) Put32u(componentsPosition, i); // update component # for unknowns
     }
     (*DirIndex) += 12;
 }