Mercurial > libavcodec.hg
comparison rv34.c @ 6096:89140b93ae09 libavcodec
Direct blocks should use motion vectors from the second reference frame
author | kostya |
---|---|
date | Mon, 31 Dec 2007 07:12:50 +0000 |
parents | ce3b68242317 |
children | a2b438bcb1d2 |
comparison
equal
deleted
inserted
replaced
6095:77626e4e0077 | 6096:89140b93ae09 |
---|---|
472 } | 472 } |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 /** | 476 /** |
477 * Calculate motion vector component that should be added for direct blocks. | |
478 */ | |
479 static int calc_add_mv(MpegEncContext *s, int dir, int component) | |
480 { | |
481 int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
482 int sum; | |
483 | |
484 sum = (s->next_picture_ptr->motion_val[0][mv_pos][component] + | |
485 s->next_picture_ptr->motion_val[0][mv_pos + 1][component] + | |
486 s->next_picture_ptr->motion_val[0][mv_pos + s->b8_stride][component] + | |
487 s->next_picture_ptr->motion_val[0][mv_pos + s->b8_stride + 1][component]) >> 2; | |
488 return dir ? -(sum >> 1) : ((sum + 1) >> 1); | |
489 } | |
490 | |
491 /** | |
477 * Predict motion vector for B-frame macroblock. | 492 * Predict motion vector for B-frame macroblock. |
478 */ | 493 */ |
479 static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2], | 494 static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2], |
480 int A_avail, int B_avail, int C_avail, | 495 int A_avail, int B_avail, int C_avail, |
481 int *mx, int *my) | 496 int *mx, int *my) |
534 | 549 |
535 rv34_pred_b_vector(A, B, C, has_A, has_B, has_C, &mx, &my); | 550 rv34_pred_b_vector(A, B, C, has_A, has_B, has_C, &mx, &my); |
536 | 551 |
537 mx += r->dmv[dir][0]; | 552 mx += r->dmv[dir][0]; |
538 my += r->dmv[dir][1]; | 553 my += r->dmv[dir][1]; |
539 //XXX add vector for bidirectionally predicted blocks | 554 |
555 if(block_type == RV34_MB_B_DIRECT){ | |
556 mx += calc_add_mv(s, dir, 0); | |
557 my += calc_add_mv(s, dir, 1); | |
558 } | |
540 for(j = 0; j < 2; j++){ | 559 for(j = 0; j < 2; j++){ |
541 for(i = 0; i < 2; i++){ | 560 for(i = 0; i < 2; i++){ |
542 cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; | 561 cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; |
543 cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; | 562 cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; |
544 } | 563 } |