Mercurial > libavcodec.hg
comparison rv34.c @ 6693:6f13852a9161 libavcodec
Skip blocks in B-frames reuse motion vectors from next reference frame.
So if referenced blocks is 16x8, 8x16 or 8x8 partitions, skip block
will have them too.
author | kostya |
---|---|
date | Sat, 26 Apr 2008 13:09:36 +0000 |
parents | 48759bfbd073 |
children | 05c3a4b419e9 |
comparison
equal
deleted
inserted
replaced
6692:25413354a79a | 6693:6f13852a9161 |
---|---|
665 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab | 665 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab |
666 : r->s.dsp.avg_h264_qpel_pixels_tab, | 666 : r->s.dsp.avg_h264_qpel_pixels_tab, |
667 r->s.dsp.avg_h264_chroma_pixels_tab); | 667 r->s.dsp.avg_h264_chroma_pixels_tab); |
668 } | 668 } |
669 | 669 |
670 static void rv34_mc_2mv_skip(RV34DecContext *r) | |
671 { | |
672 int i, j, k; | |
673 for(j = 0; j < 2; j++) | |
674 for(i = 0; i < 2; i++){ | |
675 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30, | |
676 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab | |
677 : r->s.dsp.put_h264_qpel_pixels_tab, | |
678 r->s.dsp.put_h264_chroma_pixels_tab); | |
679 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30, | |
680 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab | |
681 : r->s.dsp.avg_h264_qpel_pixels_tab, | |
682 r->s.dsp.avg_h264_chroma_pixels_tab); | |
683 } | |
684 } | |
685 | |
670 /** number of motion vectors in each macroblock type */ | 686 /** number of motion vectors in each macroblock type */ |
671 static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }; | 687 static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }; |
672 | 688 |
673 /** | 689 /** |
674 * Decode motion vector differences | 690 * Decode motion vector differences |
676 */ | 692 */ |
677 static int rv34_decode_mv(RV34DecContext *r, int block_type) | 693 static int rv34_decode_mv(RV34DecContext *r, int block_type) |
678 { | 694 { |
679 MpegEncContext *s = &r->s; | 695 MpegEncContext *s = &r->s; |
680 GetBitContext *gb = &s->gb; | 696 GetBitContext *gb = &s->gb; |
681 int i; | 697 int i, j, k; |
698 int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
699 int next_bt; | |
682 | 700 |
683 memset(r->dmv, 0, sizeof(r->dmv)); | 701 memset(r->dmv, 0, sizeof(r->dmv)); |
684 for(i = 0; i < num_mvs[block_type]; i++){ | 702 for(i = 0; i < num_mvs[block_type]; i++){ |
685 r->dmv[i][0] = svq3_get_se_golomb(gb); | 703 r->dmv[i][0] = svq3_get_se_golomb(gb); |
686 r->dmv[i][1] = svq3_get_se_golomb(gb); | 704 r->dmv[i][1] = svq3_get_se_golomb(gb); |
695 fill_rectangle(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], 2, 2, s->b8_stride, 0, 4); | 713 fill_rectangle(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], 2, 2, s->b8_stride, 0, 4); |
696 rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); | 714 rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); |
697 break; | 715 break; |
698 } | 716 } |
699 case RV34_MB_B_DIRECT: | 717 case RV34_MB_B_DIRECT: |
700 rv34_pred_mv_b (r, RV34_MB_B_DIRECT, 0); | 718 //surprisingly, it uses motion scheme from next reference frame |
701 rv34_pred_mv_b (r, RV34_MB_B_DIRECT, 1); | 719 next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y * s->mb_stride]; |
702 rv34_mc_2mv (r, RV34_MB_B_DIRECT); | 720 for(j = 0; j < 2; j++) |
721 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 } | |
726 if(IS_16X16(next_bt)) //we can use whole macroblock MC | |
727 rv34_mc_2mv(r, block_type); | |
728 else | |
729 rv34_mc_2mv_skip(r); | |
730 fill_rectangle(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], 2, 2, s->b8_stride, 0, 4); | |
703 break; | 731 break; |
704 case RV34_MB_P_16x16: | 732 case RV34_MB_P_16x16: |
705 case RV34_MB_P_MIX16x16: | 733 case RV34_MB_P_MIX16x16: |
706 rv34_pred_mv(r, block_type, 0, 0); | 734 rv34_pred_mv(r, block_type, 0, 0); |
707 rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); | 735 rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); |