diff --git a/girs/GstTag-1.0.gir b/girs/GstTag-1.0.gir index 29abd2a9b4..bfa92f46f7 100644 --- a/girs/GstTag-1.0.gir +++ b/girs/GstTag-1.0.gir @@ -151,6 +151,35 @@ The allowed values are: + + 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" + + + Defines the way a camera determines the exposure. (string) diff --git a/subprojects/gst-plugins-bad/tests/check/elements/jifmux.c b/subprojects/gst-plugins-bad/tests/check/elements/jifmux.c index afcf6bfbee..f6030392ac 100644 --- a/subprojects/gst-plugins-bad/tests/check/elements/jifmux.c +++ b/subprojects/gst-plugins-bad/tests/check/elements/jifmux.c @@ -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); diff --git a/subprojects/gst-plugins-base/gst-libs/gst/tag/gstexiftag.c b/subprojects/gst-plugins-base/gst-libs/gst/tag/gstexiftag.c index d91686a9d0..237a35f30f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/tag/gstexiftag.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/tag/gstexiftag.c @@ -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, diff --git a/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.c b/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.c index 9042ec7993..085c506e99 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.c @@ -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) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.h b/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.h index 04febbadae..105d1b8b2f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/tag/gsttageditingprivate.h @@ -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); diff --git a/subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h b/subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h index f19b4c680e..009671c88e 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/tag/tag.h @@ -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: * diff --git a/subprojects/gst-plugins-base/gst-libs/gst/tag/tags.c b/subprojects/gst-plugins-base/gst-libs/gst/tag/tags.c index d38a0c97f4..58d26d0495 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/tag/tags.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/tag/tags.c @@ -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 "