[FFmpeg-devel] [PATCH v2 1/2] libavcodec: add support for animated WebP decoding
Zlomek, Josef
josef at pex.com
Wed Jul 29 19:19:15 EEST 2020
On Wed, Jul 29, 2020 at 5:43 PM Lynne <dev at lynne.ee> wrote:
> Jul 29, 2020, 14:05 by josef at pex.com:
>
> > + if (canvas->format == AV_PIX_FMT_ARGB) {
> > + height = canvas->height;
> > + memset(canvas->data[0], 0, height * canvas->linesize[0]);
> >
>
> At least some of those image-wide memsets can be replaced with
> av_image_fill_black.
>
For the canvas, the transparent black is needed (alpha = 0),
av_image_fill_black sets alpha = 255.
The background color has to be blended in the end when generating the
output frame,
otherwise one example file would not be decoded correctly.
> +// divide by 255 and round to nearest
> > +// apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 =
> ((X+128)*257)>>16
> > +#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
> >
>
> If you don't need nearest rounding a div would likely be faster,
> especially at this range.
>
I did not expect that div by 255 was fast. I'll do some benchmarks.
I took this macro from libavcodec/pngdec.c
Thank you also for the rest of suggestions, I'll implement them.
Josef
More information about the ffmpeg-devel
mailing list