summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Real <github@tildepipe.org>2012-12-21 22:01:42 +0100
committerDennis Real <github@tildepipe.org>2012-12-21 22:01:42 +0100
commit586c49b3cc178c1b454749ba1bc76b5814f93737 (patch)
tree9722b975b08cad5b82146d4aec4490a57661878b
parent98b0add5231e16a0d8c91eff929374a2131a8124 (diff)
downloadfeh-586c49b3cc178c1b454749ba1bc76b5814f93737.zip
Some more nikon exif features:
- ISO - Whitebalance - PictureControlData - Flash output power
-rw-r--r--src/exif_cfg.h11
-rw-r--r--src/exif_nikon.c114
2 files changed, 121 insertions, 4 deletions
diff --git a/src/exif_cfg.h b/src/exif_cfg.h
index 31acc50..a3344bc 100644
--- a/src/exif_cfg.h
+++ b/src/exif_cfg.h
@@ -36,6 +36,7 @@ typedef struct
/* 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},
@@ -67,15 +68,21 @@ const t_EXIF_INFO Exif_tag_list [] =
/* show these nikon makernote tags */
const unsigned int Exif_makernote_nikon_tag_list [] =
{
+
+ 6,
8, /* Flash Setting */
9, /* Flash Mode */
24, /* Flash exposure bracket value */
135, /* Flash used */
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, /* ActiveD-Lighting */
+ 34, /* Active D-Lighting */
+
+ 35, /* PictureControlData */
183, /* AFInfo2 */
EXIF_NIKON_MAKERNOTE_END /* end marker */
diff --git a/src/exif_nikon.c b/src/exif_nikon.c
index f4a8eea..21a2f08 100644
--- a/src/exif_nikon.c
+++ b/src/exif_nikon.c
@@ -95,11 +95,20 @@ char * EXN_Prim_AF_Pt_39[EXN_PRIM_AF_PT_39_MAX] = {"(none)", "C6 (Center)", "B6"
"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"};
+
+
+
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_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);
@@ -164,6 +173,32 @@ static void exn_get_prim_af_pt(unsigned int phasedetectaf,
+/* get flash output power (for FlashInfo010x) */
+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);
+ }
+ }
+}
+
+
+
/* get ActiveD-Lighting (34) info */
static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int maxsize)
{
@@ -220,6 +255,63 @@ static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int max
+/* get nikon PictureControlData (35) info */
+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);
+ }
+
+}
+
+
+
+
/* get nikon Flash info: control mode (168) info */
static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int maxsize)
{
@@ -227,11 +319,13 @@ static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int ma
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;
/* 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%*10s%02X", &length, &version, &exn_fcm);
+ sscanf(buf, "(null): %u bytes unknown data: 303130%02X%*8s%02X%02X%02X", &length, &version, &externalflashflags, &exn_fcm, &flashoutput);
exn_fcm = exn_fcm & EXN_FLASH_CONTROL_MODE_MASK;
if ( (exn_fcm < EXN_FLASH_CONTROL_MODES_MAX)
@@ -242,7 +336,16 @@ static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int ma
)
)
{
- snprintf(buffer, maxsize, "NikonFlashControlMode: %s\n", EXN_NikonFlashControlModeValues[exn_fcm]);
+
+ 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 */
+
}
}
@@ -336,6 +439,13 @@ void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, uns
exn_get_mnote_nikon_34(ed, buffer, maxsize);
}
break;
+
+ case 35:
+ {
+ /* PictureControlData */
+ exn_get_mnote_nikon_35(ed, buffer, maxsize);
+ }
+ break;
case 168:
{