fi.helsinki.cs.ohtu.mpeg2.video
Class IntraBlock.Predictors

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.video.IntraBlock.Predictors
Enclosing class:
IntraBlock

public static class IntraBlock.Predictors
extends java.lang.Object

Encapsulates the predictors used in the encoding of intra blocks. Writing a IntraBlock to a stream also updates the predictors for the next block to be written with the same IntraBlock.Predictors instance. This class can be thought of as a common context for writing out blocks that holds the next predictors to use as global state.


Field Summary
private  int chrominance1
           
private  int chrominance2
           
private  int intraDCPrecision
           
private  int luminance
           
 
Constructor Summary
IntraBlock.Predictors(int intraDCPrecision)
          Initializes a Predictors instance.
 
Method Summary
 int getIntraDCPrecision()
          Returns the currently used intra DC precision.
protected  int getPredictor(IntraBlock.ColourComponent cc)
          Returns the predictor to use for the next DC coefficient with the specified colour component.
 void reset()
          Resets the predictors to the values specified in the standard.
 void setIntraDCPrecision(int intraDCPrecision)
          Updates the intra DC precision in use.
protected  void setPredictor(IntraBlock.ColourComponent cc, int value)
          Sets the predictor for the next DC coefficient with the specified colour component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

luminance

private int luminance

chrominance1

private int chrominance1

chrominance2

private int chrominance2

intraDCPrecision

private int intraDCPrecision
Constructor Detail

IntraBlock.Predictors

public IntraBlock.Predictors(int intraDCPrecision)
Initializes a Predictors instance. A call to reset() is not needed directly after construction.

Parameters:
intraDCPrecision - The precision in use for DC coefficients of intra blocks. Must be in range [0..3].
Method Detail

setIntraDCPrecision

public void setIntraDCPrecision(int intraDCPrecision)
Updates the intra DC precision in use. This only affects the values the predictors are set to with subsequent reset() calls.

Parameters:
intraDCPrecision - The precision in use for DC coefficients of intra blocks. Must be in range [0..3].

getIntraDCPrecision

public int getIntraDCPrecision()
Returns the currently used intra DC precision.

Returns:
The precision in the range [0..3].

reset

public void reset()
Resets the predictors to the values specified in the standard. These depend on the intra DC precision in use.


getPredictor

protected int getPredictor(IntraBlock.ColourComponent cc)
Returns the predictor to use for the next DC coefficient with the specified colour component.

Parameters:
cc - The colour component for which to get the predictor.
Returns:
The predictor for the given colour component.

setPredictor

protected void setPredictor(IntraBlock.ColourComponent cc,
                            int value)
Sets the predictor for the next DC coefficient with the specified colour component.

Parameters:
cc - The colour component for which to set the predictor.
value - The new value for the predictor.