summaryrefslogtreecommitdiff
path: root/libavcodec/motion_est.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2019-10-23 21:12:32 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-10-24 19:45:17 +0200
commit531fbce0b281be2450bbf0230c2de539230a7d84 (patch)
treee3877cf6dc62207f045d0144bd610b92471c1221 /libavcodec/motion_est.c
parent3d5d0301c3d8b0c550db78730e9cfc017d6db5fb (diff)
mpegvideo_enc: add intra_penalty option for p frames
This option allows more control over the use of intra macroblocks in predictive frames. By using '-intra_penalty max', intra macroblocks are never used in predictive frames. It is useful for glitch artists to generate input material. This option allows them to split and merge two video files while maintaining fluid motion from the second video without having intra macroblocks restoring chunks of the first video. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/motion_est.c')
-rw-r--r--libavcodec/motion_est.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 759eea479d..02c75fd470 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -971,7 +971,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
- if (vard*2 + 200*256 > varc)
+ if (vard*2 + 200*256 > varc && !s->intra_penalty)
mb_type|= CANDIDATE_MB_TYPE_INTRA;
if (varc*2 + 200*256 > vard || s->qscale > 24){
// if (varc*2 + 200*256 + 50*(s->lambda2>>FF_LAMBDA_SHIFT) > vard){
@@ -1040,7 +1040,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
intra_score= s->mecc.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16);
}
- intra_score += c->mb_penalty_factor*16;
+ intra_score += c->mb_penalty_factor*16 + s->intra_penalty;
if(intra_score < dmin){
mb_type= CANDIDATE_MB_TYPE_INTRA;
@@ -1648,7 +1648,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
}
}
-void ff_fix_long_p_mvs(MpegEncContext * s)
+void ff_fix_long_p_mvs(MpegEncContext * s, int type)
{
MotionEstContext * const c= &s->me;
const int f_code= s->f_code;
@@ -1682,8 +1682,8 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
if( mx >=range || mx <-range
|| my >=range || my <-range){
s->mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
- s->mb_type[i] |= CANDIDATE_MB_TYPE_INTRA;
- s->current_picture.mb_type[i] = CANDIDATE_MB_TYPE_INTRA;
+ s->mb_type[i] |= type;
+ s->current_picture.mb_type[i] = type;
}
}
}