[FFmpeg-devel] [PATCH] Port gradfun to libavfilter (GCI)

Stefano Sabatini stefano.sabatini-lala
Mon Dec 6 12:08:03 CET 2010


On date Monday 2010-12-06 03:19:25 +0000, Loren Merritt encoded:
> On Sun, 5 Dec 2010, Nolan L wrote:
> >On Sat, Dec 4, 2010 at 12:34 PM, Stefano Sabatini wrote:
> >
> >>This looks weird, you're putting in outlink->out_buf a reference to
> >>the input buffer, then you're doing inplace processing in end_frame().
> >>
> >>Is this really wanted? (and is this the behavior of the original
> >>filter?).
> >>
> >>If this is the case you can simplify below since you don't need a
> >>distinct inpic and outpic.
> >
> >This was basically the behavior of the original, as I understood it.
> >However, it did retain the distinction between inpic and outpic. I am
> >hesitant to change code that already works, partially because it may involve
> >rewriting some asm functions.
> >
> >I will however remove the else clause of the if, as it would be impossible
> >to have the two be inequal.
> 
> Then it sounds like you didn't port the MPlayer behaviour correctly.
> The MPlayer filter supported out==in if in is writable, and it also
> supported out!=in if in is read-only.

OK so I think we should try to mimic the behavior (and efficiency) of
the libmpcodecs system.

I'll describe a possible solution.

You take note in start_frame() if the input picref has PRESERVE
permission.

If this is not the case, you can do inplace processing in end_frame(),
and set outpic = inlink->cur_buf.

Otherwise (always in start_frame()) you'll have to request a new
buffer to the filterchain and set outpic = avfilter_get_video_buffer().

Note that the drawbox filter is quite different in this regards, since
it has rej_perm&AV_PERM_PRESERVE it requests a new buffer in
avfilter_start_frame() and copies all the content of the input picture
in the output picture, which in our case it is not convenient since
we're going to rewrite again all the pixels of the input buffer.

Same approach should be followed for the eq filter.
-- 
FFmpeg = Funny and Fantastic Maxi Prodigious Elfic Gadget



More information about the ffmpeg-devel mailing list