View Full Version : ChromaReconstructor v3.0: restore 420/422 to (almost) native 444
Dreamland
1st January 2016, 19:55
This is only my report not criticism ..I know is very hard to make good scripts for Avisinth/Vapoursinth
feisty2
2nd January 2016, 08:47
This is only my report not criticism ..I know is very hard to make good scripts for Avisinth/Vapoursinth
well, I didn't take that as criticism, just saying, it always takes a lot to restore what has been lost, sigh, I wish chroma subsampling dead immediately (as that old obsolete design from the analog era is a piece of plain junk in the digital world, lossy compression slays chroma subsampling).
MysteryX
2nd January 2016, 15:54
well, I didn't take that as criticism, just saying, it always takes a lot to restore what has been lost, sigh, I wish chroma subsampling dead immediately (as that old obsolete design from the analog era is a piece of plain junk in the digital world, lossy compression slays chroma subsampling).
YV12 chroma subsampling is designed to increase compressability.
Are you saying that this isn't true anymore?
I'm thinking of x264-10bit... it gives HIGHER quality because compressability is a greater factor than the available data.
feisty2
2nd January 2016, 16:03
YV12 chroma subsampling is designed to increase compressability.
Are you saying that this isn't true anymore?
I'm thinking of x264-10bit... it gives HIGHER quality because compressability is a greater factor than the available data.
chroma subsampling was designed to reduce the bandwidth of analog videos
the concept of "bandwidth" does not exist in the digital world, "bitrate" takes over, and lossy compression works hell better than simply shrinking the resolution (of chroma planes) to reduce the bitrate.
MysteryX
2nd January 2016, 16:41
How do you use x264 or x265 to encode in YV24 format? At that point... YUV itself doesn't make sense, can you encode straight in RGB?
Reel.Deel
2nd January 2016, 16:46
Encoding YUV 4:4:4 is still more efficient than RGB.
sneaker_ger
2nd January 2016, 16:54
x265: input format = output format
x264: --output-csp i444
BakaProxy
3rd January 2016, 03:10
>radius=32
Is this really how you wanna live your life?
Browsing doom9 and nmm-hd all day making worthless/witty comments, wasting other people their time by requesting worthless parameters.
Then one day you manage to make something remotely interesting only to disappoint everyone even further.
Like if I need to be really honest with you this is just overdoing it and even the results look mediocre.
Don't you think it is time to stop and go outside, think about what you're doing.
In the end this is all just a hobby and we can all be happy if anyone ever uses nnedi or alike for something professional.
If you want to make something, even if it is for yourself or it is to give something back to the community, make it worthwhile or at least useful.
I wish you and everyone who might stumble upon this post a happy new year.
feisty2
3rd January 2016, 03:26
>radius=32
Is this really how you wanna live your life?
Browsing doom9 and nmm-hd all day making worthless/witty comments, wasting other people their time by requesting worthless parameters.
Then one day you manage to make something remotely interesting only to disappoint everyone even further.
Like if I need to be really honest with you this is just overdoing it and even the results look mediocre.
Don't you think it is time to stop and go outside, think about what you're doing.
In the end this is all just a hobby and we can all be happy if anyone ever uses nnedi or alike for something professional.
If you want to make something, even if it is for yourself or it is to give something back to the community, make it worthwhile or at least useful.
I wish you and everyone who might stumble upon this post a happy new year.
about the "radius=32" thing, I'd say do a test by yourself, maybe a=32 is just simply useless for general denoising but in this particular case, it is required, reduce it to 16, the quality seems a bit lower but okay still, reduce it to 8, and everything starts to go to hell,
about other comments, no one's forcing you to use it anyway so, if you don't like it, then don't use it, simple like that, that's all I'm gonna say
feisty2
3rd January 2016, 03:46
and if you have a better way of doing it (improve the quality of 42x to 444 conversion)
I'm all ears..
wonkey_monkey
3rd January 2016, 12:21
Is this really how you wanna live your life?
Who threw you a peanut? What business is it of yours if it is?
Browsing doom9 and nmm-hd all day making worthless/witty comments
I suggest you re-read your own comment in light of this statement.
For what it's worth, I've been following this thread with mild interest. While I think the filter has limited use, and I don't see myself ever using it, I can appreciate what it does from a technical point of view.
Don't you think it is time to stop and go outside, think about what you're doing.
Again, read your own post. You're being insulting and condescending for no reason other than to be insulting and condescending. If this thread insults your lofty intelligence so much, just don't read it.
I fully expect both my post and yours to be deleted, since they are the only ones in this thread which contribute nothing of any interest to the world of video processing.
BakaProxy
3rd January 2016, 15:20
Then explain to me: why is radius 32 preferred in this particular case?
And why does everything go south by lowering the radius?
I won't take "because it looks good" for an answer.
What purpose does nlmeans have in this particular case if it isn't denoising?
Maybe there are more efficient kernels for this script, who knows?
feisty2
3rd January 2016, 15:33
That's complicated, the main reason for "radius = 32" is supersampling, the same amount of actual signal got diluted to a larger resolution so larger search radius is required, think "radius = 32" on a 4x supersampled clip as "radius = 8" at the original size, the kernel is actually not nlmeans, with similarity window of nlmeans set to 0, the kernel is actually a bilateral-like filter (without the distance weighting), it's used to convey high frequencies from luma to chroma planes
feisty2
3rd January 2016, 15:44
It looks mediocre to you anyway so, why even bother to ask how it works...
BakaProxy
3rd January 2016, 16:30
I didn't say that it doesn't have potential, I'm just pointing out that your current implementation is nowhere near practical.
If you can figure out some way to make this worthwhile and still render at acceptable speed then you maybe have made something interesting.
Like can't you do the super sampling outside of nlmeans with spline,bilinear,.... or possibly create a small c plugin to replace the nlmeans "hack" you're currently using (because this is definitely not how knlmeanscl is supposed to be used) to speed things up and possibly get better results, just in overall more efficient.
And why do I bother? Because I care for you, Feisty2, my sweet prince. ;)
MysteryX
3rd January 2016, 17:55
feisty2, you have an interesting concept that brought up a great discussion. I had never thought of doing YV24 encoding before, and it's a good idea in my case, with or without this.
Now... the current implementation's performance is absolutely not usable, but the concept is good. We'll have to find a way to reproduce those results "by design" instead of "by luck". There has to be a way to implement a C plugin that would do this nicely. It for sure will bring up some ideas for either yourself or others to work on.
MysteryX
4th January 2016, 19:58
x265: input format = output format
x264: --output-csp i444
I'm trying to do it with FFMPEG.
"--output-csp i444" gives "Unrecognized option 'output-csp'"
"-profile:v high444 -pix_fmt yuv444p" works libx264 but it still says "converting clip to YV12" and "Warning: data is not aligned! This can lead to a speedloss"
"-profile:v high444 -pix_fmt yuv444p" with libx265, however, says Undefined constant or missing '(' in 'high444'
How do you do 444 encoding with FFMPEG?
MysteryX
5th January 2016, 17:12
ah... I was piping through avs2yuv and was missing -csp I444. Now it works. Comparing results.
MysteryX
5th January 2016, 19:00
About encoding to 4:4:4... x265 works good enough to replace x264 according to my tests. However, 4:2:2 and 4:4:4 encoding aren't yet ready. It says you must add "-strict experimental" to use it anyway, and the encoding crashed on me.
As for what would provide the best result to upscale Chroma, it might be better to implement a solution that starts from the original YV12 data and work from it to upscale it, instead of taking already-converted YV24 data and trying to process it.
feisty2
7th January 2016, 16:16
v2.2: new parameter "mode", mode=0 for 4:2:0 and mode=1 (vertical filtering disabled) for 4:2:2
wonkey_monkey
7th January 2016, 17:20
As for what would provide the best result to upscale Chroma, it might be better to implement a solution that starts from the original YV12 data and work from it to upscale it, instead of taking already-converted YV24 data and trying to process it.
It does start from the original YV12 data. I don't think there's anything "invalid" about the first step being to convert to YV24, even if it is "lossy" in a way that, say, 8-bit to 16-bit isn't. The chroma needs to be resited anyway - it's not like any of the "original" chroma pixels can survive in-place.
Overdrive80
9th January 2016, 00:38
On special pattern, the chroma restaured picture has halo on colon, is it normal for limitations on conversion, isn't??
Thanks for you work.
jinkazuya
9th January 2016, 07:33
Just wonder how to use the script? Whenever I tried using it, error message always popped up stating "There is no function named KNLMeansCL.dll" Then I located this within the website and found it but when I tried to reload it again, another error message popped up saying "The module was not found, library missing?" Here is the unfinished basic avisynth script
LoadPlugin("C:\Users\Jinkazuya\Desktop\MeGui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("C:\Users\Jinkazuya\Desktop\Encoded Videos\01\VIDEO_TS\VTS_01_1.d2v", cpu=4, info=3)
LoadPlugin("C:\Users\Jinkazuya\Desktop\MeGui\tools\avisynth_plugin\ColorMatrix.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RgTools.dll")
Import("C:\Program Files (x86)\AviSynth 2.5\plugins\ChromaReconstructor.avs")
ColorMatrix(hints=true, threads=0)
#deinterlace
crop( 4, 0, -10, 0)
LanczosResize(640,480) # Lanczos (Sharp)
#denoise
converttoyv12()
converttoyv24()
Dither_convert_8_to_16()
ChromaReconstructor(16)
Groucho2004
9th January 2016, 10:22
Just wonder how to use the script? Whenever I tried using it, error message always popped up stating "There is no function named KNLMeansCL.dll" Then I located this within the website and found it but when I tried to reload it again, another error message popped up saying "The module was not found, library missing?"
You're most likely missing the "Visual C++ Redistributable Package for Visual Studio 2013". See the first post in the KNLMeansCL thread (http://forum.doom9.org/showthread.php?t=171379).
jinkazuya
9th January 2016, 16:37
You're most likely missing the "Visual C++ Redistributable Package for Visual Studio 2013". See the first post in the KNLMeansCL thread (http://forum.doom9.org/showthread.php?t=171379).
Yes. I do have this package installed in my computer.
feisty2
14th January 2016, 10:18
v3.0 major update, new parameter "hipass" allows you to manipulate the strength of the high frequency extraction, a new less aggressive (and a lot slower) method could be enabled when luma is not stable enough (set "wild" to False)
ispano
16th January 2016, 23:48
Wanted to say a quick thx feisty for your work on this. I'm super happy with the results in madvr and the fact I won't need to re-encode in 444. :)
De-M-oN
17th January 2016, 23:42
Spline16 is an over sharpening (unbalanced) kernel
Are you sure you're not confuse it with Spline64?
Because 16 is rather a soft scaler.
http://svn.int64.org/viewvc/int64/resamplehq/doc/kernels.html
__
Could this help with my problem?
http://forum.doom9.org/showthread.php?t=172647
I mean: If it can fill up the gaps caused by the nearest neighbor chroma scaling again with color ( I dont mind bloating it up back to RGB, I just dont want the colorless pixels) so I thought your plugin could maybe apply the interpolation by upsampling it in???
wonkey_monkey
18th January 2016, 00:37
How fast is ChromaReconstructor, approximately?
I'm without a proper computer right now, so a) I can't try it for myself and b) I've been thinking about all different kinds of filters while I can't do any work on anything. If it's fast, then no need for me to continue thinking what I'm thinking.
Are_
18th January 2016, 01:01
I didn't really test this version, but somewhat in the order of seconds per frame.
Reel.Deel
18th January 2016, 01:12
How fast is ChromaReconstructor, approximately?
Too slow to be practical, with default settings on full HD I get 0.024 fps and 0.096 fps on 960x540.
SSH4
21st January 2016, 04:39
Is this script must work in Avisynth+ r1576?
ChromaReconstructor_faster work, at least result different from source. Eedi version (without LSB) from this thread work too.
But script from first post do nothing.
All scripts tested on source PNG from first post.
caiyuwei
23rd January 2016, 20:16
Can anyone please help me to re-up support 8bits version?
bxyhxyh
23rd January 2016, 21:41
Can anyone please help me to re-up support 8bits version?
Calling Dither_convert_8_to_16() before you call ChromaReconstructor() and call Ditherpost(mode=6) after that will do the trick
caiyuwei
24th January 2016, 02:07
Calling Dither_convert_8_to_16() before you call ChromaReconstructor() and call Ditherpost(mode=6) after that will do the trick
Thank you so much for your experience.
By the way, I got error "There is no function named KNLMeansCL"
I'm using Avisynth+ r1825 and KNLMeansCL v0.6 :(
bxyhxyh
24th January 2016, 11:23
If your KNLMeansCL correctly loaded. (Loaded in script or placed in plugins directory)
It is maybe similar issue to this (https://www.doom9.org/showthread.php?p=1737277#post1737277)
StainlessS
24th January 2016, 12:14
Here same link as above post, but without any security warning ('untrusted domain' or something like that).
http://forum.doom9.org/showthread.php?p=1737277#post1737277
EDIT: If you just remove 's' from 'https:\\' you get a 404, Not Found.
caiyuwei
25th January 2016, 08:05
If your KNLMeansCL correctly loaded. (Loaded in script or placed in plugins directory)
It is maybe similar issue to this (https://www.doom9.org/showthread.php?p=1737277#post1737277)
Here same link as above post, but without any security warning ('untrusted domain' or something like that).
http://forum.doom9.org/showthread.php?p=1737277#post1737277
EDIT: If you just remove 's' from 'https:\\' you get a 404, Not Found.
Thank you so much. I installed already but it seems didn't work :(
StainlessS
25th January 2016, 19:46
I'm using Avisynth+ r1825 and KNLMeansCL v0.6
There are a certain number of requirements in 1st post of KNLMeansCL (for current version), you might want to
post what you have installed that does fill requirements for your v0.6 (and also post documented requisites for that version).
Also, might post why you are using old version (is current no longer supported by your setup ?).
caiyuwei
26th January 2016, 03:03
There are a certain number of requirements in 1st post of KNLMeansCL (for current version), you might want to
post what you have installed that does fill requirements for your v0.6 (and also post documented requisites for that version).
Also, might post why you are using old version (is current no longer supported by your setup ?).
I updated the newest version, however, it didn't work so I changed to older version as Requirements
http://forum.doom9.org/showthread.php?t=171379
StainlessS
26th January 2016, 06:22
Well if neither version worked, you are more likely to get assistance for current version. (I've never used either myself).
By the way, I got error "There is no function named KNLMeansCL"
You might like to say how you are loading plugin, autoload in plugins dir ?
Also get Dependency Walker, and run it on the KNLMeansCL dll. http://www.dependencywalker.com/
And try Groucho2004 AVSInfo tool. http://forum.doom9.org/showthread.php?t=170647
poisondeathray
31st January 2016, 05:47
Thanks for this feisty2
I cannot reproduce your results in the 1st post with the "special pattern" image - was that from an earlier version or maybe using different settings? I'm getting more halos now with v3.0. I could have sworn it looked better with an earlier version, or maybe something got buggered up with my plugins
SSH4
1st February 2016, 09:57
Thanks for this feisty2
I cannot reproduce your results in the 1st post with the "special pattern" image - was that from an earlier version or maybe using different settings? I'm getting more halos now with v3.0. I could have sworn it looked better with an earlier version, or maybe something got buggered up with my plugins
Also can't reproduce 1st post.
Using Avisinth+ all plugins separately work well. But not in this script.
Looks like problem in this "dark magic" with loooooooong numbers and ternary operators.
feisty2
1st February 2016, 10:29
Thanks for this feisty2
I cannot reproduce your results in the 1st post with the "special pattern" image - was that from an earlier version or maybe using different settings? I'm getting more halos now with v3.0. I could have sworn it looked better with an earlier version, or maybe something got buggered up with my plugins
all default settings
ImageSource("Icqh01Q.png")
converttoyv12()
converttoyv24()
Dither_convert_8_to_16()
ChromaReconstructor()
ditherpost(mode=-1)
http://i.imgur.com/ASph430.png
ImageSource("Icqh01Q.png")
converttoyv12()
converttoyv24()
Dither_convert_8_to_16()
ChromaReconstructor()
ditherpost(mode=-1)
utoy8()
http://i.imgur.com/9kL7Tsp.png
ImageSource("Icqh01Q.png")
converttoyv12()
converttoyv24()
Dither_convert_8_to_16()
ChromaReconstructor()
ditherpost(mode=-1)
vtoy8()
http://i.imgur.com/1phIBXz.png
feisty2
1st February 2016, 10:54
Is this script must work in Avisynth+ r1576?
ChromaReconstructor_faster work, at least result different from source. Eedi version (without LSB) from this thread work too.
But script from first post do nothing.
All scripts tested on source PNG from first post.
dunno about that, knlmeanscl is sometimes a little bit unstable, I actually encountered real crazy weird crap like,
you see, I didn't name parameters like "radius" and "str" from the beginning, I used to name them "a" and "h" just like in knlmeanscl, so it was like this
function ChromaReconstructor(clip src, int "a", float "h", int "hipass", int "mode", bool "wild")
{
a = default(a, 32)
h = default(h, 6.4)
hipass = default(hipass, 6)
mode = default(mode, 0)
wild = default(wild, True)
w = src.width
h = src.height / 2
ref = wild ? src.ConvertToY8() : src.ConvertToY8().KNLMeansCL(0, radius, 0, False, 1, pow(1.464968620512209618455732713658, str), lsb_inout=True)
srcU = src.UToY8()
srcV = src.VToY8()
src8 = YToUV(srcU, srcV, ref).Ditherpost(mode=-1)
up2x = src8.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up4x = up2x.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up16 = up4x.Dither_convert_8_to_16()
Luma = up16.ConvertToY8()
U = up16.UToY8()
V = up16.VtoY8()
Unew = wild ? KNLMeansCL(U, 0, a, 0, False, 1, h, Luma, lsb_inout=True) : interpolation(Luma, U, 2, h)
Unew = wild ? Unew : interpolation(Luma, Unew, 4, h)
Unew = wild ? Unew : interpolation(Luma, Unew, 8, h)
Unew = wild ? Unew : interpolation(Luma, Unew, 16, h)
Unew = wild ? Unew : interpolation(Luma, Unew, 32, h)
Unew = Unew.Dither_resize16nr(w, h, src_left=-1.25, src_top=-1.25, kernel="spline", taps=6)
Vnew = wild ? KNLMeansCL(V, 0, a, 0, False, 1, h, Luma, lsb_inout=True) : interpolation(Luma, V, 2, h)
Vnew = wild ? Vnew : interpolation(Luma, Vnew, 4, h)
Vnew = wild ? Vnew : interpolation(Luma, Vnew, 8, h)
Vnew = wild ? Vnew : interpolation(Luma, Vnew, 16, h)
Vnew = wild ? Vnew : interpolation(Luma, Vnew, 32, h)
Vnew = Vnew.Dither_resize16nr(w, h, src_left=-1.25, src_top=-1.25, kernel="spline", taps=6)
UHi = (mode == 1) ? Dither_sub16(Unew, gauss_h(Unew, hipass), dif=True) : Dither_sub16(Unew, gauss(Unew, hipass), dif=True)
VHi = (mode == 1) ? Dither_sub16(Vnew, gauss_h(Vnew, hipass), dif=True) : Dither_sub16(Vnew, gauss(Vnew, hipass), dif=True)
UFinal = Dither_add16(srcU, UHi, dif=True)
VFinal = Dither_add16(srcV, VHi, dif=True)
return YToUV(UFinal, VFinal, src.ConvertToY8())
}
everything is the same except the name of 2 parameters changed, and it gave me like no nothing, and I traced back the problem to
Unew = wild ? KNLMeansCL(U, 0, a, 0, False, 1, h, Luma, lsb_inout=True) : interpolation(Luma, U, 2, h)
and here's the magic part :confused:
I replaced "a" and "h" with default values, so
Unew = wild ? KNLMeansCL(U, 0, 32, 0, False, 1, 6.4, Luma, lsb_inout=True) : interpolation(Luma, U, 2, h)
worked without any problem!!
so wtf?! I ended up using different names for "a" and "h"...
guess you are facing the similar problem
feisty2
1st February 2016, 11:10
function test1(clip src, int "a", float "h")
{
a = default(a, 32)
h = default(h, 6.4)
w = src.width
h = src.height / 2
ref = src.ConvertToY8()
srcU = src.UToY8()
srcV = src.VToY8()
src8 = YToUV(srcU, srcV, ref).Ditherpost(mode=-1)
up2x = src8.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up4x = up2x.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up16 = up4x.Dither_convert_8_to_16()
Luma = up16.ConvertToY8()
U = up16.UToY8()
V = up16.VtoY8()
Unew = KNLMeansCL(U, 0, a, 0, False, 1, h, Luma, lsb_inout=True)
return Unew.ditherpost(mode=-1)
}
function test2(clip src, int "radius", float "str")
{
radius = default(radius, 32)
str = default(str, 6.4)
w = src.width
h = src.height / 2
ref = src.ConvertToY8()
srcU = src.UToY8()
srcV = src.VToY8()
src8 = YToUV(srcU, srcV, ref).Ditherpost(mode=-1)
up2x = src8.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up4x = up2x.nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnRight().nnedi3(field=1, dh=True, nns=4, qual=2, etype=1, nsize=0).TurnLeft()
up16 = up4x.Dither_convert_8_to_16()
Luma = up16.ConvertToY8()
U = up16.UToY8()
V = up16.VtoY8()
Unew = KNLMeansCL(U, 0, radius, 0, False, 1, str, Luma, lsb_inout=True)
return Unew.ditherpost(mode=-1)
}
ImageSource("ASph430.png")
converttoyv12()
converttoyv24()
Dither_convert_8_to_16()
stackvertical(test1(),test2())
http://i.imgur.com/b30Ijqn.png
!??
feisty2
1st February 2016, 13:07
h = default(h, 6.4)
...
h = src.height / 2
ah!! stupid me, always doing mindless things like this, thx for ur help HolyWu
then, @SSH4
I seriously don't know what went wrong when you were trying it.. :(
poisondeathray
1st February 2016, 16:21
Still can't reproduce it... :(
All plugins working separately. Even tried vanilla avisynth 2.6 x86 , switching knlmeanscl versions (0.6.11 vs. 0.7.4), dither 1.27.2
Can I ask what version of NNEDI3 you are using ? There are several versions floating around
poisondeathray
1st February 2016, 16:36
I think it was the NNEDI3 version. I was using an older version. With 0.9.4.20 - It looks a lot closer now :o
poisondeathray
1st February 2016, 19:36
(sorry third post in a row!)
Is the vpy version any faster, and I cannot find the vpy version in your github link ?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.