[FFmpeg-devel] Performances improvement in "image_copy_plane"
Marco Vianini
marco_vianini at yahoo.it
Wed Jul 13 12:38:27 EEST 2022
You can get a very big improvement of performances in the special (but very likely) case of: "(dst_linesize == bytewidth && src_linesize == bytewidth)"
In this case in fact We can "Coalesce rows", that is using ONLY ONE MEMCPY, instead of a smaller memcpy for every row (that is looping for height times).
Code:"static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height){ if (!dst || !src) return; av_assert0(abs(src_linesize) >= bytewidth); av_assert0(abs(dst_linesize) >= bytewidth); // MY PATCH START // Coalesce rows. if (dst_linesize == bytewidth && src_linesize == bytewidth) { bytewidth *= height; height = 1; src_linesize = dst_linesize = 0; }// MY PATCH STOP
for (;height > 0; height--) { memcpy(dst, src, bytewidth); dst += dst_linesize; src += src_linesize; }}"
What do You think about?Thank You
Marco Vianini
More information about the ffmpeg-devel
mailing list