- EPZS ME algo used by default.
- HQ flag activated for ffmpeg.
- Cosmetics ...
Originally committed as revision 398 to svn://svn.ffmpeg.org/ffmpeg/trunk
echo " --disable-mmx disable mmx usage"
echo " --enable-gprof enable profiling with gprof [$gprof]"
echo " --disable-grab disable audio/video grabbing code"
-echo " --enable-simple_idct use simple IDCT routines"
+echo " --enable-simple_idct use simple IDCT routines"
echo " --enable-mp3lame enable mp3 encoding via libmp3lame"
echo " --enable-win32 enable win32 cross compile"
echo " --enable-shared build shared libraries [default=no]"
static int video_qdiff = 3;
static float video_qblur = 0.5;
static float video_qcomp = 0.5;
+static int motion_estimation_method = 0;
static int video_disable = 0;
static int video_codec_id = CODEC_ID_NONE;
static int same_quality = 0;
+static int use_hq = 0;
static int use_4mv = 0;
static int do_deinterlace = 0;
break;
p++;
}
- motion_estimation_method = p - motion_str;
+ motion_estimation_method = (p - motion_str) - 4;
}
void opt_video_codec(const char *arg)
video_enc->quality = video_qscale;
}
+ if (use_hq) {
+ video_enc->flags |= CODEC_FLAG_HQ;
+ }
+
if (use_4mv) {
video_enc->flags |= CODEC_FLAG_HQ;
video_enc->flags |= CODEC_FLAG_4MV;
video_enc->get_psnr = 1;
else
video_enc->get_psnr = 0;
+
+ video_enc->me_method = motion_estimation_method;
+
/* XXX: need to find a way to set codec parameters */
if (oc->format == &ppm_format ||
oc->format == &ppmpipe_format) {
pp = motion_str;
while (*pp) {
printf(" %s", *pp);
- if ((pp - motion_str) == ME_ZERO)
+ if ((pp - motion_str - 4) == ME_ZERO)
printf("(fastest)");
- else if ((pp - motion_str) == ME_FULL)
+ else if ((pp - motion_str - 4) == ME_FULL)
printf("(slowest)");
- else if ((pp - motion_str) == ME_LOG)
+ else if ((pp - motion_str - 4) == ME_EPZS)
printf("(default)");
pp++;
}
{ "vcodec", HAS_ARG | OPT_EXPERT, {(void*)opt_video_codec}, "force video codec", "codec" },
{ "me", HAS_ARG | OPT_EXPERT, {(void*)opt_motion_estimation}, "set motion estimation method",
"method" },
+ { "hq", OPT_BOOL | OPT_EXPERT, {(void*)&use_hq}, "activate high quality settings" },
{ "4mv", OPT_BOOL | OPT_EXPERT, {(void*)&use_4mv}, "use four motion vector by macroblock (only MPEG-4)" },
{ "sameq", OPT_BOOL, {(void*)&same_quality},
"use same video quality as source (implies VBR)" },
/* 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 */
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;
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,
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]={
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
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)
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);
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);
}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;
} 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) {
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;
}
/* 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;
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