[FFmpeg-devel] [PATCH] Make slicify honour the slice direction

Stefano Sabatini stefano.sabatini-lala
Wed Dec 2 00:37:21 CET 2009


On date Tuesday 2009-12-01 12:44:10 +0100, Michael Niedermayer encoded:
> On Mon, Nov 30, 2009 at 11:41:26PM +0100, Stefano Sabatini wrote:
> > Hi, as in subject.
> > 
> > Without this some combination with the pad filter may issue weird
> > behavior.
> > 
> > Regards.
> > -- 
> > FFmpeg = Fast Furious Mere Peaceful Eccentric Guru
> 
> >  vf_slicify.c |   22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 9e459bac2cabe3ccb99c5419be00af872fc72f01  fix-slice-dir-for-slicify.patch
> > Index: libavfilter-soc/ffmpeg/libavfilter/vf_slicify.c
> > ===================================================================
> > --- libavfilter-soc.orig/ffmpeg/libavfilter/vf_slicify.c	2009-11-30 22:18:44.000000000 +0100
> > +++ libavfilter-soc/ffmpeg/libavfilter/vf_slicify.c	2009-11-30 23:34:49.000000000 +0100
> > @@ -28,6 +28,8 @@
> >  typedef struct {
> >      int h;          ///< output slice height
> >      int vshift;     ///< vertical chroma subsampling shift
> > +    int slice_dir;  ///< detected slice direction for the current frame
> > +    int slice_y;    ///< if the slice direction is bottom-up is the bottom y for the next slice
> >  } SliceContext;
> >  
> >  static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> > @@ -65,6 +67,8 @@
> >  
> >  static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
> >  {
> > +    SliceContext *slice = link->dst->priv;
> > +    slice->slice_dir = 0;
> >      avfilter_start_frame(link->dst->outputs[0], picref);
> >  }
> >  
> > @@ -78,11 +82,29 @@
> >      SliceContext *slice = link->dst->priv;
> >      int y2;
> >  
> > +    if (!slice->slice_dir) {
> > +        if (y != 0 && y + h != link->h) {
> > +            av_log(link->dst, AV_LOG_ERROR, "Slices start in the middle!\n");
> > +            return;
> > +        }
> > +        slice->slice_dir = y ?                       -1 : 1;
> > +        slice->slice_y   = y ? link->dst->outputs[0]->h : y;
> > +    }
> 
> code duplication

True.

> an additional argument in draw_slice() that specifies direction seems
> simpler to me.

Considering that the slice direction is per-frame, then it could make
sense to define the parameter in start_frame(), then a filter which
needs it may store its value in the context and use that (well this
was the first solution I devised when fixing the scale filter).

Regards.
-- 
FFmpeg = Fiendish and Furious Mega Programmable Evanescent Gadget



More information about the ffmpeg-devel mailing list