public static DcCategoryEncodedPair CalculateDifferenceDc(ColorChannel channel, int i) { int result = (int)channel.GetBlock(i)[0, 0]; if (i != 0) { result = (int)channel.GetBlock(i)[0, 0] - (int)channel.GetBlock(i - 1)[0, 0]; } return(new DcCategoryEncodedPair(AbstractCategoryEncodedPair.CalculateCategory(result), AbstractCategoryEncodedPair.EncodeCategory(result))); }
private static void Log(CodeWord codeWord, AbstractCategoryEncodedPair pair) { const bool shouldLog = false; // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (!shouldLog) { return; } Console.WriteLine(Util.GetBitsAsString(codeWord.GetCode(), codeWord.GetLength())); Console.WriteLine(Util.GetBitsAsString(pair.GetEntryCategoryEncoded(), pair.GetPair() & 0xf)); }
public static List <AcCategoryEncodedPair> EncodeCategoriesAc( IEnumerable <AcRunlengthEncodedPair> acRunLengthEncodedPairs) { List <AcCategoryEncodedPair> resultList = new List <AcCategoryEncodedPair>(); foreach (AcRunlengthEncodedPair acRunLengthEncodedPair in acRunLengthEncodedPairs) { int category = AbstractCategoryEncodedPair.CalculateCategory(acRunLengthEncodedPair.GetEntry()); int pair = (acRunLengthEncodedPair.GetZeroCount() << 4) + category; int categoryEncoded = AbstractCategoryEncodedPair.EncodeCategory(acRunLengthEncodedPair.GetEntry()); resultList.Add(new AcCategoryEncodedPair(pair, categoryEncoded)); } return(resultList); }