This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 72089793bd18d1bcb485401d7f97fabb82b08634 (commit) from dbd7368023249233216d3c6ce873213833f64940 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/72089793bd18d1bcb485401d7f97fabb82b08...
commit 72089793bd18d1bcb485401d7f97fabb82b08634 Author: Cyril Hrubis metan@ucw.cz Date: Sat May 17 22:15:45 2014 +0200
loaders: Convert MetaData loaders to GP_IO
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h index 95123ecd..93cd2df2 100644 --- a/include/loaders/GP_JPG.h +++ b/include/loaders/GP_JPG.h @@ -50,7 +50,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); /* * Loads JPEG meta-data, called markers in JPEG terminology. */ -int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data); +int GP_ReadJPGMetaData(GP_IO *io, GP_MetaData *data); int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data);
/* diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h index 0b440d06..b99e7280 100644 --- a/include/loaders/GP_PNG.h +++ b/include/loaders/GP_PNG.h @@ -48,9 +48,9 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback); GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
/* - * Loads png meta-data. + * Loads PNG meta-data. */ -int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data); +int GP_ReadPNGMetaData(GP_IO *io, GP_MetaData *data); int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data);
/* diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index da4cf48f..e45b23c4 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -184,13 +184,28 @@ static void skip_input_data(struct jpeg_decompress_struct *cinfo, long num_bytes } }
+static inline void init_source_mgr(struct my_source_mgr *src, GP_IO *io, + void *buf, size_t buf_size) +{ + src->mgr.init_source = dummy; + src->mgr.resync_to_restart = jpeg_resync_to_restart; + src->mgr.term_source = dummy; + src->mgr.fill_input_buffer = fill_input_buffer; + src->mgr.skip_input_data = skip_input_data; + src->mgr.bytes_in_buffer = 0; + src->mgr.next_input_byte = NULL; + src->io = io; + src->buffer = buf; + src->size = buf_size; +} + GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback) { struct jpeg_decompress_struct cinfo; struct my_source_mgr src; struct my_jpg_err my_err; GP_Context *ret = NULL; - uint8_t buffer[1024]; + uint8_t buf[1024]; int err;
cinfo.err = jpeg_std_error(&my_err.error_mgr); @@ -202,18 +217,7 @@ GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback) }
jpeg_create_decompress(&cinfo); - - /* Initialize custom source manager */ - src.mgr.init_source = dummy; - src.mgr.resync_to_restart = jpeg_resync_to_restart; - src.mgr.term_source = dummy; - src.mgr.fill_input_buffer = fill_input_buffer; - src.mgr.skip_input_data = skip_input_data; - src.mgr.bytes_in_buffer = 0; - src.mgr.next_input_byte = NULL; - src.io = io; - src.buffer = buffer; - src.size = sizeof(buffer); + init_source_mgr(&src, io, buf, sizeof(buf)); cinfo.src = (void*)&src;
jpeg_read_header(&cinfo, TRUE); @@ -340,10 +344,12 @@ static void save_jpg_markers(struct jpeg_decompress_struct *cinfo) jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff); }
-int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data) +int GP_ReadJPGMetaData(GP_IO *io, GP_MetaData *data) { struct jpeg_decompress_struct cinfo; + struct my_source_mgr src; struct my_jpg_err my_err; + uint8_t buf[1024]; int err;
cinfo.err = jpeg_std_error(&my_err.error_mgr); @@ -355,7 +361,8 @@ int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data) }
jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo, f); + init_source_mgr(&src, io, buf, sizeof(buf)); + cinfo.src = (void*)&src;
save_jpg_markers(&cinfo);
@@ -380,15 +387,18 @@ err1:
int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data) { - //FILE *f; - int ret = -1; + GP_IO *io; + int err, ret;
- //if (GP_OpenJPG(src_path, &f)) - // return 1; + io = GP_IOFile(src_path, GP_IO_RDONLY); + if (!io) + return 1;
- //ret = GP_ReadJPGMetaData(f, data); + ret = GP_ReadJPGMetaData(io, data);
- //fclose(f); + err = errno; + GP_IOClose(io); + errno = err;
return ret; } @@ -567,7 +577,7 @@ GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path), return NULL; }
-int GP_ReadJPGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data)) +int GP_ReadJPGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; return 1; diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 0ea37379..50f5fcdf 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -103,7 +103,6 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback) goto err2; }
- //png_init_io(png, f); png_set_read_fn(png, io, read_data); png_set_sig_bytes(png, 0); png_read_info(png, png_info); @@ -345,7 +344,7 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat } }
-int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data) +int GP_ReadPNGMetaData(GP_IO *io, GP_MetaData *data) { png_structp png; png_infop png_info = NULL; @@ -374,8 +373,8 @@ int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data) goto err2; }
- png_init_io(png, f); - png_set_sig_bytes(png, 8); + png_set_read_fn(png, io, read_data); + png_set_sig_bytes(png, 0); png_read_info(png, png_info);
load_meta_data(png, png_info, data); @@ -390,15 +389,18 @@ err1:
int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data) { - FILE *f; - int ret; + GP_IO *io; + int ret, err;
-// if (GP_OpenPNG(src_path, &f)) -// return 1; + io = GP_IOFile(src_path, GP_IO_RDONLY); + if (!io) + return 1;
- ret = GP_ReadPNGMetaData(f, data); + ret = GP_ReadPNGMetaData(io, data);
- fclose(f); + err = errno; + GP_IOClose(io); + errno = err;
return ret; } @@ -630,7 +632,7 @@ GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path), return NULL; }
-int GP_ReadPNGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data)) +int GP_ReadPNGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; return 1;
-----------------------------------------------------------------------
Summary of changes: include/loaders/GP_JPG.h | 2 +- include/loaders/GP_PNG.h | 4 +- libs/loaders/GP_JPG.c | 54 +++++++++++++++++++++++++++------------------ libs/loaders/GP_PNG.c | 24 +++++++++++--------- 4 files changed, 48 insertions(+), 36 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.