Revision 39902a8c libavcodec/rv34.c
libavcodec/rv34.c  

466  466 
} 
467  467 
} 
468  468  
469 
#define GET_PTS_DIFF(a, b) ((a  b + 8192) & 0x1FFF) 

470  
469  471 
/** 
470  472 
* Calculate motion vector component that should be added for direct blocks. 
471  473 
*/ 
472 
static int calc_add_mv(MpegEncContext *s, int dir, int component)


474 
static int calc_add_mv(RV34DecContext *r, int dir, int val)


473  475 
{ 
474 
int mv_pos = s>mb_x * 2 + s>mb_y * 2 * s>b8_stride;


475 
int sum;


476 
int refdist = GET_PTS_DIFF(r>next_pts, r>last_pts);


477 
int dist = dir ? GET_PTS_DIFF(r>next_pts, r>cur_pts) : GET_PTS_DIFF(r>cur_pts, r>last_pts);


476  478  
477 
sum = (s>next_picture_ptr>motion_val[0][mv_pos][component] +


478 
s>next_picture_ptr>motion_val[0][mv_pos + 1][component] +


479 
s>next_picture_ptr>motion_val[0][mv_pos + s>b8_stride][component] +


480 
s>next_picture_ptr>motion_val[0][mv_pos + s>b8_stride + 1][component]) >> 2;


481 
return dir ? (sum >> 1) : ((sum + 1) >> 1);


479 
if(!refdist) return 0;


480 
if(!dir)


481 
return (val * dist + refdist  1) / refdist;


482 
else


483 
return (val * dist / refdist);


482  484 
} 
483  485  
484  486 
/** 
...  ...  
545  547 
mx += r>dmv[dir][0]; 
546  548 
my += r>dmv[dir][1]; 
547  549  
548 
if(block_type == RV34_MB_B_DIRECT){ 

549 
mx += calc_add_mv(s, dir, 0); 

550 
my += calc_add_mv(s, dir, 1); 

551 
} 

552  550 
for(j = 0; j < 2; j++){ 
553  551 
for(i = 0; i < 2; i++){ 
554  552 
cur_pic>motion_val[dir][mv_pos + i + j*s>b8_stride][0] = mx; 
...  ...  
694  692 
{ 
695  693 
MpegEncContext *s = &r>s; 
696  694 
GetBitContext *gb = &s>gb; 
697 
int i, j, k; 

695 
int i, j, k, l;


698  696 
int mv_pos = s>mb_x * 2 + s>mb_y * 2 * s>b8_stride; 
699  697 
int next_bt; 
700  698  
...  ...  
719  717 
next_bt = s>next_picture_ptr>mb_type[s>mb_x + s>mb_y * s>mb_stride]; 
720  718 
for(j = 0; j < 2; j++) 
721  719 
for(i = 0; i < 2; i++) 
722 
for(k = 0; k < 2; k++){ 

723 
s>current_picture_ptr>motion_val[0][mv_pos + i + j*s>b8_stride][k] = (s>next_picture_ptr>motion_val[0][mv_pos + i + j*s>b8_stride][k] + 1) >> 1; 

724 
s>current_picture_ptr>motion_val[1][mv_pos + i + j*s>b8_stride][k] = (s>next_picture_ptr>motion_val[0][mv_pos + i + j*s>b8_stride][k] >> 1); 

725 
} 

720 
for(k = 0; k < 2; k++) 

721 
for(l = 0; l < 2; l++) 

722 
s>current_picture_ptr>motion_val[l][mv_pos + i + j*s>b8_stride][k] = calc_add_mv(r, l, s>next_picture_ptr>motion_val[0][mv_pos + i + j*s>b8_stride][k]); 

726  723 
if(IS_16X16(next_bt)) //we can use whole macroblock MC 
727  724 
rv34_mc_2mv(r, block_type); 
728  725 
else 
...  ...  
1104  1101 
return si1>type != si2>type  
1105  1102 
si1>start >= si2>start  
1106  1103 
si1>width != si2>width  
1107 
si1>height != si2>height; 

1104 
si1>height != si2>height 

1105 
si1>pts != si2>pts; 

1108  1106 
} 
1109  1107  
1110  1108 
static int rv34_decode_slice(RV34DecContext *r, int end, uint8_t* buf, int buf_size) 
...  ...  
1140  1138 
return 1; 
1141  1139 
ff_er_frame_start(s); 
1142  1140 
s>current_picture_ptr = &s>current_picture; 
1141 
r>cur_pts = r>si.pts; 

1142 
if(s>pict_type != FF_B_TYPE){ 

1143 
r>last_pts = r>next_pts; 

1144 
r>next_pts = r>cur_pts; 

1145 
} 

1143  1146 
s>mb_x = s>mb_y = 0; 
1144  1147 
} 
1145  1148 
Also available in: Unified diff