[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.10, Fri Jun 28 15:14:40 2002 UTC revision 1.13.2.1, Sat Oct 5 21:32:48 2002 UTC
# Line 80  Line 80 
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 unsigned int bound_x,                                  const int bound);
                                 const unsigned int bound_y);  
84    
85    
86    #ifdef OLD_GETPMV
87  /* get_pmvdata returns the median predictor and nothing else */  /* get_pmvdata returns the median predictor and nothing else */
88    
89  static __inline VECTOR  static __inline VECTOR
# Line 208  Line 208 
208  }  }
209    
210    
211    static __inline VECTOR
212    get_qpmv(const MACROBLOCK * const pMBs,
213                    const uint32_t x,
214                    const uint32_t y,
215                    const uint32_t x_dim,
216                    const uint32_t block)
217    {
218    
219            int xin1, xin2, xin3;
220            int yin1, yin2, yin3;
221            int vec1, vec2, vec3;
222            VECTOR lneigh, tneigh, trneigh; /* left neighbour, top neighbour, topright neighbour */
223            VECTOR median;
224    
225            static VECTOR zeroMV = { 0, 0 };
226            uint32_t index = x + y * x_dim;
227    
228            /* first row (special case) */
229            if (y == 0 && (block == 0 || block == 1)) {
230                    if ((x == 0) && (block == 0))   // first column, first block
231                    {
232                            return zeroMV;
233                    }
234                    if (block == 1)                 // second block; has only a left neighbour
235                    {
236                            return pMBs[index].qmvs[0];
237                    } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
238    
239                            return pMBs[index - 1].qmvs[1];
240                    }
241            }
242    
243            /*
244             * MODE_INTER, vm18 page 48
245             * MODE_INTER4V vm18 page 51
246             *
247             *   (x,y-1)      (x+1,y-1)
248             *   [   |   ]    [   |   ]
249             *   [ 2 | 3 ]    [ 2 |   ]
250             *
251             *   (x-1,y)       (x,y)        (x+1,y)
252             *   [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]
253             *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
254             */
255    
256            switch (block) {
257            case 0:
258                    xin1 = x - 1;
259                    yin1 = y;
260                    vec1 = 1;                               /* left */
261                    xin2 = x;
262                    yin2 = y - 1;
263                    vec2 = 2;                               /* top */
264                    xin3 = x + 1;
265                    yin3 = y - 1;
266                    vec3 = 2;                               /* top right */
267                    break;
268            case 1:
269                    xin1 = x;
270                    yin1 = y;
271                    vec1 = 0;
272                    xin2 = x;
273                    yin2 = y - 1;
274                    vec2 = 3;
275                    xin3 = x + 1;
276                    yin3 = y - 1;
277                    vec3 = 2;
278                    break;
279            case 2:
280                    xin1 = x - 1;
281                    yin1 = y;
282                    vec1 = 3;
283                    xin2 = x;
284                    yin2 = y;
285                    vec2 = 0;
286                    xin3 = x;
287                    yin3 = y;
288                    vec3 = 1;
289                    break;
290            default:
291                    xin1 = x;
292                    yin1 = y;
293                    vec1 = 2;
294                    xin2 = x;
295                    yin2 = y;
296                    vec2 = 0;
297                    xin3 = x;
298                    yin3 = y;
299                    vec3 = 1;
300            }
301    
302    
303            if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t) x_dim) {
304                    lneigh = zeroMV;
305            } else {
306                    lneigh = pMBs[xin1 + yin1 * x_dim].qmvs[vec1];
307            }
308    
309            if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) {
310                    tneigh = zeroMV;
311            } else {
312                    tneigh = pMBs[xin2 + yin2 * x_dim].qmvs[vec2];
313            }
314    
315            if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) {
316                    trneigh = zeroMV;
317            } else {
318                    trneigh = pMBs[xin3 + yin3 * x_dim].qmvs[vec3];
319            }
320    
321            /* median,minimum */
322    
323            median.x =
324                    MIN(MAX(lneigh.x, tneigh.x),
325                            MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));
326            median.y =
327                    MIN(MAX(lneigh.y, tneigh.y),
328                            MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));
329            return median;
330    }
331    
332  /* 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
333     instead of only Median MV */     instead of only Median MV */
334    
# Line 218  Line 339 
339                          const uint32_t x_dim,                          const uint32_t x_dim,
340                          const uint32_t block,                          const uint32_t block,
341                          VECTOR * const pmv,                          VECTOR * const pmv,
342                          int32_t * const psad,                          int32_t * const psad)
                         const unsigned int bound_x,  
                         const unsigned int bound_y)  
343  {  {
344    
345          /*          /*
# Line 244  Line 363 
363          const VECTOR zeroMV = { 0, 0 };          const VECTOR zeroMV = { 0, 0 };
364    
365          // first row of blocks (special case)          // first row of blocks (special case)
366          /* if (y == 0 && (block == 0 || block == 1)) { */          if (y == 0 && (block == 0 || block == 1)) {
367          if (((y == bound_y && x >= bound_x) || (y == bound_y + 1 && x < bound_x))                  if ((x == 0) && (block == 0))   // first column, first block
                 && (block == 0 || block == 1)) {  
   
                 /* if ((x == 0) && (block == 0)) */     // first column, first block  
                 if ((x == 0 || (y == bound_y && x == bound_x)) && (block == 0)) // first column, first block  
368                  {                  {
369                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
370                          psad[0] = 0;                          psad[0] = 0;
# Line 354  Line 469 
469                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
470          } else {          } else {
471                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
472                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];                  psad[3] = pMBs[xin3 + yin3 * x_dim].sad8[vec3];
473          }          }
474    
475          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
# Line 376  Line 491 
491          return 0;          return 0;
492  }  }
493    
494    #endif
495    
496            /*
497             * MODE_INTER, vm18 page 48
498             * MODE_INTER4V vm18 page 51
499             *
500             *   (x,y-1)      (x+1,y-1)
501             *   [   |   ]    [   |   ]
502             *   [ 2 | 3 ]    [ 2 |   ]
503             *
504             *   (x-1,y)       (x,y)        (x+1,y)
505             *   [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]
506             *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
507             */
508    
509    static __inline VECTOR
510    get_pmv2(const MACROBLOCK * const mbs,
511             const int mb_width,
512             const int bound,
513             const int x,
514             const int y,
515             const int block)
516    {
517            static const VECTOR zeroMV = { 0, 0 };
518    
519        int lx, ly, lz;         /* left */
520        int tx, ty, tz;         /* top */
521        int rx, ry, rz;         /* top-right */
522        int lpos, tpos, rpos;
523        int num_cand, last_cand;
524    
525            VECTOR pmv[4];  /* left neighbour, top neighbour, top-right neighbour */
526    
527            switch (block) {
528            case 0:
529                    lx = x - 1;     ly = y;         lz = 1;
530                    tx = x;         ty = y - 1;     tz = 2;
531                    rx = x + 1;     ry = y - 1;     rz = 2;
532                    break;
533            case 1:
534                    lx = x;         ly = y;         lz = 0;
535                    tx = x;         ty = y - 1;     tz = 3;
536                    rx = x + 1;     ry = y - 1;     rz = 2;
537                    break;
538            case 2:
539                    lx = x - 1;     ly = y;         lz = 3;
540                    tx = x;         ty = y;         tz = 0;
541                    rx = x;         ry = y;         rz = 1;
542                    break;
543            default:
544                    lx = x;         ly = y;         lz = 2;
545                    tx = x;         ty = y;         tz = 0;
546                    rx = x;         ry = y;         rz = 1;
547            }
548    
549        lpos = lx + ly * mb_width;
550        rpos = rx + ry * mb_width;
551        tpos = tx + ty * mb_width;
552        num_cand = 0;
553    
554        if (lpos >= bound && lx >= 0) {
555            num_cand++;
556            last_cand = 1;
557            pmv[1] = mbs[lpos].mvs[lz];
558        } else {
559            pmv[1] = zeroMV;
560        }
561    
562        if (tpos >= bound) {
563            num_cand++;
564            last_cand = 2;
565            pmv[2] = mbs[tpos].mvs[tz];
566        } else {
567            pmv[2] = zeroMV;
568        }
569    
570        if (rpos >= bound && rx < mb_width) {
571            num_cand++;
572            last_cand = 3;
573            pmv[3] = mbs[rpos].mvs[rz];
574        } else {
575            pmv[3] = zeroMV;
576        }
577    
578        /* if only one valid candidate predictor, the invalid candiates are set to the canidate */
579            if (num_cand != 1) {
580                    /* set median */
581    
582                    pmv[0].x =
583                            MIN(MAX(pmv[1].x, pmv[2].x),
584                                    MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
585                    pmv[0].y =
586                            MIN(MAX(pmv[1].y, pmv[2].y),
587                                    MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
588                    return pmv[0];
589             }
590    
591             return pmv[last_cand];  /* no point calculating median mv */
592    }
593    
594    
595    
596            /*
597             * MODE_INTER, vm18 page 48
598             * MODE_INTER4V vm18 page 51
599             *
600             *   (x,y-1)      (x+1,y-1)
601             *   [   |   ]    [   |   ]
602             *   [ 2 | 3 ]    [ 2 |   ]
603             *
604             *   (x-1,y)       (x,y)        (x+1,y)
605             *   [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]
606             *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
607             */
608    
609    static __inline VECTOR
610    get_qpmv2(const MACROBLOCK * const mbs,
611             const int mb_width,
612             const int bound,
613             const int x,
614             const int y,
615             const int block)
616    {
617            static const VECTOR zeroMV = { 0, 0 };
618    
619        int lx, ly, lz;         /* left */
620        int tx, ty, tz;         /* top */
621        int rx, ry, rz;         /* top-right */
622        int lpos, tpos, rpos;
623        int num_cand, last_cand;
624    
625            VECTOR pmv[4];  /* left neighbour, top neighbour, top-right neighbour */
626    
627            switch (block) {
628            case 0:
629                    lx = x - 1;     ly = y;         lz = 1;
630                    tx = x;         ty = y - 1;     tz = 2;
631                    rx = x + 1;     ry = y - 1;     rz = 2;
632                    break;
633            case 1:
634                    lx = x;         ly = y;         lz = 0;
635                    tx = x;         ty = y - 1;     tz = 3;
636                    rx = x + 1;     ry = y - 1;     rz = 2;
637                    break;
638            case 2:
639                    lx = x - 1;     ly = y;         lz = 3;
640                    tx = x;         ty = y;         tz = 0;
641                    rx = x;         ry = y;         rz = 1;
642                    break;
643            default:
644                    lx = x;         ly = y;         lz = 2;
645                    tx = x;         ty = y;         tz = 0;
646                    rx = x;         ry = y;         rz = 1;
647            }
648    
649        lpos = lx + ly * mb_width;
650        rpos = rx + ry * mb_width;
651        tpos = tx + ty * mb_width;
652        num_cand = 0;
653    
654        if (lpos >= bound && lx >= 0) {
655            num_cand++;
656            last_cand = 1;
657            pmv[1] = mbs[lpos].qmvs[lz];
658        } else {
659            pmv[1] = zeroMV;
660        }
661    
662        if (tpos >= bound) {
663            num_cand++;
664            last_cand = 2;
665            pmv[2] = mbs[tpos].qmvs[tz];
666        } else {
667            pmv[2] = zeroMV;
668        }
669    
670        if (rpos >= bound && rx < mb_width) {
671            num_cand++;
672            last_cand = 3;
673            pmv[3] = mbs[rpos].qmvs[rz];
674        } else {
675            pmv[3] = zeroMV;
676        }
677    
678        /* if only one valid candidate predictor, the invalid candiates are set to the canidate */
679            if (num_cand != 1) {
680                    /* set median */
681    
682                    pmv[0].x =
683                            MIN(MAX(pmv[1].x, pmv[2].x),
684                                    MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
685                    pmv[0].y =
686                            MIN(MAX(pmv[1].y, pmv[2].y),
687                                    MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
688                    return pmv[0];
689             }
690    
691             return pmv[last_cand];  /* no point calculating median mv */
692    }
693    
694    
695            /*
696             * pmv are filled with:
697             *  [0]: Median (or whatever is correct in a special case)
698             *  [1]: left neighbour
699             *  [2]: top neighbour
700             *  [3]: topright neighbour
701             * psad are filled with:
702             *  [0]: minimum of [1] to [3]
703             *  [1]: left neighbour's SAD (NB:[1] to [3] are actually not needed)
704             *  [2]: top neighbour's SAD
705             *  [3]: topright neighbour's SAD
706             */
707    
708    static __inline int
709    get_pmvdata2(const MACROBLOCK * const mbs,
710             const int mb_width,
711             const int bound,
712             const int x,
713             const int y,
714             const int block,
715                     VECTOR * const pmv,
716                     int32_t * const psad)
717    {
718            static const VECTOR zeroMV = { 0, 0 };
719    
720        int lx, ly, lz;         /* left */
721        int tx, ty, tz;         /* top */
722        int rx, ry, rz;         /* top-right */
723        int lpos, tpos, rpos;
724        int num_cand, last_cand;
725    
726            switch (block) {
727            case 0:
728                    lx = x - 1;     ly = y;         lz = 1;
729                    tx = x;         ty = y - 1;     tz = 2;
730                    rx = x + 1;     ry = y - 1;     rz = 2;
731                    break;
732            case 1:
733                    lx = x;         ly = y;         lz = 0;
734                    tx = x;         ty = y - 1;     tz = 3;
735                    rx = x + 1;     ry = y - 1;     rz = 2;
736                    break;
737            case 2:
738                    lx = x - 1;     ly = y;         lz = 3;
739                    tx = x;         ty = y;         tz = 0;
740                    rx = x;         ry = y;         rz = 1;
741                    break;
742            default:
743                    lx = x;         ly = y;         lz = 2;
744                    tx = x;         ty = y;         tz = 0;
745                    rx = x;         ry = y;         rz = 1;
746            }
747    
748        lpos = lx + ly * mb_width;
749        rpos = rx + ry * mb_width;
750        tpos = tx + ty * mb_width;
751        num_cand = 0;
752    
753        if (lpos >= bound && lx >= 0) {
754            num_cand++;
755            last_cand = 1;
756            pmv[1] = mbs[lpos].mvs[lz];
757                    psad[1] = mbs[lpos].sad8[lz];
758        } else {
759            pmv[1] = zeroMV;
760                    psad[1] = MV_MAX_ERROR;
761        }
762    
763        if (tpos >= bound) {
764            num_cand++;
765            last_cand = 2;
766            pmv[2]= mbs[tpos].mvs[tz];
767            psad[2] = mbs[tpos].sad8[tz];
768        } else {
769            pmv[2] = zeroMV;
770                    psad[2] = MV_MAX_ERROR;
771        }
772    
773        if (rpos >= bound && rx < mb_width) {
774            num_cand++;
775            last_cand = 3;
776            pmv[3] = mbs[rpos].mvs[rz];
777            psad[3] = mbs[rpos].sad8[rz];
778        } else {
779            pmv[3] = zeroMV;
780                    psad[3] = MV_MAX_ERROR;
781        }
782    
783            /* original pmvdata() compatibility hack */
784            if (x == 0 && y == 0 && block == 0)
785            {
786                    pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
787                    psad[0] = 0;
788                    psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
789                    return 0;
790            }
791    
792        /* if only one valid candidate preictor, the invalid candiates are set to the canidate */
793            if (num_cand == 1) {
794                    pmv[0] = pmv[last_cand];
795                    psad[0] = psad[last_cand];
796            // return MVequal(pmv[0], zeroMV); /* no point calculating median mv and minimum sad */
797    
798                    /* original pmvdata() compatibility hack */
799                    return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);
800            }
801    
802            if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
803                    pmv[0] = pmv[1];
804                    psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
805                    return 1;
806                    /* compatibility patch */
807                    //return y==0 && block <= 1 ? 0 : 1;
808            }
809    
810            /* set median, minimum */
811    
812            pmv[0].x =
813                    MIN(MAX(pmv[1].x, pmv[2].x),
814                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
815            pmv[0].y =
816                    MIN(MAX(pmv[1].y, pmv[2].y),
817                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
818    
819            psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
820    
821            return 0;
822    }
823    
824    /* copies of get_pmv and get_pmvdata for prediction from integer search */
825    
826    static __inline VECTOR
827    get_ipmv(const MACROBLOCK * const mbs,
828             const int mb_width,
829             const int bound,
830             const int x,
831             const int y,
832             const int block)
833    {
834            static const VECTOR zeroMV = { 0, 0 };
835    
836            int lx, ly, lz;         /* left */
837            int tx, ty, tz;         /* top */
838            int rx, ry, rz;         /* top-right */
839            int lpos, tpos, rpos;
840            int num_cand, last_cand;
841    
842            VECTOR pmv[4];  /* left neighbour, top neighbour, top-right neighbour */
843    
844            switch (block) {
845            case 0:
846                    lx = x - 1;     ly = y;         lz = 1;
847                    tx = x;         ty = y - 1;     tz = 2;
848                    rx = x + 1;     ry = y - 1;     rz = 2;
849                    break;
850            case 1:
851                    lx = x;         ly = y;         lz = 0;
852                    tx = x;         ty = y - 1;     tz = 3;
853                    rx = x + 1;     ry = y - 1;     rz = 2;
854                    break;
855            case 2:
856                    lx = x - 1;     ly = y;         lz = 3;
857                    tx = x;         ty = y;         tz = 0;
858                    rx = x;         ry = y;         rz = 1;
859                    break;
860            default:
861                    lx = x;         ly = y;         lz = 2;
862                    tx = x;         ty = y;         tz = 0;
863                    rx = x;         ry = y;         rz = 1;
864            }
865    
866        lpos = lx + ly * mb_width;
867        rpos = rx + ry * mb_width;
868        tpos = tx + ty * mb_width;
869        num_cand = 0;
870    
871        if (lpos >= bound && lx >= 0) {
872            num_cand++;
873            last_cand = 1;
874            pmv[1] = mbs[lpos].i_mvs[lz];
875        } else {
876            pmv[1] = zeroMV;
877        }
878    
879        if (tpos >= bound) {
880            num_cand++;
881            last_cand = 2;
882            pmv[2] = mbs[tpos].i_mvs[tz];
883        } else {
884            pmv[2] = zeroMV;
885        }
886    
887        if (rpos >= bound && rx < mb_width) {
888            num_cand++;
889            last_cand = 3;
890            pmv[3] = mbs[rpos].i_mvs[rz];
891        } else {
892            pmv[3] = zeroMV;
893        }
894    
895        /* if only one valid candidate predictor, the invalid candiates are set to the canidate */
896            if (num_cand != 1) {
897                    /* set median */
898    
899                    pmv[0].x =
900                            MIN(MAX(pmv[1].x, pmv[2].x),
901                                    MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
902                    pmv[0].y =
903                            MIN(MAX(pmv[1].y, pmv[2].y),
904                                    MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
905                    return pmv[0];
906             }
907    
908             return pmv[last_cand];  /* no point calculating median mv */
909    }
910    
911    static __inline int
912    get_ipmvdata(const MACROBLOCK * const mbs,
913             const int mb_width,
914             const int bound,
915             const int x,
916             const int y,
917             const int block,
918                     VECTOR * const pmv,
919                     int32_t * const psad)
920    {
921            static const VECTOR zeroMV = { 0, 0 };
922    
923        int lx, ly, lz;         /* left */
924        int tx, ty, tz;         /* top */
925        int rx, ry, rz;         /* top-right */
926        int lpos, tpos, rpos;
927        int num_cand, last_cand;
928    
929            switch (block) {
930            case 0:
931                    lx = x - 1;     ly = y;         lz = 1;
932                    tx = x;         ty = y - 1;     tz = 2;
933                    rx = x + 1;     ry = y - 1;     rz = 2;
934                    break;
935            case 1:
936                    lx = x;         ly = y;         lz = 0;
937                    tx = x;         ty = y - 1;     tz = 3;
938                    rx = x + 1;     ry = y - 1;     rz = 2;
939                    break;
940            case 2:
941                    lx = x - 1;     ly = y;         lz = 3;
942                    tx = x;         ty = y;         tz = 0;
943                    rx = x;         ry = y;         rz = 1;
944                    break;
945            default:
946                    lx = x;         ly = y;         lz = 2;
947                    tx = x;         ty = y;         tz = 0;
948                    rx = x;         ry = y;         rz = 1;
949            }
950    
951        lpos = lx + ly * mb_width;
952        rpos = rx + ry * mb_width;
953        tpos = tx + ty * mb_width;
954        num_cand = 0;
955    
956        if (lpos >= bound && lx >= 0) {
957            num_cand++;
958            last_cand = 1;
959            pmv[1] = mbs[lpos].i_mvs[lz];
960                    psad[1] = mbs[lpos].i_sad8[lz];
961        } else {
962            pmv[1] = zeroMV;
963                    psad[1] = MV_MAX_ERROR;
964        }
965    
966        if (tpos >= bound) {
967            num_cand++;
968            last_cand = 2;
969            pmv[2]= mbs[tpos].i_mvs[tz];
970            psad[2] = mbs[tpos].i_sad8[tz];
971        } else {
972            pmv[2] = zeroMV;
973                    psad[2] = MV_MAX_ERROR;
974        }
975    
976        if (rpos >= bound && rx < mb_width) {
977            num_cand++;
978            last_cand = 3;
979            pmv[3] = mbs[rpos].i_mvs[rz];
980            psad[3] = mbs[rpos].i_sad8[rz];
981        } else {
982            pmv[3] = zeroMV;
983                    psad[3] = MV_MAX_ERROR;
984        }
985    
986            /* original pmvdata() compatibility hack */
987            if (x == 0 && y == 0 && block == 0)
988            {
989                    pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
990                    psad[0] = 0;
991                    psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
992                    return 0;
993            }
994    
995        /* if only one valid candidate preictor, the invalid candiates are set to the canidate */
996            if (num_cand == 1) {
997                    pmv[0] = pmv[last_cand];
998                    psad[0] = psad[last_cand];
999            // return MVequal(pmv[0], zeroMV); /* no point calculating median mv and minimum sad */
1000    
1001                    /* original pmvdata() compatibility hack */
1002                    return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);
1003            }
1004    
1005            if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
1006                    pmv[0] = pmv[1];
1007                    psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
1008                    return 1;
1009                    /* compatibility patch */
1010                    //return y==0 && block <= 1 ? 0 : 1;
1011            }
1012    
1013            /* set median, minimum */
1014    
1015            pmv[0].x =
1016                    MIN(MAX(pmv[1].x, pmv[2].x),
1017                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
1018            pmv[0].y =
1019                    MIN(MAX(pmv[1].y, pmv[2].y),
1020                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
1021    
1022            psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
1023    
1024            return 0;
1025    }
1026    
1027    
1028  #endif                                                  /* _MBPREDICTION_H_ */  #endif                                                  /* _MBPREDICTION_H_ */

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.13.2.1

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