[FFmpeg-devel] Fwd: [PATCH] lavfi: add xbr filter

Michael Niedermayer michaelni at gmx.at
Sat Nov 8 13:21:26 CET 2014


On Sat, Nov 08, 2014 at 05:12:13PM +0530, arwa arif wrote:
> On Sat, Nov 8, 2014 at 2:56 AM, Michael Niedermayer <michaelni at gmx.at>
> wrote:
> 
> > On Fri, Nov 07, 2014 at 11:08:54PM +0530, arwa arif wrote:
> > > On Fri, Nov 7, 2014 at 10:53 PM, Michael Niedermayer <michaelni at gmx.at>
> > > wrote:
> > >
> > > > On Tue, Nov 04, 2014 at 12:26:27AM +0530, arwa arif wrote:
> > > > > Okay. I would try to complete it by tomorrow.
> > > >
> > > > any news about this ?
> > > > i know this isnt trivial to update to the other reference ...
> > > >
> > > >
> > > > >
> > > > > On Mon, Nov 3, 2014 at 8:02 PM, Stefano Sabatini <stefasab at gmail.com
> > >
> > > > wrote:
> > > > >
> > > > > > On date Monday 2014-11-03 12:09:50 +0530, arwa arif encoded:
> > > > [...]
> > > > > > So we have:
> > > > > > C++, 2xBR v3.3b, LGPL
> > > > > >
> > > > > >
> > > >
> > http://sourceforge.net/p/paintown/code/HEAD/tree/trunk/src/util/graphics/sdl/xbr.cpp
> > > > > >
> > > > > > C++, 2xBR v3.3b, GPL
> > > > > >
> > > > > >
> > > >
> > https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xbr.cpp
> > > > > >
> > > > > > The former is clearly a copy&paste from the latter, so that should
> > be
> > > > > > used as reference.
> > > > > >
> > > > > > paintown code was relicensed to GPL with Hyllian's consent, so we
> > > > > > should be able to do the same (if licensing is a concerns, which
> > > > > > probably isn't for such a fringe filter).
> > > > > >
> > > > > > Algorithm description can be found here:
> > > > > >
> > > > > >
> > > >
> > https://web.archive.org/web/20140904180543/http://board.byuu.org/viewtopic.php?f=10&t=2248
> > > > > >
> > > > > > (note: it was down the last time I checked).
> > > > > >
> > > > > > NOTE: since both are games/emulators, I suppose it won't be easy to
> > > > > > make them generate a reference output, so we should rely on
> > comparing
> > > > > > the output generated by the filter with some output found on the
> > web.
> > > > > >
> > > > > > @arwa: are you willing to readapt your xbr filter to make use of
> > > > > > Hyllian's code?
> > > > > > --
> > > > > > FFmpeg = Freak and Frightening Maxi Powered Enhancing Gangster
> > > > > > _______________________________________________
> > > > > > ffmpeg-devel mailing list
> > > > > > ffmpeg-devel at ffmpeg.org
> > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > >
> > > > > _______________________________________________
> > > > > ffmpeg-devel mailing list
> > > > > ffmpeg-devel at ffmpeg.org
> > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > >
> > > >
> > > >
> > > I tried modifying the code. I have created a patch, but I am confused how
> > > to do ALPHA_BLEND part without using float values. Currently I have
> > > commented that part in the patch. In the reference code(
> > >
> > https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xbr.cpp
> > ),
> > > they are actually doing ALPHA_BLEND with masks for 565 format. But, since
> > > FFmpeg has RGB24 format, I am not able to get a way which would do the
> > same
> > > thing without float.
> > >
> > >
> > > > --
> > > > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > > >
> > > > Good people do not need laws to tell them to act responsibly, while bad
> > > > people will find a way around the laws. -- Plato
> > > >
> >
> > >  doc/filters.texi         |    5
> > >  libavfilter/Makefile     |    1
> > >  libavfilter/allfilters.c |    1
> > >  libavfilter/vf_xbr.c     |  359
> > +++++++++++++++++++++++++++++++++++++++++++++++
> > >  4 files changed, 366 insertions(+)
> > > dc77f80072970067718918f0414f4bc94746c063
> > 0001-i-This-is-a-combination-of-2-commits.patch
> > > From 1e838a3045110791cfe1e6bf94a969b59f7160fc Mon Sep 17 00:00:00 2001
> > > From: Arwa Arif <arwaarif1994 at gmail.com>
> > > Date: Thu, 30 Oct 2014 22:06:20 +0530
> > > Subject: [PATCH] i# This is a combination of 2 commits.
> > >
> > > [PATCH]lavfi: add xbr filter
> > >
> > > xBR
> > > ---
> > >  doc/filters.texi         |    5 +
> > >  libavfilter/Makefile     |    1 +
> > >  libavfilter/allfilters.c |    1 +
> > >  libavfilter/vf_xbr.c     |  359
> > ++++++++++++++++++++++++++++++++++++++++++++++
> > >  4 files changed, 366 insertions(+)
> > >  create mode 100644 libavfilter/vf_xbr.c
> > >
> > > diff --git a/doc/filters.texi b/doc/filters.texi
> > > index 7be29de..2905e5d 100644
> > > --- a/doc/filters.texi
> > > +++ b/doc/filters.texi
> > > @@ -9163,6 +9163,11 @@ Only deinterlace frames marked as interlaced.
> > >  Default value is @samp{all}.
> > >  @end table
> > >
> > > + at section xbr
> > > +Apply high-quality magnification filter which is designed for pixel
> > art. It follows a set
> > > +of edge-detection rules @url{
> > http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
> > > +This filter was originally created by Hyllian.
> > > +
> > >  @anchor{yadif}
> > >  @section yadif
> > >
> > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > > index 6d868e7..2c56e38 100644
> > > --- a/libavfilter/Makefile
> > > +++ b/libavfilter/Makefile
> > > @@ -198,6 +198,7 @@ OBJS-$(CONFIG_VIDSTABDETECT_FILTER)          +=
> > vidstabutils.o vf_vidstabdetect.
> > >  OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)       += vidstabutils.o
> > vf_vidstabtransform.o
> > >  OBJS-$(CONFIG_VIGNETTE_FILTER)               += vf_vignette.o
> > >  OBJS-$(CONFIG_W3FDIF_FILTER)                 += vf_w3fdif.o
> > > +OBJS-$(CONFIG_XBR_FILTER)                    += vf_xbr.o
> > >  OBJS-$(CONFIG_YADIF_FILTER)                  += vf_yadif.o
> > >  OBJS-$(CONFIG_ZMQ_FILTER)                    += f_zmq.o
> > >  OBJS-$(CONFIG_ZOOMPAN_FILTER)                += vf_zoompan.o
> > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> > > index d88a9ad..2352d44 100644
> > > --- a/libavfilter/allfilters.c
> > > +++ b/libavfilter/allfilters.c
> > > @@ -213,6 +213,7 @@ void avfilter_register_all(void)
> > >      REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
> > >      REGISTER_FILTER(VIGNETTE,       vignette,       vf);
> > >      REGISTER_FILTER(W3FDIF,         w3fdif,         vf);
> > > +    REGISTER_FILTER(XBR,            xbr,            vf);
> > >      REGISTER_FILTER(YADIF,          yadif,          vf);
> > >      REGISTER_FILTER(ZMQ,            zmq,            vf);
> > >      REGISTER_FILTER(ZOOMPAN,        zoompan,        vf);
> > > diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c
> > > new file mode 100644
> > > index 0000000..416c7ce
> > > --- /dev/null
> > > +++ b/libavfilter/vf_xbr.c
> > > @@ -0,0 +1,359 @@
> > > +/*
> > > + * This file is part of FFmpeg.
> > > + *
> > > + * Copyright (c) 2014 Arwa Arif <arwaarif1994 at gmail.com>
> >
> > This should also have a copyright line for Hyllian/Jararaca
> > as some/most of the code is takenfrom /based on his implementation
> >
> > [...]
> >
> > --
> > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > No great genius has ever existed without some touch of madness. --
> > Aristotle
> >
> >

> How is RGB32 stored? Is it big endian or small endian? I assumed it to be

its native endian, so it will work fine when read as uint32 as is
done currently. That is its little endian on little endian hardware
and big endian on big endian hardware, no byte swap or endian specific
reading should be needed

A variant without A/alpha would be
AV_PIX_FMT_0RGB32 or AV_PIX_FMT_0BGR32


> RRGGBBAA. I tried with AARRGGBB also. Neither of the two are giving the
> desired results.

you can very easily find this out by setting part to 0xFF and
the rest to 0 and just looking at how the output looks, like
green, red or blue

the 0RGB32 / 0BGR32 formats should be 00RRGGBB and 00BBGGRR in
uint32_t, that is the most signifiat bits of the 32 should be 00 / AA

[...]
> +#define ALPHA_BLEND_X_W(dst, src, alpha) \
> +   ts = src; td = dst;\
> +   td = ((td|(td<<16)) & RGB_MASK); ts = ((ts|(ts<<16)) & RGB_MASK);\
> +   td = ((( ( (ts-td)*alpha ) >> 5 ) + td ) & RGB_MASK); \
> +   dst= (td|(td>>16));

this is not correct
the shift by 16 makes no sense for 24 or 32bit RGB/BGR
the orignal ALPHA_BLEND_192_W and ALPHA_BLEND_224_W from
xbr.cpp might work though

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141108/30603d70/attachment.asc>


More information about the ffmpeg-devel mailing list