[svn] / branches / dev-api-3 / xvidcore / src / motion / motion_est.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/motion/motion_est.c

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

revision 316, Fri Jul 19 13:34:32 2002 UTC revision 317, Fri Jul 19 14:56:00 2002 UTC
# Line 171  Line 171 
171          const IMAGE *const pCurrent = &current->image;          const IMAGE *const pCurrent = &current->image;
172          const IMAGE *const pRef = &reference->image;          const IMAGE *const pRef = &reference->image;
173    
174          const VECTOR zeroMV = { 0, 0 };          static const VECTOR zeroMV = { 0, 0 };
175    
176          int32_t x, y;          int32_t x, y;
177          int32_t iIntra = 0;          int32_t iIntra = 0;
# Line 2643  Line 2643 
2643  void  void
2644  MotionEstimationBVOP(MBParam * const pParam,  MotionEstimationBVOP(MBParam * const pParam,
2645                                           FRAMEINFO * const frame,                                           FRAMEINFO * const frame,
2646                                  //       const float scalefactor,                                           const int32_t time_bp,
2647                                             const int32_t time_pp,
2648                                           // forward (past) reference                                           // forward (past) reference
2649                                           const MACROBLOCK * const f_mbs,                                           const MACROBLOCK * const f_mbs,
2650                                           const IMAGE * const f_ref,                                           const IMAGE * const f_ref,
# Line 2661  Line 2662 
2662          const int mb_height = pParam->mb_height;          const int mb_height = pParam->mb_height;
2663          const int edged_width = pParam->edged_width;          const int edged_width = pParam->edged_width;
2664    
2665          const float scalefactor=0.666;          int i, j, k;
         int i, j;  
2666    
2667  //      static const VECTOR zeroMV={0,0};          static const VECTOR zeroMV={0,0};
2668    
2669          int f_sad16;    /* forward (as usual) search */          int f_sad16;    /* forward (as usual) search */
2670          int b_sad16;    /* backward (only in b-frames) search */          int b_sad16;    /* backward (only in b-frames) search */
# Line 2681  Line 2681 
2681          int d_count=0;          int d_count=0;
2682          int dnv_count=0;          int dnv_count=0;
2683          int s_count=0;          int s_count=0;
2684            const int64_t TRB = (int32_t)time_pp - (int32_t)time_bp;
2685            const int64_t TRD = (int32_t)time_pp;
2686    
2687            fprintf(stderr,"TRB = %lld  TRD = %lld  time_bp =%d time_pp =%d\n\n",TRB,TRD,time_bp,time_pp);
2688          // note: i==horizontal, j==vertical          // note: i==horizontal, j==vertical
2689          for (j = 0; j < mb_height; j++) {          for (j = 0; j < mb_height; j++) {
2690                  for (i = 0; i < mb_width; i++) {                  for (i = 0; i < mb_width; i++) {
# Line 2689  Line 2692 
2692                          const MACROBLOCK *f_mb = &f_mbs[i + j * mb_width];                          const MACROBLOCK *f_mb = &f_mbs[i + j * mb_width];
2693                          const MACROBLOCK *b_mb = &b_mbs[i + j * mb_width];                          const MACROBLOCK *b_mb = &b_mbs[i + j * mb_width];
2694    
2695                          VECTOR directMV=b_mb->mvs[0];           /* direct mode: presume linear motion */                          VECTOR directMV;
2696                            VECTOR deltaMV=zeroMV;
2697    
2698  /* special case, if collocated block is SKIPed: encoding is forward(0,0)  */  /* special case, if collocated block is SKIPed: encoding is forward(0,0)  */
2699    
# Line 2703  Line 2707 
2707                                  continue;                                  continue;
2708                          }                          }
2709    
2710                          /* candidates for best MV assumes linear motion */                          /* same method of scaling as in decoder.c, so we copy 1:1 from there */
                         /* next vector is linearly scaled (factor depends on distance to that frame) */  
   
                         mb->mvs[0].x = (int)(directMV.x * scalefactor + 0.75);  
                         mb->mvs[0].y = (int)(directMV.y * scalefactor + 0.75);  
2711    
2712                          mb->b_mvs[0].x = (int)(directMV.x * (scalefactor-1.) + 0.75); /* opposite direction! */              for (k = 0; k < 4; k++) {
2713                          mb->b_mvs[0].y = (int)(directMV.y * (scalefactor-1.) + 0.75);                                  directMV = b_mb->mvs[k];
2714    
2715                          DEBUG2("last: ",f_mb->mvs[0].x,f_mb->mvs[0].y);                                  mb->mvs[k].x = (int32_t) ((TRB * directMV.x) / TRD + deltaMV.x);
2716                          DEBUG2("next: ",b_mb->mvs[0].x,b_mb->mvs[0].y);                  mb->b_mvs[k].x = (int32_t) ((deltaMV.x == 0)
2717                          DEBUG2("directF: ",mb->mvs[0].x,mb->mvs[0].y);                                                                          ? ((TRB - TRD) * directMV.x) / TRD
2718                          DEBUG2("directB: ",mb->b_mvs[0].x,mb->b_mvs[0].y);                                      : mb->mvs[k].x - directMV.x);
2719                    mb->mvs[k].y = (int32_t) ((TRB * directMV.y) / TRD + deltaMV.y);
2720                    mb->b_mvs[k].y = (int32_t) ((deltaMV.y == 0)
2721                                                                            ? ((TRB - TRD) * directMV.y) / TRD
2722                                        : mb->mvs[k].y - directMV.y);
2723                }
2724    
2725                          d_sad16 =                          d_sad16 =
2726                                  sad16bi(frame->image.y + i * 16 + j * 16 * edged_width,                                  sad16bi(frame->image.y + i * 16 + j * 16 * edged_width,

Legend:
Removed from v.316  
changed lines
  Added in v.317

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