nsxiv0e1bc3c
set a default delay if delay is 0 (#445)
gif spec [0] doesn't mention what to do when "Delay Time" is 0. apng spec [1] states: | If the the value of the numerator is 0 the decoder should render the | next frame as quickly as possible, though viewers may impose a | reasonable lower bound. webp spec [2]: | the interpretation of frame duration of 0 (and often <= 10) is | implementation defined. so it seems that it's safe to set a default delay for 0 delay frames, which is what the older gif and webp loaders were already doing. do the same for the imlib2 multi-frame loader as well. [0]: https://www.w3.org/Graphics/GIF/spec-gif89a.txt [1]: https://wiki.mozilla.org/APNG_Specification [2]: https://developers.google.com/speed/webp/docs/riff_container#animation
+5 −1
1 file changed
- M image.c +5 −1
| @@ -54,6 +54,10 @@ enum { DEF_GIF_DELAY = 75 }; | |||
| 54 | 54 | enum { DEF_WEBP_DELAY = 75 }; | |
| 55 | 55 | #endif | |
| 56 | 56 | ||
| 57 | + | #if HAVE_IMLIB2_MULTI_FRAME | |
| 58 | + | enum { DEF_ANIM_DELAY = 75 }; | |
| 59 | + | #endif | |
| 60 | + | ||
| 57 | 61 | #define ZOOM_MIN (zoom_levels[0] / 100) | |
| 58 | 62 | #define ZOOM_MAX (zoom_levels[ARRLEN(zoom_levels) - 1] / 100) | |
| 59 | 63 | ||
| @@ -539,7 +543,7 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) | |||
| 539 | 543 | imlib_context_set_blend(!!(finfo.frame_flags & IMLIB_FRAME_BLEND)); | |
| 540 | 544 | imlib_blend_image_onto_image(frame, has_alpha, 0, 0, sw, sh, sx, sy, sw, sh); | |
| 541 | 545 | m->frames[m->cnt].im = canvas; | |
| 542 | − | m->frames[m->cnt].delay = finfo.frame_delay; | |
| 546 | + | m->frames[m->cnt].delay = finfo.frame_delay ? finfo.frame_delay : DEF_ANIM_DELAY; | |
| 543 | 547 | m->length += m->frames[m->cnt].delay; | |
| 544 | 548 | m->cnt++; | |
| 545 | 549 | imlib_context_set_image(frame); | |