[FFmpeg-devel] [PATCH] Add vf_scale.c filter

Stefano Sabatini stefano.sabatini-lala
Tue Mar 3 01:13:35 CET 2009


On date Friday 2009-02-27 16:44:46 +0100, Michael Niedermayer encoded:
> On Fri, Feb 27, 2009 at 12:56:08PM +0100, Stefano Sabatini wrote:
> > Hi all, 
> > as in subject.
> 
> first quick question
> does
> crop, expand and slices work? (a single pix_fmt working is enough)

crop seems to work, but it doesn't work like in mplayer, syntax is
x:y:w:h, also default is not centered, this should be changed I
think.

slices seem to work fine after the Vitor's patch, expand is currently
not implemented and the padding implementation in ffmpeg.c is
currently half-broken, so I think we need an expand filter as well.
 
> i mean can i take a 320x200 movie crop a 100x100 area out scale
> that to 200x200 and add a border to make 300x200 _without_ any
> memcpy() ?
> just a simple test to make sure no serious bugs are in there
> 
> second question are there any features mplayers vf_scale has that lavfi
> does not?

Yes, and it shouldn't be hard to implement them (e.g. luma/chroma
gaussian blur, params etc.), that should be done before or after the
integration?

> also we need support for interlaced scaling though this is better done
> through some generic wraper filter
> that is a filter that as arguments has another filtername and its arguments
> and that then creates 2 such filters and filters the odd and even
> lines seperately with them

OK, si there something similar in MPlayer on which to base this?

> [...]
> 
> > +        char sws_flags[256];
> > +        int i = 0;
> > +        p = strchr(sws_opts, '=');
> > +        p++;
> > +        while (*p && *p != ':' && i < sizeof(sws_flags) - 1)
> > +            sws_flags[i++] = *p++;
> > +        sws_flags[i] = 0;
> 
> sscanf("sws_flags=%255[^:]")
 >
> [...]
> > +    av_reduce(&out->outpic->pixel_aspect.num, &out->outpic->pixel_aspect.den,
> > +               out->outpic->pixel_aspect.num,  out->outpic->pixel_aspect.den,
> > +         FFMAX(out->outpic->pixel_aspect.num,  out->outpic->pixel_aspect.den));
> 
> you want to use av_gcd() here i think
 
Check the attached patches (I'll apply them to soc if are OK).

> > +
> > +    avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));
> > +
> > +    scale->sliceY = 0;
> > +}
> > +
> > +static void draw_slice(AVFilterLink *link, int y, int h)
> > +{
> > +    ScaleContext *scale = link->dst->priv;
> > +    int outH;
> > +    int vsub, hsub;
> > +    uint8_t *data[4];
> > +
> > +    avcodec_get_chroma_sub_sample(link->format, &hsub, &vsub);
> > +
> > +    data[0] = link->cur_pic->data[0] + y * link->cur_pic->linesize[0];
> > +    data[3] = link->cur_pic->data[3] + y * link->cur_pic->linesize[3];
> > +
> > +    if (link->cur_pic->data[2]) {
> > +        data[1] = link->cur_pic->data[1] + (y>>vsub)*link->cur_pic->linesize[1];
> > +        data[2] = link->cur_pic->data[2] + (y>>vsub)*link->cur_pic->linesize[2];
> > +    } else {
> > +        // Probably a paletted format
> > +        data[1] = link->cur_pic->data[1];
> > +        data[2] = link->cur_pic->data[2];
> > +    }
> 
> looks like its missing some special case for a palette

I need to know more about paletted formats...

Regards.
-- 
FFmpeg = Frenzy & Faboulous Merciless Puristic EntanGlement
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scale-use-sscanf.patch
Type: text/x-diff
Size: 770 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090303/624338bd/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scale-use-gcd.patch
Type: text/x-diff
Size: 1188 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090303/624338bd/attachment-0001.patch>



More information about the ffmpeg-devel mailing list