cz.cuni.jagrlib
Class DefaultBlockQuantizer

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.DefaultBlockQuantizer
All Implemented Interfaces:
Breakable, BlockQuantizer, PersistentParamsBinary, Property, Template
Direct Known Subclasses:
JPEGQuantizer

public abstract class DefaultBlockQuantizer
extends Piece
implements BlockQuantizer

Default implementation of BlockQuantizer interface.

Since:
0.24
See Also:
DefaultBlockQuantizer.java

Field Summary
protected static java.lang.String CATEGORY
          Object category.
protected static java.lang.String TEMPLATE_NAME
          Object template identifier.
protected  double[] tmpD
          Temporary array for intermediate double values.
protected  int[] tmpI
          Temporary array for intermediate integer values.
protected  int variant
          Quantizer variant (context).
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, reg, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
DefaultBlockQuantizer()
           
 
Method Summary
 int dequantize(int[] quant, double[] coef)
          Dequantization = reconstruction (floating-point form).
 int dequantize(int[] quant, int[] coef)
          Dequantization = reconstruction (integer form).
 boolean loadData(byte[] data)
          Loads instance parameters from (previously stored) binary data.
 int quantize(double[] coef, int[] quant)
          Quantization (floating-point form).
 int quantize(int[] coef, int[] quant)
          Quantization (integer form).
 void setBlockSize(int width, int height)
          Sets actual block size.
 void setData(int[] qtable)
          Sets quantization table for the current variant.
 void setQuality(float quality)
          Sets actual quality coefficient.
 int setVariant(int variant)
          Set actual quantizer variant (context).
 byte[] storeData()
          Pack instance parameters into binary format.
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplate, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 

Field Detail

tmpI

protected int[] tmpI
Temporary array for intermediate integer values.


tmpD

protected double[] tmpD
Temporary array for intermediate double values.


variant

protected int variant
Quantizer variant (context).


TEMPLATE_NAME

protected static final java.lang.String TEMPLATE_NAME
Object template identifier.

See Also:
Constant Field Values

CATEGORY

protected static final java.lang.String CATEGORY
Object category.

See Also:
Constant Field Values
Constructor Detail

DefaultBlockQuantizer

public DefaultBlockQuantizer()
Method Detail

setVariant

public int setVariant(int variant)
Set actual quantizer variant (context).

Specified by:
setVariant in interface BlockQuantizer
Parameters:
variant - Variant number (from 0).
Returns:
Old variant number.
See Also:
setBlockSize(int, int), setQuality(float), setData(int[])

setBlockSize

public void setBlockSize(int width,
                         int height)
Sets actual block size. Can be used both for 1D and 2D quantization.

Specified by:
setBlockSize in interface BlockQuantizer
Parameters:
width - Horizontal block size (1D block size).
height - Vertical block size (1 for 1D).
See Also:
setVariant(int), setQuality(float), setData(int[])

setQuality

public void setQuality(float quality)
Sets actual quality coefficient. Value range for the quality: 0.0f to 1.0f.

Specified by:
setQuality in interface BlockQuantizer
Parameters:
quality - New quality coefficient.
See Also:
setVariant(int), setBlockSize(int, int), setData(int[])

setData

public void setData(int[] qtable)
Sets quantization table for the current variant.

Specified by:
setData in interface BlockQuantizer
Parameters:
qtable - New quantization table. Should have the correct size and layout (scanline top-first, left-first).
See Also:
setVariant(int), setQuality(float), setBlockSize(int, int)

quantize

public int quantize(double[] coef,
                    int[] quant)
Quantization (floating-point form).

Specified by:
quantize in interface BlockQuantizer
Parameters:
coef - Source data (coefficients). Size = array size. Should have the correct size and layout (scanline top-first, left-first).
quant - Pre-allocated result array or null if it's size needs to be determined.
Returns:
Result array size (even if the quantization was not performed).
See Also:
quantize(int[],int[]), dequantize(int[],double[])

quantize

public int quantize(int[] coef,
                    int[] quant)
Quantization (integer form).

Specified by:
quantize in interface BlockQuantizer
Parameters:
coef - Source data (coefficients). Size = array size. Should have the correct size and layout (scanline top-first, left-first).
quant - Pre-allocated result array or null if it's size needs to be determined.
Returns:
Result array size (even if the quantization was not performed).
See Also:
quantize(double[],int[]), dequantize(int[],int[])

dequantize

public int dequantize(int[] quant,
                      double[] coef)
Dequantization = reconstruction (floating-point form).

Specified by:
dequantize in interface BlockQuantizer
Parameters:
quant - Source data (quantized coefficients). Size = array size. Should have the correct size and layout (scanline top-first, left-first).
coef - Pre-allocated coefficient array or null if it's size needs to be determined.
Returns:
Coefficient array size (even if the dequantization was not performed).
See Also:
dequantize(int[],int[]), quantize(double[],int[])

dequantize

public int dequantize(int[] quant,
                      int[] coef)
Dequantization = reconstruction (integer form).

Specified by:
dequantize in interface BlockQuantizer
Parameters:
quant - Source data (quantized coefficients). Size = array size. Should have the correct size and layout (scanline top-first, left-first).
coef - Pre-allocated coefficient array or null if it's size needs to be determined.
Returns:
Coefficient array size (even if the dequantization was not performed).
See Also:
dequantize(int[],double[]), quantize(int[],int[])

storeData

public byte[] storeData()
Pack instance parameters into binary format.

Specified by:
storeData in interface PersistentParamsBinary
Returns:
Data array to be stored into binary stream. Can be null. The array can be shared by all method calls.
See Also:
loadData(byte[])

loadData

public boolean loadData(byte[] data)
Loads instance parameters from (previously stored) binary data.

Specified by:
loadData in interface PersistentParamsBinary
Parameters:
data - Binary data to be interpreted. Can be null.
Returns:
true if successful.
See Also:
storeData()