[FFmpeg-cvslog] avcodec/mpegvideo: Move vbv_delay_pos to MPVMainEncContext
Andreas Rheinhardt
git at videolan.org
Wed Mar 26 06:09:52 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Mar 18 11:52:20 2025 +0100| [bceeb358573fbd7d5f94ecd1df452149282e8e58] | committer: Andreas Rheinhardt
avcodec/mpegvideo: Move vbv_delay_pos to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bceeb358573fbd7d5f94ecd1df452149282e8e58
---
libavcodec/mpeg12enc.c | 2 +-
libavcodec/mpegvideo.h | 1 -
libavcodec/mpegvideo_enc.c | 4 ++--
libavcodec/mpegvideoenc.h | 3 +++
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 1ef88d23b8..43addcfda9 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -350,7 +350,7 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
(s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
put_bits(&s->pb, 3, s->pict_type);
- s->vbv_delay_pos = put_bytes_count(&s->pb, 0);
+ m->vbv_delay_pos = put_bytes_count(&s->pb, 0);
put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
// RAL: Forward f_code also needed for B-frames
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 12cb8fc3d5..ed9224d2fe 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -401,7 +401,6 @@ typedef struct MpegEncContext {
/* MPEG-1 specific */
int last_mv_dir; ///< last mv_dir, used for B-frame encoding
- int vbv_delay_pos; ///< offset of vbv_delay in the bitstream
/* MPEG-2-specific - I wished not to have to support this mess. */
int progressive_sequence;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8af572a69e..cb1cf972d8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2023,9 +2023,9 @@ vbv_retry:
double inbits = avctx->rc_max_rate *
av_q2d(avctx->time_base);
int minbits = m->frame_bits - 8 *
- (s->vbv_delay_pos - 1);
+ (m->vbv_delay_pos - 1);
double bits = m->rc_context.buffer_index + minbits - inbits;
- uint8_t *const vbv_delay_ptr = s->pb.buf + s->vbv_delay_pos;
+ uint8_t *const vbv_delay_ptr = s->pb.buf + m->vbv_delay_pos;
if (bits < 0)
av_log(avctx, AV_LOG_ERROR,
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index c7082fe852..36c9145c96 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -72,6 +72,9 @@ typedef struct MPVMainEncContext {
int lmin, lmax;
int vbv_ignore_qmax;
+ /* MPEG-1/2 specific */
+ int vbv_delay_pos; ///< offset of vbv_delay in the bitstream
+
const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
/* frame skip options */
More information about the ffmpeg-cvslog
mailing list