[FFmpeg-cvslog] avcodec: add mathops test
Michael Niedermayer
git at videolan.org
Wed May 20 16:24:40 CEST 2015
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed May 20 13:38:01 2015 +0200| [50965e067371a905dca04f5f867d5dd497d85871] | committer: Michael Niedermayer
avcodec: add mathops test
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50965e067371a905dca04f5f867d5dd497d85871
---
libavcodec/Makefile | 1 +
libavcodec/mathops.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1fd83b..cb88fd1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -883,6 +883,7 @@ SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
TESTPROGS = imgconvert \
+ mathops \
options \
avfft \
diff --git a/libavcodec/mathops.c b/libavcodec/mathops.c
new file mode 100644
index 0000000..31c8e69
--- /dev/null
+++ b/libavcodec/mathops.c
@@ -0,0 +1,26 @@
+#include "mathops.h"
+
+#ifdef TEST
+
+#include <stdlib.h>
+
+int main(void)
+{
+ unsigned u;
+
+ for(u=0; u<65536; u++) {
+ unsigned s = u*u;
+ unsigned root = ff_sqrt(s);
+ unsigned root_m1 = ff_sqrt(s-1);
+ if (s && root != u) {
+ fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
+ return 1;
+ }
+ if (u && root_m1 != u - 1) {
+ fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif /* TEST */
More information about the ffmpeg-cvslog
mailing list