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 7d6a3c37a8066eaae2a5c3a913c9ee53768ea677 (commit) via c34bb360259398f9984c827153c53b5d35821ca2 (commit) via df6de85ac91e6206be01f513951a04df2eee0833 (commit) via 41bce152b73f2401ac8f5f8505e1be2e4ccb6ef2 (commit) via b6cbcf6d7265335c20d6dc268160aac84d5af3aa (commit) from 3a23d37e9e2fc63f02435221e96cef601b5ce2ed (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/7d6a3c37a8066eaae2a5c3a913c9ee53768ea...
commit 7d6a3c37a8066eaae2a5c3a913c9ee53768ea677 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jul 20 00:01:48 2013 +0200
spiv: A bit crude support for containers.
* Mostly works, needs better implementation though
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c index 7852fc6..ae4ac6d 100644 --- a/demos/spiv/image_loader.c +++ b/demos/spiv/image_loader.c @@ -20,6 +20,8 @@ * * *****************************************************************************/
+#include <errno.h> + #include <core/GP_Context.h> #include <core/GP_Debug.h>
@@ -33,6 +35,7 @@ static struct image_cache *img_cache; static struct image_list *img_list; static GP_Context *cur_img; +static GP_Container *cur_cont;
int image_loader_init(const char *args[], unsigned int cache_max_bytes) { @@ -58,10 +61,16 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate) struct cpu_timer timer; const char *path; GP_Context *img; + int err;
if (cur_img) return cur_img;
+ if (cur_cont) { + cur_img = GP_ContainerLoad(cur_cont, callback); + return cur_img; + } + path = image_list_img_path(img_list);
cur_img = image_cache_get(img_cache, elevate, path); @@ -73,8 +82,31 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
img = GP_LoadImage(path, callback);
- if (!img) + if (!img) { + err = errno; + + /* + * Try containers, ZIP for now, more to come + * + * TODO: How to cache container content? + */ + cur_cont = GP_OpenZip(path); + + if (cur_cont) { + img = GP_ContainerLoad(cur_cont, callback); + + if (img) { + cur_img = img; + return img; + } + + GP_ContainerClose(cur_cont); + cur_cont = NULL; + } + + errno = err; return NULL; + }
image_cache_put(img_cache, img, path);
@@ -85,6 +117,15 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
const char *image_loader_img_path(void) { + //TODO: Make this more elegant + static char path[512]; + + if (cur_cont) { + snprintf(path, sizeof(path), "%s:%u", + image_list_img_path(img_list), cur_cont->cur_img); + return path; + } + return image_list_img_path(img_list); }
@@ -112,6 +153,36 @@ void image_loader_seek(enum img_seek_offset offset, int whence) { drop_cur_img();
+ if (cur_cont) { + switch (offset) { + case IMG_FIRST: + case IMG_LAST: + //TODO do something better for IMG_DIR + case IMG_DIR: + GP_ContainerClose(cur_cont); + cur_cont = NULL; + goto list_seek; + case IMG_CUR: + break; + } + /* + * TODO: We should be able to count how much + * we get out of the container and seek + * N images in the list + * + * What about wrapping around? + */ + if (GP_ContainerSeek(cur_cont, whence, GP_CONT_CUR)) { + GP_ContainerClose(cur_cont); + cur_cont = NULL; + goto list_seek; + } + + return; + } + +list_seek: + switch (offset) { case IMG_FIRST: image_list_first(img_list); diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 96eda04..6d0cf85 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -570,6 +570,12 @@ static void show_image(struct loader_params *params) static void image_seek(struct loader_params *params, enum img_seek_offset offset, int whence) { + /* + * We need to stop loader first because image loader seek may free + * image we are currently resamling. + */ + stop_loader(); + image_loader_seek(offset, whence); show_image(params); }
http://repo.or.cz/w/gfxprim.git/commit/c34bb360259398f9984c827153c53b5d35821...
commit c34bb360259398f9984c827153c53b5d35821ca2 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jul 19 23:44:46 2013 +0200
build: Update list of exported symbols.
Add TIFFSave() + Container + ZIP container API.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt index 9820d2f..1814807 100644 --- a/build/syms/Loaders_symbols.txt +++ b/build/syms/Loaders_symbols.txt @@ -37,6 +37,7 @@ GP_MatchTIFF GP_OpenTIFF GP_ReadTIFF GP_LoadTIFF +GP_SaveTIFF
GP_SavePBM GP_LoadPBM @@ -79,3 +80,9 @@ GP_MetaDataCreate GP_MetaDataPrint GP_MetaDataGetDouble GP_MetaDataFromExif + +GP_ContainerLoad +GP_ContainerSeek + +GP_MatchZip +GP_OpenZip
http://repo.or.cz/w/gfxprim.git/commit/df6de85ac91e6206be01f513951a04df2eee0...
commit df6de85ac91e6206be01f513951a04df2eee0833 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jul 19 23:42:24 2013 +0200
loaders: Containers, ZIP: More work done.
* Add ZIP signature matching function
* Add basic seek API + Code (not finished, yet but mostly working)
* ZIP: fix loading for uncompressed parts
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/loaders/GP_Container.h b/include/loaders/GP_Container.h index 36dafdf..d3e9d0f 100644 --- a/include/loaders/GP_Container.h +++ b/include/loaders/GP_Container.h @@ -35,6 +35,12 @@
struct GP_Container;
+enum GP_ContainerWhence { + GP_CONT_FIRST, + GP_CONT_LAST, + GP_CONT_CUR, +}; + struct GP_ContainerOps { /* * Loads next image from container, use the inline function defined @@ -44,11 +50,28 @@ struct GP_ContainerOps { GP_ProgressCallback *callback);
/* + * Just loads current image, does not advance to the next image. + */ + GP_Context *(*Load)(struct GP_Container *self, + GP_ProgressCallback *callback); + + /* * Close callback, use the inline function defined bellow. */ void (*Close)(struct GP_Container *self);
- //TODO: Seek + /* + * Seeks to the offset from whence. + * + * Returns 0 on success, errno on failure. + */ + int (*Seek)(struct GP_Container *self, int offset, + enum GP_ContainerWhence whence); + + /* + * Container type name. + */ + const char *type; };
typedef struct GP_Container { @@ -57,12 +80,16 @@ typedef struct GP_Container { * of images in container is not known prior to parsing the whole * file. */ - int img_count; + unsigned int img_count; + /* * Current image counter, do not change from application. */ - int cur_img; + unsigned int cur_img;
+ /* + * Contains container callbacks + */ const struct GP_ContainerOps *ops;
char priv[]; @@ -79,6 +106,14 @@ static inline GP_Context *GP_ContainerLoadNext(GP_Container *self, return self->ops->LoadNext(self, callback); }
+/* + * Just loads current image, does not advance to the next one. + */ +GP_Context *GP_ContainerLoad(GP_Container *self, GP_ProgressCallback *callback); + +int GP_ContainerSeek(GP_Container *self, int offset, + enum GP_ContainerWhence whence); + static inline void GP_ContainerClose(GP_Container *self) { self->ops->Close(self); diff --git a/include/loaders/GP_ZIP.h b/include/loaders/GP_ZIP.h index 06031e9..cb97efd 100644 --- a/include/loaders/GP_ZIP.h +++ b/include/loaders/GP_ZIP.h @@ -36,4 +36,6 @@
GP_Container *GP_OpenZip(const char *path);
+int GP_MatchZip(const char *buf); + #endif /* LOADERS_GP_ZIP_H */ diff --git a/include/loaders/GP_ZIP.h b/libs/loaders/GP_Container.c similarity index 73% copy from include/loaders/GP_ZIP.h copy to libs/loaders/GP_Container.c index 06031e9..1a90289 100644 --- a/include/loaders/GP_ZIP.h +++ b/libs/loaders/GP_Container.c @@ -20,20 +20,31 @@ * * *****************************************************************************/
- /* - - Zip container, could be used to load images from cbz or from zip files. - - */ - -#ifndef LOADERS_GP_ZIP_H -#define LOADERS_GP_ZIP_H - -#include "core/GP_Context.h" -#include "core/GP_ProgressCallback.h" +#include <errno.h>
+#include "core/GP_Debug.h" #include "loaders/GP_Container.h"
-GP_Container *GP_OpenZip(const char *path); - -#endif /* LOADERS_GP_ZIP_H */ +int GP_ContainerSeek(GP_Container *self, int offset, + enum GP_ContainerWhence whence) +{ + if (!self->ops->Seek) { + GP_DEBUG(1, "Seek not implemented in %s container", + self->ops->type); + return ENOSYS; + } + + return self->ops->Seek(self, offset, whence); +} + +GP_Context *GP_ContainerLoad(GP_Container *self, GP_ProgressCallback *callback) +{ + if (!self->ops->Load) { + GP_DEBUG(1, "Load not implemented in %s container", + self->ops->type); + errno = ENOSYS; + return NULL; + } + + return self->ops->Load(self, callback); +} diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c index c5ab037..4874c7c 100644 --- a/libs/loaders/GP_ZIP.c +++ b/libs/loaders/GP_ZIP.c @@ -34,15 +34,46 @@
#endif /* HAVE_ZLIB */
+#include "core/GP_Common.h" #include "core/GP_Debug.h"
#include "loaders/GP_ByteUtils.h" #include "loaders/GP_JPG.h" +#include "loaders/GP_PNG.h"
#include "loaders/GP_ZIP.h"
#ifdef HAVE_ZLIB
+#define ZIP_CHUNKS_IN_TABLE 128 + +/* + * Table used for seeks, populated on the go + */ +struct zip_chunks_table { + long offsets[ZIP_CHUNKS_IN_TABLE]; + struct zip_chunks_table *next; + struct zip_chunks_table *prev; +}; + +struct zip_priv { + FILE *f; + + /* Current position in zip continer counted in images we found */ + unsigned int cur_pos; + + /* Current table */ + unsigned int cur_table_pos; + struct zip_chunks_table *cur_table; + + /* Last table and index into it, this is used for addition */ + unsigned int tables_used; + unsigned int table_used; + struct zip_chunks_table *last_table; + + struct zip_chunks_table table; +}; + #define GEN_FLAG_ENCRYPTED 0x01
struct zip_local_header { @@ -54,6 +85,9 @@ struct zip_local_header { uint32_t comp_size; uint32_t uncomp_size;
+ uint16_t fname_len; + uint16_t extf_len; + char *file_name; };
@@ -73,7 +107,7 @@ enum compress_method { COMPRESS_BZIP2 = 0x0c, };
-const char *compress_method_names[] = { +static const char *compress_method_names[] = { "Stored (no compression)", "Shrunk", "Reduced with factor 1", @@ -113,12 +147,6 @@ static int seek_bytes(FILE *f, uint32_t bytes) return 0; }
-static void read_stored(FILE *f, struct zip_local_header *header) -{ - /* ignored for now */ - seek_bytes(f, header->uncomp_size); -} - #define CHUNK 512
struct deflate_inbuf { @@ -242,47 +270,63 @@ err0: return err; }
-static int zip_next_file(FILE *f, FILE **res) +static int zip_load_header(FILE *f, struct zip_local_header *header) { - uint16_t fname_len, extf_len; - struct zip_local_header header = {.file_name = NULL}; - int ret, err = 0; + int ret; + + //TODO: check for central directory signature -> end of data
ret = GP_FRead(f, "0x50 0x4b 0x03 0x04 L2 L2 L2 I4 L4 L4 L4 L2 L2", - &header.ver, &header.bit_flags, &header.comp_type, - &header.crc, &header.comp_size, &header.uncomp_size, - &fname_len, &extf_len); + &header->ver, &header->bit_flags, &header->comp_type, + &header->crc, &header->comp_size, &header->uncomp_size, + &header->fname_len, &header->extf_len);
if (ret != 13) { GP_DEBUG(1, "Failed to read header"); return EIO; }
+ return 0; +} + +static GP_Context *zip_next_file(FILE *f, GP_ProgressCallback *callback) +{ + struct zip_local_header header = {.file_name = NULL}; + int err = 0; + GP_Context *ret = NULL; + FILE *fres; + + if ((err = zip_load_header(f, &header))) + goto out; + GP_DEBUG(1, "Have ZIP local header version %u.%u compression %s", header.ver/10, header.ver%10, compress_method_name(header.comp_type));
if (header.bit_flags & GEN_FLAG_ENCRYPTED) { GP_DEBUG(1, "Can't handle encrypted files"); - return ENOSYS; + err = ENOSYS; + goto out; }
/* * If input was taken from stdin the fname_len is either set to zero or * to one and filename is set to '-'. */ - if (fname_len) { - header.file_name = malloc(fname_len + 1); + if (header.fname_len) { + header.file_name = malloc(header.fname_len + 1);
- if (!header.file_name) - return ENOMEM; + if (!header.file_name) { + err = ENOMEM; + goto out; + }
- header.file_name[fname_len] = '0'; + header.file_name[header.fname_len] = '0';
- if (fread(header.file_name, fname_len, 1, f) != 1) { + if (fread(header.file_name, header.fname_len, 1, f) != 1) { GP_DEBUG(1, "Failed to read filename"); err = EIO; - goto err0; + goto out; }
GP_DEBUG(1, "Filename '%s' compressed size=%"PRIu32 @@ -291,69 +335,276 @@ static int zip_next_file(FILE *f, FILE **res) header.uncomp_size); }
- seek_bytes(f, extf_len); + seek_bytes(f, header.extf_len);
switch (header.comp_type) { case COMPRESS_STORED: - read_stored(f, &header); + /* skip directories */ + if (header.uncomp_size == 0) + goto out; + + ret = GP_ReadJPG(f, callback); + goto out; break; case COMPRESS_DEFLATE: - read_deflate(f, &header, res); + if (read_deflate(f, &header, &fres)) + goto out; + + ret = GP_ReadJPG(fres, callback); + err = errno; + fclose(fres); + goto out; break; default: GP_DEBUG(1, "Unimplemented compression %s", compress_method_name(header.comp_type)); - return ENOSYS; + err = ENOSYS; + goto out; }
- return 0; -err0: +out: free(header.file_name); - return err; + errno = err; + return ret; }
-struct zip_priv { - FILE *f; -}; +static unsigned int last_offset_idx(struct zip_priv *priv) +{ + return priv->table_used + priv->tables_used * ZIP_CHUNKS_IN_TABLE; +} + +static long last_recorded_offset(struct zip_priv *priv) +{ + const unsigned int last_idx = ZIP_CHUNKS_IN_TABLE - 1; + + if (priv->table_used == 0) { + if (priv->last_table->prev) + return priv->last_table->prev->offsets[last_idx]; + + return -1; + } + + return priv->last_table->offsets[priv->table_used - 1]; +} + +static void record_offset(struct zip_priv *priv, long offset) +{ + if (offset <= last_recorded_offset(priv)) + return; + + GP_DEBUG(2, "Recording offset to %i image (%li)", + last_offset_idx(priv), offset); + + if (priv->table_used >= ZIP_CHUNKS_IN_TABLE) { + struct zip_chunks_table *new_table; + + GP_DEBUG(1, "Allocating chunks table (table nr. %u) (size %i)", + priv->tables_used+1, ZIP_CHUNKS_IN_TABLE); + + new_table = malloc(sizeof(struct zip_chunks_table)); + + if (!new_table) { + GP_WARN("Malloc failed :("); + return; + } + + priv->tables_used++; + priv->table_used = 0; + new_table->prev = priv->last_table; + new_table->next = NULL; + priv->last_table->next = new_table; + priv->last_table = new_table; + } + + priv->last_table->offsets[priv->table_used++] = offset; +/* + printf("OFFSET tablen"); + unsigned int i; + for (i = 0; i < priv->table_used; i++) + printf("** %u -> %lin", i, priv->last_table->offsets[i]); + */ +}
static GP_Context *zip_load_next(GP_Container *self, GP_ProgressCallback *callback) { struct zip_priv *priv = GP_CONTAINER_PRIV(self); - FILE *res = NULL; GP_Context *ret; - int err; + long offset;
GP_DEBUG(1, "Trying to load next image from ZIP container");
- do - err = zip_next_file(priv->f, &res); - while (!err && !res); + do { + offset = ftell(priv->f); + ret = zip_next_file(priv->f, callback); + } while (ret == NULL && errno == 0);
- if (err) { - errno = err; + if (!ret) return NULL; + + if (ret) + record_offset(priv, offset); + + priv->cur_pos++; + //self->cur_img++; + self->cur_img = priv->cur_pos; + + return ret; +} + +/* Seek to the current position */ +static void seek_cur_pos(struct zip_priv *priv) +{ + unsigned int cur_table = priv->cur_pos / ZIP_CHUNKS_IN_TABLE; + unsigned int cur_pos; + + if (priv->cur_table_pos != cur_table) { + unsigned int i; + + GP_DEBUG(3, "cur_pos %u out of cur table %u", + priv->cur_pos, priv->cur_table_pos); + + priv->cur_table = &priv->table; + + for (i = 0; i < cur_table; i++) { + if (priv->cur_table->next) + priv->cur_table = priv->cur_table->next; + else + GP_WARN("The cur_pos points after last table"); + } + + priv->cur_table_pos = cur_table; }
- ret = GP_ReadJPG(res, callback); - err = errno; - fclose(res); - errno = err; + //TODO: Asert that we are not in last table and cur_pos < table_used + + cur_pos = priv->cur_pos % ZIP_CHUNKS_IN_TABLE; + + GP_DEBUG(2, "Setting current position to %u (%li)", + priv->cur_pos, priv->cur_table->offsets[cur_pos]); + + fseek(priv->f, priv->cur_table->offsets[cur_pos], SEEK_SET); +} + +static int load_next_offset(struct zip_priv *priv) +{ + struct zip_local_header header = {.file_name = NULL}; + int ret; + long offset = ftell(priv->f); + + //TODO: End of file! + if ((ret = zip_load_header(priv->f, &header))) + return ret; + + //TODO: Match image extension and signature + record_offset(priv, offset); + + /* Seek to the next local header */ + seek_bytes(priv->f, (uint32_t)header.fname_len + + (uint32_t)header.extf_len); + seek_bytes(priv->f, header.comp_size); + + return 0; +} + +/* + * Sets current position. + */ +static int set_cur_pos(struct zip_priv *priv, unsigned int where) +{ + unsigned int max = last_offset_idx(priv); + int err; + + GP_DEBUG(2, "where %u max %u", where, max); + + /* Move to the max and beyond */ + if (where >= max) { + if (max == 0) { + if ((err = load_next_offset(priv))) + return err; + priv->cur_pos = 0; + } else { + priv->cur_pos = max - 1; + seek_cur_pos(priv); + } + + while (priv->cur_pos < where) { + if ((err = load_next_offset(priv))) + return err; + priv->cur_pos++; + } + + return 0; + } + + priv->cur_pos = where; + seek_cur_pos(priv); + + return 0; +} + +static int zip_seek(GP_Container *self, int offset, + enum GP_ContainerWhence whence) +{ + struct zip_priv *priv = GP_CONTAINER_PRIV(self); + unsigned int where; + int ret; + + GP_DEBUG(1, "Seek offset=%i whence=%i", offset, whence); + + switch (whence) { + case GP_CONT_CUR: + if (offset < 0 && priv->cur_pos < (unsigned int)-offset) { + GP_WARN("Current position %u offset %i", + priv->cur_pos, offset); + where = 0; + } else { + where = priv->cur_pos + offset; + } + break; + case GP_CONT_FIRST: + where = offset; + break; + default: + return ENOSYS; + } + + ret = set_cur_pos(priv, where); + + self->cur_img = priv->cur_pos;
return ret; }
+static GP_Context *zip_load(GP_Container *self, + GP_ProgressCallback *callback) +{ + GP_Context *img; + + img = zip_load_next(self, callback); + + if (!img) + return NULL; + + zip_seek(self, -1, GP_CONT_CUR); + + return img; +} + static void zip_close(GP_Container *self) { struct zip_priv *priv = GP_CONTAINER_PRIV(self); + struct zip_chunks_table *i, *j;
GP_DEBUG(1, "Closing ZIP container");
+ /* Free allocated offset tables */ + for (i = priv->table.next; i != NULL; j = i, i = i->next, free(j)); + fclose(priv->f); free(self); }
- static int open_zip(const char *path, FILE **file) { FILE *f; @@ -387,7 +638,10 @@ err0:
static const struct GP_ContainerOps zip_ops = { .LoadNext = zip_load_next, + .Load = zip_load, .Close = zip_close, + .Seek = zip_seek, + .type = "ZIP", };
GP_Container *GP_OpenZip(const char *path) @@ -409,14 +663,31 @@ GP_Container *GP_OpenZip(const char *path) goto err0; }
- priv = GP_CONTAINER_PRIV(ret); - - priv->f = f; + GP_DEBUG(1, "ZIP Container initialized");
ret->img_count = -1; ret->cur_img = 0; ret->ops = &zip_ops;
+ priv = GP_CONTAINER_PRIV(ret); + + priv->f = f; + + priv->table.next = NULL; + priv->table.prev = NULL; + + /* Cache for current table for seeks */ + priv->cur_table = &priv->table; + priv->cur_table_pos = 0; + + /* Current position */ + priv->cur_pos = 0; + + /* Last table, used for insertion */ + priv->tables_used = 0; + priv->table_used = 0; + priv->last_table = &priv->table; + return ret; err0: fclose(f); @@ -435,3 +706,7 @@ GP_Container *GP_OpenZip(const char *path)
#endif /* HAVE_ZLIB */
+int GP_MatchZip(const char *buf) +{ + return !memcmp("PK0304", buf, 4); +}
http://repo.or.cz/w/gfxprim.git/commit/41bce152b73f2401ac8f5f8505e1be2e4ccb6...
commit 41bce152b73f2401ac8f5f8505e1be2e4ccb6ef2 Author: Cyril Hrubis metan@ucw.cz Date: Thu Jul 18 23:41:51 2013 +0200
demos: spiv: Two fixes.
* Add destroy functions for image list, image loader and call them on exit. (this makes memory debugging with valgrind easier)
* Map 0 key to resize by 10 action. (1-9 was mapped to resize by 1-9 beforehand)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c index afaff25..cef9c8e 100644 --- a/demos/spiv/image_list.c +++ b/demos/spiv/image_list.c @@ -422,6 +422,15 @@ struct image_list *image_list_create(const char *args[]) return self; }
+void image_list_destroy(struct image_list *self) +{ + if (self->in_dir) + exit_dir(self); + + free(self->arg_file_counts); + free(self); +} + const char *image_list_img_path(struct image_list *self) { if (!self->path_loaded) diff --git a/demos/spiv/image_list.h b/demos/spiv/image_list.h index 54dbfab..e2263d0 100644 --- a/demos/spiv/image_list.h +++ b/demos/spiv/image_list.h @@ -36,6 +36,9 @@ struct image_list; */ struct image_list *image_list_create(const char *args[]);
+ +void image_list_destroy(struct image_list *self); + /* * Returns path to the current image. */ diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c index 1c6321f..7852fc6 100644 --- a/demos/spiv/image_loader.c +++ b/demos/spiv/image_loader.c @@ -102,7 +102,7 @@ static void drop_cur_img(void) /* * Currently loaded image is too big to be cached -> free it. */ - if (!image_cache_get(img_cache, 1, path)) + if (!image_cache_get(img_cache, 0, path)) GP_ContextFree(cur_img);
cur_img = NULL; @@ -164,6 +164,10 @@ void image_loader_drop_cache(void)
void image_loader_destroy(void) { + GP_DEBUG(1, "Destroying loader"); + drop_cur_img(); + GP_DEBUG(1, "Destroying cache"); image_cache_destroy(img_cache); - //TODO Image list destroy? + GP_DEBUG(1, "Destroying image list"); + image_list_destroy(img_list); } diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index c594205..96eda04 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -623,7 +623,6 @@ static int init_loader(struct loader_params *params, const char **argv)
GP_DEBUG(1, "Resized cache size = %u", resized_size);
- //TODO: cache size init if (image_loader_init(argv, orig_size)) return 1;
@@ -874,8 +873,9 @@ int main(int argc, char *argv[]) case GP_KEY_ESC: case GP_KEY_ENTER: case GP_KEY_Q: - image_cache_drop(params.img_resized_cache); - image_loader_drop_cache(); + stop_loader(); + image_cache_destroy(params.img_resized_cache); + image_loader_destroy(); GP_BackendExit(backend); return 0; break; @@ -940,6 +940,9 @@ int main(int argc, char *argv[]) int val = ev.val.key.key - GP_KEY_1 + 1; resize_backend(val, shift_flag); } break; + case GP_KEY_0: + resize_backend(10, shift_flag); + break; case GP_KEY_KP_PLUS: case GP_KEY_DOT: params.show_progress_once = 1; diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c index 43cbaa1..9e2d14b 100644 --- a/demos/spiv/spiv_help.c +++ b/demos/spiv/spiv_help.c @@ -58,6 +58,7 @@ static const char *keys_help[] = { "3 - resize spiv window to the third of the image size", "...", "9 - resize spiv window to the ninth of the image size", + "0 - resize spiv window to the tenth of the image size", "", "Shift 2 - resize spiv window twice of the image size", "Shift 3 - resize spiv window three times of the image size",
http://repo.or.cz/w/gfxprim.git/commit/b6cbcf6d7265335c20d6dc268160aac84d5af...
commit b6cbcf6d7265335c20d6dc268160aac84d5af3aa Author: Cyril Hrubis metan@ucw.cz Date: Thu Jul 18 23:35:07 2013 +0200
loaders: TIFF: Mark internal funcitons static.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index ac49d06..160a85a 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -275,7 +275,7 @@ static GP_PixelType match_pixel_type(TIFF *tiff, struct tiff_header *header) } }
-uint16_t get_idx(uint8_t *row, uint32_t x, uint16_t bps) +static uint16_t get_idx(uint8_t *row, uint32_t x, uint16_t bps) { switch (bps) { case 1: @@ -294,8 +294,9 @@ uint16_t get_idx(uint8_t *row, uint32_t x, uint16_t bps) return 0; }
-int tiff_read_palette(TIFF *tiff, GP_Context *res, struct tiff_header *header, - GP_ProgressCallback *callback) +static int tiff_read_palette(TIFF *tiff, GP_Context *res, + struct tiff_header *header, + GP_ProgressCallback *callback) { if (TIFFIsTiled(tiff)) { //TODO @@ -365,8 +366,8 @@ int tiff_read_palette(TIFF *tiff, GP_Context *res, struct tiff_header *header, /* * Direct read -> data in image are in right format. */ -int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header, - GP_ProgressCallback *callback) +static int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header, + GP_ProgressCallback *callback) { uint32_t i, y; uint16_t planar_config, samples, s;
-----------------------------------------------------------------------
Summary of changes: build/syms/Loaders_symbols.txt | 7 + demos/spiv/image_list.c | 9 + demos/spiv/image_list.h | 3 + demos/spiv/image_loader.c | 81 ++++- demos/spiv/spiv.c | 15 +- demos/spiv/spiv_help.c | 1 + include/loaders/GP_Container.h | 41 ++- include/loaders/GP_ZIP.h | 2 + .../GP_ZIP.h => libs/loaders/GP_Container.c | 39 ++- libs/loaders/GP_TIFF.c | 11 +- libs/loaders/GP_ZIP.c | 369 +++++++++++++++++--- 11 files changed, 503 insertions(+), 75 deletions(-) copy include/loaders/GP_ZIP.h => libs/loaders/GP_Container.c (73%)
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.