/usr/include/CharLS/contextrunmode.h is in libcharls-dev 1.0-6.
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 | //
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//
#ifndef CHARLS_CONTEXTRUNMODE
#define CHARLS_CONTEXTRUNMODE
// Implements statistical modelling for the run mode context.
// Computes model dependent parameters like the golomb code lengths
struct CContextRunMode
{
CContextRunMode(LONG a, LONG nRItype, LONG nReset) :
A(a),
N(1),
Nn(0),
_nRItype(nRItype),
_nReset((BYTE)nReset)
{
}
LONG A;
BYTE N;
BYTE Nn;
LONG _nRItype;
BYTE _nReset;
CContextRunMode()
{}
inlinehint LONG GetGolomb() const
{
LONG Ntest = N;
LONG TEMP = A + (N >> 1) * _nRItype;
LONG k = 0;
for(; Ntest < TEMP; k++)
{
Ntest <<= 1;
ASSERT(k <= 32);
};
return k;
}
void UpdateVariables(LONG Errval, LONG EMErrval)
{
if (Errval < 0)
{
Nn = Nn + 1;
}
A = A + ((EMErrval + 1 - _nRItype) >> 1);
if (N == _nReset)
{
A = A >> 1;
N = N >> 1;
Nn = Nn >> 1;
}
N = N + 1;
}
inlinehint LONG ComputeErrVal(LONG temp, LONG k)
{
bool map = temp & 1;
LONG errvalabs = (temp + map) / 2;
if ((k != 0 || (2 * Nn >= N)) == map)
{
ASSERT(map == ComputeMap(-errvalabs, k));
return -errvalabs;
}
ASSERT(map == ComputeMap(errvalabs, k));
return errvalabs;
}
bool ComputeMap(LONG Errval, LONG k) const
{
if ((k == 0) && (Errval > 0) && (2 * Nn < N))
return 1;
else if ((Errval < 0) && (2 * Nn >= N))
return 1;
else if ((Errval < 0) && (k != 0))
return 1;
return 0;
}
inlinehint LONG ComputeMapNegativeE(LONG k) const
{
return k != 0 || (2 * Nn >= N );
}
};
#endif
|