Top Description Inners Fields Constructors Methods
org.apache.pdfbox.jbig2.decoder.mmr

public Class MMRDecompressor

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, java.util.Arrays, javax.imageio.stream.ImageInputStream, org.apache.pdfbox.jbig2.Bitmap

A decompressor for MMR compression.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
MMRDecompressor.RunData

A class encapsulating the compressed raw data.

Field Summary

Modifier and TypeField and Description
private static MMRDecompressor.Code[]
private MMRDecompressor.RunData
private static final int
private static final int
private int
private static MMRDecompressor.Code[]
private static final int
private static final int
private static MMRDecompressor.Code[]
private int

Constructor Summary

AccessConstructor and Description
public
MMRDecompressor(int width, int height, ImageInputStream stream)

Method Summary

Modifier and TypeMethod and Description
private static MMRDecompressor.Code[]
createLittleEndianTable(int[][] codes)

For little endian, the tables are structured like this:

 v--------v length = FIRST_LEVEL_TABLE_LENGTH
               v-----v length = SECOND_LEVEL_TABLE_LENGTH

 A code word which fits into the first level table (length=3)
 [Cccvvvvv]

 A code word which needs the second level table also (length=10)
 [Cccccccc] -> [ccvvv]

 "C" denotes the first code word bit
 "c" denotes a code word bit
 "v" denotes a variant bit
private void
private void
fillBitmap(Bitmap result, int line, int[] currentOffsets, int count)

private static final synchronized void
public Bitmap
private final int
uncompress1D(MMRDecompressor.RunData runData, int[] runOffsets, int width)

private final int
uncompress2D(MMRDecompressor.RunData runData, int[] referenceOffsets, int refRunLength, int[] runOffsets, int width)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blackTableback to summary
private static MMRDecompressor.Code[] blackTable
databack to summary
private MMRDecompressor.RunData data
FIRST_LEVEL_TABLE_MASKback to summary
private static final int FIRST_LEVEL_TABLE_MASK
FIRST_LEVEL_TABLE_SIZEback to summary
private static final int FIRST_LEVEL_TABLE_SIZE
heightback to summary
private int height
modeTableback to summary
private static MMRDecompressor.Code[] modeTable
SECOND_LEVEL_TABLE_MASKback to summary
private static final int SECOND_LEVEL_TABLE_MASK
SECOND_LEVEL_TABLE_SIZEback to summary
private static final int SECOND_LEVEL_TABLE_SIZE
whiteTableback to summary
private static MMRDecompressor.Code[] whiteTable
widthback to summary
private int width

Constructor Detail

MMRDecompressorback to summary
public MMRDecompressor(int width, int height, ImageInputStream stream)

Method Detail

createLittleEndianTableback to summary
private static MMRDecompressor.Code[] createLittleEndianTable(int[][] codes)

For little endian, the tables are structured like this:

 v--------v length = FIRST_LEVEL_TABLE_LENGTH
               v-----v length = SECOND_LEVEL_TABLE_LENGTH

 A code word which fits into the first level table (length=3)
 [Cccvvvvv]

 A code word which needs the second level table also (length=10)
 [Cccccccc] -> [ccvvv]

 "C" denotes the first code word bit
 "c" denotes a code word bit
 "v" denotes a variant bit
detectAndSkipEOLback to summary
private void detectAndSkipEOL()
fillBitmapback to summary
private void fillBitmap(Bitmap result, int line, int[] currentOffsets, int count)
initTablesback to summary
private static final synchronized void initTables()
uncompressback to summary
public Bitmap uncompress()
uncompress1Dback to summary
private final int uncompress1D(MMRDecompressor.RunData runData, int[] runOffsets, int width)
uncompress2Dback to summary
private final int uncompress2D(MMRDecompressor.RunData runData, int[] referenceOffsets, int refRunLength, int[] runOffsets, int width)
org.apache.pdfbox.jbig2.decoder.mmr back to summary

private final Class MMRDecompressor.Code

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv MMRDecompressor.Code[]

Constructor Summary

AccessConstructor and Description
pack-priv
Code(int[] codeData)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bitLengthback to summary
pack-priv final int bitLength
codeWordback to summary
pack-priv final int codeWord
runLengthback to summary
pack-priv final int runLength
subTableback to summary
pack-priv MMRDecompressor.Code[] subTable

Constructor Detail

Codeback to summary
pack-priv Code(int[] codeData)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

See Also
java.lang.Object#equals(Object)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

org.apache.pdfbox.jbig2.decoder.mmr back to summary

private final Class MMRDecompressor.RunData

extends Object
Class Inheritance

A class encapsulating the compressed raw data.

Field Summary

Modifier and TypeField and Description
pack-priv byte[]
pack-priv int
pack-priv int
private static final int
pack-priv int
pack-priv int
private static final int
private static final int
pack-priv int
pack-priv ImageInputStream
stream

Compressed data stream.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
align()

Skip to next byte

private void
fillBuffer(int byteOffset)

private final MMRDecompressor.Code
private final MMRDecompressor.Code
private final int
uncompressGetNextCodeLittleEndian()

Fill up the code word in little endian mode.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
pack-priv byte[] buffer
bufferBaseback to summary
pack-priv int bufferBase
bufferTopback to summary
pack-priv int bufferTop
CODE_OFFSETback to summary
private static final int CODE_OFFSET
lastCodeback to summary
pack-priv int lastCode
lastOffsetback to summary
pack-priv int lastOffset
MAX_RUN_DATA_BUFFERback to summary
private static final int MAX_RUN_DATA_BUFFER
MIN_RUN_DATA_BUFFERback to summary
private static final int MIN_RUN_DATA_BUFFER
offsetback to summary
pack-priv int offset
streamback to summary
pack-priv ImageInputStream stream

Compressed data stream.

Constructor Detail

RunDataback to summary
pack-priv RunData(ImageInputStream stream)

Method Detail

alignback to summary
private void align()

Skip to next byte

fillBufferback to summary
private void fillBuffer(int byteOffset) throws IOException
uncompressGetCodeback to summary
private final MMRDecompressor.Code uncompressGetCode(MMRDecompressor.Code[] table)
uncompressGetCodeLittleEndianback to summary
private final MMRDecompressor.Code uncompressGetCodeLittleEndian(MMRDecompressor.Code[] table)
uncompressGetNextCodeLittleEndianback to summary
private final int uncompressGetNextCodeLittleEndian()

Fill up the code word in little endian mode. This is a hotspot, therefore the algorithm is heavily optimised. For the frequent cases (i.e. short words) we try to get away with as little work as possible.
This method returns code words of 16 bits, which are aligned to the 24th bit. The lowest 8 bits are used as a "queue" of bits so that an access to the actual data is only needed, when this queue becomes empty.