private void resizeYfirst()

in src/main/java/org/apache/pdfbox/jbig2/image/Resizer.java [279:356]


    private void resizeYfirst(final Object src, final Rectangle srcBounds, final Object dst,
            final Rectangle dstBounds, final ParameterizedFilter xFilter,
            final ParameterizedFilter yFilter)
    {
        // destination scanline buffer
        final Scanline buffer = createScanline(src, dst, dstBounds.width);

        // accumulator buffer
        final Scanline accumulator = createScanline(src, dst, srcBounds.width);

        // a sampled filter for source pixels for each destination x position
        final Weighttab xWeights[] = createXWeights(srcBounds, dstBounds, xFilter);

        // Circular buffer of active lines
        final int yBufferSize = yFilter.width + 2;
        final Scanline lineBuffer[] = new Scanline[yBufferSize];
        for (int y = 0; y < yBufferSize; y++)
        {
            lineBuffer[y] = createScanline(src, dst, srcBounds.width);

            // mark scanline as unread
            lineBuffer[y].y = -1;
        }

        // range of source and destination scanlines in regions
        final int srcY0 = srcBounds.y;
        final int srcY1 = srcBounds.y + srcBounds.height;
        final int dstY0 = dstBounds.y;
        final int dstY1 = dstBounds.y + dstBounds.height;

        // used to assert no backtracking
        int yFetched = -1;

        // loop over destination scanlines
        for (int dstY = dstY0; dstY < dstY1; dstY++)
        {
            // prepare a weighttab for destination y position by a single sampled filter for current y
            // position
            final Weighttab yWeight = new Weighttab(yFilter, weightOne,
                    mappingY.mapPixelCenter(dstY), srcY0, srcY1 - 1, true);

            accumulator.clear();

            // loop over source scanlines that contribute to this destination scanline
            for (int srcY = yWeight.i0; srcY <= yWeight.i1; srcY++)
            {
                final Scanline srcBuffer = lineBuffer[srcY % yBufferSize];
                if (srcBuffer.y != srcY)
                {
                    // scanline needs to be fetched from source raster
                    srcBuffer.y = srcY;

                    if (srcY0 + srcY <= yFetched)
                        throw new AssertionError(
                                "Backtracking from line " + yFetched + " to " + (srcY0 + srcY));

                    srcBuffer.fetch(srcBounds.x, srcY0 + srcY);

                    yFetched = srcY0 + srcY;
                }

                if (debug)
                    System.out.println(
                            dstY + "[] += " + srcY + "[] * " + yWeight.weights[srcY - yWeight.i0]);

                // add weighted source buffer into accumulator (these do y filter)
                srcBuffer.accumulate(yWeight.weights[srcY - yWeight.i0], accumulator);
            }

            // and filter it into the appropriate line of line buffer (x filter)
            accumulator.filter(bitsPerChannel, finalShift, xWeights, buffer);

            // store destination scanline into destination raster
            buffer.store(dstBounds.x, dstY);
            if (debug)
                System.out.printf("\n");
        }
    }