1. A macroblock-counting error-detector comprising: a macroblock decoder, coupled to a bitstream input, for decoding macroblocks in a bitstream;
a macroblock counter for counting a number of macroblocks decoded from the bitstream;
a header decoder, coupled to the bitstream input, for decoding a packet header that includes a header macroblock number;
a count comparator, coupled to the macroblock counter and to the header decoder, for comparing the header macroblock number to a macroblock count from the macroblock counter;
an error controller, activated by the count comparator, for controlling over-writing of the macroblock counter by the header macroblock number to recover from a macroblock counting error;
a discontinuity calculator, responsive to the error controller, receiving edge pixels from at least two macroblocks, the edge pixels being along at least one common edge between the at least two macroblocks, for calculating a degree of pixel discontinuity; and
a discontinuity comparator for comparing the degree of pixel discontinuity from the discontinuity calculator to a threshold, the error controller over-writing the macroblock counter with the header macroblock number when the threshold is met,
whereby the degree of pixel discontinuity controls over-writing of the macroblock counter with the header macroblock number.