/usr/include/CharLS/context.h is in libcharls-dev 1.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | //
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//
#ifndef CHARLS_CONTEXT
#define CHARLS_CONTEXT
//
// JlsContext: a JPEG-LS context with it's current statistics.
//
struct JlsContext
{
public:
JlsContext()
{}
JlsContext(LONG a) :
A(a),
B(0),
C(0),
N(1)
{
}
LONG A;
LONG B;
short C;
short N;
inlinehint LONG GetErrorCorrection(LONG k) const
{
if (k != 0)
return 0;
return BitWiseSign(2 * B + N - 1);
}
inlinehint void UpdateVariables(LONG errorValue, LONG NEAR, LONG NRESET)
{
ASSERT(N != 0);
// For performance work on copies of A,B,N (compiler will use registers).
int b = B + errorValue * (2 * NEAR + 1);
int a = A + abs(errorValue);
int n = N;
ASSERT(a < 65536 * 256);
ASSERT(abs(b) < 65536 * 256);
if (n == NRESET)
{
a = a >> 1;
b = b >> 1;
n = n >> 1;
}
n = n + 1;
if (b + n <= 0)
{
b = b + n;
if (b <= -n)
{
b = -n + 1;
}
C = _tableC[C - 1];
}
else if (b > 0)
{
b = b - n;
if (b > 0)
{
b = 0;
}
C = _tableC[C + 1];
}
A = a;
B = b;
N = (short)n;
ASSERT(N != 0);
}
inlinehint LONG GetGolomb() const
{
LONG Ntest = N;
LONG Atest = A;
LONG k = 0;
for(; (Ntest << k) < Atest; k++)
{
ASSERT(k <= 32);
};
return k;
}
static signed char* CreateTableC()
{
static std::vector<signed char> rgtableC;
rgtableC.reserve(256 + 2);
rgtableC.push_back(-128);
for (int i = -128; i < 128; i++)
{
rgtableC.push_back(char(i));
}
rgtableC.push_back(127);
signed char* pZero = &rgtableC[128 + 1];
ASSERT(pZero[0] == 0);
return pZero;
}
private:
static signed char* _tableC;
};
#endif
|