exiftag: handle GST_TAG_CAPTURING_LIGHT_SOURCE tag

This exif tag allows to specify the different light conditions
when taking a picture. This tag is defined in:
https://exiftool.org/TagNames/EXIF.html#LightSource

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5571>
This commit is contained in:
Diego Nieto 2023-10-28 13:01:58 +02:00 committed by GStreamer Marge Bot
parent b5e119bbcc
commit 0d85cdafd5
7 changed files with 295 additions and 0 deletions

View file

@ -151,6 +151,35 @@ The allowed values are:
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h"/>
<type name="utf8" c:type="gchar*"/>
</constant>
<constant name="TAG_CAPTURING_LIGHT_SOURCE" value="capturing-light-source" c:type="GST_TAG_CAPTURING_LIGHT_SOURCE" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h">Light source used when capturing an image. (string)
The allowed values are:
"unknown"
"daylight"
"fluorescent"
"tungsten"
"flash"
"fine-weather"
"cloudy-weather"
"shade"
"daylight-fluorescent"
"day-white-fluorescent"
"cool-white-fluorescent"
"white-fluorescent"
"warm-white-fluorescent"
"standard-light-A"
"standard-light-B"
"standard-light-C"
"D55"
"D65"
"D75"
"D50"
"iso-studio-tungsten"
"other"</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h"/>
<type name="utf8" c:type="gchar*"/>
</constant>
<constant name="TAG_CAPTURING_METERING_MODE" value="capturing-metering-mode" c:type="GST_TAG_CAPTURING_METERING_MODE">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h">Defines the way a camera determines the exposure. (string)

View file

@ -201,6 +201,63 @@ end:
return -1;
}
static gint
__exif_tag_capture_light_source_to_exif_value (const gchar * str)
{
if (str == NULL) {
GST_WARNING ("Invalid light source: NULL");
return -1;
}
if (strcmp (str, "unknown") == 0)
return 0;
else if (strcmp (str, "daylight") == 0)
return 1;
else if (strcmp (str, "flourescent") == 0)
return 2;
else if (strcmp (str, "tungsten") == 0)
return 3;
else if (strcmp (str, "flash") == 0)
return 4;
else if (strcmp (str, "fine-weather") == 0)
return 9;
else if (strcmp (str, "cloudy-weather") == 0)
return 10;
else if (strcmp (str, "shade") == 0)
return 11;
else if (strcmp (str, "daylight-fluorescent") == 0)
return 12;
else if (strcmp (str, "day-white-fluorescent") == 0)
return 13;
else if (strcmp (str, "cool-white-fluorescent") == 0)
return 14;
else if (strcmp (str, "white-fluorescent") == 0)
return 15;
else if (strcmp (str, "warm-white-fluorescent") == 0)
return 16;
else if (strcmp (str, "standard-light-A") == 0)
return 17;
else if (strcmp (str, "standard-light-B") == 0)
return 18;
else if (strcmp (str, "standard-light-C") == 0)
return 19;
else if (strcmp (str, "D55") == 0)
return 20;
else if (strcmp (str, "D65") == 0)
return 21;
else if (strcmp (str, "D75") == 0)
return 22;
else if (strcmp (str, "D50") == 0)
return 23;
else if (strcmp (str, "iso-studio-tungsten") == 0)
return 24;
else if (strcmp (str, "other") == 0)
return 255;
GST_WARNING ("Invalid light source: %s", str);
return -1;
}
static gint
__exif_tag_capture_contrast_to_exif_value (const gchar * str)
{
@ -347,6 +404,8 @@ GST_COMPARE_GST_STRING_TAG_TO_EXIF_SHORT_FUNC (GST_TAG_CAPTURING_EXPOSURE_MODE,
capture_exposure_mode);
GST_COMPARE_GST_STRING_TAG_TO_EXIF_SHORT_FUNC (GST_TAG_CAPTURING_WHITE_BALANCE,
capture_white_balance);
GST_COMPARE_GST_STRING_TAG_TO_EXIF_SHORT_FUNC (GST_TAG_CAPTURING_LIGHT_SOURCE,
capture_light_source);
GST_COMPARE_GST_STRING_TAG_TO_EXIF_SHORT_FUNC (GST_TAG_CAPTURING_CONTRAST,
capture_contrast);
GST_COMPARE_GST_STRING_TAG_TO_EXIF_SHORT_FUNC
@ -631,6 +690,8 @@ static const GstExifTagMatch tag_map[] = {
compare_capture_exposure_mode},
{GST_TAG_CAPTURING_WHITE_BALANCE, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_SHORT,
compare_capture_white_balance},
{GST_TAG_CAPTURING_LIGHT_SOURCE, EXIF_TAG_LIGHT_SOURCE, EXIF_TYPE_SHORT,
compare_capture_light_source},
{GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO, EXIF_TAG_DIGITAL_ZOOM_RATIO,
EXIF_TYPE_RATIONAL, NULL},
{GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, EXIF_TAG_SCENE_CAPTURE_TYPE,
@ -1145,6 +1206,55 @@ GST_START_TEST (test_jifmux_tags)
generate_jif_file_with_tags (WHITE_BALANCE_TAG ("manual"), tmpfile);
libexif_check_tags (WHITE_BALANCE_TAG ("manual"), tmpfile);
#define LIGHT_SOURCE_TAG(t) "taglist," GST_TAG_CAPTURING_LIGHT_SOURCE "=" t
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("unknown"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("unknown"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("daylight"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("daylight"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("flourescent"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("flourescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("tungsten"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("tungsten"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("flash"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("flash"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("fine-weather"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("fine-weather"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("cloudy-weather"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("cloudy-weather"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("shade"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("shade"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("daylight-fluorescent"),
tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("daylight-fluorescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("day-white-fluorescent"),
tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("day-white-fluorescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("cool-white-fluorescent"),
tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("cool-white-fluorescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("white-fluorescent"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("white-fluorescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("warm-white-fluorescent"),
tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("warm-white-fluorescent"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("standard-light-A"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("standard-light-A"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("standard-light-B"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("standard-light-B"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("standard-light-C"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("standard-light-C"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("D55"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("D55"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("D65"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("D65"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("D75"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("D75"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("iso-studio-tungsten"),
tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("iso-studio-tungsten"), tmpfile);
generate_jif_file_with_tags (LIGHT_SOURCE_TAG ("other"), tmpfile);
libexif_check_tags (LIGHT_SOURCE_TAG ("other"), tmpfile);
#define GAIN_ADJUSTMENT_TAG(t) "taglist," GST_TAG_CAPTURING_GAIN_ADJUSTMENT "=" t
generate_jif_file_with_tags (GAIN_ADJUSTMENT_TAG ("none"), tmpfile);
libexif_check_tags (GAIN_ADJUSTMENT_TAG ("none"), tmpfile);

View file

@ -279,6 +279,7 @@ EXIF_SERIALIZATION_DESERIALIZATION_FUNC (shutter_speed);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (source);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (speed);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (white_balance);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (light_source);
EXIF_DESERIALIZATION_FUNC (resolution);
EXIF_DESERIALIZATION_FUNC (add_to_pending_tags);
@ -330,6 +331,7 @@ EXIF_DESERIALIZATION_FUNC (add_to_pending_tags);
#define EXIF_TAG_SCENE_TYPE 0xA301
#define EXIF_TAG_EXPOSURE_MODE 0xA402
#define EXIF_TAG_WHITE_BALANCE 0xA403
#define EXIF_TAG_LIGHT_SOURCE 0x9208
#define EXIF_TAG_DIGITAL_ZOOM_RATIO 0xA404
#define EXIF_TAG_FOCAL_LENGTH_IN_35_MM_FILM 0xa405
#define EXIF_TAG_SCENE_CAPTURE_TYPE 0xA406
@ -429,6 +431,8 @@ static const GstExifTagMatch tag_map_exif[] = {
0, serialize_exposure_mode, deserialize_exposure_mode},
{GST_TAG_CAPTURING_WHITE_BALANCE, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_SHORT,
0, serialize_white_balance, deserialize_white_balance},
{GST_TAG_CAPTURING_LIGHT_SOURCE, EXIF_TAG_LIGHT_SOURCE, EXIF_TYPE_SHORT,
0, serialize_light_source, deserialize_light_source},
{GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO, EXIF_TAG_DIGITAL_ZOOM_RATIO,
EXIF_TYPE_RATIONAL, 0, NULL,
NULL},
@ -2125,6 +2129,8 @@ EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (source,
capturing_source);
EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (white_balance,
capturing_white_balance);
EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (light_source,
capturing_light_source);
static void
serialize_geo_coordinate (GstExifWriter * writer, const GstTagList * taglist,

View file

@ -280,6 +280,115 @@ __exif_tag_capturing_white_balance_from_exif_value (gint value)
}
}
gint
__exif_tag_capturing_light_source_to_exif_value (const gchar * str)
{
if (str == NULL) {
GST_WARNING ("Invalid light source: NULL");
return -1;
}
if (strcmp (str, "unknown") == 0)
return 0;
else if (strcmp (str, "daylight") == 0)
return 1;
else if (strcmp (str, "flourescent") == 0)
return 2;
else if (strcmp (str, "tungsten") == 0)
return 3;
else if (strcmp (str, "flash") == 0)
return 4;
else if (strcmp (str, "fine-weather") == 0)
return 9;
else if (strcmp (str, "cloudy-weather") == 0)
return 10;
else if (strcmp (str, "shade") == 0)
return 11;
else if (strcmp (str, "daylight-fluorescent") == 0)
return 12;
else if (strcmp (str, "day-white-fluorescent") == 0)
return 13;
else if (strcmp (str, "cool-white-fluorescent") == 0)
return 14;
else if (strcmp (str, "white-fluorescent") == 0)
return 15;
else if (strcmp (str, "warm-white-fluorescent") == 0)
return 16;
else if (strcmp (str, "standard-light-A") == 0)
return 17;
else if (strcmp (str, "standard-light-B") == 0)
return 18;
else if (strcmp (str, "standard-light-C") == 0)
return 19;
else if (strcmp (str, "D55") == 0)
return 20;
else if (strcmp (str, "D65") == 0)
return 21;
else if (strcmp (str, "D75") == 0)
return 22;
else if (strcmp (str, "D50") == 0)
return 23;
else if (strcmp (str, "iso-studio-tungsten") == 0)
return 24;
else if (strcmp (str, "other") == 0)
return 255;
GST_WARNING ("Invalid light source: %s", str);
return -1;
}
const gchar *
__exif_tag_capturing_light_source_from_exif_value (gint value)
{
switch (value) {
case 0:
return "unknown";
case 1:
return "daylight";
case 2:
return "flourescent";
case 4:
return "flash";
case 9:
return "fine-weather";
case 10:
return "cloudy-weather";
case 11:
return "shade";
case 12:
return "daylight-fluorescent";
case 13:
return "day-white-fluorescent";
case 14:
return "cool-white-fluorescent";
case 15:
return "white-fluorescent";
case 16:
return "warm-white-fluorescent";
case 17:
return "standard-light-A";
case 18:
return "standard-light-B";
case 19:
return "standard-light-C";
case 20:
return "D55";
case 21:
return "D65";
case 22:
return "D75";
case 23:
return "D50";
case 24:
return "iso-studio-tungsten";
case 255:
return "other";
default:
GST_WARNING ("Invalid light source type: %d", value);
return NULL;
}
}
static gint
__exif_tag_capturing_contrast_sharpness_to_exif_value (const gchar * str,
const gchar * tag_name)

View file

@ -53,6 +53,9 @@ const gchar * __exif_tag_capturing_gain_adjustment_from_exif_value (gint value);
gint __exif_tag_capturing_white_balance_to_exif_value (const gchar * str);
const gchar * __exif_tag_capturing_white_balance_from_exif_value (gint value);
int __exif_tag_capturing_light_source_to_exif_value (const gchar * str);
const gchar * __exif_tag_capturing_light_source_from_exif_value (gint value);
gint __exif_tag_capturing_contrast_to_exif_value (const gchar * str);
const gchar * __exif_tag_capturing_contrast_from_exif_value (gint value);

View file

@ -296,6 +296,39 @@ G_BEGIN_DECLS
*/
#define GST_TAG_CAPTURING_WHITE_BALANCE "capturing-white-balance"
/**
* GST_TAG_CAPTURING_LIGHT_SOURCE:
*
* Light source used when capturing an image. (string)
*
* The allowed values are:
* "unknown"
* "daylight"
* "fluorescent"
* "tungsten"
* "flash"
* "fine-weather"
* "cloudy-weather"
* "shade"
* "daylight-fluorescent"
* "day-white-fluorescent"
* "cool-white-fluorescent"
* "white-fluorescent"
* "warm-white-fluorescent"
* "standard-light-A"
* "standard-light-B"
* "standard-light-C"
* "D55"
* "D65"
* "D75"
* "D50"
* "iso-studio-tungsten"
* "other"
*
* Since: 1.26
*/
#define GST_TAG_CAPTURING_LIGHT_SOURCE "capturing-light-source"
/**
* GST_TAG_CAPTURING_CONTRAST:
*

View file

@ -165,6 +165,11 @@ gst_tag_register_tags_internal (gpointer unused)
G_TYPE_STRING, _("capturing white balance"),
_("The white balance mode set when capturing an image"), NULL);
gst_tag_register_static (GST_TAG_CAPTURING_LIGHT_SOURCE, GST_TAG_FLAG_META,
G_TYPE_STRING, _("capturing light source"),
_("The light source indicates the kind of light when capturing an"
"image"), NULL);
gst_tag_register_static (GST_TAG_CAPTURING_CONTRAST, GST_TAG_FLAG_META,
G_TYPE_STRING, _("capturing contrast"),
_("The direction of contrast processing applied "