Unit tests for bitexact_cos() and bitexact_log2tan().
This commit is contained in:
parent
817220e91d
commit
5e9f7fc31d
1 changed files with 60 additions and 0 deletions
|
@ -3,7 +3,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mathops.c"
|
#include "mathops.c"
|
||||||
|
#include "entenc.c"
|
||||||
|
#include "entdec.c"
|
||||||
#include "entcode.c"
|
#include "entcode.c"
|
||||||
|
#include "bands.c"
|
||||||
|
#include "vq.c"
|
||||||
|
#include "cwrs.c"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -57,6 +62,59 @@ void testsqrt(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testbitexactcos(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
opus_int32 min_d,max_d,last,chk;
|
||||||
|
chk=max_d=0;
|
||||||
|
last=min_d=32767;
|
||||||
|
for(i=0;i<16385;i++)
|
||||||
|
{
|
||||||
|
opus_int32 d;
|
||||||
|
opus_int32 q=bitexact_cos(i);
|
||||||
|
chk ^= q*i;
|
||||||
|
d = last - q;
|
||||||
|
if (d>max_d)max_d=d;
|
||||||
|
if (d<min_d)min_d=d;
|
||||||
|
last = q;
|
||||||
|
}
|
||||||
|
if ((chk!=91017006)||(max_d!=5)||(min_d!=0)||(bitexact_cos(0)!=32767)||
|
||||||
|
(bitexact_cos(16384)!=1)||(bitexact_cos(8192)!=23171))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "bitexact_cos failed\n");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testbitexactlog2tan(void)
|
||||||
|
{
|
||||||
|
int i,fail;
|
||||||
|
opus_int32 min_d,max_d,last,chk;
|
||||||
|
fail=chk=max_d=0;
|
||||||
|
last=min_d=30690;
|
||||||
|
for(i=0;i<8193;i++)
|
||||||
|
{
|
||||||
|
opus_int32 d;
|
||||||
|
opus_int32 mid=bitexact_cos(i);
|
||||||
|
opus_int32 side=bitexact_cos(16384-i);
|
||||||
|
opus_int32 q=bitexact_log2tan(mid,side);
|
||||||
|
chk ^= q*i;
|
||||||
|
d = last - q;
|
||||||
|
if (q!=-1*bitexact_log2tan(side,mid))
|
||||||
|
fail = 1;
|
||||||
|
if (d>max_d)max_d=d;
|
||||||
|
if (d<min_d)min_d=d;
|
||||||
|
last = q;
|
||||||
|
}
|
||||||
|
if ((chk!=16578548)||(max_d!=3219)||(min_d!=-2)||fail||
|
||||||
|
(bitexact_log2tan(32767,1)!=30690)||(bitexact_log2tan(30274,12540)!=2611)||
|
||||||
|
(bitexact_log2tan(23171,23171)!=0))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "bitexact_log2tan failed\n");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef FIXED_POINT
|
#ifndef FIXED_POINT
|
||||||
void testlog2(void)
|
void testlog2(void)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +218,8 @@ void testilog2(void)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
testbitexactcos();
|
||||||
|
testbitexactlog2tan();
|
||||||
testdiv();
|
testdiv();
|
||||||
testsqrt();
|
testsqrt();
|
||||||
testlog2();
|
testlog2();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue