[FFmpeg-devel] [PATCH] lavfi/testsrc: extend logic in request_frame, support static image output
Stefano Sabatini
stefasab at gmail.com
Wed Aug 1 13:06:10 CEST 2012
On date Wednesday 2012-08-01 11:11:24 +0200, Nicolas George encoded:
> Le quintidi 15 thermidor, an CCXX, Stefano Sabatini a écrit :
> > ---
> > libavfilter/vsrc_testsrc.c | 44 +++++++++++++++++++++++++++++++-------------
> > 1 files changed, 31 insertions(+), 13 deletions(-)
> >
> > diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
> > index 7006e53..3f9c922 100644
> > --- a/libavfilter/vsrc_testsrc.c
> > +++ b/libavfilter/vsrc_testsrc.c
[...]
> > @@ -140,25 +143,39 @@ static int config_props(AVFilterLink *outlink)
> > static int request_frame(AVFilterLink *outlink)
> > {
> > TestSourceContext *test = outlink->src->priv;
> > - AVFilterBufferRef *picref;
> > - int ret;
> > + AVFilterBufferRef *outpicref;
> > + int ret = 0;
> >
> > if (test->max_pts >= 0 && test->pts >= test->max_pts)
> > return AVERROR_EOF;
> > - picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h);
> > - if (!picref)
> > - return AVERROR(ENOMEM);
> >
> > - picref->pts = test->pts++;
> > - picref->pos = -1;
> > - picref->video->key_frame = 1;
> > - picref->video->interlaced = 0;
> > - picref->video->pict_type = AV_PICTURE_TYPE_I;
> > - picref->video->sample_aspect_ratio = test->sar;
> > - test->fill_picture_fn(outlink->src, picref);
> > + if (test->draw_once) {
> > + if (!test->picref) {
> > + test->picref =
> > + ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_PRESERVE|AV_PERM_REUSE,
> > + test->w, test->h);
> > + if (!test->picref)
> > + return AVERROR(ENOMEM);
> > + }
> > + outpicref = avfilter_ref_buffer(test->picref, ~AV_PERM_WRITE);
> > + } else
> > + outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h);
> > +
> > + if (!outpicref)
> > + return AVERROR(ENOMEM);
> > + outpicref->pts = test->pts;
> > + outpicref->pos = -1;
> > + outpicref->video->key_frame = 1;
> > + outpicref->video->interlaced = 0;
> > + outpicref->video->pict_type = AV_PICTURE_TYPE_I;
> > + outpicref->video->sample_aspect_ratio = test->sar;
>
> > + if (!test->pts || !test->draw_once)
> > + test->fill_picture_fn(outlink->src, outpicref);
>
> Looks fragile. Maybe call fill_picture_fn just after outpicref is created,
> on both branches. Or set a flag there.
Done the first way.
> > +
> > + test->pts++;
> > test->nb_frame++;
>
> Now redundant?
Yes, but unrelated.
[...]
> Otherwise looks good to me.
Upped.
--
FFmpeg = Forgiving and Frenzy Mystic Philosophical Extravagant Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavfi-testsrc-extend-logic-in-request_frame-support-.patch
Type: text/x-diff
Size: 3497 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120801/0031a690/attachment.bin>
More information about the ffmpeg-devel
mailing list