Class JpegDecoder
java.lang.Object
org.apache.commons.imaging.common.BinaryFileParser
org.apache.commons.imaging.formats.jpeg.decoder.JpegDecoder
- All Implemented Interfaces:
JpegUtils.Visitor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]private static final int[]private final float[]private final int[]private final DhtSegment.HuffmanTable[]private final DhtSegment.HuffmanTable[]private BufferedImageprivate ImagingExceptionprivate IOExceptionprivate final DqtSegment.QuantizationTable[]private final float[][]private SofnSegmentprivate SosSegmentprivate booleanprivate final int[] -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance with the default, big-endian, byte order. -
Method Summary
Modifier and TypeMethodDescriptionprivate Block[]booleanbeginSos()decode(ByteSource byteSource) private intdecode(JpegInputStream is, DhtSegment.HuffmanTable huffmanTable) private intextend(int v, int t) private static intfastRound(float x) getIntervalStartPositions(int[] scanPayload) Returns the positions of where each interval in the provided array starts.private voidreadMcu(JpegInputStream is, int[] preds, Block[] mcu) private intreceive(int ssss, JpegInputStream is) private voidrescaleMcu(Block[] dataUnits, int hSize, int vSize, Block[] ret) voidSets the decoder to treat incoming data as using the RGB color model.(package private) static JpegInputStream[]splitByRstMarkers(int[] scanPayload) Returns an array of JpegInputStream where each field contains the JpegInputStream for one interval.booleanvisitSegment(int marker, byte[] markerBytes, int segmentLength, byte[] segmentLengthBytes, byte[] segmentData) voidvisitSos(int marker, byte[] markerBytes, byte[] imageData) Methods inherited from class BinaryFileParser
debugNumber, debugNumber, getByteOrder, setByteOrder
-
Field Details
-
BAND_MASK_ARGB
private static final int[] BAND_MASK_ARGB -
BAND_MASK_RGB
private static final int[] BAND_MASK_RGB -
quantizationTables
-
huffmanDCTables
-
huffmanACTables
-
sofnSegment
-
sosSegment
-
scaledQuantizationTables
private final float[][] scaledQuantizationTables -
image
-
imageReadException
-
ioException
-
zz
private final int[] zz -
blockInt
private final int[] blockInt -
block
private final float[] block -
useTiffRgb
private boolean useTiffRgb
-
-
Constructor Details
-
JpegDecoder
public JpegDecoder()Constructs a new instance with the default, big-endian, byte order.
-
-
Method Details
-
fastRound
private static int fastRound(float x) -
getIntervalStartPositions
Returns the positions of where each interval in the provided array starts. The number of start positions is also the count of intervals while the number of restart markers found is equal to the number of start positions minus one (because restart markers are between intervals).- Parameters:
scanPayload- array to examine- Returns:
- the start positions
-
splitByRstMarkers
Returns an array of JpegInputStream where each field contains the JpegInputStream for one interval.- Parameters:
scanPayload- array to read intervals from- Returns:
- JpegInputStreams for all intervals, at least one stream is always provided
-
allocateMcuMemory
- Throws:
ImagingException
-
beginSos
public boolean beginSos()- Specified by:
beginSosin interfaceJpegUtils.Visitor
-
decode
- Throws:
IOExceptionImagingException
-
decode
private int decode(JpegInputStream is, DhtSegment.HuffmanTable huffmanTable) throws ImagingException - Throws:
ImagingException
-
extend
private int extend(int v, int t) -
readMcu
- Throws:
ImagingException
-
receive
- Throws:
ImagingException
-
rescaleMcu
-
setTiffRgb
public void setTiffRgb()Sets the decoder to treat incoming data as using the RGB color model. This extension to the JPEG specification is intended to support TIFF files that use JPEG compression. -
visitSegment
public boolean visitSegment(int marker, byte[] markerBytes, int segmentLength, byte[] segmentLengthBytes, byte[] segmentData) throws ImagingException, IOException - Specified by:
visitSegmentin interfaceJpegUtils.Visitor- Throws:
ImagingExceptionIOException
-
visitSos
public void visitSos(int marker, byte[] markerBytes, byte[] imageData) - Specified by:
visitSosin interfaceJpegUtils.Visitor
-