private final int uncompress1D()

in src/main/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressor.java [602:647]


    private final int uncompress1D(RunData runData, int[] runOffsets, int width)
    {

        boolean whiteRun = true;
        int iBitPos = 0;
        Code code = null;
        int refOffset = 0;

        loop: while (iBitPos < width)
        {
            while (true)
            {
                if (whiteRun)
                {
                    code = runData.uncompressGetCode(whiteTable);
                }
                else
                {
                    code = runData.uncompressGetCode(blackTable);
                }

                runData.offset += code.bitLength;

                if (code.runLength < 0)
                {
                    break loop;
                }

                iBitPos += code.runLength;

                if (code.runLength < 64)
                {
                    whiteRun = !whiteRun;
                    runOffsets[refOffset++] = iBitPos;
                    break;
                }
            }
        }

        if (runOffsets[refOffset] != width)
        {
            runOffsets[refOffset] = width;
        }

        return code != null && code.runLength != MMRConstants.EOL ? refOffset : MMRConstants.EOL;
    }