From d951bb9a5c4ff8e45ade4a1413e0aa5f3b73c5a3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 22 Dec 2006 23:30:57 +0000 Subject: test DIRECT{0,0} too if flag mv0 is used slight PSNR/bitrate increase Originally committed as revision 7361 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/motion_est.c | 2 ++ libavcodec/motion_est_template.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libavcodec') diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 775544b26a..f9c0d0a601 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1978,6 +1978,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, } //FIXME something smarter if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; //dont try direct mode if its invalid for this MB + if(s->codec_id == CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy]) + type |= CANDIDATE_MB_TYPE_DIRECT0; #if 0 if(s->out_format == FMT_MPEG1) type |= CANDIDATE_MB_TYPE_INTRA; diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 1bfda10472..897c08e3df 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -1025,7 +1025,7 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int score_map[0]= dmin; //FIXME precalc first term below? - if((s->pict_type == B_TYPE || s->flags&CODEC_FLAG_MV0) && !(c->flags & FLAG_DIRECT)) + 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 */ -- cgit v1.2.3