Mercurial > libavcodec.hg
comparison motion_est.c @ 951:ad264a7d4f94 libavcodec
motion estimation pre pass
author | michaelni |
---|---|
date | Thu, 02 Jan 2003 01:29:35 +0000 |
parents | d4d714493faa |
children | f348d302a51e |
comparison
equal
deleted
inserted
replaced
950:d4d714493faa | 951:ad264a7d4f94 |
---|---|
752 if (s->unrestricted_mv) { | 752 if (s->unrestricted_mv) { |
753 *xmin = -16; | 753 *xmin = -16; |
754 *ymin = -16; | 754 *ymin = -16; |
755 if (s->h263_plus) | 755 if (s->h263_plus) |
756 *range *= 2; | 756 *range *= 2; |
757 if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4){ | 757 if(s->avctx->codec->id!=CODEC_ID_MPEG4){ |
758 *xmax = s->mb_width*16; | 758 *xmax = s->mb_width*16; |
759 *ymax = s->mb_height*16; | 759 *ymax = s->mb_height*16; |
760 }else { | 760 }else { |
761 /* XXX: dunno if this is correct but ffmpeg4 decoder wont like it otherwise | |
762 (cuz the drawn edge isnt large enough))*/ | |
763 *xmax = s->width; | 761 *xmax = s->width; |
764 *ymax = s->height; | 762 *ymax = s->height; |
765 } | 763 } |
766 } else { | 764 } else { |
767 *xmin = 0; | 765 *xmin = 0; |
1022 } | 1020 } |
1023 | 1021 |
1024 s->mb_type[mb_y*s->mb_width + mb_x]= mb_type; | 1022 s->mb_type[mb_y*s->mb_width + mb_x]= mb_type; |
1025 } | 1023 } |
1026 | 1024 |
1025 int ff_pre_estimate_p_frame_motion(MpegEncContext * s, | |
1026 int mb_x, int mb_y) | |
1027 { | |
1028 int mx, my, range, dmin; | |
1029 int xmin, ymin, xmax, ymax; | |
1030 int rel_xmin, rel_ymin, rel_xmax, rel_ymax; | |
1031 int pred_x=0, pred_y=0; | |
1032 int P[10][2]; | |
1033 const int shift= 1+s->quarter_sample; | |
1034 uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; | |
1035 const int mv_stride= s->mb_width + 2; | |
1036 const int xy= mb_x + 1 + (mb_y + 1)*mv_stride; | |
1037 | |
1038 assert(s->quarter_sample==0 || s->quarter_sample==1); | |
1039 | |
1040 s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp); | |
1041 | |
1042 get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code); | |
1043 rel_xmin= xmin - mb_x*16; | |
1044 rel_xmax= xmax - mb_x*16; | |
1045 rel_ymin= ymin - mb_y*16; | |
1046 rel_ymax= ymax - mb_y*16; | |
1047 s->me.skip=0; | |
1048 | |
1049 P_LEFT[0] = s->p_mv_table[xy + 1][0]; | |
1050 P_LEFT[1] = s->p_mv_table[xy + 1][1]; | |
1051 | |
1052 if(P_LEFT[0] < (rel_xmin<<shift)) P_LEFT[0] = (rel_xmin<<shift); | |
1053 | |
1054 /* special case for first line */ | |
1055 if (mb_y == s->mb_height-1) { | |
1056 pred_x= P_LEFT[0]; | |
1057 pred_y= P_LEFT[1]; | |
1058 } else { | |
1059 P_TOP[0] = s->p_mv_table[xy + mv_stride ][0]; | |
1060 P_TOP[1] = s->p_mv_table[xy + mv_stride ][1]; | |
1061 P_TOPRIGHT[0] = s->p_mv_table[xy + mv_stride - 1][0]; | |
1062 P_TOPRIGHT[1] = s->p_mv_table[xy + mv_stride - 1][1]; | |
1063 if(P_TOP[1] < (rel_ymin<<shift)) P_TOP[1] = (rel_ymin<<shift); | |
1064 if(P_TOPRIGHT[0] > (rel_xmax<<shift)) P_TOPRIGHT[0]= (rel_xmax<<shift); | |
1065 if(P_TOPRIGHT[1] < (rel_ymin<<shift)) P_TOPRIGHT[1]= (rel_ymin<<shift); | |
1066 | |
1067 P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); | |
1068 P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); | |
1069 | |
1070 if(s->out_format == FMT_H263){ | |
1071 pred_x = P_MEDIAN[0]; | |
1072 pred_y = P_MEDIAN[1]; | |
1073 }else { /* mpeg1 at least */ | |
1074 pred_x= P_LEFT[0]; | |
1075 pred_y= P_LEFT[1]; | |
1076 } | |
1077 } | |
1078 dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax, | |
1079 &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty); | |
1080 | |
1081 s->p_mv_table[xy][0] = mx<<shift; | |
1082 s->p_mv_table[xy][1] = my<<shift; | |
1083 | |
1084 return dmin; | |
1085 } | |
1086 | |
1027 int ff_estimate_motion_b(MpegEncContext * s, | 1087 int ff_estimate_motion_b(MpegEncContext * s, |
1028 int mb_x, int mb_y, int16_t (*mv_table)[2], Picture *picture, int f_code) | 1088 int mb_x, int mb_y, int16_t (*mv_table)[2], Picture *picture, int f_code) |
1029 { | 1089 { |
1030 int mx, my, range, dmin; | 1090 int mx, my, range, dmin; |
1031 int xmin, ymin, xmax, ymax; | 1091 int xmin, ymin, xmax, ymax; |