[FFmpeg-devel] [PATCH] avfilter/vf_deshake: replace qsort with AV_QSORT

Michael Niedermayer michael at niedermayer.cc
Sat Oct 31 05:09:10 CET 2015


On Fri, Oct 30, 2015 at 07:10:52PM -0400, Ganesh Ajjanagadde wrote:
> qsort is called indirectly in filter_frame, suggesting its performance
> criticality. AV_QSORT is substantially faster due to the inlining of the
> comparison callback. Thus, the increase in performance should be worth
> the increase in binary size.
> 
> Sample benchmark (x86-64, Haswell, GNU/Linux):
> File: original from https://trac.ffmpeg.org/ticket/1430
> command: ffmpeg -stream_loop 8 -i file.webm -vf deshake=rx=64:ry=64 -f null -
> 
> Timer truncated at 1024 runs.
> new:
> 28260 decicycles in qsort,       1 runs,      0 skips
> 35570 decicycles in qsort,       2 runs,      0 skips
> 39010 decicycles in qsort,       4 runs,      0 skips
> 46897 decicycles in qsort,       8 runs,      0 skips
> 40442 decicycles in qsort,      16 runs,      0 skips
> 41611 decicycles in qsort,      32 runs,      0 skips
> 40345 decicycles in qsort,      64 runs,      0 skips
> 38967 decicycles in qsort,     128 runs,      0 skips
> 38647 decicycles in qsort,     256 runs,      0 skips
> 40238 decicycles in qsort,     512 runs,      0 skips
> 39676 decicycles in qsort,    1024 runs,      0 skips
> 
> old:
> 1740280 decicycles in qsort,       1 runs,      0 skips
>  923560 decicycles in qsort,       2 runs,      0 skips
>  511330 decicycles in qsort,       4 runs,      0 skips
>  309720 decicycles in qsort,       8 runs,      0 skips
>  194900 decicycles in qsort,      16 runs,      0 skips
>  142686 decicycles in qsort,      32 runs,      0 skips
>  112516 decicycles in qsort,      64 runs,      0 skips
>   98166 decicycles in qsort,     128 runs,      0 skips
>   88147 decicycles in qsort,     256 runs,      0 skips
>   88706 decicycles in qsort,     512 runs,      0 skips
>   86783 decicycles in qsort,    1024 runs,      0 skips
> 
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> ---
>  libavfilter/vf_deshake.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

LGTM

nice speedup

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151031/dabf9ad1/attachment.sig>


More information about the ffmpeg-devel mailing list