summaryrefslogtreecommitdiffstats
path: root/ext/metadata
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2007-12-04 16:42:25 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2007-12-04 16:42:25 +0000
commitcf4c5c965553c2c216561e4868621b82bf0a1ab5 (patch)
tree2ab6c51be66c50014a94aeaaedab678460e27aad /ext/metadata
parentcef8e5fe609ea6af4beae2f84d7d3fcd62d0a62f (diff)
downloadgst-plugins-bad-cf4c5c965553c2c216561e4868621b82bf0a1ab5.tar.gz
gst-plugins-bad-cf4c5c965553c2c216561e4868621b82bf0a1ab5.tar.bz2
gst-plugins-bad-cf4c5c965553c2c216561e4868621b82bf0a1ab5.zip
Fixed element properties and now muxer writes to png also.
Original commit message from CVS: Fixed element properties and now muxer writes to png also.
Diffstat (limited to 'ext/metadata')
-rw-r--r--ext/metadata/gstmetadatamux.c42
-rw-r--r--ext/metadata/gstmetadatamux.h4
-rw-r--r--ext/metadata/gstmetadataparse.c43
-rw-r--r--ext/metadata/gstmetadataparse.h4
-rw-r--r--ext/metadata/metadata.c44
-rw-r--r--ext/metadata/metadata.h7
-rw-r--r--ext/metadata/metadatamuxjpeg.c7
-rw-r--r--ext/metadata/metadatamuxjpeg.h3
-rw-r--r--ext/metadata/metadatamuxpng.c109
-rw-r--r--ext/metadata/metadatamuxpng.h8
10 files changed, 166 insertions, 105 deletions
diff --git a/ext/metadata/gstmetadatamux.c b/ext/metadata/gstmetadatamux.c
index ce2b2ac4..51fef2fb 100644
--- a/ext/metadata/gstmetadatamux.c
+++ b/ext/metadata/gstmetadatamux.c
@@ -162,8 +162,6 @@ gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf,
static void gst_metadata_mux_create_chunks_from_tags (GstMetadataMux * filter);
-
-
static int
gst_metadata_mux_get_strip_seg (const gint64 offset, guint32 size,
const gint64 seg_offset, const guint32 seg_size,
@@ -289,6 +287,7 @@ gst_metadata_mux_init (GstMetadataMux * filter, GstMetadataMuxClass * gclass)
metadataparse_xmp_init ();
/* init members */
+ filter->options = META_OPT_EXIF | META_OPT_IPTC | META_OPT_XMP;
gst_metadata_mux_init_members (filter);
}
@@ -302,21 +301,21 @@ gst_metadata_mux_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case ARG_EXIF:
if (g_value_get_boolean (value))
- set_meta_option (filter->mux_data, META_OPT_EXIF);
+ filter->options |= META_OPT_EXIF;
else
- unset_meta_option (filter->mux_data, META_OPT_EXIF);
+ filter->options &= ~META_OPT_EXIF;
break;
case ARG_IPTC:
if (g_value_get_boolean (value))
- set_meta_option (filter->mux_data, META_OPT_IPTC);
+ filter->options |= META_OPT_IPTC;
else
- unset_meta_option (filter->mux_data, META_OPT_IPTC);
+ filter->options &= ~META_OPT_IPTC;
break;
case ARG_XMP:
if (g_value_get_boolean (value))
- set_meta_option (filter->mux_data, META_OPT_XMP);
+ filter->options |= META_OPT_XMP;
else
- unset_meta_option (filter->mux_data, META_OPT_XMP);
+ filter->options &= ~META_OPT_XMP;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -332,16 +331,13 @@ gst_metadata_mux_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case ARG_EXIF:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->mux_data) & META_OPT_EXIF);
+ g_value_set_boolean (value, filter->options & META_OPT_EXIF);
break;
case ARG_IPTC:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->mux_data) & META_OPT_IPTC);
+ g_value_set_boolean (value, filter->options & META_OPT_IPTC);
break;
case ARG_XMP:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->mux_data) & META_OPT_XMP);
+ g_value_set_boolean (value, filter->options & META_OPT_XMP);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -604,9 +600,6 @@ static void
gst_metadata_mux_init_members (GstMetadataMux * filter)
{
filter->need_calculate_offset = FALSE;
- filter->exif = TRUE;
- filter->iptc = FALSE;
- filter->xmp = FALSE;
filter->adapter_parsing = NULL;
filter->adapter_holding = NULL;
@@ -624,6 +617,7 @@ gst_metadata_mux_init_members (GstMetadataMux * filter)
filter->prepend_buffer = NULL;
memset (&filter->mux_data, 0x00, sizeof (MetaData));
+
}
static gboolean
@@ -814,23 +808,27 @@ gst_metadata_create_chunks_from_tags (GstMetadataMux * filter)
if (taglist) {
- if (META_DATA_OPTION (filter->mux_data) & META_OPT_EXIF) {
+ if (filter->options & META_OPT_EXIF) {
metadatamux_exif_create_chunk_from_tag_list (&buf, &size, taglist);
gst_metadata_update_segment (filter, &buf, &size, MD_CHUNK_EXIF);
}
- if (META_DATA_OPTION (filter->mux_data) & META_OPT_IPTC) {
+ if (filter->options & META_OPT_IPTC) {
metadatamux_iptc_create_chunk_from_tag_list (&buf, &size, taglist);
gst_metadata_update_segment (filter, &buf, &size, MD_CHUNK_IPTC);
}
- if (META_DATA_OPTION (filter->mux_data) & META_OPT_XMP) {
+ if (filter->options & META_OPT_XMP) {
metadatamux_xmp_create_chunk_from_tag_list (&buf, &size, taglist);
gst_metadata_update_segment (filter, &buf, &size, MD_CHUNK_XMP);
}
}
+ if (buf) {
+ g_free (buf);
+ }
+
metadata_chunk_array_remove_zero_size (&filter->mux_data.inject_chunks);
}
@@ -1768,7 +1766,7 @@ gst_metadata_mux_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:
gst_metadata_mux_init_members (filter);
filter->adapter_parsing = gst_adapter_new ();
- metadata_init (&filter->mux_data, FALSE);
+ metadata_init (&filter->mux_data, FALSE, filter->options);
break;
default:
break;
@@ -1792,7 +1790,7 @@ gst_metadata_mux_change_state (GstElement * element, GstStateChange transition)
/* cleanup parser */
/* FIXME: could be improved a bit to avoid mem allocation */
metadata_dispose (&filter->mux_data);
- metadata_init (&filter->mux_data, FALSE);
+ metadata_init (&filter->mux_data, FALSE, filter->options);
}
break;
case GST_STATE_CHANGE_READY_TO_NULL:
diff --git a/ext/metadata/gstmetadatamux.h b/ext/metadata/gstmetadatamux.h
index adfe65ee..c7cb40ba 100644
--- a/ext/metadata/gstmetadatamux.h
+++ b/ext/metadata/gstmetadatamux.h
@@ -75,9 +75,7 @@ struct _GstMetadataMux
GstPad *sinkpad, *srcpad;
- gboolean exif;
- gboolean iptc;
- gboolean xmp;
+ guint8 options;
MetaData mux_data;
GstAdapter *adapter_parsing;
diff --git a/ext/metadata/gstmetadataparse.c b/ext/metadata/gstmetadataparse.c
index d2f1a945..3dd07cb2 100644
--- a/ext/metadata/gstmetadataparse.c
+++ b/ext/metadata/gstmetadataparse.c
@@ -283,6 +283,8 @@ gst_metadata_parse_init (GstMetadataParse * filter,
metadataparse_xmp_init ();
/* init members */
+ filter->options = META_OPT_EXIF | META_OPT_IPTC | META_OPT_XMP;
+
gst_metadata_parse_init_members (filter);
}
@@ -296,21 +298,21 @@ gst_metadata_parse_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case ARG_EXIF:
if (g_value_get_boolean (value))
- set_meta_option (filter->parse_data, META_OPT_EXIF);
+ filter->options |= META_OPT_EXIF;
else
- unset_meta_option (filter->parse_data, META_OPT_EXIF);
+ filter->options &= ~META_OPT_EXIF;
break;
case ARG_IPTC:
if (g_value_get_boolean (value))
- set_meta_option (filter->parse_data, META_OPT_IPTC);
+ filter->options |= META_OPT_IPTC;
else
- unset_meta_option (filter->parse_data, META_OPT_IPTC);
+ filter->options &= ~META_OPT_IPTC;
break;
case ARG_XMP:
if (g_value_get_boolean (value))
- set_meta_option (filter->parse_data, META_OPT_XMP);
+ filter->options |= META_OPT_XMP;
else
- unset_meta_option (filter->parse_data, META_OPT_XMP);
+ filter->options &= ~META_OPT_XMP;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -326,16 +328,13 @@ gst_metadata_parse_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case ARG_EXIF:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->parse_data) & META_OPT_EXIF);
+ g_value_set_boolean (value, filter->options & META_OPT_EXIF);
break;
case ARG_IPTC:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC);
+ g_value_set_boolean (value, filter->options & META_OPT_IPTC);
break;
case ARG_XMP:
- g_value_set_boolean (value,
- META_DATA_OPTION (filter->parse_data) & META_OPT_XMP);
+ g_value_set_boolean (value, filter->options & META_OPT_XMP);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -591,9 +590,6 @@ static void
gst_metadata_parse_init_members (GstMetadataParse * filter)
{
filter->need_send_tag = FALSE;
- filter->exif = TRUE;
- filter->iptc = TRUE;
- filter->xmp = TRUE;
filter->adapter_parsing = NULL;
filter->adapter_holding = NULL;
@@ -611,6 +607,7 @@ gst_metadata_parse_init_members (GstMetadataParse * filter)
filter->prepend_buffer = NULL;
memset (&filter->parse_data, 0x00, sizeof (MetaData));
+
}
static gboolean
@@ -763,13 +760,13 @@ gst_metadata_parse_send_tags (GstMetadataParse * filter)
GstTagList *taglist = gst_tag_list_new ();
GstEvent *event;
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_EXIF)
+ if (filter->options & META_OPT_EXIF)
metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.exif_adapter, METADATA_TAG_MAP_WHOLECHUNK);
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC)
+ if (filter->options & META_OPT_IPTC)
metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.iptc_adapter, METADATA_TAG_MAP_WHOLECHUNK);
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_XMP)
+ if (filter->options & META_OPT_XMP)
metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.xmp_adapter, METADATA_TAG_MAP_WHOLECHUNK);
@@ -787,13 +784,13 @@ gst_metadata_parse_send_tags (GstMetadataParse * filter)
if (!taglist)
taglist = gst_tag_list_new ();
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_EXIF)
+ if (filter->options & META_OPT_EXIF)
metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.exif_adapter, METADATA_TAG_MAP_INDIVIDUALS);
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC)
+ if (filter->options & META_OPT_IPTC)
metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.iptc_adapter, METADATA_TAG_MAP_INDIVIDUALS);
- if (META_DATA_OPTION (filter->parse_data) & META_OPT_XMP)
+ if (filter->options & META_OPT_XMP)
metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
filter->parse_data.xmp_adapter, METADATA_TAG_MAP_INDIVIDUALS);
@@ -1733,7 +1730,7 @@ gst_metadata_parse_change_state (GstElement * element,
case GST_STATE_CHANGE_NULL_TO_READY:
gst_metadata_parse_init_members (filter);
filter->adapter_parsing = gst_adapter_new ();
- metadata_init (&filter->parse_data, TRUE);
+ metadata_init (&filter->parse_data, TRUE, filter->options);
break;
default:
break;
@@ -1757,7 +1754,7 @@ gst_metadata_parse_change_state (GstElement * element,
/* cleanup parser */
/* FIXME: could be improved a bit to avoid mem allocation */
metadata_dispose (&filter->parse_data);
- metadata_init (&filter->parse_data, TRUE);
+ metadata_init (&filter->parse_data, TRUE, filter->options);
}
break;
case GST_STATE_CHANGE_READY_TO_NULL:
diff --git a/ext/metadata/gstmetadataparse.h b/ext/metadata/gstmetadataparse.h
index 10a97da8..fa1c9b71 100644
--- a/ext/metadata/gstmetadataparse.h
+++ b/ext/metadata/gstmetadataparse.h
@@ -75,9 +75,7 @@ struct _GstMetadataParse
GstPad *sinkpad, *srcpad;
- gboolean exif;
- gboolean iptc;
- gboolean xmp;
+ guint8 options;
gboolean need_send_tag;
diff --git a/ext/metadata/metadata.c b/ext/metadata/metadata.c
index 0d9c522f..0056a51c 100644
--- a/ext/metadata/metadata.c
+++ b/ext/metadata/metadata.c
@@ -58,11 +58,11 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf,
*/
void
-metadata_init (MetaData * meta_data, gboolean parse)
+metadata_init (MetaData * meta_data, gboolean parse, guint8 options)
{
meta_data->state = STATE_NULL;
meta_data->img_type = IMG_NONE;
- meta_data->option = META_OPT_ALL;
+ meta_data->options = options;
meta_data->offset_orig = 0;
meta_data->exif_adapter = NULL;
meta_data->iptc_adapter = NULL;
@@ -124,13 +124,11 @@ metadata_parse (MetaData * meta_data, const guint8 * buf,
metadataparse_png_parse (&meta_data->format_data.png_parse,
(guint8 *) buf, &bufsize, meta_data->offset_orig, &next_start,
next_size);
- /*
- else
- ret =
- metadatamux_png_parse (&meta_data->format_data.png_mux,
- (guint8 *) buf, &bufsize, meta_data->offset_orig, &next_start,
- next_size);
- */
+ else
+ ret =
+ metadatamux_png_parse (&meta_data->format_data.png_mux,
+ (guint8 *) buf, &bufsize, meta_data->offset_orig, &next_start,
+ next_size);
break;
default:
/* unexpected */
@@ -165,10 +163,8 @@ metadata_dispose (MetaData * meta_data)
case IMG_PNG:
if (G_LIKELY (meta_data->parse))
metadataparse_png_dispose (&meta_data->format_data.png_parse);
- /*
- else
- metadatamux_png_dispose (&meta_data->format_data.png_mux);
- */
+ else
+ metadatamux_png_dispose (&meta_data->format_data.png_mux);
break;
}
@@ -217,11 +213,11 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf,
goto done;
}
- if (meta_data->option & META_OPT_EXIF)
+ if (meta_data->options & META_OPT_EXIF)
exif = &meta_data->exif_adapter;
- if (meta_data->option & META_OPT_IPTC)
+ if (meta_data->options & META_OPT_IPTC)
iptc = &meta_data->iptc_adapter;
- if (meta_data->option & META_OPT_XMP)
+ if (meta_data->options & META_OPT_XMP)
xmp = &meta_data->xmp_adapter;
if (buf[0] == 0xFF && buf[1] == 0xD8 && buf[2] == 0xFF) {
@@ -229,7 +225,7 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf,
metadataparse_jpeg_init (&meta_data->format_data.jpeg_parse, exif, iptc,
xmp, &meta_data->strip_chunks, &meta_data->inject_chunks);
else
- metadatamux_jpeg_init (&meta_data->format_data.jpeg_mux, exif, iptc, xmp,
+ metadatamux_jpeg_init (&meta_data->format_data.jpeg_mux,
&meta_data->strip_chunks, &meta_data->inject_chunks);
ret = 0;
meta_data->img_type = IMG_JPEG;
@@ -247,11 +243,9 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf,
if (G_LIKELY (meta_data->parse))
metadataparse_png_init (&meta_data->format_data.png_parse, exif, iptc,
xmp, &meta_data->strip_chunks, &meta_data->inject_chunks);
- /*
- else
- metadatamux_png_init (&meta_data->format_data.png_mux, exif, iptc, xmp,
- &meta_data->strip_chunks, &meta_data->inject_chunks);
- */
+ else
+ metadatamux_png_init (&meta_data->format_data.png_mux,
+ &meta_data->strip_chunks, &meta_data->inject_chunks);
ret = 0;
meta_data->img_type = IMG_PNG;
goto done;
@@ -275,10 +269,8 @@ metadata_lazy_update (MetaData * meta_data)
case IMG_PNG:
if (G_LIKELY (meta_data->parse))
metadataparse_png_lazy_update (&meta_data->format_data.png_parse);
- /*
- else
- metadatamux_png_lazy_update (&meta_data->format_data.png_mux);
- */
+ else
+ metadatamux_png_lazy_update (&meta_data->format_data.png_mux);
break;
default:
/* unexpected */
diff --git a/ext/metadata/metadata.h b/ext/metadata/metadata.h
index 15bdab9d..735981fa 100644
--- a/ext/metadata/metadata.h
+++ b/ext/metadata/metadata.h
@@ -80,7 +80,7 @@ typedef struct _tag_MetaData
{
MetaState state;
ImageType img_type;
- MetaOption option;
+ guint8 options;
guint32 offset_orig; /* offset since begining of stream */
union
{
@@ -101,11 +101,8 @@ typedef struct _tag_MetaData
} MetaData;
#define META_DATA_IMG_TYPE(p) (p).img_type
-#define META_DATA_OPTION(p) (p).option
-#define set_meta_option(p, m) do { (p).option = (p).option | (m); } while(FALSE)
-#define unset_meta_option(p, m) do { (p).option = (p).option & ~(m); } while(FALSE)
-extern void metadata_init (MetaData * meta_data, gboolean parse);
+extern void metadata_init (MetaData * meta_data, gboolean parse, guint8 options);
/*
* offset: number of bytes that MUST be jumped after current "buf" pointer
diff --git a/ext/metadata/metadatamuxjpeg.c b/ext/metadata/metadatamuxjpeg.c
index 25a9f6b6..0e5c9334 100644
--- a/ext/metadata/metadatamuxjpeg.c
+++ b/ext/metadata/metadatamuxjpeg.c
@@ -66,8 +66,8 @@ metadatamux_wrap_chunk (MetadataChunk * chunk, guint8 * buf, guint32 buf_size,
chunk->size += 4 + buf_size;
data[0] = a;
data[1] = b;
- data[2] = (chunk->size - 2) >> 8;
- data[3] = (chunk->size - 2) & 0x00FF;
+ data[2] = ((chunk->size - 2) >> 8) & 0xFF;
+ data[3] = (chunk->size - 2) & 0xFF;
if (buf && buf_size) {
memcpy (data + 4, buf, buf_size);
}
@@ -130,8 +130,7 @@ metadatamux_jpeg_lazy_update (JpegMuxData * jpeg_data)
}
void
-metadatamux_jpeg_init (JpegMuxData * jpeg_data, GstAdapter ** exif_adpt,
- GstAdapter ** iptc_adpt, GstAdapter ** xmp_adpt,
+metadatamux_jpeg_init (JpegMuxData * jpeg_data,
MetadataChunkArray * strip_chunks, MetadataChunkArray * inject_chunks)
{
jpeg_data->state = JPEG_MUX_NULL;
diff --git a/ext/metadata/metadatamuxjpeg.h b/ext/metadata/metadatamuxjpeg.h
index cda787d1..f07f018b 100644
--- a/ext/metadata/metadatamuxjpeg.h
+++ b/ext/metadata/metadatamuxjpeg.h
@@ -69,8 +69,7 @@ typedef struct _tag_JpegMuxData
extern void
-metadatamux_jpeg_init (JpegMuxData * jpeg_data, GstAdapter ** exif_adpt,
- GstAdapter ** iptc_adpt, GstAdapter ** xmp_adpt,
+metadatamux_jpeg_init (JpegMuxData * jpeg_data,
MetadataChunkArray * strip_chunks, MetadataChunkArray * inject_chunks);
extern void metadatamux_jpeg_dispose (JpegMuxData * jpeg_data);
diff --git a/ext/metadata/metadatamuxpng.c b/ext/metadata/metadatamuxpng.c
index afcd380b..8aa17383 100644
--- a/ext/metadata/metadatamuxpng.c
+++ b/ext/metadata/metadatamuxpng.c
@@ -52,30 +52,120 @@ metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf,
#define READ(buf, size) ( (size)--, *((buf)++) )
+static void
+make_crc_table (guint32 crc_table[])
+{
+ guint32 c;
+ guint16 n, k;
+
+ for (n = 0; n < 256; n++) {
+ c = (guint32) n;
+ for (k = 0; k < 8; k++) {
+ if (c & 1)
+ c = 0xedb88320L ^ (c >> 1);
+ else
+ c = c >> 1;
+ }
+ crc_table[n] = c;
+ }
+}
+
+static guint32
+update_crc (guint32 crc, guint8 * buf, guint32 len)
+{
+ guint32 c = crc;
+ guint32 n;
+ guint32 crc_table[256];
+
+ /* FIXME: make_crc_table should be done once in life
+ for speed up */
+ make_crc_table (crc_table);
+
+ for (n = 0; n < len; n++) {
+ c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
+ }
+ return c;
+}
+
+/* Return the CRC of the bytes buf[0..len-1]. */
+static guint32
+calc_crc (guint8 * buf, guint32 len)
+{
+ return update_crc (0xffffffffL, buf, len) ^ 0xffffffffL;
+}
+
+
+static void
+metadatamux_wrap_xmp_chunk (MetadataChunk * chunk)
+{
+ static const char XmpHeader[] = "XML:com.adobe.xmp";
+ guint8 *data = NULL;
+ guint32 crc;
+
+ data = g_new (guint8, 12 + 18 + 4 + chunk->size);
+
+ memcpy (data + 8, XmpHeader, 18);
+ memset (data + 8 + 18, 0x00, 4);
+ memcpy (data + 8 + 18 + 4, chunk->data, chunk->size);
+ g_free (chunk->data);
+ chunk->data = data;
+ chunk->size += 18 + 4;
+ data[0] = (chunk->size >> 24) & 0xFF;
+ data[1] = (chunk->size >> 16) & 0xFF;
+ data[2] = (chunk->size >> 8) & 0xFF;
+ data[3] = chunk->size & 0xFF;
+ data[4] = 'i';
+ data[5] = 'T';
+ data[6] = 'X';
+ data[7] = 't';
+ crc = calc_crc (data + 4, chunk->size + 4 + 18);
+ data[chunk->size + 8] = (crc >> 24) & 0xFF;
+ data[chunk->size + 9] = (crc >> 16) & 0xFF;
+ data[chunk->size + 10] = (crc >> 8) & 0xFF;
+ data[chunk->size + 11] = crc & 0xFF;
+ chunk->size += 12;
+
+}
+
void
-metadatamux_png_lazy_update (PngMuxData * jpeg_data)
+metadatamux_png_lazy_update (PngMuxData * png_data)
{
- /* nothing to do */
+ gsize i;
+
+ for (i = 0; i < png_data->inject_chunks->len; ++i) {
+ if (png_data->inject_chunks->chunk[i].size > 0 &&
+ png_data->inject_chunks->chunk[i].data) {
+ switch (png_data->inject_chunks->chunk[i].type) {
+ case MD_CHUNK_XMP:
+ {
+ metadatamux_wrap_xmp_chunk (&png_data->inject_chunks->chunk[i]);
+ }
+ break;
+ default:
+ GST_ERROR ("Unexpected chunk for PNG muxer.");
+ break;
+ }
+ }
+ }
}
void
-metadatamux_png_init (PngMuxData * png_data, GstAdapter ** exif_adpt,
- GstAdapter ** iptc_adpt, GstAdapter ** xmp_adpt,
+metadatamux_png_init (PngMuxData * png_data,
MetadataChunkArray * strip_chunks, MetadataChunkArray * inject_chunks)
{
png_data->state = PNG_MUX_NULL;
- png_data->xmp_adapter = xmp_adpt;
- png_data->read = 0;
png_data->strip_chunks = strip_chunks;
png_data->inject_chunks = inject_chunks;
-
}
void
metadatamux_png_dispose (PngMuxData * png_data)
{
- png_data->xmp_adapter = NULL;
+ png_data->strip_chunks = NULL;
+ png_data->inject_chunks = NULL;
+
+ png_data->state = PNG_MUX_NULL;
}
int
@@ -118,9 +208,6 @@ metadatamux_png_parse (PngMuxData * png_data, guint8 * buf,
}
- /* JUST UNTIL NOT IMPLEMENTED */
- return 0;
-
while (ret == 0) {
switch (png_data->state) {
case PNG_MUX_READING:
diff --git a/ext/metadata/metadatamuxpng.h b/ext/metadata/metadatamuxpng.h
index 3ae542c4..0e127c88 100644
--- a/ext/metadata/metadatamuxpng.h
+++ b/ext/metadata/metadatamuxpng.h
@@ -64,23 +64,19 @@ typedef struct _tag_PngMuxData
{
PngMuxState state;
- GstAdapter ** xmp_adapter;
-
MetadataChunkArray * strip_chunks;
MetadataChunkArray * inject_chunks;
- guint32 read;
} PngMuxData;
extern void
-metadatamux_png_init (PngMuxData * png_data, GstAdapter ** exif_adpt,
- GstAdapter ** iptc_adpt, GstAdapter ** xmp_adpt,
+metadatamux_png_init (PngMuxData * png_data,
MetadataChunkArray * strip_chunks, MetadataChunkArray * inject_chunks);
extern void metadatamux_png_dispose (PngMuxData * png_data);
-extern void metadatamux_png_lazy_update (PngMuxData * jpeg_data);
+extern void metadatamux_png_lazy_update (PngMuxData * png_data);
int
metadatamux_png_parse (PngMuxData * png_data, guint8 * buf,