[FFmpeg-devel] [PATCH] vsrc_buffer: add flags param to av_vsrc_buffer_add_video_buffer_ref

Stefano Sabatini stefano.sabatini-lala at poste.it
Mon Jun 6 01:39:29 CEST 2011


On date Sunday 2011-06-05 18:57:39 +0200, Michael Niedermayer encoded:
> On Sun, Jun 05, 2011 at 06:17:04PM +0200, Stefano Sabatini wrote:
> > On date Sunday 2011-06-05 00:50:12 +0200, Michael Niedermayer encoded:
> > > On Fri, Jun 03, 2011 at 07:19:50PM +0200, Stefano Sabatini wrote:
> > [...]
> > > >  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
> > 
> > Applied. In attachment the subject patch, which is imo still useful.
> > -- 
> > FFmpeg = Frenzy and Furious Mysterious Portentous Earthshaking Geisha
> 
> >  ffmpeg.c                  |    3 ++-
> >  libavfilter/avcodec.h     |    5 ++++-
> >  libavfilter/vsrc_buffer.c |   22 ++++++++++++++--------
> >  libavfilter/vsrc_buffer.h |   11 ++++++++++-
> >  4 files changed, 30 insertions(+), 11 deletions(-)
> > 80534bd5c4d4e80024658ba18803cd81de8add95  0001-vsrc_buffer-add-flags-param-to-av_vsrc_buffer_add_vi.patch
> > From fe30483eb9804cdaecdfbc2b60ec58666ac7bb0d Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > Date: Thu, 2 Jun 2011 15:43:21 +0200
> > Subject: [PATCH] vsrc_buffer: add flags param to av_vsrc_buffer_add_video_buffer_ref
> > 
> > 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.
> > ---
> >  ffmpeg.c                  |    3 ++-
> >  libavfilter/avcodec.h     |    5 ++++-
> >  libavfilter/vsrc_buffer.c |   22 ++++++++++++++--------
> >  libavfilter/vsrc_buffer.h |   11 ++++++++++-
> >  4 files changed, 30 insertions(+), 11 deletions(-)
> > 
> > diff --git a/ffmpeg.c b/ffmpeg.c
> > index fb619e7..b18224b 100644
> > --- a/ffmpeg.c
> > +++ b/ffmpeg.c
> > @@ -1691,7 +1691,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);
> >                  }
> >                  frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
> >                      !ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
> 
> iam not sure about this hunk

The flag here is not strictly required, but should avoid a leak in
case of errors (but change it to 0 if you prefer it that way).

> the rest is ok

Pushed.
-- 
FFmpeg = Fiendish and Faithless Mind-dumbing Pitiless Enlightening Goblin


More information about the ffmpeg-devel mailing list