Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th November 2012, 09:06   #1  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
FineSharp for VapourSynth

I ported Didée's FineSharp script to VapourSynth.

https://gist.github.com/chikuzen/6103665

requirement:
VapourSynth r19 or later
RemoveGrain.dll
Repair.dll

usage:
at first, download (or copy/paste to your texteditor) and put it to python3.3/Lib/site-packages as 'finesharp.py'.
Code:
import vapoursynth as vs
import finesharp
core = vs.get_core()
core.avs.LoadPlugin('/path/to/RemoveGrain.dll')
core.avs.LoadPlugin('/path/to/Repair.dll')
clip = something
fs = finesharp.FineSharp()
clip = fs.sharpen(clip, other options...)
new version:

finesharp 2016.08.21, updated for Vapoursynth R33, ~10% faster for 8bit input, no difference for 16bit. Note it requires Vapoursynth R33 or more recent.
__________________
my repositories

Last edited by Wilbert; 21st August 2016 at 18:22.
Chikuzen is offline   Reply With Quote
Old 28th July 2013, 19:36   #2  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Code:
return self.std.Lut2([c1, c2], lut, planes)
should be
Code:
return self.std.Lut2([c1, c2], planes=planes, lut=lut)
Your patch to add function evaluation to lut changed the order of the arguments so use named arguments instead.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 28th July 2013, 21:24   #3  |  Link
buchanan
Registered User
 
Join Date: Feb 2013
Location: France
Posts: 23
Chikuzen,

I applied the modifications you described here and got the filter working with VS R19 RC2, however here is the result:

Input :


Output ( vid=fs.sharpen(vid,sstr=0.7) )
buchanan is offline   Reply With Quote
Old 29th July 2013, 12:25   #4  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
updated first post link and example.

__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 22nd October 2013, 17:59   #5  |  Link
buchanan
Registered User
 
Join Date: Feb 2013
Location: France
Posts: 23
Hello !

Using FineSharp with this r21 test version of Vapoursynth produces this strange result :

Input


Output
buchanan is offline   Reply With Quote
Old 22nd October 2013, 19:15   #6  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Quote:
Originally Posted by buchanan View Post
Hello !

Using FineSharp with this r21 test version of Vapoursynth produces this strange result :

Input


Output
I made a typo in the asm. I'll put up a fixed version tomorrow.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 22nd October 2013, 19:34   #7  |  Link
sl1pkn07
Pajas Mentales...
 
Join Date: Dec 2004
Location: Spanishtán
Posts: 442
this plugin work with the internal vsremovegrain?

greetings
sl1pkn07 is offline   Reply With Quote
Old 22nd October 2013, 19:50   #8  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
If you fix the syntax, sure thing it will. It only uses the blur modes from removegrain, the ones that are implemented in vapoursynth version.
Are_ is offline   Reply With Quote
Old 22nd October 2013, 19:57   #9  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Quote:
Originally Posted by Are_ View Post
If you fix the syntax, sure thing it will. It only uses the blur modes from removegrain, the ones that are implemented in vapoursynth version.
Whoever does those changes should change it to use gray format for the masks at the same time. No reason to waste memory on that.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 16th December 2014, 14:45   #10  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
I updated it to make use of native filters only, to use gray format for all the filtering, and also ditched the class, so it should be easier to use.
Now it also supports 8, 9, 10 and 16 bits.

finesharp 2014-12-17

requirement:
VapourSynth r23 or later

Usage:
Download (or copy/paste to your texteditor) and put it in python3.4/Lib/site-packages as 'finesharp.py'.
Code:
import vapoursynth as vs
import finesharp
core = vs.get_core()
...
clip = something
clip = finesharp.sharpen(clip, other options...)

Last edited by Are_; 17th December 2014 at 18:36. Reason: updated
Are_ is offline   Reply With Quote
Old 16th December 2014, 14:49   #11  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Quote:
Originally Posted by Are_ View Post
I updated it to make use of native filters only, to use gray format for all the filtering, and also ditched the class, so it should be easier to use.

finesharp 2014-12-16

requirement:
VapourSynth r23 or later

...
If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet

Last edited by Myrsloik; 16th December 2014 at 14:52. Reason: I was wrong
Myrsloik is offline   Reply With Quote
Old 16th December 2014, 14:52   #12  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
Unfortunately it does not, because I'm not smart enough to fix the code for that.
Are_ is offline   Reply With Quote
Old 16th December 2014, 15:14   #13  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Los Angeles, California
Posts: 2,119
it's not that hard actually,
maybe take the original avs script as reference would be much easier
it's almost a copy paste styleee work
sstr = string (sstr) ----- sstr = repr (sstr)
mt_lutxy (c,b,xxxxxxxx) ---- core.std.Expr ([c,b],["xxxxxxx"])
and to make the 8bpc expr work at 16bpc
x ----- x 256 /
y ----- y 256 /
z ----- z 256 /
and add 256 * at the end of the expr
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 16th December 2014, 20:30   #14  |  Link
buchanan
Registered User
 
Join Date: Feb 2013
Location: France
Posts: 23
Quote:
Originally Posted by Myrsloik View Post
If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.
Just tried with a 10bit clip, it still throws an error "Clip must be 8bit YUV"
buchanan is offline   Reply With Quote
Old 16th December 2014, 21:45   #15  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
Quote:
Originally Posted by Myrsloik View Post
If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.
Quote:
Originally Posted by buchanan View Post
Just tried with a 10bit clip, it still throws an error "Clip must be 8bit YUV"
Yeah it works, but it adds like 20/30 of startup, I didn't permit it for that reason, but I suppose I can change that check.

I tried what you said Myrsloik, but the output was not the same, more grainy, I guess my expresion sucked and I gave up. I will keep at it another day.

Thanx for the tips feisty2, when I have a chance I will try to make it work that way. Btw, you don't need to convert anything to strings in python, that's an avisynth limitation when dealing with strings. In python you do something like:
Code:
'x y %r - +' % (thr)
with positional arguments or
Code:
'x y {thr} - +'.format(thr=thr)
with named arguments.
Are_ is offline   Reply With Quote
Old 16th December 2014, 22:24   #16  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,021
.format() is the preferred way to do string formatting in Python 3, the % notation is a Python 2 backwards compatibility thing. You can use .format() with positional arguments too, just use empty brackets:
Code:
'x y {} - +'.format(thr)

Last edited by TheFluff; 16th December 2014 at 22:28.
TheFluff is offline   Reply With Quote
Old 17th December 2014, 18:43   #17  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
Updated to support 8, 9, 10 and 16 bits.

Is it normal for expr to not run multithreaded? Or it looks like it:
Code:
No filtering:   ~1700 fps, all cores about 50%
finesharp lut:   ~400 fps, all cores about 50%
finesharp expr:   ~50 fps, one core maxed out, all the other cores almost dormant
Are_ is offline   Reply With Quote
Old 17th December 2014, 23:25   #18  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Quote:
Originally Posted by Are_ View Post
Updated to support 8, 9, 10 and 16 bits.

Is it normal for expr to not run multithreaded? Or it looks like it:
Code:
No filtering:   ~1700 fps, all cores about 50%
finesharp lut:   ~400 fps, all cores about 50%
finesharp expr:   ~50 fps, one core maxed out, all the other cores almost dormant
Expr can only run on one core at a time and it's fairly slow. All the other functions are most likely a lot faster so it ends up bottlenecking everything.

One day I'm going to use runtime code generation. It's the only way to get good speeds out of this kind of filter...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 6th September 2015, 10:57   #19  |  Link
stax76
staxrip & mpv.net
 
Join Date: Jun 2002
Posts: 5,248
has anybody updates the script?

Code:
diff = self.Lut2([clip, c2], function=expr, planes=0)
Code:
Python exception: Lut2: argument clipa is not of array type but more than one value was supplied
Traceback (most recent call last):
  File "vapoursynth.pyx", line 1467, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:24719)
  File "D:\Temp\Encoding\test temp files\test.vpy", line 7, in <module>
    clip = finesharp.FineSharp().sharpen(clip = clip)
  File "D:\Projekte\GitHub\staxrip\bin\Apps\Plugins\vs\finesharp\finesharp.py", line 148, in sharpen
    diff = self.Lut2([clip, c2], function=expr, planes=0)
  File "vapoursynth.pyx", line 1366, in vapoursynth.Function.__call__ (src\cython\vapoursynth.c:23214)
vapoursynth.Error: Lut2: argument clipa is not of array type but more than one value was supplied
__________________
I have a dream by Martin Luther King
one hundred years later...
We can never be satisfied...
With this faith...
Let freedom ring...
stax76 is offline   Reply With Quote
Old 6th September 2015, 11:36   #20  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 258
Yes, in this very same page
Are_ is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.