[FFmpeg-devel] [PATCH v7 3/3] avcodec/mpeg12dec: Add CPB coded side data

Michael Niedermayer michaelni at gmx.at
Sat Feb 22 19:02:42 EET 2020


On Fri, Feb 21, 2020 at 01:20:47PM +0000, Gaullier Nicolas wrote:
> > De : ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> De la part de Michael Niedermayer
> > Envoyé : vendredi 21 février 2020 12:54
> > À : FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> > Objet : Re: [FFmpeg-devel] [PATCH v7 3/3] avcodec/mpeg12dec: Add CPB coded side data
> > 
> > On Thu, Feb 20, 2020 at 11:22:33AM +0000, Gaullier Nicolas wrote:
> > > > De : ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> De la part de Michael Niedermayer
> > > > Envoyé : vendredi 7 février 2020 23:39
> > > > À : FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> > > > Objet : Re: [FFmpeg-devel] [PATCH v7 3/3] avcodec/mpeg12dec: Add CPB coded side data
> > > >
> > > > On Wed, Jan 15, 2020 at 12:42:13AM +0100, Nicolas Gaullier wrote:
> > > > > This fixes mpeg2video stream copies to mpeg muxer like this:
> > > > >   ffmpeg -i xdcamhd.mxf -c:v copy output.mpg
> > > > > ---
> > > > >  libavcodec/mpeg12dec.c       | 7 +++++++
> > > > >  tests/ref/fate/mxf-probe-d10 | 3 +++
> > > > >  tests/ref/fate/ts-demux      | 2 +-
> > > > >  3 files changed, 11 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index
> > > > > 17f9495a1d..48ac14fafa 100644
> > > > > --- a/libavcodec/mpeg12dec.c
> > > > > +++ b/libavcodec/mpeg12dec.c
> > > > > @@ -1398,6 +1398,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
> > > > >      MpegEncContext *s = &s1->mpeg_enc_ctx;
> > > > >      int horiz_size_ext, vert_size_ext;
> > > > >      int bit_rate_ext;
> > > > > +    AVCPBProperties *cpb_props;
> > > > >
> > > > >      skip_bits(&s->gb, 1); /* profile and level esc*/
> > > > >      s->avctx->profile       = get_bits(&s->gb, 3);
> > > > > @@ -1429,6 +1430,12 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
> > > > >      ff_dlog(s->avctx, "sequence extension\n");
> > > > >      s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
> > > > >
> > > > > +    if (cpb_props = ff_add_cpb_side_data(s->avctx)) {
> > > > > +        cpb_props->buffer_size = FFMAX(cpb_props->buffer_size, s->avctx->rc_buffer_size);
> > > > > +        if (s->bit_rate != 0x3FFFF*400)
> > > > > +            cpb_props->max_bitrate = FFMAX(cpb_props->max_bitrate, s->bit_rate);
> > > > > +    }
> > > >
> > > > why does this not export exactly the numbers as read from the header?
> > > >
> > > > thx
> > > The header values are expressed in units of 400bit/s, and the native value 0x3FFFF is reserved, in case of MPEG-1 (but the code is
> > shared), for vbr signalling.
> > > This is not very nice to read, but this is how it is implemented in current code.
> > 
> > you misunderstand, why do you take the maximum of several things instead of
> > exporting the value from the header ?
> > 
> > Thanks
> Sorry for my misunderstanding. I thought the cpb properties had to reflect the entire stream at the end and thus cumulate the size/max values.

well, i see your point but that would not work in practice because in a
scenario where a stream is remuxed the output properties would be written in
regular intervalls before the input is read to the end so that would not
work.

Outputing the values as is would at least preserve the values as they are


> I agree it is best to have an exact match with native header values.
> Thank you for your feedback.
> I will send a new version with the 2x FFMAX removed. 
> Nicolas

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200222/76c0de5e/attachment.sig>


More information about the ffmpeg-devel mailing list