Esempio n. 1
0
        /// <summary>
        /// Generated from text on F-22, F.2.2.1 - Huffman decoding of DC
        /// coefficients on ISO DIS 10918-1. Requirements and Guidelines.
        /// </summary>
        /// <param name="jpegStream">Stream that contains huffman bits</param>
        /// <param name="diff">The DC coefficient</param>
        /// <returns>The result of the read</returns>
        public JpegReadStatusInt decode_dc_coefficient(JpegBinaryReader jpegStream, out float diff)
        {
            diff = 0;
            var status = DCTable.Decode(jpegStream);

            if (status.Status != Status.Success)
            {
                return(status);
            }
            int t = status.Result;

            status = jpegStream.ReadBits(t);
            if (status.Status != Status.Success)
            {
                return(status);
            }
            diff       = HuffmanTable.Extend(status.Result, t);
            diff       = (previousDC + diff);
            previousDC = diff;
            return(status);
        }
Esempio n. 2
0
        public JpegReadStatusInt DecodeDCFirst(JpegBinaryReader stream, float[] dest)
        {
            var status = DCTable.Decode(stream);

            if (status.Status != Status.Success)
            {
                return(status);                // We reached the end of the stream.
            }
            int s = status.Result;

            status = stream.ReadBits(s);
            if (status.Status != Status.Success)
            {
                return(status);
            }
            int r = status.Result;

            s          = HuffmanTable.Extend(r, s);
            s          = (int)previousDC + s;
            previousDC = s;

            dest[0] = s << successiveLow;
            return(status);
        }