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;
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++;