[FFmpeg-devel] [PATCH] libavfilter-soc: Make overlay handle still images

Martin Storsjö martin
Fri May 8 09:56:46 CEST 2009


On Fri, 8 May 2009, Vitor Sessak wrote:

> I like it.

Great!

> > +    if (!over->pics[0][0] || !over->pics[1][0]) {
> > +        /* The first time through, pull a frame from each input */
> > +        if (!over->pics[0][0] &&
> > avfilter_request_frame(link->src->inputs[0]))
>                ^^^^^^^^^^^^^^^^
> > +            return AVERROR_EOF;
> > +        if (!over->pics[1][0] &&
> > avfilter_request_frame(link->src->inputs[1]))
>                ^^^^^^^^^^^^^^^^
> > +            return AVERROR_EOF;
> 
> Those checks are useless (you can assert(!over->pics[0][0] &&
> !over->pics[1][0]) after the if() if you wanted to double-check).

Actually, there's a use for them. Imagine that there's a frame available 
in input 0, but none at all in input 1. The first time through this, it 
pulls one frame successfully from input 0 and sets it in over->pics[0][0], 
but fails in pulling from the other input. The next time through, we're 
still in this first case of the large if - no previous output frames, just 
trying to get the initial input frame from each. In that case, we 
shouldn't pull anything from the one where we already have one frame.

I updated the comment, though, to hopefully make this slightly less 
dubious.

> > +        /* Try pulling a new candidate from each input unless we already
> > +           have one */
> > +        if (!over->pics[0][1])
> > +            avfilter_request_frame(link->src->inputs[0]);
> > +        if (!over->pics[1][1])
> > +            avfilter_request_frame(link->src->inputs[1]);
> > +        if (!over->pics[0][1] && !over->pics[1][1])
> > +            return AVERROR_EOF; /* No new candidates in any input; EOF */
> 
> I think it is better to check for the return values of
> avfilter_request_frame() and after (if not both EOF) assert(!over->pics[0][1]
> || !over->pics[1][1]).

Ok, changed this to check for the return values and then assert the 
pictures.

> > +
> > +        if (over->pics[0][1] && over->pics[1][1]) {
> > +            /* Candidates in both queues, check which one to use */
> 
> /* Neither one of the inputs has finished */

Ok, changed.

Updated patch attached.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libavfilter-soc-overlay-eof5.patch
Type: text/x-diff
Size: 3997 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090508/c42db84f/attachment.patch>



More information about the ffmpeg-devel mailing list