diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2007-11-02 16:50:42 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2007-11-02 16:50:42 +0000 |
commit | f17824d0d1c0c30815cbcf3bcae7997773e367c5 (patch) | |
tree | 39e0b76ca41fae844d906e42bdab3034a3129215 /ext/metadata/metadataparsejpeg.c | |
parent | 05e1fdf681397cc6b3f5ed115cf4e3519272f2b2 (diff) | |
download | gst-plugins-bad-f17824d0d1c0c30815cbcf3bcae7997773e367c5.tar.gz gst-plugins-bad-f17824d0d1c0c30815cbcf3bcae7997773e367c5.tar.bz2 gst-plugins-bad-f17824d0d1c0c30815cbcf3bcae7997773e367c5.zip |
Added support for PNG/XMP. Indentation. And fixed pull mode to parse the file.
Original commit message from CVS:
Added support for PNG/XMP. Indentation. And fixed pull mode to parse the file.
Diffstat (limited to 'ext/metadata/metadataparsejpeg.c')
-rw-r--r-- | ext/metadata/metadataparsejpeg.c | 78 |
1 files changed, 20 insertions, 58 deletions
diff --git a/ext/metadata/metadataparsejpeg.c b/ext/metadata/metadataparsejpeg.c index 753d436a..1a3acb4b 100644 --- a/ext/metadata/metadataparsejpeg.c +++ b/ext/metadata/metadataparsejpeg.c @@ -51,12 +51,6 @@ static int metadataparse_jpeg_reading (JpegData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); - -static int -metadataparse_jpeg_hold_chunk (JpegData * jpeg_data, guint8 ** buf, - guint32 * bufsize, guint8 ** next_start, - guint32 * next_size, GstAdapter ** adapter); - static int metadataparse_jpeg_exif (JpegData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); @@ -245,7 +239,9 @@ metadataparse_jpeg_reading (JpegData * jpeg_data, guint8 ** buf, if (jpeg_data->adpt_xmp) { if (0 == memcmp (XmpHeader, *buf, 29)) { - jpeg_data->read = chunk_size - 2; + *buf += 29; + *bufsize -= 29; + jpeg_data->read = chunk_size - 2 - 29; ret = 0; jpeg_data->state = JPEG_XMP; goto done; @@ -292,43 +288,17 @@ done: } static int -metadataparse_jpeg_hold_chunk (JpegData * jpeg_data, guint8 ** buf, - guint32 * bufsize, guint8 ** next_start, - guint32 * next_size, GstAdapter ** adapter) +metadataparse_jpeg_exif (JpegData * jpeg_data, guint8 ** buf, + guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { int ret; - if (jpeg_data->read > *bufsize) { - *next_start = *buf; - *next_size = jpeg_data->read; - ret = 1; - } else { - GstBuffer *gst_buf; - - if (NULL == *adapter) { - *adapter = gst_adapter_new (); - } - gst_buf = gst_buffer_new_and_alloc (jpeg_data->read); - memcpy (GST_BUFFER_DATA (gst_buf), *buf, jpeg_data->read); - gst_adapter_push (*adapter, gst_buf); - - *next_start = *buf + jpeg_data->read; - *buf += jpeg_data->read; - *bufsize -= jpeg_data->read; + ret = metadataparse_util_hold_chunk (&jpeg_data->read, buf, + bufsize, next_start, next_size, jpeg_data->adpt_exif); + if (ret == 0) { jpeg_data->state = JPEG_READING; - ret = 0; } - return ret; -} - -static int -metadataparse_jpeg_exif (JpegData * jpeg_data, guint8 ** buf, - guint32 * bufsize, guint8 ** next_start, guint32 * next_size) -{ - - return metadataparse_jpeg_hold_chunk (jpeg_data, buf, - bufsize, next_start, next_size, jpeg_data->adpt_exif); } @@ -339,7 +309,7 @@ metadataparse_jpeg_iptc (JpegData * jpeg_data, guint8 ** buf, int ret; - ret = metadataparse_jpeg_hold_chunk (jpeg_data, buf, + ret = metadataparse_util_hold_chunk (&jpeg_data->read, buf, bufsize, next_start, next_size, jpeg_data->adpt_iptc); @@ -350,6 +320,8 @@ metadataparse_jpeg_iptc (JpegData * jpeg_data, guint8 ** buf, unsigned int iptc_len; int res; + jpeg_data->state = JPEG_READING; + size = gst_adapter_available (*jpeg_data->adpt_iptc); buf = gst_adapter_peek (*jpeg_data->adpt_iptc, size); @@ -383,32 +355,22 @@ static int metadataparse_jpeg_xmp (JpegData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { + int ret; - return metadataparse_jpeg_hold_chunk (jpeg_data, buf, + ret = metadataparse_util_hold_chunk (&jpeg_data->read, buf, bufsize, next_start, next_size, jpeg_data->adpt_xmp); + if (ret == 0) { + jpeg_data->state = JPEG_READING; + } + return ret; } static int metadataparse_jpeg_jump (JpegData * jpeg_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { - int ret; - - if (jpeg_data->read > *bufsize) { - jpeg_data->read -= *bufsize; - *next_size = 2; - *next_start = *buf + *bufsize + jpeg_data->read; - jpeg_data->read = 0; - *bufsize = 0; - jpeg_data->state = JPEG_READING; - ret = 1; - } else { - *next_start = *buf + jpeg_data->read; - *buf += jpeg_data->read; - *bufsize -= jpeg_data->read; - jpeg_data->state = JPEG_READING; - ret = 0; - } - return ret; + jpeg_data->state = JPEG_READING; + return metadataparse_util_jump_chunk (&jpeg_data->read, buf, + bufsize, next_start, next_size); } |