@@ -236,8 +236,6 @@ typedef struct MPVContext {
uint8_t (*p_field_select_table[2]); ///< Only the first element is allocated
uint8_t (*b_field_select_table[2][2]); ///< Only the first element is allocated
int motion_est; ///< ME algorithm
- int me_penalty_compensation;
- int me_pre; ///< prepass for motion estimation
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
@@ -3563,11 +3563,11 @@ static int encode_picture(MPVMainEncContext *m, int picture_number)
/* Estimate motion for every MB */
if(s->pict_type != AV_PICTURE_TYPE_I){
- s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8;
- s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8;
+ s->lambda = (s->lambda * m->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->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) ||
- s->me_pre == 2) {
+ if ((m->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) ||
+ m->me_pre == 2) {
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
@@ -39,6 +39,9 @@ typedef MPVContext MPVEncContext;
typedef struct MPVMainEncContext {
MPVMainContext common;
+ int me_penalty_compensation;
+ int me_pre; ///< prepass for motion estimation
+
/* bit rate control */
int64_t total_bits;
int frame_bits; ///< bits used for the current frame
@@ -125,8 +128,8 @@ FF_MPV_OPT_CMP_FUNC, \
{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, 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 }, \
-{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), 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_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_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 }, \
#define FF_MPV_COMMON_BFRAME_OPTS \
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpegvideo.h | 2 -- libavcodec/mpegvideo_enc.c | 8 ++++---- libavcodec/mpegvideoenc.h | 7 +++++-- 3 files changed, 9 insertions(+), 8 deletions(-)