[FFmpeg-devel] Performances improvement in "image_copy_plane"

Paul B Mahol onemda at gmail.com
Wed Jul 13 12:54:44 EEST 2022


On Wed, Jul 13, 2022 at 11:38 AM Marco Vianini <
marco_vianini-at-yahoo.it at ffmpeg.org> wrote:

>  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
>

Show the benchmark numbers.


> Marco Vianini
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list