diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-02-26 16:11:04 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-02-26 17:39:49 +0000 |
commit | bc358088b2b074f09e638f101d2a12b3632a0d73 (patch) | |
tree | 5f25a8d96d7f8b72c6e3365c5e67a187cda750de /src | |
parent | 4360a768898cc7a43715926e2e8040cb9748bead (diff) | |
download | libnsgif-bc358088b2b074f09e638f101d2a12b3632a0d73.tar.gz libnsgif-bc358088b2b074f09e638f101d2a12b3632a0d73.tar.bz2 |
GIF: Simplify frame delay calculation.
Diffstat (limited to 'src')
-rw-r--r-- | src/gif.c | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -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; + } } } |