[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 1912, Sat Dec 18 10:17:35 2010 UTC revision 1913, Sat Dec 18 16:02:08 2010 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.23 2010-11-28 15:18:21 Isibaar Exp $   * $Id: estimation_pvop.c,v 1.24 2010-12-18 16:02:00 Isibaar Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 407  Line 407 
407                  MACROBLOCK * const pMB,                  MACROBLOCK * const pMB,
408                  const MACROBLOCK * const pMBs,                  const MACROBLOCK * const pMBs,
409                  const int block,                  const int block,
410                  SearchData * const Data)                  SearchData * const Data,
411                    const int bound)
412  {  {
413          int i = 0;          int i = 0;
414          VECTOR vbest_q; int32_t sbest_q;          VECTOR vbest_q; int32_t sbest_q;
# Line 416  Line 417 
417          *Data->currentQMV = *(OldData->currentQMV + 1 + block);          *Data->currentQMV = *(OldData->currentQMV + 1 + block);
418    
419          if(Data->qpel) {          if(Data->qpel) {
420                  Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);                  Data->predMV = get_qpmv2(pMBs, pParam->mb_width, bound, x/2, y/2, block);
421                  if (block != 0) i = d_mv_bits(  Data->currentQMV->x, Data->currentQMV->y,                  if (block != 0) i = d_mv_bits(  Data->currentQMV->x, Data->currentQMV->y,
422                                                                                  Data->predMV, Data->iFcode, 0);                                                                                  Data->predMV, Data->iFcode, 0);
423          } else {          } else {
424                  Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);                  Data->predMV = get_pmv2(pMBs, pParam->mb_width, bound, x/2, y/2, block);
425                  if (block != 0) i = d_mv_bits(  Data->currentMV->x, Data->currentMV->y,                  if (block != 0) i = d_mv_bits(  Data->currentMV->x, Data->currentMV->y,
426                                                                                  Data->predMV, Data->iFcode, 0);                                                                                  Data->predMV, Data->iFcode, 0);
427          }          }
# Line 523  Line 524 
524                  const MBParam * const pParam,                  const MBParam * const pParam,
525                  const MACROBLOCK * const pMBs,                  const MACROBLOCK * const pMBs,
526                  const MACROBLOCK * const prevMBs,                  const MACROBLOCK * const prevMBs,
527                  MACROBLOCK * const pMB)                  MACROBLOCK * const pMB,
528                    const int bound)
529  {  {
530    
531          int i, threshA;          int i, threshA;
# Line 534  Line 536 
536          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,
537                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 1);                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 1);
538    
539          get_pmvdata2(pMBs, pParam->mb_width, 0, x, y, pmv, Data->temp);          get_pmvdata2(pMBs, pParam->mb_width, bound, x, y, pmv, Data->temp);
540    
541          Data->chromaX = Data->chromaY = 0; /* chroma-sad cache */          Data->chromaX = Data->chromaY = 0; /* chroma-sad cache */
542          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;
# Line 555  Line 557 
557    
558          memset(Data->currentMV, 0, 5*sizeof(VECTOR));          memset(Data->currentMV, 0, 5*sizeof(VECTOR));
559    
560          if (Data->qpel) Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, 0);          if (Data->qpel) Data->predMV = get_qpmv2(pMBs, pParam->mb_width, bound, x, y, 0);
561          else Data->predMV = pmv[0];          else Data->predMV = pmv[0];
562    
563          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0);          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0);
# Line 681  Line 683 
683                  SearchData Data8;                  SearchData Data8;
684                  memcpy(&Data8, Data, sizeof(SearchData)); /* quick copy of common data */                  memcpy(&Data8, Data, sizeof(SearchData)); /* quick copy of common data */
685    
686                  Search8(Data, 2*x, 2*y, MotionFlags, pParam, pMB, pMBs, 0, &Data8);                  Search8(Data, 2*x, 2*y, MotionFlags, pParam, pMB, pMBs, 0, &Data8, bound);
687                  Search8(Data, 2*x + 1, 2*y, MotionFlags, pParam, pMB, pMBs, 1, &Data8);                  Search8(Data, 2*x + 1, 2*y, MotionFlags, pParam, pMB, pMBs, 1, &Data8, bound);
688                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8);                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8, bound);
689                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8);                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8, bound);
690    
691                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_RD))) {                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_RD))) {
692                          /* chroma is only used for comparison to INTER. if the comparison will be done in RD domain, it will not be used */                          /* chroma is only used for comparison to INTER. if the comparison will be done in RD domain, it will not be used */
# Line 718  Line 720 
720                                           const IMAGE * const pGMC,                                           const IMAGE * const pGMC,
721                                           const IMAGE * const pCurrent,                                           const IMAGE * const pCurrent,
722                                           const IMAGE * const pRef,                                           const IMAGE * const pRef,
723                                           const uint32_t MotionFlags)                                           const uint32_t MotionFlags,
724                                             const int bound)
725  {  {
726          const unsigned int iEdgedWidth = pParam->edged_width;          const unsigned int iEdgedWidth = pParam->edged_width;
727    
# Line 746  Line 749 
749                  else                  else
750                          cmpMV = &staticMV;                          cmpMV = &staticMV;
751    
752                  if(x > 0 && y > 0 && x < pParam->mb_width) {                  if(x > 0 && y > 0 && x < (int) pParam->mb_width) {
753                          if(MVequal((&pMBs[(x-1) + y * pParam->mb_width])->mvs[0], *cmpMV) &&                          if(MVequal((&pMBs[(x-1) + y * pParam->mb_width])->mvs[0], *cmpMV) &&
754                             MVequal((&pMBs[x + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&                             MVequal((&pMBs[x + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&
755                             MVequal((&pMBs[(x+1) + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&                             MVequal((&pMBs[(x+1) + (y-1) * pParam->mb_width])->mvs[0], *cmpMV) &&
# Line 792  Line 795 
795                  else if (sad00 < stat_thresh) {                  else if (sad00 < stat_thresh) {
796                          VECTOR predMV;                          VECTOR predMV;
797                          if (Data->qpel)                          if (Data->qpel)
798                                  predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, 0);                                  predMV = get_qpmv2(current->mbs, pParam->mb_width, bound, x, y, 0);
799                          else                          else
800                                  predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, 0);                                  predMV = get_pmv2(current->mbs, pParam->mb_width, bound, x, y, 0);
801    
802                          ZeroMacroblockP(pMB, sad00);                          ZeroMacroblockP(pMB, sad00);
803                          pMB->cbp = 0x3f;                          pMB->cbp = 0x3f;
# Line 894  Line 897 
897                                   const IMAGE * const pRefV,                                   const IMAGE * const pRefV,
898                                   const IMAGE * const pRefHV,                                   const IMAGE * const pRefHV,
899                                   const IMAGE * const pGMC,                                   const IMAGE * const pGMC,
900                                   const uint32_t iLimit)                                   const uint32_t iLimit,
901                                     const int num_slices)
902  {  {
903          MACROBLOCK *const pMBs = current->mbs;          MACROBLOCK *const pMBs = current->mbs;
904          const IMAGE *const pCurrent = &current->image;          const IMAGE *const pCurrent = &current->image;
# Line 905  Line 909 
909          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
910          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);
911          int stat_thresh = 0;          int stat_thresh = 0;
912            int bound = 0;
913          int MVmax = 0, mvSum = 0, mvCount = 0;          int MVmax = 0, mvSum = 0, mvCount = 0;
914    
915          uint32_t x, y;          uint32_t x, y;
# Line 930  Line 935 
935          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
936    
937          for (y = 0; y < mb_height; y++) {          for (y = 0; y < mb_height; y++) {
938    
939                    bound = mb_width * ((((y*num_slices) / mb_height) * mb_height + (num_slices-1)) / num_slices);
940    
941                  for (x = 0; x < mb_width; x++)  {                  for (x = 0; x < mb_width; x++)  {
942                          MACROBLOCK *pMB = &pMBs[block];                          MACROBLOCK *pMB = &pMBs[block];
943                          MACROBLOCK *prevMB = &reference->mbs[block];                          MACROBLOCK *prevMB = &reference->mbs[block];
# Line 953  Line 961 
961                          }                          }
962    
963                          skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,                          skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,
964                                                                                  pCurrent, pRef, MotionFlags);                                                                                  pCurrent, pRef, MotionFlags, bound);
965                          if (skip) continue;                          if (skip) continue;
966    
967                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
968                                          y, MotionFlags, current->vop_flags,                                          y, MotionFlags, current->vop_flags,
969                                          &Data, pParam, pMBs, reference->mbs, pMB);                                          &Data, pParam, pMBs, reference->mbs, pMB, bound);
970    
971                          if (current->vop_flags & XVID_VOP_MODEDECISION_RD)                          if (current->vop_flags & XVID_VOP_MODEDECISION_RD)
972                                  xvid_me_ModeDecision_RD(&Data, pMB, pMBs, x, y, pParam,                                  xvid_me_ModeDecision_RD(&Data, pMB, pMBs, x, y, pParam,
973                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
974                                                                  pCurrent, pRef, pGMC, current->coding_type);                                                                  pCurrent, pRef, pGMC, current->coding_type, bound);
975    
976                          else if (current->vop_flags & XVID_VOP_FAST_MODEDECISION_RD)                          else if (current->vop_flags & XVID_VOP_FAST_MODEDECISION_RD)
977                                  xvid_me_ModeDecision_Fast(&Data, pMB, pMBs, x, y, pParam,                                  xvid_me_ModeDecision_Fast(&Data, pMB, pMBs, x, y, pParam,
978                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
979                                                                  pCurrent, pRef, pGMC, current->coding_type);                                                                  pCurrent, pRef, pGMC, current->coding_type, bound);
980                          else                          else
981                                  ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam,                                  ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam,
982                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
# Line 985  Line 993 
993  }  }
994    
995  void  void
996  MotionEstimateSMP(SMPmotionData * h)  MotionEstimateSMP(SMPData * h)
997  {  {
998          const MBParam * const pParam = h->pParam;          Encoder *pEnc = (Encoder *) h->pEnc;
999          const FRAMEINFO * const current = h->current;  
1000          const FRAMEINFO * const reference = h->reference;          const MBParam * const pParam = &pEnc->mbParam;
1001          const IMAGE * const pRefH = h->pRefH;          const FRAMEINFO * const current = pEnc->current;
1002          const IMAGE * const pRefV = h->pRefV;          const FRAMEINFO * const reference = pEnc->reference;
1003          const IMAGE * const pRefHV = h->pRefHV;          const IMAGE * const pRefH = &pEnc->vInterH;
1004          const IMAGE * const pGMC = h->pGMC;          const IMAGE * const pRefV = &pEnc->vInterV;
1005            const IMAGE * const pRefHV = &pEnc->vInterHV;
1006            const IMAGE * const pGMC = &pEnc->vGMC;
1007          uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags,          uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags,
1008                                                                                                  current->vop_flags,                                                                                                  current->vop_flags,
1009                                                                                                  current->vol_flags);                                                                                                  current->vol_flags);
# Line 1002  Line 1012 
1012          const IMAGE *const pCurrent = &current->image;          const IMAGE *const pCurrent = &current->image;
1013          const IMAGE *const pRef = &reference->image;          const IMAGE *const pRef = &reference->image;
1014    
1015          const uint32_t mb_width = pParam->mb_width;          const int mb_width = pParam->mb_width;
1016          const uint32_t mb_height = pParam->mb_height;          const int mb_height = pParam->mb_height;
1017          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
1018          int stat_thresh = 0;          int stat_thresh = 0;
1019            int bound = 0;
1020            int num_slices = pEnc->num_slices;
1021          int y_step = h->y_step;          int y_step = h->y_step;
1022            int y_row = h->y_row;
1023          int start_y = h->start_y;          int start_y = h->start_y;
1024            int stop_y = h->stop_y;
1025          int MVmax = 0, mvSum = 0, mvCount = 0;          int MVmax = 0, mvSum = 0, mvCount = 0;
1026    
1027          uint32_t x, y;          int x, y;
1028          int sad00;          int sad00;
1029          int skip_thresh = INITIAL_SKIP_THRESH * \          int skip_thresh = INITIAL_SKIP_THRESH * \
1030                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
1031          int block = start_y*mb_width;          int block = (start_y+y_row)*mb_width;
1032          int * complete_count_self = h->complete_count_self;          int * complete_count_self = h->complete_count_self;
1033          const volatile int * complete_count_above = h->complete_count_above;          const volatile int * complete_count_above = h->complete_count_above;
1034          int max_mbs;          int max_mbs;
# Line 1039  Line 1053 
1053    
1054          max_mbs = 0;          max_mbs = 0;
1055    
1056          for (y = start_y; y < mb_height; y += y_step)   {          for (y = (start_y + y_row); y < stop_y; y += y_step)    {
1057                  if (y == 0) max_mbs = mb_width; /* we can process all blocks of the first row */                  bound = mb_width * ((((y*num_slices) / mb_height) * mb_height + (num_slices-1)) / num_slices);
1058    
1059                    if (y == start_y) max_mbs = mb_width; /* we can process all blocks of the first row */
1060    
1061                  for (x = 0; x < mb_width; x++)  {                  for (x = 0; x < mb_width; x++)  {
1062    
# Line 1053  Line 1069 
1069                                  if (above_count == mb_width) {                                  if (above_count == mb_width) {
1070                                          /* full line above is ready */                                          /* full line above is ready */
1071                                          above_count = mb_width+1;                                          above_count = mb_width+1;
1072                                          if (y < mb_height-y_step) {                                          if (y < (stop_y-y_step)) {
1073                                                  /* this is not last line, grab a portion of MBs from the next line too */                                                  /* this is not last line, grab a portion of MBs from the next line too */
1074                                                  above_count += MAX(0, complete_count_above[1] - 1);                                                  above_count += MAX(0, complete_count_above[1] - 1);
1075                                          }                                          }
# Line 1069  Line 1085 
1085                                  }                                  }
1086                          }                          }
1087    
   
1088                          pMB = &pMBs[block];                          pMB = &pMBs[block];
1089                          prevMB = &reference->mbs[block];                          prevMB = &reference->mbs[block];
1090    
# Line 1090  Line 1105 
1105                          }                          }
1106    
1107                          skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,                          skip = InitialSkipDecisionP(sad00, pParam, current, pMB, prevMB, x, y, &Data, pGMC,
1108                                                                                  pCurrent, pRef, MotionFlags);                                                                                  pCurrent, pRef, MotionFlags, bound);
1109    
1110                          if (skip) {                          if (skip) {
1111                                  current_mb++;                                  current_mb++;
# Line 1101  Line 1116 
1116    
1117                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
1118                                          y, MotionFlags, current->vop_flags,                                          y, MotionFlags, current->vop_flags,
1119                                          &Data, pParam, pMBs, reference->mbs, pMB);                                          &Data, pParam, pMBs, reference->mbs, pMB, bound);
1120    
1121                          if (current->vop_flags & XVID_VOP_MODEDECISION_RD)                          if (current->vop_flags & XVID_VOP_MODEDECISION_RD)
1122                                  xvid_me_ModeDecision_RD(&Data, pMB, pMBs, x, y, pParam,                                  xvid_me_ModeDecision_RD(&Data, pMB, pMBs, x, y, pParam,
1123                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
1124                                                                  pCurrent, pRef, pGMC, current->coding_type);                                                                  pCurrent, pRef, pGMC, current->coding_type, bound);
1125    
1126                          else if (current->vop_flags & XVID_VOP_FAST_MODEDECISION_RD)                          else if (current->vop_flags & XVID_VOP_FAST_MODEDECISION_RD)
1127                                  xvid_me_ModeDecision_Fast(&Data, pMB, pMBs, x, y, pParam,                                  xvid_me_ModeDecision_Fast(&Data, pMB, pMBs, x, y, pParam,
1128                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
1129                                                                  pCurrent, pRef, pGMC, current->coding_type);                                                                  pCurrent, pRef, pGMC, current->coding_type, bound);
1130                          else                          else
1131                                  ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam,                                  ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam,
1132                                                                  MotionFlags, current->vop_flags, current->vol_flags,                                                                  MotionFlags, current->vop_flags, current->vol_flags,
# Line 1125  Line 1140 
1140                          motionStatsPVOP(&MVmax, &mvCount, &mvSum, pMB, Data.qpel);                          motionStatsPVOP(&MVmax, &mvCount, &mvSum, pMB, Data.qpel);
1141    
1142                  }                  }
1143    
1144                  block += (y_step-1)*pParam->mb_width;                  block += (y_step-1)*pParam->mb_width;
1145    
1146                  complete_count_self++;                  complete_count_self++;
1147                  complete_count_above++;                  complete_count_above++;
1148          }          }

Legend:
Removed from v.1912  
changed lines
  Added in v.1913

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