summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorJuanjo <pulento@users.sourceforge.net>2002-04-14 18:57:51 +0000
committerJuanjo <pulento@users.sourceforge.net>2002-04-14 18:57:51 +0000
commite4986da9ce91c4a6f9e942c4225f0c3d90e5db95 (patch)
tree17a8d25051d364c09e4e878e1408a3b2f315869c /libavcodec
parentb1ec5875a63d5cf61629ff69fb337c6d96e7b964 (diff)
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
- EPZS ME algo used by default. - HQ flag activated for ffmpeg. - Cosmetics ... Originally committed as revision 398 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h23
-rw-r--r--libavcodec/dsputil.c3
-rw-r--r--libavcodec/motion_est.c16
-rw-r--r--libavcodec/mpegvideo.c10
-rw-r--r--libavcodec/mpegvideo.h2
5 files changed, 37 insertions, 17 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1859fe3d41..a6b03e9dde 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -56,14 +56,18 @@ enum SampleFormat {
/* 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 @@ typedef struct AVCodecContext {
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 --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index a4f900c460..0d15b2893a 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -89,6 +89,8 @@ UINT8 ff_alternate_vertical_scan[64] = {
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 @@ static UINT8 simple_mmx_permutation[64]={
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 --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 3779afe0f8..c378e3658b 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -594,7 +594,7 @@ static int epzs_motion_search(MpegEncContext * s,
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 @@ void estimate_motion(MpegEncContext * s,
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 @@ void estimate_motion(MpegEncContext * s,
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 @@ void estimate_motion(MpegEncContext * s,
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 @@ void estimate_motion(MpegEncContext * s,
}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 --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 778ef76470..7ae54ad93e 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -313,8 +313,10 @@ int MPV_encode_init(AVCodecContext *avctx)
} 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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ static void encode_picture(MpegEncContext *s, int picture_number)
}
/* 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 --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index b7fe207a52..68d5bd7fde 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -113,7 +113,7 @@ typedef struct MpegEncContext {
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