Usage: wish mpeg2info.tcl -- <filename>

...where <filename> contains an MPEG-2 video sequence.
NOTE: the file must be a video stream only, and not a video stream interleaved as part of a MPEG-2 system stream. Also, MPEG-1 streams are NOT supported.

This simple application allows random access to any frame in an MPEG-2 sequence which it then displays and annotates graphically with information about each macroblock.

The interface is comprised of a slider, a button, a display area, and an macroblock information display area.

The slider allows random access into any point in the file. The slider is marked in byte units from 0 to the file size. Upon moving the slider, the next displayable frame is found, decoded, and displayed. The slider is adjusted accordingly. The "Next" button single steps to the next frame.

The display is overlayed with graphical annotations for each macroblock. Green squares indicate intra-coded macroblocks (thus I-frames will have green squares overlayed on top of all macroblocks). Red squares indicate skipped macroblocks (thus these will appear only in P or B frames). Yellow lines indicate forward motion vectors and run from the upper left of the macroblock to the referred pixel position (note: half-pixel motion vectors are rounded to the nearest pixel). Blue lines indicate backward motion vectors.

If the mouse is dragged over the displayed frame, information specific to the macroblock under the pointer is displayed textually in the macroblock information area.

If the frame was encoded as two fields, the information displayed refers to the second field only, although two interlocking rectangles will be drawn to indicate the macroblock type (i.e., intracoded or skipped) for both top and bottom field. Lines are drawn only for the first forward and backward motion vectors although depending on the motion vector mode, more may have been encoded. Nothing is done to indicate graphically motion vector type or mode, or dct mode, but this information is displayed textually for a macroblock if the mouse is moved over that macroblock.

There is no way to step backwards.