gif

read/write GIFs
git clone git://bvnf.space/gm.git
Log | Files | Refs | README

commit 92359cc1eb4bcbce821caac0f8f2a29521ef4f28
parent 01e7426b2ea2db4f63047eae652db4239a7b8d93
Author: phoebos <ben@bvnf.space>
Date:   Wed,  1 Sep 2021 17:32:30 +0100

squelch some unused variable warnings, framework for image decoding

Diffstat:
Mgif.c | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/gif.c b/gif.c @@ -33,6 +33,11 @@ struct Gif { int colortable_len; /* 2 - 256 */ unsigned char *pixels; /* array of indices to colors */ }; +struct Image { + int colortable_len; /* 2 - 256 */ + /* TODO: local color table */ + unsigned char *pixels; +}; void print_colortable(struct Gif *g){ @@ -42,11 +47,20 @@ print_colortable(struct Gif *g){ } int +gif_decode_image(struct Image *img, unsigned char *buf){ + (void) img; + (void) buf; + return 0; +} + +int gif_decode(unsigned char *buf, size_t len){ struct Gif g = {0 }; + struct Image *img; int cur_block; enum { HEAD = 1, SPEC = 2, IMGE = 4 }; cur_block = HEAD; + (void)cur_block; if (strncmp((char *)buf, "GIF", 3)) return FAIL_GIF; buf += 3; @@ -77,20 +91,30 @@ gif_decode(unsigned char *buf, size_t len){ print_colortable(&g); + /* END OF HEADER */ + while (--len) { ++buf; switch (*buf) { case '!': - cur_block = SPEC; + if (cur_block != SPEC) { + cur_block = SPEC; + } break; case ',': - cur_block = IMGE; + if (cur_block != IMGE) { + cur_block = IMGE; + img = malloc(sizeof(struct Image)); + img->colortable_len = g.colortable_len; + gif_decode_image(img, buf); + } break; case ';': /* last char of image section */ return 0; } } + free(img); return 0; }