[FFmpeg-devel] [PATCH] Add alphaextract, alphamerge filters

Steven Robertson steven at strobe.cc
Sun Jul 15 20:35:03 CEST 2012

On Sat, Jul 14, 2012 at 4:03 PM, Nicolas George
<nicolas.george at normalesup.org> wrote:
> Le septidi 27 messidor, an CCXX, Steven Robertson a écrit :
>> It works in all cases that I've tested. I agree that timestamps would guard
>> against that problem, but I also agree that they would be more complicated ;)
>> I'd prefer to get this in in its simpler form and wait for that API to become
>> available.
> I have no objection to that, but maybe a small warning in the doc may be in
> order.


>> I'm not sure I get the intent here. I came up with this, which I believe will
>> work for the cases I can think of. If it doesn't, can you help me understand
>> why?
>>     if (!ff_bufqueue_peek(&merge->queue_alpha, 0)) {
>>       ret = ff_request_frame(ctx->inputs[1]);
>>       if (ret < 0)
>>           return ret;
>>     }
>>     if (!ff_bufqueue_peek(&merge->queue_main, 0)) {
>>       ret = ff_request_frame(ctx->inputs[0]);
>>       if (ret < 0)
>>           return ret;
>>     }
>>     return 0;
> Unfortunately, that may not work.
> Imagine you have the luminance and alpha side by side in a single video: you
> use a split and two crops to separate them, and then alphamerge. Or maybe
> you use alphaextract, then do a transform on one of the streams and merge
> them again.
> When you do your first request, it goes back to the split filter, and it
> reacts by sending a frame on both streams. The frames arrive to alphamerge,
> there is enough to produce output, so both frames are consumed. Then you
> arrive to the second ff_bufqueue_peek: as the frame that just arrived on
> input #0 has been consumed, the condition is true: the code ends up
> requesting a second frame from the split, and thus sending two frames when
> only one was requested, or returning an error code when in fact filtering
> was succesfull.

Thank you for explaining! I've switched to the algorithm you proposed.

> Filters with multiple inputs are very tricky, because frames can arrive on
> any input at inconvenient times. If anyone has suggestions on how to make
> them less so, they are very welcome.

Short of adopting CSP, nothing comes to mind ;) Perhaps a couple of
pipeline tests which simulate corner cases might make things clearer.

> I will try to comment the new version of the patch a little later.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-alphaextract-alphamerge-filters.patch
Type: application/octet-stream
Size: 17898 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120715/9a4871f9/attachment.obj>

More information about the ffmpeg-devel mailing list