-
Notifications
You must be signed in to change notification settings - Fork 17
/
test.cpp
53 lines (42 loc) · 1004 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "cabac.h"
#include "math.h"
using namespace evx;
uint8 test_kernel(uint8 value)
{
return value % 4;
}
void test_basic_cabac_rt()
{
entropy_coder coder;
bitstream a((uint32) 512);
bitstream b((uint32) 512);
bitstream c((uint32) 512);
for (uint8 i = 0; i < 32; ++i)
{
a.write_byte(test_kernel(i));
}
uint16 raw_size = a.query_occupancy();
evx_msg("raw size: %i bits", raw_size);
if (raw_size != (32 << 3))
{
evx_err("Failed to write data to the source bitstream.");
return;
}
coder.encode(&a, &b);
evx_msg("encoded size: %i bits", b.query_occupancy());
coder.decode(raw_size, &b, &c);
for (uint8 i = 0; i < c.query_byte_occupancy(); ++i)
{
if (test_kernel(i) != c.query_data()[i])
{
evx_err("Data integrity check failure.");
return;
}
}
evx_msg("test completed successfully.");
}
int main()
{
test_basic_cabac_rt();
return 0;
}