[FFmpeg-devel] [PATCH] vsrc_buffer: add flags param to av_vsrc_buffer_add_video_buffer_ref
Michael Niedermayer
michaelni at gmx.at
Sun Jun 5 00:50:12 CEST 2011
On Fri, Jun 03, 2011 at 07:19:50PM +0200, Stefano Sabatini wrote:
> On date Friday 2011-06-03 13:26:53 +0200, Etienne Buira encoded:
> > Hi Stefano, thank you very much for this patch!
> >
> > On Fri, Jun 03, 2011 at 12:36:55PM +0200, Stefano Sabatini wrote:
> > > The new flags parameter allow to specify if the video ref to add
> > > should overwrite the cache, if the flag is not set vsrc_buffer will
> > > complain and abort; otherwise it will clean the already cached video
> > > ref before to overwrite it, thus avoiding a leak.
> > >
> > > In particular, fix a massive leak occurring with ffmpeg -ss TIME -i
> > > INPUT OUTPUT.
> >
> > ffmpeg -i INPUT -ss TIME OUTPUT
> >
> > > diff --git a/ffmpeg.c b/ffmpeg.c
> > > index e5986a6..bbf8a41 100644
> > > --- a/ffmpeg.c
> > > +++ b/ffmpeg.c
> > > @@ -1665,7 +1665,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
> > > picture.sample_aspect_ratio = ist->st->sample_aspect_ratio;
> > > picture.pts = ist->pts;
> > >
> > > - av_vsrc_buffer_add_frame(ost->input_video_filter, &picture);
> > > + av_vsrc_buffer_add_frame(ost->input_video_filter,
> > > + &picture, AV_VSRC_BUF_FLAG_OVERWRITE);
> >
> > About this part, wouldn't it better not to buffer frames that will be
> > discarded anyway, by moving this #ifdef CONFIG_AVFILTER block at the
> > beginning of if(start_time == 0[...])?
>
> That's a fine idea, patch attached.
>
> > Don't know all the pros and cons about modifying API, might be a good
> > thing to add anyway.
>
> Yes I think it may be useful, even if not necessary for this fix.
> --
> FFmpeg = Fast & Fiendish Mournful Portable Eretic Generator
> ffmpeg.c | 22 +++++++---------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
> 7c2b7d6adc4e181b775dfaf02efedc39a1d374bf 0001-ffmpeg-fix-massive-leak-when-seeking.patch
> From 36e7f6a33d96a437b9dc39e297b25e721c3d6c1d Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 3 Jun 2011 19:03:44 +0200
> Subject: [PATCH] ffmpeg: fix massive leak when seeking
>
> Avoid to add frames to the vsrc_buffer in case ist->pts < start_time,
> as these frames are unused (and never released). In particular this
> condition is verified with commands of the kind:
> ffmpeg -i INPUT -ss TIME OUTPUT
>
> Also simplify.
LGTM if tested
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- 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/20110605/39c69f0b/attachment.asc>
More information about the ffmpeg-devel
mailing list