Gitweb links:
...log
http://git.netsurf-browser.org/libnsgif.git/shortlog/6bfea8c514b5aaefac83914a5db475cc63ce8f41
...commit
http://git.netsurf-browser.org/libnsgif.git/commit/6bfea8c514b5aaefac83914a5db475cc63ce8f41
...tree
http://git.netsurf-browser.org/libnsgif.git/tree/6bfea8c514b5aaefac83914a5db475cc63ce8f41
The branch, master has been updated
via 6bfea8c514b5aaefac83914a5db475cc63ce8f41 (commit)
via 0d5b742134940c65baa937697b39b94cc22a4e74 (commit)
via e1695e96b0ecc60327f8cb287517f6009eb8ddc8 (commit)
via 81e55f826dba3b749fd20f3bbd1d42ca42494732 (commit)
via d8bd0736b06045ff7591e4db27cf4cd8a6ca929b (commit)
from 030c31ccd5287813cdd60ff299a577a36900fdda (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=6bfea8c514b5aaefac83914a5db475cc63ce8f41
commit 6bfea8c514b5aaefac83914a5db475cc63ce8f41
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Test: Make decoder tolerate tolerant of bad gifs.
This makes us keep going if the scan or a frame decode fails,
ensuring everything is tested.
diff --git a/test/nsgif.c b/test/nsgif.c
index bac9061..76d7b8f 100644
--- a/test/nsgif.c
+++ b/test/nsgif.c
@@ -207,21 +207,21 @@ static void decode(FILE* ppm, const char *name, nsgif_t
*gif)
}
frame_prev = frame_new;
- err = nsgif_frame_decode(gif, frame_new, &bitmap);
- if (err != NSGIF_OK) {
- warning("nsgif_decode_frame", err);
- return;
- }
-
if (nsgif_options.info == true) {
const nsgif_frame_info_t *f_info;
f_info = nsgif_get_frame_info(gif, frame_new);
- assert(f_info != NULL);
- print_gif_frame_info(f_info);
+ if (f_info != NULL) {
+ print_gif_frame_info(f_info);
+ }
}
- if (ppm != NULL) {
+ err = nsgif_frame_decode(gif, frame_new, &bitmap);
+ if (err != NSGIF_OK) {
+ warning("nsgif_decode_frame", err);
+ /* Continue decoding the rest of the frames. */
+
+ } else if (ppm != NULL) {
fprintf(ppm, "# frame %u:\n", frame_new);
image = (const uint8_t *) bitmap;
for (uint32_t y = 0; y != info->height; y++) {
@@ -284,10 +284,9 @@ int main(int argc, char *argv[])
/* Scan the raw data */
err = nsgif_data_scan(gif, size, data);
if (err != NSGIF_OK) {
+ /* Not fatal; some GIFs are nasty. Can still try to decode
+ * any frames that were decoded successfully. */
warning("nsgif_data_scan", err);
- nsgif_destroy(gif);
- free(data);
- return EXIT_FAILURE;
}
if (nsgif_options.loops == 0) {
commitdiff
http://git.netsurf-browser.org/libnsgif.git/commit/?id=0d5b742134940c65baa937697b39b94cc22a4e74
commit 0d5b742134940c65baa937697b39b94cc22a4e74
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
API: Document nsgif_data_scan return code errors being non-fatal.
diff --git a/include/nsgif.h b/include/nsgif.h
index a8f384c..c2a98c1 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -210,6 +210,9 @@ void nsgif_destroy(nsgif_t *gif);
*
* If an error occurs, all previously scanned frames are retained.
*
+ * Note that an error returned from this function is purely informational.
+ * So long as at least one frame is available, you can display frames.
+ *
* \param[in] gif The \ref nsgif_t object.
* \param[in] size Number of bytes in data.
* \param[in] data Raw source GIF data.
commitdiff
http://git.netsurf-browser.org/libnsgif.git/commit/?id=e1695e96b0ecc60327f8cb287517f6009eb8ddc8
commit e1695e96b0ecc60327f8cb287517f6009eb8ddc8
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
API: Single error code for end of data.
diff --git a/include/nsgif.h b/include/nsgif.h
index fe11d29..a8f384c 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -82,16 +82,11 @@ typedef enum {
NSGIF_ERR_FRAME_COUNT,
/**
- * GIF source data ended without one complete frame available.
+ * Unexpected end of GIF source data.
*/
NSGIF_ERR_END_OF_DATA,
/**
- * GIF source data ended with incomplete frame.
- */
- NSGIF_ERR_END_OF_FRAME,
-
- /**
* The current frame cannot be displayed.
*/
NSGIF_ERR_FRAME_DISPLAY,
diff --git a/src/gif.c b/src/gif.c
index d2f6c61..4fdaaac 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1761,8 +1761,7 @@ const char *nsgif_strerror(nsgif_error err)
[NSGIF_ERR_BAD_FRAME] = "Requested frame does not exist",
[NSGIF_ERR_DATA_FRAME] = "Invalid frame data",
[NSGIF_ERR_FRAME_COUNT] = "Excessive number of frames",
- [NSGIF_ERR_END_OF_DATA] = "Insufficient data for first frame",
- [NSGIF_ERR_END_OF_FRAME] = "End of data during frame",
+ [NSGIF_ERR_END_OF_DATA] = "Unexpected end of GIF source data",
[NSGIF_ERR_FRAME_DISPLAY] = "Frame can't be displayed",
[NSGIF_ERR_ANIMATION_END] = "Animation complete",
};
commitdiff
http://git.netsurf-browser.org/libnsgif.git/commit/?id=81e55f826dba3b749fd20f3bbd1d42ca42494732
commit 81e55f826dba3b749fd20f3bbd1d42ca42494732
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GIF: Fix frame background colour disposal for frame clipping.
diff --git a/src/gif.c b/src/gif.c
index 637d0ae..d2f6c61 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -625,13 +625,15 @@ static void nsgif__restore_bg(
uint32_t offset_x = frame->info.rect.x0;
uint32_t offset_y = frame->info.rect.y0;
- width -= gif__clip(offset_x, width, gif->info.width);
- height -= gif__clip(offset_y, height, gif->info.height);
-
- if (frame->info.display == false || width == 0) {
+ if (frame->info.display == false ||
+ frame->info.rect.x0 >= gif->info.width ||
+ frame->info.rect.y0 >= gif->info.height) {
return;
}
+ width -= gif__clip(offset_x, width, gif->info.width);
+ height -= gif__clip(offset_y, height, gif->info.height);
+
if (frame->info.transparency) {
for (uint32_t y = 0; y < height; y++) {
uint32_t *scanline = bitmap + offset_x +
commitdiff
http://git.netsurf-browser.org/libnsgif.git/commit/?id=d8bd0736b06045ff7591e4db27cf4cd8a6ca929b
commit d8bd0736b06045ff7591e4db27cf4cd8a6ca929b
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GIF: Fix frame limit off-by-one.
diff --git a/src/gif.c b/src/gif.c
index d4d708f..637d0ae 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1703,7 +1703,7 @@ nsgif_error nsgif_frame_decode(
uint32_t start_frame;
nsgif_error ret = NSGIF_OK;
- if (frame > gif->info.frame_count) {
+ if (frame >= gif->info.frame_count) {
return NSGIF_ERR_BAD_FRAME;
}
@@ -1742,7 +1742,7 @@ const nsgif_frame_info_t *nsgif_get_frame_info(
const nsgif_t *gif,
uint32_t frame)
{
- if (frame > gif->info.frame_count) {
+ if (frame >= gif->info.frame_count) {
return NULL;
}
-----------------------------------------------------------------------
Summary of changes:
include/nsgif.h | 10 ++++------
src/gif.c | 17 +++++++++--------
test/nsgif.c | 23 +++++++++++------------
3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/include/nsgif.h b/include/nsgif.h
index fe11d29..c2a98c1 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -82,16 +82,11 @@ typedef enum {
NSGIF_ERR_FRAME_COUNT,
/**
- * GIF source data ended without one complete frame available.
+ * Unexpected end of GIF source data.
*/
NSGIF_ERR_END_OF_DATA,
/**
- * GIF source data ended with incomplete frame.
- */
- NSGIF_ERR_END_OF_FRAME,
-
- /**
* The current frame cannot be displayed.
*/
NSGIF_ERR_FRAME_DISPLAY,
@@ -215,6 +210,9 @@ void nsgif_destroy(nsgif_t *gif);
*
* If an error occurs, all previously scanned frames are retained.
*
+ * Note that an error returned from this function is purely informational.
+ * So long as at least one frame is available, you can display frames.
+ *
* \param[in] gif The \ref nsgif_t object.
* \param[in] size Number of bytes in data.
* \param[in] data Raw source GIF data.
diff --git a/src/gif.c b/src/gif.c
index d4d708f..4fdaaac 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -625,13 +625,15 @@ static void nsgif__restore_bg(
uint32_t offset_x = frame->info.rect.x0;
uint32_t offset_y = frame->info.rect.y0;
- width -= gif__clip(offset_x, width, gif->info.width);
- height -= gif__clip(offset_y, height, gif->info.height);
-
- if (frame->info.display == false || width == 0) {
+ if (frame->info.display == false ||
+ frame->info.rect.x0 >= gif->info.width ||
+ frame->info.rect.y0 >= gif->info.height) {
return;
}
+ width -= gif__clip(offset_x, width, gif->info.width);
+ height -= gif__clip(offset_y, height, gif->info.height);
+
if (frame->info.transparency) {
for (uint32_t y = 0; y < height; y++) {
uint32_t *scanline = bitmap + offset_x +
@@ -1703,7 +1705,7 @@ nsgif_error nsgif_frame_decode(
uint32_t start_frame;
nsgif_error ret = NSGIF_OK;
- if (frame > gif->info.frame_count) {
+ if (frame >= gif->info.frame_count) {
return NSGIF_ERR_BAD_FRAME;
}
@@ -1742,7 +1744,7 @@ const nsgif_frame_info_t *nsgif_get_frame_info(
const nsgif_t *gif,
uint32_t frame)
{
- if (frame > gif->info.frame_count) {
+ if (frame >= gif->info.frame_count) {
return NULL;
}
@@ -1759,8 +1761,7 @@ const char *nsgif_strerror(nsgif_error err)
[NSGIF_ERR_BAD_FRAME] = "Requested frame does not exist",
[NSGIF_ERR_DATA_FRAME] = "Invalid frame data",
[NSGIF_ERR_FRAME_COUNT] = "Excessive number of frames",
- [NSGIF_ERR_END_OF_DATA] = "Insufficient data for first frame",
- [NSGIF_ERR_END_OF_FRAME] = "End of data during frame",
+ [NSGIF_ERR_END_OF_DATA] = "Unexpected end of GIF source data",
[NSGIF_ERR_FRAME_DISPLAY] = "Frame can't be displayed",
[NSGIF_ERR_ANIMATION_END] = "Animation complete",
};
diff --git a/test/nsgif.c b/test/nsgif.c
index bac9061..76d7b8f 100644
--- a/test/nsgif.c
+++ b/test/nsgif.c
@@ -207,21 +207,21 @@ static void decode(FILE* ppm, const char *name, nsgif_t
*gif)
}
frame_prev = frame_new;
- err = nsgif_frame_decode(gif, frame_new, &bitmap);
- if (err != NSGIF_OK) {
- warning("nsgif_decode_frame", err);
- return;
- }
-
if (nsgif_options.info == true) {
const nsgif_frame_info_t *f_info;
f_info = nsgif_get_frame_info(gif, frame_new);
- assert(f_info != NULL);
- print_gif_frame_info(f_info);
+ if (f_info != NULL) {
+ print_gif_frame_info(f_info);
+ }
}
- if (ppm != NULL) {
+ err = nsgif_frame_decode(gif, frame_new, &bitmap);
+ if (err != NSGIF_OK) {
+ warning("nsgif_decode_frame", err);
+ /* Continue decoding the rest of the frames. */
+
+ } else if (ppm != NULL) {
fprintf(ppm, "# frame %u:\n", frame_new);
image = (const uint8_t *) bitmap;
for (uint32_t y = 0; y != info->height; y++) {
@@ -284,10 +284,9 @@ int main(int argc, char *argv[])
/* Scan the raw data */
err = nsgif_data_scan(gif, size, data);
if (err != NSGIF_OK) {
+ /* Not fatal; some GIFs are nasty. Can still try to decode
+ * any frames that were decoded successfully. */
warning("nsgif_data_scan", err);
- nsgif_destroy(gif);
- free(data);
- return EXIT_FAILURE;
}
if (nsgif_options.loops == 0) {
--
NetSurf GIF Decoder
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]