From 09c3e44e8a2ab04bd6ed56888e7f412b24512f2b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <michaelni@gmx.at> Date: Sun, 27 Mar 2005 12:19:59 +0000 Subject: [PATCH] motion estimation bitrate penalty compensation Originally committed as revision 4092 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 3 +++ libavcodec/avcodec.h | 9 ++++++++- libavcodec/mpegvideo.c | 2 ++ libavcodec/utils.c | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index fb9f242fe3f..cdc265328ca 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -199,6 +199,7 @@ static int video_profile = FF_PROFILE_UNKNOWN; static int video_level = FF_LEVEL_UNKNOWN; static int nsse_weight = 8; static int subpel_quality= 8; +static int me_penalty_compensation= 256; static int lowres= 0; static int frame_skip_threshold= 0; static int frame_skip_factor= 0; @@ -3324,6 +3325,7 @@ static void opt_output_file(const char *filename) video_enc->level= video_level; video_enc->nsse_weight= nsse_weight; video_enc->me_subpel_quality= subpel_quality; + video_enc->me_penalty_compensation= me_penalty_compensation; video_enc->frame_skip_threshold= frame_skip_threshold; video_enc->frame_skip_factor= frame_skip_factor; video_enc->frame_skip_exp= frame_skip_exp; @@ -4079,6 +4081,7 @@ const OptionDef options[] = { { "vlevel", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_level}, "level", "" }, { "nssew", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&nsse_weight}, "weight", "" }, { "subq", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&subpel_quality}, "", "" }, + { "mepc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&me_penalty_compensation}, "motion estimation bitrate penalty compensation", "factor (1.0 = 256)" }, { "lowres", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&lowres}, "", "" }, { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force video tag/fourcc", "fourcc/tag" }, { "skip_threshold", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&frame_skip_threshold}, "frame skip threshold", "threshold" }, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c9251c6c137..b43dfc4aa79 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -17,7 +17,7 @@ extern "C" { #define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION "0.4.9-pre1" -#define LIBAVCODEC_BUILD 4749 +#define LIBAVCODEC_BUILD 4750 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -1781,6 +1781,13 @@ typedef struct AVCodecContext { * - decoding: unused */ int mb_lmax; + + /** + * + * - encoding: set by user. + * - decoding: unused + */ + int me_penalty_compensation; } AVCodecContext; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 4dfd18c539d..36bb267138c 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -5251,6 +5251,8 @@ static void encode_picture(MpegEncContext *s, int picture_number) /* Estimate motion for every MB */ if(s->pict_type != I_TYPE){ + s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; + s->lambda2= (s->lambda2* s->avctx->me_penalty_compensation + 128)>>8; if(s->pict_type != B_TYPE && s->avctx->me_threshold==0){ if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){ s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 5c9c2425f89..afff2f98a8f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -458,6 +458,7 @@ void avcodec_get_context_defaults(AVCodecContext *s){ s->ildct_cmp= FF_CMP_VSAD; s->profile= FF_PROFILE_UNKNOWN; s->level= FF_LEVEL_UNKNOWN; + s->me_penalty_compensation= 256; s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS; s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS; -- GitLab