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

Aurelien Jacobs aurel
Thu Jul 22 23:48:27 CEST 2010


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).

> 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.

Aurel



More information about the ffmpeg-devel mailing list