This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch libavif-loader
in repository legacy-imlib2.
View the commit online.
commit 826ba826b0c75b87f232ca2366197b6198b95f6f
Author: NRK <n...@disroot.org>
AuthorDate: Wed Feb 26 04:23:06 2025 +0000
multiframe support
---
src/modules/loaders/loader_avif.c | 44 ++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/modules/loaders/loader_avif.c b/src/modules/loaders/loader_avif.c
index 9473331..7ebb03a 100644
--- a/src/modules/loaders/loader_avif.c
+++ b/src/modules/loaders/loader_avif.c
@@ -10,10 +10,12 @@ static const char *const _formats[] = { "avif" };
static int
_load(ImlibImage *im, int load_data)
{
- avifDecoder *dec;
- /* avifResult res; */
- avifRGBImage rgb;
- int rc;
+ avifDecoder *dec;
+ /* avifResult res; */
+ avifRGBImage rgb;
+ int rc;
+ int frame, fcount;
+ ImlibImageFrame *pf;
dec = avifDecoderCreate();
if (!dec)
@@ -27,7 +29,31 @@ _load(ImlibImage *im, int load_data)
default: QUIT_WITH_RC(LOAD_FAIL);
}
- if (avifDecoderNextImage(dec) != AVIF_RESULT_OK)
+ pf = NULL;
+ frame = im->frame;
+ if (frame > 0)
+ {
+ fcount = dec->imageCount;
+ if (frame > 1 && frame > fcount)
+ QUIT_WITH_RC(LOAD_BADFRAME);
+
+ pf = __imlib_GetFrame(im);
+ if (!pf)
+ QUIT_WITH_RC(LOAD_OOM);
+ pf->frame_count = fcount;
+ pf->loop_count = 0; // TODO?
+ if (pf->frame_count > 1)
+ pf->frame_flags |= FF_IMAGE_ANIMATED;
+ // TODO?
+ pf->canvas_w = dec->image->width;
+ pf->canvas_h = dec->image->height;
+ }
+ else
+ {
+ frame = 1;
+ }
+
+ if (avifDecoderNthImage(dec, frame - 1) != AVIF_RESULT_OK)
QUIT_WITH_RC(LOAD_BADIMAGE);
im->w = dec->image->width;
@@ -35,6 +61,14 @@ _load(ImlibImage *im, int load_data)
im->has_alpha = dec->alphaPresent;
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
QUIT_WITH_RC(LOAD_BADIMAGE);
+ if (pf)
+ {
+ /* pf->frame_x = 0; */
+ /* pf->frame_y = 0; */
+ pf->frame_delay = (int)(dec->imageTiming.duration * 1000);
+ pf->frame_flags |= FF_FRAME_DISPOSE_CLEAR; // TODO??
+ }
+
if (!load_data)
QUIT_WITH_RC(LOAD_SUCCESS);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.