H.264 Motion Vector Extractor - User Guide - Retrieving the motion information

From RidgeRun Developer Wiki





Previous: User Guide/Preparing the buffer Index Next: User Guide/Error codes




This page provides a basic description of the output structures for the VectorExtractor class. From these structures the motion information can be retrieved for each frame in the stream.

Frame attributes

The Frame struct contains the following attributes to describe the result of extracting the motion vectors for a single frame.

Type

Name: type
Type: FrameType enum
This attribute describes the type of the frame held by the data buffer according to the H.264 types. The following types are supported:
  • P_FRAME
  • B_FRAME
  • I_FRAME
  • SP_FRAME
  • SI_FRAME
However, only the P_FRAME type will contain extracted motion vectors.

Frame number

Name: frameNumber
Type: unsigned integer
This attribute specifies the sequential number of the frame according to the information parsed from the H.264 Slice headers.

Number of motion vectors

Name: numMotionVectors
Type: unsigned integer
This attribute specifies the total amount of extracted motion vectors from the current frame.

Motion vectors

Name: motionVectors
Type: shared pointer to an array of the MotionVector struct
This will contain all the extracted motion vectors inside an array of size numMotionVectors. The motion vectors will have the structure explained in the next section.

MotionVector attributes

The MotionVector struct contains the following attributes to describe the motion information for a macroblock or a partition of a macroblock (this can be determined with the mbWidth and mbHeight attributes).

Frame type

Name: frameType
Type: unsigned integer
This attribute contains the type of the current frame in the same format as extracted from the Slice header.

Source X

Name: srcX
Type: integer
This attribute specifies the X coordinate of the motion vector's source, meaning the macroblock's position in the previous frame.

Source Y

Name: srcY
Type: integer
This attribute specifies the Y coordinate of the motion vector's source, meaning the macroblock's position in the previous frame.

Destination X

Name: dstX
Type: integer
This attribute specifies the X coordinate of the motion vector's destination, meaning the macroblock's position in the current frame.

Destination Y

Name: dstY
Type: integer
This attribute specifies the Y coordinate of the motion vector's destination, meaning the macroblock's position in the current frame.

Macroblock width

Name: mbWidth
Type: integer
This is the width of the macroblock's partition for which the current motion vector applies. A width of 16 is as wide as the macroblock, 8 means simple macroblock partitioning while 4 indicates sub-macroblock partitioning.

Macroblock height

Name: mbHeight
Type: integer
This is the height of the macroblock's partition for which the current motion vector applies. A width of 16 is as tall as the macroblock, 8 means simple macroblock partitioning while 4 indicates sub-macroblock partitioning.


Previous: User Guide/Preparing the buffer Index Next: User Guide/Error codes