From 0d8e05880c01cc0339a1f1531baa11f031dc6c26 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 24 Jan 2017 23:37:36 -0800 Subject: [PATCH] img2webp: treat -loop as a no-op w/single images or in cases where duplicates have been reduced to one Change-Id: I145cd61b6792b021617f1234f0ba36e2a3128d84 --- examples/img2webp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/img2webp.c b/examples/img2webp.c index 799a64cc..d9012cc4 100644 --- a/examples/img2webp.c +++ b/examples/img2webp.c @@ -85,10 +85,15 @@ static int ReadImage(const char filename[], WebPPicture* const pic) { static int SetLoopCount(int loop_count, WebPData* const webp_data) { int ok = 1; WebPMuxError err; + uint32_t features; WebPMuxAnimParams new_params; WebPMux* const mux = WebPMuxCreate(webp_data, 1); if (mux == NULL) return 0; + err = WebPMuxGetFeatures(mux, &features); + ok = (err == WEBP_MUX_OK); + if (!ok || !(features & ANIMATION_FLAG)) goto End; + err = WebPMuxGetAnimationParams(mux, &new_params); ok = (err == WEBP_MUX_OK); if (ok) { @@ -101,6 +106,8 @@ static int SetLoopCount(int loop_count, WebPData* const webp_data) { err = WebPMuxAssemble(mux, webp_data); ok = (err == WEBP_MUX_OK); } + + End: WebPMuxDelete(mux); if (!ok) { fprintf(stderr, "Error during loop-count setting\n");