comparison rv34.c @ 8074:31e90d4abe28 libavcodec

Fix chroma motion compensation for RV30
author kostya
date Mon, 27 Oct 2008 19:07:39 +0000
parents 6df5221c3e26
children ae146e429003
comparison
equal deleted inserted replaced
8073:915bc657348f 8074:31e90d4abe28
555 } 555 }
556 if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD) 556 if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD)
557 fill_rectangle(cur_pic->motion_val[!dir][mv_pos], 2, 2, s->b8_stride, 0, 4); 557 fill_rectangle(cur_pic->motion_val[!dir][mv_pos], 2, 2, s->b8_stride, 0, 4);
558 } 558 }
559 559
560 static const int chroma_coeffs[3] = { 8, 5, 3 }; 560 static const int chroma_coeffs[3] = { 0, 3, 5 };
561 561
562 /** 562 /**
563 * generic motion compensation function 563 * generic motion compensation function
564 * 564 *
565 * @param r decoder context 565 * @param r decoder context
577 qpel_mc_func (*qpel_mc)[16], 577 qpel_mc_func (*qpel_mc)[16],
578 h264_chroma_mc_func (*chroma_mc)) 578 h264_chroma_mc_func (*chroma_mc))
579 { 579 {
580 MpegEncContext *s = &r->s; 580 MpegEncContext *s = &r->s;
581 uint8_t *Y, *U, *V, *srcY, *srcU, *srcV; 581 uint8_t *Y, *U, *V, *srcY, *srcU, *srcV;
582 int dxy, mx, my, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; 582 int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
583 int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off; 583 int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off;
584 int is16x16 = 1; 584 int is16x16 = 1;
585 585
586 if(thirdpel){ 586 if(thirdpel){
587 int chroma_mx, chroma_my;
587 mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24); 588 mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24);
588 my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24); 589 my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24);
589 lx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) % 3; 590 lx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) % 3;
590 ly = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) % 3; 591 ly = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) % 3;
591 uvmx = chroma_coeffs[(3*(mx&1) + lx) >> 1]; 592 chroma_mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + 1) >> 1;
592 uvmy = chroma_coeffs[(3*(my&1) + ly) >> 1]; 593 chroma_my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + 1) >> 1;
594 umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
595 umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
596 uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3];
597 uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3];
593 }else{ 598 }else{
594 mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2; 599 mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2;
595 my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2; 600 my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2;
596 lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3; 601 lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3;
597 ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3; 602 ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3;
603 umx = mx >> 1;
604 umy = my >> 1;
598 uvmx = mx & 6; 605 uvmx = mx & 6;
599 uvmy = my & 6; 606 uvmy = my & 6;
600 } 607 }
601 dxy = ly*4 + lx; 608 dxy = ly*4 + lx;
602 srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0]; 609 srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0];
603 srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1]; 610 srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1];
604 srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2]; 611 srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2];
605 src_x = s->mb_x * 16 + xoff + mx; 612 src_x = s->mb_x * 16 + xoff + mx;
606 src_y = s->mb_y * 16 + yoff + my; 613 src_y = s->mb_y * 16 + yoff + my;
607 uvsrc_x = s->mb_x * 8 + (xoff >> 1) + (mx >> 1); 614 uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx;
608 uvsrc_y = s->mb_y * 8 + (yoff >> 1) + (my >> 1); 615 uvsrc_y = s->mb_y * 8 + (yoff >> 1) + umy;
609 srcY += src_y * s->linesize + src_x; 616 srcY += src_y * s->linesize + src_x;
610 srcU += uvsrc_y * s->uvlinesize + uvsrc_x; 617 srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
611 srcV += uvsrc_y * s->uvlinesize + uvsrc_x; 618 srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
612 if( (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 3 619 if( (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 3
613 || (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 3){ 620 || (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 3){