[FFmpeg-devel] [PATCH 8/8] avidec: demux ASS and SRT tracks

Reimar Döffinger Reimar.Doeffinger
Fri Jul 23 18:13:33 CEST 2010


On Thu, Jul 22, 2010 at 11:48:27PM +0200, Aurelien Jacobs wrote:
> On Thu, Jul 22, 2010 at 07:04:48PM +0200, Reimar D?ffinger wrote:
> > On Thu, Jul 22, 2010 at 12:39:51AM +0200, Aurelien Jacobs wrote:
> > > > > +        memmove(pkt->data, ptr, size);
> > > > 
> > > > Seems like a very inefficient way to do
> > > > pkt->data += pkt->size - size;
> > > 
> > > But this is a way that won't crash when doing av_free_packet(pkt).
> > > pkt->data points to av_malloced memory, so we don't want to loose this
> > > pointer.
> > 
> > But you memset it to 0 in the end anyway, that's why it seemed
> > pointless.
> 
> Oops... Indeed my explanation was wrong. I just remembered that this
> memmove was necessary to be able to free data afterward. But it is not
> thru av_free_packet(). The pkt->data is passed to av_alloc_put_byte()
> and is freed with url_fclose() (called by av_close_input_file).

I admit I was wondering where it was freed.
Maybe a comment would be a good idea?

> > But even if I misunderstood that there should be a lot of simple
> > ways to avoid the memmove without a lot of effort.
> 
> Sure. It should be possible to save the pkt->data pointers for each
> stream, and manually free them when in avi_read_close(). I feared it
> would be kind of ugly, but I will give it a try.

Well, I may have underestimate how much effort it would be.
Don't waste too much time on it, just a comment explaining the why
is an ok solution, too.



More information about the ffmpeg-devel mailing list