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 */