An MPEG decoder verifies a previous video packet by calculating the sum-of-the-absolute
differences (SAD) for macroblock boundaries. When a macroblock counter goes off
count, the macroblocks can be placed in the wrong relative locations in a frame.
Image shapes are sliced when macroblock misplacement occurs, creating many new
bisecting edges along macroblock boundaries. These image discontinuities along
macroblock boundaries have a large SAD for pixels on either side of the macroblock
boundary. The SAD is generated along the left and upper edges of a current macroblock,
and a maximum SAD of all macroblocks in the previous video packet is generated.
When the maximum SAD is above a threshold, the macroblock counter is likely to
be in error, and the macroblock counter is reloaded with the header macroblock
number from the next packet header. When the SAD is below threshold, a mis-matching
header macroblock number is ignored.