[cvs] / xvidcore / src / prediction / mbprediction.h Repository:
ViewVC logotype

Diff of /xvidcore/src/prediction/mbprediction.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6, Fri May 3 00:45:10 2002 UTC revision 1.12, Wed Jul 3 12:32:50 2002 UTC
# Line 30  Line 30 
30   *   *
31   *************************************************************************/   *************************************************************************/
32    
33     /******************************************************************************
34      *                                                                            *
35      *  Revision history:                                                         *
36      *                                                                            *
37      *  29.06.2002 get_pmvdata() bounding                                         *
38      *                                                                            *
39      ******************************************************************************/
40    
41    
42  #ifndef _MBPREDICTION_H_  #ifndef _MBPREDICTION_H_
43  #define _MBPREDICTION_H_  #define _MBPREDICTION_H_
44    
# Line 45  Line 54 
54    
55  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )
56    
57  void MBPrediction(  void MBPrediction(FRAMEINFO * frame,    /* <-- The parameter for ACDC and MV prediction */
58          FRAMEINFO *frame, /* <-- The parameter for ACDC and MV prediction */  
59          uint32_t x_pos,   /* <-- The x position of the MB to be searched  */          uint32_t x_pos,   /* <-- The x position of the MB to be searched  */
60    
61          uint32_t y_pos,   /* <-- The y position of the MB to be searched  */          uint32_t y_pos,   /* <-- The y position of the MB to be searched  */
62    
63          uint32_t x_dim,   /* <-- Number of macroblocks in a row           */          uint32_t x_dim,   /* <-- Number of macroblocks in a row           */
64    
65          int16_t *qcoeff); /* <-> The quantized DCT coefficients           */          int16_t *qcoeff); /* <-> The quantized DCT coefficients           */
66    
67  void add_acdc(MACROBLOCK *pMB,  void add_acdc(MACROBLOCK *pMB,
# Line 67  Line 79 
79                    int16_t qcoeff[64],                    int16_t qcoeff[64],
80                    uint32_t current_quant,                    uint32_t current_quant,
81                    int32_t iDcScaler,                    int32_t iDcScaler,
82                    int16_t predictors[8]);                                    int16_t predictors[8],
83                                    const int bound);
84    
85    
86  /* get_pmvdata returns the median predictor and nothing else */  /* get_pmvdata returns the median predictor and nothing else */
87    
88  static __inline VECTOR get_pmv(const MACROBLOCK * const pMBs,  static __inline VECTOR
89    get_pmv(const MACROBLOCK * const pMBs,
90                                 const uint32_t x,                                 const uint32_t x,
91                                 const uint32_t y,                                 const uint32_t y,
92                                 const uint32_t x_dim,                                 const uint32_t x_dim,
# Line 88  Line 103 
103          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
104    
105          /* first row (special case) */          /* first row (special case) */
106          if (y == 0 && (block == 0 || block == 1))          if (y == 0 && (block == 0 || block == 1)) {
         {  
107                  if ((x == 0) && (block == 0))           // first column, first block                  if ((x == 0) && (block == 0))           // first column, first block
108                  {                  {
109                          return zeroMV;                          return zeroMV;
# Line 97  Line 111 
111                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
112                  {                  {
113                          return pMBs[index].mvs[0];                          return pMBs[index].mvs[0];
114                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
115                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
116                          return pMBs[index-1].mvs[1];                          return pMBs[index-1].mvs[1];
117                  }                  }
118          }          }
# Line 117  Line 130 
130           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
131           */           */
132    
133          switch (block)          switch (block) {
         {  
134          case 0:          case 0:
135                  xin1 = x - 1;   yin1 = y;       vec1 = 1;       /* left */                  xin1 = x - 1;
136                  xin2 = x;       yin2 = y - 1;   vec2 = 2;       /* top */                  yin1 = y;
137                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;       /* top right */                  vec1 = 1;                               /* left */
138                    xin2 = x;
139                    yin2 = y - 1;
140                    vec2 = 2;                               /* top */
141                    xin3 = x + 1;
142                    yin3 = y - 1;
143                    vec3 = 2;                               /* top right */
144                  break;                  break;
145          case 1:          case 1:
146                  xin1 = x;               yin1 = y;               vec1 = 0;                  xin1 = x;
147                  xin2 = x;               yin2 = y - 1;   vec2 = 3;                  yin1 = y;
148                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;                  vec1 = 0;
149                    xin2 = x;
150                    yin2 = y - 1;
151                    vec2 = 3;
152                    xin3 = x + 1;
153                    yin3 = y - 1;
154                    vec3 = 2;
155                  break;                  break;
156          case 2:          case 2:
157                  xin1 = x - 1;   yin1 = y;               vec1 = 3;                  xin1 = x - 1;
158                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
159                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 3;
160                    xin2 = x;
161                    yin2 = y;
162                    vec2 = 0;
163                    xin3 = x;
164                    yin3 = y;
165                    vec3 = 1;
166                  break;                  break;
167          default:          default:
168                  xin1 = x;               yin1 = y;               vec1 = 2;                  xin1 = x;
169                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
170                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 2;
171                    xin2 = x;
172                    yin2 = y;
173                    vec2 = 0;
174                    xin3 = x;
175                    yin3 = y;
176                    vec3 = 1;
177          }          }
178    
179    
180          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t) x_dim) {
         {  
181                  lneigh = zeroMV;                  lneigh = zeroMV;
182          }          } else {
         else  
         {  
183                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
184          }          }
185    
186          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) {
         {  
187                  tneigh = zeroMV;                  tneigh = zeroMV;
188          }          } else {
         else  
         {  
189                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
190          }          }
191    
192          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) {
         {  
193                  trneigh = zeroMV;                  trneigh = zeroMV;
194          }          } else {
         else  
         {  
195                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
196          }          }
197    
198          /* median,minimum */          /* median,minimum */
199    
200          median.x = MIN(MAX(lneigh.x, tneigh.x), MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));          median.x =
201          median.y = MIN(MAX(lneigh.y, tneigh.y), MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));                  MIN(MAX(lneigh.x, tneigh.x),
202                            MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));
203            median.y =
204                    MIN(MAX(lneigh.y, tneigh.y),
205                            MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));
206          return median;          return median;
207  }  }
208    
# Line 179  Line 210 
210  /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD  /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD
211     instead of only Median MV */     instead of only Median MV */
212    
213  static __inline int get_pmvdata(const MACROBLOCK * const pMBs,  static __inline int
214                                  const uint32_t x, const uint32_t y,  get_pmvdata(const MACROBLOCK * const pMBs,
215                            const uint32_t x,
216                            const uint32_t y,
217                                  const uint32_t x_dim,                                  const uint32_t x_dim,
218                                  const uint32_t block,                                  const uint32_t block,
219                                  VECTOR * const pmv,                                  VECTOR * const pmv,
# Line 204  Line 237 
237          int yin1, yin2, yin3;          int yin1, yin2, yin3;
238          int vec1, vec2, vec3;          int vec1, vec2, vec3;
239    
         static VECTOR zeroMV;  
240          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
241          zeroMV.x = zeroMV.y = 0;          const VECTOR zeroMV = { 0, 0 };
242    
243          // first row (special case)          // first row of blocks (special case)
244          if (y == 0 && (block == 0 || block == 1))          if (y == 0 && (block == 0 || block == 1)) {
         {  
245                  if ((x == 0) && (block == 0))           // first column, first block                  if ((x == 0) && (block == 0))           // first column, first block
246                  {                  {
247                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
248                          psad[0] = psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;                          psad[0] = 0;
249                            psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
250                          return 0;                          return 0;
251                  }                  }
252                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
# Line 224  Line 256 
256                          psad[0] = psad[1] = pMBs[index].sad8[0];                          psad[0] = psad[1] = pMBs[index].sad8[0];
257                          psad[2] = psad[3] = MV_MAX_ERROR;                          psad[2] = psad[3] = MV_MAX_ERROR;
258                          return 0;                          return 0;
259                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
260                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
261                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];
262                          pmv[2] = pmv[3] = zeroMV;                          pmv[2] = pmv[3] = zeroMV;
263                          psad[0] = psad[1] = pMBs[index-1].sad8[1];                          psad[0] = psad[1] = pMBs[index-1].sad8[1];
# Line 248  Line 279 
279           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]
280           */           */
281    
282          switch (block)          switch (block) {
         {  
283          case 0:          case 0:
284                  xin1 = x - 1; yin1 = y;     vec1 = 1; /* left */                  xin1 = x - 1;
285                  xin2 = x;     yin2 = y - 1; vec2 = 2; /* top */                  yin1 = y;
286                  xin3 = x + 1; yin3 = y - 1; vec3 = 2; /* top right */                  vec1 = 1;                               /* left */
287                    xin2 = x;
288                    yin2 = y - 1;
289                    vec2 = 2;                               /* top */
290                    xin3 = x + 1;
291                    yin3 = y - 1;
292                    vec3 = 2;                               /* top right */
293                  break;                  break;
294          case 1:          case 1:
295                  xin1 = x;     yin1 = y;     vec1 = 0;                  xin1 = x;
296                  xin2 = x;     yin2 = y - 1; vec2 = 3;                  yin1 = y;
297                  xin3 = x + 1; yin3 = y - 1; vec3 = 2;                  vec1 = 0;
298                    xin2 = x;
299                    yin2 = y - 1;
300                    vec2 = 3;
301                    xin3 = x + 1;
302                    yin3 = y - 1;
303                    vec3 = 2;
304                  break;                  break;
305          case 2:          case 2:
306                  xin1 = x - 1; yin1 = y; vec1 = 3;                  xin1 = x - 1;
307                  xin2 = x;     yin2 = y; vec2 = 0;                  yin1 = y;
308                  xin3 = x;     yin3 = y; vec3 = 1;                  vec1 = 3;
309                    xin2 = x;
310                    yin2 = y;
311                    vec2 = 0;
312                    xin3 = x;
313                    yin3 = y;
314                    vec3 = 1;
315                  break;                  break;
316          default:          default:
317                  xin1 = x; yin1 = y; vec1 = 2;                  xin1 = x;
318                  xin2 = x; yin2 = y; vec2 = 0;                  yin1 = y;
319                  xin3 = x; yin3 = y; vec3 = 1;                  vec1 = 2;
320                    xin2 = x;
321                    yin2 = y;
322                    vec2 = 0;
323                    xin3 = x;
324                    yin3 = y;
325                    vec3 = 1;
326          }          }
327    
328    
329          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || xin1 >= (int32_t) x_dim) {
         {  
330              pmv[1] = zeroMV;              pmv[1] = zeroMV;
331                  psad[1] = MV_MAX_ERROR;                  psad[1] = MV_MAX_ERROR;
332          }          } else {
         else  
         {  
333                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
334                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];
335          }          }
336    
337          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || xin2 >= (int32_t) x_dim) {
         {  
338                  pmv[2] = zeroMV;                  pmv[2] = zeroMV;
339                  psad[2] = MV_MAX_ERROR;                  psad[2] = MV_MAX_ERROR;
340          }          } else {
         else  
         {  
341                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
342                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];
343          }          }
344    
345          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || xin3 >= (int32_t) x_dim) {
         {  
346                  pmv[3] = zeroMV;                  pmv[3] = zeroMV;
347                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
348          }          } else {
         else  
         {  
349                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
350                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];                  psad[3] = pMBs[xin3 + yin3 * x_dim].sad8[vec3];
351          }          }
352    
353          if ( (MVequal(pmv[1],pmv[2])) && (MVequal(pmv[1],pmv[3])) )          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
354          {       pmv[0]=pmv[1];                  pmv[0] = pmv[1];
355          psad[0]=psad[1];                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
356          return 1;          return 1;
357          }          }
358    
359          /* median,minimum */          /* median,minimum */
360    
361          pmv[0].x = MIN(MAX(pmv[1].x, pmv[2].x), MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));          pmv[0].x =
362          pmv[0].y = MIN(MAX(pmv[1].y, pmv[2].y), MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));                  MIN(MAX(pmv[1].x, pmv[2].x),
363                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
364            pmv[0].y =
365                    MIN(MAX(pmv[1].y, pmv[2].y),
366                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
367          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);
368    
369          return 0;          return 0;
370  }  }
371    
372    
373            /*
374             * MODE_INTER, vm18 page 48
375             * MODE_INTER4V vm18 page 51
376             *
377             *   (x,y-1)      (x+1,y-1)
378             *   [   |   ]    [   |   ]
379             *   [ 2 | 3 ]    [ 2 |   ]
380             *
381             *   (x-1,y)       (x,y)        (x+1,y)
382             *   [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]
383             *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
384             */
385    
386    static __inline VECTOR
387    get_pmv2(const MACROBLOCK * const mbs,
388             const int mb_width,
389             const int bound,
390             const int x,
391             const int y,
392             const int block)
393    {
394            static const VECTOR zeroMV = { 0, 0 };
395    
396        int lx, ly, lz;         /* left */
397        int tx, ty, tz;         /* top */
398        int rx, ry, rz;         /* top-right */
399        int lpos, tpos, rpos;
400        int num_cand, last_cand;
401    
402            VECTOR pmv[4];  /* left neighbour, top neighbour, top-right neighbour */
403    
404            switch (block) {
405            case 0:
406                    lx = x - 1;     ly = y;         lz = 1;
407                    tx = x;         ty = y - 1;     tz = 2;
408                    rx = x + 1;     ry = y - 1;     rz = 2;
409                    break;
410            case 1:
411                    lx = x;         ly = y;         lz = 0;
412                    tx = x;         ty = y - 1;     tz = 3;
413                    rx = x + 1;     ry = y - 1;     rz = 2;
414                    break;
415            case 2:
416                    lx = x - 1;     ly = y;         lz = 3;
417                    tx = x;         ty = y;         tz = 0;
418                    rx = x;         ry = y;         rz = 1;
419                    break;
420            default:
421                    lx = x;         ly = y;         lz = 2;
422                    tx = x;         ty = y;         tz = 0;
423                    rx = x;         ry = y;         rz = 1;
424            }
425    
426        lpos = lx + ly * mb_width;
427        rpos = rx + ry * mb_width;
428        tpos = tx + ty * mb_width;
429        num_cand = 0;
430    
431        if (lpos >= bound && lx >= 0) {
432            num_cand++;
433            last_cand = 1;
434            pmv[1] = mbs[lpos].mvs[lz];
435        } else {
436            pmv[1] = zeroMV;
437        }
438    
439        if (tpos >= bound) {
440            num_cand++;
441            last_cand = 2;
442            pmv[2] = mbs[tpos].mvs[tz];
443        } else {
444            pmv[2] = zeroMV;
445        }
446    
447        if (rpos >= bound && rx < mb_width) {
448            num_cand++;
449            last_cand = 3;
450            pmv[3] = mbs[rpos].mvs[rz];
451        } else {
452            pmv[3] = zeroMV;
453        }
454    
455        /* if only one valid candidate preictor, the invalid candiates are set to the canidate */
456            if (num_cand != 1) {
457                    /* set median */
458    
459                    pmv[0].x =
460                            MIN(MAX(pmv[1].x, pmv[2].x),
461                                    MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
462                    pmv[0].y =
463                            MIN(MAX(pmv[1].y, pmv[2].y),
464                                    MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
465                    return pmv[0];
466             }
467    
468             return pmv[last_cand];  /* no point calculating median mv */
469    }
470    
471    
472    
473            /*
474             * pmv are filled with:
475             *  [0]: Median (or whatever is correct in a special case)
476             *  [1]: left neighbour
477             *  [2]: top neighbour
478             *  [3]: topright neighbour
479             * psad are filled with:
480             *  [0]: minimum of [1] to [3]
481             *  [1]: left neighbour's SAD (NB:[1] to [3] are actually not needed)
482             *  [2]: top neighbour's SAD
483             *  [3]: topright neighbour's SAD
484             */
485    static __inline int
486    get_pmvdata2(const MACROBLOCK * const mbs,
487             const int mb_width,
488             const int bound,
489             const int x,
490             const int y,
491             const int block,
492                     VECTOR * const pmv,
493                     int32_t * const psad)
494    {
495            static const VECTOR zeroMV = { 0, 0 };
496    
497        int lx, ly, lz;         /* left */
498        int tx, ty, tz;         /* top */
499        int rx, ry, rz;         /* top-right */
500        int lpos, tpos, rpos;
501        int num_cand, last_cand;
502    
503            switch (block) {
504            case 0:
505                    lx = x - 1;     ly = y;         lz = 1;
506                    tx = x;         ty = y - 1;     tz = 2;
507                    rx = x + 1;     ry = y - 1;     rz = 2;
508                    break;
509            case 1:
510                    lx = x;         ly = y;         lz = 0;
511                    tx = x;         ty = y - 1;     tz = 3;
512                    rx = x + 1;     ry = y - 1;     rz = 2;
513                    break;
514            case 2:
515                    lx = x - 1;     ly = y;         lz = 3;
516                    tx = x;         ty = y;         tz = 0;
517                    rx = x;         ry = y;         rz = 1;
518                    break;
519            default:
520                    lx = x;         ly = y;         lz = 2;
521                    tx = x;         ty = y;         tz = 0;
522                    rx = x;         ry = y;         rz = 1;
523            }
524    
525        lpos = lx + ly * mb_width;
526        rpos = rx + ry * mb_width;
527        tpos = tx + ty * mb_width;
528        num_cand = 0;
529    
530        if (lpos >= bound && lx >= 0) {
531            num_cand++;
532            last_cand = 1;
533            pmv[1] = mbs[lpos].mvs[lz];
534                    psad[1] = mbs[lpos].sad8[lz];
535        } else {
536            pmv[1] = zeroMV;
537                    psad[1] = MV_MAX_ERROR;
538        }
539    
540        if (tpos >= bound) {
541            num_cand++;
542            last_cand = 2;
543            pmv[2]= mbs[tpos].mvs[tz];
544            psad[2] = mbs[tpos].sad8[tz];
545        } else {
546            pmv[2] = zeroMV;
547                    psad[2] = MV_MAX_ERROR;
548        }
549    
550        if (rpos >= bound && rx < mb_width) {
551            num_cand++;
552            last_cand = 3;
553            pmv[3] = mbs[rpos].mvs[rz];
554            psad[3] = mbs[rpos].sad8[rz];
555        } else {
556            pmv[3] = zeroMV;
557                    psad[3] = MV_MAX_ERROR;
558        }
559    
560            /* original pmvdata() compatibility hack */
561            if (x == 0 && y == 0 && block == 0)
562            {
563                    pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
564                    psad[0] = 0;
565                    psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
566                    return 0;
567            }
568    
569        /* if only one valid candidate preictor, the invalid candiates are set to the canidate */
570            if (num_cand == 1) {
571                    pmv[0] = pmv[last_cand];
572                    psad[0] = psad[last_cand];
573            // return MVequal(pmv[0], zeroMV); /* no point calculating median mv and minimum sad */
574    
575                    /* original pmvdata() compatibility hack */
576                    return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);
577            }
578    
579            if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
580                    pmv[0] = pmv[1];
581                    psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
582                    return 1;
583                    /* compatibility patch */
584                    //return y==0 && block <= 1 ? 0 : 1;
585            }
586    
587            /* set median, minimum */
588    
589            pmv[0].x =
590                    MIN(MAX(pmv[1].x, pmv[2].x),
591                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
592            pmv[0].y =
593                    MIN(MAX(pmv[1].y, pmv[2].y),
594                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
595    
596            psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
597    
598            return 0;
599    }
600    
601    
602  #endif /* _MBPREDICTION_H_ */  #endif /* _MBPREDICTION_H_ */

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.12

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4