comparison rv34.c @ 8221:466100c8e27b libavcodec

Fix RV40 chroma MC
author kostya
date Thu, 27 Nov 2008 07:26:26 +0000
parents d8f516ca0002
children 6771b3544991
comparison
equal deleted inserted replaced
8220:47ba2232abd6 8221:466100c8e27b
642 umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24); 642 umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
643 umy = (chroma_my + (3 << 24)) / 3 - (1 << 24); 643 umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
644 uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3]; 644 uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3];
645 uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3]; 645 uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3];
646 }else{ 646 }else{
647 int cx, cy;
647 mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2; 648 mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2;
648 my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2; 649 my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2;
649 lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3; 650 lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3;
650 ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3; 651 ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3;
651 umx = mx >> 1; 652 cx = s->current_picture_ptr->motion_val[dir][mv_pos][0] / 2;
652 umy = my >> 1; 653 cy = s->current_picture_ptr->motion_val[dir][mv_pos][1] / 2;
653 uvmx = mx & 6; 654 umx = cx >> 2;
654 uvmy = my & 6; 655 umy = cy >> 2;
656 uvmx = (cx & 3) << 1;
657 uvmy = (cy & 3) << 1;
658 //due to some flaw RV40 uses the same MC compensation routine for H2V2 and H3V3
659 if(uvmx == 6 && uvmy == 6)
660 uvmx = uvmy = 4;
655 } 661 }
656 dxy = ly*4 + lx; 662 dxy = ly*4 + lx;
657 srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0]; 663 srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0];
658 srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1]; 664 srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1];
659 srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2]; 665 srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2];
702 const int xoff, const int yoff, int mv_off, 708 const int xoff, const int yoff, int mv_off,
703 const int width, const int height, int dir) 709 const int width, const int height, int dir)
704 { 710 {
705 rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30, 711 rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30,
706 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab 712 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab
707 : r->s.dsp.put_h264_qpel_pixels_tab, 713 : r->s.dsp.put_rv40_qpel_pixels_tab,
708 r->s.dsp.put_h264_chroma_pixels_tab); 714 r->rv30 ? r->s.dsp.put_h264_chroma_pixels_tab
715 : r->s.dsp.put_rv40_chroma_pixels_tab);
709 } 716 }
710 717
711 static void rv34_mc_2mv(RV34DecContext *r, const int block_type) 718 static void rv34_mc_2mv(RV34DecContext *r, const int block_type)
712 { 719 {
713 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30, 720 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30,
714 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab 721 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab
715 : r->s.dsp.put_h264_qpel_pixels_tab, 722 : r->s.dsp.put_rv40_qpel_pixels_tab,
716 r->s.dsp.put_h264_chroma_pixels_tab); 723 r->s.dsp.put_h264_chroma_pixels_tab);
717 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, 724 rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30,
718 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab 725 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab
719 : r->s.dsp.avg_h264_qpel_pixels_tab, 726 : r->s.dsp.avg_rv40_qpel_pixels_tab,
720 r->s.dsp.avg_h264_chroma_pixels_tab); 727 r->rv30 ? r->s.dsp.avg_h264_chroma_pixels_tab
728 : r->s.dsp.avg_rv40_chroma_pixels_tab);
721 } 729 }
722 730
723 static void rv34_mc_2mv_skip(RV34DecContext *r) 731 static void rv34_mc_2mv_skip(RV34DecContext *r)
724 { 732 {
725 int i, j; 733 int i, j;
726 for(j = 0; j < 2; j++) 734 for(j = 0; j < 2; j++)
727 for(i = 0; i < 2; i++){ 735 for(i = 0; i < 2; i++){
728 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30, 736 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30,
729 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab 737 r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab
730 : r->s.dsp.put_h264_qpel_pixels_tab, 738 : r->s.dsp.put_rv40_qpel_pixels_tab,
731 r->s.dsp.put_h264_chroma_pixels_tab); 739 r->rv30 ? r->s.dsp.put_h264_chroma_pixels_tab
740 : r->s.dsp.put_rv40_chroma_pixels_tab);
732 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30, 741 rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30,
733 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab 742 r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab
734 : r->s.dsp.avg_h264_qpel_pixels_tab, 743 : r->s.dsp.avg_rv40_qpel_pixels_tab,
735 r->s.dsp.avg_h264_chroma_pixels_tab); 744 r->rv30 ? r->s.dsp.avg_h264_chroma_pixels_tab
745 : r->s.dsp.avg_rv40_chroma_pixels_tab);
736 } 746 }
737 } 747 }
738 748
739 /** number of motion vectors in each macroblock type */ 749 /** number of motion vectors in each macroblock type */
740 static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }; 750 static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 };