diff options
Diffstat (limited to 'ext/metadata/metadataparsepng.c')
-rw-r--r-- | ext/metadata/metadataparsepng.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/ext/metadata/metadataparsepng.c b/ext/metadata/metadataparsepng.c index e007e9ed..d0cfa250 100644 --- a/ext/metadata/metadataparsepng.c +++ b/ext/metadata/metadataparsepng.c @@ -46,26 +46,32 @@ #include <string.h> static int -metadataparse_png_reading (PngData * png_data, guint8 ** buf, +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 -metadataparse_png_xmp (PngData * png_data, guint8 ** buf, +metadataparse_png_xmp (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); static int -metadataparse_png_jump (PngData * png_data, guint8 ** buf, +metadataparse_png_jump (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size); #define READ(buf, size) ( (size)--, *((buf)++) ) void -metadataparse_png_init (PngData * png_data, GstAdapter ** exif_adpt, +metadataparse_png_lazy_update (PngParseData * jpeg_data) +{ + /* nothing to do */ +} + +void +metadataparse_png_init (PngParseData * png_data, GstAdapter ** exif_adpt, GstAdapter ** iptc_adpt, GstAdapter ** xmp_adpt, MetadataChunkArray * strip_chunks, MetadataChunkArray * inject_chunks) { - png_data->state = PNG_NULL; + png_data->state = PNG_PARSE_NULL; png_data->xmp_adapter = xmp_adpt; png_data->read = 0; @@ -76,7 +82,7 @@ metadataparse_png_init (PngData * png_data, GstAdapter ** exif_adpt, } void -metadataparse_png_dispose (PngData * png_data) +metadataparse_png_dispose (PngParseData * png_data) { metadataparse_xmp_dispose (); @@ -84,7 +90,7 @@ metadataparse_png_dispose (PngData * png_data) } int -metadataparse_png_parse (PngData * png_data, guint8 * buf, +metadataparse_png_parse (PngParseData * png_data, guint8 * buf, guint32 * bufsize, const guint32 offset, guint8 ** next_start, guint32 * next_size) { @@ -95,7 +101,7 @@ metadataparse_png_parse (PngData * png_data, guint8 * buf, *next_start = buf; - if (png_data->state == PNG_NULL) { + if (png_data->state == PNG_PARSE_NULL) { if (*bufsize < 8) { *next_size = (buf - *next_start) + 8; @@ -119,28 +125,28 @@ metadataparse_png_parse (PngData * png_data, guint8 * buf, goto done; } - png_data->state = PNG_READING; + png_data->state = PNG_PARSE_READING; } while (ret == 0) { switch (png_data->state) { - case PNG_READING: + case PNG_PARSE_READING: ret = metadataparse_png_reading (png_data, &buf, bufsize, offset, step_buf, next_start, next_size); break; - case PNG_JUMPING: + case PNG_PARSE_JUMPING: ret = metadataparse_png_jump (png_data, &buf, bufsize, next_start, next_size); break; - case PNG_XMP: + case PNG_PARSE_XMP: ret = metadataparse_png_xmp (png_data, &buf, bufsize, next_start, next_size); break; - case PNG_DONE: + case PNG_PARSE_DONE: goto done; break; default: @@ -158,7 +164,7 @@ done: /* look for markers */ static int -metadataparse_png_reading (PngData * png_data, guint8 ** buf, +metadataparse_png_reading (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, const guint32 offset, const guint8 * step_buf, guint8 ** next_start, guint32 * next_size) { @@ -189,7 +195,7 @@ metadataparse_png_reading (PngData * png_data, guint8 ** buf, if (mark[0] == 'I' && mark[1] == 'E' && mark[2] == 'N' && mark[3] == 'D') { ret = 0; - png_data->state = PNG_DONE; + png_data->state = PNG_PARSE_DONE; goto done; } @@ -215,7 +221,7 @@ metadataparse_png_reading (PngData * png_data, guint8 ** buf, *buf += 22; /* jump "XML:com.adobe.xmp" plus some flags */ *bufsize -= 22; png_data->read = chunk_size - 22; /* four CRC bytes at the end will be jumped after */ - png_data->state = PNG_XMP; + png_data->state = PNG_PARSE_XMP; ret = 0; goto done; } @@ -225,7 +231,7 @@ metadataparse_png_reading (PngData * png_data, guint8 ** buf, /* just set jump sise */ png_data->read = chunk_size + 4; /* four CRC bytes at the end */ - png_data->state = PNG_JUMPING; + png_data->state = PNG_PARSE_JUMPING; ret = 0; done: @@ -236,16 +242,16 @@ done: } static int -metadataparse_png_jump (PngData * png_data, guint8 ** buf, +metadataparse_png_jump (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { - png_data->state = PNG_READING; + png_data->state = PNG_PARSE_READING; return metadataparse_util_jump_chunk (&png_data->read, buf, bufsize, next_start, next_size); } static int -metadataparse_png_xmp (PngData * png_data, guint8 ** buf, +metadataparse_png_xmp (PngParseData * png_data, guint8 ** buf, guint32 * bufsize, guint8 ** next_start, guint32 * next_size) { int ret; @@ -255,7 +261,7 @@ metadataparse_png_xmp (PngData * png_data, guint8 ** buf, if (ret == 0) { /* jump four CRC bytes at the end of chunk */ png_data->read = 4; - png_data->state = PNG_JUMPING; + png_data->state = PNG_PARSE_JUMPING; /* if there is a second XMP chunk in the file it will be jumped */ png_data->xmp_adapter = NULL; } |