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

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

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

revision 347, Sun Jul 28 13:06:46 2002 UTC revision 430, Fri Sep 6 16:59:47 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC   *      XVID MPEG-4 VIDEO CODEC
4   *      motion estimation   *  - Motion Estimation module -
5     *
6     *  Copyright(C) 2002 Christoph Lampert <gruel@web.de>
7     *  Copyright(C) 2002 Michael Militzer <michael@xvid.org>
8     *  Copyright(C) 2002 Edouard Gomez <ed.gomez@wanadoo.fr>
9     *  Copyright(C) 2002 chenm001 <chenm001@163.com>
10   *   *
11   *      This program is an implementation of a part of one or more MPEG-4   *      This program is an implementation of a part of one or more MPEG-4
12   *      Video tools as specified in ISO/IEC 14496-2 standard.  Those intending   *      Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
# Line 24  Line 29 
29   *   *
30   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
31   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
32   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
33   *   *
34   *************************************************************************/   *************************************************************************/
35    
 /**************************************************************************  
  *  
  *  Modifications:  
  *  
  *      01.05.2002      updated MotionEstimationBVOP  
  *      25.04.2002 partial prevMB conversion  
  *  22.04.2002 remove some compile warning by chenm001 <chenm001@163.com>  
  *  14.04.2002 added MotionEstimationBVOP()  
  *  02.04.2002 add EPZS(^2) as ME algorithm, use PMV_USESQUARES to choose between  
  *             EPZS and EPZS^2  
  *  08.02.2002 split up PMVfast into three routines: PMVFast, PMVFast_MainLoop  
  *             PMVFast_Refine to support multiple searches with different start points  
  *  07.01.2002 uv-block-based interpolation  
  *  06.01.2002 INTER/INTRA-decision is now done before any SEARCH8 (speedup)  
  *             changed INTER_BIAS to 150 (as suggested by suxen_drol)  
  *             removed halfpel refinement step in PMVfastSearch8 + quality=5  
  *             added new quality mode = 6 which performs halfpel refinement  
  *             filesize difference between quality 5 and 6 is smaller than 1%  
  *             (Isibaar)  
  *  31.12.2001 PMVfastSearch16 and PMVfastSearch8 (gruel)  
  *  30.12.2001 get_range/MotionSearchX simplified; blue/green bug fix  
  *  22.12.2001 commented best_point==99 check  
  *  19.12.2001 modified get_range (purple bug fix)  
  *  15.12.2001 moved pmv displacement from mbprediction  
  *  02.12.2001 motion estimation/compensation split (Isibaar)  
  *  16.11.2001 rewrote/tweaked search algorithms; pross@cs.rmit.edu.au  
  *  10.11.2001 support for sad16/sad8 functions  
  *  28.08.2001 reactivated MODE_INTER4V for EXT_MODE  
  *  24.08.2001 removed MODE_INTER4V_Q, disabled MODE_INTER4V for EXT_MODE  
  *  22.08.2001 added MODE_INTER4V_Q  
  *  20.08.2001 added pragma to get rid of internal compiler error with VC6  
  *             idea by Cyril. Thanks.  
  *  
  *  Michael Militzer <isibaar@videocoding.de>  
  *  
  **************************************************************************/  
   
36  #include <assert.h>  #include <assert.h>
37  #include <stdio.h>  #include <stdio.h>
38  #include <stdlib.h>  #include <stdlib.h>
# Line 186  Line 154 
154    
155                          MACROBLOCK *const pMB = &pMBs[x + y * iWcount];                          MACROBLOCK *const pMB = &pMBs[x + y * iWcount];
156    
157                            if (pMB->mode == MODE_NOT_CODED)
158                                    continue;
159    
160                          predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0);                          predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0);
161    
162                          pMB->sad16 =                          pMB->sad16 =
# Line 2888  Line 2859 
2859                  *currMV = pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;                  *currMV = pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
2860    
2861          } else {          } else {
2862    
2863                    bPredEq = get_ipmvdata(pMBs, iWcount, 0, x, y, 0, pmv, psad);
2864    
2865                  threshA = psad[0];                  threshA = psad[0];
2866                  threshB = threshA + 256;                  threshB = threshA + 256;
2867                  if (threshA < 512)                  if (threshA < 512)
# Line 2897  Line 2871 
2871                  if (threshB > 1792)                  if (threshB > 1792)
2872                          threshB = 1792;                          threshB = 1792;
2873    
                 bPredEq = get_ipmvdata(pMBs, iWcount, 0, x, y, 0, pmv, psad);  
2874                  *currMV = pmv[0];                       /* current best := prediction */                  *currMV = pmv[0];                       /* current best := prediction */
2875          }          }
2876    
# Line 3209  Line 3182 
3182                                              : mb->mvs[k].y - mb->directmv[k].y);                                              : mb->mvs[k].y - mb->directmv[k].y);
3183    
3184                                          d_sad16 +=                                          d_sad16 +=
3185                                                  sad8bi(frame->image.y + 2*(i+(k&1))*8 + 2*(j+(k>>1))*8*edged_width,                                                  sad8bi(frame->image.y + (2*i+(k&1))*8 + (2*j+(k>>1))*8*edged_width,
3186                                                    get_ref_mv(f_ref->y, f_refH->y, f_refV->y, f_refHV->y,                                                    get_ref_mv(f_ref->y, f_refH->y, f_refV->y, f_refHV->y,
3187                                                                  2*(i+(k&1)), 2*(j+(k>>1)), 8, &mb->mvs[k], edged_width),                                                                  (2*i+(k&1)), (2*j+(k>>1)), 8, &mb->mvs[k], edged_width),
3188                                                    get_ref_mv(b_ref->y, b_refH->y, b_refV->y, b_refHV->y,                                                    get_ref_mv(b_ref->y, b_refH->y, b_refV->y, b_refHV->y,
3189                                                                  2*(i+(k&1)), 2*(j+(k>>1)), 8, &mb->b_mvs[k], edged_width),                                                                  (2*i+(k&1)), (2*j+(k>>1)), 8, &mb->b_mvs[k], edged_width),
3190                                                    edged_width);                                                    edged_width);
3191                                  }                                  }
3192                          }                          }
# Line 3297  Line 3270 
3270                                                  f_predMV.x, f_predMV.y, b_predMV.x, b_predMV.y,                                                  f_predMV.x, f_predMV.y, b_predMV.x, b_predMV.y,
3271                                                  f_min_dx, f_max_dx, f_min_dy, f_max_dy,                                                  f_min_dx, f_max_dx, f_min_dy, f_max_dy,
3272                                                  b_min_dx, b_max_dx, b_min_dy, b_max_dy,                                                  b_min_dx, b_max_dx, b_min_dy, b_max_dy,
3273                                                  edged_width,  1,                                                  edged_width,  2,
3274                                                  frame->fcode, frame->bcode,frame->quant,0);                                                  frame->fcode, frame->bcode,frame->quant,0);
3275    
3276                            i_sad16 = Diamond16_InterpolMainSearch(
3277                                                    f_ref->y, f_refH->y, f_refV->y, f_refHV->y,
3278                                                    frame->image.y + i * 16 + j * 16 * edged_width,
3279                                                    b_ref->y, b_refH->y, b_refV->y, b_refHV->y,
3280                                                    i, j,
3281                                                    f_interpolMV.x, f_interpolMV.y,
3282                                                    b_interpolMV.x, b_interpolMV.y,
3283                                                    i_sad16,
3284                                                    &f_interpolMV, &b_interpolMV,
3285                                                    f_predMV.x, f_predMV.y, b_predMV.x, b_predMV.y,
3286                                                    f_min_dx, f_max_dx, f_min_dy, f_max_dy,
3287                                                    b_min_dx, b_max_dx, b_min_dy, b_max_dy,
3288                                                    edged_width,  1,
3289                                                    frame->fcode, frame->bcode,frame->quant,0);             // equiv to halfpel refine
3290    
3291    
3292  /*  DIRECT MODE DELTA VECTOR SEARCH.  /*  DIRECT MODE DELTA VECTOR SEARCH.
3293      This has to be made more effective, but at the moment I'm happy it's running at all */      This has to be made more effective, but at the moment I'm happy it's running at all */
3294    
3295  /* range is taken without fcode restriction, just a hack instead of writing down the dimensions, of course */  /* There are two range restrictions for direct mode: deltaMV is limited to [-32,31] in halfpel units, and
3296       absolute vector must not lie outside of image dimensions. Constraint one is dealt with by CHECK_MV16_DIRECT
3297       and for constraint two we need distance to boundary. This is done by get_range very large fcode (hack!) */
3298    
3299                          get_range(&min_dx, &max_dx, &min_dy, &max_dy, i, j, 16, iWidth, iHeight, 19);                          get_range(&min_dx, &max_dx, &min_dy, &max_dy, i, j, 16, iWidth, iHeight, 19);
3300    
# Line 3317  Line 3307 
3307                                                  0,0,                                                  0,0,
3308                                                  d_sad16,                                                  d_sad16,
3309                                                  &mb->deltamv,                                                  &mb->deltamv,
3310                                                  mb->directmv, // this has to be pre-initialized with b_mb->mvs[}                                                  mb->directmv, // this has to be pre-initialized with b_mb->mvs[]
3311                                            min_dx, max_dx, min_dy, max_dy,
3312                                                    edged_width, 2, frame->quant, 0);
3313    
3314                            d_sad16 = Diamond16_DirectMainSearch(
3315                                                    f_ref->y, f_refH->y, f_refV->y, f_refHV->y,
3316                                                    frame->image.y + i*16 + j*16*edged_width,
3317                                                    b_ref->y, b_refH->y, b_refV->y, b_refHV->y,
3318                                                    i, j,
3319                                                    TRB,TRD,
3320                                                    mb->deltamv.x, mb->deltamv.y,
3321                                                    d_sad16,
3322                                                    &mb->deltamv,
3323                                                    mb->directmv, // this has to be pre-initialized with b_mb->mvs[]
3324                                          min_dx, max_dx, min_dy, max_dy,                                          min_dx, max_dx, min_dy, max_dy,
3325                                                  edged_width, 1, frame->quant, 0);                                                  edged_width, 1, frame->quant, 0);               // equiv to halfpel refine
3326    
3327    
3328  //                      i_sad16 = 65535;                /* remove the comment to disable any of the MODEs */  //                      i_sad16 = 65535;                /* remove the comment to disable any of the MODEs */

Legend:
Removed from v.347  
changed lines
  Added in v.430

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