diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-30 19:07:13 -0400 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-31 10:25:00 -0400 |
commit | 7910a2c26939c4e2400af930b0995ada56a895c8 (patch) | |
tree | 298f1a58cce96759bcb8efa72ad87b6bc9398214 /libavfilter/vf_deshake.c | |
parent | 6c6ac9cb17c4944514bde833f2fa8aa8dafa974a (diff) | |
download | ffmpeg-7910a2c26939c4e2400af930b0995ada56a895c8.tar.gz |
avfilter/vf_deshake: replace qsort with AV_QSORT
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.
This optimization is just a low hanging fruit. The trac ticket 1430 is
a request for an improved deshake filter.
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
Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavfilter/vf_deshake.c')
-rw-r--r-- | libavfilter/vf_deshake.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index 885569a331..e32436d00c 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -57,6 +57,7 @@ #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/qsort.h" #include "deshake.h" #include "deshake_opencl.h" @@ -106,7 +107,7 @@ static double clean_mean(double *values, int count) int cut = count / 5; int x; - qsort(values, count, sizeof(double), cmp); + AV_QSORT(values, count, double, cmp); for (x = cut; x < count - cut; x++) { mean += values[x]; |