diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2007-12-13 17:19:54 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2007-12-13 17:19:54 +0000 |
commit | 7bc241beb0b6dd22f0b6e722174779221ceec5de (patch) | |
tree | 1a867f963d6e131563ae77ae6b8977dee73f71f2 | |
parent | 334b512629cc91ea21b0ae32f0b9b6d980059c18 (diff) | |
download | gst-plugins-bad-7bc241beb0b6dd22f0b6e722174779221ceec5de.tar.gz gst-plugins-bad-7bc241beb0b6dd22f0b6e722174779221ceec5de.tar.bz2 gst-plugins-bad-7bc241beb0b6dd22f0b6e722174779221ceec5de.zip |
Code documentation.
Original commit message from CVS:
Code documentation.
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | ext/metadata/TODO | 18 | ||||
-rw-r--r-- | ext/metadata/gstmetadatamux.c | 42 | ||||
-rw-r--r-- | ext/metadata/gstmetadataparse.c | 30 | ||||
-rw-r--r-- | ext/metadata/metadata.c | 186 | ||||
-rw-r--r-- | ext/metadata/metadata.h | 25 | ||||
-rw-r--r-- | ext/metadata/metadataiptc.c | 3 | ||||
-rw-r--r-- | ext/metadata/metadatamuxjpeg.c | 28 | ||||
-rw-r--r-- | ext/metadata/metadatamuxjpeg.h | 2 | ||||
-rw-r--r-- | ext/metadata/metadatamuxpng.c | 24 | ||||
-rw-r--r-- | ext/metadata/metadatamuxpng.h | 2 | ||||
-rw-r--r-- | ext/metadata/metadataparsejpeg.c | 68 | ||||
-rw-r--r-- | ext/metadata/metadataparsejpeg.h | 2 | ||||
-rw-r--r-- | ext/metadata/metadataparsepng.c | 38 | ||||
-rw-r--r-- | ext/metadata/metadataparsepng.h | 2 | ||||
-rw-r--r-- | ext/metadata/metadataparseutil.c | 12 | ||||
-rw-r--r-- | ext/metadata/metadataparseutil.h | 8 | ||||
-rw-r--r-- | ext/metadata/metadatatypes.h | 10 | ||||
-rw-r--r-- | ext/metadata/metadataxmp.c | 1 |
19 files changed, 326 insertions, 197 deletions
@@ -1,5 +1,27 @@ 2007-12-13 Edgard Lima <edgard.lima@indt.org.br> + * ext/metadata/TODO: + * ext/metadata/gstmetadatamux.c: + * ext/metadata/gstmetadataparse.c: + * ext/metadata/metadata.c: + * ext/metadata/metadata.h: + * ext/metadata/metadataiptc.c: + * ext/metadata/metadatamuxjpeg.c: + * ext/metadata/metadatamuxjpeg.h: + * ext/metadata/metadatamuxpng.c: + * ext/metadata/metadatamuxpng.h: + * ext/metadata/metadataparsejpeg.c: + * ext/metadata/metadataparsejpeg.h: + * ext/metadata/metadataparsepng.c: + * ext/metadata/metadataparsepng.h: + * ext/metadata/metadataparseutil.c: + * ext/metadata/metadataparseutil.h: + * ext/metadata/metadatatypes.h: + * ext/metadata/metadataxmp.c: + Code documentation. + +2007-12-13 Edgard Lima <edgard.lima@indt.org.br> + * configure.ac: * ext/metadata/Makefile.am: * ext/metadata/gstmetadatamux.c: diff --git a/ext/metadata/TODO b/ext/metadata/TODO new file mode 100644 index 00000000..8b51c871 --- /dev/null +++ b/ext/metadata/TODO @@ -0,0 +1,18 @@ + +This file contains a list of things to be done as well some open issues (questions) related to design/implementation. + +TODO: + +1- Add individual tags IPTC and XMP (and more for EXIF) +2- Use GST_TYPE_FRACTION for Rational and SRational (metadataexif.c) +3- Get properties like 'width' and 'height' from caps +4- Review the code (in order to move to gst-plugins-good) +5- Document how the plugin works (atchitecture and interaction beteween modules) + +OPEN ISSUES: + +1- What is (How) the best way to delete some tag? +2- How to change metadata when the orignal image was modified. + ex: file.jpeg has XMP, then we do filesrc ! metadataparse ! jpegdec ! pngenc ! metadatamux ! files + is the metadata still valid? which fields are no valid anymore? + diff --git a/ext/metadata/gstmetadatamux.c b/ext/metadata/gstmetadatamux.c index 953f9cdb..5c1a3bed 100644 --- a/ext/metadata/gstmetadatamux.c +++ b/ext/metadata/gstmetadatamux.c @@ -157,7 +157,7 @@ static gboolean gst_metadata_mux_configure_srccaps (GstMetadataMux * filter); static gboolean gst_metadata_mux_configure_caps (GstMetadataMux * filter); static int -gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf, +gst_metadata_mux_parse (GstMetadataMux * filter, const guint8 * buf, guint32 size); static void gst_metadata_mux_create_chunks_from_tags (GstMetadataMux * filter); @@ -976,11 +976,21 @@ gst_metadata_mux_calculate_offsets (GstMetadataMux * filter) } + +/* + * Do parsing step-by-step and reconfigure caps if need + * return: + * META_PARSING_ERROR + * META_PARSING_DONE + * META_PARSING_NEED_MORE_DATA + */ + static int -gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf, guint32 size) +gst_metadata_mux_parse (GstMetadataMux * filter, const guint8 * buf, + guint32 size) { - int ret = -1; + int ret = META_PARSING_ERROR; filter->next_offset = 0; filter->next_size = 0; @@ -988,14 +998,14 @@ gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf, guint32 size) ret = metadata_parse (&filter->mux_data, buf, size, &filter->next_offset, &filter->next_size); - if (ret < 0) { + if (ret == META_PARSING_ERROR) { if (META_DATA_IMG_TYPE (filter->mux_data) == IMG_NONE) { /* image type not recognized */ GST_ELEMENT_ERROR (filter, STREAM, TYPE_NOT_FOUND, (NULL), ("Only jpeg and png are supported")); goto done; } - } else if (ret > 0) { + } else if (ret == META_PARSING_NEED_MORE_DATA) { filter->need_more_data = TRUE; } else { filter->state = MT_STATE_MUXED; @@ -1009,7 +1019,7 @@ gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf, guint32 size) GST_ELEMENT_ERROR (filter, STREAM, FORMAT, (NULL), ("Couldn't reconfigure caps for %s", gst_metadata_mux_get_type_name (filter->img_type))); - ret = -1; + ret = META_PARSING_ERROR; goto done; } } @@ -1082,8 +1092,11 @@ gst_metadata_mux_chain (GstPad * pad, GstBuffer * buf) const guint8 *new_buf = gst_adapter_peek (filter->adapter_parsing, adpt_size); - if (gst_metadata_mux_mux (filter, new_buf, adpt_size) < 0) + if (gst_metadata_mux_parse (filter, new_buf, + adpt_size) == META_PARSING_ERROR) { + ret = GST_FLOW_ERROR; goto done; + } } } @@ -1098,8 +1111,10 @@ gst_metadata_mux_chain (GstPad * pad, GstBuffer * buf) } if (filter->need_calculate_offset) { - if (!gst_metadata_mux_calculate_offsets (filter)) + if (!gst_metadata_mux_calculate_offsets (filter)) { + ret = GST_FLOW_ERROR; goto done; + } } if (filter->offset_orig + GST_BUFFER_SIZE (buf) == filter->duration_orig) @@ -1188,8 +1203,13 @@ gst_metadata_mux_pull_range_mux (GstMetadataMux * filter) offset += filter->next_offset; + /* 'filter->next_size' only says the minimum required number of bytes. + We try provided more bytes (4096) just to avoid a lot of calls to 'metadata_parse' + returning META_PARSING_NEED_MORE_DATA */ if (filter->next_size < 4096) { if (duration - offset < 4096) { + /* In case there is no 4096 bytes available upstream. + It should be done upstream but we do here for safety */ filter->next_size = duration - offset; } else { filter->next_size = 4096; @@ -1204,16 +1224,16 @@ gst_metadata_mux_pull_range_mux (GstMetadataMux * filter) } res = - gst_metadata_mux_mux (filter, GST_BUFFER_DATA (buf), + gst_metadata_mux_parse (filter, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); - if (res < 0) { + if (res == META_PARSING_ERROR) { ret = FALSE; goto done; } gst_buffer_unref (buf); - } while (res > 0); + } while (res == META_PARSING_NEED_MORE_DATA); done: diff --git a/ext/metadata/gstmetadataparse.c b/ext/metadata/gstmetadataparse.c index a8ded250..d95a9399 100644 --- a/ext/metadata/gstmetadataparse.c +++ b/ext/metadata/gstmetadataparse.c @@ -932,10 +932,11 @@ gst_metadata_parse_calculate_offsets (GstMetadataParse * filter) } /* + * Do parsing step-by-step and reconfigure caps if need * return: - * -1 -> error - * 0 -> succeded - * 1 -> need more data + * META_PARSING_ERROR + * META_PARSING_DONE + * META_PARSING_NEED_MORE_DATA */ static int @@ -943,7 +944,7 @@ gst_metadata_parse_parse (GstMetadataParse * filter, const guint8 * buf, guint32 size) { - int ret = -1; + int ret = META_PARSING_ERROR; filter->next_offset = 0; filter->next_size = 0; @@ -951,14 +952,14 @@ gst_metadata_parse_parse (GstMetadataParse * filter, const guint8 * buf, ret = metadata_parse (&filter->parse_data, buf, size, &filter->next_offset, &filter->next_size); - if (ret < 0) { + if (ret == META_PARSING_ERROR) { if (META_DATA_IMG_TYPE (filter->parse_data) == IMG_NONE) { /* image type not recognized */ GST_ELEMENT_ERROR (filter, STREAM, TYPE_NOT_FOUND, (NULL), ("Only jpeg and png are supported")); goto done; } - } else if (ret > 0) { + } else if (ret == META_PARSING_NEED_MORE_DATA) { filter->need_more_data = TRUE; } else { gst_metadata_parse_calculate_offsets (filter); @@ -968,13 +969,14 @@ gst_metadata_parse_parse (GstMetadataParse * filter, const guint8 * buf, filter->need_send_tag = TRUE; } + /* reconfigure caps if it is different from type detected by 'metadata_parse' function */ if (filter->img_type != META_DATA_IMG_TYPE (filter->parse_data)) { filter->img_type = META_DATA_IMG_TYPE (filter->parse_data); if (!gst_metadata_parse_configure_caps (filter)) { GST_ELEMENT_ERROR (filter, STREAM, FORMAT, (NULL), ("Couldn't reconfigure caps for %s", gst_metadata_parse_get_type_name (filter->img_type))); - ret = -1; + ret = META_PARSING_ERROR; goto done; } } @@ -1047,8 +1049,11 @@ gst_metadata_parse_chain (GstPad * pad, GstBuffer * buf) const guint8 *new_buf = gst_adapter_peek (filter->adapter_parsing, adpt_size); - if (gst_metadata_parse_parse (filter, new_buf, adpt_size) < 0) + if (gst_metadata_parse_parse (filter, new_buf, + adpt_size) == META_PARSING_ERROR) { + ret = GST_FLOW_ERROR; goto done; + } } } @@ -1151,8 +1156,13 @@ gst_metadata_parse_pull_range_parse (GstMetadataParse * filter) offset += filter->next_offset; + /* 'filter->next_size' only says the minimum required number of bytes. + We try provided more bytes (4096) just to avoid a lot of calls to 'metadata_parse' + returning META_PARSING_NEED_MORE_DATA */ if (filter->next_size < 4096) { if (duration - offset < 4096) { + /* In case there is no 4096 bytes available upstream. + It should be done upstream but we do here for safety */ filter->next_size = duration - offset; } else { filter->next_size = 4096; @@ -1169,14 +1179,14 @@ gst_metadata_parse_pull_range_parse (GstMetadataParse * filter) res = gst_metadata_parse_parse (filter, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); - if (res < 0) { + if (res == META_PARSING_ERROR) { ret = FALSE; goto done; } gst_buffer_unref (buf); - } while (res > 0); + } while (res == META_PARSING_NEED_MORE_DATA); done: diff --git a/ext/metadata/metadata.c b/ext/metadata/metadata.c index 0056a51c..4fcd7c1c 100644 --- a/ext/metadata/metadata.c +++ b/ext/metadata/metadata.c @@ -49,16 +49,26 @@ *static declarations */ -static int +static MetadataParsingReturn metadata_parse_none (MetaData * meta_data, const guint8 * buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); /* - * extern implementation + * extern functions implementations */ +/* + * Init metadata handle vars. + * This function must becalled before any other function from this module. + * This functoin must not be called twice without call 'metadata_dispose' + * beteween them. + * meta_data [in]: metadata handler to be inited + * parse [in]: pass TRUE for demuxing and FALSE for muxing + * options [in]: which types of metadata will be processed (EXIF, IPTC and/or XMP). + * Look at 'MetaOption' to see the available options. + */ void -metadata_init (MetaData * meta_data, gboolean parse, guint8 options) +metadata_init (MetaData * meta_data, const gboolean parse, const guint8 options) { meta_data->state = STATE_NULL; meta_data->img_type = IMG_NONE; @@ -70,36 +80,95 @@ metadata_init (MetaData * meta_data, gboolean parse, guint8 options) meta_data->parse = parse; if (parse) { + /* when parsing we will probably strip only 3 chunk (exif, iptc and xmp) + so we use 4 just in case there is more than one chunk of them. + But this is just for convinience, 'cause the chunk_array incriases dinamically */ metadata_chunk_array_init (&meta_data->strip_chunks, 4); + /* at most 1 chunk will be injected (JPEG JFIF) */ metadata_chunk_array_init (&meta_data->inject_chunks, 1); } else { + /* at most 1 chunk will be striped (JPEG JFIF) */ metadata_chunk_array_init (&meta_data->strip_chunks, 1); + /* at most 3 chunk will be injected (EXIF, IPTC, XMP) */ metadata_chunk_array_init (&meta_data->inject_chunks, 3); } } /* - * offset: number of bytes to jump (just a hint to jump a chunk) - * size: number of bytes to read on next call (just a hint to get all chunk) + * Dispose medadata handler data. + * Call this function to free any resource allocated by 'metadata_init' + */ +void +metadata_dispose (MetaData * meta_data) +{ + + switch (meta_data->img_type) { + case IMG_JPEG: + if (G_LIKELY (meta_data->parse)) + metadataparse_jpeg_dispose (&meta_data->format_data.jpeg_parse); + else + metadatamux_jpeg_dispose (&meta_data->format_data.jpeg_mux); + break; + 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); + break; + } + + metadata_chunk_array_free (&meta_data->strip_chunks); + metadata_chunk_array_free (&meta_data->inject_chunks); + + if (meta_data->xmp_adapter) { + gst_object_unref (meta_data->xmp_adapter); + meta_data->xmp_adapter = NULL; + } + + if (meta_data->iptc_adapter) { + gst_object_unref (meta_data->iptc_adapter); + meta_data->iptc_adapter = NULL; + } + + if (meta_data->exif_adapter) { + gst_object_unref (meta_data->exif_adapter); + meta_data->exif_adapter = NULL; + } + +} + +/* + * meta_data [in]: metata handle + * buf [in]: data to be parsed + * bufsize [in]: size of data in bytes + * next_offset [out]: number of bytes to jump from the begining of 'buf' in the next call. + * i.e, 0 (zero) mean that in the next call to function "buf" must have the same + * data (probably resized, see 'size') + * size [out]: number of minimal bytes in buf for the next call to this function * return: - * -1 -> error - * 0 -> done - * 1 -> need more data + * META_PARSING_ERROR + * META_PARSING_DONE + * META_PARSING_NEED_MORE_DATA (look 'next_offset' and 'size') + * when this function returns 0 you have strip and inject chunks ready to use + * If you change the contents of strip and inject chunks, you have to call + * 'metadata_lazy_update' (this is the case when muxing) + * see MetaData->strip_chunks and MetaData->inject_chunks */ -int + +MetadataParsingReturn metadata_parse (MetaData * meta_data, const guint8 * buf, guint32 bufsize, guint32 * next_offset, guint32 * next_size) { - int ret = 0; + int ret = META_PARSING_DONE; guint8 *next_start = (guint8 *) buf; if (meta_data->state == STATE_NULL) { ret = metadata_parse_none (meta_data, buf, &bufsize, &next_start, next_size); - if (ret == 0) + if (ret == META_PARSING_DONE) meta_data->state = STATE_READING; else goto done; @@ -132,7 +201,7 @@ metadata_parse (MetaData * meta_data, const guint8 * buf, break; default: /* unexpected */ - ret = -1; + ret = META_PARSING_ERROR; goto done; break; } @@ -142,63 +211,60 @@ metadata_parse (MetaData * meta_data, const guint8 * buf, done: - if (ret == 0) { + if (ret == META_PARSING_DONE) { meta_data->state = STATE_DONE; } return ret; } +/* + * This function must be called after 'metadata_parse' and after the element has modified the 'segments'. + * This function is really importante in case o muxing 'cause: + * 1- 'cause gives the oportunity to muxers to wrapper new segments with apropriate bytes + * ex: in case of JPEG it can wrap the EXIF chunk (created using tags) with chunk id and chunk size + * 2- 'cause gives the oportunity to muxer to decide if some chunks should still be striped/injected + * ex: if there is no EXIF chunk to be inserted, the muxer decides to not strip JFIF anymore + * see MetaData->strip_chunks and MetaData->inject_chunks + */ + void -metadata_dispose (MetaData * meta_data) +metadata_lazy_update (MetaData * meta_data) { - switch (meta_data->img_type) { case IMG_JPEG: if (G_LIKELY (meta_data->parse)) - metadataparse_jpeg_dispose (&meta_data->format_data.jpeg_parse); + metadataparse_jpeg_lazy_update (&meta_data->format_data.jpeg_parse); else - metadatamux_jpeg_dispose (&meta_data->format_data.jpeg_mux); + metadatamux_jpeg_lazy_update (&meta_data->format_data.jpeg_mux); break; case IMG_PNG: if (G_LIKELY (meta_data->parse)) - metadataparse_png_dispose (&meta_data->format_data.png_parse); + metadataparse_png_lazy_update (&meta_data->format_data.png_parse); else - metadatamux_png_dispose (&meta_data->format_data.png_mux); + metadatamux_png_lazy_update (&meta_data->format_data.png_mux); + break; + default: + /* unexpected */ break; - } - - metadata_chunk_array_free (&meta_data->strip_chunks); - metadata_chunk_array_free (&meta_data->inject_chunks); - - if (meta_data->xmp_adapter) { - gst_object_unref (meta_data->xmp_adapter); - meta_data->xmp_adapter = NULL; - } - - if (meta_data->iptc_adapter) { - gst_object_unref (meta_data->iptc_adapter); - meta_data->iptc_adapter = NULL; - } - - if (meta_data->exif_adapter) { - gst_object_unref (meta_data->exif_adapter); - meta_data->exif_adapter = NULL; } } + /* - * static implementation + * static functions implementation */ -/* find image type */ -static int +/* + * Find out the type of the stream + */ +static MetadataParsingReturn metadata_parse_none (MetaData * meta_data, const guint8 * buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { - int ret = -1; + int ret = META_PARSING_ERROR; GstAdapter **exif = NULL; GstAdapter **iptc = NULL; GstAdapter **xmp = NULL; @@ -207,9 +273,15 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf, meta_data->img_type = IMG_NONE; + /* + * Be sure of add checking for more types in order from the + * less to more bytes need to detect the stream type. + */ + + /* we need at least 3 bytes to see if it is JPEG */ if (*bufsize < 3) { *next_size = 3; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -227,14 +299,15 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf, else metadatamux_jpeg_init (&meta_data->format_data.jpeg_mux, &meta_data->strip_chunks, &meta_data->inject_chunks); - ret = 0; + ret = META_PARSING_DONE; meta_data->img_type = IMG_JPEG; goto done; } + /* we need at least 8 bytes to see if it is PNG */ if (*bufsize < 8) { *next_size = 8; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -246,7 +319,7 @@ metadata_parse_none (MetaData * meta_data, const guint8 * buf, else metadatamux_png_init (&meta_data->format_data.png_mux, &meta_data->strip_chunks, &meta_data->inject_chunks); - ret = 0; + ret = META_PARSING_DONE; meta_data->img_type = IMG_PNG; goto done; } @@ -255,26 +328,3 @@ done: return ret; } - -void -metadata_lazy_update (MetaData * meta_data) -{ - switch (meta_data->img_type) { - case IMG_JPEG: - if (G_LIKELY (meta_data->parse)) - metadataparse_jpeg_lazy_update (&meta_data->format_data.jpeg_parse); - else - metadatamux_jpeg_lazy_update (&meta_data->format_data.jpeg_mux); - break; - 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); - break; - default: - /* unexpected */ - break; - } - -} diff --git a/ext/metadata/metadata.h b/ext/metadata/metadata.h index 735981fa..2a5329a6 100644 --- a/ext/metadata/metadata.h +++ b/ext/metadata/metadata.h @@ -54,13 +54,16 @@ G_BEGIN_DECLS +/* *INDENT-OFF* */ + typedef enum _tag_MetaOption { META_OPT_EXIF = (1 << 0), META_OPT_IPTC = (1 << 1), - META_OPT_XMP = (1 << 2), - META_OPT_ALL = (1 << 3) - 1 + META_OPT_XMP = (1 << 2), + META_OPT_ALL = (1 << 3) - 1 } MetaOption; +/* *INDENT-ON* */ typedef enum _tag_MetaState { @@ -102,26 +105,16 @@ typedef struct _tag_MetaData #define META_DATA_IMG_TYPE(p) (p).img_type -extern void metadata_init (MetaData * meta_data, gboolean parse, guint8 options); +extern void metadata_init (MetaData * meta_data, const gboolean parse, const guint8 options); -/* - * offset: number of bytes that MUST be jumped after current "buf" pointer - * next_size: number of minimum amount of bytes required on next step. - * if less than this is provided, the return will be 1 for sure. - * and the offset will be 0 (zero) - * return: - * -1 -> error - * 0 -> done - * 1 -> need more data - */ -extern int +extern void metadata_dispose (MetaData * meta_data); + +extern MetadataParsingReturn metadata_parse (MetaData * meta_data, const guint8 * buf, guint32 bufsize, guint32 * next_offset, guint32 * next_size); extern void metadata_lazy_update (MetaData * meta_data); -extern void metadata_dispose (MetaData * meta_data); - G_END_DECLS #endif /* __METADATA_H__ */ diff --git a/ext/metadata/metadataiptc.c b/ext/metadata/metadataiptc.c index 1e570b5f..b052d329 100644 --- a/ext/metadata/metadataiptc.c +++ b/ext/metadata/metadataiptc.c @@ -75,6 +75,7 @@ metadatamux_iptc_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, #else /* ifndef HAVE_IPTC */ #include <iptc-data.h> +#include <string.h> static void iptc_data_foreach_dataset_func (IptcDataSet * dataset, void *user_data); @@ -122,7 +123,7 @@ static void iptc_data_foreach_dataset_func (IptcDataSet * dataset, void *user_data) { - char *buf[256]; + char buf[256]; GstTagList *taglist = (GstTagList *) user_data; GST_LOG ("name -> %s", iptc_tag_get_name (dataset->record, dataset->tag)); diff --git a/ext/metadata/metadatamuxjpeg.c b/ext/metadata/metadatamuxjpeg.c index 74b7ad19..ffcefcf0 100644 --- a/ext/metadata/metadatamuxjpeg.c +++ b/ext/metadata/metadatamuxjpeg.c @@ -49,7 +49,7 @@ #include <libiptcdata/iptc-jpeg.h> #endif -static int +static MetadataParsingReturn metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size); @@ -153,13 +153,13 @@ metadatamux_jpeg_dispose (JpegMuxData * jpeg_data) jpeg_data->state = JPEG_MUX_NULL; } -int +MetadataParsingReturn metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size) { - int ret = 0; + int ret = META_PARSING_DONE; guint8 mark[2] = { 0x00, 0x00 }; const guint8 *step_buf = buf; @@ -169,7 +169,7 @@ metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, if (*bufsize < 2) { *next_size = (buf - *next_start) + 2; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -177,7 +177,7 @@ metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, mark[1] = READ (buf, *bufsize); if (mark[0] != 0xFF || mark[1] != 0xD8) { - ret = -1; + ret = META_PARSING_ERROR; goto done; } @@ -185,7 +185,7 @@ metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, } - while (ret == 0) { + while (ret == META_PARSING_DONE) { switch (jpeg_data->state) { case JPEG_MUX_READING: ret = @@ -196,7 +196,7 @@ metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, goto done; break; default: - ret = -1; + ret = META_PARSING_ERROR; break; } } @@ -209,13 +209,13 @@ done: /* look for markers */ -static int +static MetadataParsingReturn metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size) { - int ret = -1; + int ret = META_PARSING_ERROR; guint8 mark[2] = { 0x00, 0x00 }; guint16 chunk_size = 0; gint64 new_chunk_offset = 0; @@ -232,7 +232,7 @@ metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, if (*bufsize < 2) { *next_size = (*buf - *next_start) + 2; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -249,7 +249,7 @@ metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, if (chunk_size >= 16) { if (*bufsize < 5) { *next_size = (*buf - *next_start) + 5; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -263,7 +263,7 @@ metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, } if (!jfif_found) { - ret = -1; + ret = META_PARSING_ERROR; goto done; } @@ -305,11 +305,11 @@ metadatamux_jpeg_reading (JpegMuxData * jpeg_data, guint8 ** buf, metadata_chunk_array_append_sorted (jpeg_data->inject_chunks, &chunk); jpeg_data->state = JPEG_MUX_DONE; - ret = 0; + ret = META_PARSING_DONE; } else { /* invalid JPEG chunk */ - ret = -1; + ret = META_PARSING_ERROR; } diff --git a/ext/metadata/metadatamuxjpeg.h b/ext/metadata/metadatamuxjpeg.h index f07f018b..f57b7df6 100644 --- a/ext/metadata/metadatamuxjpeg.h +++ b/ext/metadata/metadatamuxjpeg.h @@ -76,7 +76,7 @@ extern void metadatamux_jpeg_dispose (JpegMuxData * jpeg_data); extern void metadatamux_jpeg_lazy_update (JpegMuxData * jpeg_data); -int +extern MetadataParsingReturn metadatamux_jpeg_parse (JpegMuxData * jpeg_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size); diff --git a/ext/metadata/metadatamuxpng.c b/ext/metadata/metadatamuxpng.c index 8aa17383..ac8e86bb 100644 --- a/ext/metadata/metadatamuxpng.c +++ b/ext/metadata/metadatamuxpng.c @@ -45,7 +45,7 @@ #include <string.h> -static int +static MetadataParsingReturn metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size); @@ -168,13 +168,13 @@ metadatamux_png_dispose (PngMuxData * png_data) png_data->state = PNG_MUX_NULL; } -int +MetadataParsingReturn metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size) { - int ret = 0; + int ret = META_PARSING_DONE; guint8 mark[8]; const guint8 *step_buf = buf; @@ -184,7 +184,7 @@ metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, if (*bufsize < 8) { *next_size = (buf - *next_start) + 8; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -200,7 +200,7 @@ metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, if (mark[0] != 0x89 || mark[1] != 0x50 || mark[2] != 0x4E || mark[3] != 0x47 || mark[4] != 0x0D || mark[5] != 0x0A || mark[6] != 0x1A || mark[7] != 0x0A) { - ret = -1; + ret = META_PARSING_ERROR; goto done; } @@ -208,7 +208,7 @@ metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, } - while (ret == 0) { + while (ret == META_PARSING_DONE) { switch (png_data->state) { case PNG_MUX_READING: ret = @@ -219,7 +219,7 @@ metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, goto done; break; default: - ret = -1; + ret = META_PARSING_ERROR; break; } } @@ -232,13 +232,13 @@ done: /* look for markers */ -static int +static MetadataParsingReturn metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size) { - int ret = -1; + int ret = META_PARSING_ERROR; guint8 mark[4]; guint32 chunk_size = 0; MetadataChunk chunk; @@ -249,7 +249,7 @@ metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf, if (*bufsize < 8) { *next_size = (*buf - *next_start) + 8; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -264,7 +264,7 @@ metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf, mark[3] = READ (*buf, *bufsize); if (!(mark[0] == 'I' && mark[1] == 'H' && mark[2] == 'D' && mark[3] == 'R')) { - ret = -1; + ret = META_PARSING_ERROR; png_data->state = PNG_MUX_NULL; goto done; } @@ -279,7 +279,7 @@ metadatamux_png_reading (PngMuxData * png_data, guint8 ** buf, metadata_chunk_array_append_sorted (png_data->inject_chunks, &chunk); png_data->state = PNG_MUX_DONE; - ret = 0; + ret = META_PARSING_DONE; done: diff --git a/ext/metadata/metadatamuxpng.h b/ext/metadata/metadatamuxpng.h index 0e127c88..96eb7bd2 100644 --- a/ext/metadata/metadatamuxpng.h +++ b/ext/metadata/metadatamuxpng.h @@ -78,7 +78,7 @@ extern void metadatamux_png_dispose (PngMuxData * png_data); extern void metadatamux_png_lazy_update (PngMuxData * png_data); -int +extern MetadataParsingReturn metadatamux_png_parse (PngMuxData * png_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size); diff --git a/ext/metadata/metadataparsejpeg.c b/ext/metadata/metadataparsejpeg.c index 541f7d7d..54d9b26d 100644 --- a/ext/metadata/metadataparsejpeg.c +++ b/ext/metadata/metadataparsejpeg.c @@ -49,26 +49,26 @@ #include <libiptcdata/iptc-jpeg.h> #endif -static int +static MetadataParsingReturn metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size); -static int +static MetadataParsingReturn metadataparse_jpeg_exif (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); #ifdef HAVE_IPTC -static int +static MetadataParsingReturn metadataparse_jpeg_iptc (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); #endif -static int +static MetadataParsingReturn metadataparse_jpeg_xmp (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); -static int +static MetadataParsingReturn metadataparse_jpeg_jump (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); @@ -105,13 +105,13 @@ metadataparse_jpeg_dispose (JpegParseData * jpeg_data) jpeg_data->xmp_adapter = NULL; } -int +MetadataParsingReturn metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size) { - int ret = 0; + int ret = META_PARSING_DONE; guint8 mark[2] = { 0x00, 0x00 }; const guint8 *step_buf = buf; @@ -121,7 +121,7 @@ metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, if (*bufsize < 2) { *next_size = (buf - *next_start) + 2; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -129,7 +129,7 @@ metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, mark[1] = READ (buf, *bufsize); if (mark[0] != 0xFF || mark[1] != 0xD8) { - ret = -1; + ret = META_PARSING_ERROR; goto done; } @@ -137,7 +137,7 @@ metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, } - while (ret == 0) { + while (ret == META_PARSING_DONE) { switch (jpeg_data->state) { case JPEG_PARSE_READING: ret = @@ -170,7 +170,7 @@ metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, goto done; break; default: - ret = -1; + ret = META_PARSING_ERROR; break; } } @@ -183,13 +183,13 @@ done: /* look for markers */ -static int +static MetadataParsingReturn metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size) { - int ret = -1; + int ret = META_PARSING_ERROR; guint8 mark[2] = { 0x00, 0x00 }; guint16 chunk_size = 0; @@ -203,7 +203,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (*bufsize < 2) { *next_size = (*buf - *next_start) + 2; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -212,18 +212,18 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (mark[0] == 0xFF) { if (mark[1] == 0xD9) { /* end of image */ - ret = 0; + ret = META_PARSING_DONE; jpeg_data->state = JPEG_PARSE_DONE; goto done; } else if (mark[1] == 0xDA) { /* start of scan, lets not look behinf of this */ - ret = 0; + ret = META_PARSING_DONE; jpeg_data->state = JPEG_PARSE_DONE; goto done; } if (*bufsize < 2) { *next_size = (*buf - *next_start) + 2; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -235,7 +235,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (chunk_size >= 16) { if (*bufsize < 14) { *next_size = (*buf - *next_start) + 14; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -251,7 +251,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (*bufsize < 6) { *next_size = (*buf - *next_start) + 6; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -292,14 +292,14 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, jpeg_data->read = chunk_size - 2; jpeg_data->state = JPEG_PARSE_EXIF; - ret = 0; + ret = META_PARSING_DONE; goto done; } } if (chunk_size >= 31) { /* size2 "http://ns.adobe.com/xap/1.0/" */ if (*bufsize < 29) { *next_size = (*buf - *next_start) + 29; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -320,7 +320,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, *bufsize -= 29; jpeg_data->read = chunk_size - 2 - 29; jpeg_data->state = JPEG_PARSE_XMP; - ret = 0; + ret = META_PARSING_DONE; goto done; } } @@ -333,7 +333,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (*bufsize < 14) { *next_size = (*buf - *next_start) + 14; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -352,7 +352,7 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, if (jpeg_data->iptc_adapter) { jpeg_data->read = chunk_size - 2; jpeg_data->state = JPEG_PARSE_IPTC; - ret = 0; + ret = META_PARSING_DONE; goto done; } } @@ -363,11 +363,11 @@ metadataparse_jpeg_reading (JpegParseData * jpeg_data, guint8 ** buf, /* just set jump sise */ jpeg_data->read = chunk_size - 2; jpeg_data->state = JPEG_PARSE_JUMPING; - ret = 0; + ret = META_PARSING_DONE; } else { /* invalid JPEG chunk */ - ret = -1; + ret = META_PARSING_ERROR; } @@ -378,7 +378,7 @@ done: } -static int +static MetadataParsingReturn metadataparse_jpeg_exif (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -386,7 +386,7 @@ metadataparse_jpeg_exif (JpegParseData * jpeg_data, guint8 ** buf, ret = metadataparse_util_hold_chunk (&jpeg_data->read, buf, bufsize, next_start, next_size, jpeg_data->exif_adapter); - if (ret == 0) { + if (ret == META_PARSING_DONE) { jpeg_data->state = JPEG_PARSE_READING; @@ -398,7 +398,7 @@ metadataparse_jpeg_exif (JpegParseData * jpeg_data, guint8 ** buf, } #ifdef HAVE_IPTC -static int +static MetadataParsingReturn metadataparse_jpeg_iptc (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -409,7 +409,7 @@ metadataparse_jpeg_iptc (JpegParseData * jpeg_data, guint8 ** buf, bufsize, next_start, next_size, jpeg_data->iptc_adapter); - if (ret == 0) { + if (ret == META_PARSING_DONE) { const guint8 *buf; guint32 size; @@ -425,7 +425,7 @@ metadataparse_jpeg_iptc (JpegParseData * jpeg_data, guint8 ** buf, if (res < 0) { /* error */ - ret = -1; + ret = META_PARSING_ERROR; } else if (res == 0) { /* no iptc data found */ gst_adapter_clear (*jpeg_data->iptc_adapter); @@ -451,7 +451,7 @@ metadataparse_jpeg_iptc (JpegParseData * jpeg_data, guint8 ** buf, } #endif -static int +static MetadataParsingReturn metadataparse_jpeg_xmp (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -460,7 +460,7 @@ metadataparse_jpeg_xmp (JpegParseData * jpeg_data, guint8 ** buf, ret = metadataparse_util_hold_chunk (&jpeg_data->read, buf, bufsize, next_start, next_size, jpeg_data->xmp_adapter); - if (ret == 0) { + if (ret == META_PARSING_DONE) { jpeg_data->state = JPEG_PARSE_READING; /* if there is a second XMP chunk in the file it will be jumped */ jpeg_data->xmp_adapter = NULL; @@ -468,7 +468,7 @@ metadataparse_jpeg_xmp (JpegParseData * jpeg_data, guint8 ** buf, return ret; } -static int +static MetadataParsingReturn metadataparse_jpeg_jump (JpegParseData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { diff --git a/ext/metadata/metadataparsejpeg.h b/ext/metadata/metadataparsejpeg.h index e5cd065e..d4e6bcdd 100644 --- a/ext/metadata/metadataparsejpeg.h +++ b/ext/metadata/metadataparsejpeg.h @@ -87,7 +87,7 @@ extern void metadataparse_jpeg_dispose (JpegParseData * jpeg_data); extern void metadataparse_jpeg_lazy_update (JpegParseData * jpeg_data); -int +extern MetadataParsingReturn metadataparse_jpeg_parse (JpegParseData * jpeg_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size); diff --git a/ext/metadata/metadataparsepng.c b/ext/metadata/metadataparsepng.c index be5bb85b..32595ad4 100644 --- a/ext/metadata/metadataparsepng.c +++ b/ext/metadata/metadataparsepng.c @@ -45,16 +45,16 @@ #include <string.h> -static int +static MetadataParsingReturn metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size); -static int +static MetadataParsingReturn metadataparse_png_xmp (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); -static int +static MetadataParsingReturn metadataparse_png_jump (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); @@ -86,13 +86,13 @@ metadataparse_png_dispose (PngParseData * png_data) png_data->xmp_adapter = NULL; } -int +MetadataParsingReturn metadataparse_png_parse (PngParseData * png_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size) { - int ret = 0; + int ret = META_PARSING_DONE; guint8 mark[8]; const guint8 *step_buf = buf; @@ -102,7 +102,7 @@ metadataparse_png_parse (PngParseData * png_data, guint8 * buf, if (*bufsize < 8) { *next_size = (buf - *next_start) + 8; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -118,7 +118,7 @@ metadataparse_png_parse (PngParseData * png_data, guint8 * buf, if (mark[0] != 0x89 || mark[1] != 0x50 || mark[2] != 0x4E || mark[3] != 0x47 || mark[4] != 0x0D || mark[5] != 0x0A || mark[6] != 0x1A || mark[7] != 0x0A) { - ret = -1; + ret = META_PARSING_ERROR; goto done; } @@ -126,7 +126,7 @@ metadataparse_png_parse (PngParseData * png_data, guint8 * buf, } - while (ret == 0) { + while (ret == META_PARSING_DONE) { switch (png_data->state) { case PNG_PARSE_READING: ret = @@ -147,7 +147,7 @@ metadataparse_png_parse (PngParseData * png_data, guint8 * buf, goto done; break; default: - ret = -1; + ret = META_PARSING_ERROR; break; } } @@ -160,13 +160,13 @@ done: /* look for markers */ -static int +static MetadataParsingReturn metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size) { - int ret = -1; + int ret = META_PARSING_ERROR; guint8 mark[4]; guint32 chunk_size = 0; @@ -176,7 +176,7 @@ metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, if (*bufsize < 8) { *next_size = (*buf - *next_start) + 8; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -191,7 +191,7 @@ metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, mark[3] = READ (*buf, *bufsize); if (mark[0] == 'I' && mark[1] == 'E' && mark[2] == 'N' && mark[3] == 'D') { - ret = 0; + ret = META_PARSING_DONE; png_data->state = PNG_PARSE_DONE; goto done; } @@ -200,7 +200,7 @@ metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, if (chunk_size >= 22) { /* "XML:com.adobe.xmp" plus some flags */ if (*bufsize < 22) { *next_size = (*buf - *next_start) + 22; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; goto done; } @@ -220,7 +220,7 @@ metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, *bufsize -= 22; png_data->read = chunk_size - 22; /* four CRC bytes at the end will be jumped after */ png_data->state = PNG_PARSE_XMP; - ret = 0; + ret = META_PARSING_DONE; goto done; } } @@ -230,7 +230,7 @@ metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, /* just set jump sise */ png_data->read = chunk_size + 4; /* four CRC bytes at the end */ png_data->state = PNG_PARSE_JUMPING; - ret = 0; + ret = META_PARSING_DONE; done: @@ -239,7 +239,7 @@ done: } -static int +static MetadataParsingReturn metadataparse_png_jump (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -248,7 +248,7 @@ metadataparse_png_jump (PngParseData * png_data, guint8 ** buf, bufsize, next_start, next_size); } -static int +static MetadataParsingReturn metadataparse_png_xmp (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -256,7 +256,7 @@ metadataparse_png_xmp (PngParseData * png_data, guint8 ** buf, ret = metadataparse_util_hold_chunk (&png_data->read, buf, bufsize, next_start, next_size, png_data->xmp_adapter); - if (ret == 0) { + if (ret == META_PARSING_DONE) { /* jump four CRC bytes at the end of chunk */ png_data->read = 4; png_data->state = PNG_PARSE_JUMPING; diff --git a/ext/metadata/metadataparsepng.h b/ext/metadata/metadataparsepng.h index a0876d02..224b48f7 100644 --- a/ext/metadata/metadataparsepng.h +++ b/ext/metadata/metadataparsepng.h @@ -82,7 +82,7 @@ extern void metadataparse_png_dispose (PngParseData * png_data); extern void metadataparse_png_lazy_update (PngParseData * jpeg_data); -int +extern MetadataParsingReturn metadataparse_png_parse (PngParseData * png_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size); diff --git a/ext/metadata/metadataparseutil.c b/ext/metadata/metadataparseutil.c index ff1b8826..845c125b 100644 --- a/ext/metadata/metadataparseutil.c +++ b/ext/metadata/metadataparseutil.c @@ -63,7 +63,7 @@ metadataparse_util_tag_list_add_chunk (GstTagList * taglist, } -int +MetadataParsingReturn metadataparse_util_hold_chunk (guint32 * read, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size, GstAdapter ** adapter) @@ -73,7 +73,7 @@ metadataparse_util_hold_chunk (guint32 * read, guint8 ** buf, if (*read > *bufsize) { *next_start = *buf; *next_size = *read; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; } else { GstBuffer *gst_buf; @@ -88,13 +88,13 @@ metadataparse_util_hold_chunk (guint32 * read, guint8 ** buf, *buf += *read; *bufsize -= *read; *read = 0; - ret = 0; + ret = META_PARSING_DONE; } return ret; } -int +MetadataParsingReturn metadataparse_util_jump_chunk (guint32 * read, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { @@ -106,13 +106,13 @@ metadataparse_util_jump_chunk (guint32 * read, guint8 ** buf, *next_start = *buf + *bufsize + *read; *read = 0; *bufsize = 0; - ret = 1; + ret = META_PARSING_NEED_MORE_DATA; } else { *next_start = *buf + *read; *buf += *read; *bufsize -= *read; *read = 0; - ret = 0; + ret = META_PARSING_DONE; } return ret; } diff --git a/ext/metadata/metadataparseutil.h b/ext/metadata/metadataparseutil.h index 5d49b54b..1dac942c 100644 --- a/ext/metadata/metadataparseutil.h +++ b/ext/metadata/metadataparseutil.h @@ -47,16 +47,20 @@ #include <gst/gst.h> #include <gst/base/gstadapter.h> +#include "metadatatypes.h" + G_BEGIN_DECLS extern void metadataparse_util_tag_list_add_chunk (GstTagList * taglist, GstTagMergeMode mode, const gchar * name, GstAdapter * adapter); -extern int metadataparse_util_hold_chunk (guint32 * read, guint8 ** buf, + +extern MetadataParsingReturn +metadataparse_util_hold_chunk (guint32 * read, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size, GstAdapter ** adapter); -extern int +extern MetadataParsingReturn metadataparse_util_jump_chunk (guint32 * read, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); diff --git a/ext/metadata/metadatatypes.h b/ext/metadata/metadatatypes.h index f3d17d2f..d58d23b4 100644 --- a/ext/metadata/metadatatypes.h +++ b/ext/metadata/metadatatypes.h @@ -48,6 +48,16 @@ G_BEGIN_DECLS +/* *INDENT-OFF* */ + +typedef enum _tag_MetadataParsingReturn { + META_PARSING_ERROR = -1, + META_PARSING_DONE = 0, + META_PARSING_NEED_MORE_DATA = 1 +} MetadataParsingReturn; + +/* *INDENT-ON* */ + typedef enum _tag_MetadataChunkType { MD_CHUNK_UNKNOWN, MD_CHUNK_EXIF, diff --git a/ext/metadata/metadataxmp.c b/ext/metadata/metadataxmp.c index 949300a0..56c3ad87 100644 --- a/ext/metadata/metadataxmp.c +++ b/ext/metadata/metadataxmp.c @@ -84,6 +84,7 @@ metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, #else /* ifndef HAVE_XMP */ #include <xmp.h> +#include <string.h> #define XMP_SCHEMA_NODE 0x80000000UL |