avcodec: add mathops test

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-05-20 13:38:01 +02:00
parent eb0c08bc69
commit 50965e0673
2 changed files with 27 additions and 0 deletions

View File

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

26
libavcodec/mathops.c Normal file
View File

@ -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 */