Issue 554 in webp: Animated webp fade in/out quality issue

271 views
Skip to first unread message

yaron… via monorail

unread,
Jan 31, 2022, 1:56:09 AM1/31/22
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554

What steps will reproduce the problem?
1. Convert animated GIF to webp including fade in/out content
2. gif2webp <input> -lossy -q 70 -kmax 0 <output>
3. issue is reproduced also with FFMPEG

What is the expected output? What do you see instead?
compression artifacts on the fade effect

What version of the product are you using? On what operating system?
libwebp-1.2.2
ubuntu

Please provide any additional information below.
small difference between frames is skipped following high threshold, which is derived from the input quality (-q)
recommended change in anim_encode.c:

static int QualityToMaxDiff(float quality) {
// const double val = pow(quality / 100., 0.5);
// const double max_diff = 31 * (1 - val) + 1 * val;
// return (int)(max_diff + 0.5);
return (int)(5 - quality / 30.);
}

Attachments:
fade_quality_issue.webp 1.1 MB

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

ygu… via monorail

unread,
Jan 31, 2022, 3:22:37 AM1/31/22
to webp-d...@webmproject.org

Comment #1 on issue 554 by ygu...@google.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c1

Thank you for the detailed report and the suggested change.
Could it be possible to have the source GIF image?

yaron… via monorail

unread,
Jan 31, 2022, 3:31:51 AM1/31/22
to webp-d...@webmproject.org

Comment #2 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c2

attached 2 examples.
[image: fadeinoutinout.gif]

ygu… via monorail

unread,
Jan 31, 2022, 5:21:15 AM1/31/22
to webp-d...@webmproject.org

Comment #3 on issue 554 by ygu...@google.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c3

I am unable to access the examples you attached, they seem to be inline in the mail body which is not properly forwarded by monorail.
Please use the "Add attachments" feature of the bug tracker firectly at https://bugs.chromium.org/p/webp/issues/detail?id=554

yaron… via monorail

unread,
Jan 31, 2022, 5:24:43 AM1/31/22
to webp-d...@webmproject.org

Comment #4 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c4

(No comment was entered for this change.)

Attachments:
fadeinoutinout.gif 4.9 MB

yaron… via monorail

unread,
Jan 31, 2022, 5:33:19 AM1/31/22
to webp-d...@webmproject.org

Comment #5 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c5

had to regenerate due to 10MB size upload limit

Attachments:
animated_dog_fade_out_in.gif 6.7 MB
animated_dog_fade_out_in.webp 878 KB

pasca… via monorail

unread,
Jan 31, 2022, 5:35:53 PM1/31/22
to webp-d...@webmproject.org

Comment #6 on issue 554 by pasca...@gmail.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c6

There are only few functions using QualityToMaxDiff:

* IsLossyBlendingPossible()
* MinimizeChangeRectangle()
* FlattenSimilarBlocks()

and i wonder which one is most responsible for the bad fading...

yaron… via monorail

unread,
Feb 1, 2022, 4:02:56 AM2/1/22
to webp-d...@webmproject.org

Comment #7 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c7

change detection between frames should be more strict to avoid miss detection, the quantization would create the lossy part.
there might be some room for skipping blocks to allow more variance in the file size (not relying only on quantization) but the diff range should be narrow (1-4)

for the attached animated_dog_fade_out_in.webp (with q=70 lossy and kmax=0) there is +40% more FlattenSimilarBlocks

I've tested another example which gave:
* IsLossyBlendingPossible() --> -3.5%
* MinimizeChangeRectangle() --> +50% (6 to 9)
* FlattenSimilarBlocks() --> -16%

I've double checked - setting MaxDiff=2 only for FlattenSimilarBlocks() is not good enough.

yaron… via monorail

unread,
Feb 8, 2022, 4:13:35 AM2/8/22
to webp-d...@webmproject.org

Comment #8 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c8

I think there is also issue with sign, if pixel values (including aloha) are high (>=0xF0)
I've change below casting from int to uint8_t

// Helper to check if each channel in 'src' and 'dst' is at most off by
// 'max_allowed_diff'.
static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst,
int max_allowed_diff) {
const uint8_t src_a = (src >> 24) & 0xff;
const uint8_t src_r = (src >> 16) & 0xff;
const uint8_t src_g = (src >> 8) & 0xff;
const uint8_t src_b = (src >> 0) & 0xff;
const uint8_t dst_a = (dst >> 24) & 0xff;
const uint8_t dst_r = (dst >> 16) & 0xff;
const uint8_t dst_g = (dst >> 8) & 0xff;
const uint8_t dst_b = (dst >> 0) & 0xff;

yaron… via monorail

unread,
Feb 8, 2022, 4:21:46 AM2/8/22
to webp-d...@webmproject.org

Comment #9 on issue 554 by yaron...@cloudinary.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c9

to clarify previous comment

sign value would 'fail' at PixelsAreSimilar return condition
(abs(src_r - dst_r) * dst_a <= (max_allowed_diff * 255))

jz… via monorail

unread,
Feb 8, 2022, 3:57:50 PM2/8/22
to webp-d...@webmproject.org
Updates:
Owner: ygu...@google.com
Status: Accepted

Comment #10 on issue 554 by jz...@google.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c10


(No comment was entered for this change.)

danie… via monorail

unread,
Oct 25, 2022, 5:41:31 AM10/25/22
to webp-d...@webmproject.org

Comment #11 on issue 554 by danie...@shopify.com: Animated webp fade in/out quality issue
https://bugs.chromium.org/p/webp/issues/detail?id=554#c11

We have noticed similar ghosting artifacts, mostly in animations with a color gradient or fade.

> change detection between frames should be more strict to avoid miss detection, the quantization would create the lossy part. [..] the diff range should be narrow (1-4).
+1 on this. The lossiness between frames seems not to be well balanced right now - especially for lower quality settings.
Are there any updates on the status of this issue?
Reply all
Reply to author
Forward
0 new messages