[FFmpeg-devel] Performances improvement in "image_copy_plane"
Timo Rothenpieler
timo at rothenpieler.org
Wed Jul 13 18:12:57 EEST 2022
On 13.07.2022 11:38, Marco Vianini wrote:
> You can get a very big improvement of performances in the special (but very likely) case of: "(dst_linesize == bytewidth && src_linesize == bytewidth)"
Isn't all that matters dst_linesize == src_linesize, and then you can
memcpy() the whole plane?
> 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
That code is mangled by your mail client and practically unreadable.
More information about the ffmpeg-devel
mailing list