last_pict_type, last_non_b_pict_type and last_lambda_for are only used by the encoder's main thread.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpegvideo.h | 3 --- libavcodec/mpegvideo_enc.c | 16 ++++++++-------- libavcodec/mpegvideoenc.h | 4 ++++ libavcodec/msmpeg4enc.c | 5 +++-- libavcodec/ratecontrol.c | 4 ++-- libavcodec/snowenc.c | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 757c514a6d..14e5e241cc 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -180,10 +180,7 @@ typedef struct MPVContext { int dquant; ///< qscale difference to prev qscale int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... int vbv_delay; - int last_pict_type; //FIXME removes - int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int droppable; - int last_lambda_for[5]; ///< last lambda for a specific pict type int skipdct; ///< skip dct and code zero residual /* motion compensation */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c537ce8c19..6d45885185 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1240,9 +1240,9 @@ static int estimate_best_b_count(MPVMainEncContext *m) //emms_c(); //s->next_picture_ptr->quality; - p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P]; + p_lambda = m->last_lambda_for[AV_PICTURE_TYPE_P]; //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; - b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B]; + b_lambda = m->last_lambda_for[AV_PICTURE_TYPE_B]; if (!b_lambda) // FIXME we should do this somewhere else b_lambda = p_lambda; lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> @@ -1577,10 +1577,10 @@ static void frame_end(MPVMainEncContext *m) emms_c(); - s->last_pict_type = s->pict_type; - s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality; + m->last_pict_type = s->pict_type; + m->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality; if (s->pict_type!= AV_PICTURE_TYPE_B) - s->last_non_b_pict_type = s->pict_type; + m->last_non_b_pict_type = s->pict_type; } static void update_noise_reduction(MPVMainEncContext *m) @@ -3527,9 +3527,9 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) ff_get_2pass_fcode(m); } else if (!(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) { if(s->pict_type==AV_PICTURE_TYPE_B) - s->lambda= s->last_lambda_for[s->pict_type]; + s->lambda = m->last_lambda_for[s->pict_type]; else - s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; + s->lambda = m->last_lambda_for[m->last_non_b_pict_type]; update_qscale(s); } @@ -3555,7 +3555,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) 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 ((m->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) || + if ((m->me_pre && m->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*)); } diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index d66462b19a..8eab164d7a 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -58,6 +58,10 @@ typedef struct MPVMainEncContext { * a delay */ int64_t reordered_pts; + int last_pict_type; //FIXME remove + int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol + int last_lambda_for[5]; ///< last lambda for a specific pict type + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 7c1fa0a1e3..f8080a194c 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -151,7 +151,8 @@ av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *m) static void find_best_tables(MSMPEG4EncContext *ms) { - MPVEncContext *const s = &ms->s.common; + MPVMainEncContext *const m = &ms->s; + MPVEncContext *const s = &m->common; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -204,7 +205,7 @@ static void find_best_tables(MSMPEG4EncContext *ms) s->rl_table_index = best; s->rl_chroma_table_index= chroma_best; - if(s->pict_type != s->last_non_b_pict_type){ + if (s->pict_type != m->last_non_b_pict_type) { s->rl_table_index= 2; if(s->pict_type==AV_PICTURE_TYPE_I) s->rl_chroma_table_index= 1; diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 4e7bbe49a7..03466a1a43 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -901,10 +901,10 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) /* update predictors */ if (picture_number > 2 && !dry_run) { const int64_t last_var = - s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum + m->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum; av_assert1(m->frame_bits >= m->stuffing_bits); - update_predictor(&rcc->pred[s->last_pict_type], + update_predictor(&rcc->pred[m->last_pict_type], rcc->last_qscale, sqrt(last_var), m->frame_bits - m->stuffing_bits); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index ebed90c729..6ff0491a77 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1858,7 +1858,7 @@ redo_frame: return -1; if(avctx->flags&AV_CODEC_FLAG_PASS1) ff_write_pass1_stats(&s->m); - mpv->last_pict_type = mpv->pict_type; + s->m.last_pict_type = mpv->pict_type; emms_c(); -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".