comparison motion_est.c @ 1668:30746f429df6 libavcodec

move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>) cleanups & fixes by me
author michael
date Tue, 09 Dec 2003 01:49:56 +0000
parents 7653a103b53c
children dea5b2946999
comparison
equal deleted inserted replaced
1667:720c073661a1 1668:30746f429df6
785 785
786 /* has allready been set to the 4 MV if 4MV is done */ 786 /* has allready been set to the 4 MV if 4MV is done */
787 if(mv4){ 787 if(mv4){
788 int mot_xy= s->block_index[0]; 788 int mot_xy= s->block_index[0];
789 789
790 s->motion_val[mot_xy ][0]= mx; 790 s->current_picture.motion_val[0][mot_xy ][0]= mx;
791 s->motion_val[mot_xy ][1]= my; 791 s->current_picture.motion_val[0][mot_xy ][1]= my;
792 s->motion_val[mot_xy+1][0]= mx; 792 s->current_picture.motion_val[0][mot_xy+1][0]= mx;
793 s->motion_val[mot_xy+1][1]= my; 793 s->current_picture.motion_val[0][mot_xy+1][1]= my;
794 794
795 mot_xy += s->block_wrap[0]; 795 mot_xy += s->block_wrap[0];
796 s->motion_val[mot_xy ][0]= mx; 796 s->current_picture.motion_val[0][mot_xy ][0]= mx;
797 s->motion_val[mot_xy ][1]= my; 797 s->current_picture.motion_val[0][mot_xy ][1]= my;
798 s->motion_val[mot_xy+1][0]= mx; 798 s->current_picture.motion_val[0][mot_xy+1][0]= mx;
799 s->motion_val[mot_xy+1][1]= my; 799 s->current_picture.motion_val[0][mot_xy+1][1]= my;
800 } 800 }
801 } 801 }
802 802
803 /** 803 /**
804 * get fullpel ME search limits. 804 * get fullpel ME search limits.
850 const int rel_xmin4= xmin - block_x*8; 850 const int rel_xmin4= xmin - block_x*8;
851 const int rel_xmax4= xmax - block_x*8 + 8; 851 const int rel_xmax4= xmax - block_x*8 + 8;
852 const int rel_ymin4= ymin - block_y*8; 852 const int rel_ymin4= ymin - block_y*8;
853 const int rel_ymax4= ymax - block_y*8 + 8; 853 const int rel_ymax4= ymax - block_y*8 + 8;
854 #endif 854 #endif
855 P_LEFT[0] = s->motion_val[mot_xy - 1][0]; 855 P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
856 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; 856 P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
857 857
858 if(P_LEFT[0] > (rel_xmax4<<shift)) P_LEFT[0] = (rel_xmax4<<shift); 858 if(P_LEFT[0] > (rel_xmax4<<shift)) P_LEFT[0] = (rel_xmax4<<shift);
859 859
860 /* special case for first line */ 860 /* special case for first line */
861 if (s->mb_y == 0 && block<2) { 861 if (s->mb_y == 0 && block<2) {
862 pred_x4= P_LEFT[0]; 862 pred_x4= P_LEFT[0];
863 pred_y4= P_LEFT[1]; 863 pred_y4= P_LEFT[1];
864 } else { 864 } else {
865 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; 865 P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
866 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; 866 P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
867 P_TOPRIGHT[0] = s->motion_val[mot_xy - mot_stride + off[block]][0]; 867 P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][0];
868 P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + off[block]][1]; 868 P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][1];
869 if(P_TOP[1] > (rel_ymax4<<shift)) P_TOP[1] = (rel_ymax4<<shift); 869 if(P_TOP[1] > (rel_ymax4<<shift)) P_TOP[1] = (rel_ymax4<<shift);
870 if(P_TOPRIGHT[0] < (rel_xmin4<<shift)) P_TOPRIGHT[0]= (rel_xmin4<<shift); 870 if(P_TOPRIGHT[0] < (rel_xmin4<<shift)) P_TOPRIGHT[0]= (rel_xmin4<<shift);
871 if(P_TOPRIGHT[0] > (rel_xmax4<<shift)) P_TOPRIGHT[0]= (rel_xmax4<<shift); 871 if(P_TOPRIGHT[0] > (rel_xmax4<<shift)) P_TOPRIGHT[0]= (rel_xmax4<<shift);
872 if(P_TOPRIGHT[1] > (rel_ymax4<<shift)) P_TOPRIGHT[1]= (rel_ymax4<<shift); 872 if(P_TOPRIGHT[1] > (rel_ymax4<<shift)) P_TOPRIGHT[1]= (rel_ymax4<<shift);
873 873
925 }else{ 925 }else{
926 mx4_sum+= mx4; 926 mx4_sum+= mx4;
927 my4_sum+= my4; 927 my4_sum+= my4;
928 } 928 }
929 929
930 s->motion_val[ s->block_index[block] ][0]= mx4; 930 s->current_picture.motion_val[0][ s->block_index[block] ][0]= mx4;
931 s->motion_val[ s->block_index[block] ][1]= my4; 931 s->current_picture.motion_val[0][ s->block_index[block] ][1]= my4;
932 932
933 if(mx4 != mx || my4 != my) same=0; 933 if(mx4 != mx || my4 != my) same=0;
934 } 934 }
935 935
936 if(same) 936 if(same)
1028 case ME_EPZS: 1028 case ME_EPZS:
1029 { 1029 {
1030 const int mot_stride = s->block_wrap[0]; 1030 const int mot_stride = s->block_wrap[0];
1031 const int mot_xy = s->block_index[0]; 1031 const int mot_xy = s->block_index[0];
1032 1032
1033 P_LEFT[0] = s->motion_val[mot_xy - 1][0]; 1033 P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
1034 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; 1034 P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
1035 1035
1036 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift); 1036 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift);
1037 1037
1038 if(mb_y) { 1038 if(mb_y) {
1039 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; 1039 P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
1040 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; 1040 P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
1041 P_TOPRIGHT[0] = s->motion_val[mot_xy - mot_stride + 2][0]; 1041 P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
1042 P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + 2][1]; 1042 P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
1043 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1] = (rel_ymax<<shift); 1043 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1] = (rel_ymax<<shift);
1044 if(P_TOPRIGHT[0] < (rel_xmin<<shift)) P_TOPRIGHT[0]= (rel_xmin<<shift); 1044 if(P_TOPRIGHT[0] < (rel_xmin<<shift)) P_TOPRIGHT[0]= (rel_xmin<<shift);
1045 if(P_TOPRIGHT[1] > (rel_ymax<<shift)) P_TOPRIGHT[1]= (rel_ymax<<shift); 1045 if(P_TOPRIGHT[1] > (rel_ymax<<shift)) P_TOPRIGHT[1]= (rel_ymax<<shift);
1046 1046
1047 P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); 1047 P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
1474 1474
1475 for(i=0; i<4; i++){ 1475 for(i=0; i<4; i++){
1476 int index= s->block_index[i]; 1476 int index= s->block_index[i];
1477 int min, max; 1477 int min, max;
1478 1478
1479 s->me.co_located_mv[i][0]= s->motion_val[index][0]; 1479 s->me.co_located_mv[i][0]= s->next_picture.motion_val[0][index][0];
1480 s->me.co_located_mv[i][1]= s->motion_val[index][1]; 1480 s->me.co_located_mv[i][1]= s->next_picture.motion_val[0][index][1];
1481 s->me.direct_basis_mv[i][0]= s->me.co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3)); 1481 s->me.direct_basis_mv[i][0]= s->me.co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3));
1482 s->me.direct_basis_mv[i][1]= s->me.co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3)); 1482 s->me.direct_basis_mv[i][1]= s->me.co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3));
1483 // s->me.direct_basis_mv[1][i][0]= s->me.co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3); 1483 // s->me.direct_basis_mv[1][i][0]= s->me.co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3);
1484 // s->me.direct_basis_mv[1][i][1]= s->me.co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(shift+3); 1484 // s->me.direct_basis_mv[1][i][1]= s->me.co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(shift+3);
1485 1485
1692 for(x=0; x<s->mb_width; x++){ 1692 for(x=0; x<s->mb_width; x++){
1693 if(s->mb_type[i]&MB_TYPE_INTER4V){ 1693 if(s->mb_type[i]&MB_TYPE_INTER4V){
1694 int block; 1694 int block;
1695 for(block=0; block<4; block++){ 1695 for(block=0; block<4; block++){
1696 int off= (block& 1) + (block>>1)*wrap; 1696 int off= (block& 1) + (block>>1)*wrap;
1697 int mx= s->motion_val[ xy + off ][0]; 1697 int mx= s->current_picture.motion_val[0][ xy + off ][0];
1698 int my= s->motion_val[ xy + off ][1]; 1698 int my= s->current_picture.motion_val[0][ xy + off ][1];
1699 1699
1700 if( mx >=range || mx <-range 1700 if( mx >=range || mx <-range
1701 || my >=range || my <-range){ 1701 || my >=range || my <-range){
1702 s->mb_type[i] &= ~MB_TYPE_INTER4V; 1702 s->mb_type[i] &= ~MB_TYPE_INTER4V;
1703 s->mb_type[i] |= MB_TYPE_INTRA; 1703 s->mb_type[i] |= MB_TYPE_INTRA;