[FFmpeg-devel] [PATCH] Add a slice_dir parameter to avfilter_start_frame()

Stefano Sabatini stefano.sabatini-lala
Fri Dec 4 01:21:06 CET 2009


On date Wednesday 2009-12-02 13:00:30 +0100, Michael Niedermayer encoded:
> On Wed, Dec 02, 2009 at 09:18:48AM +0100, Stefano Sabatini wrote:
> > On date Wednesday 2009-12-02 03:08:37 +0100, Michael Niedermayer encoded:
> > > On Wed, Dec 02, 2009 at 01:39:43AM +0100, Stefano Sabatini wrote:
> > > > Hi,
> > > > 
> > > > this is useful for the scale, slicify and pad filters, which have
> > > > otherwise to heuristically determine the slice direction, so
> > > > duplicating code.
> > > > 
> > > > Also I'm not sure about which values to use for the slice_dir, now I'm
> > > > using 1/-1 but >0/<0 may be better, suggestions?
> > > 
> > > 1/-1
> > > 
> > > 
> > > [...]
> > > > -void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
> > > > +void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref, int slice_dir)
> > > 
> > > i suggested draw_slice()
> > > we need it only in draw_slice()
> > > your code now must store it always in the context because its never needed
> > > in start_frame but always in draw_slice()
> > > you dont even attempt to explain why you do it like that and not like i
> > > suggested.
> > > YOu didnt expect me to do anything except rejecting this did you?
> > > its more complex and its completely unclear why its done like that
> > 
> > I tried to explain it in another mail, since the direction is
> > *per-frame* I thougth it was slightly more robust to pass this
> > information just one time per frame.
> > 
> > That said, I see your point and if you prefer the slice_dir in
> > draw_slice() for me it is absolutely fine.
> 
> i prefer it in draw_slice()

Updated.

One funny thing I noticed:
ffplay -loglevel debug in.avi -vfilters "scale=100:100, vflip, slicify=10, format=argb" ^| grep "scale           ->ffplay_output"
start_frame     : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] picref[0xa194b60 data[0xa30a840, 0xa30d400, 0xa30e080, (nil)] linesize[112, 64, 64, 0] pts:1400000 s:100x100]
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:92 h:8 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:82 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:72 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:62 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:52 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:42 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:32 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:22 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:12 h:10 dir:-1
draw_slice      : link[0xa0e08c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:0 h:12 dir:-1

Then I tried to comment the following lines in the scale filter: 
    if (scale->slice_y == 0 && slice_dir == -1)
        scale->slice_y = link->dst->outputs[0]->h;

start_frame     : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] picref[0x99d3040 data[0x9c72590, 0x9c75150, 0x9c75dd0, (nil)] linesize[112, 64, 64, 0] pts:2966000 s:100x100]
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-8 h:8 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-18 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-28 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-38 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-48 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-58 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-68 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-78 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-88 h:10 dir:-1
draw_slice      : link[0x996f8c0 s:100x100 fmt:yuv420p          scale           ->ffplay_output   ] y:-100 h:12 dir:-1

libswscale seems to work fine with negative values for y.

BTW, the abovementioned lines in draw_slice() are also the reason for
which I prefer to put in start_frame the slice_dir, apart for the
already mentioned reasons I think a filter may need to do something in
start_frame() with the slice_dir parameter (in this case set the
scale->slice_y parameter), rather than do that in draw_slice(), with
slice_dir in draw_slice() this is not possible.

Regards.
-- 
FFmpeg = Funny and Friendly Martial Ponderous Ecstatic Gymnast
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lavfi-add-slice-dir-to-draw-slice.patch
Type: text/x-diff
Size: 9097 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091204/d4c26fbe/attachment.patch>



More information about the ffmpeg-devel mailing list