Ejemplo n.º 1
0
        private void WriteAcDcEncodedBlock(ColorChannel channel, int xOfChannel, int yOfChannel,
                                           Dictionary <int, CodeWord> dcCodeBook,
                                           Dictionary <int, CodeWord> acCodeBook)
        {
            DcCategoryEncodedPair dc = AcDcEncoder.CalculateDifferenceDc(channel,
                                                                         channel
                                                                         .GetPlainIndexOfBlock(
                                                                             xOfChannel,
                                                                             yOfChannel));

            List <AcRunlengthEncodedPair> acRunLengthEncodedPairs =
                AcDcEncoder.EncodeRunlength(Util.ZigzagSort(channel.GetBlock(xOfChannel,
                                                                             yOfChannel)));
            List <AcCategoryEncodedPair> acCategoryEncodedPairs = AcDcEncoder.EncodeCategoriesAc(
                acRunLengthEncodedPairs);

            AcDcEncoder.WriteDcCoefficient(BitStream, dc, dcCodeBook);
            AcDcEncoder.WriteAcCoefficients(BitStream, acCategoryEncodedPairs, acCodeBook);
        }