Example #1
0
        protected void blockInter(BitReader bits, VLC vlcCoeff, int[] block, int[] scan, int escSize, int qScale,
                                  int[] qmat)
        {
            //        System.out.println();

            int idx = -1;

            if (vlcCoeff == MPEGConst.vlcCoeff0 && bits.checkNBit(1) == 1)
            {
                bits.read1Bit();
                int dc = toSigned(quantInter(1, qScale * qmat[0]), bits.read1Bit());
                SparseIDCT.start(block, dc);
                idx++;
            }
            else
            {
                SparseIDCT.start(block, 0);
            }

            for (; idx < 64;)
            {
                int readVLC = vlcCoeff.readVLC(bits);
                int ac;
                if (readVLC == MPEGConst.CODE_END)
                {
                    break;
                }
                else if (readVLC == MPEGConst.CODE_ESCAPE)
                {
                    idx += bits.readNBit(6) + 1;
                    ac   = quantInterSigned(twosSigned(bits, escSize), qScale * qmat[idx]);
                }
                else
                {
                    idx += (readVLC >> 6) + 1;
                    ac   = toSigned(quantInter(readVLC & 0x3f, qScale * qmat[idx]), bits.read1Bit());
                }
                SparseIDCT.coeff(block, scan[idx], ac);
                //            System.out.print(ac + ",");
            }
            SparseIDCT.finish(block);
        }
Example #2
0
        protected void blockIntra(BitReader bits, VLC vlcCoeff, int[] block, int[] intra_dc_predictor, int blkIdx,
                                  int[] scan, int escSize, int intra_dc_mult, int qScale, int[] qmat)
        {
            int cc    = MPEGConst.BLOCK_TO_CC[blkIdx];
            int size  = (cc == 0 ? MPEGConst.vlcDCSizeLuma : MPEGConst.vlcDCSizeChroma).readVLC(bits);
            int delta = (size != 0) ? mpegSigned(bits, size) : 0;

            intra_dc_predictor[cc] = intra_dc_predictor[cc] + delta;
            int dc = intra_dc_predictor[cc] * intra_dc_mult;

            SparseIDCT.start(block, dc);

            for (int idx = 0; idx < 64;)
            {
                int readVLC = vlcCoeff.readVLC(bits);
                int level;

                if (readVLC == MPEGConst.CODE_END)
                {
                    break;
                }
                else if (readVLC == MPEGConst.CODE_ESCAPE)
                {
                    idx  += bits.readNBit(6) + 1;
                    level = twosSigned(bits, escSize) * qScale * qmat[idx];
                    level = level >= 0 ? (level >> 4) : -(-level >> 4);
                }
                else
                {
                    idx  += (readVLC >> 6) + 1;
                    level = toSigned(((readVLC & 0x3f) * qScale * qmat[idx]) >> 4, bits.read1Bit());
                }
                SparseIDCT.coeff(block, scan[idx], level);
            }
            SparseIDCT.finish(block);
        }