[FFmpeg-devel] [PATCH] lavf: split packets before muxing.

Michael Niedermayer michaelni at gmx.at
Thu Dec 20 03:56:08 CET 2012


On Wed, Dec 19, 2012 at 10:14:00PM +0100, Clément Bœsch wrote:
> On Sat, Dec 08, 2012 at 07:42:11PM +0100, Michael Niedermayer wrote:
> > On Fri, Dec 07, 2012 at 03:21:02AM +0100, Clément Bœsch wrote:
> > > On Thu, Dec 06, 2012 at 01:51:36PM +0100, Nicolas George wrote:
> > > > Le sextidi 16 frimaire, an CCXXI, Clément Bœsch a écrit :
> > > > > New version merging the side data back after muxing.
> > > > 
> > > > Sorry to take the train already rolling (av_packet_*_side_data() are
> > > > undocumented): would it not be simpler to copy the packet structure and
> > > > adjust the size / split the side data in the copy?
> > > > 
> > > > I find that schemes like "do X; something; undo X" are usually a bad idea.
> > > > 
> > > 
> > > So something like attached instead?
> > > 
> > > [...]
> > > 
> > > -- 
> > > Clément B.
> > 
> > >  mux.c |   20 ++++++++++++++++----
> > >  1 file changed, 16 insertions(+), 4 deletions(-)
> > > d7b715e6b1ee3bc9b350902795c63b4886a6e871  0001-lavf-split-packets-before-muxing.patch
> > > From 8de676cadfdd2cf186d02f83b4decddbec021d8f Mon Sep 17 00:00:00 2001
> > > From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
> > > Date: Mon, 3 Dec 2012 23:13:53 +0100
> > > Subject: [PATCH] lavf: split packets before muxing.
> > > 
> > > After demuxing, data and side are merged. Before decoding, they are
> > > split. Encoder will perform with data and side split. This means that a
> > > muxer can receive split data (after encoding) but also merged data (if
> > > called directly after demuxing). This commit makes sure data and side
> > > are split for the muxer.
> > > ---
> > >  libavformat/mux.c | 20 ++++++++++++++++----
> > >  1 file changed, 16 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/libavformat/mux.c b/libavformat/mux.c
> > > index 9bcee99..f7bb3ad 100644
> > > --- a/libavformat/mux.c
> > > +++ b/libavformat/mux.c
> > > @@ -484,13 +484,25 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
> > >      return 0;
> > >  }
> > >  
> > > +static inline int split_write_packet(AVFormatContext *s, AVPacket *pkt)
> > > +{
> > > +    int ret;
> > > +    AVPacket spkt = *pkt;
> > > +
> > > +    av_packet_split_side_data(&spkt);
> > > +    ret = s->oformat->write_packet(s, &spkt);
> > > +    spkt.data = NULL;
> > > +    av_destruct_packet(&spkt);
> > 
> > doesnt this leak and crash the next muxer if 2 are called on the
> > same packet ?
> > 
> 
> Why would that happen? data pointer is kept verbatim in
> av_packet_split_side_data(), and the side data allocated by it will be
> destroyed by av_destruct_packet() without touching the original data
> pointer (spkt.data=NULL).
> 
> Anything I'm missing?

hmm, maybe its ok, i dont see a problem anymore ATM
so clearly either iam wrong now or i was wrong before :)

[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121220/315b6bb2/attachment.asc>


More information about the ffmpeg-devel mailing list