Gitweb links: ...log http://git.netsurf-browser.org/libnsgif.git/shortlog/5e815f4923c3c7e0d30ff665896d3331784c243d ...commit http://git.netsurf-browser.org/libnsgif.git/commit/5e815f4923c3c7e0d30ff665896d3331784c243d ...tree http://git.netsurf-browser.org/libnsgif.git/tree/5e815f4923c3c7e0d30ff665896d3331784c243d
The branch, master has been updated via 5e815f4923c3c7e0d30ff665896d3331784c243d (commit) via fa359952ebde452911c325bd6c091a11bff111b8 (commit) via b627abfbecaa7e18e2d6b6bb1f3b2ec2aae255ae (commit) via 9151ec61ef3a4af5f0643b95edce27e85ac1a7ec (commit) via 79b272cb58ea3b114f6f3cf3594ced2721b9f8dd (commit) from 848debfe6c3a000ab547d185b57b47ac5560ba8e (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 ----------------------------------------------------------------- commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=5e815f4923c3c7e0d30ff665896d3331784c243d commit 5e815f4923c3c7e0d30ff665896d3331784c243d Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> Test: Add transparency to frame info dump. diff --git a/test/nsgif.c b/test/nsgif.c index 648d3d1..bac9061 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -152,6 +152,7 @@ static void print_gif_frame_info(const nsgif_frame_info_t *info) const char *disposal = nsgif_str_disposal(info->disposal); fprintf(stdout, " - disposal-method: %s\n", disposal); + fprintf(stdout, " transparency: %s\n", info->transparency ? "yes" : "no"); fprintf(stdout, " display: %s\n", info->display ? "yes" : "no"); fprintf(stdout, " delay: %"PRIu32"\n", info->delay); fprintf(stdout, " rect:\n"); commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=fa359952ebde452911c325bd6c091a11bff111b8 commit fa359952ebde452911c325bd6c091a11bff111b8 Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> Test: Default to single loop if loop count is zero. diff --git a/test/nsgif.c b/test/nsgif.c index 796d34a..648d3d1 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -289,6 +289,10 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + if (nsgif_options.loops == 0) { + nsgif_options.loops = 1; + } + for (uint64_t i = 0; i < nsgif_options.loops; i++) { decode((i == 0) ? ppm : NULL, nsgif_options.file, gif); } commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=b627abfbecaa7e18e2d6b6bb1f3b2ec2aae255ae commit b627abfbecaa7e18e2d6b6bb1f3b2ec2aae255ae Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> Test: Add background to gif info dump. diff --git a/test/nsgif.c b/test/nsgif.c index b1b2424..796d34a 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -140,6 +140,10 @@ static void print_gif_info(const nsgif_info_t *info) fprintf(stdout, " height: %"PRIu32"\n", info->height); fprintf(stdout, " max-loops: %"PRIu32"\n", info->loop_max); fprintf(stdout, " frame-count: %"PRIu32"\n", info->frame_count); + fprintf(stdout, " background:\n"); + fprintf(stdout, " red: 0x%"PRIx8"\n", info->background[0]); + fprintf(stdout, " green: 0x%"PRIx8"\n", info->background[1]); + fprintf(stdout, " blue: 0x%"PRIx8"\n", info->background[2]); fprintf(stdout, " frames:\n"); } commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=9151ec61ef3a4af5f0643b95edce27e85ac1a7ec commit 9151ec61ef3a4af5f0643b95edce27e85ac1a7ec Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> API: Expose transparency flag in frame info. diff --git a/include/nsgif.h b/include/nsgif.h index 6029135..fe11d29 100644 --- a/include/nsgif.h +++ b/include/nsgif.h @@ -322,6 +322,8 @@ const char *nsgif_str_disposal(enum nsgif_disposal disposal); typedef struct nsgif_frame_info { /** whether the frame should be displayed/animated */ bool display; + /** whether the frame may have transparency */ + bool transparency; /** Disposal method for previous frame; affects plotting */ uint8_t disposal; diff --git a/src/gif.c b/src/gif.c index 3ae55b9..fe65352 100644 --- a/src/gif.c +++ b/src/gif.c @@ -33,8 +33,6 @@ typedef struct nsgif_frame { /** whether a full image redraw is required */ bool redraw_required; - /** whether we acknowledge transparency */ - bool transparency; /** the index designating a transparent pixel */ uint32_t transparency_index; @@ -634,7 +632,7 @@ static void nsgif__restore_bg( return; } - if (frame->transparency) { + if (frame->info.transparency) { for (uint32_t y = 0; y < height; y++) { uint32_t *scanline = bitmap + offset_x + (offset_y + y) * gif->info.width; @@ -751,7 +749,7 @@ static nsgif_error nsgif__parse_extension_graphic_control( } if (data[2] & GIF_MASK_TRANSPARENCY) { - frame->transparency = true; + frame->info.transparency = true; frame->transparency_index = data[5]; } @@ -1181,9 +1179,9 @@ static struct nsgif_frame *nsgif__get_frame( frame = &gif->frames[frame_idx]; - frame->transparency = false; frame->transparency_index = NSGIF_NO_TRANSPARENCY; frame->frame_pointer = gif->buf_pos; + frame->info.transparency = false; frame->redraw_required = false; frame->info.display = false; frame->info.disposal = 0; commitdiff http://git.netsurf-browser.org/libnsgif.git/commit/?id=79b272cb58ea3b114f6f3cf3594ced2721b9f8dd commit 79b272cb58ea3b114f6f3cf3594ced2721b9f8dd Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> API: Expose background colour in nsgif info. diff --git a/include/nsgif.h b/include/nsgif.h index 6bf2dd6..6029135 100644 --- a/include/nsgif.h +++ b/include/nsgif.h @@ -290,6 +290,8 @@ typedef struct nsgif_info { int loop_max; /** number of animation loops so far */ int loop_count; + /** background colour in same pixel format as \ref nsgif_bitmap_t. */ + uint8_t background[4]; } nsgif_info_t; /** diff --git a/src/gif.c b/src/gif.c index 3c40685..3ae55b9 100644 --- a/src/gif.c +++ b/src/gif.c @@ -76,8 +76,6 @@ struct nsgif { uint32_t frame_holders; /** background index */ uint32_t bg_index; - /** background colour */ - uint32_t bg_colour; /** image aspect ratio (ignored) */ uint32_t aspect_ratio; /** size of colour table (in entries) */ @@ -585,6 +583,30 @@ static inline nsgif_error nsgif__decode( } /** + * Helper to assign a pixel representation from a gif background colour array. + * + * \param[in] bg The background colour to read from. + * \param[out] px The pixel colour to write. + */ +static inline void nsgif__gif_bg_to_px( + const uint8_t bg[4], uint32_t *px) +{ + *px = *(uint32_t *)bg; +} + +/** + * Helper to assign a gif background colour array from a pixel representation. + * + * \param[in] px The pixel colour to read from. + * \param[out] bg The background colour to write. + */ +static inline void nsgif__gif_px_to_bg( + const uint32_t *px, uint8_t bg[4]) +{ + *(uint32_t *)bg = *px; +} + +/** * Restore a GIF to the background colour. * * \param[in] gif The gif object we're decoding. @@ -624,7 +646,9 @@ static void nsgif__restore_bg( uint32_t *scanline = bitmap + offset_x + (offset_y + y) * gif->info.width; for (uint32_t x = 0; x < width; x++) { - scanline[x] = gif->bg_colour; + nsgif__gif_bg_to_px( + gif->info.background, + &scanline[x]); } } } @@ -1497,9 +1521,13 @@ nsgif_error nsgif_data_scan( if (gif->global_colours && gif->bg_index < gif->colour_table_size) { size_t bg_idx = gif->bg_index; - gif->bg_colour = gif->global_colour_table[bg_idx]; + nsgif__gif_px_to_bg( + &gif->global_colour_table[bg_idx], + gif->info.background); } else { - gif->bg_colour = gif->global_colour_table[0]; + nsgif__gif_px_to_bg( + &gif->global_colour_table[0], + gif->info.background); } } ----------------------------------------------------------------------- Summary of changes: include/nsgif.h | 4 ++++ src/gif.c | 46 ++++++++++++++++++++++++++++++++++++---------- test/nsgif.c | 9 +++++++++ 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/include/nsgif.h b/include/nsgif.h index 6bf2dd6..fe11d29 100644 --- a/include/nsgif.h +++ b/include/nsgif.h @@ -290,6 +290,8 @@ typedef struct nsgif_info { int loop_max; /** number of animation loops so far */ int loop_count; + /** background colour in same pixel format as \ref nsgif_bitmap_t. */ + uint8_t background[4]; } nsgif_info_t; /** @@ -320,6 +322,8 @@ const char *nsgif_str_disposal(enum nsgif_disposal disposal); typedef struct nsgif_frame_info { /** whether the frame should be displayed/animated */ bool display; + /** whether the frame may have transparency */ + bool transparency; /** Disposal method for previous frame; affects plotting */ uint8_t disposal; diff --git a/src/gif.c b/src/gif.c index 3c40685..fe65352 100644 --- a/src/gif.c +++ b/src/gif.c @@ -33,8 +33,6 @@ typedef struct nsgif_frame { /** whether a full image redraw is required */ bool redraw_required; - /** whether we acknowledge transparency */ - bool transparency; /** the index designating a transparent pixel */ uint32_t transparency_index; @@ -76,8 +74,6 @@ struct nsgif { uint32_t frame_holders; /** background index */ uint32_t bg_index; - /** background colour */ - uint32_t bg_colour; /** image aspect ratio (ignored) */ uint32_t aspect_ratio; /** size of colour table (in entries) */ @@ -585,6 +581,30 @@ static inline nsgif_error nsgif__decode( } /** + * Helper to assign a pixel representation from a gif background colour array. + * + * \param[in] bg The background colour to read from. + * \param[out] px The pixel colour to write. + */ +static inline void nsgif__gif_bg_to_px( + const uint8_t bg[4], uint32_t *px) +{ + *px = *(uint32_t *)bg; +} + +/** + * Helper to assign a gif background colour array from a pixel representation. + * + * \param[in] px The pixel colour to read from. + * \param[out] bg The background colour to write. + */ +static inline void nsgif__gif_px_to_bg( + const uint32_t *px, uint8_t bg[4]) +{ + *(uint32_t *)bg = *px; +} + +/** * Restore a GIF to the background colour. * * \param[in] gif The gif object we're decoding. @@ -612,7 +632,7 @@ static void nsgif__restore_bg( return; } - if (frame->transparency) { + if (frame->info.transparency) { for (uint32_t y = 0; y < height; y++) { uint32_t *scanline = bitmap + offset_x + (offset_y + y) * gif->info.width; @@ -624,7 +644,9 @@ static void nsgif__restore_bg( uint32_t *scanline = bitmap + offset_x + (offset_y + y) * gif->info.width; for (uint32_t x = 0; x < width; x++) { - scanline[x] = gif->bg_colour; + nsgif__gif_bg_to_px( + gif->info.background, + &scanline[x]); } } } @@ -727,7 +749,7 @@ static nsgif_error nsgif__parse_extension_graphic_control( } if (data[2] & GIF_MASK_TRANSPARENCY) { - frame->transparency = true; + frame->info.transparency = true; frame->transparency_index = data[5]; } @@ -1157,9 +1179,9 @@ static struct nsgif_frame *nsgif__get_frame( frame = &gif->frames[frame_idx]; - frame->transparency = false; frame->transparency_index = NSGIF_NO_TRANSPARENCY; frame->frame_pointer = gif->buf_pos; + frame->info.transparency = false; frame->redraw_required = false; frame->info.display = false; frame->info.disposal = 0; @@ -1497,9 +1519,13 @@ nsgif_error nsgif_data_scan( if (gif->global_colours && gif->bg_index < gif->colour_table_size) { size_t bg_idx = gif->bg_index; - gif->bg_colour = gif->global_colour_table[bg_idx]; + nsgif__gif_px_to_bg( + &gif->global_colour_table[bg_idx], + gif->info.background); } else { - gif->bg_colour = gif->global_colour_table[0]; + nsgif__gif_px_to_bg( + &gif->global_colour_table[0], + gif->info.background); } } diff --git a/test/nsgif.c b/test/nsgif.c index b1b2424..bac9061 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -140,6 +140,10 @@ static void print_gif_info(const nsgif_info_t *info) fprintf(stdout, " height: %"PRIu32"\n", info->height); fprintf(stdout, " max-loops: %"PRIu32"\n", info->loop_max); fprintf(stdout, " frame-count: %"PRIu32"\n", info->frame_count); + fprintf(stdout, " background:\n"); + fprintf(stdout, " red: 0x%"PRIx8"\n", info->background[0]); + fprintf(stdout, " green: 0x%"PRIx8"\n", info->background[1]); + fprintf(stdout, " blue: 0x%"PRIx8"\n", info->background[2]); fprintf(stdout, " frames:\n"); } @@ -148,6 +152,7 @@ static void print_gif_frame_info(const nsgif_frame_info_t *info) const char *disposal = nsgif_str_disposal(info->disposal); fprintf(stdout, " - disposal-method: %s\n", disposal); + fprintf(stdout, " transparency: %s\n", info->transparency ? "yes" : "no"); fprintf(stdout, " display: %s\n", info->display ? "yes" : "no"); fprintf(stdout, " delay: %"PRIu32"\n", info->delay); fprintf(stdout, " rect:\n"); @@ -285,6 +290,10 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + if (nsgif_options.loops == 0) { + nsgif_options.loops = 1; + } + for (uint64_t i = 0; i < nsgif_options.loops; i++) { decode((i == 0) ? ppm : NULL, nsgif_options.file, gif); } -- NetSurf GIF Decoder _______________________________________________ netsurf-commits mailing list -- netsurf-commits@netsurf-browser.org To unsubscribe send an email to netsurf-commits-le...@netsurf-browser.org