fixing msmpeg4v2 encoding

Originally committed as revision 1723 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2003-04-01 15:38:01 +00:00
parent 309522372c
commit 1f9aea9b91
4 changed files with 13 additions and 11 deletions

View File

@ -648,6 +648,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 3;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
@ -657,6 +658,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 4;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
@ -666,6 +668,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 5;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
@ -2834,8 +2837,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->qscale= (int)(s->frame_qscale + 0.5); //FIXME qscale / ... stuff for ME ratedistoration
if(s->pict_type==I_TYPE){
if(s->msmpeg4_version) s->no_rounding=1;
else s->no_rounding=0;
if(s->msmpeg4_version >= 3) s->no_rounding=1;
else s->no_rounding=0;
}else if(s->pict_type!=B_TYPE){
if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;

View File

@ -439,12 +439,10 @@ void msmpeg4_encode_ext_header(MpegEncContext * s)
put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
if(s->msmpeg4_version<3)
s->flipflop_rounding=0;
else{
s->flipflop_rounding=1;
if(s->msmpeg4_version>=3)
put_bits(&s->pb, 1, s->flipflop_rounding);
}
else
assert(s->flipflop_rounding==0);
}
#endif //CONFIG_ENCODERS

View File

@ -131,7 +131,10 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
w->abt_type=0;
w->j_type=0;
assert(s->flipflop_rounding);
if (s->pict_type == I_TYPE) {
assert(s->no_rounding==1);
if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type);
if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
@ -144,7 +147,6 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 1, s->dc_table_index);
s->inter_intra_pred= 0;
s->no_rounding = 1;
}else{
int cbp_index;
@ -181,7 +183,6 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 1, s->mv_table_index);
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
s->no_rounding ^= 1;
}
s->esc3_level_length= 0;
s->esc3_run_length= 0;

View File

@ -1,8 +1,8 @@
ffmpeg regression test
dda0ba041aef50a5101884291c06d4d9 *./data/a-mpeg1.mpg
6713259d72260740bbddaea30631ea18 *./data/out.yuv
8730846cd73f07689bfab061eac3e800 *./data/a-msmpeg4v2.avi
2cfc9307a2fd9651cf9c8e42dea1a80e *./data/out.yuv
8836c5e38c7891f04e8e75836e48551e *./data/a-msmpeg4v2.avi
712aa6c959d1d90a78fe98657cbff19c *./data/out.yuv
8b2a7f5e105784d65426989e4fce6e94 *./data/a-msmpeg4.avi
8786aa956838234fe3e48d0ef8cbd46c *./data/out.yuv
a0bec32a81f9a4cd174557a49cd26430 *./data/a-wmv1.avi