Message ID | 20200224161256.44-1-nicolas.gaullier@cji.paris |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] avcodec/mpeg12dec: Do not alter avctx->rc_buffer_size | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
On Mon, Feb 24, 2020 at 5:13 PM Nicolas Gaullier
<nicolas.gaullier@cji.paris> wrote:
>
rc_buffer_size doesn't really have a meaning to a decoder (its for
encoders and muxers), so why should it not be able to change it to
match the value it reads from the bitstream?
- Hendrik
> De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de Hendrik Leppkes > Envoyé : lundi 24 février 2020 17:26 > À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Objet : Re: [FFmpeg-devel] [PATCH] avcodec/mpeg12dec: Do not alter avctx->rc_buffer_size > > On Mon, Feb 24, 2020 at 5:13 PM Nicolas Gaullier > <nicolas.gaullier@cji.paris> wrote: > > > > rc_buffer_size doesn't really have a meaning to a decoder (its for > encoders and muxers), so why should it not be able to change it to > match the value it reads from the bitstream? > > - Hendrik Both because it is not helpful : a later patch will make the value available as side data, and because API doc (avcodec.h) says "decoding: unused". The other way would have been to update the doc etc., but it does not seem relevant here. This comes from a previous review by James and I agreed with him not to change the API. As soon as this patch is applied, I will send my updated v4 patchset "Fix mpeg1/2 stream copy" which will allow reading rc_buffer_size through side data. Sorry about that, maybe I should have send all of my patches in a bunch, but this little patch is somewhat unrelated to my original patchset and I thought it was better to separate things this way. Nicolas
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 17f9495a1d..2945728edd 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -64,6 +64,7 @@ typedef struct Mpeg1Context { int slice_count; AVRational save_aspect; int save_width, save_height, save_progressive_seq; + int rc_buffer_size; AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ int tmpgexs; @@ -1417,7 +1418,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */ s->bit_rate += (bit_rate_ext << 18) * 400LL; check_marker(s->avctx, &s->gb, "after bit rate extension"); - s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; + s1->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) @@ -1433,7 +1434,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%"PRId64"\n", s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, - s->avctx->rc_buffer_size, s->bit_rate); + s1->rc_buffer_size, s->bit_rate); } static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) @@ -2118,7 +2119,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } - s->avctx->rc_buffer_size = get_bits(&s->gb, 10) * 1024 * 16; + s1->rc_buffer_size = get_bits(&s->gb, 10) * 1024 * 16; skip_bits(&s->gb, 1); /* get matrix */ @@ -2167,7 +2168,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%"PRId64", aspect_ratio_info: %d \n", - s->avctx->rc_buffer_size, s->bit_rate, s->aspect_ratio_info); + s1->rc_buffer_size, s->bit_rate, s->aspect_ratio_info); return 0; }