tag: Adds GST_TAG_CAPTURING_SOURCE

Adds a tag to indicate the source/device used for the capture.

Already maps it in exif and adds tests.

API: GST_TAG_CAPTURING_SOURCE

https://bugzilla.gnome.org/show_bug.cgi?id=631773
This commit is contained in:
Thiago Santos 2010-10-08 17:24:07 -03:00 committed by Tim-Philipp Müller
parent b49f83d738
commit 5984ff1086
7 changed files with 142 additions and 5 deletions

View file

@ -1670,6 +1670,7 @@ GST_TAG_CAPTURING_SHARPNESS
GST_TAG_CAPTURING_FLASH_FIRED
GST_TAG_CAPTURING_FLASH_MODE
GST_TAG_CAPTURING_METERING_MODE
GST_TAG_CAPTURING_SOURCE
GST_TAG_IMAGE_HORIZONTAL_PPI
GST_TAG_IMAGE_VERTICAL_PPI
gst_tag_register_musicbrainz_tags

View file

@ -134,6 +134,12 @@ serialize_ ## name (GstExifWriter * writer, const GstTagList * taglist, \
case EXIF_TYPE_LONG: \
gst_exif_writer_write_long_tag (writer, exiftag->exif_tag, exif_value); \
break; \
case EXIF_TYPE_UNDEFINED: \
{ \
guint8 data = (guint8) exif_value; \
write_exif_undefined_tag (writer, exiftag->exif_tag, &data, 1); \
} \
break; \
default: \
g_assert_not_reached (); \
GST_WARNING ("Unmapped serialization for type %d", exiftag->exif_type); \
@ -154,15 +160,23 @@ deserialize_ ## name (GstExifReader * exif_reader, \
exiftag->exif_tag); \
\
/* validate tag */ \
if (tagdata->tag_type != EXIF_TYPE_SHORT || tagdata->count != 1) { \
GST_WARNING ("0x%X has unexpected type/count", tagdata->tag); \
if (tagdata->count != 1) { \
GST_WARNING ("0x%X has unexpected count", tagdata->count); \
return 0; \
} \
\
if (exif_reader->byte_order == G_LITTLE_ENDIAN) { \
value = GST_READ_UINT16_LE (tagdata->offset_as_data); \
if (tagdata->tag_type == EXIF_TYPE_SHORT) { \
if (exif_reader->byte_order == G_LITTLE_ENDIAN) { \
value = GST_READ_UINT16_LE (tagdata->offset_as_data); \
} else { \
value = GST_READ_UINT16_BE (tagdata->offset_as_data); \
} \
} else if (tagdata->tag_type == EXIF_TYPE_UNDEFINED) { \
value = GST_READ_UINT8 (tagdata->offset_as_data); \
} else { \
value = GST_READ_UINT16_BE (tagdata->offset_as_data); \
GST_WARNING ("0x%X has unexpected type %d", exiftag->exif_tag, \
tagdata->tag_type); \
return 0; \
} \
\
str = __exif_tag_## funcname ## _from_exif_value (value); \
@ -238,9 +252,11 @@ EXIF_SERIALIZATION_DESERIALIZATION_FUNC (metering_mode);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (orientation);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (saturation);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (scene_capture_type);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (scene_type);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (sensitivity_type);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (sharpness);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (shutter_speed);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (source);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (speed);
EXIF_SERIALIZATION_DESERIALIZATION_FUNC (white_balance);
@ -289,6 +305,8 @@ EXIF_DESERIALIZATION_FUNC (add_to_pending_tags);
#define EXIF_TAG_FLASH 0x9209
#define EXIF_TAG_FOCAL_LENGTH 0x920A
#define EXIF_TAG_MAKER_NOTE 0x927C
#define EXIF_TAG_FILE_SOURCE 0xA300
#define EXIF_TAG_SCENE_TYPE 0xA301
#define EXIF_TAG_EXPOSURE_MODE 0xA402
#define EXIF_TAG_WHITE_BALANCE 0xA403
#define EXIF_TAG_DIGITAL_ZOOM_RATIO 0xA404
@ -379,6 +397,10 @@ static const GstExifTagMatch tag_map_exif[] = {
{GST_TAG_APPLICATION_DATA, EXIF_TAG_MAKER_NOTE, EXIF_TYPE_UNDEFINED, 0, NULL,
NULL},
{NULL, EXIF_FLASHPIX_VERSION_TAG, EXIF_TYPE_UNDEFINED, 0, NULL, NULL},
{GST_TAG_CAPTURING_SOURCE, EXIF_TAG_FILE_SOURCE, EXIF_TYPE_UNDEFINED,
0, serialize_source, deserialize_source},
{GST_TAG_CAPTURING_SOURCE, EXIF_TAG_SCENE_TYPE, EXIF_TYPE_UNDEFINED,
0, serialize_scene_type, deserialize_scene_type},
{GST_TAG_CAPTURING_EXPOSURE_MODE, EXIF_TAG_EXPOSURE_MODE, EXIF_TYPE_SHORT,
0, serialize_exposure_mode, deserialize_exposure_mode},
{GST_TAG_CAPTURING_WHITE_BALANCE, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_SHORT,
@ -1773,6 +1795,8 @@ EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (scene_capture_type,
capturing_scene_capture_type);
EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (sharpness,
capturing_sharpness);
EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (source,
capturing_source);
EXIF_SERIALIZATION_DESERIALIZATION_MAP_STRING_TO_INT_FUNC (white_balance,
capturing_white_balance);
@ -2518,6 +2542,44 @@ deserialize_resolution (GstExifReader * exif_reader,
return 0;
}
static void
serialize_scene_type (GstExifWriter * writer, const GstTagList * taglist,
const GstExifTagMatch * exiftag)
{
const gchar *str;
guint8 value = 0;
if (gst_tag_list_peek_string_index (taglist, GST_TAG_CAPTURING_SOURCE, 0,
&str)) {
if (strcmp (str, "dsc") == 0) {
value = 0;
}
}
if (value != 0)
write_exif_undefined_tag (writer, exiftag->exif_tag, &value, 1);
}
static gint
deserialize_scene_type (GstExifReader * exif_reader,
GstByteReader * reader, const GstExifTagMatch * exiftag,
GstExifTagData * tagdata)
{
guint8 value = 0;
GST_LOG ("Starting to parse %s tag in exif 0x%x", exiftag->gst_tag,
exiftag->exif_tag);
value = GST_READ_UINT8 (tagdata->offset_as_data);
if (value == 1) {
gst_tag_list_add (exif_reader->taglist, GST_TAG_MERGE_KEEP,
GST_TAG_CAPTURING_SOURCE, "dsc", NULL);
}
return 0;
}
static gint
deserialize_add_to_pending_tags (GstExifReader * exif_reader,
GstByteReader * reader, const GstExifTagMatch * exiftag,

View file

@ -428,3 +428,41 @@ __exif_tag_capturing_metering_mode_from_exif_value (gint value)
return NULL;
}
}
gint
__exif_tag_capturing_source_to_exif_value (const gchar * str)
{
if (str == NULL)
goto end;
if (strcmp (str, "dsc") == 0)
return 3;
else if (strcmp (str, "other") == 0)
return 0;
else if (strcmp (str, "transparent-scanner") == 0)
return 1;
else if (strcmp (str, "reflex-scanner") == 0)
return 2;
end:
GST_WARNING ("Invalid capturing source type: %s", str);
return -1;
}
const gchar *
__exif_tag_capturing_source_from_exif_value (gint value)
{
switch (value) {
case 0:
return "other";
case 1:
return "transparent-scanner";
case 2:
return "reflex-scanner";
case 3:
return "dsc";
default:
GST_WARNING ("Invalid capturing source type: %d", value);
return NULL;
}
}

View file

@ -65,6 +65,9 @@ const gchar * __exif_tag_capturing_sharpness_from_exif_value (gint value);
gint __exif_tag_capturing_metering_mode_to_exif_value (const gchar * str);
const gchar * __exif_tag_capturing_metering_mode_from_exif_value (gint value);
gint __exif_tag_capturing_source_to_exif_value (const gchar * str);
const gchar * __exif_tag_capturing_source_from_exif_value (gint value);
G_END_DECLS
#endif /* __GST_TAG_EDIT_PRIVATE_H__ */

View file

@ -339,6 +339,22 @@ G_BEGIN_DECLS
*/
#define GST_TAG_CAPTURING_METERING_MODE "capturing-metering-mode"
/**
* GST_TAG_CAPTURING_SOURCE:
*
* Indicates the source of capture. The device/medium used to do the
* capture. (string)
*
* Allowed values are:
* "dsc" (= digital still camera)
* "transparent-scanner"
* "reflex-scanner"
* "other"
*
* Since: 0.10.31
*/
#define GST_TAG_CAPTURING_SOURCE "capturing-source"
/**
* GST_TAG_IMAGE_HORIZONTAL_PPI:
*

View file

@ -173,6 +173,10 @@ gst_tag_register_tags_internal (gpointer unused)
_("The metering mode used while determining exposure for capturing an"
" image"), NULL);
gst_tag_register (GST_TAG_CAPTURING_SOURCE, GST_TAG_FLAG_META,
G_TYPE_STRING, _("capturing source"),
_("The source or type of device used for the capture"), NULL);
gst_tag_register (GST_TAG_IMAGE_HORIZONTAL_PPI, GST_TAG_FLAG_META,
G_TYPE_DOUBLE, _("image horizontal ppi"),
_("Media (image/video) intended horizontal pixel density in ppi"), NULL);

View file

@ -1419,6 +1419,19 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
g_value_set_static_string (&value, "other");
do_simple_exif_tag_serialization_deserialization
(GST_TAG_CAPTURING_METERING_MODE, &value);
g_value_set_static_string (&value, "dsc");
do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
&value);
g_value_set_static_string (&value, "other");
do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
&value);
g_value_set_static_string (&value, "transparent-scanner");
do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
&value);
g_value_set_static_string (&value, "reflex-scanner");
do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
&value);
g_value_unset (&value);
g_value_init (&value, G_TYPE_DOUBLE);