Class HorizontalPredictor.Shorts

All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ReadableByteChannel
Enclosing class:
HorizontalPredictor

private static final class HorizontalPredictor.Shorts extends HorizontalPredictor
A horizontal predictor working on short integer values.
  • Field Details

    • savedValues

      private final short[] savedValues
      The trailing values of previous invocation of HorizontalPredictor.apply(ByteBuffer, int). After each call to apply(…), the last values in the buffer are saved for use by the next invocation. The buffer capacity is exactly one pixel.
  • Constructor Details

    • Shorts

      Shorts(CompressionChannel input, int samplesPerPixel, int width)
      Creates a new predictor.
  • Method Details

    • saveLastPixel

      void saveLastPixel(ByteBuffer buffer, int offset, int position)
      Saves HorizontalPredictor.pixelStride bytes making the sample values of the last pixel. The first sample value to read from the buffer is given by position.
      Specified by:
      saveLastPixel in class HorizontalPredictor
      Parameters:
      buffer - buffer from which to save sample values.
      offset - number of bytes to keep in the currently saved values.
      position - position in the buffer of the first byte to save, after the values to keep.
    • applyOnFirst

      int applyOnFirst(ByteBuffer buffer, int position, int end, int offset)
      Applies the predictor, using savedValues as the source of previous values. Used only for the first pixel in a new invocation of HorizontalPredictor.apply(ByteBuffer, int).
      Specified by:
      applyOnFirst in class HorizontalPredictor
      Parameters:
      buffer - the buffer on which to apply the predictor.
      position - position of the first value to modify in the given buffer.
      end - position after the last value to process in this apply(…) call.
      offset - offset (in bytes) of the first saved value to use.
      Returns:
      value of position after the last sample values processed by this method.
    • applyOnRow

      int applyOnRow(ByteBuffer buffer, int position, int end)
      Applies the predictor on a row of short integers.
      Specified by:
      applyOnRow in class HorizontalPredictor
      Parameters:
      buffer - the buffer on which to apply the predictor.
      position - position of the first value to modify in the given buffer.
      end - position after the last value to process in this apply(…) call.
      Returns:
      value of position after the last sample values processed by this method.