Example #1
0
        internal void decode_ac_coefficients(JPEGBinaryReader JPEGStream, float[] zz)
        {
            int num;

            for (num = 1; num < 64; num++)
            {
                int num2 = ACTable.Decode(JPEGStream);
                int num3 = num2 >> 4;
                num2 &= 0xF;
                if (num2 != 0)
                {
                    num    += num3;
                    num3    = JPEGStream.ReadBits(num2);
                    num2    = HuffmanTable.Extend(num3, num2);
                    zz[num] = num2;
                }
                else
                {
                    if (num3 != 15)
                    {
                        break;
                    }
                    num += 15;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Generated from text on F-23, F.13 - Huffman decoded of AC coefficients
        /// on ISO DIS 10918-1. Requirements and Guidelines.
        /// </summary>
        internal void decode_ac_coefficients(JPEGBinaryReader JPEGStream, float[] zz)
        {
            for (int k = 1; k < 64; k++)
            {
                int s = ACTable.Decode(JPEGStream);
                int r = s >> 4;
                s &= 15;


                if (s != 0)
                {
                    k += r;

                    r     = (int)JPEGStream.ReadBits(s);
                    s     = (int)HuffmanTable.Extend(r, s);
                    zz[k] = s;
                }
                else
                {
                    if (r != 15)
                    {
                        //throw new JPEGMarkerFoundException();
                        return;
                    }
                    k += 15;
                }
            }
        }
Example #3
0
        public float decode_dc_coefficient(JPEGBinaryReader JPEGStream)
        {
            int   num  = DCTable.Decode(JPEGStream);
            float num2 = JPEGStream.ReadBits(num);

            num2 = HuffmanTable.Extend((int)num2, num);
            return(previousDC += num2);
        }
Example #4
0
        public void DecodeDCFirst(JPEGBinaryReader stream, float[] dest)
        {
            int num = DCTable.Decode(stream);

            num        = HuffmanTable.Extend(stream.ReadBits(num), num);
            num        = (int)previousDC + num;
            previousDC = num;
            dest[0]    = num << successiveLow;
        }
Example #5
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>
        /// <returns>DC coefficient</returns>
        public float decode_dc_coefficient(JPEGBinaryReader JPEGStream)
        {
            int   t    = DCTable.Decode(JPEGStream);
            float diff = JPEGStream.ReadBits(t);

            diff       = HuffmanTable.Extend((int)diff, t);
            diff       = (previousDC + diff);
            previousDC = diff;
            return(diff);
        }
Example #6
0
        public void DecodeDCFirst(JPEGBinaryReader stream, float[] dest)
        {
            float[] numArray = new float[0x40];
            int     t        = this.DCTable.Decode(stream);

            t = HuffmanTable.Extend(stream.ReadBits(t), t);
            t = ((int)this.previousDC) + t;
            this.previousDC = t;
            dest[0]         = t << this.successiveLow;
        }
Example #7
0
        public void DecodeDCFirst(JPEGBinaryReader stream, float[] dest)
        {
            //float[] datablock = new float[64];
            int s = DCTable.Decode(stream);
            int r = stream.ReadBits(s);

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

            dest[0] = s << successiveLow;
        }
Example #8
0
        public void DecodeACFirst(JPEGBinaryReader stream, float[] zz)
        {
            if (stream.eob_run > 0)
            {
                stream.eob_run--;
                return;
            }

            for (int k = spectralStart; k <= spectralEnd; k++)
            {
                int s = ACTable.Decode(stream);
                int r = s >> 4;
                s &= 15;


                if (s != 0)
                {
                    k += r;

                    r     = (int)stream.ReadBits(s);
                    s     = (int)HuffmanTable.Extend(r, s);
                    zz[k] = s << successiveLow;
                }
                else
                {
                    if (r != 15)
                    {
                        stream.eob_run = 1 << r;

                        if (r != 0)
                        {
                            stream.eob_run += stream.ReadBits(r);
                        }

                        stream.eob_run--;

                        break;
                    }

                    k += 15;
                }
            }
        }
Example #9
0
        public void DecodeACFirst(JPEGBinaryReader stream, float[] zz)
        {
            if (stream.eob_run > 0)
            {
                stream.eob_run--;
                return;
            }
            int num = spectralStart;
            int num3;

            while (true)
            {
                if (num > spectralEnd)
                {
                    return;
                }
                int num2 = ACTable.Decode(stream);
                num3  = num2 >> 4;
                num2 &= 0xF;
                if (num2 != 0)
                {
                    num    += num3;
                    num3    = stream.ReadBits(num2);
                    num2    = HuffmanTable.Extend(num3, num2);
                    zz[num] = num2 << successiveLow;
                }
                else
                {
                    if (num3 != 15)
                    {
                        break;
                    }
                    num += 15;
                }
                num++;
            }
            stream.eob_run = 1 << num3;
            if (num3 != 0)
            {
                stream.eob_run += stream.ReadBits(num3);
            }
            stream.eob_run--;
        }
Example #10
0
 internal void decode_ac_coefficients(JPEGBinaryReader JPEGStream, float[] zz)
 {
     for (int i = 1; i < 0x40; i++)
     {
         int t    = this.ACTable.Decode(JPEGStream);
         int num3 = t >> 4;
         t &= 15;
         if (t != 0)
         {
             i    += num3;
             zz[i] = HuffmanTable.Extend(JPEGStream.ReadBits(t), t);
         }
         else
         {
             if (num3 != 15)
             {
                 break;
             }
             i += 15;
         }
     }
 }
Example #11
0
 public void DecodeACFirst(JPEGBinaryReader stream, float[] zz)
 {
     if (stream.eob_run > 0)
     {
         stream.eob_run--;
     }
     else
     {
         for (int i = this.spectralStart; i <= this.spectralEnd; i++)
         {
             int t = this.ACTable.Decode(stream);
             int n = t >> 4;
             t &= 15;
             if (t != 0)
             {
                 i    += n;
                 t     = HuffmanTable.Extend(stream.ReadBits(t), t);
                 zz[i] = t << this.successiveLow;
             }
             else
             {
                 if (n != 15)
                 {
                     stream.eob_run = ((int)1) << n;
                     if (n != 0)
                     {
                         stream.eob_run += stream.ReadBits(n);
                     }
                     stream.eob_run--;
                     break;
                 }
                 i += 15;
             }
         }
     }
 }