[FFmpeg-devel] [PATCH v2 53/69] avcodec/mpegvideo: Move fixed_qscale to MPVMainEncContext
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Tue Feb 1 15:06:50 EET 2022
Only used by the main encoding thread.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/mpegvideo.h | 1 -
libavcodec/mpegvideo_enc.c | 10 +++++-----
libavcodec/mpegvideoenc.h | 2 ++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 99361f0733..a379f65143 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -92,7 +92,6 @@ typedef struct MPVContext {
int h263_flv; ///< use flv H.263 header
enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
- int fixed_qscale; ///< fixed qscale if non zero
int encoding; ///< true if we are encoding (vs decoding)
int max_b_frames; ///< max number of B-frames for encoding
int luma_elim_threshold;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ecc25ba8a2..4dafc68cdd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -401,7 +401,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
}
/* Fixed QSCALE */
- s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);
+ m->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);
s->adaptive_quant = (avctx->lumi_masking ||
avctx->dark_masking ||
@@ -410,7 +410,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
avctx->p_masking ||
m->border_masking ||
(s->mpv_flags & FF_MPV_FLAG_QP_RD)) &&
- !s->fixed_qscale;
+ !m->fixed_qscale;
s->loop_filter = !!(avctx->flags & AV_CODEC_FLAG_LOOP_FILTER);
@@ -474,7 +474,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- if (!s->fixed_qscale &&
+ if (!m->fixed_qscale &&
avctx->bit_rate * av_q2d(avctx->time_base) >
avctx->bit_rate_tolerance) {
double nbt = avctx->bit_rate * av_q2d(avctx->time_base) * 5;
@@ -3502,7 +3502,7 @@ static int estimate_qp(MPVMainEncContext *m, int dry_run)
s->current_picture_ptr->f->quality =
s->current_picture.f->quality = m->next_lambda;
if (!dry_run) m->next_lambda= 0;
- } else if (!s->fixed_qscale) {
+ } else if (!m->fixed_qscale) {
int quality = ff_rate_estimate_qscale(m, dry_run);
s->current_picture_ptr->f->quality =
s->current_picture.f->quality = quality;
@@ -3622,7 +3622,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number)
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
- if(!s->fixed_qscale){
+ if (!m->fixed_qscale) {
/* finding spatial complexity for I-frame rate control */
s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 42731a5edc..5c579cc155 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -46,6 +46,8 @@ typedef struct MPVMainEncContext {
int scenechange_threshold;
+ int fixed_qscale; ///< fixed qscale if non zero
+
int gop_size;
int picture_in_gop_number; ///< 0-> first pic in gop, ...
int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else
--
2.32.0
More information about the ffmpeg-devel
mailing list