diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2007-12-21 19:01:00 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2007-12-21 19:01:00 +0000 |
commit | 21962cbffe8d7255726b34bfc3a773ffcc3fa43b (patch) | |
tree | 9aba4437a94b989a7fd091c380135bb818d30f49 /ext/metadata/metadatamuxjpeg.c | |
parent | 0f2ac9fe8b5c7f37e61f3eef95299098ce953f1e (diff) | |
download | gst-plugins-bad-21962cbffe8d7255726b34bfc3a773ffcc3fa43b.tar.gz gst-plugins-bad-21962cbffe8d7255726b34bfc3a773ffcc3fa43b.tar.bz2 gst-plugins-bad-21962cbffe8d7255726b34bfc3a773ffcc3fa43b.zip |
Some IPTC tags mapped.
Original commit message from CVS:
Some IPTC tags mapped.
Diffstat (limited to 'ext/metadata/metadatamuxjpeg.c')
-rw-r--r-- | ext/metadata/metadatamuxjpeg.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/ext/metadata/metadatamuxjpeg.c b/ext/metadata/metadatamuxjpeg.c index ffcefcf0..5384f30a 100644 --- a/ext/metadata/metadatamuxjpeg.c +++ b/ext/metadata/metadatamuxjpeg.c @@ -75,6 +75,35 @@ metadatamux_wrap_chunk (MetadataChunk * chunk, const guint8 * buf, } } +#ifdef HAVE_IPTC +static gboolean +metadatamux_wrap_iptc_with_ps3 (unsigned char **buf, unsigned int *buf_size) +{ + unsigned int out_size = *buf_size + 4096; + unsigned char *outbuf = g_new (unsigned char, out_size); + int size_written; + gboolean ret = TRUE; + + size_written = + iptc_jpeg_ps3_save_iptc (NULL, 0, *buf, *buf_size, outbuf, out_size); + + g_free (*buf); + *buf = NULL; + *buf_size = 0; + + if (size_written < 0) { + g_free (outbuf); + ret = FALSE; + } else { + *buf_size = size_written; + *buf = outbuf; + } + + return ret; + +} +#endif /* #ifdef HAVE_IPTC */ + void metadatamux_jpeg_lazy_update (JpegMuxData * jpeg_data) { @@ -93,21 +122,12 @@ metadatamux_jpeg_lazy_update (JpegMuxData * jpeg_data) case MD_CHUNK_IPTC: #ifdef HAVE_IPTC { - unsigned int size = jpeg_data->inject_chunks->chunk[i].size + 256; - unsigned char *buf = g_new (guint8, size); - - size = iptc_jpeg_ps3_save_iptc (NULL, 0, - jpeg_data->inject_chunks->chunk[i].data, - jpeg_data->inject_chunks->chunk[i].size, buf, size); - if (size > 0) { - g_free (jpeg_data->inject_chunks->chunk[i].data); - jpeg_data->inject_chunks->chunk[i].data = buf; - jpeg_data->inject_chunks->chunk[i].size = size; + if (metadatamux_wrap_iptc_with_ps3 (&jpeg_data->inject_chunks-> + chunk[i].data, &jpeg_data->inject_chunks->chunk[i].size)) { metadatamux_wrap_chunk (&jpeg_data->inject_chunks->chunk[i], NULL, 0, 0xFF, 0xED); } else { GST_ERROR ("Invalid IPTC chunk\n"); - g_free (buf); /* FIXME: remove entry from list */ } } @@ -225,7 +245,6 @@ metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, static const char JfifHeader[] = "JFIF"; static const unsigned char ExifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; - static const char IptcHeader[] = "Photoshop 3.0"; static const char XmpHeader[] = "http://ns.adobe.com/xap/1.0/"; *next_start = *buf; |