1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/mpegvideo: Move me_pre, me_penalty_compensation to MPVMainEncCtx

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-19 00:39:31 +01:00
parent 0e333a5451
commit 913322a267
3 changed files with 9 additions and 8 deletions

View File

@ -223,8 +223,6 @@ typedef struct MpegEncContext {
uint64_t encoding_error[MPV_MAX_PLANES]; uint64_t encoding_error[MPV_MAX_PLANES];
int motion_est; ///< ME algorithm int motion_est; ///< ME algorithm
int me_penalty_compensation;
int me_pre; ///< prepass for motion estimation
int mv_dir; int mv_dir;
#define MV_DIR_FORWARD 1 #define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2 #define MV_DIR_BACKWARD 2

View File

@ -3735,11 +3735,11 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
/* Estimate motion for every MB */ /* Estimate motion for every MB */
if(s->pict_type != AV_PICTURE_TYPE_I){ if(s->pict_type != AV_PICTURE_TYPE_I){
s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8; s->lambda = (s->lambda * m->me_penalty_compensation + 128) >> 8;
s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8; s->lambda2 = (s->lambda2 * (int64_t) m->me_penalty_compensation + 128) >> 8;
if (s->pict_type != AV_PICTURE_TYPE_B) { if (s->pict_type != AV_PICTURE_TYPE_B) {
if ((s->me_pre && m->last_non_b_pict_type == AV_PICTURE_TYPE_I) || if ((m->me_pre && m->last_non_b_pict_type == AV_PICTURE_TYPE_I) ||
s->me_pre == 2) { m->me_pre == 2) {
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
} }
} }

View File

@ -101,6 +101,9 @@ typedef struct MPVMainEncContext {
int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol
RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
int me_penalty_compensation;
int me_pre; ///< prepass for motion estimation
int64_t mb_var_sum; ///< sum of MB variance for current frame int64_t mb_var_sum; ///< sum of MB variance for current frame
int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame
@ -218,8 +221,8 @@ FF_MPV_OPT_CMP_FUNC, \
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \ { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \ { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \ { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{"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 }, \ {"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_MAIN_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"mepre", "pre motion estimation", FF_MPV_MAIN_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \ {"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \
{"sc_threshold", "Scene change threshold", FF_MPV_MAIN_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"sc_threshold", "Scene change threshold", FF_MPV_MAIN_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \