GNOME Bugzilla – Bug 163578
[PATCH] Deinterlacer plugin
Last modified: 2008-06-11 11:11:33 UTC
I've ported dscaler/tvtime deinterlacer methods to gstreamer. Not all methods are supported by now. TomsMoComp and Greedy give some great results already. Make sure u have an x86 box if u like to give it a try. (There are no C fallbacks in the code i ported :( ) and set the tff/fields properties on the plugin. For now the plugin is called deinterlace2. See eikermann.afraid.org/dscaler for some sample images.
Created attachment 35786 [details] the plugin
Adding dep on bug 163577, as we should probably finish RFC first before we can consider this plugin complete
How's the license? Billy's dscaler code is GPL, IIRC. We don't accept GPL code in gst-plugins CVS.
Yes it's GPL. Someone with a bunch of good arguments should ask him to relicense. I'm just not smart enough to port deinterlacers ;-). For the time being it's just fine in here or gst-sandbox. btw, we must ask tvtime devels too. They did quite some inline assembler porting job.
Just to update on this one, I am trying to get hold of Billy Biggs to get this relicensed to LGPL, I think he will say yes, but he seems unavailable atm. I will update this report as soon as I get a reply.
Originally the deinterlacer methods come from DScaler, developed by Tom Barry and John Adcock. TvTime developers ported Tom and Johns "TomsMoComp" and Greedy methods to Linux. So we need to ask: ----------------- For the original deinterlace methods: * Tom Barry <trbarry@trbarry.com>, * John Adcock <john at adcock8 dot freeserve dot co dot uk> DScaler developers run a support forum at sf.net. And request everyone to post their inquiries in there. From what I can see John Adcock answers to questions regulary. DScaler Forum: http://deinterlace.sourceforge.net/phpBB/viewforum.php?f=1 Files that are ports based on their initial implementation and carry their copyright: - plugins/greedyhmacros.h - plugins/greedy.c - plugins/greedyh.asm - plugins/tomsmocomp/* For TvTime in general and most of its deinterlacer methods: * Billy Biggs <vektor@dumbterm.net>: - plugins/kdetv_greedyh.c - plugins/kdetv_tomsmocomp.c - plugins/weave.c - plugins/weavetff.c - plugins/tomsmocomp.c - plugins/tomsmocomp.h - plugins/plugins.h - plugins/weavebff.c - plugins/linear.c - plugins/vfir.c - plugins/scalerbob.c - plugins/speedy.c - plugins/speedy.h - plugins/speedtools.h - plugins/greedy.c - plugins/greedyh.c - plugins/greedyh.h Matthew J. Marjanovic <maddog@mir.com>: plugins/speedy.c If linearblend is a benefit, also: ---------------------------------- A deinterlacing method originally for mplayer. * Michael Niedermayer (michaelni@gmx.at): - plugins/linearblend.c Code to be removed before inclusion: ------------------------------------ Stefan Jahn <stefan@lkcc.org>: plugins/speedy.c In particular the code for UYVY to YUYV conversion routine originally taken from rivatv. (rivatv-convert.c video image conversion routines) (This conversion routines can be dropped: Not used. But it's still in there) Others: ------- Aaron Holtzman <aholtzma@ess.eng r.uvic.ca> (libmpeg2): Michel Lespinasse <walken@zoy.org> (libmpeg2): plugins/cpu_accel.c plugins/mmx.h plugins/mm_accel.h plugins/attributes.h (These files contain cpu detection code and preprocessor defined SIMD routines. I already found a very similar file with copyright from H. Dietz and R. Fisher in case they'd deny relicensing. e.g. here: https://cvs.comedi.org/cgi-bin/viewcvs.cgi/opts/mmx.h?rev=1.1 &content-type=text/vnd.viewcvs-markup. No GPL header in this one, must be public domain then.) Cheung Auyeung <auyeung@mot.com>: plugins/speedy.c (Don't think it is necessary to ask him as the copyright statement basically says: Do what you want but include this disclaimer.)
Created attachment 36080 [details] new version removed the gpl code originally taken from libmpeg2 and replaced it with a free version
Some of the algorithms and code that I wrote I have relicensed elsewhere under the MIT license, and I'm definitely in favour for that. However, the DScaler stuff will be more tricky, since it's GPL'ed for sure and there are more authors than what you listed. Dirk Ziegelmeier of kdetv is the guy who did the gcc asm port of the dscaler filters, so he's probably the most important contact. I can probably tell you where all of the code comes from and maybe help rewrite parts. You can contact me on irc.freenode.net as 'vektor'.
Ok, I mailed Dirk Ziegelmeier, Michael Niedermayer, Tom Barry and John Adcock asking for permission.
Got the following reply from John Adcock: Christian I'm happy to relicence my deinterlace stuff (which in this case is the greedy method) under the LGPL. It's up to Tom for the MoComp stuff. Also note that there is a new method Diag in the Dscaler5 tree that is LGPL. John
Got this from Dirk Ziegelmeier: Hello GStreamer folks, I have no objections against relicensing my porting work of any DScaler deinterlacer/filter to LGPL! Also feel free to look around in kdeextragear-3/kdetv for an image filter (Sharpness) I ported from DScaler (the other filters are trivial, but if you want, take them after asking the original authors for relicensing permission. Dirk Ziegelmeier
Got this from Tom Barry Hi Christian - I'm the author of the Greedy (High Motion), Greedy (Low Motion), and TomsMoComp deinterlacer functions. And LGPL is fine with me. That is also true of the Avisynth versions if they are any easier to port for some reason (still asm, www.trbarry.com ). - Tom
Martin, I mailed with Michael Niedermayer and he says there is no linearblend.c. So I guess this code is removed. Or is it something we might want to include, if so do you have a link to it somewhere that I can show Michael?
Ok, following update from Michael Niedermayer: > sorry, theres no linearblend.c in either of the 2 attachments but if you are talking about linearblend.c from tvtime cvs, I am pretty certain that i havnt written any part of it, the code is quite inefficient ..., anyway, in case there are any parts in linearblend.c (http://cvs.sourceforge.net/viewcvs.py/tvtime/tvtime/plugins/linearblend.c?rev=1.16&view=markup) i did write, i am gladly relicensing them under LGPL herewith -- Michael
To be clear, any code that I wrote I am also willing to relicense under the LGPL. One thing I would like for this filter is to make sure the diff to the tvtime upstream code is as small as possible, and ideally nothing, so that we can easily share code. If you are going to rip out the rivatv code, I would rather split it into a different file in tvtime upstream to make the diff smaller. Some other things I noticed in the filter code: - the vfir filter code is inspired from ffmpeg sources, but Uraeus says this is LGPL anyway. - there is memcpy code in speedy.c inspired by xine, mplayer, and the linux kernel - diff and comb factor code in speedy.c I think is from DScaler, but I was playing around with this a bunch
Created attachment 36375 [details] new version (0.0.3) * streamlined code * new methods: Greedy Low Motion, Vertical Blur (vfir) * made tff (top field first) property an enum (auto, tff, bff)
Martin and Billy, with planned rewrites etc. included, are there any more permissions we need? Or are the current permissions + planned rewrites enough to make this all LGPL?
We should have all permissions we need. Billy is going to split out the last GPL code from speedy.c upstream. Billy: In #15 u mentioned the diff/comb factor code. Was DScaler source of inspiration or copy?
Some of those functions are a direct port of the diff/comb functions in FD_CommonFunctions.asm in DScaler.
Hi Martin, I playing around with this (trying to add some tvtime-/dscaler-like deinterlace function to the TV-display function of Cupid - no worries Billy ;) ). Here´s some comments: * tff=0 (default) doesn´t work. Just play around with it, the result looks horrible (like a shaky picture as if frame orders were randomly inversed the wrong way). Also, it´s very slow. Tff=1/2 work fine. Rename it to field-order to make it clear or so... * some docs on the differences (technically, or in cpu-use or result or whatever) between the different dinterlacing methods would be nice, it´s complete black magic to me so I don´t know what to choose. * If you want, feel free to patch to remove deinterlace from CVS (and rename this to deinterlace), this seems to work a *lot* better (I really, really like it). * change License to LGPL. ;).
Hmmm, sure it's the fault of tff. There is a known issue with the greedy low motion method. tff=0 will default to tff=1 before any deinterlacing done, since there is no notation of field-order in caps or somewhere else yet. I still hesitate to make a patch and replace the old deinterlace plugin cause there are no C fallback routines (except Greedy Low Motion, IIRC) and there are definitly some arch-portability preprocessor macros missing. Billy is currently working to split out the last bit of GPL code. I'll work on that patch so we can replace the old deinterlace plugin soon.
We should re-open work on this code for 0.9, now that we're free to add properties to caps and stuff. Did the work to split out memcpy/other-GPL code from speedy.c ever happen?
Martin and Billy, where are we on this? Is this LGPL and ready to go into 0.8? (and also ready to be ported to 0.9)
Is the version from comment #16 really the latest? I haven't done any work to replace bits of GPL code. What do you really need from me here. Is there a more recent patch?
Billy I think the current blocker is that we *still* don't have adequate notation for top/bottom frames in GStreamer. Not sure about the status of the patch -- probably should look into remerging with upstream when someone gets around to looking at this again.
Billy, my impression was that the GPL code in this patch at this point where only stuff from tvtime. You said at some point that you would prefer to rewrite the code to make it cleaner/shareable instead of just say 'ok' on relicensing the tvtime code. Is this still your stance?
Is there any progress happening in this case? If people do not have enough time for rewriting maybe for now relicensing and adaption of the current code should be targeted?
Tim just ported the gst-deinterlace plugin to 0.10 . It's available in gst-plugins-bad. 2006-10-11 Tim-Philipp Müller <tim at centricular dot net> * configure.ac: * gst/deinterlace/Makefile.am: * gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_base_init), (gst_deinterlace_class_init), (gst_deinterlace_init), (gst_deinterlace_stop), (gst_deinterlace_transform_caps), (gst_deinterlace_set_caps), (gst_deinterlace_transform_ip), (gst_deinterlace_set_property), (gst_deinterlace_get_property): * gst/deinterlace/gstdeinterlace.h: Port simple deinterlacer from 0.8. Use at your own risk, don't blame me for anything it does or does not do to your precious pictures.
The simple deinterlace-plugin isn't comparable with the tvtime-algorithms, this patch uses, they are ways better in quality.
Ok, it's committed to gst-plugins-bad and ported to gstreamer 0.10 now. Still not build or enabled by default as there are some bugs left and it can be built on x86 only atm. 2008-06-11 Sebastian Dröge <slomo@circular-chaos.org> Based on a patch by: Martin Eikermann <meiker at upb dot de> * gst/deinterlace2/Makefile.am: * gst/deinterlace2/gstdeinterlace2.c: (gst_deinterlace2_method_get_type), (gst_deinterlace2_fields_get_type), (gst_deinterlace2_field_layout_get_type), (gst_deinterlace2_base_init), (gst_deinterlace2_class_init), (gst_deinterlace2_init), (gst_deinterlace2_set_method), (gst_deinterlace2_set_property), (gst_deinterlace2_get_property), (gst_deinterlace2_finalize), (gst_deinterlace2_pop_history), (gst_deinterlace2_head_history), (gst_deinterlace2_push_history), (gst_deinterlace2_deinterlace_scanlines), (gst_deinterlace2_chain), (gst_deinterlace2_setcaps), (gst_deinterlace2_sink_event), (gst_deinterlace2_change_state), (gst_deinterlace2_src_event), (gst_deinterlace2_src_query), (gst_deinterlace2_src_query_types), (plugin_init): * gst/deinterlace2/gstdeinterlace2.h: * gst/deinterlace2/tvtime/greedy.c: (copy_scanline), (deinterlace_greedy_packed422_scanline_mmxext), (dscaler_greedyl_get_method): * gst/deinterlace2/tvtime/greedyh.asm: * gst/deinterlace2/tvtime/greedyh.c: (deinterlace_frame_di_greedyh), (dscaler_greedyh_get_method), (greedyh_init), (greedyh_filter_mmx), (greedyh_filter_3dnow), (greedyh_filter_sse): * gst/deinterlace2/tvtime/greedyh.h: * gst/deinterlace2/tvtime/greedyhmacros.h: * gst/deinterlace2/tvtime/mmx.h: * gst/deinterlace2/tvtime/plugins.h: * gst/deinterlace2/tvtime/speedtools.h: * gst/deinterlace2/tvtime/speedy.c: (multiply_alpha), (clip255), (comb_factor_packed422_scanline_mmx), (diff_factor_packed422_scanline_c), (diff_factor_packed422_scanline_mmx), (diff_packed422_block8x8_mmx), (diff_packed422_block8x8_c), (packed444_to_packed422_scanline_c), (packed422_to_packed444_scanline_c), (packed422_to_packed444_rec601_scanline_c), (vfilter_chroma_121_packed422_scanline_mmx), (vfilter_chroma_121_packed422_scanline_c), (vfilter_chroma_332_packed422_scanline_mmx), (vfilter_chroma_332_packed422_scanline_c), (kill_chroma_packed422_inplace_scanline_mmx), (kill_chroma_packed422_inplace_scanline_c), (invert_colour_packed422_inplace_scanline_mmx), (invert_colour_packed422_inplace_scanline_c), (mirror_packed422_inplace_scanline_c), (interpolate_packed422_scanline_c), (convert_uyvy_to_yuyv_scanline_mmx), (convert_uyvy_to_yuyv_scanline_c), (interpolate_packed422_scanline_mmx), (interpolate_packed422_scanline_mmxext), (blit_colour_packed422_scanline_c), (blit_colour_packed422_scanline_mmx), (blit_colour_packed422_scanline_mmxext), (blit_colour_packed4444_scanline_c), (blit_colour_packed4444_scanline_mmx), (blit_colour_packed4444_scanline_mmxext), (small_memcpy), (speedy_memcpy_c), (speedy_memcpy_mmx), (speedy_memcpy_mmxext), (blit_packed422_scanline_c), (blit_packed422_scanline_mmx), (blit_packed422_scanline_mmxext), (composite_colour4444_alpha_to_packed422_scanline_c), (composite_colour4444_alpha_to_packed422_scanline_mmxext), (composite_packed4444_alpha_to_packed422_scanline_c), (composite_packed4444_alpha_to_packed422_scanline_mmxext), (composite_packed4444_to_packed422_scanline_c), (composite_packed4444_to_packed422_scanline_mmxext), (composite_alphamask_to_packed4444_scanline_c), (composite_alphamask_to_packed4444_scanline_mmxext), (composite_alphamask_alpha_to_packed4444_scanline_c), (premultiply_packed4444_scanline_c), (premultiply_packed4444_scanline_mmxext), (blend_packed422_scanline_c), (blend_packed422_scanline_mmxext), (quarter_blit_vertical_packed422_scanline_mmxext), (quarter_blit_vertical_packed422_scanline_c), (subpix_blit_vertical_packed422_scanline_c), (a8_subpix_blit_scanline_c), (myround), (init_RGB_to_YCbCr_tables), (init_YCbCr_to_RGB_tables), (rgb24_to_packed444_rec601_scanline_c), (rgba32_to_packed4444_rec601_scanline_c), (packed444_to_rgb24_rec601_scanline_c), (packed444_to_nonpremultiplied_packed4444_scanline_c), (aspect_adjust_packed4444_scanline_c), (setup_speedy_calls), (speedy_get_accel): * gst/deinterlace2/tvtime/speedy.h: * gst/deinterlace2/tvtime/sse.h: * gst/deinterlace2/tvtime/tomsmocomp.c: (Fieldcopy), (deinterlace_frame_di_tomsmocomp), (dscaler_tomsmocomp_get_method), (tomsmocomp_init), (tomsmocomp_filter_mmx), (tomsmocomp_filter_3dnow), (tomsmocomp_filter_sse): * gst/deinterlace2/tvtime/tomsmocomp.h: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoop0A.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopBottom.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopEdgeA.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopEdgeA8.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopOddA.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopOddA2.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopOddA6.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopOddAH.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopOddAH2.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopTop.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopVA.inc: * gst/deinterlace2/tvtime/tomsmocomp/SearchLoopVAH.inc: * gst/deinterlace2/tvtime/tomsmocomp/StrangeBob.inc: * gst/deinterlace2/tvtime/tomsmocomp/TomsMoCompAll.inc: * gst/deinterlace2/tvtime/tomsmocomp/TomsMoCompAll2.inc: * gst/deinterlace2/tvtime/tomsmocomp/WierdBob.inc: * gst/deinterlace2/tvtime/vfir.c: (deinterlace_line), (deinterlace_scanline_vfir), (copy_scanline), (dscaler_vfir_get_method): * gst/deinterlace2/tvtime/x86-64_macros.inc: Add a deinterlacer plugin based on the tvtime/DScaler deinterlacer, which was relicensed to LGPL for GStreamer and in theory provides better and faster results than the simple deinterlace element. Fixes bug #163578. Ported to GStreamer 0.10 but still not enabled or included in the build system by default because of bad artefacts caused by a bug somewhere and as it can be only build on x86/amd64 ATM and requires special CFLAGS. Will be fixed soon.