From 5e6a1083fd7f707f178a6786fed35b9aec1f5e4e Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 8 Nov 2016 17:21:55 +0100 Subject: [PATCH] Bug 773450 - Animated WEBP images should be able to set frame delay... ...in the export dialog Read back timestamps into layer names. Adds the exact duration to the layer names. Previously, they were not reloaded correctly. --- plug-ins/file-webp/file-webp-load.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plug-ins/file-webp/file-webp-load.c b/plug-ins/file-webp/file-webp-load.c index af335cbdd7..72372c374c 100644 --- a/plug-ins/file-webp/file-webp-load.c +++ b/plug-ins/file-webp/file-webp-load.c @@ -158,7 +158,8 @@ load_image (const gchar *filename, WebPAnimInfo anim_info; WebPAnimDecoderOptions dec_options; gint frame_num = 1; - + WebPDemuxer *demux = NULL; + WebPIterator iter = { 0, }; if (! WebPAnimDecoderOptionsInit (&dec_options)) { @@ -166,6 +167,12 @@ load_image (const gchar *filename, if (dec) WebPAnimDecoderDelete (dec); + if (demux) + { + WebPDemuxReleaseIterator (&iter); + WebPDemuxDelete (demux); + } + return -1; } @@ -187,6 +194,10 @@ load_image (const gchar *filename, goto error; } + demux = WebPDemux (&wp_data); + if (! demux || ! WebPDemuxGetFrame (demux, 1, &iter)) + goto error; + /* Attempt to decode the data as a WebP animation image */ while (WebPAnimDecoderHasMoreFrames (dec)) { @@ -202,14 +213,17 @@ load_image (const gchar *filename, goto error; } - name = g_strdup_printf (_("Frame %d"), frame_num); + name = g_strdup_printf (_("Frame %d (%dms)"), frame_num, iter.duration); create_layer (image_ID, outdata, 0, name, width, height); g_free (name); frame_num++; + WebPDemuxNextFrame (&iter); } WebPAnimDecoderDelete (dec); + WebPDemuxReleaseIterator (&iter); + WebPDemuxDelete (demux); } /* Free the original compressed data */