Commit 26b409d6 authored by michaelni's avatar michaelni

fixing motion estimation with h263p hopefully


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@355 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 28edb70e
...@@ -51,6 +51,7 @@ extern UINT32 inverse[256]; ...@@ -51,6 +51,7 @@ extern UINT32 inverse[256];
static UINT16 mv_penalty[MAX_FCODE][MAX_MV*2+1]; static UINT16 mv_penalty[MAX_FCODE][MAX_MV*2+1];
static UINT8 fcode_tab[MAX_MV*2+1]; static UINT8 fcode_tab[MAX_MV*2+1];
static UINT8 umv_fcode_tab[MAX_MV*2+1];
int h263_get_picture_format(int width, int height) int h263_get_picture_format(int width, int height)
{ {
...@@ -689,13 +690,16 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s) ...@@ -689,13 +690,16 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
mv_penalty[f_code][mv+MAX_MV]= len; mv_penalty[f_code][mv+MAX_MV]= len;
} }
} }
for(f_code=MAX_FCODE; f_code>0; f_code--){ for(f_code=MAX_FCODE; f_code>0; f_code--){
for(mv=-(16<<f_code); mv<(16<<f_code); mv++){ for(mv=-(16<<f_code); mv<(16<<f_code); mv++){
fcode_tab[mv+MAX_MV]= f_code; fcode_tab[mv+MAX_MV]= f_code;
} }
} }
for(mv=0; mv<MAX_MV*2+1; mv++){
umv_fcode_tab[mv]= 1;
}
} }
void h263_encode_init(MpegEncContext *s) void h263_encode_init(MpegEncContext *s)
...@@ -709,10 +713,11 @@ void h263_encode_init(MpegEncContext *s) ...@@ -709,10 +713,11 @@ void h263_encode_init(MpegEncContext *s)
init_mv_penalty_and_fcode(s); init_mv_penalty_and_fcode(s);
} }
s->mv_penalty= mv_penalty; s->mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
// use fcodes >1 only for mpeg4&h263 FIXME // use fcodes >1 only for mpeg4 & h263 & h263p FIXME
if(!s->h263_msmpeg4) s->fcode_tab= fcode_tab; if(s->h263_plus) s->fcode_tab= umv_fcode_tab;
else if(s->h263_pred) s->fcode_tab= fcode_tab;
} }
static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
......
...@@ -381,6 +381,9 @@ int MPV_encode_init(AVCodecContext *avctx) ...@@ -381,6 +381,9 @@ int MPV_encode_init(AVCodecContext *avctx)
else if (s->out_format == FMT_MPEG1) else if (s->out_format == FMT_MPEG1)
mpeg1_encode_init(s); 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;
s->encoding = 1; s->encoding = 1;
/* init */ /* init */
...@@ -1126,8 +1129,8 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -1126,8 +1129,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
} }
} }
/* find best f_code */ /* find best f_code for ME which do unlimited searches */
if(s->pict_type==P_TYPE){ if(s->pict_type==P_TYPE && s->full_search>3){
int mv_num[8]; int mv_num[8];
int i; int i;
int loose=0; int loose=0;
...@@ -1149,6 +1152,10 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -1149,6 +1152,10 @@ static void encode_picture(MpegEncContext *s, int picture_number)
if(loose > 10) break; //FIXME this is pretty ineffective if(loose > 10) break; //FIXME this is pretty ineffective
} }
s->f_code= i; s->f_code= i;
/* for(i=0; i<=MAX_FCODE; i++){
printf("%d ", mv_num[i]);
}
printf("\n");*/
}else{ }else{
s->f_code= 1; s->f_code= 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment