# HG changeset patch # User pulento # Date 1018810671 0 # Node ID cda7d0857baf66e5f9c0c205eb3384eed1770e6a # Parent 3ef1cc75d5f5e0ee740247f5d3a32755a0ecde5d - ME setting moved to AVCodecContext/MpegEncContext, no longer a global. - EPZS ME algo used by default. - HQ flag activated for ffmpeg. - Cosmetics ... diff -r 3ef1cc75d5f5 -r cda7d0857baf avcodec.h --- a/avcodec.h Fri Apr 12 14:01:10 2002 +0000 +++ b/avcodec.h Sun Apr 14 18:57:51 2002 +0000 @@ -56,14 +56,18 @@ /* in bytes */ #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432 -/* motion estimation type */ -extern int motion_estimation_method; -#define ME_ZERO 0 -#define ME_FULL 1 -#define ME_LOG 2 -#define ME_PHODS 3 -#define ME_EPZS 4 -#define ME_X1 5 +/* motion estimation type, EPZS by default */ +enum Motion_Est_ID { + ME_ZERO = -4, + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, + ME_X1 +}; + +/* ME algos sorted by quality */ +static const int Motion_Est_QTab[] = { -4, -1, -2, 1, 0, -3 }; /* encoding support */ /* note not everything is supported yet */ @@ -89,6 +93,9 @@ int flags; int sub_id; /* some codecs needs additionnal format info. It is stored there */ + + int me_method; /* ME algorithm used for video coding */ + /* video only */ int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */ int width, height; diff -r 3ef1cc75d5f5 -r cda7d0857baf dsputil.c --- a/dsputil.c Fri Apr 12 14:01:10 2002 +0000 +++ b/dsputil.c Sun Apr 14 18:57:51 2002 +0000 @@ -89,6 +89,8 @@ 38, 46, 54, 62, 39, 47, 55, 63, }; +#ifdef SIMPLE_IDCT + /* Input permutation for the simple_idct_mmx */ static UINT8 simple_mmx_permutation[64]={ 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, @@ -100,6 +102,7 @@ 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, }; +#endif /* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */ UINT32 inverse[256]={ diff -r 3ef1cc75d5f5 -r cda7d0857baf motion_est.c --- a/motion_est.c Fri Apr 12 14:01:10 2002 +0000 +++ b/motion_est.c Sun Apr 14 18:57:51 2002 +0000 @@ -594,7 +594,7 @@ CHECK_MV(P[0][0]>>shift, P[0][1]>>shift) //check(best[0],best[1],0, b0) - if(s->full_search==ME_EPZS) + if(s->me_method==ME_EPZS) dmin= small_diamond_search(s, best, dmin, new_pic, old_pic, pic_stride, pred_x, pred_y, mv_penalty, quant, xmin, ymin, xmax, ymax, shift); else @@ -825,7 +825,7 @@ int P[6][2]; const int shift= 1+s->quarter_sample; int mb_type=0; - + //static int skip=0; range = 8 * (1 << (s->f_code - 1)); /* XXX: temporary kludge to avoid overflow for msmpeg4 */ if (s->out_format == FMT_H263 && !s->h263_msmpeg4) @@ -851,7 +851,7 @@ xmax = s->mb_width*16 - 16; ymax = s->mb_height*16 - 16; } - switch(s->full_search) { + switch(s->me_method) { case ME_ZERO: default: no_motion_search(s, &mx, &my); @@ -999,6 +999,7 @@ s->avg_mb_var+= varc; s->mc_mb_var += vard; + #if 0 printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n", varc, s->avg_mb_var, sum, vard, mx - xx, my - yy); @@ -1016,12 +1017,19 @@ }else{ if (vard <= 64 || vard < varc) { mb_type|= MB_TYPE_INTER; - if (s->full_search != ME_ZERO) { + if (s->me_method != ME_ZERO) { halfpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax, pred_x, pred_y); } else { mx -= 16 * mb_x; my -= 16 * mb_y; } +#if 0 + if (vard < 10) { + skip++; + fprintf(stderr,"\nEarly skip: %d vard: %2d varc: %5d dmin: %d", + skip, vard, varc, dmin); + } +#endif }else{ mb_type|= MB_TYPE_INTRA; mx = 0;//mx*2 - 32 * mb_x; diff -r 3ef1cc75d5f5 -r cda7d0857baf mpegvideo.c --- a/mpegvideo.c Fri Apr 12 14:01:10 2002 +0000 +++ b/mpegvideo.c Sun Apr 14 18:57:51 2002 +0000 @@ -313,8 +313,10 @@ } else { s->intra_only = 0; } - s->full_search = motion_estimation_method; - + + /* ME algorithm */ + s->me_method = avctx->me_method; + /* Fixed QSCALE */ s->fixed_qscale = (avctx->flags & CODEC_FLAG_QSCALE); switch(avctx->codec->id) { @@ -413,7 +415,7 @@ mpeg1_encode_init(s); /* dont use mv_penalty table for crap MV as it would be confused */ - if(s->full_search<4) s->mv_penalty= default_mv_penalty; + if (s->me_method < 0) s->mv_penalty = default_mv_penalty; s->encoding = 1; @@ -1344,7 +1346,7 @@ } /* find best f_code for ME which do unlimited searches */ - if(s->pict_type==P_TYPE && s->full_search>3){ + if(s->pict_type == P_TYPE && s->me_method >= 0){ int mv_num[8]; int i; int loose=0; diff -r 3ef1cc75d5f5 -r cda7d0857baf mpegvideo.h --- a/mpegvideo.h Fri Apr 12 14:01:10 2002 +0000 +++ b/mpegvideo.h Sun Apr 14 18:57:51 2002 +0000 @@ -113,7 +113,7 @@ int b_code; /* backward resolution for B Frames (mpeg4) */ INT16 *mv_table[2]; /* MV table (1MV per MB)*/ INT16 (*motion_val)[2]; /* used for MV prediction (4MV per MB)*/ - int full_search; + int me_method; /* ME algorithm */ int mv_dir; #define MV_DIR_BACKWARD 1 #define MV_DIR_FORWARD 2