X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmotion_est_template.c;h=70b4f824a248db821c224d6d6c21456084e7d686;hb=13686bc2cddbeca540863052e2895460d062ccc3;hp=28c637af888bdf35d527420b0a799ea772eaa76d;hpb=2b0cdd9ec697164ac0415b8629c4a6e5ae9a3b8d;p=ffmpeg diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 28c637af888..70b4f824a24 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -17,7 +17,6 @@ * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * */ /** @@ -27,11 +26,11 @@ //lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...) #define LOAD_COMMON\ - uint32_t attribute_unused * const score_map= c->score_map;\ - const int attribute_unused xmin= c->xmin;\ - const int attribute_unused ymin= c->ymin;\ - const int attribute_unused xmax= c->xmax;\ - const int attribute_unused ymax= c->ymax;\ + uint32_t av_unused * const score_map= c->score_map;\ + const int av_unused xmin= c->xmin;\ + const int av_unused ymin= c->ymin;\ + const int av_unused xmax= c->xmax;\ + const int av_unused ymax= c->ymax;\ uint8_t *mv_penalty= c->current_mv_penalty;\ const int pred_x= c->pred_x;\ const int pred_y= c->pred_y;\ @@ -991,13 +990,24 @@ static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dm return var_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); } +/*! + \param P[10][2] a list of candidate mvs to check before starting the + iterative search. If one of the candidates is close to the optimal mv, then + it takes fewer iterations. And it increases the chance that we find the + optimal mv. + */ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], int ref_mv_scale, int flags, int size, int h) { MotionEstContext * const c= &s->me; - int best[2]={0, 0}; - int d, dmin; + int best[2]={0, 0}; /*!< x and y coordinates of the best motion vector. + i.e. the difference between the position of the + block currently being encoded and the position of + the block chosen to predict it from. */ + int d; ///< the score (cmp + penalty) of any given mv + int dmin; /*!< the best value of d, i.e. the score + corresponding to the mv stored in best[]. */ int map_generation; int penalty_factor; const int ref_mv_stride= s->mb_stride; //pass as arg FIXME @@ -1024,6 +1034,10 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int map[0]= map_generation; score_map[0]= dmin; + //FIXME precalc first term below? + if((s->pict_type == B_TYPE && !(c->flags & FLAG_DIRECT)) || s->flags&CODEC_FLAG_MV0) + dmin += (mv_penalty[pred_x] + mv_penalty[pred_y])*penalty_factor; + /* first line */ if (s->first_slice_line) { CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)