MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / gfInit

Method gfInit

Libraries/unrar/rs16.cpp:33–53  ·  view source on GitHub ↗

Initialize logarithms and exponents Galois field tables.

Source from the content-addressed store, hash-verified

31
32// Initialize logarithms and exponents Galois field tables.
33void RSCoder16::gfInit()
34{
35 gfExp=new uint[4*gfSize+1];
36 gfLog=new uint[gfSize+1];
37
38 for (uint L=0,E=1;L<gfSize;L++)
39 {
40 gfLog[E]=L;
41 gfExp[L]=E;
42 gfExp[L+gfSize]=E; // Duplicate the table to avoid gfExp overflow check.
43 E<<=1;
44 if (E>gfSize)
45 E^=0x1100B; // Irreducible field-generator polynomial.
46 }
47
48 // log(0)+log(x) must be outside of usual log table, so we can set it
49 // to 0 and avoid check for 0 in multiplication parameters.
50 gfLog[0]= 2*gfSize;
51 for (uint I=2*gfSize;I<=4*gfSize;I++) // Results for log(0)+log(x).
52 gfExp[I]=0;
53}
54
55
56uint RSCoder16::gfAdd(uint a,uint b) // Addition in Galois field.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected