[svn] / trunk / xvidcore / src / motion / estimation_pvop.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/motion/estimation_pvop.c

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

revision 1564, Sun Dec 5 04:53:01 2004 UTC revision 1691, Mon Feb 27 00:24:02 2006 UTC
# Line 21  Line 21 
21   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
24   * $Id: estimation_pvop.c,v 1.9 2004-12-05 04:53:01 syskin Exp $   * $Id: estimation_pvop.c,v 1.21 2006-02-27 00:24:02 syskin Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 39  Line 39 
39  #include "motion.h"  #include "motion.h"
40  #include "sad.h"  #include "sad.h"
41  #include "motion_inlines.h"  #include "motion_inlines.h"
42    #include "motion_smp.h"
43    
44    
45  static const int xvid_me_lambda_vec8[32] =  static const int xvid_me_lambda_vec8[32] =
46          {     0    ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5),          {     0    ,(int)(1.0 * NEIGH_TEND_8X8 + 0.5),
47          (int)(1.15582*NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5),          (int)(2.0*NEIGH_TEND_8X8 + 0.5), (int)(3.0*NEIGH_TEND_8X8 + 0.5),
48          (int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5),          (int)(4.0*NEIGH_TEND_8X8 + 0.5), (int)(5.0*NEIGH_TEND_8X8 + 0.5),
49          (int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5),          (int)(6.0*NEIGH_TEND_8X8 + 0.5), (int)(7.0*NEIGH_TEND_8X8 + 0.5),
50          (int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5),          (int)(8.0*NEIGH_TEND_8X8 + 0.5), (int)(9.0*NEIGH_TEND_8X8 + 0.5),
51          (int)(2.91455*NEIGH_TEND_8X8 + 0.5), (int)(3.23253*NEIGH_TEND_8X8 + 0.5),          (int)(10.0*NEIGH_TEND_8X8 + 0.5), (int)(11.0*NEIGH_TEND_8X8 + 0.5),
52          (int)(3.58158*NEIGH_TEND_8X8 + 0.5), (int)(3.96555*NEIGH_TEND_8X8 + 0.5),          (int)(12.0*NEIGH_TEND_8X8 + 0.5), (int)(13.0*NEIGH_TEND_8X8 + 0.5),
53          (int)(4.38887*NEIGH_TEND_8X8 + 0.5), (int)(4.85673*NEIGH_TEND_8X8 + 0.5),          (int)(14.0*NEIGH_TEND_8X8 + 0.5), (int)(15.0*NEIGH_TEND_8X8 + 0.5),
54          (int)(5.37519*NEIGH_TEND_8X8 + 0.5), (int)(5.95144*NEIGH_TEND_8X8 + 0.5),          (int)(16.0*NEIGH_TEND_8X8 + 0.5), (int)(17.0*NEIGH_TEND_8X8 + 0.5),
55          (int)(6.59408*NEIGH_TEND_8X8 + 0.5), (int)(7.31349*NEIGH_TEND_8X8 + 0.5),          (int)(18.0*NEIGH_TEND_8X8 + 0.5), (int)(19.0*NEIGH_TEND_8X8 + 0.5),
56          (int)(8.12242*NEIGH_TEND_8X8 + 0.5), (int)(9.03669*NEIGH_TEND_8X8 + 0.5),          (int)(20.0*NEIGH_TEND_8X8 + 0.5), (int)(21.0*NEIGH_TEND_8X8 + 0.5),
57          (int)(10.0763*NEIGH_TEND_8X8 + 0.5), (int)(11.2669*NEIGH_TEND_8X8 + 0.5),          (int)(22.0*NEIGH_TEND_8X8 + 0.5), (int)(23.0*NEIGH_TEND_8X8 + 0.5),
58          (int)(12.6426*NEIGH_TEND_8X8 + 0.5), (int)(14.2493*NEIGH_TEND_8X8 + 0.5),          (int)(24.0*NEIGH_TEND_8X8 + 0.5), (int)(25.0*NEIGH_TEND_8X8 + 0.5),
59          (int)(16.1512*NEIGH_TEND_8X8 + 0.5), (int)(18.442*NEIGH_TEND_8X8 + 0.5),          (int)(26.0*NEIGH_TEND_8X8 + 0.5), (int)(27.0*NEIGH_TEND_8X8 + 0.5),
60          (int)(21.2656*NEIGH_TEND_8X8 + 0.5), (int)(24.8580*NEIGH_TEND_8X8 + 0.5),          (int)(28.0*NEIGH_TEND_8X8 + 0.5), (int)(29.0*NEIGH_TEND_8X8 + 0.5),
61          (int)(29.6436*NEIGH_TEND_8X8 + 0.5), (int)(36.4949*NEIGH_TEND_8X8 + 0.5)          (int)(30.0*NEIGH_TEND_8X8 + 0.5), (int)(31.0*NEIGH_TEND_8X8 + 0.5)
62  };  };
63    
64  static void  static void
# Line 82  Line 84 
84          sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp);          sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp);
85          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);
86    
87          sad += (data->lambda16 * t * sad)>>10;          sad += (data->lambda16 * t);
88          data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10;          data->temp[0] += (data->lambda8 * t);
89    
90          if (data->chroma) {          if (data->chroma) {
91                  if (sad >= data->iMinSAD[0]) goto no16;                  if (sad >= data->iMinSAD[0]) goto no16;
# Line 129  Line 131 
131          sad = sad8(data->Cur, Reference, data->iEdgedWidth);          sad = sad8(data->Cur, Reference, data->iEdgedWidth);
132          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);
133    
134          sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10;          sad += (data->lambda8 * t);
135    
136          if (sad < *(data->iMinSAD)) {          if (sad < *(data->iMinSAD)) {
137                  *(data->iMinSAD) = sad;                  *(data->iMinSAD) = sad;
# Line 423  Line 425 
425                                                                                  Data->predMV, Data->iFcode, 0);                                                                                  Data->predMV, Data->iFcode, 0);
426          }          }
427    
428          *(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10;          *(Data->iMinSAD) += (Data->lambda8 * i);
429    
430          if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) {          if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) {
431    
# Line 557  Line 559 
559          else Data->predMV = pmv[0];          else Data->predMV = pmv[0];
560    
561          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0);          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0);
562          Data->iMinSAD[0] = pMB->sad16 + ((Data->lambda16 * i * pMB->sad16)>>10);          Data->iMinSAD[0] = pMB->sad16 + (Data->lambda16 * i);
563          Data->iMinSAD[1] = pMB->sad8[0] + ((Data->lambda8 * i * (pMB->sad8[0]+NEIGH_8X8_BIAS)) >> 10);          Data->iMinSAD[1] = pMB->sad8[0] + (Data->lambda8 * i);
564          Data->iMinSAD[2] = pMB->sad8[1];          Data->iMinSAD[2] = pMB->sad8[1];
565          Data->iMinSAD[3] = pMB->sad8[2];          Data->iMinSAD[3] = pMB->sad8[2];
566          Data->iMinSAD[4] = pMB->sad8[3];          Data->iMinSAD[4] = pMB->sad8[3];
# Line 705  Line 707 
707          } else Data->iMinSAD[1] = 4096*256;          } else Data->iMinSAD[1] = 4096*256;
708  }  }
709    
710    static int
711    InitialSkipDecisionP(int sad00,
712                                             const MBParam * pParam,
713                                             const FRAMEINFO * current,
714                                             MACROBLOCK * pMB,
715                                             const MACROBLOCK * prevMB,
716                                             int x, int y,
717                                             const SearchData * Data,
718                                             const IMAGE * const pGMC,
719                                             const IMAGE * const pCurrent,
720                                             const IMAGE * const pRef,
721                                             const uint32_t MotionFlags)
722    {
723            const unsigned int iEdgedWidth = pParam->edged_width;
724    
725            int skip_thresh = INITIAL_SKIP_THRESH * \
726                    (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
727            int stat_thresh = 0;
728    
729            /* initial skip decision */
730            if (current->coding_type != S_VOP)      { /* no fast SKIP for S(GMC)-VOPs */
731                    if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh)
732                            if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant)) {
733                                    ZeroMacroblockP(pMB, sad00);
734                                    pMB->mode = MODE_NOT_CODED;
735                                    return 1;
736                            }
737            }
738    
739            if(MotionFlags & XVID_ME_DETECT_STATIC_MOTION) {
740                    VECTOR *cmpMV;
741                    VECTOR staticMV = { 0, 0 };
742                    const MACROBLOCK * pMBs = current->mbs;
743    
744                    if (current->coding_type == S_VOP)
745                            cmpMV = &pMB->amv;
746                    else
747                            cmpMV = &staticMV;
748    
749                    if(x > 0 && y > 0 && x < pParam->mb_width) {
750                            if(MVequal((&pMBs[(x-1) + y * pParam->mb_width])->mvs[0], *cmpMV) &&
751                               MVequal((&pMBs[x + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&
752                               MVequal((&pMBs[(x+1) + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&
753                               MVequal(prevMB->mvs[0], *cmpMV)) {
754                                    stat_thresh = MAX((&pMBs[(x-1) + y * pParam->mb_width])->sad16,
755                                                              MAX((&pMBs[x + (y-1) * pParam->mb_width])->sad16,
756                                                              MAX((&pMBs[(x+1) + (y-1) * pParam->mb_width])->sad16,
757                                                              prevMB->sad16)));
758                            } else {
759                                    stat_thresh = MIN((&pMBs[(x-1) + y * pParam->mb_width])->sad16,
760                                                              MIN((&pMBs[x + (y-1) * pParam->mb_width])->sad16,
761                                                              MIN((&pMBs[(x+1) + (y-1) * pParam->mb_width])->sad16,
762                                                              prevMB->sad16)));
763                            }
764                    }
765            }
766    
767             /* favorize (0,0) or global vector for cartoons */
768            if (current->vop_flags & XVID_VOP_CARTOON) {
769                    if (current->coding_type == S_VOP) {
770                            int32_t iSAD = sad16(pCurrent->y + (x + y * iEdgedWidth) * 16,
771                            pGMC->y + 16*y*iEdgedWidth + 16*x, iEdgedWidth, 65536);
772    
773                            if (Data->chroma) {
774                                    iSAD += sad8(pCurrent->u + x*8 + y*(iEdgedWidth/2)*8, pGMC->u + 8*y*(iEdgedWidth/2) + 8*x, iEdgedWidth/2);
775                                    iSAD += sad8(pCurrent->v + (x + y*(iEdgedWidth/2))*8, pGMC->v + 8*y*(iEdgedWidth/2) + 8*x, iEdgedWidth/2);
776                            }
777    
778                            if (iSAD <= stat_thresh) {              /* mode decision GMC */
779                                    pMB->mode = MODE_INTER;
780                                    pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = iSAD;
781                                    pMB->mcsel = 1;
782                                    if (Data->qpel) {
783                                            pMB->qmvs[0] = pMB->qmvs[1] = pMB->qmvs[2] = pMB->qmvs[3] = pMB->amv;
784                                            pMB->mvs[0].x = pMB->mvs[1].x = pMB->mvs[2].x = pMB->mvs[3].x = pMB->amv.x/2;
785                                            pMB->mvs[0].y = pMB->mvs[1].y = pMB->mvs[2].y = pMB->mvs[3].y = pMB->amv.y/2;
786                                    } else
787                                            pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv;
788    
789                                    return 1;
790                            }
791                    }
792                    else if (sad00 < stat_thresh) {
793                            VECTOR predMV;
794                            if (Data->qpel)
795                                    predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, 0);
796                            else
797                                    predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, 0);
798    
799                            ZeroMacroblockP(pMB, sad00);
800                            pMB->cbp = 0x3f;
801                            pMB->pmvs[0].x = - predMV.x;
802                            pMB->pmvs[0].y = - predMV.y;
803                            return 1;
804                    }
805            }
806    
807            return 0;
808    }
809    
810  static __inline uint32_t  static __inline uint32_t
811  MakeGoodMotionFlags(const uint32_t MotionFlags, const uint32_t VopFlags, const uint32_t VolFlags)  MakeGoodMotionFlags(const uint32_t MotionFlags, const uint32_t VopFlags, const uint32_t VolFlags)
812  {  {
# Line 751  Line 853 
853          return Flags;          return Flags;
854  }  }
855    
856  bool  static __inline void
857    motionStatsPVOP(int * const MVmax, int * const mvCount, int * const mvSum,
858                                    const MACROBLOCK * const pMB, const int qpel)
859    {
860            const VECTOR * const mv = qpel ? pMB->qmvs : pMB->mvs;
861            int i;
862            int max = *MVmax;
863    
864            switch (pMB->mode) {
865            case MODE_INTER4V:
866                    *mvCount += 3;
867                    for(i = 3; i; i--) {
868                            if (mv[i].x > max) max = mv[i].x;
869                            else if (-mv[i].x - 1 > max) max = -mv[i].x - 1;
870                            *mvSum += mv[i].x * mv[i].x;
871                            if (mv[i].y > max) max = mv[i].y;
872                            else if (-mv[i].y - 1 > max) max = -mv[i].y - 1;
873                            *mvSum += mv[i].y * mv[i].y;
874                    }
875            case MODE_INTER:
876                    (*mvCount)++;
877                    *mvSum += mv[0].x * mv[0].x;
878                    *mvSum += mv[0].y * mv[0].y;
879                    if (mv[0].x > max) max = mv[0].x;
880                    else if (-mv[0].x - 1 > max) max = -mv[0].x - 1;
881                    if (mv[0].y > max) max = mv[0].y;
882                    else if (-mv[0].y - 1 > max) max = -mv[0].y - 1;
883                    *MVmax = max;
884            default:
885                    break;
886            }
887    }
888    
889    void
890  MotionEstimation(MBParam * const pParam,  MotionEstimation(MBParam * const pParam,
891                                   FRAMEINFO * const current,                                   FRAMEINFO * const current,
892                                   FRAMEINFO * const reference,                                   FRAMEINFO * const reference,
# Line 770  Line 905 
905          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
906          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);
907          int stat_thresh = 0;          int stat_thresh = 0;
908            int MVmax = 0, mvSum = 0, mvCount = 0;
909    
910          uint32_t x, y;          uint32_t x, y;
911          int32_t sad00;          int sad00;
912          int skip_thresh = INITIAL_SKIP_THRESH * \          int skip_thresh = INITIAL_SKIP_THRESH * \
913                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
914            int block = 0;
915    
916          /* some pre-initialized thingies for SearchP */          /* some pre-initialized thingies for SearchP */
917          DECLARE_ALIGNED_MATRIX(dct_space, 3, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(dct_space, 3, 64, int16_t, CACHE_LINE);
# Line 794  Line 931 
931    
932          for (y = 0; y < mb_height; y++) {          for (y = 0; y < mb_height; y++) {
933                  for (x = 0; x < mb_width; x++)  {                  for (x = 0; x < mb_width; x++)  {
934                          MACROBLOCK *pMB = &pMBs[x + y * pParam->mb_width];                          MACROBLOCK *pMB = &pMBs[block];
935                          MACROBLOCK *prevMB = &reference->mbs[x + y * pParam->mb_width];                          MACROBLOCK *prevMB = &reference->mbs[block];
936                            int skip;
937                            block++;
938    
939                          pMB->sad16 =                          pMB->sad16 =
940                                  sad16v(pCurrent->y + (x + y * iEdgedWidth) * 16,                                  sad16v(pCurrent->y + (x + y * iEdgedWidth) * 16,
# Line 813  Line 952 
952                                  sad00 += Data.chromaSAD;                                  sad00 += Data.chromaSAD;
953                          }                          }
954    
955                          /* initial skip decision */                          skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,
956                          if (current->coding_type != S_VOP)      { /* no fast SKIP for S(GMC)-VOPs */                                                                                  pCurrent, pRef, MotionFlags);
957                                  if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh)                          if (skip) continue;
958                                          if (Data.chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant)) {  
959                                                  ZeroMacroblockP(pMB, sad00);                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
960                                                  pMB->mode = MODE_NOT_CODED;                                          y, MotionFlags, current->vop_flags,
961                                                  continue;                                          &Data, pParam, pMBs, reference->mbs, pMB);
962    
963                            if (current->vop_flags & XVID_VOP_MODEDECISION_RD)
964                                    xvid_me_ModeDecision_RD(&Data, pMB, pMBs, x, y, pParam,
965                                                                    MotionFlags, current->vop_flags, current->vol_flags,
966                                                                    pCurrent, pRef, pGMC, current->coding_type);
967    
968                            else if (current->vop_flags & XVID_VOP_FAST_MODEDECISION_RD)
969                                    xvid_me_ModeDecision_Fast(&Data, pMB, pMBs, x, y, pParam,
970                                                                    MotionFlags, current->vop_flags, current->vol_flags,
971                                                                    pCurrent, pRef, pGMC, current->coding_type);
972                            else
973                                    ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam,
974                                                                    MotionFlags, current->vop_flags, current->vol_flags,
975                                                                    pCurrent, pRef, pGMC, current->coding_type, sad00);
976    
977    
978                            motionStatsPVOP(&MVmax, &mvCount, &mvSum, pMB, Data.qpel);
979                                          }                                          }
980                          }                          }
981    
982                          if(MotionFlags & XVID_ME_DETECT_STATIC_MOTION) {          current->fcode = getMinFcode(MVmax);
983                                  if(x > 0 && y > 0 && x < pParam->mb_width) {          current->sStat.iMvSum = mvSum;
984                                          if(MVequal((&pMBs[(x-1) + y * pParam->mb_width])->mvs[0], zeroMV) &&          current->sStat.iMvCount = mvCount;
                                            MVequal((&pMBs[x + (y-1) * pParam->mb_width])->mvs[0], zeroMV) &&  
                                        MVequal((&pMBs[(x+1) + (y-1) * pParam->mb_width])->mvs[0], zeroMV) &&  
                                        MVequal(prevMB->mvs[0], zeroMV)) {  
                                                 stat_thresh = MAX((&pMBs[(x-1) + y * pParam->mb_width])->sad16,  
                                                                           MAX((&pMBs[x + (y-1) * pParam->mb_width])->sad16,  
                                                                           MAX((&pMBs[(x+1) + (y-1) * pParam->mb_width])->sad16,  
                                                                           prevMB->sad16)));  
                                         } else {  
                                                 stat_thresh = MIN((&pMBs[(x-1) + y * pParam->mb_width])->sad16,  
                                                                           MIN((&pMBs[x + (y-1) * pParam->mb_width])->sad16,  
                                                                           MIN((&pMBs[(x+1) + (y-1) * pParam->mb_width])->sad16,  
                                                                           prevMB->sad16)));  
985                                          }                                          }
986    
987    void
988    MotionEstimateSMP(SMPmotionData * h)
989    {
990            const MBParam * const pParam = h->pParam;
991            const FRAMEINFO * const current = h->current;
992            const FRAMEINFO * const reference = h->reference;
993            const IMAGE * const pRefH = h->pRefH;
994            const IMAGE * const pRefV = h->pRefV;
995            const IMAGE * const pRefHV = h->pRefHV;
996            const IMAGE * const pGMC = h->pGMC;
997            uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags,
998                                                                                                    current->vop_flags,
999                                                                                                    current->vol_flags);
1000    
1001            MACROBLOCK *const pMBs = current->mbs;
1002            const IMAGE *const pCurrent = &current->image;
1003            const IMAGE *const pRef = &reference->image;
1004    
1005            const uint32_t mb_width = pParam->mb_width;
1006            const uint32_t mb_height = pParam->mb_height;
1007            const uint32_t iEdgedWidth = pParam->edged_width;
1008            int stat_thresh = 0;
1009            int MVmax = 0, mvSum = 0, mvCount = 0;
1010            int y_step = h->y_step;
1011            int start_y = h->start_y;
1012    
1013            uint32_t x, y;
1014            int sad00;
1015            int skip_thresh = INITIAL_SKIP_THRESH * \
1016                    (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
1017            int block = start_y*mb_width;
1018            int * complete_count_self = h->complete_count_self;
1019            const volatile int * complete_count_above = h->complete_count_above;
1020            int max_mbs;
1021            int current_mb = 0;
1022    
1023            /* some pre-initialized thingies for SearchP */
1024            DECLARE_ALIGNED_MATRIX(dct_space, 3, 64, int16_t, CACHE_LINE);
1025            SearchData Data;
1026            memset(&Data, 0, sizeof(SearchData));
1027            Data.iEdgedWidth = iEdgedWidth;
1028            Data.iFcode = current->fcode;
1029            Data.rounding = pParam->m_rounding_type;
1030            Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);
1031            Data.chroma = MotionFlags & XVID_ME_CHROMA_PVOP;
1032            Data.dctSpace = dct_space;
1033            Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);
1034            Data.mpeg_quant_matrices = pParam->mpeg_quant_matrices;
1035    
1036            /* todo: sort out temp memory space */
1037            Data.RefQ = h->RefQ;
1038            if (sadInit) (*sadInit) ();
1039    
1040            max_mbs = 0;
1041    
1042            for (y = start_y; y < mb_height; y += y_step)   {
1043                    if (y == 0) max_mbs = mb_width; /* we can process all blocks of the first row */
1044    
1045                    for (x = 0; x < mb_width; x++)  {
1046    
1047                            MACROBLOCK *pMB, *prevMB;
1048                            int skip;
1049    
1050                            if (current_mb >= max_mbs) {
1051                                    /* we ME-ed all macroblocks we safely could. grab next portion */
1052                                    int above_count = *complete_count_above; /* sync point */
1053                                    if (above_count == mb_width) {
1054                                            /* full line above is ready */
1055                                            above_count = mb_width+1;
1056                                            if (y < mb_height-y_step) {
1057                                                    /* this is not last line, grab a portion of MBs from the next line too */
1058                                                    above_count += MAX(0, complete_count_above[1] - 1);
1059                                  }                                  }
1060                          }                          }
1061    
1062                           /* favorize (0,0) vector for cartoons */                                  max_mbs = current_mb + above_count - x - 1;
1063                          if ((current->vop_flags & XVID_VOP_CARTOON) &&  
1064                                  ((sad00 < pMB->quant * 4 * skip_thresh) || (sad00 < stat_thresh))) {                                  if (current_mb >= max_mbs) {
1065                                  ZeroMacroblockP(pMB, sad00);                                          /* current workload is zero */
1066                                            x--;
1067                                            sched_yield();
1068                                            continue;
1069                                    }
1070                            }
1071    
1072    
1073                            pMB = &pMBs[block];
1074                            prevMB = &reference->mbs[block];
1075    
1076                            pMB->sad16 =
1077                                    sad16v(pCurrent->y + (x + y * iEdgedWidth) * 16,
1078                                                            pRef->y + (x + y * iEdgedWidth) * 16,
1079                                                            pParam->edged_width, pMB->sad8);
1080    
1081                            sad00 = 4*MAX(MAX(pMB->sad8[0], pMB->sad8[1]), MAX(pMB->sad8[2], pMB->sad8[3]));
1082    
1083                            if (Data.chroma) {
1084                                    Data.chromaSAD = sad8(pCurrent->u + x*8 + y*(iEdgedWidth/2)*8,
1085                                                                            pRef->u + x*8 + y*(iEdgedWidth/2)*8, iEdgedWidth/2)
1086                                                                    + sad8(pCurrent->v + (x + y*(iEdgedWidth/2))*8,
1087                                                                            pRef->v + (x + y*(iEdgedWidth/2))*8, iEdgedWidth/2);
1088                                    pMB->sad16 += Data.chromaSAD;
1089                                    sad00 += Data.chromaSAD;
1090                            }
1091    
1092                            skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,
1093                                                                                    pCurrent, pRef, MotionFlags);
1094    
1095                            if (skip) {
1096                                    current_mb++;
1097                                    block++;
1098                                    *complete_count_self = x+1;
1099                                  continue;                                  continue;
1100                          }                          }
1101    
# Line 867  Line 1117 
1117                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
1118                                                                  pCurrent, pRef, pGMC, current->coding_type, sad00);                                                                  pCurrent, pRef, pGMC, current->coding_type, sad00);
1119    
1120                            *complete_count_self = x+1;
1121    
1122                            current_mb++;
1123                            block++;
1124    
1125                            motionStatsPVOP(&MVmax, &mvCount, &mvSum, pMB, Data.qpel);
1126    
1127                  }                  }
1128                    block += (y_step-1)*pParam->mb_width;
1129                    complete_count_self++;
1130                    complete_count_above++;
1131          }          }
1132          return 0;  
1133            h->minfcode = getMinFcode(MVmax);
1134    
1135            h->MVmax = MVmax;
1136            h->mvSum = mvSum;
1137            h->mvCount = mvCount;
1138  }  }
1139    
1140    

Legend:
Removed from v.1564  
changed lines
  Added in v.1691

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