--- mbprediction.h 2002/09/07 13:43:00 1.14 +++ mbprediction.h 2002/10/19 12:20:33 1.16 @@ -3,6 +3,9 @@ * XVID MPEG-4 VIDEO CODEC * - MB prediction header file - * + * Copyright(C) 2002 Christoph Lampert + * 2002 Peter Ross + * * This program is an implementation of a part of one or more MPEG-4 * Video tools as specified in ISO/IEC 14496-2 standard. Those intending * to use this software module in hardware or software products are @@ -26,7 +29,7 @@ * along with this program; if not, write to the xvid_free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: mbprediction.h,v 1.14 2002/09/07 13:43:00 edgomez Exp $ + * $Id: mbprediction.h,v 1.16 2002/10/19 12:20:33 edgomez Exp $ * *************************************************************************/ @@ -138,7 +141,7 @@ lpos = lx + ly * mb_width; rpos = rx + ry * mb_width; tpos = tx + ty * mb_width; - num_cand = 0; + last_cand = num_cand = 0; if (lpos >= bound && lx >= 0) { num_cand++; @@ -164,7 +167,14 @@ pmv[3] = zeroMV; } - /* if only one valid candidate predictor, the invalid candiates are set to the canidate */ + /* + * If there're more than one candidate, we return the median vector + * edgomez : the special case "no candidates" is handled the same way + * because all vectors are set to zero. So the median vector + * is {0,0}, and this is exactly the vector we must return + * according to the mpeg4 specs. + */ + if (num_cand != 1) { /* set median */ @@ -238,7 +248,7 @@ lpos = lx + ly * mb_width; rpos = rx + ry * mb_width; tpos = tx + ty * mb_width; - num_cand = 0; + last_cand = num_cand = 0; if (lpos >= bound && lx >= 0) { num_cand++; @@ -356,7 +366,7 @@ lpos = lx + ly * mb_width; rpos = rx + ry * mb_width; tpos = tx + ty * mb_width; - num_cand = 0; + last_cand = num_cand = 0; if (lpos >= bound && lx >= 0) { num_cand++; @@ -441,7 +451,7 @@ lpos = lx + ly * mb_width; rpos = rx + ry * mb_width; tpos = tx + ty * mb_width; - num_cand = 0; + last_cand = num_cand = 0; if (lpos >= bound && lx >= 0) { num_cand++;