[FFmpeg-devel] [Patch] Scale filter should use multiples of 2

Stefano Sabatini stefano.sabatini-lala
Thu Jul 1 16:27:33 CEST 2010


On date Thursday 2010-07-01 10:00:18 -0400, Daniel G. Taylor encoded:
> On 06/30/2010 07:40 PM, Stefano Sabatini wrote:
> >
> >>Index: libavfilter/vf_scale.c
> >>===================================================================
> >>--- libavfilter/vf_scale.c	(revision 23891)
> >>+++ libavfilter/vf_scale.c	(working copy)
> >>@@ -33,7 +33,7 @@
> >>      /**
> >>       * New dimensions. Special values are:
> >>       *   0 = original width/height
> >>-     *  -1 = keep original aspect
> >>+     *  -x = keep original aspect and make mod-x, e.g. -16 for multiples of 16
> >
> >Just a question, couldn't this be achieved using parametric values for
> >w:h?
> >
> >I don't want to add code and complexity when all this may be
> >accomplished by a more general mechanism.
> >
> >For example we may have a = w / h
> >w'/h' = a = w/h
> >h' = w' / a
> >
> >scale=OUT_W:mod(OUT_W/a, 2)
> 
> I suppose that will work (and Michael is right about it being
> round() instead of mod), but doesn't having to parse such values
> make this incredibly more complex? Are there utilities in libav* to
> make parsing that easy?
> 
> Also, what other use cases are there for such a system? We can round
> to the nearest multiple, but what else would it do that warrants
> such a system?

For example you may to parametrically change the size:
# double size
scale=2*w:2*h
# decrease size by 50%
scale=w/2:h/2
# invert w/h sizes
scale=h:w
# seek for greek harmony
scale=h*PHI:h

> Basically, I don't know how I can do this easily, and writing a
> bunch of code doing it a stupid way seems like a waste of time, so
> any advice would be appreciated if we do want to go this way.

libavutil/eval.h, check how it is done in the libavfilter-soc overlay
and setpts filters. This requires to add eval evalutation to the scale
filter, check the recent patch by Baptiste on which I commented
yesterday.

Regards.
-- 
FFmpeg = Fundamentalist & Faithless Maxi Ponderous Exploitable Gymnast



More information about the ffmpeg-devel mailing list