예제 #1
0
파일: Dqt.cs 프로젝트: juliobbv/CsJpgDec
 static void Log(BinaryReader reader, QuantTable quantTable)
 {
     Logger.WriteLine("Table ID: " + quantTable.id);
     Logger.WriteLine("Precision: " + quantTable.precision);
     Logger.WriteLine("The table itself");
     Common.PrintTable(quantTable.table, 8, 8, 4);
     Logger.WriteLine();
 }
예제 #2
0
파일: Dqt.cs 프로젝트: 0-v-0/test
        public static int ReadTable(BinaryReader reader, ImgInfo imgInfo)
        {
            byte tableInfo = reader.ReadByte();
            byte tableId   = (byte)(tableInfo & 0xf);           // Low 4 bits of tableInfo

            if (tableId > 3)
            {
                throw new Exception("Invalid ID for quantization table");
            }

            var quantTable = new QuantTable
            {
                id        = tableId,
                precision = (byte)(tableInfo >> 4),                 // High 4 bits of tableInfo
                valid     = true,
                table     = new ushort[64]
            };

            int sizeOfElement = quantTable.precision == 0 ? 1 : 2;

            var tabla = FileOps.tablasZigzag[8];

            // Quantizer tables are in zigzag too!
            if (quantTable.precision == 0)
            {
                for (int i = 0; i < 64; i++)
                {
                    quantTable.table[tabla[i].Y * 8 + tabla[i].X] = reader.ReadByte();
                }
            }
            else
            {
                for (int i = 0; i < 64; i++)
                {
                    quantTable.table[tabla[i].Y * 8 + tabla[i].X] = reader.ReadBEUInt16();
                }
            }

            imgInfo.quantTables[tableId] = quantTable;

            //Log(reader, quantTable);

            return(1 + 64 * sizeOfElement);
        }
예제 #3
0
파일: Dqt.cs 프로젝트: juliobbv/CsJpgDec
        public static int ReadTable(BinaryReader reader, ImgInfo imgInfo)
        {
            byte tableInfo = reader.ReadByte();
            byte tableId = (byte)(tableInfo & 0xf); // Low 4 bits of tableInfo

            if (tableId > 3)
                throw new Exception("Invalid ID for quantization table");

            var quantTable = new QuantTable();

            quantTable.id = tableId;
            quantTable.precision = (byte)(tableInfo >> 4); // High 4 bits of tableInfo
            quantTable.valid = true;
            quantTable.table = new ushort[64];

            int sizeOfElement = quantTable.precision == 0 ? 1: 2;

            var tabla = FileOps.tablasZigzag[8];

            // Quantizer tables are in zigzag too!
            if (quantTable.precision == 0)
            {
                for (int i = 0; i < 64; i++)
                {
                    quantTable.table[tabla[i].Y * 8 + tabla[i].X] = reader.ReadByte();
                }
            }
            else
            {
                for (int i = 0; i < 64; i++)
                {
                    quantTable.table[tabla[i].Y * 8 + tabla[i].X] = reader.ReadBEUInt16();
                }
            }

            imgInfo.quantTables[tableId] = quantTable;

            Log(reader, quantTable);

            return 1 + 64 * sizeOfElement;
        }