private sbyte DecodeSign(ContextVector contextVector, int x, int y) { contextVector.GetSignCodingContextLabelAndXorBit(out int contextLabel, out int xorBit); var cx = GetContext(contextLabel); var d = EntropyCoder.DecodeNextBit(cx); var signBit = d ^ xorBit; var sign = (sbyte)((signBit == 0) ? 1 : -1); UpdateNeighbourContextVectors(x, y, sign); return(sign); }
private void RunSignificancePassOnCoefficient(int x, int y, bool includeZeroContext) { var coefficient = CoefficientArray[GetCoefficientIndex(x, y)]; if (coefficient.Sign == 0) { var contextLabel = coefficient.ContextVector.GetSignificanceCodingContextLabel(CodeBlock.Subband.SubbandType); if ((contextLabel != 0) || includeZeroContext) { var cx = GetContext(contextLabel); if (EntropyCoder.DecodeNextBit(cx) == 1) { var sign = DecodeSign(coefficient.ContextVector, x, y); coefficient.ApplySignificance(sign, CurrentCodingPass.BitPlane); } else { coefficient.ApplySignificance(0, CurrentCodingPass.BitPlane); } } } }