[FFmpeg-devel] [PATCH] lavfi: edgedetect filter

Michael Niedermayer michaelni at gmx.at
Wed Aug 8 15:42:20 CEST 2012


Hi

On Wed, Aug 08, 2012 at 02:12:02PM +0200, Clément Bœsch wrote:
> On Wed, Aug 08, 2012 at 12:55:15PM +0200, Stefano Sabatini wrote:
> [...]
> > > +static void gaussian_blur(AVFilterContext *ctx, int w, int h,
> > > +                                uint8_t *dst, int dst_linesize,
> > > +                          const uint8_t *src, int src_linesize)
> > > +{
> > > +    int i, j;
> > > +
> > > +    memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
> > > +    memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
> > > +    for (j = 2; j < h - 2; j++) {
> > > +        dst[0] = src[0];
> > > +        dst[1] = src[1];
> > > +        for (i = 2; i < w - 2; i++) {
> > > +            dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
> > > +                    + (src[-2*src_linesize + i-1] + src[2*src_linesize + i-1]) * 4
> > > +                    + (src[-2*src_linesize + i  ] + src[2*src_linesize + i  ]) * 5
> > > +                    + (src[-2*src_linesize + i+1] + src[2*src_linesize + i+1]) * 4
> > > +                    + (src[-2*src_linesize + i+2] + src[2*src_linesize + i+2]) * 2
> > > +
> > > +                    + (src[  -src_linesize + i-2] + src[  src_linesize + i-2]) *  4
> > > +                    + (src[  -src_linesize + i-1] + src[  src_linesize + i-1]) *  9
> > > +                    + (src[  -src_linesize + i  ] + src[  src_linesize + i  ]) * 12
> > > +                    + (src[  -src_linesize + i+1] + src[  src_linesize + i+1]) *  9
> > > +                    + (src[  -src_linesize + i+2] + src[  src_linesize + i+2]) *  4
> > > +
> > > +                    + src[i-2] *  5
> > > +                    + src[i-1] * 12
> > > +                    + src[i  ] * 15
> > > +                    + src[i+1] * 12
> > > +                    + src[i+2] *  5) / 159;
> > > +        }
> > 
> > My feeling is that we should avoid to hardcode convolution operations,
> > and write generic code for it. Also we may want to make the size of
> > the gaussian mask parametric, as well as the sigma parameter used to
> > compute the mask.
> > 
> > Convolution operations are useful per-se, and could be used to
> > implement ad-hoc filters.
> > 
> 
> I've just used the standard matrix for that algorithm; from a performance
> point of view it also has some benefits. Note that it is relatively
> trivial to write so I'm not sure such generic code would be required.
> Maybe we could macro-generate various version of that but I'm not sure
> that's really important in that case.
> 
> This step really is just to quickly get rid of some noise.
> 
> Do we have already use these in some other filters?

swscale can apply generic seperably (in 1D H/V) convolutions.


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120808/62eb454f/attachment.asc>


More information about the ffmpeg-devel mailing list