Ejemplo n.º 1
0
        private void getCTransformTable(TokenD token)
        {
            // read header Size;
            int tmp;
            tmp = token.readShort();

            token.tableDTT.hisz = token.readByte();
            token.tableDTT.losz = token.readByte();

            token.tableDTT.hifilt = new float[token.tableDTT.hisz];
            token.tableDTT.lofilt = new float[token.tableDTT.losz];

            int aSize;
            if (token.tableDTT.hisz % 2 != 0)
            {
                aSize = (token.tableDTT.hisz + 1) / 2;
            }
            else
            {
                aSize = token.tableDTT.hisz / 2;
            }

            float[] aLofilt = new float[aSize];

            aSize--;
            for (int cnt = 0; cnt <= aSize; cnt++)
            {
                int sign = token.readByte();
                int scale = token.readByte();
                long shrtDat = token.readInt();
                aLofilt[cnt] = (float)shrtDat;

                while (scale > 0)
                {
                    aLofilt[cnt] /= 10.0F;
                    scale--;
                }

                if (sign != 0)
                {
                    aLofilt[cnt] *= -1.0F;
                }

                if (token.tableDTT.hisz % 2 != 0)
                {
                    token.tableDTT.hifilt[cnt + aSize] = intSign(cnt) * aLofilt[cnt];
                    if (cnt > 0)
                    {
                        token.tableDTT.hifilt[aSize - cnt] = token.tableDTT.hifilt[cnt + aSize];
                    }
                }
                else
                {
                    token.tableDTT.hifilt[cnt + aSize + 1] = intSign(cnt) * aLofilt[cnt];
                    token.tableDTT.hifilt[aSize - cnt] = -1 * token.tableDTT.hifilt[cnt + aSize + 1];
                }
            }

            if (token.tableDTT.losz % 2 != 0)
            {
                aSize = (token.tableDTT.losz + 1) / 2;
            }
            else
            {
                aSize = token.tableDTT.losz / 2;
            }

            float[] aHifilt = new float[aSize];

            aSize--;
            for (int cnt = 0; cnt <= aSize; cnt++)
            {
                int sign = token.readByte();
                int scale = token.readByte();
                long shrtDat = token.readInt();

                aHifilt[cnt] = (float)shrtDat;

                while (scale > 0)
                {
                    aHifilt[cnt] /= 10.0F;
                    scale--;
                }

                if (sign != 0)
                {
                    aHifilt[cnt] *= -1.0F;
                }

                if (token.tableDTT.losz % 2 != 0)
                {
                    token.tableDTT.lofilt[cnt + aSize] = intSign(cnt) * aHifilt[cnt];
                    if (cnt > 0)
                    {
                        token.tableDTT.lofilt[aSize - cnt] = token.tableDTT.lofilt[cnt + aSize];
                    }
                }
                else
                {
                    token.tableDTT.lofilt[cnt + aSize + 1] = intSign(cnt + 1) * aHifilt[cnt];
                    token.tableDTT.lofilt[aSize - cnt] = token.tableDTT.lofilt[cnt + aSize + 1];
                }
            }

            token.tableDTT.lodef = 1;
            token.tableDTT.hidef = 1;
        }
Ejemplo n.º 2
0
        private int getCNextbitsWSQ(TokenD token, IntRef marker, IntRef bitCount, int bitsReq, IntRef nextByte)
        {
            if (bitCount.value == 0)
            {
                nextByte.value = token.readByte();

                bitCount.value = 8;
                if (nextByte.value == 0xFF)
                {
                    int code2 = token.readByte();  /*stuffed byte of buffer*/

                    if (code2 != 0x00 && bitsReq == 1)
                    {
                        marker.value = (nextByte.value << 8) | code2;
                        return 1;
                    }
                    if (code2 != 0x00)
                    {
                        throw new SystemException("ERROR: getCNextbitsWSQ : No stuffed zeros.");
                    }
                }
            }

            int bits, tbits;  /*bits of current buffer byte requested*/
            int bitsNeeded; /*additional bits required to finish request*/

            if (bitsReq <= bitCount.value)
            {
                bits = (nextByte.value >> (bitCount.value - bitsReq)) & (WSQConstants.BITMASK[bitsReq]);
                bitCount.value -= bitsReq;
                nextByte.value &= WSQConstants.BITMASK[bitCount.value];
            }
            else
            {
                bitsNeeded = bitsReq - bitCount.value; /*additional bits required to finish request*/
                bits = nextByte.value << bitsNeeded;
                bitCount.value = 0;
                tbits = getCNextbitsWSQ(token, marker, bitCount, bitsNeeded, nextByte);
                bits |= tbits;
            }

            return bits;
        }
Ejemplo n.º 3
0
        private WSQHelper.HuffmanTable getCHuffmanTable(TokenD token, int maxHuffcounts, int bytesLeft, bool readTableLen)
        {
            WSQHelper.HuffmanTable huffmanTable = new WSQHelper.HuffmanTable();

            /* table_len */
            if (readTableLen)
            {
                huffmanTable.tableLen = token.readShort();
                huffmanTable.bytesLeft = huffmanTable.tableLen - 2;
                bytesLeft = huffmanTable.bytesLeft;
            }
            else
            {
                huffmanTable.bytesLeft = bytesLeft;
            }

            /* If no bytes left ... */
            if (bytesLeft <= 0)
            {
                throw new SystemException("ERROR : getCHuffmanTable : no huffman table bytes remaining");
            }

            /* Table ID */
            huffmanTable.tableId = token.readByte();
            huffmanTable.bytesLeft--;

            huffmanTable.huffbits = new int[WSQConstants.MAX_HUFFBITS];
            int numHufvals = 0;
            /* L1 ... L16 */
            for (int i = 0; i < WSQConstants.MAX_HUFFBITS; i++)
            {
                huffmanTable.huffbits[i] = token.readByte();
                numHufvals += huffmanTable.huffbits[i];
            }
            huffmanTable.bytesLeft -= WSQConstants.MAX_HUFFBITS;

            if (numHufvals > maxHuffcounts + 1)
            {
                throw new SystemException("ERROR : getCHuffmanTable : numHufvals is larger than MAX_HUFFCOUNTS");
            }

            /* Could allocate only the amount needed ... then we wouldn't */
            /* need to pass MAX_HUFFCOUNTS. */
            huffmanTable.huffvalues = new int[maxHuffcounts + 1];

            /* V1,1 ... V16,16 */
            for (int i = 0; i < numHufvals; i++)
            {
                huffmanTable.huffvalues[i] = token.readByte();
            }
            huffmanTable.bytesLeft -= numHufvals;

            return huffmanTable;
        }
Ejemplo n.º 4
0
        private WSQHelper.HeaderFrm getCFrameHeaderWSQ(TokenD token)
        {
            WSQHelper.HeaderFrm headerFrm = new WSQHelper.HeaderFrm();

            //noinspection UnusedDeclaration
            int hdrSize = token.readShort(); /* header size */

            headerFrm.black = token.readByte();
            headerFrm.white = token.readByte();
            headerFrm.height = token.readShort();
            headerFrm.width = token.readShort();
            int scale = token.readByte(); /* exponent scaling parameter */
            int shrtDat = token.readShort(); /* buffer pointer */
            headerFrm.mShift = (float)shrtDat;
            while (scale > 0)
            {
                headerFrm.mShift /= 10.0F;
                scale--;
            }

            scale = token.readByte();
            shrtDat = token.readShort();
            headerFrm.rScale = (float)shrtDat;
            while (scale > 0)
            {
                headerFrm.rScale /= 10.0F;
                scale--;
            }

            headerFrm.wsqEncoder = token.readByte();
            headerFrm.software = token.readShort();

            return headerFrm;
        }
Ejemplo n.º 5
0
 private int getCBlockHeader(TokenD token)
 {
     token.readShort(); /* block header size */
     return token.readByte();
 }
Ejemplo n.º 6
0
        public void getCQuantizationTable(TokenD token)
        {
            int tmp;
            tmp = token.readShort(); /* header size */
            int scale = token.readByte(); /* scaling parameter */
            int shrtDat = token.readShort(); /* counter and temp short buffer */

            token.tableDQT.binCenter = (float)shrtDat;
            while (scale > 0)
            {
                token.tableDQT.binCenter /= 10.0F;
                scale--;
            }

            for (int cnt = 0; cnt < Table_DQT.MAX_SUBBANDS; cnt++)
            {
                scale = token.readByte();
                shrtDat = token.readShort();
                token.tableDQT.qBin[cnt] = (float)shrtDat;
                while (scale > 0)
                {
                    token.tableDQT.qBin[cnt] /= 10.0F;
                    scale--;
                }

                scale = token.readByte();
                shrtDat = token.readShort();
                token.tableDQT.zBin[cnt] = (float)shrtDat;
                while (scale > 0)
                {
                    token.tableDQT.zBin[cnt] /= 10.0F;
                    scale--;
                }
            }

            token.tableDQT.dqtDef = (char)1;
        }