From 9740687b6be5631b2c0500eb38938a4b47df54f2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Oct 2004 17:21:34 +0000 Subject: fix and cleanup h261 mb_type selection Originally committed as revision 3647 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h261.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'libavcodec/h261.c') diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 490e0d30a6..e7fa63e923 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -220,12 +220,11 @@ void ff_h261_encode_mb(MpegEncContext * s, int motion_x, int motion_y) { H261Context * h = (H261Context *)s; - int old_mtype, mvd, mv_diff_x, mv_diff_y, i, cbp; + int mvd, mv_diff_x, mv_diff_y, i, cbp; cbp = 63; // avoid warning mvd = 0; h->current_mba++; - old_mtype = h->mtype; h->mtype = 0; if (!s->mb_intra){ @@ -233,14 +232,8 @@ void ff_h261_encode_mb(MpegEncContext * s, cbp= get_cbp(s, block); /* mvd indicates if this block is motion compensated */ - if(((motion_x >> 1) - h->current_mv_x != 0) || ((motion_y >> 1 ) - h->current_mv_y) != 0){ - mvd = 1; - } - else if((motion_x >> 1 == 0) && (motion_y >> 1 == 0)){ - mvd = 0; - } - else - mvd = 1; + mvd = motion_x | motion_y; + if((cbp | mvd | s->dquant ) == 0) { /* skip macroblock */ s->skip_count++; @@ -255,14 +248,15 @@ void ff_h261_encode_mb(MpegEncContext * s, /* calculate MTYPE */ if(!s->mb_intra){ - h->mtype+=2; - if(mvd == 1){ - h->mtype+=2; - if(cbp!=0) - h->mtype+=1; + h->mtype++; + + if(mvd || s->loop_filter) + h->mtype+=3; if(s->loop_filter) h->mtype+=3; - } + if(cbp || s->dquant) + h->mtype++; + assert(h->mtype > 1); } if(s->dquant) -- cgit v1.2.3