On Wed, Jul 29, 2020 at 5:43 PM Lynne <d...@lynne.ee> wrote: > Jul 29, 2020, 14:05 by jo...@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 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".