Mercurial > libavcodec.hg
diff motion_est.c @ 1051:e5a9dbf597d4 libavcodec
mpeg1 bframe encoding patch by (Rapha¸«³l LEGRAND) with some modifications by me
author | michaelni |
---|---|
date | Sat, 08 Feb 2003 12:00:57 +0000 |
parents | 8d686fbb6a8c |
children | f07fd48c23d4 |
line wrap: on
line diff
--- a/motion_est.c Fri Feb 07 16:44:48 2003 +0000 +++ b/motion_est.c Sat Feb 08 12:00:57 2003 +0000 @@ -1493,12 +1493,13 @@ fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor; //printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin); { - int score= dmin; - type=MB_TYPE_DIRECT; + int score= fmin; + type = MB_TYPE_FORWARD; - if(fmin<score){ - score=fmin; - type= MB_TYPE_FORWARD; + // RAL: No MB_TYPE_DIRECT in MPEG-1 video (only MPEG-4) + if (s->codec_id != CODEC_ID_MPEG1VIDEO && dmin <= score){ + score = dmin; + type = MB_TYPE_DIRECT; } if(bmin<score){ score=bmin; @@ -1643,21 +1644,32 @@ int y; UINT8 * fcode_tab= s->fcode_tab; + // RAL: 8 in MPEG-1, 16 in MPEG-4 + int range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code); + /* clip / convert to intra 16x16 type MVs */ for(y=0; y<s->mb_height; y++){ int x; int xy= (y+1)* (s->mb_width+2)+1; int i= y*s->mb_width; - for(x=0; x<s->mb_width; x++){ - if( fcode_tab[mv_table[xy][0] + MAX_MV] > f_code - || fcode_tab[mv_table[xy][0] + MAX_MV] == 0){ - if(mv_table[xy][0]>0) mv_table[xy][0]= (16<<f_code)-1; - else mv_table[xy][0]= -(16<<f_code); + for(x=0; x<s->mb_width; x++) + { + if (s->mb_type[i] & type) // RAL: "type" test added... + { + if (fcode_tab[mv_table[xy][0] + MAX_MV] > f_code || fcode_tab[mv_table[xy][0] + MAX_MV] == 0) + { + if(mv_table[xy][0]>0) + mv_table[xy][0]= range-1; + else + mv_table[xy][0]= -range; + } + if (fcode_tab[mv_table[xy][1] + MAX_MV] > f_code || fcode_tab[mv_table[xy][1] + MAX_MV] == 0) + { + if(mv_table[xy][1]>0) + mv_table[xy][1]= range-1; + else + mv_table[xy][1]= -range; } - if( fcode_tab[mv_table[xy][1] + MAX_MV] > f_code - || fcode_tab[mv_table[xy][1] + MAX_MV] == 0){ - if(mv_table[xy][1]>0) mv_table[xy][1]= (16<<f_code)-1; - else mv_table[xy][1]= -(16<<f_code); } xy++; i++;