Hello Urvang,
I am glad I now understand the spec. I hope other people will
understand its current form.
Now, back to the proposed changes.
Why 'dispose_to_background' is not an ideal solution for
semitransparent animations? A good example is given by Anthony Thysen
on his web page about GIF optimizations
http://www.imagemagick.org/Usage/anim_opt/ in the "Moving Hole
Animation" paragraph. I can also describe a simple example:
2 frame animation:
1st frame is a fully opaque photo
2nd frame is exactly the same, except it has one single transparent pixel
The only way to encode the second frame is to use
dispose_to_background, effectively erasing the whole canvas and then
encoding the whole 2nd frame.
If you had a blend/no_blend flag, the second frame could be just one
transparent pixel.
The example above may seem a bit extreme, but the problem is quite real.
---
The Previous dispose method is actually not that resource intensive as
you describe. The viewer only needs to remember 1 frame, not all
previous frames. But I am not saying this is a critical feature, just
handy for an arguably important class of animations.
---
So, let's summarize the facts... WebP now has 2 disposal methods:
1. No disposal - this is handy for opaque animations and allows the
writers to encode the current frame as a difference to previous frame.
The alpha channel of WebP is (just like in GIF's case) (mis)used to
represent a change mask. This means that the alpha channel will most
likely consist of 0s and 255s only and must be saved lossleslly or
else it would not do a good job as a change mask. Note that alpha
blending in these cases is trivial. I cannot imagine a realistic
scenario, in which the encoder would (without non-scalable, human
assistance) effectively use semi-transparent pixels when encoding
difference between 2 consecutive frames.
2. Background disposal - handy for ... I am actually not sure. It does
not seem handy at all. It is the only way to encode a frame that has a
semitransparent pixel where the previous frame didn't (in a way that
is often quite unoptimal). It may also be good for animations that are
mostly empty and if not empty, the frames are very different. But for
this kind of animations, the 'No disposal' is not much worse, because
encoding an area filled with single color does not take much space,
does it?
This does not seem good to me. If you really want to keep things as
simple as possible, cover the basic cases and allow the writers to do
sensible optimizations, I would propose this:
1. drop the disposal method
2. drop the background color from the header
3. add a blending method (maybe find a better name for it - like
composition method or something like that) with 2 options:
- No blending - replace the rectangle on the canvas
- Mask blending - if pixel alpha < 128, keep old pixel, else replace
with new pixel
This is very easy to implement for the viewers and I believe will
cover the basic cases better and without ambiguities (like the
color-space correct alpha-blending, which involves color managing the
pixels before and after blending them). It also allows writers to
easily do the basic optimizations.
There are a lot of ways how to allow better optimizations that do not
cost too much resources, but I believe this is the real core.
Best regards,
Vlasta