summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exif.c465
-rw-r--r--src/exif.h17
-rw-r--r--src/exif_canon.c30
-rw-r--r--src/exif_canon.h3
-rw-r--r--src/exif_cfg.h100
-rw-r--r--src/exif_nikon.c796
-rw-r--r--src/exif_nikon.h3
7 files changed, 729 insertions, 685 deletions
diff --git a/src/exif.c b/src/exif.c
index 9ad9dae..18025c2 100644
--- a/src/exif.c
+++ b/src/exif.c
@@ -42,118 +42,117 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* remove all spaces on the right end of a string */
void exif_trim_spaces(char *str)
{
- char *end;
-
- for (end = str; *str!='\0'; str++)
- {
- if (*str != ' ')
- {
- end = str + 1;
- }
- }
- *end = '\0';
+ char *end;
+
+ for (end = str; *str != '\0'; str++) {
+ if (*str != ' ') {
+ end = str + 1;
+ }
+ }
+ *end = '\0';
}
/* show given exif tag content with tag name */
-void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize)
+void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag, char *buffer,
+ unsigned int maxsize)
{
- char s[EXIF_MAX_DATA];
- ExifEntry *entry = NULL;
-
- if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) )
- {
- entry = exif_content_get_entry(d->ifd[ifd], tag);
- if (entry != NULL)
- {
- /* Get the contents of the tag in human-readable form */
- exif_entry_get_value(entry, s, EXIF_MAX_DATA);
-
- /* Don't bother printing it if it's entirely blank */
- exif_trim_spaces(s);
- if (*s != '\0')
- {
- D(("%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s));
- snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s);
- }
- }
- }
+ char s[EXIF_MAX_DATA];
+ ExifEntry *entry = NULL;
+
+ if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) {
+ entry = exif_content_get_entry(d->ifd[ifd], tag);
+ if (entry != NULL) {
+ /* Get the contents of the tag in human-readable form */
+ exif_entry_get_value(entry, s, EXIF_MAX_DATA);
+
+ /* Don't bother printing it if it's entirely blank */
+ exif_trim_spaces(s);
+ if (*s != '\0') {
+ D(("%s: %s\n",
+ exif_tag_get_name_in_ifd(tag, ifd), s));
+ snprintf(buffer, (size_t) maxsize,
+ "%s: %s\n",
+ exif_tag_get_name_in_ifd(tag,
+ ifd), s);
+ }
+ }
+ }
}
/* show given exif tag content without tag name */
-void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize)
+void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag,
+ char *buffer, unsigned int maxsize)
{
- char s[EXIF_MAX_DATA];
- ExifEntry *entry = NULL;
-
- if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) )
- {
- entry = exif_content_get_entry(d->ifd[ifd], tag);
- if (entry != NULL)
- {
- /* Get the contents of the tag in human-readable form */
- exif_entry_get_value(entry, s, EXIF_MAX_DATA);
-
- /* Don't bother printing it if it's entirely blank */
- exif_trim_spaces(s);
- if (*s != '\0')
- {
- D(("%s - %s\n", exif_tag_get_name_in_ifd(tag,ifd), s));
- snprintf(buffer, (size_t)maxsize, "%s", s);
- }
- }
- }
+ char s[EXIF_MAX_DATA];
+ ExifEntry *entry = NULL;
+
+ if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) {
+ entry = exif_content_get_entry(d->ifd[ifd], tag);
+ if (entry != NULL) {
+ /* Get the contents of the tag in human-readable form */
+ exif_entry_get_value(entry, s, EXIF_MAX_DATA);
+
+ /* Don't bother printing it if it's entirely blank */
+ exif_trim_spaces(s);
+ if (*s != '\0') {
+ D(("%s - %s\n",
+ exif_tag_get_name_in_ifd(tag, ifd), s));
+ snprintf(buffer, (size_t) maxsize, "%s",
+ s);
+ }
+ }
+ }
}
/* Show the given MakerNote tag if it exists */
-void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize)
+void exif_get_mnote_tag(ExifData * d, unsigned int tag, char *buffer,
+ unsigned int maxsize)
{
- ExifMnoteData *mn = NULL;
- int i, num;
- char buf[1024];
-
- if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) )
- {
- mn = exif_data_get_mnote_data(d);
- }
- else
- {
- return;
- }
-
- if ( mn != NULL )
- {
- num = exif_mnote_data_count(mn);
-
- /* Loop through all MakerNote tags, searching for the desired one */
- for (i=0; i < num; ++i)
- {
- D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i),
- exif_mnote_data_get_id(mn, i),
- exif_mnote_data_get_name(mn,i),
- exif_mnote_data_get_title(mn, i) ));
-
- if (exif_mnote_data_get_id(mn, i) == tag)
- {
- if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf)))
- {
- /* Don't bother printing it if it's entirely blank */
- exif_trim_spaces(buf);
- if (*buf != '\0')
- {
- D(("%s\n", buf));
- snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf);
- }
- }
- }
- }
- }
+ ExifMnoteData *mn = NULL;
+ int i, num;
+ char buf[1024];
+
+ if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) {
+ mn = exif_data_get_mnote_data(d);
+ } else {
+ return;
+ }
+
+ if (mn != NULL) {
+ num = exif_mnote_data_count(mn);
+
+ /* Loop through all MakerNote tags, searching for the desired one */
+ for (i = 0; i < num; ++i) {
+ D(("%d/%d %d 0x%2x %s; %s\n", i, num,
+ exif_mnote_data_get_id(mn, i),
+ exif_mnote_data_get_id(mn, i),
+ exif_mnote_data_get_name(mn, i),
+ exif_mnote_data_get_title(mn, i)));
+
+ if (exif_mnote_data_get_id(mn, i) == tag) {
+ if (exif_mnote_data_get_value
+ (mn, i, buf, sizeof(buf))) {
+ /* Don't bother printing it if it's entirely blank */
+ exif_trim_spaces(buf);
+ if (*buf != '\0') {
+ D(("%s\n", buf));
+ snprintf(buffer,
+ (size_t) maxsize,
+ "%s: %s\n",
+ exif_mnote_data_get_title
+ (mn, i), buf);
+ }
+ }
+ }
+ }
+ }
}
@@ -161,80 +160,75 @@ void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned in
/* get gps coordinates if available */
void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
-
- buf[0] = '\0';
- exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF, buf, sizeof(buf));
- if ( buf[0] != '\0' )
- {
- snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "GPS: %s ", buf);
- }
- else
- {
- return;
- }
-
- buf[0] = '\0';
- exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf, sizeof(buf));
- if ( buf[0] != '\0' )
- {
- snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf);
- }
- else
- {
- return;
- }
-
- buf[0] = '\0';
- exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF, buf, sizeof(buf));
- if ( buf[0] != '\0' )
- {
- snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), ", %s ", buf);
- }
- else
- {
- return;
- }
-
- buf[0] = '\0';
- exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf, sizeof(buf));
- if ( buf[0] != '\0' )
- {
- snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf);
- }
- else
- {
- return;
- }
-
- buf[0] = '\0';
- exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf, sizeof(buf));
- if ( buf[0] != '\0' )
- {
- snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "(%s)\n", buf);
- }
- else
- {
- return;
- }
+ char buf[EXIF_STD_BUF_LEN];
+
+ buf[0] = '\0';
+ exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF,
+ buf, sizeof(buf));
+ if (buf[0] != '\0') {
+ snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
+ "GPS: %s ", buf);
+ } else {
+ return;
+ }
+
+ buf[0] = '\0';
+ exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf,
+ sizeof(buf));
+ if (buf[0] != '\0') {
+ snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
+ "%s ", buf);
+ } else {
+ return;
+ }
+
+ buf[0] = '\0';
+ exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF,
+ buf, sizeof(buf));
+ if (buf[0] != '\0') {
+ snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
+ ", %s ", buf);
+ } else {
+ return;
+ }
+
+ buf[0] = '\0';
+ exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf,
+ sizeof(buf));
+ if (buf[0] != '\0') {
+ snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
+ "%s ", buf);
+ } else {
+ return;
+ }
+
+ buf[0] = '\0';
+ exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf,
+ sizeof(buf));
+ if (buf[0] != '\0') {
+ snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
+ "(%s)\n", buf);
+ } else {
+ return;
+ }
}
/* return data structure with exif data if available */
-ExifData * exif_get_data(char *path)
+ExifData *exif_get_data(char *path)
{
- ExifData *ed = NULL;
+ ExifData *ed = NULL;
- /* Load an ExifData object from an EXIF file */
- ed = exif_data_new_from_file(path);
- if (ed == NULL)
- {
- D(("File not readable or no Exif data present in %s\n", path));
- }
+ /* Load an ExifData object from an EXIF file */
+ ed = exif_data_new_from_file(path);
+ if (ed == NULL) {
+ D(("File not readable or no Exif data present in %s\n",
+ path));
+ }
- return(ed);
+ return (ed);
}
@@ -243,76 +237,91 @@ ExifData * exif_get_data(char *path)
/* get all exif data in readable form */
void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize)
{
- ExifEntry *entry = NULL;
- char buf[EXIF_STD_BUF_LEN];
- unsigned short int i = 0;
-
- if ( (buffer == NULL) || (maxsize == 0) )
- {
- return;
- }
- else if (ed == NULL)
- {
- snprintf(buffer, (size_t)maxsize, "%s\n", "No Exif data in file.");
- return;
- }
- else
- {
- /* show normal exif tags. list must be defined in exif_cfg.h */
- while ( (i < USHRT_MAX) && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT) )
- {
- exif_get_tag(ed, Exif_tag_list[i].ifd, Exif_tag_list[i].tag, buffer + strlen(buffer), maxsize - strlen(buffer));
- i++;
- }
-
- /* show vendor specific makernote tags */
- entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_MAKE);
- if (entry != NULL)
- {
-
- if (exif_entry_get_value(entry, buf, sizeof(buf)))
- {
- exif_trim_spaces(buf);
-
- if ( (strcmp(buf, "NIKON CORPORATION") == 0)
- || (strcmp(buf, "Nikon") == 0)
- || (strcmp(buf, "NIKON") == 0)
- )
- {
- /* show nikon makernote exif tags. list must be defined in exif_cfg.h */
- i=0;
- while ( (i < USHRT_MAX) && (Exif_makernote_nikon_tag_list[i] != EXIF_NIKON_MAKERNOTE_END) )
- {
- exn_get_mnote_nikon_tags(ed, Exif_makernote_nikon_tag_list[i],
- buffer + strlen(buffer), maxsize - strlen(buffer));
- i++;
- }
-
- }
- else if ( (strcmp(buf, "Canon") == 0) )
- {
- /* show canon makernote exif tags. list must be defined in exif_cfg.h */
- i=0;
- while ( (i < USHRT_MAX) && (Exif_makernote_canon_tag_list[i] != EXIF_CANON_MAKERNOTE_END) )
- {
- exc_get_mnote_canon_tags(ed, Exif_makernote_canon_tag_list[i],
- buffer + strlen(buffer), maxsize - strlen(buffer));
- i++;
- }
-
- }
- else
- {
- }
- }
-
- }
-
- /* show gps coordinates */
- exif_get_gps_coords(ed, buffer + strlen(buffer), maxsize - strlen(buffer));
-
- }
-
+ ExifEntry *entry = NULL;
+ char buf[EXIF_STD_BUF_LEN];
+ unsigned short int i = 0;
+
+ if ((buffer == NULL) || (maxsize == 0)) {
+ return;
+ } else if (ed == NULL) {
+ snprintf(buffer, (size_t) maxsize, "%s\n",
+ "No Exif data in file.");
+ return;
+ } else {
+ /* show normal exif tags. list must be defined in exif_cfg.h */
+ while ((i < USHRT_MAX)
+ && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT)) {
+ exif_get_tag(ed, Exif_tag_list[i].ifd,
+ Exif_tag_list[i].tag,
+ buffer + strlen(buffer),
+ maxsize - strlen(buffer));
+ i++;
+ }
+
+ /* show vendor specific makernote tags */
+ entry =
+ exif_content_get_entry(ed->ifd[EXIF_IFD_0],
+ EXIF_TAG_MAKE);
+ if (entry != NULL) {
+
+ if (exif_entry_get_value(entry, buf, sizeof(buf))) {
+ exif_trim_spaces(buf);
+
+ if ((strcmp(buf, "NIKON CORPORATION") == 0)
+ || (strcmp(buf, "Nikon") == 0)
+ || (strcmp(buf, "NIKON") == 0)
+ ) {
+ /* show nikon makernote exif tags. list must be defined in exif_cfg.h */
+ i = 0;
+ while ((i < USHRT_MAX)
+ &&
+ (Exif_makernote_nikon_tag_list
+ [i] !=
+ EXIF_NIKON_MAKERNOTE_END))
+ {
+ exn_get_mnote_nikon_tags
+ (ed,
+ Exif_makernote_nikon_tag_list
+ [i],
+ buffer +
+ strlen(buffer),
+ maxsize -
+ strlen(buffer));
+ i++;
+ }
+
+ } else if ((strcmp(buf, "Canon") == 0)) {
+ /* show canon makernote exif tags. list must be defined in exif_cfg.h */
+ i = 0;
+ while ((i < USHRT_MAX)
+ &&
+ (Exif_makernote_canon_tag_list
+ [i] !=
+ EXIF_CANON_MAKERNOTE_END))
+ {
+ exc_get_mnote_canon_tags
+ (ed,
+ Exif_makernote_canon_tag_list
+ [i],
+ buffer +
+ strlen(buffer),
+ maxsize -
+ strlen(buffer));
+ i++;
+ }
+
+ } else {
+ }
+ }
+
+ }
+
+ /* show gps coordinates */
+ exif_get_gps_coords(ed, buffer + strlen(buffer),
+ maxsize - strlen(buffer));
+
+ }
+
}
#endif
diff --git a/src/exif.h b/src/exif.h
index 79187f4..41769c0 100644
--- a/src/exif.h
+++ b/src/exif.h
@@ -32,11 +32,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define EXIF_STD_BUF_LEN 128
extern void exif_trim_spaces(char *str);
-extern void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize);
-extern void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize);
-extern void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize);
-extern void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize);
-extern ExifData * exif_get_data(char *path);
-extern void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize);
+extern void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag,
+ char *buffer, unsigned int maxsize);
+extern void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag,
+ char *buffer, unsigned int maxsize);
+extern void exif_get_mnote_tag(ExifData * d, unsigned int tag,
+ char *buffer, unsigned int maxsize);
+extern void exif_get_gps_coords(ExifData * ed, char *buffer,
+ unsigned int maxsize);
+extern ExifData *exif_get_data(char *path);
+extern void exif_get_info(ExifData * ed, char *buffer,
+ unsigned int maxsize);
#endif
diff --git a/src/exif_canon.c b/src/exif_canon.c
index 8801899..ee72164 100644
--- a/src/exif_canon.c
+++ b/src/exif_canon.c
@@ -36,26 +36,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* get interesting canon maker note tags in readable form */
-void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize)
+void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag,
+ char *buffer, unsigned int maxsize)
{
- /* char buf[EXIF_STD_BUF_LEN];
+ /* char buf[EXIF_STD_BUF_LEN];
- buf[0] = '\0';
- exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf));
- exif_trim_spaces(buf); */
+ buf[0] = '\0';
+ exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf));
+ exif_trim_spaces(buf); */
- switch(tag)
- {
- default:
- {
- /* normal makernote tags without special treatment */
- exif_get_mnote_tag(ed, tag, buffer, maxsize);
- }
- break;
- }
+ switch (tag) {
+ default:
+ {
+ /* normal makernote tags without special treatment */
+ exif_get_mnote_tag(ed, tag, buffer, maxsize);
+ }
+ break;
+ }
- return;
+ return;
}
#endif
diff --git a/src/exif_canon.h b/src/exif_canon.h
index d8682c3..58ecc0e 100644
--- a/src/exif_canon.h
+++ b/src/exif_canon.h
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libexif/exif-data.h>
-extern void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize);
+extern void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag,
+ char *buffer, unsigned int maxsize);
#endif
diff --git a/src/exif_cfg.h b/src/exif_cfg.h
index a961147..f93ab7b 100644
--- a/src/exif_cfg.h
+++ b/src/exif_cfg.h
@@ -28,78 +28,74 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libexif/exif-data.h>
-typedef struct
-{
- ExifIfd ifd; /* section */
- ExifTag tag; /* tag */
+typedef struct {
+ ExifIfd ifd; /* section */
+ ExifTag tag; /* tag */
} t_EXIF_INFO;
/* show these standard tags. section must be given first, than the tag itself */
/* definition: http://libexif.sourceforge.net/api/exif-tag_8h.html */
-const t_EXIF_INFO Exif_tag_list [] =
-{
- {EXIF_IFD_0, EXIF_TAG_MAKE},
- {EXIF_IFD_0, EXIF_TAG_MODEL},
- {EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION},
- {EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL},
- {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME},
- {EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE},
- {EXIF_IFD_EXIF, EXIF_TAG_FNUMBER},
- {EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE},
- {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE},
- {EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS},
- {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH},
- {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM},
- {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE},
- {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM},
- {EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE},
- {EXIF_IFD_EXIF, EXIF_TAG_FLASH},
-
- {EXIF_IFD_COUNT, 0} /* end marker */
+const t_EXIF_INFO Exif_tag_list[] = {
+ { EXIF_IFD_0, EXIF_TAG_MAKE },
+ { EXIF_IFD_0, EXIF_TAG_MODEL },
+ { EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION },
+ { EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL },
+ { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME },
+ { EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE },
+ { EXIF_IFD_EXIF, EXIF_TAG_FNUMBER },
+ { EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE },
+ { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE },
+ { EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS },
+ { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH },
+ { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM },
+ { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE },
+ { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM },
+ { EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE },
+ { EXIF_IFD_EXIF, EXIF_TAG_FLASH },
+
+ { EXIF_IFD_COUNT, 0 } /* end marker */
};
/* Nikon */
-#define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */
+#define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */
/* show these nikon makernote tags */
-const unsigned int Exif_makernote_nikon_tag_list [] =
-{
-
- 6,
- 8, /* Flash Setting */
- 9, /* Flash Mode */
- 135, /* Flash used */
- 18, /* Flash Exposure Comp */
- 168, /* Flash info: control mode */
-
- 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */
- 5, /* White Balance */
- 132, /* Lens */
- 171, /* Digital Vari-Program */
- 34, /* Active D-Lighting */
-
- 35, /* PictureControlData */
- 183, /* AFInfo2 */
-
- EXIF_NIKON_MAKERNOTE_END /* end marker */
+const unsigned int Exif_makernote_nikon_tag_list[] = {
+
+ 6,
+ 8, /* Flash Setting */
+ 9, /* Flash Mode */
+ 135, /* Flash used */
+ 18, /* Flash Exposure Comp */
+ 168, /* Flash info: control mode */
+
+ 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */
+ 5, /* White Balance */
+ 132, /* Lens */
+ 171, /* Digital Vari-Program */
+ 34, /* Active D-Lighting */
+
+ 35, /* PictureControlData */
+ 183, /* AFInfo2 */
+
+ EXIF_NIKON_MAKERNOTE_END /* end marker */
};
/* Canon */
-#define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */
+#define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */
/* show these canon makernote tags */
-const unsigned int Exif_makernote_canon_tag_list [] =
-{
- 8, /* Image Number */
- 9, /* Owner Name */
-
- EXIF_CANON_MAKERNOTE_END /* end marker */
+const unsigned int Exif_makernote_canon_tag_list[] = {
+ 8, /* Image Number */
+ 9, /* Owner Name */
+
+ EXIF_CANON_MAKERNOTE_END /* end marker */
};
diff --git a/src/exif_nikon.c b/src/exif_nikon.c
index c058d8c..a81f290 100644
--- a/src/exif_nikon.c
+++ b/src/exif_nikon.c
@@ -37,12 +37,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Flash control mode */
/* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#FlashControlMode */
#define EXN_FLASH_CONTROL_MODES_MAX 9
-char *EXN_NikonFlashControlModeValues[EXN_FLASH_CONTROL_MODES_MAX] = {"Off",
- "iTTL-BL", "iTTL", "Auto Aperture",
- "Automatic", "GN (distance priority)",
- "Manual", "Repeating Flash",
- "N/A" /* "N/A" is not a nikon setting */
- };
+char *EXN_NikonFlashControlModeValues[EXN_FLASH_CONTROL_MODES_MAX] =
+ { "Off",
+ "iTTL-BL", "iTTL", "Auto Aperture",
+ "Automatic", "GN (distance priority)",
+ "Manual", "Repeating Flash",
+ "N/A" /* "N/A" is not a nikon setting */
+};
#define EXN_FLASH_CONTROL_MODE_MASK 0x7F
@@ -50,280 +51,302 @@ char *EXN_NikonFlashControlModeValues[EXN_FLASH_CONTROL_MODES_MAX] = {"Off",
/* AFInfo2 */
/* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#AFInfo2 */
#define EXN_CONTRAST_DETECT_AF_MAX 2
-char *EXN_NikonContrastDetectAF[EXN_CONTRAST_DETECT_AF_MAX] = {"Off", "On"};
+char *EXN_NikonContrastDetectAF[EXN_CONTRAST_DETECT_AF_MAX] =
+ { "Off", "On" };
/* AFArea Mode for ContrastDetectAF Off */
#define EXN_AF_AREA_MODE_P_MAX 13
char *EXN_NikonAFAreaModePhase[EXN_AF_AREA_MODE_P_MAX] = {
- "Single Area", "Dynamic Area", "Dynamic Area (closest subject)",
- "Group Dynamic ", "Dynamic Area (9 points) ", "Dynamic Area (21 points)",
- "Dynamic Area (51 points) ", "Dynamic Area (51 points, 3D-tracking)",
- "Auto-area", "Dynamic Area (3D-tracking)", "Single Area (wide)",
- "Dynamic Area (wide)", "Dynamic Area (wide, 3D-tracking)"};
+ "Single Area", "Dynamic Area", "Dynamic Area (closest subject)",
+ "Group Dynamic ", "Dynamic Area (9 points) ",
+ "Dynamic Area (21 points)",
+ "Dynamic Area (51 points) ",
+ "Dynamic Area (51 points, 3D-tracking)",
+ "Auto-area", "Dynamic Area (3D-tracking)", "Single Area (wide)",
+ "Dynamic Area (wide)", "Dynamic Area (wide, 3D-tracking)"
+};
/* AFArea Mode for ContrastDetectAF On */
#define EXN_AF_AREA_MODE_C_MAX 5
char *EXN_NikonAFAreaModeContr[EXN_AF_AREA_MODE_C_MAX] = {
- "Contrast-detect",
- "Contrast-detect (normal area)",
- "Contrast-detect (wide area)",
- "Contrast-detect (face priority)",
- "Contrast-detect (subject tracking)"};
+ "Contrast-detect",
+ "Contrast-detect (normal area)",
+ "Contrast-detect (wide area)",
+ "Contrast-detect (face priority)",
+ "Contrast-detect (subject tracking)"
+};
#define EXN_PHASE_DETECT_AF_MAX 4
-char *EXN_NikonPhaseDetectAF[EXN_PHASE_DETECT_AF_MAX] = {"Off", "On (51-point)",
- "On (11-point)", "On (39-point)"};
+char *EXN_NikonPhaseDetectAF[EXN_PHASE_DETECT_AF_MAX] =
+ { "Off", "On (51-point)",
+ "On (11-point)", "On (39-point)"
+};
/* PrimaryAFPoint and AFPointsUsed only valid with PhaseDetectAF == On */
#define EXN_PRIM_AF_PT_51_MAX 52
-char * EXN_Prim_AF_Pt_51[EXN_PRIM_AF_PT_51_MAX] = {"(none)", "C6 (Center)", "B6", "A5",
- "D6", "E5", "C7", "B7", "A6", "D7", "E6", "C5", "B5", "A4", "D5", "E4", "C8", "B8",
- "A7", "D8", "E7", "C9", "B9", "A8", "D9", "E8", "C10", "B10", "A9", "D10", "E9",
- "C11", "B11", "D11", "C4", "B4", "A3", "D4", "E3", "C3", "B3", "A2", "D3", "E2",
- "C2", "B2", "A1", "D2", "E1", "C1", "B1", "D1"};
-
+char *EXN_Prim_AF_Pt_51[EXN_PRIM_AF_PT_51_MAX] =
+ { "(none)", "C6 (Center)", "B6", "A5",
+ "D6", "E5", "C7", "B7", "A6", "D7", "E6", "C5", "B5", "A4", "D5",
+ "E4", "C8", "B8",
+ "A7", "D8", "E7", "C9", "B9", "A8", "D9", "E8", "C10", "B10", "A9",
+ "D10", "E9",
+ "C11", "B11", "D11", "C4", "B4", "A3", "D4", "E3", "C3", "B3",
+ "A2", "D3", "E2",
+ "C2", "B2", "A1", "D2", "E1", "C1", "B1", "D1"
+};
+
#define EXN_PRIM_AF_PT_11_MAX 12
-char * EXN_Prim_AF_Pt_11[EXN_PRIM_AF_PT_11_MAX] = {"(none)", "Center", "Top", "Bottom",
- "Mid-left", "Upper-left", "Lower-left", "Far Left", "Mid-right", "Upper-right",
- "Lower-right", "Far Right"};
+char *EXN_Prim_AF_Pt_11[EXN_PRIM_AF_PT_11_MAX] =
+ { "(none)", "Center", "Top", "Bottom",
+ "Mid-left", "Upper-left", "Lower-left", "Far Left", "Mid-right",
+ "Upper-right",
+ "Lower-right", "Far Right"
+};
#define EXN_PRIM_AF_PT_39_MAX 40
-char * EXN_Prim_AF_Pt_39[EXN_PRIM_AF_PT_39_MAX] = {"(none)", "C6 (Center)", "B6", "A2",
- "D6", "E2", "C7", "B7", "A3", "D7", "E3", "C5", "B5", "A1", "D5", "E1", "C8", "B8",
- "D8", "C9", "B9", "D9", "C10", "B10", "D10", "C11", "B11", "D11", "C4", "B4", "D4",
- "C3", "B3", "D3", "C2", "B2", "D2", "C1", "B1", "D1"};
+char *EXN_Prim_AF_Pt_39[EXN_PRIM_AF_PT_39_MAX] =
+ { "(none)", "C6 (Center)", "B6", "A2",
+ "D6", "E2", "C7", "B7", "A3", "D7", "E3", "C5", "B5", "A1", "D5",
+ "E1", "C8", "B8",
+ "D8", "C9", "B9", "D9", "C10", "B10", "D10", "C11", "B11", "D11",
+ "C4", "B4", "D4",
+ "C3", "B3", "D3", "C2", "B2", "D2", "C1", "B1", "D1"
+};
#define EXN_PIC_CTRL_ADJ_MAX 3
-char * EXN_Pic_Ctrl_Adj[EXN_PIC_CTRL_ADJ_MAX] = {"Default Settings",
- "Quick Adjust",
- "Full Control"};
+char *EXN_Pic_Ctrl_Adj[EXN_PIC_CTRL_ADJ_MAX] = { "Default Settings",
+ "Quick Adjust",
+ "Full Control"
+};
static void exn_get_prim_af_pt(unsigned int phasedetectaf,
- unsigned int primafpt,
- char * buffer,
- unsigned int maxsize);
-static void exn_get_flash_output(unsigned int flashoutput, char * buffer, unsigned int maxsize);
-static void exn_get_mnote_nikon_18(ExifData *ed, char * buffer, unsigned int maxsize);
-static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int maxsize);
-static void exn_get_mnote_nikon_35(ExifData *ed, char * buffer, unsigned int maxsize);
-static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int maxsize);
-static void exn_get_mnote_nikon_183(ExifData *ed, char * buffer, unsigned int maxsize);
+ unsigned int primafpt,
+ char *buffer, unsigned int maxsize);
+static void exn_get_flash_output(unsigned int flashoutput, char *buffer,
+ unsigned int maxsize);
+static void exn_get_mnote_nikon_18(ExifData * ed, char *buffer,
+ unsigned int maxsize);
+static void exn_get_mnote_nikon_34(ExifData * ed, char *buffer,
+ unsigned int maxsize);
+static void exn_get_mnote_nikon_35(ExifData * ed, char *buffer,
+ unsigned int maxsize);
+static void exn_get_mnote_nikon_168(ExifData * ed, char *buffer,
+ unsigned int maxsize);
+static void exn_get_mnote_nikon_183(ExifData * ed, char *buffer,
+ unsigned int maxsize);
/* get primary AF point */
static void exn_get_prim_af_pt(unsigned int phasedetectaf,
- unsigned int primafpt,
- char * buffer,
- unsigned int maxsize)
+ unsigned int primafpt,
+ char *buffer, unsigned int maxsize)
{
-
- switch(phasedetectaf)
- {
- case 0:
- {
- /* phasedetect not used. should not happen */
- snprintf(buffer, maxsize, "FAIL");
- return;
- }
- break;
- case 1:
- {
- /* 51 pt */
- if ( primafpt < EXN_PRIM_AF_PT_51_MAX )
- {
- snprintf(buffer, maxsize, "%s", EXN_Prim_AF_Pt_51[primafpt]);
- }
- return;
- }
- break;
- case 2:
- {
- /* 11 pt */
- if ( primafpt < EXN_PRIM_AF_PT_11_MAX )
- {
- snprintf(buffer, maxsize, "%s", EXN_Prim_AF_Pt_11[primafpt]);
- }
- return;
- }
- break;
- case 3:
- {
- /* 39 pt */
- if ( primafpt < EXN_PRIM_AF_PT_39_MAX )
- {
- snprintf(buffer, maxsize, "%s", EXN_Prim_AF_Pt_39[primafpt]);
- }
- return;
- }
- break;
- default:
- {
- snprintf(buffer, maxsize, "?");
- return;
- }
- break;
-
- }
-
+
+ switch (phasedetectaf) {
+ case 0:
+ {
+ /* phasedetect not used. should not happen */
+ snprintf(buffer, maxsize, "FAIL");
+ return;
+ }
+ break;
+ case 1:
+ {
+ /* 51 pt */
+ if (primafpt < EXN_PRIM_AF_PT_51_MAX) {
+ snprintf(buffer, maxsize, "%s",
+ EXN_Prim_AF_Pt_51[primafpt]);
+ }
+ return;
+ }
+ break;
+ case 2:
+ {
+ /* 11 pt */
+ if (primafpt < EXN_PRIM_AF_PT_11_MAX) {
+ snprintf(buffer, maxsize, "%s",
+ EXN_Prim_AF_Pt_11[primafpt]);
+ }
+ return;
+ }
+ break;
+ case 3:
+ {
+ /* 39 pt */
+ if (primafpt < EXN_PRIM_AF_PT_39_MAX) {
+ snprintf(buffer, maxsize, "%s",
+ EXN_Prim_AF_Pt_39[primafpt]);
+ }
+ return;
+ }
+ break;
+ default:
+ {
+ snprintf(buffer, maxsize, "?");
+ return;
+ }
+ break;
+
+ }
+
}
/* get flash output power (for FlashInfo010x) */
-static void exn_get_flash_output(unsigned int flashoutput, char * buffer, unsigned int maxsize)
+static void exn_get_flash_output(unsigned int flashoutput, char *buffer,
+ unsigned int maxsize)
{
-
- if ( flashoutput == 0 )
- {
- /* full power */
- snprintf(buffer, maxsize, "Full");
- }
- else
- {
- if ( (flashoutput % 6) == 0 )
- {
- /* value is a power of 2 */
- snprintf(buffer, maxsize, "1/%d", 1<<(flashoutput/6));
- }
- else
- {
- /* something uneven...ugly. maybe introduce pow() function from libm later */
- snprintf(buffer, maxsize, "1/2^(%f)", ((float)flashoutput)/6.0);
- }
- }
+
+ if (flashoutput == 0) {
+ /* full power */
+ snprintf(buffer, maxsize, "Full");
+ } else {
+ if ((flashoutput % 6) == 0) {
+ /* value is a power of 2 */
+ snprintf(buffer, maxsize, "1/%d",
+ 1 << (flashoutput / 6));
+ } else {
+ /* something uneven...ugly. maybe introduce pow() function from libm later */
+ snprintf(buffer, maxsize, "1/2^(%f)",
+ ((float) flashoutput) / 6.0);
+ }
+ }
}
/* get ActiveD-Lighting (18) info */
-static void exn_get_mnote_nikon_18(ExifData *ed, char * buffer, unsigned int maxsize)
+static void exn_get_mnote_nikon_18(ExifData * ed, char *buffer,
+ unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
- float data = 0;
+ char buf[EXIF_STD_BUF_LEN];
+ float data = 0;
- buf[0] = '\0';
- exif_get_mnote_tag(ed, 18, buf, sizeof(buf));
+ buf[0] = '\0';
+ exif_get_mnote_tag(ed, 18, buf, sizeof(buf));
- sscanf(buf, "Flash Exposure Compensation: %f", &data); /* libexif buggy here. fix conversion */
+ sscanf(buf, "Flash Exposure Compensation: %f", &data); /* libexif buggy here. fix conversion */
- snprintf(buffer, maxsize, "FlashExposureCompensation: %+.1f EV\n", ((float)((signed char)round(data*6.0))) / 6.0 );
+ snprintf(buffer, maxsize, "FlashExposureCompensation: %+.1f EV\n",
+ ((float) ((signed char) round(data * 6.0))) / 6.0);
}
/* get ActiveD-Lighting (34) info */
-static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int maxsize)
+static void exn_get_mnote_nikon_34(ExifData * ed, char *buffer,
+ unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
- unsigned int data = 0;
- char *answer;
-
- buf[0] = '\0';
- exif_get_mnote_tag(ed, 34, buf, sizeof(buf));
- sscanf(buf, "(null): %u", &data); /* not directly supported by libexif yet */
-
- switch(data)
- {
- case 0:
- {
- answer = "Off";
- }
- break;
- case 1:
- {
- answer = "Low";
- }
- break;
- case 3:
- {
- answer = "Normal";
- }
- break;
- case 5:
- {
- answer = "High";
- }
- break;
- case 7:
- {
- answer = "Extra High";
- }
- break;
- case 65535:
- {
- answer = "Auto";
- }
- break;
- default:
- {
- answer = "N/A"; /* this is not a nikon value */
- }
-
- }
-
- snprintf(buffer, maxsize, "Active D-Lightning: %s\n", answer);
-
+ char buf[EXIF_STD_BUF_LEN];
+ unsigned int data = 0;
+ char *answer;
+
+ buf[0] = '\0';
+ exif_get_mnote_tag(ed, 34, buf, sizeof(buf));
+ sscanf(buf, "(null): %u", &data); /* not directly supported by libexif yet */
+
+ switch (data) {
+ case 0:
+ {
+ answer = "Off";
+ }
+ break;
+ case 1:
+ {
+ answer = "Low";
+ }
+ break;
+ case 3:
+ {
+ answer = "Normal";
+ }
+ break;
+ case 5:
+ {
+ answer = "High";
+ }
+ break;
+ case 7:
+ {
+ answer = "Extra High";
+ }
+ break;
+ case 65535:
+ {
+ answer = "Auto";
+ }
+ break;
+ default:
+ {
+ answer = "N/A"; /* this is not a nikon value */
+ }
+
+ }
+
+ snprintf(buffer, maxsize, "Active D-Lightning: %s\n", answer);
+
}
/* get nikon PictureControlData (35) info */
-static void exn_get_mnote_nikon_35(ExifData *ed, char * buffer, unsigned int maxsize)
+static void exn_get_mnote_nikon_35(ExifData * ed, char *buffer,
+ unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
- char picturecontrolname[EXIF_STD_BUF_LEN];
- char picturecontrolbase[EXIF_STD_BUF_LEN];
- unsigned int version = 0;
- unsigned int length = 0;
- unsigned int piccontroladj = 0;
- unsigned int piccontrolquickadj = 0;
- unsigned int sharpness = 0;
- unsigned int contrast = 0;
- unsigned int brightness = 0;
- unsigned int saturation = 0;
- unsigned int hueadjustment = 0;
- unsigned int i, j;
-
- /* libexif does not support PictureControlData 35 yet. so we have to parse the debug data :-( */
- buf[0] = '\0';
- exif_get_mnote_tag(ed, 35, buf, sizeof(buf));
-
- sscanf(buf, "(null): %u bytes unknown data: 303130%02X%40s%40s%*8s%02X%02X%02X%02X%02X%02X%02X",
- &length, &version, &picturecontrolname[0], &picturecontrolbase[0],
- &piccontroladj, &piccontrolquickadj,
- &sharpness, &contrast, &brightness, &saturation, &hueadjustment
- );
-
- /* printf("--%s %d-%d-\n", buf, version, piccontroladj); */
-
- for ( i=0; i<40; i++ )
- {
- sscanf(&picturecontrolname[2*i], "%2X", &j);
- picturecontrolname[i] = j;
- sscanf(&picturecontrolbase[2*i], "%2X", &j);
- picturecontrolbase[i] = j;
-
- }
- exif_trim_spaces(picturecontrolname);
- exif_trim_spaces(picturecontrolbase);
-
- if ( ((length == 58) && (version == '0'))
- && (piccontroladj < EXN_PIC_CTRL_ADJ_MAX)
-
- )
- {
- snprintf(buffer, maxsize,
- "PictCtrlData: Name: %s; Base: %s; CtrlAdj: %s; Quick: %d; Shrp: %d; Contr: %d; Brght: %d; Sat: %d; Hue: %d\n",
- picturecontrolname, picturecontrolbase,
- EXN_Pic_Ctrl_Adj[piccontroladj], piccontrolquickadj,
- sharpness, contrast, brightness, saturation, hueadjustment);
- }
+ char buf[EXIF_STD_BUF_LEN];
+ char picturecontrolname[EXIF_STD_BUF_LEN];
+ char picturecontrolbase[EXIF_STD_BUF_LEN];
+ unsigned int version = 0;
+ unsigned int length = 0;
+ unsigned int piccontroladj = 0;
+ unsigned int piccontrolquickadj = 0;
+ unsigned int sharpness = 0;
+ unsigned int contrast = 0;
+ unsigned int brightness = 0;
+ unsigned int saturation = 0;
+ unsigned int hueadjustment = 0;
+ unsigned int i, j;
+
+ /* libexif does not support PictureControlData 35 yet. so we have to parse the debug data :-( */
+ buf[0] = '\0';
+ exif_get_mnote_tag(ed, 35, buf, sizeof(buf));
+
+ sscanf(buf,
+ "(null): %u bytes unknown data: 303130%02X%40s%40s%*8s%02X%02X%02X%02X%02X%02X%02X",
+ &length, &version, &picturecontrolname[0],
+ &picturecontrolbase[0], &piccontroladj, &piccontrolquickadj,
+ &sharpness, &contrast, &brightness, &saturation,
+ &hueadjustment);
+
+ /* printf("--%s %d-%d-\n", buf, version, piccontroladj); */
+
+ for (i = 0; i < 40; i++) {
+ sscanf(&picturecontrolname[2 * i], "%2X", &j);
+ picturecontrolname[i] = j;
+ sscanf(&picturecontrolbase[2 * i], "%2X", &j);
+ picturecontrolbase[i] = j;
+
+ }
+ exif_trim_spaces(picturecontrolname);
+ exif_trim_spaces(picturecontrolbase);
+
+ if (((length == 58) && (version == '0'))
+ && (piccontroladj < EXN_PIC_CTRL_ADJ_MAX)
+ ) {
+ snprintf(buffer, maxsize,
+ "PictCtrlData: Name: %s; Base: %s; CtrlAdj: %s; Quick: %d; Shrp: %d; Contr: %d; Brght: %d; Sat: %d; Hue: %d\n",
+ picturecontrolname, picturecontrolbase,
+ EXN_Pic_Ctrl_Adj[piccontroladj],
+ piccontrolquickadj, sharpness, contrast,
+ brightness, saturation, hueadjustment);
+ }
}
@@ -331,180 +354,189 @@ static void exn_get_mnote_nikon_35(ExifData *ed, char * buffer, unsigned int max
/* get nikon Flash info: control mode (168) info */
-static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int maxsize)
+static void exn_get_mnote_nikon_168(ExifData * ed, char *buffer,
+ unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
- unsigned int version = 0;
- unsigned int length = 0;
- unsigned int exn_fcm = (EXN_FLASH_CONTROL_MODES_MAX-1); /* default to N/A */
- unsigned int flashoutput = 0;
- unsigned int externalflashflags = 0;
- unsigned int flashcompensation = 0;
-
- /* libexif does not support flash info 168 yet. so we have to parse the debug data :-( */
- buf[0] = '\0';
- exif_get_mnote_tag(ed, 168, buf, sizeof(buf));
- sscanf(buf, "(null): %u bytes unknown data: 303130%02X%*8s%02X%02X%02X%02X", &length, &version, &externalflashflags, &exn_fcm, &flashoutput, &flashcompensation);
- exn_fcm = exn_fcm & EXN_FLASH_CONTROL_MODE_MASK;
-
- /* printf("%s - %d %d %d %d\n", buf, externalflashflags, exn_fcm, flashoutput, (signed char)flashcompensation); */
-
- if ( (exn_fcm < EXN_FLASH_CONTROL_MODES_MAX)
- && ( ((length == 22) && (version == '3')) /* Nikon FlashInfo0103 */
- || ((length == 22) && (version == '4')) /* Nikon FlashInfo0104 */
- || ((length == 21) && (version == '2')) /* Nikon FlashInfo0102 */
- || ((length == 19) && (version == '0')) /* Nikon FlashInfo0100 */
- )
- )
- {
-
- buf[0] = '\0';
- exn_get_flash_output(flashoutput, buf, EXIF_STD_BUF_LEN);
- snprintf(buffer, maxsize, "NikonFlashControlMode: %s (Power: %s)\n", EXN_NikonFlashControlModeValues[exn_fcm], buf);
-
- /* External Flash Flags. Not as useful as expected. Not used (yet). */
- /* if ( (externalflashflags & (1<<2)) ) -> Bounce Flash */
- /* if ( (externalflashflags & (1<<4)) ) -> Wide Flash Adapter */
- /* if ( (externalflashflags & (1<<5)) ) -> Dome Diffusor */
-
- }
+ char buf[EXIF_STD_BUF_LEN];
+ unsigned int version = 0;
+ unsigned int length = 0;
+ unsigned int exn_fcm = (EXN_FLASH_CONTROL_MODES_MAX - 1); /* default to N/A */
+ unsigned int flashoutput = 0;
+ unsigned int externalflashflags = 0;
+ unsigned int flashcompensation = 0;
+
+ /* libexif does not support flash info 168 yet. so we have to parse the debug data :-( */
+ buf[0] = '\0';
+ exif_get_mnote_tag(ed, 168, buf, sizeof(buf));
+ sscanf(buf,
+ "(null): %u bytes unknown data: 303130%02X%*8s%02X%02X%02X%02X",
+ &length, &version, &externalflashflags, &exn_fcm,
+ &flashoutput, &flashcompensation);
+ exn_fcm = exn_fcm & EXN_FLASH_CONTROL_MODE_MASK;
+
+ /* printf("%s - %d %d %d %d\n", buf, externalflashflags, exn_fcm, flashoutput, (signed char)flashcompensation); */
+
+ if ((exn_fcm < EXN_FLASH_CONTROL_MODES_MAX)
+ && (((length == 22) && (version == '3')) /* Nikon FlashInfo0103 */
+ ||((length == 22) && (version == '4')) /* Nikon FlashInfo0104 */
+ ||((length == 21) && (version == '2')) /* Nikon FlashInfo0102 */
+ ||((length == 19) && (version == '0')) /* Nikon FlashInfo0100 */
+ )
+ ) {
+
+ buf[0] = '\0';
+ exn_get_flash_output(flashoutput, buf, EXIF_STD_BUF_LEN);
+ snprintf(buffer, maxsize,
+ "NikonFlashControlMode: %s (Power: %s)\n",
+ EXN_NikonFlashControlModeValues[exn_fcm], buf);
+
+ /* External Flash Flags. Not as useful as expected. Not used (yet). */
+ /* if ( (externalflashflags & (1<<2)) ) -> Bounce Flash */
+ /* if ( (externalflashflags & (1<<4)) ) -> Wide Flash Adapter */
+ /* if ( (externalflashflags & (1<<5)) ) -> Dome Diffusor */
+
+ }
}
/* get nikon AFInfo2 (183) info */
-static void exn_get_mnote_nikon_183(ExifData *ed, char * buffer, unsigned int maxsize)
+static void exn_get_mnote_nikon_183(ExifData * ed, char *buffer,
+ unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
- unsigned int contrastdetectaf = 0;
- unsigned int afareamode = 0;
- unsigned int phasedetectaf = 0;
- unsigned int primaryafpoint = 0;
- unsigned int version = 0;
- unsigned int length = 0;
-
- /* AFInfo2 */
- /* libexif does not support AFInfo2 183 yet. so we have to parse the debug data :-( */
- buf[0] = '\0';
- exif_get_mnote_tag(ed, 183, buf, sizeof(buf));
- sscanf(buf, "(null): %u bytes unknown data: 303130%02X%02X%02X%02X%02X", &length, &version,
- &contrastdetectaf,
- &afareamode,
- &phasedetectaf,
- &primaryafpoint
- );
-
-
- if ( ((length == 30) && (version == '0'))
- && (contrastdetectaf < EXN_CONTRAST_DETECT_AF_MAX)
- && (phasedetectaf < EXN_PHASE_DETECT_AF_MAX)
- )
- {
- if ( (contrastdetectaf != 0) && (afareamode < EXN_AF_AREA_MODE_C_MAX) )
- {
- /* Contrast AF (live view) */
- snprintf(buffer, maxsize,
- "ContrastDetectAF: %s; AFAreaMode: %s\n",
- EXN_NikonContrastDetectAF[contrastdetectaf],
- EXN_NikonAFAreaModeContr[afareamode]);
-
- }
- else if ( (phasedetectaf != 0) && (afareamode < EXN_AF_AREA_MODE_P_MAX) )
- {
- /* Phase AF */
- buf[0] = '\0';
- exn_get_prim_af_pt(phasedetectaf, primaryafpoint, buf, EXIF_STD_BUF_LEN);
-
- snprintf(buffer, maxsize,
- "PhaseDetectAF: %s; AreaMode: %s; PrimaryAFPoint: %s\n",
- EXN_NikonPhaseDetectAF[phasedetectaf],
- EXN_NikonAFAreaModePhase[afareamode],
- buf
- );
- }
-
- }
+ char buf[EXIF_STD_BUF_LEN];
+ unsigned int contrastdetectaf = 0;
+ unsigned int afareamode = 0;
+ unsigned int phasedetectaf = 0;
+ unsigned int primaryafpoint = 0;
+ unsigned int version = 0;
+ unsigned int length = 0;
+
+ /* AFInfo2 */
+ /* libexif does not support AFInfo2 183 yet. so we have to parse the debug data :-( */
+ buf[0] = '\0';
+ exif_get_mnote_tag(ed, 183, buf, sizeof(buf));
+ sscanf(buf,
+ "(null): %u bytes unknown data: 303130%02X%02X%02X%02X%02X",
+ &length, &version, &contrastdetectaf, &afareamode,
+ &phasedetectaf, &primaryafpoint);
+
+
+ if (((length == 30) && (version == '0'))
+ && (contrastdetectaf < EXN_CONTRAST_DETECT_AF_MAX)
+ && (phasedetectaf < EXN_PHASE_DETECT_AF_MAX)
+ ) {
+ if ((contrastdetectaf != 0)
+ && (afareamode < EXN_AF_AREA_MODE_C_MAX)) {
+ /* Contrast AF (live view) */
+ snprintf(buffer, maxsize,
+ "ContrastDetectAF: %s; AFAreaMode: %s\n",
+ EXN_NikonContrastDetectAF
+ [contrastdetectaf],
+ EXN_NikonAFAreaModeContr[afareamode]);
+
+ } else if ((phasedetectaf != 0)
+ && (afareamode < EXN_AF_AREA_MODE_P_MAX)) {
+ /* Phase AF */
+ buf[0] = '\0';
+ exn_get_prim_af_pt(phasedetectaf, primaryafpoint,
+ buf, EXIF_STD_BUF_LEN);
+
+ snprintf(buffer, maxsize,
+ "PhaseDetectAF: %s; AreaMode: %s; PrimaryAFPoint: %s\n",
+ EXN_NikonPhaseDetectAF[phasedetectaf],
+ EXN_NikonAFAreaModePhase[afareamode],
+ buf);
+ }
+
+ }
}
/* get interesting nikon maker note tags in readable form */
-void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize)
+void exn_get_mnote_nikon_tags(ExifData * ed, unsigned int tag,
+ char *buffer, unsigned int maxsize)
{
- char buf[EXIF_STD_BUF_LEN];
-
- buf[0] = '\0';
- exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf));
- exif_trim_spaces(buf);
-
- switch(tag)
- {
- /* show only if flash was used */
- case 8: /* Flash Setting */
- case 9: /* Flash Mode */
- case 135: /* Flash used */
- {
- if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) )
- {
- /* show extended flash info only if flash was fired */
- exif_get_mnote_tag(ed, tag, buffer, maxsize);
- }
- }
- break;
-
- case 18: /* FlashExposureComp */
- {
- if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) )
- {
- /* show only if flash was fired */
- exn_get_mnote_nikon_18(ed, buffer, maxsize);
- }
- }
- break;
-
- case 34:
- {
- /* ActiveD-Lighting */
- exn_get_mnote_nikon_34(ed, buffer, maxsize);
- }
- break;
-
- case 35:
- {
- /* PictureControlData */
- exn_get_mnote_nikon_35(ed, buffer, maxsize);
- }
- break;
-
- case 168:
- {
- /* Flash info: control mode */
- if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) )
- {
- /* show extended flash info only if flash was fired */
- exn_get_mnote_nikon_168(ed, buffer, maxsize);
- }
- }
- break;
-
- case 183:
- {
- /* AFInfo 2 */
- exn_get_mnote_nikon_183(ed, buffer, maxsize);
- }
- break;
-
- default:
- {
- /* normal makernote tags without special treatment */
- exif_get_mnote_tag(ed, tag, buffer, maxsize);
- }
- break;
- }
-
-
- return;
+ char buf[EXIF_STD_BUF_LEN];
+
+ buf[0] = '\0';
+ exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf));
+ exif_trim_spaces(buf);
+
+ switch (tag) {
+ /* show only if flash was used */
+ case 8: /* Flash Setting */
+ case 9: /* Flash Mode */
+ case 135: /* Flash used */
+ {
+ if (!
+ (strcmp("Flash: Flash did not fire\n", buf) ==
+ 0)) {
+ /* show extended flash info only if flash was fired */
+ exif_get_mnote_tag(ed, tag, buffer,
+ maxsize);
+ }
+ }
+ break;
+
+ case 18: /* FlashExposureComp */
+ {
+ if (!
+ (strcmp("Flash: Flash did not fire\n", buf) ==
+ 0)) {
+ /* show only if flash was fired */
+ exn_get_mnote_nikon_18(ed, buffer,
+ maxsize);
+ }
+ }
+ break;
+
+ case 34:
+ {
+ /* ActiveD-Lighting */
+ exn_get_mnote_nikon_34(ed, buffer, maxsize);
+ }
+ break;
+
+ case 35:
+ {
+ /* PictureControlData */
+ exn_get_mnote_nikon_35(ed, buffer, maxsize);
+ }
+ break;
+
+ case 168:
+ {
+ /* Flash info: control mode */
+ if (!
+ (strcmp("Flash: Flash did not fire\n", buf) ==
+ 0)) {
+ /* show extended flash info only if flash was fired */
+ exn_get_mnote_nikon_168(ed, buffer,
+ maxsize);
+ }
+ }
+ break;
+
+ case 183:
+ {
+ /* AFInfo 2 */
+ exn_get_mnote_nikon_183(ed, buffer, maxsize);
+ }
+ break;
+
+ default:
+ {
+ /* normal makernote tags without special treatment */
+ exif_get_mnote_tag(ed, tag, buffer, maxsize);
+ }
+ break;
+ }
+
+
+ return;
}
#endif
diff --git a/src/exif_nikon.h b/src/exif_nikon.h
index 16e8fb9..49d14b6 100644
--- a/src/exif_nikon.h
+++ b/src/exif_nikon.h
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libexif/exif-data.h>
-extern void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize);
+extern void exn_get_mnote_nikon_tags(ExifData * ed, unsigned int tag,
+ char *buffer, unsigned int maxsize);
#endif