|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.helsinki.cs.ohtu.mpeg2.video.Quantizer
public class Quantizer
Contains the quantization functionality used in MPEG-2. All the input and output arrays in this class represent 8*8 matrices in row-major format.
Nested Class Summary | |
---|---|
static class |
Quantizer.ScaleType
This enumeration contains the two quantizer scale mappings used in MPEG-2. |
Field Summary | |
---|---|
private static int |
HEIGHT
|
static int[] |
INTRA_BLOCK_DEFAULT_WEIGHTS
This is the default weighting matrix for the quantization of intra blocks. |
private int[] |
intraBlockWeights
|
private int |
intraDCMult
|
private int |
intraDCPrecision
|
private static int[] |
LINEAR_SCALE
|
static int[] |
NON_INTRA_BLOCK_DEFAULT_WEIGHTS
This is the default weighting matrix for the quantization of non-intra blocks. |
private int[] |
nonIntraBlockWeights
|
private static int[] |
NONLINEAR_SCALE
|
private Quantizer.ScaleType |
scaleType
|
private static int |
WIDTH
|
Constructor Summary | |
---|---|
Quantizer(int[] intraBlockWeights,
int[] nonIntraBlockWeights,
Quantizer.ScaleType scaleType,
int intraDCPrecision)
Constructs a new quantizer with the given weighting matrices, quantizer scaling type and precision of DC coefficients in intra blocks. |
|
Quantizer(Quantizer.ScaleType scaleType,
int intraDCPrecision)
Constructs a new quantizer with the default weighting matrices and the given quantizer scaling type and precision of the DC coefficients in intra blocks. |
Method Summary | |
---|---|
private void |
doMismatchControl(int[] values)
|
int[] |
getIntraBlockWeights()
|
int |
getIntraDCPrecision()
|
int[] |
getNonIntraBlockWeights()
|
Quantizer.ScaleType |
getScaleType()
|
int[] |
inverseQuantize(int[] input,
boolean intra,
int scaleCode)
Inverse quantizes the given block, saturates the values and performs MPEG-2 style mismatch control on the result. |
void |
inverseQuantize(int[] input,
int[] target,
boolean intra,
int scaleCode)
Inverse quantizes the given block, saturates the values and performs MPEG-2 style mismatch control on the result. |
private void |
inverseQuantizeIntra(int[] input,
int[] target,
int intraDCMult,
int scale)
|
private int |
inverseQuantizeIntraACCoefficient(int value,
int weight,
int scale)
|
private int |
inverseQuantizeIntraDCCoefficient(int quantizedValue,
int intraDCMult)
|
private void |
inverseQuantizeNonIntra(int[] input,
int[] target,
int scale)
|
private int |
inverseQuantizeNonIntraCoefficient(int value,
int weight,
int scale)
|
int[] |
quantize(int[] input,
boolean intra,
int scaleCode)
Quantizes the given block and saturates the values. |
void |
quantize(int[] input,
int[] target,
boolean intra,
int scaleCode)
Quantizes the given block and saturates the values. |
private void |
quantizeIntra(int[] input,
int[] target,
int intraDCMult,
int scale)
|
private int |
quantizeIntraACCoefficient(int value,
int weight,
int scale)
|
private int |
quantizeIntraDCCoefficient(int value,
int intraDCMult)
|
private void |
quantizeNonIntra(int[] input,
int[] target,
int scale)
|
private int |
quantizeNonIntraCoefficient(int value,
int weight,
int scale)
|
private int |
saturate(int value,
int min,
int max)
|
private void |
saturateIntraForward(int[] input,
int[] target)
|
private void |
saturateInverse(int[] input,
int[] target)
|
private void |
saturateNonIntraForward(int[] input,
int[] target)
|
void |
setIntraBlockWeights(int[] intraBlockWeights)
|
void |
setIntraDCPrecision(int intraDCPrecision)
Sets the precision used in the quantization of DC coefficients in intra blocks. |
void |
setNonIntraBlockWeights(int[] nonIntraBlockWeights)
|
void |
setScaleType(Quantizer.ScaleType scaleType)
|
private int |
signum(int a)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int[] LINEAR_SCALE
private static final int[] NONLINEAR_SCALE
public static final int[] INTRA_BLOCK_DEFAULT_WEIGHTS
public static final int[] NON_INTRA_BLOCK_DEFAULT_WEIGHTS
private static final int WIDTH
private static final int HEIGHT
private int[] intraBlockWeights
private int[] nonIntraBlockWeights
private Quantizer.ScaleType scaleType
private int intraDCPrecision
private int intraDCMult
Constructor Detail |
---|
public Quantizer(int[] intraBlockWeights, int[] nonIntraBlockWeights, Quantizer.ScaleType scaleType, int intraDCPrecision)
intraBlockWeights
- Matrix of the weights for quantizing intra blocks. This is a
8*8 two dimensional array in row-major format.nonIntraBlockWeights
- Matrix of the weights for quantizing non-intra blocks. This is
a 8*8 two dimensional array in row-major format.scaleType
- The quantizer scaling mapping type to use.intraDCPrecision
- The precision of the DC coefficients in intra blocks, in bits.
Must lie in range [8, 11].public Quantizer(Quantizer.ScaleType scaleType, int intraDCPrecision)
scaleType
- The quantizer scaling mapping type to use.intraDCPrecision
- The precision of the DC coefficients in intra blocks, in bits.
Must lie in range [8, 11].Method Detail |
---|
public void quantize(int[] input, int[] target, boolean intra, int scaleCode)
The DC coefficient in intra blocks will be in the range [0, 2^intra_dc_precision]. Other coefficients will be in the range [-2047, 2047].
Coefficients in non-intra blocks will be in the range [-2047, 2047].
input
- The block to quantize.target
- Indicates where to put the result.intra
- Whether the input block is an intra block.scaleCode
- The quantizer_scale_code used in the containing macroblock.public int[] quantize(int[] input, boolean intra, int scaleCode)
The DC coefficient in intra blocks will be in the range [0, 2^intra_dc_precision]. Other coefficients will be in the range [-2047, 2047].
Coefficients in non-intra blocks will be in the range [-2047, 2047].
input
- The block to quantize.intra
- Whether the input block is an intra block.scaleCode
- The quantizer_scale_code used in the containing macroblock.
private void quantizeIntra(int[] input, int[] target, int intraDCMult, int scale)
private void quantizeNonIntra(int[] input, int[] target, int scale)
private int quantizeIntraDCCoefficient(int value, int intraDCMult)
private int quantizeIntraACCoefficient(int value, int weight, int scale)
private int quantizeNonIntraCoefficient(int value, int weight, int scale)
public void inverseQuantize(int[] input, int[] target, boolean intra, int scaleCode)
input
- The block to inverse quantize.target
- Indicates where to put the result.intra
- Whether the input block is an intra block.scaleCode
- The quantizer_scale_code used in the containing macroblock.public int[] inverseQuantize(int[] input, boolean intra, int scaleCode)
input
- The block to inverse quantize.intra
- Whether the input block is an intra block.scaleCode
- The quantizer_scale_code used in the containing macroblock.
private void inverseQuantizeIntra(int[] input, int[] target, int intraDCMult, int scale)
private void inverseQuantizeNonIntra(int[] input, int[] target, int scale)
private int inverseQuantizeIntraDCCoefficient(int quantizedValue, int intraDCMult)
private int inverseQuantizeIntraACCoefficient(int value, int weight, int scale)
private int inverseQuantizeNonIntraCoefficient(int value, int weight, int scale)
private int signum(int a)
private void saturateIntraForward(int[] input, int[] target)
private void saturateNonIntraForward(int[] input, int[] target)
private void saturateInverse(int[] input, int[] target)
private int saturate(int value, int min, int max)
private void doMismatchControl(int[] values)
public void setIntraDCPrecision(int intraDCPrecision)
intraDCPrecision
- The precision in bits. Must be in range [8,11].public int getIntraDCPrecision()
public void setIntraBlockWeights(int[] intraBlockWeights)
intraBlockWeights
- The weighting matrix to be used for intra blockspublic int[] getIntraBlockWeights()
public void setNonIntraBlockWeights(int[] nonIntraBlockWeights)
nonIntraBlockWeights
- The weighting matrix to be used for non-intra blockspublic int[] getNonIntraBlockWeights()
public void setScaleType(Quantizer.ScaleType scaleType)
scaleType
- The new scale typepublic Quantizer.ScaleType getScaleType()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |