Log in

View Full Version : Anyone can help me with MPEG-2 field prediction?


Magno
10th June 2004, 16:44
I am developing a MPEG-2 application to decode and debug a MPEG-2 compliant stream step by step. I have coded all motion estimation algorithms described by the standar ISO/IEC 13818-2(MPEG-2 VIDEO), but i have right now some problems: whenever i try to decode a picture which has some field-predicted (16x8, dual prime or just field motion) macroblock, this one appears awful. It seems like it isn't properly predicted because the motion compensation has any field-aligned problem.

The algorithm i use to calculate the coordinates of the macroblock used as prediction in a field motion macroblock inside a frame picture is the following (in a P-frame, for simplicity's sake):

- i get the first motion vector mv[0][0][t], I divide it by two and add the current macroblock position (i.e., i add this the coordinates of the target macroblock, the one which i am calculating the prediction for)
- if motion_vertical_field_select[0][t] is "1", i take the samples in the resulting position calculated above from the BOTTOM FIELD, else from the TOP FIELD. But if the resulting vector points to a sample in the TOP FIELD but motion_vertical_field_select[0][t] = BOTTOM FIELD, what should I do? should I take the sample above or below that?
- the same algorithm is used to calculate mv[1][0][t] to get the prediction for the bottom field of the macroblock, with the same problem. What's more, I have an extra problem here: which is the reference position to add the motion vector? The same as for the top field, or maybe the top field plus 1, since the destination samples are going to be inserted into the bottom field?

Please, I pray for your help, since it has been a whloe month trying to discover where the error was, but I couldn't find it :(

THANK YOU IN ADVANCE!