Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HuffmanScanDecoder"/> class.
 /// </summary>
 /// <param name="stream">The input stream.</param>
 /// <param name="frame">The image frame.</param>
 /// <param name="dcHuffmanTables">The DC Huffman tables.</param>
 /// <param name="acHuffmanTables">The AC Huffman tables.</param>
 /// <param name="componentsLength">The length of the components. Different to the array length.</param>
 /// <param name="restartInterval">The reset interval.</param>
 /// <param name="spectralStart">The spectral selection start.</param>
 /// <param name="spectralEnd">The spectral selection end.</param>
 /// <param name="successiveHigh">The successive approximation bit high end.</param>
 /// <param name="successiveLow">The successive approximation bit low end.</param>
 public HuffmanScanDecoder(
     DoubleBufferedStreamReader stream,
     JpegFrame frame,
     HuffmanTable[] dcHuffmanTables,
     HuffmanTable[] acHuffmanTables,
     int componentsLength,
     int restartInterval,
     int spectralStart,
     int spectralEnd,
     int successiveHigh,
     int successiveLow)
 {
     this.dctZigZag        = ZigZag.CreateUnzigTable();
     this.stream           = stream;
     this.scanBuffer       = new HuffmanScanBuffer(stream);
     this.frame            = frame;
     this.dcHuffmanTables  = dcHuffmanTables;
     this.acHuffmanTables  = acHuffmanTables;
     this.components       = frame.Components;
     this.componentsLength = componentsLength;
     this.restartInterval  = restartInterval;
     this.todo             = restartInterval;
     this.spectralStart    = spectralStart;
     this.spectralEnd      = spectralEnd;
     this.successiveHigh   = successiveHigh;
     this.successiveLow    = successiveLow;
 }
Esempio n. 2
0
        /// <summary>
        /// Decodes the entropy coded data.
        /// </summary>
        public void ParseEntropyCodedData(int componentCount)
        {
            this.cancellationToken.ThrowIfCancellationRequested();

            this.componentsCount = componentCount;

            this.scanBuffer = new HuffmanScanBuffer(this.stream);

            bool fullScan = this.frame.Progressive || this.frame.MultiScan;

            this.frame.AllocateComponents(fullScan);

            if (!this.frame.Progressive)
            {
                this.ParseBaselineData();
            }
            else
            {
                this.ParseProgressiveData();
            }

            if (this.scanBuffer.HasBadMarker())
            {
                this.stream.Position = this.scanBuffer.MarkerPosition;
            }
        }