Fwd: [PATCH] lavfi: add xbr filter
On Fri, Nov 7, 2014 at 10:53 PM, Michael Niedermayer <michaelni@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@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...
C++, 2xBR v3.3b, GPL
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xb...
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@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@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/xb...), 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
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@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@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...
C++, 2xBR v3.3b, GPL
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xb...
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@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@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/xb...), 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.
you do not need floats for the blend stuff these macros simply mix 2 pixels and the reference does it using "bit tricks", which is something quite cool the 128 aka 50:50 mixing works simply by taking the 2 16bit values RRRRRGGGGGBBBBB and the second pixel rrrrrgggggbbbbb zeros the least significant bits of each RRRR0GGGG0BBBB0 and the second pixel rrrr0gggg0bbbb0 and then adds the 2 together as if they where one value the other blend variants work by spliting green out so there are unused and zeroed bits between the components RRRRR00000BBBBB and 00000GGGGG00000 / rrrrr00000bbbbb and 00000ggggg00000 the other operations are carefully selected to scale the red and blue values without them affecting each other or the green this stuff above is very interresting and sometimes quite usefull to perform multiple computations at once but you should not need to understand this for xbr at least not deeply because i suspect the original macros work fine with updated bitmasks for rgb24/rgb32/bgr24/bgr32 #define pg_lbmask 0xFEFEFE #define pg_red_blue_mask 0xFF00FF #define pg_green_mask 0x00FF00 [...]
+static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y) +{ + unsigned int e, i,px; + unsigned int ex, ex2, ex3; + unsigned int ke, ki; + unsigned int ts, td; + + int nextOutputLine = output->linesize[0];
this is wrong, nextOutputLine is used as an index into a uint32_t * while linesize is byte based, it thus needs a /4 also the implementation works with RGB/BGR32 but query_formats() asks for AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24 this should instead be AV_PIX_FMT_RGB32, AV_PIX_FMT_BGR32 to match the /4 for linesize and the uint32_t otherwise ifAV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24 is left its more tricky
+ + for (int y = 0; y < input->height; y++) { + + uint32_t pprev; + uint32_t pprev2; + + uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 2); + + /* middle. the -2 just makes the offsets later on work out */
+ uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 2);
the - 2 is similarly wrong as input->data[0] is byte and not pixel based, it should be a 4*2
+ /* up one */ + uint32_t * sa1 = sa2 - input->linesize[0]; + /* up two */ + uint32_t * sa0 = sa1 - input->linesize[0]; + /* down one */ + uint32_t * sa3 = sa2 + input->linesize[0]; + /* down two */ + uint32_t * sa4 = sa3 + input->linesize[0];
these are wrong the other way around and need /4 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
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@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@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...
C++, 2xBR v3.3b, GPL
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xb...
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@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@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/xb...), 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@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
+@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@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
On Sat, Nov 8, 2014 at 2:56 AM, Michael Niedermayer <michaelni@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@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@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...
C++, 2xBR v3.3b, GPL
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xb...
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@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@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/xb... ),
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@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
+@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@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 RRGGBBAA. I tried with AARRGGBB also. Neither of the two are giving the desired results.
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
arwa arif <arwaarif1994 <at> gmail.com> writes:
How is RGB32 stored?
It is BGRA for little endian and ARGB for big endian. Use a colourspace with "A" if your filter correctly deals with transparency, "0" if your filter does not output the same alpha information as the input has. You can allow both if the filter copies transparency correctly but does not need it. Carl Eugen
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@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@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@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...
C++, 2xBR v3.3b, GPL
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xb...
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@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@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/xb... ),
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@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
+@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@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 ..."
On Sat, Nov 08, 2014 at 05:12:13PM +0530, arwa arif wrote: [...]
+static int df(uint32_t x, uint32_t y, const uint32_t *r2y) +{ + +#define YMASK 0xff0000 +#define UMASK 0x00ff00 +#define VMASK 0x0000ff + + uint32_t yuv1 = r2y[x & 0xffffff]; + uint32_t yuv2 = r2y[y & 0xffffff]; + + return abs((yuv1 & YMASK) - (yuv2 & YMASK)) > (48 << 16) || + abs((yuv1 & UMASK) - (yuv2 & UMASK)) > ( 7 << 8) || + abs((yuv1 & VMASK) - (yuv2 & VMASK)) > ( 6 << 0);
the "> some constant" is wrong the new code expects this to be a scalar not a boolean adding the 3 absolute differences together should work better [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates
participants (3)
-
arwa arif -
Carl Eugen Hoyos -
Michael Niedermayer