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 22nd September 2015, 01:37   #1  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
nnedi3_rpow2 function for VapourSynth

Since jackoneill moved his nnedi3_rpow2 function to /dev/null, I decided to take the plunge and write my own function in python : https://gist.github.com/YamashitaRen...7524e794779d9c
The nnedi3 plugin is required for nnedi3_rpow2 : http://forum.doom9.org/showthread.php?t=166434
The znedi3 plugin is required for znedi3_rpow2 : https://github.com/sekrit-twc/znedi3
The nnedi3cl plugin is required for nnedi3cl_rpow2 : https://forum.doom9.org/showthread.php?t=174902
The eedi2 plugin is required for eedi2_rpow2 : http://forum.doom9.org/showthread.php?t=171136

It has been greatly inspired by jackoneill's plugin.

Shifted output should be correct but I'm no expert in programming and function hadn't been tested extensively so you never know...
Comparisons with zimg/fmtconv/old_nnedi3_rpow2 are warmly welcome.

Usage is :
Code:
nnedi3_rpow2(clip,rfactor,correct_shift="zimg",nsize=0,nns=3,qual=1,etype=0,pscrn=2,opt=True)
znedi3_rpow2(clip,rfactor,correct_shift="zimg",nsize=0,nns=3,qual=1,etype=0,pscrn=2,opt=True)
nnedi3cl_rpow2(clip,rfactor,correct_shift="zimg",nsize=0,nns=3,qual=1,etype=0,pscrn=2,opt=True)
eedi3_rpow2(clip,rfactor,correct_shift="zimg",alpha=0.2,beta=0.25,gamma=20,nrad=2,mdis=20,hp=0,ucubic=1,cost3=1,vcheck=2,vthresh0=32,vthresh1=64,vthresh2=4,sclip=None)
eedi2_rpow2(clip,rfactor,correct_shift="zimg",mthresh=10,lthresh=20,vthresh=20,estr=2,dstr=4,maxd=24,map=0,nt=50,pp=1)
By default it corrects the shift with "zimg".
It can correct it with "fmtconv" too.
Or it can not correct it if you use another value.

Example :
Code:
import vapoursynth as vs
import edi_rpow2 as edi
core = vs.get_core()
clip = yourclip
clip = core.resize.Bicubic(clip=clip,format=vs.YUV420P16,dither_type="error_diffusion")
clip = edi.znedi3_rpow2(clip=clip,rfactor=2)
clip = core.resize.Spline36(clip=clip,width=clip.width*2/3,height=clip.height*2/3)
edi_rpow2.py has to be in the site-packages directory of your python3 path.

Last edited by YamashitaRen; 21st May 2018 at 23:19. Reason: Update.
YamashitaRen is offline   Reply With Quote
Old 22nd September 2015, 14:47   #2  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 322
Well, I did some test and found:
- If input bits > 8 errors out about nnedi3 parameters, consider using None for dynamic parameters.
- Output is always 8 bit regardless the bitdepth of the input.
- If rfactor >= 8 outputs has incorrect dimensions, like one step to big.

I coded (too, doh) this script in python but never uploaded it, but I did a very literal translation form the .cpp code, not sure if it is right or not, I felt like a monkey lol.
Output as far as I know is exact to the original, just in case you want to check it against yours.
Are_ is offline   Reply With Quote
Old 22nd September 2015, 15:04   #3  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Thanks for your feedback !

1) Okay, I'll try that.
2) Wow, forgot that we're living in a world where 8 bits isn't "everything".
3) Curious, I'll have to investigate that.

Thanks for your script, it will indeed be interesting to look at it.

edit :
1) and 2) are fixed
edit :
3) is fixed

Last edited by YamashitaRen; 23rd September 2015 at 16:49.
YamashitaRen is offline   Reply With Quote
Old 23rd September 2015, 16:53   #4  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Wow, shame on me, 3) was a maths mistake !
Shift wasn't corrected too. Reason : http://stackoverflow.com/questions/1...nd-powers-math

Now everything "should" be fine, thanks again for your advices
YamashitaRen is offline   Reply With Quote
Old 14th October 2015, 15:58   #5  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
eedi3_rpow2 and eedi2_rpow2 functions have been added
I'm using the same old "correct_shift" for all the functions. Hope it will be... correct.
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1
YamashitaRen is offline   Reply With Quote
Old 26th January 2016, 21:47   #6  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
You're missing the parameters to set new height and width of the video
lansing is offline   Reply With Quote
Old 28th January 2016, 09:06   #7  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
You can use core.resize
Don't forget to process in 16bits, so you will not lose any precision.
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1

Last edited by YamashitaRen; 28th January 2016 at 09:17.
YamashitaRen is offline   Reply With Quote
Old 20th February 2017, 00:00   #8  |  Link
DJ-1
Registered User
 
Join Date: May 2009
Posts: 328
So what's the deal with resizing here?
In the avisynth version off nnedi3 resize also have a option of secondary scale..i.e: spline , Lanczsos, Gauss etc etc

Here just shows core.resize nnedi3 rprow2 line with Lanzsos.

What are the main differences between how this works and how the avisynth did?
Cheers.

Sent from my HTC 10 using Tapatalk

Last edited by DJ-1; 11th May 2017 at 11:37.
DJ-1 is offline   Reply With Quote
Old 20th February 2017, 11:58   #9  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Avisynth version may resize the image and shift the subpixels at the same time.

Here you double your image resolution with nnedi3_rpow2 then scale back the image to the resolution of your choice with the filter of your choice (could be fmtc.resample or core.resize).
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1

Last edited by YamashitaRen; 20th February 2017 at 12:05.
YamashitaRen is offline   Reply With Quote
Old 15th May 2017, 08:44   #10  |  Link
DJ-1
Registered User
 
Join Date: May 2009
Posts: 328
Does this include the rpow2 c-shift that the avisynth version did?

I don't see c-shift in the script

Cheers.

Sent from my HTC_M10h using Tapatalk
DJ-1 is offline   Reply With Quote
Old 15th May 2017, 08:48   #11  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Yeah there is no cshift. Though there is a correct_shift argument...
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1
YamashitaRen is offline   Reply With Quote
Old 15th May 2017, 08:50   #12  |  Link
DJ-1
Registered User
 
Join Date: May 2009
Posts: 328
I assume that's the vapoursynth equal to the old avisynth thing then?
Basically re centre the chrome offset?
Cheers.

Sent from my HTC_M10h using Tapatalk
DJ-1 is offline   Reply With Quote
Old 15th May 2017, 08:51   #13  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Yeah, it's the name I used for that.

Btw, default mode is now zimg since it's bundled with vapoursynth.
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1

Last edited by YamashitaRen; 15th May 2017 at 08:53.
YamashitaRen is offline   Reply With Quote
Old 15th May 2017, 09:19   #14  |  Link
DJ-1
Registered User
 
Join Date: May 2009
Posts: 328
Is that correct-shift argument auto done under the hood? ( unseen in the script) or is it just the gui I using not have it implement maybe?

Should I see it in script..?

Thanks.

Sent from my HTC_M10h using Tapatalk
DJ-1 is offline   Reply With Quote
Old 15th May 2017, 11:16   #15  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
It's there : https://gist.github.com/YamashitaRen...i_rpow2-py-L75
It will be automatically used as long as you don't start tinkering with the "correct_shift" argument.
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1

Last edited by YamashitaRen; 23rd May 2018 at 00:57.
YamashitaRen is offline   Reply With Quote
Old 21st May 2018, 23:24   #16  |  Link
YamashitaRen
Registered User
 
Join Date: Apr 2014
Location: France
Posts: 33
Added znedi3 and nnedi3cl support. Thanks to Selur and theChaosCoder for forcing me to wake up from my slumber.
Went back to the original "scale the whole picture" process instead of "scale the width then scale the height" process after some talk with _08 and torque.

Archive from OP, this is the process I was using previously :
Quote:
However, I decided to "double width n times then double height n times" instead of "doubling the whole picture (width and height) n times".
It should make the function more efficient than otherwise, but it means that output will be different than old nned3_rpow2 plugin too...
If you have something against it, say it loud and clear.
__________________
Want to OCR hardsubs ? Try YoloCR : https://v.gd/wqvAF1

Last edited by YamashitaRen; 22nd May 2018 at 22:31.
YamashitaRen is offline   Reply With Quote
Old 8th November 2020, 13:16   #17  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
Is it supposed to always output 4:4:4 no matter what subsampling the input has? https://gist.github.com/YamashitaRen...i_rpow2-py-L92
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote
Reply

Tags
eedi2, eedi3, nnedi3, rpow2, upscale

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 10:51.


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