diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 04617fecac4246bc1526f2a73e6ec942d31b142d..4e1c877219bd33a69f624106059f245dc49d2efb 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1938,12 +1938,13 @@ typedef struct AVCodecContext { */ int mb_lmax; +#if FF_API_PRIVATE_OPT /** - * - * - encoding: Set by user. - * - decoding: unused + * @deprecated use encoder private options instead */ + attribute_deprecated int me_penalty_compensation; +#endif /** * diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e7914fd0548ab1f1d85bac7ce9a9c535596a6952..7c1b48afb8a41ff9c6f421187e4858e1eea3e359 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -250,6 +250,7 @@ typedef struct MpegEncContext { int me_method; ///< ME algorithm #endif int motion_est; ///< ME algorithm + int me_penalty_compensation; int mv_dir; #define MV_DIR_FORWARD 1 #define MV_DIR_BACKWARD 2 @@ -616,6 +617,7 @@ FF_MPV_OPT_CMP_FUNC, \ {"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ {"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ extern const AVOption ff_mpv_generic_options[]; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 599cd065fa37fd2c984a19e8dcd4c6d884f75ac6..213367a84efc7beea2d7714d8c1abbf5598cf91e 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -298,6 +298,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) FF_DISABLE_DEPRECATION_WARNINGS if (avctx->rtp_payload_size) s->rtp_payload_size = avctx->rtp_payload_size; + if (avctx->me_penalty_compensation) + s->me_penalty_compensation = avctx->me_penalty_compensation; FF_ENABLE_DEPRECATION_WARNINGS #endif @@ -3460,8 +3462,8 @@ static int encode_picture(MpegEncContext *s, int picture_number) /* Estimate motion for every MB */ if(s->pict_type != AV_PICTURE_TYPE_I){ - s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; - s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; + s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8; + s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8; if (s->pict_type != AV_PICTURE_TYPE_B) { if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){ s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 11063176db7cabab4c352b0886210a64e0ffc8fb..fbf0967f31053d710e4e032b708d48b12292bb33 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -384,7 +384,9 @@ static const AVOption avcodec_options[] = { #endif {"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E}, {"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E}, +#if FF_API_PRIVATE_OPT {"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, V|E}, +#endif {"skip_loop_filter", NULL, OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"skip_idct" , NULL, OFFSET(skip_idct) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"skip_frame" , NULL, OFFSET(skip_frame) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},