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 > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th September 2017, 14:38   #161  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Use IsYUV420(), IsYUV422() and ISYUV444()
MysteryX is offline   Reply With Quote
Old 10th September 2017, 14:43   #162  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by burfadel View Post
Updated the first post with version 1.6.

If you extract the luminance channel such it is just the Y channel, obviously it is a different format to the YUV clip such as output from the chroma filtering. You first have to convert back to the same format before combining. This is fine, however when you are in more than 8 bits, the commands such as isYV12() etc do not work since it is expecting a YUV420Y8 clip for it to be true. Since it is a YUV420P10 clip (for example) the command isYV12() seems to give back false. If you run convertToYV12(), it keeps the higher bitdepth of 10 etc, so isYV12() still doesn't work. This, and possibly other little issues, are problematic when you want to have the output clip the same format as the input clip and it isn't 8-bit etc. This is why I put back the 'do not process' flags to the luma commands, it was either that or dropping support for YV16 and YV24, which obviously isn't desirable.

It works fine as is because the bit depths can be matched easily and the pixel type hasn't changed. I could do a convertbits() just so isYV12() etc works, but then it's an extra unnecessary bit of processing that will probably affect speed more than what was gained by converting it to Y8 and going back to the desired pixel type.
Don't use IsYV12, use Is420 -- works at any bit depth.
Don't use ConvertToYV12, use ConvertToYUV420.
To combine the planes again, use CombinePlanes(Y-clip, U-clip, V-clip, "YUV") (for one example)
raffriff42 is offline   Reply With Quote
Old 10th September 2017, 16:11   #163  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
This issue has several issues. On 1080p content, it throws a validation error on enh. Then it crashes on gBlur value being out of range. And then, output doesn't have the right dimensions!

I used Spline36Resize(Width/2, Height/2) to test and work around the bug, so I'm testing on 960x540

Performance-wise -- Prefetch(8)

v1.3c
Code:
FPS (min | max | average):      0.239 | 9584 | 14.75
Memory usage (phys | virt):     582 | 695 MiB
Thread count:                   36
CPU usage (average):            55%
v1.6
Code:
FPS (min | max | average):      0.915 | 15800 | 13.10
Memory usage (phys | virt):     1031 | 1162 MiB
Thread count:                   38
CPU usage (average):            61%
It felt a lot slower, but it mostly just takes longer to initialize but then performance isn't far off v1.3c. However... memory usage is twice higher!!! And that's at HALF the resolution. In a x86 processing chain, this leaves me no room for much other processing.

As for versioning, it's bad practice to use major/minor version numbers for development versions. Agree, Microsoft did it with Windows Millenium and Vista, but it's bad practice. You'd get to v1.35 before having a script ready for production. Generally, most people use version numbers below 1 for alpha/beta/dev versions, and for FrameRateConverter, I just put the date instead of a version number until it was finalized.

Semantic Versioning Guidelines
Quote:
Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.


How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
Also keeping a development history is good practice.

So far v1.3c is what works best. I can't easily test this version side-by-side because frame dimensions don't match.


Btw could you explain this line?
Code:
noise =  mt_binarize (clense(mt_makediff(mt_binarize(noised), mt_edge(sharpen(clean, 0.82), "prewitt")), grey=true))
I see you're using this to exclude blacks from renoise, but I don't think that's a good way to do it. Have you tried applying a gamma curve to the noise you want to insert back using mt_lut?
motion_mask = mmask(noised, fvec3, kind=1, ml=120).mt_binarize(32, u=1, v=1)

Last edited by MysteryX; 10th September 2017 at 16:58.
MysteryX is offline   Reply With Quote
Old 10th September 2017, 19:17   #164  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
A big difference between 1.3C and higher is changing from MDegrain2 to MDegrain4, which gives better output. Working in Y plane only should reduce this memory usage, I should also be able to recover some speed etc in places. The motionmask has a mt_binarize to create a hard mask, the soft mask is simply too weak for it. As for the dimensions, it's the padding and cropping afterwards, I guess that's why pointresize and not crop is used at the end in the padding script. Pointresize is used so you can add non-mod based padding, addborders requires mod based depending on the pixel type.

As for the renoise, not sure how to apply mt_lut to it such that it is only applied on non-dark areas. I'll give it another try.

Last edited by burfadel; 10th September 2017 at 19:19.
burfadel is offline   Reply With Quote
Old 10th September 2017, 21:22   #165  |  Link
DarkNite
Almost Silent Member
 
DarkNite's Avatar
 
Join Date: Jun 2002
Location: Purgatory
Posts: 273
Cranked up a test run of mClean 1.6 last night, and have been faced with two errors. First error was upon initial loading of the script: Enh reported only accepting ranges of 0-54 when using mClean(), so I defined enh as 15, and was off to the races. Come back this morning to a job that is 5 frames from completion, and an Out of memory (Unable to allocate 2992224 bytes) error from Virtualdub FilterMod. Both are firsts for me, at least as far as mClean is concerned.
__________________
Rethinking the "Why?" chromosome.
DarkNite is offline   Reply With Quote
Old 10th September 2017, 22:04   #166  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
That out of memory issue is weird, a tad shy of 3 MB. Maybe I'm triggering a small memory leak somewhere since once the memory is initially allocated it shouldn't increase with time. I have to admit 1.6 does have bugs, but when it works it's good... makes testing interesting! Later today my time I'll post 1.6b with the necessary fixes. I have two different 'concepts' that may help further with speed without quality loss, unfortunately if they work it will make the code look a bit dodgy with people scratching their heads as to why i did it in such a way. The goal of course is efficacy of the concept, not how it looks in script!
burfadel is offline   Reply With Quote
Old 11th September 2017, 00:16   #167  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by burfadel View Post
As for the renoise, not sure how to apply mt_lut to it such that it is only applied on non-dark areas. I'll give it another try.
First of all, what is causing the extra artifacts in dark scenes? Is it a "bug" with MDegrain that causes that?

Generally, when there are issues only on dark (or bright) scenes, it's an indication that it's an issue with the gamma curve, where if you apply a value linearly, it will have a large impact on dark/bright scenes and low impact on middle values. This might be the case here.

Just try applying a 2.2 gamma curve on the noise and see what it does. Syntax is mt_lut("x 2.2 ^")
MysteryX is offline   Reply With Quote
Old 11th September 2017, 10:39   #168  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
Updated first post to version 1.7

Changes:
  • fixed errors introduced with 1.6
  • changed analysis, should be faster without motion quality loss; in testing it was either the same or fractionally better depending on the motion
  • luma now processed as a single plane (Y12 default)
  • changed application of renoise, application processes only above luma value 20, application scaled from 0 at value 20 to 100 at values 40 and above

It wasn't a linear light issue. If applied the given linear light formula it basically looks like it boosts gamma by 2.2?

Let me know how the new analysis works. Should be faster with same or better perceived quality.

Last edited by burfadel; 11th September 2017 at 13:58.
burfadel is offline   Reply With Quote
Old 11th September 2017, 16:32   #169  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Doing some tests. First thing I'm noticing is that it's applying a strong sharpening to scenes without noise, which is a no-no (unless I really want to run a sharpener which I don't). It uses enh=35 for 1080p. Just lowering it a bit works. 25 is too soft, 30 is too sharp, 28 is good.

Original / mClean v1.3c / mClean(enh=28) / mClean(enh=35)




This latest version is causing color shifts (SBS logo)
Original / mClean


Mostly all it does with the KARA - Dazzling Red clip is over-sharpen and distort colors. Can't really compare because of color shifts.

On my 288p VCD upscaled to 768p (full script and replacing the denoiser line). enh=15 is too much but enh=7 works. Interestingly enough, renoise makes very little difference at all ... if anything, it just add a little bit of sharpening? This version is doing a good job here, keeping the right details and discarding the right things.

No denoise / mClean v1.3c / mClean(enh=7) / mClean(enh=15)


Other types of noise, however, it's not doing anything expect sharpening the noise and distorting colors again
No denoise / mClean(enh=7)


Here, it's adding several distortions compared to v1.3c, such as loosing the teeth
No denoise / mClean v1.3c / mClean(enh=7)


In terms of versioning, changing the major number from 1 to 0 would respect the conventions; then each dev build could keep incrementing the way you're doing (0.7, 0.8, etc)

Last edited by MysteryX; 11th September 2017 at 18:07.
MysteryX is offline   Reply With Quote
Old 11th September 2017, 19:19   #170  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
I can change enh setting, just thought of a better - and obvious in many ways, way applying the strength. I didn't think to test with VCD resolution. The colour shift is easily fixed, again it's possibly a function of resolution. I'd have to find some clips where it doesn't work as well as previous versions as it's some simple fine tuning. 1.7 should be faster?
burfadel is offline   Reply With Quote
Old 11th September 2017, 20:28   #171  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
download KARA - Dazzling Red (link above) and try on it
MysteryX is offline   Reply With Quote
Old 12th September 2017, 15:16   #172  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
@burfadel will you port this script to vapoursynth too? I find it quite effective against heavy noise, with better "color stabilising" than smdegrain. (at least for my anime source)
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 13th September 2017, 04:33   #173  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
In terms of performance (with prefetch 8)

v1.6 - 540p
Code:
FPS (min | max | average):      0.915 | 15800 | 13.10
Memory usage (phys | virt):     1031 | 1162 MiB
Thread count:                   38
CPU usage (average):            61%
v1.7 - 540p
Code:
FPS (min | max | average):      1.557 | 21067 | 21.87
Memory usage (phys | virt):     859 | 932 MiB
Thread count:                   35
CPU usage (average):            68%
v1.7 - 1080p
Code:
FPS (min | max | average):      0.768 | 64957 | 5.620
Memory usage (phys | virt):     1702 | 2026 MiB
Thread count:                   41
CPU usage (average):            69%
I think you've just designed the most expensive plugin in Avisynth in terms of memory usage. Makes it difficult to insert it into a script -- almost have to run it separately with an intermediary AVI file.

Last edited by MysteryX; 13th September 2017 at 04:41.
MysteryX is offline   Reply With Quote
Old 13th September 2017, 06:45   #174  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by MysteryX View Post
In terms of performance
Can you post the script with which which you obtained these results?
Groucho2004 is offline   Reply With Quote
Old 13th September 2017, 11:57   #175  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
Quote:
Originally Posted by MysteryX View Post
In terms of performance (with prefetch 8)

v1.6 - 540p
Code:
FPS (min | max | average):      0.915 | 15800 | 13.10
Memory usage (phys | virt):     1031 | 1162 MiB
Thread count:                   38
CPU usage (average):            61%
v1.7 - 540p
Code:
FPS (min | max | average):      1.557 | 21067 | 21.87
Memory usage (phys | virt):     859 | 932 MiB
Thread count:                   35
CPU usage (average):            68%
v1.7 - 1080p
Code:
FPS (min | max | average):      0.768 | 64957 | 5.620
Memory usage (phys | virt):     1702 | 2026 MiB
Thread count:                   41
CPU usage (average):            69%
I think you've just designed the most expensive plugin in Avisynth in terms of memory usage. Makes it difficult to insert it into a script -- almost have to run it separately with an intermediary AVI file.
I'm guessing you're running 32-bit Avisynth? I suspect it's the recalc, great for performance but obviously not for memory when combined with multithreading! I can think of two alternatives, I'll have to figure which one is more appropriate.

Last edited by burfadel; 13th September 2017 at 12:56.
burfadel is offline   Reply With Quote
Old 13th September 2017, 14:25   #176  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Ran a few tests (i5 2500K @ 4GHz / 4 cores, AVS+ 64 bit):

[Script]
Code:
#SetMemoryMax(3000)
colorbars(width = 1920, height = 1080, pixel_type = "yv12").killaudio().assumefps(25, 1).trim(0, 99)
#ConvertTo16Bit()
mclean()
#Prefetch(4)
8 bit video (YV12):
Code:
FPS (min | max | average):      0.979 | 18.07 | 4.996
Memory usage (phys | virt):     582 | 587 MiB
Thread count:                   15
CPU usage (average):            27%
16 bit video (YUV420P16):
Code:
FPS (min | max | average):      0.377 | 2.532 | 1.503
Memory usage (phys | virt):     741 | 745 MiB
Thread count:                   15
CPU usage (average):            26%
16 bit video with Prefetch(4):
Code:
FPS (min | max | average):      0.699 | 85227 | 3.964
Memory usage (phys | virt):     1269 | 1471 MiB
Thread count:                   19
CPU usage (average):            77%
16 bit video with Prefetch(8) without using SetMemoryMax():
Code:
FPS (min | max | average):      0.029 | 325413 | 1.090
Memory usage (phys | virt):     1636 | 1954 MiB
Thread count:                   35
CPU usage (average):            81%
16 bit video with Prefetch(8) and SetMemoryMax(3000):
Code:
FPS (min | max | average):      0.508 | 325413 | 5.097
Memory usage (phys | virt):     2194 | 2535 MiB
Thread count:                   44
CPU usage (average):            99%
- 16 bit processing is a lot slower than 8 bit
- Using Prefetch(8) needs SetMemoryMax() to be set to ~3000 or performance drops massively

Last edited by Groucho2004; 13th September 2017 at 14:58.
Groucho2004 is offline   Reply With Quote
Old 13th September 2017, 15:27   #177  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by Groucho2004 View Post
Can you post the script with which which you obtained these results?
sure
Code:
LWLibavVideoSource("source.mp4")
mclean()
Prefetch(8)
Quote:
Originally Posted by Groucho2004 View Post
Using Prefetch(8) needs SetMemoryMax() to be set to ~3000 or performance drops massively
That's not even an option with x86
MysteryX is offline   Reply With Quote
Old 13th September 2017, 15:29   #178  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by MysteryX View Post
That's not even an option with x86
Why not? I just tried it, works just fine, although a bit slower than AVS+ 64 bit. Obviously that only works on a 64 bit OS.
Groucho2004 is offline   Reply With Quote
Old 13th September 2017, 16:40   #179  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Isn't x86 limited to 2GB? There's the 3GB patch but even with that I've had crashes when approaching the 2GB limit. (maybe related to AvisynthShader, haven't tested in a while)
MysteryX is offline   Reply With Quote
Old 13th September 2017, 16:47   #180  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by MysteryX View Post
Isn't x86 limited to 2GB?
Yes, on 32 bit Windows (there are OS hacks but I wouldn't recommend them)

Quote:
Originally Posted by MysteryX View Post
There's the 3GB patch but even with that I've had crashes when approaching the 2GB limit.
The 3 GB patch only applies to 32 Bit Windows. So, you're on 32 bit Windows?

If the application that uses 32 Bit Avisynth is built with the LARGEADDRESSAWARE linker switch it can address up to 4 GB on a 64 Bit OS.

Last edited by Groucho2004; 13th September 2017 at 20:56.
Groucho2004 is offline   Reply With Quote
Reply

Tags
cleaning, denoise, denoiser, mclean


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 23:39.


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