[FFmpeg-cvslog] avfilter/vf_removegrain: replace qsort with AV_QSORT
Ganesh Ajjanagadde
git at videolan.org
Mon Oct 26 12:15:32 CET 2015
ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanagadde at gmail.com> | Sun Oct 25 15:06:01 2015 -0400| [68a0a164d1f63daba2397cc1f1c1902b744fa415] | committer: Ganesh Ajjanagadde
avfilter/vf_removegrain: replace qsort with AV_QSORT
filter_slice calls qsort, so qsort is in a performance critical
position. AV_QSORT is substantially faster due to the inlining of the
comparison callback. Thus, the increase in performance is worth the
increase in binary size.
Sample benchmark (x86-64, Haswell, GNU/Linux),
filter-removegrain-mode-02 (from FATE)
new:
24060 decicycles in qsort, 1 runs, 0 skips
15690 decicycles in qsort, 2 runs, 0 skips
9307 decicycles in qsort, 4 runs, 0 skips
5572 decicycles in qsort, 8 runs, 0 skips
3485 decicycles in qsort, 16 runs, 0 skips
2517 decicycles in qsort, 32 runs, 0 skips
1979 decicycles in qsort, 64 runs, 0 skips
1911 decicycles in qsort, 128 runs, 0 skips
1568 decicycles in qsort, 256 runs, 0 skips
1596 decicycles in qsort, 512 runs, 0 skips
1614 decicycles in qsort, 1024 runs, 0 skips
1874 decicycles in qsort, 2046 runs, 2 skips
2186 decicycles in qsort, 4094 runs, 2 skips
old:
246960 decicycles in qsort, 1 runs, 0 skips
135765 decicycles in qsort, 2 runs, 0 skips
70920 decicycles in qsort, 4 runs, 0 skips
37710 decicycles in qsort, 8 runs, 0 skips
20831 decicycles in qsort, 16 runs, 0 skips
12225 decicycles in qsort, 32 runs, 0 skips
8083 decicycles in qsort, 64 runs, 0 skips
6270 decicycles in qsort, 128 runs, 0 skips
5321 decicycles in qsort, 256 runs, 0 skips
4860 decicycles in qsort, 512 runs, 0 skips
4424 decicycles in qsort, 1024 runs, 0 skips
4191 decicycles in qsort, 2046 runs, 2 skips
4934 decicycles in qsort, 4094 runs, 2 skips
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68a0a164d1f63daba2397cc1f1c1902b744fa415
---
libavfilter/vf_removegrain.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c
index da17f6a..3a28b15 100644
--- a/libavfilter/vf_removegrain.c
+++ b/libavfilter/vf_removegrain.c
@@ -24,6 +24,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/qsort.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
@@ -92,7 +93,7 @@ static int mode02(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
{
int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 };
- qsort(&a, 8, sizeof(a[0]), cmp_int);
+ AV_QSORT(a, 8, int, cmp_int);
return av_clip(c, a[2 - 1 ], a[7 - 1]);
}
@@ -101,7 +102,7 @@ static int mode03(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
{
int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 };
- qsort(&a, 8, sizeof(a[0]), cmp_int);
+ AV_QSORT(a, 8, int, cmp_int);
return av_clip(c, a[3 - 1 ], a[6 - 1]);
}
@@ -110,7 +111,7 @@ static int mode04(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
{
int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 };
- qsort(&a, 8, sizeof(a[0]), cmp_int);
+ AV_QSORT(a, 8, int, cmp_int);
return av_clip(c, a[4 - 1 ], a[5 - 1]);
}
More information about the ffmpeg-cvslog
mailing list