public PairHuffmanDecoderInterface(IDecoderReader decoderReader, IDecoderFileWriter decoderFileWriter, bool isByteCountEven)
 {
     this.decoderReader     = decoderReader;
     this.decoderFileWriter = decoderFileWriter;
     this.symbolQuantityDic = SymbolQuantityMapConverter.PairExtToIntConvert(decoderReader.SymbolCounts);
     this.isByteCountEven   = isByteCountEven;
 }
 public MarkowHuffmanDecoderInterface(IDecoderReader decoderReader, IDecoderFileWriter decoderFileWriter)
 {
     this.decoderReader       = decoderReader;
     this.decoderFileWriter   = decoderFileWriter;
     this.perSymbolDictionary = SymbolQuantityMapConverter.MarkowExtToIntConvert(decoderReader.SymbolCounts);
     foreach (DefaultableSymbol <byte> key in perSymbolDictionary.Keys)
     {
         this.symbolsCount += perSymbolDictionary[key].Sum(x => x.Value);
     }
 }
        public void Encode()
        {
            Dictionary <byte, int> symbolQuantityDic = createDictionary();
            var           builder      = new HuffmanCodecBuilder <byte>();
            var           tree         = builder.BuildTree(Comparer <byte> .Default, symbolQuantityDic);
            ICoder <byte> huffmanCoder = builder.GetCoder(tree);

            huffmanCoder.Encode(new StandardHuffmanCoderInput(inputReader), new HuffmanCoderOutput(coderOutputWriter));
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Standard, false, SymbolQuantityMapConverter.StandardIntToExtConvert(symbolQuantityDic, huffmanCoder.GetEncodingDictionary()));
        }
        public void Encode()
        {
            DefaultableSymbol <byte> previousSymbol;
            Dictionary <DefaultableSymbol <byte>, ICoder <byte> > coderDictionary = createCoderDictionary();

            coderDictionary[new DefaultableSymbol <byte>(true)].Encode(new MarkowHuffmanCoderInput(inputReader.Current), new HuffmanCoderOutput(coderOutputWriter));
            previousSymbol = new DefaultableSymbol <byte>(inputReader.Current);
            while (inputReader.MoveNext())
            {
                coderDictionary[previousSymbol].Encode(new MarkowHuffmanCoderInput(inputReader.Current), new HuffmanCoderOutput(coderOutputWriter));
                previousSymbol = new DefaultableSymbol <byte>(inputReader.Current);
            }
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Markov, true, SymbolQuantityMapConverter.MarkowIntToExtConvert(this.symbolDictionary, CreateEncodingDictionaries(coderDictionary)));
        }
Example #5
0
        public void Encode()
        {
            var symbolQuantityDic = createDictionary();
            var builder           = new HuffmanCodecBuilder <Tuple <byte, DefaultableSymbol <byte> > >();
            var tree       = builder.BuildTree(new PairComparer(), symbolQuantityDic);
            var coder      = builder.GetCoder(tree);
            var coderInput = new PairHuffmanCoderInput(inputReader);

            coder.Encode(coderInput, new HuffmanCoderOutput(coderOutputWriter));
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Block, coderInput.isSpecialSymbol, SymbolQuantityMapConverter.PairIntToExtConvert(symbolQuantityDic, coder.GetEncodingDictionary()));
        }
Example #6
0
 public StandardHuffmanDecoderInterface(IDecoderReader decoderReader, IDecoderFileWriter decoderFileWriter)
 {
     this.decoderReader     = decoderReader;
     this.decoderFileWriter = decoderFileWriter;
     this.symbolQuantityDic = SymbolQuantityMapConverter.StandardExtToIntConvert(decoderReader.SymbolCounts);
 }