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

avcodec/mpegvideo: Move vbv_delay_pos to MPVMainEncContext

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-18 11:52:20 +01:00
parent bf4dedd6b5
commit bceeb35857
4 changed files with 6 additions and 4 deletions

View File

@ -350,7 +350,7 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
(s->picture_number - mpeg12->gop_picture_number) & 0x3ff); (s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
put_bits(&s->pb, 3, s->pict_type); 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 */ put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
// RAL: Forward f_code also needed for B-frames // RAL: Forward f_code also needed for B-frames

View File

@ -401,7 +401,6 @@ typedef struct MpegEncContext {
/* MPEG-1 specific */ /* MPEG-1 specific */
int last_mv_dir; ///< last mv_dir, used for B-frame encoding 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. */ /* MPEG-2-specific - I wished not to have to support this mess. */
int progressive_sequence; int progressive_sequence;

View File

@ -2023,9 +2023,9 @@ vbv_retry:
double inbits = avctx->rc_max_rate * double inbits = avctx->rc_max_rate *
av_q2d(avctx->time_base); av_q2d(avctx->time_base);
int minbits = m->frame_bits - 8 * 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; 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) if (bits < 0)
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,

View File

@ -72,6 +72,9 @@ typedef struct MPVMainEncContext {
int lmin, lmax; int lmin, lmax;
int vbv_ignore_qmax; 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 const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
/* frame skip options */ /* frame skip options */