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

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

public class SequenceExtensionHeader
extends java.lang.Object

Represents extension part of the mandatory headers in a MPEG-2 video sequence. A video sequence is the highest level syntactic structure in a MPEG-2 video bitstream. A video sequence is described by headers which are written to its immediate beginning. This class represents the sequence extension header, the second of those headers. It always immediately follows a SequenceHeader in the bitstream. Together, they form a extended video sequence meta-header. The extended sequence header is represented by the class ExtendedSequenceHeader.


Nested Class Summary
static class SequenceExtensionHeader.ChromaFormat
          Represents the allowed values for the chroma format field.
static class SequenceExtensionHeader.Level
          Represents the allowed values for the level field.
static class SequenceExtensionHeader.Profile
          Represents the allowed values for the profile field.
static class SequenceExtensionHeader.SpecialProfileAndLevel
          Represents the allowed values for the special profile and level field.
 
Field Summary
(package private)  UnsignedIntegerField bitRateExtension
           
(package private)  SequenceExtensionHeader.ChromaFormat chromaFormat
           
(package private)  UnsignedIntegerField frameRateExtensionDenominator
           
(package private)  UnsignedIntegerField frameRateExtensionNumerator
           
(package private)  boolean hasSpecialProfileAndLevel
           
(package private)  UnsignedIntegerField horizontalSizeExtension
           
(package private)  SequenceExtensionHeader.Level level
           
(package private)  boolean lowDelay
           
(package private)  SequenceExtensionHeader.Profile profile
           
(package private)  boolean progressiveSequence
           
(package private)  SequenceExtensionHeader.SpecialProfileAndLevel specialProfileAndLevel
           
(package private)  UnsignedIntegerField vbvBufferSizeExtension
           
(package private)  UnsignedIntegerField verticalSizeExtension
           
 
Constructor Summary
SequenceExtensionHeader(SequenceExtensionHeader.Profile profile, SequenceExtensionHeader.Level level, boolean progressiveSequence, SequenceExtensionHeader.ChromaFormat chromaFormat, int horizontalSizeExtension, int verticalSizeExtension, int bitRateExtension, int vbvBufferSizeExtension, boolean lowDelay, int frameRateExtensionNumerator, int frameRateExtensionDenominator)
          Constructs a new instance.
SequenceExtensionHeader(SequenceExtensionHeader.SpecialProfileAndLevel profileAndLevel, boolean progressiveSequence, SequenceExtensionHeader.ChromaFormat chromaFormat, int horizontalSizeExtension, int verticalSizeExtension, int bitRateExtension, int vbvBufferSizeExtension, boolean lowDelay, int frameRateExtensionNumerator, int frameRateExtensionDenominator)
          Constructs a new instance.
 
Method Summary
private  void commonInit(boolean progressiveSequence, SequenceExtensionHeader.ChromaFormat chromaFormat, int horizontalSizeExtension, int verticalSizeExtension, int bitRateExtension, int vbvBufferSizeExtension, boolean lowDelay, int frameRateExtensionNumerator, int frameRateExtensionDenominator)
           
 long getBitRateExtension()
          Gets the bit rate extension.
 SequenceExtensionHeader.ChromaFormat getChromaFormat()
          Gets the chroma format.
 long getFrameRateExtensionDenominator()
          Gets the frame rate extension denominator.
 long getFrameRateExtensionNumerator()
          Gets the frame rate extension numerator.
 long getHorizontalSizeExtension()
          Gets the horizontal size extension.
 SequenceExtensionHeader.Level getLevel()
          Gets the level for this instance.
 SequenceExtensionHeader.Profile getProfile()
          Gets the profile for this instance.
 SequenceExtensionHeader.SpecialProfileAndLevel getSpecialProfileAndLevel()
          Gets the special profile and level combination specified by the header.
 long getVBVBufferSizeExtension()
          Gets the video buffering verifier buffer size extension.
 long getVerticalSizeExtension()
          Gets the vertical size extension.
 boolean hasSpecialProfileAndLevel()
          Returns whether the header specifies a special profile and level combination.
 boolean isLowDelay()
          Determines whether or not the header specifies the video sequence to be low-delay.
 boolean isProgressiveSequence()
          Determines whether or not the header specifies the video sequence to be entirely progressive.
 void setBitRateExtension(int bitRateExtension)
          Sets the bit rate extension.
 void setChromaFormat(SequenceExtensionHeader.ChromaFormat chromaFormat)
          Sets the chroma format for this instance.
 void setFrameRateExtensionDenominator(int frameRateExtensionDenominator)
          Sets the frame rate extension denominator.
 void setFrameRateExtensionNumerator(int frameRateExtensionNumerator)
          Sets the frame rate extension numerator.
 void setHorizontalSizeExtension(int horizontalSizeExtension)
          Sets the horizontal size extension.
 void setLowDelay(boolean lowDelay)
          Sets the header to specify whether the video sequence is low-delay or not.
 void setProfileAndLevel(SequenceExtensionHeader.Profile profile, SequenceExtensionHeader.Level level)
          Sets the the header to specify the given profile and level.
 void setProfileAndLevel(SequenceExtensionHeader.SpecialProfileAndLevel specialProfileAndLevel)
          Sets the the header to specify the given special profile and level combination.
 void setProgressiveSequence(boolean progressiveSequence)
          Sets whether or not the video sequence is specified to be entirely progressive.
 void setVBVBufferSizeExtension(int vbvBufferSizeExtension)
          Sets the video buffering verifier buffer size extension.
 void setVerticalSizeExtension(int verticalSizeExtension)
          Sets the vertical size extension.
 void writeTo(BitOutputStream stream)
          Writes the header to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasSpecialProfileAndLevel

boolean hasSpecialProfileAndLevel

profile

SequenceExtensionHeader.Profile profile

level

SequenceExtensionHeader.Level level

specialProfileAndLevel

SequenceExtensionHeader.SpecialProfileAndLevel specialProfileAndLevel

progressiveSequence

boolean progressiveSequence

chromaFormat

SequenceExtensionHeader.ChromaFormat chromaFormat

horizontalSizeExtension

UnsignedIntegerField horizontalSizeExtension

verticalSizeExtension

UnsignedIntegerField verticalSizeExtension

bitRateExtension

UnsignedIntegerField bitRateExtension

vbvBufferSizeExtension

UnsignedIntegerField vbvBufferSizeExtension

lowDelay

boolean lowDelay

frameRateExtensionNumerator

UnsignedIntegerField frameRateExtensionNumerator

frameRateExtensionDenominator

UnsignedIntegerField frameRateExtensionDenominator
Constructor Detail

SequenceExtensionHeader

public SequenceExtensionHeader(SequenceExtensionHeader.Profile profile,
                               SequenceExtensionHeader.Level level,
                               boolean progressiveSequence,
                               SequenceExtensionHeader.ChromaFormat chromaFormat,
                               int horizontalSizeExtension,
                               int verticalSizeExtension,
                               int bitRateExtension,
                               int vbvBufferSizeExtension,
                               boolean lowDelay,
                               int frameRateExtensionNumerator,
                               int frameRateExtensionDenominator)
Constructs a new instance. The header will initially specify the profile and level independently, as if a call to setProfileAndLevel(profile, level) was made.

Parameters:
profile - The initial profile.
progressiveSequence - The initial value for the progressive sequence flag.
level - The initial level.
chromaFormat - The initial chroma format.
horizontalSizeExtension - The initial horizontal size extension.
verticalSizeExtension - The initial vertical size extension.
bitRateExtension - The initial bit rate extension.
vbvBufferSizeExtension - The initial VBV buffer size extension.
lowDelay - The initial value for the low-delay flag.
frameRateExtensionNumerator - The initial frame rate extension numerator.
frameRateExtensionDenominator - The initial frame rate extension denominator.

SequenceExtensionHeader

public SequenceExtensionHeader(SequenceExtensionHeader.SpecialProfileAndLevel profileAndLevel,
                               boolean progressiveSequence,
                               SequenceExtensionHeader.ChromaFormat chromaFormat,
                               int horizontalSizeExtension,
                               int verticalSizeExtension,
                               int bitRateExtension,
                               int vbvBufferSizeExtension,
                               boolean lowDelay,
                               int frameRateExtensionNumerator,
                               int frameRateExtensionDenominator)
Constructs a new instance. The header will initially specify the profile and level together as a special combination, as if a call to setProfileAndLevel(profileAndLevel) was made.

Parameters:
profileAndLevel - The initial special profile and level combination.
progressiveSequence - The initial value for the progressive sequence flag.
chromaFormat - The initial chroma format.
horizontalSizeExtension - The initial horizontal size extension.
verticalSizeExtension - The initial vertical size extension.
bitRateExtension - The initial bit rate extension.
vbvBufferSizeExtension - The initial VBV buffer size extension.
lowDelay - The initial value for the low-delay flag.
frameRateExtensionNumerator - The initial frame rate extension numerator.
frameRateExtensionDenominator - The initial frame rate extension denominator.
Method Detail

commonInit

private void commonInit(boolean progressiveSequence,
                        SequenceExtensionHeader.ChromaFormat chromaFormat,
                        int horizontalSizeExtension,
                        int verticalSizeExtension,
                        int bitRateExtension,
                        int vbvBufferSizeExtension,
                        boolean lowDelay,
                        int frameRateExtensionNumerator,
                        int frameRateExtensionDenominator)

hasSpecialProfileAndLevel

public boolean hasSpecialProfileAndLevel()
Returns whether the header specifies a special profile and level combination. If true, getSpecialProfileAndLevel() will return the special profile and level combination specified. Otherwise, the profile and level are specified independently, as gettable using getProfile() and getLevel(), respectively.


getProfile

public SequenceExtensionHeader.Profile getProfile()
Gets the profile for this instance. This only makes sense if this header specifies the profile and level independently, as set by setProfileAndLevel(Profile profile, Level level).

Returns:
The profile.

getLevel

public SequenceExtensionHeader.Level getLevel()
Gets the level for this instance. This only makes sense if this header specifies the profile and level independently, as set by setProfileAndLevel(Profile profile, Level level).

Returns:
The level.

getSpecialProfileAndLevel

public SequenceExtensionHeader.SpecialProfileAndLevel getSpecialProfileAndLevel()
Gets the special profile and level combination specified by the header. This only makes sense if this header specifies a special profile and level combination, as set by setProfileAndLevel(SpecialProfileAndLevel specialProfileAndLevel).

Returns:
The combination.

setProfileAndLevel

public void setProfileAndLevel(SequenceExtensionHeader.Profile profile,
                               SequenceExtensionHeader.Level level)
Sets the the header to specify the given profile and level.

Parameters:
profile - The profile.
level - The level.

setProfileAndLevel

public void setProfileAndLevel(SequenceExtensionHeader.SpecialProfileAndLevel specialProfileAndLevel)
Sets the the header to specify the given special profile and level combination.

Parameters:
specialProfileAndLevel - The combination.

isProgressiveSequence

public boolean isProgressiveSequence()
Determines whether or not the header specifies the video sequence to be entirely progressive.

Returns:
true if the video sequence is entirely progressive, false if it can also contain interlaced frames and fields.

setProgressiveSequence

public void setProgressiveSequence(boolean progressiveSequence)
Sets whether or not the video sequence is specified to be entirely progressive.

Parameters:
progressiveSequence - true if the video sequence is entirely progressive, false if it can also contain interlaced frames and fields.

getChromaFormat

public SequenceExtensionHeader.ChromaFormat getChromaFormat()
Gets the chroma format.

Returns:
The format.

setChromaFormat

public void setChromaFormat(SequenceExtensionHeader.ChromaFormat chromaFormat)
Sets the chroma format for this instance.

Parameters:
chromaFormat - The format.

getHorizontalSizeExtension

public long getHorizontalSizeExtension()
Gets the horizontal size extension.

Returns:
The extension. Only the lowest 2 bits will be meaningful.

setHorizontalSizeExtension

public void setHorizontalSizeExtension(int horizontalSizeExtension)
Sets the horizontal size extension.

Parameters:
horizontalSizeExtension - The extension. The value must fit into 2 bits.

getVerticalSizeExtension

public long getVerticalSizeExtension()
Gets the vertical size extension.

Returns:
The extension. Only the lowest 2 bits will be meaningful.

setVerticalSizeExtension

public void setVerticalSizeExtension(int verticalSizeExtension)
Sets the vertical size extension.

Parameters:
verticalSizeExtension - The extension. The value must fit into 2 bits.

getBitRateExtension

public long getBitRateExtension()
Gets the bit rate extension.

Returns:
The extension. Only the lowest 12 bits will be meaningful.

setBitRateExtension

public void setBitRateExtension(int bitRateExtension)
Sets the bit rate extension.

Parameters:
bitRateExtension - The extension. The value must fit into 12 bits.

getVBVBufferSizeExtension

public long getVBVBufferSizeExtension()
Gets the video buffering verifier buffer size extension.

Returns:
The extension. Only the lowest 8 bits will be meaningful.

setVBVBufferSizeExtension

public void setVBVBufferSizeExtension(int vbvBufferSizeExtension)
Sets the video buffering verifier buffer size extension.

Parameters:
vbvBufferSizeExtension - The extension. The value must fit into 8 bits.

isLowDelay

public boolean isLowDelay()
Determines whether or not the header specifies the video sequence to be low-delay.

Returns:
true if the sequence is low-delay, false if not.

setLowDelay

public void setLowDelay(boolean lowDelay)
Sets the header to specify whether the video sequence is low-delay or not.

Parameters:
lowDelay - true if the sequence is low-delay, false if not.

getFrameRateExtensionNumerator

public long getFrameRateExtensionNumerator()
Gets the frame rate extension numerator.

Returns:
The numerator. Only the lowest 2 bits will be meaningful.

setFrameRateExtensionNumerator

public void setFrameRateExtensionNumerator(int frameRateExtensionNumerator)
Sets the frame rate extension numerator.

Parameters:
frameRateExtensionNumerator - The numerator. The value must fit into 2 bits.

getFrameRateExtensionDenominator

public long getFrameRateExtensionDenominator()
Gets the frame rate extension denominator.

Returns:
The denominator. Only the lowest 5 bits will be meaningful.

setFrameRateExtensionDenominator

public void setFrameRateExtensionDenominator(int frameRateExtensionDenominator)
Sets the frame rate extension denominator.

Parameters:
frameRateExtensionDenominator - The denominator. The value must fit into 5 bits.

writeTo

public void writeTo(BitOutputStream stream)
             throws java.io.IOException
Writes the header to a stream.

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