summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-02-26 16:11:04 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2022-02-26 16:19:51 +0000
commit4a037e58acc229ba133e727b15b3fd3d1d3b0c5b (patch)
tree304b187f21f92a68033d8500af7d34c7fabeb898
parent02b1c6de36df8f4cd0b1eea52dafbd8840756f95 (diff)
downloadlibnsgif-4a037e58acc229ba133e727b15b3fd3d1d3b0c5b.tar.gz
libnsgif-4a037e58acc229ba133e727b15b3fd3d1d3b0c5b.tar.bz2
GIF: Simplify frame delay calculation.
-rw-r--r--src/gif.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/gif.c b/src/gif.c
index db99afd..5317a9e 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1618,7 +1618,6 @@ nsgif_error nsgif_frame_prepare(
};
uint32_t delay = 0;
uint32_t frame = gif->frame;
- uint32_t frame_next;
if (gif->frame != NSGIF_FRAME_INVALID &&
gif->frame < gif->info.frame_count &&
@@ -1632,7 +1631,7 @@ nsgif_error nsgif_frame_prepare(
return NSGIF_ERR_ANIMATION_END;
}
- ret = nsgif__next_displayable_frame(gif, &frame, NULL);
+ ret = nsgif__next_displayable_frame(gif, &frame, &delay);
if (ret != NSGIF_OK) {
return ret;
}
@@ -1641,17 +1640,22 @@ nsgif_error nsgif_frame_prepare(
gif->info.loop_count++;
}
- frame_next = frame;
- ret = nsgif__next_displayable_frame(gif, &frame_next, &delay);
- if (ret != NSGIF_OK) {
- return ret;
- }
+ if (gif->info.frame_count == 1) {
+ delay = NSGIF_INFINITE;
+
+ } else if (gif->info.loop_max != 0) {
+ uint32_t frame_next = frame;
+ ret = nsgif__next_displayable_frame(gif, &frame_next, NULL);
+ if (ret != NSGIF_OK) {
+ return ret;
+ }
- if (frame_next < frame) {
- if (nsgif__animation_complete(
- gif->info.loop_count + 1,
- gif->info.loop_max)) {
- delay = NSGIF_INFINITE;
+ if (frame_next < frame) {
+ if (nsgif__animation_complete(
+ gif->info.loop_count + 1,
+ gif->info.loop_max)) {
+ delay = NSGIF_INFINITE;
+ }
}
}