home :: class_hierarchy

Coding Element Class Hierarchy

The CodingElement Class

At the root of the coding element class hierarchy is the "CodingElement" class. This is an abstract class with no direct instantiations. This class encapsulates information common to every coding element including:

  • BitAddress
    A read only property returning the bit count of the first bit of this coding element. In other words, the number of bits read from the BitStream object before this coding element was encountered. NOTE: this is the count of *bits* not bytes.
  • Length
    A read-only property returning the length of this coding element in bits as encoded in the bitstream.
  • isContiguous()
    A method that returns a boolean value indicating whether all of the bits that encode this coding element are contiguous in the bitstream. The was intended to support coding elements which are compound elements which encapsulate other coding elements that are not necessarily back-to-back within the bitstream. In practice, all coding elements, including compound ones like the picture header, are contiguous.

Atomic vs. Compound Coding Elements

At this point, it may be useful to discuss the difference between an "atomic" coding element and a "compound" coding element. An atomic coding element is a sequence of bits that encode a specific value with a specific purpose. For example, a 32-bit start code is an atomic coding element, the 10 bits that make up the temporal reference number in a picture header is an atomic coding element, and so on. A compound coding element is a collection of one or more atomic coding elements that form a higher level of syntax for the video stream. For example, all of the atomic coding elements that go into a picture header are collected together in a compound coding element called PictureHeader. Atomic coding elements are published as events as they are encountered. Compound coding elements are published after the last of its components is published.

Compound coding element events generally provide an interface to retrieve its component parts if you need them. This allows you to subscribe to the level of detail that makes the most sense. If, for example, you are interested in a number of different pieces of information that all reside in the picture header (e.g., the temporal reference, the picture coding type I, P, or B, etc.), then it would make sense to subscribe to the entire picture header event and then get to the specific pieces of information you need by going through the published picture header event. If you really just need the temporal reference, then it would make more sense to just subscribe to the temporal reference event.

Atomic coding element events are all subclasses of the abstract class AtomicCodingElement, which in turn is a direct subclass of CodingElement. Most compound element events are direct subclasses of CodingElement. The notable exceptions are the SequenceHeader, SequenceExtension, PictureHeader, PictureCodingExtension, GroupOfPicturesHeader, SliceHeader, and QuantMatrixExtension which are all grouped together as subclasses of Header which in turn is a direct subclass of CodingElement. The Header class does not provide much functionality other than give you a convenient way to subscribe to all the header type events without having to specify a handler for each specific header type. Note that the start code coding element that announces the presence of a particular header is not considered part of the header (i.e., the StartCode atomic coding element is not contained by the header that the StartCode identifies).

It is important to note that the organization of these coding element event types does not reflect the organization of the MPEG-2 bitstream. In other words, the Slice coding element contains Macroblock coding elements which in turn contain MacroblockAddressDelta, MacroblockMode, and Block coding elements. However, all of these coding elements mentioned are just direct subclasses of CodingElement since they are all compound coding elements. For more information on the organization of an MPEG-2 bitstream (i.e., which compound elements contain which other compound and atomic coding elements, what order things arrive in, etc.) see here for an overview. Full details, of course, can be found in the MPEG-2 standard specification.

The Hierarchy

Below is an abbreviated map to the coding element class hierarchy. The numerous atomic coding elements are not all individually listed, but it should give you a general idea for how things are structured and lists some of the more important atomic coding elements that you may find useful. See the class documentation for more details.

  • CodingElement
    • AtomicCodingElement
      • StartCode
      • OpaqueBits
      • HuffmanEncodedCoeff
      • TemporalReference
      • PictureStructure
      • PictureCodingType
      • Other subclasses of AtomicCodingElement too numerous to list invidually
    • Header
      • SequenceHeader
      • SequenceExtension
      • PictureHeader
      • PictureCodingExtension
      • GroupOfPicturesHeader
      • SliceHeader
      • QuantMatrixExtension
    • Macroblock
    • MacroblockAddressDelta
    • MacroblockMode
    • MotionVector
    • Block
    • DiffEncodedCoeff
    • MatrixCodingElement
      • IntraQuantiserMatrix
      • NonIntraQuantiserMatrix
      • ChromaIntraQuantiserMatrix
      • ChromaNonIntraQuantiserMatrix
    • UserData
    • Slice

permalink 2004.11.23-09:24.00