📄 precinctsizespec.cpp
字号:
return true;
}
// Adjust cT for last byte
CT = 8;
}
// 5) Now we can calculate the number 'k' of bits having error
// resilience information, which is the number of bits left to
// normalization in the C register, minus 1.
k = CT-1;
// 6) The predictable termination policy is as if an LPS interval was
// coded that caused a renormalization of 'k' bits, before the
// termination marker started
// We first check if an LPS is decoded, that causes a renormalization
// of 'k' bits. Worst case is smallest LPS probability 'q' that causes
// a renormalization of 'k' bits.
q = 0x8000>>k;
// Check that we can decode an LPS interval of probability 'q'
A -= q;
if ((C>>16) <A)
{
// Error: MPS interval decoded
return true;
}
// OK: LPS interval decoded
C -= (A<<16);
// -- LPS Exchange
// Here 'a' can not be smaller than 'q' because the minimum value
// for 'a' is 0x8000-0x4000=0x4000 and 'q' is set to a value equal
// to or smaller than that.
A = q;
// -- Renormalize
do{
if(CT==0)
ByteIn();
A<<=1;
C<<=1;
CT--;
} while (A< 0x8000);
// -- End renormalization
// -- End LPS Exchange
// 7) Everything seems OK, we have checked the C register for the LPS
// symbols and ensured that it is followed by bits synthetized by the
// termination marker.
return false;
}