fi.helsinki.cs.ohtu.mpeg2.video
Class SliceHeader

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.video.SliceHeader

public class SliceHeader
extends java.lang.Object

Represents the slice header.


Field Summary
private  boolean intraSlice
           
private  int quantizerScaleCode
           
private  int slicePictureID
           
private  boolean slicePictureIDEnabled
           
private  int verticalPosition
           
private  boolean verticalPositionExtensionEnabled
           
 
Constructor Summary
SliceHeader(int verticalPosition, boolean verticalPositionExtensionEnabled, int quantizerScaleCode)
          Constructs a new SliceHeader instance with the specified vertical position and quantizer scale code.
 
Method Summary
 int getQuantizerScaleCode()
          Returns the current quantizer scale code of this slice.
 int getSlicePictureID()
          Returns the slice picture ID.
 int getVerticalPosition()
          Returns the vertical position of this slice.
 boolean isIntraSlice()
          Returns whether the intra slice flag is set.
 boolean isSlicePictureIDEnabled()
          Returns whether the slice picture ID has been set or not.
 boolean isVerticalPositionExtensionEnabled()
          Returns a boolean indicating whether the vertical position extension is enabled or not.
 void setIntraSlice(boolean intraSlice)
          Sets the intra slice flag.
 void setQuantizerScaleCode(int quantizerScaleCode)
          Sets the quantizer scale code for this slice.
 void setSlicePictureID(int slicePictureID)
          Sets the picture ID for this slice.
 void setVerticalPosition(int verticalPosition)
          Sets the vertical position for this slice.
 void setVerticalPositionExtensionEnabled(boolean verticalPositionExtensionEnabled)
          Sets whether the vertical position extension is enabled or not.
 void unsetSlicePictureID()
          Unsets the picture ID.
 void writeTo(BitOutputStream stream)
          Writes the slice header to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verticalPosition

private int verticalPosition

verticalPositionExtensionEnabled

private boolean verticalPositionExtensionEnabled

quantizerScaleCode

private int quantizerScaleCode

intraSlice

private boolean intraSlice

slicePictureIDEnabled

private boolean slicePictureIDEnabled

slicePictureID

private int slicePictureID
Constructor Detail

SliceHeader

public SliceHeader(int verticalPosition,
                   boolean verticalPositionExtensionEnabled,
                   int quantizerScaleCode)
Constructs a new SliceHeader instance with the specified vertical position and quantizer scale code. If the frame this slice is in contains more than 175 rows of macroblocks (usually when there are more than 2800 lines) then the vertial position extension must be enabled. With the vertical position extension there can be 1024 rows of macroblocks.

Parameters:
verticalPosition - The vertical position of this slice. Without the extension this must be in the range [1..175]. With the extension this must be in the range [1..1024].
verticalPositionExtensionEnabled - Whether the vertical position extension is enabled or not.
quantizerScaleCode - The quantizer scale code for macroblocks in this slice.
Method Detail

setVerticalPosition

public void setVerticalPosition(int verticalPosition)
Sets the vertical position for this slice.

Parameters:
verticalPosition - The vertical position of this slice. Without the extension this must be in the range [1..175]. With the extension this must be in the range [1..1024].

getVerticalPosition

public int getVerticalPosition()
Returns the vertical position of this slice.

Returns:
This slice's vertical position.

isVerticalPositionExtensionEnabled

public boolean isVerticalPositionExtensionEnabled()
Returns a boolean indicating whether the vertical position extension is enabled or not.

Returns:
True if the extension is enabled and false otherwise.

setVerticalPositionExtensionEnabled

public void setVerticalPositionExtensionEnabled(boolean verticalPositionExtensionEnabled)
Sets whether the vertical position extension is enabled or not.

Parameters:
verticalPositionExtensionEnabled - Whether the vertical position extension is enabled or not.

setQuantizerScaleCode

public void setQuantizerScaleCode(int quantizerScaleCode)
Sets the quantizer scale code for this slice. Macroblocks inherit this value, but can override it.

Parameters:
quantizerScaleCode - The quantizer scale code to use.

getQuantizerScaleCode

public int getQuantizerScaleCode()
Returns the current quantizer scale code of this slice.

Returns:
This slice's quantizer scale code.

isIntraSlice

public boolean isIntraSlice()
Returns whether the intra slice flag is set. This flag may be set to true for slices containing only intra type macroblocks.

Returns:
Whether the intra slice flag is set or not.

setIntraSlice

public void setIntraSlice(boolean intraSlice)
Sets the intra slice flag. This flag may be set to true for slices containing only intra type macroblocks. This does not affect the decoding process. Instead it is inteded to help media devices implement fast forward/reverse. It is allowed to set this flag to false even if a slice does contain only intra type macroblocks.

Parameters:
intraSlice - Whether the intra slice flag should be set or not.

getSlicePictureID

public int getSlicePictureID()
Returns the slice picture ID.

Returns:
This slice's picture ID.

setSlicePictureID

public void setSlicePictureID(int slicePictureID)
Sets the picture ID for this slice. This must be the same for all slices in a picture. This does not affect the decoding process. The picture ID provides some error resilience by informing which slices belong to a new picture in situations where picture headers have been lost.

Parameters:
slicePictureID - The picture ID for this slice.

unsetSlicePictureID

public void unsetSlicePictureID()
Unsets the picture ID. As a result the picture ID is not written to the stream.


isSlicePictureIDEnabled

public boolean isSlicePictureIDEnabled()
Returns whether the slice picture ID has been set or not.

Returns:
True if the slice picture has been set and has not been unset. False otherwise.

writeTo

public void writeTo(BitOutputStream stream)
             throws java.io.IOException
Writes the slice header to a stream. The slice extension part (containing the intra slice flag and slice picture ID) is written only if either the intra slice flag is true or the slice picture ID is enabled. Otherwise the intra slice flag is implicitly false.

Parameters:
stream - The stream to write to.
Throws:
java.io.IOException - Exception from the stream.